Files

56 lines
2.0 KiB
C

#ifndef __USART_H
#define __USART_H
#include "stdio.h"
#include "stm32f4xx_conf.h"
#include "sys.h"
//////////////////////////////////////////////////////////////////////////////////
//This program is for educational purposes only, without the author's permission, may not be used for any other purpose
//ALIENTEK STM32F4 Explorer Board
//Initialize serial port 1
//Hot Atomic @ALIENTEK
//Forum: www.openedv.com
//Date modified: 2014/6/10
//Version: V1.4
//All rights reserved pirated reserved.
//Copyright(C) Guangzhou wing electronic technology limited company 2009-2019
//All rights reserved
//********************************************************************************
//V1.3 changes description
// Supports serial port baud rate setting at different frequencies.
// Added support for printf
// Serial port receive command features have been added.
// Fixed printf first character missing bug
//V1.4 amended description
// 1, modify the initialize serial IO bug
// 2, modify the USART_RX_STA makes serial port maximum bytes received 2 of 14
// 3, USART_REC_LEN, defines the serial port the maximum allowable number of bytes received (not more than 2 of 14)
// 4, the modified EN_USART1_RX method
//V1.5 modify the description
// 1, added support for UCOSII
//////////////////////////////////////////////////////////////////////////////////
#define DEBUG_PORT USART1
/* Defines -------------------------------------------------------------------*/
#define UART1_TX_BUFFER_SIZE 1024
#define UART1_RX_BUFFER_SIZE 128
/* Type declarations ---------------------------------------------------------*/
typedef struct{
u16 RxInPos, RxOutPos;
u16 TxInPos, TxOutPos;
u8 RxBuf[UART1_RX_BUFFER_SIZE];
u8 TxBuf[UART1_TX_BUFFER_SIZE];
} UART1_Info;
void uart1_init(u32 bound);
ErrorStatus UART1_GetChar(u8 *data);
void UART1_PutChar(const u8 ascii);
void UART1_PutStr(u8 *str, u16 len);
void UART1_printf(const char *fmt,...);
u8 UART1_GC(void);
#endif