Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_td1207r.h
1 #ifndef _BC_TD1207R_H
2 #define _BC_TD1207R_H
3 
4 #include <bc_scheduler.h>
5 #include <bc_gpio.h>
6 #include <bc_uart.h>
7 
11 
13 
14 #define BC_TD1207R_TX_FIFO_BUFFER_SIZE 64
15 #define BC_TD1207R_RX_FIFO_BUFFER_SIZE 64
16 
18 
20 
21 typedef enum
22 {
25 
28 
31 
34 
36 
38 
39 typedef struct bc_td1207r_t bc_td1207r_t;
40 
42 
43 typedef enum
44 {
45  BC_TD1207R_STATE_READY = 0,
46  BC_TD1207R_STATE_ERROR = 1,
47  BC_TD1207R_STATE_INITIALIZE = 2,
48  BC_TD1207R_STATE_INITIALIZE_RESET_L = 3,
49  BC_TD1207R_STATE_INITIALIZE_RESET_H = 4,
50  BC_TD1207R_STATE_INITIALIZE_AT_COMMAND = 5,
51  BC_TD1207R_STATE_INITIALIZE_AT_RESPONSE = 6,
52  BC_TD1207R_STATE_SEND_RF_FRAME_COMMAND = 7,
53  BC_TD1207R_STATE_SEND_RF_FRAME_RESPONSE = 8
54 
55 } bc_td1207r_state_t;
56 
57 struct bc_td1207r_t
58 {
59  bc_scheduler_task_id_t _task_id;
60  bc_gpio_channel_t _reset_signal;
61  bc_uart_channel_t _uart_channel;
62  bc_td1207r_state_t _state;
63  bc_fifo_t _tx_fifo;
64  bc_fifo_t _rx_fifo;
65  uint8_t _tx_fifo_buffer[BC_TD1207R_TX_FIFO_BUFFER_SIZE];
66  uint8_t _rx_fifo_buffer[BC_TD1207R_RX_FIFO_BUFFER_SIZE];
67  void (*_event_handler)(bc_td1207r_t *, bc_td1207r_event_t, void *);
68  void *_event_param;
69  char _command[BC_TD1207R_TX_FIFO_BUFFER_SIZE];
70  char _response[BC_TD1207R_RX_FIFO_BUFFER_SIZE];
71  uint8_t _message_buffer[12];
72  size_t _message_length;
73 };
74 
76 
81 
82 void bc_td1207r_init(bc_td1207r_t *self, bc_gpio_channel_t reset_signal, bc_uart_channel_t uart_channel);
83 
88 
89 void bc_td1207r_set_event_handler(bc_td1207r_t *self, void (*event_handler)(bc_td1207r_t *, bc_td1207r_event_t, void *), void *event_param);
90 
95 
97 
104 
105 bool bc_td1207r_send_rf_frame(bc_td1207r_t *self, const void *buffer, size_t length);
106 
108 
109 #endif // _BC_TD1207R_H
bool bc_td1207r_send_rf_frame(bc_td1207r_t *self, const void *buffer, size_t length)
Send RF frame command.
Definition: bc_td1207r.c:47
bc_uart_channel_t
UART channels.
Definition: bc_uart.h:13
Structure of FIFO instance.
Definition: bc_fifo.h:12
RF frame transmission started event.
Definition: bc_td1207r.h:30
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
struct bc_td1207r_t bc_td1207r_t
TD1207R instance.
Definition: bc_td1207r.h:39
void bc_td1207r_set_event_handler(bc_td1207r_t *self, void(*event_handler)(bc_td1207r_t *, bc_td1207r_event_t, void *), void *event_param)
Set callback function.
Definition: bc_td1207r.c:36
bc_td1207r_event_t
Callback events.
Definition: bc_td1207r.h:21
RF frame transmission finished event.
Definition: bc_td1207r.h:33
void bc_td1207r_init(bc_td1207r_t *self, bc_gpio_channel_t reset_signal, bc_uart_channel_t uart_channel)
Initialize TD1207R.
Definition: bc_td1207r.c:13
bc_gpio_channel_t
GPIO channels.
Definition: bc_gpio.h:12
Error event.
Definition: bc_td1207r.h:27
Ready event.
Definition: bc_td1207r.h:24
bool bc_td1207r_is_ready(bc_td1207r_t *self)
Check if modem is ready for commands.
Definition: bc_td1207r.c:42