在线时间185 小时
UID3375312
注册时间2017-6-28
NXP金币12
TA的每日心情 | 开心 2020-12-17 09:04 |
---|
签到天数: 346 天 连续签到: 1 天 [LV.8]以坛为家I
金牌会员
 
- 积分
- 1363
- 最后登录
- 2025-5-7
|
日天说大家还有很多人不会点这个OLED的屏幕,今天我主要把大致细节给大家讲一下。话不多说直接开整。
一、SPI任意I/O口模拟软件SPI
中景园的OLED128*64的屏幕主要有以下图片几个引脚,分别为GND,VCC,D0,D1,RES,DC,CS。前两个为电源,D0为时钟引脚,D1为数据输入引脚,如果要使用硬件SPI就需要接MOSI,RES为复位引脚给SPI没鸡毛关系,DC为数据/命令选择脚,CS顾名思义为片选信号了,如果用硬件SPI就需要(D0-SCK)(D1-MOSI)(CS及其DC就两个普通的IO口)。
这里为了引脚集中我统一选择了FC0的引脚进行使能,原理图小伙伴都有了,我就不贴了哈。上程序
- #define oled_sclk_pin 28
- #define oled_sdin_pin 29
- #define oled_rst_pin 23
- #define oled_dc_pin 30
- #define oled_cs_pin 7
- #define OLED_SCLK_Clr() GPIO_PinWrite(GPIO,port_zero, oled_sclk_pin, 0)//CLK_FC0_SCK,D0,
- #define OLED_SCLK_Set() GPIO_PinWrite(GPIO,port_zero, oled_sclk_pin, 1)
- #define OLED_SDIN_Clr() GPIO_PinWrite(GPIO,port_zero, oled_sdin_pin, 0)//DIN_FC0_MOSI,D1
- #define OLED_SDIN_Set() GPIO_PinWrite(GPIO,port_zero, oled_sdin_pin, 1)
- #define OLED_RST_Clr() GPIO_PinWrite(GPIO,port_zero, oled_rst_pin, 0)//RES_FC0_SDA
- #define OLED_RST_Set() GPIO_PinWrite(GPIO,port_zero, oled_rst_pin, 1)
- #define OLED_DC_Clr() GPIO_PinWrite(GPIO,port_zero, oled_dc_pin, 0)//DC_FC0_MISO
- #define OLED_DC_Set() GPIO_PinWrite(GPIO,port_zero, oled_dc_pin, 1)
-
- #define OLED_CS_Clr() GPIO_PinWrite(GPIO,port_one, oled_cs_pin, 0)//CS_FC0_SCL FL0_SEL1 P1_7
- #define OLED_CS_Set() GPIO_PinWrite(GPIO,port_one, oled_cs_pin, 1)
- void Software_SPI_Init(void)
- {
- gpio_pin_config_t sclk_config={kGPIO_DigitalOutput,0}; //low
- gpio_pin_config_t sdin_config={kGPIO_DigitalOutput,0}; //low
- gpio_pin_config_t rst_config= {kGPIO_DigitalOutput,0}; //low
- gpio_pin_config_t dc_config= {kGPIO_DigitalOutput,0}; //low
- gpio_pin_config_t cs_config= {kGPIO_DigitalOutput,0}; //low
- /* Init output LED GPIO. */
- GPIO_PinInit(GPIO, port_zero, oled_sclk_pin, &sclk_config);
- GPIO_PinInit(GPIO, port_zero, oled_sdin_pin, &sdin_config);
- GPIO_PinInit(GPIO, port_zero, oled_rst_pin, &rst_config);
- GPIO_PinInit(GPIO, port_zero, oled_dc_pin, &dc_config);
- GPIO_PinInit(GPIO, port_one, oled_cs_pin, &cs_config);
- }
复制代码 这一段就把FC0的几个I/O的功能给用了,因为LPC单片机端口复用默认是0即为IO口使用,但是呢养成一个好习惯,还是去吧该有的属性给配置了,这里虽然OLED的电流不是很大,使能与否都可以点亮,那万一遇到初始化功耗高的呢或者输出必须推挽,上拉呢?所以这里还是对端口的属性做了补充,上代码- const uint32_t port0_pin23_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
- /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PinMuxSet(IOCON, 0U, 23U, port0_pin23_config);
-
- const uint32_t port0_pin28_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
- /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PinMuxSet(IOCON, 0U, 28U, port0_pin28_config);
-
-
- const uint32_t port0_pin29_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
- /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
- IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config);
-
- const uint32_t port0_pin30_config = (/* Pin is configured as FC7_TXD_SCL_MISO_WS */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
- /* PORT0 PIN30 (coords: 94) is configured as FC7_TXD_SCL_MISO_WS */
- IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config);
-
- const uint32_t port1_pin7_config = (/* Pin is configured as FC7_TXD_SCL_MISO_WS */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
- /* PORT0 PIN30 (coords: 94) is configured as FC7_TXD_SCL_MISO_WS */
- IOCON_PinMuxSet(IOCON, 1U, 7U, port1_pin7_config);
复制代码
二、图片取样BMP图片显示
小编比较懒,就截图了社区了LOGO处理了一下(这里我用的PS输出的bmp位图),用其他软件输出位图都是可以的,但是一定要设置大小(max128*64),位宽等。然后利用LCD2002完美破解版软件取出数据,进行显示,至于绘图方式,社区已经有小伙伴分享了资料,大家可以去下载,这里给张飞机票。资料
三、汉字、字符、ASCII、数字显示
根据官方提供的函数,我这里乱写了一通,实现了标题上的功能。
现在我把整个程序包放出来提供给大家下载使用,这个工程是我之前用的双核,砍掉了之间的连接,大家下载下来用CORE0工程就好了,拿到后修改一下remove的路径就好了。以下是我做的视频,我让日天贴出来。
CM33_CORE0.zip
(67.7 KB, 下载次数: 7)
|
|