generated from hulk/gd32e23x_template_cmake_vscode
AI工具写的环形缓冲区
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#ifndef BOARD_CONFIG_H
|
||||
#define BOARD_CONFIG_H
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[RS485 PHY DEFINE]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define RS485_MAX13487 //RS485 PHY : MAX13487 (AutoDir)
|
||||
#undef RS485_MAX13487 //RS485 PHY : SP3487 (no AutoDir)
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define LED_PORT GPIOA
|
||||
@@ -17,6 +22,7 @@
|
||||
#define RS485_PHY USART0
|
||||
#define RS485_BAUDRATE 115200U
|
||||
#define RS485_EN_PIN GPIO_PIN_1
|
||||
#define RS485_IRQ USART0_IRQn
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
10
Inc/command.h
Normal file
10
Inc/command.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void command_process(void);
|
||||
void handle_command(const uint8_t *cmd, uint8_t len);
|
||||
|
||||
#endif // COMMAND_H
|
@@ -1,47 +1,27 @@
|
||||
/*!
|
||||
\file systick.h
|
||||
\brief the header file of systick
|
||||
|
||||
\version 2025-02-10, V2.4.0, demo for GD32E23x
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2025, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ************************************************************************
|
||||
*
|
||||
* @file systick.h
|
||||
* @author GD32
|
||||
* @brief
|
||||
*
|
||||
* ************************************************************************
|
||||
* @copyright Copyright (c) 2024 GD32
|
||||
* ************************************************************************
|
||||
*/
|
||||
#ifndef SYS_TICK_H
|
||||
#define SYS_TICK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* function declarations */
|
||||
/* configure systick */
|
||||
void systick_config(void);
|
||||
|
||||
/* delay a time in milliseconds */
|
||||
void delay_ms(uint32_t count);
|
||||
/* delay decrement */
|
||||
void delay_decrement(void);
|
||||
|
||||
#endif /* SYS_TICK_H */
|
||||
/* delay a time in microseconds */
|
||||
void delay_us(uint32_t count);
|
||||
|
||||
#endif /* SYS_TICK_H */
|
@@ -3,13 +3,15 @@
|
||||
|
||||
#include "gd32e23x.h"
|
||||
|
||||
#define RX_BUFFER_SIZE 32
|
||||
|
||||
typedef enum {
|
||||
UART_PRINTF_USART0 = 0,
|
||||
UART_PRINTF_USART1 = 1,
|
||||
UART_PRINTF_BOTH = 2
|
||||
} uart_printf_port_t;
|
||||
|
||||
void uart0_init(void);
|
||||
void uart_set_printf_port(uart_printf_port_t port);
|
||||
void rs485_init(void);
|
||||
// void uart_set_printf_port(uart_printf_port_t port);
|
||||
|
||||
#endif // UART_H
|
||||
|
14
Inc/uart_ring_buffer.h
Normal file
14
Inc/uart_ring_buffer.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef UART_RING_BUFFER_H
|
||||
#define UART_RING_BUFFER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define UART_RX_BUFFER_SIZE 128
|
||||
void uart_ring_buffer_init(void);
|
||||
uint16_t uart_rx_available(void);
|
||||
int uart_rx_get(void);
|
||||
void uart_rx_put(uint8_t data);
|
||||
void uart_rx_clear(void);
|
||||
|
||||
#endif // UART_RING_BUFFER_H
|
Reference in New Issue
Block a user