diff --git a/examples/stm32/f4/stm32f4-disco/blink/blink.c b/examples/stm32/f4/stm32f4-disco/blink/blink.c
index d95a7eb..8b90836 100644
--- a/examples/stm32/f4/stm32f4-disco/blink/blink.c
+++ b/examples/stm32/f4/stm32f4-disco/blink/blink.c
@@ -17,8 +17,8 @@
* along with this library. If not, see .
*/
-#include
-#include
+#include
+#include
#define GREEN_LED GPIO13
#define RED_LED GPIO13
@@ -31,7 +31,7 @@ int main(void)
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
/* Enable GPIOG clock. (this enables the pins to work) */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPGEN);
+ rcc_periph_clock_enable(RCC_GPIOG);
/* Set the "mode" of the GPIO pin to output, no pullups or pulldowns */
gpio_mode_setup(GPIOG, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GREEN_LED );
diff --git a/examples/stm32/f4/stm32f4-disco/lcd-serial/console.c b/examples/stm32/f4/stm32f4-disco/lcd-serial/console.c
index a78ea99..b9ac721 100644
--- a/examples/stm32/f4/stm32f4-disco/lcd-serial/console.c
+++ b/examples/stm32/f4/stm32f4-disco/lcd-serial/console.c
@@ -191,7 +191,7 @@ int console_gets(char *s, int len) {
void console_setup(int baud) {
/* MUST enable the GPIO clock in ADDITION to the USART clock */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ rcc_periph_clock_enable(RCC_GPIOD);
/* This example uses PD5 and PD6 for Tx and Rx respectively
* but other pins are available for this role on USART2 (our chosen
@@ -213,7 +213,7 @@ void console_setup(int baud) {
* attach to different buses, and even some UARTS are attached to
* APB1 and some to APB2, again the data sheet is useful here.
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
+ rcc_periph_clock_enable(RCC_USART2);
/* Set up USART/UART parameters using the libopencm3 helper functions */
usart_set_baudrate(CONSOLE_UART, baud);
diff --git a/examples/stm32/f4/stm32f4-disco/lcd-serial/lcd-spi.c b/examples/stm32/f4/stm32f4-disco/lcd-serial/lcd-spi.c
index 2935e79..c25afed 100644
--- a/examples/stm32/f4/stm32f4-disco/lcd-serial/lcd-spi.c
+++ b/examples/stm32/f4/stm32f4-disco/lcd-serial/lcd-spi.c
@@ -347,9 +347,7 @@ lcd_spi_init(void) {
* Set up the GPIO lines for the SPI port and
* control lines on the display.
*/
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPFEN);
+ rcc_periph_clock_enable(RCC_GPIOC | RCC_GPIOD | RCC_GPIOF);
gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO2);
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO13);
@@ -364,7 +362,7 @@ lcd_spi_init(void) {
/* Implement state management hack */
nvic_enable_irq(NVIC_SPI5_IRQ);
- rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SPI5EN);
+ rcc_periph_clock_enable(RCC_SPI5);
/* This should configure SPI5 as we need it configured */
tmp = SPI_SR(LCD_SPI);
SPI_CR2(LCD_SPI) |= (SPI_CR2_SSOE | SPI_CR2_RXNEIE);
diff --git a/examples/stm32/f4/stm32f4-disco/lcd-serial/sdram.c b/examples/stm32/f4/stm32f4-disco/lcd-serial/sdram.c
index 4c6e4e7..ae8b0e2 100644
--- a/examples/stm32/f4/stm32f4-disco/lcd-serial/sdram.c
+++ b/examples/stm32/f4/stm32f4-disco/lcd-serial/sdram.c
@@ -67,12 +67,8 @@ sdram_init(void) {
/*
* First all the GPIO pins that end up as SDRAM pins
*/
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPEEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPFEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPGEN);
+ rcc_periph_clock_enable(RCC_GPIOB | RCC_GPIOC | RCC_GPIOD |
+ RCC_GPIOE | RCC_GPIOF | RCC_GPIOG);
for (i = 0; i < 6; i++) {
gpio_mode_setup(sdram_pins[i].gpio, GPIO_MODE_AF, GPIO_PUPD_NONE,
@@ -83,7 +79,7 @@ sdram_init(void) {
}
/* Enable the SDRAM Controller */
- rcc_peripheral_enable_clock(&RCC_AHB3ENR, RCC_AHB3ENR_FMCEN);
+ rcc_periph_clock_enable(RCC_FSMC);
/* Note the STM32F429-DISCO board has the ram attached to bank 2 */
/* Timing parameters computed for a 168Mhz clock */
diff --git a/examples/stm32/f4/stm32f4-disco/sdram/console.c b/examples/stm32/f4/stm32f4-disco/sdram/console.c
index c37afd0..f6031c2 100644
--- a/examples/stm32/f4/stm32f4-disco/sdram/console.c
+++ b/examples/stm32/f4/stm32f4-disco/sdram/console.c
@@ -193,7 +193,7 @@ int console_gets(char *s, int len) {
void console_setup(void) {
/* MUST enable the GPIO clock in ADDITION to the USART clock */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ rcc_periph_clock_enable(RCC_GPIOD);
/* This example uses PD5 and PD6 for Tx and Rx respectively
* but other pins are available for this role on USART2 (our chosen
@@ -215,7 +215,7 @@ void console_setup(void) {
* attach to different buses, and even some UARTS are attached to
* APB1 and some to APB2, again the data sheet is useful here.
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
+ rcc_periph_clock_enable(RCC_USART2);
/* Set up USART/UART parameters using the libopencm3 helper functions */
usart_set_baudrate(CONSOLE_UART, 115200);
diff --git a/examples/stm32/f4/stm32f4-disco/sdram/sdram.c b/examples/stm32/f4/stm32f4-disco/sdram/sdram.c
index 5cde357..6dfd332 100644
--- a/examples/stm32/f4/stm32f4-disco/sdram/sdram.c
+++ b/examples/stm32/f4/stm32f4-disco/sdram/sdram.c
@@ -73,12 +73,15 @@ sdram_init(void) {
/*
* First all the GPIO pins that end up as SDRAM pins
*/
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPEEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPFEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPGEN);
+ rcc_periph_clock_enable(RCC_GPIOB | RCC_GPIOC | RCC_GPIOD |
+ RCC_GPIOE | RCC_GPIOF | RCC_GPIOG);
+/*
+ rcc_periph_clock_enable(RCC_GPIOC);
+ rcc_periph_clock_enable(RCC_GPIOD);
+ rcc_periph_clock_enable(RCC_GPIOE);
+ rcc_periph_clock_enable(RCC_GPIOF);
+ rcc_periph_clock_enable(RCC_GPIOG);
+*/
for (i = 0; i < 6; i++) {
gpio_mode_setup(sdram_pins[i].gpio, GPIO_MODE_AF, GPIO_PUPD_NONE,
@@ -89,7 +92,7 @@ sdram_init(void) {
}
/* Enable the SDRAM Controller */
- rcc_peripheral_enable_clock(&RCC_AHB3ENR, RCC_AHB3ENR_FMCEN);
+ rcc_periph_clock_enable(RCC_FSMC);
/* Note the STM32F429-DISCO board has the ram attached to bank 2 */
/* Timing parameters computed for a 168Mhz clock */
diff --git a/examples/stm32/f4/stm32f4-disco/spi/console.c b/examples/stm32/f4/stm32f4-disco/spi/console.c
index 2e7a7a0..b4fe9cd 100644
--- a/examples/stm32/f4/stm32f4-disco/spi/console.c
+++ b/examples/stm32/f4/stm32f4-disco/spi/console.c
@@ -191,7 +191,7 @@ int console_gets(char *s, int len) {
void console_setup(int baud) {
/* MUST enable the GPIO clock in ADDITION to the USART clock */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ rcc_periph_clock_enable(RCC_GPIOD);
/* This example uses PD5 and PD6 for Tx and Rx respectively
* but other pins are available for this role on USART2 (our chosen
@@ -213,7 +213,7 @@ void console_setup(int baud) {
* attach to different buses, and even some UARTS are attached to
* APB1 and some to APB2, again the data sheet is useful here.
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
+ rcc_periph_clock_enable(RCC_USART2);
/* Set up USART/UART parameters using the libopencm3 helper functions */
usart_set_baudrate(CONSOLE_UART, baud);
diff --git a/examples/stm32/f4/stm32f4-disco/spi/spi-mems.c b/examples/stm32/f4/stm32f4-disco/spi/spi-mems.c
index 24899f3..8f1b60a 100644
--- a/examples/stm32/f4/stm32f4-disco/spi/spi-mems.c
+++ b/examples/stm32/f4/stm32f4-disco/spi/spi-mems.c
@@ -225,8 +225,7 @@ int main(void) {
console_setup(115200);
/* Enable the GPIO ports whose pins we are using */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPFEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
+ rcc_periph_clock_enable(RCC_GPIOF | RCC_GPIOC);
gpio_mode_setup(GPIOF, GPIO_MODE_AF, GPIO_PUPD_PULLDOWN,
GPIO7 | GPIO8 | GPIO9);
@@ -238,7 +237,7 @@ int main(void) {
gpio_set(GPIOC, GPIO1);
gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO1);
- rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SPI5EN);
+ rcc_periph_clock_enable(RCC_SPI5);
cr_tmp = SPI_CR1_BAUDRATE_FPCLK_DIV_8 |\
SPI_CR1_MSTR |\
diff --git a/examples/stm32/f4/stm32f4-disco/systick-blink/systick-blink.c b/examples/stm32/f4/stm32f4-disco/systick-blink/systick-blink.c
index a16c835..7a9ebd4 100644
--- a/examples/stm32/f4/stm32f4-disco/systick-blink/systick-blink.c
+++ b/examples/stm32/f4/stm32f4-disco/systick-blink/systick-blink.c
@@ -74,7 +74,7 @@ int main(void)
clock_setup();
/* Enable GPIOD clock. */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPGEN);
+ rcc_periph_clock_enable(RCC_GPIOG);
/* Set GPIO13-14 (in GPIO port G) to 'output push-pull'. */
gpio_mode_setup(GPIOG, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO13 | GPIO14);
diff --git a/examples/stm32/f4/stm32f4-disco/usart-irq/usart-irq.c b/examples/stm32/f4/stm32f4-disco/usart-irq/usart-irq.c
index b46c808..5bb1b6a 100644
--- a/examples/stm32/f4/stm32f4-disco/usart-irq/usart-irq.c
+++ b/examples/stm32/f4/stm32f4-disco/usart-irq/usart-irq.c
@@ -242,7 +242,7 @@ void countdown(void);
* This provides an example function which is constantly
* printing for 20 seconds and not looking for typed characters.
* however with the interrupt driven receieve queue you can type
- * ^C while it is counting down and it will be interrupted.
+ * ^C while it is counting down and it will be interrupted.
*/
void countdown(void) {
int i = 200;
@@ -272,7 +272,7 @@ int main(void) {
clock_setup(); // initialize our clock
/* MUST enable the GPIO clock in ADDITION to the USART clock */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ rcc_periph_clock_enable(RCC_GPIOD);
/* This example uses PD5 and PD6 for Tx and Rx respectively
* but other pins are available for this role on USART2 (our chosen
@@ -294,7 +294,7 @@ int main(void) {
* attach to different buses, and even some UARTS are attached to
* APB1 and some to APB2, again the data sheet is useful here.
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
+ rcc_periph_clock_enable(RCC_USART2);
/* Set up USART/UART parameters using the libopencm3 helper functions */
usart_set_baudrate(CONSOLE_UART, 115200);
diff --git a/examples/stm32/f4/stm32f4-disco/usart/usart.c b/examples/stm32/f4/stm32f4-disco/usart/usart.c
index 03bbfb9..6d314ba 100644
--- a/examples/stm32/f4/stm32f4-disco/usart/usart.c
+++ b/examples/stm32/f4/stm32f4-disco/usart/usart.c
@@ -134,7 +134,7 @@ int main(void) {
clock_setup(); // initialize our clock
/* MUST enable the GPIO clock in ADDITION to the USART clock */
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ rcc_periph_clock_enable(RCC_GPIOD);
/* This example uses PD5 and PD6 for Tx and Rx respectively
* but other pins are available for this role on USART2 (our chosen
@@ -155,7 +155,7 @@ int main(void) {
* attach to different buses, and even some UARTS are attached to
* APB1 and some to APB2, again the data sheet is useful here.
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
+ rcc_periph_clock_enable(RCC_USART2);
/* Set up USART/UART parameters using the libopencm3 helper functions */
usart_set_baudrate(CONSOLE_UART, 115200);