A Library for MCP3008
Dependents: Nucleo_MCP3008_Test ProjetoBB KIK01 MASTER_SPI_MCP3008
Diff: mcp3008.cpp
- Revision:
- 3:a9e08cdf0b95
- Parent:
- 2:96130c28149e
diff -r 96130c28149e -r a9e08cdf0b95 mcp3008.cpp --- a/mcp3008.cpp Sun Jun 18 19:58:42 2017 +0000 +++ b/mcp3008.cpp Fri Jun 30 15:58:59 2017 +0000 @@ -6,8 +6,8 @@ #define MODE_DIFF 0x00 // Differential mode -MCP3008::MCP3008(SPI bus, PinName cs) - : m_cs(cs), m_bus(bus) +MCP3008::MCP3008(SPI* p_bus, PinName cs) + : m_cs(cs), m_p_bus(p_bus) { deselect(); } @@ -37,9 +37,9 @@ select(); // Odd writing requirements, see the datasheet for details - m_bus.write(command_high); - int high_byte = m_bus.write(command_low) & 0x03; - int low_byte = m_bus.write(0); + m_p_bus->write(command_high); + int high_byte = m_p_bus->write(command_low) & 0x03; + int low_byte = m_p_bus->write(0); deselect(); @@ -61,9 +61,9 @@ select(); // Odd writing and reading requirements, see the datasheet for details. - m_bus.write(command_high); - int high_byte = m_bus.write(command_low) & 0x03; - int low_byte = m_bus.write(0); + m_p_bus->write(command_high); + int high_byte = m_p_bus->write(command_low) & 0x03; + int low_byte = m_p_bus->write(0); deselect();