Skip to main content

app_easy_timer不适用于user_app_on_init

1个月前

app_easy_timer不适用于user_app_on_init

张贴了gustavo.laureano.65分 5回复
0旋转

你好,

我跟着本指南:

http://lpccs-docs.dialog-seminiondiond.com/tutorial_sdk6 / add_data.html.

to make the advertising data dynamic, but for some reason the timer is not started when called from user_app_on_init, but works when called from another place (like on_disconnect)

在App_On_Init中调用的函数(用断点检查),它不会落入“returneyal_timer_invalid_invalid_timer”(也使用断点检查)

Any ideas why would the timer not start from init?

Thanks

Best Regards
古斯塔沃

accepted answer!

1个月前

PM_DIALOG.

嗨gustavo,

谢谢你的问题。我建议在user_app_on_init()之后设置计时器。请尝试以下更改:

在user_config.h:

#定义USER_ADVERTISE_DATA “\ X12 \ X21 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X11 \ X00”

在user_callback_config.h:

.default_operation_adv = user_app_adv_start,.app_on_init = user_app_on_init,

在user_empty_peripherala_template.h:

void user_app_adv_start(void);void user_app_on_init(void);

在user_empty_peripheral_template.c:

uint8_t my_counter __section_zero(“保留_mem_area0”);// @Retention Memory Timer_hnd app_adv_data_update_timer_used __section_zero(“Retention_mem_area0”);void update_add_data(){my_counter ++;//将计数器值复制到广告数据(忽略扫描响应数据)UINT8_T ADV_DATA [USER_ADVERTESS_DATA_LEN];memcpy(&adv_data,user_advertise_data,user_advertise_data_len);//将计数器值加载到广告数据的最后八位字节(Adving Data Adv_Data [User_Advertise_Data_Len -1] = My_counter;//更新广告数据app_easy_gap_update_add_data(adv_data,user_advertise_data_len,null,null);//重新启动timer app_add_data_update_timer_used = app_easy_timer(100,update_add_addata);// void user_app_adv_start(void){app_add_data_update_timer_used = app_easy_timer(100,update_add_data);//一秒钟单拍计时器app_easy_gap_undircted_advertise_start(); } void user_app_on_init() { my_counter = 0; // After we have initialized our variable, we call the default handler default_app_on_init(); }

谢谢,PM_DIALOG.

1个月前

gustavo.laureano. 65分

Hi PM_Dialog

Thanks, It works when I start from the adv_start user callback, the only change I made was to always cancel any previous timer, otherwise it was generating multiple timer instances running in parallel:

void user_app_adv_start(void){app_easy_timer_cancel(app_add_data_update_timer_used);app_add_data_update_timer_used = app_easy_timer(app_add_data_update_to,avd_data_update_timer_cb);//一秒钟单拍计时器app_easy_gap_undircted_advertise_start();}

但是你有什么想法为什么无法从App_init回调开始定时器?
I searched the documentation and there is no explicit reason why it would not work..

And another (unrelated) question:
在DA14531上使用UART ROM代码(使用#undef CFG_UART1_SDK)时,我遇到了问题,它永远不会调用注册的回调,并且只有在我设置使用SDK UART实现时(#define cfg_uart1_sdk),但我找不到任何信息,说明为什么ROM代码无法正常工作,这是ROM代码上的错误吗?或者我需要在处理中断时始终使用编译的驱动程序?

Thanks!
古斯塔沃

1个月前

PM_DIALOG.

嗨gustavo.laureano,

您能否分享user_app_on_init()和您在侧面使用的UART函数?

谢谢,PM_DIALOG.

1个月前

gustavo.laureano. 65分

以下是相关零件:

user_periph_setup.c上的外设初始化

静态常量uart_cfg_t uart_cfg = {.baud_rate =UART_BAUDRATE_115200, .data_bits = UART_DATABITS_8, .parity = UART_PARITY_NONE, .stop_bits = UART_STOPBITS_1, .auto_flow_control = UART_AFCE_DIS, .use_fifo = UART_FIFO_DIS, .tx_fifo_tr_lvl = UART_TX_FIFO_LEVEL_0, .rx_fifo_tr_lvl = UART_RX_FIFO_LEVEL_0, .intr_priority = 2, }; void periph_init(void) { // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); // ROM patch patch_func(); // Initialize peripherals uart_initialize(UART1, &uart_cfg); GPIO_ConfigurePin(UARTx_TX_GPIO_PORT, UARTx_TX_GPIO_PIN, OUTPUT, PID_UART1_TX, false); GPIO_ConfigurePin(UARTx_RX_GPIO_PORT, UARTx_RX_GPIO_PIN, INPUT, PID_UART1_RX, false); // Enable the pads GPIO_set_pad_latch_en(true); }

我的user.c上的代码:

静态void UART_READ_CB(UINT16_T长度){//将接收的字节推入环形缓冲区ringbuffer_add(ringbuffer_inst_rx,&rxbuf_cb);//启动下一个异步读取1个字符。UART_RECEIVE(UART1,&RXBUF_CB,1,UART_OP_INTR);} void user_app_on_init(void){ringbuffer_init(ringbuffer_inst_rx,ringbufer_buffer_rx,sizeof(uint8_t),64);UART_REGISTER_RX_CB(UART1,UART_READ_CB);UART_RECEIVE(UART1,&RXBUF_CB,1,UART_OP_INTR);/ *启动UART接收* / default_app_on_init();}

发送数据(通过阻塞模式下的UART_SEND)始终有效,但是在i #define cfg_uart1_sdk时,使用中断接收数据,否则从未调用UART_READ_CB

1个月前

PM_DIALOG.

嗨gustavo.laureano,

Thanks for your comment. In order to use the uart_register_rx_cb(), the CFG_UART1_SDK macro should be defined. The ROM driver is different that’s why you see this behavior.

谢谢,PM_DIALOG.