久芯网

Mbed OS 的函数,改成HAL函数怎么写?请教请教

avatar 立码赚 提问时间: 2023-07-10 16:41:15 / 未解决
  1. TextLCD::TextLCD(PinName rs, PinName e, PinName d4, PinName d5,
  2.                  PinName d6, PinName d7, LCDType type) : _rs(rs),
  3.         _e(e), _d(d4, d5, d6, d7),
  4.         _type(type) {

  5.     _e  = 1;
  6.     _rs = 0;            // command mode

  7.     wait_us(1500);        // Wait 15ms to ensure powered up

  8.     /* send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)*/
  9.     for (int i=0; i<3; i++) {
  10.         writeByte(0x3);
  11.         wait_us(1640);  // this command takes 1.64ms, so wait for it
  12.     }
  13.     writeByte(0x2);     // 4-bit mode
  14.     wait_us(40);    // most instructions take 40us

  15.     writeCommand(0x28); // Function set 001 BW N F - -
  16.     writeCommand(0x0C);
  17.     writeCommand(0x6);  // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
  18.     cls();
  19. }
复制代码
这个原来是Mbed OS 的函数,改成 HAl函数怎么搞?希望大师指导指导
3个回答
  • avatar lugl
    回答时间: 2023-07-10 17:03:46

    writeByte,你找到这个函数,把这个函数修改过来就行了,还有就是delay也要相应的修改。

  • avatar xmshao
    回答时间: 2023-07-10 17:36:33

    你既然用过MBED,从架构上讲有有类似的地方,都有个硬件抽象层。你现在想使用STM32HAL库的话,个人觉得最快的办法就是先打开一些STM32HAL库的例程看看,了解下结构。相信你可以很快上手。

  • avatar 立码赚
    回答时间: 2023-07-10 17:54:40
    lugl 发表于 2022-12-22 11:38
    writeByte,你找到这个函数,把这个函数修改过来就行了,还有就是delay也要相应的修改。

    找了别一个程序,不改这个了

会员中心 微信客服
客服
回到顶部