| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Macros | Variables
DC590_subset.ino File Reference

Go to the source code of this file.

## Functions
static void | EnqueueSerialData ()
| Enqueue serial data. More...
char | DequeueChar ()
| Dequeue character. More...
char | get_char ()
| Gets the character. More...
boolean | CheckSerialData ()
| Determines if serial data is available and stores data in the queue. More...
boolean | DelayAndCheckSerialData (unsigned long ms)
| Delay and check serial data. More...
static void | byte_to_hex (byte value)
| convert a Byte to two hexadecimal characters. More...
byte | read_hex ()
| Reads hexadecimal value from serial port read 2 hex characters from the serial buffer and convert them to a byte. More...
boolean | tinyDC590B (char command)
| process commands received via serial interface. More...

## Macros
#define | MISO_TIMEOUT 1000
#define | QUEUE_ELEMENTS 250
| max elements in the queue More...
#define | QUEUE_SIZE (QUEUE_ELEMENTS + 1)
| queue size. More...

## Variables
unsigned char | pseudo_reset = 0
const byte | spi_mode = 0
const byte | i2c_mode = 1
const byte | i2c_auxiliary_mode = 2
byte | serial_mode = spi_mode
boolean | dc590Busy = false
| DC590 busy flag. More...
char | hex_digits [16]
| hex conversion constants More...
char | hex_to_byte_buffer [5]
| buffer for ASCII hex to byte conversion More...
char | byte_to_hex_buffer [3]
| buffer for byte to ASCII hex conversion More...
static uint8_t | Queue [QUEUE_SIZE]
| The queue. More...
static uint8_t | QueueIn = 0
| The queue in element. More...
static uint8_t | QueueOut = 0
| The queue out element. More...

## Function Documentation

## ◆ byte_to_hex()

void byte_to_hex | ( | byte | value | ) |
| static

convert a Byte to two hexadecimal characters.

Result stored to byte_to_hex_buffer

Parameters

  value | byte to be converted

Definition at line 228 of file DC590_subset.ino.

## ◆ CheckSerialData()

boolean CheckSerialData | ( |  | ) |

Determines if serial data is available and stores data in the queue.

Returns
  true if new data is available

Definition at line 200 of file DC590_subset.ino.

## ◆ DelayAndCheckSerialData()

boolean DelayAndCheckSerialData | ( | unsigned long | ms | ) |

Delay and check serial data.

(while delaying we periodically check for new serial data and store the data)

Parameters

  ms | delay in milliseconds.

Returns
  true if new serial data is available

Definition at line 212 of file DC590_subset.ino.

## ◆ DequeueChar()

char DequeueChar | ( |  | ) |

Dequeue character.

Returns
  A char.

Definition at line 180 of file DC590_subset.ino.

## ◆ EnqueueSerialData()

void EnqueueSerialData | ( |  | ) |
| static

Enqueue serial data.

Definition at line 153 of file DC590_subset.ino.

## ◆ get_char()

char get_char | ( | void |  | ) |

Gets the character.

get the next character either from the serial port or the internal queue

Returns
  The character.

Read a command from the serial port

Returns
  char

Definition at line 191 of file DC590_subset.ino.

## ◆ read_hex()

char read_hex | ( | void |  | ) |

Reads hexadecimal value from serial port read 2 hex characters from the serial buffer and convert them to a byte.

Returns
  the hexadecimal value as a byte.

Read 2 hex characters from the serial buffer and convert them to a byte

Returns
  char data Read Data

Definition at line 240 of file DC590_subset.ino.

## ◆ tinyDC590B()

boolean tinyDC590B | ( | char | command | ) |

process commands received via serial interface.

Those are the m,l commands and the basic DC590B commands used for DC590B compatibility mode that allows the GUI to communicate with this sketch. (basic set of DC590 commands to allow I2C communication to the LTC2947)

Parameters

  command | the command to be decoded

Returns
  true if command was recognized and decoded, false for unknown command

Definition at line 255 of file DC590_subset.ino.

## Macro Definition Documentation

## ◆ MISO_TIMEOUT

