Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 16 additions & 119 deletions .github/workflows/deploy_with_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ jobs:
conan config install https://github.com/libhal/conan-config2.git
conan hal setup

- name: 🔨 Build for cortex-m3 to cache compiler
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m3 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing
- name: 🔨 Build for cortex-m33f to cache compiler
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m33f --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📦 Create tarball of conan packages
run: tar -czf conan-packages.tar.gz -C ~/.conan2 p
Expand All @@ -74,7 +74,7 @@ jobs:
retention-days: 1

# Build jobs for each architecture
build_cortex_m3:
build_cortex_m33f:
needs: setup_compiler_cache
runs-on: ubuntu-24.04
env:
Expand Down Expand Up @@ -109,124 +109,21 @@ jobs:
- name: 📦 Extract conan packages tarball
run: tar -xzf conan-packages.tar.gz -C ~/.conan2

- name: 📦 Create `Debug` package for cortex-m3
run: conan create . -s:h build_type=Debug -s:h os=baremetal -s:h arch=cortex-m3 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing
- name: 📦 Create `Debug` package for cortex-m33f
run: conan create . -s:h build_type=Debug -s:h os=baremetal -s:h arch=cortex-m33f \
--version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing \
-o:h flash_clkdiv=2 -o:h rp_revision=a2 -o:h flash_size="(16 * 1024 * 1024)" -o:h use_w25q_flash=True

- name: 📦 Create `MinSizeRel` package for cortex-m3
run: conan create . -s:h build_type=MinSizeRel -s:h os=baremetal -s:h arch=cortex-m3 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing
- name: 📦 Create `MinSizeRel` package for cortex-m33f
run: conan create . -s:h build_type=MinSizeRel -s:h os=baremetal -s:h arch=cortex-m33f \
--version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing \
-o:h flash_clkdiv=2 -o:h rp_revision=a2 -o:h flash_size="(16 * 1024 * 1024)" -o:h use_w25q_flash=True

- name: 📦 Create `Release` package for cortex-m3
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m3 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📡 Sign into JFrog Artifactory
if: ${{ inputs.version != 'latest' }}
env:
PASSWORD: ${{ secrets.JFROG_LIBHAL_TRUNK_ID_TOKEN }}
JFROG_USER: ${{ secrets.JFROG_LIBHAL_TRUNK_ID_TOKEN_USER }}
run: conan remote login -p $PASSWORD libhal $JFROG_USER

- name: 🆙 Upload package version ${{ inputs.version }} to conan repo
if: ${{ inputs.version != 'latest' }}
run: conan upload "libhal-arm-mcu/${{ inputs.version }}" --confirm -r=libhal

build_cortex_m4:
needs: setup_compiler_cache
runs-on: ubuntu-24.04
env:
VERBOSE: 1
steps:
- uses: actions/checkout@v4.1.1
if: ${{ inputs.version != 'latest' }}
with:
submodules: true
repository: ${{ inputs.repo }}
ref: ${{ inputs.version }}

- uses: actions/checkout@v4.1.1
if: ${{ inputs.version == 'latest' }}
with:
submodules: true
repository: ${{ inputs.repo }}

- name: 🔍 setup libhal
run: |
pipx install conan>=${{ inputs.conan_version }}
conan --version
conan config install https://github.com/libhal/conan-config2.git
conan hal setup

- name: 📥 Download conan package cache
uses: actions/download-artifact@v4
with:
name: conan-packages-${{ inputs.upload_suffix }}
path: .

- name: 📦 Extract conan packages tarball
run: tar -xzf conan-packages.tar.gz -C ~/.conan2

- name: 📦 Create `Debug` package for cortex-m4
run: conan create . -s:h build_type=Debug -s:h os=baremetal -s:h arch=cortex-m4 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📦 Create `MinSizeRel` package for cortex-m4
run: conan create . -s:h build_type=MinSizeRel -s:h os=baremetal -s:h arch=cortex-m4 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📦 Create `Release` package for cortex-m4
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m4 --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📡 Sign into JFrog Artifactory
if: ${{ inputs.version != 'latest' }}
env:
PASSWORD: ${{ secrets.JFROG_LIBHAL_TRUNK_ID_TOKEN }}
JFROG_USER: ${{ secrets.JFROG_LIBHAL_TRUNK_ID_TOKEN_USER }}
run: conan remote login -p $PASSWORD libhal $JFROG_USER

