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.
CMCP320x_SPI Class Reference
This class provides simplified SPI access to a Microchip MCP320x 12-Bit A/D Converter with SPI Serial Interface device. More...
#include <MCP320x_SPI.h>
Public Types | |
enum | Mcp320xFamilly { , _3204 = 0x01, _3208 = 0x03 } |
MCP320x familly. More... | |
enum | Mcp320xChannels { , CH1 = 0x01, CH2 = 0x02, CH3 = 0x03, CH4 = 0x04, CH5 = 0x05, CH6 = 0x06, CH7 = 0x07 } |
MCP320x channels to read. More... | |
Public Member Functions | |
CMCP320x_SPI (const PinName p_mosi, const PinName p_miso, const PinName p_sclk, const PinName p_cs=NC, const Mcp320xFamilly p_familly=_3201, const unsigned int p_frequency=1000000) | |
Constructor with Write Protect command pin wired. | |
virtual | ~CMCP320x_SPI () |
Destructor If managed, the /CS pin is set to 1 before to release it. | |
const SPI * | operator* () |
Used to return the unique instance of SPI instance. | |
float | Read (const Mcp320xChannels p_channels=CH1) |
Launch an analog to digital conversion on the specified channel | |
void | SetConfig (const bool p_settings) |
Change current configuration (only for MCP3204/8) | |
bool | Shutdown (const bool p_shutdown) |
Shutdown the device. |
Detailed Description
This class provides simplified SPI access to a Microchip MCP320x 12-Bit A/D Converter with SPI Serial Interface device.
V0.0.0.1
Microchip MCP42xxx/MCP41xxx Serial EEPROM device reference: DS11195C
Note that MCP3201 has no SI pin, only a SO output pin Note that for SPI details, please visit http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
- Remarks:
- This class was validated with Tektronix TDS2014 oscilloscope in 3.3V
Definition at line 39 of file MCP320x_SPI.h.
Member Enumeration Documentation
enum Mcp320xChannels |
MCP320x channels to read.
- Enumerator:
CH1 See DS21290F/DS21290F.
CH2 See DS21298E.
CH3 See DS21298E.
CH4 See DS21298E.
CH5 See DS21298E.
CH6 See DS21298E.
CH7 See DS21298E.
Definition at line 79 of file MCP320x_SPI.h.
enum Mcp320xFamilly |
MCP320x familly.
Definition at line 71 of file MCP320x_SPI.h.
Constructor & Destructor Documentation
CMCP320x_SPI | ( | const PinName | p_mosi, |
const PinName | p_miso, | ||
const PinName | p_sclk, | ||
const PinName | p_cs = NC , |
||
const Mcp320xFamilly | p_familly = _3201 , |
||
const unsigned int | p_frequency = 1000000 |
||
) |
Constructor with Write Protect command pin wired.
- Parameters:
-
p_mosi,: MBed pin for SDI p_miso,: MBed pin for SDO p_sclk,: MBed pin for CLK p_cs : MBed pin for Chip Select. If NC, assumes that application manage /CS, default value is NC, not connected p_familly,: MCP320x familly. Default: _3201 p_frequency,: Frequency of the SPI interface (SCK), default value is 1MHz
Definition at line 26 of file MCP320x_SPI.cpp.
~CMCP320x_SPI | ( | ) | [virtual] |
Destructor If managed, the /CS pin is set to 1 before to release it.
Definition at line 66 of file MCP320x_SPI.cpp.
Member Function Documentation
const SPI* operator* | ( | ) |
Used to return the unique instance of SPI instance.
Definition at line 108 of file MCP320x_SPI.h.
float Read | ( | const Mcp320xChannels | p_channels = CH1 ) |
Launch an analog to digital conversion on the specified channel
- Parameters:
-
p_channel The channel to convert
- Returns:
- The converted value
Definition at line 85 of file MCP320x_SPI.cpp.
void SetConfig | ( | const bool | p_settings ) |
Change current configuration (only for MCP3204/8)
- Parameters:
-
p_setConfig Set to true for single-ended inputs configuration, false for pseudo-differential inputs
- See also:
- DS21298E-page 17 Clause 4.1 Analog Inputs
Definition at line 111 of file MCP320x_SPI.cpp.
bool Shutdown | ( | const bool | p_shutdown ) |
Shutdown the device.
Definition at line 121 of file MCP320x_SPI.cpp.
Generated on Wed Jul 20 2022 01:06:38 by
