67 #define DC1633_DAC_ADDRESS 0x22 //pin-strapped address for DAC 70 #define LTC2933_I2C_ADDRESS LTC2933_I2C_GLOBAL_ADDRESS 93 uint8_t *addresses = NULL;
96 if (Serial.available())
99 if (user_command !=
'm')
100 Serial.println(user_command);
102 switch (user_command)
114 Serial.println(res, HEX);
149 addresses = smbus->
probe(0);
150 while (*addresses != 0)
152 Serial.print(F(
"ADDR 0x"));
153 Serial.println(*addresses++, HEX);
157 Serial.println(F(
"Incorrect Option"));
169 Serial.print(F(
"\n*****************************************************************\n"));
170 Serial.print(F(
"* DC1633B Demonstration Program *\n"));
171 Serial.print(F(
"* *\n"));
172 Serial.print(F(
"* This program demonstrates how to send and receive data from *\n"));
173 Serial.print(F(
"* the DC1633B demo board. *\n"));
174 Serial.print(F(
"* *\n"));
175 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator.*\n"));
176 Serial.print(F(
"* *\n"));
177 Serial.print(F(
"*****************************************************************\n"));
183 Serial.print(F(
" 1-Write LTC2933 registers with default settings\n"));
184 Serial.print(F(
" 2-Read Status (STATUS_WORD)\n"));
185 Serial.print(F(
" 3-Read All Registers\n"));
186 Serial.print(F(
" 4-Set DAC voltages on Vn pins to interesting values\n"));
187 Serial.print(F(
" 5-Change LTC2933 voltage thresholds to match interesting DAC voltages\n"));
188 Serial.print(F(
" 6-Set DAC voltages on Vn pins to +20% high values\n"));
189 Serial.print(F(
" 7-Clear LTC2933 ALERTB\n"));
190 Serial.print(F(
" 8-Bus Probe\n"));
191 Serial.print(F(
"\nEnter a command:"));
197 Serial.println(F(
"\nWarning: Demo board not detected. Linduino will attempt to proceed."));
210 return ((res&0x0001) == 0x0001) ? 1 : 0;
218 Serial.print(F(
"\n LTC2933_WRITE_PROTECT:"));
219 Serial.println(res, HEX);
222 Serial.print(F(
"\n LTC2933_GPI_CONFIG: "));
223 Serial.println(res, HEX);
226 Serial.print(F(
"\n LTC2933_GPIO1_CONFIG: "));
227 Serial.println(res, HEX);
230 Serial.print(F(
"\n LTC2933_GPIO2_3_CONFIG: "));
231 Serial.println(res, HEX);
234 Serial.print(F(
"\n LTC2933_V1_THR: "));
235 Serial.println(res, HEX);
238 Serial.print(F(
"\n LTC2933_V2_THR: "));
239 Serial.println(res, HEX);
242 Serial.print(F(
"\n LTC2933_V3_THR: "));
243 Serial.println(res, HEX);
246 Serial.print(F(
"\n LTC2933_V4_THR: "));
247 Serial.println(res, HEX);
250 Serial.print(F(
"\n LTC2933_V5_THR: "));
251 Serial.println(res, HEX);
254 Serial.print(F(
"\n LTC2933_V6_THR: "));
255 Serial.println(res, HEX);
258 Serial.print(F(
"\n LTC2933_V1_CONFIG: "));
259 Serial.println(res, HEX);
262 Serial.print(F(
"\n LTC2933_V2_CONFIG: "));
263 Serial.println(res, HEX);
266 Serial.print(F(
"\n LTC2933_V3_CONFIG: "));
267 Serial.println(res, HEX);
270 Serial.print(F(
"\n LTC2933_V4_CONFIG: "));
271 Serial.println(res, HEX);
274 Serial.print(F(
"\n LTC2933_V5_CONFIG: "));
275 Serial.println(res, HEX);
278 Serial.print(F(
"\n LTC2933_V6_CONFIG: "));
279 Serial.println(res, HEX);
282 Serial.print(F(
"\n LTC2933_HISTORY_WORD: "));
283 Serial.println(res, HEX);
286 Serial.print(F(
"\n LTC2933_BACKUP_WORD: "));
287 Serial.println(res, HEX);
290 Serial.print(F(
"\n LTC2933_STATUS_WORD: "));
291 Serial.println(res, HEX);
292 Serial.print(F(
"\n"));
321 Serial.println(F(
"\nERROR: LTC2933 is write-protected. Cannot write to registers"));
350 Serial.println(F(
"\nERROR: LTC2933 is write-protected. Cannot write to registers"));
365 uint8_t *
data = (uint8_t *)malloc(3*
sizeof(uint8_t));
366 uint8_t cmd, ch_addr;
372 if ((channel < 8) && (channel >= 0))
374 ch_addr = (uint8_t)channel;
382 data[0] = cmd | ch_addr;
384 if ((voltage > 0) && (voltage < 4.096))
387 v_data = (uint16_t)(v*4096);
391 Serial.println(F(
"\nERROR: Voltage out of DAC range"));
393 data[1] = (uint8_t)(v_data >> 4);
394 data[2] = (uint8_t)(v_data << 4);
397 Wire.beginTransmission(dac_address);
401 Wire.endTransmission(1);
#define LTC2933_HISTORY_WORD
static void ltc2933_demo_board_demo_thresholds(uint8_t ltc2933_i2c_address)
Load different voltage threshold settings into RAM.
unsigned char user_command
#define LTC2933_CLEAR_HISTORY
#define LTC2933_V4_CONFIG
static void print_prompt()
Prints main menu.
Header File for Linduino Libraries and Demo Code.
static void dc1633_write_dac_voltage(uint8_t dac_address, int channel, float voltage)
program the DAC on the DC1633B demo board to a voltage
static void setup()
Initialize Linduino.
static uint8_t dc1633_dac_address
#define LTC2933_V1_CONFIG
static uint8_t channel
LTC2305 Channel selection.
Header for LTC2933: Programable Hex Voltage Supervisor with EEPROM.
static void ltc2933_read_registers(uint8_t ltc2933_i2c_address)
Read all registers from RAM.
virtual void writeWord(uint8_t address, uint8_t command, uint16_t data)=0
SMBus write word command.
#define LTC2933_V2_CONFIG
union LT_union_int32_4bytes data
#define LTC2933_STATUS_WORD
#define LTC2933_V6_CONFIG
static void loop()
Repeats Linduino loop.
#define LTC2933_GPIO2_3_CONFIG
LT_I2CBus: Routines to communicate to I2C by Wire Library.
#define LTC2933_V5_CONFIG
#define LTC2933_WRITE_PROTECT
#define LTC2933_I2C_ADDRESS
static void print_title()
Prints the title block when program first starts.
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
static void ltc2933_demo_board_defaults(uint8_t ltc2933_i2c_address)
Load demo-board default settings into RAM.
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
#define DC1633_DAC_ADDRESS
LTC SMBus Support: Implementation for a shared SMBus layer.
static void ltc2933_clear_alertb(uint8_t ltc2933_i2c_address)
Clear ALERTB.
#define LTC2933_GPIO1_CONFIG
#define LTC2933_BACKUP_WORD
#define LTC2933_V3_CONFIG
#define LTC2933_GPI_CONFIG
static int ltc2933_is_write_protected(uint8_t ltc2933_i2c_address)
Return 1 if the LTC2933 is write-protected.
virtual uint16_t readWord(uint8_t address, uint8_t command)=0
SMBus read word command.
static uint8_t ltc2933_i2c_address