1.1 --- a/Display_COG_Process.c Sun Apr 07 18:35:52 2013 +0000
1.2 +++ b/Display_COG_Process.c Sun May 19 21:18:16 2013 +0000
1.3 @@ -22,6 +22,7 @@
1.4 #include "Display_COG_Process.h"
1.5 #include "Display_Hardware_Driver.h"
1.6 #include "Display_Controller.h"
1.7 +#include <stdio.h>
1.8
1.9
1.10 /******************************************************************************
1.11 @@ -519,32 +520,7 @@
1.12
1.13 void epd_PowerOn(void)
1.14 {
1.15 - epd_discharge_low();
1.16 - epd_rst_low();
1.17 - epd_cs_low();
1.18 - epd_spi_init();
1.19 -
1.20 - epd_pwm_active(5);
1.21 -
1.22 - epd_panelon_on();
1.23 -
1.24 - epd_pwm_active(10);
1.25 -
1.26 - epd_cs_high();
1.27 -
1.28 - //epd_border_high();
1.29 -
1.30 - epd_rst_high();
1.31 -
1.32 - epd_pwm_active(5);
1.33 -
1.34 - epd_rst_low();
1.35 -
1.36 - epd_pwm_active(5);
1.37 -
1.38 - epd_rst_high();
1.39 -
1.40 - epd_pwm_active(5);
1.41 + bsp_PowerOn();
1.42 }
1.43
1.44 void epd_InitializeDriver(uint8_t EPDIndex)
1.45 @@ -599,6 +575,7 @@
1.46 epd_SPI_Send_Byte(0x05, 0x0f);
1.47 epd_delay_ms(30);
1.48 epd_SPI_Send_Byte(0x02, 0x24);
1.49 + printf("Done initialisation.\n");
1.50 }
1.51
1.52 void epd_Display (uint8_t *pNewImg, uint8_t *pPrevImg)
1.53 @@ -633,18 +610,7 @@
1.54 epd_SPI_Send_Byte(0x04, 0xA0);
1.55 epd_delay_ms(40);
1.56 epd_SPI_Send_Byte(0x04, 0x00);
1.57 -
1.58 - epd_rst_low();
1.59 - epd_cs_low();
1.60 - epd_spi_detach();
1.61 - epd_panelon_off();
1.62 -
1.63 - //epd_border_low();
1.64 -
1.65 - epd_discharge_high();
1.66 - epd_delay_ms(150);
1.67 - epd_discharge_low();
1.68 +
1.69 + printf("Shutdown...\n");
1.70 + bsp_Shutdown();
1.71 }
1.72 -
1.73 -
1.74 -
2.1 --- a/Display_Hardware_Driver.c Sun Apr 07 18:35:52 2013 +0000
2.2 +++ b/Display_Hardware_Driver.c Sun May 19 21:18:16 2013 +0000
2.3 @@ -16,6 +16,7 @@
2.4 * Includes
2.5 *****************************************************************************/
2.6 #include "Display_Hardware_Driver.h"
2.7 +#include <ubb/ubb.h>
2.8
2.9
2.10 /******************************************************************************
2.11 @@ -24,59 +25,25 @@
2.12 void epd_cs_high(void)
2.13 {
2.14 // CS_SET_HIGH;
2.15 - bsp_pinOut(BSP_PIN_6, 1);
2.16 + SET(EPD_SSEL);
2.17 }
2.18
2.19 void epd_cs_low(void)
2.20 {
2.21 // CS_SET_LOW;
2.22 - bsp_pinOut(BSP_PIN_6, 0);
2.23 + CLR(EPD_SSEL);
2.24 }
2.25
2.26 void epd_rst_high(void)
2.27 {
2.28 // RST_SET_HIGH;
2.29 - bsp_pinOut(BSP_PIN_12, 1);
2.30 + SET(EPD_RESET);
2.31 }
2.32
2.33 void epd_rst_low(void)
2.34 {
2.35 // RST_SET_LOW;
2.36 - bsp_pinOut(BSP_PIN_12, 0);
2.37 -}
2.38 -
2.39 -void epd_discharge_high(void)
2.40 -{
2.41 - // DISCHARGE_SET_HIGH;
2.42 - bsp_pinOut(BSP_PIN_14, 1);
2.43 -}
2.44 -
2.45 -void epd_discharge_low(void)
2.46 -{
2.47 - // DISCHARGE_SET_LOW;
2.48 - bsp_pinOut(BSP_PIN_14, 0);
2.49 -}
2.50 -
2.51 -void epd_panelon_off(void)
2.52 -{
2.53 - // PANELON_SET_LOW;
2.54 - bsp_pinOut(BSP_PIN_13, 0);
2.55 -}
2.56 -
2.57 -void epd_panelon_on(void)
2.58 -{
2.59 - // PANELON_SET_HIGH;
2.60 - bsp_pinOut(BSP_PIN_13, 1);
2.61 -}
2.62 -
2.63 -void epd_border_high(void)
2.64 -{
2.65 - // BORDER_SET_HIGH;
2.66 -}
2.67 -
2.68 -void epd_border_low(void)
2.69 -{
2.70 - // BORDER_SET_LOW;
2.71 + CLR(EPD_RESET);
2.72 }
2.73
2.74 void epd_delay_ms(uint32_t Time)
2.75 @@ -119,20 +86,7 @@
2.76 #endif
2.77 void epd_pwm_active(uint16_t delayInMs)
2.78 {
2.79 - uint16_t numOfIterations;
2.80 -
2.81 - numOfIterations = delayInMs * 100;
2.82 - // PWM_DIR_OUT;
2.83 - bsp_pinMode(BSP_PIN_11, BSP_PINMODE_OUTPUT);
2.84 - for(; numOfIterations > 0; numOfIterations--)
2.85 - {
2.86 - // PWM_SET_HIGH;
2.87 - bsp_pinOut(BSP_PIN_11, 1);
2.88 - bsp_delayUs(5); //100kHz (96kHz ideal)
2.89 - // PWM_SET_LOW;
2.90 - bsp_pinOut(BSP_PIN_11, 0);
2.91 - bsp_delayUs(5);
2.92 - }
2.93 + bsp_pwm_active(delayInMs);
2.94 }
2.95
2.96
2.97 @@ -204,29 +158,7 @@
2.98
2.99 void epd_InitDisplayHardware(void)
2.100 {
2.101 - // RST_DIR_OUT;
2.102 - bsp_pinMode(BSP_PIN_12, BSP_PINMODE_OUTPUT);
2.103 - // DISCHARGE_DIR_OUT;
2.104 - bsp_pinMode(BSP_PIN_14, BSP_PINMODE_OUTPUT);
2.105 - // CS_DIR_OUT;
2.106 - bsp_pinMode(BSP_PIN_6, BSP_PINMODE_OUTPUT);
2.107 - // PANELON_DIR_OUT;
2.108 - bsp_pinMode(BSP_PIN_13, BSP_PINMODE_OUTPUT);
2.109 - // DRIVERBUSY_DIR_IN;
2.110 - bsp_pinMode(BSP_PIN_7, BSP_PINMODE_INPUT);
2.111 - // BORDER_DIR_OUT;
2.112 -
2.113 -
2.114 - epd_panelon_off();
2.115 - epd_spi_init();
2.116 - epd_cs_low();
2.117 - // epd_pwm_low();
2.118 - epd_pwm_active(0); //set output low
2.119 - epd_rst_low();
2.120 - epd_discharge_low();
2.121 -
2.122 -// TESTPin_DIR_OUT();
2.123 -// TESTPin2_DIR_OUT();
2.124 + bsp_InitDisplayHardware();
2.125 }
2.126
2.127 //************************************************************************
3.1 --- a/Display_Hardware_Driver.h Sun Apr 07 18:35:52 2013 +0000
3.2 +++ b/Display_Hardware_Driver.h Sun May 19 21:18:16 2013 +0000
3.3 @@ -68,16 +68,9 @@
3.4 void epd_cs_low(void);
3.5 void epd_rst_high(void);
3.6 void epd_rst_low(void);
3.7 -void epd_discharge_high(void);
3.8 -void epd_discharge_low(void);
3.9 -void epd_panelon_off(void);
3.10 -void epd_panelon_on(void);
3.11
3.12 void epd_pwm_active(uint16_t delayInMs);
3.13
3.14 -void epd_border_high(void);
3.15 -void epd_border_low(void);
3.16 -
3.17 void epd_TestPinLow(void);
3.18 void epd_TestPinHigh(void);
3.19 void epd_TestPinTrigger(void);
4.1 --- a/Makefile Sun Apr 07 18:35:52 2013 +0000
4.2 +++ b/Makefile Sun May 19 21:18:16 2013 +0000
4.3 @@ -9,15 +9,16 @@
4.4
4.5 LIBUBB = ../ben-blinkenlights/libubb
4.6 SYSLIBS = ../openwrt-xburst/staging_dir/target-mipsel_eglibc-2.15/usr/lib
4.7 +TOOLBIN = ../openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.6-linaro_eglibc-2.15/bin
4.8
4.9 ARCH = mipsel-openwrt-linux
4.10 -CC = $(ARCH)-gcc
4.11 +CC = $(TOOLBIN)/$(ARCH)-gcc
4.12
4.13 -CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include # -DDEBUG=1
4.14 +CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include -DNANONOTE # -DDISPLAY_IN_USE=EPD_TYPE_270 # -DDEBUG=1
4.15 LDFLAGS = -lubb -L$(LIBUBB) #-static #-L$(SYSLIBS)
4.16
4.17 TARGET = test
4.18 -SRC = test.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c
4.19 +SRC = test.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c logo.c
4.20 OBJ = $(SRC:.c=.o)
4.21
4.22 .PHONY: all clean distclean
4.23 @@ -31,7 +32,7 @@
4.24 echo "Nothing else to clean."
4.25
4.26 $(TARGET): $(OBJ)
4.27 - $(CC) $(LDFLAGS) $< -o $@
4.28 + $(CC) $(LDFLAGS) $(OBJ) -o $@
4.29
4.30 .c.o:
4.31 $(CC) -c $(CFLAGS) $< -o $@
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/bsp.c Sun May 19 21:18:16 2013 +0000
5.3 @@ -0,0 +1,316 @@
5.4 +/*
5.5 + * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication.
5.6 + *
5.7 + * Copyright (C) 2013 Paul Boddie
5.8 + *
5.9 + * SPI functions derived from those in lib/atben.c by Werner Almesberger:
5.10 + *
5.11 + * Copyright (C) 2010-2011 Werner Almesberger
5.12 + *
5.13 + * This program is free software; you can redistribute it and/or modify
5.14 + * it under the terms of the GNU General Public License as published by
5.15 + * the Free Software Foundation; either version 2 of the License, or
5.16 + * (at your option) any later version.
5.17 + *
5.18 + * Driver-related code originally provided under the following terms:
5.19 + *
5.20 + * Copyright 2013 Pervasive Displays, Inc.
5.21 + *
5.22 + * Licensed under the Apache License, Version 2.0 (the "License");
5.23 + * you may not use this file except in compliance with the License.
5.24 + * You may obtain a copy of the License at:
5.25 + *
5.26 + * http://www.apache.org/licenses/LICENSE-2.0
5.27 + *
5.28 + * Unless required by applicable law or agreed to in writing,
5.29 + * software distributed under the License is distributed on an
5.30 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
5.31 + * express or implied. See the License for the specific language
5.32 + * governing permissions and limitations under the License.
5.33 + */
5.34 +
5.35 +#include <ubb/ubb.h>
5.36 +#include <unistd.h>
5.37 +#include <sys/time.h>
5.38 +#include <time.h>
5.39 +#include <stdio.h>
5.40 +#include "bsp.h"
5.41 +#include "Display_Hardware_Driver.h"
5.42 +
5.43 +void bsp_init()
5.44 +{
5.45 + OUT(UBB_DAT2);
5.46 + OUT(UBB_DAT3);
5.47 + OUT(UBB_CMD);
5.48 + OUT(UBB_CLK);
5.49 + OUT(UBB_DAT0);
5.50 + OUT(UBB_DAT1);
5.51 +}
5.52 +
5.53 +/* NanoNote-specific functions. */
5.54 +
5.55 +void shift_select()
5.56 +{
5.57 + CLR(MUX_S0);
5.58 +}
5.59 +
5.60 +void shift_update()
5.61 +{
5.62 + SET(SHIFT_RCK);
5.63 + CLR(SHIFT_RCK);
5.64 +}
5.65 +
5.66 +void shift_init()
5.67 +{
5.68 + /* Initiate a clear operation. */
5.69 +
5.70 + CLR(SHIFT_SCLR);
5.71 +
5.72 + /* Set clocks to known state. */
5.73 +
5.74 + CLR(SHIFT_SCK);
5.75 + CLR(SHIFT_RCK);
5.76 +
5.77 + /* Propagate the clear operation. */
5.78 +
5.79 + shift_update();
5.80 +
5.81 + /* Finalise the initialisation. */
5.82 +
5.83 + SET(SHIFT_SCLR);
5.84 +}
5.85 +
5.86 +void shift_reinit()
5.87 +{
5.88 + /* Set clocks to known state. */
5.89 +
5.90 + CLR(SHIFT_SCK);
5.91 + CLR(SHIFT_RCK);
5.92 +
5.93 + /* Avoid clear operation. */
5.94 +
5.95 + SET(SHIFT_SCLR);
5.96 +}
5.97 +
5.98 +void shift_in(uint8_t v)
5.99 +{
5.100 + if (v)
5.101 + SET(SHIFT_SI);
5.102 + else
5.103 + CLR(SHIFT_SI);
5.104 +
5.105 + SET(SHIFT_SCK);
5.106 + CLR(SHIFT_SCK);
5.107 +}
5.108 +
5.109 +void epd_select()
5.110 +{
5.111 + SET(MUX_S0);
5.112 +}
5.113 +
5.114 +/* Callback functions. */
5.115 +
5.116 +void bsp_InitDisplayHardware()
5.117 +{
5.118 + /* This should do the following:
5.119 +
5.120 + PANEL = 0
5.121 + CS/SSEL = 0
5.122 + PWM = 0
5.123 + RESET = 0
5.124 + DIS = 0
5.125 +
5.126 + (Could shift 0, 0 -> PANEL, DIS
5.127 + or 0, 0, 0 -> PANEL, BORDER, DIS.)
5.128 + */
5.129 +
5.130 + shift_select();
5.131 + shift_init(); /* PANEL = DIS = 0 */
5.132 +
5.133 + epd_select();
5.134 + CLR(EPD_SSEL);
5.135 + CLR(EPD_PWM);
5.136 + CLR(EPD_RESET);
5.137 + CLR(EPD_MOSI);
5.138 +
5.139 + printf("Hardware initialised.\n");
5.140 +}
5.141 +
5.142 +void bsp_PowerOn()
5.143 +{
5.144 + /* This should do the following:
5.145 +
5.146 + RESET = 0
5.147 + DIS = 0
5.148 + CS/SSEL = 0
5.149 + */
5.150 +
5.151 + epd_select();
5.152 + epd_rst_low();
5.153 +
5.154 + shift_select();
5.155 + shift_init(); /* PANEL = DIS = 0 */
5.156 +
5.157 + printf("RESET = PANEL = DIS = 0\n");
5.158 +
5.159 + /* Then, the following:
5.160 +
5.161 + PWM = 1/0 (5ms)
5.162 + PANEL = 1
5.163 + PWM = 1/0 (10ms)
5.164 + BORDER = 1?
5.165 + RESET = 1
5.166 + PWM = 1/0 (5ms)
5.167 + RESET = 0
5.168 + PWM = 1/0 (5ms)
5.169 + RESET = 1
5.170 + PWM = 1/0 (5ms)
5.171 +
5.172 + (Could shift 1 -> PANEL => PANEL=1, DIS=0
5.173 + or 1, 1 -> PANEL, BORDER => PANEL=1, BORDER=1, DIS=0)
5.174 + */
5.175 +
5.176 + epd_select();
5.177 + epd_spi_init();
5.178 + printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
5.179 + epd_pwm_active(5);
5.180 + printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
5.181 +
5.182 + shift_select();
5.183 + shift_init(); /* PANEL = DIS = 0 (still) */
5.184 + shift_in(1); /* PANEL = 1 */
5.185 + shift_update();
5.186 + printf("PANEL = 1\n");
5.187 +
5.188 + epd_select();
5.189 + printf("PWM at 10ms starting: %u\n", bsp_getMsTicks());
5.190 + epd_pwm_active(10);
5.191 + printf("PWM at 10ms done: %u\n", bsp_getMsTicks());
5.192 + epd_cs_high();
5.193 + epd_rst_high();
5.194 + printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
5.195 + epd_pwm_active(5);
5.196 + printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
5.197 + epd_rst_low();
5.198 + printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
5.199 + epd_pwm_active(5);
5.200 + printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
5.201 + epd_rst_high();
5.202 + printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
5.203 + epd_pwm_active(5);
5.204 + printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
5.205 +
5.206 + printf("Hardware powered.\n");
5.207 +}
5.208 +
5.209 +void bsp_pwm_active(uint16_t delayInMs)
5.210 +{
5.211 + uint16_t numOfIterations;
5.212 +
5.213 + numOfIterations = delayInMs * 100;
5.214 + for (; numOfIterations > 0; numOfIterations--)
5.215 + {
5.216 + // PWM_SET_HIGH;
5.217 + SET(EPD_PWM);
5.218 + bsp_delayUs(5); //100kHz (96kHz ideal)
5.219 + // PWM_SET_LOW;
5.220 + CLR(EPD_PWM);
5.221 + bsp_delayUs(5);
5.222 + }
5.223 +}
5.224 +
5.225 +void bsp_Shutdown()
5.226 +{
5.227 + /* This should complete the power off operation as follows:
5.228 +
5.229 + RESET = 0
5.230 + CS/SSEL = 0
5.231 + PANEL = 0
5.232 + BORDER = 0?
5.233 + DIS = 1
5.234 + DIS = 0 (after 150ms)
5.235 +
5.236 + (Could shift 0 -> PANEL => PANEL=0, DIS=1
5.237 + or 0, 0 -> PANEL, BORDER => PANEL=0, BORDER=0, DIS=1)
5.238 + */
5.239 +
5.240 + epd_select();
5.241 + epd_rst_low();
5.242 + epd_cs_low();
5.243 + epd_spi_detach();
5.244 +
5.245 + shift_reinit();
5.246 + shift_select();
5.247 + shift_in(0); /* PANEL = 0; DIS = 1 */
5.248 + shift_update();
5.249 + printf("Wait for 150ms, starting: %u\n", bsp_getMsTicks());
5.250 + epd_delay_ms(150);
5.251 + printf("Wait for 150ms, done: %u\n", bsp_getMsTicks());
5.252 + shift_in(0); /* PANEL = 0; DIS = 0 */
5.253 + shift_update();
5.254 +
5.255 + printf("Hardware shut down.\n");
5.256 +}
5.257 +
5.258 +void bsp_spiInit()
5.259 +{
5.260 + CLR(EPD_SCK);
5.261 +}
5.262 +
5.263 +/**
5.264 + * Send the given value via MOSI.
5.265 + */
5.266 +void bsp_writeToDisplay(uint8_t *data, uint16_t len)
5.267 +{
5.268 + uint8_t mask, *ptr, *limit = data + len;
5.269 +
5.270 + for (ptr = data; ptr < limit; ptr++)
5.271 + {
5.272 + for (mask = 0x80; mask; mask >>= 1)
5.273 + {
5.274 + if (*ptr & mask)
5.275 + {
5.276 + SET(EPD_MOSI);
5.277 + }
5.278 + else
5.279 + {
5.280 + CLR(EPD_MOSI);
5.281 + }
5.282 +
5.283 + SET(EPD_SCK);
5.284 + CLR(EPD_SCK);
5.285 + }
5.286 + }
5.287 +}
5.288 +
5.289 +void bsp_delayMs(uint32_t ms)
5.290 +{
5.291 + bsp_delayUs(ms * 1000);
5.292 +}
5.293 +
5.294 +void bsp_delayUs(uint32_t us)
5.295 +{
5.296 + #ifndef NANONOTE
5.297 + struct timespec tv;
5.298 + tv.tv_sec = 0;
5.299 + tv.tv_nsec = us * 100;
5.300 + nanosleep(&tv, NULL);
5.301 + #else
5.302 + uint64_t i = us * 16;
5.303 + while (i-- > 0);
5.304 + #endif
5.305 +}
5.306 +
5.307 +uint32_t bsp_getMsTicks()
5.308 +{
5.309 + struct timeval tv;
5.310 + gettimeofday(&tv, NULL);
5.311 + return tv.tv_sec * 1000 + tv.tv_usec / 1000;
5.312 +}
5.313 +
5.314 +/* Unsupported. */
5.315 +
5.316 +int16_t bsp_getTemp()
5.317 +{
5.318 + return 20;
5.319 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/bsp.h Sun May 19 21:18:16 2013 +0000
6.3 @@ -0,0 +1,112 @@
6.4 +#ifndef __BSP_H__
6.5 +#define __BSP_H__
6.6 +
6.7 +#include <ubb/ubb.h>
6.8 +
6.9 +/* Pin assignments (74HC4052):
6.10 + *
6.11 + * Sniffer UBB 74HC4052 #1 74HC4052 #2 10K Resistor M74HC595B1R EM027AS012
6.12 + * ------- ---- ----------- ----------- ------------ ----------- ----------
6.13 + * DAT2 DAT2 13 (1Z)
6.14 + * CD DAT3 3 (2Z)
6.15 + * CMD CMD 10 (S0) 10 (S0) IN OUT 10 (SCLR#)
6.16 + * VCC VDD 16 (VCC) 16 (VCC) 16 (VCC) 2 (3V3)
6.17 + * CLK CLK 3 (SCK)
6.18 + * GND GND 8 (GND) 8 (GND) 8 (GND) 1 (GND)
6.19 + * DAT0 DAT0 13 (1Z)
6.20 + * DAT1 DAT1 3 (2Z)
6.21 + *
6.22 + * Multiplexer pin selection:
6.23 + *
6.24 + * {Z}Y{S1/S0}
6.25 + *
6.26 + * 1Z with S1=0, S0=0 => 1Y0 (output 1, channel 0)
6.27 + * 2Z with S1=0, S0=0 => 2Y0 (output 2, channel 0)
6.28 + *
6.29 + * 1Z with S1=0, S0=1 => 1Y1 (output 1, channel 1)
6.30 + * 2Z with S1=0, S0=1 => 2Y1 (output 2, channel 1)
6.31 + *
6.32 + * Connections to the shift register (channel 0):
6.33 + *
6.34 + * Sniffer UBB 74HC4052 #1 M74HC595B1R
6.35 + * ------- --- ----------- -----------
6.36 + * DAT2 DAT2 12 (1Y0) 12 (RCK)
6.37 + * CD DAT3 1 (2Y0) 14 (SI)
6.38 + *
6.39 + * 74HC4052 #2
6.40 + * -----------
6.41 + * DAT0 DAT0 12 (1Y0) 10 (SCLR#)
6.42 + * DAT1 DAT1 1 (2Y0) 11 (SCK)
6.43 + *
6.44 + * Connections to the display board (channel 1):
6.45 + *
6.46 + * Sniffer UBB 74HC4052 #1 EM027AS012
6.47 + * ------- --- ----------- ----------
6.48 + * DAT2 DAT2 14 (1Y1) 4 (MOSI)
6.49 + * CD DAT3 5 (2Y1) 6 (SSEL)
6.50 + *
6.51 + * 74HC4052 #2
6.52 + * -----------
6.53 + * DAT0 DAT0 14 (1Y1) 11 (PWM)
6.54 + * DAT1 DAT1 5 (2Y1) 12 (RESET)
6.55 + *
6.56 + * Connections from the shift register (providing persistent outputs for
6.57 + * channel 0):
6.58 + *
6.59 + * M74HC595B1R EM027AS012
6.60 + * ----------- ----------
6.61 + * 15 (QA) 13 (PANEL)
6.62 + * 1 (QB) 14 (DIS)
6.63 + *
6.64 + * General connections:
6.65 + *
6.66 + * Sniffer UBB 74HC4052 M74HC595B1R
6.67 + * ------- ---- -------- -----------
6.68 + * GND GND 6 (E#) 13 (G#)
6.69 + * 7 (VEE)
6.70 + * 9 (S1)
6.71 + */
6.72 +
6.73 +/* CMD/S0 = 0 */
6.74 +
6.75 +#define SHIFT_SCLR UBB_DAT0
6.76 +#define SHIFT_SCK UBB_DAT1
6.77 +#define SHIFT_RCK UBB_DAT2
6.78 +#define SHIFT_SI UBB_DAT3
6.79 +
6.80 +/* CMD/S1 = 1 */
6.81 +
6.82 +#define EPD_PWM UBB_DAT0
6.83 +#define EPD_RESET UBB_DAT1
6.84 +#define EPD_MOSI UBB_DAT2
6.85 +#define EPD_SSEL UBB_DAT3
6.86 +
6.87 +/* Channel-insensitive. */
6.88 +
6.89 +#define MUX_S0 UBB_CMD
6.90 +#define EPD_SCK UBB_CLK
6.91 +
6.92 +/* NanoNote-specific functions. */
6.93 +
6.94 +void shift_select();
6.95 +void shift_update();
6.96 +void shift_init();
6.97 +void shift_reinit();
6.98 +void shift_in(uint8_t v);
6.99 +void epd_select();
6.100 +
6.101 +/* Board-specific interface functions. */
6.102 +
6.103 +void bsp_init();
6.104 +void bsp_InitDisplayHardware();
6.105 +void bsp_PowerOn();
6.106 +void bsp_pwm_active(uint16_t delayInMs);
6.107 +void bsp_Shutdown();
6.108 +void bsp_spiInit();
6.109 +void bsp_writeToDisplay(uint8_t *data, uint16_t len);
6.110 +void bsp_delayMs(uint32_t ms);
6.111 +void bsp_delayUs(uint32_t us);
6.112 +uint32_t bsp_getMsTicks();
6.113 +int16_t bsp_getTemp();
6.114 +
6.115 +#endif /* __BSP_H__ */
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/test.c Sun May 19 21:18:16 2013 +0000
7.3 @@ -0,0 +1,71 @@
7.4 +/*
7.5 + * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication.
7.6 + *
7.7 + * Copyright (C) 2013 Paul Boddie
7.8 + *
7.9 + * This program is free software; you can redistribute it and/or modify
7.10 + * it under the terms of the GNU General Public License as published by
7.11 + * the Free Software Foundation; either version 2 of the License, or
7.12 + * (at your option) any later version.
7.13 + */
7.14 +
7.15 +#include <ubb/ubb.h>
7.16 +#include <stdio.h>
7.17 +#include <stdlib.h>
7.18 +#include <string.h>
7.19 +#include <signal.h>
7.20 +#include "logo.h"
7.21 +#include "Display_Controller.h"
7.22 +#include "bsp.h"
7.23 +
7.24 +/**
7.25 + * Handle termination of the process.
7.26 + */
7.27 +void shutdown(int signum)
7.28 +{
7.29 + printf("Closing...\n");
7.30 + ubb_close(0);
7.31 + exit(1);
7.32 +}
7.33 +
7.34 +/* Main program and basic initialisation. */
7.35 +
7.36 +int main(int argc, char *argv[])
7.37 +{
7.38 + uint8_t *current_image, blank_image[176][33];
7.39 +
7.40 + signal(SIGINT, &shutdown);
7.41 +
7.42 + if (ubb_open(0) < 0) {
7.43 + perror("ubb_open");
7.44 + return 1;
7.45 + }
7.46 +
7.47 + ubb_power(1);
7.48 + printf("Power on.\n");
7.49 +
7.50 + /* Need to initialise the board. */
7.51 +
7.52 + bsp_init();
7.53 + printf("Initialised.\n");
7.54 +
7.55 + /* Initialise an array containing the current image. */
7.56 +
7.57 + memset((uint8_t*) &blank_image[0][0], 0xff, 176*33);
7.58 + current_image = (uint8_t*) &blank_image[0][0];
7.59 + printf("Set blank image.\n");
7.60 +
7.61 + /* Call epd_DisplayImg with the new image and current image. */
7.62 +
7.63 + epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image);
7.64 + printf("Updated image.\n");
7.65 +
7.66 + /* Set the current image to the new image. */
7.67 +
7.68 + current_image = &image_data[0][0][0];
7.69 +
7.70 + printf("Closing...\n");
7.71 + ubb_close(0);
7.72 +
7.73 + return 0;
7.74 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/tools/bitmap.py Sun May 19 21:18:16 2013 +0000
8.3 @@ -0,0 +1,84 @@
8.4 +#!/usr/bin/env python
8.5 +
8.6 +import PIL.Image
8.7 +import sys
8.8 +
8.9 +def get_image(input_filename, width, height):
8.10 +
8.11 + i = PIL.Image.open(input_filename)
8.12 + if i.size != (width, height):
8.13 + i.thumbnail((width, height), PIL.Image.ANTIALIAS)
8.14 +
8.15 + # Convert to monochrome.
8.16 +
8.17 + i = i.convert("1")
8.18 +
8.19 + all_values = []
8.20 + values = []
8.21 + last = None
8.22 + x = 0
8.23 + byte = 0
8.24 +
8.25 + for value in i.getdata():
8.26 +
8.27 + byte = (byte << 1) + (value == 255 and 1 or 0)
8.28 + x += 1
8.29 +
8.30 + if x % 8 == 0:
8.31 + values.append(byte)
8.32 + byte = 0
8.33 +
8.34 + if x == width:
8.35 + x = 0
8.36 + byte = 0
8.37 + all_values.append(values)
8.38 + values = []
8.39 +
8.40 + return all_values
8.41 +
8.42 +if __name__ == "__main__":
8.43 + import sys, os
8.44 +
8.45 + if len(sys.argv) < 3:
8.46 + print sys.argv[0], "<output basename> <image filename>..."
8.47 + sys.exit(1)
8.48 +
8.49 + output_basename = sys.argv[1]
8.50 + input_filenames = sys.argv[2:]
8.51 + width = 264
8.52 + height = 176
8.53 + number_of_images = len(input_filenames)
8.54 +
8.55 + f = open("%s.c" % output_basename, "wb")
8.56 +
8.57 + try:
8.58 + # Write the image data.
8.59 +
8.60 + f.write("#include <stdint.h>\n")
8.61 + f.write("const uint8_t image_data[%d][%d][%d] = {\n" % (number_of_images, height, width / 8))
8.62 + for input_filename in input_filenames:
8.63 + f.write("{\n")
8.64 + data = get_image(input_filename, width, height)
8.65 + for y in range(0, height):
8.66 + values = data[y]
8.67 + f.write("{\n")
8.68 + f.write(", ".join([("0x%02x" % v) for v in values]))
8.69 + f.write("},\n")
8.70 + f.write("},\n")
8.71 + f.write("};\n")
8.72 +
8.73 + finally:
8.74 + f.close()
8.75 +
8.76 + f = open("%s.h" % output_basename, "wb")
8.77 +
8.78 + try:
8.79 + f.write("#include <stdint.h>\n")
8.80 + f.write("extern const uint8_t image_data[%d][%d][%d];\n" % (number_of_images, height, width / 8))
8.81 + f.write("#define MAX_IMAGE %d\n" % (number_of_images - 1))
8.82 + f.write("#define NUMBER_OF_IMAGES %d\n" % number_of_images)
8.83 +
8.84 + finally:
8.85 + f.close()
8.86 +
8.87 +# vim: tabstop=4 expandtab shiftwidth=4