初级会员
- 积分
- 71
- 金钱
- 71
- 注册时间
- 2013-9-11
- 在线时间
- 6 小时
|
发表于 2016-2-2 14:14:19
|
显示全部楼层
#ifdef _RAISONANCE_
#define PUTCHAR_PROTOTYPE int putchar (char c)
#define GETCHAR_PROTOTYPE int getchar (void)
#elif defined (_COSMIC_)
#define PUTCHAR_PROTOTYPE char putchar (char c)
#define GETCHAR_PROTOTYPE char getchar (void)
#else /* _IAR_ */
#define PUTCHAR_PROTOTYPE int putchar (int c)
#define GETCHAR_PROTOTYPE int getchar (void)
void SendChar(uint8_t ch)
{
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE) == 0);
USART1->DR = ch;
}
void Sendstr(uint8_t *s,uint8_t n) //串口发送字符串
{
int i = 0;
while(i < n)
{
SendChar(s[i]);
i++;
}
}
PUTCHAR_PROTOTYPE //打印输出函数printf,可用于调试
{
/* Write a character to the USART */
USART_SendData8(USART1, c);
/* Loop until the end of transmission */
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
return (c);
} |
|