1.1 --- a/Display_COG_Process.c Sun May 19 21:42:23 2013 +0000
1.2 +++ b/Display_COG_Process.c Tue May 21 15:23:53 2013 +0000
1.3 @@ -520,7 +520,32 @@
1.4
1.5 void epd_PowerOn(void)
1.6 {
1.7 - bsp_PowerOn();
1.8 + epd_discharge_low();
1.9 + epd_rst_low();
1.10 + epd_cs_low();
1.11 + epd_spi_init();
1.12 +
1.13 + epd_pwm_active(5);
1.14 +
1.15 + epd_panelon_on();
1.16 +
1.17 + epd_pwm_active(10);
1.18 +
1.19 + epd_cs_high();
1.20 +
1.21 + //epd_border_high();
1.22 +
1.23 + epd_rst_high();
1.24 +
1.25 + epd_pwm_active(5);
1.26 +
1.27 + epd_rst_low();
1.28 +
1.29 + epd_pwm_active(5);
1.30 +
1.31 + epd_rst_high();
1.32 +
1.33 + epd_pwm_active(5);
1.34 }
1.35
1.36 void epd_InitializeDriver(uint8_t EPDIndex)
1.37 @@ -611,6 +636,14 @@
1.38 epd_delay_ms(40);
1.39 epd_SPI_Send_Byte(0x04, 0x00);
1.40
1.41 - printf("Shutdown...\n");
1.42 - bsp_Shutdown();
1.43 + epd_rst_low();
1.44 + epd_cs_low();
1.45 + epd_spi_detach();
1.46 + epd_panelon_off();
1.47 +
1.48 + //epd_border_low();
1.49 +
1.50 + epd_discharge_high();
1.51 + epd_delay_ms(150);
1.52 + epd_discharge_low();
1.53 }
2.1 --- a/Display_Hardware_Driver.c Sun May 19 21:42:23 2013 +0000
2.2 +++ b/Display_Hardware_Driver.c Tue May 21 15:23:53 2013 +0000
2.3 @@ -46,6 +46,40 @@
2.4 CLR(EPD_RESET);
2.5 }
2.6
2.7 +void epd_discharge_high(void)
2.8 +{
2.9 + // DISCHARGE_SET_HIGH;
2.10 + SET(EPD_DIS);
2.11 +}
2.12 +
2.13 +void epd_discharge_low(void)
2.14 +{
2.15 + // DISCHARGE_SET_LOW;
2.16 + CLR(EPD_DIS);
2.17 +}
2.18 +
2.19 +void epd_panelon_off(void)
2.20 +{
2.21 + // PANELON_SET_LOW;
2.22 + ubb_power(1);
2.23 +}
2.24 +
2.25 +void epd_panelon_on(void)
2.26 +{
2.27 + // PANELON_SET_HIGH;
2.28 + ubb_power(0);
2.29 +}
2.30 +
2.31 +void epd_border_high(void)
2.32 +{
2.33 + // BORDER_SET_HIGH;
2.34 +}
2.35 +
2.36 +void epd_border_low(void)
2.37 +{
2.38 + // BORDER_SET_LOW;
2.39 +}
2.40 +
2.41 void epd_delay_ms(uint32_t Time)
2.42 {
2.43 bsp_delayMs(Time);
2.44 @@ -86,7 +120,19 @@
2.45 #endif
2.46 void epd_pwm_active(uint16_t delayInMs)
2.47 {
2.48 - bsp_pwm_active(delayInMs);
2.49 + uint16_t numOfIterations;
2.50 +
2.51 + numOfIterations = delayInMs * 100;
2.52 + // PWM_DIR_OUT;
2.53 + for(; numOfIterations > 0; numOfIterations--)
2.54 + {
2.55 + // PWM_SET_HIGH;
2.56 + SET(EPD_PWM);
2.57 + bsp_delayUs(5); //100kHz (96kHz ideal)
2.58 + // PWM_SET_LOW;
2.59 + CLR(EPD_PWM);
2.60 + bsp_delayUs(5);
2.61 + }
2.62 }
2.63
2.64
2.65 @@ -158,7 +204,13 @@
2.66
2.67 void epd_InitDisplayHardware(void)
2.68 {
2.69 - bsp_InitDisplayHardware();
2.70 + epd_panelon_off();
2.71 + epd_spi_init();
2.72 + epd_cs_low();
2.73 + // epd_pwm_low();
2.74 + epd_pwm_active(0); //set output low
2.75 + epd_rst_low();
2.76 + epd_discharge_low();
2.77 }
2.78
2.79 //************************************************************************
3.1 --- a/Display_Hardware_Driver.h Sun May 19 21:42:23 2013 +0000
3.2 +++ b/Display_Hardware_Driver.h Tue May 21 15:23:53 2013 +0000
3.3 @@ -68,9 +68,16 @@
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/bsp.c Sun May 19 21:42:23 2013 +0000
4.2 +++ b/bsp.c Tue May 21 15:23:53 2013 +0000
4.3 @@ -45,216 +45,17 @@
4.4 OUT(UBB_CLK);
4.5 OUT(UBB_DAT0);
4.6 OUT(UBB_DAT1);
4.7 -}
4.8
4.9 -/* NanoNote-specific functions. */
4.10 -
4.11 -void shift_select()
4.12 -{
4.13 - CLR(MUX_S0);
4.14 -}
4.15 -
4.16 -void shift_update()
4.17 -{
4.18 - SET(SHIFT_RCK);
4.19 - CLR(SHIFT_RCK);
4.20 -}
4.21 -
4.22 -void shift_init()
4.23 -{
4.24 - /* Initiate a clear operation. */
4.25 -
4.26 - CLR(SHIFT_SCLR);
4.27 -
4.28 - /* Set clocks to known state. */
4.29 -
4.30 - CLR(SHIFT_SCK);
4.31 - CLR(SHIFT_RCK);
4.32 -
4.33 - /* Propagate the clear operation. */
4.34 -
4.35 - shift_update();
4.36 -
4.37 - /* Finalise the initialisation. */
4.38 -
4.39 - SET(SHIFT_SCLR);
4.40 -}
4.41 -
4.42 -void shift_reinit()
4.43 -{
4.44 - /* Set clocks to known state. */
4.45 -
4.46 - CLR(SHIFT_SCK);
4.47 - CLR(SHIFT_RCK);
4.48 -
4.49 - /* Avoid clear operation. */
4.50 -
4.51 - SET(SHIFT_SCLR);
4.52 -}
4.53 -
4.54 -void shift_in(uint8_t v)
4.55 -{
4.56 - if (v)
4.57 - SET(SHIFT_SI);
4.58 - else
4.59 - CLR(SHIFT_SI);
4.60 -
4.61 - SET(SHIFT_SCK);
4.62 - CLR(SHIFT_SCK);
4.63 -}
4.64 -
4.65 -void epd_select()
4.66 -{
4.67 - SET(MUX_S0);
4.68 -}
4.69 -
4.70 -/* Callback functions. */
4.71 -
4.72 -void bsp_InitDisplayHardware()
4.73 -{
4.74 - /* This should do the following:
4.75 -
4.76 - PANEL = 0
4.77 - CS/SSEL = 0
4.78 - PWM = 0
4.79 - RESET = 0
4.80 - DIS = 0
4.81 -
4.82 - (Could shift 0, 0 -> PANEL, DIS
4.83 - or 0, 0, 0 -> PANEL, BORDER, DIS.)
4.84 - */
4.85 -
4.86 - shift_select();
4.87 - shift_init(); /* PANEL = DIS = 0 */
4.88 -
4.89 - epd_select();
4.90 - CLR(EPD_SSEL);
4.91 - CLR(EPD_PWM);
4.92 - CLR(EPD_RESET);
4.93 - CLR(EPD_MOSI);
4.94 -
4.95 - printf("Hardware initialised.\n");
4.96 -}
4.97 -
4.98 -void bsp_PowerOn()
4.99 -{
4.100 - /* This should do the following:
4.101 -
4.102 - RESET = 0
4.103 - DIS = 0
4.104 - CS/SSEL = 0
4.105 - */
4.106 -
4.107 - epd_select();
4.108 - epd_rst_low();
4.109 -
4.110 - shift_select();
4.111 - shift_init(); /* PANEL = DIS = 0 */
4.112 -
4.113 - printf("RESET = PANEL = DIS = 0\n");
4.114 -
4.115 - /* Then, the following:
4.116 -
4.117 - PWM = 1/0 (5ms)
4.118 - PANEL = 1
4.119 - PWM = 1/0 (10ms)
4.120 - BORDER = 1?
4.121 - RESET = 1
4.122 - PWM = 1/0 (5ms)
4.123 - RESET = 0
4.124 - PWM = 1/0 (5ms)
4.125 - RESET = 1
4.126 - PWM = 1/0 (5ms)
4.127 -
4.128 - (Could shift 1 -> PANEL => PANEL=1, DIS=0
4.129 - or 1, 1 -> PANEL, BORDER => PANEL=1, BORDER=1, DIS=0)
4.130 - */
4.131 -
4.132 - epd_select();
4.133 - epd_spi_init();
4.134 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
4.135 - epd_pwm_active(5);
4.136 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
4.137 -
4.138 - shift_select();
4.139 - shift_init(); /* PANEL = DIS = 0 (still) */
4.140 - shift_in(1); /* PANEL = 1 */
4.141 - shift_update();
4.142 - printf("PANEL = 1\n");
4.143 -
4.144 - epd_select();
4.145 - printf("PWM at 10ms starting: %u\n", bsp_getMsTicks());
4.146 - epd_pwm_active(10);
4.147 - printf("PWM at 10ms done: %u\n", bsp_getMsTicks());
4.148 - epd_cs_high();
4.149 - epd_rst_high();
4.150 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
4.151 - epd_pwm_active(5);
4.152 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
4.153 - epd_rst_low();
4.154 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
4.155 - epd_pwm_active(5);
4.156 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
4.157 - epd_rst_high();
4.158 - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks());
4.159 - epd_pwm_active(5);
4.160 - printf("PWM at 5ms done: %u\n", bsp_getMsTicks());
4.161 -
4.162 - printf("Hardware powered.\n");
4.163 -}
4.164 -
4.165 -void bsp_pwm_active(uint16_t delayInMs)
4.166 -{
4.167 - uint16_t numOfIterations;
4.168 -
4.169 - numOfIterations = delayInMs * 100;
4.170 - for (; numOfIterations > 0; numOfIterations--)
4.171 - {
4.172 - // PWM_SET_HIGH;
4.173 - SET(EPD_PWM);
4.174 - bsp_delayUs(5); //100kHz (96kHz ideal)
4.175 - // PWM_SET_LOW;
4.176 - CLR(EPD_PWM);
4.177 - bsp_delayUs(5);
4.178 - }
4.179 -}
4.180 -
4.181 -void bsp_Shutdown()
4.182 -{
4.183 - /* This should complete the power off operation as follows:
4.184 -
4.185 - RESET = 0
4.186 - CS/SSEL = 0
4.187 - PANEL = 0
4.188 - BORDER = 0?
4.189 - DIS = 1
4.190 - DIS = 0 (after 150ms)
4.191 -
4.192 - (Could shift 0 -> PANEL => PANEL=0, DIS=1
4.193 - or 0, 0 -> PANEL, BORDER => PANEL=0, BORDER=0, DIS=1)
4.194 - */
4.195 -
4.196 - epd_select();
4.197 - epd_rst_low();
4.198 - epd_cs_low();
4.199 - epd_spi_detach();
4.200 -
4.201 - shift_reinit();
4.202 - shift_select();
4.203 - shift_in(0); /* PANEL = 0; DIS = 1 */
4.204 - shift_update();
4.205 - printf("Wait for 150ms, starting: %u\n", bsp_getMsTicks());
4.206 - epd_delay_ms(150);
4.207 - printf("Wait for 150ms, done: %u\n", bsp_getMsTicks());
4.208 - shift_in(0); /* PANEL = 0; DIS = 0 */
4.209 - shift_update();
4.210 -
4.211 - printf("Hardware shut down.\n");
4.212 + CLR(UBB_DAT2);
4.213 + CLR(UBB_DAT3);
4.214 + CLR(UBB_CMD);
4.215 + CLR(UBB_CLK);
4.216 + CLR(UBB_DAT0);
4.217 + CLR(UBB_DAT1);
4.218 }
4.219
4.220 void bsp_spiInit()
4.221 {
4.222 - CLR(EPD_SCK);
4.223 }
4.224
4.225 /**
4.226 @@ -296,8 +97,8 @@
4.227 tv.tv_nsec = us * 100;
4.228 nanosleep(&tv, NULL);
4.229 #else
4.230 - uint64_t i = us * 16;
4.231 - while (i-- > 0);
4.232 + uint64_t i = us * 24;
4.233 + while (i--);
4.234 #endif
4.235 }
4.236
5.1 --- a/bsp.h Sun May 19 21:42:23 2013 +0000
5.2 +++ b/bsp.h Tue May 21 15:23:53 2013 +0000
5.3 @@ -3,97 +3,33 @@
5.4
5.5 #include <ubb/ubb.h>
5.6
5.7 -/* Pin assignments (74HC4052):
5.8 - *
5.9 - * Sniffer UBB 74HC4052 #1 74HC4052 #2 10K Resistor M74HC595B1R EM027AS012
5.10 - * ------- ---- ----------- ----------- ------------ ----------- ----------
5.11 - * DAT2 DAT2 13 (1Z)
5.12 - * CD DAT3 3 (2Z)
5.13 - * CMD CMD 10 (S0) 10 (S0) IN OUT 10 (SCLR#)
5.14 - * VCC VDD 16 (VCC) 16 (VCC) 16 (VCC) 2 (3V3)
5.15 - * CLK CLK 3 (SCK)
5.16 - * GND GND 8 (GND) 8 (GND) 8 (GND) 1 (GND)
5.17 - * DAT0 DAT0 13 (1Z)
5.18 - * DAT1 DAT1 3 (2Z)
5.19 - *
5.20 - * Multiplexer pin selection:
5.21 - *
5.22 - * {Z}Y{S1/S0}
5.23 - *
5.24 - * 1Z with S1=0, S0=0 => 1Y0 (output 1, channel 0)
5.25 - * 2Z with S1=0, S0=0 => 2Y0 (output 2, channel 0)
5.26 - *
5.27 - * 1Z with S1=0, S0=1 => 1Y1 (output 1, channel 1)
5.28 - * 2Z with S1=0, S0=1 => 2Y1 (output 2, channel 1)
5.29 - *
5.30 - * Connections to the shift register (channel 0):
5.31 +/* Pin assignments:
5.32 *
5.33 - * Sniffer UBB 74HC4052 #1 M74HC595B1R
5.34 - * ------- --- ----------- -----------
5.35 - * DAT2 DAT2 12 (1Y0) 12 (RCK)
5.36 - * CD DAT3 1 (2Y0) 14 (SI)
5.37 - *
5.38 - * 74HC4052 #2
5.39 - * -----------
5.40 - * DAT0 DAT0 12 (1Y0) 10 (SCLR#)
5.41 - * DAT1 DAT1 1 (2Y0) 11 (SCK)
5.42 - *
5.43 - * Connections to the display board (channel 1):
5.44 - *
5.45 - * Sniffer UBB 74HC4052 #1 EM027AS012
5.46 - * ------- --- ----------- ----------
5.47 - * DAT2 DAT2 14 (1Y1) 4 (MOSI)
5.48 - * CD DAT3 5 (2Y1) 6 (SSEL)
5.49 - *
5.50 - * 74HC4052 #2
5.51 - * -----------
5.52 - * DAT0 DAT0 14 (1Y1) 11 (PWM)
5.53 - * DAT1 DAT1 5 (2Y1) 12 (RESET)
5.54 - *
5.55 - * Connections from the shift register (providing persistent outputs for
5.56 - * channel 0):
5.57 - *
5.58 - * M74HC595B1R EM027AS012
5.59 - * ----------- ----------
5.60 - * 15 (QA) 13 (PANEL)
5.61 - * 1 (QB) 14 (DIS)
5.62 + * Sniffer UBB EM027AS012
5.63 + * ------- ---- -----------
5.64 + * DAT2 DAT2 4 (MOSI)
5.65 + * CD DAT3 6 (SSEL)
5.66 + * CMD CMD 11 (PWM)
5.67 + * VCC VDD 13 (PANEL)
5.68 + * CLK CLK 3 (SCK)
5.69 + * GND GND
5.70 + * DAT0 DAT0 12 (RESET)
5.71 + * DAT1 DAT1 14 (DIS)
5.72 *
5.73 * General connections:
5.74 *
5.75 - * Sniffer UBB 74HC4052 M74HC595B1R
5.76 - * ------- ---- -------- -----------
5.77 - * GND GND 6 (E#) 13 (G#)
5.78 - * 7 (VEE)
5.79 - * 9 (S1)
5.80 + * EM027AS012
5.81 + * ----------
5.82 + * 1 (GND)
5.83 + * 2 (3V3)
5.84 */
5.85
5.86 -/* CMD/S0 = 0 */
5.87 -
5.88 -#define SHIFT_SCLR UBB_DAT0
5.89 -#define SHIFT_SCK UBB_DAT1
5.90 -#define SHIFT_RCK UBB_DAT2
5.91 -#define SHIFT_SI UBB_DAT3
5.92 -
5.93 -/* CMD/S1 = 1 */
5.94 -
5.95 -#define EPD_PWM UBB_DAT0
5.96 -#define EPD_RESET UBB_DAT1
5.97 -#define EPD_MOSI UBB_DAT2
5.98 -#define EPD_SSEL UBB_DAT3
5.99 -
5.100 -/* Channel-insensitive. */
5.101 -
5.102 -#define MUX_S0 UBB_CMD
5.103 -#define EPD_SCK UBB_CLK
5.104 -
5.105 -/* NanoNote-specific functions. */
5.106 -
5.107 -void shift_select();
5.108 -void shift_update();
5.109 -void shift_init();
5.110 -void shift_reinit();
5.111 -void shift_in(uint8_t v);
5.112 -void epd_select();
5.113 +#define EPD_MOSI UBB_DAT2
5.114 +#define EPD_SSEL UBB_DAT3
5.115 +#define EPD_PWM UBB_CMD
5.116 +#define EPD_SCK UBB_CLK
5.117 +#define EPD_RESET UBB_DAT0
5.118 +#define EPD_DIS UBB_DAT1
5.119
5.120 /* Board-specific interface functions. */
5.121