115 Serial.begin(115200);
143 if (Serial.available())
148 Serial.println(user_command);
150 switch (user_command)
209 Serial.println(
"Incorrect Option");
214 Serial.println(
"*************************");
225 uint8_t port, value = 0;
227 Serial.println(F(
"Select CQ output (1,2,3,4, 5=ALL)"));
231 Serial.println(
"All");
235 Serial.println(port);
238 if ((port < 1) || (port > 5))
240 Serial.println(F(
"Selection out of range"));
244 Serial.println(F(
"Select 1 to Enable or 0 to Disable"));
246 Serial.println(value);
248 if ((value < 0) || (value > 1))
250 Serial.println(F(
"Selection out of range"));
256 Serial.print(F(
"CQ output"));
259 Serial.print(
"s are ");
265 Serial.print(F(
" is "));
267 Serial.println(value);
275 uint8_t port, value = 0;
277 Serial.println(F(
"Select L+ output (1,2,3,4, 5=ALL)"));
281 Serial.println(
"All");
285 Serial.println(port);
288 if ((port < 1) || (port > 5))
290 Serial.println(F(
"Selection out of range"));
294 Serial.println(F(
"Select 1 to Enable or 0 to Disable"));
296 Serial.println(value);
298 if ((value < 0) || (value > 1))
300 Serial.println(F(
"Selection out of range"));
306 Serial.print(F(
"L+ output"));
309 Serial.print(
"s are ");
315 Serial.print(F(
" is "));
317 Serial.println(value);
325 uint8_t
data, port = 0;
327 Serial.println(F(
"Generate Wakeup for CQ output (1,2,3,4)"));
329 Serial.println(port);
331 if ((port < 1) || (port > 4))
333 Serial.println(F(
"Selection out of range"));
337 Serial.print(
"Wake-Up Request generated for CQ");
347 Serial.println(F(
"Enable (1) or Disable (0) 24V Mode"));
350 if ((value < 0) || (value > 1))
352 Serial.println(F(
"Selection out of range"));
357 Serial.print(F(
"24VMODE = "));
358 Serial.println(value);
368 Serial.println(F(
"Enable SIO mode for CQ output (1,2,3,4, 5=ALL)"));
372 Serial.println(
"All");
376 Serial.println(port);
379 if ((port < 1) || (port > 5))
381 Serial.println(F(
"Selection out of range"));
384 Serial.print(F(
"SIO mode set for "));
391 Serial.print(
"port ");
402 uint8_t port, value = 0;
404 Serial.println(F(
"Select port for ILLM (1,2,3,4, 5=All)"));
407 if ((port < 1) || (port > 5))
409 Serial.println(F(
"Selection out of range"));
414 Serial.println(
"All");
418 Serial.println(port);
421 Serial.println(F(
"Enter value to write (0x0-0x3); use Hex 0xn format."));
424 Serial.println(value, HEX);
426 if ((value < 0x0) || (value > 0x3))
428 Serial.println(F(
"Value out of range"));
442 Serial.println(F(
"Event registers cleared"));
453 Serial.println(F(
"All registers updated"));
463 Serial.println(F(
"LTC2874 has been reset"));
475 Serial.println(F(
"Select Register to be read (0x0-0xE); use Hex 0xn format."));
477 if ((address > 0xE ) || (address < 0x0))
479 Serial.println(
"No registers in this range");
485 Serial.print(
"Register 0x");
486 Serial.print(address, HEX);
487 Serial.print(
" reads 0x");
488 Serial.println (data, HEX);
505 Serial.print(
"Selected Register is 0x");
506 Serial.println(address, HEX);
508 Serial.println(F(
"Enter data to load in register; use Hex 0xnn format."));
511 Serial.print(
"Data loaded is 0x");
512 Serial.println(data, HEX);
525 Serial.println(F(
"Select Register that contains bit to read (0x0-0xE); use Hex 0xn format."));
529 if ((address > 0xE ) || (address < 0x0))
531 Serial.println(
"No registers in this range");
535 Serial.print(
"Selected Register is 0x");
536 Serial.println(address, HEX);
538 Serial.println(F(
"Enter bit position (0-7) for bit to read"));
540 Serial.print(
"Bit position ");
542 value = 0x01 << value;
546 Serial.println(value);
563 Serial.print(
"Selected Register is 0x");
564 Serial.println(address, HEX);
566 Serial.println(F(
"Enter bit position (0-7) to Set"));
569 Serial.print(
"Bit position ");
573 Serial.print(
" has been Set");
590 Serial.print(
"Selected Register is 0x");
591 Serial.println(address, HEX);
593 Serial.println(F(
"Enter bit position (0-7) to Clear"));
596 Serial.print(
"Bit position ");
600 Serial.print(
" has been Cleared");
609 Serial.println(
"*****************************************************************");
610 Serial.println(
"* DC1880A Demonstration Program *");
611 Serial.println(
"* *");
612 Serial.println(
"* This program demonstrates communication with the LTC2874 *");
613 Serial.println(
"* Quad IO-Link Master Hot Swap Controller and PHY *");
614 Serial.println(
"* *");
615 Serial.println(
"* *");
616 Serial.println(
"* *");
617 Serial.println(
"* Set the baud rate to 115200 select the newline terminator. *");
618 Serial.println(
"*****************************************************************");
626 Serial.println(
"\nLTC2874 Demo Menu:");
628 Serial.println(
" 1-CQ Output Enable/Disable");
629 Serial.println(
" 2-L+ Output Enable/Disable");
630 Serial.println(
" 3-Generate Wake-Up Request (WURQ)");
631 Serial.println(
" 4-24V IO-Link Mode");
632 Serial.println(
" 5-SIO Mode");
633 Serial.println(
" 6-Select ILLM Sinking Current");
634 Serial.println(
" 7-Clear Event Registers");
635 Serial.println(
" 8-Update All");
636 Serial.println(
" 9-Reset");
637 Serial.println(
" 10-Read Register");
638 Serial.println(
" 11-Write Register");
639 Serial.println(
" 12-Read Bit");
640 Serial.println(
" 13-Set Bit");
641 Serial.println(
" 14-Clear Bit");
645 Serial.print(
"Enter a command: ");
655 Serial.println(F(
"Select Register to write to; use Hex 0xn format."));
656 Serial.println(F(
"NOTE: 0x0,0x6 and 0x7 are read only."));
660 if ((address > 0xF ) || (address < 0x0))
662 Serial.println(
"Error: Invalid register");
665 else if (address == 0)
667 Serial.println(
"Error: Register 0x0 is read only");
670 else if (address == 5)
672 Serial.println(
"Error: Only lower nibble of 0x5 is writable");
674 else if (address == 6)
676 Serial.println(
"Error: Register 0x6 is read only");
679 else if (address == 7)
681 Serial.println(
"Error: Register 0x7 is read only");
693 Serial.println(F(
"No demo board connected."));
694 Serial.println(F(
"However, the Linduino will attempt to proceed..."));
static uint8_t reg_test()
Test register number against valid range for Write.
static void menu_1_cq()
Menu 1: Enable/Disable CQ output for specified port.
unsigned char user_command
static void menu_11_write_register()
Menu 11: Write byte of data to a register.
#define LTC2874_EVENT4_REG5
void LTC2874_lplus_output(uint8_t port, uint8_t value)
Enables or Disables L+ output for specified port, then Updates.
void LTC2874_sio_mode(uint8_t port)
Sets SIO_MODE bit (and also Clears SLEW bit) for specified port, then Updates.
#define output_high(pin)
Set "pin" high.
static void menu_2_lplus()
Menu 2: Enable/Disable L+ output for specified port.
Header File for Linduino Libraries and Demo Code.
static void loop()
Repeats Linduino loop.
static void menu_4_24v_mode()
Menu 4: Change value of 24VMODE bit.
LTC2874: Quad IO-Link Master Hot Swap Power Controller and PHY.
static void menu_3_wakeup_cq()
Menu 3: Generate Wake-Up Request (WURQ) on CQ output.
static void print_warning_prompt()
Print warning prompt.
union LT_union_int32_4bytes data
static void menu_6_set_illm()
Menu 6: Change ILLM setting for specified port.
void LTC2874_write_register(uint8_t LTC2874_register, uint8_t LTC2874_data)
Writes byte of data to a register without Updating.
static void menu_10_read_register()
Menu 10: Read byte of data from a register.
void LTC2874_cq_output(uint8_t port, uint8_t value)
Enables or Disables CQ output for specified port, then Updates.
#define LTC2874_EVENT2_REG3
static void menu_14_write_bit_clr()
Menu 14: Clear one bit in writable register.
void LTC2874_write_ILLM_value(uint8_t port, uint8_t value)
Changes ILLM (Sinking current) setting for specified port without Updating.
static void menu_12_read_bit()
Menu 12: Read one bit from a register.
static void print_title()
Print the title block.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
static void setup()
Initialize Linduino.
void LTC2874_reset(void)
Resets LTC2874, returning default values to registers.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC2874_EVENT3_REG4
uint8_t LTC2874_read_bit(uint8_t LTC2874_register, uint8_t LTC2874_bit)
Reads a data BIT from specified register.
static void menu_5_sio_mode()
Menu 5: Change SIO_MODE setting for specified port.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void menu_9_reset()
Menu 9: Reset LTC2874.
void LTC2874_wakeup_request(uint8_t port)
Sends WURQ (Wake-up Request) on specified port.
#define LTC2874_EVENT1_REG2
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static void print_prompt()
Print main menu and prompt user for an input command.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
void LTC2874_write_bit_clr_update_all(uint8_t LTC2874_register, uint8_t LTC2874_bit)
Clears a register bit, then Updates.
void LTC2874_update_all(void)
Updates all registers.
void LTC2874_write_register_update_all(uint8_t LTC2874_register, uint8_t LTC2874_data)
Writes byte of data to a register, then Updates.
void LTC2874_24v_mode(uint8_t value)
Changes value of the 24VMODE bit, then Updates.
void LTC2874_write_bit_set_update_all(uint8_t LTC2874_register, uint8_t LTC2874_bit)
Sets a register bit, then Updates.
uint8_t LTC2874_read_reg(uint8_t LTC2874_register)
Reads data byte from specified register.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static void menu_13_write_bit_set()
Menu 13: Set one bit in writable register.
static void menu_7_clear_event()
Menu 7: Clear all Event registers.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
static void menu_8_update_all()
Menu 8: Update all registers.