优化整定,DHCP有问题待优化

This commit is contained in:
冯佳
2026-03-09 15:34:18 +08:00
parent 20597d22e5
commit 925df72fa0
30 changed files with 2556 additions and 2002 deletions

74
drivers/hal/hal.h Normal file
View File

@ -0,0 +1,74 @@
/*
* 硬件抽象层通用接口
* 功能定义硬件抽象层的通用接口包括串口、I2C和以太网驱动
* 依赖硬件STM32F407VE
* 跨平台适配点:通过不同平台的实现文件适配不同硬件
*/
#ifndef HAL_H
#define HAL_H
#include <stdint.h>
#include "osal.h"
/* 硬件抽象层错误码 */
typedef enum {
HAL_STATUS_OK = 0,
HAL_STATUS_ERROR = -1,
HAL_STATUS_BUSY = -2,
HAL_STATUS_TIMEOUT = -3
} hal_status_t;
/* 串口波特率定义 */
typedef enum {
HAL_UART_BAUDRATE_9600 = 9600,
HAL_UART_BAUDRATE_115200 = 115200,
HAL_UART_BAUDRATE_460800 = 460800,
HAL_UART_BAUDRATE_921600 = 921600
} hal_uart_baudrate_t;
/* I2C时钟速度定义 */
typedef enum {
HAL_I2C_CLOCK_SPEED_100K = 100000,
HAL_I2C_CLOCK_SPEED_400K = 400000
} hal_i2c_clock_speed_t;
/* 串口硬件抽象层接口 */
typedef struct {
hal_status_t (*init)(hal_uart_baudrate_t baudrate);
hal_status_t (*deinit)(void);
hal_status_t (*send)(const uint8_t *data, uint32_t len);
hal_status_t (*recv)(uint8_t *data, uint32_t len, uint32_t timeout);
} hal_uart_ops_t;
/* I2C硬件抽象层接口 */
typedef struct {
hal_status_t (*init)(hal_i2c_clock_speed_t clock_speed);
hal_status_t (*deinit)(void);
hal_status_t (*master_transmit)(uint16_t dev_addr, const uint8_t *data, uint32_t len, uint32_t timeout);
hal_status_t (*master_receive)(uint16_t dev_addr, uint8_t *data, uint32_t len, uint32_t timeout);
} hal_i2c_ops_t;
/* 以太网硬件抽象层接口 */
typedef struct {
hal_status_t (*init)(void);
hal_status_t (*deinit)(void);
hal_status_t (*send)(const uint8_t *data, uint32_t len);
hal_status_t (*recv)(uint8_t *data, uint32_t *len, uint32_t timeout);
hal_status_t (*get_link_status)(void);
} hal_eth_ops_t;
/* 硬件抽象层操作结构体 */
typedef struct {
const hal_uart_ops_t *uart;
const hal_i2c_ops_t *i2c;
const hal_eth_ops_t *eth;
} hal_ops_t;
/* 硬件抽象层初始化函数 */
extern hal_status_t hal_init(void);
/* 获取硬件抽象层操作结构体 */
extern const hal_ops_t *hal_get_ops(void);
#endif /* HAL_H */