# HG changeset patch # User Paul Boddie # Date 1369149833 0 # Node ID 39d69db68adbcadc5235754cc2149cc7232e4487 # Parent 6a559742d15396300f2302b0e0bcdec8a8775bc2 Switched to a more direct mapping of UBB pins to EPD inputs. diff -r 6a559742d153 -r 39d69db68adb Display_COG_Process.c --- a/Display_COG_Process.c Sun May 19 21:42:23 2013 +0000 +++ b/Display_COG_Process.c Tue May 21 15:23:53 2013 +0000 @@ -520,7 +520,32 @@ void epd_PowerOn(void) { - bsp_PowerOn(); + epd_discharge_low(); + epd_rst_low(); + epd_cs_low(); + epd_spi_init(); + + epd_pwm_active(5); + + epd_panelon_on(); + + epd_pwm_active(10); + + epd_cs_high(); + + //epd_border_high(); + + epd_rst_high(); + + epd_pwm_active(5); + + epd_rst_low(); + + epd_pwm_active(5); + + epd_rst_high(); + + epd_pwm_active(5); } void epd_InitializeDriver(uint8_t EPDIndex) @@ -611,6 +636,14 @@ epd_delay_ms(40); epd_SPI_Send_Byte(0x04, 0x00); - printf("Shutdown...\n"); - bsp_Shutdown(); + epd_rst_low(); + epd_cs_low(); + epd_spi_detach(); + epd_panelon_off(); + + //epd_border_low(); + + epd_discharge_high(); + epd_delay_ms(150); + epd_discharge_low(); } diff -r 6a559742d153 -r 39d69db68adb Display_Hardware_Driver.c --- a/Display_Hardware_Driver.c Sun May 19 21:42:23 2013 +0000 +++ b/Display_Hardware_Driver.c Tue May 21 15:23:53 2013 +0000 @@ -46,6 +46,40 @@ CLR(EPD_RESET); } +void epd_discharge_high(void) +{ + // DISCHARGE_SET_HIGH; + SET(EPD_DIS); +} + +void epd_discharge_low(void) +{ + // DISCHARGE_SET_LOW; + CLR(EPD_DIS); +} + +void epd_panelon_off(void) +{ + // PANELON_SET_LOW; + ubb_power(1); +} + +void epd_panelon_on(void) +{ + // PANELON_SET_HIGH; + ubb_power(0); +} + +void epd_border_high(void) +{ + // BORDER_SET_HIGH; +} + +void epd_border_low(void) +{ + // BORDER_SET_LOW; +} + void epd_delay_ms(uint32_t Time) { bsp_delayMs(Time); @@ -86,7 +120,19 @@ #endif void epd_pwm_active(uint16_t delayInMs) { - bsp_pwm_active(delayInMs); + uint16_t numOfIterations; + + numOfIterations = delayInMs * 100; + // PWM_DIR_OUT; + for(; numOfIterations > 0; numOfIterations--) + { + // PWM_SET_HIGH; + SET(EPD_PWM); + bsp_delayUs(5); //100kHz (96kHz ideal) + // PWM_SET_LOW; + CLR(EPD_PWM); + bsp_delayUs(5); + } } @@ -158,7 +204,13 @@ void epd_InitDisplayHardware(void) { - bsp_InitDisplayHardware(); + epd_panelon_off(); + epd_spi_init(); + epd_cs_low(); + // epd_pwm_low(); + epd_pwm_active(0); //set output low + epd_rst_low(); + epd_discharge_low(); } //************************************************************************ diff -r 6a559742d153 -r 39d69db68adb Display_Hardware_Driver.h --- a/Display_Hardware_Driver.h Sun May 19 21:42:23 2013 +0000 +++ b/Display_Hardware_Driver.h Tue May 21 15:23:53 2013 +0000 @@ -68,9 +68,16 @@ void epd_cs_low(void); void epd_rst_high(void); void epd_rst_low(void); +void epd_discharge_high(void); +void epd_discharge_low(void); +void epd_panelon_off(void); +void epd_panelon_on(void); void epd_pwm_active(uint16_t delayInMs); +void epd_border_high(void); +void epd_border_low(void); + void epd_TestPinLow(void); void epd_TestPinHigh(void); void epd_TestPinTrigger(void); diff -r 6a559742d153 -r 39d69db68adb bsp.c --- a/bsp.c Sun May 19 21:42:23 2013 +0000 +++ b/bsp.c Tue May 21 15:23:53 2013 +0000 @@ -45,216 +45,17 @@ OUT(UBB_CLK); OUT(UBB_DAT0); OUT(UBB_DAT1); -} -/* NanoNote-specific functions. */ - -void shift_select() -{ - CLR(MUX_S0); -} - -void shift_update() -{ - SET(SHIFT_RCK); - CLR(SHIFT_RCK); -} - -void shift_init() -{ - /* Initiate a clear operation. */ - - CLR(SHIFT_SCLR); - - /* Set clocks to known state. */ - - CLR(SHIFT_SCK); - CLR(SHIFT_RCK); - - /* Propagate the clear operation. */ - - shift_update(); - - /* Finalise the initialisation. */ - - SET(SHIFT_SCLR); -} - -void shift_reinit() -{ - /* Set clocks to known state. */ - - CLR(SHIFT_SCK); - CLR(SHIFT_RCK); - - /* Avoid clear operation. */ - - SET(SHIFT_SCLR); -} - -void shift_in(uint8_t v) -{ - if (v) - SET(SHIFT_SI); - else - CLR(SHIFT_SI); - - SET(SHIFT_SCK); - CLR(SHIFT_SCK); -} - -void epd_select() -{ - SET(MUX_S0); -} - -/* Callback functions. */ - -void bsp_InitDisplayHardware() -{ - /* This should do the following: - - PANEL = 0 - CS/SSEL = 0 - PWM = 0 - RESET = 0 - DIS = 0 - - (Could shift 0, 0 -> PANEL, DIS - or 0, 0, 0 -> PANEL, BORDER, DIS.) - */ - - shift_select(); - shift_init(); /* PANEL = DIS = 0 */ - - epd_select(); - CLR(EPD_SSEL); - CLR(EPD_PWM); - CLR(EPD_RESET); - CLR(EPD_MOSI); - - printf("Hardware initialised.\n"); -} - -void bsp_PowerOn() -{ - /* This should do the following: - - RESET = 0 - DIS = 0 - CS/SSEL = 0 - */ - - epd_select(); - epd_rst_low(); - - shift_select(); - shift_init(); /* PANEL = DIS = 0 */ - - printf("RESET = PANEL = DIS = 0\n"); - - /* Then, the following: - - PWM = 1/0 (5ms) - PANEL = 1 - PWM = 1/0 (10ms) - BORDER = 1? - RESET = 1 - PWM = 1/0 (5ms) - RESET = 0 - PWM = 1/0 (5ms) - RESET = 1 - PWM = 1/0 (5ms) - - (Could shift 1 -> PANEL => PANEL=1, DIS=0 - or 1, 1 -> PANEL, BORDER => PANEL=1, BORDER=1, DIS=0) - */ - - epd_select(); - epd_spi_init(); - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks()); - epd_pwm_active(5); - printf("PWM at 5ms done: %u\n", bsp_getMsTicks()); - - shift_select(); - shift_init(); /* PANEL = DIS = 0 (still) */ - shift_in(1); /* PANEL = 1 */ - shift_update(); - printf("PANEL = 1\n"); - - epd_select(); - printf("PWM at 10ms starting: %u\n", bsp_getMsTicks()); - epd_pwm_active(10); - printf("PWM at 10ms done: %u\n", bsp_getMsTicks()); - epd_cs_high(); - epd_rst_high(); - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks()); - epd_pwm_active(5); - printf("PWM at 5ms done: %u\n", bsp_getMsTicks()); - epd_rst_low(); - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks()); - epd_pwm_active(5); - printf("PWM at 5ms done: %u\n", bsp_getMsTicks()); - epd_rst_high(); - printf("PWM at 5ms starting: %u\n", bsp_getMsTicks()); - epd_pwm_active(5); - printf("PWM at 5ms done: %u\n", bsp_getMsTicks()); - - printf("Hardware powered.\n"); -} - -void bsp_pwm_active(uint16_t delayInMs) -{ - uint16_t numOfIterations; - - numOfIterations = delayInMs * 100; - for (; numOfIterations > 0; numOfIterations--) - { - // PWM_SET_HIGH; - SET(EPD_PWM); - bsp_delayUs(5); //100kHz (96kHz ideal) - // PWM_SET_LOW; - CLR(EPD_PWM); - bsp_delayUs(5); - } -} - -void bsp_Shutdown() -{ - /* This should complete the power off operation as follows: - - RESET = 0 - CS/SSEL = 0 - PANEL = 0 - BORDER = 0? - DIS = 1 - DIS = 0 (after 150ms) - - (Could shift 0 -> PANEL => PANEL=0, DIS=1 - or 0, 0 -> PANEL, BORDER => PANEL=0, BORDER=0, DIS=1) - */ - - epd_select(); - epd_rst_low(); - epd_cs_low(); - epd_spi_detach(); - - shift_reinit(); - shift_select(); - shift_in(0); /* PANEL = 0; DIS = 1 */ - shift_update(); - printf("Wait for 150ms, starting: %u\n", bsp_getMsTicks()); - epd_delay_ms(150); - printf("Wait for 150ms, done: %u\n", bsp_getMsTicks()); - shift_in(0); /* PANEL = 0; DIS = 0 */ - shift_update(); - - printf("Hardware shut down.\n"); + CLR(UBB_DAT2); + CLR(UBB_DAT3); + CLR(UBB_CMD); + CLR(UBB_CLK); + CLR(UBB_DAT0); + CLR(UBB_DAT1); } void bsp_spiInit() { - CLR(EPD_SCK); } /** @@ -296,8 +97,8 @@ tv.tv_nsec = us * 100; nanosleep(&tv, NULL); #else - uint64_t i = us * 16; - while (i-- > 0); + uint64_t i = us * 24; + while (i--); #endif } diff -r 6a559742d153 -r 39d69db68adb bsp.h --- a/bsp.h Sun May 19 21:42:23 2013 +0000 +++ b/bsp.h Tue May 21 15:23:53 2013 +0000 @@ -3,97 +3,33 @@ #include -/* Pin assignments (74HC4052): - * - * Sniffer UBB 74HC4052 #1 74HC4052 #2 10K Resistor M74HC595B1R EM027AS012 - * ------- ---- ----------- ----------- ------------ ----------- ---------- - * DAT2 DAT2 13 (1Z) - * CD DAT3 3 (2Z) - * CMD CMD 10 (S0) 10 (S0) IN OUT 10 (SCLR#) - * VCC VDD 16 (VCC) 16 (VCC) 16 (VCC) 2 (3V3) - * CLK CLK 3 (SCK) - * GND GND 8 (GND) 8 (GND) 8 (GND) 1 (GND) - * DAT0 DAT0 13 (1Z) - * DAT1 DAT1 3 (2Z) - * - * Multiplexer pin selection: - * - * {Z}Y{S1/S0} - * - * 1Z with S1=0, S0=0 => 1Y0 (output 1, channel 0) - * 2Z with S1=0, S0=0 => 2Y0 (output 2, channel 0) - * - * 1Z with S1=0, S0=1 => 1Y1 (output 1, channel 1) - * 2Z with S1=0, S0=1 => 2Y1 (output 2, channel 1) - * - * Connections to the shift register (channel 0): +/* Pin assignments: * - * Sniffer UBB 74HC4052 #1 M74HC595B1R - * ------- --- ----------- ----------- - * DAT2 DAT2 12 (1Y0) 12 (RCK) - * CD DAT3 1 (2Y0) 14 (SI) - * - * 74HC4052 #2 - * ----------- - * DAT0 DAT0 12 (1Y0) 10 (SCLR#) - * DAT1 DAT1 1 (2Y0) 11 (SCK) - * - * Connections to the display board (channel 1): - * - * Sniffer UBB 74HC4052 #1 EM027AS012 - * ------- --- ----------- ---------- - * DAT2 DAT2 14 (1Y1) 4 (MOSI) - * CD DAT3 5 (2Y1) 6 (SSEL) - * - * 74HC4052 #2 - * ----------- - * DAT0 DAT0 14 (1Y1) 11 (PWM) - * DAT1 DAT1 5 (2Y1) 12 (RESET) - * - * Connections from the shift register (providing persistent outputs for - * channel 0): - * - * M74HC595B1R EM027AS012 - * ----------- ---------- - * 15 (QA) 13 (PANEL) - * 1 (QB) 14 (DIS) + * Sniffer UBB EM027AS012 + * ------- ---- ----------- + * DAT2 DAT2 4 (MOSI) + * CD DAT3 6 (SSEL) + * CMD CMD 11 (PWM) + * VCC VDD 13 (PANEL) + * CLK CLK 3 (SCK) + * GND GND + * DAT0 DAT0 12 (RESET) + * DAT1 DAT1 14 (DIS) * * General connections: * - * Sniffer UBB 74HC4052 M74HC595B1R - * ------- ---- -------- ----------- - * GND GND 6 (E#) 13 (G#) - * 7 (VEE) - * 9 (S1) + * EM027AS012 + * ---------- + * 1 (GND) + * 2 (3V3) */ -/* CMD/S0 = 0 */ - -#define SHIFT_SCLR UBB_DAT0 -#define SHIFT_SCK UBB_DAT1 -#define SHIFT_RCK UBB_DAT2 -#define SHIFT_SI UBB_DAT3 - -/* CMD/S1 = 1 */ - -#define EPD_PWM UBB_DAT0 -#define EPD_RESET UBB_DAT1 -#define EPD_MOSI UBB_DAT2 -#define EPD_SSEL UBB_DAT3 - -/* Channel-insensitive. */ - -#define MUX_S0 UBB_CMD -#define EPD_SCK UBB_CLK - -/* NanoNote-specific functions. */ - -void shift_select(); -void shift_update(); -void shift_init(); -void shift_reinit(); -void shift_in(uint8_t v); -void epd_select(); +#define EPD_MOSI UBB_DAT2 +#define EPD_SSEL UBB_DAT3 +#define EPD_PWM UBB_CMD +#define EPD_SCK UBB_CLK +#define EPD_RESET UBB_DAT0 +#define EPD_DIS UBB_DAT1 /* Board-specific interface functions. */