how to use libuarte

I want to use the async driver,but did not find the example or explanation.

I have looked for the whole examples with "nrf_libuarte_async.h", found nothing,a little strange,I guess the NRF_LOG should useed this lib,but not check yet.

Parents
  • get reply from gemini:

    _uarte_idx:

    用途: 指定要使用的 UARTE 硬件实例的索引。

    安全值: 在 nRF52810 上,只有一个 UARTE 外设,所以该值必须是 0。

    _timer0_idx:

    用途: 这是底层 nrf_libuarte_drv 驱动内部使用的定时器。它用于管理 EasyDMA 传输和缓冲区切换。

    安全值: SoftDevice 会使用 TIMER0,因此你不能使用 0。你应该选择一个空闲的定时器,例如 1 或 2。

    _rtc1_idx 和 _timer1_idx:

    用途: 这两个参数用于异步超时机制。库会根据你的 sdk_config.h 配置选择一个作为超时计时器。它会从 TIMER1、RTC1 和 App Timer 中选择一个。

    安全值: RTC0 通常被 SoftDevice 占用,所以 RTC1 是一个安全的选择。TIMER1 和 TIMER2 通常也是可用的。

    如何选择:

    如果你想使用 TIMER1 作为超时计时器,将 _timer1_idx 设置为 1,并将 _rtc1_idx 设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    如果你想使用 RTC1 作为超时计时器,将 _rtc1_idx 设置为 1,并将 _timer1_idx 设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    如果你想使用 app_timer,则将 _rtc1_idx 和 _timer1_idx 都设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    I defined like this :

    NRF_LIBUARTE_ASYNC_DEFINE(m_libuarte, 0, 1,    NRF_LIBUARTE_PERIPHERAL_NOT_USED,2,    NRF_SDH_BLE_GATT_MAX_MTU_SIZE,3);

    It report error 100

    ..\..\..\app_uarte.c(14): error:  #94: the size of an array must be greater than zero
      NRF_LIBUARTE_ASYNC_DEFINE(m_libuarte, 0, 1,    NRF_LIBUARTE_PERIPHERAL_NOT_USED,2,    NRF_SDH_BLE_GATT_MAX_MTU_SIZE,3);

    this is the extend result of NRF_LIBUARTE_ASYNC_DEFINE:

    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(3 >= 3)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(!((1 == 0) && (255 == 255) && (2 == 255)))])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 < 1)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(1 == 1)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 == 1)])]; 
    
    static nrf_libuarte_drv_ctrl_blk_t m_libuarte_libuartectrl_blk; 
    static const nrf_libuarte_drv_t m_libuarte_libuarte = { 
    . ctrl_blk = &m_libuarte_libuartectrl_blk, 
    . timer = { . p_reg = ((NRF_TIMER_Type*) 0x40009000UL), 
    . instance_id = 1, . cc_channel_count = 4, }, 
    . uarte = ((NRF_UARTE_Type*) 0x40002000UL), }; 
    
    static uint8_t * m_libuarte_rxdata_queue_nrf_queue_buffer[(3) + 1]; 
    static nrf_queue_cb_t m_libuarte_rxdata_queue_nrf_queue_cb; 
    ; 
    const nrf_queue_t m_libuarte_rxdata_queue __attribute__ ((section("nrf_queue"))) __attribute__((used)) = { 
    . p_cb = &m_libuarte_rxdata_queue_nrf_queue_cb, 
    . p_buffer = m_libuarte_rxdata_queue_nrf_queue_buffer, 
    . size = (3), . element_size = sizeof(uint8_t *), 
    . mode = NRF_QUEUE_MODE_NO_OVERFLOW,   }; 
    
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !((3) <= 255)])]; 
    static uint8_t m_libuarte_rx_pool_nrf_balloc_pool_stack[(3)]; 
    static uint32_t m_libuarte_rx_pool_nrf_balloc_pool_mem [((((52)) - 1) + (sizeof(uint32_t)) - ((((52)) - 1) % (sizeof(uint32_t)))) * (3) / sizeof(uint32_t)]; 
    static nrf_balloc_cb_t m_libuarte_rx_pool_nrf_balloc_cb; ; 
    const nrf_balloc_t m_libuarte_rx_pool __attribute__ ((section("nrf_balloc"))) __attribute__((used)) = { 
    . p_cb = &m_libuarte_rx_pool_nrf_balloc_cb, 
    . p_stack_base = m_libuarte_rx_pool_nrf_balloc_pool_stack, 
    . p_stack_limit = m_libuarte_rx_pool_nrf_balloc_pool_stack + (3), 
    . p_memory_begin = m_libuarte_rx_pool_nrf_balloc_pool_mem, 
    . block_size = ((((52)) - 1) + (sizeof(uint32_t)) - ((((52)) - 1) % (sizeof(uint32_t)))),    };   
    ; 
    static app_timer_t m_libuarte_app_timer_data = { . end_val = 0xFFFFFFFFFFFFFFFFULL, }; 
    static const app_timer_id_t m_libuarte_app_timer = &m_libuarte_app_timer_data; nrf_libuarte_app_timer_ctrl_blk_t m_libuarte_app_timer_ctrl_blk; 
    static nrf_libuarte_async_ctrl_blk_t m_libuartectrl_blk;  
    static const nrf_libuarte_async_t m_libuarte = { 
    . p_rx_pool = &m_libuarte_rx_pool, 
    . p_rx_queue = &m_libuarte_rxdata_queue, 
    . p_rtc = 0, 
    . p_timer = 0, 
    . p_app_timer = &m_libuarte_app_timer, 
    . p_app_timer_ctrl_blk = &m_libuarte_app_timer_ctrl_blk, 
    . p_libuarte = &m_libuarte_libuarte, 
    . p_ctrl_blk = &m_libuartectrl_blk, 
    . rx_buf_size = 52,  }; 
    ;
     

    this is false, but what triggered this?

    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 == 1)])]; 

    I'm useing nrf52810,nrf52 SDK 17.1,S113.

    BLE peripheral, use UARTE + BLE SD to bridge between my MCU & Server instead of NUS.

    I have disabled LOG,so no conflict on UARTE.

    TIMER1 & TIMER2 enabled.

