Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
TianYing_ty100
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TY
TianYing_ty100
Commits
140457a2
Commit
140457a2
authored
May 23, 2024
by
李俭双
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix:更换串口驱动
parent
bee502c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
21 deletions
+52
-21
UART_DEMO.c
...re/Source/Device/Cmsemicon/BAT32A239/RTE/UART/UART_DEMO.c
+47
-15
UART_DEMO.h
...re/Source/Device/Cmsemicon/BAT32A239/RTE/UART/UART_DEMO.h
+5
-6
No files found.
Firmware/Source/Device/Cmsemicon/BAT32A239/RTE/UART/UART_DEMO.c
View file @
140457a2
...
@@ -9,16 +9,11 @@
...
@@ -9,16 +9,11 @@
* Description : *
* Description : *
* Function List : *
* 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 "UART_DEMO.h"
//#include <stdint.h>
unsigned
char
UART0_RX_BUF
[
UART_MAX_RECV_LEN
];
unsigned
char
UART0_RX_BUF
[
UART_MAX_RECV_LEN
];
unsigned
short
UART0_RX_STA
=
0
;
unsigned
short
UART0_RX_STA
=
0
;
unsigned
char
UART0_TX_BUF
[
UART_MAX_RECV_LEN
];
...
@@ -28,9 +23,9 @@ unsigned short UART0_RX_STA = 0;
...
@@ -28,9 +23,9 @@ unsigned short UART0_RX_STA = 0;
* @param bound
* @param bound
* @return init status
* @return init status
******************************************************************************/
******************************************************************************/
int8_t
Uart0_Init
(
uint32_t
bound
)
int8_t
Uart0_Init
(
uint32_t
bound
)
//主要查看寄存器
{
{
int8_t
ret
;
int8_t
ret
;
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
UART_InitTypeDef
UART_InitStructure
=
{
0
};
UART_InitTypeDef
UART_InitStructure
=
{
0
};
...
@@ -150,21 +145,58 @@ void uart_callback_error(uint8_t err_type)
...
@@ -150,21 +145,58 @@ void uart_callback_error(uint8_t err_type)
* @param None
* @param None
* @return None
* @return None
*****************************************************************************/
*****************************************************************************/
uint8_t
uart0_interrupt_receive
(
void
)
void
uart0_interrupt_receive
(
void
)
{
{
uint8_t
rx_data
;
volatile
uint8_t
rx_data
;
uint8_t
err_type
;
volatile
uint8_t
err_type
;
INTC_ClearPendingIRQ
(
SR0_IRQn
);
INTC_ClearPendingIRQ
(
SR0_IRQn
);
err_type
=
UART_GetErrStaus
(
UART0
,
UART_FLAG_FEF
|
UART_FLAG_PEF
|
UART_FLAG_OVF
);
err_type
=
UART_GetErrStaus
(
UART0
,
UART_FLAG_FEF
|
UART_FLAG_PEF
|
UART_FLAG_OVF
);
if
(
err_type
)
if
(
err_type
)
{
{
UART_ClearFlag
(
UART0
,
UART_FLAG_FEF
|
UART_FLAG_PEF
|
UART_FLAG_OVF
);
uart_callback_error
(
err_type
);
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
;
}
}
Firmware/Source/Device/Cmsemicon/BAT32A239/RTE/UART/UART_DEMO.h
View file @
140457a2
...
@@ -6,11 +6,11 @@
...
@@ -6,11 +6,11 @@
#include "uart.h"
#include "uart.h"
#include "gpio.h"
#include "gpio.h"
#include "isr.h"
#include "isr.h"
#define UART0_DMA_RCV
#define UART_MAX_RECV_LEN 256
#define UART_MAX_RECV_LEN 64
extern
unsigned
char
UART1_RX_BUF
[
UART_MAX_RECV_LEN
];
extern
unsigned
char
UART0_RX_BUF
[
UART_MAX_RECV_LEN
];
extern
unsigned
short
UART1_RX_STA
;
extern
unsigned
short
UART0_RX_STA
;
extern
unsigned
char
UART0_TX_BUF
[
UART_MAX_RECV_LEN
];
int8_t
Uart0_Init
(
uint32_t
bound
);
int8_t
Uart0_Init
(
uint32_t
bound
);
...
@@ -19,6 +19,5 @@ char Uart0_Receive(void);
...
@@ -19,6 +19,5 @@ char Uart0_Receive(void);
void
Uart0_IntSend
(
uint8_t
*
tx_buf
,
uint16_t
tx_num
);
void
Uart0_IntSend
(
uint8_t
*
tx_buf
,
uint16_t
tx_num
);
void
uart0_interrupt_send
(
void
*
msg
);
void
uart0_interrupt_send
(
void
*
msg
);
uint8_t
uart0_interrupt_receive
(
void
);
void
uart0_interrupt_receive
(
void
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment