EVAL-ADXL362-ARDZ accelerometer shield

Dependencies:   ADXL362

Dependents:   EVAL_ADXL362_ARDZ-helloworld

For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all

Committer:
adisuciu
Date:
Wed May 18 15:19:27 2016 +0000
Revision:
0:689a0bf410c3
Child:
2:e56adca82fee
Initial revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
adisuciu 0:689a0bf410c3 1 /**
adisuciu 0:689a0bf410c3 2 ******************************************************************************
adisuciu 0:689a0bf410c3 3 * @file Lcd.c
adisuciu 0:689a0bf410c3 4 * @brief Header file for ST7565R LCD control.
adisuciu 0:689a0bf410c3 5 * @author ADI
adisuciu 0:689a0bf410c3 6 * @date March 2016
adisuciu 0:689a0bf410c3 7 *
adisuciu 0:689a0bf410c3 8 *******************************************************************************
adisuciu 0:689a0bf410c3 9 * Copyright 2015(c) Analog Devices, Inc.
adisuciu 0:689a0bf410c3 10 *
adisuciu 0:689a0bf410c3 11 * All rights reserved.
adisuciu 0:689a0bf410c3 12 *
adisuciu 0:689a0bf410c3 13 * Redistribution and use in source and binary forms, with or without modification,
adisuciu 0:689a0bf410c3 14 * are permitted provided that the following conditions are met:
adisuciu 0:689a0bf410c3 15 * - Redistributions of source code must retain the above copyright
adisuciu 0:689a0bf410c3 16 * notice, this list of conditions and the following disclaimer.
adisuciu 0:689a0bf410c3 17 * - Redistributions in binary form must reproduce the above copyright
adisuciu 0:689a0bf410c3 18 * notice, this list of conditions and the following disclaimer in
adisuciu 0:689a0bf410c3 19 * the documentation and/or other materials provided with the
adisuciu 0:689a0bf410c3 20 * distribution.
adisuciu 0:689a0bf410c3 21 * - Neither the name of Analog Devices, Inc. nor the names of its
adisuciu 0:689a0bf410c3 22 * contributors may be used to endorse or promote products derived
adisuciu 0:689a0bf410c3 23 * from this software without specific prior written permission.
adisuciu 0:689a0bf410c3 24 * - The use of this software may or may not infringe the patent rights
adisuciu 0:689a0bf410c3 25 * of one or more patent holders. This license does not release you
adisuciu 0:689a0bf410c3 26 * from the requirement that you obtain separate licenses from these
adisuciu 0:689a0bf410c3 27 * patent holders to use this software.
adisuciu 0:689a0bf410c3 28 * - Use of the software either in source or binary form, must be run
adisuciu 0:689a0bf410c3 29 * on or directly connected to an Analog Devices Inc. component.
adisuciu 0:689a0bf410c3 30 *
adisuciu 0:689a0bf410c3 31 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
adisuciu 0:689a0bf410c3 32 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
adisuciu 0:689a0bf410c3 33 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
adisuciu 0:689a0bf410c3 34 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
adisuciu 0:689a0bf410c3 35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
adisuciu 0:689a0bf410c3 36 * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
adisuciu 0:689a0bf410c3 37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
adisuciu 0:689a0bf410c3 38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
adisuciu 0:689a0bf410c3 39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
adisuciu 0:689a0bf410c3 40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
adisuciu 0:689a0bf410c3 41 *
adisuciu 0:689a0bf410c3 42 *******************************************************************************
adisuciu 0:689a0bf410c3 43 **/
adisuciu 0:689a0bf410c3 44 #ifndef LCD_H_
adisuciu 0:689a0bf410c3 45 #define LCD_H_
adisuciu 0:689a0bf410c3 46
adisuciu 0:689a0bf410c3 47
adisuciu 0:689a0bf410c3 48 /******************************************************************************/
adisuciu 0:689a0bf410c3 49 /***************************** Include Files **********************************/
adisuciu 0:689a0bf410c3 50 /******************************************************************************/
adisuciu 0:689a0bf410c3 51 #include <stdio.h>
adisuciu 0:689a0bf410c3 52 #include "mbed.h"
adisuciu 0:689a0bf410c3 53
adisuciu 0:689a0bf410c3 54 class Lcd
adisuciu 0:689a0bf410c3 55 {
adisuciu 0:689a0bf410c3 56 public:
adisuciu 0:689a0bf410c3 57
adisuciu 0:689a0bf410c3 58 const static uint8_t pui8Rec8x8[8];
adisuciu 0:689a0bf410c3 59 const static uint8_t pui8RecInv8x8[8];
adisuciu 0:689a0bf410c3 60 const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14)
adisuciu 0:689a0bf410c3 61
adisuciu 0:689a0bf410c3 62 Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6,
adisuciu 0:689a0bf410c3 63 PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK =
adisuciu 0:689a0bf410c3 64 SPI_SCK);
adisuciu 0:689a0bf410c3 65 void init(void);
adisuciu 0:689a0bf410c3 66 void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str);
adisuciu 0:689a0bf410c3 67 void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width,
adisuciu 0:689a0bf410c3 68 const uint8_t *pui8symbol);
adisuciu 0:689a0bf410c3 69 void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data);
adisuciu 0:689a0bf410c3 70 void set_line(uint8_t ui8line);
adisuciu 0:689a0bf410c3 71 void set_cursor(uint8_t ui8PA, uint8_t ui8CA);
adisuciu 0:689a0bf410c3 72 void bl_enable();
adisuciu 0:689a0bf410c3 73 void bl_disable();
adisuciu 0:689a0bf410c3 74
adisuciu 0:689a0bf410c3 75 void write_cmd(uint8_t cmd);
adisuciu 0:689a0bf410c3 76 void write_data(uint8_t data);
adisuciu 0:689a0bf410c3 77
adisuciu 0:689a0bf410c3 78
adisuciu 0:689a0bf410c3 79 typedef enum {
adisuciu 0:689a0bf410c3 80 CMD_DISPLAY_OFF = 0xAE,
adisuciu 0:689a0bf410c3 81 CMD_DISPLAY_ON = 0xAF,
adisuciu 0:689a0bf410c3 82 CMD_SET_DISP_START_LINE = 0x40,
adisuciu 0:689a0bf410c3 83 CMD_SET_PAGE = 0xB0,
adisuciu 0:689a0bf410c3 84 CMD_SET_COLUMN_UPPER = 0x10,
adisuciu 0:689a0bf410c3 85 CMD_SET_COLUMN_LOWER = 0x00,
adisuciu 0:689a0bf410c3 86 CMD_SET_ADC_NORMAL = 0xA0,
adisuciu 0:689a0bf410c3 87 CMD_SET_ADC_REVERSE = 0xA1,
adisuciu 0:689a0bf410c3 88 CMD_SET_DISP_NORMAL = 0xA6,
adisuciu 0:689a0bf410c3 89 CMD_SET_DISP_REVERSE = 0xA7,
adisuciu 0:689a0bf410c3 90 CMD_SET_ALLPTS_NORMAL = 0xA4,
adisuciu 0:689a0bf410c3 91 CMD_SET_ALLPTS_ON = 0xA5,
adisuciu 0:689a0bf410c3 92 CMD_SET_BIAS_9 = 0xA2,
adisuciu 0:689a0bf410c3 93 CMD_SET_BIAS_7 = 0xA3,
adisuciu 0:689a0bf410c3 94 CMD_RMW = 0xE0,
adisuciu 0:689a0bf410c3 95 CMD_RMW_CLEAR = 0xEE,
adisuciu 0:689a0bf410c3 96 CMD_INTERNAL_RESET = 0xE2,
adisuciu 0:689a0bf410c3 97 CMD_SET_COM_NORMAL = 0xC0,
adisuciu 0:689a0bf410c3 98 CMD_SET_COM_REVERSE = 0xC8,
adisuciu 0:689a0bf410c3 99 CMD_SET_POWER_CONTROL = 0x28,
adisuciu 0:689a0bf410c3 100 CMD_SET_RESISTOR_RATIO = 0x20,
adisuciu 0:689a0bf410c3 101 CMD_SET_VOLUME_FIRST = 0x81,
adisuciu 0:689a0bf410c3 102 CMD_SET_VOLUME_SECOND = 0,
adisuciu 0:689a0bf410c3 103 CMD_SET_STATIC_OFF = 0xAC,
adisuciu 0:689a0bf410c3 104 CMD_SET_STATIC_ON = 0xAD,
adisuciu 0:689a0bf410c3 105 CMD_SET_STATIC_REG = 0x0,
adisuciu 0:689a0bf410c3 106 CMD_SET_BOOSTER_FIRST = 0xF8,
adisuciu 0:689a0bf410c3 107 CMD_SET_BOOSTER_234 = 0,
adisuciu 0:689a0bf410c3 108 CMD_SET_BOOSTER_5 = 1,
adisuciu 0:689a0bf410c3 109 CMD_SET_BOOSTER_6 = 3,
adisuciu 0:689a0bf410c3 110 CMD_NOP = 0xE3,
adisuciu 0:689a0bf410c3 111 CMD_TEST = 0xF0,
adisuciu 0:689a0bf410c3 112 } lcd_commands_t;
adisuciu 0:689a0bf410c3 113
adisuciu 0:689a0bf410c3 114 static const uint8_t LCD_COLUMNS = 128u;
adisuciu 0:689a0bf410c3 115 static const uint8_t LCD_PAGES = 4u;
adisuciu 0:689a0bf410c3 116 static const uint8_t LCD_LINES = 64u;
adisuciu 0:689a0bf410c3 117 static const uint8_t UP_X = 112;
adisuciu 0:689a0bf410c3 118 static const uint8_t LEFT_X = 104;
adisuciu 0:689a0bf410c3 119 static const uint8_t RIGHT_X = 120;
adisuciu 0:689a0bf410c3 120 static const uint8_t DOWN_X = 112;
adisuciu 0:689a0bf410c3 121 static const uint8_t CENTER_X = 112;
adisuciu 0:689a0bf410c3 122 static const uint8_t ACC_LIMIT = 80;
adisuciu 0:689a0bf410c3 123 static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y
adisuciu 0:689a0bf410c3 124 static const uint8_t OFFS_ASCII = 32; ///< ASCII offset
adisuciu 0:689a0bf410c3 125
adisuciu 0:689a0bf410c3 126 static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C
adisuciu 0:689a0bf410c3 127 static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code)
adisuciu 0:689a0bf410c3 128
adisuciu 0:689a0bf410c3 129 private:
adisuciu 0:689a0bf410c3 130
adisuciu 0:689a0bf410c3 131 DigitalOut rst, a0, bl, cs;
adisuciu 0:689a0bf410c3 132 SPI lcd_spi;
adisuciu 0:689a0bf410c3 133
adisuciu 0:689a0bf410c3 134
adisuciu 0:689a0bf410c3 135
adisuciu 0:689a0bf410c3 136 };
adisuciu 0:689a0bf410c3 137
adisuciu 0:689a0bf410c3 138 #endif /* LCD_H_ */