stm32f0: gpio: rcc: separate GPIO and RCC setup
This commit is contained in:
parent
eaa61e50af
commit
ea142b75fe
9 changed files with 54 additions and 19 deletions
1
source/platform/Makefile
Normal file
1
source/platform/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
-include source/platform/$(TARGET)/Makefile
|
2
source/platform/stm32f0/Makefile
Normal file
2
source/platform/stm32f0/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
|||
obj-y += source/platform/stm32f0/gpio.o
|
||||
obj-y += source/platform/stm32f0/rcc.o
|
26
source/platform/stm32f0/gpio.c
Normal file
26
source/platform/stm32f0/gpio.c
Normal 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)
|
||||
{
|
||||
}
|
18
source/platform/stm32f0/rcc.c
Normal file
18
source/platform/stm32f0/rcc.c
Normal 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)
|
||||
{
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue