main.c
来自「开源的国外AT91SAM7S64开发板」· C语言 代码 · 共 48 行
C
48 行
// This program shows how to work with USART port
// USART0 and USART 1 (respectively RS232_0 connector and RS232_1 connector) returns echo + *
// Notice: Jumper RXDO/DRXD must be in position RXDO
// Jumper TXDO/DTXD must be in position TXDO
#include "AT91SAM7S64.h"
#include "system.h"
#include "usart.h"
//it's a simple delay
void Delay (unsigned long a) { while (--a!=0); }
//variables for readed char from uart
unsigned int ch1 = 0;
unsigned int ch2 = 0;
int main()
{
/**** System init ****/
InitFrec();
/**** UART ****/
InitUSART0();
InitUSART1();
while(1)
{
/*** UART ***/
ch1 = read_char_USART0_nonstop();
if(ch1 != 0)
{
write_char_USART0(ch1);
write_char_USART0('*');
ch1 = 0;
}
ch2 = read_char_USART1_nonstop();
if(ch2 != 0)
{
write_char_USART1(ch2);
write_char_USART1('*');
ch2 = 0;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?