Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static uint16_t adc10_data_get(void)
- {
- uint16_t adc_read;
- NRF_ADC->INTENSET= 0; // disable interrupt
- NRF_ADC->EVENTS_END = 0;
- NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled; // Enable ADC
- NRF_ADC->CONFIG = (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos) /* Bits 17..16 : ADC external reference pin selection. */
- | (ADC_CONFIG_PSEL_AnalogInput5 << ADC_CONFIG_PSEL_Pos) /*!< Use analog input X as analog input. */
- | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) /*!< Use internal 1.2V bandgap voltage as reference for conversion. */
- | (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) /*!< Analog input specified by PSEL with prescaling used as input for the conversion. */
- | (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos); /*!< 10bit ADC resolution. */
- NRF_ADC->TASKS_START = 1; //Start ADC sampling
- while (!NRF_ADC->EVENTS_END) {} // wait till ADC sampling finishes
- NRF_ADC->EVENTS_END = 0;
- adc_read = NRF_ADC->RESULT; // read ADC result
- NRF_ADC->TASKS_STOP = 1; //Use the STOP task to save current. Workaround for PAN_028 rev1.5 anomaly 1.
- return adc_read;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement