FreeCalypso > hg > fc-magnetite
changeset 131:384fbd61c252
src/cs/drivers/drv_app/r2d/lcds/c139: import from tcs211-c139
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 07 Oct 2016 22:04:02 +0000 |
parents | a0c5d28798fe |
children | b8fc86826624 |
files | src/cs/drivers/drv_app/r2d/lcds/c139/colors.h src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_init_i.c |
diffstat | 3 files changed, 147 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cs/drivers/drv_app/r2d/lcds/c139/colors.h Fri Oct 07 22:04:02 2016 +0000 @@ -0,0 +1,16 @@ +/* + * TI's BMI code does not seem to have an existing configuration for small + * color displays, only large color, large mono and small mono - hence in the + * present configuration we are telling TI's code that we have a mono display. + * But the real LCD on the C139 is 16-bit color. Here we define the physical + * color values to which TI's black and white will be mapped. + * + * We are also pretending to be the 84x48 pix LCD on TI's C-Sample, hence we + * are displaying a 84x48 pix UI on a physical 96x64 pix LCD. We center the + * virtual display in the physical one, and the border color is defined here + * as well. + */ + +#define LCD16_COLOR_BLACK 0x0000 +#define LCD16_COLOR_WHITE 0xFFFF +#define LCD16_COLOR_BORDER 0x5555
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c Fri Oct 07 22:04:02 2016 +0000 @@ -0,0 +1,80 @@ +#include "r2d/lcds/c139/colors.h" + +void c139_uwire_xmit(UINT16 cmd) +{ + * (volatile UINT16 *) TDR = cmd << 7; + * (volatile UINT16 *) CSR |= NB_BITS_WR_9 + CS_CMD + START ; // transmit command data + while (((* (volatile UINT16 *) CSR) & CSRB) != 0 ); // wait for end of WRITE + * (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select +} + +void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param) +{ + c139_uwire_xmit(cmd); + c139_uwire_xmit(param | 0x100); +} + +void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend, + UINT8 ystart, UINT8 yend) +{ + c139_lcd_ctrl_cmd(0x10, xstart); + c139_lcd_ctrl_cmd(0x11, ystart); + c139_lcd_ctrl_cmd(0x12, xend); + c139_lcd_ctrl_cmd(0x13, yend); + c139_lcd_ctrl_cmd(0x14, xstart); + c139_lcd_ctrl_cmd(0x15, ystart); +} + +void c139_lcd_send_pix(UINT16 pixval) +{ + c139_uwire_xmit((pixval >> 8) | 0x100); + c139_uwire_xmit((pixval & 0xFF) | 0x100); +} + +void r2d_lcd_power_on(void) +{ +} + +void r2d_lcd_power_off(void) +{ +} + +static int get_pix_from_sw_fb(UINT32 *fb, UINT16 x, UINT16 y) +{ + UINT32 *p, mask; + UINT16 yword, ybit; + + /* mirroring */ + x = R2D_WIDTH - x; + y = R2D_HEIGHT - y; + yword = y >> 5; + ybit = y & 31; + p = fb + x * R2D_MWHEIGHT + yword; + mask = 1 << ybit; + if (*p & mask) + return(1); + else + return(0); +} + +void r2d_refresh(void) +{ + UINT16 x, y; + UINT32 *fb; + + fb = r2d_g_framebuffer->p_memory_words; + + /* set the LCD up to refresh the 84x48 area */ + c139_set_lcd_addr_region(6, 89, 8, 55); + /* send the pixels */ + for (y = 0; y < R2D_HEIGHT; y++) { + for (x = 0; x < R2D_WIDTH; x++) { + if (get_pix_from_sw_fb(fb, x, y)) + c139_lcd_send_pix(LCD16_COLOR_BLACK); + else + c139_lcd_send_pix(LCD16_COLOR_WHITE); + } + } + + r2d_reinit_update_region(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_init_i.c Fri Oct 07 22:04:02 2016 +0000 @@ -0,0 +1,51 @@ +#include "r2d/lcds/c139/colors.h" + +#define R2D_MB_PRIM_SIZE 2000 + +extern void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param); +extern void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend, + UINT8 ystart, UINT8 yend); +extern void c139_lcd_send_pix(UINT16 pixval); + +void uwire_init_lcd(void) +{ + * ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out + * ( UINT16 *) CNTL_RST |= (0x04); // set reset_out to 0 + rvf_delay(RVF_MS_TO_TICKS(5)); // waits for 5 ms + * ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out + + * (volatile UINT16 *) SR1 = CS0_FRQ_FINT_2; + * (volatile UINT16 *) SR3 = SR3_CLK_EN; // enables the uwire clock + * (volatile UINT16 *) CSR = INDEX_CS0; // selects CS0 +} + +static void r2d_refresh_task_init(void) +{ + UINT16 i; + + uwire_init_lcd(); + rvf_delay(RVF_MS_TO_TICKS(5)); // waits for 5 ms + + /* LCD controller init */ + c139_lcd_ctrl_cmd(0x3F, 0x01); + c139_lcd_ctrl_cmd(0x20, 0x03); + c139_lcd_ctrl_cmd(0x31, 0x03); + + /* initial hw framebuffer clearing */ + c139_set_lcd_addr_region(0, 95, 0, 63); + for (i = 0; i < 96 * 64; i++) + c139_lcd_send_pix(LCD16_COLOR_BORDER); +} + +static void r2d_refresh_task_kill(void) +{ +} + +static void r2d_dithering_init(void) +{ + R2D_MALLOC(r2d_mb_id,UINT32,sizeof(UINT32)*4,r2d_g_dithering_matrix); + r2d_g_dithering_matrix[0]=0; + r2d_g_dithering_matrix[1]=2; + r2d_g_dithering_matrix[2]=3; + r2d_g_dithering_matrix[3]=1; +}