Skip to content

Commit

Permalink
✨ Add rmd_drc_v2 and rmd_mc_x_v2 demos (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
kammce authored Jan 4, 2025
1 parent 0911b6d commit d008f6b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,33 @@ jobs:
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-lpc40.git
platform_profile: v2/lpc4074
platform_profile_url: https://github.com/libhal/libhal-arm-mcu.git
platform_profile: v1/lpc4074
secrets: inherit

demo_check_lpc4078:
uses: libhal/ci/.github/workflows/[email protected]
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-lpc40.git
platform_profile: v2/lpc4078
platform_profile_url: https://github.com/libhal/libhal-arm-mcu.git
platform_profile: v1/lpc4078
secrets: inherit

demo_check_stm32f103c8:
uses: libhal/ci/.github/workflows/[email protected]
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-arm-mcu.git
platform_profile: v1/stm32f103c8
secrets: inherit

demo_check_micromod:
uses: libhal/ci/.github/workflows/[email protected]
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-micromod.git
platform_profile: v1/mod-stm32f1-v5
secrets: inherit
4 changes: 4 additions & 0 deletions demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ project(demos LANGUAGES CXX)
libhal_build_demos(
DEMOS
drc
drc_v2
drc_v2_resources
mc_x
mc_x_v2
mc_x_v2_resources
rc_servo

INCLUDES
Expand Down
2 changes: 1 addition & 1 deletion demos/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class demos(ConanFile):
def requirements(self):
bootstrap = self.python_requires["libhal-bootstrap"]
bootstrap.module.add_demo_requirements(self)
self.requires("libhal-actuator/[^1.0.0 || latest]")
self.requires("libhal-actuator/[^1.1.0 || latest]")
2 changes: 1 addition & 1 deletion demos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource_list resources{};
hal::delay(clock, 1000ms);
}
}

// test
int main()
{
hal::set_terminate(terminate_handler);
Expand Down
11 changes: 10 additions & 1 deletion demos/platforms/micromod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,14 @@ void initialize_platform(resource_list& p_resources)
p_resources.status_led = &hal::micromod::v1::led();
p_resources.clock = &hal::micromod::v1::uptime_clock();
p_resources.console = &hal::micromod::v1::console(hal::buffer<128>);
p_resources.can = &hal::micromod::v1::can();
if constexpr (use_can_v1) {
p_resources.can = &hal::micromod::v1::can();
} else {
static std::array<hal::can_message, 4> receive_buffer{};
p_resources.can_transceiver =
&hal::micromod::v1::can_transceiver(receive_buffer);
p_resources.can_bus_manager = &hal::micromod::v1::can_bus_manager();
p_resources.can_identifier_filter =
&hal::micromod::v1::can_identifier_filter0();
}
}
16 changes: 16 additions & 0 deletions demos/platforms/stm32f103c8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <libhal-armcortex/startup.hpp>
#include <libhal-armcortex/system_control.hpp>

#include <libhal-stm32f1/can.hpp>
#include <libhal-stm32f1/clock.hpp>
#include <libhal-stm32f1/constants.hpp>
#include <libhal-stm32f1/output_pin.hpp>
Expand Down Expand Up @@ -47,4 +48,19 @@ void initialize_platform(resource_list& p_resources)
p_resources.console = &uart1;
p_resources.clock = &counter;
p_resources.status_led = &led;

if constexpr (use_can_v1) {
static hal::stm32f1::can driver({}, hal::stm32f1::can_pins::pb9_pb8);
p_resources.can = &driver;
} else {
static std::array<hal::can_message, 4> receive_buffer{};
static hal::stm32f1::can_peripheral_manager can(
100_kHz, hal::stm32f1::can_pins::pb9_pb8);
static auto can_transceiver = can.acquire_transceiver(receive_buffer);
p_resources.can_transceiver = &can_transceiver;
static auto can_bus_manager = can.acquire_bus_manager();
p_resources.can_bus_manager = &can_bus_manager;
static auto can_identifier_filter = can.acquire_identifier_filter();
p_resources.can_identifier_filter = &can_identifier_filter.filter[0];
}
}
15 changes: 10 additions & 5 deletions demos/resource_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
struct resource_list
{
hal::callback<void()> reset;
std::optional<hal::serial*> console = std::nullopt;
std::optional<hal::steady_clock*> clock = std::nullopt;
std::optional<hal::output_pin*> status_led = std::nullopt;
std::optional<hal::can*> can = std::nullopt;
std::optional<hal::pwm*> pwm = std::nullopt;
std::optional<hal::serial*> console;
std::optional<hal::steady_clock*> clock;
std::optional<hal::output_pin*> status_led;
std::optional<hal::can*> can;
std::optional<hal::can_transceiver*> can_transceiver;
std::optional<hal::can_bus_manager*> can_bus_manager;
std::optional<hal::can_identifier_filter*> can_identifier_filter;
std::optional<hal::pwm*> pwm;
};

// Application function is implemented by one of the .cpp files.
void initialize_platform(resource_list& p_resources);
void application(resource_list& p_resources);

constexpr bool use_can_v1 = false;

0 comments on commit d008f6b

Please sign in to comment.