SemiDrive SSDK Appication Program Interface PTG3.0
sdrv_sent.h
Go to the documentation of this file.
1
26#ifndef SDRV_SENT_DRV_H_
27#define SDRV_SENT_DRV_H_
28
29#include <compiler.h>
30#include <sdrv_common.h>
31#include <types.h>
32
33/* Single Secure Sensor Message Format include 6 data nibbles(24-bit). */
34#define SENT_SECURE_SENSOR_DATA_NIBBLE 6U
35/* High Speed Message Format include 4 data nibbles(12-bit). */
36#define SENT_HIGH_SPEED_DATA_NIBBLE 4U
37
45};
46
47/* Sdrv sent struct. */
48typedef struct sdrv_sent sdrv_sent_t;
50/* Recv frame over callback function. */
51typedef void (*sdrv_sent_recv_cb_t)(sdrv_sent_t *ctrl,
52 sdrv_sent_chanid_e sent_chan_id,
53 void *userdata);
54
56typedef enum {
59 1U,
62 3U,
64
66typedef enum {
69 SENT_DATA_WIDTH_12_BIT = 3U, //**< Sent frame data width is 12bits. */
74
76typedef enum {
80
82typedef enum {
85 1U,
88
90typedef enum sdrv_frame_err {
91 SENT_OK = 0U,
92 SENT_SYNC_ERR = (1U << 0),
93 SENT_STATUS_ERR = (1U << 1),
94 SENT_DATA_ERR = (1U << 2),
95 SENT_CRC_ERR = (1U << 3),
96 SENT_LOW_PULSE_ERR = (1U << 4),
97 SENT_MSB_NOT_ZERO = (1U << 5),
98 SENT_INV_MSN_ERR = (1U << 6),
100 SENT_TICK_FREQ_ERR = (1U << 8),
101 SENT_NOT_OK = (1U << 31),
103
105typedef enum sent_frame_state {
107 SENT_SYNC = 1U,
109 SENT_STATUS = 2U,
112 SENT_CRC = 4U,
114 SENT_PAUSE = 5U,
117
119typedef enum sent_chan_state {
125
126/* Sent frame information. */
127typedef struct sent_chan_frame {
130 volatile uint8_t rxframe[6];
131 uint8_t frame_dl;
132 volatile uint8_t rx_index;
133 volatile uint8_t frame_sta;
134 volatile uint8_t frame_crc;
135 volatile uint32_t frame_err;
136 volatile bool frame_valid;
138
140typedef struct sdrv_sent_chan {
145 void *userdata;
149 uint32_t tickfreq;
150 uint8_t fifowml;
156 uint8_t
158 uint8_t
161 uint32_t expect_scaler;
162 volatile uint32_t actual_scaler;
166
168struct sdrv_sent {
169 uint32_t base;
170 int32_t irq;
173 uint16_t clk_div;
174 uint32_t clk_freq;
177 uint8_t chan_num;
180};
181
183typedef struct sdrv_sent_chan_config {
186 uint32_t tickfreq;
194 uint8_t fifowml;
202 uint8_t
204 uint8_t
208
210typedef struct sdrv_sent_config {
211 uint32_t base;
212 uint32_t irq;
215 uint16_t clk_div;
216 uint32_t clk_freq;
218 uint8_t
223
238
250
264 sdrv_sent_recv_cb_t callback, void *userdata);
265
279 sdrv_sent_chanid_e sent_chan_id);
280
294 sdrv_sent_chanid_e sent_chan_id);
295
311 sdrv_sent_chanid_e sent_chan_id);
312
326 uint32_t *frame_err, sent_chan_frame_t *frame);
333int sdrv_sent_irq_handle(uint32_t irq, void *ctrl);
334#endif /* SDRV_SENT_H_ */
SemiDrive driver common header file.
int32_t status_t
Type used for all status and error return values.
Definition: sdrv_common.h:82
enum sent_frame_state sdrv_sent_frame_state_e
Sdrv sent frame status enum.
struct sdrv_sent_config sdrv_sent_config_t
Sdrv sent module config struct.
void(* sdrv_sent_recv_cb_t)(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sent_chan_id, void *userdata)
Definition: sdrv_sent.h:51
sdrv_sent_bitnum_e
Sdrv sent data width enum.
Definition: sdrv_sent.h:66
@ SENT_DATA_WIDTH_8_BIT
Definition: sdrv_sent.h:68
@ SENT_DATA_WIDTH_16_BIT
Definition: sdrv_sent.h:70
@ SENT_DATA_WIDTH_4_BIT
Definition: sdrv_sent.h:67
@ SENT_DATA_WIDTH_12_BIT
Definition: sdrv_sent.h:69
@ SENT_DATA_WIDTH_20_BIT
Definition: sdrv_sent.h:71
@ SENT_DATA_WIDTH_24_BIT
Definition: sdrv_sent.h:72
sdrv_frame_err
Sdrv sent frame error code enum.
Definition: sdrv_sent.h:90
@ SENT_OK
Definition: sdrv_sent.h:91
@ SENT_TICK_FREQ_ERR
Definition: sdrv_sent.h:100
@ SENT_NOT_OK
Definition: sdrv_sent.h:101
@ SENT_LOW_PULSE_ERR
Definition: sdrv_sent.h:96
@ SENT_MSB_NOT_ZERO
Definition: sdrv_sent.h:97
@ SENT_INV_MSN_ERR
Definition: sdrv_sent.h:98
@ SENT_STATUS_ERR
Definition: sdrv_sent.h:93
@ SENT_CONUNTER_VAL_ERR
Definition: sdrv_sent.h:99
@ SENT_SYNC_ERR
Definition: sdrv_sent.h:92
@ SENT_CRC_ERR
Definition: sdrv_sent.h:95
@ SENT_DATA_ERR
Definition: sdrv_sent.h:94
enum sent_chan_state sent_chan_state_e
Sdrv sent frame status enum.
enum sdrv_frame_err sdrv_frame_err_e
Sdrv sent frame error code enum.
struct sent_chan_frame sent_chan_frame_t
status_t sdrv_sent_init(sdrv_sent_t *ctrl, sdrv_sent_config_t *cfg)
Sdrv sent controller initialization.
sent_chan_state
Sdrv sent frame status enum.
Definition: sdrv_sent.h:119
@ CHAN_STATUS_STOPPED
Definition: sdrv_sent.h:123
@ CHAN_STATUS_RUNNING
Definition: sdrv_sent.h:122
@ CHAN_STATUS_UNINIT
Definition: sdrv_sent.h:120
@ CHAN_STATUS_INITED
Definition: sdrv_sent.h:121
status_t sdrv_sent_get_frame(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sent_chan_id, uint32_t *frame_err, sent_chan_frame_t *frame)
Get sent frame info.
sdrv_sent_sta_e
Sdrv sent status enum.
Definition: sdrv_sent.h:76
@ SENT_STATUS_INITED
Definition: sdrv_sent.h:78
@ SENT_STATUS_UNINIT
Definition: sdrv_sent.h:77
int sdrv_sent_irq_handle(uint32_t irq, void *ctrl)
Sdrv sent interrupt handler.
struct sdrv_sent_chan sdrv_sent_chan_t
Sdrv sent channel struct.
status_t sdrv_sent_recv_stop(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sent_chan_id)
Sent stop recv frame.
sdrv_sent_chanid
Sdrv sent channel id enum.
Definition: sdrv_sent.h:39
@ SDRV_SENT_HW_CPT_B
Definition: sdrv_sent.h:41
@ SDRV_SENT_HW_CPT_A
Definition: sdrv_sent.h:40
@ SDRV_SENT_CHAN_NUM
Definition: sdrv_sent.h:44
@ SDRV_SENT_HW_CPT_D
Definition: sdrv_sent.h:43
@ SDRV_SENT_HW_CPT_C
Definition: sdrv_sent.h:42
status_t sdrv_sent_parse_msg(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sent_chan_id)
Parse sent frame.
enum sdrv_sent_chanid sdrv_sent_chanid_e
Definition: sdrv_sent.h:49
status_t sdrv_sent_recv_start(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sent_chan_id)
Sent starts to receive frames.
sent_frame_state
Sdrv sent frame status enum.
Definition: sdrv_sent.h:105
@ SENT_DATA
Definition: sdrv_sent.h:111
@ SENT_IDLE
Definition: sdrv_sent.h:106
@ SENT_CRC
Definition: sdrv_sent.h:112
@ SENT_PAUSE
Definition: sdrv_sent.h:114
@ SENT_SYNC
Definition: sdrv_sent.h:107
@ SENT_STATUS
Definition: sdrv_sent.h:109
sdrv_sent_fastchan_e
Sdrv sent channel transmit format enum.
Definition: sdrv_sent.h:82
@ SENT_HIGH_SPEED_FORMAT
Definition: sdrv_sent.h:86
@ SENT_STANDARD_FORMAT
Definition: sdrv_sent.h:83
@ SENT_SINGLE_SECURE_FORMAT
Definition: sdrv_sent.h:84
struct sdrv_sent_chan_config sdrv_sent_chan_config_t
Sdrv sent channel config struct.
status_t sdrv_sent_set_callback(sdrv_sent_t *ctrl, sdrv_sent_chanid_e sdrv_sent_chanid, sdrv_sent_recv_cb_t callback, void *userdata)
Sent set callback function.
status_t sdrv_sent_deinit(sdrv_sent_t *ctrl)
Sdrv sent controller deinitialization.
sdrv_sent_clk_src_e
sdrv sent clock source enum.
Definition: sdrv_sent.h:56
@ SDRV_SENT_LP_CLK
Definition: sdrv_sent.h:61
@ SDRV_SENT_AHF_CLK
Definition: sdrv_sent.h:58
@ SDRV_SENT_HF_CLK
Definition: sdrv_sent.h:57
@ SDRV_SENT_EXT_CLK
Definition: sdrv_sent.h:60
Sdrv sent channel config struct.
Definition: sdrv_sent.h:183
bool filter_en
Definition: sdrv_sent.h:201
sdrv_sent_fastchan_e fast_chan
Definition: sdrv_sent.h:189
sdrv_sent_chanid_e chan_id
Definition: sdrv_sent.h:184
uint8_t lowpulse_width
Definition: sdrv_sent.h:192
uint8_t sample_interval
Definition: sdrv_sent.h:205
bool pause_pulse
Definition: sdrv_sent.h:199
uint8_t fifowml
Definition: sdrv_sent.h:194
uint32_t tickfreq
Definition: sdrv_sent.h:186
uint8_t filter_bandwidth
Definition: sdrv_sent.h:203
sdrv_sent_bitnum_e data_bitnum
Definition: sdrv_sent.h:191
Sdrv sent channel struct.
Definition: sdrv_sent.h:140
bool filter_en
Definition: sdrv_sent.h:155
sent_chan_frame_t frame_info
Definition: sdrv_sent.h:164
sdrv_sent_chanid_e chan_id
Definition: sdrv_sent.h:141
volatile uint32_t actual_scaler
Definition: sdrv_sent.h:162
uint8_t lowpulse_width
Definition: sdrv_sent.h:147
uint8_t sample_interval
Definition: sdrv_sent.h:159
volatile sent_chan_state_e chan_sta
Definition: sdrv_sent.h:142
bool pause_pulse
Definition: sdrv_sent.h:148
sdrv_sent_recv_cb_t frameover_cb
Definition: sdrv_sent.h:144
uint32_t expect_scaler
Definition: sdrv_sent.h:161
uint8_t fifowml
Definition: sdrv_sent.h:150
uint32_t tickfreq
Definition: sdrv_sent.h:149
uint8_t filter_bandwidth
Definition: sdrv_sent.h:157
void * userdata
Definition: sdrv_sent.h:145
Sdrv sent module config struct.
Definition: sdrv_sent.h:210
uint32_t base
Definition: sdrv_sent.h:211
uint32_t irq
Definition: sdrv_sent.h:212
sdrv_sent_chan_config_t chan_cfg[SDRV_SENT_CHAN_NUM]
Definition: sdrv_sent.h:221
uint32_t clk_freq
Definition: sdrv_sent.h:216
uint16_t clk_div
Definition: sdrv_sent.h:215
uint8_t chan_cfg_num
Definition: sdrv_sent.h:219
sdrv_sent_clk_src_e clk_sel
Definition: sdrv_sent.h:214
Sdrv sent module struct.
Definition: sdrv_sent.h:168
uint32_t base
Definition: sdrv_sent.h:169
int32_t irq
Definition: sdrv_sent.h:170
uint32_t clk_freq
Definition: sdrv_sent.h:174
uint8_t chan_num
Definition: sdrv_sent.h:177
uint16_t clk_div
Definition: sdrv_sent.h:173
sdrv_sent_chan_t chan[SDRV_SENT_CHAN_NUM]
Definition: sdrv_sent.h:179
sdrv_sent_clk_src_e clk_sel
Definition: sdrv_sent.h:172
volatile sdrv_sent_sta_e sent_sta
Definition: sdrv_sent.h:176
Definition: sdrv_sent.h:127
volatile sdrv_sent_frame_state_e cur_state
Definition: sdrv_sent.h:129
volatile uint8_t frame_sta
Definition: sdrv_sent.h:133
volatile uint32_t frame_err
Definition: sdrv_sent.h:135
volatile uint8_t frame_crc
Definition: sdrv_sent.h:134
volatile uint8_t rx_index
Definition: sdrv_sent.h:132
uint8_t frame_dl
Definition: sdrv_sent.h:131
volatile uint8_t rxframe[6]
Definition: sdrv_sent.h:130
sdrv_sent_fastchan_e frame_format
Definition: sdrv_sent.h:128
volatile bool frame_valid
Definition: sdrv_sent.h:136