文章

RT-Thread HAL层介绍

整体框架

plantuml

@startuml
!theme black-knight
package APP <<Node>> {
    class OBJECT2{

    }
    class OBJECT1{

    }
}
package PLATFLORM <<Node>> {
    class API{

    }
    class PLAT_OBJECT{

    }
}
package BOOTLOADER <<Node>> {
    class BOOT_OBJECT{

    } 
}
package DRIVER <<Node>> {
    struct DRIVER_LIST{
        IIC_Driver drv_iic
        EEPROM_Driver drv_eeprom
        FLASH_Driver drv_flash
        SPI_Driver drv_spi
        RTC_Driver drv_rtc
        Measurechip_Driver drv_mes
        LCD_Driver drv_lcd
        ISO7816_Driver drv_iso
        ESAM_Driver drv_esam
    }
    class IIC_Driver{
        IIC_DEV* dev_iic=dev_iic_1
        void rt_i2c_control();
        void rt_i2c_transfer();
    }
    class EEPROM_Driver{
        IIC_DEV* dev_iic=dev_iic_soft1
        void eeprom_read();
        void eeporm_write();
    }
    note top: 使用I2C的eeprom
    class FLASH_Driver{
        SPI_DEV* dev_spi_1
        int FLASH_SIZE
        int FLASH_PAGE_SIZE
        int FLASH_END
        void rt_hw_spiflash_init();
        void flash_write();
        void flash_read();
    }
}
package HAL <<Node>> {
    package INTERFACE{
    struct DEV_LIST{
        IIC_DEV dev_iic_1
        IIC_DEV dev_iic_soft1
        RTC_DEV dev_rtc_1
        SPI_DEV dev_spi_1
        FLASH_DEV dev_flash
        GPIO_DEV dev_gpio_1
        UART_DEV dev_uart_1
    }
    note right of DEV_LIST::dev_flash
        片内flash
    end note
    abstract class IIC_DEV{
        I2C_TypeDef Instance
        HAL_I2C_StateTypeDef State
        HAL_I2C_ModeTypeDef Mode
        void HAL_I2C_Mem_Write(void);
        void I2C_MasterTransmit_TXE(void);
    }
    abstract class SPI_DEV{
        void HAL_SPI_IRQHandler(void);
        void HAL_SPI_Transmit(void);
        void HAL_SPI_Receive(void);
    }
    }
    package IMPLEMENT{
    class IIC_DEV_1{
    }
    class IIC_DEV_SOFT{
    }
    class SPI_DEV_1{
    }
    }

}
package BSP <<Node>> {
    class IO_CONTROL{
        array IO_LIST
    }

    class REGISTER_CONTROL{
        array REGISTER_LIST
        +register_init()
    }
    package "CMSIS-CORE" {
    class SYSTICK{
    }
    note top: 系统定时器
    class NVIC{
    }
    note top: 中断控制器
    class SCB{
    }
    note top: System Control Block registers\n(系统控制寄存器)
    class MPU{
    }
    note top: 内存保护寄存器
    class FPU{
    }
    note top: 浮点运算寄存器
    }
    package "CPU-PORT" {
    class CONTEXT_SWITCH{
    }
    }
    note bottom of "CONTEXT_SWITCH": 抢占式内核所需的上下文切换,\n使用汇编直接操作寄存器保证高效
    note top of "CMSIS-CORE": Common Microcontroller Software Interface Standard. 
}
IIC_DEV_1 --> IO_CONTROL
IO_CONTROL -left-> REGISTER_CONTROL
IIC_DEV_1 --> REGISTER_CONTROL
IIC_DEV <|.. IIC_DEV_1: 实现
IIC_DEV <|.. IIC_DEV_SOFT: 实现
SPI_DEV <|.. SPI_DEV_1: 实现
IIC_Driver --> IIC_DEV: 关联
EEPROM_Driver --> IIC_DEV: 关联
FLASH_Driver --> SPI_DEV: 关联
BOOT_OBJECT --> FLASH_Driver: BOOT是否加载驱动?
API --> FLASH_Driver: 关联
PLAT_OBJECT --> FLASH_Driver: 关联
OBJECT1 --> API: 关联
OBJECT2 --> IIC_Driver: 跨层调用?
@enduml
本文由作者按照 CC BY 4.0 进行授权

© Kai. 保留部分权利。

浙ICP备20006745号-2,本站由 Jekyll 生成,采用 Chirpy 主题。