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