Compare commits
4 Commits
feature/do
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af9db5a1b0 | ||
|
|
470ad75376 | ||
| e6f5315dac | |||
| f64a92aa5c |
@ -4,15 +4,10 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
Unit-Tests:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: fedora-cpp
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
apt update
|
||||
apt install -y --no-install-recommends build-essential cmake ninja-build
|
||||
|
||||
- name: Configure build
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: |
|
||||
@ -29,16 +24,10 @@ jobs:
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: ctest . --output-on-failure
|
||||
Docs:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: fedora-cpp
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
apt update
|
||||
apt install -y --no-install-recommends build-essential cmake ninja-build doxygen python3-sphinx python3 python3-pip
|
||||
pip3 install breathe
|
||||
|
||||
- name: Configure build
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: |
|
||||
|
||||
@ -14,6 +14,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
|
||||
|
||||
option(SKULLC_WITH_TESTS "Enable unit testing." OFF)
|
||||
option(SKULLC_WITH_HAL "Enable the compiling and deployment of the HAL dependent sections." OFF)
|
||||
option(SKULLC_USE_HAL_ST "Enable the ST HAl when SKULLC_WITH_HAL is enabled." OFF)
|
||||
option(SKULLC_USE_HAL_ESP "Enable the ESP HAL when SKULLC_WITH_HAL is enabled." OFF)
|
||||
option(SKULLC_WITH_DOCS "Enable documentation building." OFF)
|
||||
|
||||
include(skullc-install)
|
||||
|
||||
37
Peripherals/Inc/peripherals_hal_concepts.hpp
Normal file
37
Peripherals/Inc/peripherals_hal_concepts.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Created by erki on 11/02/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Peripherals::Hal
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
concept Gpio = requires (T t, const T ct) {
|
||||
t.set(true);
|
||||
t.toggle();
|
||||
{ ct.read() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
concept SerialInterface = requires (T t, std::uint8_t* data, const std::uint32_t len) {
|
||||
{ t.transmit(data, len) } -> std::same_as<bool>;
|
||||
{ t.transmit(std::array<std::uint8_t, 10>{}) } -> std::same_as<bool>;
|
||||
{ t.receive(data, len) } -> std::same_as<bool>;
|
||||
{ t.receive(std::array<std::uint8_t, 10>{}) } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template<typename T, typename RegName>
|
||||
concept RegisterInterface = requires (T t, RegName reg, std::uint8_t* data, const std::uint32_t len) {
|
||||
t.writerRegister(reg, std::uint8_t{});
|
||||
t.writeRegisterMultibyte(reg, data, len);
|
||||
{ t.readRegister(reg, std::uint32_t{}) } -> std::same_as<std::uint8_t>;
|
||||
t.readRegisterMultibyte(reg, data, len, std::uint32_t{});
|
||||
};
|
||||
|
||||
}
|
||||
51
Peripherals/Inc/peripherals_hal_esp.hpp
Normal file
51
Peripherals/Inc/peripherals_hal_esp.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by erki on 11/02/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef SKULLC_USE_HAL_ESP
|
||||
|
||||
#include <peripherals_hal_concepts.hpp>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
|
||||
namespace Peripherals::Hal::Esp
|
||||
{
|
||||
|
||||
struct Gpio
|
||||
{
|
||||
gpio_num_t gpio;
|
||||
const bool inverted = false;
|
||||
|
||||
Gpio() = delete;
|
||||
explicit Gpio(gpio_num_t gpio, const bool inverted)
|
||||
: gpio(gpio), inverted(inverted)
|
||||
{ }
|
||||
|
||||
void set(const bool& state)
|
||||
{
|
||||
gpio_set_level(gpio, inverted ? !state : state);
|
||||
}
|
||||
|
||||
void toggle() { gpio_set_level(gpio, !gpio_get_level(gpio)); }
|
||||
|
||||
bool read() const
|
||||
{
|
||||
return inverted ? !bool(gpio_get_level(gpio)) : bool(gpio_get_level(gpio));
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(Peripherals::Hal::Gpio<Gpio>);
|
||||
|
||||
#define CREATE_GPIO(name) \
|
||||
Peripherals::Hal::Esp::Gpio{name, false}
|
||||
|
||||
#define CREATE_INV_GPIO(name) \
|
||||
Peripherals::Hal::Esp::Gpio{name, true}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
# warning "ESP HAL included without SKULLC_USE_HAL_ESP being defined."
|
||||
#endif /* SKULLC_USE_HAL_ESP */
|
||||
@ -8,6 +8,8 @@
|
||||
#ifndef SKULLC_PERIPHERALS_HAL_ST_HPP_
|
||||
#define SKULLC_PERIPHERALS_HAL_ST_HPP_
|
||||
|
||||
#ifdef SKULLC_USE_HAL_ST
|
||||
|
||||
#include <main.h>
|
||||
|
||||
#include <array>
|
||||
@ -343,4 +345,8 @@ struct ItmSerialInterface
|
||||
}// namespace Hal
|
||||
}// namespace Peripherals
|
||||
|
||||
#else
|
||||
# warning "ESP HAL included without SKULLC_USE_HAL_ESP being defined."
|
||||
#endif /* SKULLC_USE_HAL_ST */
|
||||
|
||||
#endif /* SKULLC_PERIPHERALS_HAL_ST_HPP_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user