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.
acd_nrf52_saadc.h@10:b763d9cfc063, 2017-10-04 (annotated)
- Committer:
- jurica238814
- Date:
- Wed Oct 04 08:01:51 2017 +0000
- Revision:
- 10:b763d9cfc063
- Parent:
- 8:b4afe08821f5
Resolution and input range hardcoded.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurica238814 | 0:838e26b2ef09 | 1 | /* |
Dautor | 1:2d6e904c6843 | 2 | * Made by Jurica Resetar and Karlo Milicevic @ aconno, 2017 |
jurica238814 | 0:838e26b2ef09 | 3 | * jurica_resetar@yahoo.com |
jurica238814 | 0:838e26b2ef09 | 4 | * aconno.de |
jurica238814 | 0:838e26b2ef09 | 5 | * All rights reserved |
jurica238814 | 0:838e26b2ef09 | 6 | * |
jurica238814 | 0:838e26b2ef09 | 7 | */ |
Dautor | 3:fcada8b3b567 | 8 | |
Dautor | 3:fcada8b3b567 | 9 | #ifndef ACD_NRF52_SAADC_H |
Dautor | 3:fcada8b3b567 | 10 | #define ACD_NRF52_SAADC_H |
Dautor | 3:fcada8b3b567 | 11 | |
Dautor | 3:fcada8b3b567 | 12 | #include "mbed.h" |
Dautor | 3:fcada8b3b567 | 13 | |
jurica238814 | 8:b4afe08821f5 | 14 | #define NUM_OF_CHANNELS (8) |
jurica238814 | 8:b4afe08821f5 | 15 | |
Dautor | 3:fcada8b3b567 | 16 | /** NRF52 adc library |
Dautor | 3:fcada8b3b567 | 17 | */ |
Dautor | 3:fcada8b3b567 | 18 | class NRF52_SAADC{ |
Dautor | 1:2d6e904c6843 | 19 | public: |
Dautor | 3:fcada8b3b567 | 20 | /** Initializes adc module |
Dautor | 3:fcada8b3b567 | 21 | */ |
jurica238814 | 8:b4afe08821f5 | 22 | NRF52_SAADC(uint8_t analogIn); |
jurica238814 | 8:b4afe08821f5 | 23 | NRF52_SAADC(uint8_t pPin, uint8_t nPin); |
jurica238814 | 8:b4afe08821f5 | 24 | int16_t read(); |
jurica238814 | 8:b4afe08821f5 | 25 | |
Dautor | 1:2d6e904c6843 | 26 | ~NRF52_SAADC(); |
jurica238814 | 8:b4afe08821f5 | 27 | bool addDiffChannel(uint8_t pInput, uint8_t nInput); |
jurica238814 | 8:b4afe08821f5 | 28 | |
Dautor | 3:fcada8b3b567 | 29 | /** @returns |
Dautor | 3:fcada8b3b567 | 30 | * 0 on success, 1 otherwise |
Dautor | 3:fcada8b3b567 | 31 | */ |
Dautor | 3:fcada8b3b567 | 32 | bool addChannel(uint8_t pin); |
Dautor | 3:fcada8b3b567 | 33 | void calibrate(); |
Dautor | 5:f797719350a6 | 34 | /** Reads analog pins |
Dautor | 5:f797719350a6 | 35 | */ |
Dautor | 3:fcada8b3b567 | 36 | void updateData(); |
Dautor | 5:f797719350a6 | 37 | /** @returns |
Dautor | 5:f797719350a6 | 38 | * pointer to analog input data - data is stored in channel add order |
Dautor | 5:f797719350a6 | 39 | */ |
Dautor | 3:fcada8b3b567 | 40 | int16_t *getData() { return data; } |
jurica238814 | 8:b4afe08821f5 | 41 | |
jurica238814 | 8:b4afe08821f5 | 42 | static uint8_t channelCounter; |
Dautor | 1:2d6e904c6843 | 43 | private: |
jurica238814 | 8:b4afe08821f5 | 44 | static int16_t data[sizeof(int16_t)*8]; // 8 channels |
jurica238814 | 8:b4afe08821f5 | 45 | uint8_t channel; |
jurica238814 | 8:b4afe08821f5 | 46 | |
Dautor | 1:2d6e904c6843 | 47 | }; |
jurica238814 | 0:838e26b2ef09 | 48 | |
jurica238814 | 0:838e26b2ef09 | 49 | #endif // ACD_NRF52_SAADC_H |