本帖最后由 sky.sun.zz 于 2015-10-10 15:09 编辑
楼主,修改了GPIO口操作定义,是可以控制GPIO:
#ifndef __LCD_H
#define __LCD_H
#include "stm32f446xx.h"
#include "font.h"
#include <stdbool.h>
#define LCD_HEIGHT 240
#define LCD_WIDTH 320
#define ENZERO 1
#define DISZERO 0
#define USEWALLPAPER 0
#define USEBACKCOLOR 1
#define DONOTCARE 0
void _delayus(unsigned int n);
#define LCD_RST {GPIOB->ODR &=~0X0010;=GPIO_PIN_8;_delayus(7);GPIOB->ODR |=0X0010;_delayus(7);GPIOB->BSRR=GPIO_PIN_8;}
#define LCD_CS_CLR GPIOB->ODR &=~0x0400
#define LCD_CS_SET GPIOB->ODR |=0x0400
#define LCD_RS_CLR GPIOB->ODR &=~0x0001
#define LCD_RS_SET GPIOB->ODR |=0X0001
#define LCD_WR_CLR GPIOB->ODR &=~0X8000
#define LCD_WR_SET GPIOB->ODR |=0X8000
#define LCD_RD_CLR GPIOB->ODR &=~0X0008
#define LCD_RD_SET GPIOB->ODR |=0X0008
#define DATAOUT(dat) {GPIOC->ODR &=0XE000; GPIOC->ODR |= dat&0X1FFF; GPIOB->ODR &=0XFF8F; GPIOB->ODR |= (dat>>9)&0X0070;}
void LCD_SetColors(uint16_t TextColor, uint16_t BackColor);
void LCD_GetColors(uint16_t *TextColor, uint16_t *BackColor);
void LCD_SetTextColor(uint16_t Color);
void LCD_SetBackColor(uint16_t Color);
void LCD_SetFont(sFONT *fonts);
sFONT *LCD_GetFont(void);
void LCD_Init(void);
void LCD_Clear(uint16_t color);
void LCD_Fill_Color(uint16_t i0, uint16_t j0, uint16_t width, uint16_t height, uint16_t color);
void LCD_SetPixel(uint16_t x,uint16_t y,uint16_t color);
void LCD_DrawLine(uint16_t Xstart,uint16_t Ystart,uint16_t Xend,uint16_t Yend,uint16_t color);
void LCD_DrawRect(uint16_t i0, uint16_t j0, uint16_t i1, uint16_t j1, uint16_t color);
void LCD_DrawCircle(uint16_t i_start, uint16_t j_start, uint16_t radius,uint16_t color);
void LCD_ShowBMP(uint16_t X0,uint16_t Y0,uint16_t width,uint16_t height,const uint16_t *BMP);
void LCD_ShowBMP3(uint16_t X0,uint16_t Y0,uint16_t width,uint16_t height,const uint16_t *BMP);
void WriteNum(uint16_t x,uint16_t y,uint32_t num0,uint8_t len,uint8_t enzero,sFONT *fonts,uint16_t TextColor,uint16_t BackColor,uint8_t useWhichBGColor);
uint8_t WriteOneASCII(uint16_t x0,uint16_t y0,uint8_t pucMsk,sFONT *fonts,uint16_t TextColor,uint16_t BackColor,uint8_t useWhichBGColor);
void WriteString(uint16_t x0, uint16_t y0,uint8_t *pcStr,sFONT *fonts,uint16_t TextColor,uint16_t BackColor,uint8_t useWhichBGColor);
void LCD_Show**(uint16_t x,uint16_t y);
void LCD_ShowBatBmp(uint16_t x,uint16_t y);
void LCD_SetWallpaper(uint8_t wpindex);
void LCD_ShowIcon(uint16_t x,uint16_t y,uint8_t icindex,uint8_t sel);
//»±ÊÑÕÉ«yeqinggui 20130410
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //×ØÉ«
#define BRRED 0XFC07 //×غìÉ«
#define GRAY 0X8430 //»ÒÉ«
//GUIÑÕÉ«
#define DARKBLUE 0X01CF //ÉîÀ¶É«
#define LIGHTBLUE 0X7D7C //dzÀ¶É«
#define GRAYBLUE 0X5458 //»ÒÀ¶É«
//ÒÔÉÏÈýɫΪPANELµÄÑÕÉ«
#define LIGHTGREEN 0X841F //dzÂÌÉ«
//#define LIGHTGRAY 0XEF5B //dz»ÒÉ«(PANNEL)
#define LGRAY 0XC618 //dz»ÒÉ«(PANNEL),´°Ìå±³¾°É«
#define LGRAYBLUE 0XA651 //dz»ÒÀ¶É«(Öмä²ãÑÕÉ«)
#define LBBLUE 0X2B12 //dz×ØÀ¶É«(Ñ¡ÔñÌõÄ¿µÄ·´É«)
//LCD_RD_SET;
#define LCD_WR_REG(data){\
LCD_CS_CLR;\
LCD_RS_CLR;\
LCD_WR_CLR;\
DATAOUT(data);\
_delayus(5);\
LCD_WR_SET;\
_delayus(5);\
LCD_CS_SET;\
}
//LCD_RD_SET;
#define LCD_WR_DATA(data){\
LCD_CS_CLR;\
LCD_WR_CLR;\
LCD_RS_SET;\
DATAOUT(data);\
_delayus(5);\
LCD_WR_SET;\
_delayus(5);\
LCD_CS_SET;\
}
#define LCD_WR_ONEDOT(color){\
LCD_CS_CLR;\
LCD_RD_SET;\
LCD_RS_SET;\
DATAOUT(color);\
LCD_WR_CLR;\
LCD_WR_SET;\
LCD_CS_SET;\
}
#endif
你的 LCD_WR_REG()编译有一个警告,应该纠正,否则写的数据可能有误。
LCD.rar
(4.3 MB)
如果仍然无法解决,应该检查一下硬件了。
|