Examples updated to use new rcc_periph_clock_enable function
This commit is contained in:
@@ -136,7 +136,7 @@ static void setup_button_press_timer(void)
|
||||
static int setup_rtc(void)
|
||||
{
|
||||
/* turn on power block to enable unlocking */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_PWREN);
|
||||
rcc_periph_clock_enable(RCC_PWR);
|
||||
pwr_disable_backup_domain_write_protect();
|
||||
|
||||
/* reset rtc */
|
||||
@@ -269,13 +269,13 @@ static void reset_clocks(void)
|
||||
rcc_clock_setup_msi(&myclock_config);
|
||||
|
||||
/* buttons and uarts */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOAEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
/* user feedback leds */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
/* Enable clocks for USART2. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
/* And a timers for button presses */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM7EN);
|
||||
rcc_periph_clock_enable(RCC_TIM7);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
@@ -37,15 +37,15 @@ static void clock_setup(void)
|
||||
{
|
||||
rcc_clock_setup_pll(&clock_config[CLOCK_VRANGE1_HSI_PLL_24MHZ]);
|
||||
/* Lots of things on all ports... */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOAEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
|
||||
/* Enable clocks for USART2. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
|
||||
/* And timers. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM6EN);
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM7EN);
|
||||
rcc_periph_clock_enable(RCC_TIM6);
|
||||
rcc_periph_clock_enable(RCC_TIM7);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,20 +22,17 @@
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/stm32/gpio.h>
|
||||
|
||||
#define PORT_LED GPIOB
|
||||
#define PIN_LED GPIO6
|
||||
|
||||
static void gpio_setup(void)
|
||||
{
|
||||
/* Enable GPIOB clock. */
|
||||
/* Manually: */
|
||||
//RCC_AHBENR |= RCC_AHBENR_GPIOBEN;
|
||||
/* Using API functions: */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
|
||||
/* Set GPIO6 (in GPIO port B) to 'output push-pull'. */
|
||||
/* Using API functions: */
|
||||
gpio_mode_setup(PORT_LED, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, PIN_LED);
|
||||
gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO6);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@@ -47,23 +44,23 @@ int main(void)
|
||||
/* Blink the LED (PC8) on the board. */
|
||||
while (1) {
|
||||
/* Manually: */
|
||||
// GPIOD_BSRR = GPIO12; /* LED off */
|
||||
// GPIOD_BSRR = GPIO6; /* LED off */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// GPIOD_BRR = GPIO12; /* LED on */
|
||||
// GPIOD_BRR = GPIO6; /* LED on */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
|
||||
/* Using API functions gpio_set()/gpio_clear(): */
|
||||
// gpio_set(GPIOD, GPIO12); /* LED off */
|
||||
// gpio_set(GPIOD, GPIO6); /* LED off */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// gpio_clear(GPIOD, GPIO12); /* LED on */
|
||||
// gpio_clear(GPIOD, GPIO6); /* LED on */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
|
||||
/* Using API function gpio_toggle(): */
|
||||
gpio_toggle(PORT_LED, PIN_LED); /* LED on/off */
|
||||
gpio_toggle(GPIOB, GPIO6); /* LED on/off */
|
||||
for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ static void clock_setup(void)
|
||||
{
|
||||
/* We are running on MSI after boot. */
|
||||
/* Enable GPIOD clock for LED & USARTs. */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOAEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
|
||||
/* Enable clocks for USART2. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
}
|
||||
|
||||
static void usart_setup(void)
|
||||
|
||||
@@ -26,11 +26,11 @@ static void clock_setup(void)
|
||||
{
|
||||
/* We are running on MSI after boot. */
|
||||
/* Enable GPIOD clock for LED & USARTs. */
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOAEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
|
||||
/* Enable clocks for USART2. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
}
|
||||
|
||||
static void usart_setup(void)
|
||||
|
||||
Reference in New Issue
Block a user