66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
|
#include "SWM320.h"
|
|||
|
|
|||
|
void SerialInit(void);
|
|||
|
|
|||
|
int main(void)
|
|||
|
{
|
|||
|
uint32_t i;
|
|||
|
|
|||
|
SystemInit();
|
|||
|
|
|||
|
SerialInit();
|
|||
|
|
|||
|
GPIO_Init(GPIOA, PIN4, 1, 0, 0); //GPIOA.4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
GPIO_Init(GPIOA, PIN5, 1, 0, 0); //GPIOA.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
GPIO_ClrBit(GPIOA, PIN4);
|
|||
|
GPIO_SetBit(GPIOA, PIN5);
|
|||
|
|
|||
|
while(1==1)
|
|||
|
{
|
|||
|
GPIO_InvBit(GPIOA, PIN4);
|
|||
|
GPIO_InvBit(GPIOA, PIN5);
|
|||
|
for(i=0; i<5000000; i++) i=i;
|
|||
|
|
|||
|
printf("Hi, World!\r\n");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void SerialInit(void)
|
|||
|
{
|
|||
|
UART_InitStructure UART_initStruct;
|
|||
|
|
|||
|
PORT_Init(PORTA, PIN2, FUNMUX0_UART0_RXD, 1); //GPIOA.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪUART0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
PORT_Init(PORTA, PIN3, FUNMUX1_UART0_TXD, 0); //GPIOA.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪUART0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
UART_initStruct.Baudrate = 57600;
|
|||
|
UART_initStruct.DataBits = UART_DATA_8BIT;
|
|||
|
UART_initStruct.Parity = UART_PARITY_NONE;
|
|||
|
UART_initStruct.StopBits = UART_STOP_1BIT;
|
|||
|
UART_initStruct.RXThreshold = 3;
|
|||
|
UART_initStruct.RXThresholdIEn = 0;
|
|||
|
UART_initStruct.TXThreshold = 3;
|
|||
|
UART_initStruct.TXThresholdIEn = 0;
|
|||
|
UART_initStruct.TimeoutTime = 10;
|
|||
|
UART_initStruct.TimeoutIEn = 0;
|
|||
|
UART_Init(UART0, &UART_initStruct);
|
|||
|
UART_Open(UART0);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: fputc()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: printf()ʹ<EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʵĴ<EFBFBD><EFBFBD>ڴ<EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: int ch Ҫ<EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|||
|
* FILE *f <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
int fputc(int ch, FILE *f)
|
|||
|
{
|
|||
|
UART_WriteByte(UART0, ch);
|
|||
|
|
|||
|
while(UART_IsTXBusy(UART0));
|
|||
|
|
|||
|
return ch;
|
|||
|
}
|