stm32f1: gpio: prepare GPIOs
This commit is contained in:
parent
1c0a6907df
commit
e05afe9cc9
4 changed files with 8 additions and 6 deletions
|
@ -6,9 +6,9 @@
|
|||
#include <macros.h>
|
||||
|
||||
struct buzzer buzzers[] = {
|
||||
{ TIM2, TIM_OC3 },
|
||||
{ TIM2, TIM_OC4 },
|
||||
{ TIM2, TIM_OC1 },
|
||||
};
|
||||
|
||||
size_t nbuzzers = count_of(buzzers);
|
||||
|
||||
void buzzer_init(struct buzzer *buzzer)
|
||||
|
|
|
@ -32,13 +32,13 @@ int gpio_init(void)
|
|||
/* Set up GPIOs for timers. */
|
||||
gpio_primary_remap(0, AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_TIM2_PR1_CH3);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_TIM2_PR1_CH4);
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_TIM2_PR1_CH1_ETR);
|
||||
|
||||
/* Set up GPIO for LED. */
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
|
||||
gpio_clear(GPIOB, GPIO0);
|
||||
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO10);
|
||||
gpio_set(GPIOC, GPIO10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
#include <macros.h>
|
||||
|
||||
struct led leds[] = {
|
||||
{ GPIOB, GPIO0, 1 },
|
||||
{ GPIOC, GPIO10, 1 },
|
||||
};
|
||||
|
||||
size_t nleds = count_of(leds);
|
||||
|
||||
void led_enable(struct led *led)
|
||||
|
|
|
@ -7,6 +7,7 @@ int rcc_init(void)
|
|||
rcc_periph_clock_enable(RCC_AFIO);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
rcc_periph_clock_enable(RCC_GPIOC);
|
||||
rcc_periph_clock_enable(RCC_SPI1);
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
|
|
Loading…
Add table
Reference in a new issue