#define MISO_TIMEOUT 1000

    tinyDC590 is used to give basic DC590B compatibility to e.g. DC2574A_KIT sketch so
    it can also be operated together with the LTC2947 GUI

    DC590B compatibility:
    tinyDC590 provides a subset of the DC590B commands.
    This way the e.g. the LTC2947 GUI is also able to communicate with the DC2574A_KIT sketch which enables the
    user to use the GUI to change LTC2947 configuration e.g. to set alarm thresholds etc.
    The main limitations of this compatibility mode are:
    - EEPROM read from the DC2334A demo board is faked (it will always report the right EEPROM string)
    - SPI operation is not supported, due to incompatibility with the optional LCD Keypad Shield

    Command  Function                          Notes
    Q        Receive Byte *                    I2C only, send ACK
    R        Receive Byte *                    I2C only, sends NACK
    Sxx      Send byte (2 hex chars) *         SPI and I2C. Returns ‘N’ if slave NACKs.
    s        Send start condition              I2C only
    p        Send stop condition               I2C only
    Z        Send line feed to host (0x0A)
    I        Read demo board info.
    i        Read contoller ID and firmware rev
    O        Turn isolated power on
    o        Turn isolated power off
    MI       Switch to isolated I2C mode
    Kxy      Bang pin, x argument is ‘0’ or ‘1’ for low or high, y is pin address, see below.
    jxy      Set pin mode, x argument is ‘0’ or ‘1’ for INPUT or OUTPUT, y is pin address, see below.
    ky       Read pin, answer is ‘0’ or ‘1’ for low or high, y is pin address, see below.
    Uxxy     Write Port D bus, xx is ASCII Hex data, y is strobe pin address, strobed low.
    D         Delay milliseconds
    P         PingPause (echo P, wait 5 ms)
    g         IO pin low
    G         IO pin high
    H         Wait for SDO=1                  (SPI only) ‘T’ on timeout
    L         Wait for SDO=0                  (SPI only) ‘T’ on timeout
    0x80      DC590B pseudo Reset

    the following DC590B commands are NOT implemented:
    r         Receive 7 bits                  In SPI mode only.
    t         Begin recording loop
    u         Stop recording loop
    v         Echo loop
    Txx       Tranceive (send and receive) *  (SPI only)
    w         Loop until another command rec’d
    X         CS=1
    x         CS=0
    MS        Switch to isolated SPI mode
    MX        Switch to auxillary I2C mode

Copyright 2018(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
- Use of the software either in source or binary form, must be run on or directly connected to an Analog Devices Inc. component.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 100 of file DC590_subset.ino.

## ◆ QUEUE_ELEMENTS

#define QUEUE_ELEMENTS 250

max elements in the queue

Definition at line 137 of file DC590_subset.ino.

## ◆ QUEUE_SIZE

#define QUEUE_SIZE (QUEUE_ELEMENTS + 1)

queue size.

Definition at line 140 of file DC590_subset.ino.

## Variable Documentation

## ◆ byte_to_hex_buffer

char byte_to_hex_buffer[3]

Initial value:
=
{
'\0', '\0', '\0'
}

buffer for byte to ASCII hex conversion

Definition at line 126 of file DC590_subset.ino.

## ◆ dc590Busy

boolean dc590Busy = false

DC590 busy flag.

DC590 busy check.

Asserted while DC590B command is processed

Definition at line 110 of file DC590_subset.ino.

## ◆ hex_digits

char hex_digits[16]

Initial value:
=
{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
}

hex conversion constants

Definition at line 113 of file DC590_subset.ino.

## ◆ hex_to_byte_buffer

char hex_to_byte_buffer[5]

Initial value:
=
{
'0', 'x', '0', '0', '\0'
}

buffer for ASCII hex to byte conversion

Definition at line 119 of file DC590_subset.ino.

## ◆ i2c_auxiliary_mode

const byte i2c_auxiliary_mode = 2

Definition at line 106 of file DC590_subset.ino.

## ◆ i2c_mode

const byte i2c_mode = 1

Definition at line 105 of file DC590_subset.ino.

## ◆ pseudo_reset

unsigned char pseudo_reset = 0

Definition at line 102 of file DC590_subset.ino.

## ◆ Queue

uint8_t Queue[QUEUE_SIZE]
| static

The queue.

Definition at line 143 of file DC590_subset.ino.

## ◆ QueueIn

uint8_t QueueIn = 0
| static

The queue in element.

Definition at line 146 of file DC590_subset.ino.

## ◆ QueueOut

uint8_t QueueOut = 0
| static

The queue out element.

Definition at line 149 of file DC590_subset.ino.

## ◆ serial_mode

byte serial_mode = spi_mode

Definition at line 107 of file DC590_subset.ino.

## ◆ spi_mode

const byte spi_mode = 0

Definition at line 104 of file DC590_subset.ino.