优化整定,DHCP有问题待优化
This commit is contained in:
57
drivers/hal/hal.c
Normal file
57
drivers/hal/hal.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 硬件抽象层实现
|
||||
* 功能:实现硬件抽象层的初始化和操作结构体获取
|
||||
* 依赖硬件:STM32F407VE
|
||||
* 跨平台适配点:通过不同平台的实现文件适配不同硬件
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
/* 前向声明平台特定的硬件抽象层实现 */
|
||||
extern const hal_uart_ops_t stm32f4_uart_ops;
|
||||
extern const hal_i2c_ops_t stm32f4_i2c_ops;
|
||||
extern const hal_eth_ops_t stm32f4_eth_ops;
|
||||
|
||||
/* 硬件抽象层操作结构体 */
|
||||
static const hal_ops_t hal_ops = {
|
||||
.uart = &stm32f4_uart_ops,
|
||||
.i2c = &stm32f4_i2c_ops,
|
||||
.eth = &stm32f4_eth_ops
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 硬件抽象层初始化
|
||||
* @return hal_status_t: 操作结果
|
||||
* @note 初始化所有硬件抽象层组件
|
||||
*/
|
||||
hal_status_t hal_init(void)
|
||||
{
|
||||
hal_status_t status = HAL_STATUS_OK;
|
||||
|
||||
/* 初始化串口 */
|
||||
if (hal_ops.uart->init(HAL_UART_BAUDRATE_115200) != HAL_STATUS_OK) {
|
||||
status = HAL_STATUS_ERROR;
|
||||
}
|
||||
|
||||
/* 初始化I2C */
|
||||
if (hal_ops.i2c->init(HAL_I2C_CLOCK_SPEED_100K) != HAL_STATUS_OK) {
|
||||
status = HAL_STATUS_ERROR;
|
||||
}
|
||||
|
||||
/* 初始化以太网 */
|
||||
if (hal_ops.eth->init() != HAL_STATUS_OK) {
|
||||
status = HAL_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取硬件抽象层操作结构体
|
||||
* @return const hal_ops_t*: 硬件抽象层操作结构体指针
|
||||
* @note 返回硬件抽象层操作结构体,用于访问各种硬件操作
|
||||
*/
|
||||
const hal_ops_t *hal_get_ops(void)
|
||||
{
|
||||
return &hal_ops;
|
||||
}
|
||||
Reference in New Issue
Block a user