標(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
看一下使用串口的示例代碼
#include "hml/hml.h"
void sys_init(void)
{
UART_configTypeDef uc;
uc.baudrate = 115200; /* baud rate is 115200bps */
uc.baudrateGenerator = UART_baudrateGenerator_brt; /* select timer-1 as baud rate generator */
uc.baudGeneratorPrescalerState = DISABLE; /* 1T mode */
uc.interruptState = ENABLE;
uc.interruptPriority = DISABLE;
uc.mode = UART_mode_1;
uc.multiBaudrate = DISABLE;
uc.pinmap = UART_pinmap_0;
uc.receiveState = ENABLE;
UART_config(&uc);
}
void main(void)
{
sys_init();
while (true)
{
/* send per 500ms */
sleep(500);
UART_sendString("Hello, world!\r\n");
}
}
復(fù)制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1