SAADC differential input setup. With EPD display.

Dependencies:   GDEP015OC1 acn_nrf52_saadc adc52832_common

main.cpp

Committer:
jurica238814
Date:
2017-09-28
Revision:
0:04520242cfef
Child:
1:41e296b93414

File content as of revision 0:04520242cfef:

/*
 * Example to demonstrate usage of the nrf52's SAADC in differential working\
 * mode.
 *
 * Made by Jurica Resetar @ aconno
 * jurica_resetar@yahoo.com
 * More info @ aconno.de
 *
 * All rights reserved
 *
 */
 
 
 
#include "mbed.h"
#include "acd_nrf52_saadc.h"
 
#define PRINT           (1)

#if PRINT
    #include "nrf52_uart.h"
    NRF52_UART uart(p25, p26, Baud9600);
    char buffer[255];
    #define SEND(...) {uint8_t len = sprintf(buffer, __VA_ARGS__); uart.send(buffer, len);}
#else
    #define SEND(...)
#endif


NRF52_SAADC analogIn;

int main(void){
    float voltageDiff;
    int16_t rawData;
    // Configure SAADC
    analogIn.addChannel(5); // Set VDD as source to SAADC
    analogIn.calibrate();   //
    
    while(1){
        analogIn.updateData();
        rawData = analogIn.getData()[0];
        voltageDiff = (float)((3.6/512)*rawData);
        SEND("Voltage differance is: %fV\r\n", voltageDiff);
        //SEND("Raw data is: %d\n\r", rawData);
    }
}