SmartSnippets DA1459x SDK
mcif.h
Go to the documentation of this file.
1 
41 #ifndef MCIF_H
42 #define MCIF_H
43 #include "osal.h"
44 
49 
59 #define MCIF_CLIENTS_NR 1
60 
67 #ifndef MCIF_USE_TASK_NOTIFICATIONS
68 #define MCIF_USE_TASK_NOTIFICATIONS 0
69 #endif
70 
76 #ifndef MCIF_MAX_ARGS
77 #define MCIF_MAX_ARGS 2
78 #endif
79 
86 #ifndef MCIF_UART
87 #define MCIF_UART HW_UART1
88 #endif
89 
95 #ifndef MCIF_GPIO_PORT_UART_RX
96 #define MCIF_GPIO_PORT_UART_RX HW_GPIO_PORT_1
97 #endif
98 
104 #ifndef MCIF_GPIO_PIN_UART_RX
105 #define MCIF_GPIO_PIN_UART_RX HW_GPIO_PIN_5
106 #endif
107 
113 #ifndef MCIF_GPIO_PORT_UART_TX
114 #define MCIF_GPIO_PORT_UART_TX HW_GPIO_PORT_1
115 #endif
116 
122 #ifndef MCIF_GPIO_PIN_UART_TX
123 #define MCIF_GPIO_PIN_UART_TX HW_GPIO_PIN_0
124 #endif
125 
126 
133 #ifndef MCIF_UART_BAUDRATE
134 #define MCIF_UART_BAUDRATE HW_UART_BAUDRATE_115200
135 #endif
136 
143 #ifndef MCIF_UART_DATABITS
144 #define MCIF_UART_DATABITS HW_UART_DATABITS_8
145 #endif
146 
153 #ifndef MCIF_UART_STOPBITS
154 #define MCIF_UART_STOPBITS HW_UART_STOPBITS_1
155 #endif
156 
163 #ifndef MCIF_UART_PARITY
164 #define MCIF_UART_PARITY HW_UART_PARITY_NONE
165 #endif
166 
174 #ifndef MCIF_LOG_TAG
175 #define MCIF_LOG_TAG 30
176 #endif
177 
184 #ifndef MCIF_ASCII_MAX_LINE
185 #define MCIF_ASCII_MAX_LINE 80
186 #endif
187 
194 #ifndef MCIF_UART_DMA_BUFFER
195 #define MCIF_UART_DMA_BUFFER MCIF_ASCII_MAX_LINE
196 #else
197 #if (MCIF_UART_DMA_BUFFER < MCIF_ASCII_MAX_LINE)
198 #undef MCIF_UART_DMA_BUFFER
199 #define MCIF_UART_DMA_BUFFER MCIF_ASCII_MAX_LINE
200 #endif
201 #endif
202 
209 #ifndef MCIF_ASCII_PROMPT
210 #define MCIF_ASCII_PROMPT "\r\nEnter command (or ?/help for help) > "
211 #endif
212 
214 
227 struct mcif_message_s {
228  uint16_t len;
229  char buffer[0];
230 };
231 
239 
241 #define MCIF_ASCII_FLAGS_MASK 0x3
242 
250 #define MCIF_ASCII_FLAGS_ARG1_NA 0x0
251 #define MCIF_ASCII_FLAGS_ARG2_NA 0x0
252 #define MCIF_ASCII_FLAGS_ARG3_NA 0x0
253 #define MCIF_ASCII_FLAGS_ARG4_NA 0x0
254 #define MCIF_ASCII_FLAGS_ARG5_NA 0x0
255 #define MCIF_ASCII_FLAGS_ARG6_NA 0x0
256 
264 #define MCIF_ASCII_FLAGS_ARG1_INT 0x1
265 #define MCIF_ASCII_FLAGS_ARG2_INT 0x4
266 #define MCIF_ASCII_FLAGS_ARG3_INT 0x10
267 #define MCIF_ASCII_FLAGS_ARG4_INT 0x40
268 #define MCIF_ASCII_FLAGS_ARG5_INT 0x100
269 #define MCIF_ASCII_FLAGS_ARG6_INT 0x400
270 
280 #define MCIF_ASCII_FLAGS_ARG1_STR 0x2
281 #define MCIF_ASCII_FLAGS_ARG2_STR 0x8
282 #define MCIF_ASCII_FLAGS_ARG3_STR 0x20
283 #define MCIF_ASCII_FLAGS_ARG4_STR 0x80
284 #define MCIF_ASCII_FLAGS_ARG5_STR 0x200
285 #define MCIF_ASCII_FLAGS_ARG6_STR 0x800
286 
296 #define MCIF_ASCII_FLAGS_ARG1_STR_NO_WHITE 0x3
297 #define MCIF_ASCII_FLAGS_ARG2_STR_NO_WHITE 0xc
298 #define MCIF_ASCII_FLAGS_ARG3_STR_NO_WHITE 0x30
299 #define MCIF_ASCII_FLAGS_ARG4_STR_NO_WHITE 0xc0
300 #define MCIF_ASCII_FLAGS_ARG5_STR_NO_WHITE 0x300
301 #define MCIF_ASCII_FLAGS_ARG6_STR_NO_WHITE 0xc00
302 
311 #if MCIF_MAX_ARGS < 4
312 #define MCIF_ASCII_FLAGS_AUTO_REPLY 0x80
313 #else
314 #define MCIF_ASCII_FLAGS_AUTO_REPLY 0x8000
315 #endif
316 
317 #if MCIF_MAX_ARGS > 2
318 typedef void (*cmd_cb_t)(xQueueHandle txq, void **args);
319 #else
320 typedef void (*cmd_cb_t)(xQueueHandle txq, void *arg1, void *arg2);
321 #endif
322 
338 {
339  const char *name;
340 #if MCIF_MAX_ARGS > 2
341  void (*fn)(xQueueHandle txq, void **args);
342 #else
343  void (*fn)(xQueueHandle txq, void *arg1, void *arg2);
344 #endif
345  const char *help_str;
346 #if MCIF_MAX_ARGS < 4
347  uint8_t flags;
348 #else
349  uint16_t flags;
350 #endif
351 };
352 
372  const struct mcif_ascii_parse_element_s *parse_table,
373  xQueueHandle txq,
374  struct mcif_message_s *msg);
375 
398  const struct mcif_ascii_parse_element_s *parse_table,
399  xQueueHandle txq,
400  struct mcif_message_s *msg) __WEAK;
401 
422  const struct mcif_ascii_parse_element_s *parse_table,
423  xQueueHandle txq,
424  struct mcif_message_s *msg) __WEAK;
425 
445 void mcif_ascii_send_response(const struct mcif_ascii_parse_element_s *parse_table,
446  xQueueHandle txq,
447  struct mcif_message_s *msg, bool show_prompt);
449 
469 void mcif_setup_queues(int cli_id, OS_QUEUE txq, OS_QUEUE rxq);
470 
471 
472 #if MCIF_USE_TASK_NOTIFICATIONS == 1
473 
496 void mcif_setup_client_notifications(int cli_id, OS_TASK handle, uint8_t notif_bit);
497 #endif
498 
514 OS_BASE_TYPE mcif_queue_send(int cli_id, const void *item,
515  OS_TICK_TIME wait_ticks);
516 
525 void mcif_init(void);
526 
527 #endif /* MCIF_H */
528 
mcif_ascii_parse_element_s::flags
uint8_t flags
Definition: mcif.h:347
mcif_ascii_print_unknown
void mcif_ascii_print_unknown(const struct mcif_ascii_parse_element_s *parse_table, xQueueHandle txq, struct mcif_message_s *msg) __WEAK
Print the unknown command message.
mcif_ascii_parse_element_s::name
const char * name
Definition: mcif.h:339
mcif_init
void mcif_init(void)
Initialize MCIF framework.
mcif_setup_queues
void mcif_setup_queues(int cli_id, OS_QUEUE txq, OS_QUEUE rxq)
Setup the MCIF queues.
mcif_ascii_send_response
void mcif_ascii_send_response(const struct mcif_ascii_parse_element_s *parse_table, xQueueHandle txq, struct mcif_message_s *msg, bool show_prompt)
Send a response to the terminal.
osal.h
OS abstraction layer API.
mcif_ascii_parse_element_s
MCIF-ASCII command description structure.
Definition: mcif.h:337
mcif_queue_send
OS_BASE_TYPE mcif_queue_send(int cli_id, const void *item, OS_TICK_TIME wait_ticks)
Send a message to MCIF.
mcif_ascii_parse_element_s::help_str
const char * help_str
Definition: mcif.h:345
cmd_cb_t
void(* cmd_cb_t)(xQueueHandle txq, void *arg1, void *arg2)
ASCII command-set argument X not-applicable flag.
Definition: mcif.h:320
mcif_ascii_parse_element_s::fn
void(* fn)(xQueueHandle txq, void *arg1, void *arg2)
Definition: mcif.h:343
mcif_ascii_print_prompt
void mcif_ascii_print_prompt(const struct mcif_ascii_parse_element_s *parse_table, xQueueHandle txq, struct mcif_message_s *msg) __WEAK
Print a prompt.
mcif_ascii_parse_message
void mcif_ascii_parse_message(const struct mcif_ascii_parse_element_s *parse_table, xQueueHandle txq, struct mcif_message_s *msg)
Parse the received message.
msg
Structure for messages with id, type, data.
Definition: msg_queues.h:144