Driver for National Semiconductor ADC128Sxxx family of analog to digital converters
ADC128S Class Reference
An interface for driving a National Semiconductor ADC128Sxxx analog to digital converter using SPI. More...
#include <ADC128S.h>
Public Member Functions | |
ADC128S (PinName mosi, PinName miso, PinName sck, PinName cs) | |
Create an ADC128S interface. | |
int | getChannel (void) |
Get the next channel to be converted with next call to read() | |
void | setChannel (int channel) |
Set channel to be used for the next conversion. | |
unsigned int | read (void) |
Convert the current channel and return the result and prepare to read the next channel. | |
unsigned int | read (int channel) |
Read in analog value from the specified ADC channel. |
Detailed Description
An interface for driving a National Semiconductor ADC128Sxxx analog to digital converter using SPI.
#include "mbed.h" #include "ADC128S.h" Serial pc(USBTX, USBRX); // tx, rx ADC128S adc(p5, p6, p7, p15); // mosi, miso, sck, cs int main() { unsigned int result; pc.baud(115200); while(1) { for (int i = 0; i < 8; i++) { result = adc.read(i); pc.printf("ADC(%d)=%d\n", i, result); } pc.printf("\n"); } }
Definition at line 29 of file ADC128S.h.
Constructor & Destructor Documentation
ADC128S | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sck, | ||
PinName | cs | ||
) |
Create an ADC128S interface.
- Parameters:
-
mosi MOSI line miso MISO line sck SCK line cs !CS/!SS line
Definition at line 8 of file ADC128S.cpp.
Member Function Documentation
int getChannel | ( | void | ) |
Get the next channel to be converted with next call to read()
- Returns:
- an integer representing the adc channel about to be converted
Definition at line 13 of file ADC128S.cpp.
unsigned int read | ( | int | channel ) |
Read in analog value from the specified ADC channel.
- Parameters:
-
channel The ADC channel to read
- Returns:
- the analog to digital conversion result
Definition at line 37 of file ADC128S.cpp.
unsigned int read | ( | void | ) |
Convert the current channel and return the result and prepare to read the next channel.
The channel will count to 7 and then wrap around to 0. See also: setChannel()
- Parameters:
-
returns conversion for the curent channel and prepares to read the next channel
Definition at line 25 of file ADC128S.cpp.
void setChannel | ( | int | channel ) |
Set channel to be used for the next conversion.
- Parameters:
-
channel is the adc channel you want to read with next call to read()
Definition at line 17 of file ADC128S.cpp.
Generated on Sat Jul 23 2022 19:31:45 by 1.7.2