37 #ifndef LONGAN_NANO_LED_H_
38 #define LONGAN_NANO_LED_H_
44 #include <gd32vf103.h>
169 static inline bool init(
void )
180 rcu_periph_clock_enable(RCU_GPIOA);
181 rcu_periph_clock_enable(RCU_GPIOC);
183 gpio_init(Led_gpio::RED_GPIO, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,Led_pin::RED_PIN);
184 gpio_init(Led_gpio::GREEN_GPIO, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,Led_pin::GREEN_PIN);
185 gpio_init(Led_gpio::BLUE_GPIO, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,Led_pin::BLUE_PIN);
211 bit_status led_r = FlagStatus::SET;
212 bit_status led_g = FlagStatus::SET;
213 bit_status led_b = FlagStatus::SET;
222 case (Leds::Color::BLACK):
227 case (Leds::Color::WHITE):
229 led_r = FlagStatus::RESET;
230 led_g = FlagStatus::RESET;
231 led_b = FlagStatus::RESET;
242 gpio_bit_write( Led_gpio::RED_GPIO, Led_pin::RED_PIN, (bit_status)led_r );
243 gpio_bit_write( Led_gpio::GREEN_GPIO, Led_pin::GREEN_PIN, (bit_status)led_g );
244 gpio_bit_write( Led_gpio::BLUE_GPIO, Led_pin::BLUE_PIN, (bit_status)led_b );
275 case (Leds::Color::RED):
277 gpio_bit_write(Led_gpio::RED_GPIO, Led_pin::RED_PIN, (bit_status)(1-gpio_input_bit_get(Led_gpio::RED_GPIO, Led_pin::RED_PIN)));
280 case (Leds::Color::GREEN):
282 gpio_bit_write(Led_gpio::GREEN_GPIO, Led_pin::GREEN_PIN, (bit_status)(1-gpio_input_bit_get(Led_gpio::GREEN_GPIO, Led_pin::GREEN_PIN)));
285 case (Leds::Color::BLUE):
287 gpio_bit_write(Led_gpio::BLUE_GPIO, Led_pin::BLUE_PIN, (bit_status)(1-gpio_input_bit_get(Led_gpio::BLUE_GPIO, Led_pin::BLUE_PIN)));
325 case (Leds::Color::RED):
327 gpio_bit_set(Led_gpio::RED_GPIO, Led_pin::RED_PIN);
330 case (Leds::Color::GREEN):
332 gpio_bit_set(Led_gpio::GREEN_GPIO, Led_pin::GREEN_PIN);
335 case (Leds::Color::BLUE):
337 gpio_bit_set(Led_gpio::BLUE_GPIO, Led_pin::BLUE_PIN);
375 case (Leds::Color::RED):
377 gpio_bit_reset(Led_gpio::RED_GPIO, Led_pin::RED_PIN);
380 case (Leds::Color::GREEN):
382 gpio_bit_reset(Led_gpio::GREEN_GPIO, Led_pin::GREEN_PIN);
385 case (Leds::Color::BLUE):
387 gpio_bit_reset(Led_gpio::BLUE_GPIO, Led_pin::BLUE_PIN);
440 #warning "Multiple inclusion of hader file LONGAN_NANO_LED_H_"