SAADC library and drivers for nrf52832.

Dependents:   acd52832_SAADC_Differential_input_EPD acd52832_Car_battery_ch acd52832_Car_battery_ch_2

Library to use aconno drivers for Nordic Semiconductor nrf52832 SAADC.

Committer:
Dautor
Date:
Wed Aug 23 07:28:42 2017 +0000
Revision:
1:2d6e904c6843
Parent:
0:838e26b2ef09
Child:
2:1e7d6ab5b04b
Battery read working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Dautor 1:2d6e904c6843 1 #include "acd_nrf52_saadc.h"
Dautor 1:2d6e904c6843 2
Dautor 1:2d6e904c6843 3 // add and remove analog channels -> +/- maxcnt
Dautor 1:2d6e904c6843 4
Dautor 1:2d6e904c6843 5 NRF52_SAADC::NRF52_SAADC(int16_t *dataPointer) : dataPointer(dataPointer){
Dautor 1:2d6e904c6843 6 NRF_SAADC->ENABLE = 1;
Dautor 1:2d6e904c6843 7 NRF_SAADC->RESULT.MAXCNT = 1;
Dautor 1:2d6e904c6843 8 NRF_SAADC->RESULT.PTR =(uint32_t)dataPointer;
Dautor 1:2d6e904c6843 9 NRF_SAADC->CH[0].PSELP = 9; // Input positive pin is VDD = 9
Dautor 1:2d6e904c6843 10 }
Dautor 1:2d6e904c6843 11
Dautor 1:2d6e904c6843 12 NRF52_SAADC::~NRF52_SAADC(){
Dautor 1:2d6e904c6843 13
Dautor 1:2d6e904c6843 14 }
Dautor 1:2d6e904c6843 15
Dautor 1:2d6e904c6843 16 void NRF52_SAADC::getData(){
Dautor 1:2d6e904c6843 17 NRF_SAADC->TASKS_START = 1;
Dautor 1:2d6e904c6843 18 while(!NRF_SAADC->EVENTS_STARTED);
Dautor 1:2d6e904c6843 19 NRF_SAADC->TASKS_SAMPLE = 1;
Dautor 1:2d6e904c6843 20 while(!NRF_SAADC->EVENTS_END);
Dautor 1:2d6e904c6843 21 while(!NRF_SAADC->EVENTS_RESULTDONE);
Dautor 1:2d6e904c6843 22 while(!NRF_SAADC->EVENTS_DONE);
Dautor 1:2d6e904c6843 23 //if(NRF_SAADC->RESULT.AMOUNT == 0);
Dautor 1:2d6e904c6843 24 wait_us(20);
Dautor 1:2d6e904c6843 25 NRF_SAADC->TASKS_STOP = 1;
Dautor 1:2d6e904c6843 26 while(!NRF_SAADC->EVENTS_STOPPED);
Dautor 1:2d6e904c6843 27 }