From 885b3d53b3a491c62fb0634b78cb9857723ac15d Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 11 Feb 2013 09:25:26 +0100 Subject: removed GDISP_LLD() macro --- drivers/gdisp/ILI9320/gdisp_lld.c | 570 ----------- drivers/gdisp/ILI9320/gdisp_lld.mk | 5 - drivers/gdisp/ILI9320/gdisp_lld_board_example.h | 59 -- .../ILI9320/gdisp_lld_board_olimex_stm32_lcd.h | 85 -- drivers/gdisp/ILI9320/gdisp_lld_config.h | 54 -- drivers/gdisp/ILI9320/readme.txt | 15 - drivers/gdisp/ILI9325/gdisp_lld.c | 580 ----------- drivers/gdisp/ILI9325/gdisp_lld.mk | 5 - drivers/gdisp/ILI9325/gdisp_lld_board_example.h | 59 -- .../gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h | 96 -- drivers/gdisp/ILI9325/gdisp_lld_config.h | 54 -- drivers/gdisp/ILI9325/readme.txt | 15 - drivers/gdisp/Nokia6610GE12/GE12.h | 81 -- drivers/gdisp/Nokia6610GE12/gdisp_lld.c | 528 ---------- drivers/gdisp/Nokia6610GE12/gdisp_lld.mk | 5 - .../gdisp/Nokia6610GE12/gdisp_lld_board_example.h | 135 --- .../gdisp_lld_board_olimexsam7ex256.h | 196 ---- drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h | 58 -- drivers/gdisp/Nokia6610GE12/readme.txt | 15 - drivers/gdisp/Nokia6610GE8/GE8.h | 67 -- drivers/gdisp/Nokia6610GE8/gdisp_lld.c | 483 --------- drivers/gdisp/Nokia6610GE8/gdisp_lld.mk | 5 - .../gdisp/Nokia6610GE8/gdisp_lld_board_example.h | 135 --- .../Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h | 196 ---- drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h | 58 -- drivers/gdisp/Nokia6610GE8/readme.txt | 15 - drivers/gdisp/S6D1121/gdisp_lld.c | 571 ----------- drivers/gdisp/S6D1121/gdisp_lld.mk | 5 - drivers/gdisp/S6D1121/gdisp_lld_board_example.h | 125 --- .../gdisp/S6D1121/gdisp_lld_board_olimex_e407.h | 94 -- drivers/gdisp/S6D1121/gdisp_lld_config.h | 54 -- drivers/gdisp/S6D1121/readme.txt | 9 - drivers/gdisp/SSD1289/gdisp_lld.c | 583 ----------- drivers/gdisp/SSD1289/gdisp_lld.mk | 5 - drivers/gdisp/SSD1289/gdisp_lld_board_example.h | 125 --- .../gdisp/SSD1289/gdisp_lld_board_example_fsmc.h | 164 ---- .../SSD1289/gdisp_lld_board_firebullstm32f103.h | 157 --- drivers/gdisp/SSD1289/gdisp_lld_config.h | 53 - drivers/gdisp/SSD1289/readme.txt | 19 - drivers/gdisp/SSD1963/gdisp_lld.c | 613 ------------ drivers/gdisp/SSD1963/gdisp_lld.mk | 5 - drivers/gdisp/SSD1963/gdisp_lld_config.h | 53 - drivers/gdisp/SSD1963/gdisp_lld_panel.h | 53 - drivers/gdisp/SSD1963/readme.txt | 38 - drivers/gdisp/SSD1963/ssd1963.h | 133 --- drivers/gdisp/TestStub/gdisp_lld.c | 133 --- drivers/gdisp/TestStub/gdisp_lld.mk | 5 - drivers/gdisp/TestStub/gdisp_lld_config.h | 51 - drivers/gdisp/TestStub/readme.txt | 16 - drivers/gdisp/VMT/gdisp_lld.c | 271 ------ drivers/gdisp/VMT/gdisp_lld.mk | 7 - drivers/gdisp/VMT/gdisp_lld_config.h | 71 -- drivers/gdisp/VMT/gdisp_lld_driver1.c | 52 - drivers/gdisp/VMT/gdisp_lld_driver2.c | 52 - drivers/gdisp/VMT/readme.txt | 23 - drivers/ginput/toggle/Pal/ginput_lld.mk | 5 - drivers/ginput/toggle/Pal/ginput_lld_toggle.c | 63 -- .../toggle/Pal/ginput_lld_toggle_board_example.h | 61 -- .../Pal/ginput_lld_toggle_board_olimexsam7ex256.h | 57 -- .../ginput/toggle/Pal/ginput_lld_toggle_config.h | 48 - drivers/ginput/toggle/Pal/readme.txt | 13 - drivers/ginput/touch/ADS7843/ginput_lld.mk | 5 - drivers/ginput/touch/ADS7843/ginput_lld_mouse.c | 144 --- .../touch/ADS7843/ginput_lld_mouse_board_example.h | 88 -- .../ginput_lld_mouse_board_firebull_stm32f103.h | 103 -- .../ginput_lld_mouse_board_olimex_stm32_e407.h | 103 -- .../ginput/touch/ADS7843/ginput_lld_mouse_config.h | 44 - drivers/ginput/touch/ADS7843/readme.txt | 9 - drivers/ginput/touch/MCU/ginput_lld.mk | 5 - drivers/ginput/touch/MCU/ginput_lld_mouse.c | 140 --- .../touch/MCU/ginput_lld_mouse_board_example.h | 98 -- .../MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h | 165 ---- drivers/ginput/touch/MCU/ginput_lld_mouse_config.h | 44 - drivers/ginput/touch/MCU/readme.txt | 9 - drivers/multiple/Win32/gdisp_lld.c | 1026 -------------------- drivers/multiple/Win32/gdisp_lld.mk | 5 - drivers/multiple/Win32/gdisp_lld_config.h | 54 -- drivers/multiple/Win32/ginput_lld_mouse_config.h | 62 -- drivers/multiple/Win32/ginput_lld_toggle_config.h | 54 -- drivers/multiple/Win32/readme.txt | 22 - drivers/tdisp/HD44780/tdisp_lld.c | 153 --- drivers/tdisp/HD44780/tdisp_lld.mk | 6 - drivers/tdisp/HD44780/tdisp_lld_board_example.h | 64 -- drivers/tdisp/HD44780/tdisp_lld_config.h | 45 - 84 files changed, 9809 deletions(-) delete mode 100644 drivers/gdisp/ILI9320/gdisp_lld.c delete mode 100644 drivers/gdisp/ILI9320/gdisp_lld.mk delete mode 100644 drivers/gdisp/ILI9320/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h delete mode 100644 drivers/gdisp/ILI9320/gdisp_lld_config.h delete mode 100644 drivers/gdisp/ILI9320/readme.txt delete mode 100644 drivers/gdisp/ILI9325/gdisp_lld.c delete mode 100644 drivers/gdisp/ILI9325/gdisp_lld.mk delete mode 100644 drivers/gdisp/ILI9325/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h delete mode 100644 drivers/gdisp/ILI9325/gdisp_lld_config.h delete mode 100644 drivers/gdisp/ILI9325/readme.txt delete mode 100644 drivers/gdisp/Nokia6610GE12/GE12.h delete mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld.c delete mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld.mk delete mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h delete mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h delete mode 100644 drivers/gdisp/Nokia6610GE12/readme.txt delete mode 100644 drivers/gdisp/Nokia6610GE8/GE8.h delete mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld.c delete mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld.mk delete mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h delete mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h delete mode 100644 drivers/gdisp/Nokia6610GE8/readme.txt delete mode 100644 drivers/gdisp/S6D1121/gdisp_lld.c delete mode 100644 drivers/gdisp/S6D1121/gdisp_lld.mk delete mode 100644 drivers/gdisp/S6D1121/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h delete mode 100644 drivers/gdisp/S6D1121/gdisp_lld_config.h delete mode 100644 drivers/gdisp/S6D1121/readme.txt delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld.c delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld.mk delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_example.h delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h delete mode 100644 drivers/gdisp/SSD1289/gdisp_lld_config.h delete mode 100644 drivers/gdisp/SSD1289/readme.txt delete mode 100644 drivers/gdisp/SSD1963/gdisp_lld.c delete mode 100644 drivers/gdisp/SSD1963/gdisp_lld.mk delete mode 100644 drivers/gdisp/SSD1963/gdisp_lld_config.h delete mode 100644 drivers/gdisp/SSD1963/gdisp_lld_panel.h delete mode 100644 drivers/gdisp/SSD1963/readme.txt delete mode 100644 drivers/gdisp/SSD1963/ssd1963.h delete mode 100644 drivers/gdisp/TestStub/gdisp_lld.c delete mode 100644 drivers/gdisp/TestStub/gdisp_lld.mk delete mode 100644 drivers/gdisp/TestStub/gdisp_lld_config.h delete mode 100644 drivers/gdisp/TestStub/readme.txt delete mode 100644 drivers/gdisp/VMT/gdisp_lld.c delete mode 100644 drivers/gdisp/VMT/gdisp_lld.mk delete mode 100644 drivers/gdisp/VMT/gdisp_lld_config.h delete mode 100644 drivers/gdisp/VMT/gdisp_lld_driver1.c delete mode 100644 drivers/gdisp/VMT/gdisp_lld_driver2.c delete mode 100644 drivers/gdisp/VMT/readme.txt delete mode 100644 drivers/ginput/toggle/Pal/ginput_lld.mk delete mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle.c delete mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h delete mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h delete mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h delete mode 100644 drivers/ginput/toggle/Pal/readme.txt delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld.mk delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse.c delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h delete mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h delete mode 100644 drivers/ginput/touch/ADS7843/readme.txt delete mode 100644 drivers/ginput/touch/MCU/ginput_lld.mk delete mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse.c delete mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h delete mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h delete mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_config.h delete mode 100644 drivers/ginput/touch/MCU/readme.txt delete mode 100644 drivers/multiple/Win32/gdisp_lld.c delete mode 100644 drivers/multiple/Win32/gdisp_lld.mk delete mode 100644 drivers/multiple/Win32/gdisp_lld_config.h delete mode 100644 drivers/multiple/Win32/ginput_lld_mouse_config.h delete mode 100644 drivers/multiple/Win32/ginput_lld_toggle_config.h delete mode 100644 drivers/multiple/Win32/readme.txt delete mode 100644 drivers/tdisp/HD44780/tdisp_lld.c delete mode 100644 drivers/tdisp/HD44780/tdisp_lld.mk delete mode 100644 drivers/tdisp/HD44780/tdisp_lld_board_example.h delete mode 100644 drivers/tdisp/HD44780/tdisp_lld_config.h (limited to 'drivers') diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c deleted file mode 100644 index 202f06dd..00000000 --- a/drivers/gdisp/ILI9320/gdisp_lld.c +++ /dev/null @@ -1,570 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9320/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the ILI9320 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_OLIMEX_STM32_LCD) - #include "gdisp_lld_board_olimex_stm32_lcd.h" -#else - #include "gdisp_lld_board.h" -#endif - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/* This controller is only ever used with a 240 x 320 display */ -#if defined(GDISP_SCREEN_HEIGHT) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_HEIGHT -#endif -#if defined(GDISP_SCREEN_WIDTH) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_WIDTH -#endif - -#define GDISP_SCREEN_WIDTH 240 -#define GDISP_SCREEN_HEIGHT 320 - -#define GDISP_INITIAL_CONTRAST 50 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ -uint32_t DISPLAY_CODE; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ -static __inline void lld_lcdDelay(uint16_t us) { - chThdSleepMicroseconds(us); -} - -static __inline void lld_lcdWriteIndex(uint16_t index) { - GDISP_LLD(write_index)(index); -} - -static __inline void lld_lcdWriteData(uint16_t data) { - GDISP_LLD(write_data)(data); -} - -static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - GDISP_LLD(write_index)(lcdReg); - GDISP_LLD(write_data)(lcdRegValue); -} - -static __inline uint16_t lld_lcdReadData(void) { - /* fix this! */ - //return GDISP_LLD(read_data); - return GDISP_RAM; -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - volatile uint16_t dummy; - - GDISP_LLD(write_index)(lcdReg); - dummy = lld_lcdReadData(); - (void)dummy; - - return lld_lcdReadData(); -} - -static __inline void lld_lcdWriteStreamStart(void) { - lld_lcdWriteIndex(0x0022); -} - -static __inline void lld_lcdWriteStreamStop(void) { - -} - -static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - for(i = 0; i < size; i++) - lld_lcdWriteData(buffer[i]); -} - -static __inline void lld_lcdReadStreamStart(void) { - lld_lcdWriteIndex(0x0022); -} - -static __inline void lld_lcdReadStreamStop(void) { - -} - -static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - dummy = lld_lcdReadData(); - (void)dummy; - - for(i = 0; i < size; i++) - buffer[i] = lld_lcdReadData(); -} - -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - GDISP_LLD(init_board)(); - - /* Hardware reset */ - GDISP_LLD(setpin_reset)(TRUE); - lld_lcdDelay(1000); - GDISP_LLD(setpin_reset)(FALSE); - lld_lcdDelay(1000); - - DISPLAY_CODE = lld_lcdReadReg(0); - lld_lcdWriteReg(0x0000, 0x0001); //start Int. osc - lld_lcdDelay(500); - lld_lcdWriteReg(0x0001, 0x0100); //Set SS bit (shift direction of outputs is from S720 to S1) - lld_lcdWriteReg(0x0002, 0x0700); //select the line inversion - lld_lcdWriteReg(0x0003, 0x1038); //Entry mode(Horizontal : increment,Vertical : increment, AM=1) - lld_lcdWriteReg(0x0004, 0x0000); //Resize control(No resizing) - lld_lcdWriteReg(0x0008, 0x0202); //front and back porch 2 lines - lld_lcdWriteReg(0x0009, 0x0000); //select normal scan - lld_lcdWriteReg(0x000A, 0x0000); //display control 4 - lld_lcdWriteReg(0x000C, 0x0000); //system interface(2 transfer /pixel), internal sys clock, - lld_lcdWriteReg(0x000D, 0x0000); //Frame marker position - lld_lcdWriteReg(0x000F, 0x0000); //selects clk, enable and sync signal polarity, - lld_lcdWriteReg(0x0010, 0x0000); // - lld_lcdWriteReg(0x0011, 0x0000); //power control 2 reference voltages = 1:1, - lld_lcdWriteReg(0x0012, 0x0000); //power control 3 VRH - lld_lcdWriteReg(0x0013, 0x0000); //power control 4 VCOM amplitude - lld_lcdDelay(500); - lld_lcdWriteReg(0x0010, 0x17B0); //power control 1 BT,AP - lld_lcdWriteReg(0x0011, 0x0137); //power control 2 DC,VC - lld_lcdDelay(500); - lld_lcdWriteReg(0x0012, 0x0139); //power control 3 VRH - lld_lcdDelay(500); - lld_lcdWriteReg(0x0013, 0x1d00); //power control 4 vcom amplitude - lld_lcdWriteReg(0x0029, 0x0011); //power control 7 VCOMH - lld_lcdDelay(500); - lld_lcdWriteReg(0x0030, 0x0007); - lld_lcdWriteReg(0x0031, 0x0403); - lld_lcdWriteReg(0x0032, 0x0404); - lld_lcdWriteReg(0x0035, 0x0002); - lld_lcdWriteReg(0x0036, 0x0707); - lld_lcdWriteReg(0x0037, 0x0606); - lld_lcdWriteReg(0x0038, 0x0106); - lld_lcdWriteReg(0x0039, 0x0007); - lld_lcdWriteReg(0x003c, 0x0700); - lld_lcdWriteReg(0x003d, 0x0707); - lld_lcdWriteReg(0x0020, 0x0000); //starting Horizontal GRAM Address - lld_lcdWriteReg(0x0021, 0x0000); //starting Vertical GRAM Address - lld_lcdWriteReg(0x0050, 0x0000); //Horizontal GRAM Start Position - lld_lcdWriteReg(0x0051, 0x00EF); //Horizontal GRAM end Position - lld_lcdWriteReg(0x0052, 0x0000); //Vertical GRAM Start Position - lld_lcdWriteReg(0x0053, 0x013F); //Vertical GRAM end Position - switch (DISPLAY_CODE) { - case 0x9320: - lld_lcdWriteReg(0x0060, 0x2700); //starts scanning from G1, and 320 drive lines - break; - case 0x9325: - lld_lcdWriteReg(0x0060, 0xA700); //starts scanning from G1, and 320 drive lines - break; - } - - lld_lcdWriteReg(0x0061, 0x0001); //fixed base display - lld_lcdWriteReg(0x006a, 0x0000); //no scroll - lld_lcdWriteReg(0x0090, 0x0010); //set Clocks/Line =16, Internal Operation Clock Frequency=fosc/1, - lld_lcdWriteReg(0x0092, 0x0000); //set gate output non-overlap period=0 - lld_lcdWriteReg(0x0093, 0x0003); //set Source Output Position=3 - lld_lcdWriteReg(0x0095, 0x0110); //RGB interface(Clocks per line period=16 clocks) - lld_lcdWriteReg(0x0097, 0x0110); //set Gate Non-overlap Period 0 locksc - lld_lcdWriteReg(0x0098, 0x0110); // - lld_lcdWriteReg(0x0007, 0x0173); //display On - - // Turn on the backlight - GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); - - /* Initialise the GDISP structure */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; - GDISP.Contrast = GDISP_INITIAL_CONTRAST; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - - return TRUE; -} - -static void lld_lcdSetCursor(uint16_t x, uint16_t y) { - uint32_t addr; - - addr = y * 0x100 + x; - - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0020, addr & 0xff); /* low addr */ - lld_lcdWriteReg(0x0021, (addr >> 8) & 0x1ff); /* high addr */ - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0020, (addr >> 8) & 0x1ff); /* low addr */ - lld_lcdWriteReg(0x0021, addr & 0xff); /* high addr */ - break; - - case GDISP_ROTATE_180: - break; - - case GDISP_ROTATE_270: - break; - } -} - -static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0050, x); - lld_lcdWriteReg(0x0051, x + cx - 1); - lld_lcdWriteReg(0x0052, y); - lld_lcdWriteReg(0x0053, y + cy - 1); - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0050, y); - lld_lcdWriteReg(0x0051, y + cy - 1); - lld_lcdWriteReg(0x0052, x); - lld_lcdWriteReg(0x0053, x + cx - 1); - break; - - case GDISP_ROTATE_180: - break; - - case GDISP_ROTATE_270: - break; - - } - - lld_lcdSetCursor(x, y); -} - -static __inline void lld_lcdResetViewPort(void) { - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - case GDISP_ROTATE_180: - lld_lcdSetViewPort(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); - break; - case GDISP_ROTATE_90: - case GDISP_ROTATE_270: - lld_lcdSetViewPort(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); - break; - } -} - -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - unsigned i, area; - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(color); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy; - unsigned lg; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - - endx = srcx + cx; - endy = y + cy; - lg = srccx - cx; - buffer += srcx + srcy * srccx; - for(; y < endy; y++, buffer += lg) - for(x=srcx; x < endx; x++) - lld_lcdWriteData(*buffer++); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - color_t color; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; - #endif - - lld_lcdSetCursor(x, y); - lld_lcdWriteStreamStart(); - - color = lld_lcdReadData(); - color = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - abslines = lines < 0 ? -lines : lines; - - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetViewPort(x, row0, cx, 1); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, cx); - lld_lcdReadStreamStop(); - - lld_lcdSetViewPort(x, row1, cx, 1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, cx); - lld_lcdWriteStreamStop(); - } - } - - /* fill the remaining gap */ - lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); - lld_lcdWriteStreamStart(); - gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if(GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - lld_lcdWriteReg(0x0007, 0x0000); - lld_lcdWriteReg(0x0010, 0x0000); - lld_lcdWriteReg(0x0011, 0x0000); - lld_lcdWriteReg(0x0012, 0x0000); - lld_lcdWriteReg(0x0013, 0x0000); - GDISP_LLD(set_backlight)(0); - break; - - case powerOn: - //*************Power On sequence ******************// - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */ - lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ - GDISP_LLD(set_backlight)(GDISP.Backlight); - if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) - GDISP_LLD(init)(); - break; - - case powerSleep: - lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); - break; - - case powerDeepSleep: - lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); - break; - - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - - case GDISP_CONTROL_ORIENTATION: - if(GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0001, 0x0100); - lld_lcdWriteReg(0x0003, 0x1038); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0001, 0x0000); - lld_lcdWriteReg(0x0003, 0x1030); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - - case GDISP_ROTATE_180: - /* ToDo */ - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - - case GDISP_ROTATE_270: - /* ToDo */ - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - - default: - return; - } - - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; - - case GDISP_CONTROL_BACKLIGHT: - if((unsigned)value > 100) value = (void *)100; - GDISP_LLD(set_backlight)((unsigned)value); - GDISP.Backlight = (unsigned)value; - break; - - default: - return; - } - } - -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/ILI9320/gdisp_lld.mk b/drivers/gdisp/ILI9320/gdisp_lld.mk deleted file mode 100644 index bcdd3230..00000000 --- a/drivers/gdisp/ILI9320/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/ILI9320 diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_example.h b/drivers/gdisp/ILI9320/gdisp_lld_board_example.h deleted file mode 100644 index a79e557b..00000000 --- a/drivers/gdisp/ILI9320/gdisp_lld_board_example.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9320/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9320 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_BOARD_H -#define GDISP_LLD_BOARD_H - -static __inline void GDISP_LLD(init_board)(void) { - #error "ILI9320: You must implement the init_board routine for your board" -} - -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - #error "ILI9320: You must implement setpin_reset routine for your board" -} - -static __inline void GDISP_LLD(write_index)(uint16_t data) { - #error "ILI9320: You must implement write_index routine for your board" -} - -static __inline void GDISP_LLD(write_data)(uint16_t data) { - #error "ILI9320: You must implement write_data routine for your board" -} - -static __inline uint16_t GDISP_LLD(read_data)(void) { - #error "ILI9320: You must implement read_data routine for your board" -} - -/* if not available, just ignore the argument and return */ -static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { - #error "ILI9320: You must implement set_backlight routine for your board" -} - -#endif /* GDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h deleted file mode 100644 index a6d9d631..00000000 --- a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9320 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_BOARD_H -#define GDISP_LLD_BOARD_H - -#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ -#define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* RS = 1 */ - -static __inline void GDISP_LLD(init_board)(void) { - /* FSMC setup for F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - /* set pin modes */ - IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0}; - IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0}; - palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); - - const unsigned char FSMC_Bank = 0; - - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); - - /* Bank1 NOR/SRAM control register configuration - * This is actually not needed as already set by default after reset */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; -} - -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - if(state) - palClearPad(GPIOE, GPIOE_TFT_RST); - else - palSetPad(GPIOE, GPIOE_TFT_RST); -} - -static __inline void GDISP_LLD(write_index)(uint16_t reg) { - GDISP_REG = reg; -} - -static __inline void GDISP_LLD(write_data)(uint16_t data) { - GDISP_RAM = data; -} - -static __inline uint16_t GDISP_LLD(read_data)(void) { - return GDISP_RAM; -} - -static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { - if(percent == 100) - palClearPad(GPIOD, GPIOD_TFT_LIGHT); - else - palSetPad(GPIOD, GPIOD_TFT_LIGHT); -} - -#endif /* GDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9320/gdisp_lld_config.h b/drivers/gdisp/ILI9320/gdisp_lld_config.h deleted file mode 100644 index d55f2115..00000000 --- a/drivers/gdisp/ILI9320/gdisp_lld_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9320/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the ILI9320 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_CONFIG_H -#define GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "ILI9320" -#define GDISP_LLD(x) gdisp_lld_##x##_ILI9320 - -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS FALSE -#define GDISP_HARDWARE_SCROLL FALSE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9320/readme.txt b/drivers/gdisp/ILI9320/readme.txt deleted file mode 100644 index dcffe206..00000000 --- a/drivers/gdisp/ILI9320/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - - d) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - Olimex STM32-LCD - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld.mk diff --git a/drivers/gdisp/ILI9325/gdisp_lld.c b/drivers/gdisp/ILI9325/gdisp_lld.c deleted file mode 100644 index 42b03d74..00000000 --- a/drivers/gdisp/ILI9325/gdisp_lld.c +++ /dev/null @@ -1,580 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9325/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the ILI9325 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_HY_STM32_100P) - #include "gdisp_lld_board_hy_stm32_100p.h" -#else - #include "gdisp_lld_board.h" -#endif - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/* This controller is only ever used with a 240 x 320 display */ -#if defined(GDISP_SCREEN_HEIGHT) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_HEIGHT -#endif -#if defined(GDISP_SCREEN_WIDTH) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_WIDTH -#endif - -#define GDISP_SCREEN_WIDTH 240 -#define GDISP_SCREEN_HEIGHT 320 - -#define GDISP_INITIAL_CONTRAST 50 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ -uint32_t DISPLAY_CODE; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ -static __inline void lld_lcdDelay(uint16_t us) { - chThdSleepMicroseconds(us); -} - -static __inline void lld_lcdWriteIndex(uint16_t index) { - GDISP_LLD(write_index)(index); -} - -static __inline void lld_lcdWriteData(uint16_t data) { - GDISP_LLD(write_data)(data); -} - -static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - GDISP_LLD(write_index)(lcdReg); - GDISP_LLD(write_data)(lcdRegValue); -} - -static __inline uint16_t lld_lcdReadData(void) { - /* fix this! */ - //return GDISP_LLD(read_data); - return GDISP_RAM; -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - volatile uint16_t dummy; - - GDISP_LLD(write_index)(lcdReg); - dummy = lld_lcdReadData(); - (void)dummy; - - return lld_lcdReadData(); -} - -static __inline void lld_lcdWriteStreamStart(void) { - lld_lcdWriteIndex(0x0022); -} - -static __inline void lld_lcdWriteStreamStop(void) { - -} - -static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - for(i = 0; i < size; i++) - lld_lcdWriteData(buffer[i]); -} - -static __inline void lld_lcdReadStreamStart(void) { - lld_lcdWriteIndex(0x0022); -} - -static __inline void lld_lcdReadStreamStop(void) { - -} - -static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - dummy = lld_lcdReadData(); - (void)dummy; - - for(i = 0; i < size; i++) - buffer[i] = lld_lcdReadData(); -} - -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - GDISP_LLD(init_board)(); - - /* Hardware reset */ - GDISP_LLD(setpin_reset)(TRUE); - lld_lcdDelay(1000); - GDISP_LLD(setpin_reset)(FALSE); - lld_lcdDelay(1000); - - // chinese code starts here - lld_lcdWriteReg(0x0000,0x0001); - lld_lcdDelay(10); - - lld_lcdWriteReg(0x0015,0x0030); - lld_lcdWriteReg(0x0011,0x0040); - lld_lcdWriteReg(0x0010,0x1628); - lld_lcdWriteReg(0x0012,0x0000); - lld_lcdWriteReg(0x0013,0x104d); - lld_lcdDelay(10); - lld_lcdWriteReg(0x0012,0x0010); - lld_lcdDelay(10); - lld_lcdWriteReg(0x0010,0x2620); - lld_lcdWriteReg(0x0013,0x344d); //304d - lld_lcdDelay(10); - - lld_lcdWriteReg(0x0001,0x0100); - lld_lcdWriteReg(0x0002,0x0300); - lld_lcdWriteReg(0x0003,0x1038);//0x1030 - lld_lcdWriteReg(0x0008,0x0604); - lld_lcdWriteReg(0x0009,0x0000); - lld_lcdWriteReg(0x000A,0x0008); - - lld_lcdWriteReg(0x0041,0x0002); - lld_lcdWriteReg(0x0060,0x2700); - lld_lcdWriteReg(0x0061,0x0001); - lld_lcdWriteReg(0x0090,0x0182); - lld_lcdWriteReg(0x0093,0x0001); - lld_lcdWriteReg(0x00a3,0x0010); - lld_lcdDelay(10); - - //################# void Gamma_Set(void) ####################// - lld_lcdWriteReg(0x30,0x0000); - lld_lcdWriteReg(0x31,0x0502); - lld_lcdWriteReg(0x32,0x0307); - lld_lcdWriteReg(0x33,0x0305); - lld_lcdWriteReg(0x34,0x0004); - lld_lcdWriteReg(0x35,0x0402); - lld_lcdWriteReg(0x36,0x0707); - lld_lcdWriteReg(0x37,0x0503); - lld_lcdWriteReg(0x38,0x1505); - lld_lcdWriteReg(0x39,0x1505); - lld_lcdDelay(10); - - //################## void Display_ON(void) ####################// - lld_lcdWriteReg(0x0007,0x0001); - lld_lcdDelay(10); - lld_lcdWriteReg(0x0007,0x0021); - lld_lcdWriteReg(0x0007,0x0023); - lld_lcdDelay(10); - lld_lcdWriteReg(0x0007,0x0033); - lld_lcdDelay(10); - lld_lcdWriteReg(0x0007,0x0133); - - // chinese code ends here - - // Turn on the backlight - GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); - - /* Initialise the GDISP structure */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; - GDISP.Contrast = GDISP_INITIAL_CONTRAST; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - - return TRUE; -} - -static void lld_lcdSetCursor(uint16_t x, uint16_t y) { - - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0020, x); - lld_lcdWriteReg(0x0021, y); - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0020, y); - lld_lcdWriteReg(0x0021, x); - break; - - case GDISP_ROTATE_180: - lld_lcdWriteReg(0x0020, x); - lld_lcdWriteReg(0x0021, y); - break; - - case GDISP_ROTATE_270: - lld_lcdWriteReg(0x0020, y); - lld_lcdWriteReg(0x0021, x); - break; - } -} - -static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0050, x); - lld_lcdWriteReg(0x0051, x + cx - 1); - lld_lcdWriteReg(0x0052, y); - lld_lcdWriteReg(0x0053, y + cy - 1); - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0050, y); - lld_lcdWriteReg(0x0051, y + cy - 1); - lld_lcdWriteReg(0x0052, x); - lld_lcdWriteReg(0x0053, x + cx - 1); - break; - - case GDISP_ROTATE_180: - lld_lcdWriteReg(0x0050, x); - lld_lcdWriteReg(0x0051, x + cx - 1); - lld_lcdWriteReg(0x0052, y); - lld_lcdWriteReg(0x0053, y + cy - 1); - break; - - case GDISP_ROTATE_270: - lld_lcdWriteReg(0x0050, y); - lld_lcdWriteReg(0x0051, y + cy - 1); - lld_lcdWriteReg(0x0052, x); - lld_lcdWriteReg(0x0053, x + cx - 1); - break; - - } - - lld_lcdSetCursor(x, y); -} - -static __inline void lld_lcdResetViewPort(void) { - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - case GDISP_ROTATE_180: - lld_lcdSetViewPort(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); - break; - case GDISP_ROTATE_90: - case GDISP_ROTATE_270: - lld_lcdSetViewPort(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); - break; - } -} - -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - unsigned i, area; - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(color); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy; - unsigned lg; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - - endx = srcx + cx; - endy = y + cy; - lg = srccx - cx; - buffer += srcx + srcy * srccx; - for(; y < endy; y++, buffer += lg) - for(x=srcx; x < endx; x++) - lld_lcdWriteData(*buffer++); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - color_t color; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; - #endif - - lld_lcdSetCursor(x, y); - lld_lcdWriteStreamStart(); - - color = lld_lcdReadData(); - color = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - abslines = lines < 0 ? -lines : lines; - - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetViewPort(x, row0, cx, 1); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, cx); - lld_lcdReadStreamStop(); - - lld_lcdSetViewPort(x, row1, cx, 1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, cx); - lld_lcdWriteStreamStop(); - } - } - - /* fill the remaining gap */ - lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); - lld_lcdWriteStreamStart(); - gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if(GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - lld_lcdWriteReg(0x0007, 0x0000); - lld_lcdWriteReg(0x0010, 0x0000); - lld_lcdWriteReg(0x0011, 0x0000); - lld_lcdWriteReg(0x0012, 0x0000); - lld_lcdWriteReg(0x0013, 0x0000); - GDISP_LLD(set_backlight)(0); - break; - - case powerOn: - //*************Power On sequence ******************// - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */ - lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ - lld_lcdDelay(500); - lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ - GDISP_LLD(set_backlight)(GDISP.Backlight); - if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) - GDISP_LLD(init)(); - break; - - case powerSleep: - lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); - break; - - case powerDeepSleep: - lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ - lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ - lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ - lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); - break; - - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - - case GDISP_CONTROL_ORIENTATION: - if(GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x0001, 0x0100); - lld_lcdWriteReg(0x0003, 0x1038); - lld_lcdWriteReg(0x0060, 0x2700); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x0001, 0x0000); - lld_lcdWriteReg(0x0003, 0x1030); - lld_lcdWriteReg(0x0060, 0x2700); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - - case GDISP_ROTATE_180: - lld_lcdWriteReg(0x0001, 0x0000); - lld_lcdWriteReg(0x0003, 0x1038); - lld_lcdWriteReg(0x0060, 0xa700); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - - case GDISP_ROTATE_270: - lld_lcdWriteReg(0x0001, 0x0100); - lld_lcdWriteReg(0x0003, 0x1030); - lld_lcdWriteReg(0x0060, 0xA700); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - - default: - return; - } - - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; - - case GDISP_CONTROL_BACKLIGHT: - if((unsigned)value > 100) value = (void *)100; - GDISP_LLD(set_backlight)((unsigned)value); - GDISP.Backlight = (unsigned)value; - break; - - default: - return; - } - } - -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/ILI9325/gdisp_lld.mk b/drivers/gdisp/ILI9325/gdisp_lld.mk deleted file mode 100644 index b5061324..00000000 --- a/drivers/gdisp/ILI9325/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/ILI9325 diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_example.h b/drivers/gdisp/ILI9325/gdisp_lld_board_example.h deleted file mode 100644 index 7b537dcd..00000000 --- a/drivers/gdisp/ILI9325/gdisp_lld_board_example.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9325/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_BOARD_H -#define GDISP_LLD_BOARD_H - -static __inline void GDISP_LLD(init_board)(void) { - #error "ILI9325: You must implement the init_board routine for your board" -} - -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - #error "ILI9325: You must implement setpin_reset routine for your board" -} - -static __inline void GDISP_LLD(write_index)(uint16_t data) { - #error "ILI9325: You must implement write_index routine for your board" -} - -static __inline void GDISP_LLD(write_data)(uint16_t data) { - #error "ILI9325: You must implement write_data routine for your board" -} - -static __inline uint16_t GDISP_LLD(read_data)(void) { - #error "ILI9325: You must implement read_data routine for your board" -} - -/* if not available, just ignore the argument and return */ -static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { - #error "ILI9325: You must implement set_backlight routine for your board" -} - -#endif /* GDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h b/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h deleted file mode 100644 index e785ad10..00000000 --- a/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - driver quickly hacked together from a chinese sourcecode that came - with the board and existing ili9320 code by Chris van Dongen (sjaak) - (sjaak2002 at msn.com) - - Also added rotation for 180 and 270 degrees and minor tweaks to - setcursor - - Added code comes without warranty and free bugs. Feel free to use - or misuse the added code :D -*/ - - -/** - * @file drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_BOARD_H -#define GDISP_LLD_BOARD_H - -#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ -#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - -static __inline void GDISP_LLD(init_board)(void) { - /* FSMC setup for F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - /* set pin modes */ -/* IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0}; - IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0}; - palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); */ - - const unsigned char FSMC_Bank = 0; - - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); - - /* Bank1 NOR/SRAM control register configuration - * This is actually not needed as already set by default after reset */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; - -} - -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - if(state) - palClearPad(GPIOE, GPIOE_TFT_RST); - else - palSetPad(GPIOE, GPIOE_TFT_RST); -} - -static __inline void GDISP_LLD(write_index)(uint16_t reg) { - GDISP_REG = reg; -} - -static __inline void GDISP_LLD(write_data)(uint16_t data) { - GDISP_RAM = data; -} - -static __inline uint16_t GDISP_LLD(read_data)(void) { - return GDISP_RAM; -} - -static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { - percent=percent; // avoid a warning -} - -#endif /* GDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9325/gdisp_lld_config.h b/drivers/gdisp/ILI9325/gdisp_lld_config.h deleted file mode 100644 index 44f8323f..00000000 --- a/drivers/gdisp/ILI9325/gdisp_lld_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/ILI9325/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the ILI9325 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef GDISP_LLD_CONFIG_H -#define GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "ILI9325" -#define GDISP_LLD(x) gdisp_lld_##x##_ILI9325 - -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS FALSE -#define GDISP_HARDWARE_SCROLL FALSE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/ILI9325/readme.txt b/drivers/gdisp/ILI9325/readme.txt deleted file mode 100644 index 9150610e..00000000 --- a/drivers/gdisp/ILI9325/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - - d) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - HY_STM32_100p - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.mk diff --git a/drivers/gdisp/Nokia6610GE12/GE12.h b/drivers/gdisp/Nokia6610GE12/GE12.h deleted file mode 100644 index 6c980e2e..00000000 --- a/drivers/gdisp/Nokia6610GE12/GE12.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GE12_H -#define GE12_H - -// ************************************************************************************* -// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver (GE12) -// -// Taken from Philips data sheet Feb 14, 2003 -// ************************************************************************************* - -// Philips PCF8833 LCD controller command codes -#define NOP 0x00 // nop -#define SWRESET 0x01 // software reset -#define BSTROFF 0x02 // booster voltage OFF -#define BSTRON 0x03 // booster voltage ON -#define RDDIDIF 0x04 // read display identification -#define RDDST 0x09 // read display status -#define SLEEPIN 0x10 // sleep in -#define SLEEPOUT 0x11 // sleep out -#define PTLON 0x12 // partial display mode -#define NORON 0x13 // display normal mode -#define INVOFF 0x20 // inversion OFF -#define INVON 0x21 // inversion ON -#define DALO 0x22 // all pixel OFF -#define DAL 0x23 // all pixel ON -#define SETCON 0x25 // write contrast -#define DISPOFF 0x28 // display OFF -#define DISPON 0x29 // display ON -#define CASET 0x2A // column address set -#define PASET 0x2B // page address set -#define RAMWR 0x2C // memory write -#define RGBSET 0x2D // colour set -#define PTLAR 0x30 // partial area -#define VSCRDEF 0x33 // vertical scrolling definition -#define TEOFF 0x34 // test mode -#define TEON 0x35 // test mode -#define MADCTL 0x36 // memory access control -#define SEP 0x37 // vertical scrolling start address -#define IDMOFF 0x38 // idle mode OFF -#define IDMON 0x39 // idle mode ON -#define COLMOD 0x3A // interface pixel format -#define SETVOP 0xB0 // set Vop -#define BRS 0xB4 // bottom row swap -#define TRS 0xB6 // top row swap -#define DISCTR 0xB9 // display control -#define DOR 0xBA // data order -#define TCDFE 0xBD // enable/disable DF temperature compensation -#define TCVOPE 0xBF // enable/disable Vop temp comp -#define EC 0xC0 // internal or external oscillator -#define SETMUL 0xC2 // set multiplication factor -#define TCVOPAB 0xC3 // set TCVOP slopes A and B -#define TCVOPCD 0xC4 // set TCVOP slopes c and d -#define TCDF 0xC5 // set divider frequency -#define DF8COLOR 0xC6 // set divider frequency 8-color mode -#define SETBS 0xC7 // set bias system -#define RDTEMP 0xC8 // temperature read back -#define NLI 0xC9 // n-line inversion -#define RDID1 0xDA // read ID1 -#define RDID2 0xDB // read ID2 -#define RDID3 0xDC // read ID3 - -#endif /* GE12_H */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld.c b/drivers/gdisp/Nokia6610GE12/gdisp_lld.c deleted file mode 100644 index 7e5e1215..00000000 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE12/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 GE12 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/* Controller definitions */ -#include "GE12.h" - -/* This controller is only ever used with a 132 x 132 display */ -#if defined(GDISP_SCREEN_HEIGHT) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_HEIGHT -#endif -#if defined(GDISP_SCREEN_WIDTH) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_WIDTH -#endif -#define GDISP_SCREEN_HEIGHT 132 -#define GDISP_SCREEN_WIDTH 132 - -#define GDISP_INITIAL_CONTRAST 38 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_OLIMEX_SAM7_EX256) - #include "gdisp_lld_board_olimexsam7ex256.h" -#else - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#endif - -// Some macros just to make reading the code easier -#define delayms(ms) chThdSleepMilliseconds(ms) -#define write_data2(d1, d2) { write_data(d1); write_data(d2); } -#define write_data3(d1, d2, d3) { write_data(d1); write_data(d2); write_data(d3); } -#define write_cmd1(cmd, d1) { write_cmd(cmd); write_data(d1); } -#define write_cmd2(cmd, d1, d2) { write_cmd(cmd); write_data2(d1, d2); } -#define write_cmd3(cmd, d1, d2, d3) { write_cmd(cmd); write_data3(d1, d2, d3); } - -// A very common thing to do. -// An inline function has been used here incase the parameters have side effects with the internal calculations. -static __inline void setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { - write_cmd2(CASET, x, x+cx-1); // Column address set - write_cmd2(PASET, y, y+cy-1); // Page address set -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - init_board(); - - // Hardware reset - setpin_reset(TRUE); - delayms(20); - setpin_reset(FALSE); - delayms(20); - - // Get the bus for the following initialisation commands - acquire_bus(); - - // UNTESTED - #if 1 - write_cmd(SLEEPOUT); // Sleep out - write_cmd(INVON); // Inversion on: seems to be required for this controller - write_cmd1(COLMOD, 0x03); // Color Interface Pixel Format - 0x03 = 12 bits-per-pixel - write_cmd1(MADCTL, 0xC8); // Memory access controler - 0xC0 = mirror x and y, reverse rgb - write_cmd1(SETCON, GDISP_INITIAL_CONTRAST); // Write contrast - delayms(20); - write_cmd(DISPON); // Display On - #else - // Alternative - write_cmd(SOFTRST); // Software Reset - delayms(20); - write_cmd(INITESC); // Initial escape - delayms(20); - write_cmd1(REFSET, 0x00); // Refresh set - write_cmd(DISPCTRL); // Set Display control - really 7 bytes of data - write_data(128); // Set the lenght of one selection term - write_data(128); // Set N inversion -> no N inversion - write_data(134); // Set frame frequence and bias rate -> 2 devision of frequency and 1/8 bias, 1/67 duty, 96x67 size - write_data(84); // Set duty parameter - write_data(69); // Set duty parameter - write_data(82); // Set duty parameter - write_data(67); // Set duty parameter - write_cmd(GRAYSCALE0); // Grey scale 0 position set - really 15 bytes of data - write_data(1); // GCP1 - gray lavel to be output when the RAM data is "0001" - write_data(2); // GCP2 - gray lavel to be output when the RAM data is "0010" - write_data(4); // GCP3 - gray lavel to be output when the RAM data is "0011" - write_data(8); // GCP4 - gray lavel to be output when the RAM data is "0100" - write_data(16); // GCP5 - gray lavel to be output when the RAM data is "0101" - write_data(30); // GCP6 - gray lavel to be output when the RAM data is "0110" - write_data(40); // GCP7 - gray lavel to be output when the RAM data is "0111" - write_data(50); // GCP8 - gray lavel to be output when the RAM data is "1000" - write_data(60); // GCP9 - gray lavel to be output when the RAM data is "1001" - write_data(70); // GCP10 - gray lavel to be output when the RAM data is "1010" - write_data(80); // GCP11 - gray lavel to be output when the RAM data is "1011" - write_data(90); // GCP12 - gray lavel to be output when the RAM data is "1100" - write_data(100); // GCP13 - gray lavel to be output when the RAM data is "1101" - write_data(110); // GCP14 - gray lavel to be output when the RAM data is "1110" - write_data(127); // GCP15 - gray lavel to be output when the RAM data is "1111" - write_cmd1(GAMMA, 0x01); // Gamma curve set - select gray scale - GRAYSCALE 0 or GREYSCALE 1 - Select grey scale 0 - write_cmd1(COMMONDRV, 0x00); // Command driver output - Set COM1-COM41 side come first, normal mod - write_cmd(NORMALMODE); // Set Normal mode (my) - // write_cmd(INVERSIONOFF); // Inversion off - write_cmd2(COLADDRSET, 0, 131); // Column address set - write_cmd2(PAGEADDRSET, 0, 131); // Page address set - write_cmd1(ACCESSCTRL, 0x40); // Memory access controler - 0x40 horizontal - // write_data(0x20); // vertical - write_cmd1(PWRCTRL, 0x04); // Power control - Internal resistance, V1OUT -> high power mode, oscilator devision rate - write_cmd(SLEEPOUT); // Sleep out - write_cmd(VOLTCTRL); // Voltage control - voltage control and write contrast define LCD electronic volume - // write_data(0x7f); // full voltage control - // write_data(0x03); // must be "1" - write_cmd1(CONTRAST, GDISP_INITIAL_CONTRAST); // Write contrast - delayms(20); - write_cmd(TEMPGRADIENT); // Temperature gradient - really 14 bytes of data - for(i=0; i<14; i++) - write_data(0); - write_cmd(BOOSTVON); // Booster voltage ON - write_cmd(DISPLAYON); // Finally - Display On - #endif - - // Release the bus - release_bus(); - - /* Turn on the back-light */ - set_backlight(GDISP_INITIAL_BACKLIGHT); - - /* Initialise the GDISP structure to match */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; - GDISP.Contrast = GDISP_INITIAL_CONTRAST; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - acquire_bus(); - setviewport(x, y, 1, 1); - write_cmd3(RAMWR, 0, (color>>8) & 0x0F, color & 0xFF); - release_bus(); -} - -/* ---- Optional Routines ---- */ - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - unsigned i, tuples; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. - // This extra pixel is ignored by the controller. - - acquire_bus(); - setviewport(x, y, cx, cy); - write_cmd(RAMWR); - for(i=0; i < tuples; i++) - write_data3(((color >> 4) & 0xFF), (((color << 4) & 0xF0)|((color >> 8) & 0x0F)), (color & 0xFF)); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy, lg; - color_t c1, c2; - #if GDISP_PACKED_PIXELS - coord_t pos; - const uint8_t *p; - #endif - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - /* What are our end points */ - endx = srcx + cx; - endy = y + cy; - - acquire_bus(); - setviewport(x, y, cx, cy); - write_cmd(RAMWR); - - #if !GDISP_PACKED_PIXELS - // Although this controller uses packed pixels we support unpacked pixel - // formats in this blit by packing the data as we feed it to the controller. - lg = srccx - cx; - buffer += srcy * srccx + srcx; - x = srcx; - while (1) { - /* Get a pixel */ - c1 = *buffer++; - if (++x >= endx) { - if (++y >= endy) { - /* Odd pixel at end */ - write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); - break; - } - x = srcx; - buffer += lg; - } - /* Get the next pixel */ - c2 = *buffer++; - write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); - if (++x >= endx) { - if (++y >= endy) - break; - x = srcx; - buffer += lg; - } - } - - #else - - // Although this controller uses packed pixels, we may have to feed it into - // the controller with different packing to the source bitmap - #if !GDISP_PACKED_LINES - srccx = (srccx + 1) & ~1; - #endif - pos = srcy*srccx; - lg = (srccx - cx)/2*3; - p = ((const uint8_t *)buffer) + ((pos+srcx)/2 * 3); - - x = srcx; - while (1) { - /* Get a pixel */ - switch((pos+x)&1) { - case 0: c1 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; - case 1: c1 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; - } - if (++x >= endx) { - if (++y >= endy) { - /* Odd pixel at end */ - write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); - break; - } - x = srcx; - p += lg; - pos += srccx; - } - /* Get the next pixel */ - switch((pos+x)&1) { - case 0: c2 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; - case 1: c2 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; - } - write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); - if (++x >= endx) { - if (++y >= endy) - break; - x = srcx; - p += lg; - pos += srccx; - } - } - #endif - release_bus(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) - /** - * @brief Get the color of a particular pixel. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - /* NOT IMPLEMENTED */ - /* Some board hardware might support this in the future. - * The Olimex board doesn't. - */ - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) - /** - * @brief Scroll vertically a section of the screen. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - /* NOT IMPLEMENTED */ - /* The hardware seems capable of doing this. - * It is just really complex so we leave it out for now. - */ - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @details Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - /* The hardware is capable of supporting... - * GDISP_CONTROL_POWER - not implemented yet - * GDISP_CONTROL_ORIENTATION - not implemented yet - * GDISP_CONTROL_BACKLIGHT - supported (the OlimexSAM7EX256 board.h currently only implements off/on although PWM is supported by the hardware) - * GDISP_CONTROL_CONTRAST - supported - */ - switch(what) { -#if 0 - // NOT IMPLEMENTED YET - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - // Code here - break; - case powerOn: - // Code here - /* You may need this --- - * if (GDISP.Powermode != powerSleep) - * GDISP_LLD(init)(); - */ - break; - case powerSleep: - /* Code here */ - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; -#endif -#if 0 - // NOT IMPLEMENTED YET - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) - // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - // Code here - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - // Code here - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - // Code here - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - // Code here - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -#endif - case GDISP_CONTROL_BACKLIGHT: - if ((unsigned)value > 100) value = (void *)100; - set_backlight((unsigned)value); - GDISP.Backlight = (unsigned)value; - return; - case GDISP_CONTROL_CONTRAST: - if ((unsigned)value > 100) value = (void *)100; - acquire_bus(); - write_cmd1(CONTRAST,(unsigned)value); - release_bus(); - GDISP.Contrast = (unsigned)value; - return; - } - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk b/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk deleted file mode 100644 index 575d52a3..00000000 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12 diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h deleted file mode 100644 index 1885f07c..00000000 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 GE12 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for init_board for your board" -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for setpin_reset for your board" -} - -/** - * @brief Set the lcd back-light level. - * @note For now 0% turns the backlight off, anything else the backlight is on. - * While the hardware supports PWM backlight control, we are not using it - * yet. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for set_backlight for your board" -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for acquire_bus for your board" -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for release_bus for your board" -} - -/** - * @brief Send an 8 bit command to the lcd. - * - * @param[in] cmd The command to send - * - * @notapi - */ -static __inline void write_cmd(uint16_t cmd) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for write_cmd for your board" -} - -/** - * @brief Send an 8 bit data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for write_data for your board" -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { - /* Code here */ - #error "gdispNokia6610GE12: You must supply a definition for read_data for your board" -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h deleted file mode 100644 index c161a9a3..00000000 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h - * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -// ****************************************************** -// Pointers to AT91SAM7X256 peripheral data structures -// ****************************************************** -volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; -volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; -volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; -volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; -volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void init_board(void) { - // ********************************************************************************************* - // InitSpi( ) - // - // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display - // - // I/O ports used: PA2 = LCD Reset (set to low to reset) - // PA12 = LCD chip select (set to low to select the LCD chip) - // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) - // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // PA18 = SPI0_SPCK Serial Clock (to LCD slave) - // PB20 = backlight control (normally PWM control, 1 = full on) - // - // *********************************************************************************************} - - /* This code should really use the ChibiOS driver for these functions */ - - // Pin for backlight - pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW - pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output - - // Reset pin - pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH - pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output - - // CS pin - this seems to be ignored - // pPIOA->PIO_SODR = 1<<12; // Set PA2 to HIGH - // pPIOA->PIO_OER = 1<<12; // Configure PA2 as output - - // Init SPI0 - // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) - // BIT12 = PA12 -> SPI0_NPCS0 chip select - // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) - // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) - pPIOA->PIO_PDR = (1<<12) | (1<<16) | (1<<17) | (1<<18); - pPIOA->PIO_ASR = (1<<12) | (1<<16) | (1<<17) | (1<<18); - pPIOA->PIO_BSR = 0; - - //enable the clock of SPI - pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; - - // Fixed mode - pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset - pSPI->SPI_CR = 0x01; //SPI Enable - - //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 - pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 - - //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz - pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - if (state) - palClearPad(IOPORT1, PIOA_LCD_RESET); - else - palSetPad(IOPORT1, PIOA_LCD_RESET); -} - -/** - * @brief Set the lcd back-light level. - * @note For now 0% turns the backlight off, anything else the backlight is on. - * While the hardware supports PWM backlight control, we are not using it - * yet. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - if (percent) - palSetPad(IOPORT2, PIOB_LCD_BL); - else - palClearPad(IOPORT2, PIOB_LCD_BL); -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Nothing to do for this board as the LCD is the only device on the SPI port */ -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - // Nothing to do for this board as the LCD is the only device on the SPI port -} - -/** - * @brief Send an 8 bit command to the lcd. - * - * @param[in] cmd The command to send - * - * @notapi - */ -static __inline void write_cmd(uint16_t cmd) { - // wait for the previous transfer to complete - while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); - // send the command - pSPI->SPI_TDR = cmd & 0xFF; -} - -/** - * @brief Send an 8 bit data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - // wait for the previous transfer to complete - while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); - // send the data - pSPI->SPI_TDR = data | 0x0100; -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * - * @notapi - */ -static __inline uint16_t read_data(void) { - #error "gdispNokia6610GE12: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" - return 0; -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h deleted file mode 100644 index ab9d35e7..00000000 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 GE12 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "Nokia6610GE12" -#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE12 - -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 -/* This driver supports both packed and unpacked pixel formats and line formats. - * By default we leave these as FALSE. - */ -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/readme.txt b/drivers/gdisp/Nokia6610GE12/readme.txt deleted file mode 100644 index 54c4570f..00000000 --- a/drivers/gdisp/Nokia6610GE12/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -This driver is for the Nokia6610 Philips (GE12) controller - -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - Olimex SAM7-EX256 - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk diff --git a/drivers/gdisp/Nokia6610GE8/GE8.h b/drivers/gdisp/Nokia6610GE8/GE8.h deleted file mode 100644 index 789308a9..00000000 --- a/drivers/gdisp/Nokia6610GE8/GE8.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GE8_H -#define GE8_H - -// ***************************************************************************** -// Include file for Epson S1D15G00 LCD Controller (GE8) -// -// Author: James P Lynch August 30, 2007 -// Modified for GDISP: Andrew Hannam August 2, 2012 -// -// ***************************************************************************** - -#define DISON 0xAF // Display on -#define DISOFF 0xAE // Display off -#define DISNOR 0xA6 // Normal display -#define DISINV 0xA7 // Inverse display -#define COMSCN 0xBB // Common scan direction -#define DISCTL 0xCA // Display control -#define SLPIN 0x95 // Sleep in -#define SLPOUT 0x94 // Sleep out -#define PASET 0x75 // Page address set -#define CASET 0x15 // Column address set -#define DATCTL 0xBC // Data scan direction, etc. -#define RGBSET8 0xCE // 256-color position set -#define RAMWR 0x5C // Writing to memory -#define RAMRD 0x5D // Reading from memory -#define PTLIN 0xA8 // Partial display in -#define PTLOUT 0xA9 // Partial display out -#define RMWIN 0xE0 // Read and modify write -#define RMWOUT 0xEE // End -#define ASCSET 0xAA // Area scroll set -#define SCSTART 0xAB // Scroll start set -#define OSCON 0xD1 // Internal oscillation on -#define OSCOFF 0xD2 // Internal oscillation off -#define PWRCTR 0x20 // Power control -#define VOLCTR 0x81 // Electronic volume control -#define VOLUP 0xD6 // Increment electronic control by 1 -#define VOLDOWN 0xD7 // Decrement electronic control by 1 -#define TMPGRD 0x82 // Temperature gradient set -#define EPCTIN 0xCD // Control EEPROM -#define EPCOUT 0xCC // Cancel EEPROM control -#define EPMWR 0xFC // Write into EEPROM -#define EPMRD 0xFD // Read from EEPROM -#define EPSRRD1 0x7C // Read register 1 -#define EPSRRD2 0x7D // Read register 2 -#define NOP 0x25 // NOP instruction - -#endif /* GE8_H */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld.c b/drivers/gdisp/Nokia6610GE8/gdisp_lld.c deleted file mode 100644 index beba41a9..00000000 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld.c +++ /dev/null @@ -1,483 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE8/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 GE8 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#include "GE8.h" - -/* This controller is only ever used with a 132 x 132 display */ -#if defined(GDISP_SCREEN_HEIGHT) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_HEIGHT -#endif -#if defined(GDISP_SCREEN_WIDTH) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_WIDTH -#endif -#define GDISP_SCREEN_HEIGHT 132 -#define GDISP_SCREEN_WIDTH 132 - -#define GDISP_INITIAL_CONTRAST 38 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_OLIMEX_SAM7_EX256) - #include "gdisp_lld_board_olimexsam7ex256.h" -#else - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#endif - -// Some macros just to make reading the code easier -#define delayms(ms) chThdSleepMilliseconds(ms) -#define write_data2(d1, d2) { write_data(d1); write_data(d2); } -#define write_data3(d1, d2, d3) { write_data(d1); write_data(d2); write_data(d3); } -#define write_cmd1(cmd, d1) { write_cmd(cmd); write_data(d1); } -#define write_cmd2(cmd, d1, d2) { write_cmd(cmd); write_data2(d1, d2); } -#define write_cmd3(cmd, d1, d2, d3) { write_cmd(cmd); write_data3(d1, d2, d3); } - -// A very common thing to do. -// An inline function has been used here incase the parameters have side effects with the internal calculations. -static __inline void setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { - write_cmd2(CASET, x, x+cx-1); // Column address set - write_cmd2(PASET, y, y+cy-1); // Page address set -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - init_board(); - - // Hardware reset - setpin_reset(TRUE); - delayms(20); - setpin_reset(FALSE); - delayms(20); - - // Get the bus for the following initialisation commands - acquire_bus(); - - write_cmd3(DISCTL, 0x00, 0x20, 0x00); // Display control - // P1: 0x00 = 2 divisions, switching period=8 (default) - // P2: 0x20 = nlines/4 - 1 = 132/4 - 1 = 32) - // P3: 0x00 = no inversely highlighted lines - write_cmd1(COMSCN, 0x01); // COM scan P1: 0x01 = Scan 1->80, 160<-81 - write_cmd(OSCON); // Internal oscilator ON - write_cmd(SLPOUT); // Sleep out - write_cmd1(PWRCTR, 0x0F); // Power control - reference voltage regulator on, circuit voltage follower on, BOOST ON - write_cmd3(DATCTL, 0x48, 0x00, 0x02); // Data control - // P1: 0x01 = page address inverted, column address normal, address scan in column direction - // P2: 0x00 = RGB sequence (default value) - // P3: 0x02 = Grayscale -> 16 (selects 12-bit color, type A) - write_cmd2(VOLCTR, GDISP_INITIAL_CONTRAST, 0x03); // Voltage control (contrast setting) - // P1 = Contrast - // P2 = 3 resistance ratio (only value that works) - delayms(100); // allow power supply to stabilize - write_cmd(DISON); // Turn on the display - - // Release the bus - release_bus(); - - /* Turn on the back-light */ - set_backlight(GDISP_INITIAL_BACKLIGHT); - - /* Initialise the GDISP structure to match */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; - GDISP.Contrast = GDISP_INITIAL_CONTRAST; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - acquire_bus(); - setviewport(x, y, 1, 1); - write_cmd3(RAMWR, 0, (color>>8) & 0x0F, color & 0xFF); - release_bus(); -} - -/* ---- Optional Routines ---- */ - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - unsigned i, tuples; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. - // This extra pixel is ignored by the controller. - - acquire_bus(); - setviewport(x, y, cx, cy); - write_cmd(RAMWR); - for(i=0; i < tuples; i++) - write_data3(((color >> 4) & 0xFF), (((color << 4) & 0xF0)|((color >> 8) & 0x0F)), (color & 0xFF)); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy, lg; - color_t c1, c2; - #if GDISP_PACKED_PIXELS - coord_t pos; - const uint8_t *p; - #endif - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - /* What are our end points */ - endx = srcx + cx; - endy = y + cy; - - acquire_bus(); - setviewport(x, y, cx, cy); - write_cmd(RAMWR); - - #if !GDISP_PACKED_PIXELS - // Although this controller uses packed pixels we support unpacked pixel - // formats in this blit by packing the data as we feed it to the controller. - lg = srccx - cx; - buffer += srcy * srccx + srcx; - x = srcx; - while (1) { - /* Get a pixel */ - c1 = *buffer++; - if (++x >= endx) { - if (++y >= endy) { - /* Odd pixel at end */ - write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); - break; - } - x = srcx; - buffer += lg; - } - /* Get the next pixel */ - c2 = *buffer++; - write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); - if (++x >= endx) { - if (++y >= endy) - break; - x = srcx; - buffer += lg; - } - } - - #else - - // Although this controller uses packed pixels, we may have to feed it into - // the controller with different packing to the source bitmap - #if !GDISP_PACKED_LINES - srccx = (srccx + 1) & ~1; - #endif - pos = srcy*srccx; - lg = (srccx - cx)/2*3; - p = ((const uint8_t *)buffer) + ((pos+srcx)/2 * 3); - - x = srcx; - while (1) { - /* Get a pixel */ - switch((pos+x)&1) { - case 0: c1 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; - case 1: c1 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; - } - if (++x >= endx) { - if (++y >= endy) { - /* Odd pixel at end */ - write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); - break; - } - x = srcx; - p += lg; - pos += srccx; - } - /* Get the next pixel */ - switch((pos+x)&1) { - case 0: c2 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; - case 1: c2 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; - } - write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); - if (++x >= endx) { - if (++y >= endy) - break; - x = srcx; - p += lg; - pos += srccx; - } - } - #endif - release_bus(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) - /** - * @brief Get the color of a particular pixel. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - /* NOT IMPLEMENTED */ - /* Some board hardware might support this in the future. - * The Olimex board doesn't. - */ - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) - /** - * @brief Scroll vertically a section of the screen. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - /* NOT IMPLEMENTED */ - /* The hardware seems capable of doing this. - * It is just really complex so we leave it out for now. - */ - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @details Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - /* The hardware is capable of supporting... - * GDISP_CONTROL_POWER - not implemented yet - * GDISP_CONTROL_ORIENTATION - not implemented yet - * GDISP_CONTROL_BACKLIGHT - supported (the OlimexSAM7EX256 board.h currently only implements off/on although PWM is supported by the hardware) - * GDISP_CONTROL_CONTRAST - supported - */ - switch(what) { -#if 0 - // NOT IMPLEMENTED YET - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - // Code here - break; - case powerOn: - // Code here - /* You may need this --- - * if (GDISP.Powermode != powerSleep) - * GDISP_LLD(init)(); - */ - break; - case powerSleep: - /* Code here */ - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; -#endif -#if 0 - // NOT IMPLEMENTED YET - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) - // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - // Code here - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - // Code here - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - // Code here - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - // Code here - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -#endif - case GDISP_CONTROL_BACKLIGHT: - if ((unsigned)value > 100) value = (void *)100; - set_backlight((unsigned)value); - GDISP.Backlight = (unsigned)value; - return; - case GDISP_CONTROL_CONTRAST: - if ((unsigned)value > 100) value = (void *)100; - acquire_bus(); - write_cmd2(VOLCTR, (unsigned)value, 0x03); - release_bus(); - GDISP.Contrast = (unsigned)value; - return; - } - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk b/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk deleted file mode 100644 index 3a1adec9..00000000 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8 diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h deleted file mode 100644 index fd330590..00000000 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 GE8 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for init_board for your board" -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for setpin_reset for your board" -} - -/** - * @brief Set the lcd back-light level. - * @note For now 0% turns the backlight off, anything else the backlight is on. - * While the hardware supports PWM backlight control, we are not using it - * yet. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for set_backlight for your board" -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for acquire_bus for your board" -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for release_bus for your board" -} - -/** - * @brief Send an 8 bit command to the lcd. - * - * @param[in] cmd The command to send - * - * @notapi - */ -static __inline void write_cmd(uint16_t cmd) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for write_cmd for your board" -} - -/** - * @brief Send an 8 bit data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for write_data for your board" -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { - /* Code here */ - #error "gdispNokia6610GE8: You must supply a definition for read_data for your board" -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h deleted file mode 100644 index f3b32b3a..00000000 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h - * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -// ****************************************************** -// Pointers to AT91SAM7X256 peripheral data structures -// ****************************************************** -volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; -volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; -volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; -volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; -volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void init_board(void) { - // ********************************************************************************************* - // InitSpi( ) - // - // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display - // - // I/O ports used: PA2 = LCD Reset (set to low to reset) - // PA12 = LCD chip select (set to low to select the LCD chip) - // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) - // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // PA18 = SPI0_SPCK Serial Clock (to LCD slave) - // PB20 = backlight control (normally PWM control, 1 = full on) - // - // *********************************************************************************************} - - /* This code should really use the ChibiOS driver for these functions */ - - // Pin for backlight - pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW - pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output - - // Reset pin - pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH - pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output - - // CS pin - this seems to be ignored - // pPIOA->PIO_SODR = 1<<12; // Set PA2 to HIGH - // pPIOA->PIO_OER = 1<<12; // Configure PA2 as output - - // Init SPI0 - // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) - // BIT12 = PA12 -> SPI0_NPCS0 chip select - // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) - // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) - pPIOA->PIO_PDR = (1<<12) | (1<<16) | (1<<17) | (1<<18); - pPIOA->PIO_ASR = (1<<12) | (1<<16) | (1<<17) | (1<<18); - pPIOA->PIO_BSR = 0; - - //enable the clock of SPI - pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; - - // Fixed mode - pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset - pSPI->SPI_CR = 0x01; //SPI Enable - - //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 - pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 - - //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz - pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - if (state) - palClearPad(IOPORT1, PIOA_LCD_RESET); - else - palSetPad(IOPORT1, PIOA_LCD_RESET); -} - -/** - * @brief Set the lcd back-light level. - * @note For now 0% turns the backlight off, anything else the backlight is on. - * While the hardware supports PWM backlight control, we are not using it - * yet. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - if (percent) - palSetPad(IOPORT2, PIOB_LCD_BL); - else - palClearPad(IOPORT2, PIOB_LCD_BL); -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Nothing to do for this board as the LCD is the only device on the SPI port */ -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - // Nothing to do for this board as the LCD is the only device on the SPI port -} - -/** - * @brief Send an 8 bit command to the lcd. - * - * @param[in] cmd The command to send - * - * @notapi - */ -static __inline void write_cmd(uint16_t cmd) { - // wait for the previous transfer to complete - while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); - // send the command - pSPI->SPI_TDR = cmd & 0xFF; -} - -/** - * @brief Send an 8 bit data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - // wait for the previous transfer to complete - while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); - // send the data - pSPI->SPI_TDR = data | 0x0100; -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * - * @notapi - */ -static __inline uint16_t read_data(void) { - #error "gdispNokia6610GE8: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" - return 0; -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h deleted file mode 100644 index 87bdb824..00000000 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 GE8 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "Nokia6610GE8" -#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE8 - -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 -/* This driver supports both packed and unpacked pixel formats and line formats. - * By default we leave these as FALSE. - */ -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/readme.txt b/drivers/gdisp/Nokia6610GE8/readme.txt deleted file mode 100644 index c8ad8faa..00000000 --- a/drivers/gdisp/Nokia6610GE8/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -This driver is for the Nokia6610 Epson (GE8) controller - -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - Olimex SAM7-EX256 - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk diff --git a/drivers/gdisp/S6D1121/gdisp_lld.c b/drivers/gdisp/S6D1121/gdisp_lld.c deleted file mode 100644 index e690456a..00000000 --- a/drivers/gdisp/S6D1121/gdisp_lld.c +++ /dev/null @@ -1,571 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/S6D1121/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the S6d1121 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#if defined(GDISP_SCREEN_HEIGHT) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GISP_SCREEN_HEIGHT -#endif -#if defined(GDISP_SCREEN_WIDTH) - #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." - #undef GDISP_SCREEN_WIDTH -#endif - -#define GDISP_SCREEN_HEIGHT 320 -#define GDISP_SCREEN_WIDTH 240 - -#define GDISP_INITIAL_CONTRAST 50 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_OLIMEX_STM32_E407) - #include "gdisp_lld_board_olimex_e407.h" -#else - #include "gdisp_lld_board.h" -#endif - -/* Some common routines and macros */ -#define write_reg(reg, data) { write_index(reg); write_data(data); } -#define stream_start() write_index(0x0022); -#define stream_stop() -#define delay(us) chThdSleepMicroseconds(us) -#define delayms(ms) chThdSleepMilliseconds(ms) - -static __inline void set_cursor(coord_t x, coord_t y) { - /* R20h - 8 bit - * R21h - 9 bit - */ - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - write_reg(0x0020, x & 0x00FF); - write_reg(0x0021, y & 0x01FF); - break; - case GDISP_ROTATE_90: - /* Note X has already been mirrored, so we do it directly */ - write_reg(0x0020, y & 0x00FF); - write_reg(0x0021, x & 0x01FF); - break; - case GDISP_ROTATE_180: - write_reg(0x0020, (GDISP_SCREEN_WIDTH - 1 - x) & 0x00FF); - write_reg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - y) & 0x01FF); - break; - case GDISP_ROTATE_270: - write_reg(0x0020, (GDISP_SCREEN_WIDTH - 1 - y) & 0x00FF); - write_reg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - x) & 0x01FF); - break; - } -} - -static __inline void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { - /* HSA / HEA are 8 bit - * VSA / VEA are 9 bit - * use masks 0x00FF and 0x01FF to enforce this - */ - - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - write_reg(0x46, (((x + cx - 1) << 8) & 0xFF00 ) | - (x & 0x00FF)); - - write_reg(0x48, y & 0x01FF); - write_reg(0x47, (y + cy - 1) & 0x01FF); - break; - case GDISP_ROTATE_90: - write_reg(0x46, (((y + cy - 1) << 8) & 0xFF00) | - (y & 0x00FF)); - - write_reg(0x48, x & 0x01FF); - write_reg(0x47, (x + cx - 1) & 0x01FF); - break; - case GDISP_ROTATE_180: - write_reg(0x46, (((GDISP_SCREEN_WIDTH - x - 1) & 0x00FF) << 8) | - ((GDISP_SCREEN_WIDTH - (x + cx)) & 0x00FF)); - write_reg(0x48, (GDISP_SCREEN_HEIGHT - (y + cy)) & 0x01FF); - write_reg(0x47, (GDISP_SCREEN_HEIGHT- y - 1) & 0x01FF); - break; - case GDISP_ROTATE_270: - write_reg(0x46, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | - ((GDISP_SCREEN_WIDTH - (y + cy)) & 0x00FF)); - write_reg(0x48, (GDISP_SCREEN_HEIGHT - (x + cx)) & 0x01FF); - write_reg(0x47, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } - - set_cursor(x, y); -} - -static __inline void reset_viewport(void) { - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - case GDISP_ROTATE_180: - set_viewport(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); - break; - case GDISP_ROTATE_90: - case GDISP_ROTATE_270: - set_viewport(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); - break; - } -} - -bool_t GDISP_LLD(init)(void) { - /* initialize the hardware */ - init_board(); - - /* Hardware reset */ - setpin_reset(TRUE); - delayms(20); - setpin_reset(TRUE); - delayms(20); - - /* Get the bus for the following initialisation commands */ - acquire_bus(); - - write_reg(0x11,0x2004); - write_reg(0x13,0xCC00); - write_reg(0x15,0x2600); - write_reg(0x14,0x252A); - write_reg(0x12,0x0033); - write_reg(0x13,0xCC04); - - delayms(1); - - write_reg(0x13,0xCC06); - - delayms(1); - - write_reg(0x13,0xCC4F); - - delayms(1); - - write_reg(0x13,0x674F); - write_reg(0x11,0x2003); - - delayms(1); - - // Gamma Setting - write_reg(0x30,0x2609); - write_reg(0x31,0x242C); - write_reg(0x32,0x1F23); - write_reg(0x33,0x2425); - write_reg(0x34,0x2226); - write_reg(0x35,0x2523); - write_reg(0x36,0x1C1A); - write_reg(0x37,0x131D); - write_reg(0x38,0x0B11); - write_reg(0x39,0x1210); - write_reg(0x3A,0x1315); - write_reg(0x3B,0x3619); - write_reg(0x3C,0x0D00); - write_reg(0x3D,0x000D); - - write_reg(0x16,0x0007); - write_reg(0x02,0x0013); - write_reg(0x03,0x0003); - write_reg(0x01,0x0127); - - delayms(1); - - write_reg(0x08,0x0303); - write_reg(0x0A,0x000B); - write_reg(0x0B,0x0003); - write_reg(0x0C,0x0000); - write_reg(0x41,0x0000); - write_reg(0x50,0x0000); - write_reg(0x60,0x0005); - write_reg(0x70,0x000B); - write_reg(0x71,0x0000); - write_reg(0x78,0x0000); - write_reg(0x7A,0x0000); - write_reg(0x79,0x0007); - write_reg(0x07,0x0051); - - delayms(1); - - write_reg(0x07,0x0053); - write_reg(0x79,0x0000); - - reset_viewport(); - set_backlight(GDISP_INITIAL_BACKLIGHT); - - /* Now initialise the GDISP structure */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - - acquire_bus(); - set_cursor(x, y); - write_reg(0x0022, color); - release_bus(); -} - -/* ---- Optional Routines ---- */ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - acquire_bus(); - set_cursor(0, 0); - stream_start(); - - for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) - write_data(color); - - stream_stop(); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - unsigned i, area; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - area = cx*cy; - acquire_bus(); - set_viewport(x, y, cx, cy); - stream_start(); - for(i = 0; i < area; i++) - write_data(color); - stream_stop(); - reset_viewport(); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy; - unsigned lg; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - acquire_bus(); - set_viewport(x, y, cx, cy); - stream_start(); - - endx = srcx + cx; - endy = y + cy; - lg = srccx - cx; - buffer += srcx + srcy * srccx; - for(; y < endy; y++, buffer += lg) - for(x=srcx; x < endx; x++) - write_data(*buffer++); - stream_stop(); - reset_viewport(); - release_bus(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - /* This routine is marked "DO NOT USE" in the original - * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL - * turned off for now. - */ - color_t color; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; - #endif - - aquire_bus(); - set_cursor(x, y); - stream_start(); - - color = lld_lcdReadData(); - color = lld_lcdReadData(); - - stream_stop(); - release_bus(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - /* This is marked as "TODO: Test this" in the original GLCD driver. - * For now we just leave the GDISP_HARDWARE_SCROLL off. - */ - static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - abslines = lines < 0 ? -lines : lines; - - acquire_bus(); - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - set_viewport(x, row0, cx, 1); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, cx); - lld_lcdReadStreamStop(); - - set_viewport(x, row1, cx, 1); - stream_start(); - write_data(buf, cx); - stream_stop(); - } - } - - /* fill the remaining gap */ - set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); - stream_start(); - gap = cx*abslines; - for(i = 0; i < gap; i++) write_data(bgcolor); - stream_stop(); - reset_viewport(); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @details Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - /* Code here */ - /* break; */ - case powerOn: - /* Code here */ - /* You may need this --- - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init(); - */ - /* break; */ - case powerSleep: - /* Code here */ - /* break; */ - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - write_reg(0x0001,0x0127); - write_reg(0x03, 0b0011); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - write_reg(0x0001,0x0027); - write_reg(0x0003, 0b1011); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - write_reg(0x0001,0x0127); - write_reg(0x0003, 0b0000); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - write_reg(0x0001,0x0027); - write_reg(0x0003, 0b1000); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/S6D1121/gdisp_lld.mk b/drivers/gdisp/S6D1121/gdisp_lld.mk deleted file mode 100644 index 38c23c43..00000000 --- a/drivers/gdisp/S6D1121/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/S6D1121 diff --git a/drivers/gdisp/S6D1121/gdisp_lld_board_example.h b/drivers/gdisp/S6D1121/gdisp_lld_board_example.h deleted file mode 100644 index 2396b155..00000000 --- a/drivers/gdisp/S6D1121/gdisp_lld_board_example.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/S6D1121/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -/** - * @brief Initialise the board for the display. - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ -#error "SSD1289: You must supply a definition for init_board for your board" -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - /* Code here */ -#error "SSD1289: You must supply a definition for setpin_reset for your board" -} - -/** - * @brief Set the lcd back-light level. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - /* Code here */ -#error "SSD1289: You must supply a definition for set_backlight for your board" -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { -#error "SSD1289: You must supply a definition for acquire_bus for your board" -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { -#error "SSD1289: You must supply a definition for release_bus for your board" -} - -/** - * @brief Send data to the index register. - * - * @param[in] index The index register to set - * - * @notapi - */ -static __inline void write_index(uint16_t index) { - /* Code here */ -#error "SSD1289: You must supply a definition for write_index for your board" -} - -/** - * @brief Send data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - /* Code here */ -#error "SSD1289: You must supply a definition for write_data for your board" -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { - /* Code here */ -#error "SSD1289: You must supply a definition for read_data for your board" -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h b/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h deleted file mode 100644 index 34224425..00000000 --- a/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h - * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ -#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - -static __inline void init_board(void) { - int FSMC_Bank = 0; - - /* STM32F4 FSMC init */ - rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); - - /* set pins to FSMC mode */ - IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | - (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; - - IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | - (1 << 13) | (1 << 14) | (1 << 15), 0}; - - palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); - palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); - - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); - - /* Bank1 NOR/SRAM control register configuration */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; -} - -static __inline void setpin_reset(bool_t state) { - (void)state; - - /* Nothing to do here */ -} - -static __inline void set_backlight(uint8_t percent) { - (void)percent; - - /* Nothing to do here */ -} - -static __inline void acquire_bus(void) { - /* Nothing to do here */ -} - -static __inline void release_bus(void) { - /* Nothing to do here */ -} - -static __inline void write_index(uint16_t index) { - GDISP_REG = index; -} - -static __inline void write_data(uint16_t data) { - GDISP_RAM = data; -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -static __inline uint16_t read_data(void) { - return GDISP_RAM; -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/gdisp/S6D1121/gdisp_lld_config.h b/drivers/gdisp/S6D1121/gdisp_lld_config.h deleted file mode 100644 index c662d0e7..00000000 --- a/drivers/gdisp/S6D1121/gdisp_lld_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/S6D1121/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the S6D1121 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "S6D1121" -#define GDISP_LLD(x) gdisp_lld_##x##_S6D1121 - -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD FALSE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/S6D1121/readme.txt b/drivers/gdisp/S6D1121/readme.txt deleted file mode 100644 index b76b565f..00000000 --- a/drivers/gdisp/S6D1121/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld.mk - diff --git a/drivers/gdisp/SSD1289/gdisp_lld.c b/drivers/gdisp/SSD1289/gdisp_lld.c deleted file mode 100644 index d8d185cd..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1289/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the SSD1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 320 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 240 -#endif - -#define GDISP_INITIAL_CONTRAST 50 -#define GDISP_INITIAL_BACKLIGHT 100 - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#elif defined(BOARD_FIREBULL_STM32_F103) - #include "gdisp_lld_board_firebullstm32f103.h" -#else - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#endif - -// Some common routines and macros -#define write_reg(reg, data) { write_index(reg); write_data(data); } -#define stream_start() write_index(0x0022); -#define stream_stop() -#define delay(us) chThdSleepMicroseconds(us) -#define delayms(ms) chThdSleepMilliseconds(ms) - -static __inline void set_cursor(coord_t x, coord_t y) { - /* Reg 0x004E is an 8 bit value - * Reg 0x004F is 9 bit - * Use a bit mask to make sure they are not set too high - */ - switch(GDISP.Orientation) { - case GDISP_ROTATE_180: - write_reg(0x004e, (GDISP_SCREEN_WIDTH-1-x) & 0x00FF); - write_reg(0x004f, (GDISP_SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case GDISP_ROTATE_0: - write_reg(0x004e, x & 0x00FF); - write_reg(0x004f, y & 0x01FF); - break; - case GDISP_ROTATE_270: - write_reg(0x004e, y & 0x00FF); - write_reg(0x004f, x & 0x01FF); - break; - case GDISP_ROTATE_90: - write_reg(0x004e, (GDISP_SCREEN_WIDTH - y - 1) & 0x00FF); - write_reg(0x004f, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } -} - -static void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { - - set_cursor(x, y); - - /* Reg 0x44 - Horizontal RAM address position - * Upper Byte - HEA - * Lower Byte - HSA - * 0 <= HSA <= HEA <= 0xEF - * Reg 0x45,0x46 - Vertical RAM address position - * Lower 9 bits gives 0-511 range in each value - * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F - */ - - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); - write_reg(0x45, y & 0x01FF); - write_reg(0x46, (y+cy-1) & 0x01FF); - break; - case GDISP_ROTATE_270: - write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (y & 0x00FF)); - write_reg(0x45, x & 0x01FF); - write_reg(0x46, (x+cx-1) & 0x01FF); - break; - case GDISP_ROTATE_180: - write_reg(0x44, (((GDISP_SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (x+cx)) & 0x00FF)); - write_reg(0x45, (GDISP_SCREEN_HEIGHT-(y+cy)) & 0x01FF); - write_reg(0x46, (GDISP_SCREEN_HEIGHT-y-1) & 0x01FF); - break; - case GDISP_ROTATE_90: - write_reg(0x44, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (y+cy)) & 0x00FF)); - write_reg(0x45, (GDISP_SCREEN_HEIGHT - (x+cx)) & 0x01FF); - write_reg(0x46, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } - - set_cursor(x, y); -} - -static __inline void reset_viewport(void) { - set_viewport(0, 0, GDISP.Width, GDISP.Height); -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - init_board(); - - // Hardware reset - setpin_reset(TRUE); - delayms(20); - setpin_reset(FALSE); - delayms(20); - - // Get the bus for the following initialisation commands - acquire_bus(); - - write_reg(0x0000,0x0001); delay(5); - write_reg(0x0003,0xA8A4); delay(5); - write_reg(0x000C,0x0000); delay(5); - write_reg(0x000D,0x080C); delay(5); - write_reg(0x000E,0x2B00); delay(5); - write_reg(0x001E,0x00B0); delay(5); - write_reg(0x0001,0x2B3F); delay(5); - write_reg(0x0002,0x0600); delay(5); - write_reg(0x0010,0x0000); delay(5); - write_reg(0x0011,0x6070); delay(5); - write_reg(0x0005,0x0000); delay(5); - write_reg(0x0006,0x0000); delay(5); - write_reg(0x0016,0xEF1C); delay(5); - write_reg(0x0017,0x0003); delay(5); - write_reg(0x0007,0x0133); delay(5); - write_reg(0x000B,0x0000); delay(5); - write_reg(0x000F,0x0000); delay(5); - write_reg(0x0041,0x0000); delay(5); - write_reg(0x0042,0x0000); delay(5); - write_reg(0x0048,0x0000); delay(5); - write_reg(0x0049,0x013F); delay(5); - write_reg(0x004A,0x0000); delay(5); - write_reg(0x004B,0x0000); delay(5); - write_reg(0x0044,0xEF00); delay(5); - write_reg(0x0045,0x0000); delay(5); - write_reg(0x0046,0x013F); delay(5); - write_reg(0x0030,0x0707); delay(5); - write_reg(0x0031,0x0204); delay(5); - write_reg(0x0032,0x0204); delay(5); - write_reg(0x0033,0x0502); delay(5); - write_reg(0x0034,0x0507); delay(5); - write_reg(0x0035,0x0204); delay(5); - write_reg(0x0036,0x0204); delay(5); - write_reg(0x0037,0x0502); delay(5); - write_reg(0x003A,0x0302); delay(5); - write_reg(0x003B,0x0302); delay(5); - write_reg(0x0023,0x0000); delay(5); - write_reg(0x0024,0x0000); delay(5); - write_reg(0x0025,0x8000); delay(5); - write_reg(0x004f,0x0000); delay(5); - write_reg(0x004e,0x0000); delay(5); - - // Release the bus - release_bus(); - - /* Turn on the back-light */ - set_backlight(GDISP_INITIAL_BACKLIGHT); - - /* Initialise the GDISP structure */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; - GDISP.Contrast = GDISP_INITIAL_CONTRAST; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - - acquire_bus(); - set_cursor(x, y); - write_reg(0x0022, color); - release_bus(); -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If gfillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - acquire_bus(); - reset_viewport(); - set_cursor(0, 0); - stream_start(); - for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) - write_data(color); - stream_stop(); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - unsigned i, area; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - area = cx*cy; - - acquire_bus(); - set_viewport(x, y, cx, cy); - stream_start(); - for(i = 0; i < area; i++) - write_data(color); - stream_stop(); - release_bus(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - coord_t endx, endy; - unsigned lg; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - acquire_bus(); - set_viewport(x, y, cx, cy); - stream_start(); - - endx = srcx + cx; - endy = y + cy; - lg = srccx - cx; - buffer += srcx + srcy * srccx; - for(; y < endy; y++, buffer += lg) - for(x=srcx; x < endx; x++) - write_data(*buffer++); - stream_stop(); - release_bus(); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The pixel to be read - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - color_t color; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; - #endif - - acquire_bus(); - set_cursor(x, y); - stream_start(); - color = read_data(); // dummy read - color = read_data(); - stream_stop(); - release_bus(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines, j; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - abslines = lines < 0 ? -lines : lines; - - acquire_bus(); - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - set_viewport(x, row0, cx, 1); - stream_start(); - j = read_data(); // dummy read - for (j = 0; j < cx; j++) - buf[j] = read_data(); - stream_stop(); - - set_viewport(x, row1, cx, 1); - stream_start(); - for (j = 0; j < cx; j++) - write_data(buf[j]); - stream_stop(); - } - } - - /* fill the remaining gap */ - set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); - stream_start(); - gap = cx*abslines; - for(i = 0; i < gap; i++) write_data(bgcolor); - stream_stop(); - release_bus(); - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @details Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - acquire_bus(); - write_reg(0x0010, 0x0000); // leave sleep mode - write_reg(0x0007, 0x0000); // halt operation - write_reg(0x0000, 0x0000); // turn off oszillator - write_reg(0x0010, 0x0001); // enter sleepmode - release_bus(); - break; - case powerOn: - acquire_bus(); - write_reg(0x0010, 0x0000); // leave sleep mode - release_bus(); - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init)(); - break; - case powerSleep: - acquire_bus(); - write_reg(0x0010, 0x0001); // enter sleep mode - release_bus(); - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - acquire_bus(); - write_reg(0x0001, 0x2B3F); - /* ID = 11 AM = 0 */ - write_reg(0x0011, 0x6070); - release_bus(); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - acquire_bus(); - write_reg(0x0001, 0x293F); - /* ID = 11 AM = 1 */ - write_reg(0x0011, 0x6078); - release_bus(); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - acquire_bus(); - write_reg(0x0001, 0x2B3F); - /* ID = 01 AM = 0 */ - write_reg(0x0011, 0x6040); - release_bus(); - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - acquire_bus(); - write_reg(0x0001, 0x293F); - /* ID = 01 AM = 1 */ - write_reg(0x0011, 0x6048); - release_bus(); - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld.mk b/drivers/gdisp/SSD1289/gdisp_lld.mk deleted file mode 100644 index e340a7dc..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/SSD1289 diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example.h deleted file mode 100644 index 00c4b869..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld_board_example.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1289/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -/** - * @brief Initialise the board for the display. - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ -#error "SSD1289: You must supply a definition for init_board for your board" -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - /* Code here */ -#error "SSD1289: You must supply a definition for setpin_reset for your board" -} - -/** - * @brief Set the lcd back-light level. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - /* Code here */ -#error "SSD1289: You must supply a definition for set_backlight for your board" -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { -#error "SSD1289: You must supply a definition for acquire_bus for your board" -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { -#error "SSD1289: You must supply a definition for release_bus for your board" -} - -/** - * @brief Send data to the index register. - * - * @param[in] index The index register to set - * - * @notapi - */ -static __inline void write_index(uint16_t index) { - /* Code here */ -#error "SSD1289: You must supply a definition for write_index for your board" -} - -/** - * @brief Send data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - /* Code here */ -#error "SSD1289: You must supply a definition for write_data for your board" -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { - /* Code here */ -#error "SSD1289: You must supply a definition for read_data for your board" -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h deleted file mode 100644 index 76a5c04c..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h - * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -#define GDISP_REG ((volatile uint16_t *) 0x60000000)[0] /* RS = 0 */ -#define GDISP_RAM ((volatile uint16_t *) 0x60020000)[0] /* RS = 1 */ - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the io port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void init_board(void) { - const unsigned char FSMC_Bank; - - #if defined(STM32F1XX) || defined(STM32F3XX) - /* FSMC setup for F1/F3 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - #error "DMA not implemented for F1/F3 Devices" - #endif - #elif defined(STM32F4XX) || defined(STM32F2XX) - /* STM32F2-F4 FSMC init */ - rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); - - #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt(); - dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM); - dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); - #endif - #else - #error "FSMC not implemented for this device" - #endif - - /* set pins to FSMC mode */ - IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | - (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; - - IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | - (1 << 13) | (1 << 14) | (1 << 15), 0}; - - palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); - palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); - - FSMC_Bank = 0; - - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \ - | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \ - | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ; - - /* Bank1 NOR/SRAM control register configuration - * This is actually not needed as already set by default after reset */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - (void) state; - /* Nothing to do here */ -} - -/** - * @brief Set the lcd back-light level. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - (void) percent; - /* Nothing to do here */ -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Nothing to do here */ -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - /* Nothing to do here */ -} - -/** - * @brief Send data to the index register. - * - * @param[in] index The index register to set - * - * @notapi - */ -static __inline void write_index(uint16_t index) { GDISP_REG = index; } - -/** - * @brief Send data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { GDISP_RAM = data; } - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { return GDISP_RAM; } -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h b/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h deleted file mode 100644 index 9cff5a19..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h - * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -#define SET_CS palSetPad(GPIOD, 12); -#define CLR_CS palClearPad(GPIOD, 12); -#define SET_RS palSetPad(GPIOD, 13); -#define CLR_RS palClearPad(GPIOD, 13); -#define SET_WR palSetPad(GPIOD, 14); -#define CLR_WR palClearPad(GPIOD, 14); -#define SET_RD palSetPad(GPIOD, 15); -#define CLR_RD palClearPad(GPIOD, 15); - -/** - * @brief Initialise the board for the display. - * @notes This board definition uses GPIO and assumes exclusive access to these GPIO pins - * - * @notapi - */ -static __inline void init_board(void) { - palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, 12, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, 13, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, 14, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOD, 15, PAL_MODE_OUTPUT_PUSHPULL); - - // Configure the pins to a well know state - SET_RS; - SET_RD; - SET_WR; - CLR_CS; -} - - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void setpin_reset(bool_t state) { - (void) state; - /* Nothing to do here - reset pin tied to Vcc */ -} - -/** - * @brief Set the lcd back-light level. - * - * @param[in] percent 0 to 100% - * - * @notapi - */ -static __inline void set_backlight(uint8_t percent) { - (void) percent; - /* Nothing to do here - Backlight always on */ -} - -/** - * @brief Take exclusive control of the bus - * - * @notapi - */ -static __inline void acquire_bus(void) { - /* Nothing to do here since LCD is the only device on that bus */ -} - -/** - * @brief Release exclusive control of the bus - * - * @notapi - */ -static __inline void release_bus(void) { - /* Nothing to do here since LCD is the only device on that bus */ -} - -/** - * @brief Send data to the index register. - * - * @param[in] index The index register to set - * - * @notapi - */ -static __inline void write_index(uint16_t index) { - palWritePort(GPIOE, index); - CLR_RS; CLR_WR; SET_WR; SET_RS; -} - -/** - * @brief Send data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void write_data(uint16_t data) { - palWritePort(GPIOE, data); - CLR_WR; SET_WR; -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t read_data(void) { - uint16_t value; - - // change pin mode to digital input - palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_INPUT); - - CLR_RD; - value = palReadPort(GPIOE); - value = palReadPort(GPIOE); - SET_RD; - - // change pin mode back to digital output - palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); - - return value; -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_config.h b/drivers/gdisp/SSD1289/gdisp_lld_config.h deleted file mode 100644 index dafbc90f..00000000 --- a/drivers/gdisp/SSD1289/gdisp_lld_config.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1289/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the SSD1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "SSD1289" -#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289 - -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/drivers/gdisp/SSD1289/readme.txt b/drivers/gdisp/SSD1289/readme.txt deleted file mode 100644 index b160abbe..00000000 --- a/drivers/gdisp/SSD1289/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - - c) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h or gdisp_lld_board_fsmc.h file as a basis. - Currently known boards are: - BOARD_FIREBULL_STM32_F103 - GPIO interface: requires GDISP_CMD_PORT and GDISP_DATA_PORT to be defined - - d) The following are optional - define them if you are not using the defaults below: - #define GDISP_SCREEN_WIDTH 320 - #define GDISP_SCREEN_HEIGHT 240 - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.mk diff --git a/drivers/gdisp/SSD1963/gdisp_lld.c b/drivers/gdisp/SSD1963/gdisp_lld.c deleted file mode 100644 index 41cbd969..00000000 --- a/drivers/gdisp/SSD1963/gdisp_lld.c +++ /dev/null @@ -1,613 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1963/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 320 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 240 -#endif - -/* All the board specific code should go in these include file so the driver - * can be ported to another board just by creating a suitable file. - */ -//#if defined(BOARD_YOURBOARDNAME) -// #include "gdisp_lld_board_yourboardname.h" -//#else -// /* Include the user supplied board definitions */ -// #include "gdisp_lld_board.h" -//#endif - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -#include "ssd1963.h" - - -#if defined(GDISP_USE_FSMC) -__inline void GDISP_LLD(writeindex)(uint8_t cmd) { - GDISP_REG = cmd; -} - -__inline void GDISP_LLD(writereg)(uint16_t lcdReg,uint16_t lcdRegValue) { - GDISP_REG = lcdReg; - GDISP_RAM = lcdRegValue; -} - -__inline void GDISP_LLD(writedata)(uint16_t data) { - GDISP_RAM = data; -} - -__inline uint16_t GDISP_LLD(readdata)(void) { - return (GDISP_RAM); -} - -__inline uint8_t GDISP_LLD(readreg)(uint8_t lcdReg) { - GDISP_REG = lcdReg; - return (GDISP_RAM); -} - -__inline void GDISP_LLD(writestreamstart)(void) { - GDISP_LLD(writeindex)(SSD1963_WRITE_MEMORY_START); -} - -__inline void GDISP_LLD(readstreamstart)(void) { - GDISP_LLD(writeindex)(SSD1963_READ_MEMORY_START); -} - -__inline void GDISP_LLD(writestream)(uint16_t *buffer, uint16_t size) { - uint16_t i; - for(i = 0; i < size; i++) - GDISP_RAM = buffer[i]; -} - -__inline void GDISP_LLD(readstream)(uint16_t *buffer, size_t size) { - uint16_t i; - - for(i = 0; i < size; i++) { - buffer[i] = GDISP_RAM; - } -} - -#elif defined(GDISP_USE_GPIO) - -__inline void GDISP_LLD(writeindex)(uint8_t cmd) { - Set_CS; Set_RS; Set_WR; Clr_RD; - palWritePort(GDISP_DATA_PORT, cmd); - Clr_CS; -} - -__inline void GDISP_LLD(writereg)(uint16_t lcdReg,uint16_t lcdRegValue) { - Set_CS; Set_RS; Set_WR; Clr_RD; - palWritePort(GDISP_DATA_PORT, lcdReg); - Clr_RS; - palWritePort(GDISP_DATA_PORT, lcdRegValue); - Clr_CS; -} -__inline void GDISP_LLD(writedata)(uint16_t data) { - Set_CS; Clr_RS; Set_WR; Clr_RD; - palWritePort(GDISP_DATA_PORT, data); - Clr_CS; -} - -__inline uint16_t GDISP_LLD(readdata)(void) { - Set_CS; Clr_RS; Clr_WR; Set_RD; - uint16_t data = palReadPort(GDISP_DATA_PORT); - Clr_CS; - return data; -} - -__inline uint8_t GDISP_LLD(readreg)(uint8_t lcdReg) { - Set_CS; Set_RS; Clr_WR; Set_RD; - palWritePort(GDISP_DATA_PORT, lcdReg); - Clr_RS; - uint16_t data = palReadPort(GDISP_DATA_PORT); - Clr_CS; - return data; -} - -__inline void GDISP_LLD(writestreamstart)(void) { - GDISP_LLD(writeindex)(SSD1963_WRITE_MEMORY_START); -} - -__inline void GDISP_LLD(readstreamstart)(void) { - GDISP_LLD(writeindex)(SSD1963_READ_MEMORY_START); -} - -__inline void GDISP_LLD(writestream)(uint16_t *buffer, uint16_t size) { - uint16_t i; - Set_CS; Clr_RS; Set_WR; Clr_RD; - for(i = 0; i < size; i++) { - Set_WR; - palWritePort(GDISP_DATA_PORT, buffer[i]); - Clr_WR; - } - Clr_CS; -} - -__inline void GDISP_LLD(readstream)(uint16_t *buffer, size_t size) { - uint16_t i; - Set_CS; Clr_RS; Clr_WR; Set_RD; - for(i = 0; i < size; i++) { - Set_RD; - buffer[i] = palReadPort(GDISP_DATA_PORT); - Clr_RD; - } -} -#endif - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialisation. - * @return TRUE if successful, FALSE on error. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise the display */ - -#if defined(GDISP_USE_FSMC) - - #if defined(STM32F1XX) || defined(STM32F3XX) - /* FSMC setup for F1/F3 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - #error "DMA not implemented for F1/F3 Devices" - #endif - #elif defined(STM32F4XX) || defined(STM32F2XX) - /* STM32F2-F4 FSMC init */ - rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); - - #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt(); - dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM); - dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); - #endif - #else - #error "FSMC not implemented for this device" - #endif - - /* set pins to FSMC mode */ - IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | - (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; - - IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | - (1 << 13) | (1 << 14) | (1 << 15), 0}; - - palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); - palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); - - const unsigned char FSMC_Bank = 0; - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \ - | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \ - | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ; - - /* Bank1 NOR/SRAM control register configuration - * This is actually not needed as already set by default after reset */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; - -#elif defined(GDISP_USE_GPIO) - IOBus busCMD = {GDISP_CMD_PORT, (1 << GDISP_CS) | (1 << GDISP_RS) | (1 << GDISP_WR) | (1 << GDISP_RD), 0}; - IOBus busDATA = {GDISP_CMD_PORT, 0xFFFFF, 0}; - palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL); - palSetBusMode(&busDATA, PAL_MODE_OUTPUT_PUSHPULL); - -#else - #error "Please define GDISP_USE_FSMC or GDISP_USE_GPIO" -#endif - GDISP_LLD(writeindex)(SSD1963_SOFT_RESET); - chThdSleepMicroseconds(100); - - /* Driver PLL config */ - GDISP_LLD(writeindex)(SSD1963_SET_PLL_MN); - GDISP_LLD(writedata)(35); // PLLclk = REFclk (10Mhz) * 36 (360Mhz) - GDISP_LLD(writedata)(2); // SYSclk = PLLclk / 3 (120MHz) - GDISP_LLD(writedata)(4); // Apply calculation bit, else it is ignored - - GDISP_LLD(writeindex)(SSD1963_SET_PLL); // Enable PLL - GDISP_LLD(writedata)(0x01); - chThdSleepMicroseconds(200); - - GDISP_LLD(writeindex)(SSD1963_SET_PLL); // Use PLL - GDISP_LLD(writedata)(0x03); - chThdSleepMicroseconds(200); - - GDISP_LLD(writeindex)(SSD1963_SOFT_RESET); - chThdSleepMicroseconds(100); - - /* Screen size */ - GDISP_LLD(writeindex)(SSD1963_SET_GDISP_MODE); -// GDISP_LLD(writedata)(0x0000); - GDISP_LLD(writedata)(0b00011000); //Enabled dithering - GDISP_LLD(writedata)(0x0000); - GDISP_LLD(writedata)(mHIGH((GDISP_SCREEN_WIDTH+1))); - GDISP_LLD(writedata)((GDISP_SCREEN_WIDTH+1)); - GDISP_LLD(writedata)(mHIGH((GDISP_SCREEN_HEIGHT+1))); - GDISP_LLD(writedata)((GDISP_SCREEN_HEIGHT+1)); - GDISP_LLD(writedata)(0x0000); - - GDISP_LLD(writeindex)(SSD1963_SET_PIXEL_DATA_INTERFACE); - GDISP_LLD(writedata)(SSD1963_PDI_16BIT565); - - /* LCD Clock specs */ - GDISP_LLD(writeindex)(SSD1963_SET_LSHIFT_FREQ); - GDISP_LLD(writedata)((GDISP_FPR >> 16) & 0xFF); - GDISP_LLD(writedata)((GDISP_FPR >> 8) & 0xFF); - GDISP_LLD(writedata)(GDISP_FPR & 0xFF); - - GDISP_LLD(writeindex)(SSD1963_SET_HORI_PERIOD); - GDISP_LLD(writedata)(mHIGH(SCREEN_HSYNC_PERIOD)); - GDISP_LLD(writedata)(mLOW(SCREEN_HSYNC_PERIOD)); - GDISP_LLD(writedata)(mHIGH((SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH))); - GDISP_LLD(writedata)(mLOW((SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH))); - GDISP_LLD(writedata)(SCREEN_HSYNC_PULSE); - GDISP_LLD(writedata)(0x00); - GDISP_LLD(writedata)(0x00); - GDISP_LLD(writedata)(0x00); - - GDISP_LLD(writeindex)(SSD1963_SET_VERT_PERIOD); - GDISP_LLD(writedata)(mHIGH(SCREEN_VSYNC_PERIOD)); - GDISP_LLD(writedata)(mLOW(SCREEN_VSYNC_PERIOD)); - GDISP_LLD(writedata)(mHIGH((SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH))); - GDISP_LLD(writedata)(mLOW((SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH))); - GDISP_LLD(writedata)(SCREEN_VSYNC_PULSE); - GDISP_LLD(writedata)(0x00); - GDISP_LLD(writedata)(0x00); - - /* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel */ - GDISP_LLD(writeindex)(SSD1963_SET_TEAR_ON); - GDISP_LLD(writedata)(0x0000); - - /* Turn on */ - GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_ON); - #if defined(GDISP_USE_FSMC) - /* FSMC delay reduced as the controller now runs at full speed */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_0 | FSMC_BTR1_DATAST_2 | FSMC_BTR1_BUSTURN_0 ; - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; - #endif - - /* Initialise the GDISP structure to match */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - - return TRUE; -} - -void GDISP_LLD(setwindow)(coord_t x0, coord_t y0, coord_t x1, coord_t y1) { - /* We don't need to validate here as the LLD routines will validate first. - * - * #if GDISP_NEED_VALIDATION - * if (x0 >= GDISP.Width || y0 >= GDISP.Height || x0 < 0 || y0 < 0) return; - * else if (x1 >= GDISP.Width || y1 >= GDISP.Height || y1 < 0 || y2 < 0) return; - * #endif - */ - GDISP_LLD(writeindex)(SSD1963_SET_PAGE_ADDRESS); - GDISP_LLD(writedata)((y0 >> 8) & 0xFF); - GDISP_LLD(writedata)((y0 >> 0) & 0xFF); - GDISP_LLD(writedata)((y1 >> 8) & 0xFF); - GDISP_LLD(writedata)((y1 >> 0) & 0xFF); - GDISP_LLD(writeindex)(SSD1963_SET_COLUMN_ADDRESS); - GDISP_LLD(writedata)((x0 >> 8) & 0xFF); - GDISP_LLD(writedata)((x0 >> 0) & 0xFF); - GDISP_LLD(writedata)((x1 >> 8) & 0xFF); - GDISP_LLD(writedata)((x1 >> 0) & 0xFF); -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - - GDISP_LLD(setwindow)(x, y, x, y); - GDISP_LLD(writestreamstart)(); - GDISP_LLD(writedata)(color); -} - -/* ---- Optional Routines ---- */ - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - uint32_t area; - area = cx*cy; - - GDISP_LLD(setwindow)(x, y, x+cx-1, y+cy-1); - GDISP_LLD(writestreamstart)(); - - #if defined(GDISP_USE_FSMC) && defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - uint8_t i; - dmaStreamSetPeripheral(GDISP_DMA_STREAM, &color); - dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); - for (i = area/65535; i; i--) { - dmaStreamSetTransactionSize(GDISP_DMA_STREAM, 65535); - dmaStreamEnable(GDISP_DMA_STREAM); - dmaWaitCompletion(GDISP_DMA_STREAM); - } - dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area%65535); - dmaStreamEnable(GDISP_DMA_STREAM); - dmaWaitCompletion(GDISP_DMA_STREAM); - #else - uint32_t index; - for(index = 0; index < area; index++) - GDISP_LLD(writedata)(color); - #endif //#ifdef GDISP_USE_DMA -} -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - GDISP_LLD(setwindow)(x, y, x+cx-1, y+cy-1); - GDISP_LLD(writestreamstart)(); - - buffer += srcx + srcy * srccx; - - #if defined(GDISP_USE_FSMC) && defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) - uint32_t area = cx*cy; - uint8_t i; - dmaStreamSetPeripheral(GDISP_DMA_STREAM, buffer); - dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PINC | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); - for (i = area/65535; i; i--) { - dmaStreamSetTransactionSize(GDISP_DMA_STREAM, 65535); - dmaStreamEnable(GDISP_DMA_STREAM); - dmaWaitCompletion(GDISP_DMA_STREAM); - } - dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area%65535); - dmaStreamEnable(GDISP_DMA_STREAM); - dmaWaitCompletion(GDISP_DMA_STREAM); - #else - coord_t endx, endy; - unsigned lg; - endx = srcx + cx; - endy = y + cy; - lg = srccx - cx; - for(; y < endy; y++, buffer += lg) - for(x=srcx; x < endx; x++) - GDISP_LLD(writedata)(*buffer++); - #endif //#ifdef GDISP_USE_DMA - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - /* NOT IMPLEMENTED YET */ - - /* - uint16_t size = x1 - x0 ; - - lld_lcdWriteIndex(SSD1963_SET_SCROLL_AREA); - lld_lcdWriteData((x0 >> 8) & 0xFF); - lld_lcdWriteData((x0 >> 0) & 0xFF); - lld_lcdWriteData((size >> 8) & 0xFF); - lld_lcdWriteData((size >> 0) & 0xFF); - lld_lcdWriteData(((lcd_height-x1) >> 8) & 0xFF); - lld_lcdWriteData(((lcd_height-x1) >> 0) & 0xFF); - - lld_lcdWriteIndex(SSD1963_SET_SCROLL_START); - lld_lcdWriteData((lines >> 8) & 0xFF); - lld_lcdWriteData((lines >> 0) & 0xFF); - */ - } - -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @details Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - /* NOT IMPLEMENTED YET */ - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - GDISP_LLD(writeindex)(SSD1963_EXIT_SLEEP_MODE); // leave sleep mode - chThdSleepMicroseconds(5000); - GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_OFF); - GDISP_LLD(writeindex)(SSD1963_SET_DEEP_SLEEP); // enter deep sleep mode - break; - case powerOn: - GDISP_LLD(readreg)(0x0000); chThdSleepMicroseconds(5000); // 2x Dummy reads to wake up from deep sleep - GDISP_LLD(readreg)(0x0000); chThdSleepMicroseconds(5000); - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init)(); - GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_ON); - - break; - case powerSleep: - GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_OFF); - GDISP_LLD(writeindex)(SSD1963_ENTER_SLEEP_MODE); // enter sleep mode - chThdSleepMicroseconds(5000); - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - /* Code here */ - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - /* Code here */ - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - /* Code here */ - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - /* Code here */ - GDISP.Height = GDISP_SCREEN_WIDTH; - GDISP.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ diff --git a/drivers/gdisp/SSD1963/gdisp_lld.mk b/drivers/gdisp/SSD1963/gdisp_lld.mk deleted file mode 100644 index 7b967502..00000000 --- a/drivers/gdisp/SSD1963/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1963/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/SSD1963 diff --git a/drivers/gdisp/SSD1963/gdisp_lld_config.h b/drivers/gdisp/SSD1963/gdisp_lld_config.h deleted file mode 100644 index 34b4f72b..00000000 --- a/drivers/gdisp/SSD1963/gdisp_lld_config.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - ChibiOS/GFX Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/SSD1963/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "SSD1963" -#define GDISP_LLD(x) gdisp_lld_##x##_SSD1963 - -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -/* Maybe someday soon */ -#define GDISP_HARDWARE_SCROLL FALSE -#define GDISP_HARDWARE_CONTROL FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/SSD1963/gdisp_lld_panel.h b/drivers/gdisp/SSD1963/gdisp_lld_panel.h deleted file mode 100644 index b4ed5c80..00000000 --- a/drivers/gdisp/SSD1963/gdisp_lld_panel.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - ChibiOS/GFX Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file SSD1963/gdisp_lld_panel.h - * @brief TFT LCD panel properties. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_PANEL_H -#define _GDISP_LLD_PANEL_H - -/* LCD panel specs */ -#define GDISP_SCREEN_WIDTH 480 -#define GDISP_SCREEN_HEIGHT 272 - -#define SCREEN_FPS 60ULL - -#define SCREEN_HSYNC_BACK_PORCH 2LL -#define SCREEN_HSYNC_FRONT_PORCH 2ULL -#define SCREEN_HSYNC_PULSE 41ULL - -#define SCREEN_VSYNC_BACK_PORCH 2ULL -#define SCREEN_VSYNC_FRONT_PORCH 2ULL -#define SCREEN_VSYNC_PULSE 10ULL - -#define SCREEN_HSYNC_PERIOD (SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH + GDISP_SCREEN_WIDTH + SCREEN_HSYNC_FRONT_PORCH) -#define SCREEN_VSYNC_PERIOD (SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH + GDISP_SCREEN_HEIGHT + SCREEN_VSYNC_FRONT_PORCH) - -#define SCREEN_PCLK (SCREEN_HSYNC_PERIOD * SCREEN_VSYNC_PERIOD * SCREEN_FPS) -#define GDISP_FPR ((SCREEN_PCLK * 1048576)/100000000) - -#endif -/** @} */ diff --git a/drivers/gdisp/SSD1963/readme.txt b/drivers/gdisp/SSD1963/readme.txt deleted file mode 100644 index 567faf58..00000000 --- a/drivers/gdisp/SSD1963/readme.txt +++ /dev/null @@ -1,38 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: #define GDISP_NEED_MULTITHREAD TRUE - c) One (only) of: - #define GDISP_USE_GPIO - #define GDISP_USE_FSMC - d) If you want to use DMA (only works with FSMC): - #define GDISP_USE_DMA - #define GDISP_DMA_STREAM STM32_DMA2_STREAM6 //You can change the DMA channel according to your needs - -2. Edit gdisp_lld_panel.h with your panel properties - -3. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/SSD1963/gdisp_lld.mk - - -Example FSMC config with DMA: - -#define GDISP_SCREEN_WIDTH 480 -#define GDISP_SCREEN_HEIGHT 272 - -#define GDISP_USE_FSMC - -#define GDISP_USE_DMA -#define GDISP_DMA_STREAM STM32_DMA2_STREAM6 - -#if defined(GDISP_USE_GPIO) - - #define GDISP_CMD_PORT GPIOC - #define GDISP_DATA_PORT GPIOD - - #define GDISP_CS 0 - #define GDISP_RS 1 - #define GDISP_WR 2 - #define GDISP_RD 3 -#endif diff --git a/drivers/gdisp/SSD1963/ssd1963.h b/drivers/gdisp/SSD1963/ssd1963.h deleted file mode 100644 index 1aa28382..00000000 --- a/drivers/gdisp/SSD1963/ssd1963.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef SSD1963_H -#define SSD1963_H - -#include "gdisp_lld_panel.h" - -#if defined(GDISP_USE_GPIO) - #define Set_CS palSetPad(GDISP_CMD_PORT, GDISP_CS); - #define Clr_CS palClearPad(GDISP_CMD_PORT, GDISP_CS); - #define Set_RS palSetPad(GDISP_CMD_PORT, GDISP_RS); - #define Clr_RS palClearPad(GDISP_CMD_PORT, GDISP_RS); - #define Set_WR palSetPad(GDISP_CMD_PORT, GDISP_WR); - #define Clr_WR palClearPad(GDISP_CMD_PORT, GDISP_WR); - #define Set_RD palSetPad(GDISP_CMD_PORT, GDISP_RD); - #define Clr_RD palClearPad(GDISP_CMD_PORT, GDISP_RD); -#endif - -#if defined(GDISP_USE_FSMC) - /* Using FSMC A16 as RS */ - #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ - #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ -#endif - -#define mHIGH(x) (x >> 8) -#define mLOW(x) (x & 0xFF) - -/* SSD1963 commands */ - -#define SSD1963_NOP 0x0000 -#define SSD1963_SOFT_RESET 0x0001 -#define SSD1963_GET_POWER_MODE 0x000A -#define SSD1963_GET_ADDRESS_MODE 0x000B -#define SSD1963_GET_DISPLAY_MODE 0x000D -#define SSD1963_GET_TEAR_EFFECT_STATUS 0x000E -#define SSD1963_ENTER_SLEEP_MODE 0x0010 -#define SSD1963_EXIT_SLEEP_MODE 0x0011 -#define SSD1963_ENTER_PARTIAL_MODE 0x0012 -#define SSD1963_ENTER_NORMAL_MODE 0x0013 -#define SSD1963_EXIT_INVERT_MODE 0x0020 -#define SSD1963_ENTER_INVERT_MODE 0x0021 -#define SSD1963_SET_GAMMA_CURVE 0x0026 -#define SSD1963_SET_DISPLAY_OFF 0x0028 -#define SSD1963_SET_DISPLAY_ON 0x0029 -#define SSD1963_SET_COLUMN_ADDRESS 0x002A -#define SSD1963_SET_PAGE_ADDRESS 0x002B -#define SSD1963_WRITE_MEMORY_START 0x002C -#define SSD1963_READ_MEMORY_START 0x002E -#define SSD1963_SET_PARTIAL_AREA 0x0030 -#define SSD1963_SET_SCROLL_AREA 0x0033 -#define SSD1963_SET_TEAR_OFF 0x0034 -#define SSD1963_SET_TEAR_ON 0x0035 -#define SSD1963_SET_ADDRESS_MODE 0x0036 -#define SSD1963_SET_SCROLL_START 0x0037 -#define SSD1963_EXIT_IDLE_MODE 0x0038 -#define SSD1963_ENTER_IDLE_MODE 0x0039 -#define SSD1963_SET_PIXEL_FORMAT 0x003A -#define SSD1963_WRITE_MEMORY_CONTINUE 0x003C -#define SSD1963_READ_MEMORY_CONTINUE 0x003E -#define SSD1963_SET_TEAR_SCANLINE 0x0044 -#define SSD1963_GET_SCANLINE 0x0045 -#define SSD1963_READ_DDB 0x00A1 -#define SSD1963_SET_GDISP_MODE 0x00B0 -#define SSD1963_GET_GDISP_MODE 0x00B1 -#define SSD1963_SET_HORI_PERIOD 0x00B4 -#define SSD1963_GET_HORI_PERIOD 0x00B5 -#define SSD1963_SET_VERT_PERIOD 0x00B6 -#define SSD1963_GET_VERT_PERIOD 0x00B7 -#define SSD1963_SET_GPIO_CONF 0x00B8 -#define SSD1963_GET_GPIO_CONF 0x00B9 -#define SSD1963_SET_GPIO_VALUE 0x00BA -#define SSD1963_GET_GPIO_STATUS 0x00BB -#define SSD1963_SET_POST_PROC 0x00BC -#define SSD1963_GET_POST_PROC 0x00BD -#define SSD1963_SET_PWM_CONF 0x00BE -#define SSD1963_GET_PWM_CONF 0x00BF -#define SSD1963_GET_GDISP_GEN0 0x00C0 -#define SSD1963_SET_GDISP_GEN0 0x00C1 -#define SSD1963_GET_GDISP_GEN1 0x00C2 -#define SSD1963_SET_GDISP_GEN1 0x00C3 -#define SSD1963_GET_GDISP_GEN2 0x00C4 -#define SSD1963_SET_GDISP_GEN2 0x00C5 -#define SSD1963_GET_GDISP_GEN3 0x00C6 -#define SSD1963_SET_GDISP_GEN3 0x00C7 -#define SSD1963_SET_GPIO0_ROP 0x00C8 -#define SSD1963_GET_GPIO0_ROP 0x00C9 -#define SSD1963_SET_GPIO1_ROP 0x00CA -#define SSD1963_GET_GPIO1_ROP 0x00CB -#define SSD1963_SET_GPIO2_ROP 0x00CC -#define SSD1963_GET_GPIO2_ROP 0x00CD -#define SSD1963_SET_GPIO3_ROP 0x00CE -#define SSD1963_GET_GPIO3_ROP 0x00CF -#define SSD1963_SET_DBC_CONF 0x00D0 -#define SSD1963_GET_DBC_CONF 0x00D1 -#define SSD1963_SET_DBC_TH 0x00D4 -#define SSD1963_GET_DBC_TH 0x00D5 -#define SSD1963_SET_PLL 0x00E0 -#define SSD1963_SET_PLL_MN 0x00E2 -#define SSD1963_GET_PLL_MN 0x00E3 -#define SSD1963_GET_PLL_STATUS 0x00E4 -#define SSD1963_SET_DEEP_SLEEP 0x00E5 -#define SSD1963_SET_LSHIFT_FREQ 0x00E6 -#define SSD1963_GET_LSHIFT_FREQ 0x00E7 -#define SSD1963_SET_PIXEL_DATA_INTERFACE 0x00F0 - #define SSD1963_PDI_8BIT 0 - #define SSD1963_PDI_12BIT 1 - #define SSD1963_PDI_16BIT 2 - #define SSD1963_PDI_16BIT565 3 - #define SSD1963_PDI_18BIT 4 - #define SSD1963_PDI_24BIT 5 - #define SSD1963_PDI_9BIT 6 -#define SSD1963_GET_PIXEL_DATA_INTERFACE 0x00F1 - -#endif - diff --git a/drivers/gdisp/TestStub/gdisp_lld.c b/drivers/gdisp/TestStub/gdisp_lld.c deleted file mode 100644 index 83049aa2..00000000 --- a/drivers/gdisp/TestStub/gdisp_lld.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/TestStub/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source (stub). - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 128 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 128 -#endif - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise the GDISP structure */ - GDISP.Width = GDISP_SCREEN_WIDTH; - GDISP.Height = GDISP_SCREEN_HEIGHT; - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOff; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - (void)x; - (void)y; - (void)color; -} - -/* ---- Optional Routines ---- */ - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - (void)x; - (void)y; - - return 0; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - (void)x; - (void)y; - (void)cx; - (void)cy; - (void)lines; - (void)bgcolor; - } -#endif - -#endif /* GFX_USE_GDISP */ -/** @} */ diff --git a/drivers/gdisp/TestStub/gdisp_lld.mk b/drivers/gdisp/TestStub/gdisp_lld.mk deleted file mode 100644 index 5f35be9d..00000000 --- a/drivers/gdisp/TestStub/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/TestStub/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/TestStub diff --git a/drivers/gdisp/TestStub/gdisp_lld_config.h b/drivers/gdisp/TestStub/gdisp_lld_config.h deleted file mode 100644 index 18c2de59..00000000 --- a/drivers/gdisp/TestStub/gdisp_lld_config.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/TestStub/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header (stub). - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "TestStub" -#define GDISP_LLD(x) gdisp_lld_##x##_TestStub - -#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL -#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/drivers/gdisp/TestStub/readme.txt b/drivers/gdisp/TestStub/readme.txt deleted file mode 100644 index 11145290..00000000 --- a/drivers/gdisp/TestStub/readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -This low level driver is a test stub that doesn't talk to any -real hardware. It is included to allow testing of the compilation -process. - -Do not use this driver as a template for new drivers. Use the - templates/gdispXXXXX directory for that. - -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) - you want to compile test eg: GDISP_NEED_MULTITHREAD - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/gdisp/TestStub/gdisp_lld.mk diff --git a/drivers/gdisp/VMT/gdisp_lld.c b/drivers/gdisp/VMT/gdisp_lld.c deleted file mode 100644 index 9d9c7382..00000000 --- a/drivers/gdisp/VMT/gdisp_lld.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define GDISP_LLD_NO_STRUCT - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_) -#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_) - -/* Prototypes for lld driver functions */ -bool_t GDISP_LLD1(init)(void); -void *GDISP_LLD1(query)(unsigned what); -void GDISP_LLD1(clear)(color_t color); -void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD1(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CLIP - void GDISP_LLD1(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif -#if GDISP_NEED_CIRCLE - void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_ARC - void GDISP_LLD1(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); - void GDISP_LLD1(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD1(control)(unsigned what, void *value); -#endif - -bool_t GDISP_LLD2(init)(void); -void *GDISP_LLD2(query)(unsigned what); -void GDISP_LLD2(clear)(color_t color); -void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD2(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CLIP - void GDISP_LLD2(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif -#if GDISP_NEED_CIRCLE - void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_ARC - void GDISP_LLD2(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); - void GDISP_LLD2(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD2(control)(unsigned what, void *value); -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/* Our VMT table variables */ -void *GDISP_LLD_VMT(query)(unsigned what); -void GDISP_LLD_VMT(clear)(color_t color); -void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD_VMT(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); - -#if GDISP_NEED_CIRCLE -void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif - -#if GDISP_NEED_ELLIPSE -void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif - -/* Text Rendering Functions */ -#if GDISP_NEED_TEXT -void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); -void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif - -/* Pixel readback */ -#if GDISP_NEED_PIXELREAD -color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); -#endif - -/* Scrolling Function - clears the area scrolled out */ -#if GDISP_NEED_SCROLL -void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif - -/* Set driver specific control */ -#if GDISP_NEED_CONTROL -void GDISP_LLD_VMT(control)(unsigned what, void *value); -#endif -/* Clipping Functions */ -#if GDISP_NEED_CLIP -void GDISP_LLD_VMT(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif - - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -bool_t gdisp_lld_init_VMT(void) { - if (GDISP_VMT_NAME1(gdisp_lld_init_)()) { - gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_); - gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_); - gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME1(gdisp_lld_blitareaex_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_ARC - gdisp_lld_drawarc_VMT = GDISP_VMT_NAME1(gdisp_lld_drawarc_); - gdisp_lld_fillarc_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarc_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_); - #endif - #if GDISP_NEED_CLIP - gdisp_lld_setclip_VMT = GDISP_VMT_NAME1(gdisp_lld_setclip_); - #endif - - return TRUE; - } - - if (GDISP_VMT_NAME2(gdisp_lld_init_)()) { - gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_); - gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_); - gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME2(gdisp_lld_blitareaex_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_ARC - gdisp_lld_drawarc_VMT = GDISP_VMT_NAME2(gdisp_lld_drawarc_); - gdisp_lld_fillarc_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarc_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_); - #endif - #if GDISP_NEED_CLIP - gdisp_lld_setclip_VMT = GDISP_VMT_NAME2(gdisp_lld_setclip_); - #endif - - return TRUE; - } - return FALSE; -} - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld.mk b/drivers/gdisp/VMT/gdisp_lld.mk deleted file mode 100644 index 96918f8a..00000000 --- a/drivers/gdisp/VMT/gdisp_lld.mk +++ /dev/null @@ -1,7 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld.c \ - $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld_driver1.c \ - $(GFXLIB)//drivers/gdisp/VMT/gdisp_lld_driver2.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/VMT diff --git a/drivers/gdisp/VMT/gdisp_lld_config.h b/drivers/gdisp/VMT/gdisp_lld_config.h deleted file mode 100644 index 8c7bfc9c..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_config.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header template. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "VMT" -#define GDISP_LLD(x) gdisp_lld_##x##_VMT -#define GDISP_LLD_VMT(x) (*GDISP_LLD(x)) - -#define GDISP_HARDWARE_LINES TRUE -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES TRUE -#define GDISP_HARDWARE_CIRCLEFILLS TRUE -#define GDISP_HARDWARE_ELLIPSES TRUE -#define GDISP_HARDWARE_ELLIPSEFILLS TRUE -#define GDISP_HARDWARE_ARCS TRUE -#define GDISP_HARDWARE_ARCFILLS TRUE -#define GDISP_HARDWARE_TEXT TRUE -#define GDISP_HARDWARE_TEXTFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_HARDWARE_QUERY TRUE -#define GDISP_HARDWARE_CLIP TRUE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld_driver1.c b/drivers/gdisp/VMT/gdisp_lld_driver1.c deleted file mode 100644 index 01fd4cf0..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_driver1.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_driver1.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define CONFIGFILE() <../GDISP_VMT_NAME1()/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME1()/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gfx.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld_driver2.c b/drivers/gdisp/VMT/gdisp_lld_driver2.c deleted file mode 100644 index ed0e8555..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_driver2.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_driver2.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define CONFIGFILE() <../GDISP_VMT_NAME2()/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME2()/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gfx.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/readme.txt b/drivers/gdisp/VMT/readme.txt deleted file mode 100644 index d6b71e0e..00000000 --- a/drivers/gdisp/VMT/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -This driver enables you to have two underlying drivers handling different hardware. -A choice is made at run-time of which driver to call based on which driver succeeds -to initialise first (init returns TRUE). - -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) Define these: - #define GDISP_VMT_NAME1(x) x##YourDriver1 - #define GDISP_VMT_NAME2(x) x##YourDriver2 - Note YourDriver1 & 2 are the basenames of the directories containing the driver. - Note that both drivers must be the same pixel format which is - GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your - pixel format is different on both drivers. - d) Any driver specific defines. If both drivers use the same defines then they must - accept the same values for the define. - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk - diff --git a/drivers/ginput/toggle/Pal/ginput_lld.mk b/drivers/ginput/toggle/Pal/ginput_lld.mk deleted file mode 100644 index d398da9d..00000000 --- a/drivers/ginput/toggle/Pal/ginput_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/ginput/toggle/Pal/ginput_lld_toggle.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/ginput/toggle/Pal diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle.c b/drivers/ginput/toggle/Pal/ginput_lld_toggle.c deleted file mode 100644 index e2ecc116..00000000 --- a/drivers/ginput/toggle/Pal/ginput_lld_toggle.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/toggle/Pal/ginput_lld_toggle.c - * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware. - * - * @defgroup Toggle Toggle - * @ingroup GINPUT - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) /*|| defined(__DOXYGEN__)*/ - -#include "ginput/lld/toggle.h" - -GINPUT_TOGGLE_DECLARE_STRUCTURE(); - -/** - * @brief Initialise the port. - * - * @param[in] ptc A pointer to one of the entries in GInputToggleConfigTable - * - * @notapi - */ -void ginput_lld_toggle_init(const GToggleConfig *ptc) { - palSetGroupMode(((IOBus *)ptc->id)->portid, ptc->mask, 0, ptc->mode); -} - -/** - * @brief Get the bits from the port. - * - * @param[in] ptc A pointer to one of the entries in GInputToggleConfigTable - * - * @notapi - */ -unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { - return palReadBus((IOBus *)ptc->id); -} - -#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ -/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h deleted file mode 100644 index 20fc44b5..00000000 --- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h - * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the example board. - * - * @defgroup Toggle Toggle - * @ingroup GINPUT - * @{ - */ - -#ifndef _GDISP_LLD_TOGGLE_BOARD_H -#define _GDISP_LLD_TOGGLE_BOARD_H - -#error "GINPUT Toggle Pal Driver: You need to define your board definitions" - -// The below are example values - -#define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs -#define GINPUT_TOGGLE_CONFIG_ENTRIES 2 // The total number of GToggleConfig entries - -#define GINPUT_TOGGLE_SW1 0 // Switch 1 -#define GINPUT_TOGGLE_SW2 1 // Switch 2 -#define GINPUT_TOGGLE_UP 2 // Joystick Up -#define GINPUT_TOGGLE_DOWN 3 // Joystick Down -#define GINPUT_TOGGLE_LEFT 4 // Joystick Left -#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right -#define GINPUT_TOGGLE_CENTER 6 // Joystick Center - -#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ - const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ - {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \ - PIOB_SW1_MASK|PIOB_SW2_MASK, \ - PIOB_SW1_MASK|PIOB_SW2_MASK, \ - PAL_MODE_INPUT}, \ - {AT91C_BASE_PIOA, /* B1..4 Joystick */ \ - PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ - PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ - PAL_MODE_INPUT}, \ - } - -#endif /* _GDISP_LLD_TOGGLE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h deleted file mode 100644 index 4f3d6800..00000000 --- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h - * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the Olimex SAM7EX256 board. - * - * @defgroup Toggle Toggle - * @ingroup GINPUT - * @{ - */ - -#ifndef _GDISP_LLD_TOGGLE_BOARD_H -#define _GDISP_LLD_TOGGLE_BOARD_H - -#define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs -#define GINPUT_TOGGLE_CONFIG_ENTRIES 2 // The total number of GToggleConfig entries - -#define GINPUT_TOGGLE_SW1 0 // Switch 1 -#define GINPUT_TOGGLE_SW2 1 // Switch 2 -#define GINPUT_TOGGLE_UP 2 // Joystick Up -#define GINPUT_TOGGLE_DOWN 3 // Joystick Down -#define GINPUT_TOGGLE_LEFT 4 // Joystick Left -#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right -#define GINPUT_TOGGLE_CENTER 6 // Joystick Center - -#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ - const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ - {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \ - PIOB_SW1_MASK|PIOB_SW2_MASK, \ - PIOB_SW1_MASK|PIOB_SW2_MASK, \ - PAL_MODE_INPUT}, \ - {AT91C_BASE_PIOA, /* B1..4 Joystick */ \ - PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ - PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ - PAL_MODE_INPUT}, \ - } - -#endif /* _GDISP_LLD_TOGGLE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h deleted file mode 100644 index 162d35df..00000000 --- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h - * @brief GINPUT Toggle Driver configuration header. - * - * @defgroup Toggle Toggle - * @ingroup GINPUT - * @{ - */ - -#ifndef _GINPUT_LLD_TOGGLE_CONFIG_H -#define _GINPUT_LLD_TOGGLE_CONFIG_H - -#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE - -#if GINPUT_TOGGLE_USE_CUSTOM_BOARD - /* Include the user supplied board definitions */ - #include "ginput_lld_toggle_board.h" -#elif defined(BOARD_OLIMEX_SAM7_EX256) - #include "ginput_lld_toggle_board_olimexsam7ex256.h" -#else - /* Include the user supplied board definitions */ - #include "ginput_lld_toggle_board.h" -#endif - -#endif /* GFX_USE_GDISP && GINPUT_NEED_TOGGLE */ - -#endif /* _GINPUT_LLD_TOGGLE_CONFIG_H */ -/** @} */ diff --git a/drivers/ginput/toggle/Pal/readme.txt b/drivers/ginput/toggle/Pal/readme.txt deleted file mode 100644 index e6976f7d..00000000 --- a/drivers/ginput/toggle/Pal/readme.txt +++ /dev/null @@ -1,13 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GINPUT TRUE - #define GINPUT_NEED_TOGGLE TRUE - d) If you are not using a known board then create a ginput_lld_toggle_board.h file - and ensure it is on your include path. - Use the ginput_lld_toggle_board_example.h file as a basis. - Currently known boards are: - Olimex SAM7-EX256 - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/ginput/togglePal/ginput_lld.mk diff --git a/drivers/ginput/touch/ADS7843/ginput_lld.mk b/drivers/ginput/touch/ADS7843/ginput_lld.mk deleted file mode 100644 index b6ac0ea6..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/ginput/touch/ADS7843 diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c deleted file mode 100644 index 65065176..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse.c - * @brief GINPUT Touch low level driver source for the ADS7843. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/ - -#include "ginput/lld/mouse.h" - -#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD - #include "ginput_lld_mouse_board.h" -#elif defined(BOARD_FIREBULL_STM32_F103) - #include "ginput_lld_mouse_board_firebull_stm32f103.h" -#elif defined(BOARD_OLIMEX_STM32_E407) - #include "ginput_lld_mouse_board_olimex_stm32_e407.h" -#else - #include "ginput_lld_mouse_board_example.h" -#endif - -static uint16_t sampleBuf[7]; -static coord_t lastx, lasty; - -/** - * @brief 7-point median filtering code for touch samples - * - * @note This is an internally used routine only. - * - * @notapi - */ -static void filter(void) { - uint16_t temp; - int i,j; - - for(i = 0; i < 4; i++) { - for(j = i; j < 7; j++) { - if(sampleBuf[i] > sampleBuf[j]) { - /* Swap the values */ - temp = sampleBuf[i]; - sampleBuf[i] = sampleBuf[j]; - sampleBuf[j] = temp; - } - } - } -} - -/** - * @brief Initialise the mouse/touch. - * - * @notapi - */ -void ginput_lld_mouse_init(void) { - init_board(); -} - -/** - * @brief Read the mouse/touch position. - * - * @param[in] pt A pointer to the structure to fill - * - * @note For drivers that don't support returning a position - * when the touch is up (most touch devices), it should - * return the previous position with the new Z value. - * The z value is the pressure for those touch devices - * that support it (-100 to 100 where > 0 is touched) - * or, 0 or 100 for those drivers that don't. - * - * @notapi - */ -void ginput_lld_mouse_get_reading(MouseReading *pt) { - uint16_t i; - - // If touch-off return the previous results - if (!getpin_pressed()) { - pt->x = lastx; - pt->y = lasty; - pt->z = 0; - pt->buttons = 0; - return; - } - - // Read the port to get the touch settings - aquire_bus(); - - /* Get the X value - * Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. Note that PENIRQ is disabled while reading. - * Finally switch on PENIRQ once again - perform a dummy read. - * Once we have the readings, find the medium using our filter function - */ - read_value(0xD1); - for(i = 0; i < 7; i++) - sampleBuf[i] = read_value(0xD1); - read_value(0xD0); - filter(); - lastx = (coord_t)sampleBuf[3]; - - /* Get the Y value using the same process as above */ - read_value(0x91); - for(i = 0; i < 7; i++) - sampleBuf[i] = read_value(0x91); - read_value(0x90); - filter(); - lasty = (coord_t)sampleBuf[3]; - - // Release the bus - release_bus(); - - // Return the results - pt->x = lastx; - pt->y = lasty; - pt->z = 100; - pt->buttons = GINPUT_TOUCH_PRESSED; -} - -#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */ -/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h deleted file mode 100644 index 9f4f2dc1..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h - * @brief GINPUT Touch low level driver source for the ADS7843 on the example board. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ - #error "ginputADS7843: You must supply a definition for init_board for your board" -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static __inline bool_t getpin_pressed(void) { - /* Code here */ - #error "ginputADS7843: You must supply a definition for getpin_pressed for your board" -} - -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static __inline void aquire_bus(void) { - /* Code here */ - #error "ginputADS7843: You must supply a definition for aquire_bus for your board" -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static __inline void release_bus(void) { - /* Code here */ - #error "ginputADS7843: You must supply a definition for release_bus for your board" -} - -/** - * @brief Read a value from touch controller - * @return The value read from the controller - * - * params[in] port The controller port to read. - * - * @notapi - */ -static __inline uint16_t read_value(uint16_t port) { - /* Code here */ - #error "ginputADS7843: You must supply a definition for read_value for your board" -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h deleted file mode 100644 index bc018b89..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h - * @brief GINPUT ouch low level driver source for the ADS7843 on the FireBull STM32F103-FB board. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -static const SPIConfig spicfg = { - NULL, - GPIOC, - 6, - /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static __inline void init_board(void) { - spiStart(&SPID1, &spicfg); -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static __inline bool_t getpin_pressed(void) { - return (!palReadPad(GPIOC, 4)); -} -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static __inline void aquire_bus(void) { - spiAcquireBus(&SPID1); - //TOUCHSCREEN_SPI_PROLOGUE(); - palClearPad(GPIOC, 6); -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static __inline void release_bus(void) { - palSetPad(GPIOC, 6); - spiReleaseBus(&SPID1); - //TOUCHSCREEN_SPI_EPILOGUE(); -} - -/** - * @brief Read a value from touch controller - * @return The value read from the controller - * - * params[in] port The controller port to read. - * - * @notapi - */ -static __inline uint16_t read_value(uint16_t port) { - static uint8_t txbuf[3] = {0}; - static uint8_t rxbuf[3] = {0}; - uint16_t ret; - - txbuf[0] = port; - - spiExchange(&SPID1, 3, txbuf, rxbuf); - - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - - return ret; -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h deleted file mode 100644 index 6c5f7e37..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h - * @brief GINPUT Touch low level driver source for the ADS7843 on an Olimex STM32E407. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -static const SPIConfig spicfg = { - NULL, - GPIOG, - 10, - /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static __inline void init_board(void) { - spiStart(&SPID2, &spicfg); -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static __inline bool_t getpin_pressed(void) { - return (!palReadPad(GPIOG, 0)); -} -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static __inline void aquire_bus(void) { - spiAcquireBus(&SPID2); - //TOUCHSCREEN_SPI_PROLOGUE(); - palClearPad(GPIOG, 10); -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static __inline void release_bus(void) { - palSetPad(GPIOG, 10); - spiReleaseBus(&SPID2); - //TOUCHSCREEN_SPI_EPILOGUE(); -} - -/** - * @brief Read a value from touch controller - * @return The value read from the controller - * - * params[in] port The controller port to read. - * - * @notapi - */ -static __inline uint16_t read_value(uint16_t port) { - static uint8_t txbuf[3] = {0}; - static uint8_t rxbuf[3] = {0}; - uint16_t ret; - - txbuf[0] = port; - - spiExchange(&SPID2, 3, txbuf, rxbuf); - - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - - return ret; -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h deleted file mode 100644 index 30a13841..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h - * @brief GINPUT LLD header file for mouse/touch driver. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _LLD_GINPUT_MOUSE_CONFIG_H -#define _LLD_GINPUT_MOUSE_CONFIG_H - -#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH -#define GINPUT_MOUSE_NEED_CALIBRATION TRUE -#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE -#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5 -#define GINPUT_MOUSE_READ_CYCLES 4 -#define GINPUT_MOUSE_POLL_PERIOD 25 -#define GINPUT_MOUSE_MAX_CLICK_JITTER 10 -#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 -#define GINPUT_MOUSE_CLICK_TIME 500 - -#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ -/** @} */ diff --git a/drivers/ginput/touch/ADS7843/readme.txt b/drivers/ginput/touch/ADS7843/readme.txt deleted file mode 100644 index 852a1ea0..00000000 --- a/drivers/ginput/touch/ADS7843/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GINPUT TRUE - b) #define GINPUT_NEED_MOUSE TRUE - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld.mk - diff --git a/drivers/ginput/touch/MCU/ginput_lld.mk b/drivers/ginput/touch/MCU/ginput_lld.mk deleted file mode 100644 index eb8fb2d8..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld_mouse.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/ginput/touch/MCU diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse.c b/drivers/ginput/touch/MCU/ginput_lld_mouse.c deleted file mode 100644 index b43a14e7..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/MCU/ginput_lld_mouse.c - * @brief GINPUT Touch low level driver source for the MCU. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/ - -#include "ginput/lld/mouse.h" - -#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD - #include "ginput_lld_mouse_board.h" -#elif defined(BOARD_OLIMEX_STM32_LCD) - #include "ginput_lld_mouse_board_olimex_stm32_lcd.h" -#else - #include "ginput_lld_mouse_board.h" -#endif - -static uint16_t sampleBuf[7]; -static coord_t lastx, lasty; - -/** - * @brief 7-point median filtering code for touchscreen samples - * - * @note This is an internally used routine only. - * - * @notapi - */ -static void filter(void) { - uint16_t temp; - int i,j; - - for(i = 0; i < 4; i++) { - for(j = i; j < 7; j++) { - if(sampleBuf[i] > sampleBuf[j]) { - /* Swap the values */ - temp = sampleBuf[i]; - sampleBuf[i] = sampleBuf[j]; - sampleBuf[j] = temp; - } - } - } -} - -/** - * @brief Initialise the mouse/touch. - * - * @notapi - */ -void ginput_lld_mouse_init(void) { - init_board(); -} - -/** - * @brief Read the mouse/touch position. - * - * @param[in] pt A pointer to the structure to fill - * - * @note For drivers that don't support returning a position - * when the touch is up (most touch devices), it should - * return the previous position with the new Z value. - * The z value is the pressure for those touch devices - * that support it (-100 to 100 where > 0 is touched) - * or, 0 or 100 for those drivers that don't. - * - * @notapi - */ -void ginput_lld_mouse_get_reading(MouseReading *pt) { - uint16_t i; - - // If touch-off return the previous results - if (!getpin_pressed()) { - pt->x = lastx; - pt->y = lasty; - pt->z = 0; - pt->buttons = 0; - return; - } - - // Read the port to get the touch settings - aquire_bus(); - - /* Get the X value - * Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. - * Once we have the readings, find the medium using our filter function - */ - read_x_value(); - for(i = 0; i < 7; i++) - sampleBuf[i] = read_x_value(); - filter(); - lastx = (coord_t)sampleBuf[3]; - - /* Get the Y value using the same process as above */ - read_y_value(); - for(i = 0; i < 7; i++) - sampleBuf[i] = read_y_value(); - filter(); - lasty = (coord_t)sampleBuf[3]; - - // Release the bus - release_bus(); - - // Return the results - pt->x = lastx; - pt->y = lasty; - pt->z = 100; - pt->buttons = GINPUT_TOUCH_PRESSED; -} - -#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */ -/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h deleted file mode 100644 index 913d50c9..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h - * @brief GINPUT Touch low level driver source for the MCU on the example board. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static __inline void init_board(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for init_board for your board" -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static __inline bool_t getpin_pressed(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for getpin_pressed for your board" -} - -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static __inline void aquire_bus(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for aquire_bus for your board" -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static __inline void release_bus(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for release_bus for your board" -} - -/** - * @brief Read an x value from touch controller - * @return The value read from the controller - * - * @notapi - */ -static __inline uint16_t read_x_value(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for read_x_value for your board" -} - -/** - * @brief Read an y value from touch controller - * @return The value read from the controller - * - * @notapi - */ -static __inline uint16_t read_y_value(void) { - /* Code here */ - #error "ginputMCU: You must supply a definition for read_y_value for your board" -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h deleted file mode 100644 index 510e8e81..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h - * @brief GINPUT Touch low level driver source for the MCU on the example board. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -#define ADC_NUM_CHANNELS 2 -#define ADC_BUF_DEPTH 1 - -static const ADCConversionGroup adc_y_config = { - FALSE, - ADC_NUM_CHANNELS, - NULL, - NULL, - 0, 0, - 0, 0, - ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS), - 0, - ADC_SQR3_SQ2_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN13) -}; - -static const ADCConversionGroup adc_x_config = { - FALSE, - ADC_NUM_CHANNELS, - NULL, - NULL, - 0, 0, - 0, 0, - ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS), - 0, - ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11) -}; - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static __inline void init_board(void) { - adcStart(&ADCD1, NULL); -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static __inline bool_t getpin_pressed(void) { - palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_PULLDOWN); - palSetPadMode(GPIOC, 1, PAL_MODE_INPUT); - palSetPadMode(GPIOC, 2, PAL_MODE_INPUT); - palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL); - palSetPad(GPIOC, 3); - - return palReadPad(GPIOC, 0); -} - -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static __inline void aquire_bus(void) { - -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static __inline void release_bus(void) { - -} - -/** - * @brief Read an x value from touch controller - * @return The value read from the controller - * - * @notapi - */ -static __inline uint16_t read_x_value(void) { - uint16_t val1, val2; - adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH]; - - palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_ANALOG); - palSetPadMode(GPIOC, 1, PAL_MODE_INPUT_ANALOG); - palSetPadMode(GPIOC, 2, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL); - - palSetPad(GPIOC, 2); - palClearPad(GPIOC, 3); - chThdSleepMilliseconds(1); - adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH); - val1 = ((samples[0] + samples[1])/2); - - palClearPad(GPIOC, 2); - palSetPad(GPIOC, 3); - chThdSleepMilliseconds(1); - adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH); - val2 = ((samples[0] + samples[1])/2); - - return ((val1+((1<<12)-val2))/4); -} - -/** - * @brief Read an y value from touch controller - * @return The value read from the controller - * - * @notapi - */ -static __inline uint16_t read_y_value(void) { - uint16_t val1, val2; - adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH]; - - palSetPadMode(GPIOC, 2, PAL_MODE_INPUT_ANALOG); - palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG); - palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(GPIOC, 1, PAL_MODE_OUTPUT_PUSHPULL); - - palSetPad(GPIOC, 1); - palClearPad(GPIOC, 0); - chThdSleepMilliseconds(1); - adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH); - val1 = ((samples[0] + samples[1])/2); - - palClearPad(GPIOC, 1); - palSetPad(GPIOC, 0); - chThdSleepMilliseconds(1); - adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH); - val2 = ((samples[0] + samples[1])/2); - - return ((val1+((1<<12)-val2))/4); -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h deleted file mode 100644 index 1b5c7b6b..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file drivers/ginput/touch/MCU/ginput_lld_mouse_config.h - * @brief GINPUT LLD header file for touch driver. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _LLD_GINPUT_MOUSE_CONFIG_H -#define _LLD_GINPUT_MOUSE_CONFIG_H - -#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH -#define GINPUT_MOUSE_NEED_CALIBRATION TRUE -#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE -#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12 -#define GINPUT_MOUSE_READ_CYCLES 4 -#define GINPUT_MOUSE_POLL_PERIOD 25 -#define GINPUT_MOUSE_MAX_CLICK_JITTER 2 -#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 -#define GINPUT_MOUSE_CLICK_TIME 500 - -#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ -/** @} */ diff --git a/drivers/ginput/touch/MCU/readme.txt b/drivers/ginput/touch/MCU/readme.txt deleted file mode 100644 index 4dbe5543..00000000 --- a/drivers/ginput/touch/MCU/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GINPUT TRUE - b) #define GINPUT_NEED_MOUSE TRUE - -2. To your makefile add the following lines: - include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk - diff --git a/drivers/multiple/Win32/gdisp_lld.c b/drivers/multiple/Win32/gdisp_lld.c deleted file mode 100644 index d44bbfad..00000000 --- a/drivers/multiple/Win32/gdisp_lld.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/multiple/Win32/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for Win32. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#include -#include -#include -#include -#include -#include - -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 640 -#endif -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 480 -#endif - -#if GINPUT_NEED_TOGGLE - /* Include toggle support code */ - #include "ginput/lld/toggle.h" - - const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { - {0, 0xFF, 0x00, PAL_MODE_INPUT}, - }; -#endif - -#if GINPUT_NEED_MOUSE - /* Include mouse support code */ - #include "ginput/lld/mouse.h" -#endif - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local routines . */ -/*===========================================================================*/ - -#define WIN32_USE_MSG_REDRAW FALSE -#if GINPUT_NEED_TOGGLE - #define WIN32_BUTTON_AREA 16 -#else - #define WIN32_BUTTON_AREA 0 -#endif - -#define APP_NAME "GDISP" - -#define COLOR2BGR(c) ((((c) & 0xFF)<<16)|((c) & 0xFF00)|(((c)>>16) & 0xFF)) -#define BGR2COLOR(c) COLOR2BGR(c) - -static HWND winRootWindow = NULL; -static HDC dcBuffer = NULL; -static HBITMAP dcBitmap = NULL; -static HBITMAP dcOldBitmap; -static volatile bool_t isReady = FALSE; -static coord_t wWidth, wHeight; - -#if GINPUT_NEED_MOUSE - static coord_t mousex, mousey; - static uint16_t mousebuttons; -#endif -#if GINPUT_NEED_TOGGLE - static uint8_t toggles = 0; -#endif - -static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - HDC dc; - PAINTSTRUCT ps; - #if GINPUT_NEED_TOGGLE - HBRUSH hbrOn, hbrOff; - HPEN pen; - RECT rect; - HGDIOBJ old; - POINT p; - coord_t pos; - uint8_t bit; - #endif - - switch (Msg) { - case WM_CREATE: - break; - case WM_LBUTTONDOWN: - #if GINPUT_NEED_MOUSE - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons |= GINPUT_MOUSE_BTN_LEFT; - goto mousemove; - } - #endif - #if GINPUT_NEED_TOGGLE - bit = 1 << ((coord_t)LOWORD(lParam)*8/wWidth); - toggles ^= bit; - rect.left = 0; - rect.right = wWidth; - rect.top = wHeight; - rect.bottom = wHeight + WIN32_BUTTON_AREA; - InvalidateRect(hWnd, &rect, FALSE); - UpdateWindow(hWnd); - #if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE - ginputToggleWakeup(); - #endif - #endif - break; - case WM_LBUTTONUP: - #if GINPUT_NEED_TOGGLE - if ((toggles & 0xF0)) { - toggles &= 0x0F; - rect.left = 0; - rect.right = wWidth; - rect.top = wHeight; - rect.bottom = wHeight + WIN32_BUTTON_AREA; - InvalidateRect(hWnd, &rect, FALSE); - UpdateWindow(hWnd); - #if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE - ginputToggleWakeup(); - #endif - } - #endif - #if GINPUT_NEED_MOUSE - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons &= ~GINPUT_MOUSE_BTN_LEFT; - goto mousemove; - } - #endif - break; -#if GINPUT_NEED_MOUSE - case WM_MBUTTONDOWN: - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons |= GINPUT_MOUSE_BTN_MIDDLE; - goto mousemove; - } - break; - case WM_MBUTTONUP: - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons &= ~GINPUT_MOUSE_BTN_MIDDLE; - goto mousemove; - } - break; - case WM_RBUTTONDOWN: - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons |= GINPUT_MOUSE_BTN_RIGHT; - goto mousemove; - } - break; - case WM_RBUTTONUP: - if ((coord_t)HIWORD(lParam) < wHeight) { - mousebuttons &= ~GINPUT_MOUSE_BTN_RIGHT; - goto mousemove; - } - break; - case WM_MOUSEMOVE: - if ((coord_t)HIWORD(lParam) >= wHeight) - break; - mousemove: - mousex = (coord_t)LOWORD(lParam); - mousey = (coord_t)HIWORD(lParam); - #if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE - ginputMouseWakeup(); - #endif - break; -#endif - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - case WM_SYSKEYUP: - case WM_KEYUP: - break; - case WM_CHAR: - case WM_DEADCHAR: - case WM_SYSCHAR: - case WM_SYSDEADCHAR: - break; - case WM_PAINT: - dc = BeginPaint(hWnd, &ps); - BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top, - ps.rcPaint.right - ps.rcPaint.left, - (ps.rcPaint.bottom > wHeight ? wHeight : ps.rcPaint.bottom) - ps.rcPaint.top, - dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); - #if GINPUT_NEED_TOGGLE - if (ps.rcPaint.bottom >= wHeight) { - pen = CreatePen(PS_SOLID, 1, COLOR2BGR(Black)); - hbrOn = CreateSolidBrush(COLOR2BGR(Blue)); - hbrOff = CreateSolidBrush(COLOR2BGR(Gray)); - old = SelectObject(dc, pen); - MoveToEx(dc, 0, wHeight, &p); - LineTo(dc, wWidth, wHeight); - for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) { - rect.left = pos; - rect.right = pos + wWidth/8; - rect.top = wHeight; - rect.bottom = wHeight + WIN32_BUTTON_AREA; - FillRect(dc, &rect, (toggles & bit) ? hbrOn : hbrOff); - if (pos > 0) { - MoveToEx(dc, rect.left, rect.top, &p); - LineTo(dc, rect.left, rect.bottom); - } - } - DeleteObject(hbrOn); - DeleteObject(hbrOff); - SelectObject(dc, old); - } - #endif - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - SelectObject(dcBuffer, dcOldBitmap); - DeleteDC(dcBuffer); - DeleteObject(dcBitmap); - winRootWindow = NULL; - break; - default: - return DefWindowProc(hWnd, Msg, wParam, lParam); - } - return 0; -} - -static DWORD WINAPI WindowThread(LPVOID lpParameter) { - (void)lpParameter; - - MSG msg; - HANDLE hInstance; - WNDCLASS wc; - RECT rect; - HDC dc; - - hInstance = GetModuleHandle(NULL); - - wc.style = CS_HREDRAW | CS_VREDRAW; // | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC)myWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = APP_NAME; - RegisterClass(&wc); - - rect.top = 0; rect.bottom = wHeight+WIN32_BUTTON_AREA; - rect.left = 0; rect.right = wWidth; - AdjustWindowRect(&rect, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0); - winRootWindow = CreateWindow(APP_NAME, "", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0, 0, - rect.right-rect.left, rect.bottom-rect.top, 0, 0, hInstance, NULL); - assert(winRootWindow != NULL); - - - GetClientRect(winRootWindow, &rect); - wWidth = rect.right-rect.left; - wHeight = rect.bottom - rect.top - WIN32_BUTTON_AREA; - - dc = GetDC(winRootWindow); - dcBitmap = CreateCompatibleBitmap(dc, wWidth, wHeight); - dcBuffer = CreateCompatibleDC(dc); - ReleaseDC(winRootWindow, dc); - dcOldBitmap = SelectObject(dcBuffer, dcBitmap); - - ShowWindow(winRootWindow, SW_SHOW); - UpdateWindow(winRootWindow); - isReady = TRUE; - - while(GetMessage(&msg, NULL, 0, 0) > 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - ExitProcess(0); - return msg.wParam; -} - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialisation. - * @return TRUE if successful, FALSE on error. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - RECT rect; - - /* Set the window dimensions */ - GetWindowRect(GetDesktopWindow(), &rect); - wWidth = rect.right - rect.left; - wHeight = rect.bottom - rect.top - WIN32_BUTTON_AREA; - if (wWidth > GDISP_SCREEN_WIDTH) - wWidth = GDISP_SCREEN_WIDTH; - if (wHeight > GDISP_SCREEN_HEIGHT) - wHeight = GDISP_SCREEN_HEIGHT; - - /* Initialise the window */ - CreateThread(0, 0, WindowThread, 0, 0, 0); - while (!isReady) - Sleep(1); - - /* Initialise the GDISP structure to match */ - GDISP.Orientation = GDISP_ROTATE_0; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - GDISP.Width = wWidth; - GDISP.Height = wHeight; - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - HDC dc; - #if WIN32_USE_MSG_REDRAW - RECT rect; - #endif - #if GDISP_NEED_CONTROL - coord_t t; - #endif - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - // Clip pre orientation change - if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - #endif - - #if GDISP_NEED_CONTROL - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - break; - case GDISP_ROTATE_90: - t = GDISP.Height - 1 - y; - y = x; - x = t; - break; - case GDISP_ROTATE_180: - x = GDISP.Width - 1 - x; - y = GDISP.Height - 1 - y; - break; - case GDISP_ROTATE_270: - t = GDISP.Width - 1 - x; - x = y; - y = t; - break; - } - #endif - - // Draw the pixel in the buffer - color = COLOR2BGR(color); - SetPixel(dcBuffer, x, y, color); - - #if WIN32_USE_MSG_REDRAW - rect.left = x; rect.right = x+1; - rect.top = y; rect.bottom = y+1; - InvalidateRect(winRootWindow, &rect, FALSE); - UpdateWindow(winRootWindow); - #else - // Draw the pixel again directly on the screen. - // This is cheaper than invalidating a single pixel in the window - dc = GetDC(winRootWindow); - SetPixel(dc, x, y, color); - ReleaseDC(winRootWindow, dc); - #endif -} - -/* ---- Optional Routines ---- */ - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - POINT p; - HPEN pen; - HDC dc; - HGDIOBJ old; - #if GDISP_NEED_CLIP - HRGN clip; - #endif - #if WIN32_USE_MSG_REDRAW - RECT rect; - #endif - #if GDISP_NEED_CONTROL - coord_t t; - #endif - - #if GDISP_NEED_CLIP - clip = NULL; - #endif - - #if GDISP_NEED_CONTROL - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - #if GDISP_NEED_CLIP - // Clip post orientation change - if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) - clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1); - #endif - break; - case GDISP_ROTATE_90: - t = GDISP.Height - 1 - y0; - y0 = x0; - x0 = t; - t = GDISP.Height - 1 - y1; - y1 = x1; - x1 = t; - #if GDISP_NEED_CLIP - // Clip post orientation change - if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) - clip = CreateRectRgn(GDISP.Height-1-GDISP.clipy1, GDISP.clipx0, GDISP.Height-1-GDISP.clipy0, GDISP.clipx1); - #endif - break; - case GDISP_ROTATE_180: - x0 = GDISP.Width - 1 - x0; - y0 = GDISP.Height - 1 - y0; - x1 = GDISP.Width - 1 - x1; - y1 = GDISP.Height - 1 - y1; - #if GDISP_NEED_CLIP - // Clip post orientation change - if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) - clip = CreateRectRgn(GDISP.Width-1-GDISP.clipx1, GDISP.Height-1-GDISP.clipy1, GDISP.Width-1-GDISP.clipx0, GDISP.Height-1-GDISP.clipy0); - #endif - break; - case GDISP_ROTATE_270: - t = GDISP.Width - 1 - x0; - x0 = y0; - y0 = t; - t = GDISP.Width - 1 - x1; - x1 = y1; - y1 = t; - #if GDISP_NEED_CLIP - // Clip post orientation change - if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) - clip = CreateRectRgn(GDISP.clipy0, GDISP.Width-1-GDISP.clipx1, GDISP.clipy1, GDISP.Width-1-GDISP.clipx0); - #endif - break; - } - #else - #if GDISP_NEED_CLIP - clip = NULL; - if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) - clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1); - #endif - #endif - - color = COLOR2BGR(color); - pen = CreatePen(PS_SOLID, 1, color); - if (pen) { - // Draw the line in the buffer - #if GDISP_NEED_CLIP - if (clip) SelectClipRgn(dcBuffer, clip); - #endif - old = SelectObject(dcBuffer, pen); - MoveToEx(dcBuffer, x0, y0, &p); - LineTo(dcBuffer, x1, y1); - SelectObject(dcBuffer, old); - SetPixel(dcBuffer, x1, y1, color); - #if GDISP_NEED_CLIP - if (clip) SelectClipRgn(dcBuffer, NULL); - #endif - - #if WIN32_USE_MSG_REDRAW - rect.left = x0; rect.right = x1+1; - rect.top = y0; rect.bottom = y1+1; - InvalidateRect(winRootWindow, &rect, FALSE); - UpdateWindow(winRootWindow); - #else - // Redrawing the line on the screen is cheaper than invalidating the whole rectangular area - dc = GetDC(winRootWindow); - #if GDISP_NEED_CLIP - if (clip) SelectClipRgn(dc, clip); - #endif - old = SelectObject(dc, pen); - MoveToEx(dc, x0, y0, &p); - LineTo(dc, x1, y1); - SelectObject(dc, old); - SetPixel(dc, x1, y1, color); - #if GDISP_NEED_CLIP - if (clip) SelectClipRgn(dc, NULL); - #endif - ReleaseDC(winRootWindow, dc); - #endif - - DeleteObject(pen); - } - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - HDC dc; - RECT rect; - HBRUSH hbr; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - // Clip pre orientation change - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - #if GDISP_NEED_CONTROL - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - break; - case GDISP_ROTATE_90: - rect.top = x; - rect.bottom = rect.top+cx; - rect.right = GDISP.Height - y; - rect.left = rect.right-cy; - break; - case GDISP_ROTATE_180: - rect.bottom = GDISP.Height - y; - rect.top = rect.bottom-cy; - rect.right = GDISP.Width - x; - rect.left = rect.right-cx; - break; - case GDISP_ROTATE_270: - rect.bottom = GDISP.Width - x; - rect.top = rect.bottom-cx; - rect.left = y; - rect.right = rect.left+cy; - break; - } - #else - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - #endif - - color = COLOR2BGR(color); - hbr = CreateSolidBrush(color); - - if (hbr) { - // Fill the area - FillRect(dcBuffer, &rect, hbr); - - #if WIN32_USE_MSG_REDRAW - InvalidateRect(winRootWindow, &rect, FALSE); - UpdateWindow(winRootWindow); - #else - // Filling the area directly on the screen is likely to be cheaper than invalidating it - dc = GetDC(winRootWindow); - FillRect(dc, &rect, hbr); - ReleaseDC(winRootWindow, dc); - #endif - - DeleteObject(hbr); - } - } -#endif - -#if (GDISP_HARDWARE_BITFILLS && GDISP_NEED_CONTROL) || defined(__DOXYGEN__) - static pixel_t *rotateimg(coord_t cx, coord_t cy, coord_t srcx, coord_t srccx, const pixel_t *buffer) { - pixel_t *dstbuf; - pixel_t *dst; - const pixel_t *src; - size_t sz; - coord_t i, j; - - // Shortcut. - if (GDISP.Orientation == GDISP_ROTATE_0 && srcx == 0 && cx == srccx) - return (pixel_t *)buffer; - - // Allocate the destination buffer - sz = (size_t)cx * (size_t)cy; - if (!(dstbuf = (pixel_t *)malloc(sz * sizeof(pixel_t)))) - return 0; - - // Copy the bits we need - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - for(dst = dstbuf, src = buffer+srcx, j = 0; j < cy; j++) - for(i = 0; i < cx; i++, src += srccx - cx) - *dst++ = *src++; - break; - case GDISP_ROTATE_90: - for(src = buffer+srcx, j = 0; j < cy; j++) { - dst = dstbuf+cy-j-1; - for(i = 0; i < cx; i++, src += srccx - cx, dst += cy) - *dst = *src++; - } - break; - case GDISP_ROTATE_180: - for(dst = dstbuf+sz, src = buffer+srcx, j = 0; j < cy; j++) - for(i = 0; i < cx; i++, src += srccx - cx) - *--dst = *src++; - break; - case GDISP_ROTATE_270: - for(src = buffer+srcx, j = 0; j < cy; j++) { - dst = dstbuf+sz-cy+j; - for(i = 0; i < cx; i++, src += srccx - cx, dst -= cy) - *dst = *src++; - } - break; - } - return dstbuf; - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] srcx, srcy The bitmap position to start the fill from - * @param[in] srccx The width of a line in the bitmap. - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - BITMAPV4HEADER bmpInfo; - RECT rect; - #if GDISP_NEED_CONTROL - pixel_t *srcimg; - #endif - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - // Clip pre orientation change - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } - if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - // Make everything relative to the start of the line - buffer += srccx*srcy; - srcy = 0; - - memset(&bmpInfo, 0, sizeof(bmpInfo)); - bmpInfo.bV4Size = sizeof(bmpInfo); - bmpInfo.bV4Planes = 1; - bmpInfo.bV4BitCount = 32; - bmpInfo.bV4AlphaMask = 0; - bmpInfo.bV4RedMask = RGB2COLOR(255,0,0); - bmpInfo.bV4GreenMask = RGB2COLOR(0,255,0); - bmpInfo.bV4BlueMask = RGB2COLOR(0,0,255); - bmpInfo.bV4V4Compression = BI_BITFIELDS; - bmpInfo.bV4XPelsPerMeter = 3078; - bmpInfo.bV4YPelsPerMeter = 3078; - bmpInfo.bV4ClrUsed = 0; - bmpInfo.bV4ClrImportant = 0; - bmpInfo.bV4CSType = 0; //LCS_sRGB; - - #if GDISP_NEED_CONTROL - bmpInfo.bV4SizeImage = (cy*cx) * sizeof(pixel_t); - srcimg = rotateimg(cx, cy, srcx, srccx, buffer); - if (!srcimg) return; - - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - bmpInfo.bV4Width = cx; - bmpInfo.bV4Height = -cy; /* top-down image */ - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - break; - case GDISP_ROTATE_90: - bmpInfo.bV4Width = cy; - bmpInfo.bV4Height = -cx; /* top-down image */ - rect.top = x; - rect.bottom = rect.top+cx; - rect.right = GDISP.Height - y; - rect.left = rect.right-cy; - break; - case GDISP_ROTATE_180: - bmpInfo.bV4Width = cx; - bmpInfo.bV4Height = -cy; /* top-down image */ - rect.bottom = GDISP.Height - y; - rect.top = rect.bottom-cy; - rect.right = GDISP.Width - x; - rect.left = rect.right-cx; - break; - case GDISP_ROTATE_270: - bmpInfo.bV4Width = cy; - bmpInfo.bV4Height = -cx; /* top-down image */ - rect.bottom = GDISP.Width - x; - rect.top = rect.bottom-cx; - rect.left = y; - rect.right = rect.left+cy; - break; - } - SetDIBitsToDevice(dcBuffer, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0, 0, 0, rect.bottom-rect.top, srcimg, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS); - if (srcimg != (pixel_t *)buffer) - free(srcimg); - - #else - bmpInfo.bV4Width = srccx; - bmpInfo.bV4Height = -cy; /* top-down image */ - bmpInfo.bV4SizeImage = (cy*srccx) * sizeof(pixel_t); - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - SetDIBitsToDevice(dcBuffer, x, y, cx, cy, srcx, 0, 0, cy, buffer, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS); - #endif - - // Invalidate the region to get it on the screen. - InvalidateRect(winRootWindow, &rect, FALSE); - UpdateWindow(winRootWindow); - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * @return The color of the specified pixel. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - color_t color; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - // Clip pre orientation change - if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; - #endif - - #if GDISP_NEED_CONTROL - switch(GDISP.Orientation) { - case GDISP_ROTATE_90: - t = GDISP.Height - 1 - y; - y = x; - x = t; - break; - case GDISP_ROTATE_180: - x = GDISP.Width - 1 - x; - y = GDISP.Height - 1 - y; - break; - case GDISP_ROTATE_270: - t = GDISP.Width - 1 - x; - x = y; - y = t; - break; - } - #endif - - color = GetPixel(dcBuffer, x, y); - return BGR2COLOR(color); - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - RECT rect, frect, srect; - HBRUSH hbr; - - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - // Clip pre orientation change - if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } - if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; - if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; - if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; - #endif - - if (lines > cy) lines = cy; - else if (-lines > cy) lines = -cy; - - bgcolor = COLOR2BGR(bgcolor); - hbr = CreateSolidBrush(bgcolor); - - #if GDISP_NEED_CONTROL - switch(GDISP.Orientation) { - case GDISP_ROTATE_0: - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - lines = -lines; - goto vertical_scroll; - case GDISP_ROTATE_90: - rect.top = x; - rect.bottom = rect.top+cx; - rect.right = GDISP.Height - y; - rect.left = rect.right-cy; - goto horizontal_scroll; - case GDISP_ROTATE_180: - rect.bottom = GDISP.Height - y; - rect.top = rect.bottom-cy; - rect.right = GDISP.Width - x; - rect.left = rect.right-cx; - vertical_scroll: - srect.left = frect.left = rect.left; - srect.right = frect.right = rect.right; - if (lines > 0) { - srect.top = frect.top = rect.top; - frect.bottom = rect.top+lines; - srect.bottom = rect.bottom-lines; - } else { - srect.bottom = frect.bottom = rect.bottom; - frect.top = rect.bottom+lines; - srect.top = rect.top-lines; - } - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); - break; - case GDISP_ROTATE_270: - rect.bottom = GDISP.Width - x; - rect.top = rect.bottom-cx; - rect.left = y; - rect.right = rect.left+cy; - lines = -lines; - horizontal_scroll: - srect.top = frect.top = rect.top; - srect.bottom = frect.bottom = rect.bottom; - if (lines > 0) { - srect.left = frect.left = rect.left; - frect.right = rect.left+lines; - srect.right = rect.right-lines; - } else { - srect.right = frect.right = rect.right; - frect.left = rect.right+lines; - srect.left = rect.left-lines; - } - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, lines, 0, &srect, 0, 0, 0); - break; - } - #else - rect.top = y; - rect.bottom = rect.top+cy; - rect.left = x; - rect.right = rect.left+cx; - lines = -lines; - srect.left = frect.left = rect.left; - srect.right = frect.right = rect.right; - if (lines > 0) { - srect.top = frect.top = rect.top; - frect.bottom = rect.top+lines; - srect.bottom = rect.bottom-lines; - } else { - srect.bottom = frect.bottom = rect.bottom; - frect.top = rect.bottom+lines; - srect.top = rect.top-lines; - } - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); - #endif - - if (hbr) - FillRect(dcBuffer, &frect, hbr); - InvalidateRect(winRootWindow, &rect, FALSE); - UpdateWindow(winRootWindow); - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case GDISP_ROTATE_0: - GDISP.Width = wWidth; - GDISP.Height = wHeight; - break; - case GDISP_ROTATE_90: - GDISP.Height = wWidth; - GDISP.Width = wHeight; - break; - case GDISP_ROTATE_180: - GDISP.Width = wWidth; - GDISP.Height = wHeight; - break; - case GDISP_ROTATE_270: - GDISP.Height = wWidth; - GDISP.Width = wHeight; - break; - default: - return; - } - - #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION - GDISP.clipx0 = 0; - GDISP.clipy0 = 0; - GDISP.clipx1 = GDISP.Width; - GDISP.clipy1 = GDISP.Height; - #endif - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_POWER: - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#if GINPUT_NEED_MOUSE - - void ginput_lld_mouse_init(void) {} - - void ginput_lld_mouse_get_reading(MouseReading *pt) { - pt->x = mousex; - pt->y = mousey > wHeight ? wHeight : mousey; - pt->z = (mousebuttons & GINPUT_MOUSE_BTN_LEFT) ? 100 : 0; - pt->buttons = mousebuttons; - } - -#endif /* GINPUT_NEED_MOUSE */ - -#if GINPUT_NEED_TOGGLE - - void ginput_lld_toggle_init(const GToggleConfig *ptc) { (void) ptc; } - unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { (void) ptc; return toggles; } - -#endif /* GINPUT_NEED_MOUSE */ - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/multiple/Win32/gdisp_lld.mk b/drivers/multiple/Win32/gdisp_lld.mk deleted file mode 100644 index b116088b..00000000 --- a/drivers/multiple/Win32/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/multiple/Win32/gdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/multiple/Win32 diff --git a/drivers/multiple/Win32/gdisp_lld_config.h b/drivers/multiple/Win32/gdisp_lld_config.h deleted file mode 100644 index bebd76b9..00000000 --- a/drivers/multiple/Win32/gdisp_lld_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS-GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/multiple/Win32/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for Win32. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "Win32" -#define GDISP_LLD(x) gdisp_lld_##x##_Win32 - -#define GDISP_HARDWARE_LINES TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/multiple/Win32/ginput_lld_mouse_config.h b/drivers/multiple/Win32/ginput_lld_mouse_config.h deleted file mode 100644 index ceeedcb9..00000000 --- a/drivers/multiple/Win32/ginput_lld_mouse_config.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file drivers/multiple/Win32/ginput_lld_mouse_config.h - * @brief GINPUT LLD header file for mouse/touch driver. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _LLD_GINPUT_MOUSE_CONFIG_H -#define _LLD_GINPUT_MOUSE_CONFIG_H - -// This driver supports being both a mouse or a touch device (we don't actually know which it really is) -// When operating in mouse mode a long left button click does not generate a context click. -// When operating in touch mode we allow sloppier clicks etc -#if 1 - #define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE - #define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click - #define GINPUT_MOUSE_NEED_CALIBRATION FALSE - #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE - #define GINPUT_MOUSE_READ_CYCLES 1 - #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1 - #define GINPUT_MOUSE_MAX_CLICK_JITTER 0 - #define GINPUT_MOUSE_MAX_MOVE_JITTER 0 -#else - #define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH - #define GINPUT_MOUSE_CLICK_TIME 700 // Long click = Context Click - #define GINPUT_MOUSE_NEED_CALIBRATION FALSE // Can be set to TRUE just for testing - #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE - #define GINPUT_MOUSE_READ_CYCLES 1 - #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 2 - #define GINPUT_MOUSE_MAX_CLICK_JITTER 2 - #define GINPUT_MOUSE_MAX_MOVE_JITTER 2 -#endif - -// This driver supports both an "interrupt" mode, and a polled mode -#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread -//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven - -#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ -/** @} */ - diff --git a/drivers/multiple/Win32/ginput_lld_toggle_config.h b/drivers/multiple/Win32/ginput_lld_toggle_config.h deleted file mode 100644 index 84ebaaa2..00000000 --- a/drivers/multiple/Win32/ginput_lld_toggle_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/multiple/Win32/ginput_lld_toggle_config.h - * @brief GINPUT Toggle Driver configuration header. - * - * @defgroup Toggle Toggle - * @ingroup GINPUT - * - * @{ - */ - -#ifndef _GINPUT_LLD_TOGGLE_CONFIG_H -#define _GINPUT_LLD_TOGGLE_CONFIG_H - -#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE - -#define GINPUT_TOGGLE_POLL_PERIOD TIME_INFINITE // We are interrupt driven (or polled - ether works here) -#define GINPUT_TOGGLE_NUM_PORTS 8 // The total number of toggle inputs -#define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries - -#define GINPUT_TOGGLE_SW1 0 // Switch 1 - Toggle -#define GINPUT_TOGGLE_SW2 1 // Switch 2 - Toggle -#define GINPUT_TOGGLE_SW3 2 // Switch 3 - Toggle -#define GINPUT_TOGGLE_SW4 3 // Switch 4 - Toggle - -#define GINPUT_TOGGLE_MOMENTARY1 4 // Switch 5 - Momentary -#define GINPUT_TOGGLE_MOMENTARY2 5 // Switch 6 - Momentary -#define GINPUT_TOGGLE_MOMENTARY3 6 // Switch 7 - Momentary -#define GINPUT_TOGGLE_MOMENTARY4 7 // Switch 8 - Momentary - -#endif /* GFX_USE_GDISP && GINPUT_NEED_TOGGLE */ - -#endif /* _GINPUT_LLD_TOGGLE_CONFIG_H */ -/** @} */ - diff --git a/drivers/multiple/Win32/readme.txt b/drivers/multiple/Win32/readme.txt deleted file mode 100644 index 6151f2f2..00000000 --- a/drivers/multiple/Win32/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -To use this driver: - -This driver is special in that it implements both the gdisp low level driver -and a touchscreen driver. - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) #define GFX_USE_GINPUT TRUE - #define GINPUT_USE_MOUSE TRUE - c) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - d) All of the following (with appropriate values): - #define GDISP_SCREEN_WIDTH 640 - #define GDISP_SCREEN_HEIGHT 480 - - -2. To your makefile add the following lines: - include $(GFXLIB)/gfx.mk - include $(GFXLIB)/drivers/multiple/Win32/gdisp_lld.mk - -3. Modify your makefile to add -lgdi32 to the DLIBS line. i.e. - DLIBS = -lws2_32 -lgdi32 - diff --git a/drivers/tdisp/HD44780/tdisp_lld.c b/drivers/tdisp/HD44780/tdisp_lld.c deleted file mode 100644 index d0f4af0d..00000000 --- a/drivers/tdisp/HD44780/tdisp_lld.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/tdisp/HD44780/tdisp_lld.c - * @brief TDISP driver subsystem low level driver source for the HD44780 display - * - * @addtogroup TDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/ - -#include "tdisp_lld_board_example.h" - -static void _writeData(uint8_t data) { - write_bus(data); - - setpin_e(TRUE); - chThdSleepMicroseconds(1); - setpin_e(FALSE); - chThdSleepMicroseconds(5); -} - -void tdisp_lld_write_cmd(uint8_t data) { - setpin_rs(FALSE); - setpin_rw(FALSE); - - #if TDISP_NEED_4BIT_MODE - _writeData(data>>4); - #endif - _writeData(data); -} - -void tdisp_lld_write_data(uint8_t data) { - setpin_rs(TRUE); - setpin_rw(FALSE); - - #if TDISP_NEED_4BIT_MODE - _writeData(data>>4); - #endif - _writeData(data); -} - -bool_t tdisp_lld_init(void) { - /* initialise MCU hardware */ - init_board(); - - /* wait some time */ - chThdSleepMilliseconds(50); - - tdisp_lld_write_cmd(0x38); - chThdSleepMilliseconds(64); - - tdisp_lld_write_cmd(0x0f); - chThdSleepMicroseconds(50); - - tdisp_lld_write_cmd(0x01); - chThdSleepMilliseconds(5); - - tdisp_lld_write_cmd(0x06); - chThdSleepMicroseconds(50); - - return TRUE; -} - -void tdisp_lld_set_cursor(coord_t col, coord_t row) { - uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - - if(row >= TDISP_ROWS) - row = TDISP_ROWS - 1; - - tdisp_lld_write_cmd(0x80 | (col + row_offsets[row])); -} - -void tdisp_lld_create_char(uint8_t address, char *charmap) { - uint8_t i; - - /* make sure we don't write somewhere we're not supposed to */ - address &= TDISP_MAX_CUSTOM_CHARS; - - tdisp_lld_write_cmd(0x40 | (address << 3)); - - for(i = 0; i < 8; i++) { - tdisp_lld_write_data(charmap[i]); - } -} - -void tdisp_lld_clear(void) { - tdisp_lld_write_cmd(0x01); -} - -void tdisp_lld_home(void) { - tdisp_lld_write_cmd(0x02); -} - -void tdisp_lld_control(uint16_t what, void *value) { - (void)what; - (void)value; -/* - switch(attributes) { - case TDISP_ON: - _displaycontrol |= 0x04; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - case TDISP_OFF: - _displaycontrol &=~ 0x04; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - case TDISP_CURSOR_ON: - _displaycontrol |= 0x02; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - case TDISP_CURSOR_OFF: - _displaycontrol &=~ 0x02; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - case TDISP_CURSOR_BLINK_ON: - _displaycontrol |= 0x00; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - case TDISP_CURSOR_BLINK_OFF: - _displaycontrol &=~ 0x00; - tdisp_lld_write_cmd(0x08 | _displaycontrol); - break; - } -*/ -} - -#endif /* GFX_USE_TDISP */ -/** @} */ - diff --git a/drivers/tdisp/HD44780/tdisp_lld.mk b/drivers/tdisp/HD44780/tdisp_lld.mk deleted file mode 100644 index 88780bea..00000000 --- a/drivers/tdisp/HD44780/tdisp_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/tdisp/HD44780/tdisp_lld.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/tdisp/HD44780 - diff --git a/drivers/tdisp/HD44780/tdisp_lld_board_example.h b/drivers/tdisp/HD44780/tdisp_lld_board_example.h deleted file mode 100644 index 3f5c47d7..00000000 --- a/drivers/tdisp/HD44780/tdisp_lld_board_example.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/tdisp/HD44780/tdisp_lld_board_example.h - * @brief TDISP driver subsystem board interface for the HD44780 display - * - * @addtogroup TDISP - * @{ - */ - -#ifndef _TDISP_LLD_BOARD_H -#define _TDISP_LLD_BOARD_H - -void init_board(void) { - palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); - palSetGroupMode(GPIOG, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); -} - -void setpin_e(bool_t state) { - if(state) - palSetPad(GPIOE, 2); - else - palClearPad(GPIOE, 2); -} - -void setpin_rs(bool_t state) { - if(state) - palSetPad(GPIOE, 0); - else - palClearPad(GPIOE, 0); -} - -void setpin_rw(bool_t state) { - if(state) - palSetPad(GPIOE, 1); - else - palClearPad(GPIOE, 1); -} - -void write_bus(uint8_t data) { - palWritePort(GPIOG, data); -} - -#endif /* _TDISP_LLD_BOARD_H */ -/** @} */ - diff --git a/drivers/tdisp/HD44780/tdisp_lld_config.h b/drivers/tdisp/HD44780/tdisp_lld_config.h deleted file mode 100644 index 3b37cd70..00000000 --- a/drivers/tdisp/HD44780/tdisp_lld_config.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/tdisp/HD44780/tdisp_lld_config.h - * @brief TDISP Driver subsystem low level driver header for the HD44780 display. - * - * @addtogroup TDISP - * @{ - */ - -#ifndef _TDISP_LLD_CONFIG_H -#define _TDISP_LLD_CONFIG_H - -#if GFX_USE_TDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define TDISP_DRIVER_NAME "HD44780" - -#define TDISP_MAX_CUSTOM_CHARS 0x07 - -#endif /* GFX_USE_TDISP */ - -#endif /* _TDISP_LLD_CONFIG_H */ -/** @} */ -- cgit v1.2.3 From 1bfc5a9f85e7c3296095105ca8e3ee1215b22be8 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 11 Feb 2013 09:25:45 +0100 Subject: removed GDISP_LLD() macro - fix --- drivers/gdisp/ILI9320/gdisp_lld.c | 570 +++++++++++ drivers/gdisp/ILI9320/gdisp_lld.mk | 5 + drivers/gdisp/ILI9320/gdisp_lld_board_example.h | 59 ++ .../ILI9320/gdisp_lld_board_olimex_stm32_lcd.h | 85 ++ drivers/gdisp/ILI9320/gdisp_lld_config.h | 54 ++ drivers/gdisp/ILI9320/readme.txt | 15 + drivers/gdisp/ILI9325/gdisp_lld.c | 580 +++++++++++ drivers/gdisp/ILI9325/gdisp_lld.mk | 5 + drivers/gdisp/ILI9325/gdisp_lld_board_example.h | 59 ++ .../gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h | 96 ++ drivers/gdisp/ILI9325/gdisp_lld_config.h | 54 ++ drivers/gdisp/ILI9325/readme.txt | 15 + drivers/gdisp/Nokia6610GE12/GE12.h | 81 ++ drivers/gdisp/Nokia6610GE12/gdisp_lld.c | 528 ++++++++++ drivers/gdisp/Nokia6610GE12/gdisp_lld.mk | 5 + .../gdisp/Nokia6610GE12/gdisp_lld_board_example.h | 135 +++ .../gdisp_lld_board_olimexsam7ex256.h | 196 ++++ drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h | 58 ++ drivers/gdisp/Nokia6610GE12/readme.txt | 15 + drivers/gdisp/Nokia6610GE8/GE8.h | 67 ++ drivers/gdisp/Nokia6610GE8/gdisp_lld.c | 483 +++++++++ drivers/gdisp/Nokia6610GE8/gdisp_lld.mk | 5 + .../gdisp/Nokia6610GE8/gdisp_lld_board_example.h | 135 +++ .../Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h | 196 ++++ drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h | 58 ++ drivers/gdisp/Nokia6610GE8/readme.txt | 15 + drivers/gdisp/S6D1121/gdisp_lld.c | 571 +++++++++++ drivers/gdisp/S6D1121/gdisp_lld.mk | 5 + drivers/gdisp/S6D1121/gdisp_lld_board_example.h | 125 +++ .../gdisp/S6D1121/gdisp_lld_board_olimex_e407.h | 94 ++ drivers/gdisp/S6D1121/gdisp_lld_config.h | 54 ++ drivers/gdisp/S6D1121/readme.txt | 9 + drivers/gdisp/SSD1289/gdisp_lld.c | 583 +++++++++++ drivers/gdisp/SSD1289/gdisp_lld.mk | 5 + drivers/gdisp/SSD1289/gdisp_lld_board_example.h | 125 +++ .../gdisp/SSD1289/gdisp_lld_board_example_fsmc.h | 164 ++++ .../SSD1289/gdisp_lld_board_firebullstm32f103.h | 157 +++ drivers/gdisp/SSD1289/gdisp_lld_config.h | 53 + drivers/gdisp/SSD1289/readme.txt | 19 + drivers/gdisp/SSD1963/gdisp_lld.c | 613 ++++++++++++ drivers/gdisp/SSD1963/gdisp_lld.mk | 5 + drivers/gdisp/SSD1963/gdisp_lld_config.h | 53 + drivers/gdisp/SSD1963/gdisp_lld_panel.h | 53 + drivers/gdisp/SSD1963/readme.txt | 38 + drivers/gdisp/SSD1963/ssd1963.h | 133 +++ drivers/gdisp/TestStub/gdisp_lld.c | 133 +++ drivers/gdisp/TestStub/gdisp_lld.mk | 5 + drivers/gdisp/TestStub/gdisp_lld_config.h | 51 + drivers/gdisp/TestStub/readme.txt | 16 + drivers/gdisp/VMT/gdisp_lld.c | 271 ++++++ drivers/gdisp/VMT/gdisp_lld.mk | 7 + drivers/gdisp/VMT/gdisp_lld_config.h | 71 ++ drivers/gdisp/VMT/gdisp_lld_driver1.c | 52 + drivers/gdisp/VMT/gdisp_lld_driver2.c | 52 + drivers/gdisp/VMT/readme.txt | 23 + drivers/ginput/toggle/Pal/ginput_lld.mk | 5 + drivers/ginput/toggle/Pal/ginput_lld_toggle.c | 63 ++ .../toggle/Pal/ginput_lld_toggle_board_example.h | 61 ++ .../Pal/ginput_lld_toggle_board_olimexsam7ex256.h | 57 ++ .../ginput/toggle/Pal/ginput_lld_toggle_config.h | 48 + drivers/ginput/toggle/Pal/readme.txt | 13 + drivers/ginput/touch/ADS7843/ginput_lld.mk | 5 + drivers/ginput/touch/ADS7843/ginput_lld_mouse.c | 144 +++ .../touch/ADS7843/ginput_lld_mouse_board_example.h | 88 ++ .../ginput_lld_mouse_board_firebull_stm32f103.h | 103 ++ .../ginput_lld_mouse_board_olimex_stm32_e407.h | 103 ++ .../ginput/touch/ADS7843/ginput_lld_mouse_config.h | 44 + drivers/ginput/touch/ADS7843/readme.txt | 9 + drivers/ginput/touch/MCU/ginput_lld.mk | 5 + drivers/ginput/touch/MCU/ginput_lld_mouse.c | 140 +++ .../touch/MCU/ginput_lld_mouse_board_example.h | 98 ++ .../MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h | 165 ++++ drivers/ginput/touch/MCU/ginput_lld_mouse_config.h | 44 + drivers/ginput/touch/MCU/readme.txt | 9 + drivers/multiple/Win32/gdisp_lld.c | 1026 ++++++++++++++++++++ drivers/multiple/Win32/gdisp_lld.mk | 5 + drivers/multiple/Win32/gdisp_lld_config.h | 54 ++ drivers/multiple/Win32/ginput_lld_mouse_config.h | 62 ++ drivers/multiple/Win32/ginput_lld_toggle_config.h | 54 ++ drivers/multiple/Win32/readme.txt | 22 + drivers/tdisp/HD44780/tdisp_lld.c | 153 +++ drivers/tdisp/HD44780/tdisp_lld.mk | 6 + drivers/tdisp/HD44780/tdisp_lld_board_example.h | 64 ++ drivers/tdisp/HD44780/tdisp_lld_config.h | 45 + 84 files changed, 9809 insertions(+) create mode 100644 drivers/gdisp/ILI9320/gdisp_lld.c create mode 100644 drivers/gdisp/ILI9320/gdisp_lld.mk create mode 100644 drivers/gdisp/ILI9320/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h create mode 100644 drivers/gdisp/ILI9320/gdisp_lld_config.h create mode 100644 drivers/gdisp/ILI9320/readme.txt create mode 100644 drivers/gdisp/ILI9325/gdisp_lld.c create mode 100644 drivers/gdisp/ILI9325/gdisp_lld.mk create mode 100644 drivers/gdisp/ILI9325/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h create mode 100644 drivers/gdisp/ILI9325/gdisp_lld_config.h create mode 100644 drivers/gdisp/ILI9325/readme.txt create mode 100644 drivers/gdisp/Nokia6610GE12/GE12.h create mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld.c create mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld.mk create mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h create mode 100644 drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h create mode 100644 drivers/gdisp/Nokia6610GE12/readme.txt create mode 100644 drivers/gdisp/Nokia6610GE8/GE8.h create mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld.c create mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld.mk create mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h create mode 100644 drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h create mode 100644 drivers/gdisp/Nokia6610GE8/readme.txt create mode 100644 drivers/gdisp/S6D1121/gdisp_lld.c create mode 100644 drivers/gdisp/S6D1121/gdisp_lld.mk create mode 100644 drivers/gdisp/S6D1121/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h create mode 100644 drivers/gdisp/S6D1121/gdisp_lld_config.h create mode 100644 drivers/gdisp/S6D1121/readme.txt create mode 100644 drivers/gdisp/SSD1289/gdisp_lld.c create mode 100644 drivers/gdisp/SSD1289/gdisp_lld.mk create mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h create mode 100644 drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h create mode 100644 drivers/gdisp/SSD1289/gdisp_lld_config.h create mode 100644 drivers/gdisp/SSD1289/readme.txt create mode 100644 drivers/gdisp/SSD1963/gdisp_lld.c create mode 100644 drivers/gdisp/SSD1963/gdisp_lld.mk create mode 100644 drivers/gdisp/SSD1963/gdisp_lld_config.h create mode 100644 drivers/gdisp/SSD1963/gdisp_lld_panel.h create mode 100644 drivers/gdisp/SSD1963/readme.txt create mode 100644 drivers/gdisp/SSD1963/ssd1963.h create mode 100644 drivers/gdisp/TestStub/gdisp_lld.c create mode 100644 drivers/gdisp/TestStub/gdisp_lld.mk create mode 100644 drivers/gdisp/TestStub/gdisp_lld_config.h create mode 100644 drivers/gdisp/TestStub/readme.txt create mode 100644 drivers/gdisp/VMT/gdisp_lld.c create mode 100644 drivers/gdisp/VMT/gdisp_lld.mk create mode 100644 drivers/gdisp/VMT/gdisp_lld_config.h create mode 100644 drivers/gdisp/VMT/gdisp_lld_driver1.c create mode 100644 drivers/gdisp/VMT/gdisp_lld_driver2.c create mode 100644 drivers/gdisp/VMT/readme.txt create mode 100644 drivers/ginput/toggle/Pal/ginput_lld.mk create mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle.c create mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h create mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h create mode 100644 drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h create mode 100644 drivers/ginput/toggle/Pal/readme.txt create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld.mk create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse.c create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h create mode 100644 drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h create mode 100644 drivers/ginput/touch/ADS7843/readme.txt create mode 100644 drivers/ginput/touch/MCU/ginput_lld.mk create mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse.c create mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h create mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h create mode 100644 drivers/ginput/touch/MCU/ginput_lld_mouse_config.h create mode 100644 drivers/ginput/touch/MCU/readme.txt create mode 100644 drivers/multiple/Win32/gdisp_lld.c create mode 100644 drivers/multiple/Win32/gdisp_lld.mk create mode 100644 drivers/multiple/Win32/gdisp_lld_config.h create mode 100644 drivers/multiple/Win32/ginput_lld_mouse_config.h create mode 100644 drivers/multiple/Win32/ginput_lld_toggle_config.h create mode 100644 drivers/multiple/Win32/readme.txt create mode 100644 drivers/tdisp/HD44780/tdisp_lld.c create mode 100644 drivers/tdisp/HD44780/tdisp_lld.mk create mode 100644 drivers/tdisp/HD44780/tdisp_lld_board_example.h create mode 100644 drivers/tdisp/HD44780/tdisp_lld_config.h (limited to 'drivers') diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c new file mode 100644 index 00000000..c4468b6d --- /dev/null +++ b/drivers/gdisp/ILI9320/gdisp_lld.c @@ -0,0 +1,570 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9320/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the ILI9320 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_OLIMEX_STM32_LCD) + #include "gdisp_lld_board_olimex_stm32_lcd.h" +#else + #include "gdisp_lld_board.h" +#endif + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/* This controller is only ever used with a 240 x 320 display */ +#if defined(GDISP_SCREEN_HEIGHT) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_HEIGHT +#endif +#if defined(GDISP_SCREEN_WIDTH) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_WIDTH +#endif + +#define GDISP_SCREEN_WIDTH 240 +#define GDISP_SCREEN_HEIGHT 320 + +#define GDISP_INITIAL_CONTRAST 50 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +uint32_t DISPLAY_CODE; + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ +static __inline void lld_lcdDelay(uint16_t us) { + chThdSleepMicroseconds(us); +} + +static __inline void lld_lcdWriteIndex(uint16_t index) { + GDISP_LLD(write_index)(index); +} + +static __inline void lld_lcdWriteData(uint16_t data) { + GDISP_LLD(write_data)(data); +} + +static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { + GDISP_LLD(write_index)(lcdReg); + GDISP_LLD(write_data)(lcdRegValue); +} + +static __inline uint16_t lld_lcdReadData(void) { + /* fix this! */ + //return GDISP_LLD(read_data); + return GDISP_RAM; +} + +static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + volatile uint16_t dummy; + + GDISP_LLD(write_index)(lcdReg); + dummy = lld_lcdReadData(); + (void)dummy; + + return lld_lcdReadData(); +} + +static __inline void lld_lcdWriteStreamStart(void) { + lld_lcdWriteIndex(0x0022); +} + +static __inline void lld_lcdWriteStreamStop(void) { + +} + +static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + + for(i = 0; i < size; i++) + lld_lcdWriteData(buffer[i]); +} + +static __inline void lld_lcdReadStreamStart(void) { + lld_lcdWriteIndex(0x0022); +} + +static __inline void lld_lcdReadStreamStop(void) { + +} + +static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { + uint16_t i; + volatile uint16_t dummy; + + dummy = lld_lcdReadData(); + (void)dummy; + + for(i = 0; i < size; i++) + buffer[i] = lld_lcdReadData(); +} + +bool_t lld_gdisp_init(void) { + /* Initialise your display */ + GDISP_LLD(init_board)(); + + /* Hardware reset */ + GDISP_LLD(setpin_reset)(TRUE); + lld_lcdDelay(1000); + GDISP_LLD(setpin_reset)(FALSE); + lld_lcdDelay(1000); + + DISPLAY_CODE = lld_lcdReadReg(0); + lld_lcdWriteReg(0x0000, 0x0001); //start Int. osc + lld_lcdDelay(500); + lld_lcdWriteReg(0x0001, 0x0100); //Set SS bit (shift direction of outputs is from S720 to S1) + lld_lcdWriteReg(0x0002, 0x0700); //select the line inversion + lld_lcdWriteReg(0x0003, 0x1038); //Entry mode(Horizontal : increment,Vertical : increment, AM=1) + lld_lcdWriteReg(0x0004, 0x0000); //Resize control(No resizing) + lld_lcdWriteReg(0x0008, 0x0202); //front and back porch 2 lines + lld_lcdWriteReg(0x0009, 0x0000); //select normal scan + lld_lcdWriteReg(0x000A, 0x0000); //display control 4 + lld_lcdWriteReg(0x000C, 0x0000); //system interface(2 transfer /pixel), internal sys clock, + lld_lcdWriteReg(0x000D, 0x0000); //Frame marker position + lld_lcdWriteReg(0x000F, 0x0000); //selects clk, enable and sync signal polarity, + lld_lcdWriteReg(0x0010, 0x0000); // + lld_lcdWriteReg(0x0011, 0x0000); //power control 2 reference voltages = 1:1, + lld_lcdWriteReg(0x0012, 0x0000); //power control 3 VRH + lld_lcdWriteReg(0x0013, 0x0000); //power control 4 VCOM amplitude + lld_lcdDelay(500); + lld_lcdWriteReg(0x0010, 0x17B0); //power control 1 BT,AP + lld_lcdWriteReg(0x0011, 0x0137); //power control 2 DC,VC + lld_lcdDelay(500); + lld_lcdWriteReg(0x0012, 0x0139); //power control 3 VRH + lld_lcdDelay(500); + lld_lcdWriteReg(0x0013, 0x1d00); //power control 4 vcom amplitude + lld_lcdWriteReg(0x0029, 0x0011); //power control 7 VCOMH + lld_lcdDelay(500); + lld_lcdWriteReg(0x0030, 0x0007); + lld_lcdWriteReg(0x0031, 0x0403); + lld_lcdWriteReg(0x0032, 0x0404); + lld_lcdWriteReg(0x0035, 0x0002); + lld_lcdWriteReg(0x0036, 0x0707); + lld_lcdWriteReg(0x0037, 0x0606); + lld_lcdWriteReg(0x0038, 0x0106); + lld_lcdWriteReg(0x0039, 0x0007); + lld_lcdWriteReg(0x003c, 0x0700); + lld_lcdWriteReg(0x003d, 0x0707); + lld_lcdWriteReg(0x0020, 0x0000); //starting Horizontal GRAM Address + lld_lcdWriteReg(0x0021, 0x0000); //starting Vertical GRAM Address + lld_lcdWriteReg(0x0050, 0x0000); //Horizontal GRAM Start Position + lld_lcdWriteReg(0x0051, 0x00EF); //Horizontal GRAM end Position + lld_lcdWriteReg(0x0052, 0x0000); //Vertical GRAM Start Position + lld_lcdWriteReg(0x0053, 0x013F); //Vertical GRAM end Position + switch (DISPLAY_CODE) { + case 0x9320: + lld_lcdWriteReg(0x0060, 0x2700); //starts scanning from G1, and 320 drive lines + break; + case 0x9325: + lld_lcdWriteReg(0x0060, 0xA700); //starts scanning from G1, and 320 drive lines + break; + } + + lld_lcdWriteReg(0x0061, 0x0001); //fixed base display + lld_lcdWriteReg(0x006a, 0x0000); //no scroll + lld_lcdWriteReg(0x0090, 0x0010); //set Clocks/Line =16, Internal Operation Clock Frequency=fosc/1, + lld_lcdWriteReg(0x0092, 0x0000); //set gate output non-overlap period=0 + lld_lcdWriteReg(0x0093, 0x0003); //set Source Output Position=3 + lld_lcdWriteReg(0x0095, 0x0110); //RGB interface(Clocks per line period=16 clocks) + lld_lcdWriteReg(0x0097, 0x0110); //set Gate Non-overlap Period 0 locksc + lld_lcdWriteReg(0x0098, 0x0110); // + lld_lcdWriteReg(0x0007, 0x0173); //display On + + // Turn on the backlight + GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; + GDISP.Contrast = GDISP_INITIAL_CONTRAST; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + + return TRUE; +} + +static void lld_lcdSetCursor(uint16_t x, uint16_t y) { + uint32_t addr; + + addr = y * 0x100 + x; + + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0020, addr & 0xff); /* low addr */ + lld_lcdWriteReg(0x0021, (addr >> 8) & 0x1ff); /* high addr */ + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0020, (addr >> 8) & 0x1ff); /* low addr */ + lld_lcdWriteReg(0x0021, addr & 0xff); /* high addr */ + break; + + case GDISP_ROTATE_180: + break; + + case GDISP_ROTATE_270: + break; + } +} + +static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0050, x); + lld_lcdWriteReg(0x0051, x + cx - 1); + lld_lcdWriteReg(0x0052, y); + lld_lcdWriteReg(0x0053, y + cy - 1); + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0050, y); + lld_lcdWriteReg(0x0051, y + cy - 1); + lld_lcdWriteReg(0x0052, x); + lld_lcdWriteReg(0x0053, x + cx - 1); + break; + + case GDISP_ROTATE_180: + break; + + case GDISP_ROTATE_270: + break; + + } + + lld_lcdSetCursor(x, y); +} + +static __inline void lld_lcdResetViewPort(void) { + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); + break; + } +} + +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + lld_lcdSetCursor(x, y); + lld_lcdWriteReg(0x0022, color); +} + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + void lld_gdisp_clear(color_t color) { + unsigned i; + + lld_lcdSetCursor(0, 0); + lld_lcdWriteStreamStart(); + + for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) + lld_lcdWriteData(color); + + lld_lcdWriteStreamStop(); + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + unsigned i, area; + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(color); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy; + unsigned lg; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + + endx = srcx + cx; + endy = y + cy; + lg = srccx - cx; + buffer += srcx + srcy * srccx; + for(; y < endy; y++, buffer += lg) + for(x=srcx; x < endx; x++) + lld_lcdWriteData(*buffer++); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + color_t color; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; + #endif + + lld_lcdSetCursor(x, y); + lld_lcdWriteStreamStart(); + + color = lld_lcdReadData(); + color = lld_lcdReadData(); + + lld_lcdWriteStreamStop(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + abslines = lines < 0 ? -lines : lines; + + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + lld_lcdSetViewPort(x, row0, cx, 1); + lld_lcdReadStreamStart(); + lld_lcdReadStream(buf, cx); + lld_lcdReadStreamStop(); + + lld_lcdSetViewPort(x, row1, cx, 1); + lld_lcdWriteStreamStart(); + lld_lcdWriteStream(buf, cx); + lld_lcdWriteStreamStop(); + } + } + + /* fill the remaining gap */ + lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); + lld_lcdWriteStreamStart(); + gap = cx*abslines; + for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + void lld_gdisp_control(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if(GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + lld_lcdWriteReg(0x0007, 0x0000); + lld_lcdWriteReg(0x0010, 0x0000); + lld_lcdWriteReg(0x0011, 0x0000); + lld_lcdWriteReg(0x0012, 0x0000); + lld_lcdWriteReg(0x0013, 0x0000); + GDISP_LLD(set_backlight)(0); + break; + + case powerOn: + //*************Power On sequence ******************// + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */ + lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ + GDISP_LLD(set_backlight)(GDISP.Backlight); + if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) + lld_gdisp_init(); + break; + + case powerSleep: + lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + GDISP_LLD(set_backlight)(0); + break; + + case powerDeepSleep: + lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + GDISP_LLD(set_backlight)(0); + break; + + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + + case GDISP_CONTROL_ORIENTATION: + if(GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0001, 0x0100); + lld_lcdWriteReg(0x0003, 0x1038); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0001, 0x0000); + lld_lcdWriteReg(0x0003, 0x1030); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + + case GDISP_ROTATE_180: + /* ToDo */ + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + + case GDISP_ROTATE_270: + /* ToDo */ + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + + default: + return; + } + + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; + + case GDISP_CONTROL_BACKLIGHT: + if((unsigned)value > 100) value = (void *)100; + GDISP_LLD(set_backlight)((unsigned)value); + GDISP.Backlight = (unsigned)value; + break; + + default: + return; + } + } + +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/ILI9320/gdisp_lld.mk b/drivers/gdisp/ILI9320/gdisp_lld.mk new file mode 100644 index 00000000..bcdd3230 --- /dev/null +++ b/drivers/gdisp/ILI9320/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/ILI9320 diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_example.h b/drivers/gdisp/ILI9320/gdisp_lld_board_example.h new file mode 100644 index 00000000..a79e557b --- /dev/null +++ b/drivers/gdisp/ILI9320/gdisp_lld_board_example.h @@ -0,0 +1,59 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9320/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the ILI9320 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_BOARD_H +#define GDISP_LLD_BOARD_H + +static __inline void GDISP_LLD(init_board)(void) { + #error "ILI9320: You must implement the init_board routine for your board" +} + +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + #error "ILI9320: You must implement setpin_reset routine for your board" +} + +static __inline void GDISP_LLD(write_index)(uint16_t data) { + #error "ILI9320: You must implement write_index routine for your board" +} + +static __inline void GDISP_LLD(write_data)(uint16_t data) { + #error "ILI9320: You must implement write_data routine for your board" +} + +static __inline uint16_t GDISP_LLD(read_data)(void) { + #error "ILI9320: You must implement read_data routine for your board" +} + +/* if not available, just ignore the argument and return */ +static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { + #error "ILI9320: You must implement set_backlight routine for your board" +} + +#endif /* GDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h new file mode 100644 index 00000000..a6d9d631 --- /dev/null +++ b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h @@ -0,0 +1,85 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h + * @brief GDISP Graphic Driver subsystem board interface for the ILI9320 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_BOARD_H +#define GDISP_LLD_BOARD_H + +#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ +#define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* RS = 1 */ + +static __inline void GDISP_LLD(init_board)(void) { + /* FSMC setup for F1 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + + /* set pin modes */ + IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0}; + IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0}; + palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); + + const unsigned char FSMC_Bank = 0; + + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); + + /* Bank1 NOR/SRAM control register configuration + * This is actually not needed as already set by default after reset */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; +} + +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + if(state) + palClearPad(GPIOE, GPIOE_TFT_RST); + else + palSetPad(GPIOE, GPIOE_TFT_RST); +} + +static __inline void GDISP_LLD(write_index)(uint16_t reg) { + GDISP_REG = reg; +} + +static __inline void GDISP_LLD(write_data)(uint16_t data) { + GDISP_RAM = data; +} + +static __inline uint16_t GDISP_LLD(read_data)(void) { + return GDISP_RAM; +} + +static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { + if(percent == 100) + palClearPad(GPIOD, GPIOD_TFT_LIGHT); + else + palSetPad(GPIOD, GPIOD_TFT_LIGHT); +} + +#endif /* GDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9320/gdisp_lld_config.h b/drivers/gdisp/ILI9320/gdisp_lld_config.h new file mode 100644 index 00000000..d55f2115 --- /dev/null +++ b/drivers/gdisp/ILI9320/gdisp_lld_config.h @@ -0,0 +1,54 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9320/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the ILI9320 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_CONFIG_H +#define GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "ILI9320" +#define GDISP_LLD(x) gdisp_lld_##x##_ILI9320 + +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS FALSE +#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9320/readme.txt b/drivers/gdisp/ILI9320/readme.txt new file mode 100644 index 00000000..dcffe206 --- /dev/null +++ b/drivers/gdisp/ILI9320/readme.txt @@ -0,0 +1,15 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + + d) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + Olimex STM32-LCD + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld.mk diff --git a/drivers/gdisp/ILI9325/gdisp_lld.c b/drivers/gdisp/ILI9325/gdisp_lld.c new file mode 100644 index 00000000..bc2b6dd5 --- /dev/null +++ b/drivers/gdisp/ILI9325/gdisp_lld.c @@ -0,0 +1,580 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9325/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the ILI9325 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_HY_STM32_100P) + #include "gdisp_lld_board_hy_stm32_100p.h" +#else + #include "gdisp_lld_board.h" +#endif + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/* This controller is only ever used with a 240 x 320 display */ +#if defined(GDISP_SCREEN_HEIGHT) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_HEIGHT +#endif +#if defined(GDISP_SCREEN_WIDTH) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_WIDTH +#endif + +#define GDISP_SCREEN_WIDTH 240 +#define GDISP_SCREEN_HEIGHT 320 + +#define GDISP_INITIAL_CONTRAST 50 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +uint32_t DISPLAY_CODE; + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ +static __inline void lld_lcdDelay(uint16_t us) { + chThdSleepMicroseconds(us); +} + +static __inline void lld_lcdWriteIndex(uint16_t index) { + GDISP_LLD(write_index)(index); +} + +static __inline void lld_lcdWriteData(uint16_t data) { + GDISP_LLD(write_data)(data); +} + +static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { + GDISP_LLD(write_index)(lcdReg); + GDISP_LLD(write_data)(lcdRegValue); +} + +static __inline uint16_t lld_lcdReadData(void) { + /* fix this! */ + //return GDISP_LLD(read_data); + return GDISP_RAM; +} + +static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + volatile uint16_t dummy; + + GDISP_LLD(write_index)(lcdReg); + dummy = lld_lcdReadData(); + (void)dummy; + + return lld_lcdReadData(); +} + +static __inline void lld_lcdWriteStreamStart(void) { + lld_lcdWriteIndex(0x0022); +} + +static __inline void lld_lcdWriteStreamStop(void) { + +} + +static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + + for(i = 0; i < size; i++) + lld_lcdWriteData(buffer[i]); +} + +static __inline void lld_lcdReadStreamStart(void) { + lld_lcdWriteIndex(0x0022); +} + +static __inline void lld_lcdReadStreamStop(void) { + +} + +static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { + uint16_t i; + volatile uint16_t dummy; + + dummy = lld_lcdReadData(); + (void)dummy; + + for(i = 0; i < size; i++) + buffer[i] = lld_lcdReadData(); +} + +bool_t lld_gdisp_init(void) { + /* Initialise your display */ + GDISP_LLD(init_board)(); + + /* Hardware reset */ + GDISP_LLD(setpin_reset)(TRUE); + lld_lcdDelay(1000); + GDISP_LLD(setpin_reset)(FALSE); + lld_lcdDelay(1000); + + // chinese code starts here + lld_lcdWriteReg(0x0000,0x0001); + lld_lcdDelay(10); + + lld_lcdWriteReg(0x0015,0x0030); + lld_lcdWriteReg(0x0011,0x0040); + lld_lcdWriteReg(0x0010,0x1628); + lld_lcdWriteReg(0x0012,0x0000); + lld_lcdWriteReg(0x0013,0x104d); + lld_lcdDelay(10); + lld_lcdWriteReg(0x0012,0x0010); + lld_lcdDelay(10); + lld_lcdWriteReg(0x0010,0x2620); + lld_lcdWriteReg(0x0013,0x344d); //304d + lld_lcdDelay(10); + + lld_lcdWriteReg(0x0001,0x0100); + lld_lcdWriteReg(0x0002,0x0300); + lld_lcdWriteReg(0x0003,0x1038);//0x1030 + lld_lcdWriteReg(0x0008,0x0604); + lld_lcdWriteReg(0x0009,0x0000); + lld_lcdWriteReg(0x000A,0x0008); + + lld_lcdWriteReg(0x0041,0x0002); + lld_lcdWriteReg(0x0060,0x2700); + lld_lcdWriteReg(0x0061,0x0001); + lld_lcdWriteReg(0x0090,0x0182); + lld_lcdWriteReg(0x0093,0x0001); + lld_lcdWriteReg(0x00a3,0x0010); + lld_lcdDelay(10); + + //################# void Gamma_Set(void) ####################// + lld_lcdWriteReg(0x30,0x0000); + lld_lcdWriteReg(0x31,0x0502); + lld_lcdWriteReg(0x32,0x0307); + lld_lcdWriteReg(0x33,0x0305); + lld_lcdWriteReg(0x34,0x0004); + lld_lcdWriteReg(0x35,0x0402); + lld_lcdWriteReg(0x36,0x0707); + lld_lcdWriteReg(0x37,0x0503); + lld_lcdWriteReg(0x38,0x1505); + lld_lcdWriteReg(0x39,0x1505); + lld_lcdDelay(10); + + //################## void Display_ON(void) ####################// + lld_lcdWriteReg(0x0007,0x0001); + lld_lcdDelay(10); + lld_lcdWriteReg(0x0007,0x0021); + lld_lcdWriteReg(0x0007,0x0023); + lld_lcdDelay(10); + lld_lcdWriteReg(0x0007,0x0033); + lld_lcdDelay(10); + lld_lcdWriteReg(0x0007,0x0133); + + // chinese code ends here + + // Turn on the backlight + GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; + GDISP.Contrast = GDISP_INITIAL_CONTRAST; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + + return TRUE; +} + +static void lld_lcdSetCursor(uint16_t x, uint16_t y) { + + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0020, x); + lld_lcdWriteReg(0x0021, y); + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0020, y); + lld_lcdWriteReg(0x0021, x); + break; + + case GDISP_ROTATE_180: + lld_lcdWriteReg(0x0020, x); + lld_lcdWriteReg(0x0021, y); + break; + + case GDISP_ROTATE_270: + lld_lcdWriteReg(0x0020, y); + lld_lcdWriteReg(0x0021, x); + break; + } +} + +static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0050, x); + lld_lcdWriteReg(0x0051, x + cx - 1); + lld_lcdWriteReg(0x0052, y); + lld_lcdWriteReg(0x0053, y + cy - 1); + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0050, y); + lld_lcdWriteReg(0x0051, y + cy - 1); + lld_lcdWriteReg(0x0052, x); + lld_lcdWriteReg(0x0053, x + cx - 1); + break; + + case GDISP_ROTATE_180: + lld_lcdWriteReg(0x0050, x); + lld_lcdWriteReg(0x0051, x + cx - 1); + lld_lcdWriteReg(0x0052, y); + lld_lcdWriteReg(0x0053, y + cy - 1); + break; + + case GDISP_ROTATE_270: + lld_lcdWriteReg(0x0050, y); + lld_lcdWriteReg(0x0051, y + cy - 1); + lld_lcdWriteReg(0x0052, x); + lld_lcdWriteReg(0x0053, x + cx - 1); + break; + + } + + lld_lcdSetCursor(x, y); +} + +static __inline void lld_lcdResetViewPort(void) { + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); + break; + } +} + +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + lld_lcdSetCursor(x, y); + lld_lcdWriteReg(0x0022, color); +} + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + void lld_gdisp_clear(color_t color) { + unsigned i; + + lld_lcdSetCursor(0, 0); + lld_lcdWriteStreamStart(); + + for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) + lld_lcdWriteData(color); + + lld_lcdWriteStreamStop(); + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + unsigned i, area; + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(color); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy; + unsigned lg; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + + endx = srcx + cx; + endy = y + cy; + lg = srccx - cx; + buffer += srcx + srcy * srccx; + for(; y < endy; y++, buffer += lg) + for(x=srcx; x < endx; x++) + lld_lcdWriteData(*buffer++); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + color_t color; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; + #endif + + lld_lcdSetCursor(x, y); + lld_lcdWriteStreamStart(); + + color = lld_lcdReadData(); + color = lld_lcdReadData(); + + lld_lcdWriteStreamStop(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + abslines = lines < 0 ? -lines : lines; + + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + lld_lcdSetViewPort(x, row0, cx, 1); + lld_lcdReadStreamStart(); + lld_lcdReadStream(buf, cx); + lld_lcdReadStreamStop(); + + lld_lcdSetViewPort(x, row1, cx, 1); + lld_lcdWriteStreamStart(); + lld_lcdWriteStream(buf, cx); + lld_lcdWriteStreamStop(); + } + } + + /* fill the remaining gap */ + lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); + lld_lcdWriteStreamStart(); + gap = cx*abslines; + for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + void lld_gdisp_control(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if(GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + lld_lcdWriteReg(0x0007, 0x0000); + lld_lcdWriteReg(0x0010, 0x0000); + lld_lcdWriteReg(0x0011, 0x0000); + lld_lcdWriteReg(0x0012, 0x0000); + lld_lcdWriteReg(0x0013, 0x0000); + GDISP_LLD(set_backlight)(0); + break; + + case powerOn: + //*************Power On sequence ******************// + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */ + lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ + lld_lcdDelay(500); + lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ + GDISP_LLD(set_backlight)(GDISP.Backlight); + if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) + lld_gdisp_init(); + break; + + case powerSleep: + lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + GDISP_LLD(set_backlight)(0); + break; + + case powerDeepSleep: + lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */ + lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ + lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */ + lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ + lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ + lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ + GDISP_LLD(set_backlight)(0); + break; + + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + + case GDISP_CONTROL_ORIENTATION: + if(GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0001, 0x0100); + lld_lcdWriteReg(0x0003, 0x1038); + lld_lcdWriteReg(0x0060, 0x2700); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0001, 0x0000); + lld_lcdWriteReg(0x0003, 0x1030); + lld_lcdWriteReg(0x0060, 0x2700); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + + case GDISP_ROTATE_180: + lld_lcdWriteReg(0x0001, 0x0000); + lld_lcdWriteReg(0x0003, 0x1038); + lld_lcdWriteReg(0x0060, 0xa700); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + + case GDISP_ROTATE_270: + lld_lcdWriteReg(0x0001, 0x0100); + lld_lcdWriteReg(0x0003, 0x1030); + lld_lcdWriteReg(0x0060, 0xA700); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + + default: + return; + } + + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; + + case GDISP_CONTROL_BACKLIGHT: + if((unsigned)value > 100) value = (void *)100; + GDISP_LLD(set_backlight)((unsigned)value); + GDISP.Backlight = (unsigned)value; + break; + + default: + return; + } + } + +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/ILI9325/gdisp_lld.mk b/drivers/gdisp/ILI9325/gdisp_lld.mk new file mode 100644 index 00000000..b5061324 --- /dev/null +++ b/drivers/gdisp/ILI9325/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/ILI9325 diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_example.h b/drivers/gdisp/ILI9325/gdisp_lld_board_example.h new file mode 100644 index 00000000..7b537dcd --- /dev/null +++ b/drivers/gdisp/ILI9325/gdisp_lld_board_example.h @@ -0,0 +1,59 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9325/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_BOARD_H +#define GDISP_LLD_BOARD_H + +static __inline void GDISP_LLD(init_board)(void) { + #error "ILI9325: You must implement the init_board routine for your board" +} + +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + #error "ILI9325: You must implement setpin_reset routine for your board" +} + +static __inline void GDISP_LLD(write_index)(uint16_t data) { + #error "ILI9325: You must implement write_index routine for your board" +} + +static __inline void GDISP_LLD(write_data)(uint16_t data) { + #error "ILI9325: You must implement write_data routine for your board" +} + +static __inline uint16_t GDISP_LLD(read_data)(void) { + #error "ILI9325: You must implement read_data routine for your board" +} + +/* if not available, just ignore the argument and return */ +static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { + #error "ILI9325: You must implement set_backlight routine for your board" +} + +#endif /* GDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h b/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h new file mode 100644 index 00000000..e785ad10 --- /dev/null +++ b/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h @@ -0,0 +1,96 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + driver quickly hacked together from a chinese sourcecode that came + with the board and existing ili9320 code by Chris van Dongen (sjaak) + (sjaak2002 at msn.com) + + Also added rotation for 180 and 270 degrees and minor tweaks to + setcursor + + Added code comes without warranty and free bugs. Feel free to use + or misuse the added code :D +*/ + + +/** + * @file drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h + * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_BOARD_H +#define GDISP_LLD_BOARD_H + +#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ +#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ + +static __inline void GDISP_LLD(init_board)(void) { + /* FSMC setup for F1 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + + /* set pin modes */ +/* IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0}; + IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0}; + palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); */ + + const unsigned char FSMC_Bank = 0; + + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); + + /* Bank1 NOR/SRAM control register configuration + * This is actually not needed as already set by default after reset */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + +} + +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + if(state) + palClearPad(GPIOE, GPIOE_TFT_RST); + else + palSetPad(GPIOE, GPIOE_TFT_RST); +} + +static __inline void GDISP_LLD(write_index)(uint16_t reg) { + GDISP_REG = reg; +} + +static __inline void GDISP_LLD(write_data)(uint16_t data) { + GDISP_RAM = data; +} + +static __inline uint16_t GDISP_LLD(read_data)(void) { + return GDISP_RAM; +} + +static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { + percent=percent; // avoid a warning +} + +#endif /* GDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9325/gdisp_lld_config.h b/drivers/gdisp/ILI9325/gdisp_lld_config.h new file mode 100644 index 00000000..44f8323f --- /dev/null +++ b/drivers/gdisp/ILI9325/gdisp_lld_config.h @@ -0,0 +1,54 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/ILI9325/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the ILI9325 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef GDISP_LLD_CONFIG_H +#define GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "ILI9325" +#define GDISP_LLD(x) gdisp_lld_##x##_ILI9325 + +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS FALSE +#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/gdisp/ILI9325/readme.txt b/drivers/gdisp/ILI9325/readme.txt new file mode 100644 index 00000000..9150610e --- /dev/null +++ b/drivers/gdisp/ILI9325/readme.txt @@ -0,0 +1,15 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + + d) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + HY_STM32_100p + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.mk diff --git a/drivers/gdisp/Nokia6610GE12/GE12.h b/drivers/gdisp/Nokia6610GE12/GE12.h new file mode 100644 index 00000000..6c980e2e --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/GE12.h @@ -0,0 +1,81 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GE12_H +#define GE12_H + +// ************************************************************************************* +// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver (GE12) +// +// Taken from Philips data sheet Feb 14, 2003 +// ************************************************************************************* + +// Philips PCF8833 LCD controller command codes +#define NOP 0x00 // nop +#define SWRESET 0x01 // software reset +#define BSTROFF 0x02 // booster voltage OFF +#define BSTRON 0x03 // booster voltage ON +#define RDDIDIF 0x04 // read display identification +#define RDDST 0x09 // read display status +#define SLEEPIN 0x10 // sleep in +#define SLEEPOUT 0x11 // sleep out +#define PTLON 0x12 // partial display mode +#define NORON 0x13 // display normal mode +#define INVOFF 0x20 // inversion OFF +#define INVON 0x21 // inversion ON +#define DALO 0x22 // all pixel OFF +#define DAL 0x23 // all pixel ON +#define SETCON 0x25 // write contrast +#define DISPOFF 0x28 // display OFF +#define DISPON 0x29 // display ON +#define CASET 0x2A // column address set +#define PASET 0x2B // page address set +#define RAMWR 0x2C // memory write +#define RGBSET 0x2D // colour set +#define PTLAR 0x30 // partial area +#define VSCRDEF 0x33 // vertical scrolling definition +#define TEOFF 0x34 // test mode +#define TEON 0x35 // test mode +#define MADCTL 0x36 // memory access control +#define SEP 0x37 // vertical scrolling start address +#define IDMOFF 0x38 // idle mode OFF +#define IDMON 0x39 // idle mode ON +#define COLMOD 0x3A // interface pixel format +#define SETVOP 0xB0 // set Vop +#define BRS 0xB4 // bottom row swap +#define TRS 0xB6 // top row swap +#define DISCTR 0xB9 // display control +#define DOR 0xBA // data order +#define TCDFE 0xBD // enable/disable DF temperature compensation +#define TCVOPE 0xBF // enable/disable Vop temp comp +#define EC 0xC0 // internal or external oscillator +#define SETMUL 0xC2 // set multiplication factor +#define TCVOPAB 0xC3 // set TCVOP slopes A and B +#define TCVOPCD 0xC4 // set TCVOP slopes c and d +#define TCDF 0xC5 // set divider frequency +#define DF8COLOR 0xC6 // set divider frequency 8-color mode +#define SETBS 0xC7 // set bias system +#define RDTEMP 0xC8 // temperature read back +#define NLI 0xC9 // n-line inversion +#define RDID1 0xDA // read ID1 +#define RDID2 0xDB // read ID2 +#define RDID3 0xDC // read ID3 + +#endif /* GE12_H */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld.c b/drivers/gdisp/Nokia6610GE12/gdisp_lld.c new file mode 100644 index 00000000..6ce7b581 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld.c @@ -0,0 +1,528 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE12/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 GE12 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/* Controller definitions */ +#include "GE12.h" + +/* This controller is only ever used with a 132 x 132 display */ +#if defined(GDISP_SCREEN_HEIGHT) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_HEIGHT +#endif +#if defined(GDISP_SCREEN_WIDTH) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_WIDTH +#endif +#define GDISP_SCREEN_HEIGHT 132 +#define GDISP_SCREEN_WIDTH 132 + +#define GDISP_INITIAL_CONTRAST 38 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_OLIMEX_SAM7_EX256) + #include "gdisp_lld_board_olimexsam7ex256.h" +#else + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#endif + +// Some macros just to make reading the code easier +#define delayms(ms) chThdSleepMilliseconds(ms) +#define write_data2(d1, d2) { write_data(d1); write_data(d2); } +#define write_data3(d1, d2, d3) { write_data(d1); write_data(d2); write_data(d3); } +#define write_cmd1(cmd, d1) { write_cmd(cmd); write_data(d1); } +#define write_cmd2(cmd, d1, d2) { write_cmd(cmd); write_data2(d1, d2); } +#define write_cmd3(cmd, d1, d2, d3) { write_cmd(cmd); write_data3(d1, d2, d3); } + +// A very common thing to do. +// An inline function has been used here incase the parameters have side effects with the internal calculations. +static __inline void setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { + write_cmd2(CASET, x, x+cx-1); // Column address set + write_cmd2(PASET, y, y+cy-1); // Page address set +} + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + /* Initialise your display */ + init_board(); + + // Hardware reset + setpin_reset(TRUE); + delayms(20); + setpin_reset(FALSE); + delayms(20); + + // Get the bus for the following initialisation commands + acquire_bus(); + + // UNTESTED + #if 1 + write_cmd(SLEEPOUT); // Sleep out + write_cmd(INVON); // Inversion on: seems to be required for this controller + write_cmd1(COLMOD, 0x03); // Color Interface Pixel Format - 0x03 = 12 bits-per-pixel + write_cmd1(MADCTL, 0xC8); // Memory access controler - 0xC0 = mirror x and y, reverse rgb + write_cmd1(SETCON, GDISP_INITIAL_CONTRAST); // Write contrast + delayms(20); + write_cmd(DISPON); // Display On + #else + // Alternative + write_cmd(SOFTRST); // Software Reset + delayms(20); + write_cmd(INITESC); // Initial escape + delayms(20); + write_cmd1(REFSET, 0x00); // Refresh set + write_cmd(DISPCTRL); // Set Display control - really 7 bytes of data + write_data(128); // Set the lenght of one selection term + write_data(128); // Set N inversion -> no N inversion + write_data(134); // Set frame frequence and bias rate -> 2 devision of frequency and 1/8 bias, 1/67 duty, 96x67 size + write_data(84); // Set duty parameter + write_data(69); // Set duty parameter + write_data(82); // Set duty parameter + write_data(67); // Set duty parameter + write_cmd(GRAYSCALE0); // Grey scale 0 position set - really 15 bytes of data + write_data(1); // GCP1 - gray lavel to be output when the RAM data is "0001" + write_data(2); // GCP2 - gray lavel to be output when the RAM data is "0010" + write_data(4); // GCP3 - gray lavel to be output when the RAM data is "0011" + write_data(8); // GCP4 - gray lavel to be output when the RAM data is "0100" + write_data(16); // GCP5 - gray lavel to be output when the RAM data is "0101" + write_data(30); // GCP6 - gray lavel to be output when the RAM data is "0110" + write_data(40); // GCP7 - gray lavel to be output when the RAM data is "0111" + write_data(50); // GCP8 - gray lavel to be output when the RAM data is "1000" + write_data(60); // GCP9 - gray lavel to be output when the RAM data is "1001" + write_data(70); // GCP10 - gray lavel to be output when the RAM data is "1010" + write_data(80); // GCP11 - gray lavel to be output when the RAM data is "1011" + write_data(90); // GCP12 - gray lavel to be output when the RAM data is "1100" + write_data(100); // GCP13 - gray lavel to be output when the RAM data is "1101" + write_data(110); // GCP14 - gray lavel to be output when the RAM data is "1110" + write_data(127); // GCP15 - gray lavel to be output when the RAM data is "1111" + write_cmd1(GAMMA, 0x01); // Gamma curve set - select gray scale - GRAYSCALE 0 or GREYSCALE 1 - Select grey scale 0 + write_cmd1(COMMONDRV, 0x00); // Command driver output - Set COM1-COM41 side come first, normal mod + write_cmd(NORMALMODE); // Set Normal mode (my) + // write_cmd(INVERSIONOFF); // Inversion off + write_cmd2(COLADDRSET, 0, 131); // Column address set + write_cmd2(PAGEADDRSET, 0, 131); // Page address set + write_cmd1(ACCESSCTRL, 0x40); // Memory access controler - 0x40 horizontal + // write_data(0x20); // vertical + write_cmd1(PWRCTRL, 0x04); // Power control - Internal resistance, V1OUT -> high power mode, oscilator devision rate + write_cmd(SLEEPOUT); // Sleep out + write_cmd(VOLTCTRL); // Voltage control - voltage control and write contrast define LCD electronic volume + // write_data(0x7f); // full voltage control + // write_data(0x03); // must be "1" + write_cmd1(CONTRAST, GDISP_INITIAL_CONTRAST); // Write contrast + delayms(20); + write_cmd(TEMPGRADIENT); // Temperature gradient - really 14 bytes of data + for(i=0; i<14; i++) + write_data(0); + write_cmd(BOOSTVON); // Booster voltage ON + write_cmd(DISPLAYON); // Finally - Display On + #endif + + // Release the bus + release_bus(); + + /* Turn on the back-light */ + set_backlight(GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure to match */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; + GDISP.Contrast = GDISP_INITIAL_CONTRAST; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + acquire_bus(); + setviewport(x, y, 1, 1); + write_cmd3(RAMWR, 0, (color>>8) & 0x0F, color & 0xFF); + release_bus(); +} + +/* ---- Optional Routines ---- */ + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + unsigned i, tuples; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. + // This extra pixel is ignored by the controller. + + acquire_bus(); + setviewport(x, y, cx, cy); + write_cmd(RAMWR); + for(i=0; i < tuples; i++) + write_data3(((color >> 4) & 0xFF), (((color << 4) & 0xF0)|((color >> 8) & 0x0F)), (color & 0xFF)); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy, lg; + color_t c1, c2; + #if GDISP_PACKED_PIXELS + coord_t pos; + const uint8_t *p; + #endif + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + /* What are our end points */ + endx = srcx + cx; + endy = y + cy; + + acquire_bus(); + setviewport(x, y, cx, cy); + write_cmd(RAMWR); + + #if !GDISP_PACKED_PIXELS + // Although this controller uses packed pixels we support unpacked pixel + // formats in this blit by packing the data as we feed it to the controller. + lg = srccx - cx; + buffer += srcy * srccx + srcx; + x = srcx; + while (1) { + /* Get a pixel */ + c1 = *buffer++; + if (++x >= endx) { + if (++y >= endy) { + /* Odd pixel at end */ + write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); + break; + } + x = srcx; + buffer += lg; + } + /* Get the next pixel */ + c2 = *buffer++; + write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); + if (++x >= endx) { + if (++y >= endy) + break; + x = srcx; + buffer += lg; + } + } + + #else + + // Although this controller uses packed pixels, we may have to feed it into + // the controller with different packing to the source bitmap + #if !GDISP_PACKED_LINES + srccx = (srccx + 1) & ~1; + #endif + pos = srcy*srccx; + lg = (srccx - cx)/2*3; + p = ((const uint8_t *)buffer) + ((pos+srcx)/2 * 3); + + x = srcx; + while (1) { + /* Get a pixel */ + switch((pos+x)&1) { + case 0: c1 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; + case 1: c1 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; + } + if (++x >= endx) { + if (++y >= endy) { + /* Odd pixel at end */ + write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); + break; + } + x = srcx; + p += lg; + pos += srccx; + } + /* Get the next pixel */ + switch((pos+x)&1) { + case 0: c2 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; + case 1: c2 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; + } + write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); + if (++x >= endx) { + if (++y >= endy) + break; + x = srcx; + p += lg; + pos += srccx; + } + } + #endif + release_bus(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) + /** + * @brief Get the color of a particular pixel. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + /* NOT IMPLEMENTED */ + /* Some board hardware might support this in the future. + * The Olimex board doesn't. + */ + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) + /** + * @brief Scroll vertically a section of the screen. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + /* NOT IMPLEMENTED */ + /* The hardware seems capable of doing this. + * It is just really complex so we leave it out for now. + */ + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @details Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + /* The hardware is capable of supporting... + * GDISP_CONTROL_POWER - not implemented yet + * GDISP_CONTROL_ORIENTATION - not implemented yet + * GDISP_CONTROL_BACKLIGHT - supported (the OlimexSAM7EX256 board.h currently only implements off/on although PWM is supported by the hardware) + * GDISP_CONTROL_CONTRAST - supported + */ + switch(what) { +#if 0 + // NOT IMPLEMENTED YET + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + // Code here + break; + case powerOn: + // Code here + /* You may need this --- + * if (GDISP.Powermode != powerSleep) + * lld_gdisp_init(); + */ + break; + case powerSleep: + /* Code here */ + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; +#endif +#if 0 + // NOT IMPLEMENTED YET + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) + // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + // Code here + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + // Code here + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + // Code here + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + // Code here + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +#endif + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)value > 100) value = (void *)100; + set_backlight((unsigned)value); + GDISP.Backlight = (unsigned)value; + return; + case GDISP_CONTROL_CONTRAST: + if ((unsigned)value > 100) value = (void *)100; + acquire_bus(); + write_cmd1(CONTRAST,(unsigned)value); + release_bus(); + GDISP.Contrast = (unsigned)value; + return; + } + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk b/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk new file mode 100644 index 00000000..575d52a3 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12 diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h new file mode 100644 index 00000000..1885f07c --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h @@ -0,0 +1,135 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 GE12 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for init_board for your board" +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for setpin_reset for your board" +} + +/** + * @brief Set the lcd back-light level. + * @note For now 0% turns the backlight off, anything else the backlight is on. + * While the hardware supports PWM backlight control, we are not using it + * yet. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for set_backlight for your board" +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for acquire_bus for your board" +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for release_bus for your board" +} + +/** + * @brief Send an 8 bit command to the lcd. + * + * @param[in] cmd The command to send + * + * @notapi + */ +static __inline void write_cmd(uint16_t cmd) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for write_cmd for your board" +} + +/** + * @brief Send an 8 bit data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for write_data for your board" +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { + /* Code here */ + #error "gdispNokia6610GE12: You must supply a definition for read_data for your board" +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h new file mode 100644 index 00000000..c161a9a3 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h @@ -0,0 +1,196 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_board_olimexsam7ex256.h + * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +// ****************************************************** +// Pointers to AT91SAM7X256 peripheral data structures +// ****************************************************** +volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; +volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; +volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; +volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; +volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void init_board(void) { + // ********************************************************************************************* + // InitSpi( ) + // + // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display + // + // I/O ports used: PA2 = LCD Reset (set to low to reset) + // PA12 = LCD chip select (set to low to select the LCD chip) + // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) + // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // PA18 = SPI0_SPCK Serial Clock (to LCD slave) + // PB20 = backlight control (normally PWM control, 1 = full on) + // + // *********************************************************************************************} + + /* This code should really use the ChibiOS driver for these functions */ + + // Pin for backlight + pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW + pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output + + // Reset pin + pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH + pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output + + // CS pin - this seems to be ignored + // pPIOA->PIO_SODR = 1<<12; // Set PA2 to HIGH + // pPIOA->PIO_OER = 1<<12; // Configure PA2 as output + + // Init SPI0 + // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) + // BIT12 = PA12 -> SPI0_NPCS0 chip select + // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) + // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) + pPIOA->PIO_PDR = (1<<12) | (1<<16) | (1<<17) | (1<<18); + pPIOA->PIO_ASR = (1<<12) | (1<<16) | (1<<17) | (1<<18); + pPIOA->PIO_BSR = 0; + + //enable the clock of SPI + pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; + + // Fixed mode + pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset + pSPI->SPI_CR = 0x01; //SPI Enable + + //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 + pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 + + //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz + pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + if (state) + palClearPad(IOPORT1, PIOA_LCD_RESET); + else + palSetPad(IOPORT1, PIOA_LCD_RESET); +} + +/** + * @brief Set the lcd back-light level. + * @note For now 0% turns the backlight off, anything else the backlight is on. + * While the hardware supports PWM backlight control, we are not using it + * yet. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + if (percent) + palSetPad(IOPORT2, PIOB_LCD_BL); + else + palClearPad(IOPORT2, PIOB_LCD_BL); +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Nothing to do for this board as the LCD is the only device on the SPI port */ +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + // Nothing to do for this board as the LCD is the only device on the SPI port +} + +/** + * @brief Send an 8 bit command to the lcd. + * + * @param[in] cmd The command to send + * + * @notapi + */ +static __inline void write_cmd(uint16_t cmd) { + // wait for the previous transfer to complete + while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); + // send the command + pSPI->SPI_TDR = cmd & 0xFF; +} + +/** + * @brief Send an 8 bit data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + // wait for the previous transfer to complete + while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); + // send the data + pSPI->SPI_TDR = data | 0x0100; +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * + * @notapi + */ +static __inline uint16_t read_data(void) { + #error "gdispNokia6610GE12: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" + return 0; +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h new file mode 100644 index 00000000..ab9d35e7 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h @@ -0,0 +1,58 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 GE12 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "Nokia6610GE12" +#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE12 + +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 +/* This driver supports both packed and unpacked pixel formats and line formats. + * By default we leave these as FALSE. + */ +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE12/readme.txt b/drivers/gdisp/Nokia6610GE12/readme.txt new file mode 100644 index 00000000..54c4570f --- /dev/null +++ b/drivers/gdisp/Nokia6610GE12/readme.txt @@ -0,0 +1,15 @@ +This driver is for the Nokia6610 Philips (GE12) controller + +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + Olimex SAM7-EX256 + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld.mk diff --git a/drivers/gdisp/Nokia6610GE8/GE8.h b/drivers/gdisp/Nokia6610GE8/GE8.h new file mode 100644 index 00000000..789308a9 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/GE8.h @@ -0,0 +1,67 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GE8_H +#define GE8_H + +// ***************************************************************************** +// Include file for Epson S1D15G00 LCD Controller (GE8) +// +// Author: James P Lynch August 30, 2007 +// Modified for GDISP: Andrew Hannam August 2, 2012 +// +// ***************************************************************************** + +#define DISON 0xAF // Display on +#define DISOFF 0xAE // Display off +#define DISNOR 0xA6 // Normal display +#define DISINV 0xA7 // Inverse display +#define COMSCN 0xBB // Common scan direction +#define DISCTL 0xCA // Display control +#define SLPIN 0x95 // Sleep in +#define SLPOUT 0x94 // Sleep out +#define PASET 0x75 // Page address set +#define CASET 0x15 // Column address set +#define DATCTL 0xBC // Data scan direction, etc. +#define RGBSET8 0xCE // 256-color position set +#define RAMWR 0x5C // Writing to memory +#define RAMRD 0x5D // Reading from memory +#define PTLIN 0xA8 // Partial display in +#define PTLOUT 0xA9 // Partial display out +#define RMWIN 0xE0 // Read and modify write +#define RMWOUT 0xEE // End +#define ASCSET 0xAA // Area scroll set +#define SCSTART 0xAB // Scroll start set +#define OSCON 0xD1 // Internal oscillation on +#define OSCOFF 0xD2 // Internal oscillation off +#define PWRCTR 0x20 // Power control +#define VOLCTR 0x81 // Electronic volume control +#define VOLUP 0xD6 // Increment electronic control by 1 +#define VOLDOWN 0xD7 // Decrement electronic control by 1 +#define TMPGRD 0x82 // Temperature gradient set +#define EPCTIN 0xCD // Control EEPROM +#define EPCOUT 0xCC // Cancel EEPROM control +#define EPMWR 0xFC // Write into EEPROM +#define EPMRD 0xFD // Read from EEPROM +#define EPSRRD1 0x7C // Read register 1 +#define EPSRRD2 0x7D // Read register 2 +#define NOP 0x25 // NOP instruction + +#endif /* GE8_H */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld.c b/drivers/gdisp/Nokia6610GE8/gdisp_lld.c new file mode 100644 index 00000000..006c964b --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld.c @@ -0,0 +1,483 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE8/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 GE8 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#include "GE8.h" + +/* This controller is only ever used with a 132 x 132 display */ +#if defined(GDISP_SCREEN_HEIGHT) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_HEIGHT +#endif +#if defined(GDISP_SCREEN_WIDTH) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_WIDTH +#endif +#define GDISP_SCREEN_HEIGHT 132 +#define GDISP_SCREEN_WIDTH 132 + +#define GDISP_INITIAL_CONTRAST 38 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_OLIMEX_SAM7_EX256) + #include "gdisp_lld_board_olimexsam7ex256.h" +#else + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#endif + +// Some macros just to make reading the code easier +#define delayms(ms) chThdSleepMilliseconds(ms) +#define write_data2(d1, d2) { write_data(d1); write_data(d2); } +#define write_data3(d1, d2, d3) { write_data(d1); write_data(d2); write_data(d3); } +#define write_cmd1(cmd, d1) { write_cmd(cmd); write_data(d1); } +#define write_cmd2(cmd, d1, d2) { write_cmd(cmd); write_data2(d1, d2); } +#define write_cmd3(cmd, d1, d2, d3) { write_cmd(cmd); write_data3(d1, d2, d3); } + +// A very common thing to do. +// An inline function has been used here incase the parameters have side effects with the internal calculations. +static __inline void setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { + write_cmd2(CASET, x, x+cx-1); // Column address set + write_cmd2(PASET, y, y+cy-1); // Page address set +} + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + /* Initialise your display */ + init_board(); + + // Hardware reset + setpin_reset(TRUE); + delayms(20); + setpin_reset(FALSE); + delayms(20); + + // Get the bus for the following initialisation commands + acquire_bus(); + + write_cmd3(DISCTL, 0x00, 0x20, 0x00); // Display control + // P1: 0x00 = 2 divisions, switching period=8 (default) + // P2: 0x20 = nlines/4 - 1 = 132/4 - 1 = 32) + // P3: 0x00 = no inversely highlighted lines + write_cmd1(COMSCN, 0x01); // COM scan P1: 0x01 = Scan 1->80, 160<-81 + write_cmd(OSCON); // Internal oscilator ON + write_cmd(SLPOUT); // Sleep out + write_cmd1(PWRCTR, 0x0F); // Power control - reference voltage regulator on, circuit voltage follower on, BOOST ON + write_cmd3(DATCTL, 0x48, 0x00, 0x02); // Data control + // P1: 0x01 = page address inverted, column address normal, address scan in column direction + // P2: 0x00 = RGB sequence (default value) + // P3: 0x02 = Grayscale -> 16 (selects 12-bit color, type A) + write_cmd2(VOLCTR, GDISP_INITIAL_CONTRAST, 0x03); // Voltage control (contrast setting) + // P1 = Contrast + // P2 = 3 resistance ratio (only value that works) + delayms(100); // allow power supply to stabilize + write_cmd(DISON); // Turn on the display + + // Release the bus + release_bus(); + + /* Turn on the back-light */ + set_backlight(GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure to match */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; + GDISP.Contrast = GDISP_INITIAL_CONTRAST; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + acquire_bus(); + setviewport(x, y, 1, 1); + write_cmd3(RAMWR, 0, (color>>8) & 0x0F, color & 0xFF); + release_bus(); +} + +/* ---- Optional Routines ---- */ + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + unsigned i, tuples; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. + // This extra pixel is ignored by the controller. + + acquire_bus(); + setviewport(x, y, cx, cy); + write_cmd(RAMWR); + for(i=0; i < tuples; i++) + write_data3(((color >> 4) & 0xFF), (((color << 4) & 0xF0)|((color >> 8) & 0x0F)), (color & 0xFF)); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy, lg; + color_t c1, c2; + #if GDISP_PACKED_PIXELS + coord_t pos; + const uint8_t *p; + #endif + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + /* What are our end points */ + endx = srcx + cx; + endy = y + cy; + + acquire_bus(); + setviewport(x, y, cx, cy); + write_cmd(RAMWR); + + #if !GDISP_PACKED_PIXELS + // Although this controller uses packed pixels we support unpacked pixel + // formats in this blit by packing the data as we feed it to the controller. + lg = srccx - cx; + buffer += srcy * srccx + srcx; + x = srcx; + while (1) { + /* Get a pixel */ + c1 = *buffer++; + if (++x >= endx) { + if (++y >= endy) { + /* Odd pixel at end */ + write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); + break; + } + x = srcx; + buffer += lg; + } + /* Get the next pixel */ + c2 = *buffer++; + write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); + if (++x >= endx) { + if (++y >= endy) + break; + x = srcx; + buffer += lg; + } + } + + #else + + // Although this controller uses packed pixels, we may have to feed it into + // the controller with different packing to the source bitmap + #if !GDISP_PACKED_LINES + srccx = (srccx + 1) & ~1; + #endif + pos = srcy*srccx; + lg = (srccx - cx)/2*3; + p = ((const uint8_t *)buffer) + ((pos+srcx)/2 * 3); + + x = srcx; + while (1) { + /* Get a pixel */ + switch((pos+x)&1) { + case 0: c1 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; + case 1: c1 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; + } + if (++x >= endx) { + if (++y >= endy) { + /* Odd pixel at end */ + write_data3(0, ((c1 >> 8) & 0x0F), (c1 & 0xFF)); + break; + } + x = srcx; + p += lg; + pos += srccx; + } + /* Get the next pixel */ + switch((pos+x)&1) { + case 0: c2 = (((color_t)p[0]) << 4)|(((color_t)p[1])>>4); break; + case 1: c2 = (((color_t)p[1]&0x0F) << 8)|((color_t)p[1]); break; + } + write_data3(((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); + if (++x >= endx) { + if (++y >= endy) + break; + x = srcx; + p += lg; + pos += srccx; + } + } + #endif + release_bus(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) + /** + * @brief Get the color of a particular pixel. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + /* NOT IMPLEMENTED */ + /* Some board hardware might support this in the future. + * The Olimex board doesn't. + */ + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) + /** + * @brief Scroll vertically a section of the screen. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + /* NOT IMPLEMENTED */ + /* The hardware seems capable of doing this. + * It is just really complex so we leave it out for now. + */ + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @details Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + /* The hardware is capable of supporting... + * GDISP_CONTROL_POWER - not implemented yet + * GDISP_CONTROL_ORIENTATION - not implemented yet + * GDISP_CONTROL_BACKLIGHT - supported (the OlimexSAM7EX256 board.h currently only implements off/on although PWM is supported by the hardware) + * GDISP_CONTROL_CONTRAST - supported + */ + switch(what) { +#if 0 + // NOT IMPLEMENTED YET + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + // Code here + break; + case powerOn: + // Code here + /* You may need this --- + * if (GDISP.Powermode != powerSleep) + * lld_gdisp_init(); + */ + break; + case powerSleep: + /* Code here */ + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; +#endif +#if 0 + // NOT IMPLEMENTED YET + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) + // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + // Code here + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + // Code here + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + // Code here + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + // Code here + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +#endif + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)value > 100) value = (void *)100; + set_backlight((unsigned)value); + GDISP.Backlight = (unsigned)value; + return; + case GDISP_CONTROL_CONTRAST: + if ((unsigned)value > 100) value = (void *)100; + acquire_bus(); + write_cmd2(VOLCTR, (unsigned)value, 0x03); + release_bus(); + GDISP.Contrast = (unsigned)value; + return; + } + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk b/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk new file mode 100644 index 00000000..3a1adec9 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8 diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h new file mode 100644 index 00000000..fd330590 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h @@ -0,0 +1,135 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 GE8 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for init_board for your board" +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for setpin_reset for your board" +} + +/** + * @brief Set the lcd back-light level. + * @note For now 0% turns the backlight off, anything else the backlight is on. + * While the hardware supports PWM backlight control, we are not using it + * yet. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for set_backlight for your board" +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for acquire_bus for your board" +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for release_bus for your board" +} + +/** + * @brief Send an 8 bit command to the lcd. + * + * @param[in] cmd The command to send + * + * @notapi + */ +static __inline void write_cmd(uint16_t cmd) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for write_cmd for your board" +} + +/** + * @brief Send an 8 bit data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for write_data for your board" +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { + /* Code here */ + #error "gdispNokia6610GE8: You must supply a definition for read_data for your board" +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h new file mode 100644 index 00000000..f3b32b3a --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h @@ -0,0 +1,196 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_board_olimexsam7ex256.h + * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +// ****************************************************** +// Pointers to AT91SAM7X256 peripheral data structures +// ****************************************************** +volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; +volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; +volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; +volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; +volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void init_board(void) { + // ********************************************************************************************* + // InitSpi( ) + // + // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display + // + // I/O ports used: PA2 = LCD Reset (set to low to reset) + // PA12 = LCD chip select (set to low to select the LCD chip) + // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) + // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // PA18 = SPI0_SPCK Serial Clock (to LCD slave) + // PB20 = backlight control (normally PWM control, 1 = full on) + // + // *********************************************************************************************} + + /* This code should really use the ChibiOS driver for these functions */ + + // Pin for backlight + pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW + pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output + + // Reset pin + pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH + pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output + + // CS pin - this seems to be ignored + // pPIOA->PIO_SODR = 1<<12; // Set PA2 to HIGH + // pPIOA->PIO_OER = 1<<12; // Configure PA2 as output + + // Init SPI0 + // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) + // BIT12 = PA12 -> SPI0_NPCS0 chip select + // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) + // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) + pPIOA->PIO_PDR = (1<<12) | (1<<16) | (1<<17) | (1<<18); + pPIOA->PIO_ASR = (1<<12) | (1<<16) | (1<<17) | (1<<18); + pPIOA->PIO_BSR = 0; + + //enable the clock of SPI + pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; + + // Fixed mode + pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset + pSPI->SPI_CR = 0x01; //SPI Enable + + //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 + pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 + + //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz + pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + if (state) + palClearPad(IOPORT1, PIOA_LCD_RESET); + else + palSetPad(IOPORT1, PIOA_LCD_RESET); +} + +/** + * @brief Set the lcd back-light level. + * @note For now 0% turns the backlight off, anything else the backlight is on. + * While the hardware supports PWM backlight control, we are not using it + * yet. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + if (percent) + palSetPad(IOPORT2, PIOB_LCD_BL); + else + palClearPad(IOPORT2, PIOB_LCD_BL); +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Nothing to do for this board as the LCD is the only device on the SPI port */ +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + // Nothing to do for this board as the LCD is the only device on the SPI port +} + +/** + * @brief Send an 8 bit command to the lcd. + * + * @param[in] cmd The command to send + * + * @notapi + */ +static __inline void write_cmd(uint16_t cmd) { + // wait for the previous transfer to complete + while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); + // send the command + pSPI->SPI_TDR = cmd & 0xFF; +} + +/** + * @brief Send an 8 bit data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + // wait for the previous transfer to complete + while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); + // send the data + pSPI->SPI_TDR = data | 0x0100; +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * + * @notapi + */ +static __inline uint16_t read_data(void) { + #error "gdispNokia6610GE8: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" + return 0; +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h new file mode 100644 index 00000000..87bdb824 --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h @@ -0,0 +1,58 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 GE8 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "Nokia6610GE8" +#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE8 + +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 +/* This driver supports both packed and unpacked pixel formats and line formats. + * By default we leave these as FALSE. + */ +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/Nokia6610GE8/readme.txt b/drivers/gdisp/Nokia6610GE8/readme.txt new file mode 100644 index 00000000..c8ad8faa --- /dev/null +++ b/drivers/gdisp/Nokia6610GE8/readme.txt @@ -0,0 +1,15 @@ +This driver is for the Nokia6610 Epson (GE8) controller + +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + Olimex SAM7-EX256 + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld.mk diff --git a/drivers/gdisp/S6D1121/gdisp_lld.c b/drivers/gdisp/S6D1121/gdisp_lld.c new file mode 100644 index 00000000..0d856c79 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld.c @@ -0,0 +1,571 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/S6D1121/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the S6d1121 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#if defined(GDISP_SCREEN_HEIGHT) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GISP_SCREEN_HEIGHT +#endif +#if defined(GDISP_SCREEN_WIDTH) + #warning "GDISP: This low level driver does not support setting a screen size. It is being ignored." + #undef GDISP_SCREEN_WIDTH +#endif + +#define GDISP_SCREEN_HEIGHT 320 +#define GDISP_SCREEN_WIDTH 240 + +#define GDISP_INITIAL_CONTRAST 50 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_OLIMEX_STM32_E407) + #include "gdisp_lld_board_olimex_e407.h" +#else + #include "gdisp_lld_board.h" +#endif + +/* Some common routines and macros */ +#define write_reg(reg, data) { write_index(reg); write_data(data); } +#define stream_start() write_index(0x0022); +#define stream_stop() +#define delay(us) chThdSleepMicroseconds(us) +#define delayms(ms) chThdSleepMilliseconds(ms) + +static __inline void set_cursor(coord_t x, coord_t y) { + /* R20h - 8 bit + * R21h - 9 bit + */ + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + write_reg(0x0020, x & 0x00FF); + write_reg(0x0021, y & 0x01FF); + break; + case GDISP_ROTATE_90: + /* Note X has already been mirrored, so we do it directly */ + write_reg(0x0020, y & 0x00FF); + write_reg(0x0021, x & 0x01FF); + break; + case GDISP_ROTATE_180: + write_reg(0x0020, (GDISP_SCREEN_WIDTH - 1 - x) & 0x00FF); + write_reg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - y) & 0x01FF); + break; + case GDISP_ROTATE_270: + write_reg(0x0020, (GDISP_SCREEN_WIDTH - 1 - y) & 0x00FF); + write_reg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - x) & 0x01FF); + break; + } +} + +static __inline void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { + /* HSA / HEA are 8 bit + * VSA / VEA are 9 bit + * use masks 0x00FF and 0x01FF to enforce this + */ + + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + write_reg(0x46, (((x + cx - 1) << 8) & 0xFF00 ) | + (x & 0x00FF)); + + write_reg(0x48, y & 0x01FF); + write_reg(0x47, (y + cy - 1) & 0x01FF); + break; + case GDISP_ROTATE_90: + write_reg(0x46, (((y + cy - 1) << 8) & 0xFF00) | + (y & 0x00FF)); + + write_reg(0x48, x & 0x01FF); + write_reg(0x47, (x + cx - 1) & 0x01FF); + break; + case GDISP_ROTATE_180: + write_reg(0x46, (((GDISP_SCREEN_WIDTH - x - 1) & 0x00FF) << 8) | + ((GDISP_SCREEN_WIDTH - (x + cx)) & 0x00FF)); + write_reg(0x48, (GDISP_SCREEN_HEIGHT - (y + cy)) & 0x01FF); + write_reg(0x47, (GDISP_SCREEN_HEIGHT- y - 1) & 0x01FF); + break; + case GDISP_ROTATE_270: + write_reg(0x46, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | + ((GDISP_SCREEN_WIDTH - (y + cy)) & 0x00FF)); + write_reg(0x48, (GDISP_SCREEN_HEIGHT - (x + cx)) & 0x01FF); + write_reg(0x47, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } + + set_cursor(x, y); +} + +static __inline void reset_viewport(void) { + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + set_viewport(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + set_viewport(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); + break; + } +} + +bool_t lld_gdisp_init(void) { + /* initialize the hardware */ + init_board(); + + /* Hardware reset */ + setpin_reset(TRUE); + delayms(20); + setpin_reset(TRUE); + delayms(20); + + /* Get the bus for the following initialisation commands */ + acquire_bus(); + + write_reg(0x11,0x2004); + write_reg(0x13,0xCC00); + write_reg(0x15,0x2600); + write_reg(0x14,0x252A); + write_reg(0x12,0x0033); + write_reg(0x13,0xCC04); + + delayms(1); + + write_reg(0x13,0xCC06); + + delayms(1); + + write_reg(0x13,0xCC4F); + + delayms(1); + + write_reg(0x13,0x674F); + write_reg(0x11,0x2003); + + delayms(1); + + // Gamma Setting + write_reg(0x30,0x2609); + write_reg(0x31,0x242C); + write_reg(0x32,0x1F23); + write_reg(0x33,0x2425); + write_reg(0x34,0x2226); + write_reg(0x35,0x2523); + write_reg(0x36,0x1C1A); + write_reg(0x37,0x131D); + write_reg(0x38,0x0B11); + write_reg(0x39,0x1210); + write_reg(0x3A,0x1315); + write_reg(0x3B,0x3619); + write_reg(0x3C,0x0D00); + write_reg(0x3D,0x000D); + + write_reg(0x16,0x0007); + write_reg(0x02,0x0013); + write_reg(0x03,0x0003); + write_reg(0x01,0x0127); + + delayms(1); + + write_reg(0x08,0x0303); + write_reg(0x0A,0x000B); + write_reg(0x0B,0x0003); + write_reg(0x0C,0x0000); + write_reg(0x41,0x0000); + write_reg(0x50,0x0000); + write_reg(0x60,0x0005); + write_reg(0x70,0x000B); + write_reg(0x71,0x0000); + write_reg(0x78,0x0000); + write_reg(0x7A,0x0000); + write_reg(0x79,0x0007); + write_reg(0x07,0x0051); + + delayms(1); + + write_reg(0x07,0x0053); + write_reg(0x79,0x0000); + + reset_viewport(); + set_backlight(GDISP_INITIAL_BACKLIGHT); + + /* Now initialise the GDISP structure */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + + acquire_bus(); + set_cursor(x, y); + write_reg(0x0022, color); + release_bus(); +} + +/* ---- Optional Routines ---- */ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void lld_gdisp_clear(color_t color) { + unsigned i; + + acquire_bus(); + set_cursor(0, 0); + stream_start(); + + for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) + write_data(color); + + stream_stop(); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + unsigned i, area; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + area = cx*cy; + acquire_bus(); + set_viewport(x, y, cx, cy); + stream_start(); + for(i = 0; i < area; i++) + write_data(color); + stream_stop(); + reset_viewport(); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy; + unsigned lg; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + acquire_bus(); + set_viewport(x, y, cx, cy); + stream_start(); + + endx = srcx + cx; + endy = y + cy; + lg = srccx - cx; + buffer += srcx + srcy * srccx; + for(; y < endy; y++, buffer += lg) + for(x=srcx; x < endx; x++) + write_data(*buffer++); + stream_stop(); + reset_viewport(); + release_bus(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + /* This routine is marked "DO NOT USE" in the original + * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL + * turned off for now. + */ + color_t color; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; + #endif + + aquire_bus(); + set_cursor(x, y); + stream_start(); + + color = lld_lcdReadData(); + color = lld_lcdReadData(); + + stream_stop(); + release_bus(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + /* This is marked as "TODO: Test this" in the original GLCD driver. + * For now we just leave the GDISP_HARDWARE_SCROLL off. + */ + static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + abslines = lines < 0 ? -lines : lines; + + acquire_bus(); + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + set_viewport(x, row0, cx, 1); + lld_lcdReadStreamStart(); + lld_lcdReadStream(buf, cx); + lld_lcdReadStreamStop(); + + set_viewport(x, row1, cx, 1); + stream_start(); + write_data(buf, cx); + stream_stop(); + } + } + + /* fill the remaining gap */ + set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); + stream_start(); + gap = cx*abslines; + for(i = 0; i < gap; i++) write_data(bgcolor); + stream_stop(); + reset_viewport(); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @details Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + /* Code here */ + /* break; */ + case powerOn: + /* Code here */ + /* You may need this --- + if (GDISP.Powermode != powerSleep) + GDISP_LLD(init(); + */ + /* break; */ + case powerSleep: + /* Code here */ + /* break; */ + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + write_reg(0x0001,0x0127); + write_reg(0x03, 0b0011); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + write_reg(0x0001,0x0027); + write_reg(0x0003, 0b1011); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + write_reg(0x0001,0x0127); + write_reg(0x0003, 0b0000); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + write_reg(0x0001,0x0027); + write_reg(0x0003, 0b1000); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/S6D1121/gdisp_lld.mk b/drivers/gdisp/S6D1121/gdisp_lld.mk new file mode 100644 index 00000000..38c23c43 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/S6D1121 diff --git a/drivers/gdisp/S6D1121/gdisp_lld_board_example.h b/drivers/gdisp/S6D1121/gdisp_lld_board_example.h new file mode 100644 index 00000000..2396b155 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld_board_example.h @@ -0,0 +1,125 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/S6D1121/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +/** + * @brief Initialise the board for the display. + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ +#error "SSD1289: You must supply a definition for init_board for your board" +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + /* Code here */ +#error "SSD1289: You must supply a definition for setpin_reset for your board" +} + +/** + * @brief Set the lcd back-light level. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + /* Code here */ +#error "SSD1289: You must supply a definition for set_backlight for your board" +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { +#error "SSD1289: You must supply a definition for acquire_bus for your board" +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { +#error "SSD1289: You must supply a definition for release_bus for your board" +} + +/** + * @brief Send data to the index register. + * + * @param[in] index The index register to set + * + * @notapi + */ +static __inline void write_index(uint16_t index) { + /* Code here */ +#error "SSD1289: You must supply a definition for write_index for your board" +} + +/** + * @brief Send data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + /* Code here */ +#error "SSD1289: You must supply a definition for write_data for your board" +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { + /* Code here */ +#error "SSD1289: You must supply a definition for read_data for your board" +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h b/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h new file mode 100644 index 00000000..34224425 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h @@ -0,0 +1,94 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.h + * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ +#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ + +static __inline void init_board(void) { + int FSMC_Bank = 0; + + /* STM32F4 FSMC init */ + rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); + + /* set pins to FSMC mode */ + IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | + (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; + + IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | + (1 << 13) | (1 << 14) | (1 << 15), 0}; + + palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); + palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); + + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); + + /* Bank1 NOR/SRAM control register configuration */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; +} + +static __inline void setpin_reset(bool_t state) { + (void)state; + + /* Nothing to do here */ +} + +static __inline void set_backlight(uint8_t percent) { + (void)percent; + + /* Nothing to do here */ +} + +static __inline void acquire_bus(void) { + /* Nothing to do here */ +} + +static __inline void release_bus(void) { + /* Nothing to do here */ +} + +static __inline void write_index(uint16_t index) { + GDISP_REG = index; +} + +static __inline void write_data(uint16_t data) { + GDISP_RAM = data; +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +static __inline uint16_t read_data(void) { + return GDISP_RAM; +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/gdisp/S6D1121/gdisp_lld_config.h b/drivers/gdisp/S6D1121/gdisp_lld_config.h new file mode 100644 index 00000000..c662d0e7 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld_config.h @@ -0,0 +1,54 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/S6D1121/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the S6D1121 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "S6D1121" +#define GDISP_LLD(x) gdisp_lld_##x##_S6D1121 + +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD FALSE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/gdisp/S6D1121/readme.txt b/drivers/gdisp/S6D1121/readme.txt new file mode 100644 index 00000000..b76b565f --- /dev/null +++ b/drivers/gdisp/S6D1121/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld.mk + diff --git a/drivers/gdisp/SSD1289/gdisp_lld.c b/drivers/gdisp/SSD1289/gdisp_lld.c new file mode 100644 index 00000000..96fb94e6 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld.c @@ -0,0 +1,583 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1289/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the SSD1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 320 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 240 +#endif + +#define GDISP_INITIAL_CONTRAST 50 +#define GDISP_INITIAL_BACKLIGHT 100 + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#if defined(GDISP_USE_CUSTOM_BOARD) && GDISP_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#elif defined(BOARD_FIREBULL_STM32_F103) + #include "gdisp_lld_board_firebullstm32f103.h" +#else + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#endif + +// Some common routines and macros +#define write_reg(reg, data) { write_index(reg); write_data(data); } +#define stream_start() write_index(0x0022); +#define stream_stop() +#define delay(us) chThdSleepMicroseconds(us) +#define delayms(ms) chThdSleepMilliseconds(ms) + +static __inline void set_cursor(coord_t x, coord_t y) { + /* Reg 0x004E is an 8 bit value + * Reg 0x004F is 9 bit + * Use a bit mask to make sure they are not set too high + */ + switch(GDISP.Orientation) { + case GDISP_ROTATE_180: + write_reg(0x004e, (GDISP_SCREEN_WIDTH-1-x) & 0x00FF); + write_reg(0x004f, (GDISP_SCREEN_HEIGHT-1-y) & 0x01FF); + break; + case GDISP_ROTATE_0: + write_reg(0x004e, x & 0x00FF); + write_reg(0x004f, y & 0x01FF); + break; + case GDISP_ROTATE_270: + write_reg(0x004e, y & 0x00FF); + write_reg(0x004f, x & 0x01FF); + break; + case GDISP_ROTATE_90: + write_reg(0x004e, (GDISP_SCREEN_WIDTH - y - 1) & 0x00FF); + write_reg(0x004f, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } +} + +static void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { + + set_cursor(x, y); + + /* Reg 0x44 - Horizontal RAM address position + * Upper Byte - HEA + * Lower Byte - HSA + * 0 <= HSA <= HEA <= 0xEF + * Reg 0x45,0x46 - Vertical RAM address position + * Lower 9 bits gives 0-511 range in each value + * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F + */ + + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); + write_reg(0x45, y & 0x01FF); + write_reg(0x46, (y+cy-1) & 0x01FF); + break; + case GDISP_ROTATE_270: + write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (y & 0x00FF)); + write_reg(0x45, x & 0x01FF); + write_reg(0x46, (x+cx-1) & 0x01FF); + break; + case GDISP_ROTATE_180: + write_reg(0x44, (((GDISP_SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (x+cx)) & 0x00FF)); + write_reg(0x45, (GDISP_SCREEN_HEIGHT-(y+cy)) & 0x01FF); + write_reg(0x46, (GDISP_SCREEN_HEIGHT-y-1) & 0x01FF); + break; + case GDISP_ROTATE_90: + write_reg(0x44, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (y+cy)) & 0x00FF)); + write_reg(0x45, (GDISP_SCREEN_HEIGHT - (x+cx)) & 0x01FF); + write_reg(0x46, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } + + set_cursor(x, y); +} + +static __inline void reset_viewport(void) { + set_viewport(0, 0, GDISP.Width, GDISP.Height); +} + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + /* Initialise your display */ + init_board(); + + // Hardware reset + setpin_reset(TRUE); + delayms(20); + setpin_reset(FALSE); + delayms(20); + + // Get the bus for the following initialisation commands + acquire_bus(); + + write_reg(0x0000,0x0001); delay(5); + write_reg(0x0003,0xA8A4); delay(5); + write_reg(0x000C,0x0000); delay(5); + write_reg(0x000D,0x080C); delay(5); + write_reg(0x000E,0x2B00); delay(5); + write_reg(0x001E,0x00B0); delay(5); + write_reg(0x0001,0x2B3F); delay(5); + write_reg(0x0002,0x0600); delay(5); + write_reg(0x0010,0x0000); delay(5); + write_reg(0x0011,0x6070); delay(5); + write_reg(0x0005,0x0000); delay(5); + write_reg(0x0006,0x0000); delay(5); + write_reg(0x0016,0xEF1C); delay(5); + write_reg(0x0017,0x0003); delay(5); + write_reg(0x0007,0x0133); delay(5); + write_reg(0x000B,0x0000); delay(5); + write_reg(0x000F,0x0000); delay(5); + write_reg(0x0041,0x0000); delay(5); + write_reg(0x0042,0x0000); delay(5); + write_reg(0x0048,0x0000); delay(5); + write_reg(0x0049,0x013F); delay(5); + write_reg(0x004A,0x0000); delay(5); + write_reg(0x004B,0x0000); delay(5); + write_reg(0x0044,0xEF00); delay(5); + write_reg(0x0045,0x0000); delay(5); + write_reg(0x0046,0x013F); delay(5); + write_reg(0x0030,0x0707); delay(5); + write_reg(0x0031,0x0204); delay(5); + write_reg(0x0032,0x0204); delay(5); + write_reg(0x0033,0x0502); delay(5); + write_reg(0x0034,0x0507); delay(5); + write_reg(0x0035,0x0204); delay(5); + write_reg(0x0036,0x0204); delay(5); + write_reg(0x0037,0x0502); delay(5); + write_reg(0x003A,0x0302); delay(5); + write_reg(0x003B,0x0302); delay(5); + write_reg(0x0023,0x0000); delay(5); + write_reg(0x0024,0x0000); delay(5); + write_reg(0x0025,0x8000); delay(5); + write_reg(0x004f,0x0000); delay(5); + write_reg(0x004e,0x0000); delay(5); + + // Release the bus + release_bus(); + + /* Turn on the back-light */ + set_backlight(GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = GDISP_INITIAL_BACKLIGHT; + GDISP.Contrast = GDISP_INITIAL_CONTRAST; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + + acquire_bus(); + set_cursor(x, y); + write_reg(0x0022, color); + release_bus(); +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If gfillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void lld_gdisp_clear(color_t color) { + unsigned i; + + acquire_bus(); + reset_viewport(); + set_cursor(0, 0); + stream_start(); + for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) + write_data(color); + stream_stop(); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + unsigned i, area; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + area = cx*cy; + + acquire_bus(); + set_viewport(x, y, cx, cy); + stream_start(); + for(i = 0; i < area; i++) + write_data(color); + stream_stop(); + release_bus(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + coord_t endx, endy; + unsigned lg; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + acquire_bus(); + set_viewport(x, y, cx, cy); + stream_start(); + + endx = srcx + cx; + endy = y + cy; + lg = srccx - cx; + buffer += srcx + srcy * srccx; + for(; y < endy; y++, buffer += lg) + for(x=srcx; x < endx; x++) + write_data(*buffer++); + stream_stop(); + release_bus(); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The pixel to be read + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + color_t color; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; + #endif + + acquire_bus(); + set_cursor(x, y); + stream_start(); + color = read_data(); // dummy read + color = read_data(); + stream_stop(); + release_bus(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines, j; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + abslines = lines < 0 ? -lines : lines; + + acquire_bus(); + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + set_viewport(x, row0, cx, 1); + stream_start(); + j = read_data(); // dummy read + for (j = 0; j < cx; j++) + buf[j] = read_data(); + stream_stop(); + + set_viewport(x, row1, cx, 1); + stream_start(); + for (j = 0; j < cx; j++) + write_data(buf[j]); + stream_stop(); + } + } + + /* fill the remaining gap */ + set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); + stream_start(); + gap = cx*abslines; + for(i = 0; i < gap; i++) write_data(bgcolor); + stream_stop(); + release_bus(); + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @details Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + acquire_bus(); + write_reg(0x0010, 0x0000); // leave sleep mode + write_reg(0x0007, 0x0000); // halt operation + write_reg(0x0000, 0x0000); // turn off oszillator + write_reg(0x0010, 0x0001); // enter sleepmode + release_bus(); + break; + case powerOn: + acquire_bus(); + write_reg(0x0010, 0x0000); // leave sleep mode + release_bus(); + if (GDISP.Powermode != powerSleep) + lld_gdisp_init(); + break; + case powerSleep: + acquire_bus(); + write_reg(0x0010, 0x0001); // enter sleep mode + release_bus(); + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + acquire_bus(); + write_reg(0x0001, 0x2B3F); + /* ID = 11 AM = 0 */ + write_reg(0x0011, 0x6070); + release_bus(); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + acquire_bus(); + write_reg(0x0001, 0x293F); + /* ID = 11 AM = 1 */ + write_reg(0x0011, 0x6078); + release_bus(); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + acquire_bus(); + write_reg(0x0001, 0x2B3F); + /* ID = 01 AM = 0 */ + write_reg(0x0011, 0x6040); + release_bus(); + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + acquire_bus(); + write_reg(0x0001, 0x293F); + /* ID = 01 AM = 1 */ + write_reg(0x0011, 0x6048); + release_bus(); + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld.mk b/drivers/gdisp/SSD1289/gdisp_lld.mk new file mode 100644 index 00000000..e340a7dc --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/SSD1289 diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example.h new file mode 100644 index 00000000..00c4b869 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_example.h @@ -0,0 +1,125 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1289/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +/** + * @brief Initialise the board for the display. + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ +#error "SSD1289: You must supply a definition for init_board for your board" +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + /* Code here */ +#error "SSD1289: You must supply a definition for setpin_reset for your board" +} + +/** + * @brief Set the lcd back-light level. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + /* Code here */ +#error "SSD1289: You must supply a definition for set_backlight for your board" +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { +#error "SSD1289: You must supply a definition for acquire_bus for your board" +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { +#error "SSD1289: You must supply a definition for release_bus for your board" +} + +/** + * @brief Send data to the index register. + * + * @param[in] index The index register to set + * + * @notapi + */ +static __inline void write_index(uint16_t index) { + /* Code here */ +#error "SSD1289: You must supply a definition for write_index for your board" +} + +/** + * @brief Send data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + /* Code here */ +#error "SSD1289: You must supply a definition for write_data for your board" +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { + /* Code here */ +#error "SSD1289: You must supply a definition for read_data for your board" +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h new file mode 100644 index 00000000..76a5c04c --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h @@ -0,0 +1,164 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h + * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +#define GDISP_REG ((volatile uint16_t *) 0x60000000)[0] /* RS = 0 */ +#define GDISP_RAM ((volatile uint16_t *) 0x60020000)[0] /* RS = 1 */ + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the io port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void init_board(void) { + const unsigned char FSMC_Bank; + + #if defined(STM32F1XX) || defined(STM32F3XX) + /* FSMC setup for F1/F3 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + + #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + #error "DMA not implemented for F1/F3 Devices" + #endif + #elif defined(STM32F4XX) || defined(STM32F2XX) + /* STM32F2-F4 FSMC init */ + rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); + + #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt(); + dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM); + dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); + #endif + #else + #error "FSMC not implemented for this device" + #endif + + /* set pins to FSMC mode */ + IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | + (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; + + IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | + (1 << 13) | (1 << 14) | (1 << 15), 0}; + + palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); + palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); + + FSMC_Bank = 0; + + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \ + | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \ + | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ; + + /* Bank1 NOR/SRAM control register configuration + * This is actually not needed as already set by default after reset */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + (void) state; + /* Nothing to do here */ +} + +/** + * @brief Set the lcd back-light level. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + (void) percent; + /* Nothing to do here */ +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Nothing to do here */ +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + /* Nothing to do here */ +} + +/** + * @brief Send data to the index register. + * + * @param[in] index The index register to set + * + * @notapi + */ +static __inline void write_index(uint16_t index) { GDISP_REG = index; } + +/** + * @brief Send data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { GDISP_RAM = data; } + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { return GDISP_RAM; } +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h b/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h new file mode 100644 index 00000000..9cff5a19 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h @@ -0,0 +1,157 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h + * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +#define SET_CS palSetPad(GPIOD, 12); +#define CLR_CS palClearPad(GPIOD, 12); +#define SET_RS palSetPad(GPIOD, 13); +#define CLR_RS palClearPad(GPIOD, 13); +#define SET_WR palSetPad(GPIOD, 14); +#define CLR_WR palClearPad(GPIOD, 14); +#define SET_RD palSetPad(GPIOD, 15); +#define CLR_RD palClearPad(GPIOD, 15); + +/** + * @brief Initialise the board for the display. + * @notes This board definition uses GPIO and assumes exclusive access to these GPIO pins + * + * @notapi + */ +static __inline void init_board(void) { + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 12, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 13, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 14, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 15, PAL_MODE_OUTPUT_PUSHPULL); + + // Configure the pins to a well know state + SET_RS; + SET_RD; + SET_WR; + CLR_CS; +} + + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void setpin_reset(bool_t state) { + (void) state; + /* Nothing to do here - reset pin tied to Vcc */ +} + +/** + * @brief Set the lcd back-light level. + * + * @param[in] percent 0 to 100% + * + * @notapi + */ +static __inline void set_backlight(uint8_t percent) { + (void) percent; + /* Nothing to do here - Backlight always on */ +} + +/** + * @brief Take exclusive control of the bus + * + * @notapi + */ +static __inline void acquire_bus(void) { + /* Nothing to do here since LCD is the only device on that bus */ +} + +/** + * @brief Release exclusive control of the bus + * + * @notapi + */ +static __inline void release_bus(void) { + /* Nothing to do here since LCD is the only device on that bus */ +} + +/** + * @brief Send data to the index register. + * + * @param[in] index The index register to set + * + * @notapi + */ +static __inline void write_index(uint16_t index) { + palWritePort(GPIOE, index); + CLR_RS; CLR_WR; SET_WR; SET_RS; +} + +/** + * @brief Send data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void write_data(uint16_t data) { + palWritePort(GPIOE, data); + CLR_WR; SET_WR; +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t read_data(void) { + uint16_t value; + + // change pin mode to digital input + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_INPUT); + + CLR_RD; + value = palReadPort(GPIOE); + value = palReadPort(GPIOE); + SET_RD; + + // change pin mode back to digital output + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); + + return value; +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/SSD1289/gdisp_lld_config.h b/drivers/gdisp/SSD1289/gdisp_lld_config.h new file mode 100644 index 00000000..dafbc90f --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_config.h @@ -0,0 +1,53 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1289/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the SSD1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "SSD1289" +#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289 + +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/SSD1289/readme.txt b/drivers/gdisp/SSD1289/readme.txt new file mode 100644 index 00000000..b160abbe --- /dev/null +++ b/drivers/gdisp/SSD1289/readme.txt @@ -0,0 +1,19 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + + c) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h or gdisp_lld_board_fsmc.h file as a basis. + Currently known boards are: + BOARD_FIREBULL_STM32_F103 - GPIO interface: requires GDISP_CMD_PORT and GDISP_DATA_PORT to be defined + + d) The following are optional - define them if you are not using the defaults below: + #define GDISP_SCREEN_WIDTH 320 + #define GDISP_SCREEN_HEIGHT 240 + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.mk diff --git a/drivers/gdisp/SSD1963/gdisp_lld.c b/drivers/gdisp/SSD1963/gdisp_lld.c new file mode 100644 index 00000000..0b676ebc --- /dev/null +++ b/drivers/gdisp/SSD1963/gdisp_lld.c @@ -0,0 +1,613 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1963/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 320 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 240 +#endif + +/* All the board specific code should go in these include file so the driver + * can be ported to another board just by creating a suitable file. + */ +//#if defined(BOARD_YOURBOARDNAME) +// #include "gdisp_lld_board_yourboardname.h" +//#else +// /* Include the user supplied board definitions */ +// #include "gdisp_lld_board.h" +//#endif + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +#include "ssd1963.h" + + +#if defined(GDISP_USE_FSMC) +__inline void GDISP_LLD(writeindex)(uint8_t cmd) { + GDISP_REG = cmd; +} + +__inline void GDISP_LLD(writereg)(uint16_t lcdReg,uint16_t lcdRegValue) { + GDISP_REG = lcdReg; + GDISP_RAM = lcdRegValue; +} + +__inline void GDISP_LLD(writedata)(uint16_t data) { + GDISP_RAM = data; +} + +__inline uint16_t GDISP_LLD(readdata)(void) { + return (GDISP_RAM); +} + +__inline uint8_t GDISP_LLD(readreg)(uint8_t lcdReg) { + GDISP_REG = lcdReg; + return (GDISP_RAM); +} + +__inline void GDISP_LLD(writestreamstart)(void) { + GDISP_LLD(writeindex)(SSD1963_WRITE_MEMORY_START); +} + +__inline void GDISP_LLD(readstreamstart)(void) { + GDISP_LLD(writeindex)(SSD1963_READ_MEMORY_START); +} + +__inline void GDISP_LLD(writestream)(uint16_t *buffer, uint16_t size) { + uint16_t i; + for(i = 0; i < size; i++) + GDISP_RAM = buffer[i]; +} + +__inline void GDISP_LLD(readstream)(uint16_t *buffer, size_t size) { + uint16_t i; + + for(i = 0; i < size; i++) { + buffer[i] = GDISP_RAM; + } +} + +#elif defined(GDISP_USE_GPIO) + +__inline void GDISP_LLD(writeindex)(uint8_t cmd) { + Set_CS; Set_RS; Set_WR; Clr_RD; + palWritePort(GDISP_DATA_PORT, cmd); + Clr_CS; +} + +__inline void GDISP_LLD(writereg)(uint16_t lcdReg,uint16_t lcdRegValue) { + Set_CS; Set_RS; Set_WR; Clr_RD; + palWritePort(GDISP_DATA_PORT, lcdReg); + Clr_RS; + palWritePort(GDISP_DATA_PORT, lcdRegValue); + Clr_CS; +} +__inline void GDISP_LLD(writedata)(uint16_t data) { + Set_CS; Clr_RS; Set_WR; Clr_RD; + palWritePort(GDISP_DATA_PORT, data); + Clr_CS; +} + +__inline uint16_t GDISP_LLD(readdata)(void) { + Set_CS; Clr_RS; Clr_WR; Set_RD; + uint16_t data = palReadPort(GDISP_DATA_PORT); + Clr_CS; + return data; +} + +__inline uint8_t GDISP_LLD(readreg)(uint8_t lcdReg) { + Set_CS; Set_RS; Clr_WR; Set_RD; + palWritePort(GDISP_DATA_PORT, lcdReg); + Clr_RS; + uint16_t data = palReadPort(GDISP_DATA_PORT); + Clr_CS; + return data; +} + +__inline void GDISP_LLD(writestreamstart)(void) { + GDISP_LLD(writeindex)(SSD1963_WRITE_MEMORY_START); +} + +__inline void GDISP_LLD(readstreamstart)(void) { + GDISP_LLD(writeindex)(SSD1963_READ_MEMORY_START); +} + +__inline void GDISP_LLD(writestream)(uint16_t *buffer, uint16_t size) { + uint16_t i; + Set_CS; Clr_RS; Set_WR; Clr_RD; + for(i = 0; i < size; i++) { + Set_WR; + palWritePort(GDISP_DATA_PORT, buffer[i]); + Clr_WR; + } + Clr_CS; +} + +__inline void GDISP_LLD(readstream)(uint16_t *buffer, size_t size) { + uint16_t i; + Set_CS; Clr_RS; Clr_WR; Set_RD; + for(i = 0; i < size; i++) { + Set_RD; + buffer[i] = palReadPort(GDISP_DATA_PORT); + Clr_RD; + } +} +#endif + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialisation. + * @return TRUE if successful, FALSE on error. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + /* Initialise the display */ + +#if defined(GDISP_USE_FSMC) + + #if defined(STM32F1XX) || defined(STM32F3XX) + /* FSMC setup for F1/F3 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + + #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + #error "DMA not implemented for F1/F3 Devices" + #endif + #elif defined(STM32F4XX) || defined(STM32F2XX) + /* STM32F2-F4 FSMC init */ + rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); + + #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt(); + dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM); + dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); + #endif + #else + #error "FSMC not implemented for this device" + #endif + + /* set pins to FSMC mode */ + IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | + (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; + + IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | + (1 << 13) | (1 << 14) | (1 << 15), 0}; + + palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); + palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); + + const unsigned char FSMC_Bank = 0; + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \ + | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \ + | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ; + + /* Bank1 NOR/SRAM control register configuration + * This is actually not needed as already set by default after reset */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + +#elif defined(GDISP_USE_GPIO) + IOBus busCMD = {GDISP_CMD_PORT, (1 << GDISP_CS) | (1 << GDISP_RS) | (1 << GDISP_WR) | (1 << GDISP_RD), 0}; + IOBus busDATA = {GDISP_CMD_PORT, 0xFFFFF, 0}; + palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL); + palSetBusMode(&busDATA, PAL_MODE_OUTPUT_PUSHPULL); + +#else + #error "Please define GDISP_USE_FSMC or GDISP_USE_GPIO" +#endif + GDISP_LLD(writeindex)(SSD1963_SOFT_RESET); + chThdSleepMicroseconds(100); + + /* Driver PLL config */ + GDISP_LLD(writeindex)(SSD1963_SET_PLL_MN); + GDISP_LLD(writedata)(35); // PLLclk = REFclk (10Mhz) * 36 (360Mhz) + GDISP_LLD(writedata)(2); // SYSclk = PLLclk / 3 (120MHz) + GDISP_LLD(writedata)(4); // Apply calculation bit, else it is ignored + + GDISP_LLD(writeindex)(SSD1963_SET_PLL); // Enable PLL + GDISP_LLD(writedata)(0x01); + chThdSleepMicroseconds(200); + + GDISP_LLD(writeindex)(SSD1963_SET_PLL); // Use PLL + GDISP_LLD(writedata)(0x03); + chThdSleepMicroseconds(200); + + GDISP_LLD(writeindex)(SSD1963_SOFT_RESET); + chThdSleepMicroseconds(100); + + /* Screen size */ + GDISP_LLD(writeindex)(SSD1963_SET_GDISP_MODE); +// GDISP_LLD(writedata)(0x0000); + GDISP_LLD(writedata)(0b00011000); //Enabled dithering + GDISP_LLD(writedata)(0x0000); + GDISP_LLD(writedata)(mHIGH((GDISP_SCREEN_WIDTH+1))); + GDISP_LLD(writedata)((GDISP_SCREEN_WIDTH+1)); + GDISP_LLD(writedata)(mHIGH((GDISP_SCREEN_HEIGHT+1))); + GDISP_LLD(writedata)((GDISP_SCREEN_HEIGHT+1)); + GDISP_LLD(writedata)(0x0000); + + GDISP_LLD(writeindex)(SSD1963_SET_PIXEL_DATA_INTERFACE); + GDISP_LLD(writedata)(SSD1963_PDI_16BIT565); + + /* LCD Clock specs */ + GDISP_LLD(writeindex)(SSD1963_SET_LSHIFT_FREQ); + GDISP_LLD(writedata)((GDISP_FPR >> 16) & 0xFF); + GDISP_LLD(writedata)((GDISP_FPR >> 8) & 0xFF); + GDISP_LLD(writedata)(GDISP_FPR & 0xFF); + + GDISP_LLD(writeindex)(SSD1963_SET_HORI_PERIOD); + GDISP_LLD(writedata)(mHIGH(SCREEN_HSYNC_PERIOD)); + GDISP_LLD(writedata)(mLOW(SCREEN_HSYNC_PERIOD)); + GDISP_LLD(writedata)(mHIGH((SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH))); + GDISP_LLD(writedata)(mLOW((SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH))); + GDISP_LLD(writedata)(SCREEN_HSYNC_PULSE); + GDISP_LLD(writedata)(0x00); + GDISP_LLD(writedata)(0x00); + GDISP_LLD(writedata)(0x00); + + GDISP_LLD(writeindex)(SSD1963_SET_VERT_PERIOD); + GDISP_LLD(writedata)(mHIGH(SCREEN_VSYNC_PERIOD)); + GDISP_LLD(writedata)(mLOW(SCREEN_VSYNC_PERIOD)); + GDISP_LLD(writedata)(mHIGH((SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH))); + GDISP_LLD(writedata)(mLOW((SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH))); + GDISP_LLD(writedata)(SCREEN_VSYNC_PULSE); + GDISP_LLD(writedata)(0x00); + GDISP_LLD(writedata)(0x00); + + /* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel */ + GDISP_LLD(writeindex)(SSD1963_SET_TEAR_ON); + GDISP_LLD(writedata)(0x0000); + + /* Turn on */ + GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_ON); + #if defined(GDISP_USE_FSMC) + /* FSMC delay reduced as the controller now runs at full speed */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_0 | FSMC_BTR1_DATAST_2 | FSMC_BTR1_BUSTURN_0 ; + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + #endif + + /* Initialise the GDISP structure to match */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + + return TRUE; +} + +void GDISP_LLD(setwindow)(coord_t x0, coord_t y0, coord_t x1, coord_t y1) { + /* We don't need to validate here as the LLD routines will validate first. + * + * #if GDISP_NEED_VALIDATION + * if (x0 >= GDISP.Width || y0 >= GDISP.Height || x0 < 0 || y0 < 0) return; + * else if (x1 >= GDISP.Width || y1 >= GDISP.Height || y1 < 0 || y2 < 0) return; + * #endif + */ + GDISP_LLD(writeindex)(SSD1963_SET_PAGE_ADDRESS); + GDISP_LLD(writedata)((y0 >> 8) & 0xFF); + GDISP_LLD(writedata)((y0 >> 0) & 0xFF); + GDISP_LLD(writedata)((y1 >> 8) & 0xFF); + GDISP_LLD(writedata)((y1 >> 0) & 0xFF); + GDISP_LLD(writeindex)(SSD1963_SET_COLUMN_ADDRESS); + GDISP_LLD(writedata)((x0 >> 8) & 0xFF); + GDISP_LLD(writedata)((x0 >> 0) & 0xFF); + GDISP_LLD(writedata)((x1 >> 8) & 0xFF); + GDISP_LLD(writedata)((x1 >> 0) & 0xFF); +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + + GDISP_LLD(setwindow)(x, y, x, y); + GDISP_LLD(writestreamstart)(); + GDISP_LLD(writedata)(color); +} + +/* ---- Optional Routines ---- */ + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + uint32_t area; + area = cx*cy; + + GDISP_LLD(setwindow)(x, y, x+cx-1, y+cy-1); + GDISP_LLD(writestreamstart)(); + + #if defined(GDISP_USE_FSMC) && defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + uint8_t i; + dmaStreamSetPeripheral(GDISP_DMA_STREAM, &color); + dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); + for (i = area/65535; i; i--) { + dmaStreamSetTransactionSize(GDISP_DMA_STREAM, 65535); + dmaStreamEnable(GDISP_DMA_STREAM); + dmaWaitCompletion(GDISP_DMA_STREAM); + } + dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area%65535); + dmaStreamEnable(GDISP_DMA_STREAM); + dmaWaitCompletion(GDISP_DMA_STREAM); + #else + uint32_t index; + for(index = 0; index < area; index++) + GDISP_LLD(writedata)(color); + #endif //#ifdef GDISP_USE_DMA +} +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + GDISP_LLD(setwindow)(x, y, x+cx-1, y+cy-1); + GDISP_LLD(writestreamstart)(); + + buffer += srcx + srcy * srccx; + + #if defined(GDISP_USE_FSMC) && defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) + uint32_t area = cx*cy; + uint8_t i; + dmaStreamSetPeripheral(GDISP_DMA_STREAM, buffer); + dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PINC | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); + for (i = area/65535; i; i--) { + dmaStreamSetTransactionSize(GDISP_DMA_STREAM, 65535); + dmaStreamEnable(GDISP_DMA_STREAM); + dmaWaitCompletion(GDISP_DMA_STREAM); + } + dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area%65535); + dmaStreamEnable(GDISP_DMA_STREAM); + dmaWaitCompletion(GDISP_DMA_STREAM); + #else + coord_t endx, endy; + unsigned lg; + endx = srcx + cx; + endy = y + cy; + lg = srccx - cx; + for(; y < endy; y++, buffer += lg) + for(x=srcx; x < endx; x++) + GDISP_LLD(writedata)(*buffer++); + #endif //#ifdef GDISP_USE_DMA + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + /* NOT IMPLEMENTED YET */ + + /* + uint16_t size = x1 - x0 ; + + lld_lcdWriteIndex(SSD1963_SET_SCROLL_AREA); + lld_lcdWriteData((x0 >> 8) & 0xFF); + lld_lcdWriteData((x0 >> 0) & 0xFF); + lld_lcdWriteData((size >> 8) & 0xFF); + lld_lcdWriteData((size >> 0) & 0xFF); + lld_lcdWriteData(((lcd_height-x1) >> 8) & 0xFF); + lld_lcdWriteData(((lcd_height-x1) >> 0) & 0xFF); + + lld_lcdWriteIndex(SSD1963_SET_SCROLL_START); + lld_lcdWriteData((lines >> 8) & 0xFF); + lld_lcdWriteData((lines >> 0) & 0xFF); + */ + } + +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @details Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + /* NOT IMPLEMENTED YET */ + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + GDISP_LLD(writeindex)(SSD1963_EXIT_SLEEP_MODE); // leave sleep mode + chThdSleepMicroseconds(5000); + GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_OFF); + GDISP_LLD(writeindex)(SSD1963_SET_DEEP_SLEEP); // enter deep sleep mode + break; + case powerOn: + GDISP_LLD(readreg)(0x0000); chThdSleepMicroseconds(5000); // 2x Dummy reads to wake up from deep sleep + GDISP_LLD(readreg)(0x0000); chThdSleepMicroseconds(5000); + if (GDISP.Powermode != powerSleep) + lld_gdisp_init(); + GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_ON); + + break; + case powerSleep: + GDISP_LLD(writeindex)(SSD1963_SET_DISPLAY_OFF); + GDISP_LLD(writeindex)(SSD1963_ENTER_SLEEP_MODE); // enter sleep mode + chThdSleepMicroseconds(5000); + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + /* Code here */ + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + /* Code here */ + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + /* Code here */ + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + /* Code here */ + GDISP.Height = GDISP_SCREEN_WIDTH; + GDISP.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/SSD1963/gdisp_lld.mk b/drivers/gdisp/SSD1963/gdisp_lld.mk new file mode 100644 index 00000000..7b967502 --- /dev/null +++ b/drivers/gdisp/SSD1963/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1963/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/SSD1963 diff --git a/drivers/gdisp/SSD1963/gdisp_lld_config.h b/drivers/gdisp/SSD1963/gdisp_lld_config.h new file mode 100644 index 00000000..34b4f72b --- /dev/null +++ b/drivers/gdisp/SSD1963/gdisp_lld_config.h @@ -0,0 +1,53 @@ +/* + ChibiOS/GFX Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/SSD1963/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "SSD1963" +#define GDISP_LLD(x) gdisp_lld_##x##_SSD1963 + +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +/* Maybe someday soon */ +#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_CONTROL FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/gdisp/SSD1963/gdisp_lld_panel.h b/drivers/gdisp/SSD1963/gdisp_lld_panel.h new file mode 100644 index 00000000..b4ed5c80 --- /dev/null +++ b/drivers/gdisp/SSD1963/gdisp_lld_panel.h @@ -0,0 +1,53 @@ +/* + ChibiOS/GFX Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file SSD1963/gdisp_lld_panel.h + * @brief TFT LCD panel properties. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_PANEL_H +#define _GDISP_LLD_PANEL_H + +/* LCD panel specs */ +#define GDISP_SCREEN_WIDTH 480 +#define GDISP_SCREEN_HEIGHT 272 + +#define SCREEN_FPS 60ULL + +#define SCREEN_HSYNC_BACK_PORCH 2LL +#define SCREEN_HSYNC_FRONT_PORCH 2ULL +#define SCREEN_HSYNC_PULSE 41ULL + +#define SCREEN_VSYNC_BACK_PORCH 2ULL +#define SCREEN_VSYNC_FRONT_PORCH 2ULL +#define SCREEN_VSYNC_PULSE 10ULL + +#define SCREEN_HSYNC_PERIOD (SCREEN_HSYNC_PULSE + SCREEN_HSYNC_BACK_PORCH + GDISP_SCREEN_WIDTH + SCREEN_HSYNC_FRONT_PORCH) +#define SCREEN_VSYNC_PERIOD (SCREEN_VSYNC_PULSE + SCREEN_VSYNC_BACK_PORCH + GDISP_SCREEN_HEIGHT + SCREEN_VSYNC_FRONT_PORCH) + +#define SCREEN_PCLK (SCREEN_HSYNC_PERIOD * SCREEN_VSYNC_PERIOD * SCREEN_FPS) +#define GDISP_FPR ((SCREEN_PCLK * 1048576)/100000000) + +#endif +/** @} */ diff --git a/drivers/gdisp/SSD1963/readme.txt b/drivers/gdisp/SSD1963/readme.txt new file mode 100644 index 00000000..567faf58 --- /dev/null +++ b/drivers/gdisp/SSD1963/readme.txt @@ -0,0 +1,38 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: #define GDISP_NEED_MULTITHREAD TRUE + c) One (only) of: + #define GDISP_USE_GPIO + #define GDISP_USE_FSMC + d) If you want to use DMA (only works with FSMC): + #define GDISP_USE_DMA + #define GDISP_DMA_STREAM STM32_DMA2_STREAM6 //You can change the DMA channel according to your needs + +2. Edit gdisp_lld_panel.h with your panel properties + +3. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/SSD1963/gdisp_lld.mk + + +Example FSMC config with DMA: + +#define GDISP_SCREEN_WIDTH 480 +#define GDISP_SCREEN_HEIGHT 272 + +#define GDISP_USE_FSMC + +#define GDISP_USE_DMA +#define GDISP_DMA_STREAM STM32_DMA2_STREAM6 + +#if defined(GDISP_USE_GPIO) + + #define GDISP_CMD_PORT GPIOC + #define GDISP_DATA_PORT GPIOD + + #define GDISP_CS 0 + #define GDISP_RS 1 + #define GDISP_WR 2 + #define GDISP_RD 3 +#endif diff --git a/drivers/gdisp/SSD1963/ssd1963.h b/drivers/gdisp/SSD1963/ssd1963.h new file mode 100644 index 00000000..1aa28382 --- /dev/null +++ b/drivers/gdisp/SSD1963/ssd1963.h @@ -0,0 +1,133 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef SSD1963_H +#define SSD1963_H + +#include "gdisp_lld_panel.h" + +#if defined(GDISP_USE_GPIO) + #define Set_CS palSetPad(GDISP_CMD_PORT, GDISP_CS); + #define Clr_CS palClearPad(GDISP_CMD_PORT, GDISP_CS); + #define Set_RS palSetPad(GDISP_CMD_PORT, GDISP_RS); + #define Clr_RS palClearPad(GDISP_CMD_PORT, GDISP_RS); + #define Set_WR palSetPad(GDISP_CMD_PORT, GDISP_WR); + #define Clr_WR palClearPad(GDISP_CMD_PORT, GDISP_WR); + #define Set_RD palSetPad(GDISP_CMD_PORT, GDISP_RD); + #define Clr_RD palClearPad(GDISP_CMD_PORT, GDISP_RD); +#endif + +#if defined(GDISP_USE_FSMC) + /* Using FSMC A16 as RS */ + #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ + #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ +#endif + +#define mHIGH(x) (x >> 8) +#define mLOW(x) (x & 0xFF) + +/* SSD1963 commands */ + +#define SSD1963_NOP 0x0000 +#define SSD1963_SOFT_RESET 0x0001 +#define SSD1963_GET_POWER_MODE 0x000A +#define SSD1963_GET_ADDRESS_MODE 0x000B +#define SSD1963_GET_DISPLAY_MODE 0x000D +#define SSD1963_GET_TEAR_EFFECT_STATUS 0x000E +#define SSD1963_ENTER_SLEEP_MODE 0x0010 +#define SSD1963_EXIT_SLEEP_MODE 0x0011 +#define SSD1963_ENTER_PARTIAL_MODE 0x0012 +#define SSD1963_ENTER_NORMAL_MODE 0x0013 +#define SSD1963_EXIT_INVERT_MODE 0x0020 +#define SSD1963_ENTER_INVERT_MODE 0x0021 +#define SSD1963_SET_GAMMA_CURVE 0x0026 +#define SSD1963_SET_DISPLAY_OFF 0x0028 +#define SSD1963_SET_DISPLAY_ON 0x0029 +#define SSD1963_SET_COLUMN_ADDRESS 0x002A +#define SSD1963_SET_PAGE_ADDRESS 0x002B +#define SSD1963_WRITE_MEMORY_START 0x002C +#define SSD1963_READ_MEMORY_START 0x002E +#define SSD1963_SET_PARTIAL_AREA 0x0030 +#define SSD1963_SET_SCROLL_AREA 0x0033 +#define SSD1963_SET_TEAR_OFF 0x0034 +#define SSD1963_SET_TEAR_ON 0x0035 +#define SSD1963_SET_ADDRESS_MODE 0x0036 +#define SSD1963_SET_SCROLL_START 0x0037 +#define SSD1963_EXIT_IDLE_MODE 0x0038 +#define SSD1963_ENTER_IDLE_MODE 0x0039 +#define SSD1963_SET_PIXEL_FORMAT 0x003A +#define SSD1963_WRITE_MEMORY_CONTINUE 0x003C +#define SSD1963_READ_MEMORY_CONTINUE 0x003E +#define SSD1963_SET_TEAR_SCANLINE 0x0044 +#define SSD1963_GET_SCANLINE 0x0045 +#define SSD1963_READ_DDB 0x00A1 +#define SSD1963_SET_GDISP_MODE 0x00B0 +#define SSD1963_GET_GDISP_MODE 0x00B1 +#define SSD1963_SET_HORI_PERIOD 0x00B4 +#define SSD1963_GET_HORI_PERIOD 0x00B5 +#define SSD1963_SET_VERT_PERIOD 0x00B6 +#define SSD1963_GET_VERT_PERIOD 0x00B7 +#define SSD1963_SET_GPIO_CONF 0x00B8 +#define SSD1963_GET_GPIO_CONF 0x00B9 +#define SSD1963_SET_GPIO_VALUE 0x00BA +#define SSD1963_GET_GPIO_STATUS 0x00BB +#define SSD1963_SET_POST_PROC 0x00BC +#define SSD1963_GET_POST_PROC 0x00BD +#define SSD1963_SET_PWM_CONF 0x00BE +#define SSD1963_GET_PWM_CONF 0x00BF +#define SSD1963_GET_GDISP_GEN0 0x00C0 +#define SSD1963_SET_GDISP_GEN0 0x00C1 +#define SSD1963_GET_GDISP_GEN1 0x00C2 +#define SSD1963_SET_GDISP_GEN1 0x00C3 +#define SSD1963_GET_GDISP_GEN2 0x00C4 +#define SSD1963_SET_GDISP_GEN2 0x00C5 +#define SSD1963_GET_GDISP_GEN3 0x00C6 +#define SSD1963_SET_GDISP_GEN3 0x00C7 +#define SSD1963_SET_GPIO0_ROP 0x00C8 +#define SSD1963_GET_GPIO0_ROP 0x00C9 +#define SSD1963_SET_GPIO1_ROP 0x00CA +#define SSD1963_GET_GPIO1_ROP 0x00CB +#define SSD1963_SET_GPIO2_ROP 0x00CC +#define SSD1963_GET_GPIO2_ROP 0x00CD +#define SSD1963_SET_GPIO3_ROP 0x00CE +#define SSD1963_GET_GPIO3_ROP 0x00CF +#define SSD1963_SET_DBC_CONF 0x00D0 +#define SSD1963_GET_DBC_CONF 0x00D1 +#define SSD1963_SET_DBC_TH 0x00D4 +#define SSD1963_GET_DBC_TH 0x00D5 +#define SSD1963_SET_PLL 0x00E0 +#define SSD1963_SET_PLL_MN 0x00E2 +#define SSD1963_GET_PLL_MN 0x00E3 +#define SSD1963_GET_PLL_STATUS 0x00E4 +#define SSD1963_SET_DEEP_SLEEP 0x00E5 +#define SSD1963_SET_LSHIFT_FREQ 0x00E6 +#define SSD1963_GET_LSHIFT_FREQ 0x00E7 +#define SSD1963_SET_PIXEL_DATA_INTERFACE 0x00F0 + #define SSD1963_PDI_8BIT 0 + #define SSD1963_PDI_12BIT 1 + #define SSD1963_PDI_16BIT 2 + #define SSD1963_PDI_16BIT565 3 + #define SSD1963_PDI_18BIT 4 + #define SSD1963_PDI_24BIT 5 + #define SSD1963_PDI_9BIT 6 +#define SSD1963_GET_PIXEL_DATA_INTERFACE 0x00F1 + +#endif + diff --git a/drivers/gdisp/TestStub/gdisp_lld.c b/drivers/gdisp/TestStub/gdisp_lld.c new file mode 100644 index 00000000..be323912 --- /dev/null +++ b/drivers/gdisp/TestStub/gdisp_lld.c @@ -0,0 +1,133 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/TestStub/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source (stub). + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 128 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 128 +#endif + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + /* Initialise the GDISP structure */ + GDISP.Width = GDISP_SCREEN_WIDTH; + GDISP.Height = GDISP_SCREEN_HEIGHT; + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOff; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + (void)x; + (void)y; + (void)color; +} + +/* ---- Optional Routines ---- */ + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + (void)x; + (void)y; + + return 0; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + (void)x; + (void)y; + (void)cx; + (void)cy; + (void)lines; + (void)bgcolor; + } +#endif + +#endif /* GFX_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/TestStub/gdisp_lld.mk b/drivers/gdisp/TestStub/gdisp_lld.mk new file mode 100644 index 00000000..5f35be9d --- /dev/null +++ b/drivers/gdisp/TestStub/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/TestStub/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/TestStub diff --git a/drivers/gdisp/TestStub/gdisp_lld_config.h b/drivers/gdisp/TestStub/gdisp_lld_config.h new file mode 100644 index 00000000..18c2de59 --- /dev/null +++ b/drivers/gdisp/TestStub/gdisp_lld_config.h @@ -0,0 +1,51 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/TestStub/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header (stub). + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "TestStub" +#define GDISP_LLD(x) gdisp_lld_##x##_TestStub + +#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL +#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/TestStub/readme.txt b/drivers/gdisp/TestStub/readme.txt new file mode 100644 index 00000000..11145290 --- /dev/null +++ b/drivers/gdisp/TestStub/readme.txt @@ -0,0 +1,16 @@ +This low level driver is a test stub that doesn't talk to any +real hardware. It is included to allow testing of the compilation +process. + +Do not use this driver as a template for new drivers. Use the + templates/gdispXXXXX directory for that. + +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) + you want to compile test eg: GDISP_NEED_MULTITHREAD + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/gdisp/TestStub/gdisp_lld.mk diff --git a/drivers/gdisp/VMT/gdisp_lld.c b/drivers/gdisp/VMT/gdisp_lld.c new file mode 100644 index 00000000..9d9c7382 --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld.c @@ -0,0 +1,271 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/VMT/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +#define GDISP_LLD_NO_STRUCT + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_) +#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_) + +/* Prototypes for lld driver functions */ +bool_t GDISP_LLD1(init)(void); +void *GDISP_LLD1(query)(unsigned what); +void GDISP_LLD1(clear)(color_t color); +void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD1(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); +void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); +#if GDISP_NEED_CLIP + void GDISP_LLD1(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); +#endif +#if GDISP_NEED_CIRCLE + void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif +#if GDISP_NEED_ELLIPSE + void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif +#if GDISP_NEED_ARC + void GDISP_LLD1(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); + void GDISP_LLD1(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); +#endif +#if GDISP_NEED_TEXT + void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); + void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif +#if GDISP_NEED_PIXELREAD + color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y); +#endif +#if GDISP_NEED_SCROLL + void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif +#if GDISP_NEED_CONTROL + void GDISP_LLD1(control)(unsigned what, void *value); +#endif + +bool_t GDISP_LLD2(init)(void); +void *GDISP_LLD2(query)(unsigned what); +void GDISP_LLD2(clear)(color_t color); +void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD2(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); +void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); +#if GDISP_NEED_CLIP + void GDISP_LLD2(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); +#endif +#if GDISP_NEED_CIRCLE + void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif +#if GDISP_NEED_ELLIPSE + void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif +#if GDISP_NEED_ARC + void GDISP_LLD2(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); + void GDISP_LLD2(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); +#endif +#if GDISP_NEED_TEXT + void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); + void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif +#if GDISP_NEED_PIXELREAD + color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y); +#endif +#if GDISP_NEED_SCROLL + void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif +#if GDISP_NEED_CONTROL + void GDISP_LLD2(control)(unsigned what, void *value); +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/* Our VMT table variables */ +void *GDISP_LLD_VMT(query)(unsigned what); +void GDISP_LLD_VMT(clear)(color_t color); +void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD_VMT(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); +void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); + +#if GDISP_NEED_CIRCLE +void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif + +#if GDISP_NEED_ELLIPSE +void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif + +/* Text Rendering Functions */ +#if GDISP_NEED_TEXT +void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); +void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif + +/* Pixel readback */ +#if GDISP_NEED_PIXELREAD +color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); +#endif + +/* Scrolling Function - clears the area scrolled out */ +#if GDISP_NEED_SCROLL +void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif + +/* Set driver specific control */ +#if GDISP_NEED_CONTROL +void GDISP_LLD_VMT(control)(unsigned what, void *value); +#endif +/* Clipping Functions */ +#if GDISP_NEED_CLIP +void GDISP_LLD_VMT(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); +#endif + + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +bool_t gdisp_lld_init_VMT(void) { + if (GDISP_VMT_NAME1(gdisp_lld_init_)()) { + gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_); + gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_); + gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_); + gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_); + gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME1(gdisp_lld_blitareaex_); + gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_); + #if GDISP_NEED_CIRCLE + gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_); + gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_); + #endif + #if GDISP_NEED_ELLIPSE + gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_); + gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_); + #endif + #if GDISP_NEED_ARC + gdisp_lld_drawarc_VMT = GDISP_VMT_NAME1(gdisp_lld_drawarc_); + gdisp_lld_fillarc_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarc_); + #endif + #if GDISP_NEED_TEXT + gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_); + gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_); + #endif + #if GDISP_NEED_PIXELREAD + gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_); + #endif + #if GDISP_NEED_SCROLL + gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_); + #endif + #if GDISP_NEED_CONTROL + gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_); + #endif + #if GDISP_NEED_CLIP + gdisp_lld_setclip_VMT = GDISP_VMT_NAME1(gdisp_lld_setclip_); + #endif + + return TRUE; + } + + if (GDISP_VMT_NAME2(gdisp_lld_init_)()) { + gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_); + gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_); + gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_); + gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_); + gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME2(gdisp_lld_blitareaex_); + gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_); + #if GDISP_NEED_CIRCLE + gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_); + gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_); + #endif + #if GDISP_NEED_ELLIPSE + gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_); + gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_); + #endif + #if GDISP_NEED_ARC + gdisp_lld_drawarc_VMT = GDISP_VMT_NAME2(gdisp_lld_drawarc_); + gdisp_lld_fillarc_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarc_); + #endif + #if GDISP_NEED_TEXT + gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_); + gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_); + #endif + #if GDISP_NEED_PIXELREAD + gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_); + #endif + #if GDISP_NEED_SCROLL + gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_); + #endif + #if GDISP_NEED_CONTROL + gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_); + #endif + #if GDISP_NEED_CLIP + gdisp_lld_setclip_VMT = GDISP_VMT_NAME2(gdisp_lld_setclip_); + #endif + + return TRUE; + } + return FALSE; +} + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/VMT/gdisp_lld.mk b/drivers/gdisp/VMT/gdisp_lld.mk new file mode 100644 index 00000000..96918f8a --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld.mk @@ -0,0 +1,7 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld.c \ + $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld_driver1.c \ + $(GFXLIB)//drivers/gdisp/VMT/gdisp_lld_driver2.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/gdisp/VMT diff --git a/drivers/gdisp/VMT/gdisp_lld_config.h b/drivers/gdisp/VMT/gdisp_lld_config.h new file mode 100644 index 00000000..8c7bfc9c --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld_config.h @@ -0,0 +1,71 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/VMT/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header template. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "VMT" +#define GDISP_LLD(x) gdisp_lld_##x##_VMT +#define GDISP_LLD_VMT(x) (*GDISP_LLD(x)) + +#define GDISP_HARDWARE_LINES TRUE +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CIRCLES TRUE +#define GDISP_HARDWARE_CIRCLEFILLS TRUE +#define GDISP_HARDWARE_ELLIPSES TRUE +#define GDISP_HARDWARE_ELLIPSEFILLS TRUE +#define GDISP_HARDWARE_ARCS TRUE +#define GDISP_HARDWARE_ARCFILLS TRUE +#define GDISP_HARDWARE_TEXT TRUE +#define GDISP_HARDWARE_TEXTFILLS TRUE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE +#define GDISP_HARDWARE_QUERY TRUE +#define GDISP_HARDWARE_CLIP TRUE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/gdisp/VMT/gdisp_lld_driver1.c b/drivers/gdisp/VMT/gdisp_lld_driver1.c new file mode 100644 index 00000000..01fd4cf0 --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld_driver1.c @@ -0,0 +1,52 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/VMT/gdisp_lld_driver1.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +#define CONFIGFILE() <../GDISP_VMT_NAME1()/gdisp_lld_config.h> +#define DRIVERFILE() <../GDISP_VMT_NAME1()/gdisp_lld.c> + +/* We don't need these in our VMT referenced driver */ +#undef GDISP_NEED_MSGAPI +#define GDISP_NEED_MSGAPI FALSE + +/* Include the specific config file we want */ +#include CONFIGFILE() + +/* Bring in our API */ +#include "gfx.h" + +/* Add the low level driver */ +#include DRIVERFILE() + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/VMT/gdisp_lld_driver2.c b/drivers/gdisp/VMT/gdisp_lld_driver2.c new file mode 100644 index 00000000..ed0e8555 --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld_driver2.c @@ -0,0 +1,52 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/gdisp/VMT/gdisp_lld_driver2.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +#define CONFIGFILE() <../GDISP_VMT_NAME2()/gdisp_lld_config.h> +#define DRIVERFILE() <../GDISP_VMT_NAME2()/gdisp_lld.c> + +/* We don't need these in our VMT referenced driver */ +#undef GDISP_NEED_MSGAPI +#define GDISP_NEED_MSGAPI FALSE + +/* Include the specific config file we want */ +#include CONFIGFILE() + +/* Bring in our API */ +#include "gfx.h" + +/* Add the low level driver */ +#include DRIVERFILE() + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/gdisp/VMT/readme.txt b/drivers/gdisp/VMT/readme.txt new file mode 100644 index 00000000..d6b71e0e --- /dev/null +++ b/drivers/gdisp/VMT/readme.txt @@ -0,0 +1,23 @@ +This driver enables you to have two underlying drivers handling different hardware. +A choice is made at run-time of which driver to call based on which driver succeeds +to initialise first (init returns TRUE). + +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) Define these: + #define GDISP_VMT_NAME1(x) x##YourDriver1 + #define GDISP_VMT_NAME2(x) x##YourDriver2 + Note YourDriver1 & 2 are the basenames of the directories containing the driver. + Note that both drivers must be the same pixel format which is + GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your + pixel format is different on both drivers. + d) Any driver specific defines. If both drivers use the same defines then they must + accept the same values for the define. + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk + diff --git a/drivers/ginput/toggle/Pal/ginput_lld.mk b/drivers/ginput/toggle/Pal/ginput_lld.mk new file mode 100644 index 00000000..d398da9d --- /dev/null +++ b/drivers/ginput/toggle/Pal/ginput_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/ginput/toggle/Pal/ginput_lld_toggle.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/ginput/toggle/Pal diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle.c b/drivers/ginput/toggle/Pal/ginput_lld_toggle.c new file mode 100644 index 00000000..e2ecc116 --- /dev/null +++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle.c @@ -0,0 +1,63 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/toggle/Pal/ginput_lld_toggle.c + * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) /*|| defined(__DOXYGEN__)*/ + +#include "ginput/lld/toggle.h" + +GINPUT_TOGGLE_DECLARE_STRUCTURE(); + +/** + * @brief Initialise the port. + * + * @param[in] ptc A pointer to one of the entries in GInputToggleConfigTable + * + * @notapi + */ +void ginput_lld_toggle_init(const GToggleConfig *ptc) { + palSetGroupMode(((IOBus *)ptc->id)->portid, ptc->mask, 0, ptc->mode); +} + +/** + * @brief Get the bits from the port. + * + * @param[in] ptc A pointer to one of the entries in GInputToggleConfigTable + * + * @notapi + */ +unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { + return palReadBus((IOBus *)ptc->id); +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ +/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h new file mode 100644 index 00000000..20fc44b5 --- /dev/null +++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h @@ -0,0 +1,61 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h + * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the example board. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ + +#ifndef _GDISP_LLD_TOGGLE_BOARD_H +#define _GDISP_LLD_TOGGLE_BOARD_H + +#error "GINPUT Toggle Pal Driver: You need to define your board definitions" + +// The below are example values + +#define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs +#define GINPUT_TOGGLE_CONFIG_ENTRIES 2 // The total number of GToggleConfig entries + +#define GINPUT_TOGGLE_SW1 0 // Switch 1 +#define GINPUT_TOGGLE_SW2 1 // Switch 2 +#define GINPUT_TOGGLE_UP 2 // Joystick Up +#define GINPUT_TOGGLE_DOWN 3 // Joystick Down +#define GINPUT_TOGGLE_LEFT 4 // Joystick Left +#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right +#define GINPUT_TOGGLE_CENTER 6 // Joystick Center + +#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ + const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ + {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \ + PIOB_SW1_MASK|PIOB_SW2_MASK, \ + PIOB_SW1_MASK|PIOB_SW2_MASK, \ + PAL_MODE_INPUT}, \ + {AT91C_BASE_PIOA, /* B1..4 Joystick */ \ + PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ + PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ + PAL_MODE_INPUT}, \ + } + +#endif /* _GDISP_LLD_TOGGLE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h new file mode 100644 index 00000000..4f3d6800 --- /dev/null +++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h @@ -0,0 +1,57 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h + * @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the Olimex SAM7EX256 board. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ + +#ifndef _GDISP_LLD_TOGGLE_BOARD_H +#define _GDISP_LLD_TOGGLE_BOARD_H + +#define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs +#define GINPUT_TOGGLE_CONFIG_ENTRIES 2 // The total number of GToggleConfig entries + +#define GINPUT_TOGGLE_SW1 0 // Switch 1 +#define GINPUT_TOGGLE_SW2 1 // Switch 2 +#define GINPUT_TOGGLE_UP 2 // Joystick Up +#define GINPUT_TOGGLE_DOWN 3 // Joystick Down +#define GINPUT_TOGGLE_LEFT 4 // Joystick Left +#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right +#define GINPUT_TOGGLE_CENTER 6 // Joystick Center + +#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ + const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ + {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \ + PIOB_SW1_MASK|PIOB_SW2_MASK, \ + PIOB_SW1_MASK|PIOB_SW2_MASK, \ + PAL_MODE_INPUT}, \ + {AT91C_BASE_PIOA, /* B1..4 Joystick */ \ + PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ + PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \ + PAL_MODE_INPUT}, \ + } + +#endif /* _GDISP_LLD_TOGGLE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h new file mode 100644 index 00000000..162d35df --- /dev/null +++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h @@ -0,0 +1,48 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h + * @brief GINPUT Toggle Driver configuration header. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_TOGGLE_CONFIG_H +#define _GINPUT_LLD_TOGGLE_CONFIG_H + +#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE + +#if GINPUT_TOGGLE_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "ginput_lld_toggle_board.h" +#elif defined(BOARD_OLIMEX_SAM7_EX256) + #include "ginput_lld_toggle_board_olimexsam7ex256.h" +#else + /* Include the user supplied board definitions */ + #include "ginput_lld_toggle_board.h" +#endif + +#endif /* GFX_USE_GDISP && GINPUT_NEED_TOGGLE */ + +#endif /* _GINPUT_LLD_TOGGLE_CONFIG_H */ +/** @} */ diff --git a/drivers/ginput/toggle/Pal/readme.txt b/drivers/ginput/toggle/Pal/readme.txt new file mode 100644 index 00000000..e6976f7d --- /dev/null +++ b/drivers/ginput/toggle/Pal/readme.txt @@ -0,0 +1,13 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GINPUT TRUE + #define GINPUT_NEED_TOGGLE TRUE + d) If you are not using a known board then create a ginput_lld_toggle_board.h file + and ensure it is on your include path. + Use the ginput_lld_toggle_board_example.h file as a basis. + Currently known boards are: + Olimex SAM7-EX256 + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/ginput/togglePal/ginput_lld.mk diff --git a/drivers/ginput/touch/ADS7843/ginput_lld.mk b/drivers/ginput/touch/ADS7843/ginput_lld.mk new file mode 100644 index 00000000..b6ac0ea6 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/ginput/touch/ADS7843 diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c new file mode 100644 index 00000000..65065176 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c @@ -0,0 +1,144 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse.c + * @brief GINPUT Touch low level driver source for the ADS7843. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/ + +#include "ginput/lld/mouse.h" + +#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD + #include "ginput_lld_mouse_board.h" +#elif defined(BOARD_FIREBULL_STM32_F103) + #include "ginput_lld_mouse_board_firebull_stm32f103.h" +#elif defined(BOARD_OLIMEX_STM32_E407) + #include "ginput_lld_mouse_board_olimex_stm32_e407.h" +#else + #include "ginput_lld_mouse_board_example.h" +#endif + +static uint16_t sampleBuf[7]; +static coord_t lastx, lasty; + +/** + * @brief 7-point median filtering code for touch samples + * + * @note This is an internally used routine only. + * + * @notapi + */ +static void filter(void) { + uint16_t temp; + int i,j; + + for(i = 0; i < 4; i++) { + for(j = i; j < 7; j++) { + if(sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp = sampleBuf[i]; + sampleBuf[i] = sampleBuf[j]; + sampleBuf[j] = temp; + } + } + } +} + +/** + * @brief Initialise the mouse/touch. + * + * @notapi + */ +void ginput_lld_mouse_init(void) { + init_board(); +} + +/** + * @brief Read the mouse/touch position. + * + * @param[in] pt A pointer to the structure to fill + * + * @note For drivers that don't support returning a position + * when the touch is up (most touch devices), it should + * return the previous position with the new Z value. + * The z value is the pressure for those touch devices + * that support it (-100 to 100 where > 0 is touched) + * or, 0 or 100 for those drivers that don't. + * + * @notapi + */ +void ginput_lld_mouse_get_reading(MouseReading *pt) { + uint16_t i; + + // If touch-off return the previous results + if (!getpin_pressed()) { + pt->x = lastx; + pt->y = lasty; + pt->z = 0; + pt->buttons = 0; + return; + } + + // Read the port to get the touch settings + aquire_bus(); + + /* Get the X value + * Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled while reading. + * Finally switch on PENIRQ once again - perform a dummy read. + * Once we have the readings, find the medium using our filter function + */ + read_value(0xD1); + for(i = 0; i < 7; i++) + sampleBuf[i] = read_value(0xD1); + read_value(0xD0); + filter(); + lastx = (coord_t)sampleBuf[3]; + + /* Get the Y value using the same process as above */ + read_value(0x91); + for(i = 0; i < 7; i++) + sampleBuf[i] = read_value(0x91); + read_value(0x90); + filter(); + lasty = (coord_t)sampleBuf[3]; + + // Release the bus + release_bus(); + + // Return the results + pt->x = lastx; + pt->y = lasty; + pt->z = 100; + pt->buttons = GINPUT_TOUCH_PRESSED; +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */ +/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h new file mode 100644 index 00000000..9f4f2dc1 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h @@ -0,0 +1,88 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h + * @brief GINPUT Touch low level driver source for the ADS7843 on the example board. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +/** + * @brief Initialise the board for the touch. + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ + #error "ginputADS7843: You must supply a definition for init_board for your board" +} + +/** + * @brief Check whether the surface is currently touched + * @return TRUE if the surface is currently touched + * + * @notapi + */ +static __inline bool_t getpin_pressed(void) { + /* Code here */ + #error "ginputADS7843: You must supply a definition for getpin_pressed for your board" +} + +/** + * @brief Aquire the bus ready for readings + * + * @notapi + */ +static __inline void aquire_bus(void) { + /* Code here */ + #error "ginputADS7843: You must supply a definition for aquire_bus for your board" +} + +/** + * @brief Release the bus after readings + * + * @notapi + */ +static __inline void release_bus(void) { + /* Code here */ + #error "ginputADS7843: You must supply a definition for release_bus for your board" +} + +/** + * @brief Read a value from touch controller + * @return The value read from the controller + * + * params[in] port The controller port to read. + * + * @notapi + */ +static __inline uint16_t read_value(uint16_t port) { + /* Code here */ + #error "ginputADS7843: You must supply a definition for read_value for your board" +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h new file mode 100644 index 00000000..bc018b89 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h @@ -0,0 +1,103 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h + * @brief GINPUT ouch low level driver source for the ADS7843 on the FireBull STM32F103-FB board. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +static const SPIConfig spicfg = { + NULL, + GPIOC, + 6, + /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; + +/** + * @brief Initialise the board for the touch. + * + * @notapi + */ +static __inline void init_board(void) { + spiStart(&SPID1, &spicfg); +} + +/** + * @brief Check whether the surface is currently touched + * @return TRUE if the surface is currently touched + * + * @notapi + */ +static __inline bool_t getpin_pressed(void) { + return (!palReadPad(GPIOC, 4)); +} +/** + * @brief Aquire the bus ready for readings + * + * @notapi + */ +static __inline void aquire_bus(void) { + spiAcquireBus(&SPID1); + //TOUCHSCREEN_SPI_PROLOGUE(); + palClearPad(GPIOC, 6); +} + +/** + * @brief Release the bus after readings + * + * @notapi + */ +static __inline void release_bus(void) { + palSetPad(GPIOC, 6); + spiReleaseBus(&SPID1); + //TOUCHSCREEN_SPI_EPILOGUE(); +} + +/** + * @brief Read a value from touch controller + * @return The value read from the controller + * + * params[in] port The controller port to read. + * + * @notapi + */ +static __inline uint16_t read_value(uint16_t port) { + static uint8_t txbuf[3] = {0}; + static uint8_t rxbuf[3] = {0}; + uint16_t ret; + + txbuf[0] = port; + + spiExchange(&SPID1, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h new file mode 100644 index 00000000..6c5f7e37 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h @@ -0,0 +1,103 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h + * @brief GINPUT Touch low level driver source for the ADS7843 on an Olimex STM32E407. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +static const SPIConfig spicfg = { + NULL, + GPIOG, + 10, + /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; + +/** + * @brief Initialise the board for the touch. + * + * @notapi + */ +static __inline void init_board(void) { + spiStart(&SPID2, &spicfg); +} + +/** + * @brief Check whether the surface is currently touched + * @return TRUE if the surface is currently touched + * + * @notapi + */ +static __inline bool_t getpin_pressed(void) { + return (!palReadPad(GPIOG, 0)); +} +/** + * @brief Aquire the bus ready for readings + * + * @notapi + */ +static __inline void aquire_bus(void) { + spiAcquireBus(&SPID2); + //TOUCHSCREEN_SPI_PROLOGUE(); + palClearPad(GPIOG, 10); +} + +/** + * @brief Release the bus after readings + * + * @notapi + */ +static __inline void release_bus(void) { + palSetPad(GPIOG, 10); + spiReleaseBus(&SPID2); + //TOUCHSCREEN_SPI_EPILOGUE(); +} + +/** + * @brief Read a value from touch controller + * @return The value read from the controller + * + * params[in] port The controller port to read. + * + * @notapi + */ +static __inline uint16_t read_value(uint16_t port) { + static uint8_t txbuf[3] = {0}; + static uint8_t rxbuf[3] = {0}; + uint16_t ret; + + txbuf[0] = port; + + spiExchange(&SPID2, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h new file mode 100644 index 00000000..30a13841 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h @@ -0,0 +1,44 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h + * @brief GINPUT LLD header file for mouse/touch driver. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _LLD_GINPUT_MOUSE_CONFIG_H +#define _LLD_GINPUT_MOUSE_CONFIG_H + +#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH +#define GINPUT_MOUSE_NEED_CALIBRATION TRUE +#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE +#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5 +#define GINPUT_MOUSE_READ_CYCLES 4 +#define GINPUT_MOUSE_POLL_PERIOD 25 +#define GINPUT_MOUSE_MAX_CLICK_JITTER 10 +#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 +#define GINPUT_MOUSE_CLICK_TIME 500 + +#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ +/** @} */ diff --git a/drivers/ginput/touch/ADS7843/readme.txt b/drivers/ginput/touch/ADS7843/readme.txt new file mode 100644 index 00000000..852a1ea0 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GINPUT TRUE + b) #define GINPUT_NEED_MOUSE TRUE + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld.mk + diff --git a/drivers/ginput/touch/MCU/ginput_lld.mk b/drivers/ginput/touch/MCU/ginput_lld.mk new file mode 100644 index 00000000..eb8fb2d8 --- /dev/null +++ b/drivers/ginput/touch/MCU/ginput_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld_mouse.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/ginput/touch/MCU diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse.c b/drivers/ginput/touch/MCU/ginput_lld_mouse.c new file mode 100644 index 00000000..b43a14e7 --- /dev/null +++ b/drivers/ginput/touch/MCU/ginput_lld_mouse.c @@ -0,0 +1,140 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/MCU/ginput_lld_mouse.c + * @brief GINPUT Touch low level driver source for the MCU. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/ + +#include "ginput/lld/mouse.h" + +#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD + #include "ginput_lld_mouse_board.h" +#elif defined(BOARD_OLIMEX_STM32_LCD) + #include "ginput_lld_mouse_board_olimex_stm32_lcd.h" +#else + #include "ginput_lld_mouse_board.h" +#endif + +static uint16_t sampleBuf[7]; +static coord_t lastx, lasty; + +/** + * @brief 7-point median filtering code for touchscreen samples + * + * @note This is an internally used routine only. + * + * @notapi + */ +static void filter(void) { + uint16_t temp; + int i,j; + + for(i = 0; i < 4; i++) { + for(j = i; j < 7; j++) { + if(sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp = sampleBuf[i]; + sampleBuf[i] = sampleBuf[j]; + sampleBuf[j] = temp; + } + } + } +} + +/** + * @brief Initialise the mouse/touch. + * + * @notapi + */ +void ginput_lld_mouse_init(void) { + init_board(); +} + +/** + * @brief Read the mouse/touch position. + * + * @param[in] pt A pointer to the structure to fill + * + * @note For drivers that don't support returning a position + * when the touch is up (most touch devices), it should + * return the previous position with the new Z value. + * The z value is the pressure for those touch devices + * that support it (-100 to 100 where > 0 is touched) + * or, 0 or 100 for those drivers that don't. + * + * @notapi + */ +void ginput_lld_mouse_get_reading(MouseReading *pt) { + uint16_t i; + + // If touch-off return the previous results + if (!getpin_pressed()) { + pt->x = lastx; + pt->y = lasty; + pt->z = 0; + pt->buttons = 0; + return; + } + + // Read the port to get the touch settings + aquire_bus(); + + /* Get the X value + * Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. + * Once we have the readings, find the medium using our filter function + */ + read_x_value(); + for(i = 0; i < 7; i++) + sampleBuf[i] = read_x_value(); + filter(); + lastx = (coord_t)sampleBuf[3]; + + /* Get the Y value using the same process as above */ + read_y_value(); + for(i = 0; i < 7; i++) + sampleBuf[i] = read_y_value(); + filter(); + lasty = (coord_t)sampleBuf[3]; + + // Release the bus + release_bus(); + + // Return the results + pt->x = lastx; + pt->y = lasty; + pt->z = 100; + pt->buttons = GINPUT_TOUCH_PRESSED; +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */ +/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h new file mode 100644 index 00000000..913d50c9 --- /dev/null +++ b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h @@ -0,0 +1,98 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h + * @brief GINPUT Touch low level driver source for the MCU on the example board. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +/** + * @brief Initialise the board for the touch. + * + * @notapi + */ +static __inline void init_board(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for init_board for your board" +} + +/** + * @brief Check whether the surface is currently touched + * @return TRUE if the surface is currently touched + * + * @notapi + */ +static __inline bool_t getpin_pressed(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for getpin_pressed for your board" +} + +/** + * @brief Aquire the bus ready for readings + * + * @notapi + */ +static __inline void aquire_bus(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for aquire_bus for your board" +} + +/** + * @brief Release the bus after readings + * + * @notapi + */ +static __inline void release_bus(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for release_bus for your board" +} + +/** + * @brief Read an x value from touch controller + * @return The value read from the controller + * + * @notapi + */ +static __inline uint16_t read_x_value(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for read_x_value for your board" +} + +/** + * @brief Read an y value from touch controller + * @return The value read from the controller + * + * @notapi + */ +static __inline uint16_t read_y_value(void) { + /* Code here */ + #error "ginputMCU: You must supply a definition for read_y_value for your board" +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h new file mode 100644 index 00000000..510e8e81 --- /dev/null +++ b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h @@ -0,0 +1,165 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h + * @brief GINPUT Touch low level driver source for the MCU on the example board. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +#define ADC_NUM_CHANNELS 2 +#define ADC_BUF_DEPTH 1 + +static const ADCConversionGroup adc_y_config = { + FALSE, + ADC_NUM_CHANNELS, + NULL, + NULL, + 0, 0, + 0, 0, + ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS), + 0, + ADC_SQR3_SQ2_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN13) +}; + +static const ADCConversionGroup adc_x_config = { + FALSE, + ADC_NUM_CHANNELS, + NULL, + NULL, + 0, 0, + 0, 0, + ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS), + 0, + ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11) +}; + +/** + * @brief Initialise the board for the touch. + * + * @notapi + */ +static __inline void init_board(void) { + adcStart(&ADCD1, NULL); +} + +/** + * @brief Check whether the surface is currently touched + * @return TRUE if the surface is currently touched + * + * @notapi + */ +static __inline bool_t getpin_pressed(void) { + palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOC, 1, PAL_MODE_INPUT); + palSetPadMode(GPIOC, 2, PAL_MODE_INPUT); + palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL); + palSetPad(GPIOC, 3); + + return palReadPad(GPIOC, 0); +} + +/** + * @brief Aquire the bus ready for readings + * + * @notapi + */ +static __inline void aquire_bus(void) { + +} + +/** + * @brief Release the bus after readings + * + * @notapi + */ +static __inline void release_bus(void) { + +} + +/** + * @brief Read an x value from touch controller + * @return The value read from the controller + * + * @notapi + */ +static __inline uint16_t read_x_value(void) { + uint16_t val1, val2; + adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH]; + + palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_ANALOG); + palSetPadMode(GPIOC, 1, PAL_MODE_INPUT_ANALOG); + palSetPadMode(GPIOC, 2, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL); + + palSetPad(GPIOC, 2); + palClearPad(GPIOC, 3); + chThdSleepMilliseconds(1); + adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH); + val1 = ((samples[0] + samples[1])/2); + + palClearPad(GPIOC, 2); + palSetPad(GPIOC, 3); + chThdSleepMilliseconds(1); + adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH); + val2 = ((samples[0] + samples[1])/2); + + return ((val1+((1<<12)-val2))/4); +} + +/** + * @brief Read an y value from touch controller + * @return The value read from the controller + * + * @notapi + */ +static __inline uint16_t read_y_value(void) { + uint16_t val1, val2; + adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH]; + + palSetPadMode(GPIOC, 2, PAL_MODE_INPUT_ANALOG); + palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG); + palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOC, 1, PAL_MODE_OUTPUT_PUSHPULL); + + palSetPad(GPIOC, 1); + palClearPad(GPIOC, 0); + chThdSleepMilliseconds(1); + adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH); + val1 = ((samples[0] + samples[1])/2); + + palClearPad(GPIOC, 1); + palSetPad(GPIOC, 0); + chThdSleepMilliseconds(1); + adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH); + val2 = ((samples[0] + samples[1])/2); + + return ((val1+((1<<12)-val2))/4); +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ +/** @} */ diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h new file mode 100644 index 00000000..1b5c7b6b --- /dev/null +++ b/drivers/ginput/touch/MCU/ginput_lld_mouse_config.h @@ -0,0 +1,44 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file drivers/ginput/touch/MCU/ginput_lld_mouse_config.h + * @brief GINPUT LLD header file for touch driver. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _LLD_GINPUT_MOUSE_CONFIG_H +#define _LLD_GINPUT_MOUSE_CONFIG_H + +#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH +#define GINPUT_MOUSE_NEED_CALIBRATION TRUE +#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE +#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12 +#define GINPUT_MOUSE_READ_CYCLES 4 +#define GINPUT_MOUSE_POLL_PERIOD 25 +#define GINPUT_MOUSE_MAX_CLICK_JITTER 2 +#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 +#define GINPUT_MOUSE_CLICK_TIME 500 + +#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ +/** @} */ diff --git a/drivers/ginput/touch/MCU/readme.txt b/drivers/ginput/touch/MCU/readme.txt new file mode 100644 index 00000000..4dbe5543 --- /dev/null +++ b/drivers/ginput/touch/MCU/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GINPUT TRUE + b) #define GINPUT_NEED_MOUSE TRUE + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk + diff --git a/drivers/multiple/Win32/gdisp_lld.c b/drivers/multiple/Win32/gdisp_lld.c new file mode 100644 index 00000000..8a46abc9 --- /dev/null +++ b/drivers/multiple/Win32/gdisp_lld.c @@ -0,0 +1,1026 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/multiple/Win32/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for Win32. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +#include +#include +#include +#include +#include +#include + +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 640 +#endif +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 480 +#endif + +#if GINPUT_NEED_TOGGLE + /* Include toggle support code */ + #include "ginput/lld/toggle.h" + + const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { + {0, 0xFF, 0x00, PAL_MODE_INPUT}, + }; +#endif + +#if GINPUT_NEED_MOUSE + /* Include mouse support code */ + #include "ginput/lld/mouse.h" +#endif + +/* Include the emulation code for things we don't support */ +#include "gdisp/lld/emulation.c" + +/*===========================================================================*/ +/* Driver local routines . */ +/*===========================================================================*/ + +#define WIN32_USE_MSG_REDRAW FALSE +#if GINPUT_NEED_TOGGLE + #define WIN32_BUTTON_AREA 16 +#else + #define WIN32_BUTTON_AREA 0 +#endif + +#define APP_NAME "GDISP" + +#define COLOR2BGR(c) ((((c) & 0xFF)<<16)|((c) & 0xFF00)|(((c)>>16) & 0xFF)) +#define BGR2COLOR(c) COLOR2BGR(c) + +static HWND winRootWindow = NULL; +static HDC dcBuffer = NULL; +static HBITMAP dcBitmap = NULL; +static HBITMAP dcOldBitmap; +static volatile bool_t isReady = FALSE; +static coord_t wWidth, wHeight; + +#if GINPUT_NEED_MOUSE + static coord_t mousex, mousey; + static uint16_t mousebuttons; +#endif +#if GINPUT_NEED_TOGGLE + static uint8_t toggles = 0; +#endif + +static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + HDC dc; + PAINTSTRUCT ps; + #if GINPUT_NEED_TOGGLE + HBRUSH hbrOn, hbrOff; + HPEN pen; + RECT rect; + HGDIOBJ old; + POINT p; + coord_t pos; + uint8_t bit; + #endif + + switch (Msg) { + case WM_CREATE: + break; + case WM_LBUTTONDOWN: + #if GINPUT_NEED_MOUSE + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons |= GINPUT_MOUSE_BTN_LEFT; + goto mousemove; + } + #endif + #if GINPUT_NEED_TOGGLE + bit = 1 << ((coord_t)LOWORD(lParam)*8/wWidth); + toggles ^= bit; + rect.left = 0; + rect.right = wWidth; + rect.top = wHeight; + rect.bottom = wHeight + WIN32_BUTTON_AREA; + InvalidateRect(hWnd, &rect, FALSE); + UpdateWindow(hWnd); + #if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE + ginputToggleWakeup(); + #endif + #endif + break; + case WM_LBUTTONUP: + #if GINPUT_NEED_TOGGLE + if ((toggles & 0xF0)) { + toggles &= 0x0F; + rect.left = 0; + rect.right = wWidth; + rect.top = wHeight; + rect.bottom = wHeight + WIN32_BUTTON_AREA; + InvalidateRect(hWnd, &rect, FALSE); + UpdateWindow(hWnd); + #if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE + ginputToggleWakeup(); + #endif + } + #endif + #if GINPUT_NEED_MOUSE + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons &= ~GINPUT_MOUSE_BTN_LEFT; + goto mousemove; + } + #endif + break; +#if GINPUT_NEED_MOUSE + case WM_MBUTTONDOWN: + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons |= GINPUT_MOUSE_BTN_MIDDLE; + goto mousemove; + } + break; + case WM_MBUTTONUP: + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons &= ~GINPUT_MOUSE_BTN_MIDDLE; + goto mousemove; + } + break; + case WM_RBUTTONDOWN: + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons |= GINPUT_MOUSE_BTN_RIGHT; + goto mousemove; + } + break; + case WM_RBUTTONUP: + if ((coord_t)HIWORD(lParam) < wHeight) { + mousebuttons &= ~GINPUT_MOUSE_BTN_RIGHT; + goto mousemove; + } + break; + case WM_MOUSEMOVE: + if ((coord_t)HIWORD(lParam) >= wHeight) + break; + mousemove: + mousex = (coord_t)LOWORD(lParam); + mousey = (coord_t)HIWORD(lParam); + #if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE + ginputMouseWakeup(); + #endif + break; +#endif + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + case WM_SYSKEYUP: + case WM_KEYUP: + break; + case WM_CHAR: + case WM_DEADCHAR: + case WM_SYSCHAR: + case WM_SYSDEADCHAR: + break; + case WM_PAINT: + dc = BeginPaint(hWnd, &ps); + BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top, + ps.rcPaint.right - ps.rcPaint.left, + (ps.rcPaint.bottom > wHeight ? wHeight : ps.rcPaint.bottom) - ps.rcPaint.top, + dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); + #if GINPUT_NEED_TOGGLE + if (ps.rcPaint.bottom >= wHeight) { + pen = CreatePen(PS_SOLID, 1, COLOR2BGR(Black)); + hbrOn = CreateSolidBrush(COLOR2BGR(Blue)); + hbrOff = CreateSolidBrush(COLOR2BGR(Gray)); + old = SelectObject(dc, pen); + MoveToEx(dc, 0, wHeight, &p); + LineTo(dc, wWidth, wHeight); + for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) { + rect.left = pos; + rect.right = pos + wWidth/8; + rect.top = wHeight; + rect.bottom = wHeight + WIN32_BUTTON_AREA; + FillRect(dc, &rect, (toggles & bit) ? hbrOn : hbrOff); + if (pos > 0) { + MoveToEx(dc, rect.left, rect.top, &p); + LineTo(dc, rect.left, rect.bottom); + } + } + DeleteObject(hbrOn); + DeleteObject(hbrOff); + SelectObject(dc, old); + } + #endif + EndPaint(hWnd, &ps); + break; + case WM_DESTROY: + PostQuitMessage(0); + SelectObject(dcBuffer, dcOldBitmap); + DeleteDC(dcBuffer); + DeleteObject(dcBitmap); + winRootWindow = NULL; + break; + default: + return DefWindowProc(hWnd, Msg, wParam, lParam); + } + return 0; +} + +static DWORD WINAPI WindowThread(LPVOID lpParameter) { + (void)lpParameter; + + MSG msg; + HANDLE hInstance; + WNDCLASS wc; + RECT rect; + HDC dc; + + hInstance = GetModuleHandle(NULL); + + wc.style = CS_HREDRAW | CS_VREDRAW; // | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)myWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = GetStockObject(WHITE_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = APP_NAME; + RegisterClass(&wc); + + rect.top = 0; rect.bottom = wHeight+WIN32_BUTTON_AREA; + rect.left = 0; rect.right = wWidth; + AdjustWindowRect(&rect, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0); + winRootWindow = CreateWindow(APP_NAME, "", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0, 0, + rect.right-rect.left, rect.bottom-rect.top, 0, 0, hInstance, NULL); + assert(winRootWindow != NULL); + + + GetClientRect(winRootWindow, &rect); + wWidth = rect.right-rect.left; + wHeight = rect.bottom - rect.top - WIN32_BUTTON_AREA; + + dc = GetDC(winRootWindow); + dcBitmap = CreateCompatibleBitmap(dc, wWidth, wHeight); + dcBuffer = CreateCompatibleDC(dc); + ReleaseDC(winRootWindow, dc); + dcOldBitmap = SelectObject(dcBuffer, dcBitmap); + + ShowWindow(winRootWindow, SW_SHOW); + UpdateWindow(winRootWindow); + isReady = TRUE; + + while(GetMessage(&msg, NULL, 0, 0) > 0) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + ExitProcess(0); + return msg.wParam; +} + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialisation. + * @return TRUE if successful, FALSE on error. + * + * @notapi + */ +bool_t lld_gdisp_init(void) { + RECT rect; + + /* Set the window dimensions */ + GetWindowRect(GetDesktopWindow(), &rect); + wWidth = rect.right - rect.left; + wHeight = rect.bottom - rect.top - WIN32_BUTTON_AREA; + if (wWidth > GDISP_SCREEN_WIDTH) + wWidth = GDISP_SCREEN_WIDTH; + if (wHeight > GDISP_SCREEN_HEIGHT) + wHeight = GDISP_SCREEN_HEIGHT; + + /* Initialise the window */ + CreateThread(0, 0, WindowThread, 0, 0, 0); + while (!isReady) + Sleep(1); + + /* Initialise the GDISP structure to match */ + GDISP.Orientation = GDISP_ROTATE_0; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + GDISP.Width = wWidth; + GDISP.Height = wHeight; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { + HDC dc; + #if WIN32_USE_MSG_REDRAW + RECT rect; + #endif + #if GDISP_NEED_CONTROL + coord_t t; + #endif + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + // Clip pre orientation change + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + #endif + + #if GDISP_NEED_CONTROL + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + break; + case GDISP_ROTATE_90: + t = GDISP.Height - 1 - y; + y = x; + x = t; + break; + case GDISP_ROTATE_180: + x = GDISP.Width - 1 - x; + y = GDISP.Height - 1 - y; + break; + case GDISP_ROTATE_270: + t = GDISP.Width - 1 - x; + x = y; + y = t; + break; + } + #endif + + // Draw the pixel in the buffer + color = COLOR2BGR(color); + SetPixel(dcBuffer, x, y, color); + + #if WIN32_USE_MSG_REDRAW + rect.left = x; rect.right = x+1; + rect.top = y; rect.bottom = y+1; + InvalidateRect(winRootWindow, &rect, FALSE); + UpdateWindow(winRootWindow); + #else + // Draw the pixel again directly on the screen. + // This is cheaper than invalidating a single pixel in the window + dc = GetDC(winRootWindow); + SetPixel(dc, x, y, color); + ReleaseDC(winRootWindow, dc); + #endif +} + +/* ---- Optional Routines ---- */ + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void lld_gdisp_draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + POINT p; + HPEN pen; + HDC dc; + HGDIOBJ old; + #if GDISP_NEED_CLIP + HRGN clip; + #endif + #if WIN32_USE_MSG_REDRAW + RECT rect; + #endif + #if GDISP_NEED_CONTROL + coord_t t; + #endif + + #if GDISP_NEED_CLIP + clip = NULL; + #endif + + #if GDISP_NEED_CONTROL + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + #if GDISP_NEED_CLIP + // Clip post orientation change + if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) + clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1); + #endif + break; + case GDISP_ROTATE_90: + t = GDISP.Height - 1 - y0; + y0 = x0; + x0 = t; + t = GDISP.Height - 1 - y1; + y1 = x1; + x1 = t; + #if GDISP_NEED_CLIP + // Clip post orientation change + if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) + clip = CreateRectRgn(GDISP.Height-1-GDISP.clipy1, GDISP.clipx0, GDISP.Height-1-GDISP.clipy0, GDISP.clipx1); + #endif + break; + case GDISP_ROTATE_180: + x0 = GDISP.Width - 1 - x0; + y0 = GDISP.Height - 1 - y0; + x1 = GDISP.Width - 1 - x1; + y1 = GDISP.Height - 1 - y1; + #if GDISP_NEED_CLIP + // Clip post orientation change + if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) + clip = CreateRectRgn(GDISP.Width-1-GDISP.clipx1, GDISP.Height-1-GDISP.clipy1, GDISP.Width-1-GDISP.clipx0, GDISP.Height-1-GDISP.clipy0); + #endif + break; + case GDISP_ROTATE_270: + t = GDISP.Width - 1 - x0; + x0 = y0; + y0 = t; + t = GDISP.Width - 1 - x1; + x1 = y1; + y1 = t; + #if GDISP_NEED_CLIP + // Clip post orientation change + if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) + clip = CreateRectRgn(GDISP.clipy0, GDISP.Width-1-GDISP.clipx1, GDISP.clipy1, GDISP.Width-1-GDISP.clipx0); + #endif + break; + } + #else + #if GDISP_NEED_CLIP + clip = NULL; + if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height) + clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1); + #endif + #endif + + color = COLOR2BGR(color); + pen = CreatePen(PS_SOLID, 1, color); + if (pen) { + // Draw the line in the buffer + #if GDISP_NEED_CLIP + if (clip) SelectClipRgn(dcBuffer, clip); + #endif + old = SelectObject(dcBuffer, pen); + MoveToEx(dcBuffer, x0, y0, &p); + LineTo(dcBuffer, x1, y1); + SelectObject(dcBuffer, old); + SetPixel(dcBuffer, x1, y1, color); + #if GDISP_NEED_CLIP + if (clip) SelectClipRgn(dcBuffer, NULL); + #endif + + #if WIN32_USE_MSG_REDRAW + rect.left = x0; rect.right = x1+1; + rect.top = y0; rect.bottom = y1+1; + InvalidateRect(winRootWindow, &rect, FALSE); + UpdateWindow(winRootWindow); + #else + // Redrawing the line on the screen is cheaper than invalidating the whole rectangular area + dc = GetDC(winRootWindow); + #if GDISP_NEED_CLIP + if (clip) SelectClipRgn(dc, clip); + #endif + old = SelectObject(dc, pen); + MoveToEx(dc, x0, y0, &p); + LineTo(dc, x1, y1); + SelectObject(dc, old); + SetPixel(dc, x1, y1, color); + #if GDISP_NEED_CLIP + if (clip) SelectClipRgn(dc, NULL); + #endif + ReleaseDC(winRootWindow, dc); + #endif + + DeleteObject(pen); + } + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void lld_gdisp_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + HDC dc; + RECT rect; + HBRUSH hbr; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + // Clip pre orientation change + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + #if GDISP_NEED_CONTROL + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + break; + case GDISP_ROTATE_90: + rect.top = x; + rect.bottom = rect.top+cx; + rect.right = GDISP.Height - y; + rect.left = rect.right-cy; + break; + case GDISP_ROTATE_180: + rect.bottom = GDISP.Height - y; + rect.top = rect.bottom-cy; + rect.right = GDISP.Width - x; + rect.left = rect.right-cx; + break; + case GDISP_ROTATE_270: + rect.bottom = GDISP.Width - x; + rect.top = rect.bottom-cx; + rect.left = y; + rect.right = rect.left+cy; + break; + } + #else + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + #endif + + color = COLOR2BGR(color); + hbr = CreateSolidBrush(color); + + if (hbr) { + // Fill the area + FillRect(dcBuffer, &rect, hbr); + + #if WIN32_USE_MSG_REDRAW + InvalidateRect(winRootWindow, &rect, FALSE); + UpdateWindow(winRootWindow); + #else + // Filling the area directly on the screen is likely to be cheaper than invalidating it + dc = GetDC(winRootWindow); + FillRect(dc, &rect, hbr); + ReleaseDC(winRootWindow, dc); + #endif + + DeleteObject(hbr); + } + } +#endif + +#if (GDISP_HARDWARE_BITFILLS && GDISP_NEED_CONTROL) || defined(__DOXYGEN__) + static pixel_t *rotateimg(coord_t cx, coord_t cy, coord_t srcx, coord_t srccx, const pixel_t *buffer) { + pixel_t *dstbuf; + pixel_t *dst; + const pixel_t *src; + size_t sz; + coord_t i, j; + + // Shortcut. + if (GDISP.Orientation == GDISP_ROTATE_0 && srcx == 0 && cx == srccx) + return (pixel_t *)buffer; + + // Allocate the destination buffer + sz = (size_t)cx * (size_t)cy; + if (!(dstbuf = (pixel_t *)malloc(sz * sizeof(pixel_t)))) + return 0; + + // Copy the bits we need + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + for(dst = dstbuf, src = buffer+srcx, j = 0; j < cy; j++) + for(i = 0; i < cx; i++, src += srccx - cx) + *dst++ = *src++; + break; + case GDISP_ROTATE_90: + for(src = buffer+srcx, j = 0; j < cy; j++) { + dst = dstbuf+cy-j-1; + for(i = 0; i < cx; i++, src += srccx - cx, dst += cy) + *dst = *src++; + } + break; + case GDISP_ROTATE_180: + for(dst = dstbuf+sz, src = buffer+srcx, j = 0; j < cy; j++) + for(i = 0; i < cx; i++, src += srccx - cx) + *--dst = *src++; + break; + case GDISP_ROTATE_270: + for(src = buffer+srcx, j = 0; j < cy; j++) { + dst = dstbuf+sz-cy+j; + for(i = 0; i < cx; i++, src += srccx - cx, dst -= cy) + *dst = *src++; + } + break; + } + return dstbuf; + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void lld_gdisp_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + BITMAPV4HEADER bmpInfo; + RECT rect; + #if GDISP_NEED_CONTROL + pixel_t *srcimg; + #endif + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + // Clip pre orientation change + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + // Make everything relative to the start of the line + buffer += srccx*srcy; + srcy = 0; + + memset(&bmpInfo, 0, sizeof(bmpInfo)); + bmpInfo.bV4Size = sizeof(bmpInfo); + bmpInfo.bV4Planes = 1; + bmpInfo.bV4BitCount = 32; + bmpInfo.bV4AlphaMask = 0; + bmpInfo.bV4RedMask = RGB2COLOR(255,0,0); + bmpInfo.bV4GreenMask = RGB2COLOR(0,255,0); + bmpInfo.bV4BlueMask = RGB2COLOR(0,0,255); + bmpInfo.bV4V4Compression = BI_BITFIELDS; + bmpInfo.bV4XPelsPerMeter = 3078; + bmpInfo.bV4YPelsPerMeter = 3078; + bmpInfo.bV4ClrUsed = 0; + bmpInfo.bV4ClrImportant = 0; + bmpInfo.bV4CSType = 0; //LCS_sRGB; + + #if GDISP_NEED_CONTROL + bmpInfo.bV4SizeImage = (cy*cx) * sizeof(pixel_t); + srcimg = rotateimg(cx, cy, srcx, srccx, buffer); + if (!srcimg) return; + + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + bmpInfo.bV4Width = cx; + bmpInfo.bV4Height = -cy; /* top-down image */ + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + break; + case GDISP_ROTATE_90: + bmpInfo.bV4Width = cy; + bmpInfo.bV4Height = -cx; /* top-down image */ + rect.top = x; + rect.bottom = rect.top+cx; + rect.right = GDISP.Height - y; + rect.left = rect.right-cy; + break; + case GDISP_ROTATE_180: + bmpInfo.bV4Width = cx; + bmpInfo.bV4Height = -cy; /* top-down image */ + rect.bottom = GDISP.Height - y; + rect.top = rect.bottom-cy; + rect.right = GDISP.Width - x; + rect.left = rect.right-cx; + break; + case GDISP_ROTATE_270: + bmpInfo.bV4Width = cy; + bmpInfo.bV4Height = -cx; /* top-down image */ + rect.bottom = GDISP.Width - x; + rect.top = rect.bottom-cx; + rect.left = y; + rect.right = rect.left+cy; + break; + } + SetDIBitsToDevice(dcBuffer, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0, 0, 0, rect.bottom-rect.top, srcimg, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS); + if (srcimg != (pixel_t *)buffer) + free(srcimg); + + #else + bmpInfo.bV4Width = srccx; + bmpInfo.bV4Height = -cy; /* top-down image */ + bmpInfo.bV4SizeImage = (cy*srccx) * sizeof(pixel_t); + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + SetDIBitsToDevice(dcBuffer, x, y, cx, cy, srcx, 0, 0, cy, buffer, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS); + #endif + + // Invalidate the region to get it on the screen. + InvalidateRect(winRootWindow, &rect, FALSE); + UpdateWindow(winRootWindow); + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * @return The color of the specified pixel. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { + color_t color; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + // Clip pre orientation change + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; + #endif + + #if GDISP_NEED_CONTROL + switch(GDISP.Orientation) { + case GDISP_ROTATE_90: + t = GDISP.Height - 1 - y; + y = x; + x = t; + break; + case GDISP_ROTATE_180: + x = GDISP.Width - 1 - x; + y = GDISP.Height - 1 - y; + break; + case GDISP_ROTATE_270: + t = GDISP.Width - 1 - x; + x = y; + y = t; + break; + } + #endif + + color = GetPixel(dcBuffer, x, y); + return BGR2COLOR(color); + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + RECT rect, frect, srect; + HBRUSH hbr; + + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + // Clip pre orientation change + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; + #endif + + if (lines > cy) lines = cy; + else if (-lines > cy) lines = -cy; + + bgcolor = COLOR2BGR(bgcolor); + hbr = CreateSolidBrush(bgcolor); + + #if GDISP_NEED_CONTROL + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + lines = -lines; + goto vertical_scroll; + case GDISP_ROTATE_90: + rect.top = x; + rect.bottom = rect.top+cx; + rect.right = GDISP.Height - y; + rect.left = rect.right-cy; + goto horizontal_scroll; + case GDISP_ROTATE_180: + rect.bottom = GDISP.Height - y; + rect.top = rect.bottom-cy; + rect.right = GDISP.Width - x; + rect.left = rect.right-cx; + vertical_scroll: + srect.left = frect.left = rect.left; + srect.right = frect.right = rect.right; + if (lines > 0) { + srect.top = frect.top = rect.top; + frect.bottom = rect.top+lines; + srect.bottom = rect.bottom-lines; + } else { + srect.bottom = frect.bottom = rect.bottom; + frect.top = rect.bottom+lines; + srect.top = rect.top-lines; + } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); + break; + case GDISP_ROTATE_270: + rect.bottom = GDISP.Width - x; + rect.top = rect.bottom-cx; + rect.left = y; + rect.right = rect.left+cy; + lines = -lines; + horizontal_scroll: + srect.top = frect.top = rect.top; + srect.bottom = frect.bottom = rect.bottom; + if (lines > 0) { + srect.left = frect.left = rect.left; + frect.right = rect.left+lines; + srect.right = rect.right-lines; + } else { + srect.right = frect.right = rect.right; + frect.left = rect.right+lines; + srect.left = rect.left-lines; + } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, lines, 0, &srect, 0, 0, 0); + break; + } + #else + rect.top = y; + rect.bottom = rect.top+cy; + rect.left = x; + rect.right = rect.left+cx; + lines = -lines; + srect.left = frect.left = rect.left; + srect.right = frect.right = rect.right; + if (lines > 0) { + srect.top = frect.top = rect.top; + frect.bottom = rect.top+lines; + srect.bottom = rect.bottom-lines; + } else { + srect.bottom = frect.bottom = rect.bottom; + frect.top = rect.bottom+lines; + srect.top = rect.top-lines; + } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); + #endif + + if (hbr) + FillRect(dcBuffer, &frect, hbr); + InvalidateRect(winRootWindow, &rect, FALSE); + UpdateWindow(winRootWindow); + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void lld_gdisp_control(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case GDISP_ROTATE_0: + GDISP.Width = wWidth; + GDISP.Height = wHeight; + break; + case GDISP_ROTATE_90: + GDISP.Height = wWidth; + GDISP.Width = wHeight; + break; + case GDISP_ROTATE_180: + GDISP.Width = wWidth; + GDISP.Height = wHeight; + break; + case GDISP_ROTATE_270: + GDISP.Height = wWidth; + GDISP.Width = wHeight; + break; + default: + return; + } + + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_POWER: + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#if GINPUT_NEED_MOUSE + + void ginput_lld_mouse_init(void) {} + + void ginput_lld_mouse_get_reading(MouseReading *pt) { + pt->x = mousex; + pt->y = mousey > wHeight ? wHeight : mousey; + pt->z = (mousebuttons & GINPUT_MOUSE_BTN_LEFT) ? 100 : 0; + pt->buttons = mousebuttons; + } + +#endif /* GINPUT_NEED_MOUSE */ + +#if GINPUT_NEED_TOGGLE + + void ginput_lld_toggle_init(const GToggleConfig *ptc) { (void) ptc; } + unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { (void) ptc; return toggles; } + +#endif /* GINPUT_NEED_MOUSE */ + +#endif /* GFX_USE_GDISP */ +/** @} */ + diff --git a/drivers/multiple/Win32/gdisp_lld.mk b/drivers/multiple/Win32/gdisp_lld.mk new file mode 100644 index 00000000..b116088b --- /dev/null +++ b/drivers/multiple/Win32/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/multiple/Win32/gdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/multiple/Win32 diff --git a/drivers/multiple/Win32/gdisp_lld_config.h b/drivers/multiple/Win32/gdisp_lld_config.h new file mode 100644 index 00000000..bebd76b9 --- /dev/null +++ b/drivers/multiple/Win32/gdisp_lld_config.h @@ -0,0 +1,54 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS-GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/multiple/Win32/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for Win32. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "Win32" +#define GDISP_LLD(x) gdisp_lld_##x##_Win32 + +#define GDISP_HARDWARE_LINES TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ + diff --git a/drivers/multiple/Win32/ginput_lld_mouse_config.h b/drivers/multiple/Win32/ginput_lld_mouse_config.h new file mode 100644 index 00000000..ceeedcb9 --- /dev/null +++ b/drivers/multiple/Win32/ginput_lld_mouse_config.h @@ -0,0 +1,62 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file drivers/multiple/Win32/ginput_lld_mouse_config.h + * @brief GINPUT LLD header file for mouse/touch driver. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _LLD_GINPUT_MOUSE_CONFIG_H +#define _LLD_GINPUT_MOUSE_CONFIG_H + +// This driver supports being both a mouse or a touch device (we don't actually know which it really is) +// When operating in mouse mode a long left button click does not generate a context click. +// When operating in touch mode we allow sloppier clicks etc +#if 1 + #define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE + #define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click + #define GINPUT_MOUSE_NEED_CALIBRATION FALSE + #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE + #define GINPUT_MOUSE_READ_CYCLES 1 + #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1 + #define GINPUT_MOUSE_MAX_CLICK_JITTER 0 + #define GINPUT_MOUSE_MAX_MOVE_JITTER 0 +#else + #define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH + #define GINPUT_MOUSE_CLICK_TIME 700 // Long click = Context Click + #define GINPUT_MOUSE_NEED_CALIBRATION FALSE // Can be set to TRUE just for testing + #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE + #define GINPUT_MOUSE_READ_CYCLES 1 + #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 2 + #define GINPUT_MOUSE_MAX_CLICK_JITTER 2 + #define GINPUT_MOUSE_MAX_MOVE_JITTER 2 +#endif + +// This driver supports both an "interrupt" mode, and a polled mode +#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread +//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven + +#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ +/** @} */ + diff --git a/drivers/multiple/Win32/ginput_lld_toggle_config.h b/drivers/multiple/Win32/ginput_lld_toggle_config.h new file mode 100644 index 00000000..84ebaaa2 --- /dev/null +++ b/drivers/multiple/Win32/ginput_lld_toggle_config.h @@ -0,0 +1,54 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/multiple/Win32/ginput_lld_toggle_config.h + * @brief GINPUT Toggle Driver configuration header. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * + * @{ + */ + +#ifndef _GINPUT_LLD_TOGGLE_CONFIG_H +#define _GINPUT_LLD_TOGGLE_CONFIG_H + +#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE + +#define GINPUT_TOGGLE_POLL_PERIOD TIME_INFINITE // We are interrupt driven (or polled - ether works here) +#define GINPUT_TOGGLE_NUM_PORTS 8 // The total number of toggle inputs +#define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries + +#define GINPUT_TOGGLE_SW1 0 // Switch 1 - Toggle +#define GINPUT_TOGGLE_SW2 1 // Switch 2 - Toggle +#define GINPUT_TOGGLE_SW3 2 // Switch 3 - Toggle +#define GINPUT_TOGGLE_SW4 3 // Switch 4 - Toggle + +#define GINPUT_TOGGLE_MOMENTARY1 4 // Switch 5 - Momentary +#define GINPUT_TOGGLE_MOMENTARY2 5 // Switch 6 - Momentary +#define GINPUT_TOGGLE_MOMENTARY3 6 // Switch 7 - Momentary +#define GINPUT_TOGGLE_MOMENTARY4 7 // Switch 8 - Momentary + +#endif /* GFX_USE_GDISP && GINPUT_NEED_TOGGLE */ + +#endif /* _GINPUT_LLD_TOGGLE_CONFIG_H */ +/** @} */ + diff --git a/drivers/multiple/Win32/readme.txt b/drivers/multiple/Win32/readme.txt new file mode 100644 index 00000000..6151f2f2 --- /dev/null +++ b/drivers/multiple/Win32/readme.txt @@ -0,0 +1,22 @@ +To use this driver: + +This driver is special in that it implements both the gdisp low level driver +and a touchscreen driver. + +1. Add in your halconf.h: + a) #define GFX_USE_GDISP TRUE + b) #define GFX_USE_GINPUT TRUE + #define GINPUT_USE_MOUSE TRUE + c) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + d) All of the following (with appropriate values): + #define GDISP_SCREEN_WIDTH 640 + #define GDISP_SCREEN_HEIGHT 480 + + +2. To your makefile add the following lines: + include $(GFXLIB)/gfx.mk + include $(GFXLIB)/drivers/multiple/Win32/gdisp_lld.mk + +3. Modify your makefile to add -lgdi32 to the DLIBS line. i.e. + DLIBS = -lws2_32 -lgdi32 + diff --git a/drivers/tdisp/HD44780/tdisp_lld.c b/drivers/tdisp/HD44780/tdisp_lld.c new file mode 100644 index 00000000..d0f4af0d --- /dev/null +++ b/drivers/tdisp/HD44780/tdisp_lld.c @@ -0,0 +1,153 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/tdisp/HD44780/tdisp_lld.c + * @brief TDISP driver subsystem low level driver source for the HD44780 display + * + * @addtogroup TDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/ + +#include "tdisp_lld_board_example.h" + +static void _writeData(uint8_t data) { + write_bus(data); + + setpin_e(TRUE); + chThdSleepMicroseconds(1); + setpin_e(FALSE); + chThdSleepMicroseconds(5); +} + +void tdisp_lld_write_cmd(uint8_t data) { + setpin_rs(FALSE); + setpin_rw(FALSE); + + #if TDISP_NEED_4BIT_MODE + _writeData(data>>4); + #endif + _writeData(data); +} + +void tdisp_lld_write_data(uint8_t data) { + setpin_rs(TRUE); + setpin_rw(FALSE); + + #if TDISP_NEED_4BIT_MODE + _writeData(data>>4); + #endif + _writeData(data); +} + +bool_t tdisp_lld_init(void) { + /* initialise MCU hardware */ + init_board(); + + /* wait some time */ + chThdSleepMilliseconds(50); + + tdisp_lld_write_cmd(0x38); + chThdSleepMilliseconds(64); + + tdisp_lld_write_cmd(0x0f); + chThdSleepMicroseconds(50); + + tdisp_lld_write_cmd(0x01); + chThdSleepMilliseconds(5); + + tdisp_lld_write_cmd(0x06); + chThdSleepMicroseconds(50); + + return TRUE; +} + +void tdisp_lld_set_cursor(coord_t col, coord_t row) { + uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + + if(row >= TDISP_ROWS) + row = TDISP_ROWS - 1; + + tdisp_lld_write_cmd(0x80 | (col + row_offsets[row])); +} + +void tdisp_lld_create_char(uint8_t address, char *charmap) { + uint8_t i; + + /* make sure we don't write somewhere we're not supposed to */ + address &= TDISP_MAX_CUSTOM_CHARS; + + tdisp_lld_write_cmd(0x40 | (address << 3)); + + for(i = 0; i < 8; i++) { + tdisp_lld_write_data(charmap[i]); + } +} + +void tdisp_lld_clear(void) { + tdisp_lld_write_cmd(0x01); +} + +void tdisp_lld_home(void) { + tdisp_lld_write_cmd(0x02); +} + +void tdisp_lld_control(uint16_t what, void *value) { + (void)what; + (void)value; +/* + switch(attributes) { + case TDISP_ON: + _displaycontrol |= 0x04; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + case TDISP_OFF: + _displaycontrol &=~ 0x04; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + case TDISP_CURSOR_ON: + _displaycontrol |= 0x02; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + case TDISP_CURSOR_OFF: + _displaycontrol &=~ 0x02; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + case TDISP_CURSOR_BLINK_ON: + _displaycontrol |= 0x00; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + case TDISP_CURSOR_BLINK_OFF: + _displaycontrol &=~ 0x00; + tdisp_lld_write_cmd(0x08 | _displaycontrol); + break; + } +*/ +} + +#endif /* GFX_USE_TDISP */ +/** @} */ + diff --git a/drivers/tdisp/HD44780/tdisp_lld.mk b/drivers/tdisp/HD44780/tdisp_lld.mk new file mode 100644 index 00000000..88780bea --- /dev/null +++ b/drivers/tdisp/HD44780/tdisp_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/tdisp/HD44780/tdisp_lld.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/tdisp/HD44780 + diff --git a/drivers/tdisp/HD44780/tdisp_lld_board_example.h b/drivers/tdisp/HD44780/tdisp_lld_board_example.h new file mode 100644 index 00000000..3f5c47d7 --- /dev/null +++ b/drivers/tdisp/HD44780/tdisp_lld_board_example.h @@ -0,0 +1,64 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/tdisp/HD44780/tdisp_lld_board_example.h + * @brief TDISP driver subsystem board interface for the HD44780 display + * + * @addtogroup TDISP + * @{ + */ + +#ifndef _TDISP_LLD_BOARD_H +#define _TDISP_LLD_BOARD_H + +void init_board(void) { + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); + palSetGroupMode(GPIOG, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); +} + +void setpin_e(bool_t state) { + if(state) + palSetPad(GPIOE, 2); + else + palClearPad(GPIOE, 2); +} + +void setpin_rs(bool_t state) { + if(state) + palSetPad(GPIOE, 0); + else + palClearPad(GPIOE, 0); +} + +void setpin_rw(bool_t state) { + if(state) + palSetPad(GPIOE, 1); + else + palClearPad(GPIOE, 1); +} + +void write_bus(uint8_t data) { + palWritePort(GPIOG, data); +} + +#endif /* _TDISP_LLD_BOARD_H */ +/** @} */ + diff --git a/drivers/tdisp/HD44780/tdisp_lld_config.h b/drivers/tdisp/HD44780/tdisp_lld_config.h new file mode 100644 index 00000000..3b37cd70 --- /dev/null +++ b/drivers/tdisp/HD44780/tdisp_lld_config.h @@ -0,0 +1,45 @@ +/* + ChibiOS/GFX - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file drivers/tdisp/HD44780/tdisp_lld_config.h + * @brief TDISP Driver subsystem low level driver header for the HD44780 display. + * + * @addtogroup TDISP + * @{ + */ + +#ifndef _TDISP_LLD_CONFIG_H +#define _TDISP_LLD_CONFIG_H + +#if GFX_USE_TDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TDISP_DRIVER_NAME "HD44780" + +#define TDISP_MAX_CUSTOM_CHARS 0x07 + +#endif /* GFX_USE_TDISP */ + +#endif /* _TDISP_LLD_CONFIG_H */ +/** @} */ -- cgit v1.2.3 From 60b16e86858a12d513292c36f6aa265d8f19033a Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 11 Feb 2013 10:26:34 +0100 Subject: more GDISP_LLD() cleanup --- drivers/gdisp/ILI9320/gdisp_lld.c | 30 +-- drivers/gdisp/ILI9320/gdisp_lld_board_example.h | 12 +- .../ILI9320/gdisp_lld_board_olimex_stm32_lcd.h | 12 +- drivers/gdisp/ILI9320/gdisp_lld_config.h | 1 - drivers/gdisp/ILI9325/gdisp_lld.c | 30 +-- drivers/gdisp/ILI9325/gdisp_lld_board_example.h | 12 +- .../gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h | 12 +- drivers/gdisp/ILI9325/gdisp_lld_config.h | 1 - drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h | 1 - drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h | 1 - drivers/gdisp/S6D1121/gdisp_lld.c | 2 +- drivers/gdisp/S6D1121/gdisp_lld_config.h | 1 - drivers/gdisp/SSD1289/gdisp_lld_config.h | 1 - drivers/gdisp/TestStub/gdisp_lld_config.h | 1 - drivers/gdisp/VMT/gdisp_lld.c | 271 --------------------- drivers/gdisp/VMT/gdisp_lld.mk | 7 - drivers/gdisp/VMT/gdisp_lld_config.h | 71 ------ drivers/gdisp/VMT/gdisp_lld_driver1.c | 52 ---- drivers/gdisp/VMT/gdisp_lld_driver2.c | 52 ---- drivers/gdisp/VMT/readme.txt | 23 -- drivers/multiple/Win32/gdisp_lld_config.h | 1 - 21 files changed, 55 insertions(+), 539 deletions(-) delete mode 100644 drivers/gdisp/VMT/gdisp_lld.c delete mode 100644 drivers/gdisp/VMT/gdisp_lld.mk delete mode 100644 drivers/gdisp/VMT/gdisp_lld_config.h delete mode 100644 drivers/gdisp/VMT/gdisp_lld_driver1.c delete mode 100644 drivers/gdisp/VMT/gdisp_lld_driver2.c delete mode 100644 drivers/gdisp/VMT/readme.txt (limited to 'drivers') diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c index c4468b6d..6a324cd4 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld.c +++ b/drivers/gdisp/ILI9320/gdisp_lld.c @@ -81,28 +81,28 @@ static __inline void lld_lcdDelay(uint16_t us) { } static __inline void lld_lcdWriteIndex(uint16_t index) { - GDISP_LLD(write_index)(index); + lld_gdisp_write_index(index); } static __inline void lld_lcdWriteData(uint16_t data) { - GDISP_LLD(write_data)(data); + lld_gdisp_write_data(data); } static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - GDISP_LLD(write_index)(lcdReg); - GDISP_LLD(write_data)(lcdRegValue); + lld_gdisp_write_index(lcdReg); + lld_gdisp_write_data(lcdRegValue); } static __inline uint16_t lld_lcdReadData(void) { /* fix this! */ - //return GDISP_LLD(read_data); + //return lld_gdisp_read_data; return GDISP_RAM; } static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { volatile uint16_t dummy; - GDISP_LLD(write_index)(lcdReg); + lld_gdisp_write_index(lcdReg); dummy = lld_lcdReadData(); (void)dummy; @@ -145,12 +145,12 @@ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { bool_t lld_gdisp_init(void) { /* Initialise your display */ - GDISP_LLD(init_board)(); + lld_gdisp_init_board(); /* Hardware reset */ - GDISP_LLD(setpin_reset)(TRUE); + lld_gdisp_reset_pin(TRUE); lld_lcdDelay(1000); - GDISP_LLD(setpin_reset)(FALSE); + lld_gdisp_reset_pin(FALSE); lld_lcdDelay(1000); DISPLAY_CODE = lld_lcdReadReg(0); @@ -215,7 +215,7 @@ bool_t lld_gdisp_init(void) { lld_lcdWriteReg(0x0007, 0x0173); //display On // Turn on the backlight - GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); + lld_gdisp_backlight(GDISP_INITIAL_BACKLIGHT); /* Initialise the GDISP structure */ GDISP.Width = GDISP_SCREEN_WIDTH; @@ -457,7 +457,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0011, 0x0000); lld_lcdWriteReg(0x0012, 0x0000); lld_lcdWriteReg(0x0013, 0x0000); - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; case powerOn: @@ -476,7 +476,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ lld_lcdDelay(500); lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ - GDISP_LLD(set_backlight)(GDISP.Backlight); + lld_gdisp_backlight(GDISP.Backlight); if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) lld_gdisp_init(); break; @@ -489,7 +489,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; case powerDeepSleep: @@ -500,7 +500,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; default: @@ -554,7 +554,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { case GDISP_CONTROL_BACKLIGHT: if((unsigned)value > 100) value = (void *)100; - GDISP_LLD(set_backlight)((unsigned)value); + lld_gdisp_backlight((unsigned)value); GDISP.Backlight = (unsigned)value; break; diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_example.h b/drivers/gdisp/ILI9320/gdisp_lld_board_example.h index a79e557b..f07b34c6 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld_board_example.h +++ b/drivers/gdisp/ILI9320/gdisp_lld_board_example.h @@ -29,28 +29,28 @@ #ifndef GDISP_LLD_BOARD_H #define GDISP_LLD_BOARD_H -static __inline void GDISP_LLD(init_board)(void) { +static __inline void lld_gdisp_init_board(void) { #error "ILI9320: You must implement the init_board routine for your board" } -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { +static __inline void lld_gdisp_reset_pin(bool_t state) { #error "ILI9320: You must implement setpin_reset routine for your board" } -static __inline void GDISP_LLD(write_index)(uint16_t data) { +static __inline void lld_gdisp_write_index(uint16_t data) { #error "ILI9320: You must implement write_index routine for your board" } -static __inline void GDISP_LLD(write_data)(uint16_t data) { +static __inline void lld_gdisp_write_data(uint16_t data) { #error "ILI9320: You must implement write_data routine for your board" } -static __inline uint16_t GDISP_LLD(read_data)(void) { +static __inline uint16_t lld_gdisp_read_data(void) { #error "ILI9320: You must implement read_data routine for your board" } /* if not available, just ignore the argument and return */ -static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { +static __inline uint16_t lld_gdisp_backlight(uint8_t percentage) { #error "ILI9320: You must implement set_backlight routine for your board" } diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h index a6d9d631..d2d54ce9 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h +++ b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h @@ -32,7 +32,7 @@ #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ #define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* RS = 1 */ -static __inline void GDISP_LLD(init_board)(void) { +static __inline void lld_gdisp_init_board(void) { /* FSMC setup for F1 */ rccEnableAHB(RCC_AHBENR_FSMCEN, 0); @@ -54,26 +54,26 @@ static __inline void GDISP_LLD(init_board)(void) { FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; } -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { +static __inline void lld_gdisp_reset_pin(bool_t state) { if(state) palClearPad(GPIOE, GPIOE_TFT_RST); else palSetPad(GPIOE, GPIOE_TFT_RST); } -static __inline void GDISP_LLD(write_index)(uint16_t reg) { +static __inline void lld_gdisp_write_index(uint16_t reg) { GDISP_REG = reg; } -static __inline void GDISP_LLD(write_data)(uint16_t data) { +static __inline void lld_gdisp_write_data(uint16_t data) { GDISP_RAM = data; } -static __inline uint16_t GDISP_LLD(read_data)(void) { +static __inline uint16_t lld_gdisp_read_data(void) { return GDISP_RAM; } -static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { +static __inline void lld_gdisp_backlight(uint8_t percent) { if(percent == 100) palClearPad(GPIOD, GPIOD_TFT_LIGHT); else diff --git a/drivers/gdisp/ILI9320/gdisp_lld_config.h b/drivers/gdisp/ILI9320/gdisp_lld_config.h index d55f2115..1606ce95 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld_config.h +++ b/drivers/gdisp/ILI9320/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "ILI9320" -#define GDISP_LLD(x) gdisp_lld_##x##_ILI9320 #define GDISP_HARDWARE_CLEARS TRUE #define GDISP_HARDWARE_FILLS TRUE diff --git a/drivers/gdisp/ILI9325/gdisp_lld.c b/drivers/gdisp/ILI9325/gdisp_lld.c index bc2b6dd5..e9500cc5 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld.c +++ b/drivers/gdisp/ILI9325/gdisp_lld.c @@ -81,28 +81,28 @@ static __inline void lld_lcdDelay(uint16_t us) { } static __inline void lld_lcdWriteIndex(uint16_t index) { - GDISP_LLD(write_index)(index); + lld_gdisp_write_index(index); } static __inline void lld_lcdWriteData(uint16_t data) { - GDISP_LLD(write_data)(data); + lld_gdisp_write_data(data); } static __inline void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - GDISP_LLD(write_index)(lcdReg); - GDISP_LLD(write_data)(lcdRegValue); + lld_gdisp_write_index(lcdReg); + lld_gdisp_write_data(lcdRegValue); } static __inline uint16_t lld_lcdReadData(void) { /* fix this! */ - //return GDISP_LLD(read_data); + //return lld_gdisp_read_data; return GDISP_RAM; } static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { volatile uint16_t dummy; - GDISP_LLD(write_index)(lcdReg); + lld_gdisp_write_index(lcdReg); dummy = lld_lcdReadData(); (void)dummy; @@ -145,12 +145,12 @@ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { bool_t lld_gdisp_init(void) { /* Initialise your display */ - GDISP_LLD(init_board)(); + lld_gdisp_init_board(); /* Hardware reset */ - GDISP_LLD(setpin_reset)(TRUE); + lld_gdisp_reset_pin(TRUE); lld_lcdDelay(1000); - GDISP_LLD(setpin_reset)(FALSE); + lld_gdisp_reset_pin(FALSE); lld_lcdDelay(1000); // chinese code starts here @@ -210,7 +210,7 @@ bool_t lld_gdisp_init(void) { // chinese code ends here // Turn on the backlight - GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT); + lld_gdisp_backlight(GDISP_INITIAL_BACKLIGHT); /* Initialise the GDISP structure */ GDISP.Width = GDISP_SCREEN_WIDTH; @@ -461,7 +461,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0011, 0x0000); lld_lcdWriteReg(0x0012, 0x0000); lld_lcdWriteReg(0x0013, 0x0000); - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; case powerOn: @@ -480,7 +480,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */ lld_lcdDelay(500); lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */ - GDISP_LLD(set_backlight)(GDISP.Backlight); + lld_gdisp_backlight(GDISP.Backlight); if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep) lld_gdisp_init(); break; @@ -493,7 +493,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; case powerDeepSleep: @@ -504,7 +504,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */ lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */ - GDISP_LLD(set_backlight)(0); + lld_gdisp_backlight(0); break; default: @@ -564,7 +564,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { case GDISP_CONTROL_BACKLIGHT: if((unsigned)value > 100) value = (void *)100; - GDISP_LLD(set_backlight)((unsigned)value); + lld_gdisp_backlight((unsigned)value); GDISP.Backlight = (unsigned)value; break; diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_example.h b/drivers/gdisp/ILI9325/gdisp_lld_board_example.h index 7b537dcd..547952ee 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld_board_example.h +++ b/drivers/gdisp/ILI9325/gdisp_lld_board_example.h @@ -29,28 +29,28 @@ #ifndef GDISP_LLD_BOARD_H #define GDISP_LLD_BOARD_H -static __inline void GDISP_LLD(init_board)(void) { +static __inline void lld_gdisp_init_board(void) { #error "ILI9325: You must implement the init_board routine for your board" } -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { +static __inline void lld_gdisp_reset_pin(bool_t state) { #error "ILI9325: You must implement setpin_reset routine for your board" } -static __inline void GDISP_LLD(write_index)(uint16_t data) { +static __inline void lld_gdisp_write_index(uint16_t data) { #error "ILI9325: You must implement write_index routine for your board" } -static __inline void GDISP_LLD(write_data)(uint16_t data) { +static __inline void lld_gdisp_write_data(uint16_t data) { #error "ILI9325: You must implement write_data routine for your board" } -static __inline uint16_t GDISP_LLD(read_data)(void) { +static __inline uint16_t lld_gdisp_read_data(void) { #error "ILI9325: You must implement read_data routine for your board" } /* if not available, just ignore the argument and return */ -static __inline uint16_t GDISP_LLD(set_backlight)(uint8_t percentage) { +static __inline uint16_t lld_gdisp_backlight(uint8_t percentage) { #error "ILI9325: You must implement set_backlight routine for your board" } diff --git a/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h b/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h index e785ad10..94d418b0 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h +++ b/drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h @@ -45,7 +45,7 @@ #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ -static __inline void GDISP_LLD(init_board)(void) { +static __inline void lld_gdisp_init_board(void) { /* FSMC setup for F1 */ rccEnableAHB(RCC_AHBENR_FSMCEN, 0); @@ -68,26 +68,26 @@ static __inline void GDISP_LLD(init_board)(void) { } -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { +static __inline void lld_gdisp_reset_pin(bool_t state) { if(state) palClearPad(GPIOE, GPIOE_TFT_RST); else palSetPad(GPIOE, GPIOE_TFT_RST); } -static __inline void GDISP_LLD(write_index)(uint16_t reg) { +static __inline void lld_gdisp_write_index(uint16_t reg) { GDISP_REG = reg; } -static __inline void GDISP_LLD(write_data)(uint16_t data) { +static __inline void lld_gdisp_write_data(uint16_t data) { GDISP_RAM = data; } -static __inline uint16_t GDISP_LLD(read_data)(void) { +static __inline uint16_t lld_gdisp_read_data(void) { return GDISP_RAM; } -static __inline void GDISP_LLD(set_backlight)(uint8_t percent) { +static __inline void lld_gdisp_backlight(uint8_t percent) { percent=percent; // avoid a warning } diff --git a/drivers/gdisp/ILI9325/gdisp_lld_config.h b/drivers/gdisp/ILI9325/gdisp_lld_config.h index 44f8323f..414fc05e 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld_config.h +++ b/drivers/gdisp/ILI9325/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "ILI9325" -#define GDISP_LLD(x) gdisp_lld_##x##_ILI9325 #define GDISP_HARDWARE_CLEARS TRUE #define GDISP_HARDWARE_FILLS TRUE diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h index ab9d35e7..9db24e26 100644 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "Nokia6610GE12" -#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE12 #define GDISP_HARDWARE_FILLS TRUE #define GDISP_HARDWARE_BITFILLS TRUE diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h b/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h index 87bdb824..c50e26f1 100644 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "Nokia6610GE8" -#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610GE8 #define GDISP_HARDWARE_FILLS TRUE #define GDISP_HARDWARE_BITFILLS TRUE diff --git a/drivers/gdisp/S6D1121/gdisp_lld.c b/drivers/gdisp/S6D1121/gdisp_lld.c index 0d856c79..863e5e46 100644 --- a/drivers/gdisp/S6D1121/gdisp_lld.c +++ b/drivers/gdisp/S6D1121/gdisp_lld.c @@ -508,7 +508,7 @@ void lld_gdisp_draw_pixel(coord_t x, coord_t y, color_t color) { /* Code here */ /* You may need this --- if (GDISP.Powermode != powerSleep) - GDISP_LLD(init(); + lld_gdisp_init(); */ /* break; */ case powerSleep: diff --git a/drivers/gdisp/S6D1121/gdisp_lld_config.h b/drivers/gdisp/S6D1121/gdisp_lld_config.h index c662d0e7..00c01da2 100644 --- a/drivers/gdisp/S6D1121/gdisp_lld_config.h +++ b/drivers/gdisp/S6D1121/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "S6D1121" -#define GDISP_LLD(x) gdisp_lld_##x##_S6D1121 #define GDISP_HARDWARE_CLEARS TRUE #define GDISP_HARDWARE_FILLS TRUE diff --git a/drivers/gdisp/SSD1289/gdisp_lld_config.h b/drivers/gdisp/SSD1289/gdisp_lld_config.h index dafbc90f..62b3c7b9 100644 --- a/drivers/gdisp/SSD1289/gdisp_lld_config.h +++ b/drivers/gdisp/SSD1289/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "SSD1289" -#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289 #define GDISP_HARDWARE_CLEARS TRUE #define GDISP_HARDWARE_FILLS TRUE diff --git a/drivers/gdisp/TestStub/gdisp_lld_config.h b/drivers/gdisp/TestStub/gdisp_lld_config.h index 18c2de59..8ae82ff4 100644 --- a/drivers/gdisp/TestStub/gdisp_lld_config.h +++ b/drivers/gdisp/TestStub/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "TestStub" -#define GDISP_LLD(x) gdisp_lld_##x##_TestStub #define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL #define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD diff --git a/drivers/gdisp/VMT/gdisp_lld.c b/drivers/gdisp/VMT/gdisp_lld.c deleted file mode 100644 index 9d9c7382..00000000 --- a/drivers/gdisp/VMT/gdisp_lld.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gfx.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define GDISP_LLD_NO_STRUCT - -/* Include the emulation code for things we don't support */ -#include "gdisp/lld/emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_) -#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_) - -/* Prototypes for lld driver functions */ -bool_t GDISP_LLD1(init)(void); -void *GDISP_LLD1(query)(unsigned what); -void GDISP_LLD1(clear)(color_t color); -void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD1(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CLIP - void GDISP_LLD1(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif -#if GDISP_NEED_CIRCLE - void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_ARC - void GDISP_LLD1(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); - void GDISP_LLD1(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD1(control)(unsigned what, void *value); -#endif - -bool_t GDISP_LLD2(init)(void); -void *GDISP_LLD2(query)(unsigned what); -void GDISP_LLD2(clear)(color_t color); -void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD2(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CLIP - void GDISP_LLD2(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif -#if GDISP_NEED_CIRCLE - void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_ARC - void GDISP_LLD2(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); - void GDISP_LLD2(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD2(control)(unsigned what, void *value); -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/* Our VMT table variables */ -void *GDISP_LLD_VMT(query)(unsigned what); -void GDISP_LLD_VMT(clear)(color_t color); -void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD_VMT(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); -void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); - -#if GDISP_NEED_CIRCLE -void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif - -#if GDISP_NEED_ELLIPSE -void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif - -/* Text Rendering Functions */ -#if GDISP_NEED_TEXT -void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); -void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif - -/* Pixel readback */ -#if GDISP_NEED_PIXELREAD -color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); -#endif - -/* Scrolling Function - clears the area scrolled out */ -#if GDISP_NEED_SCROLL -void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif - -/* Set driver specific control */ -#if GDISP_NEED_CONTROL -void GDISP_LLD_VMT(control)(unsigned what, void *value); -#endif -/* Clipping Functions */ -#if GDISP_NEED_CLIP -void GDISP_LLD_VMT(setclip)(coord_t x, coord_t y, coord_t cx, coord_t cy); -#endif - - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -bool_t gdisp_lld_init_VMT(void) { - if (GDISP_VMT_NAME1(gdisp_lld_init_)()) { - gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_); - gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_); - gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME1(gdisp_lld_blitareaex_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_ARC - gdisp_lld_drawarc_VMT = GDISP_VMT_NAME1(gdisp_lld_drawarc_); - gdisp_lld_fillarc_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarc_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_); - #endif - #if GDISP_NEED_CLIP - gdisp_lld_setclip_VMT = GDISP_VMT_NAME1(gdisp_lld_setclip_); - #endif - - return TRUE; - } - - if (GDISP_VMT_NAME2(gdisp_lld_init_)()) { - gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_); - gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_); - gdisp_lld_blitareaex_VMT = GDISP_VMT_NAME2(gdisp_lld_blitareaex_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_ARC - gdisp_lld_drawarc_VMT = GDISP_VMT_NAME2(gdisp_lld_drawarc_); - gdisp_lld_fillarc_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarc_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_); - #endif - #if GDISP_NEED_CLIP - gdisp_lld_setclip_VMT = GDISP_VMT_NAME2(gdisp_lld_setclip_); - #endif - - return TRUE; - } - return FALSE; -} - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld.mk b/drivers/gdisp/VMT/gdisp_lld.mk deleted file mode 100644 index 96918f8a..00000000 --- a/drivers/gdisp/VMT/gdisp_lld.mk +++ /dev/null @@ -1,7 +0,0 @@ -# List the required driver. -GFXSRC += $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld.c \ - $(GFXLIB)/drivers/gdisp/VMT/gdisp_lld_driver1.c \ - $(GFXLIB)//drivers/gdisp/VMT/gdisp_lld_driver2.c - -# Required include directories -GFXINC += $(GFXLIB)/drivers/gdisp/VMT diff --git a/drivers/gdisp/VMT/gdisp_lld_config.h b/drivers/gdisp/VMT/gdisp_lld_config.h deleted file mode 100644 index 8c7bfc9c..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_config.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header template. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if GFX_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "VMT" -#define GDISP_LLD(x) gdisp_lld_##x##_VMT -#define GDISP_LLD_VMT(x) (*GDISP_LLD(x)) - -#define GDISP_HARDWARE_LINES TRUE -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES TRUE -#define GDISP_HARDWARE_CIRCLEFILLS TRUE -#define GDISP_HARDWARE_ELLIPSES TRUE -#define GDISP_HARDWARE_ELLIPSEFILLS TRUE -#define GDISP_HARDWARE_ARCS TRUE -#define GDISP_HARDWARE_ARCFILLS TRUE -#define GDISP_HARDWARE_TEXT TRUE -#define GDISP_HARDWARE_TEXTFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_HARDWARE_QUERY TRUE -#define GDISP_HARDWARE_CLIP TRUE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* GFX_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld_driver1.c b/drivers/gdisp/VMT/gdisp_lld_driver1.c deleted file mode 100644 index 01fd4cf0..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_driver1.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_driver1.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define CONFIGFILE() <../GDISP_VMT_NAME1()/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME1()/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gfx.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/gdisp_lld_driver2.c b/drivers/gdisp/VMT/gdisp_lld_driver2.c deleted file mode 100644 index ed0e8555..00000000 --- a/drivers/gdisp/VMT/gdisp_lld_driver2.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - ChibiOS/GFX - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/GFX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file drivers/gdisp/VMT/gdisp_lld_driver2.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/ - -#define CONFIGFILE() <../GDISP_VMT_NAME2()/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME2()/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gfx.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* GFX_USE_GDISP */ -/** @} */ - diff --git a/drivers/gdisp/VMT/readme.txt b/drivers/gdisp/VMT/readme.txt deleted file mode 100644 index d6b71e0e..00000000 --- a/drivers/gdisp/VMT/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -This driver enables you to have two underlying drivers handling different hardware. -A choice is made at run-time of which driver to call based on which driver succeeds -to initialise first (init returns TRUE). - -To use this driver: - -1. Add in your halconf.h: - a) #define GFX_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) Define these: - #define GDISP_VMT_NAME1(x) x##YourDriver1 - #define GDISP_VMT_NAME2(x) x##YourDriver2 - Note YourDriver1 & 2 are the basenames of the directories containing the driver. - Note that both drivers must be the same pixel format which is - GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your - pixel format is different on both drivers. - d) Any driver specific defines. If both drivers use the same defines then they must - accept the same values for the define. - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk - diff --git a/drivers/multiple/Win32/gdisp_lld_config.h b/drivers/multiple/Win32/gdisp_lld_config.h index bebd76b9..f62b0fdb 100644 --- a/drivers/multiple/Win32/gdisp_lld_config.h +++ b/drivers/multiple/Win32/gdisp_lld_config.h @@ -36,7 +36,6 @@ /*===========================================================================*/ #define GDISP_DRIVER_NAME "Win32" -#define GDISP_LLD(x) gdisp_lld_##x##_Win32 #define GDISP_HARDWARE_LINES TRUE #define GDISP_HARDWARE_FILLS TRUE -- cgit v1.2.3