This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use atfifo(automatic fifo)?

Hi, there

     I try to use the nrf_atfifo  in my program, but I found the atfifo cause hard fault  in my program,below is how I use the at_fifo in my program.  

 

    NRF_ATFIFO_DEF(my_fifo, uint16_t, 32);
    NRF_ATFIFO_INIT(my_fifo); 
    uint16_t *some_val ;
    some_val=nrf_atfifo_item_get(my_fifo, NULL);
    if(some_val)NRF_LOG_INFO("fifo is empty");

and I also found that the code example in the nrf_atfifo.h is not correct like below , because the parameter of the nrf_atfifo_item_put is 2 not 4

     * @brief Macro for creating an instance.
     *
     * Creates the FIFO object variable itself.
     *
     * Usage example:
     * @code
     * NRF_ATFIFO_DEF(my_fifo, uint16_t, 12);
     * NRF_ATFIFO_INIT(my_fifo);
     *
     * uint16_t some_val = 45;
     * nrf_atfifo_item_put(my_fifo, &some_val, sizeof(some_val), NULL);
     * nrf_atfifo_item_get(my_fifo, &some_val, sizeof(some_val), NULL);
     * @endcode
     *
     * @param[in] fifo_id      Identifier of a FIFO object.
     *                         This identifier will be a pointer to the instance.
     *                         It makes it possible to use this directly for the functions
     *                         that operate on the FIFO.
     *                         Because it is a static const object, it should be optimized by the compiler.
     * @param[in] storage_type Type of data that will be stored in the FIFO.
     * @param[in] item_cnt     Capacity of the created FIFO in maximum number of items that may be stored.
     *                         The phisical size of the buffer will be 1 element bigger.
     */
    #define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt)                 \
        static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1];     \
        static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id);                  \
        static nrf_atfifo_t * const fifo_id = &NRF_ATFIFO_INST_NAME(fifo_id)

Is there any example to use the atfifo? thank you!

Parents Reply Children
No Data
Related