Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: acd52832_SAADC_Differential_input_2
Fork of acn_nrf52_saadc by
Diff: acd_nrf52_saadc.cpp
- Revision:
- 1:2d6e904c6843
- Parent:
- 0:838e26b2ef09
- Child:
- 2:1e7d6ab5b04b
--- a/acd_nrf52_saadc.cpp Tue Aug 22 12:16:06 2017 +0000 +++ b/acd_nrf52_saadc.cpp Wed Aug 23 07:28:42 2017 +0000 @@ -0,0 +1,27 @@ +#include "acd_nrf52_saadc.h" + +// add and remove analog channels -> +/- maxcnt + +NRF52_SAADC::NRF52_SAADC(int16_t *dataPointer) : dataPointer(dataPointer){ + NRF_SAADC->ENABLE = 1; + NRF_SAADC->RESULT.MAXCNT = 1; + NRF_SAADC->RESULT.PTR =(uint32_t)dataPointer; + NRF_SAADC->CH[0].PSELP = 9; // Input positive pin is VDD = 9 +} + +NRF52_SAADC::~NRF52_SAADC(){ + +} + +void NRF52_SAADC::getData(){ + NRF_SAADC->TASKS_START = 1; + while(!NRF_SAADC->EVENTS_STARTED); + NRF_SAADC->TASKS_SAMPLE = 1; + while(!NRF_SAADC->EVENTS_END); + while(!NRF_SAADC->EVENTS_RESULTDONE); + while(!NRF_SAADC->EVENTS_DONE); + //if(NRF_SAADC->RESULT.AMOUNT == 0); + wait_us(20); + NRF_SAADC->TASKS_STOP = 1; + while(!NRF_SAADC->EVENTS_STOPPED); +}