interoberlin / nRF51-adc-test

A simple demonstration of ADC and NUS (Nordic UART Service) using the nRF-DK board.
http://electronut.in/nrf51-adc-test/
0 stars 0 forks source link

macro "APP_TIMER_INIT" passed 4 arguments, but takes just 3 #8

Open matthiasbock opened 8 years ago

matthiasbock commented 8 years ago
$ ./build.sh 
rm -rf _build *.jlink
echo  Makefile
Makefile
mkdir _build
Compiling file: app_button.c
Compiling file: app_error.c
Compiling file: app_fifo.c
Compiling file: app_timer.c
Compiling file: app_trace.c
Compiling file: nrf_assert.c
Compiling file: retarget.c
Compiling file: app_uart_fifo.c
Compiling file: nrf_delay.c
Compiling file: nrf_adc.c
Compiling file: nrf_drv_common.c
Compiling file: nrf_drv_gpiote.c
Compiling file: pstorage.c
Compiling file: bsp.c
Compiling file: bsp_btn_ble.c
Compiling file: main.c
../../../main.c: In function 'main':
../../../main.c:371:60: error: macro "APP_TIMER_INIT" passed 4 arguments, but takes just 3
     APP_TIMER_INIT(0, (2 + BSP_APP_TIMERS_NUMBER), 4, false);
                                                            ^
../../../main.c:371:5: error: 'APP_TIMER_INIT' undeclared (first use in this function)
     APP_TIMER_INIT(0, (2 + BSP_APP_TIMERS_NUMBER), 4, false);
     ^
../../../main.c:371:5: note: each undeclared identifier is reported only once for each function it appears in
Makefile:171: recipe for target '_build/main.o' failed
make: *** [_build/main.o] Error 1
matthiasbock commented 8 years ago

Also occurs with nrf51-ble-tutorial-advertising:

Compiling file: main.c
../../../main.c: In function 'timers_init':
../../../main.c:80:98: error: macro "APP_TIMER_APPSH_INIT" passed 4 arguments, but takes just 3
     APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true);
                                                                                                  ^
../../../main.c:80:5: error: 'APP_TIMER_APPSH_INIT' undeclared (first use in this function)
     APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true);
     ^
../../../main.c:80:5: note: each undeclared identifier is reported only once for each function it appears in
Makefile:174: recipe for target '_build/main.o' failed
make: *** [_build/main.o] Error 1
matthiasbock commented 8 years ago

The relevant excerpt from $(SDK_PATH)/components/libraries/timer/app_timer.h:

/**@brief Initialize the application timer module.
 *
 * @details This macro handles dimensioning and allocation of the memory buffer required by the timer,
 *          making sure that the buffer is correctly aligned. It will also connect the timer module
 *          to the scheduler (if specified).
 *
 * @note    This module assumes that the LFCLK is already running. If it is not, the module will
 *          be non-functional, since the RTC will not run. If you do not use a SoftDevice, you
 *          must start the LFCLK manually. See the rtc_example's lfclk_config() function
 *          for an example of how to do this. If you use a SoftDevice, the LFCLK is started on
 *          SoftDevice init.
 *
 *
 * @param[in]  PRESCALER        Value of the RTC1 PRESCALER register. This will decide the
 *                              timer tick rate. Set to 0 for no prescaling.
 * @param[in]  OP_QUEUES_SIZE   Size of queues holding timer operations that are pending execution.
 * @param[in]  SCHEDULER_FUNC   Pointer to scheduler event handler
 *
 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
 *       several times as long as it is from the same location, for example, to do a re-initialization).
 */
/*lint -emacro(506, APP_TIMER_INIT) */ /* Suppress "Constant value Boolean */
#define APP_TIMER_INIT(PRESCALER, OP_QUEUES_SIZE, SCHEDULER_FUNC)                                  \
    do                                                                                             \
    {                                                                                              \
        static uint32_t APP_TIMER_BUF[CEIL_DIV(APP_TIMER_BUF_SIZE((OP_QUEUES_SIZE) + 1),           \
                                               sizeof(uint32_t))];                                 \
        uint32_t ERR_CODE = app_timer_init((PRESCALER),                                            \
                                           (OP_QUEUES_SIZE) + 1,                                   \
                                           APP_TIMER_BUF,                                          \
                                           SCHEDULER_FUNC);                                        \
        APP_ERROR_CHECK(ERR_CODE);                                                                 \
    } while (0)

...

/**@brief Function for initializing the timer module.
 *
 * Normally, initialization should be done using the APP_TIMER_INIT() macro, because that macro will both
 *       allocate the buffers needed by the timer module (including aligning the buffers correctly)
 *       and take care of connecting the timer module to the scheduler (if specified).
 *
 * @param[in]  prescaler           Value of the RTC1 PRESCALER register. Set to 0 for no prescaling.
 * @param[in]  op_queues_size      Size of queues holding timer operations that are pending
 *                                 execution. Note that due to the queue implementation, this size must
 *                                 be one more than the size that is actually needed.
 * @param[in]  p_buffer            Pointer to memory buffer for internal use in the app_timer
 *                                 module. The size of the buffer can be computed using the
 *                                 APP_TIMER_BUF_SIZE() macro. The buffer must be aligned to a
 *                                 4 byte boundary.
 * @param[in]  evt_schedule_func   Function for passing time-out events to the scheduler. Point to
 *                                 app_timer_evt_schedule() to connect to the scheduler. Set to NULL
 *                                 to make the timer module call the time-out handler directly from
 *                                 the timer interrupt handler.
 *
 * @retval     NRF_SUCCESS               If the module was initialized successfully.
 * @retval     NRF_ERROR_INVALID_PARAM   If a parameter was invalid (buffer not aligned to a 4 byte
 *                                       boundary or NULL).
 */
uint32_t app_timer_init(uint32_t                      prescaler,
                        uint8_t                       op_queues_size,
                        void *                        p_buffer,
                        app_timer_evt_schedule_func_t evt_schedule_func);