mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
加入串口接收
This commit is contained in:
@@ -36,7 +36,8 @@ extern UART_HandleTypeDef huart6;
|
|||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
#define USART_RX_BUFFER_SIZE 25
|
#define USART_RX_BUFFER_SIZE 25
|
||||||
extern uint8_t uart_receive_str[USART_RX_BUFFER_SIZE + 1];
|
extern uint8_t uart_receive_buf[USART_RX_BUFFER_SIZE + 1];
|
||||||
|
extern uint8_t uart_receive_flag;
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
void MX_USART6_UART_Init(void);
|
void MX_USART6_UART_Init(void);
|
||||||
|
|||||||
@@ -250,9 +250,10 @@ void USART6_IRQHandler(void)
|
|||||||
/* USER CODE BEGIN USART6_IRQn 0 */
|
/* USER CODE BEGIN USART6_IRQn 0 */
|
||||||
if(__HAL_UART_GET_FLAG(&huart6, UART_FLAG_IDLE) != RESET)
|
if(__HAL_UART_GET_FLAG(&huart6, UART_FLAG_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
|
uart_receive_flag = 1;
|
||||||
__HAL_UART_CLEAR_FLAG(&huart6, UART_FLAG_IDLE);
|
__HAL_UART_CLEAR_FLAG(&huart6, UART_FLAG_IDLE);
|
||||||
HAL_UART_DMAStop(&huart6);
|
HAL_UART_DMAStop(&huart6);
|
||||||
HAL_UART_Receive_DMA(&huart6, uart_receive_str, USART_RX_BUFFER_SIZE);
|
HAL_UART_Receive_DMA(&huart6, uart_receive_buf, USART_RX_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END USART6_IRQn 0 */
|
/* USER CODE END USART6_IRQn 0 */
|
||||||
|
|||||||
@@ -21,9 +21,11 @@
|
|||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
// memeory for receive string
|
// memeory for receive string
|
||||||
uint8_t uart_receive_str[USART_RX_BUFFER_SIZE + 1];
|
uint8_t uart_receive_buf[USART_RX_BUFFER_SIZE + 1];
|
||||||
|
uint8_t uart_receive_flag = 0; // flag for receive complete
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
@@ -162,6 +164,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
|||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
int fputc(int ch, FILE *f)
|
||||||
|
{
|
||||||
|
HAL_UART_Transmit(&huart6, (uint8_t *)&ch, 1, 0xffff);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
//串口6发送
|
//串口6发送
|
||||||
void UART6_TX_Send(uint8_t *buffer, uint16_t length)
|
void UART6_TX_Send(uint8_t *buffer, uint16_t length)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user