- name: 🆙 Upload package version ${{ inputs.version }} to conan repo
if: ${{ inputs.version != 'latest' }}
run: conan upload "libhal-arm-mcu/${{ inputs.version }}" --confirm -r=libhal

build_cortex_m4f:
needs: setup_compiler_cache
runs-on: ubuntu-24.04
env:
VERBOSE: 1
steps:
- uses: actions/checkout@v4.1.1
if: ${{ inputs.version != 'latest' }}
with:
submodules: true
repository: ${{ inputs.repo }}
ref: ${{ inputs.version }}

- uses: actions/checkout@v4.1.1
if: ${{ inputs.version == 'latest' }}
with:
submodules: true
repository: ${{ inputs.repo }}

- name: 🔍 setup libhal
run: |
pipx install conan>=${{ inputs.conan_version }}
conan --version
conan config install https://github.com/libhal/conan-config2.git
conan hal setup

- name: 📥 Download conan package cache
uses: actions/download-artifact@v4
with:
name: conan-packages-${{ inputs.upload_suffix }}
path: .

- name: 📦 Extract conan packages tarball
run: tar -xzf conan-packages.tar.gz -C ~/.conan2

- name: 📦 Create `Debug` package for cortex-m4f
run: conan create . -s:h build_type=Debug -s:h os=baremetal -s:h arch=cortex-m4f --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📦 Create `MinSizeRel` package for cortex-m4f
run: conan create . -s:h build_type=MinSizeRel -s:h os=baremetal -s:h arch=cortex-m4f --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing

- name: 📦 Create `Release` package for cortex-m4f
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m4f --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing
- name: 📦 Create `Release` package for cortex-m33f
run: conan create . -s:h build_type=Release -s:h os=baremetal -s:h arch=cortex-m33f \
--version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing \
-o:h flash_clkdiv=2 -o:h rp_revision=a2 -o:h flash_size="(16 * 1024 * 1024)" -o:h use_w25q_flash=True

- name: 📡 Sign into JFrog Artifactory
if: ${{ inputs.version != 'latest' }}
Expand All @@ -237,4 +134,4 @@ jobs:

- name: 🆙 Upload package version ${{ inputs.version }} to conan repo
if: ${{ inputs.version != 'latest' }}
run: conan upload "libhal-arm-mcu/${{ inputs.version }}" --confirm -r=libhal
run: conan upload "libhal-picosdk/${{ inputs.version }}" --confirm -r=libhal
164 changes: 21 additions & 143 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,159 +14,27 @@

cmake_minimum_required(VERSION 3.15)

if(DEFINED ENV{PICO_SDK_PATH})
set(PICO_CXX_ENABLE_EXCEPTIONS 1)
set(PICO_NO_PICOTOOL 1)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
endif()
set(CMAKE_COLOR_DIAGNOSTICS ON)

project(libhal-arm-mcu LANGUAGES CXX C ASM)

