查看: 7190|回复: 7

[原创] 逐飞科技LPC55S69_IOT小板评测之OLED软件模拟SPI显示

[复制链接]
  • TA的每日心情
    开心
    2020-12-17 09:04
  • 签到天数: 346 天

    连续签到: 1 天

    [LV.8]以坛为家I

    19

    主题

    94

    帖子

    3

    金牌会员

    Rank: 6Rank: 6

    积分
    1363
    最后登录
    2025-5-7
    发表于 2020-11-4 22:49:59 | 显示全部楼层 |阅读模式
      日天说大家还有很多人不会点这个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口)。
    a4634b8ed62bd3e994255e586c868ae.jpg
    这里为了引脚集中我统一选择了FC0的引脚进行使能,原理图小伙伴都有了,我就不贴了哈。上程序
    1. #define oled_sclk_pin 28
    2. #define oled_sdin_pin 29
    3. #define oled_rst_pin  23
    4. #define oled_dc_pin   30
    5. #define oled_cs_pin   7

    6. #define OLED_SCLK_Clr() GPIO_PinWrite(GPIO,port_zero, oled_sclk_pin, 0)//CLK_FC0_SCK,D0,   
    7. #define OLED_SCLK_Set() GPIO_PinWrite(GPIO,port_zero, oled_sclk_pin, 1)

    8. #define OLED_SDIN_Clr() GPIO_PinWrite(GPIO,port_zero, oled_sdin_pin, 0)//DIN_FC0_MOSI,D1      
    9. #define OLED_SDIN_Set() GPIO_PinWrite(GPIO,port_zero, oled_sdin_pin, 1)

    10. #define OLED_RST_Clr() GPIO_PinWrite(GPIO,port_zero, oled_rst_pin, 0)//RES_FC0_SDA           
    11. #define OLED_RST_Set() GPIO_PinWrite(GPIO,port_zero, oled_rst_pin, 1)

    12. #define OLED_DC_Clr() GPIO_PinWrite(GPIO,port_zero, oled_dc_pin, 0)//DC_FC0_MISO              
    13. #define OLED_DC_Set() GPIO_PinWrite(GPIO,port_zero, oled_dc_pin, 1)
    14.                      
    15. #define OLED_CS_Clr()  GPIO_PinWrite(GPIO,port_one, oled_cs_pin, 0)//CS_FC0_SCL            FL0_SEL1  P1_7
    16. #define OLED_CS_Set()  GPIO_PinWrite(GPIO,port_one, oled_cs_pin, 1)

    17. void Software_SPI_Init(void)
    18. {        
    19.                 gpio_pin_config_t sclk_config={kGPIO_DigitalOutput,0}; //low
    20.                 gpio_pin_config_t sdin_config={kGPIO_DigitalOutput,0}; //low
    21.                 gpio_pin_config_t rst_config= {kGPIO_DigitalOutput,0}; //low
    22.                 gpio_pin_config_t dc_config=  {kGPIO_DigitalOutput,0}; //low
    23.                 gpio_pin_config_t cs_config=  {kGPIO_DigitalOutput,0}; //low
    24.     /* Init output LED GPIO. */        
    25.     GPIO_PinInit(GPIO, port_zero, oled_sclk_pin, &sclk_config);
    26.                 GPIO_PinInit(GPIO, port_zero, oled_sdin_pin, &sdin_config);
    27.                 GPIO_PinInit(GPIO, port_zero, oled_rst_pin, &rst_config);
    28.                 GPIO_PinInit(GPIO, port_zero, oled_dc_pin, &dc_config);
    29.                 GPIO_PinInit(GPIO, port_one, oled_cs_pin, &cs_config);
    30. }
    复制代码
    这一段就把FC0的几个I/O的功能给用了,因为LPC单片机端口复用默认是0即为IO口使用,但是呢养成一个好习惯,还是去吧该有的属性给配置了,这里虽然OLED的电流不是很大,使能与否都可以点亮,那万一遇到初始化功耗高的呢或者输出必须推挽,上拉呢?所以这里还是对端口的属性做了补充,上代码
    1. const uint32_t port0_pin23_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
    2.                                          IOCON_PIO_FUNC0 |
    3.                                          /* No addition pin function */
    4.                                          IOCON_PIO_MODE_INACT |
    5.                                          /* Standard mode, output slew rate control is enabled */
    6.                                          IOCON_PIO_SLEW_STANDARD |
    7.                                          /* Input function is not inverted */
    8.                                          IOCON_PIO_INV_DI |
    9.                                          /* Enables digital function */
    10.                                          IOCON_PIO_DIGITAL_EN |
    11.                                          /* Open drain is disabled */
    12.                                          IOCON_PIO_OPENDRAIN_DI);
    13.     /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
    14.     IOCON_PinMuxSet(IOCON, 0U, 23U, port0_pin23_config);
    15.         
    16.                 const uint32_t port0_pin28_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
    17.                                          IOCON_PIO_FUNC0 |
    18.                                          /* No addition pin function */
    19.                                          IOCON_PIO_MODE_INACT |
    20.                                          /* Standard mode, output slew rate control is enabled */
    21.                                          IOCON_PIO_SLEW_STANDARD |
    22.                                          /* Input function is not inverted */
    23.                                          IOCON_PIO_INV_DI |
    24.                                          /* Enables digital function */
    25.                                          IOCON_PIO_DIGITAL_EN |
    26.                                          /* Open drain is disabled */
    27.                                          IOCON_PIO_OPENDRAIN_DI);
    28.     /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
    29.     IOCON_PinMuxSet(IOCON, 0U, 28U, port0_pin28_config);

    30.                
    31.                
    32.                 const uint32_t port0_pin29_config = (/* Pin is configured as FC7_RXD_SDA_MOSI_DATA */
    33.                                          IOCON_PIO_FUNC0 |
    34.                                          /* No addition pin function */
    35.                                          IOCON_PIO_MODE_INACT |
    36.                                          /* Standard mode, output slew rate control is enabled */
    37.                                          IOCON_PIO_SLEW_STANDARD |
    38.                                          /* Input function is not inverted */
    39.                                          IOCON_PIO_INV_DI |
    40.                                          /* Enables digital function */
    41.                                          IOCON_PIO_DIGITAL_EN |
    42.                                          /* Open drain is disabled */
    43.                                          IOCON_PIO_OPENDRAIN_DI);
    44.     /* PORT0 PIN29 (coords: 92) is configured as FC7_RXD_SDA_MOSI_DATA */
    45.     IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config);        
    46.                
    47.     const uint32_t port0_pin30_config = (/* Pin is configured as FC7_TXD_SCL_MISO_WS */
    48.                                          IOCON_PIO_FUNC0 |
    49.                                          /* No addition pin function */
    50.                                          IOCON_PIO_MODE_INACT |
    51.                                          /* Standard mode, output slew rate control is enabled */
    52.                                          IOCON_PIO_SLEW_STANDARD |
    53.                                          /* Input function is not inverted */
    54.                                          IOCON_PIO_INV_DI |
    55.                                          /* Enables digital function */
    56.                                          IOCON_PIO_DIGITAL_EN |
    57.                                          /* Open drain is disabled */
    58.                                          IOCON_PIO_OPENDRAIN_DI);
    59.     /* PORT0 PIN30 (coords: 94) is configured as FC7_TXD_SCL_MISO_WS */
    60.     IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config);
    61.                
    62.                 const uint32_t port1_pin7_config = (/* Pin is configured as FC7_TXD_SCL_MISO_WS */
    63.                                          IOCON_PIO_FUNC0 |
    64.                                          /* No addition pin function */
    65.                                          IOCON_PIO_MODE_INACT |
    66.                                          /* Standard mode, output slew rate control is enabled */
    67.                                          IOCON_PIO_SLEW_STANDARD |
    68.                                          /* Input function is not inverted */
    69.                                          IOCON_PIO_INV_DI |
    70.                                          /* Enables digital function */
    71.                                          IOCON_PIO_DIGITAL_EN |
    72.                                          /* Open drain is disabled */
    73.                                          IOCON_PIO_OPENDRAIN_DI);
    74.     /* PORT0 PIN30 (coords: 94) is configured as FC7_TXD_SCL_MISO_WS */
    75.     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)
    哎...今天够累的,签到来了~
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-8-8 16:43
  • 签到天数: 1504 天

    连续签到: 1 天

    [LV.Master]伴坛终老

    97

    主题

    4693

    帖子

    12

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    10096
    最后登录
    2025-8-31
    发表于 2020-11-5 09:23:30 | 显示全部楼层
    大神 厉害了!
    速度与技术并存
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2025-7-31 14:43
  • 签到天数: 213 天

    连续签到: 1 天

    [LV.7]常住居民III

    34

    主题

    816

    帖子

    0

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    2193
    最后登录
    2025-7-31
    发表于 2020-11-5 09:30:32 | 显示全部楼层
    学习了!
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-7-11 08:53
  • 签到天数: 301 天

    连续签到: 2 天

    [LV.8]以坛为家I

    3932

    主题

    7552

    帖子

    0

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    40117
    最后登录
    2025-9-2
    发表于 2020-11-5 10:11:47 | 显示全部楼层
    视频上传中,稍后贴链接
    qiandao qiandao
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    擦汗
    2016-12-2 08:40
  • 签到天数: 3 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    103

    主题

    869

    帖子

    7

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    4351
    最后登录
    2025-8-21
    发表于 2020-11-5 10:49:03 | 显示全部楼层
    大神牛P
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    12 小时前
  • 签到天数: 1875 天

    连续签到: 1 天

    [LV.Master]伴坛终老

    203

    主题

    3万

    帖子

    64

    超级版主

    Rank: 8Rank: 8

    积分
    112717
    最后登录
    2025-9-1
    发表于 2020-11-5 18:10:33 | 显示全部楼层
    感谢分享,支持~~
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    慵懒
    2021-3-3 11:23
  • 签到天数: 9 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    1

    主题

    23

    帖子

    0

    中级会员

    Rank: 3Rank: 3

    积分
    278
    最后登录
    2021-9-15
    发表于 2020-11-5 20:44:09 | 显示全部楼层
    睡神大佬
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-11-4 13:30
  • 签到天数: 47 天

    连续签到: 1 天

    [LV.5]常住居民I

    3

    主题

    176

    帖子

    0

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    424
    最后登录
    2025-7-16
    发表于 2020-11-6 11:35:59 | 显示全部楼层
    感谢分享!
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-9-2 12:49 , Processed in 0.099410 second(s), 27 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表