lib for working with ltc2991s

Dependents:   ece495_firmware

Fork of ltc2991_test by Logan Rooper

Committer:
bdk9
Date:
Thu Jan 19 02:55:42 2017 +0000
Revision:
8:c0ae66611a12
Parent:
0:1473318f27b6
Final Code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lrdawg99 0:1473318f27b6 1 //! @todo Review this file.
lrdawg99 0:1473318f27b6 2 /*
lrdawg99 0:1473318f27b6 3 Linduino.h
lrdawg99 0:1473318f27b6 4
lrdawg99 0:1473318f27b6 5 This file contains the hardware definitions for the Linduino.
lrdawg99 0:1473318f27b6 6
lrdawg99 0:1473318f27b6 7 REVISION HISTORY
lrdawg99 0:1473318f27b6 8 $Revision: 4637 $
lrdawg99 0:1473318f27b6 9 $Date: 2016-01-29 10:04:59 -0800 (Fri, 29 Jan 2016) $
lrdawg99 0:1473318f27b6 10
lrdawg99 0:1473318f27b6 11 Copyright (c) 2013, Linear Technology Corp.(LTC)
lrdawg99 0:1473318f27b6 12 All rights reserved.
lrdawg99 0:1473318f27b6 13
lrdawg99 0:1473318f27b6 14 Redistribution and use in source and binary forms, with or without
lrdawg99 0:1473318f27b6 15 modification, are permitted provided that the following conditions are met:
lrdawg99 0:1473318f27b6 16
lrdawg99 0:1473318f27b6 17 1. Redistributions of source code must retain the above copyright notice, this
lrdawg99 0:1473318f27b6 18 list of conditions and the following disclaimer.
lrdawg99 0:1473318f27b6 19 2. Redistributions in binary form must reproduce the above copyright notice,
lrdawg99 0:1473318f27b6 20 this list of conditions and the following disclaimer in the documentation
lrdawg99 0:1473318f27b6 21 and/or other materials provided with the distribution.
lrdawg99 0:1473318f27b6 22
lrdawg99 0:1473318f27b6 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
lrdawg99 0:1473318f27b6 24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
lrdawg99 0:1473318f27b6 25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lrdawg99 0:1473318f27b6 26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
lrdawg99 0:1473318f27b6 27 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
lrdawg99 0:1473318f27b6 28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
lrdawg99 0:1473318f27b6 29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
lrdawg99 0:1473318f27b6 30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
lrdawg99 0:1473318f27b6 31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
lrdawg99 0:1473318f27b6 32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lrdawg99 0:1473318f27b6 33
lrdawg99 0:1473318f27b6 34 The views and conclusions contained in the software and documentation are those
lrdawg99 0:1473318f27b6 35 of the authors and should not be interpreted as representing official policies,
lrdawg99 0:1473318f27b6 36 either expressed or implied, of Linear Technology Corp.
lrdawg99 0:1473318f27b6 37
lrdawg99 0:1473318f27b6 38 The Linear Technology Linduino is not affiliated with the official Arduino team.
lrdawg99 0:1473318f27b6 39 However, the Linduino is only possible because of the Arduino team's commitment
lrdawg99 0:1473318f27b6 40 to the open-source community. Please, visit http://www.arduino.cc and
lrdawg99 0:1473318f27b6 41 http://store.arduino.cc , and consider a purchase that will help fund their
lrdawg99 0:1473318f27b6 42 ongoing work.
lrdawg99 0:1473318f27b6 43 */
lrdawg99 0:1473318f27b6 44
lrdawg99 0:1473318f27b6 45 //! @defgroup Linduino Linduino: Linear Technology Arduino-Compatible Demonstration Board
lrdawg99 0:1473318f27b6 46
lrdawg99 0:1473318f27b6 47 /*! @file
lrdawg99 0:1473318f27b6 48 @ingroup Linduino
lrdawg99 0:1473318f27b6 49 @ingroup QuikEval
lrdawg99 0:1473318f27b6 50 Header File for Linduino Libraries and Demo Code
lrdawg99 0:1473318f27b6 51 */
lrdawg99 0:1473318f27b6 52
lrdawg99 0:1473318f27b6 53 #ifndef LINDUINO_H
lrdawg99 0:1473318f27b6 54 #define LINDUINO_H
lrdawg99 0:1473318f27b6 55
lrdawg99 0:1473318f27b6 56 //#include <Arduino.h> // typedefs use types defined in this header file.
lrdawg99 0:1473318f27b6 57
lrdawg99 0:1473318f27b6 58 //! @name LINDUINO PIN ASSIGNMENTS
lrdawg99 0:1473318f27b6 59 //! @{
lrdawg99 0:1473318f27b6 60
lrdawg99 0:1473318f27b6 61 #define QUIKEVAL_GPIO 9 //!< Linduino QuikEval GPIO pin (QuikEval connector pin 14) connects to Arduino pin 9
lrdawg99 0:1473318f27b6 62 #define QUIKEVAL_CS SS //!< QuikEval CS pin (SPI chip select on QuikEval connector pin 6) connects to Arduino SS pin.
lrdawg99 0:1473318f27b6 63 #define QUIKEVAL_MUX_MODE_PIN 8 /*!< QUIKEVAL_MUX_MODE_PIN defines the control pin for the QuikEval MUX.
lrdawg99 0:1473318f27b6 64 The I2C port's SCL and the SPI port's SCK signals share the same pin on the Linduino's QuikEval connector.
lrdawg99 0:1473318f27b6 65 Additionally, the I2C port's SDA and the SPI port's MOSI signals share the same pin on the Linduino's QuikEval connector.
lrdawg99 0:1473318f27b6 66 The pair of pins connected to the QuikEval connector is switched using a MUX on the Linduino board.
lrdawg99 0:1473318f27b6 67 The control pin to switch the MUX is defined as QUIKEVAL_MUX_MODE_PIN (Arduino pin 8). */
lrdawg99 0:1473318f27b6 68 //! @}
lrdawg99 0:1473318f27b6 69
lrdawg99 0:1473318f27b6 70 // Macros
lrdawg99 0:1473318f27b6 71 //! Set "pin" low
lrdawg99 0:1473318f27b6 72 //! @param pin pin to be driven LOW
lrdawg99 0:1473318f27b6 73 #define output_low(pin) digitalWrite(pin, LOW)
lrdawg99 0:1473318f27b6 74 //! Set "pin" high
lrdawg99 0:1473318f27b6 75 //! @param pin pin to be driven HIGH
lrdawg99 0:1473318f27b6 76 #define output_high(pin) digitalWrite(pin, HIGH)
lrdawg99 0:1473318f27b6 77 //! Return the state of pin "pin"
lrdawg99 0:1473318f27b6 78 //! @param pin pin to be read (HIGH or LOW).
lrdawg99 0:1473318f27b6 79 //! @return the state of pin "pin"
lrdawg99 0:1473318f27b6 80 #define input(pin) digitalRead(pin)
lrdawg99 0:1473318f27b6 81
lrdawg99 0:1473318f27b6 82 //! @name ENDIAN DEPENDENT BYTE INDEXES
lrdawg99 0:1473318f27b6 83 //! @{
lrdawg99 0:1473318f27b6 84 //! Arduino/Linduino is a Little Endian Device, where the least significant byte is stored in the first byte of larger data types.
lrdawg99 0:1473318f27b6 85 #ifdef BIG_ENDIAN
lrdawg99 0:1473318f27b6 86 #define LSB 1 //!< Location of Least Signficant Byte when Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 87 #define MSB 0 //!< Location of Most Signficant Byte when Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 88 #define LSW 1 //!< Location of Least Signficant Word when Long Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 89 #define MSW 0 //!< Location of most Signficant Word when Long Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 90 #else
lrdawg99 0:1473318f27b6 91 #define LSB 0 //!< Location of Least Signficant Byte when Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 92 #define MSB 1 //!< Location of Most Signficant Byte when Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 93 #define LSW 0 //!< Location of Least Signficant Word when Long Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 94 #define MSW 1 //!< Location of most Signficant Word when Long Word is accessed as Byte Array
lrdawg99 0:1473318f27b6 95 #endif
lrdawg99 0:1473318f27b6 96 //! @}
lrdawg99 0:1473318f27b6 97
lrdawg99 0:1473318f27b6 98 //! This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer)
lrdawg99 0:1473318f27b6 99 //! into two uint8_t's (8-bit unsigned integers) and vice versa.
lrdawg99 0:1473318f27b6 100 union LT_union_int16_2bytes
lrdawg99 0:1473318f27b6 101 {
lrdawg99 0:1473318f27b6 102 int16_t LT_int16; //!< 16-bit signed integer to be converted to two bytes
lrdawg99 0:1473318f27b6 103 uint16_t LT_uint16; //!< 16-bit unsigned integer to be converted to two bytes
lrdawg99 0:1473318f27b6 104 uint8_t LT_byte[2]; //!< 2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer
lrdawg99 0:1473318f27b6 105 };
lrdawg99 0:1473318f27b6 106
lrdawg99 0:1473318f27b6 107 //! This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer)
lrdawg99 0:1473318f27b6 108 //! four uint8_t's (8-bit unsigned integers) and vice versa.
lrdawg99 0:1473318f27b6 109 union LT_union_int32_4bytes
lrdawg99 0:1473318f27b6 110 {
lrdawg99 0:1473318f27b6 111 int32_t LT_int32; //!< 32-bit signed integer to be converted to four bytes
lrdawg99 0:1473318f27b6 112 uint32_t LT_uint32; //!< 32-bit unsigned integer to be converted to four bytes
lrdawg99 0:1473318f27b6 113 uint8_t LT_byte[4]; //!< 4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer
lrdawg99 0:1473318f27b6 114 };
lrdawg99 0:1473318f27b6 115
lrdawg99 0:1473318f27b6 116 //! This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer)
lrdawg99 0:1473318f27b6 117 //! into two uint16_t's (16-bit unsigned integers) and vice versa.
lrdawg99 0:1473318f27b6 118 union LT_union_uint32_2uint16s
lrdawg99 0:1473318f27b6 119 {
lrdawg99 0:1473318f27b6 120 int32_t LT_int32; //!< 32-bit signed integer to be converted to four bytes
lrdawg99 0:1473318f27b6 121 uint32_t LT_uint32; //!< 32-bit unsigned integer to be converted to four bytes
lrdawg99 0:1473318f27b6 122 uint16_t LT_uint16[2]; //!< 2 words (unsigned 16-bit integers) to be converted to a 32-bit signed or unsigned integer
lrdawg99 0:1473318f27b6 123 };
lrdawg99 0:1473318f27b6 124
lrdawg99 0:1473318f27b6 125 //! This union splits one float into four uint8_t's (8-bit unsigned integers) and vice versa.
lrdawg99 0:1473318f27b6 126 union LT_union_float_4bytes
lrdawg99 0:1473318f27b6 127 {
lrdawg99 0:1473318f27b6 128 float LT_float; //!< float to be converted to four bytes
lrdawg99 0:1473318f27b6 129 uint8_t LT_byte[4]; //!< 4 bytes (unsigned 8-bit integers) to be converted to a float
lrdawg99 0:1473318f27b6 130 };
lrdawg99 0:1473318f27b6 131
lrdawg99 0:1473318f27b6 132
lrdawg99 0:1473318f27b6 133 #endif // LINDUINO_H