stm32f0: gpio: rcc: separate GPIO and RCC setup

This commit is contained in:
S.J.R. van Schaik 2017-07-18 15:08:46 +02:00
parent eaa61e50af
commit ea142b75fe
9 changed files with 54 additions and 19 deletions

1
source/platform/Makefile Normal file
View file

@ -0,0 +1 @@
-include source/platform/$(TARGET)/Makefile

View file

@ -0,0 +1,2 @@
obj-y += source/platform/stm32f0/gpio.o
obj-y += source/platform/stm32f0/rcc.o

View file

@ -0,0 +1,26 @@
#include <libopencm3/stm32/gpio.h>
#include <gpio.h>
int gpio_init(void)
{
/* Set up GPIOs for SPI 1 */
gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO4);
gpio_set(GPIOA, GPIO4);
gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO3 | GPIO4 | GPIO5);
gpio_set_af(GPIOB, GPIO_AF0, GPIO3 | GPIO4 | GPIO5);
/* Set up GPIOs for user console (USART 1) */
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
gpio_set_af(GPIOA, GPIO_AF1, GPIO9 | GPIO10);
/* Set up GPIOs for admin console (USART 2) */
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2 | GPIO3);
gpio_set_af(GPIOA, GPIO_AF1, GPIO2 | GPIO3);
return 0;
}
void gpio_cleanup(void)
{
}

View file

@ -0,0 +1,18 @@
#include <libopencm3/stm32/rcc.h>
#include <rcc.h>
int rcc_init(void)
{
rcc_periph_clock_enable(RCC_GPIOA);
rcc_periph_clock_enable(RCC_GPIOB);
rcc_periph_clock_enable(RCC_SPI1);
rcc_periph_clock_enable(RCC_USART1);
rcc_periph_clock_enable(RCC_USART2);
return 0;
}
void rcc_cleanup(void)
{
}