Skip to content

Commit 25a3e3e

Browse files
committed
✨ Add stm32f411 to list of platforms
1 parent 17e3956 commit 25a3e3e

File tree

3 files changed

+70
-10
lines changed

3 files changed

+70
-10
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ jobs:
5959
platform_profile: v1/stm32f103c8
6060
secrets: inherit
6161

62+
demo_check_stm32f411re:
63+
uses: libhal/ci/.github/workflows/[email protected]
64+
with:
65+
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
66+
compiler_profile: v1/arm-gcc-12.3
67+
platform_profile_url: https://github.com/libhal/libhal-arm-mcu.git
68+
platform_profile: v1/stm32f411re
69+
secrets: inherit
70+
6271
demo_check_mod-stm32f1-v4:
6372
uses: libhal/ci/.github/workflows/[email protected]
6473
with:

demos/applications/mpu6050.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ void application(resource_list& p_map)
4040
hal::print(console, "Reading acceleration... \n");
4141
auto acceleration = mpu.read();
4242

43-
hal::print<64>(console,
44-
"Scale: 2g \t x = %fg, y = %fg, z = %fg \n",
45-
acceleration.x,
46-
acceleration.y,
47-
acceleration.z);
43+
hal::print<128>(console,
44+
"Scale: 2g:\tx = %fg, y = %fg, z = %fg \n",
45+
acceleration.x,
46+
acceleration.y,
47+
acceleration.z);
4848

4949
hal::delay(clock, 500ms);
5050

@@ -54,10 +54,10 @@ void application(resource_list& p_map)
5454

5555
mpu.configure_full_scale(hal::sensor::mpu6050::max_acceleration::g4);
5656
acceleration = mpu.read();
57-
hal::print<64>(console,
58-
"Scale: 4g \t x = %fg, y = %fg, z = %fg \n\n",
59-
acceleration.x,
60-
acceleration.y,
61-
acceleration.z);
57+
hal::print<128>(console,
58+
"Scale: 4g:\tx = %fg, y = %fg, z = %fg \n\n",
59+
acceleration.x,
60+
acceleration.y,
61+
acceleration.z);
6262
}
6363
}

demos/platforms/stm32f411re.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2024 Khalil Estell
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <libhal-arm-mcu/dwt_counter.hpp>
16+
#include <libhal-arm-mcu/startup.hpp>
17+
#include <libhal-arm-mcu/stm32f411/clock.hpp>
18+
#include <libhal-arm-mcu/stm32f411/constants.hpp>
19+
#include <libhal-arm-mcu/stm32f411/i2c.hpp>
20+
#include <libhal-arm-mcu/stm32f411/output_pin.hpp>
21+
#include <libhal-arm-mcu/stm32f411/uart.hpp>
22+
#include <libhal-arm-mcu/system_control.hpp>
23+
#include <libhal/io_waiter.hpp>
24+
#include <libhal/units.hpp>
25+
26+
#include <resource_list.hpp>
27+
28+
void initialize_platform(resource_list& p_resources)
29+
{
30+
using namespace hal::literals;
31+
32+
// Set the MCU to the maximum clock speed
33+
hal::stm32f411::maximum_speed_using_internal_oscillator();
34+
35+
auto const cpu_frequency =
36+
hal::stm32f411::frequency(hal::stm32f411::peripheral::cpu);
37+
static hal::cortex_m::dwt_counter steady_clock(cpu_frequency);
38+
39+
static hal::stm32f411::i2c i2c(1,
40+
hal::i2c::settings{ .clock_rate = 100_kHz });
41+
42+
static hal::stm32f411::uart uart2(
43+
hal::port<2>, hal::buffer<128>, { .baud_rate = 115200 });
44+
45+
static hal::stm32f411::output_pin led(hal::stm32f411::peripheral::gpio_a, 5);
46+
47+
p_resources.clock = &steady_clock;
48+
p_resources.console = &uart2;
49+
p_resources.i2c = &i2c;
50+
p_resources.status_led = &led;
51+
}

0 commit comments

Comments
 (0)