c - nrf51 timer driver code bugs -
i'm trying make application using nrf51 development kit & i'm trying use timer driver, when induled c & h files of driver got error :
static const nrf_drv_timer_config_t m_default_config[] = {// here told me there error #1 #if (timer0_enabled == 1) nrf_drv_timer_default_config(0), #endif #if (timer1_enabled == 1) nrf_drv_timer_default_config(1), #endif #if (timer2_enabled == 1) nrf_drv_timer_default_config(2) #endif }; // here told me there error #2 ret_code_t nrf_drv_timer_init(nrf_drv_timer_t const * const p_instance, nrf_drv_timer_config_t const * p_config, nrf_timer_event_handler_t timer_event_handler) { assert((p_instance->instance_id) < timer_instance_number); assert(timer_is_bit_width_valid(p_instance->instance_id, p_config->bit_width)); if (m_cb[p_instance->instance_id].state != nrf_drv_state_uninitialized) { return nrf_error_invalid_state; // timer initialized } if (p_config == null) { p_config = &m_default_config[p_instance->instance_id]; } #ifdef softdevice_present if (p_instance->p_reg == nrf_timer0) { return nrf_error_invalid_param; } #endif nrf_drv_common_irq_enable(p_instance->irq, p_config->interrupt_priority); mp_contexts[p_instance->instance_id] = p_config->p_context; if (timer_event_handler != null) { m_timer_event_handlers[p_instance->instance_id] = timer_event_handler; } else { return nrf_error_invalid_param; } nrf_timer_mode_set(p_instance->p_reg, p_config->mode); nrf_timer_bit_width_set(p_instance->p_reg, p_config->bit_width); nrf_timer_frequency_set(p_instance->p_reg, p_config->frequency); m_cb[p_instance->instance_id].state = nrf_drv_state_initialized; return nrf_success; }
the error #1 says "an empty initializer invalid array unspecified bound" error #2 says expected expression
i till didn't use of these functions in main.c code, i'm added header files used further.
error 1: apparently neither of timerx_enabled
1, array empty. const
, there no chance initialize later. result in array of 0 elements, not allowed. easiest might have #else
clause single null entry. however, suspect have configure stuff system first. read documentation.
error 2: might follow error, or 1 of custom types not defined - hard without more info, or location error reported not of actual error, or ... . best fix first error, try again error 2.
Comments
Post a Comment