Skip to content

Commit cff46fc

Browse files
committed
Improved stm32 GPIO driver
Complete rewrite of the stm32 gpio driver using updated APIs. Moves all GPIO related atoms from `platform_defaultatoms.{c,h}` into `gpio_driver.c` Improved input validation. Adds read support port driver. Adds nif functions to support read and write. Adds cmake configuration options to disable nifs and/or port driver when building the VM. Closes atomvm#571 Addresses atomvm#894 on STM32 platform. Signed-off-by: Winford <[email protected]>
1 parent 9aab333 commit cff46fc

File tree

11 files changed

+668
-309
lines changed

11 files changed

+668
-309
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Added support for the OTP `socket` interface.
1919
- Enhancd performance of STM32 by enabling flash cache and i-cache with branch prediction.
2020
- Added cmake configuration option `AVM_CONFIG_REBOOT_ON_NOT_OK` for STM32
21+
- New gpio driver for STM32 with nif and port support for read and write functions.
2122

2223
## [0.6.0-alpha.1] - 2023-10-09
2324

src/platforms/stm32/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ option(AVM_LOG_DISABLE "Disable log output" OFF)
3333
option(AVM_ENABLE_LOG_COLOR "Use color log output" OFF)
3434
option(AVM_ENABLE_LOG_LINES "Include source and line info for all enbled levels" OFF)
3535
option(AVM_CONFIG_REBOOT_ON_NOT_OK "Reboot when application exits with non 'ok' return" OFF)
36+
option(AVM_DISABLE_GPIO_NIFS "Disable GPIO nifs (input and output)" OFF)
37+
option(AVM_DISABLE_GPIO_PORT_DRIVER "Disable GPIO 'port' driver (input, output, and interrupts)" OFF)
3638

3739
set(AVM_DISABLE_SMP ON FORCE)
3840

@@ -64,6 +66,14 @@ if (AVM_ENABLE_LOG_LINES)
6466
add_compile_definitions(ENABLE_LOG_LINE_INFO)
6567
endif()
6668

69+
# Configure Drivers
70+
if (AVM_DISABLE_GPIO_NIFS)
71+
add_compile_definitions(AVM_DISABLE_GPIO_NIFS)
72+
endif()
73+
if (AVM_DISABLE_GPIO_PORT_DRIVER)
74+
add_compile_definitions(AVM_DISABLE_GPIO_PORT_DRIVER)
75+
endif()
76+
6777
# Include an error in case the user forgets to specify ARM as a toolchain
6878
if (NOT CMAKE_TOOLCHAIN_FILE)
6979
message(FATAL_ERROR "Cross compiling only. Please use -DCMAKE_TOOLCHAIN_FILE=cmake/arm-toolchain.cmake or use\

src/platforms/stm32/src/lib/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ project (libAtomVMPlatformSTM32)
2323

2424
set(HEADER_FILES
2525
avm_log.h
26-
gpiodriver.h
27-
platform_defaultatoms.h
26+
gpio_driver.h
2827
stm_sys.h
2928
../../../../libAtomVM/platform_nifs.h
3029
../../../../libAtomVM/sys.h
3130
)
3231

3332
set(SOURCE_FILES
34-
gpiodriver.c
35-
platform_defaultatoms.c
33+
gpio_driver.c
3634
platform_nifs.c
3735
sys.c
3836
)

0 commit comments

Comments
 (0)