1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /*
- * (c) danielinux 2019
- * GPLv.2
- *
- * See LICENSE for details
- */
- #include <stdint.h>
- #include "system.h"
- #include "led.h"
- void led_setup(uint32_t led)
- {
- uint32_t reg;
- AHB1_CLOCK_ER |= GPIOA_AHB1_CLOCK_ER;
- reg = GPIOA_MODE & ~ (0x03 << (led * 2));
- GPIOA_MODE = reg | (1 << (led * 2));
- reg = GPIOA_PUPD & (0x03 << (led * 2));
- GPIOA_PUPD = reg | (0x02 << (led * 2));
- led_off(led);
- }
- void pio_on(uint32_t pio)
- {
- GPIOA_BSRR |= (1 << pio);
- }
- void pio_off(uint32_t pio)
- {
- GPIOA_BSRR |= (1 << (pio + 16));
- }
- void pio_toggle(uint32_t pio)
- {
- uint32_t reg;
- reg = GPIOA_ODR;
- if ((reg & (1 << pio)) == (1 << pio))
- pio_off(pio);
- else
- pio_on(pio);
- }
|