10 void print_adc_get_i(uint8_t channel_i
) {
15 spi_puth2(adc_get_i(channel_i
));
19 typedef struct text_cmd_s
{
21 const uint8_t param_ct
;
23 // void (* const func0 )(void);
24 void (* const func1
)(uint8_t,...);
25 // void (* const func2 )(...);
29 #define CMD(c,param,_func) \
30 { .text = (c), .param_ct = (param), .func = {.func1=(_func)} }
32 text_cmd_t text_cmd_list
[] = {
34 CMD('a',1,print_adc_get_i
)
36 #define TEXT_CMD_LIST_SZ CT(text_cmd_list)
39 typedef enum input_state_e
{INP_WAIT
, INP_ATT
, INP_CMD_FOUND
, INP_CMP_PARAM
} input_state_t
;
41 void process_rx(void) {
42 input_state_t state
= INP_WAIT
;
48 int c
= spi_getchar();
59 for(uint8_t i
=0;i
<TEXT_CMD_LIST_SZ
;i
++) {
60 if(text_cmd_list
[i
].text
==c
) {
61 state
= INP_CMD_FOUND
;
73 // we just found a command (on the last character).
74 if (text_cmd_list
[cmd_num
].param_ct
==param_ct
) {