|
這個(gè)項(xiàng)目封裝STC12系列的寄存器配置信息, 提供接口方法給上層調(diào)用. 因?yàn)閭鹘y(tǒng)的代碼都是直接用八進(jìn)制值給寄存器賦值進(jìn)行操作, 不便于記憶, 用這個(gè)封裝庫就可以使用類似于STM的高級語言方式進(jìn)行開發(fā), 解決了開發(fā)過程極度依賴手冊的問題.
項(xiàng)目地址: 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ù)制代碼
|
評分
-
查看全部評分
|