AD7172 library
Diff: ad7172.cpp
- Revision:
- 8:8466106f2e1b
- Parent:
- 7:ba79fe65707d
- Child:
- 9:e71f2bdd2f83
--- a/ad7172.cpp Fri Jun 19 14:04:13 2020 +0000 +++ b/ad7172.cpp Tue Jun 30 19:17:29 2020 +0000 @@ -64,12 +64,12 @@ //@AD7172 class constructor. //@param spi - The handler of the instance of the driver. //@param slave_select - The Slave Chip Select Id to be passed to the SPI calls. -AD7172::AD7172(SPI& p_spi,PinName slave_select,DigitalIn& p_rdy) +AD7172::AD7172(SPI& p_spi,PinName slave_select,DigitalIn& p_rdy) : _spi(p_spi), _rdy(p_rdy) { _spi.format(8,3); //8 bits ; POL=1 ; PHASE=1 _spi.frequency(10000000); //10 MHz SPI clock rate - continuous_on = 0; + continuous_on = 0; //Continuous read mode flag cs = new DigitalOut(slave_select); //Define cs as digital out variable referred to slave_select pin Reset(); //Calling the AD7172-2 restart function @@ -123,9 +123,9 @@ void AD7172::ReadID() { *cs=0; - _spi.write(0x40|AD7172_ID_REG); - id.bytes[1] = _spi.write(0x00); - id.bytes[0] = _spi.write(0x00); + _spi.write(0x40|AD7172_ID_REG); //Configures the communication register to read the ID address + id.bytes[1] = _spi.write(0x00); //Read the two most significant bytes + id.bytes[0] = _spi.write(0x00); //Read the two lesat significant bytes *cs=1; }