首頁(yè) 資訊 > 創(chuàng)新 > 正文

【愛普特 APT32F110 ev board 試用測(cè)評(píng)】之三: printf花式表白

APT32F110x 系列串口功能強(qiáng)大:?可以完成STM32串口功能,驅(qū)動(dòng)AT 物聯(lián)網(wǎng)模組不在話下。

資源串行通信接口:1 × I2C,3 x UART,1 x USART,1 x SPI,1 x SIO

通用異步收發(fā)器(UART)


(相關(guān)資料圖)

? 3個(gè)通道

? 8位數(shù)據(jù)長(zhǎng)度,支持校驗(yàn)位(奇偶校驗(yàn),0/1校驗(yàn))

? 單獨(dú)的8x8位收發(fā)FIFO?

? 可編程的波特率

同步異步收發(fā)器(USART)

? 1個(gè)通道

? 支持5、6、7和8位數(shù)據(jù)長(zhǎng)度?

? 單獨(dú)的8x8位收發(fā)FIFO

? 可編程的波特率?

? 校驗(yàn)位,幀檢測(cè)和緩存溢出錯(cuò)誤報(bào)告?

? 支持Loop-back模式?

? 支持同步全雙工模式?

? 支持LIN總線協(xié)議: LIN1.2或者LIN2.0

? 支持智能卡協(xié)議: ISO7816-3兼容

編程實(shí)踐:

時(shí)鐘配置

void system_init(void)

{

CK_CPU_DISALLNORMALIRQ;

csi_iwdt_close();//close iwdt

csi_sysclk_config();//sysclk config

csi_get_sclk_freq();

csi_get_pclk_freq();

csi_tick_init();

csi_clk_calib();

CK_CPU_ENALLNORMALIRQ;

}

串口配置: 115200波特率

__attribute__((weak)) void board_init(void)

{

//console config for print

console.uart_id = (uint32_t)CONSOLE_IDX;

console.baudrate = 115200U;

console.tx.pin = CONSOLE_TXD;? ?

console.tx.func = CONSOLE_TXD_FUNC;

console.rx.pin = CONSOLE_RXD;

console.rx.func = CONSOLE_RXD_FUNC;

console.uart = (csp_uart_t *)(APB_UART0_BASE + CONSOLE_IDX * 0x1000);

console_init(&console);

#ifdef CONFIG_USER_PM//low power manage switch

if(csi_get_rst_reason() & RST_SRC_SNOOZE_WKUP)//wake up from snooze mode

{

g_tPmCore.wkup_frm_snooze = (void *)csi_ureg_read(USER_REG0);

if(g_tPmCore.wkup_frm_snooze)

g_tPmCore.wkup_frm_snooze();

}

else if(csi_get_rst_reason() & RST_SRC_SHD_WKUP)//wake up from shutdown mode

{

g_tPmCore.wkup_frm_shutdown = (void *)csi_ureg_read(USER_REG0);

if(g_tPmCore.wkup_frm_shutdown)

g_tPmCore.wkup_frm_shutdown();

}

#endif

}

花式打印表白啊,程序員哄女孩子的利器??!

先上圖案:

代碼實(shí)現(xiàn)很簡(jiǎn)單,?printf打印就可以了:

int main()

{

//start_system();

system_init();

board_init();

csi_pin_set_mux(PB02, PB02_OUTPUT); //PA06 output

csi_pin_set_high(PB02); //PA06 output high;

int a[23][80] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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" ",a[i][j]);

else if(a[i][j] == 1)

my_printf("*",a[i][j]);

else if(a[i][j] == 2)

my_printf("o",a[i][j]);

else if(a[i][j] == 3)

my_printf("u",a[i][j]);

}

//my_printf("%d",a[i][j]);

my_printf("\n");

while(1)

{

//my_printf("Best wishes to every one\n"); //print message

mdelay(1000); //delay 100ms

csi_pin_toggle(PB02); //PA06 toggle

}

}

關(guān)鍵詞: 數(shù)據(jù)長(zhǎng)度 奇偶校驗(yàn) 不在話下 就可以了 溢出錯(cuò)誤

最近更新

關(guān)于本站 管理團(tuán)隊(duì) 版權(quán)申明 網(wǎng)站地圖 聯(lián)系合作 招聘信息

Copyright © 2005-2018 創(chuàng)投網(wǎng) - www.mallikadua.com All rights reserved
聯(lián)系我們:39 60 29 14 2@qq.com
皖I(lǐng)CP備2022009963號(hào)-3