# Should probably refine this to actually not compile
# drivers for all platforms all the time, but for now this
# serves my purposes
if(NOT DEFINED ENV{PICO_SDK_PATH})
set(source_list
src/system_controller.cpp
src/dwt_counter.cpp
src/interrupt.cpp
src/systick_timer.cpp

# lpc40
src/lpc40/adc.cpp
src/lpc40/can.cpp
src/lpc40/clock.cpp
src/lpc40/dac.cpp
src/lpc40/dma.cpp
src/lpc40/i2c.cpp
src/lpc40/input_pin.cpp
src/lpc40/interrupt_pin.cpp
src/lpc40/interrupt.cpp
src/lpc40/output_pin.cpp
src/lpc40/pin.cpp
src/lpc40/power.cpp
src/lpc40/pwm.cpp
src/lpc40/spi.cpp
src/lpc40/dma_spi.cpp
src/lpc40/stream_dac.cpp
src/lpc40/uart.cpp

# stm32_generic
src/stm32_generic/i2c.cpp
src/stm32_generic/pwm.cpp
src/stm32_generic/quadrature_encoder.cpp
src/stm32_generic/spi.cpp
src/stm32_generic/timer.cpp
src/stm32_generic/uart.cpp

# stm32f1
src/stm32f1/can.cpp
src/stm32f1/can2.cpp
src/stm32f1/clock.cpp
src/stm32f1/gpio.cpp
src/stm32f1/independent_watchdog.cpp
src/stm32f1/input_pin.cpp
src/stm32f1/interrupt.cpp
src/stm32f1/output_pin.cpp
src/stm32f1/pin.cpp
src/stm32f1/power.cpp
src/stm32f1/pwm.cpp
src/stm32f1/quadrature_encoder.cpp
src/stm32f1/timer.cpp
src/stm32f1/uart.cpp
src/stm32f1/spi.cpp
src/stm32f1/adc.cpp
src/stm32f1/usart.cpp
src/stm32f1/usb.cpp

# stm32f411
src/stm32f411/clock.cpp
src/stm32f411/dma.cpp
src/stm32f411/i2c.cpp
src/stm32f411/input_pin.cpp
src/stm32f411/interrupt.cpp
src/stm32f411/output_pin.cpp
src/stm32f411/pin.cpp
src/stm32f411/power.cpp
src/stm32f411/spi.cpp
src/stm32f411/uart.cpp

# stm32f40
src/stm32f40/output_pin.cpp
)

set(
test_sources
# cortex_m
tests/dwt_counter.test.cpp
tests/interrupt.test.cpp
tests/main.test.cpp
tests/systick_timer.test.cpp

# lpc40
tests/lpc40/adc.test.cpp
tests/lpc40/can.test.cpp
tests/lpc40/i2c.test.cpp
tests/lpc40/input_pin.test.cpp
tests/lpc40/interrupt_pin.test.cpp
tests/lpc40/output_pin.test.cpp
tests/lpc40/pwm.test.cpp
tests/lpc40/spi.test.cpp
tests/lpc40/stream_dac.test.cpp
tests/lpc40/uart.test.cpp

# stm32f1
tests/stm32f1/can.test.cpp
tests/stm32f1/can2.test.cpp
tests/stm32f1/output_pin.test.cpp
tests/stm32f1/uart.test.cpp
tests/stm32f1/spi.test.cpp
tests/stm32f1/adc.test.cpp
tests/stm32f1/usb.test.cpp

# stm32f411
tests/stm32f411/output_pin.test.cpp
tests/stm32f411/spi.test.cpp
)

else()
set(source_list
src/rp/gpio.cpp
src/rp/serial.cpp
src/rp/i2c.cpp
src/rp/pwm.cpp
src/rp/adc.cpp
src/rp/spi.cpp
src/rp/time.cpp
src/system_controller.cpp
src/dwt_counter.cpp
src/interrupt.cpp
)
project(libhal-picosdk LANGUAGES CXX C ASM)

pico_sdk_init()

set(pico_dep
hardware_gpio_headers
pico_time_headers
pico_stdio_headers
hardware_sync_headers
hardware_i2c_headers
hardware_pwm_headers
hardware_adc_headers
hardware_spi_headers
hardware_uart_headers
hardware_timer_headers
hardware_dma_headers
)

endif()

libhal_test_and_make_library(
LIBRARY_NAME libhal-arm-mcu
LIBRARY_NAME libhal-picosdk

SOURCES
${source_list}
src/gpio.cpp
src/serial.cpp
src/i2c.cpp
src/pwm.cpp
src/adc.cpp
src/spi.cpp
src/time.cpp
src/dwt_counter.cpp
src/terminate_handler.cpp

TEST_SOURCES
Expand All @@ -183,6 +51,16 @@ libhal_test_and_make_library(
libhal::util
nonstd::ring-span-lite
nonstd::scope-lite
${pico_dep}
hardware_gpio_headers
pico_time_headers
pico_stdio_headers
hardware_sync_headers
hardware_i2c_headers
hardware_pwm_headers
hardware_adc_headers
hardware_spi_headers
hardware_uart_headers
hardware_timer_headers
hardware_dma_headers
)

Loading
Loading