Simplified access to a Microchip Digital Potentiometer (MCP41xxx/MCP42xxx) devices
Dependents: MCP41xxxApp MCP320xApp MCP41xxxApp
Revision 5:4f6133144e7e, committed 2013-04-05
- Comitter:
- Yann
- Date:
- Fri Apr 05 13:36:29 2013 +0000
- Parent:
- 4:bbfc8e352ff5
- Child:
- 6:ded0d8a6729c
- Commit message:
- Add support of MCP3204/8
Changed in this revision
| MCP4xxxx_SPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MCP4xxxx_SPI.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MCP4xxxx_SPI.cpp Mon Feb 04 17:15:33 2013 +0000
+++ b/MCP4xxxx_SPI.cpp Fri Apr 05 13:36:29 2013 +0000
@@ -28,14 +28,14 @@
CMCP4xxxx_SPI::SPIModuleRefCounter += 1;
if (CMCP4xxxx_SPI::SPIModuleRefCounter > 1) {
- // Nothing to do
+ //FIXME Check that SPI settings are identical. Otherwise it should failed
return;
}
_spiInstance = new SPI(p_mosi, p_miso, p_sclk);
_spiInstance->frequency(p_frequency); // Set the frequency of the SPI interface
_spiInstance->format(16, 0); // See http://mbed.org/users/mbed_official/code/mbed/docs/0954ebd79f59//classmbed_1_1SPI.html
- DEBUG_ENTER("CMCP4xxxx_SPI: refCounter=%d", CMCP4xxxx_SPI::SPIModuleRefCounter)
+ DEBUG("CMCP4xxxx_SPI: refCounter=%d", CMCP4xxxx_SPI::SPIModuleRefCounter)
if (p_cs != NC) {
DEBUG("CMCP4xxxx_SPI: /CS managed");
@@ -79,7 +79,7 @@
}
// Release _reset if required
if (_cs != NULL) {
- _cs->write(0);
+ _cs->write(1);
delete _cs;
}
// Release _reset if required
--- a/MCP4xxxx_SPI.h Mon Feb 04 17:15:33 2013 +0000
+++ b/MCP4xxxx_SPI.h Fri Apr 05 13:36:29 2013 +0000
@@ -81,6 +81,7 @@
CMCP4xxxx_SPI(const PinName p_mosi, const PinName p_miso, const PinName p_sclk, const PinName p_cs = NC, const PinName p_reset = NC, const PinName p_shdn = NC, const unsigned int p_frequency = 1000000);
/** Destructor
+ * /CS pin is set to 1 before to release it
*/
virtual ~CMCP4xxxx_SPI();
Yann Garcia