#ifndef __LED_DRIVER_H__ #define __LED_DRIVER_H__ #include #include "bus_core.h" #include "gpio_driver.h" class Led { public: Led(GpioPort port, uint32_t pin); ~Led() = default; Led(const Led &) = delete; Led &operator=(const Led &) = delete; RetCode init(); void on(); void off(); void toggle(); private: GpioBus bus_; GpioPin pin_; }; class LedManager { public: static LedManager &instance(); RetCode init_all(); Led &led(uint8_t index); LedManager(const LedManager &) = delete; LedManager &operator=(const LedManager &) = delete; private: LedManager(); static constexpr uint8_t LED_COUNT = 4; Led led0_{GpioPort::E, 0x08}; Led led1_{GpioPort::D, 0x80}; Led led2_{GpioPort::G, 0x08}; Led led3_{GpioPort::A, 0x20}; Led *leds_[LED_COUNT] = {&led0_, &led1_, &led2_, &led3_}; }; #endif