Brody Kellish / ltc2991_lib

Dependents:   ece495_firmware

Fork of ltc2991_test by Logan Rooper

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Linduino.h Source File

Linduino.h

Go to the documentation of this file.
00001 //! @todo Review this file.
00002 /*
00003 Linduino.h
00004 
00005 This file contains the hardware definitions for the Linduino.
00006 
00007 REVISION HISTORY
00008 $Revision: 4637 $
00009 $Date: 2016-01-29 10:04:59 -0800 (Fri, 29 Jan 2016) $
00010 
00011 Copyright (c) 2013, Linear Technology Corp.(LTC)
00012 All rights reserved.
00013 
00014 Redistribution and use in source and binary forms, with or without
00015 modification, are permitted provided that the following conditions are met:
00016 
00017 1. Redistributions of source code must retain the above copyright notice, this
00018    list of conditions and the following disclaimer.
00019 2. Redistributions in binary form must reproduce the above copyright notice,
00020    this list of conditions and the following disclaimer in the documentation
00021    and/or other materials provided with the distribution.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00027 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 The views and conclusions contained in the software and documentation are those
00035 of the authors and should not be interpreted as representing official policies,
00036 either expressed or implied, of Linear Technology Corp.
00037 
00038 The Linear Technology Linduino is not affiliated with the official Arduino team.
00039 However, the Linduino is only possible because of the Arduino team's commitment
00040 to the open-source community.  Please, visit http://www.arduino.cc and
00041 http://store.arduino.cc , and consider a purchase that will help fund their
00042 ongoing work.
00043 */
00044 
00045 //! @defgroup Linduino Linduino: Linear Technology Arduino-Compatible Demonstration Board
00046 
00047 /*! @file
00048     @ingroup Linduino
00049     @ingroup QuikEval
00050     Header File for Linduino Libraries and Demo Code
00051 */
00052 
00053 #ifndef LINDUINO_H
00054 #define LINDUINO_H
00055 
00056 //#include <Arduino.h>  // typedefs use types defined in this header file.
00057 
00058 //! @name LINDUINO PIN ASSIGNMENTS
00059 //! @{
00060 
00061 #define QUIKEVAL_GPIO 9          //!< Linduino QuikEval GPIO pin (QuikEval connector pin 14) connects to Arduino pin 9
00062 #define QUIKEVAL_CS SS           //!< QuikEval CS pin (SPI chip select on QuikEval connector pin 6) connects to Arduino SS pin.
00063 #define QUIKEVAL_MUX_MODE_PIN 8  /*!< QUIKEVAL_MUX_MODE_PIN defines the control pin for the QuikEval MUX.
00064 The I2C port's SCL and the SPI port's SCK signals share the same pin on the Linduino's QuikEval connector.
00065 Additionally, the I2C port's SDA and the SPI port's MOSI signals share the same pin on the Linduino's QuikEval connector.
00066 The pair of pins connected to the QuikEval connector is switched using a MUX on the Linduino board.
00067 The control pin to switch the MUX is defined as QUIKEVAL_MUX_MODE_PIN (Arduino pin 8). */
00068 //! @}
00069 
00070 // Macros
00071 //! Set "pin" low
00072 //! @param pin pin to be driven LOW
00073 #define output_low(pin)   digitalWrite(pin, LOW)
00074 //! Set "pin" high
00075 //! @param pin pin to be driven HIGH
00076 #define output_high(pin)  digitalWrite(pin, HIGH)
00077 //! Return the state of pin "pin"
00078 //! @param pin pin to be read (HIGH or LOW).
00079 //! @return the state of pin "pin"
00080 #define input(pin)        digitalRead(pin)
00081 
00082 //! @name ENDIAN DEPENDENT BYTE INDEXES
00083 //! @{
00084 //! Arduino/Linduino is a Little Endian Device, where the least significant byte is stored in the first byte of larger data types.
00085 #ifdef BIG_ENDIAN
00086 #define LSB 1 //!< Location of Least Signficant Byte when Word is accessed as Byte Array
00087 #define MSB 0 //!< Location of Most Signficant Byte when Word is accessed as Byte Array
00088 #define LSW 1 //!< Location of Least Signficant Word when Long Word is accessed as Byte Array
00089 #define MSW 0 //!< Location of most Signficant Word when Long Word is accessed as Byte Array
00090 #else
00091 #define LSB 0 //!< Location of Least Signficant Byte when Word is accessed as Byte Array
00092 #define MSB 1 //!< Location of Most Signficant Byte when Word is accessed as Byte Array
00093 #define LSW 0 //!< Location of Least Signficant Word when Long Word is accessed as Byte Array
00094 #define MSW 1 //!< Location of most Signficant Word when Long Word is accessed as Byte Array
00095 #endif
00096 //! @}
00097 
00098 //! This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer)
00099 //! into two uint8_t's (8-bit unsigned integers) and vice versa.
00100   union LT_union_int16_2bytes
00101   {
00102     int16_t LT_int16;    //!< 16-bit signed integer to be converted to two bytes
00103     uint16_t LT_uint16;  //!< 16-bit unsigned integer to be converted to two bytes
00104     uint8_t LT_byte[2];  //!< 2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer
00105   };
00106 
00107 //! This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer)
00108 //! four uint8_t's (8-bit unsigned integers) and vice versa.
00109 union LT_union_int32_4bytes
00110 {
00111   int32_t LT_int32;       //!< 32-bit signed integer to be converted to four bytes
00112   uint32_t LT_uint32;     //!< 32-bit unsigned integer to be converted to four bytes
00113   uint8_t LT_byte[4];     //!< 4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer
00114 };
00115 
00116 //! This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer)
00117 //! into two uint16_t's (16-bit unsigned integers) and vice versa.
00118 union LT_union_uint32_2uint16s
00119 {
00120   int32_t LT_int32;       //!< 32-bit signed integer to be converted to four bytes
00121   uint32_t LT_uint32;     //!< 32-bit unsigned integer to be converted to four bytes
00122   uint16_t LT_uint16[2];  //!< 2 words (unsigned 16-bit integers) to be converted to a 32-bit signed or unsigned integer
00123 };
00124 
00125 //! This union splits one float into four uint8_t's (8-bit unsigned integers) and vice versa.
00126 union LT_union_float_4bytes
00127 {
00128   float LT_float;      //!< float to be converted to four bytes
00129   uint8_t LT_byte[4];  //!< 4 bytes (unsigned 8-bit integers) to be converted to a float
00130 };
00131 
00132 
00133 #endif  // LINDUINO_H