1 /*
2 * Copyright (c) 2012 Travis Geiselbrecht
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8 #include <lk/err.h>
9 #include <lk/debug.h>
10 #include <lk/trace.h>
11 #include <target.h>
12 #include <lk/compiler.h>
13 #include <dev/gpio.h>
14 #include <stm32f2xx_usart.h>
15 #include <stm32f2xx_rcc.h>
16 #include <stm32f2xx_gpio.h>
17 #include <platform/stm32.h>
18 #include <platform/gpio.h>
19 #include <target/gpioconfig.h>
20
target_early_init(void)21 void target_early_init(void) {
22 /* configure the usart3 pins */
23 gpio_config(GPIO_USART3_TX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF_USART3) | GPIO_PULLUP);
24 gpio_config(GPIO_USART3_RX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF_USART3) | GPIO_PULLUP);
25
26 stm32_debug_early_init();
27
28 /* configure some status leds */
29 gpio_config(GPIO_LED0, GPIO_OUTPUT);
30 gpio_config(GPIO_LED1, GPIO_OUTPUT);
31 gpio_config(GPIO_LED2, GPIO_OUTPUT);
32 gpio_config(GPIO_LED3, GPIO_OUTPUT);
33 }
34
target_init(void)35 void target_init(void) {
36 TRACE_ENTRY;
37
38 stm32_debug_init();
39
40 TRACE_EXIT;
41 }
42
target_set_debug_led(unsigned int led,bool on)43 void target_set_debug_led(unsigned int led, bool on) {
44 switch (led) {
45 case 0:
46 gpio_set(GPIO_LED0, on);
47 break;
48 case 1:
49 gpio_set(GPIO_LED1, on);
50 break;
51 case 2:
52 gpio_set(GPIO_LED2, on);
53 break;
54 case 3:
55 gpio_set(GPIO_LED3, on);
56 break;
57 }
58 }
59
60