cleanup
This commit is contained in:
parent
94322d769e
commit
3b19353f88
2 changed files with 29 additions and 29 deletions
42
glcd.c
42
glcd.c
|
@ -5,30 +5,30 @@
|
||||||
static uint16_t DeviceCode;
|
static uint16_t DeviceCode;
|
||||||
|
|
||||||
static __inline void lcdWriteIndex(uint16_t index) {
|
static __inline void lcdWriteIndex(uint16_t index) {
|
||||||
Clr_Rs;
|
Clr_RS;
|
||||||
Set_nRd;
|
Set_RD;
|
||||||
|
|
||||||
LCD_DATA_PORT->ODR = index;
|
LCD_DATA_PORT->ODR = index;
|
||||||
|
|
||||||
Clr_nWr;
|
Clr_WR;
|
||||||
Set_nWr;
|
Set_WR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void lcdWriteData(uint16_t data) {
|
static __inline void lcdWriteData(uint16_t data) {
|
||||||
Set_Rs;
|
Set_RS;
|
||||||
|
|
||||||
LCD_DATA_PORT->ODR = data;
|
LCD_DATA_PORT->ODR = data;
|
||||||
|
|
||||||
Clr_nWr;
|
Clr_WR;
|
||||||
Set_nWr;
|
Set_WR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadData(void) {
|
static __inline uint16_t lcdReadData(void) {
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
|
|
||||||
Set_Rs;
|
Set_RS;
|
||||||
Set_nWr;
|
Set_WR;
|
||||||
Clr_nRd;
|
Clr_RD;
|
||||||
|
|
||||||
// change pin mode to digital input
|
// change pin mode to digital input
|
||||||
LCD_DATA_PORT->CRH = 0x44444444;
|
LCD_DATA_PORT->CRH = 0x44444444;
|
||||||
|
@ -41,25 +41,25 @@ static __inline uint16_t lcdReadData(void) {
|
||||||
LCD_DATA_PORT->CRH = 0x33333333;
|
LCD_DATA_PORT->CRH = 0x33333333;
|
||||||
LCD_DATA_PORT->CRL = 0x33333333;
|
LCD_DATA_PORT->CRL = 0x33333333;
|
||||||
|
|
||||||
Set_nRd;
|
Set_RD;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
|
static __inline void lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
|
||||||
Clr_Cs;
|
Clr_CS;
|
||||||
lcdWriteIndex(lcdReg);
|
lcdWriteIndex(lcdReg);
|
||||||
lcdWriteData(lcdRegValue);
|
lcdWriteData(lcdRegValue);
|
||||||
Set_Cs;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
||||||
uint16_t lcdRAM;
|
uint16_t lcdRAM;
|
||||||
|
|
||||||
Clr_Cs;
|
Clr_CS;
|
||||||
lcdWriteIndex(lcdReg);
|
lcdWriteIndex(lcdReg);
|
||||||
lcdRAM = lcdReadData();
|
lcdRAM = lcdReadData();
|
||||||
Set_Cs;
|
Set_CS;
|
||||||
|
|
||||||
return lcdRAM;
|
return lcdRAM;
|
||||||
}
|
}
|
||||||
|
@ -102,24 +102,24 @@ void lcdSetWindows(uint16_t xStart,uint16_t yStart,uint16_t xLong,uint16_t yLong
|
||||||
void lcdClear(uint16_t Color) {
|
void lcdClear(uint16_t Color) {
|
||||||
uint32_t index=0;
|
uint32_t index=0;
|
||||||
lcdSetCursor(0,0);
|
lcdSetCursor(0,0);
|
||||||
Clr_Cs;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lcdWriteIndex(0x0022);
|
||||||
for(index=0;index<76800;index++)
|
for(index=0;index<76800;index++)
|
||||||
{
|
{
|
||||||
lcdWriteData(Color);
|
lcdWriteData(Color);
|
||||||
}
|
}
|
||||||
Set_Cs;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lcdGetPoint(uint16_t Xpos,uint16_t Ypos) {
|
uint16_t lcdGetPoint(uint16_t Xpos,uint16_t Ypos) {
|
||||||
u16 dummy;
|
u16 dummy;
|
||||||
|
|
||||||
lcdSetCursor(Xpos,Ypos);
|
lcdSetCursor(Xpos,Ypos);
|
||||||
Clr_Cs;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lcdWriteIndex(0x0022);
|
||||||
dummy = lcdReadData();
|
dummy = lcdReadData();
|
||||||
dummy = lcdReadData();
|
dummy = lcdReadData();
|
||||||
Set_Cs;
|
Set_CS;
|
||||||
|
|
||||||
if( DeviceCode==0x7783 || DeviceCode==0x4531 || DeviceCode==0x8989 )
|
if( DeviceCode==0x7783 || DeviceCode==0x4531 || DeviceCode==0x8989 )
|
||||||
return dummy;
|
return dummy;
|
||||||
|
@ -261,11 +261,11 @@ void lcdFillArea2(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t c
|
||||||
|
|
||||||
lcdSetWindows(x0, y0, x1, y1);
|
lcdSetWindows(x0, y0, x1, y1);
|
||||||
lcdSetCursor(x0, x1);
|
lcdSetCursor(x0, x1);
|
||||||
Clr_Cs;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lcdWriteIndex(0x0022);
|
||||||
for(index = 0; index < area; index++)
|
for(index = 0; index < area; index++)
|
||||||
lcdWriteData(color);
|
lcdWriteData(color);
|
||||||
Set_Cs;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdDrawRect(uint8_t x0, uint16_t y0, uint8_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
void lcdDrawRect(uint8_t x0, uint16_t y0, uint8_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
||||||
|
|
16
glcd.h
16
glcd.h
|
@ -7,14 +7,14 @@
|
||||||
#define SCREEN_WIDTH 320
|
#define SCREEN_WIDTH 320
|
||||||
#define SCREEN_HEIGHT 240
|
#define SCREEN_HEIGHT 240
|
||||||
|
|
||||||
#define Set_Cs LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_CS);
|
#define Set_CS LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_CS);
|
||||||
#define Clr_Cs LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_CS);
|
#define Clr_CS LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_CS);
|
||||||
#define Set_Rs LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_RS);
|
#define Set_RS LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_RS);
|
||||||
#define Clr_Rs LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_RS);
|
#define Clr_RS LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_RS);
|
||||||
#define Set_nWr LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_WR);
|
#define Set_WR LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_WR);
|
||||||
#define Clr_nWr LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_WR);
|
#define Clr_WR LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_WR);
|
||||||
#define Set_nRd LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_RD);
|
#define Set_RD LCD_CMD_PORT->ODR |= (1 << GPIOD_LCD_RD);
|
||||||
#define Clr_nRd LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_RD);
|
#define Clr_RD LCD_CMD_PORT->ODR &= ~(1 << GPIOD_LCD_RD);
|
||||||
|
|
||||||
/* LCD color */
|
/* LCD color */
|
||||||
#define White 0xFFFF
|
#define White 0xFFFF
|
||||||
|
|
Loading…
Add table
Reference in a new issue