Hi, When compiling my program on SEGGER embedded studio I get the error:
Compiling ‘main.c’
main.c
expected expression before '{' token
in expansion of macro 'NRF_DRV_ADC_DEFAULT_CHANNEL'
In the code:
#define ADC_RIGHT ADC_CONFIG_PSEL_AnalogInput2
#define ADC_DOWN ADC_CONFIG_PSEL_AnalogInput3
#define ADC_LEFT ADC_CONFIG_PSEL_AnalogInput4
#define ADC_UP ADC_CONFIG_PSEL_AnalogInput5
uint32_t SSW_LIST[4] = { ADC_RIGHT, ADC_DOWN, ADC_LEFT, ADC_UP };
static void adc_config(nrf_drv_adc_channel_t channel)
{
ret_code_t ret_code;
nrf_drv_adc_config_t config = NRF_DRV_ADC_DEFAULT_CONFIG;
ret_code = nrf_drv_adc_init(&config, adc_event_handler);
APP_ERROR_CHECK(ret_code);
nrf_drv_adc_channel_enable(&channel);
}
int main(void)
{
uint32_t err_code;
bool erase_bonds;
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
uart_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
printf("\r\nUART Start!\r\n");
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
// Enter main loop.
for (;;)
{
uint32_t i;
int j = 0;
for (i = 0; i < ADC_BUFFER_SIZE; i++)
{
nrf_adc_config_input_t channel = SSW_LIST[j];
adc_config(NRF_DRV_ADC_DEFAULT_CHANNEL(channel)); // error in this line
APP_ERROR_CHECK(nrf_drv_adc_buffer_convert(adc_buffer,ADC_BUFFER_SIZE));
if(j==3)
j = 0;
else
j++;
if(send_flag){
uint32_t err_code;
char snum[5];
itoa(adc_buffer[i], snum, 10);
err_code = ble_nus_string_send(&m_nus, snum, 5);
}
power_manage();
nrf_delay_ms(SAMPLING_PERIOD);
}
}
}
on the last line.
The same program compiled on Keil gives this error:
..\..\..\main.c(660): error: #29: expected an expression
adc_config(
RF_DRV_ADC_DEFAULT_CHANNEL(SSW_LIST[j]));
The function adc_config is the same as SDK V12 adc example thanks a lot