lm4f: Update examples to the new GPIO API

We updated the GPIO API to use the AHB bus; however the AHP aperture for
GPIO ports A through J needs to be explicitly enabled at runtime. Accessing
the AHB aperture otherwise hardfaults.

To make the examples work again, we call gpio_enable_ahb_aperture() at the
start of main().

Since we're at it, we also take out the ugly register accesses in favor
of the new gpio functions.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc
2013-05-17 19:55:08 -05:00
parent 3758ce779f
commit adddf9e418
3 changed files with 22 additions and 39 deletions

View File

@@ -25,14 +25,10 @@
static void uart_setup(void)
{
u32 pins;
/* Enable GPIOA in run mode. */
periph_clock_enable(RCC_GPIOA);
/* Configure PA0 and PA1 as alternate function pins */
pins = GPIO0 | GPIO1;
GPIO_AFSEL(GPIOA) |= pins;
GPIO_DEN(GPIOA) |= pins;
/* PA0 and PA1 are muxed to UART0 during power on, by default */
/* Mux PA0 and PA1 to UART0 (alternate function 1) */
gpio_set_af(GPIOA, 1, GPIO0 | GPIO1);
/* Enable the UART clock */
periph_clock_enable(RCC_UART0);
@@ -79,6 +75,7 @@ void uart0_isr(void)
int main(void)
{
gpio_enable_ahb_aperture();
uart_setup();
uart_irq_setup();