33 changed files with 1000 additions and 683 deletions
@ -0,0 +1,95 @@ |
|||
/*
|
|||
ChibiOS/GFX - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
/**
|
|||
* Make sure you have the following stuff enabled in your halconf.h: |
|||
* |
|||
* #define GFX_USE_GDISP TRUE |
|||
* #define GFX_USE_GWIN TRUE |
|||
* #define GDISP_NEED_SCROLL TRUE (optional but recommended) |
|||
* #define GDISP_NEED_CLIP TRUE (optional but recommended) |
|||
* #define GWIN_NEED_CONSOLE TRUE |
|||
*/ |
|||
|
|||
#include "ch.h" |
|||
#include "hal.h" |
|||
#include "chprintf.h" |
|||
#include "gdisp.h" |
|||
#include "gwin.h" |
|||
|
|||
/* The handles for our three consoles */ |
|||
GHandle GW1, GW2, GW3; |
|||
|
|||
/* The streams for our three consoles */ |
|||
BaseSequentialStream *S1, *S2, *S3; |
|||
|
|||
int main(void) { |
|||
uint8_t i; |
|||
|
|||
halInit(); |
|||
chSysInit(); |
|||
|
|||
/* initialize and clear the display */ |
|||
gdispInit(); |
|||
gdispClear(Black); |
|||
|
|||
/* create the three console windows and set a font for each */ |
|||
GW1 = gwinCreateConsole(NULL, 0, 0, gdispGetWidth(), gdispGetHeight()/2, &fontUI2Double); |
|||
GW2 = gwinCreateConsole(NULL, 0, gdispGetHeight()/2, gdispGetWidth()/2, gdispGetHeight(), &fontSmall); |
|||
GW3 = gwinCreateConsole(NULL, gdispGetWidth()/2, gdispGetHeight()/2, gdispGetWidth(), gdispGetHeight(), &fontSmall); |
|||
|
|||
/* Set the fore- and background colors for each console */ |
|||
gwinSetColor(GW1, Green); |
|||
gwinSetBgColor(GW1, Black); |
|||
gwinSetColor(GW2, White); |
|||
gwinSetBgColor(GW2, Blue); |
|||
gwinSetColor(GW3, Black); |
|||
gwinSetBgColor(GW3, Red); |
|||
|
|||
/* clear all console windows - to set background */ |
|||
gwinClear(GW1); |
|||
gwinClear(GW2); |
|||
gwinClear(GW3); |
|||
|
|||
/* receive the stream pointers of each console */ |
|||
S1 = gwinGetConsoleStream(GW1); |
|||
S2 = gwinGetConsoleStream(GW2); |
|||
S3 = gwinGetConsoleStream(GW3); |
|||
|
|||
/* Output some data on the first console */ |
|||
for(i = 0; i < 10; i++) { |
|||
chprintf(S1, "Hello ChibiOS/GFX!\r\n"); |
|||
} |
|||
|
|||
/* Output some data on the second console */ |
|||
for(i = 0; i < 16; i++) { |
|||
chprintf(S2, "Message Nr.: %d\r\n", i+1); |
|||
} |
|||
|
|||
/* Output some data on the third console */ |
|||
for(i = 0; i < 18; i++) { |
|||
chprintf(S3, "Message Nr.: %d\r\n", i+1); |
|||
} |
|||
|
|||
while(TRUE) { |
|||
chThdSleepMilliseconds(500); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,65 @@ |
|||
/*
|
|||
ChibiOS/GFX - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
/**
|
|||
* Make sure you have enabled the GTimer module in your halconf.h: |
|||
* |
|||
* #define GFX_USE_GTIMER TRUE |
|||
*/ |
|||
|
|||
#include "ch.h" |
|||
#include "hal.h" |
|||
#include "gtimer.h" |
|||
|
|||
GTimer GT1, GT2; |
|||
|
|||
void callback1(void* arg) { |
|||
(void)arg; |
|||
|
|||
palTogglePad(GPIOD, GPIOD_LED3); |
|||
} |
|||
|
|||
void callback2(void* arg) { |
|||
(void)arg; |
|||
|
|||
palSetPad(GPIOD, GPIOD_LED4); |
|||
} |
|||
|
|||
int main(void) { |
|||
halInit(); |
|||
chSysInit(); |
|||
|
|||
/* initialize the timers */ |
|||
gtimerInit(>1); |
|||
gtimerInit(>2); |
|||
|
|||
/* continious mode - callback1() called without any argument every 250ms */ |
|||
gtimerStart(>1, callback1, NULL, TRUE, 250); |
|||
|
|||
/* single shot mode - callback2() called without any argument once after 1s */ |
|||
gtimerStart(>2, callback2, NULL, FALSE, 1000); |
|||
|
|||
while(TRUE) { |
|||
chThdSleepMilliseconds(500); |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1,72 @@ |
|||
/*
|
|||
ChibiOS/GFX - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
/**
|
|||
* Make sure you have the following stuff enabled in your halconf.h: |
|||
* |
|||
* #define GFX_USE_GDISP TRUE |
|||
* #define GDISP_NEED_SCROLL TRUE |
|||
* #define GDISP_NEED_CLIP TRUE (optional but recommended) |
|||
*/ |
|||
|
|||
|
|||
#include "ch.h" |
|||
#include "hal.h" |
|||
#include "gdisp.h" |
|||
#include "gwin.h" |
|||
|
|||
/* The handles for our two Windows */ |
|||
GHandle GW1, GW2; |
|||
|
|||
int main(void) { |
|||
halInit(); |
|||
chSysInit(); |
|||
|
|||
/* Initialize and clear the display */ |
|||
gdispInit(); |
|||
gdispClear(Lime); |
|||
|
|||
/* Create two windows */ |
|||
GW1 = gwinCreateWindow(NULL, 20, 10, 200, 150); |
|||
GW2 = gwinCreateWindow(NULL, 50, 190, 150, 100); |
|||
|
|||
/* Set fore- and background colors for both windows */ |
|||
gwinSetColor(GW1, Black); |
|||
gwinSetBgColor(GW1, White); |
|||
gwinSetColor(GW2, White); |
|||
gwinSetBgColor(GW2, Blue); |
|||
|
|||
/* Clear both windows - to set background color */ |
|||
gwinClear(GW1); |
|||
gwinClear(GW2); |
|||
|
|||
/*
|
|||
* Draw two filled circles at the same coordinate |
|||
* of each window to demonstrate the relative coordinates |
|||
* of windows |
|||
*/ |
|||
gwinFillCircle(GW1, 20, 20, 15); |
|||
gwinFillCircle(GW2, 20, 20, 15); |
|||
|
|||
while(TRUE) { |
|||
chThdSleepMilliseconds(500); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,36 @@ |
|||
/* |
|||
ChibiOS/GFX - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
/** |
|||
* @addtogroup GTIMER |
|||
* @details The GTIMER module provides high level, simple and hardware |
|||
* independend timers. The timers are meant to be used in different |
|||
* ChibiOS/GFX modules and are not very accurate. |
|||
* |
|||
* @details The reason why ChibiOS/GFX has it's own timer abstraction is because |
|||
* virtual timers provided by ChibiOS/RT are interrupt context only. |
|||
* While great for what they are designed for, they make coding of the input |
|||
* drivers much more complex. |
|||
* For non-performance critical drivers like these input drivers, it would also |
|||
* hog an in-ordinate amount of critical (interrupt locked) system time. |
|||
* This contrary to the goals of a real-time operating system. So a user-land |
|||
* (thread based) timer mechanism is also required. |
|||
*/ |
|||
|
@ -0,0 +1,125 @@ |
|||
/*
|
|||
ChibiOS/RT - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
/**
|
|||
* @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 */ |
|||
/** @} */ |
@ -0,0 +1,94 @@ |
|||
/*
|
|||
ChibiOS/RT - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
/**
|
|||
* @file drivers/gdisp/S6D1121/gdisp_lld_board_olimex_e407.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)) /* 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 */ |
|||
/** @} */ |
|||
|
@ -1,254 +0,0 @@ |
|||
/*
|
|||
ChibiOS/GFX - Copyright (C) 2012 |
|||
Joel Bodenmann aka Tectu <joel@unormal.org> |
|||
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#ifndef S6D1121_H |
|||
#define S6D1121_H |
|||
|
|||
// I/O assignments
|
|||
#define GDISP_BL_GPIO GPIOB |
|||
#define GDISP_BL_PIN 8 |
|||
|
|||
#define GDISP_CS_GPIO GPIOD |
|||
#define GDISP_CS_PIN 7 |
|||
|
|||
#define GDISP_RS_GPIO GPIOD |
|||
#define GDISP_RS_PIN 11 |
|||
|
|||
#define GDISP_RST_GPIO GPIOD |
|||
#define GDISP_RST_PIN 10 |
|||
|
|||
#define GDISP_RD_GPIO GPIOD |
|||
#define GDISP_RD_PIN 9 |
|||
|
|||
#define GDISP_WR_GPIO GPIOD |
|||
#define GDISP_WR_PIN 8 |
|||
|
|||
#define GDISP_D0_GPIO GPIOD |
|||
#define GDISP_D4_GPIO GPIOE |
|||
|
|||
/* all interfaces use RST via GPIO */ |
|||
/* TODO: option to disable RST; assumes RST is tied high */ |
|||
#define GDISP_RST_LOW palClearPad(GDISP_RST_GPIO, GDISP_RST_PIN) |
|||
#define GDISP_RST_HIGH palSetPad(GDISP_RST_GPIO, GDISP_RST_PIN) |
|||
|
|||
#define s6d1121_delay(n) halPolledDelay(MS2RTT(n)); |
|||
|
|||
#if defined(GDISP_USE_GPIO) |
|||
|
|||
#define GDISP_CS_LOW palClearPad(GDISP_CS_GPIO, GDISP_CS_PIN) |
|||
#define GDISP_CS_HIGH palSetPad(GDISP_CS_GPIO, GDISP_CS_PIN) |
|||
|
|||
#define GDISP_RS_LOW palClearPad(GDISP_RS_GPIO, GDISP_RS_PIN) |
|||
#define GDISP_RS_HIGH palSetPad(GDISP_RS_GPIO, GDISP_RS_PIN) |
|||
|
|||
#define GDISP_RD_LOW palClearPad(GDISP_RD_GPIO, GDISP_RD_PIN) |
|||
#define GDISP_RD_HIGH palSetPad(GDISP_RD_GPIO, GDISP_RD_PIN) |
|||
|
|||
#define GDISP_WR_LOW palClearPad(GDISP_WR_GPIO, GDISP_WR_PIN) |
|||
#define GDISP_WR_HIGH palSetPad(GDISP_WR_GPIO, GDISP_WR_PIN) |
|||
|
|||
#define GDISP_BL_LOW palClearPad(GDISP_BL_GPIO, GDISP_BL_PIN) |
|||
#define GDISP_BL_HIGH palSetPad(GDISP_BL_GPIO, GDISP_BL_PIN) |
|||
|
|||
|
|||
static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); } |
|||
static inline void lld_lcdwrite(uint16_t db) { |
|||
GDISP_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0); |
|||
GDISP_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F); |
|||
GDISP_WR_LOW; |
|||
lld_lcddelay(); |
|||
GDISP_WR_HIGH; |
|||
} |
|||
static __inline uint16_t lld_lcdReadData(void) { |
|||
uint16_t value=0; |
|||
|
|||
GDISP_RS_HIGH; GDISP_WR_HIGH; GDISP_RD_LOW; |
|||
#ifndef STM32F4XX |
|||
// change pin mode to digital input
|
|||
GDISP_DATA_PORT->CRH = 0x47444444; |
|||
GDISP_DATA_PORT->CRL = 0x47444444; |
|||
#endif |
|||
#ifndef STM32F4XX |
|||
// change pin mode back to digital output
|
|||
GDISP_DATA_PORT->CRH = 0x33333333; |
|||
GDISP_DATA_PORT->CRL = 0x33333333; |
|||
#endif |
|||
GDISP_RD_HIGH; |
|||
return value; |
|||
} |
|||
static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { |
|||
uint16_t lcdRAM; |
|||
|
|||
GDISP_CS_LOW; GDISP_RS_LOW; |
|||
lld_lcdwrite(lcdReg); |
|||
GDISP_RS_HIGH; |
|||
lcdRAM = lld_lcdReadData(); |
|||
GDISP_CS_HIGH; |
|||
return lcdRAM; |
|||
} |
|||
static void lld_lcdWriteIndex(uint16_t lcdReg) { |
|||
GDISP_RS_LOW; |
|||
lld_lcdwrite(lcdReg); |
|||
GDISP_RS_HIGH; |
|||
} |
|||
static void lld_lcdWriteData(uint16_t lcdData) { |
|||
lld_lcdwrite(lcdData); |
|||
} |
|||
static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { |
|||
GDISP_CS_LOW; |
|||
lld_lcdWriteIndex(lcdReg); |
|||
lld_lcdWriteData(lcdRegValue); |
|||
GDISP_CS_HIGH; |
|||
} |
|||
static __inline void lld_lcdWriteStreamStart(void) { |
|||
GDISP_CS_LOW; |
|||
lld_lcdWriteIndex(0x0022); |
|||
} |
|||
static __inline void lld_lcdWriteStreamStop(void) { |
|||
GDISP_CS_HIGH; |
|||
} |
|||
static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { |
|||
uint16_t i; |
|||
|
|||
for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); } |
|||
} |
|||
static __inline void lld_lcdReadStreamStart(void) { /* TODO */ } |
|||
static __inline void lld_lcdReadStreamStop(void) { /* TODO */ } |
|||
static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { |
|||
(void)buffer; |
|||
(void)size; |
|||
|
|||
/* TODO */ |
|||
} |
|||
|
|||
#elif defined(GDISP_USE_FSMC) |
|||
#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ |
|||
#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ |
|||
|
|||
static __inline void lld_lcdWriteIndex(uint16_t index) { GDISP_REG = index; } |
|||
static __inline void lld_lcdWriteData(uint16_t data) { GDISP_RAM = data; } |
|||
static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { |
|||
GDISP_REG = lcdReg; |
|||
GDISP_RAM = lcdRegValue; |
|||
} |
|||
static __inline uint16_t lld_lcdReadData(void) { return (GDISP_RAM); } |
|||
static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { |
|||
GDISP_REG = lcdReg; |
|||
return GDISP_RAM; |
|||
} |
|||
static __inline void lld_lcdWriteStreamStart(void) { GDISP_REG = 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++) GDISP_RAM = buffer[i]; |
|||
} |
|||
static __inline void lld_lcdReadStreamStart(void) { GDISP_REG = 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; |
|||
|
|||
/* throw away first value read */ |
|||
dummy = GDISP_RAM; |
|||
for(i = 0; i < size; i++) buffer[i] = GDISP_RAM; |
|||
} |
|||
|
|||
#elif defined(GDISP_USE_SPI) |
|||
#error "gdispS6d1121: GDISP_USE_SPI not implemented yet" |
|||
#endif |
|||
|
|||
static void lld_lcdSetCursor(coord_t x, coord_t y) { |
|||
/* R20h - 8 bit
|
|||
* R21h - 9 bit |
|||
*/ |
|||
switch(GDISP.Orientation) { |
|||
case GDISP_ROTATE_0: |
|||
lld_lcdWriteReg(0x0020, x & 0x00FF); |
|||
lld_lcdWriteReg(0x0021, y & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_90: |
|||
/* Note X has already been mirrored, so we do it directly */ |
|||
lld_lcdWriteReg(0x0020, y & 0x00FF); |
|||
lld_lcdWriteReg(0x0021, x & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_180: |
|||
lld_lcdWriteReg(0x0020, (GDISP_SCREEN_WIDTH - 1 - x) & 0x00FF); |
|||
lld_lcdWriteReg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - y) & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_270: |
|||
lld_lcdWriteReg(0x0020, (GDISP_SCREEN_WIDTH - 1 - y) & 0x00FF); |
|||
lld_lcdWriteReg(0x0021, (GDISP_SCREEN_HEIGHT - 1 - x) & 0x01FF); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_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: |
|||
lld_lcdWriteReg(0x46, (((x + cx - 1) << 8) & 0xFF00 ) | |
|||
(x & 0x00FF)); |
|||
|
|||
lld_lcdWriteReg(0x48, y & 0x01FF); |
|||
lld_lcdWriteReg(0x47, (y + cy - 1) & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_90: |
|||
lld_lcdWriteReg(0x46, (((y + cy - 1) << 8) & 0xFF00) | |
|||
(y & 0x00FF)); |
|||
|
|||
lld_lcdWriteReg(0x48, x & 0x01FF); |
|||
lld_lcdWriteReg(0x47, (x + cx - 1) & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_180: |
|||
lld_lcdWriteReg(0x46, (((GDISP_SCREEN_WIDTH - x - 1) & 0x00FF) << 8) | |
|||
((GDISP_SCREEN_WIDTH - (x + cx)) & 0x00FF)); |
|||
lld_lcdWriteReg(0x48, (GDISP_SCREEN_HEIGHT - (y + cy)) & 0x01FF); |
|||
lld_lcdWriteReg(0x47, (GDISP_SCREEN_HEIGHT- y - 1) & 0x01FF); |
|||
break; |
|||
case GDISP_ROTATE_270: |
|||
lld_lcdWriteReg(0x46, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | |
|||
((GDISP_SCREEN_WIDTH - (y + cy)) & 0x00FF)); |
|||
lld_lcdWriteReg(0x48, (GDISP_SCREEN_HEIGHT - (x + cx)) & 0x01FF); |
|||
lld_lcdWriteReg(0x47, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); |
|||
break; |
|||
} |
|||
|
|||
lld_lcdSetCursor(x, y); |
|||
} |
|||
|
|||
static 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; |
|||
} |
|||
} |
|||
|
|||
#endif /* S6D1121_H */ |
|||
|