1.1 --- a/Display_COG_Process.c Sun May 19 22:06:40 2013 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,616 +0,0 @@
1.4 -// Copyright 2013 Pervasive Displays, Inc.
1.5 -//
1.6 -// Licensed under the Apache License, Version 2.0 (the "License");
1.7 -// you may not use this file except in compliance with the License.
1.8 -// You may obtain a copy of the License at:
1.9 -//
1.10 -// http://www.apache.org/licenses/LICENSE-2.0
1.11 -//
1.12 -// Unless required by applicable law or agreed to in writing,
1.13 -// software distributed under the License is distributed on an
1.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1.15 -// express or implied. See the License for the specific language
1.16 -// governing permissions and limitations under the License.
1.17 -
1.18 -/******************************************************************************
1.19 - * Includes
1.20 - *****************************************************************************/
1.21 -//#include "driver_config.h"
1.22 -//#include "target_config.h"
1.23 -//#include "type.h"
1.24 -//#include "gpio.h"
1.25 -#include "Display_COG_Process.h"
1.26 -#include "Display_Hardware_Driver.h"
1.27 -#include "Display_Controller.h"
1.28 -#include <stdio.h>
1.29 -
1.30 -
1.31 -/******************************************************************************
1.32 - * Defines and typedefs
1.33 - *****************************************************************************/
1.34 -#define _GaugeFrameTimeMark 0
1.35 -
1.36 -const COG_Parameters_t COG_Parameters[3]= {
1.37 - { //for 1.44"
1.38 - {0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0x00},
1.39 - 0x03,
1.40 - (128/8),
1.41 - 96,
1.42 - (((128+96)*2)/8),
1.43 - (43),
1.44 - 480
1.45 - },
1.46 - { //for 2.0"
1.47 - {0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00},
1.48 - 0x03,
1.49 - (200/8),
1.50 - 96,
1.51 - (((200+96)*2)/8)+1,
1.52 - (53),
1.53 - 480
1.54 - },
1.55 - { //for 2.7"
1.56 - {0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00},
1.57 - 0x00,
1.58 - (264/8),
1.59 - 176,
1.60 - (((264+176)*2)/8)+1,
1.61 - 105,
1.62 - 630
1.63 - },
1.64 -};
1.65 -
1.66 -const uint8_t ScanTable[4] = {0xC0, 0x30, 0x0C, 0x03};
1.67 -
1.68 -
1.69 -/******************************************************************************
1.70 - * Local variables
1.71 - *****************************************************************************/
1.72 -static uint32_t StageTime = 480;
1.73 -static COG_LineDataPacket_t COG_Line;
1.74 -static uint16_t EPD_Type_Index = 0;
1.75 -static uint16_t cnt = 0;
1.76 -static uint32_t Currentframe;
1.77 -static uint8_t *DataLineEven;
1.78 -static uint8_t *DataLineOdd;
1.79 -static uint8_t *DataLineScan;
1.80 -static uint8_t *DisplayOrgPtr;
1.81 -
1.82 -
1.83 -/******************************************************************************
1.84 - * Local functions
1.85 - *****************************************************************************/
1.86 -static void SetTemperature_Factor(uint8_t EPD_Type_Index)
1.87 -{
1.88 - int16_t Temperature;
1.89 -
1.90 - //Get current temperature
1.91 - Temperature = epd_get_temperature();
1.92 -
1.93 - if (Temperature < -10)
1.94 - {
1.95 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 17;
1.96 - }
1.97 - else if (Temperature < -5)
1.98 - {
1.99 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 12;
1.100 - }
1.101 - else if (Temperature < 5)
1.102 - {
1.103 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 8;
1.104 - }
1.105 - else if (Temperature < 10)
1.106 - {
1.107 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 4;
1.108 - }
1.109 - else if (Temperature < 15)
1.110 - {
1.111 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 3;
1.112 - }
1.113 - else if (Temperature < 20)
1.114 - {
1.115 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 2;
1.116 - }
1.117 - else if (Temperature < 40)
1.118 - {
1.119 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 1;
1.120 - }
1.121 - else
1.122 - {
1.123 - StageTime = (COG_Parameters[EPD_Type_Index].StageTime * 7)/10;
1.124 - }
1.125 -}
1.126 -
1.127 -static void Driver_TypeSelect(uint8_t typeIndex)
1.128 -{
1.129 - switch(typeIndex)
1.130 - {
1.131 - case EPDType_144:
1.132 - DataLineEven=&COG_Line.LineDatas.COG_144LineData.Even[0];
1.133 - DataLineOdd=&COG_Line.LineDatas.COG_144LineData.Odd[0];
1.134 - DataLineScan=&COG_Line.LineDatas.COG_144LineData.Scan[0];
1.135 - break;
1.136 - case EPDType_200:
1.137 - DataLineEven=&COG_Line.LineDatas.COG_20LineData.Even[0];
1.138 - DataLineOdd=&COG_Line.LineDatas.COG_20LineData.Odd[0];
1.139 - DataLineScan=&COG_Line.LineDatas.COG_20LineData.Scan[0];
1.140 - break;
1.141 - case EPDType_270:
1.142 - DataLineEven=&COG_Line.LineDatas.COG_27LineData.Even[0];
1.143 - DataLineOdd=&COG_Line.LineDatas.COG_27LineData.Odd[0];
1.144 - DataLineScan=&COG_Line.LineDatas.COG_27LineData.Scan[0];
1.145 - break;
1.146 - }
1.147 -}
1.148 -
1.149 -//#pragma GCC optimize ("-O3")
1.150 -static void Display_Stage_1 (uint8_t *PreviousPicture)
1.151 -{
1.152 - uint16_t i,j,k; // general counters
1.153 - uint8_t TempByte; // Temporary storage for image data check
1.154 - uint16_t StartClock;
1.155 -#ifdef DISPLAY_180_DEGREE
1.156 - uint8_t *DataLinePrt;
1.157 - DisplayOrgPtr = (PreviousPicture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.158 -#else
1.159 - DisplayOrgPtr = PreviousPicture;
1.160 -#endif
1.161 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.162 -//TestPinTrigger();
1.163 - cnt = 0;
1.164 - StartClock = epd_GetCurrentTimeTick();
1.165 - do
1.166 - {
1.167 -// TestPin2Trigger();
1.168 - PreviousPicture = DisplayOrgPtr;
1.169 -#ifdef DISPLAY_180_DEGREE
1.170 - DataLinePrt = PreviousPicture;
1.171 -#endif
1.172 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.173 - {
1.174 - // SPI (0x04, ...)
1.175 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.176 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.177 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.178 - {
1.179 - TempByte = (*PreviousPicture++);
1.180 -#ifdef DISPLAY_180_DEGREE
1.181 - DataLineEven[j] = ((TempByte & 0x80) ? BLACK3 : WHITE3)
1.182 - | ((TempByte & 0x20) ? BLACK2 : WHITE2)
1.183 - | ((TempByte & 0x08) ? BLACK1 : WHITE1)
1.184 - | ((TempByte & 0x02) ? BLACK0 : WHITE0);
1.185 -
1.186 - DataLineOdd[k--] = ((TempByte & 0x01) ? BLACK3 : WHITE3)
1.187 - | ((TempByte & 0x04) ? BLACK2 : WHITE2)
1.188 - | ((TempByte & 0x10) ? BLACK1 : WHITE1)
1.189 - | ((TempByte & 0x40) ? BLACK0 : WHITE0);
1.190 - DataLinePrt--;
1.191 -#else
1.192 - DataLineOdd[j] = ((TempByte & 0x80) ? BLACK3 : WHITE3)
1.193 - | ((TempByte & 0x20) ? BLACK2 : WHITE2)
1.194 - | ((TempByte & 0x08) ? BLACK1 : WHITE1)
1.195 - | ((TempByte & 0x02) ? BLACK0 : WHITE0);
1.196 -
1.197 - DataLineEven[k--] = ((TempByte & 0x01) ? BLACK3 : WHITE3)
1.198 - | ((TempByte & 0x04) ? BLACK2 : WHITE2)
1.199 - | ((TempByte & 0x10) ? BLACK1 : WHITE1)
1.200 - | ((TempByte & 0x40) ? BLACK0 : WHITE0);
1.201 -#endif
1.202 - }
1.203 -#ifdef DISPLAY_180_DEGREE
1.204 - PreviousPicture = DataLinePrt;
1.205 -#endif
1.206 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.207 - // SPI (0x0a, line data....)
1.208 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.209 -
1.210 - // SPI (0x02, 0x25)
1.211 - epd_SPI_Send_Byte(0x02, 0x2F);
1.212 -
1.213 - DataLineScan[(i>>2)] = 0;
1.214 - }
1.215 -#if(!_GaugeFrameTimeMark)
1.216 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.217 - {
1.218 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.219 - }
1.220 -#endif
1.221 - //TestPin2Trigger();
1.222 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.223 - cnt++;
1.224 - }while (StageTime>Currentframe);
1.225 -// TestPin2Trigger();
1.226 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.227 -// TestPin2Trigger();
1.228 -// TestPinTrigger();
1.229 -}
1.230 -
1.231 -//#pragma GCC optimize ("-O3")
1.232 -static void Display_Stage_2 (uint8_t *PreviousPicture)
1.233 -{
1.234 - uint16_t i, j, k; // general counters
1.235 - uint8_t TempByte; // Temporary storage for image data check
1.236 - uint16_t StartClock;
1.237 -#ifdef DISPLAY_180_DEGREE
1.238 - uint8_t *DataLinePrt;
1.239 - DisplayOrgPtr = (PreviousPicture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.240 -#else
1.241 - DisplayOrgPtr = PreviousPicture;
1.242 -#endif
1.243 -
1.244 -// TestPinTrigger();
1.245 - cnt = 0;
1.246 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.247 - StartClock = epd_GetCurrentTimeTick();
1.248 - do
1.249 - {
1.250 -// TestPin2Trigger();
1.251 - PreviousPicture = DisplayOrgPtr;
1.252 -#ifdef DISPLAY_180_DEGREE
1.253 - DataLinePrt = PreviousPicture;
1.254 -#endif
1.255 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.256 - {
1.257 - // SPI (0x04, ...)
1.258 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.259 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.260 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // make every bit in the line black
1.261 - {
1.262 - TempByte =(*PreviousPicture++);
1.263 -#ifdef DISPLAY_180_DEGREE
1.264 - DataLineEven[j] = ((TempByte & 0x80) ? WHITE3 : NOTHING)
1.265 - | ((TempByte & 0x20) ? WHITE2 : NOTHING)
1.266 - | ((TempByte & 0x08) ? WHITE1 : NOTHING)
1.267 - | ((TempByte & 0x02) ? WHITE0 : NOTHING);
1.268 - DataLineOdd[k--] = ((TempByte & 0x01) ? WHITE3 : NOTHING)
1.269 - | ((TempByte & 0x04) ? WHITE2 : NOTHING)
1.270 - | ((TempByte & 0x10) ? WHITE1 : NOTHING)
1.271 - | ((TempByte & 0x40) ? WHITE0 : NOTHING);
1.272 - DataLinePrt--;
1.273 -#else
1.274 - DataLineOdd[j] = ((TempByte & 0x80) ? WHITE3 : NOTHING)
1.275 - | ((TempByte & 0x20) ? WHITE2 : NOTHING)
1.276 - | ((TempByte & 0x08) ? WHITE1 : NOTHING)
1.277 - | ((TempByte & 0x02) ? WHITE0 : NOTHING);
1.278 - DataLineEven[k--] = ((TempByte & 0x01) ? WHITE3 : NOTHING)
1.279 - | ((TempByte & 0x04) ? WHITE2 : NOTHING)
1.280 - | ((TempByte & 0x10) ? WHITE1 : NOTHING)
1.281 - | ((TempByte & 0x40) ? WHITE0 : NOTHING);
1.282 -#endif
1.283 - }
1.284 -
1.285 -#ifdef DISPLAY_180_DEGREE
1.286 - PreviousPicture = DataLinePrt;
1.287 -#endif
1.288 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.289 - // SPI (0x0a, line data....)
1.290 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.291 -
1.292 - epd_SPI_Send_Byte(0x02, 0x25);
1.293 -
1.294 - DataLineScan[(i>>2)] = 0;
1.295 - }
1.296 -#if(!_GaugeFrameTimeMark)
1.297 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.298 - {
1.299 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.300 - }
1.301 -#endif
1.302 - //TestPin2Trigger();
1.303 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.304 - cnt++;
1.305 - }while (StageTime>Currentframe);
1.306 -// TestPin2Trigger();
1.307 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.308 -// TestPin2Trigger();
1.309 -// TestPinTrigger();
1.310 -}
1.311 -
1.312 -
1.313 -//#pragma GCC optimize ("-O3")
1.314 -static void Display_Stage_3 (uint8_t *Picture)
1.315 -{
1.316 - uint16_t i, j,k; // general counters
1.317 - uint8_t TempByte; // Temporary storage for image data check
1.318 - uint16_t StartClock;
1.319 -#ifdef DISPLAY_180_DEGREE
1.320 - uint8_t *DataLinePrt;
1.321 - DisplayOrgPtr = (Picture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.322 -#else
1.323 - DisplayOrgPtr = Picture;
1.324 -#endif
1.325 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.326 - cnt = 0;
1.327 -// TestPinTrigger();
1.328 - StartClock = epd_GetCurrentTimeTick();
1.329 - do
1.330 - {
1.331 -// TestPin2Trigger();
1.332 - Picture = DisplayOrgPtr;
1.333 -#ifdef DISPLAY_180_DEGREE
1.334 - DataLinePrt = Picture;
1.335 -#endif
1.336 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.337 - {
1.338 - // SPI (0x04, 0x03)
1.339 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.340 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.341 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.342 - {
1.343 - TempByte = (*Picture++);
1.344 -#ifdef DISPLAY_180_DEGREE
1.345 - DataLineEven[j] = ((TempByte & 0x80) ? BLACK3 : NOTHING)
1.346 - | ((TempByte & 0x20) ? BLACK2 : NOTHING )
1.347 - | ((TempByte & 0x08) ? BLACK1 : NOTHING )
1.348 - | ((TempByte & 0x02) ? BLACK0 : NOTHING );
1.349 -
1.350 - DataLineOdd[k--] = ((TempByte & 0x01) ? BLACK3 : NOTHING)
1.351 - | ((TempByte & 0x04) ? BLACK2 : NOTHING )
1.352 - | ((TempByte & 0x10) ? BLACK1 : NOTHING )
1.353 - | ((TempByte & 0x40) ? BLACK0 : NOTHING );
1.354 - DataLinePrt--;
1.355 -#else
1.356 - DataLineOdd[j] = ((TempByte & 0x80) ? BLACK3 : NOTHING)
1.357 - | ((TempByte & 0x20) ? BLACK2 : NOTHING )
1.358 - | ((TempByte & 0x08) ? BLACK1 : NOTHING )
1.359 - | ((TempByte & 0x02) ? BLACK0 : NOTHING );
1.360 -
1.361 - DataLineEven[k--] = ((TempByte & 0x01) ? BLACK3 : NOTHING)
1.362 - | ((TempByte & 0x04) ? BLACK2 : NOTHING )
1.363 - | ((TempByte & 0x10) ? BLACK1 : NOTHING )
1.364 - | ((TempByte & 0x40) ? BLACK0 : NOTHING );
1.365 -#endif
1.366 - }
1.367 -#ifdef DISPLAY_180_DEGREE
1.368 - Picture = DataLinePrt;
1.369 -#endif
1.370 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.371 - // SPI (0x0a, line data....)
1.372 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.373 -
1.374 - epd_SPI_Send_Byte(0x02, 0x2F);
1.375 -
1.376 - DataLineScan[(i>>2)] = 0;
1.377 - }
1.378 -#if(!_GaugeFrameTimeMark)
1.379 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.380 - {
1.381 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.382 - }
1.383 -#endif
1.384 - //TestPin2Trigger();
1.385 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.386 - cnt++;
1.387 - }while (StageTime>Currentframe);
1.388 -// TestPin2Trigger();
1.389 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.390 -// TestPin2Trigger();
1.391 -// TestPinTrigger();
1.392 -}
1.393 -
1.394 -//#pragma GCC optimize ("-O3")
1.395 -static void Display_Stage_4 (uint8_t *Picture)
1.396 -{
1.397 - uint16_t i, j,k; // general counters
1.398 - uint8_t TempByte; // Temporary storage for image data check
1.399 - uint16_t StartClock;
1.400 -#ifdef DISPLAY_180_DEGREE
1.401 - uint8_t *DataLinePrt;
1.402 - DisplayOrgPtr = (Picture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.403 -#else
1.404 - DisplayOrgPtr = Picture;
1.405 -#endif
1.406 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.407 - cnt = 0;
1.408 -// TestPinTrigger();
1.409 -
1.410 - StartClock = epd_GetCurrentTimeTick();
1.411 - do
1.412 - {
1.413 -// TestPin2Trigger();
1.414 - Picture = DisplayOrgPtr;
1.415 -#ifdef DISPLAY_180_DEGREE
1.416 - DataLinePrt = Picture;
1.417 -#endif
1.418 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.419 - {
1.420 - // SPI (0x04, ...)
1.421 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.422 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.423 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.424 - {
1.425 - TempByte =(*Picture++);
1.426 -#ifdef DISPLAY_180_DEGREE
1.427 - DataLineEven[j] = ((TempByte & 0x80) ? WHITE3 : BLACK3 )
1.428 - | ((TempByte & 0x20) ? WHITE2 : BLACK2 )
1.429 - | ((TempByte & 0x08) ? WHITE1 : BLACK1 )
1.430 - | ((TempByte & 0x02) ? WHITE0 : BLACK0 );
1.431 -
1.432 - DataLineOdd[k--] = ((TempByte & 0x01) ? WHITE3 : BLACK3 )
1.433 - | ((TempByte & 0x04) ? WHITE2 : BLACK2 )
1.434 - | ((TempByte & 0x10) ? WHITE1 : BLACK1 )
1.435 - | ((TempByte & 0x40) ? WHITE0 : BLACK0 );
1.436 - DataLinePrt--;
1.437 -#else
1.438 - DataLineOdd[j] = ((TempByte & 0x80) ? WHITE3 : BLACK3 )
1.439 - | ((TempByte & 0x20) ? WHITE2 : BLACK2 )
1.440 - | ((TempByte & 0x08) ? WHITE1 : BLACK1 )
1.441 - | ((TempByte & 0x02) ? WHITE0 : BLACK0 );
1.442 -
1.443 - DataLineEven[k--] = ((TempByte & 0x01) ? WHITE3 : BLACK3 )
1.444 - | ((TempByte & 0x04) ? WHITE2 : BLACK2 )
1.445 - | ((TempByte & 0x10) ? WHITE1 : BLACK1 )
1.446 - | ((TempByte & 0x40) ? WHITE0 : BLACK0 );
1.447 -#endif
1.448 - }
1.449 -#ifdef DISPLAY_180_DEGREE
1.450 - Picture = DataLinePrt;
1.451 -#endif
1.452 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.453 - // SPI (0x0a, line data....)
1.454 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.455 -
1.456 - epd_SPI_Send_Byte(0x02, 0x2F);
1.457 -
1.458 - DataLineScan[(i>>2)] = 0;
1.459 - }
1.460 -#if(!_GaugeFrameTimeMark)
1.461 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.462 - {
1.463 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.464 - }
1.465 -#endif
1.466 - //TestPin2Trigger();
1.467 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.468 - cnt++;
1.469 - }while (StageTime>Currentframe);
1.470 -
1.471 -// TestPin2Trigger();
1.472 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.473 -// TestPin2Trigger();
1.474 -// TestPinTrigger();
1.475 -}
1.476 -
1.477 -static void Display_Nothing (void)
1.478 -{
1.479 - uint16_t i; // general counters
1.480 -
1.481 - for (i = 0; i < COG_Parameters[EPD_Type_Index].HORIZONTAL; i++) // make every bit in the line white
1.482 - {
1.483 - DataLineEven[i] = 0x00;
1.484 - DataLineOdd[i] = 0x00;
1.485 - }
1.486 -
1.487 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.488 - {
1.489 - epd_SPI_Send_Byte(0x04, 0x03);
1.490 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.491 - // SPI (0x0a, line data....)
1.492 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.493 -
1.494 - epd_SPI_Send_Byte(0x02, 0x2F);
1.495 - }
1.496 -}
1.497 -
1.498 -static void Dummy_line(void)
1.499 -{
1.500 - uint16_t i;
1.501 -
1.502 - for (i = 0; i < COG_Parameters[EPD_Type_Index].DataLineSize; i++)
1.503 - {
1.504 - COG_Line.uint8[i] = 0x00;
1.505 - }
1.506 -
1.507 - epd_SPI_Send_Byte(0x04, 0x03);
1.508 -
1.509 - // SPI (0x0a, line data....)
1.510 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.511 -
1.512 - epd_SPI_Send_Byte(0x02, 0x2F);
1.513 -}
1.514 -
1.515 -
1.516 -/******************************************************************************
1.517 - * Public functions
1.518 - *****************************************************************************/
1.519 -void epd_HwInit(void)
1.520 -{
1.521 - epd_InitDisplayHardware();
1.522 -}
1.523 -
1.524 -void epd_PowerOn(void)
1.525 -{
1.526 - bsp_PowerOn();
1.527 -}
1.528 -
1.529 -void epd_InitializeDriver(uint8_t EPDIndex)
1.530 -{
1.531 - uint8_t SendBuffer[2];
1.532 - uint16_t k;
1.533 -
1.534 - EPD_Type_Index = EPDIndex;
1.535 -
1.536 - //Data Line Clear
1.537 - for (k = 0; k <= __LineDataSize; k ++)
1.538 - {
1.539 - COG_Line.uint8[k] = 0x00;
1.540 - }
1.541 - Driver_TypeSelect(EPDIndex);
1.542 - k = 0;
1.543 -
1.544 - SetTemperature_Factor(EPDIndex);
1.545 -
1.546 - /*while (DRIVERBUSY_Get())
1.547 - {
1.548 - delayT32B0Us(500);
1.549 - if((k++)>=1000) return;//wait 500 ms
1.550 - }
1.551 - */
1.552 -
1.553 - // SPI (0x01, 0x0000, 0x0000, 0x01ff, 0xe000)
1.554 - epd_SPI_Send(0x01, (uint8_t *)&COG_Parameters[EPDIndex].ChannelSelect, 8);
1.555 -
1.556 - epd_SPI_Send_Byte(0x06, 0xff);
1.557 - epd_SPI_Send_Byte(0x07, 0x9d);
1.558 - epd_SPI_Send_Byte(0x08, 0x00);
1.559 -
1.560 - // SPI (0x09, 0xd000)
1.561 - SendBuffer[0] = 0xd0;
1.562 - SendBuffer[1] = 0x00;
1.563 - epd_SPI_Send(0x09, SendBuffer, 2);
1.564 -
1.565 - epd_SPI_Send_Byte(0x04,COG_Parameters[EPDIndex].VoltageLevel);
1.566 -
1.567 - epd_SPI_Send_Byte(0x03, 0x01);
1.568 - epd_SPI_Send_Byte(0x03, 0x00);
1.569 -
1.570 - epd_pwm_active(5);
1.571 -
1.572 - epd_SPI_Send_Byte(0x05, 0x01);
1.573 -
1.574 - epd_pwm_active(30);
1.575 -
1.576 - epd_SPI_Send_Byte(0x05, 0x03);
1.577 - epd_delay_ms(30);
1.578 - epd_SPI_Send_Byte(0x05, 0x0f);
1.579 - epd_delay_ms(30);
1.580 - epd_SPI_Send_Byte(0x02, 0x24);
1.581 - printf("Done initialisation.\n");
1.582 -}
1.583 -
1.584 -void epd_Display (uint8_t *pNewImg, uint8_t *pPrevImg)
1.585 -{
1.586 - //COG Process - update display in four steps
1.587 - Display_Stage_1(pPrevImg);
1.588 - Display_Stage_2(pPrevImg);
1.589 - Display_Stage_3(pNewImg);
1.590 - Display_Stage_4(pNewImg);
1.591 -}
1.592 -
1.593 -void epd_PowerOff (void)
1.594 -{
1.595 - Display_Nothing();
1.596 - Dummy_line();
1.597 - epd_delay_ms(25);
1.598 -
1.599 - //border_low();
1.600 - //epd_delay_ms(_30ms);
1.601 - //border_high();
1.602 -
1.603 - epd_SPI_Send_Byte(0x03, 0x01);
1.604 - epd_SPI_Send_Byte(0x02, 0x05);
1.605 - epd_SPI_Send_Byte(0x05, 0x0E);
1.606 - epd_SPI_Send_Byte(0x05, 0x02);
1.607 - epd_SPI_Send_Byte(0x04, 0x0C);
1.608 - epd_delay_ms(120);
1.609 - epd_SPI_Send_Byte(0x05, 0x00);
1.610 - epd_SPI_Send_Byte(0x07, 0x0D);
1.611 - epd_SPI_Send_Byte(0x04, 0x50);
1.612 - epd_delay_ms(40);
1.613 - epd_SPI_Send_Byte(0x04, 0xA0);
1.614 - epd_delay_ms(40);
1.615 - epd_SPI_Send_Byte(0x04, 0x00);
1.616 -
1.617 - printf("Shutdown...\n");
1.618 - bsp_Shutdown();
1.619 -}
2.1 --- a/Display_COG_Process.h Sun May 19 22:06:40 2013 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,120 +0,0 @@
2.4 -// Copyright 2013 Pervasive Displays, Inc.
2.5 -//
2.6 -// Licensed under the Apache License, Version 2.0 (the "License");
2.7 -// you may not use this file except in compliance with the License.
2.8 -// You may obtain a copy of the License at:
2.9 -//
2.10 -// http://www.apache.org/licenses/LICENSE-2.0
2.11 -//
2.12 -// Unless required by applicable law or agreed to in writing,
2.13 -// software distributed under the License is distributed on an
2.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
2.15 -// express or implied. See the License for the specific language
2.16 -// governing permissions and limitations under the License.
2.17 -
2.18 -#ifndef __Display_COG_Process_H_
2.19 -#define __Display_COG_Process_H_
2.20 -
2.21 -/******************************************************************************
2.22 - * Includes
2.23 - *****************************************************************************/
2.24 -
2.25 - #include "bsp.h"
2.26 -
2.27 -/******************************************************************************
2.28 - * Defines and typedefs
2.29 - *****************************************************************************/
2.30 -#define BLACK0 (0x03)
2.31 -#define BLACK1 (0x0C)
2.32 -#define BLACK2 (0x30)
2.33 -#define BLACK3 (0xc0)
2.34 -#define WHITE0 (0x02)
2.35 -#define WHITE1 (0x08)
2.36 -#define WHITE2 (0x20)
2.37 -#define WHITE3 (0x80)
2.38 -
2.39 -#define NOTHING (0x00)
2.40 -#define SCANON (0xC0)
2.41 -#define __LineDataSize 111
2.42 -
2.43 -/*
2.44 -enum
2.45 -{
2.46 - _5ms,
2.47 - _10ms,
2.48 - _25ms,
2.49 - _30ms,
2.50 - _40ms,
2.51 - _120ms,
2.52 - _150ms,
2.53 - _300ms
2.54 -};
2.55 -*/
2.56 -
2.57 -typedef enum
2.58 -{
2.59 - EPDType_144 = 0, //1.44" display
2.60 - EPDType_200 = 1, //2.0" display
2.61 - EPDType_270 = 2 //2.7" display
2.62 -} EPDType_t;
2.63 -#define EPD_TYPE_144 0
2.64 -#define EPD_TYPE_200 1
2.65 -#define EPD_TYPE_270 2
2.66 -
2.67 -typedef struct
2.68 -{
2.69 - uint8_t Even[16];
2.70 - uint8_t Scan[24];
2.71 - uint8_t Odd [16];
2.72 -} COG_144_LineData_t;
2.73 -
2.74 -typedef struct
2.75 -{
2.76 - uint8_t Even[25];
2.77 - uint8_t Scan[24];
2.78 - uint8_t Odd [25];
2.79 - uint8_t DummyData;
2.80 -} COG_20_LineData_t;
2.81 -
2.82 -typedef struct
2.83 -{
2.84 - uint8_t Even[33];
2.85 - uint8_t Scan[44];
2.86 - uint8_t Odd [33];
2.87 - uint8_t DummyData;
2.88 -} COG_27_LineData_t;
2.89 -
2.90 -typedef union
2.91 -{
2.92 - union
2.93 - {
2.94 - COG_144_LineData_t COG_144LineData;
2.95 - COG_20_LineData_t COG_20LineData;
2.96 - COG_27_LineData_t COG_27LineData;
2.97 - } LineDatas;
2.98 - uint8_t uint8[__LineDataSize];
2.99 -} COG_LineDataPacket_t;
2.100 -
2.101 -typedef struct
2.102 -{
2.103 - uint8_t ChannelSelect[8];
2.104 - uint8_t VoltageLevel;
2.105 - uint16_t HORIZONTAL;
2.106 - uint16_t VERTICAL;
2.107 - uint8_t DataLineSize;
2.108 - uint16_t FrameTime;
2.109 - uint16_t StageTime;
2.110 -} COG_Parameters_t;
2.111 -
2.112 -extern const COG_Parameters_t COG_Parameters[3];
2.113 -
2.114 -/******************************************************************************
2.115 - * Prototypes
2.116 - *****************************************************************************/
2.117 -void epd_HwInit(void);
2.118 -void epd_PowerOn(void);
2.119 -void epd_InitializeDriver(uint8_t EPDIndex);
2.120 -void epd_Display(uint8_t *pNewImg, uint8_t *pPrevImg);
2.121 -void epd_PowerOff(void);
2.122 -
2.123 -#endif //__Display_COG_Process_H_
3.1 --- a/Display_Controller.c Sun May 19 22:06:40 2013 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,40 +0,0 @@
3.4 -// Copyright 2013 Pervasive Displays, Inc.
3.5 -//
3.6 -// Licensed under the Apache License, Version 2.0 (the "License");
3.7 -// you may not use this file except in compliance with the License.
3.8 -// You may obtain a copy of the License at:
3.9 -//
3.10 -// http://www.apache.org/licenses/LICENSE-2.0
3.11 -//
3.12 -// Unless required by applicable law or agreed to in writing,
3.13 -// software distributed under the License is distributed on an
3.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
3.15 -// express or implied. See the License for the specific language
3.16 -// governing permissions and limitations under the License.
3.17 -
3.18 -/******************************************************************************
3.19 - * Includes
3.20 - *****************************************************************************/
3.21 -//#include "driver_config.h"
3.22 -//#include "type.h"
3.23 -//#include "gpio.h"
3.24 -#include "Display_Controller.h"
3.25 -
3.26 -/******************************************************************************
3.27 - * Global Functions
3.28 - *****************************************************************************/
3.29 -
3.30 -void epd_DisplayImg(EPDType_t EPDType, uint8_t *pNewImg, uint8_t *pPrevImg)
3.31 -{
3.32 - //always initialize display (has been powered off before)
3.33 - epd_HwInit();
3.34 - epd_PowerOn();
3.35 - epd_InitializeDriver(EPDType);
3.36 -
3.37 - //display new picture, but first remove old one
3.38 - epd_Display(pNewImg, pPrevImg);
3.39 -
3.40 - //power down display - picture still displayed
3.41 - epd_PowerOff();
3.42 -}
3.43 -
4.1 --- a/Display_Controller.h Sun May 19 22:06:40 2013 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,34 +0,0 @@
4.4 -// Copyright 2013 Pervasive Displays, Inc.
4.5 -//
4.6 -// Licensed under the Apache License, Version 2.0 (the "License");
4.7 -// you may not use this file except in compliance with the License.
4.8 -// You may obtain a copy of the License at:
4.9 -//
4.10 -// http://www.apache.org/licenses/LICENSE-2.0
4.11 -//
4.12 -// Unless required by applicable law or agreed to in writing,
4.13 -// software distributed under the License is distributed on an
4.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
4.15 -// express or implied. See the License for the specific language
4.16 -// governing permissions and limitations under the License.
4.17 -
4.18 -#ifndef __Display_Controller_H_
4.19 -#define __Display_Controller_H_
4.20 -
4.21 -/******************************************************************************
4.22 - * Includes
4.23 - *****************************************************************************/
4.24 -#include "bsp.h"
4.25 -#include "Display_COG_Process.h"
4.26 -
4.27 -/******************************************************************************
4.28 - * Defines and typedefs
4.29 - *****************************************************************************/
4.30 -#define DISPLAY_IN_USE EPD_TYPE_270
4.31 -
4.32 -/******************************************************************************
4.33 - * Prototypes
4.34 - *****************************************************************************/
4.35 -void epd_DisplayImg(EPDType_t EPDType, uint8_t *pNewImg, uint8_t *pPrevImg);
4.36 -
4.37 -#endif //__Display_Controller_H_
5.1 --- a/Display_Hardware_Driver.c Sun May 19 22:06:40 2013 +0000
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,190 +0,0 @@
5.4 -// Copyright 2013 Pervasive Displays, Inc.
5.5 -//
5.6 -// Licensed under the Apache License, Version 2.0 (the "License");
5.7 -// you may not use this file except in compliance with the License.
5.8 -// You may obtain a copy of the License at:
5.9 -//
5.10 -// http://www.apache.org/licenses/LICENSE-2.0
5.11 -//
5.12 -// Unless required by applicable law or agreed to in writing,
5.13 -// software distributed under the License is distributed on an
5.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
5.15 -// express or implied. See the License for the specific language
5.16 -// governing permissions and limitations under the License.
5.17 -
5.18 -/******************************************************************************
5.19 - * Includes
5.20 - *****************************************************************************/
5.21 -#include "Display_Hardware_Driver.h"
5.22 -#include <ubb/ubb.h>
5.23 -
5.24 -
5.25 -/******************************************************************************
5.26 - * Public functions
5.27 - *****************************************************************************/
5.28 -void epd_cs_high(void)
5.29 -{
5.30 - // CS_SET_HIGH;
5.31 - SET(EPD_SSEL);
5.32 -}
5.33 -
5.34 -void epd_cs_low(void)
5.35 -{
5.36 - // CS_SET_LOW;
5.37 - CLR(EPD_SSEL);
5.38 -}
5.39 -
5.40 -void epd_rst_high(void)
5.41 -{
5.42 - // RST_SET_HIGH;
5.43 - SET(EPD_RESET);
5.44 -}
5.45 -
5.46 -void epd_rst_low(void)
5.47 -{
5.48 - // RST_SET_LOW;
5.49 - CLR(EPD_RESET);
5.50 -}
5.51 -
5.52 -void epd_delay_ms(uint32_t Time)
5.53 -{
5.54 - bsp_delayMs(Time);
5.55 -}
5.56 -
5.57 -int16_t epd_get_temperature(void)
5.58 -{
5.59 - return bsp_getTemp();
5.60 -}
5.61 -
5.62 -uint32_t epd_GetCurrentTimeTick(void)
5.63 -{
5.64 - return bsp_getMsTicks();
5.65 -}
5.66 -
5.67 -//******************************************************************
5.68 -//PWM Configuration/Control
5.69 -//******************************************************************
5.70 -#if 0
5.71 -volatile uint32_t period = 500; //96Khz PWM frequency
5.72 -
5.73 -void epd_pwm_disable(void)
5.74 -{
5.75 - disable_timer16(1);
5.76 - LPC_IOCON->PIO1_9 &= 0xFC;//Disable PWM,set general IO
5.77 - PWM_DIR_OUT();
5.78 - PWM_SET_LOW();
5.79 -}
5.80 -
5.81 -void epd_pwm_active(void)
5.82 -{
5.83 - PWM_SET_HIGH();
5.84 - /* Initialize the PWM in timer32_1 enabling match0 output */
5.85 - init_timer16PWM(1, period, MATCH0,0);
5.86 - setMatch_timer16PWM (1, 1, period/8);
5.87 - enable_timer16(1);
5.88 -}
5.89 -#endif
5.90 -void epd_pwm_active(uint16_t delayInMs)
5.91 -{
5.92 - bsp_pwm_active(delayInMs);
5.93 -}
5.94 -
5.95 -
5.96 -//******************************************************************
5.97 -//SPI Configuration
5.98 -//******************************************************************
5.99 -void epd_spi_detach(void)
5.100 -{
5.101 -#if 0
5.102 - LPC_IOCON->PIO0_8 &= 0xFC;; /* SSP I/O config */
5.103 - SPIMISO_DIR_OUT();
5.104 - SPIMISO_Set(Low);
5.105 -
5.106 - LPC_IOCON->PIO0_9 &= 0xFC; /* SSP MOSI */
5.107 - SPIMOSI_DIR_OUT();
5.108 - SPIMOSI_Set(Low);
5.109 -
5.110 - LPC_IOCON->PIO2_11 &= 0xFC;
5.111 - SPICLK_DIR_OUT();
5.112 - SPICLK_Set(Low);
5.113 -#endif
5.114 -}
5.115 -void epd_spi_init (void)
5.116 -{
5.117 - bsp_spiInit();
5.118 -//SSP_IOConfig( SSP_PORT ); /* initialize SSP port */
5.119 -//SSP_Init( SSP_PORT );
5.120 -}
5.121 -
5.122 -void epd_SPI_Send (unsigned char Register, unsigned char *Data, unsigned Length)
5.123 -{
5.124 - uint8_t buf[2];
5.125 -
5.126 - epd_cs_low();
5.127 - buf[0] = 0x70;
5.128 - buf[1] = Register;
5.129 - bsp_writeToDisplay(buf, 2);
5.130 - epd_cs_high();
5.131 - bsp_delayUs(10);
5.132 -
5.133 - epd_cs_low();
5.134 - buf[0] = 0x72;
5.135 - bsp_writeToDisplay(buf, 1);
5.136 - bsp_writeToDisplay(Data, Length);
5.137 - epd_cs_high();
5.138 - bsp_delayUs(10);
5.139 -}
5.140 -
5.141 -
5.142 -
5.143 -void epd_SPI_Send_Byte (uint8_t Register, uint8_t Data)
5.144 -{
5.145 - uint8_t buf[2];
5.146 -
5.147 - epd_cs_low();
5.148 - buf[0] = 0x70;
5.149 - buf[1] = Register;
5.150 - bsp_writeToDisplay(buf, 2);
5.151 - epd_cs_high();
5.152 - bsp_delayUs(10);
5.153 -
5.154 - epd_cs_low();
5.155 - buf[0] = 0x72;
5.156 - buf[1] = Data;
5.157 - bsp_writeToDisplay(buf, 2);
5.158 - epd_cs_high();
5.159 - bsp_delayUs(10);
5.160 -}
5.161 -
5.162 -void epd_InitDisplayHardware(void)
5.163 -{
5.164 - bsp_InitDisplayHardware();
5.165 -}
5.166 -
5.167 -//************************************************************************
5.168 -void TestPinLow(void)
5.169 -{
5.170 -// TESTPin_Set(0);
5.171 -}
5.172 -void TestPinHigh(void)
5.173 -{
5.174 -// TESTPin_Set(1);
5.175 -}
5.176 -void TestPinTrigger(void)
5.177 -{
5.178 -// if(TESTPin_Get())TestPinLow();
5.179 -// else TestPinHigh();
5.180 -}
5.181 -void TestPin2Low(void)
5.182 -{
5.183 -// TESTPin2_Set(0);
5.184 -}
5.185 -void TestPin2High(void)
5.186 -{
5.187 -// TESTPin2_Set(1);
5.188 -}
5.189 -void TestPin2Trigger(void)
5.190 -{
5.191 -// if(TESTPin2_Get())TestPin2Low();
5.192 -// else TestPin2High();
5.193 -}
6.1 --- a/Display_Hardware_Driver.h Sun May 19 22:06:40 2013 +0000
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,95 +0,0 @@
6.4 -// Copyright 2013 Pervasive Displays, Inc.
6.5 -//
6.6 -// Licensed under the Apache License, Version 2.0 (the "License");
6.7 -// you may not use this file except in compliance with the License.
6.8 -// You may obtain a copy of the License at:
6.9 -//
6.10 -// http://www.apache.org/licenses/LICENSE-2.0
6.11 -//
6.12 -// Unless required by applicable law or agreed to in writing,
6.13 -// software distributed under the License is distributed on an
6.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
6.15 -// express or implied. See the License for the specific language
6.16 -// governing permissions and limitations under the License.
6.17 -
6.18 -#ifndef __DISPLAY_HARDWARE_DRIVER_H_
6.19 -#define __DISPLAY_HARDWARE_DRIVER_H_
6.20 -
6.21 -/******************************************************************************
6.22 - * Includes
6.23 - *****************************************************************************/
6.24 -
6.25 -#include "bsp.h"
6.26 -
6.27 -
6.28 -/******************************************************************************
6.29 - * Defines and typedefs
6.30 - *****************************************************************************/
6.31 -
6.32 -//Pin 12 on Serial Expansion Connector
6.33 -// #define RST_DIR_OUT SEC14_PIN12_SET_OUTP
6.34 -// #define RST_SET_HIGH SEC14_PIN12_SET_HIGH
6.35 -// #define RST_SET_LOW SEC14_PIN12_SET_LOW
6.36 -
6.37 -//Pin 14 on Serial Expansion Connector
6.38 -// #define DISCHARGE_DIR_OUT SEC14_PIN14_SET_OUTP
6.39 -// #define DISCHARGE_SET_HIGH SEC14_PIN14_SET_HIGH
6.40 -// #define DISCHARGE_SET_LOW SEC14_PIN14_SET_LOW
6.41 -
6.42 -//Pin 6 on Serial Expansion Connector
6.43 -// #define CS_DIR_OUT SEC14_PIN6_SET_OUTP
6.44 -// #define CS_SET_HIGH SEC14_PIN6_SET_HIGH
6.45 -// #define CS_SET_LOW SEC14_PIN6_SET_LOW
6.46 -
6.47 -//Pin 13 on Serial Expansion Connector
6.48 -// #define PANELON_DIR_OUT SEC14_PIN13_SET_OUTP
6.49 -// #define PANELON_SET_HIGH SEC14_PIN13_SET_HIGH
6.50 -// #define PANELON_SET_LOW SEC14_PIN13_SET_LOW
6.51 -
6.52 -//Pin 7 on Serial Expansion Connector
6.53 -// #define DRIVERBUSY_DIR_IN SEC14_PIN7_SET_INP
6.54 -// #define DRIVERBUSY_GET SEC14_PIN7_INP
6.55 -
6.56 -//Not implemented
6.57 -// #define BORDER_DIR_OUT
6.58 -// #define BORDER_SET_HIGH
6.59 -// #define BORDER_SET_LOW
6.60 -
6.61 -//Pin 11 on Serial Expansion Connector
6.62 -// #define PWM_DIR_OUT SEC14_PIN11_SET_OUTP
6.63 -// #define PWM_SET_HIGH SEC14_PIN11_SET_HIGH
6.64 -// #define PWM_SET_LOW SEC14_PIN11_SET_LOW
6.65 -
6.66 -
6.67 -/******************************************************************************
6.68 - * Prototypes
6.69 - *****************************************************************************/
6.70 -void epd_cs_high(void);
6.71 -void epd_cs_low(void);
6.72 -void epd_rst_high(void);
6.73 -void epd_rst_low(void);
6.74 -
6.75 -void epd_pwm_active(uint16_t delayInMs);
6.76 -
6.77 -void epd_TestPinLow(void);
6.78 -void epd_TestPinHigh(void);
6.79 -void epd_TestPinTrigger(void);
6.80 -
6.81 -void epd_TestPin2Low(void);
6.82 -void epd_TestPin2High(void);
6.83 -void epd_TestPin2Trigger(void);
6.84 -
6.85 -void epd_delay_ms(uint32_t Time);
6.86 -int16_t epd_get_temperature(void);
6.87 -uint32_t epd_GetCurrentTimeTick(void);
6.88 -
6.89 -/***************************************************************************/
6.90 -void epd_spi_detach(void);
6.91 -void epd_spi_init (void);
6.92 -void epd_SPI_Send (unsigned char Register, unsigned char *Data, unsigned Length);
6.93 -void epd_SPI_Send_Byte (uint8_t Register, uint8_t Data);
6.94 -void epd_InitDisplayHardware (void);
6.95 -
6.96 -/****************************************************************************/
6.97 -
6.98 -#endif //__DISPLAY_HARDWARE_DRIVER_H_
7.1 --- a/EPD.c Sun May 19 22:06:40 2013 +0000
7.2 +++ b/EPD.c Tue May 21 15:08:07 2013 +0000
7.3 @@ -14,25 +14,14 @@
7.4
7.5
7.6 #include "EPD.h"
7.7 +#include "bsp.h"
7.8 +#include <stdio.h>
7.9
7.10 -typedef enum {
7.11 - LOW=0,
7.12 - HIGH=1
7.13 -} EPD_pinstate;
7.14 -
7.15 -static void EPD_line(uint16_t line, const uint8_t *data, uint8_t fixed_value, uint8_t read_progmem, EPD_stage stage);
7.16 +static void EPD_line(uint16_t line, const uint8_t *data, uint8_t fixed_value, EPD_stage stage);
7.17 static void SPI_send(const uint8_t *buffer, uint16_t length);
7.18 static void SPI_put(uint8_t c);
7.19 static void SPI_put_wait(uint8_t c);
7.20
7.21 -static void EPD_Pin_init();
7.22 -static void EPD_Pin_EPD_CS(EPD_pinstate pin);
7.23 -static void EPD_Pin_RESET(EPD_pinstate pin);
7.24 -static void EPD_Pin_PANEL_ON(EPD_pinstate pin);
7.25 -static void EPD_Pin_DISCHARGE(EPD_pinstate pin);
7.26 -static void EPD_Pin_BORDER(EPD_pinstate pin);
7.27 -static EPD_pinstate epd_get_busy(void);
7.28 -
7.29 static void epd_pwm_active(uint16_t delayInMs);
7.30
7.31
7.32 @@ -80,28 +69,18 @@
7.33 static void EPD_frame_fixed(uint8_t fixed_value, EPD_stage stage) {
7.34 uint8_t line;
7.35 for (line = 0; line < epd.lines_per_display ; ++line) {
7.36 - EPD_line(line, 0, fixed_value, FALSE, stage);
7.37 + EPD_line(line, 0, fixed_value, stage);
7.38 }
7.39 }
7.40
7.41 -static void EPD_frame_data(PROGMEM const uint8_t *image, EPD_stage stage){
7.42 +static void EPD_frame_data(const uint8_t *image, EPD_stage stage){
7.43 uint8_t line;
7.44 for (line = 0; line < epd.lines_per_display ; ++line) {
7.45 - EPD_line(line, &image[line * epd.bytes_per_line], 0, TRUE, stage);
7.46 + EPD_line(line, &image[line * epd.bytes_per_line], 0, stage);
7.47 }
7.48 }
7.49
7.50
7.51 -#if defined(EPD_ENABLE_EXTRA_SRAM)
7.52 -static void EPD_frame_sram(const uint8_t *image, EPD_stage stage){
7.53 - uint8_t line;
7.54 - for (line = 0; line < epd.lines_per_display ; ++line) {
7.55 - EPD_line(line, &image[line * epd.bytes_per_line], 0, FALSE, stage);
7.56 - }
7.57 -}
7.58 -#endif
7.59 -
7.60 -
7.61 static void EPD_frame_fixed_repeat(uint8_t fixed_value, EPD_stage stage) {
7.62 int32_t stage_time = epd.factored_stage_time;
7.63 do {
7.64 @@ -117,7 +96,7 @@
7.65 }
7.66
7.67
7.68 -static void EPD_frame_data_repeat(PROGMEM const uint8_t *image, EPD_stage stage) {
7.69 +static void EPD_frame_data_repeat(const uint8_t *image, EPD_stage stage) {
7.70 int32_t stage_time = epd.factored_stage_time;
7.71 do {
7.72 uint32_t t_start = bsp_getMsTicks();
7.73 @@ -131,51 +110,7 @@
7.74 } while (stage_time > 0);
7.75 }
7.76
7.77 -#include <limits.h>
7.78 -#if defined(EPD_ENABLE_EXTRA_SRAM)
7.79 -static void EPD_frame_sram_repeat(const uint8_t *image, EPD_stage stage) {
7.80 - int32_t stage_time = epd.factored_stage_time;
7.81 - do {
7.82 - uint32_t t_start = bsp_getMsTicks();
7.83 - EPD_frame_sram(image, stage);
7.84 - uint32_t t_end = bsp_getMsTicks();
7.85 - if (t_end > t_start) {
7.86 - stage_time -= t_end - t_start;
7.87 - } else {
7.88 - stage_time -= t_start - t_end + 1 + 0xffffffffU;
7.89 - }
7.90 - } while (stage_time > 0);
7.91 -}
7.92 -#endif
7.93 -
7.94 -#if 0
7.95 -typedef void EPD_reader(void *buffer, uint32_t address, uint16_t length);
7.96 -
7.97 -static void EPD_frame_cb(uint32_t address, EPD_reader *reader, EPD_stage stage) {
7.98 - static uint8_t buffer[264 / 8];
7.99 - uint8_t line;
7.100 - for (line = 0; line < epd.lines_per_display; ++line) {
7.101 - reader(buffer, address + line * epd.bytes_per_line, epd.bytes_per_line);
7.102 - EPD_line(line, buffer, 0, FALSE, stage);
7.103 - }
7.104 -}
7.105 -
7.106 -static void EPD_frame_cb_repeat(uint32_t address, EPD_reader *reader, EPD_stage stage) {
7.107 - int32_t stage_time = epd.factored_stage_time;
7.108 - do {
7.109 - uint32_t t_start = bsp_getMsTicks();
7.110 - EPD_frame_cb(address, reader, stage);
7.111 - uint32_t t_end = bsp_getMsTicks();
7.112 - if (t_end > t_start) {
7.113 - stage_time -= t_end - t_start;
7.114 - } else {
7.115 - stage_time -= t_start - t_end + 1 + 0xffffffffU;
7.116 - }
7.117 - } while (stage_time > 0);
7.118 -}
7.119 -#endif
7.120 -
7.121 -static void EPD_line(uint16_t line, const uint8_t *data, uint8_t fixed_value, uint8_t read_progmem, EPD_stage stage) {
7.122 +static void EPD_line(uint16_t line, const uint8_t *data, uint8_t fixed_value, EPD_stage stage) {
7.123 // charge pump voltage levels
7.124 bsp_delayUs(10);
7.125 SPI_send(CU8(0x70, 0x04), 2);
7.126 @@ -473,7 +408,7 @@
7.127 void EPD_end(void) {
7.128
7.129 EPD_frame_fixed(0x55, EPD_normal); // dummy frame
7.130 - EPD_line(0x7fffu, 0, 0x55, FALSE, EPD_normal); // dummy_line
7.131 + EPD_line(0x7fffu, 0, 0x55, EPD_normal); // dummy_line
7.132
7.133 bsp_delayMs(25);
7.134
7.135 @@ -576,32 +511,22 @@
7.136 EPD_frame_fixed_repeat(0xaa, EPD_normal);
7.137 }
7.138
7.139 -// assuming a clear (white) screen output an image (PROGMEM data)
7.140 -void EPD_image(PROGMEM const uint8_t *image) {
7.141 +// assuming a clear (white) screen output an image
7.142 +void EPD_image(const uint8_t *image) {
7.143 EPD_frame_fixed_repeat(0xaa, EPD_compensate);
7.144 EPD_frame_fixed_repeat(0xaa, EPD_white);
7.145 EPD_frame_data_repeat(image, EPD_inverse);
7.146 EPD_frame_data_repeat(image, EPD_normal);
7.147 }
7.148
7.149 -// change from old image to new image (PROGMEM data)
7.150 -void EPD_image_progmem(PROGMEM const uint8_t *old_image, PROGMEM const uint8_t *new_image) {
7.151 +// change from old image to new image
7.152 +void EPD_image_change(const uint8_t *old_image, const uint8_t *new_image) {
7.153 EPD_frame_data_repeat(old_image, EPD_compensate);
7.154 EPD_frame_data_repeat(old_image, EPD_white);
7.155 EPD_frame_data_repeat(new_image, EPD_inverse);
7.156 EPD_frame_data_repeat(new_image, EPD_normal);
7.157 }
7.158
7.159 -#if defined(EPD_ENABLE_EXTRA_SRAM)
7.160 -// change from old image to new image (SRAM version)
7.161 -void EPD_image_sram(const uint8_t *old_image, const uint8_t *new_image) {
7.162 - EPD_frame_sram_repeat(old_image, EPD_compensate);
7.163 - EPD_frame_sram_repeat(old_image, EPD_white);
7.164 - EPD_frame_sram_repeat(new_image, EPD_inverse);
7.165 - EPD_frame_sram_repeat(new_image, EPD_normal);
7.166 -}
7.167 -#endif
7.168 -
7.169
7.170 static void SPI_put(uint8_t c) {
7.171 uint8_t placeholder = c;
7.172 @@ -629,86 +554,20 @@
7.173 EPD_Pin_EPD_CS(HIGH);
7.174 }
7.175
7.176 -static void EPD_Pin_init()
7.177 -{
7.178 - bsp_pinDir(6, 1); // CS
7.179 - bsp_pinDir(7, 0); // Driver Busy
7.180 - bsp_pinDir(8, 1); // Border
7.181 - bsp_pinDir(11, 1); // Pwm
7.182 - bsp_pinDir(12, 1); // Reset
7.183 - bsp_pinDir(13, 1); // Panel On
7.184 - bsp_pinDir(14, 1); // Discharge
7.185 -}
7.186 -
7.187 -static void EPD_Pin_EPD_CS(EPD_pinstate pin)
7.188 -{
7.189 - if (HIGH == pin) {
7.190 - bsp_pinSet(6);
7.191 - }
7.192 - else {
7.193 - bsp_pinClr(6);
7.194 - }
7.195 -}
7.196 -
7.197 -static void EPD_Pin_RESET(EPD_pinstate pin)
7.198 -{
7.199 - if (HIGH == pin) {
7.200 - bsp_pinSet(12);
7.201 - }
7.202 - else {
7.203 - bsp_pinClr(12);
7.204 - }
7.205 -}
7.206 -
7.207 -static void EPD_Pin_PANEL_ON(EPD_pinstate pin)
7.208 -{
7.209 - if (HIGH == pin) {
7.210 - bsp_pinSet(13);
7.211 - }
7.212 - else {
7.213 - bsp_pinClr(13);
7.214 - }
7.215 -}
7.216 -
7.217 -static void EPD_Pin_DISCHARGE(EPD_pinstate pin)
7.218 -{
7.219 - if (HIGH == pin) {
7.220 - bsp_pinSet(14);
7.221 - }
7.222 - else {
7.223 - bsp_pinClr(14);
7.224 - }
7.225 -}
7.226 -
7.227 -static void EPD_Pin_BORDER(EPD_pinstate pin)
7.228 -{
7.229 - if (HIGH == pin) {
7.230 - bsp_pinSet(8);
7.231 - }
7.232 - else {
7.233 - bsp_pinClr(8);
7.234 - }
7.235 -}
7.236 -
7.237 -static EPD_pinstate epd_get_busy(void)
7.238 -{
7.239 - if (bsp_pinState(7))
7.240 - return HIGH;
7.241 - else
7.242 - return LOW;
7.243 -}
7.244 -
7.245 static void epd_pwm_active(uint16_t delayInMs)
7.246 {
7.247 uint16_t numOfIterations;
7.248 + uint32_t now = bsp_getMsTicks();
7.249
7.250 numOfIterations = delayInMs * 100;
7.251
7.252 for(; numOfIterations > 0; numOfIterations--)
7.253 {
7.254 - bsp_pinSet(11);
7.255 + EPD_Pin_PWM(HIGH);
7.256 bsp_delayUs(5); //100kHz
7.257 - bsp_pinClr(11);
7.258 + EPD_Pin_PWM(LOW);
7.259 bsp_delayUs(5);
7.260 }
7.261 +
7.262 + printf("PWM done for %dms.\n", bsp_getMsTicks() - now);
7.263 }
8.1 --- a/EPD.h Sun May 19 22:06:40 2013 +0000
8.2 +++ b/EPD.h Tue May 21 15:08:07 2013 +0000
8.3 @@ -16,18 +16,17 @@
8.4 #ifndef __EPD_H__
8.5 #define __EPD_H__
8.6
8.7 -#include "bsp.h"
8.8 -
8.9 -//TODO
8.10 -#define PROGMEM /*const*/
8.11 +#include <stdint.h>
8.12
8.13 -// if more SRAM available (8 kBytes)
8.14 -#define EPD_ENABLE_EXTRA_SRAM 1
8.15 +typedef enum {
8.16 + FALSE=0,
8.17 + TRUE=1
8.18 +} bool;
8.19
8.20 -//typedef enum {
8.21 -// LOW=0,
8.22 -// HIGH=1
8.23 -//} EPD_pinstate;
8.24 +typedef enum {
8.25 + LOW=0,
8.26 + HIGH=1
8.27 +} EPD_pinstate;
8.28
8.29 typedef enum {
8.30 EPD_1_44, // 128 x 96
8.31 @@ -51,9 +50,9 @@
8.32 uint16_t dots_per_line;
8.33 uint16_t bytes_per_line;
8.34 uint16_t bytes_per_scan;
8.35 - PROGMEM const uint8_t *gate_source;
8.36 + const uint8_t *gate_source;
8.37 uint16_t gate_source_length;
8.38 - PROGMEM const uint8_t *channel_select;
8.39 + const uint8_t *channel_select;
8.40 uint16_t channel_select_length;
8.41 uint8_t filler;
8.42 } COG_Parameters_t;
8.43 @@ -69,16 +68,11 @@
8.44 // clear display (anything -> white)
8.45 void EPD_clear(void);
8.46
8.47 -// assuming a clear (white) screen output an image (PROGMEM data)
8.48 -void EPD_image(PROGMEM const uint8_t *image);
8.49 +// assuming a clear (white) screen output an image
8.50 +void EPD_image(const uint8_t *image);
8.51
8.52 -// change from old image to new image (PROGMEM data)
8.53 -void EPD_image_progmem(PROGMEM const uint8_t *old_image, PROGMEM const uint8_t *new_image);
8.54 -
8.55 -#if defined(EPD_ENABLE_EXTRA_SRAM)
8.56 -// change from old image to new image (SRAM version)
8.57 -void EPD_image_sram(const uint8_t *old_image, const uint8_t *new_image);
8.58 -#endif
8.59 +// change from old image to new image
8.60 +void EPD_image_change(const uint8_t *old_image, const uint8_t *new_image);
8.61
8.62
8.63 #endif //__EPD_H__
9.1 --- a/Makefile Sun May 19 22:06:40 2013 +0000
9.2 +++ b/Makefile Tue May 21 15:08:07 2013 +0000
9.3 @@ -14,11 +14,11 @@
9.4 ARCH = mipsel-openwrt-linux
9.5 CC = $(TOOLBIN)/$(ARCH)-gcc
9.6
9.7 -CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include -DNANONOTE # -DDISPLAY_IN_USE=EPD_TYPE_270 # -DDEBUG=1
9.8 +CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include
9.9 LDFLAGS = -lubb -L$(LIBUBB) #-static #-L$(SYSLIBS)
9.10
9.11 TARGET = test
9.12 -SRC = test.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c logo.c
9.13 +SRC = test.c bsp.c EPD.c logo.c
9.14 OBJ = $(SRC:.c=.o)
9.15
9.16 .PHONY: all clean distclean
10.1 --- a/bsp.c Sun May 19 22:06:40 2013 +0000
10.2 +++ b/bsp.c Tue May 21 15:08:07 2013 +0000
10.3 @@ -35,9 +35,8 @@
10.4 #include <time.h>
10.5 #include <stdio.h>
10.6 #include "bsp.h"
10.7 -#include "Display_Hardware_Driver.h"
10.8
10.9 -void bsp_init()
10.10 +void EPD_Pin_init()
10.11 {
10.12 OUT(UBB_DAT2);
10.13 OUT(UBB_DAT3);
10.14 @@ -45,230 +44,77 @@
10.15 OUT(UBB_CLK);
10.16 OUT(UBB_DAT0);
10.17 OUT(UBB_DAT1);
10.18 -}
10.19
10.20 -/* NanoNote-specific functions. */
10.21 -
10.22 -void shift_select()
10.23 -{
10.24 - CLR(MUX_S0);
10.25 -}
10.26 -
10.27 -void shift_update()
10.28 -{
10.29 - SET(SHIFT_RCK);
10.30 - CLR(SHIFT_RCK);
10.31 -}
10.32 -
10.33 -void shift_init()
10.34 -{
10.35 - /* Initiate a clear operation. */
10.36 -
10.37 - CLR(SHIFT_SCLR);
10.38 -
10.39 - /* Set clocks to known state. */
10.40 -
10.41 - CLR(SHIFT_SCK);
10.42 - CLR(SHIFT_RCK);
10.43 -
10.44 - /* Propagate the clear operation. */
10.45 -
10.46 - shift_update();
10.47 -
10.48 - /* Finalise the initialisation. */
10.49 -
10.50 - SET(SHIFT_SCLR);
10.51 + CLR(UBB_DAT2);
10.52 + CLR(UBB_DAT3);
10.53 + CLR(UBB_CMD);
10.54 + CLR(UBB_CLK);
10.55 + CLR(UBB_DAT0);
10.56 + CLR(UBB_DAT1);
10.57 }
10.58
10.59 -void shift_reinit()
10.60 +void EPD_Pin_EPD_CS(EPD_pinstate pin)
10.61 {
10.62 - /* Set clocks to known state. */
10.63 -
10.64 - CLR(SHIFT_SCK);
10.65 - CLR(SHIFT_RCK);
10.66 -
10.67 - /* Avoid clear operation. */
10.68 -
10.69 - SET(SHIFT_SCLR);
10.70 -}
10.71 -
10.72 -void shift_in(uint8_t v)
10.73 -{
10.74 - if (v)
10.75 - SET(SHIFT_SI);
10.76 + if (pin == HIGH)
10.77 + SET(EPD_SSEL);
10.78 else
10.79 - CLR(SHIFT_SI);
10.80 -
10.81 - SET(SHIFT_SCK);
10.82 - CLR(SHIFT_SCK);
10.83 + CLR(EPD_SSEL);
10.84 }
10.85
10.86 -void epd_select()
10.87 -{
10.88 - SET(MUX_S0);
10.89 -}
10.90 -
10.91 -/* Callback functions. */
10.92 -
10.93 -void bsp_InitDisplayHardware()
10.94 +void EPD_Pin_RESET(EPD_pinstate pin)
10.95 {
10.96 - /* This should do the following:
10.97 -
10.98 - PANEL = 0
10.99 - CS/SSEL = 0
10.100 - PWM = 0
10.101 - RESET = 0
10.102 - DIS = 0
10.103 -
10.104 - (Could shift 0, 0 -> PANEL, DIS
10.105 - or 0, 0, 0 -> PANEL, BORDER, DIS.)
10.106 - */
10.107 -
10.108 - shift_select();
10.109 - shift_init(); /* PANEL = DIS = 0 */
10.110 -
10.111 - epd_select();
10.112 - CLR(EPD_SSEL);
10.113 - CLR(EPD_PWM);
10.114 - CLR(EPD_RESET);
10.115 - CLR(EPD_MOSI);
10.116 -
10.117 - printf("Hardware initialised.\n");
10.118 + if (pin == HIGH)
10.119 + SET(EPD_RESET);
10.120 + else
10.121 + CLR(EPD_RESET);
10.122 + printf("RESET = %d\n", pin);
10.123 }
10.124
10.125 -void bsp_PowerOn()
10.126 +void EPD_Pin_PANEL_ON(EPD_pinstate pin)
10.127 {
10.128 - /* This should do the following:
10.129 -
10.130 - RESET = 0
10.131 - DIS = 0
10.132 - CS/SSEL = 0
10.133 - */
10.134 -
10.135 - epd_select();
10.136 - epd_rst_low();
10.137 -
10.138 - shift_select();
10.139 - shift_init(); /* PANEL = DIS = 0 */
10.140 -
10.141 - printf("RESET = PANEL = DIS = 0\n");
10.142 -
10.143 - /* Then, the following:
10.144 -
10.145 - PWM = 1/0 (5ms)
10.146 - PANEL = 1
10.147 - PWM = 1/0 (10ms)
10.148 - BORDER = 1?
10.149 - RESET = 1
10.150 - PWM = 1/0 (5ms)
10.151 - RESET = 0
10.152 - PWM = 1/0 (5ms)
10.153 - RESET = 1
10.154 - PWM = 1/0 (5ms)
10.155 + if (pin == HIGH)
10.156 + ubb_power(1);
10.157 + else
10.158 + ubb_power(0);
10.159 + printf("PANEL = %d\n", pin);
10.160 +}
10.161
10.162 - (Could shift 1 -> PANEL => PANEL=1, DIS=0
10.163 - or 1, 1 -> PANEL, BORDER => PANEL=1, BORDER=1, DIS=0)
10.164 - */
10.165 -
10.166 - epd_select();
10.167 - epd_spi_init();
10.168 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
10.169 - epd_pwm_active(5);
10.170 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
10.171 -
10.172 - shift_select();
10.173 - shift_init(); /* PANEL = DIS = 0 (still) */
10.174 - shift_in(1); /* PANEL = 1 */
10.175 - shift_update();
10.176 - printf("PANEL = 1\n");
10.177 -
10.178 - epd_select();
10.179 - printf("PWM at 10ms starting: %u\n", bsp_getMsTicks());
10.180 - epd_pwm_active(10);
10.181 - printf("PWM at 10ms done: %u\n", bsp_getMsTicks());
10.182 - epd_cs_high();
10.183 - epd_rst_high();
10.184 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
10.185 - epd_pwm_active(5);
10.186 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
10.187 - epd_rst_low();
10.188 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
10.189 - epd_pwm_active(5);
10.190 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
10.191 - epd_rst_high();
10.192 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
10.193 - epd_pwm_active(5);
10.194 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
10.195 -
10.196 - printf("Hardware powered.\n");
10.197 +void EPD_Pin_DISCHARGE(EPD_pinstate pin)
10.198 +{
10.199 + if (pin == HIGH)
10.200 + SET(EPD_DIS);
10.201 + else
10.202 + CLR(EPD_DIS);
10.203 + printf("DIS = %d\n", pin);
10.204 }
10.205
10.206 -void bsp_pwm_active(uint16_t delayInMs)
10.207 +void EPD_Pin_BORDER(EPD_pinstate pin)
10.208 {
10.209 - uint16_t numOfIterations;
10.210 +}
10.211
10.212 - numOfIterations = delayInMs * 100;
10.213 - for (; numOfIterations > 0; numOfIterations--)
10.214 - {
10.215 - // PWM_SET_HIGH;
10.216 +void EPD_Pin_PWM(EPD_pinstate pin)
10.217 +{
10.218 + if (pin == HIGH)
10.219 SET(EPD_PWM);
10.220 - bsp_delayUs(5); //100kHz (96kHz ideal)
10.221 - // PWM_SET_LOW;
10.222 + else
10.223 CLR(EPD_PWM);
10.224 - bsp_delayUs(5);
10.225 - }
10.226 }
10.227
10.228 -void bsp_Shutdown()
10.229 +EPD_pinstate epd_get_busy()
10.230 {
10.231 - /* This should complete the power off operation as follows:
10.232 -
10.233 - RESET = 0
10.234 - CS/SSEL = 0
10.235 - PANEL = 0
10.236 - BORDER = 0?
10.237 - DIS = 1
10.238 - DIS = 0 (after 150ms)
10.239 -
10.240 - (Could shift 0 -> PANEL => PANEL=0, DIS=1
10.241 - or 0, 0 -> PANEL, BORDER => PANEL=0, BORDER=0, DIS=1)
10.242 - */
10.243 -
10.244 - epd_select();
10.245 - epd_rst_low();
10.246 - epd_cs_low();
10.247 - epd_spi_detach();
10.248 -
10.249 - shift_reinit();
10.250 - shift_select();
10.251 - shift_in(0); /* PANEL = 0; DIS = 1 */
10.252 - shift_update();
10.253 - printf("Wait for 150ms, starting: %u\n", bsp_getMsTicks());
10.254 - epd_delay_ms(150);
10.255 - printf("Wait for 150ms, done: %u\n", bsp_getMsTicks());
10.256 - shift_in(0); /* PANEL = 0; DIS = 0 */
10.257 - shift_update();
10.258 -
10.259 - printf("Hardware shut down.\n");
10.260 + bsp_delayUs(1);
10.261 + return LOW;
10.262 }
10.263
10.264 -void bsp_spiInit()
10.265 +void bsp_spiWrite(uint8_t *buffer, uint16_t length)
10.266 {
10.267 - CLR(EPD_SCK);
10.268 -}
10.269 + uint8_t mask, *ptr, *limit = buffer + length;
10.270
10.271 -/**
10.272 - * Send the given value via MOSI.
10.273 - */
10.274 -void bsp_writeToDisplay(uint8_t *data, uint16_t len)
10.275 -{
10.276 - uint8_t mask, *ptr, *limit = data + len;
10.277 -
10.278 - for (ptr = data; ptr < limit; ptr++)
10.279 + for (ptr = buffer; ptr < limit; ptr++)
10.280 {
10.281 for (mask = 0x80; mask; mask >>= 1)
10.282 {
10.283 - if (*ptr & mask)
10.284 + if (*(ptr) & mask)
10.285 {
10.286 SET(EPD_MOSI);
10.287 }
10.288 @@ -290,15 +136,12 @@
10.289
10.290 void bsp_delayUs(uint32_t us)
10.291 {
10.292 - #ifndef NANONOTE
10.293 - struct timespec tv;
10.294 - tv.tv_sec = 0;
10.295 - tv.tv_nsec = us * 100;
10.296 - nanosleep(&tv, NULL);
10.297 - #else
10.298 - uint64_t i = us * 16;
10.299 - while (i-- > 0);
10.300 - #endif
10.301 + /* uint32_t now = bsp_getUsTicks(); */
10.302 +
10.303 + /* while (bsp_getUsTicks() - now < us); */
10.304 +
10.305 + uint32_t count = us * 24;
10.306 + while (count--);
10.307 }
10.308
10.309 uint32_t bsp_getMsTicks()
10.310 @@ -308,7 +151,12 @@
10.311 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
10.312 }
10.313
10.314 -/* Unsupported. */
10.315 +uint32_t bsp_getUsTicks()
10.316 +{
10.317 + struct timeval tv;
10.318 + gettimeofday(&tv, NULL);
10.319 + return tv.tv_sec * 1000000 + tv.tv_usec;
10.320 +}
10.321
10.322 int16_t bsp_getTemp()
10.323 {
11.1 --- a/bsp.h Sun May 19 22:06:40 2013 +0000
11.2 +++ b/bsp.h Tue May 21 15:08:07 2013 +0000
11.3 @@ -2,111 +2,52 @@
11.4 #define __BSP_H__
11.5
11.6 #include <ubb/ubb.h>
11.7 +#include "EPD.h"
11.8
11.9 -/* Pin assignments (74HC4052):
11.10 - *
11.11 - * Sniffer UBB 74HC4052 #1 74HC4052 #2 10K Resistor M74HC595B1R EM027AS012
11.12 - * ------- ---- ----------- ----------- ------------ ----------- ----------
11.13 - * DAT2 DAT2 13 (1Z)
11.14 - * CD DAT3 3 (2Z)
11.15 - * CMD CMD 10 (S0) 10 (S0) IN OUT 10 (SCLR#)
11.16 - * VCC VDD 16 (VCC) 16 (VCC) 16 (VCC) 2 (3V3)
11.17 - * CLK CLK 3 (SCK)
11.18 - * GND GND 8 (GND) 8 (GND) 8 (GND) 1 (GND)
11.19 - * DAT0 DAT0 13 (1Z)
11.20 - * DAT1 DAT1 3 (2Z)
11.21 - *
11.22 - * Multiplexer pin selection:
11.23 - *
11.24 - * {Z}Y{S1/S0}
11.25 - *
11.26 - * 1Z with S1=0, S0=0 => 1Y0 (output 1, channel 0)
11.27 - * 2Z with S1=0, S0=0 => 2Y0 (output 2, channel 0)
11.28 - *
11.29 - * 1Z with S1=0, S0=1 => 1Y1 (output 1, channel 1)
11.30 - * 2Z with S1=0, S0=1 => 2Y1 (output 2, channel 1)
11.31 - *
11.32 - * Connections to the shift register (channel 0):
11.33 +/* Pin assignments:
11.34 *
11.35 - * Sniffer UBB 74HC4052 #1 M74HC595B1R
11.36 - * ------- --- ----------- -----------
11.37 - * DAT2 DAT2 12 (1Y0) 12 (RCK)
11.38 - * CD DAT3 1 (2Y0) 14 (SI)
11.39 - *
11.40 - * 74HC4052 #2
11.41 - * -----------
11.42 - * DAT0 DAT0 12 (1Y0) 10 (SCLR#)
11.43 - * DAT1 DAT1 1 (2Y0) 11 (SCK)
11.44 - *
11.45 - * Connections to the display board (channel 1):
11.46 - *
11.47 - * Sniffer UBB 74HC4052 #1 EM027AS012
11.48 - * ------- --- ----------- ----------
11.49 - * DAT2 DAT2 14 (1Y1) 4 (MOSI)
11.50 - * CD DAT3 5 (2Y1) 6 (SSEL)
11.51 - *
11.52 - * 74HC4052 #2
11.53 - * -----------
11.54 - * DAT0 DAT0 14 (1Y1) 11 (PWM)
11.55 - * DAT1 DAT1 5 (2Y1) 12 (RESET)
11.56 - *
11.57 - * Connections from the shift register (providing persistent outputs for
11.58 - * channel 0):
11.59 - *
11.60 - * M74HC595B1R EM027AS012
11.61 - * ----------- ----------
11.62 - * 15 (QA) 13 (PANEL)
11.63 - * 1 (QB) 14 (DIS)
11.64 + * Sniffer UBB EM027AS012
11.65 + * ------- ---- -----------
11.66 + * DAT2 DAT2 4 (MOSI)
11.67 + * CD DAT3 6 (SSEL)
11.68 + * CMD CMD 11 (PWM)
11.69 + * VCC VDD 13 (PANEL)
11.70 + * CLK CLK 3 (SCK)
11.71 + * GND GND
11.72 + * DAT0 DAT0 12 (RESET)
11.73 + * DAT1 DAT1 14 (DIS)
11.74 *
11.75 * General connections:
11.76 *
11.77 - * Sniffer UBB 74HC4052 M74HC595B1R
11.78 - * ------- ---- -------- -----------
11.79 - * GND GND 6 (E#) 13 (G#)
11.80 - * 7 (VEE)
11.81 - * 9 (S1)
11.82 + * EM027AS012
11.83 + * ----------
11.84 + * 1 (GND)
11.85 + * 2 (3V3)
11.86 */
11.87
11.88 -/* CMD/S0 = 0 */
11.89 -
11.90 -#define SHIFT_SCLR UBB_DAT0
11.91 -#define SHIFT_SCK UBB_DAT1
11.92 -#define SHIFT_RCK UBB_DAT2
11.93 -#define SHIFT_SI UBB_DAT3
11.94 -
11.95 -/* CMD/S1 = 1 */
11.96 -
11.97 -#define EPD_PWM UBB_DAT0
11.98 -#define EPD_RESET UBB_DAT1
11.99 -#define EPD_MOSI UBB_DAT2
11.100 -#define EPD_SSEL UBB_DAT3
11.101 -
11.102 -/* Channel-insensitive. */
11.103 -
11.104 -#define MUX_S0 UBB_CMD
11.105 -#define EPD_SCK UBB_CLK
11.106 -
11.107 -/* NanoNote-specific functions. */
11.108 -
11.109 -void shift_select();
11.110 -void shift_update();
11.111 -void shift_init();
11.112 -void shift_reinit();
11.113 -void shift_in(uint8_t v);
11.114 -void epd_select();
11.115 +#define EPD_MOSI UBB_DAT2
11.116 +#define EPD_SSEL UBB_DAT3
11.117 +#define EPD_PWM UBB_CMD
11.118 +#define EPD_SCK UBB_CLK
11.119 +#define EPD_RESET UBB_DAT0
11.120 +#define EPD_DIS UBB_DAT1
11.121
11.122 /* Board-specific interface functions. */
11.123
11.124 -void bsp_init();
11.125 -void bsp_InitDisplayHardware();
11.126 -void bsp_PowerOn();
11.127 -void bsp_pwm_active(uint16_t delayInMs);
11.128 -void bsp_Shutdown();
11.129 -void bsp_spiInit();
11.130 -void bsp_writeToDisplay(uint8_t *data, uint16_t len);
11.131 +void EPD_Pin_init();
11.132 +void EPD_Pin_EPD_CS(EPD_pinstate pin);
11.133 +void EPD_Pin_RESET(EPD_pinstate pin);
11.134 +void EPD_Pin_PANEL_ON(EPD_pinstate pin);
11.135 +void EPD_Pin_DISCHARGE(EPD_pinstate pin);
11.136 +void EPD_Pin_BORDER(EPD_pinstate pin);
11.137 +void EPD_Pin_PWM(EPD_pinstate pin);
11.138 +EPD_pinstate epd_get_busy();
11.139 +
11.140 +void bsp_spiWrite(uint8_t *buffer, uint16_t length);
11.141 void bsp_delayMs(uint32_t ms);
11.142 void bsp_delayUs(uint32_t us);
11.143 uint32_t bsp_getMsTicks();
11.144 +uint32_t bsp_getUsTicks();
11.145 int16_t bsp_getTemp();
11.146
11.147 #endif /* __BSP_H__ */
12.1 --- a/test.c Sun May 19 22:06:40 2013 +0000
12.2 +++ b/test.c Tue May 21 15:08:07 2013 +0000
12.3 @@ -15,9 +15,12 @@
12.4 #include <string.h>
12.5 #include <signal.h>
12.6 #include "logo.h"
12.7 -#include "Display_Controller.h"
12.8 +#include "EPD.h"
12.9 #include "bsp.h"
12.10
12.11 +static uint8_t old_image[264 * 176 / 8],
12.12 + new_image[264 * 176 / 8];
12.13 +
12.14 /**
12.15 * Handle termination of the process.
12.16 */
12.17 @@ -32,8 +35,6 @@
12.18
12.19 int main(int argc, char *argv[])
12.20 {
12.21 - uint8_t *current_image, blank_image[176][33];
12.22 -
12.23 signal(SIGINT, &shutdown);
12.24
12.25 if (ubb_open(0) < 0) {
12.26 @@ -41,28 +42,32 @@
12.27 return 1;
12.28 }
12.29
12.30 - ubb_power(1);
12.31 - printf("Power on.\n");
12.32 -
12.33 /* Need to initialise the board. */
12.34
12.35 - bsp_init();
12.36 + EPD_init(EPD_2_7);
12.37 printf("Initialised.\n");
12.38
12.39 /* Initialise an array containing the current image. */
12.40
12.41 - memset((uint8_t*) &blank_image[0][0], 0xff, 176*33);
12.42 - current_image = (uint8_t*) &blank_image[0][0];
12.43 - printf("Set blank image.\n");
12.44 + memset(old_image, 0, sizeof(old_image));
12.45 + /* memset(new_image, 0, sizeof(new_image)); */
12.46 + memcpy(new_image, (uint8_t *) image_data[0], sizeof(new_image));
12.47
12.48 - /* Call epd_DisplayImg with the new image and current image. */
12.49 + printf("Clear image.\n");
12.50
12.51 - epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image);
12.52 - printf("Updated image.\n");
12.53 + EPD_begin();
12.54 + EPD_setFactor(bsp_getTemp());
12.55 + EPD_clear();
12.56 + EPD_end();
12.57 +
12.58 + printf("Set image.\n");
12.59
12.60 - /* Set the current image to the new image. */
12.61 + EPD_begin();
12.62 + EPD_setFactor(bsp_getTemp());
12.63 + EPD_image_change(old_image, new_image);
12.64 + EPD_end();
12.65
12.66 - current_image = &image_data[0][0][0];
12.67 + /* memcpy(old_image, new_image, sizeof(old_image)); */
12.68
12.69 printf("Closing...\n");
12.70 ubb_close(0);