这里再介绍一下在飞凌RT1052开发板上使用键盘端口(KPP)来驱动SPI接口OLED屏的用法。 OLED屏与RT1052的连接关系如下: CS --P1.24 使个引脚输出高低电平的定义如下: #define OLED_CS_Clr() GPIO_PinWrite(GPIO1, (24U), 0U); #define OLED_CS_Set() GPIO_PinWrite(GPIO1, (24U), 1U); #define OLED_DC_Clr() GPIO_PinWrite(GPIO1, (26U), 0U); #define OLED_DC_Set() GPIO_PinWrite(GPIO1, (26U), 1U); #define OLED_RST_Clr()
GPIO_PinWrite(GPIO1, (28U), 0U); #define OLED_RST_Set() GPIO_PinWrite(GPIO1, (28U), 1U); #define OLED_SDIN_Clr() GPIO_PinWrite(GPIO1, (27U), 0U); #define OLED_SDIN_Set() GPIO_PinWrite(GPIO1, (27U), 1U); #define OLED_SCLK_Clr()
GPIO_PinWrite(GPIO1, (25U), 0U); #define OLED_SCLK_Set() GPIO_PinWrite(GPIO1, (25U), 1U); 配置各引脚为输出端口的函数为: void LCD_GPIO_Cogfig(void) { gpio_pin_config_t led_config =
{kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit(GPIO1, (25U),
&led_config); GPIO_PinInit(GPIO1, (27U),
&led_config); GPIO_PinInit(GPIO1, (24U),
&led_config); GPIO_PinInit(GPIO1, (26U),
&led_config); GPIO_PinInit(GPIO1, (28U),
&led_config); GPIO_PinInit(GPIO1, (30U), &led_config); GPIO_PinInit(GPIO1, (31U),
&led_config); }
该OLED屏的初始化函数为: void OLED_Init(void) { LCD_GPIO_Cogfig(); OLED_RST_Set(); delay_ms(100); OLED_RST_Clr(); delay_ms(100); OLED_RST_Set(); OLED_WR_Byte(0xAE,OLED_CMD);//--turn
off oled panel OLED_WR_Byte(0x00,OLED_CMD);//---set
low column address OLED_WR_Byte(0x10,OLED_CMD);//---set
high column address OLED_WR_Byte(0x40,OLED_CMD);//--set
start line address Set Mapping RAM OLED_WR_Byte(0x81,OLED_CMD);//--set contrast
control register OLED_WR_Byte(0xCF,OLED_CMD); //
Set SEG Output Current Brightness OLED_WR_Byte(0xA1,OLED_CMD);//--Set
SEG/Column Mapping OLED_WR_Byte(0xC8,OLED_CMD);//Set
COM/Row Scan Direction OLED_WR_Byte(0xA6,OLED_CMD);//--set
normal display OLED_WR_Byte(0xA8,OLED_CMD);//--set
multiplex ratio(1 to 64) OLED_WR_Byte(0x3f,OLED_CMD);//--1/64
duty OLED_WR_Byte(0xD3,OLED_CMD);//-set
display offset OLED_WR_Byte(0x00,OLED_CMD);//-not
offset OLED_WR_Byte(0xd5,OLED_CMD);//--set
display clock divide ratio/oscillator frequency OLED_WR_Byte(0x80,OLED_CMD);//--set
divide ratio, Set Clock as 100 Frames/Sec OLED_WR_Byte(0xD9,OLED_CMD);//--set
pre-charge period OLED_WR_Byte(0xF1,OLED_CMD);//Set
Pre-Charge as 15 Clocks & Discharge as 1 Clock OLED_WR_Byte(0xDA,OLED_CMD);//--set
com pins hardware configuration OLED_WR_Byte(0x12,OLED_CMD); OLED_WR_Byte(0xDB,OLED_CMD);//--set
vcomh OLED_WR_Byte(0x40,OLED_CMD);//Set
VCOM Deselect Level OLED_WR_Byte(0x20,OLED_CMD);//-Set
Page Addressing Mode (0x00/0x01/0x02) OLED_WR_Byte(0x02,OLED_CMD);// OLED_WR_Byte(0x8D,OLED_CMD);//--set
Charge Pump enable/disable OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10)
disable OLED_WR_Byte(0xA4,OLED_CMD);//
Disable Entire Display On (0xa4/0xa5) OLED_WR_Byte(0xA6,OLED_CMD);//
Disable Inverse Display On (0xa6/a7) OLED_WR_Byte(0xAF,OLED_CMD);//--turn
on oled panel OLED_WR_Byte(0xAF,OLED_CMD); /*display ON*/ OLED_Clear(); OLED_Set_Pos(0,0); } SPI 接口OLED屏显示效果
实现图示效果的主程序为: int main(void) { uint16_t i=0; gpio_pin_config_t led_config =
{kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; BOARD_ConfigMPU(); BOARD_InitPins(); BOARD_BootClockRUN(); BOARD_InitDebugConsole(); GPIO_PinInit(EXAMPLE_LED_GPIO,
EXAMPLE_LED_GPIO_PIN, &led_config); delay(); OLED_Init(); OLED_Clear(); OLED_ShowString(8,0,"OK1052-C"); OLED_ShowString(8,2,"OLED
TEST"); OLED_ShowString(8,4,"JINGLIXIXI"); OLED_ShowString(8,6,"2018/11/8"); while(1); } |
jinglixixi 发表于 2018-11-2 23:33
飞凌RT1052开发板例程如何下载?
liyang 发表于 2018-11-5 08:35
您好,您指的是如何下载教程到您个人电脑还是下载例程到开发板?如果是前者您可以从我们官方论坛的相应版 ...
jinglixixi 发表于 2018-11-10 09:44
谢谢,已经解决了。资料下载在是在社区活动提供的资源中,程序下载是使用的ST_LINK V2。
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-12-22 14:07
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.