A collection of Analog Devices drivers for the mbed platform
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Diff: libraries/AD5270/AD5270.cpp
- Revision:
- 28:e24b911ddd7c
- Parent:
- 24:dae7123d432a
--- a/libraries/AD5270/AD5270.cpp Tue May 24 18:24:35 2016 +0200
+++ b/libraries/AD5270/AD5270.cpp Thu Aug 18 15:14:12 2016 +0300
@@ -125,11 +125,11 @@
* @param data - (optional)value for the requested command
* @return response form the AD5270
*/
-uint16_t AD5270::write_cmd(uint8_t command, uint16_t data)
+uint16_t AD5270::write_cmd(uint8_t command, uint16_t data, bool toggle_cs)
{
/* build 16 bit data to be written - Command + Value */
uint16_t ui16Command = ((command & 0x3C) << 8) | (data & 0x3FF);
- return write_reg(ui16Command);
+ return write_reg(ui16Command, toggle_cs);
}
/**
@@ -164,16 +164,16 @@
* @param data to be written
* @return data returned by the AD5270
*/
-uint16_t AD5270::write_reg(uint16_t data)
+uint16_t AD5270::write_reg(uint16_t data, bool toggle_cs)
{
uint16_t result;
uint8_t upper_byte = (data >> 8) & 0xFF;
uint8_t lower_byte = data & 0xFF;
ad5270.format(8, _SPI_MODE);
- cs = false;
+ cs = false & toggle_cs;
result = ((ad5270.write(upper_byte)) << 8);
result |= ad5270.write(lower_byte);
- cs = true;
+ cs = true & toggle_cs;
return result;
}
@@ -279,5 +279,11 @@
write_cmd(SW_SHUTDOWN, static_cast<uint8_t>(mode));
}
+void AD5270::daisy_chain(uint8_t *buffer, uint8_t size)
+{
+ cs = 0;
+ for(int i = 0; i < size; i++)
+ buffer[i] = ad5270.write(buffer[i]);
+ cs = 1;
+}
-
CN0357 - Toxic gas measurement
CN0216 - Weight Scale