65 #define DC1605_DAC_ADDRESS 0x22 //7-bit global address for DAC 68 #define LTC2936_I2C_ADDRESS 0x58 // 10 96 uint8_t *addresses = NULL;
99 if (Serial.available())
102 Serial.println(user_command);
104 switch (user_command)
125 Serial.println(res, HEX);
178 addresses = smbus->
probe(0);
179 while (*addresses != 0)
181 Serial.print(F(
"ADDR 0x"));
182 Serial.println(*addresses++, HEX);
186 Serial.println(F(
"Incorrect Option"));
198 Serial.print(F(
"\n*****************************************************************\n"));
199 Serial.print(F(
"* DC1605B Demonstration Program *\n"));
200 Serial.print(F(
"* *\n"));
201 Serial.print(F(
"* This program demonstrates how to send and receive data from *\n"));
202 Serial.print(F(
"* the DC1605B demo board. *\n"));
203 Serial.print(F(
"* *\n"));
204 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator.*\n"));
205 Serial.print(F(
"* *\n"));
206 Serial.print(F(
"*****************************************************************\n"));
212 Serial.print(F(
" 1-Write LTC2936 registers with default settings\n"));
213 Serial.print(F(
" 2-Read Status (STATUS_WORD)\n"));
214 Serial.print(F(
" 3-Read All Registers\n"));
215 Serial.print(F(
" 4-Set DAC voltages on Vn pins to interesting values\n"));
216 Serial.print(F(
" 5-Change LTC2936 voltage thresholds to match interesting DAC voltages\n"));
217 Serial.print(F(
" 6-Set DAC voltages on Vn pins to +20% high values\n"));
218 Serial.print(F(
" 7-Clear LTC2936 ALERTB\n"));
219 Serial.print(F(
" 8-Bus Probe\n"));
220 Serial.print(F(
"\nEnter a command:"));
226 Serial.println(F(
"\nWarning: Demo board not detected. Linduino will attempt to proceed."));
239 return ((res&0x0001) == 0x0001) ? 1 : 0;
246 if ((ltc2936_i2c_address >= 0x50) && (ltc2936_i2c_address <= 0x57))
255 Serial.println(F(
"\nWARNING: Linduino should not be used to address address 0x5n."));
256 Serial.println(F(
"WARNING: Addresses 0x5n are shared by the DC1605B EEPROM."));
257 Serial.println(F(
"WARNING: When using Linduino, set ASEL1 jumper = 1"));
265 Serial.print(F(
"\n LTC2936_WRITE_PROTECT:"));
266 Serial.println(res, HEX);
269 Serial.print(F(
"\n LTC2936_GPI_CONFIG: "));
270 Serial.println(res, HEX);
273 Serial.print(F(
"\n LTC2936_GPIO1_CONFIG: "));
274 Serial.println(res, HEX);
277 Serial.print(F(
"\n LTC2936_GPIO2_3_CONFIG: "));
278 Serial.println(res, HEX);
281 Serial.print(F(
"\n LTC2936_V1_THR: "));
282 Serial.println(res, HEX);
285 Serial.print(F(
"\n LTC2936_V2_THR: "));
286 Serial.println(res, HEX);
289 Serial.print(F(
"\n LTC2936_V3_THR: "));
290 Serial.println(res, HEX);
293 Serial.print(F(
"\n LTC2936_V4_THR: "));
294 Serial.println(res, HEX);
297 Serial.print(F(
"\n LTC2936_V5_THR: "));
298 Serial.println(res, HEX);
301 Serial.print(F(
"\n LTC2936_V6_THR: "));
302 Serial.println(res, HEX);
305 Serial.print(F(
"\n LTC2936_V1_CONFIG: "));
306 Serial.println(res, HEX);
309 Serial.print(F(
"\n LTC2936_V2_CONFIG: "));
310 Serial.println(res, HEX);
313 Serial.print(F(
"\n LTC2936_V3_CONFIG: "));
314 Serial.println(res, HEX);
317 Serial.print(F(
"\n LTC2936_V4_CONFIG: "));
318 Serial.println(res, HEX);
321 Serial.print(F(
"\n LTC2936_V5_CONFIG: "));
322 Serial.println(res, HEX);
325 Serial.print(F(
"\n LTC2936_V6_CONFIG: "));
326 Serial.println(res, HEX);
329 Serial.print(F(
"\n LTC2936_HISTORY_WORD: "));
330 Serial.println(res, HEX);
333 Serial.print(F(
"\n LTC2936_PADS: "));
334 Serial.println(res, HEX);
337 Serial.print(F(
"\n LTC2936_BACKUP_WORD: "));
338 Serial.println(res, HEX);
341 Serial.print(F(
"\n LTC2936_STATUS_WORD: "));
342 Serial.println(res, HEX);
343 Serial.print(F(
"\n"));
387 Serial.println(F(
"\nERROR: LTC2936 is write-protected. Cannot write to registers"));
431 Serial.println(F(
"\nERROR: LTC2936 is write-protected. Cannot write to registers"));
448 uint8_t *
data = (uint8_t *)malloc(3*
sizeof(uint8_t));
449 uint8_t cmd, ch_addr;
455 if ((channel < 8) && (channel >= 0))
457 ch_addr = (uint8_t)channel;
465 data[0] = cmd | ch_addr;
467 if ((voltage > 0) && (voltage < 4.096))
470 v_data = (uint16_t)(v*4096);
474 Serial.println(F(
"\nERROR: Voltage out of DAC range"));
476 data[1] = (uint8_t)(v_data >> 4);
477 data[2] = (uint8_t)(v_data << 4);
480 Wire.beginTransmission(dac_address);
485 Wire.endTransmission(1);
#define LTC2936_V2_CONFIG
static uint8_t dc1605_dac_address
static void loop()
Repeats Linduino loop.
unsigned char user_command
#define LTC2936_CLEAR_HISTORY
static int dc1605b_is_address_0x5n(uint8_t ltc2936_i2c_address)
Return 1 if the ltc2936 device address is 0x50 - 0x57 which are the DC1605B EEPROM address...
static void setup()
Initialize Linduino.
#define DC1605_DAC_ADDRESS
Header File for Linduino Libraries and Demo Code.
virtual void sendByte(uint8_t address, uint8_t command)=0
SMBus send byte command.
static uint8_t ltc2936_i2c_address
#define LTC2936_V3_CONFIG
#define LTC2936_GPIO2_3_CONFIG
static void ltc2936_read_registers(uint8_t ltc2936_i2c_address)
Read all registers from RAM.
static uint8_t channel
LTC2305 Channel selection.
static void ltc2936_demo_board_defaults(uint8_t ltc2936_i2c_address)
Load demo-board default settings into RAM.
virtual void writeWord(uint8_t address, uint8_t command, uint16_t data)=0
SMBus write word command.
Header for LTC2936: Programable Hex Voltage Supervisor with Comparator Outputs and EEPROM...
union LT_union_int32_4bytes data
#define LTC2936_I2C_ADDRESS
LT_I2CBus: Routines to communicate to I2C by Wire Library.
#define LTC2936_V1_CONFIG
#define LTC2936_V5_CONFIG
#define LTC2936_V6_CONFIG
static void print_prompt()
Prints main menu.
#define LTC2936_BACKUP_WORD
#define LTC2936_STATUS_WORD
static void dc1605b_print_address_warning()
Print a warning message to go with the 0x5n address.
static void ltc2936_clear_alertb(uint8_t ltc2936_i2c_address)
Clear ALERTB.
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
LTC SMBus Support: Implementation for a shared SMBus layer.
static void dc1605_write_dac_voltage(uint8_t dac_address, int channel, float voltage)
program the DAC on the DC1605B demo board to a voltage
#define LTC2936_V4_CONFIG
static int ltc2936_is_write_protected(uint8_t ltc2936_i2c_address)
Return 1 if the LTC2936 is write-protected.
#define LTC2936_HISTORY_WORD
static void print_title()
Prints the title block when program first starts.
static void ltc2936_demo_board_demo_thresholds(uint8_t ltc2936_i2c_address)
Load different voltage threshold settings into RAM.
#define LTC2936_WRITE_PROTECT
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
#define LTC2936_GPIO1_CONFIG
virtual uint16_t readWord(uint8_t address, uint8_t command)=0
SMBus read word command.
#define LTC2936_GPI_CONFIG