refactor: UartBus全面重构为USART,支持直接构造即可用
- UartBus -> USART (类名更符合外设命名规范) - 构造函数 USART(UartPort port, uint32_t baudrate) 自动完成GPIO+外设初始化 - 移除default_instance()单例模式,移除init()/deinit()/irq_handler() - 新增reinit(baudrate)支持时钟切换后波特率重新校准 - 新增static setDefault()用于printf路由选择 - 移除UartConfig配置结构体 - 更新iap.h/iap.cpp中UartBus引用为USART - 更新main.cpp使用新USART构造模式
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
class Led {
|
||||
public:
|
||||
Led(GpioBus &bus, uint32_t pin);
|
||||
Led(GpioPort port, uint32_t pin);
|
||||
~Led() = default;
|
||||
|
||||
Led(const Led &) = delete;
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
void toggle();
|
||||
|
||||
private:
|
||||
GpioBus bus_;
|
||||
GpioPin pin_;
|
||||
GpioConfig config_;
|
||||
};
|
||||
|
||||
class LedManager {
|
||||
@@ -37,17 +37,12 @@ private:
|
||||
LedManager();
|
||||
static constexpr uint8_t LED_COUNT = 4;
|
||||
|
||||
GpioBus bus_a_{GpioPort::A};
|
||||
GpioBus bus_d_{GpioPort::D};
|
||||
GpioBus bus_e_{GpioPort::E};
|
||||
GpioBus bus_g_{GpioPort::G};
|
||||
Led led0_{GpioPort::E, 0x08};
|
||||
Led led1_{GpioPort::D, 0x80};
|
||||
Led led2_{GpioPort::G, 0x08};
|
||||
Led led3_{GpioPort::A, 0x20};
|
||||
|
||||
Led led1_{bus_e_, 0x08}; /* PE3 */
|
||||
Led led2_{bus_d_, 0x80}; /* PD7 */
|
||||
Led led3_{bus_g_, 0x08}; /* PG3 */
|
||||
Led led4_{bus_a_, 0x20}; /* PA5 */
|
||||
|
||||
Led *leds_[LED_COUNT] = {&led1_, &led2_, &led3_, &led4_};
|
||||
Led *leds_[LED_COUNT] = {&led0_, &led1_, &led2_, &led3_};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user