Reply
  • get reply from gemini:

    _uarte_idx:

    用途: 指定要使用的 UARTE 硬件实例的索引。

    安全值: 在 nRF52810 上,只有一个 UARTE 外设,所以该值必须是 0。

    _timer0_idx:

    用途: 这是底层 nrf_libuarte_drv 驱动内部使用的定时器。它用于管理 EasyDMA 传输和缓冲区切换。

    安全值: SoftDevice 会使用 TIMER0,因此你不能使用 0。你应该选择一个空闲的定时器,例如 1 或 2。

    _rtc1_idx 和 _timer1_idx:

    用途: 这两个参数用于异步超时机制。库会根据你的 sdk_config.h 配置选择一个作为超时计时器。它会从 TIMER1、RTC1 和 App Timer 中选择一个。

    安全值: RTC0 通常被 SoftDevice 占用,所以 RTC1 是一个安全的选择。TIMER1 和 TIMER2 通常也是可用的。

    如何选择:

    如果你想使用 TIMER1 作为超时计时器,将 _timer1_idx 设置为 1,并将 _rtc1_idx 设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    如果你想使用 RTC1 作为超时计时器,将 _rtc1_idx 设置为 1,并将 _timer1_idx 设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    如果你想使用 app_timer,则将 _rtc1_idx 和 _timer1_idx 都设置为 NRF_LIBUARTE_PERIPHERAL_NOT_USED。

    I defined like this :

    NRF_LIBUARTE_ASYNC_DEFINE(m_libuarte, 0, 1,    NRF_LIBUARTE_PERIPHERAL_NOT_USED,2,    NRF_SDH_BLE_GATT_MAX_MTU_SIZE,3);

    It report error 100

    ..\..\..\app_uarte.c(14): error:  #94: the size of an array must be greater than zero
      NRF_LIBUARTE_ASYNC_DEFINE(m_libuarte, 0, 1,    NRF_LIBUARTE_PERIPHERAL_NOT_USED,2,    NRF_SDH_BLE_GATT_MAX_MTU_SIZE,3);

    this is the extend result of NRF_LIBUARTE_ASYNC_DEFINE:

    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(3 >= 3)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(!((1 == 0) && (255 == 255) && (2 == 255)))])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 < 1)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(1 == 1)])]; 
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 == 1)])]; 
    
    static nrf_libuarte_drv_ctrl_blk_t m_libuarte_libuartectrl_blk; 
    static const nrf_libuarte_drv_t m_libuarte_libuarte = { 
    . ctrl_blk = &m_libuarte_libuartectrl_blk, 
    . timer = { . p_reg = ((NRF_TIMER_Type*) 0x40009000UL), 
    . instance_id = 1, . cc_channel_count = 4, }, 
    . uarte = ((NRF_UARTE_Type*) 0x40002000UL), }; 
    
    static uint8_t * m_libuarte_rxdata_queue_nrf_queue_buffer[(3) + 1]; 
    static nrf_queue_cb_t m_libuarte_rxdata_queue_nrf_queue_cb; 
    ; 
    const nrf_queue_t m_libuarte_rxdata_queue __attribute__ ((section("nrf_queue"))) __attribute__((used)) = { 
    . p_cb = &m_libuarte_rxdata_queue_nrf_queue_cb, 
    . p_buffer = m_libuarte_rxdata_queue_nrf_queue_buffer, 
    . size = (3), . element_size = sizeof(uint8_t *), 
    . mode = NRF_QUEUE_MODE_NO_OVERFLOW,   }; 
    
    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !((3) <= 255)])]; 
    static uint8_t m_libuarte_rx_pool_nrf_balloc_pool_stack[(3)]; 
    static uint32_t m_libuarte_rx_pool_nrf_balloc_pool_mem [((((52)) - 1) + (sizeof(uint32_t)) - ((((52)) - 1) % (sizeof(uint32_t)))) * (3) / sizeof(uint32_t)]; 
    static nrf_balloc_cb_t m_libuarte_rx_pool_nrf_balloc_cb; ; 
    const nrf_balloc_t m_libuarte_rx_pool __attribute__ ((section("nrf_balloc"))) __attribute__((used)) = { 
    . p_cb = &m_libuarte_rx_pool_nrf_balloc_cb, 
    . p_stack_base = m_libuarte_rx_pool_nrf_balloc_pool_stack, 
    . p_stack_limit = m_libuarte_rx_pool_nrf_balloc_pool_stack + (3), 
    . p_memory_begin = m_libuarte_rx_pool_nrf_balloc_pool_mem, 
    . block_size = ((((52)) - 1) + (sizeof(uint32_t)) - ((((52)) - 1) % (sizeof(uint32_t)))),    };   
    ; 
    static app_timer_t m_libuarte_app_timer_data = { . end_val = 0xFFFFFFFFFFFFFFFFULL, }; 
    static const app_timer_id_t m_libuarte_app_timer = &m_libuarte_app_timer_data; nrf_libuarte_app_timer_ctrl_blk_t m_libuarte_app_timer_ctrl_blk; 
    static nrf_libuarte_async_ctrl_blk_t m_libuartectrl_blk;  
    static const nrf_libuarte_async_t m_libuarte = { 
    . p_rx_pool = &m_libuarte_rx_pool, 
    . p_rx_queue = &m_libuarte_rxdata_queue, 
    . p_rtc = 0, 
    . p_timer = 0, 
    . p_app_timer = &m_libuarte_app_timer, 
    . p_app_timer_ctrl_blk = &m_libuarte_app_timer_ctrl_blk, 
    . p_libuarte = &m_libuarte_libuarte, 
    . p_ctrl_blk = &m_libuartectrl_blk, 
    . rx_buf_size = 52,  }; 
    ;
     

    this is false, but what triggered this?

    extern char (*_do_assert(void)) [sizeof(char[1 - 2* !(0 == 1)])]; 

    I'm useing nrf52810,nrf52 SDK 17.1,S113.

    BLE peripheral, use UARTE + BLE SD to bridge between my MCU & Server instead of NUS.

    I have disabled LOG,so no conflict on UARTE.

    TIMER1 & TIMER2 enabled.

Children
Related