📄 output.c
字号:
#include "board.h"
#include "at91sam7s64.h"
#include "lib_at91sam7s64.h"
#include "ADS.h"
#include "Output.h"
//*----------------------------------------------------------------------------
//* Function Name : Init_Debug
//* Object : 调试串口初始化 (固定波特率115200)
//* Input Parameters : none
//* Output Parameters : none
//*----------------------------------------------------------------------------
void Init_Debug(void)
{
AT91F_DBGU_CfgPIO();
// Configure DBGU
AT91F_US_Configure (
(AT91PS_USART) AT91C_BASE_DBGU, // DBGU base address
MCK, // 60 MHz
AT91C_US_ASYNC_MODE, // mode Register to be programmed
115200 , // baudrate to be programmed
0); // timeguard to be programmed
// Enable Transmitter
AT91F_US_EnableTx((AT91PS_USART) AT91C_BASE_DBGU);
// Enable Receiver
AT91F_US_EnableRx((AT91PS_USART) AT91C_BASE_DBGU);
}
//*----------------------------------------------------------------------------
//* \fn AT91F_DBGU_Printk
//* \brief This function is used to send a string through the DBGU channel (Very low level debugging)
//*----------------------------------------------------------------------------
void AT91F_DBGU_Printk(
char *buffer) // \arg pointer to a string ending by \0
{
while(*buffer != '\0') {
while (!AT91F_US_TxReady((AT91PS_USART)AT91C_BASE_DBGU));
AT91F_US_PutChar((AT91PS_USART)AT91C_BASE_DBGU, *buffer++);
}
}
//*----------------------------------------------------------------------------
//* Function Name : bcd2bin
//* Object : BCD码转二进制
//* Input Parameters : none
//* Output Parameters : none
//*----------------------------------------------------------------------------
INT8U bcd2bin(INT8U c)
{
return ((c>>4)*10) + (c&0x0f);
}
//*----------------------------------------------------------------------------
//* Function Name : pri
//* Object : 把数字显示出来
//* Input Parameters : none
//* Output Parameters : none
//*----------------------------------------------------------------------------
void pri(INT32U offset)
{
INT8U buffer[11];
INT8U i;
buffer[0] = ((offset /10000000000ll))+0x30;
buffer[1] = ((offset %1000000000)/100000000)+0x30;
buffer[2] = ((offset %100000000) /10000000)+0x30;
buffer[3] = ((offset %10000000) /1000000)+0x30;
buffer[4] = ((offset %1000000) /100000)+0x30;
buffer[5] = ((offset %100000) /10000)+0x30;
buffer[6] = ((offset %10000) /1000)+0x30;
buffer[7] = ((offset %1000) /100)+0x30;
buffer[8] = ((offset %100) /10)+0x30;
buffer[9] = (offset %10) +0x30;
buffer[10] = '\0';
for(i=0;i<9;i++)
{
if(buffer[i] =='0')
{
buffer[i] = ' ';
}
else
{
break;
}
}
AT91F_DBGU_Printk((char *)&buffer[i/*10-bit*/]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -