blob: 3b5807b6fee69c7e23225552692a1424ef5dc2b2 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2012 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <err.h>
24#include <debug.h>
25#include <trace.h>
26#include <target.h>
27#include <compiler.h>
28#include <dev/gpio.h>
29#include <stm32f10x_usart.h>
30#include <stm32f10x_rcc.h>
31#include <stm32f10x_gpio.h>
32#include <stm32f10x_flash.h>
33#include <stm32f10x_dbgmcu.h>
34#include <platform/stm32.h>
35#include <platform/gpio.h>
36#include <target/gpioconfig.h>
37
38void target_early_init(void)
39{
40 /* configure the usart3 pins */
41 GPIO_PinRemapConfig(GPIO_FullRemap_USART3, ENABLE);
42
43 gpio_config(GPIO(GPIO_PORT_D, 8), GPIO_STM32_AF);
44 gpio_config(GPIO(GPIO_PORT_D, 9), GPIO_INPUT);
45
46 stm32_debug_early_init();
47
48 /* configure some status leds */
49 gpio_set(GPIO_LED0, 0);
50 gpio_set(GPIO_LED1, 0);
51
52 gpio_config(GPIO_LED0, GPIO_OUTPUT);
53 gpio_config(GPIO_LED1, GPIO_OUTPUT);
54}
55
56void target_init(void)
57{
58 TRACE_ENTRY;
59
60 stm32_debug_init();
61
62 TRACE_EXIT;
63}
64
65void target_set_debug_led(unsigned int led, bool on)
66{
67 switch (led) {
68 case 0:
69 gpio_set(GPIO_LED0, on);
70 break;
71 case 1:
72 gpio_set(GPIO_LED1, on);
73 break;
74 }
75}
76