Commit 140457a2 authored by 李俭双's avatar 李俭双

🐞 fix:更换串口驱动

parent bee502c3
......@@ -9,16 +9,11 @@
* Description : *
* Function List : *
********************************************************************************/
//#include "uart_demo.h"
//#include "tim_demo.h"
//#include "dma_demo.h"
//#include "uart.h"
//#include "gpio.h"
#include "UART_DEMO.h"
//#include <stdint.h>
unsigned char UART0_RX_BUF[UART_MAX_RECV_LEN];
unsigned short UART0_RX_STA = 0;
unsigned char UART0_TX_BUF[UART_MAX_RECV_LEN];
......@@ -28,7 +23,7 @@ unsigned short UART0_RX_STA = 0;
* @param bound
* @return init status
******************************************************************************/
int8_t Uart0_Init(uint32_t bound)
int8_t Uart0_Init(uint32_t bound)//主要查看寄存器
{
int8_t ret;
GPIO_InitTypeDef GPIO_InitStruct = {0};
......@@ -150,21 +145,58 @@ void uart_callback_error(uint8_t err_type)
* @param None
* @return None
*****************************************************************************/
uint8_t uart0_interrupt_receive(void)
void uart0_interrupt_receive(void)
{
uint8_t rx_data;
uint8_t err_type;
volatile uint8_t rx_data;
volatile uint8_t err_type;
INTC_ClearPendingIRQ(SR0_IRQn);
err_type = UART_GetErrStaus(UART0, UART_FLAG_FEF | UART_FLAG_PEF | UART_FLAG_OVF);
if (err_type)
{
UART_ClearFlag(UART0,UART_FLAG_FEF | UART_FLAG_PEF | UART_FLAG_OVF);
uart_callback_error(err_type);
}
rx_data = UART0_RX;
//UART_Put((uint8_t)UART0_RX);
// if ((UART0_RX_STA & 0x8000U) == 0) //½ÓÊÕδÍê³É
// {
// if (UART0_RX_STA & 0x4000U) //½ÓÊÕµ½0x0d
// {
// if (rx_data != 0x0a)
// {
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA++;
// }
// else
// {
// UART0_RX_STA |= 0x8000;
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// }
// else //»¹Î´½ÓÊÕµ½0x0d
// {
// if (rx_data == 0x0d)
// {
// UART0_RX_STA |= 0x4000;
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// else
// {
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// }
// }
// else if ((UART0_RX_STA & 0x8000U) == 1) // receive finished
// {
// }
return rx_data;
}
......@@ -6,11 +6,11 @@
#include "uart.h"
#include "gpio.h"
#include "isr.h"
#define UART0_DMA_RCV
#define UART_MAX_RECV_LEN 64
#define UART_MAX_RECV_LEN 256
extern unsigned char UART1_RX_BUF[UART_MAX_RECV_LEN];
extern unsigned short UART1_RX_STA ;
extern unsigned char UART0_RX_BUF[UART_MAX_RECV_LEN];
extern unsigned short UART0_RX_STA ;
extern unsigned char UART0_TX_BUF[UART_MAX_RECV_LEN];
int8_t Uart0_Init(uint32_t bound);
......@@ -19,6 +19,5 @@ char Uart0_Receive(void);
void Uart0_IntSend(uint8_t *tx_buf, uint16_t tx_num);
void uart0_interrupt_send(void *msg);
uint8_t uart0_interrupt_receive(void);
void uart0_interrupt_receive(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment