/**@brief Function for application main entry. */ int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. timers_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); device_manager_init(erase_bonds); gap_params_init(); advertising_init(); services_init(); conn_params_init(); saadc_init(); // Start execution. application_timers_start(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { // trigger next ADC conversion nrf_drv_saadc_sample_convert(0,&adc_sample); advdata.p_manuf_specific_data->data.p_data[0] = adc_sample/100 + '0'; advdata.p_manuf_specific_data->data.p_data[1] = adc_sample%100/10 + '0'; advdata.p_manuf_specific_data->data.p_data[2] = adc_sample%10 + '0'; nrf_delay_ms(100); ble_advdata_set(&advdata, NULL); } }
/** * @brief Function for main application entry. */ int main(void) { LEDS_CONFIGURE(LEDS_MASK); //Configure all leds LEDS_OFF(LEDS_MASK); //Turn off all leds NRF_POWER->DCDCEN = 1; //Enabling the DCDC converter for lower current consumption #ifdef UART_PRINTING_ENABLED uint32_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); //Configure Logging. LOGGING is used to show the SAADC sampled result. Default is UART, but RTT can be configured in sdk_config.h NRF_LOG_INFO("\n\rSAADC Low Power Example.\r\n"); #endif //UART_PRINTING_ENABLED lfclk_config(); //Configure low frequency 32kHz clock rtc_config(); //Configure RTC. The RTC will generate periodic interrupts. Requires 32kHz clock to operate. saadc_init(); //Initialize and start SAADC while (1) { if(m_saadc_calibrate == true) { #ifdef UART_PRINTING_ENABLED NRF_LOG_INFO("SAADC calibration starting... \r\n"); //Print on UART #endif //UART_PRINTING_ENABLED while(nrf_drv_saadc_calibrate_offset() != NRF_SUCCESS); //Trigger calibration task m_saadc_calibrate = false; } nrf_pwr_mgmt_run(); #ifdef UART_PRINTING_ENABLED NRF_LOG_FLUSH(); #endif //UART_PRINTING_ENABLED } }
ret_code_t nrf_drv_csense_init(nrf_drv_csense_config_t const * p_config, nrf_drv_csense_event_handler_t event_handler) { ASSERT(m_csense.module_state == NRF_DRV_STATE_UNINITIALIZED); ASSERT(p_config->output_pin <= NUMBER_OF_PINS); ret_code_t err_code; if(p_config == NULL) { return NRF_ERROR_INVALID_PARAM; } if(event_handler == NULL) { return NRF_ERROR_INVALID_PARAM; } m_csense.busy = false; #if USE_COMP == 0 m_csense.output_pin = p_config->output_pin; nrf_gpio_cfg_output(m_csense.output_pin); nrf_gpio_pin_set(m_csense.output_pin); #endif //COMP_PRESENT m_csense.event_handler = event_handler; #if USE_COMP err_code = comp_init(); if(err_code != NRF_SUCCESS) { return err_code; } err_code = timer_init(); if(err_code != NRF_SUCCESS) { return err_code; } err_code = ppi_init(); if(err_code != NRF_SUCCESS) { return err_code; } #else #ifdef ADC_PRESENT err_code = adc_init(); if(err_code != NRF_SUCCESS) { return err_code; } #elif defined(SAADC_PRESENT) err_code = saadc_init(); if(err_code != NRF_SUCCESS) { return err_code; } #endif //ADC_PRESENT #endif //USE_COMP m_csense.module_state = NRF_DRV_STATE_INITIALIZED; return NRF_SUCCESS; }