本帖最后由 1223657347 于 2015-12-21 20:29 编辑
- uint8_t __ILI9341_IO_ByteWrite(uint8_t dat)
- {
- // uint8_t temp;
- // HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*) &dat, &temp, 1, 1000);
- // return temp;
-
- while((SPI1->SR & (1<<1)) == 0)
- ; //等待发送区空
-
- *((__IO uint8_t *)(&SPI1->DR)) = dat;
-
- while(SPI1->SR & (1<<7))
- ; //Wait for not busy
- while((SPI1->SR & (1<<0)) == 0)
- ; //等待接收区非空
-
- return *((__IO uint8_t *)(&SPI1->DR));
- }
- uint8_t __ILI9341_IO_ByteRead(void)
- {
- return __ILI9341_IO_ByteWrite(0xFF);
- }
我这个是操作SPI接口的LCD驱动芯片的读写代码(基于STM32F070RB),HAL库和寄存器方式都是可以的用的,楼主试试能不能用
PS:用寄存器操作的话,一定要在初始化里使能SPI
- __HAL_SPI_ENABLE(&SpiHandle);
并且更改FRXTH(单字节)
|