標(biāo)題: STC12系列的封裝庫 HML_FwLib_STC12 [打印本頁]

作者: michaelchain    時間: 2021-8-16 00:30
標(biāo)題: STC12系列的封裝庫 HML_FwLib_STC12
這個項目封裝STC12系列的寄存器配置信息, 提供接口方法給上層調(diào)用. 因為傳統(tǒng)的代碼都是直接用八進(jìn)制值給寄存器賦值進(jìn)行操作, 不便于記憶, 用這個封裝庫就可以使用類似于STM的高級語言方式進(jìn)行開發(fā), 解決了開發(fā)過程極度依賴手冊的問題.
項目地址: https://github.com/IOsetting/HML_FwLib_STC12

看一下使用串口的示例代碼
  1. #include "hml/hml.h"

  2. void sys_init(void)
  3. {
  4.     UART_configTypeDef uc;

  5.     uc.baudrate                    = 115200;                        /* baud rate is 115200bps */
  6.     uc.baudrateGenerator           = UART_baudrateGenerator_brt;    /* select timer-1 as baud rate generator */
  7.     uc.baudGeneratorPrescalerState = DISABLE;                       /* 1T mode */
  8.     uc.interruptState              = ENABLE;
  9.     uc.interruptPriority           = DISABLE;
  10.     uc.mode                        = UART_mode_1;
  11.     uc.multiBaudrate               = DISABLE;
  12.     uc.pinmap                      = UART_pinmap_0;
  13.     uc.receiveState                = ENABLE;

  14.     UART_config(&uc);
  15. }

  16. void main(void)
  17. {
  18.     sys_init();

  19.     while (true)
  20.     {
  21.         /* send per 500ms */
  22.         sleep(500);
  23.         UART_sendString("Hello, world!\r\n");
  24.     }
  25. }
復(fù)制代碼









歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1