paul@0 | 1 | // Copyright 2013 Pervasive Displays, Inc. |
paul@0 | 2 | // |
paul@0 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
paul@0 | 4 | // you may not use this file except in compliance with the License. |
paul@0 | 5 | // You may obtain a copy of the License at: |
paul@0 | 6 | // |
paul@0 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
paul@0 | 8 | // |
paul@0 | 9 | // Unless required by applicable law or agreed to in writing, |
paul@0 | 10 | // software distributed under the License is distributed on an |
paul@0 | 11 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
paul@0 | 12 | // express or implied. See the License for the specific language |
paul@0 | 13 | // governing permissions and limitations under the License. |
paul@0 | 14 | |
paul@0 | 15 | /****************************************************************************** |
paul@0 | 16 | * Includes |
paul@0 | 17 | *****************************************************************************/ |
paul@0 | 18 | #include "Display_Hardware_Driver.h" |
paul@1 | 19 | #include <ubb/ubb.h> |
paul@0 | 20 | |
paul@0 | 21 | |
paul@0 | 22 | /****************************************************************************** |
paul@0 | 23 | * Public functions |
paul@0 | 24 | *****************************************************************************/ |
paul@0 | 25 | void epd_cs_high(void) |
paul@0 | 26 | { |
paul@0 | 27 | // CS_SET_HIGH; |
paul@1 | 28 | SET(EPD_SSEL); |
paul@0 | 29 | } |
paul@0 | 30 | |
paul@0 | 31 | void epd_cs_low(void) |
paul@0 | 32 | { |
paul@0 | 33 | // CS_SET_LOW; |
paul@1 | 34 | CLR(EPD_SSEL); |
paul@0 | 35 | } |
paul@0 | 36 | |
paul@0 | 37 | void epd_rst_high(void) |
paul@0 | 38 | { |
paul@0 | 39 | // RST_SET_HIGH; |
paul@1 | 40 | SET(EPD_RESET); |
paul@0 | 41 | } |
paul@0 | 42 | |
paul@0 | 43 | void epd_rst_low(void) |
paul@0 | 44 | { |
paul@0 | 45 | // RST_SET_LOW; |
paul@1 | 46 | CLR(EPD_RESET); |
paul@0 | 47 | } |
paul@0 | 48 | |
paul@0 | 49 | void epd_delay_ms(uint32_t Time) |
paul@0 | 50 | { |
paul@0 | 51 | bsp_delayMs(Time); |
paul@0 | 52 | } |
paul@0 | 53 | |
paul@0 | 54 | int16_t epd_get_temperature(void) |
paul@0 | 55 | { |
paul@0 | 56 | return bsp_getTemp(); |
paul@0 | 57 | } |
paul@0 | 58 | |
paul@0 | 59 | uint32_t epd_GetCurrentTimeTick(void) |
paul@0 | 60 | { |
paul@0 | 61 | return bsp_getMsTicks(); |
paul@0 | 62 | } |
paul@0 | 63 | |
paul@0 | 64 | //****************************************************************** |
paul@0 | 65 | //PWM Configuration/Control |
paul@0 | 66 | //****************************************************************** |
paul@0 | 67 | #if 0 |
paul@0 | 68 | volatile uint32_t period = 500; //96Khz PWM frequency |
paul@0 | 69 | |
paul@0 | 70 | void epd_pwm_disable(void) |
paul@0 | 71 | { |
paul@0 | 72 | disable_timer16(1); |
paul@0 | 73 | LPC_IOCON->PIO1_9 &= 0xFC;//Disable PWM,set general IO |
paul@0 | 74 | PWM_DIR_OUT(); |
paul@0 | 75 | PWM_SET_LOW(); |
paul@0 | 76 | } |
paul@0 | 77 | |
paul@0 | 78 | void epd_pwm_active(void) |
paul@0 | 79 | { |
paul@0 | 80 | PWM_SET_HIGH(); |
paul@0 | 81 | /* Initialize the PWM in timer32_1 enabling match0 output */ |
paul@0 | 82 | init_timer16PWM(1, period, MATCH0,0); |
paul@0 | 83 | setMatch_timer16PWM (1, 1, period/8); |
paul@0 | 84 | enable_timer16(1); |
paul@0 | 85 | } |
paul@0 | 86 | #endif |
paul@0 | 87 | void epd_pwm_active(uint16_t delayInMs) |
paul@0 | 88 | { |
paul@1 | 89 | bsp_pwm_active(delayInMs); |
paul@0 | 90 | } |
paul@0 | 91 | |
paul@0 | 92 | |
paul@0 | 93 | //****************************************************************** |
paul@0 | 94 | //SPI Configuration |
paul@0 | 95 | //****************************************************************** |
paul@0 | 96 | void epd_spi_detach(void) |
paul@0 | 97 | { |
paul@0 | 98 | #if 0 |
paul@0 | 99 | LPC_IOCON->PIO0_8 &= 0xFC;; /* SSP I/O config */ |
paul@0 | 100 | SPIMISO_DIR_OUT(); |
paul@0 | 101 | SPIMISO_Set(Low); |
paul@0 | 102 | |
paul@0 | 103 | LPC_IOCON->PIO0_9 &= 0xFC; /* SSP MOSI */ |
paul@0 | 104 | SPIMOSI_DIR_OUT(); |
paul@0 | 105 | SPIMOSI_Set(Low); |
paul@0 | 106 | |
paul@0 | 107 | LPC_IOCON->PIO2_11 &= 0xFC; |
paul@0 | 108 | SPICLK_DIR_OUT(); |
paul@0 | 109 | SPICLK_Set(Low); |
paul@0 | 110 | #endif |
paul@0 | 111 | } |
paul@0 | 112 | void epd_spi_init (void) |
paul@0 | 113 | { |
paul@0 | 114 | bsp_spiInit(); |
paul@0 | 115 | //SSP_IOConfig( SSP_PORT ); /* initialize SSP port */ |
paul@0 | 116 | //SSP_Init( SSP_PORT ); |
paul@0 | 117 | } |
paul@0 | 118 | |
paul@0 | 119 | void epd_SPI_Send (unsigned char Register, unsigned char *Data, unsigned Length) |
paul@0 | 120 | { |
paul@0 | 121 | uint8_t buf[2]; |
paul@0 | 122 | |
paul@0 | 123 | epd_cs_low(); |
paul@0 | 124 | buf[0] = 0x70; |
paul@0 | 125 | buf[1] = Register; |
paul@0 | 126 | bsp_writeToDisplay(buf, 2); |
paul@0 | 127 | epd_cs_high(); |
paul@0 | 128 | bsp_delayUs(10); |
paul@0 | 129 | |
paul@0 | 130 | epd_cs_low(); |
paul@0 | 131 | buf[0] = 0x72; |
paul@0 | 132 | bsp_writeToDisplay(buf, 1); |
paul@0 | 133 | bsp_writeToDisplay(Data, Length); |
paul@0 | 134 | epd_cs_high(); |
paul@0 | 135 | bsp_delayUs(10); |
paul@0 | 136 | } |
paul@0 | 137 | |
paul@0 | 138 | |
paul@0 | 139 | |
paul@0 | 140 | void epd_SPI_Send_Byte (uint8_t Register, uint8_t Data) |
paul@0 | 141 | { |
paul@0 | 142 | uint8_t buf[2]; |
paul@0 | 143 | |
paul@0 | 144 | epd_cs_low(); |
paul@0 | 145 | buf[0] = 0x70; |
paul@0 | 146 | buf[1] = Register; |
paul@0 | 147 | bsp_writeToDisplay(buf, 2); |
paul@0 | 148 | epd_cs_high(); |
paul@0 | 149 | bsp_delayUs(10); |
paul@0 | 150 | |
paul@0 | 151 | epd_cs_low(); |
paul@0 | 152 | buf[0] = 0x72; |
paul@0 | 153 | buf[1] = Data; |
paul@0 | 154 | bsp_writeToDisplay(buf, 2); |
paul@0 | 155 | epd_cs_high(); |
paul@0 | 156 | bsp_delayUs(10); |
paul@0 | 157 | } |
paul@0 | 158 | |
paul@0 | 159 | void epd_InitDisplayHardware(void) |
paul@0 | 160 | { |
paul@1 | 161 | bsp_InitDisplayHardware(); |
paul@0 | 162 | } |
paul@0 | 163 | |
paul@0 | 164 | //************************************************************************ |
paul@0 | 165 | void TestPinLow(void) |
paul@0 | 166 | { |
paul@0 | 167 | // TESTPin_Set(0); |
paul@0 | 168 | } |
paul@0 | 169 | void TestPinHigh(void) |
paul@0 | 170 | { |
paul@0 | 171 | // TESTPin_Set(1); |
paul@0 | 172 | } |
paul@0 | 173 | void TestPinTrigger(void) |
paul@0 | 174 | { |
paul@0 | 175 | // if(TESTPin_Get())TestPinLow(); |
paul@0 | 176 | // else TestPinHigh(); |
paul@0 | 177 | } |
paul@0 | 178 | void TestPin2Low(void) |
paul@0 | 179 | { |
paul@0 | 180 | // TESTPin2_Set(0); |
paul@0 | 181 | } |
paul@0 | 182 | void TestPin2High(void) |
paul@0 | 183 | { |
paul@0 | 184 | // TESTPin2_Set(1); |
paul@0 | 185 | } |
paul@0 | 186 | void TestPin2Trigger(void) |
paul@0 | 187 | { |
paul@0 | 188 | // if(TESTPin2_Get())TestPin2Low(); |
paul@0 | 189 | // else TestPin2High(); |
paul@0 | 190 | } |