Skip to content

Commit 42ecd09

Browse files
author
Silver Kuusik
committed
add appending status register to data
1 parent 84683d1 commit 42ecd09

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

AD7173.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ int AD7173Class::set_adc_mode_config(data_mode_t data_mode, clock_mode_t clock_m
122122
return 0;
123123
}
124124

125-
int AD7173Class::set_interface_mode_config(bool continuous_read) {
125+
int AD7173Class::set_interface_mode_config(bool continuous_read, bool append_status_reg) {
126126
/* Address: 0x02, Reset: 0x0000, Name: IFMODE */
127127

128128
/* prepare the configuration value */
129129
/* RESERVED [15:13], ALT_SYNC [12], IOSTRENGTH [11], HIDE_DELAY [10], RESERVED [9], DOUT_RESET [8], CONTREAD [7], DATA_STAT [6], REG_CHECK [5], RESERVED [4], CRC_EN [3:2], RESERVED [1], WL16 [0] */
130130
byte value[2] = {0x00, 0x00};
131-
value[1] = (continuous_read << 7);
131+
value[1] = (continuous_read << 7) | (append_status_reg << 6);
132132

133133
/* update the configuration value */
134134
this->set_register(IFMODE_REG, value, 2);

AD7173.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class AD7173Class {
260260
@return int - error code
261261
==================================================
262262
*/
263-
int set_interface_mode_config(bool);
263+
int set_interface_mode_config(bool, bool);
264264

265265
/*
266266
==========================================

examples/Basic/Basic.ino

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
example to configure and get data from AD7173 ADC
44
=================================================
55
*/
6-
#include <SPI.h>
76
#include <AD7173.h>
87

98
void setup() {
@@ -54,16 +53,17 @@ void setup() {
5453
/* INTERNAL_CLOCK, INTERNAL_CLOCK_OUTPUT, EXTERNAL_CLOCK_INPUT, EXTERNAL_CRYSTAL */
5554
AD7173.set_adc_mode_config(CONTINUOUS_CONVERSION_MODE, INTERNAL_CLOCK);
5655

57-
/* enable or disable CONTINUOUS_READ_MODE, to exit use AD7173.reset(); */
58-
/* AD7173.reset(); return all registers to default state, so everything has to be setup again */
59-
AD7173.set_interface_mode_config(false);
56+
/* enable/disable CONTINUOUS_READ_MODE and appending STATUS register to data */
57+
/* to exit CONTINUOUS_READ_MODE use AD7173.reset(); */
58+
/* AD7173.reset(); returns all registers to default state, so everything has to be setup again */
59+
AD7173.set_interface_mode_config(false, true);
6060

6161
/* wait for ADC */
6262
delay(10);
6363
}
6464

65-
/* ADC conversion data */
66-
byte data[3];
65+
/* ADC conversion data and STATUS register */
66+
byte data[4];
6767

6868
void loop() {
6969
/* when ADC conversion is finished */
@@ -75,6 +75,7 @@ void loop() {
7575
Serial.print(data[0], HEX);
7676
Serial.print(data[1], HEX);
7777
Serial.println(data[2], HEX);
78+
Serial.println(data[3], HEX);
7879
delay(100);
7980
}
80-
}
81+
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=AD7173
2-
version=0.3.3
2+
version=0.4
33
author=Silver Kuusik <silver.kuusik@gmail.com>
44
maintainer=Silver Kuusik <silver.kuusik@gmail.com>
55
sentence=Arduino library for Analog Devices AD7173 analog digital converter
66
paragraph=This library was developed as the 24bit interface for Brain-Duino. It implements basic functionality of the AD7173 for using it with Brain-Duino or other purposes.
77
category=Communication
88
url=https://github.com/brain-duino/AD7173-Arduino
9-
architectures=avr
9+
architectures=*

0 commit comments

Comments
 (0)