Update Docs; Add 3D-Models for flash and Motor driver; Update Readme; Check program code for exceeding size in CMakeLists.txt; Moved measure() function to core1.c/core1.h; Added direction enum typedef; Update Control Loop Block Diagram;
This commit is contained in:
1 parent
7d2c80574a
commit
acdbf3cffe
25 files changed
+1195
-632
No files matched your search
+69
-5
@@ -53,7 +53,9 @@ pico_set_program_name(RP2040-Decoder "RP2040-Decoder")
|
||||
pico_set_program_version(RP2040-Decoder "1.0")
|
||||
|
||||
|
||||
# LOGLEVEL>0 enables debugging via stdio, this can be done either via USB or alternatively,
|
||||
# Logging configuration:
|
||||
#
|
||||
# LOGLEVEL>0 enables logging messages via stdio, this can be done either via USB or alternatively,
|
||||
# directly with the UART TX/RX pins (see pin definition in RP2040-Decoder-board.h).
|
||||
#
|
||||
# In order to use stdio via USB please set STDIO_USB_ENABLED to 1 below
|
||||
@@ -62,9 +64,9 @@ pico_set_program_version(RP2040-Decoder "1.0")
|
||||
# Additional Notes:
|
||||
# - When logging is disabled (LOGLEVEL 0), all logging functions will be completely excluded during compilation.
|
||||
# - Be cautious: Logging can alter timing behavior. For example, the PID controller is time critical,
|
||||
# limit the frequency of log outputs—such as printing only every 100th iteration.
|
||||
# - Note that with UART logging enabled, PICO_DEFAULT_UART_TX_PIN and PICO_DEFAULT_UART_RX_PIN are disabled for decoder functions
|
||||
# because they are used for UART communication. This is automatically configured for you below.
|
||||
# limit the frequency of log outputs—such as logging only every 100th iteration.
|
||||
# - Note that with UART logging enabled, PICO_DEFAULT_UART_TX_PIN and PICO_DEFAULT_UART_RX_PIN are disabled for decoder functions.
|
||||
# These pins are used for UART communication. Disablign is done automatically in RP2040-Decoder-board.h or RP2040-Decoder-board-legacy.h respectively.
|
||||
set(LOGLEVEL 1)
|
||||
# Additionally, the LOG_WAIT parameter can be configured to make the controller wait for user input via stdio before continuing.
|
||||
# This is useful for ensuring that all stdio logging outputs are captured.
|
||||
@@ -82,7 +84,8 @@ target_compile_definitions( RP2040-Decoder PRIVATE
|
||||
LOGLEVEL=${LOGLEVEL}
|
||||
LOG_WAIT=${LOG_WAIT}
|
||||
STDIO_UART_ENABLED=${STDIO_UART_ENABLED}
|
||||
STDIO_USB_ENABLED=${STDIO_USB_ENABLED})
|
||||
STDIO_USB_ENABLED=${STDIO_USB_ENABLED}
|
||||
)
|
||||
# Warn when logging is enabled (LOGLEVEL>0) and neither stdio is enabled
|
||||
if (LOGLEVEL GREATER 0 AND (STDIO_USB_ENABLED EQUAL 0 AND STDIO_UART_ENABLED EQUAL 0))
|
||||
message(WARNING "\nWARNING: Logging (LOGLEVEL>0) enabled with both STDIO_USB_ENABLED and STDIO_UART_ENABLED disabled!")
|
||||
@@ -107,3 +110,64 @@ target_include_directories(RP2040-Decoder PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(RP2040-Decoder)
|
||||
|
||||
# Program size check
|
||||
#
|
||||
# Check for program size exceeding limits as CVs are stored at the end of flash, the program could theoretically overwrite this.
|
||||
# In practice the program size is usually only about 100KiB.
|
||||
# Extract the directory of the C compiler and construct the path to the 'arm-none-eabi-size' tool
|
||||
get_filename_component(C_COMPILER_DIR ${CMAKE_C_COMPILER} DIRECTORY)
|
||||
set(SIZE_TOOL ${C_COMPILER_DIR}/arm-none-eabi-size)
|
||||
|
||||
# Add custom command to check the flash size after build
|
||||
add_custom_command(TARGET RP2040-Decoder POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Checking flash size for $<TARGET_FILE:RP2040-Decoder>"
|
||||
COMMAND ${SIZE_TOOL} $<TARGET_FILE:RP2040-Decoder> > size_output.txt
|
||||
)
|
||||
|
||||
# Read the size output file
|
||||
file(READ "${CMAKE_BINARY_DIR}/size_output.txt" SIZE_OUTPUT)
|
||||
|
||||
# Print the content of SIZE_OUTPUT
|
||||
message(STATUS "arm-none-eabi-size output:\n${SIZE_OUTPUT}")
|
||||
|
||||
# Use regex to match all numbers
|
||||
string(REGEX MATCHALL "[0-9]+" MATCHED_VALUES "${SIZE_OUTPUT}")
|
||||
|
||||
# Get third element from list of matches, this corresponds with dec table value in "size_output.txt"
|
||||
list(GET MATCHED_VALUES 3 PROGRAM_SIZE_DEC)
|
||||
|
||||
# Check for success of program size extraction from "size_output.txt"
|
||||
if(PROGRAM_SIZE_DEC)
|
||||
message(STATUS "PROGRAM_SIZE_DEC: ${PROGRAM_SIZE_DEC} bytes")
|
||||
else()
|
||||
message(FATAL_ERROR "Could not extract program size from size_output.txt")
|
||||
endif()
|
||||
|
||||
|
||||
# Path to the header file that defines PICO_FLASH_SIZE_BYTES
|
||||
set(FLASH_CONFIG_HEADER ${CMAKE_SOURCE_DIR}/${PICO_BOARD}.h)
|
||||
# Read the contents of the header file into a variable
|
||||
file(READ ${FLASH_CONFIG_HEADER} HEADER_CONTENT)
|
||||
|
||||
# Extract the value of PICO_FLASH_SIZE_BYTES using a regular expression
|
||||
string(REGEX MATCHALL "#define PICO_FLASH_SIZE_BYTES [0-9]+" MACRO_MATCH "${HEADER_CONTENT}")
|
||||
string(REGEX MATCHALL "[0-9]+" PICO_FLASH_SIZE_BYTES "${MACRO_MATCH}")
|
||||
|
||||
|
||||
# Check for success of PICO_FLASH_SIZE_BYTES extraction from board header file
|
||||
if(PICO_FLASH_SIZE_BYTES)
|
||||
message(STATUS "PICO_FLASH_SIZE_BYTES: ${PICO_FLASH_SIZE_BYTES} bytes")
|
||||
else()
|
||||
message(FATAL_ERROR "Failed to find PICO_FLASH_SIZE_BYTES in the header file.")
|
||||
endif()
|
||||
|
||||
# Sector size is always 4096 bytes
|
||||
set(FLASH_SECTOR_SIZE 4096)
|
||||
message(STATUS "FLASH_SECTOR_SIZE: ${FLASH_SECTOR_SIZE} bytes")
|
||||
# Subtract flash sector size from flash size
|
||||
math(EXPR FLASH_TARGET_OFFSET "${PICO_FLASH_SIZE_BYTES} - ${FLASH_SECTOR_SIZE}")
|
||||
message(STATUS "FLASH_TARGET_OFFSET: ${FLASH_TARGET_OFFSET} bytes")
|
||||
|
||||
if(PROGRAM_SIZE_DEC GREATER FLASH_TARGET_OFFSET)
|
||||
message(FATAL_ERROR "Program size exceeds allowed flash size. Flash sector containing the CVs would be overwritten! Please reduce the size of the program.")
|
||||
endif()
|
||||
Reference in new issue
Block a user