初级会员
- 积分
- 80
- 金钱
- 80
- 注册时间
- 2022-6-29
- 在线时间
- 33 小时
|
10金钱
STM32F107连接了ILI9341、OV7670、DP83848后,LCD数据线不能独享GPIOB端口,所以还使用了GPIOD的引脚
STM32F107和ILI9341的data线连接如下
STM32F107 | PB0 | PB1 | PB2 | PB3 | PB4 | PB5 | PB6 | PB7 | PB8 | PB9 | PB10 | PD11 | PD12 | PD15 | PB14 | PB15 | ILI9341 | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 | D11 | D12 | D13 | D14 | D15 |
所以,lcd.h中定义DATAIN和DATAOUT应该如下:
#define DATAOUT(x) {GPIOB->ODR|=x&0xC7FF;GPIOD->ODR|=x&0x9800;}
#define DATAIN (GPIOB->IDR&0xC7FF)|(GPIOD->IDR&0x1800)|((GPIOD->IDR&0x8000)>>2);
而LCD_RD_DATA应该如下
u16 LCD_RD_DATA(void)
{
u16 t;
GPIOB->CRL=0X88888888;
GPIOB->CRH=0X88000888;
GPIOB->ODR&=0X3800;
GPIOD->CRL=0X00000000;
GPIOD->CRH=0X80088000;
GPIOD->ODR&=0X67FF;
LCD_RS_SET;
LCD_CS_CLR;
LCD_RD_CLR;
opt_delay(2);
t=DATAIN;
LCD_RD_SET;
LCD_CS_SET;
GPIOB->CRL=0X33333333;
GPIOB->CRH=0X33000333;
GPIOB->ODR&=0XC7FF;
GPIOD->CRL=0X00000000;
GPIOD->CRH=0X30033000;
GPIOD->ODR&=0X9800;
return t;
}
请问对不对?
|
|