Skip to content

Commit

Permalink
Improved stm32 GPIO driver
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
UncleGrumpy committed Oct 25, 2023
1 parent 9aab333 commit 2a025b6
Show file tree
Hide file tree
Showing 11 changed files with 666 additions and 309 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for the OTP `socket` interface.
- Enhancd performance of STM32 by enabling flash cache and i-cache with branch prediction.
- Added cmake configuration option `AVM_CONFIG_REBOOT_ON_NOT_OK` for STM32
- New gpio driver for STM32 with nif and port support for read and write functions.

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

Expand Down
10 changes: 10 additions & 0 deletions src/platforms/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ option(AVM_LOG_DISABLE "Disable log output" OFF)
option(AVM_ENABLE_LOG_COLOR "Use color log output" OFF)
option(AVM_ENABLE_LOG_LINES "Include source and line info for all enbled levels" OFF)
option(AVM_CONFIG_REBOOT_ON_NOT_OK "Reboot when application exits with non 'ok' return" OFF)
option(AVM_DISABLE_GPIO_NIFS "Disable GPIO nifs (input and output)" OFF)
option(AVM_DISABLE_GPIO_PORT_DRIVER "Disable GPIO 'port' driver (input, output, and interrupts)" OFF)

set(AVM_DISABLE_SMP ON FORCE)

Expand Down Expand Up @@ -64,6 +66,14 @@ if (AVM_ENABLE_LOG_LINES)
add_compile_definitions(ENABLE_LOG_LINE_INFO)
endif()

# Configure Drivers
if (AVM_DISABLE_GPIO_NIFS)
add_compile_definitions(AVM_DISABLE_GPIO_NIFS)
endif()
if (AVM_DISABLE_GPIO_PORT_DRIVER)
add_compile_definitions(AVM_DISABLE_GPIO_PORT_DRIVER)
endif()

# Include an error in case the user forgets to specify ARM as a toolchain
if (NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Cross compiling only. Please use -DCMAKE_TOOLCHAIN_FILE=cmake/arm-toolchain.cmake or use\
Expand Down
6 changes: 2 additions & 4 deletions src/platforms/stm32/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ project (libAtomVMPlatformSTM32)

set(HEADER_FILES
avm_log.h
gpiodriver.h
platform_defaultatoms.h
gpio_driver.h
stm_sys.h
../../../../libAtomVM/platform_nifs.h
../../../../libAtomVM/sys.h
)

set(SOURCE_FILES
gpiodriver.c
platform_defaultatoms.c
gpio_driver.c
platform_nifs.c
sys.c
)
Expand Down
Loading

0 comments on commit 2a025b6

Please sign in to comment.