Initial commit: PY32MD530H28U7TR步进电机控制器项目
完整实现了以下模块: - 系统数据总线(sys_data_bus)模块间通信 - UART/USART/LPUART驱动 + RS485半双工 - I2C驱动(AS5600角度传感器 + AT24C02 EEPROM) - Modbus RTU从站协议 - 步进电机微步进控制(正弦/余弦换相+S曲线加减速) - 到位开关驱动(DI_MIN/DI_MAX) - PGA+ADC电流检测 - 系统监控任务(内存/串口/传感器/任务状态) - LED/Key外设驱动 - 基于CMake + arm-none-eabi-gcc构建系统
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#ifndef UART_DRIVER_H__
|
||||
#define UART_DRIVER_H__
|
||||
|
||||
#include "common_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
UART_ID_USART1 = 0,
|
||||
UART_ID_UART1,
|
||||
UART_ID_LPUART1,
|
||||
UART_ID_COUNT,
|
||||
} uart_id_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t tx_bytes;
|
||||
uint32_t rx_bytes;
|
||||
uint32_t overflow_errors;
|
||||
} uart_stats_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t baudrate;
|
||||
uint8_t data_bits;
|
||||
uint8_t stop_bits;
|
||||
uint8_t parity;
|
||||
} uart_config_t;
|
||||
|
||||
ret_code_t uart_init(uart_id_t id, const uart_config_t *config);
|
||||
ret_code_t uart_deinit(uart_id_t id);
|
||||
ret_code_t uart_send(uart_id_t id, const uint8_t *data, uint32_t len);
|
||||
ret_code_t uart_receive(uart_id_t id, uint8_t *data, uint32_t len, uint32_t timeout);
|
||||
ret_code_t uart_send_dma(uart_id_t id, const uint8_t *data, uint32_t len);
|
||||
ret_code_t uart_receive_dma(uart_id_t id, uint8_t *data, uint32_t len);
|
||||
uint32_t uart_available(uart_id_t id);
|
||||
ret_code_t uart_set_rs485_dir(uart_id_t id, uint8_t tx_mode);
|
||||
const uart_stats_t* uart_get_stats(uart_id_t id);
|
||||
void uart_reset_stats(uart_id_t id);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user