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

NRF52 SDK Redesign

Hello, Nordic Team, I'm embedded designer from Russia, discovered your amazing wireless MCU NRF52832. I looked through your SDK and peripheral drivers, and unfortunately found a bad code style such as:

CODE_FOR_<some dma periph>
(
    ...
)
CODE_FOR_<some periph>
(
    ...
)

..and this:

#define APP_UART_FIFO_INIT(P_COMM_PARAMS, RX_BUF_SIZE, TX_BUF_SIZE, EVT_HANDLER, IRQ_PRIO, ERR_CODE)

    do                                                                                             \
    {                                                                                              \
        app_uart_buffers_t buffers;                                                                \
        static uint8_t     rx_buf[RX_BUF_SIZE];                                                    \
        static uint8_t     tx_buf[TX_BUF_SIZE];                                                    \
                                                                                                   \
        buffers.rx_buf      = rx_buf;                                                              \
        buffers.rx_buf_size = sizeof (rx_buf);                                                     \
        buffers.tx_buf      = tx_buf;                                                              \
        buffers.tx_buf_size = sizeof (tx_buf);                                                     \
        ERR_CODE = app_uart_init(P_COMM_PARAMS, &buffers, EVT_HANDLER, IRQ_PRIO);                  \
    } while (0)

and bad, arduino-styled delay:

static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
{
__ASM (
"loop:\n\t"
       " SUBS R0, R0, #1\n\t"
       " NOP\n\t"
       " NOP\n\t"
       " NOP\n\t"
       .....
       .....//many many "NOP"s for 1 microsecond delay
       .....
        " NOP\n\t"
       " BNE.n loop\n\t");
}

..and other oddities in the code.

And in startup clocks initialization... there is no startup clocks initialization, and without little delay for starting clock system core does not start. I put small 15ms delay in begin of main() to fix it. I think - its needed for PLL setup time, or flash internal init time or some other startup work. In ST Microelectronics MCUs STM32 i see special startup file where implemented delay until clock system's flag is set.

I want to write for you nRF52 HAL and API, together with some more developers from Russia.

It is with the following parameters:

-CamelCase for functions.

-No big preprocessor macroses, or macros with static.

-Initialization structures and functions to work with them by pointer.

-Possible to use C++ and OOP style of API (classes with methods instead of structures and functions)

-The right delay function (with SysTick timer)

-Greatly reduced the number of preprocessor directives in working code (they prevent people from reading the code)

-and other features used in CMSIS Standard code and ST code

My social network link: http://vk.com/id306014907

Related