Post It

Dependencies:   LM75B

Fork of EM027BS013 by EmbeddedArtists AB

Committer:
ShalajLawania
Date:
Tue Dec 09 10:26:31 2014 +0000
Revision:
1:3700ccf919d8
Parent:
0:9297e33f50cf
Post It

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:9297e33f50cf 1 /**
embeddedartists 0:9297e33f50cf 2 * \file
embeddedartists 0:9297e33f50cf 3 *
embeddedartists 0:9297e33f50cf 4 * \brief The functions of EPD GPIO
embeddedartists 0:9297e33f50cf 5 *
embeddedartists 0:9297e33f50cf 6 * Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved.
embeddedartists 0:9297e33f50cf 7 *
embeddedartists 0:9297e33f50cf 8 * Authors: Pervasive Displays Inc.
embeddedartists 0:9297e33f50cf 9 *
embeddedartists 0:9297e33f50cf 10 * Redistribution and use in source and binary forms, with or without
embeddedartists 0:9297e33f50cf 11 * modification, are permitted provided that the following conditions
embeddedartists 0:9297e33f50cf 12 * are met:
embeddedartists 0:9297e33f50cf 13 *
embeddedartists 0:9297e33f50cf 14 * 1. Redistributions of source code must retain the above copyright
embeddedartists 0:9297e33f50cf 15 * notice, this list of conditions and the following disclaimer.
embeddedartists 0:9297e33f50cf 16 * 2. Redistributions in binary form must reproduce the above copyright
embeddedartists 0:9297e33f50cf 17 * notice, this list of conditions and the following disclaimer in
embeddedartists 0:9297e33f50cf 18 * the documentation and/or other materials provided with the
embeddedartists 0:9297e33f50cf 19 * distribution.
embeddedartists 0:9297e33f50cf 20 *
embeddedartists 0:9297e33f50cf 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
embeddedartists 0:9297e33f50cf 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
embeddedartists 0:9297e33f50cf 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
embeddedartists 0:9297e33f50cf 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
embeddedartists 0:9297e33f50cf 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
embeddedartists 0:9297e33f50cf 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
embeddedartists 0:9297e33f50cf 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
embeddedartists 0:9297e33f50cf 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
embeddedartists 0:9297e33f50cf 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
embeddedartists 0:9297e33f50cf 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
embeddedartists 0:9297e33f50cf 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
embeddedartists 0:9297e33f50cf 32 */
embeddedartists 0:9297e33f50cf 33
embeddedartists 0:9297e33f50cf 34
embeddedartists 0:9297e33f50cf 35 #include "EPD_hardware_gpio.h"
embeddedartists 0:9297e33f50cf 36
embeddedartists 0:9297e33f50cf 37 #include "mbed.h"
embeddedartists 0:9297e33f50cf 38
embeddedartists 0:9297e33f50cf 39 extern PinName SEC06;
embeddedartists 0:9297e33f50cf 40 extern PinName SEC07;
embeddedartists 0:9297e33f50cf 41 extern PinName SEC08;
embeddedartists 0:9297e33f50cf 42 extern PinName SEC11;
embeddedartists 0:9297e33f50cf 43 extern PinName SEC12;
embeddedartists 0:9297e33f50cf 44 extern PinName SEC13;
embeddedartists 0:9297e33f50cf 45 extern PinName SEC14;
embeddedartists 0:9297e33f50cf 46
embeddedartists 0:9297e33f50cf 47 static DigitalOut* pinEpdCS = NULL;
embeddedartists 0:9297e33f50cf 48 static DigitalIn* pinEpdBusy = NULL;
embeddedartists 0:9297e33f50cf 49 static DigitalOut* pinEpdBorder = NULL;
embeddedartists 0:9297e33f50cf 50 static DigitalOut* pinFlashCS = NULL;
embeddedartists 0:9297e33f50cf 51 static DigitalOut* pinEpdReset = NULL;
embeddedartists 0:9297e33f50cf 52 static DigitalOut* pinEpdPanelOn = NULL;
embeddedartists 0:9297e33f50cf 53 static DigitalOut* pinEpdDischarge = NULL;
embeddedartists 0:9297e33f50cf 54
embeddedartists 0:9297e33f50cf 55 /**
embeddedartists 0:9297e33f50cf 56 * \brief Set EPD_CS pin to high
embeddedartists 0:9297e33f50cf 57 */
embeddedartists 0:9297e33f50cf 58 void EPD_cs_high (void) {
embeddedartists 0:9297e33f50cf 59 //set_gpio_high(EPD_CS_PORT,EPD_CS_PIN);
embeddedartists 0:9297e33f50cf 60 *pinEpdCS = 1;
embeddedartists 0:9297e33f50cf 61 }
embeddedartists 0:9297e33f50cf 62
embeddedartists 0:9297e33f50cf 63 /**
embeddedartists 0:9297e33f50cf 64 * \brief Set EPD_CS pin to low
embeddedartists 0:9297e33f50cf 65 */
embeddedartists 0:9297e33f50cf 66 void EPD_cs_low (void) {
embeddedartists 0:9297e33f50cf 67 // set_gpio_low(EPD_CS_PORT,EPD_CS_PIN);
embeddedartists 0:9297e33f50cf 68 *pinEpdCS = 0;
embeddedartists 0:9297e33f50cf 69 }
embeddedartists 0:9297e33f50cf 70
embeddedartists 0:9297e33f50cf 71 /**
embeddedartists 0:9297e33f50cf 72 * \brief Set Flash_CS pin to high
embeddedartists 0:9297e33f50cf 73 */
embeddedartists 0:9297e33f50cf 74 void EPD_flash_cs_high(void) {
embeddedartists 0:9297e33f50cf 75 // set_gpio_high(Flash_CS_PORT,Flash_CS_PIN);
embeddedartists 0:9297e33f50cf 76 *pinFlashCS = 1;
embeddedartists 0:9297e33f50cf 77 }
embeddedartists 0:9297e33f50cf 78
embeddedartists 0:9297e33f50cf 79 /**
embeddedartists 0:9297e33f50cf 80 * \brief Set Flash_CS pin to low
embeddedartists 0:9297e33f50cf 81 */
embeddedartists 0:9297e33f50cf 82 void EPD_flash_cs_low (void) {
embeddedartists 0:9297e33f50cf 83 // set_gpio_low(Flash_CS_PORT,Flash_CS_PIN);
embeddedartists 0:9297e33f50cf 84 *pinFlashCS = 0;
embeddedartists 0:9297e33f50cf 85 }
embeddedartists 0:9297e33f50cf 86
embeddedartists 0:9297e33f50cf 87 /**
embeddedartists 0:9297e33f50cf 88 * \brief Set /RESET pin to high
embeddedartists 0:9297e33f50cf 89 */
embeddedartists 0:9297e33f50cf 90 void EPD_rst_high (void) {
embeddedartists 0:9297e33f50cf 91 // set_gpio_high(EPD_RST_PORT,EPD_RST_PIN);
embeddedartists 0:9297e33f50cf 92 *pinEpdReset = 1;
embeddedartists 0:9297e33f50cf 93 }
embeddedartists 0:9297e33f50cf 94
embeddedartists 0:9297e33f50cf 95 /**
embeddedartists 0:9297e33f50cf 96 * \brief Set /RESET pin to low
embeddedartists 0:9297e33f50cf 97 */
embeddedartists 0:9297e33f50cf 98 void EPD_rst_low (void) {
embeddedartists 0:9297e33f50cf 99 // set_gpio_low(EPD_RST_PORT,EPD_RST_PIN);
embeddedartists 0:9297e33f50cf 100 *pinEpdReset = 0;
embeddedartists 0:9297e33f50cf 101 }
embeddedartists 0:9297e33f50cf 102
embeddedartists 0:9297e33f50cf 103 /**
embeddedartists 0:9297e33f50cf 104 * \brief Set DISCHARGE pin to high
embeddedartists 0:9297e33f50cf 105 */
embeddedartists 0:9297e33f50cf 106 void EPD_discharge_high (void) {
embeddedartists 0:9297e33f50cf 107 // set_gpio_high(EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN);
embeddedartists 0:9297e33f50cf 108 *pinEpdDischarge = 1;
embeddedartists 0:9297e33f50cf 109 }
embeddedartists 0:9297e33f50cf 110
embeddedartists 0:9297e33f50cf 111 /**
embeddedartists 0:9297e33f50cf 112 * \brief Set DISCHARGE pin to low
embeddedartists 0:9297e33f50cf 113 */
embeddedartists 0:9297e33f50cf 114 void EPD_discharge_low (void) {
embeddedartists 0:9297e33f50cf 115 // set_gpio_low(EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN);
embeddedartists 0:9297e33f50cf 116 *pinEpdDischarge = 0;
embeddedartists 0:9297e33f50cf 117 }
embeddedartists 0:9297e33f50cf 118
embeddedartists 0:9297e33f50cf 119 /**
embeddedartists 0:9297e33f50cf 120 * \brief Set Vcc (PANEL_ON) to high
embeddedartists 0:9297e33f50cf 121 */
embeddedartists 0:9297e33f50cf 122 void EPD_Vcc_turn_on (void) {
embeddedartists 0:9297e33f50cf 123 // set_gpio_high(EPD_PANELON_PORT,EPD_PANELON_PIN);
embeddedartists 0:9297e33f50cf 124 *pinEpdPanelOn = 1;
embeddedartists 0:9297e33f50cf 125 }
embeddedartists 0:9297e33f50cf 126
embeddedartists 0:9297e33f50cf 127 /**
embeddedartists 0:9297e33f50cf 128 * \brief Set Vcc (PANEL_ON) to low
embeddedartists 0:9297e33f50cf 129 */
embeddedartists 0:9297e33f50cf 130 void EPD_Vcc_turn_off (void) {
embeddedartists 0:9297e33f50cf 131 // set_gpio_low(EPD_PANELON_PORT,EPD_PANELON_PIN);
embeddedartists 0:9297e33f50cf 132 *pinEpdPanelOn = 0;
embeddedartists 0:9297e33f50cf 133 }
embeddedartists 0:9297e33f50cf 134
embeddedartists 0:9297e33f50cf 135 /**
embeddedartists 0:9297e33f50cf 136 * \brief Set BORDER_CONTROL pin to high
embeddedartists 0:9297e33f50cf 137 */
embeddedartists 0:9297e33f50cf 138 void EPD_border_high(void) {
embeddedartists 0:9297e33f50cf 139 // set_gpio_high(EPD_PANELON_PORT,EPD_BORDER_PIN);
embeddedartists 0:9297e33f50cf 140 *pinEpdBorder = 1;
embeddedartists 0:9297e33f50cf 141 }
embeddedartists 0:9297e33f50cf 142
embeddedartists 0:9297e33f50cf 143 /**
embeddedartists 0:9297e33f50cf 144 * \brief Set BORDER_CONTROL pin to low
embeddedartists 0:9297e33f50cf 145 */
embeddedartists 0:9297e33f50cf 146 void EPD_border_low (void) {
embeddedartists 0:9297e33f50cf 147 // set_gpio_low(EPD_PANELON_PORT,EPD_BORDER_PIN);
embeddedartists 0:9297e33f50cf 148 *pinEpdBorder = 0;
embeddedartists 0:9297e33f50cf 149 }
embeddedartists 0:9297e33f50cf 150
embeddedartists 0:9297e33f50cf 151 /**
embeddedartists 0:9297e33f50cf 152 * \brief Set PWM pin to high
embeddedartists 0:9297e33f50cf 153 */
embeddedartists 0:9297e33f50cf 154 void EPD_pwm_high(void) {
embeddedartists 0:9297e33f50cf 155 // set_gpio_high(PWM_PORT,PWM_PIN);
embeddedartists 0:9297e33f50cf 156
embeddedartists 0:9297e33f50cf 157 // Not in use
embeddedartists 0:9297e33f50cf 158 }
embeddedartists 0:9297e33f50cf 159
embeddedartists 0:9297e33f50cf 160 /**
embeddedartists 0:9297e33f50cf 161 * \brief Set PWM pin to low
embeddedartists 0:9297e33f50cf 162 */
embeddedartists 0:9297e33f50cf 163 void EPD_pwm_low (void) {
embeddedartists 0:9297e33f50cf 164 // config_gpio_dir_o(SPIMISO_PORT,SPIMISO_PIN);
embeddedartists 0:9297e33f50cf 165 // set_gpio_low(PWM_PORT,PWM_PIN);
embeddedartists 0:9297e33f50cf 166
embeddedartists 0:9297e33f50cf 167 // Not in use
embeddedartists 0:9297e33f50cf 168 }
embeddedartists 0:9297e33f50cf 169
embeddedartists 0:9297e33f50cf 170 /**
embeddedartists 0:9297e33f50cf 171 * \brief Set MISO pin of SPI to low
embeddedartists 0:9297e33f50cf 172 */
embeddedartists 0:9297e33f50cf 173 void SPIMISO_low(void) {
embeddedartists 0:9297e33f50cf 174 // config_gpio_dir_o(SPIMISO_PORT,SPIMISO_PIN);
embeddedartists 0:9297e33f50cf 175 // set_gpio_low(SPIMISO_PORT,SPIMISO_PIN);
embeddedartists 0:9297e33f50cf 176
embeddedartists 0:9297e33f50cf 177 // Not in use
embeddedartists 0:9297e33f50cf 178 }
embeddedartists 0:9297e33f50cf 179
embeddedartists 0:9297e33f50cf 180 /**
embeddedartists 0:9297e33f50cf 181 * \brief Set MOSI pin of SPI to low
embeddedartists 0:9297e33f50cf 182 */
embeddedartists 0:9297e33f50cf 183 void SPIMOSI_low(void) {
embeddedartists 0:9297e33f50cf 184 // set_gpio_low(SPIMOSI_PORT,SPIMOSI_PIN);
embeddedartists 0:9297e33f50cf 185
embeddedartists 0:9297e33f50cf 186 // Not in use
embeddedartists 0:9297e33f50cf 187 }
embeddedartists 0:9297e33f50cf 188
embeddedartists 0:9297e33f50cf 189 /**
embeddedartists 0:9297e33f50cf 190 * \brief Set Clock of SPI to low
embeddedartists 0:9297e33f50cf 191 */
embeddedartists 0:9297e33f50cf 192 void SPICLK_low(void) {
embeddedartists 0:9297e33f50cf 193 // set_gpio_low(SPICLK_PORT,SPICLK_PIN);
embeddedartists 0:9297e33f50cf 194
embeddedartists 0:9297e33f50cf 195 // Not in use
embeddedartists 0:9297e33f50cf 196 }
embeddedartists 0:9297e33f50cf 197
embeddedartists 0:9297e33f50cf 198 /**
embeddedartists 0:9297e33f50cf 199 * \brief Get BUSY pin status
embeddedartists 0:9297e33f50cf 200 */
embeddedartists 0:9297e33f50cf 201 bool EPD_IsBusy(void) {
embeddedartists 0:9297e33f50cf 202 // return (bool)input_get(EPD_BUSY_PORT,EPD_BUSY_PIN);
embeddedartists 0:9297e33f50cf 203 return pinEpdBusy->read();
embeddedartists 0:9297e33f50cf 204 }
embeddedartists 0:9297e33f50cf 205
embeddedartists 0:9297e33f50cf 206 /**
embeddedartists 0:9297e33f50cf 207 * \brief Configure GPIO
embeddedartists 0:9297e33f50cf 208 */
embeddedartists 0:9297e33f50cf 209 void EPD_initialize_gpio(void) {
embeddedartists 0:9297e33f50cf 210
embeddedartists 0:9297e33f50cf 211 pinEpdCS = new DigitalOut(SEC06); // SEC-06 Requires J14 9-10 to NOT be connected
embeddedartists 0:9297e33f50cf 212 pinEpdBusy = new DigitalIn(SEC07); // SEC-07
embeddedartists 0:9297e33f50cf 213 pinEpdBorder = new DigitalOut(SEC08); // SEC-08
embeddedartists 0:9297e33f50cf 214 pinFlashCS = new DigitalOut(SEC11); // SEC-11
embeddedartists 0:9297e33f50cf 215 pinEpdReset = new DigitalOut(SEC12); // SEC-12
embeddedartists 0:9297e33f50cf 216 pinEpdPanelOn = new DigitalOut(SEC13); // SEC-13
embeddedartists 0:9297e33f50cf 217 pinEpdDischarge = new DigitalOut(SEC14); // SEC-14
embeddedartists 0:9297e33f50cf 218
embeddedartists 0:9297e33f50cf 219 // config_gpio_dir_i( EPD_BUSY_PORT,EPD_BUSY_PIN);
embeddedartists 0:9297e33f50cf 220 // //Set Xin to GPIO
embeddedartists 0:9297e33f50cf 221 // BITCLR (CS_PORT_SEL, EPD_CS_PIN);
embeddedartists 0:9297e33f50cf 222 // BITCLR (CS_PORT_SEL2,EPD_CS_PIN);
embeddedartists 0:9297e33f50cf 223 // //Set Xout to GPIO
embeddedartists 0:9297e33f50cf 224 // BITCLR (Flash_CS_PORT_SEL, Flash_CS_PIN);
embeddedartists 0:9297e33f50cf 225 // BITCLR (Flash_CS_PORT_SEL2,Flash_CS_PIN);
embeddedartists 0:9297e33f50cf 226 //
embeddedartists 0:9297e33f50cf 227 // config_gpio_dir_o( EPD_CS_PORT,EPD_CS_PIN);
embeddedartists 0:9297e33f50cf 228 // config_gpio_dir_o( EPD_RST_PORT,EPD_RST_PIN);
embeddedartists 0:9297e33f50cf 229 // config_gpio_dir_o( EPD_PANELON_PORT,EPD_PANELON_PIN);
embeddedartists 0:9297e33f50cf 230 // config_gpio_dir_o( EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN);
embeddedartists 0:9297e33f50cf 231 // config_gpio_dir_o( EPD_BORDER_PORT,EPD_BORDER_PIN);
embeddedartists 0:9297e33f50cf 232 // config_gpio_dir_o( Flash_CS_PORT,Flash_CS_PIN);
embeddedartists 0:9297e33f50cf 233 // config_gpio_dir_o( PWM_PORT,PWM_PIN);
embeddedartists 0:9297e33f50cf 234 // config_gpio_dir_i( Temper_PORT,Temper_PIN);
embeddedartists 0:9297e33f50cf 235 EPD_flash_cs_high();
embeddedartists 0:9297e33f50cf 236 EPD_border_low();
embeddedartists 0:9297e33f50cf 237 }
embeddedartists 0:9297e33f50cf 238