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.
Fork of AnalogIn_Diff by
AnalogIn_Diff Class Reference
class of AnalogIn_Diff for K64F Example: More...
#include <AnalogIn_Diff.h>
Public Member Functions | |
| AnalogIn_Diff (int adc_ch) | |
| Create an AnalogIn_Diff. | |
| ~AnalogIn_Diff () | |
| Destroy an AnalogIn_Diff. | |
| float | read () |
| Read the input voltage, represented as a float range [-0.5 ; 0.5]. | |
| int16_t | read_raws16 () |
| Read the input voltage, represented as an 16-bit Signed 2's complement. | |
| operator float () | |
| An operator shorthand for read() | |
Detailed Description
class of AnalogIn_Diff for K64F Example:
#include "mbed.h" #include "AnalogIn_Diff.h" Ticker flipperADC; bool flag_TX=false; void flipADC() { flag_TX=true; } int main() { flipperADC.attach(&flipADC, 1.0); AnalogIn_Diff adc_diff(ADC_DIFF(0,1)); // ADC Diff pin+ ADC0_DP1 and pin- ADC0_DM1 while (true) { if(flag_TX) { pc.printf("analog= %f \r\n",adc_diff.read()); //-0.5 < analog < 0.5 ; (-0.5 # ADC0_DP1=0.0V ADC0_DM1=3.3V) (0.0 # ADC0_DP1=1.65V ADC0_DM1=1.65V) (0.5 # ADC0_DP1=3.3V ADC0_DM1=0.0V) flag_TX=false; } } }
Definition at line 66 of file AnalogIn_Diff.h.
Constructor & Destructor Documentation
| AnalogIn_Diff | ( | int | adc_ch ) |
Create an AnalogIn_Diff.
- Parameters:
-
adc_ch is ADC_DIFF(adc, ch)
Definition at line 23 of file AnalohIn_Diff.cpp.
| ~AnalogIn_Diff | ( | ) |
Destroy an AnalogIn_Diff.
Definition at line 21 of file AnalohIn_Diff.cpp.
Member Function Documentation
| operator float | ( | ) |
An operator shorthand for read()
The float() operator can be used as a shorthand for read() to simplify common code sequences
Example:
float x = volume.read(); float x = volume; if(volume.read() > 0.25) { ... } if(volume > 0.25) { ... }
Definition at line 108 of file AnalogIn_Diff.h.
| float read | ( | ) |
Read the input voltage, represented as a float range [-0.5 ; 0.5].
- Returns:
- A floating-point value representing the current input voltage, measured as a percentage
Definition at line 74 of file AnalohIn_Diff.cpp.
| int16_t read_raws16 | ( | ) |
Read the input voltage, represented as an 16-bit Signed 2's complement.
- Returns:
- 16-bit signed representing the current input voltage, normalised to a 16-bit signed
Definition at line 66 of file AnalohIn_Diff.cpp.
Generated on Tue Jul 12 2022 14:09:18 by
1.7.2

ADC DIFF K64F