18
18
#include < libhal-arm-mcu/stm32f1/can.hpp>
19
19
#include < libhal-arm-mcu/stm32f1/clock.hpp>
20
20
#include < libhal-arm-mcu/stm32f1/constants.hpp>
21
+ #include < libhal-arm-mcu/stm32f1/gpio.hpp>
21
22
#include < libhal-arm-mcu/stm32f1/input_pin.hpp>
22
23
#include < libhal-arm-mcu/stm32f1/output_pin.hpp>
23
24
#include < libhal-arm-mcu/stm32f1/spi.hpp>
24
25
#include < libhal-arm-mcu/stm32f1/timer.hpp>
25
26
#include < libhal-arm-mcu/stm32f1/uart.hpp>
27
+ #include < libhal-arm-mcu/stm32f1/usart.hpp>
26
28
#include < libhal-arm-mcu/system_control.hpp>
27
29
#include < libhal-util/atomic_spin_lock.hpp>
28
30
#include < libhal-util/bit_bang_i2c.hpp>
@@ -47,24 +49,38 @@ void initialize_platform(resource_list& p_resources)
47
49
hal::stm32f1::maximum_speed_using_internal_oscillator ();
48
50
hal::stm32f1::release_jtag_pins ();
49
51
52
+ using st_peripheral = hal::stm32f1::peripheral;
53
+
50
54
auto cpu_frequency = hal::stm32f1::frequency (hal::stm32f1::peripheral::cpu);
51
55
static hal::cortex_m::dwt_counter steady_clock (cpu_frequency);
52
56
p_resources.clock = &steady_clock;
53
57
54
58
static hal::stm32f1::uart uart1 (hal::port<1 >, hal::buffer<128 >);
55
59
p_resources.console = &uart1;
56
60
57
- static hal::stm32f1::output_pin led (' C' , 13 );
61
+ static hal::stm32f1::usart<st_peripheral::usart2> usart2;
62
+ static auto usart2_serial = usart2.acquire_serial (hal::buffer<128 >);
63
+ p_resources.zero_copy_serial = &usart2_serial;
64
+
65
+ static hal::stm32f1::uart usart1 (hal::port<1 >, hal::buffer<128 >);
66
+ p_resources.console = &usart1;
67
+
68
+ // ===========================================================================
69
+ // Setup GPIO
70
+ // ===========================================================================
71
+
72
+ static hal::stm32f1::gpio<st_peripheral::gpio_a> gpio_a;
73
+ static hal::stm32f1::gpio<st_peripheral::gpio_b> gpio_b;
74
+ static hal::stm32f1::gpio<st_peripheral::gpio_c> gpio_c;
75
+ static auto led = gpio_c.acquire_output_pin (13 );
58
76
p_resources.status_led = &led;
59
77
60
78
static hal::stm32f1::input_pin input_pin (' B' , 4 );
61
79
p_resources.input_pin = &input_pin;
62
80
63
81
static hal::atomic_spin_lock adc_lock;
64
- static hal::stm32f1::adc_peripheral_manager adc (
65
- hal::stm32f1::adc_peripheral_manager::adc_selection::adc1, adc_lock);
66
- static auto pb0 =
67
- adc.acquire_channel (hal::stm32f1::adc_peripheral_manager::pins::pb0);
82
+ static hal::stm32f1::adc<st_peripheral::adc1> adc (adc_lock);
83
+ static auto pb0 = adc.acquire_channel (hal::stm32f1::adc_pins::pb0);
68
84
p_resources.adc = &pb0;
69
85
70
86
static hal::stm32f1::output_pin sda_output_pin (' B' , 7 );
0 commit comments