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:
- 6:57e342aaaca7
- Parent:
- 4:616c6590bbd2
- Child:
- 7:1093819c3bbf
--- a/acd_nrf52_saadc.cpp Wed Aug 23 09:28:35 2017 +0000
+++ b/acd_nrf52_saadc.cpp Thu Aug 24 11:54:14 2017 +0000
@@ -4,9 +4,9 @@
NRF52_SAADC::NRF52_SAADC(){
NRF_SAADC->ENABLE = 1;
- memset(data, 0, sizeof(data));
+ memset(data, 0, sizeof(data)); // Just to make sure data is zero
NRF_SAADC->RESULT.PTR =(uint32_t)data;
- NRF_SAADC->RESULT.MAXCNT = 0;
+ //NRF_SAADC->RESULT.MAXCNT = 0;
}
NRF52_SAADC::~NRF52_SAADC(){
@@ -17,8 +17,7 @@
NRF_SAADC->TASKS_START = 1;
while(!NRF_SAADC->EVENTS_STARTED);
NRF_SAADC->TASKS_SAMPLE = 1;
- for(uint8_t i = 0; i < NRF_SAADC->RESULT.MAXCNT; ++i)
- {
+ for(uint8_t i = 0; i < NRF_SAADC->RESULT.MAXCNT; ++i){
while(!NRF_SAADC->EVENTS_RESULTDONE);
while(!NRF_SAADC->EVENTS_DONE);
while(!NRF_SAADC->EVENTS_END);
@@ -29,8 +28,7 @@
}
bool NRF52_SAADC::addChannel(uint8_t pin){
- if(NRF_SAADC->RESULT.MAXCNT < 8)
- {
+ if(NRF_SAADC->RESULT.MAXCNT < 8){
int channel = NRF_SAADC->RESULT.MAXCNT;
NRF_SAADC->CH[channel].PSELP = pin; // Input positive pin is VDD = 9
NRF_SAADC->CH[channel].CONFIG = 0x00020000; // reset
