[stm32f2xx] Clean up gpios and get uart3 running

This commit is contained in:
Chris Anderson
2012-10-05 15:36:14 -07:00
parent f54f887e71
commit b614bcf281
8 changed files with 57 additions and 79 deletions

View File

@@ -25,7 +25,14 @@
#include <platform/gpio.h>
#define GPIO_LED0 GPIO(GPIO_PORT_C, 6)
#define GPIO_LED1 GPIO(GPIO_PORT_C, 7)
#define GPIO_USART3_TX GPIO(GPIO_PORT_C, 10)
#define GPIO_USART3_RX GPIO(GPIO_PORT_C, 11)
#define GPIO_LED0 GPIO(GPIO_PORT_G, 6)
#define GPIO_LED1 GPIO(GPIO_PORT_G, 8)
#define GPIO_LED2 GPIO(GPIO_PORT_I, 9)
#define GPIO_LED3 GPIO(GPIO_PORT_C, 7)
void stm3220g_set_led_bits(unsigned int nr);
#endif

View File

@@ -25,9 +25,9 @@
#include <target.h>
#include <compiler.h>
#include <dev/gpio.h>
//#include <stm32f10x_usart.h>
//#include <stm32f10x_rcc.h>
//#include <stm32f10x_gpio.h>
#include <stm32f2xx_usart.h>
#include <stm32f2xx_rcc.h>
#include <stm32f2xx_gpio.h>
//#include <stm32f10x_flash.h>
//#include <stm32f10x_dbgmcu.h>
#include <platform/stm32.h>
@@ -36,22 +36,22 @@
void target_early_init(void)
{
#if 0
/* configure the usart3 pins */
GPIO_PinRemapConfig(GPIO_FullRemap_USART3, ENABLE);
gpio_config(GPIO(GPIO_PORT_D, 8), GPIO_STM32_AF);
gpio_config(GPIO(GPIO_PORT_D, 9), GPIO_INPUT);
gpio_config(GPIO_USART3_TX, GPIO_STM32_AF | GPIO_PULLUP);
gpio_config(GPIO_USART3_RX, GPIO_STM32_AF | GPIO_PULLUP);
GPIO_PinAFConfig(GPIOC, 10, GPIO_AF_USART3);
GPIO_PinAFConfig(GPIOC, 11, GPIO_AF_USART3);
stm32_debug_early_init();
/* configure some status leds */
gpio_set(GPIO_LED0, 0);
gpio_set(GPIO_LED1, 0);
gpio_config(GPIO_LED0, GPIO_OUTPUT);
gpio_config(GPIO_LED1, GPIO_OUTPUT);
#endif
gpio_config(GPIO_LED2, GPIO_OUTPUT);
gpio_config(GPIO_LED3, GPIO_OUTPUT);
stm3220g_set_led_bits(1);
}
void target_init(void)
@@ -65,7 +65,6 @@ void target_init(void)
void target_set_debug_led(unsigned int led, bool on)
{
#if 0
switch (led) {
case 0:
gpio_set(GPIO_LED0, on);
@@ -73,7 +72,19 @@ void target_set_debug_led(unsigned int led, bool on)
case 1:
gpio_set(GPIO_LED1, on);
break;
case 2:
gpio_set(GPIO_LED2, on);
break;
case 3:
gpio_set(GPIO_LED3, on);
break;
}
#endif
}
void stm3220g_set_led_bits(unsigned int nr)
{
gpio_set(GPIO_LED0, nr & 1);
gpio_set(GPIO_LED1, nr & 2);
gpio_set(GPIO_LED2, nr & 4);
gpio_set(GPIO_LED3, nr & 8);
}