【爱普特 APT32F110 ev board 试用测评】之三: printf花式表白

  APT32F110x 系列串口功能强大: 可以完成STM32串口功能,驱动AT 物联网模组不在话下。

 资源串行通信接口:1 × I2C3 x UART1 x USART1 x SPI1 x SIO

 通用异步收发器(UART

3个通道

8位数据长度,支持校验位(奇偶校验,0/1校验)

单独的8x8位收发FIFO 

可编程的波特率

同步异步收发器(USART

1个通道

支持5678位数据长度 

单独的8x8位收发FIFO

可编程的波特率 

校验位,帧检测和缓存溢出错误报告 

支持Loop-back模式 

支持同步全双工模式 

支持LIN总线协议: LIN1.2或者LIN2.0

支持智能卡协议: ISO7816-3兼容

2.png


编程实践:

 时钟配置

    

   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


}

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

   先上图案:

1.png


代码实现很简单, 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,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,2,2,2,2,2,2,2,2,2,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,1,1,1,1,1,1,1,1,0,0,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,2,2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2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,0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,0,3,0,3,0,0,3,3,0,0,3,3,0,3,0,0,0,0,3,0,0,0,3,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,0,3,0,3,0,0,3,3,3,3,3,3,0,3,0,0,0,0,3,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,3,0,0,0,3,0,3,0,0,0,3,0,0,0,3,0,0,0,3,3,0,0,0,0,0,3,0,0,0,0,3,0,0,0,3,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,3,3,3,0,0,3,0,0,3,3,3,0,0,0,0,3,0,0,0,0,0,3,3,3,0,0,0,3,3,3,3,0,0,0,3,3,3,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,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


     };


 


 for(int i=0;i<23;i++)


  for(int j=0;j<80;j++)


  {


   if(a[i][j] == 0)


    my_printf(" ",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

  }

  

}