A collection of Analog Devices drivers for the mbed platform

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

Committer:
Dragos Bogdan
Date:
Tue May 17 18:37:29 2016 +0300
Revision:
23:174dd32fa661
EVAL_ADXL362_ARDZ: Rename folder to eval_adxl362_ardz

Who changed what in which revision?

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