mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-07-07 13:08:09 +02:00
Refactor Rust drivers for strict idiomatic documentation and 8-line enforcement
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ARM GCC",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/Inc/**"
|
||||
],
|
||||
"defines": [
|
||||
"__GNUC__",
|
||||
"__ARM_ARCH_8M_MAIN__",
|
||||
"__ARMCC_VERSION"
|
||||
],
|
||||
"compilerPath": "${userHome}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gcc",
|
||||
"compileCommands": "${workspaceFolder}/compile_commands.json",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "gcc-arm",
|
||||
"compilerArgs": [
|
||||
"-mcpu=cortex-m33",
|
||||
"-mthumb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ARM GCC (Windows)",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/Inc/**"
|
||||
],
|
||||
"defines": [
|
||||
"__GNUC__",
|
||||
"__ARM_ARCH_8M_MAIN__",
|
||||
"__ARMCC_VERSION"
|
||||
],
|
||||
"compilerPath": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gcc.exe",
|
||||
"compileCommands": "${workspaceFolder}/compile_commands.json",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "gcc-arm",
|
||||
"compilerArgs": [
|
||||
"-mcpu=cortex-m33",
|
||||
"-mthumb"
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"marus25.cortex-debug",
|
||||
"ms-vscode.cpptools",
|
||||
"ms-vscode.cpptools-extension-pack",
|
||||
"ms-vscode.vscode-serial-monitor",
|
||||
"raspberry-pi.raspberry-pi-pico"
|
||||
]
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug RP2350 (OpenOCD)",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"executable": "${workspaceFolder}/build/button.elf",
|
||||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"serverpath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd",
|
||||
"searchDir": [
|
||||
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts"
|
||||
],
|
||||
"gdbPath": "${userHome}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gdb",
|
||||
"device": "RP2350",
|
||||
"configFiles": [
|
||||
"interface/cmsis-dap.cfg",
|
||||
"target/rp2350.cfg"
|
||||
],
|
||||
"svdFile": "${userHome}/.pico-sdk/sdk/2.2.0/src/rp2350/hardware_regs/RP2350.svd",
|
||||
"overrideLaunchCommands": [
|
||||
"set arch armv8-m.main",
|
||||
"set output-radix 16",
|
||||
"monitor reset init",
|
||||
"load",
|
||||
"monitor reset halt"
|
||||
],
|
||||
"openOCDPreConfigLaunchCommands": [
|
||||
"set USE_CORE { cm0 cm1 }"
|
||||
],
|
||||
"openOCDLaunchCommands": [
|
||||
"adapter speed 5000"
|
||||
],
|
||||
"preLaunchTask": "Compile Project",
|
||||
"showDevDebugOutput": "raw",
|
||||
"windows": {
|
||||
"serverpath": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||
"searchDir": [
|
||||
"${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/scripts"
|
||||
],
|
||||
"gdbPath": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gdb.exe",
|
||||
"svdFile": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0/src/rp2350/hardware_regs/RP2350.svd"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"cmake.showSystemKits": false,
|
||||
"cmake.options.statusBarVisibility": "hidden",
|
||||
"cmake.options.advanced": {
|
||||
"build": {
|
||||
"statusBarVisibility": "hidden"
|
||||
},
|
||||
"launch": {
|
||||
"statusBarVisibility": "hidden"
|
||||
},
|
||||
"debug": {
|
||||
"statusBarVisibility": "hidden"
|
||||
}
|
||||
},
|
||||
"cmake.configureOnEdit": false,
|
||||
"cmake.automaticReconfigure": false,
|
||||
"cmake.configureOnOpen": false,
|
||||
"cmake.generator": "Ninja",
|
||||
"cmake.cmakePath": "${userHome}/.pico-sdk/cmake/v3.31.5/bin/cmake",
|
||||
"C_Cpp.debugShortcut": false,
|
||||
"terminal.integrated.env.windows": {
|
||||
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0",
|
||||
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1",
|
||||
"Path": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.31.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}"
|
||||
},
|
||||
"terminal.integrated.env.osx": {
|
||||
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
||||
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||
},
|
||||
"terminal.integrated.env.linux": {
|
||||
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
||||
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||
},
|
||||
"raspberry-pi-pico.cmakeAutoConfigure": true,
|
||||
"raspberry-pi-pico.useCmakeTools": false,
|
||||
"raspberry-pi-pico.cmakePath": "${HOME}/.pico-sdk/cmake/v3.31.5/bin/cmake",
|
||||
"raspberry-pi-pico.ninjaPath": "${HOME}/.pico-sdk/ninja/v1.12.1/ninja"
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Compile Project",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "dedicated"
|
||||
},
|
||||
"problemMatcher": "$gcc",
|
||||
"windows": {
|
||||
"command": ".\\build.bat"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Clean Project",
|
||||
"type": "shell",
|
||||
"command": "make clean",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "dedicated"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"windows": {
|
||||
"command": ".\\clean.bat"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run Project",
|
||||
"type": "shell",
|
||||
"command": "${userHome}/.pico-sdk/picotool/2.2.0-a4/picotool/picotool",
|
||||
"args": [
|
||||
"load",
|
||||
"build/button.uf2",
|
||||
"-fx"
|
||||
],
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "dedicated"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"dependsOn": [
|
||||
"Compile Project"
|
||||
],
|
||||
"windows": {
|
||||
"command": "${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool/picotool.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Flash",
|
||||
"type": "shell",
|
||||
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd",
|
||||
"args": [
|
||||
"-s",
|
||||
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||
"-f",
|
||||
"interface/cmsis-dap.cfg",
|
||||
"-f",
|
||||
"target/rp2350.cfg",
|
||||
"-c",
|
||||
"adapter speed 5000; program build/button.elf verify reset exit"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"dependsOn": [
|
||||
"Compile Project"
|
||||
],
|
||||
"windows": {
|
||||
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Rescue Reset",
|
||||
"type": "process",
|
||||
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd",
|
||||
"args": [
|
||||
"-s",
|
||||
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||
"-f",
|
||||
"interface/cmsis-dap.cfg",
|
||||
"-f",
|
||||
"target/${command:raspberry-pi-pico.getChip}-rescue.cfg",
|
||||
"-c",
|
||||
"adapter speed 5000; reset halt; exit"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"windows": {
|
||||
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "RISC-V Reset (RP2350)",
|
||||
"type": "process",
|
||||
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd",
|
||||
"args": [
|
||||
"-s",
|
||||
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||
"-c",
|
||||
"set USE_CORE { rv0 rv1 cm0 cm1 }",
|
||||
"-f",
|
||||
"interface/cmsis-dap.cfg",
|
||||
"-f",
|
||||
"target/rp2350.cfg",
|
||||
"-c",
|
||||
"adapter speed 5000; init;",
|
||||
"-c",
|
||||
"write_memory 0x40120158 8 { 0x3 }; echo [format \"Info : ARCHSEL 0x%02x\" [read_memory 0x40120158 8 1]];",
|
||||
"-c",
|
||||
"reset halt; targets rp2350.rv0; echo [format \"Info : ARCHSEL_STATUS 0x%02x\" [read_memory 0x4012015C 8 1]]; exit"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"windows": {
|
||||
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* @file rp2350.h
|
||||
* @brief RP2350 Device Peripheral Access Layer Header File.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Memory-mapped register structures and peripheral base addresses
|
||||
* for the RP2350 microcontroller (Cortex-M33 dual-core). All
|
||||
* register offsets verified against the RP2350 datasheet
|
||||
* (RP-008373-DS-2).
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_H
|
||||
#define __RP2350_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*!< Defines 'read / write' permissions */
|
||||
#define __IO volatile
|
||||
|
||||
/*!< Stack addresses */
|
||||
#define STACK_TOP 0x20082000UL
|
||||
#define STACK_LIMIT 0x2007A000UL
|
||||
|
||||
/*!< Memory map */
|
||||
#define XIP_BASE 0x10000000UL
|
||||
#define SRAM_BASE 0x20000000UL
|
||||
#define SIO_BASE 0xD0000000UL
|
||||
#define PPB_BASE 0xE0000000UL
|
||||
|
||||
/*!< APB peripherals */
|
||||
#define CLOCKS_BASE 0x40010000UL
|
||||
#define RESETS_BASE 0x40020000UL
|
||||
#define IO_BANK0_BASE 0x40028000UL
|
||||
#define PADS_BANK0_BASE 0x40038000UL
|
||||
#define XOSC_BASE 0x40048000UL
|
||||
#define UART0_BASE 0x40070000UL
|
||||
|
||||
/**
|
||||
* @brief XOSC (External Crystal Oscillator)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t CTRL; // Control register Address offset: 0x00
|
||||
__IO uint32_t STATUS; // Status register Address offset: 0x04
|
||||
__IO uint32_t DORMANT; // Dormant mode Address offset: 0x08
|
||||
__IO uint32_t STARTUP; // Startup delay Address offset: 0x0C
|
||||
__IO uint32_t COUNT; // Frequency count Address offset: 0x10
|
||||
} XOSC_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief CLOCKS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t RESERVED0[18]; // Other clock registers Address offset: 0x00-0x44
|
||||
__IO uint32_t CLK_PERI_CTRL; // Peripheral clock control Address offset: 0x48
|
||||
} CLOCKS_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief RESETS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t RESET; // Reset control Address offset: 0x00
|
||||
__IO uint32_t WDSEL; // Watchdog select Address offset: 0x04
|
||||
__IO uint32_t RESET_DONE; // Reset done status Address offset: 0x08
|
||||
} RESETS_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief IO_BANK0 GPIO Control (one per GPIO)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t STATUS; // GPIO status Address offset: 0x00
|
||||
__IO uint32_t CTRL; // GPIO control Address offset: 0x04
|
||||
} IO_BANK0_GPIO_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief IO_BANK0
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
IO_BANK0_GPIO_TypeDef GPIO[30]; // GPIO 0-29 status/ctrl pairs Address offset: 0x000-0x0E8
|
||||
} IO_BANK0_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief PADS_BANK0
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t VOLTAGE_SELECT; // Voltage select Address offset: 0x00
|
||||
__IO uint32_t GPIO[30]; // GPIO 0-29 pad control Address offset: 0x04-0x78
|
||||
} PADS_BANK0_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief Peripheral Definitions
|
||||
*/
|
||||
#define XOSC ((XOSC_TypeDef *) XOSC_BASE)
|
||||
#define CLOCKS ((CLOCKS_TypeDef *) CLOCKS_BASE)
|
||||
#define RESETS ((RESETS_TypeDef *) RESETS_BASE)
|
||||
#define IO_BANK0 ((IO_BANK0_TypeDef *) IO_BANK0_BASE)
|
||||
#define PADS_BANK0 ((PADS_BANK0_TypeDef *) PADS_BANK0_BASE)
|
||||
#define SIO ((volatile uint32_t *) SIO_BASE)
|
||||
#define CPACR ((volatile uint32_t *) (PPB_BASE + 0x0ED88UL))
|
||||
|
||||
/**
|
||||
* @brief XOSC bit definitions
|
||||
*/
|
||||
#define XOSC_STATUS_STABLE_SHIFT 31U
|
||||
|
||||
/**
|
||||
* @brief CPACR bit definitions
|
||||
*/
|
||||
#define CPACR_CP0_SHIFT 0U
|
||||
#define CPACR_CP1_SHIFT 1U
|
||||
|
||||
/**
|
||||
* @brief CLOCKS bit definitions
|
||||
*/
|
||||
#define CLK_PERI_CTRL_ENABLE_SHIFT 11U
|
||||
#define CLK_PERI_CTRL_AUXSRC_SHIFT 5U
|
||||
#define CLK_PERI_CTRL_AUXSRC_XOSC 4U
|
||||
|
||||
/**
|
||||
* @brief RESETS bit definitions
|
||||
*/
|
||||
#define RESETS_RESET_IO_BANK0_SHIFT 6U
|
||||
#define RESETS_RESET_UART0_SHIFT 26U
|
||||
|
||||
/**
|
||||
* @brief IO_BANK0 bit definitions
|
||||
*/
|
||||
#define IO_BANK0_CTRL_FUNCSEL_MASK 0x1FU
|
||||
#define IO_BANK0_CTRL_FUNCSEL_UART 0x02U
|
||||
#define IO_BANK0_CTRL_FUNCSEL_SIO 0x05U
|
||||
|
||||
/**
|
||||
* @brief PADS_BANK0 bit definitions
|
||||
*/
|
||||
#define PADS_BANK0_OD_SHIFT 7U
|
||||
#define PADS_BANK0_IE_SHIFT 6U
|
||||
#define PADS_BANK0_PUE_SHIFT 3U
|
||||
#define PADS_BANK0_PDE_SHIFT 2U
|
||||
#define PADS_BANK0_ISO_SHIFT 8U
|
||||
|
||||
/**
|
||||
* @brief UART register offsets (word indices from UART0_BASE)
|
||||
*/
|
||||
#define UART_DR_OFFSET (0x000U / 4U)
|
||||
#define UART_FR_OFFSET (0x018U / 4U)
|
||||
#define UART_IBRD_OFFSET (0x024U / 4U)
|
||||
#define UART_FBRD_OFFSET (0x028U / 4U)
|
||||
#define UART_LCR_H_OFFSET (0x02CU / 4U)
|
||||
#define UART_CR_OFFSET (0x030U / 4U)
|
||||
|
||||
/**
|
||||
* @brief UART flag register bit definitions
|
||||
*/
|
||||
#define UART_FR_TXFF_MASK 32U
|
||||
#define UART_FR_RXFE_MASK 16U
|
||||
|
||||
/**
|
||||
* @brief UART line control and enable values
|
||||
*/
|
||||
#define UART_LCR_H_8N1_FIFO 0x70U
|
||||
#define UART_CR_ENABLE ((3U << 8) | 1U)
|
||||
|
||||
/**
|
||||
* @brief GPIO pin definitions
|
||||
*/
|
||||
#define LED_PIN 25U
|
||||
#define BUTTON_PIN 15U
|
||||
|
||||
/**
|
||||
* @brief SIO GPIO register offsets (word indices from SIO_BASE)
|
||||
*/
|
||||
#define SIO_GPIO_IN_OFFSET (0x004U / 4U)
|
||||
#define SIO_GPIO_OUT_SET_OFFSET (0x018U / 4U)
|
||||
#define SIO_GPIO_OUT_CLR_OFFSET (0x020U / 4U)
|
||||
#define SIO_GPIO_OUT_XOR_OFFSET (0x028U / 4U)
|
||||
#define SIO_GPIO_OE_SET_OFFSET (0x038U / 4U)
|
||||
|
||||
#endif /* __RP2350_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file rp2350_button.h
|
||||
* @brief Button input driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Push-button GPIO input driver with software debounce.
|
||||
* The button pin is configured as active-low with internal
|
||||
* pull-up; pressing the button connects the pin to GND.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_BUTTON_H
|
||||
#define __RP2350_BUTTON_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize a GPIO pin as an active-low button input with pull-up.
|
||||
* @param pin GPIO pin number to configure as a button input
|
||||
* @param debounce_ms debounce settling time in milliseconds
|
||||
* @retval None
|
||||
*/
|
||||
void button_init(uint32_t pin, uint32_t debounce_ms);
|
||||
|
||||
/**
|
||||
* @brief Read the debounced state of the button.
|
||||
* @param pin GPIO pin number previously initialized with button_init()
|
||||
* @retval bool true if the button is firmly pressed, false if released
|
||||
*/
|
||||
bool button_is_pressed(uint32_t pin);
|
||||
|
||||
#endif /* __RP2350_BUTTON_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file rp2350_delay.h
|
||||
* @brief Delay driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Millisecond busy-wait delay calibrated for a 12 MHz clock.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_DELAY_H
|
||||
#define __RP2350_DELAY_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms);
|
||||
|
||||
#endif /* __RP2350_DELAY_H */
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file rp2350_gpio.h
|
||||
* @brief GPIO driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* SIO-based GPIO configuration, set, clear, toggle, and read
|
||||
* functions for the RP2350 GPIO pins 0-29.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_GPIO_H
|
||||
#define __RP2350_GPIO_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Configure a GPIO pin as SIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_config(uint32_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Drive a GPIO output high.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_set(uint32_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Drive a GPIO output low.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_clear(uint32_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Toggle a GPIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_toggle(uint32_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Configure a GPIO pin as SIO input with internal pull-up.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_config_input_pullup(uint32_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Read the current input level of a GPIO pin.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval bool true if pin is high, false if low
|
||||
*/
|
||||
bool gpio_get(uint32_t gpio_num);
|
||||
|
||||
#endif /* __RP2350_GPIO_H */
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @file rp2350_led.h
|
||||
* @brief LED driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* High-level GPIO output / LED driver wrapping the
|
||||
* low-level GPIO functions.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_LED_H
|
||||
#define __RP2350_LED_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize a GPIO pin as a push-pull digital output.
|
||||
* @param pin GPIO pin number to configure
|
||||
* @retval None
|
||||
*/
|
||||
void led_init(uint32_t pin);
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_on(uint32_t pin);
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_off(uint32_t pin);
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_toggle(uint32_t pin);
|
||||
|
||||
/**
|
||||
* @brief Query the current drive state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval bool true if the pin is driven high, false if low
|
||||
*/
|
||||
bool led_get_state(uint32_t pin);
|
||||
|
||||
#endif /* __RP2350_LED_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file rp2350_reset.h
|
||||
* @brief Reset controller driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Provides subsystem reset release for IO_BANK0.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_RESET_H
|
||||
#define __RP2350_RESET_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void);
|
||||
|
||||
#endif /* __RP2350_RESET_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file rp2350_reset_handler.h
|
||||
* @brief Reset handler header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Entry point after reset. Performs stack initialization, XOSC
|
||||
* setup, subsystem reset release, UART initialization,
|
||||
* and branches to main().
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_RESET_HANDLER_H
|
||||
#define __RP2350_RESET_HANDLER_H
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void Reset_Handler(void) __attribute__((noreturn));
|
||||
|
||||
#endif /* __RP2350_RESET_HANDLER_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file rp2350_stack.h
|
||||
* @brief Stack pointer initialization header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Sets MSP, PSP, MSPLIM, and PSPLIM from the STACK_TOP and
|
||||
* STACK_LIMIT values defined in rp2350.h.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_STACK_H
|
||||
#define __RP2350_STACK_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void);
|
||||
|
||||
#endif /* __RP2350_STACK_H */
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file rp2350_uart.h
|
||||
* @brief UART0 driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Bare-metal UART0 driver supporting TX/RX on GPIO 0/1 at
|
||||
* 115200 baud (12 MHz XOSC clock).
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_UART_H
|
||||
#define __RP2350_UART_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether a received byte is waiting in the UART FIFO.
|
||||
* @retval bool true if at least one byte is available
|
||||
*/
|
||||
bool uart_is_readable(void);
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void);
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c);
|
||||
|
||||
/**
|
||||
* @brief Transmit a null-terminated string over UART0.
|
||||
* @param str pointer to the string to send
|
||||
* @retval None
|
||||
*/
|
||||
void uart_puts(const char *str);
|
||||
|
||||
/**
|
||||
* @brief Convert a lowercase ASCII character to uppercase.
|
||||
* @param c input character
|
||||
* @retval char uppercase equivalent or original character
|
||||
*/
|
||||
char uart_to_upper(char c);
|
||||
|
||||
#endif /* __RP2350_UART_H */
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file rp2350_xosc.h
|
||||
* @brief XOSC driver header for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* External crystal oscillator initialization and peripheral
|
||||
* clock enable using the XOSC registers.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef __RP2350_XOSC_H
|
||||
#define __RP2350_XOSC_H
|
||||
|
||||
#include "rp2350.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void);
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void);
|
||||
|
||||
#endif /* __RP2350_XOSC_H */
|
||||
@@ -0,0 +1,87 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# @file Makefile
|
||||
# @author Kevin Thomas
|
||||
# @brief Build script for RP2350 bare-metal C button driver.
|
||||
#
|
||||
# Compiles, links, and generates UF2 firmware for the RP2350.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# OS detection
|
||||
ifeq ($(OS),Windows_NT)
|
||||
MKDIR = if not exist $(subst /,\\,$(BUILD_DIR)) mkdir $(subst /,\\,$(BUILD_DIR))
|
||||
RM = if exist $(subst /,\\,$(BUILD_DIR)) rmdir /s /q $(subst /,\\,$(BUILD_DIR))
|
||||
else
|
||||
MKDIR = mkdir -p $(BUILD_DIR)
|
||||
RM = rm -rf $(BUILD_DIR)
|
||||
endif
|
||||
|
||||
# Toolchain
|
||||
CC = arm-none-eabi-gcc
|
||||
OBJCOPY = arm-none-eabi-objcopy
|
||||
SIZE = arm-none-eabi-size
|
||||
|
||||
# Target
|
||||
TARGET = button
|
||||
|
||||
# Directories
|
||||
SRC_DIR = Src
|
||||
INC_DIR = Inc
|
||||
BUILD_DIR = build
|
||||
|
||||
# CPU flags
|
||||
CPU_FLAGS = -mcpu=cortex-m33 -mthumb
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS = $(CPU_FLAGS) -Og -g3 -Wall -Wextra \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-I$(INC_DIR)
|
||||
|
||||
# Linker flags
|
||||
LDFLAGS = $(CPU_FLAGS) -T linker.ld -nostdlib -Wl,--gc-sections
|
||||
|
||||
# Source files
|
||||
SRCS = $(SRC_DIR)/vector_table.c \
|
||||
$(SRC_DIR)/rp2350_reset_handler.c \
|
||||
$(SRC_DIR)/rp2350_stack.c \
|
||||
$(SRC_DIR)/rp2350_xosc.c \
|
||||
$(SRC_DIR)/rp2350_reset.c \
|
||||
$(SRC_DIR)/rp2350_uart.c \
|
||||
$(SRC_DIR)/rp2350_gpio.c \
|
||||
$(SRC_DIR)/rp2350_led.c \
|
||||
$(SRC_DIR)/rp2350_delay.c \
|
||||
$(SRC_DIR)/rp2350_button.c \
|
||||
$(SRC_DIR)/main.c \
|
||||
$(SRC_DIR)/image_def.c
|
||||
|
||||
# Object files
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
|
||||
|
||||
# Rules
|
||||
.PHONY: all clean flash
|
||||
|
||||
all: $(BUILD_DIR)/$(TARGET).bin
|
||||
@echo "==================================="
|
||||
@echo "SUCCESS! Created $(TARGET).elf and $(TARGET).bin"
|
||||
@echo "==================================="
|
||||
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJS)
|
||||
$(CC) $(LDFLAGS) $(OBJS) -o $@
|
||||
$(SIZE) $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
|
||||
$(BUILD_DIR):
|
||||
$(MKDIR)
|
||||
|
||||
clean:
|
||||
$(RM)
|
||||
|
||||
flash: $(BUILD_DIR)/$(TARGET).elf
|
||||
openocd -f interface/cmsis-dap.cfg -f target/rp2350.cfg \
|
||||
-c "adapter speed 5000" \
|
||||
-c "program $< verify reset exit"
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file image_def.c
|
||||
* @brief RP2350 IMAGE_DEF block for boot ROM image recognition.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Must appear within the first 4 KB of flash for the boot ROM
|
||||
* to accept the image.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
0x42, 0x01, 0x21, 0x10,
|
||||
0xFF, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x79, 0x35, 0x12, 0xAB
|
||||
};
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief Button demonstration: debounced press mirrors to LED + UART report.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Demonstrates GPIO input using the button driver. The onboard
|
||||
* LED mirrors the button state and every edge transition is
|
||||
* reported over UART.
|
||||
*
|
||||
* Wiring:
|
||||
* GPIO15 -> One leg of push button
|
||||
* GND -> Other leg of push button
|
||||
* GPIO25 -> Onboard LED (no external wiring needed)
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_button.h"
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_uart.h"
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/** @brief Button debounce window in milliseconds */
|
||||
#define DEBOUNCE_MS 20
|
||||
/** @brief Button polling interval in milliseconds */
|
||||
#define POLL_DELAY_MS 10
|
||||
|
||||
/**
|
||||
* @brief Drive the LED to match the current button state.
|
||||
* @param pressed true if button is pressed, false if released
|
||||
* @retval None
|
||||
*/
|
||||
static void set_led_state(bool pressed)
|
||||
{
|
||||
if (pressed)
|
||||
led_on(LED_PIN);
|
||||
else
|
||||
led_off(LED_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Report a button edge transition over UART.
|
||||
* @param pressed current button state
|
||||
* @param last_state pointer to the stored previous button state
|
||||
* @retval None
|
||||
*/
|
||||
static void report_edge(bool pressed, bool *last_state)
|
||||
{
|
||||
if (pressed != *last_state)
|
||||
{
|
||||
if (pressed)
|
||||
uart_puts("Button: PRESSED\r\n");
|
||||
else
|
||||
uart_puts("Button: RELEASED\r\n");
|
||||
*last_state = pressed;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Poll the button, mirror to LED, and report edges.
|
||||
* @param last_state pointer to the stored previous button state
|
||||
* @retval None
|
||||
*/
|
||||
static void poll_button(bool *last_state)
|
||||
{
|
||||
bool pressed;
|
||||
pressed = button_is_pressed(BUTTON_PIN);
|
||||
set_led_state(pressed);
|
||||
report_edge(pressed, last_state);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
button_init(BUTTON_PIN, DEBOUNCE_MS);
|
||||
led_init(LED_PIN);
|
||||
uart_puts("Button driver initialized: button=GPIO15 led=GPIO25\r\n");
|
||||
bool last_state = false;
|
||||
while (1)
|
||||
{
|
||||
poll_button(&last_state);
|
||||
delay_ms(POLL_DELAY_MS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file rp2350_button.c
|
||||
* @brief Button input driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Configures a GPIO pin as an active-low input with internal
|
||||
* pull-up and provides debounced press detection using a
|
||||
* busy-wait confirmation delay.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_button.h"
|
||||
#include "rp2350_gpio.h"
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
static uint32_t debounce_delay_ms = 20;
|
||||
|
||||
/**
|
||||
* @brief Re-sample the pin after the debounce delay to confirm press.
|
||||
* @param pin GPIO pin number to re-sample
|
||||
* @retval bool true if the pin is still low after the debounce delay
|
||||
*/
|
||||
static bool debounce_confirm(uint32_t pin)
|
||||
{
|
||||
delay_ms(debounce_delay_ms);
|
||||
return !gpio_get(pin);
|
||||
}
|
||||
|
||||
void button_init(uint32_t pin, uint32_t debounce_ms)
|
||||
{
|
||||
debounce_delay_ms = debounce_ms;
|
||||
gpio_config_input_pullup(pin);
|
||||
}
|
||||
|
||||
bool button_is_pressed(uint32_t pin)
|
||||
{
|
||||
if (!gpio_get(pin))
|
||||
return debounce_confirm(pin);
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file rp2350_delay.c
|
||||
* @brief Delay driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Busy-wait millisecond delay calibrated for a 12 MHz clock
|
||||
* (3600 loop iterations per millisecond).
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
return;
|
||||
__asm__ volatile (
|
||||
"mov r4, #3600\n\t"
|
||||
"mul r5, %0, r4\n\t"
|
||||
"1:\n\t"
|
||||
"subs r5, #1\n\t"
|
||||
"bne 1b\n\t"
|
||||
:
|
||||
: "r" (ms)
|
||||
: "r4", "r5", "cc"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @file rp2350_gpio.c
|
||||
* @brief GPIO driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* SIO-based GPIO configuration using IO_BANK0 and PADS_BANK0
|
||||
* register structs defined in rp2350.h. All register offsets
|
||||
* verified against the RP2350 datasheet (RP-008373-DS-2).
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_gpio.h"
|
||||
|
||||
/**
|
||||
* @brief Configure pad control for a GPIO pin.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
static void gpio_config_pad(uint32_t gpio_num)
|
||||
{
|
||||
uint32_t value;
|
||||
value = PADS_BANK0->GPIO[gpio_num];
|
||||
value &= ~(1U << PADS_BANK0_OD_SHIFT);
|
||||
value |= (1U << PADS_BANK0_IE_SHIFT);
|
||||
value &= ~(1U << PADS_BANK0_ISO_SHIFT);
|
||||
PADS_BANK0->GPIO[gpio_num] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set IO_BANK0 FUNCSEL to SIO for a GPIO pin.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
static void gpio_config_funcsel(uint32_t gpio_num)
|
||||
{
|
||||
uint32_t value;
|
||||
value = IO_BANK0->GPIO[gpio_num].CTRL;
|
||||
value &= ~IO_BANK0_CTRL_FUNCSEL_MASK;
|
||||
value |= IO_BANK0_CTRL_FUNCSEL_SIO;
|
||||
IO_BANK0->GPIO[gpio_num].CTRL = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure pad for input with pull-up enabled.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
static void gpio_config_pad_input_pullup(uint32_t gpio_num)
|
||||
{
|
||||
uint32_t value;
|
||||
value = PADS_BANK0->GPIO[gpio_num];
|
||||
value |= (1U << PADS_BANK0_IE_SHIFT);
|
||||
value &= ~(1U << PADS_BANK0_ISO_SHIFT);
|
||||
value |= (1U << PADS_BANK0_PUE_SHIFT);
|
||||
value &= ~(1U << PADS_BANK0_PDE_SHIFT);
|
||||
PADS_BANK0->GPIO[gpio_num] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the output driver for a GPIO pin via SIO.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
static void gpio_enable_output(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OE_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
void gpio_config(uint32_t gpio_num)
|
||||
{
|
||||
gpio_config_pad(gpio_num);
|
||||
gpio_config_funcsel(gpio_num);
|
||||
gpio_enable_output(gpio_num);
|
||||
}
|
||||
|
||||
void gpio_set(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
void gpio_clear(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_CLR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
void gpio_toggle(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_XOR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
bool gpio_get(uint32_t gpio_num)
|
||||
{
|
||||
return (SIO[SIO_GPIO_IN_OFFSET] & (1U << gpio_num)) != 0;
|
||||
}
|
||||
|
||||
void gpio_config_input_pullup(uint32_t gpio_num)
|
||||
{
|
||||
gpio_config_pad_input_pullup(gpio_num);
|
||||
gpio_config_funcsel(gpio_num);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @file rp2350_led.c
|
||||
* @brief LED driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* High-level wrapper around the GPIO driver for LED control.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_gpio.h"
|
||||
|
||||
void led_init(uint32_t pin)
|
||||
{
|
||||
gpio_config(pin);
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
void led_on(uint32_t pin)
|
||||
{
|
||||
gpio_set(pin);
|
||||
}
|
||||
|
||||
void led_off(uint32_t pin)
|
||||
{
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
void led_toggle(uint32_t pin)
|
||||
{
|
||||
gpio_toggle(pin);
|
||||
}
|
||||
|
||||
bool led_get_state(uint32_t pin)
|
||||
{
|
||||
return gpio_get(pin);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file rp2350_reset.c
|
||||
* @brief Reset controller driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Releases IO_BANK0 from reset and waits until the subsystem
|
||||
* is ready.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = RESETS->RESET;
|
||||
value &= ~(1U << RESETS_RESET_IO_BANK0_SHIFT);
|
||||
RESETS->RESET = value;
|
||||
while ((RESETS->RESET_DONE & (1U << RESETS_RESET_IO_BANK0_SHIFT)) == 0) {}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file rp2350_reset_handler.c
|
||||
* @brief Reset handler implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Entry point after power-on or system reset. Initializes the
|
||||
* stack, XOSC, subsystem resets, UART, then branches
|
||||
* to main().
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_reset_handler.h"
|
||||
#include "rp2350_stack.h"
|
||||
#include "rp2350_xosc.h"
|
||||
#include "rp2350_reset.h"
|
||||
#include "rp2350_uart.h"
|
||||
|
||||
extern int main(void);
|
||||
|
||||
extern uint32_t __data_lma;
|
||||
extern uint32_t __data_start;
|
||||
extern uint32_t __data_end;
|
||||
extern uint32_t __bss_start;
|
||||
extern uint32_t __bss_end;
|
||||
|
||||
static void _data_copy_init(void)
|
||||
{
|
||||
uint32_t *src = &__data_lma;
|
||||
uint32_t *dst = &__data_start;
|
||||
while (dst < &__data_end)
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
||||
static void _bss_zero_init(void)
|
||||
{
|
||||
uint32_t *dst = &__bss_start;
|
||||
while (dst < &__bss_end)
|
||||
*dst++ = 0U;
|
||||
}
|
||||
|
||||
void _ram_init(void)
|
||||
{
|
||||
stack_init();
|
||||
_data_copy_init();
|
||||
_bss_zero_init();
|
||||
}
|
||||
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
"bl _ram_init\n\t"
|
||||
"bl xosc_init\n\t"
|
||||
"bl xosc_enable_peri_clk\n\t"
|
||||
"bl reset_init_subsystem\n\t"
|
||||
"bl uart_release_reset\n\t"
|
||||
"bl uart_init\n\t"
|
||||
"b main\n\t"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file rp2350_stack.c
|
||||
* @brief Stack pointer initialization for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Sets MSP, PSP, MSPLIM, and PSPLIM using inline assembly.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
"ldr r0, =%0\n\t"
|
||||
"msr PSP, r0\n\t"
|
||||
"ldr r0, =%1\n\t"
|
||||
"msr MSPLIM, r0\n\t"
|
||||
"msr PSPLIM, r0\n\t"
|
||||
"ldr r0, =%0\n\t"
|
||||
"msr MSP, r0\n\t"
|
||||
:
|
||||
: "i" (STACK_TOP), "i" (STACK_LIMIT)
|
||||
: "r0"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file rp2350_uart.c
|
||||
* @brief UART0 driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Configures UART0 on GPIO 0 (TX) and GPIO 1 (RX) at 115200
|
||||
* baud using the 12 MHz XOSC clock.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_uart.h"
|
||||
|
||||
/** @brief Base address pointer for UART0 peripheral registers */
|
||||
#define UART_BASE ((volatile uint32_t *) UART0_BASE)
|
||||
|
||||
/**
|
||||
* @brief Clear the UART0 reset bit in the reset controller.
|
||||
* @retval None
|
||||
*/
|
||||
static void uart_clear_reset_bit(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = RESETS->RESET;
|
||||
value &= ~(1U << RESETS_RESET_UART0_SHIFT);
|
||||
RESETS->RESET = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait until the UART0 block is out of reset.
|
||||
* @retval None
|
||||
*/
|
||||
static void uart_wait_reset_done(void)
|
||||
{
|
||||
while ((RESETS->RESET_DONE & (1U << RESETS_RESET_UART0_SHIFT)) == 0) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure GPIO pins 0 (TX) and 1 (RX) for UART function.
|
||||
* @retval None
|
||||
*/
|
||||
static void uart_configure_pins(void)
|
||||
{
|
||||
IO_BANK0->GPIO[0].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
IO_BANK0->GPIO[1].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
PADS_BANK0->GPIO[0] = 0x04;
|
||||
PADS_BANK0->GPIO[1] = 0x40;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set UART0 baud rate divisors for 115200 at 12 MHz.
|
||||
* @retval None
|
||||
*/
|
||||
static void uart_set_baud(void)
|
||||
{
|
||||
UART_BASE[UART_CR_OFFSET] = 0;
|
||||
UART_BASE[UART_IBRD_OFFSET] = 6;
|
||||
UART_BASE[UART_FBRD_OFFSET] = 33;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure line control and enable UART0.
|
||||
* @retval None
|
||||
*/
|
||||
static void uart_enable(void)
|
||||
{
|
||||
UART_BASE[UART_LCR_H_OFFSET] = UART_LCR_H_8N1_FIFO;
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
uart_clear_reset_bit();
|
||||
uart_wait_reset_done();
|
||||
}
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
uart_configure_pins();
|
||||
uart_set_baud();
|
||||
uart_enable();
|
||||
}
|
||||
|
||||
bool uart_is_readable(void)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {}
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {}
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)c;
|
||||
}
|
||||
|
||||
void uart_puts(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
uart_putchar(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
char uart_to_upper(char c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return (char)(c - 32);
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file rp2350_xosc.c
|
||||
* @brief XOSC driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Configures the external crystal oscillator and enables the
|
||||
* peripheral clock sourced from XOSC.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
XOSC->CTRL = 0x00FABAA0U;
|
||||
while ((XOSC->STATUS & (1U << XOSC_STATUS_STABLE_SHIFT)) == 0) {}
|
||||
}
|
||||
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = CLOCKS->CLK_PERI_CTRL;
|
||||
value |= (1U << CLK_PERI_CTRL_ENABLE_SHIFT);
|
||||
value |= (CLK_PERI_CTRL_AUXSRC_XOSC << CLK_PERI_CTRL_AUXSRC_SHIFT);
|
||||
CLOCKS->CLK_PERI_CTRL = value;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file vector_table.c
|
||||
* @brief Vector table with initial stack pointer and reset handler.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Placed in the .vectors section at the start of flash.
|
||||
* The Thumb bit (bit 0 = 1) is automatically set by the
|
||||
* linker for function pointers in Thumb mode.
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t _stack_top;
|
||||
extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
Reset_Handler
|
||||
};
|
||||
Binary file not shown.
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file linker.ld
|
||||
* @author Kevin Thomas
|
||||
* @brief Minimal linker script for bare-metal RP2350 development.
|
||||
*
|
||||
* Defines FLASH (XIP 32 MB) and RAM (520 kB SRAM) regions.
|
||||
* The vector table is placed at the start of flash (0x10000000).
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 Kevin Thomas.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Entry point.
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/**
|
||||
* Define memory regions.
|
||||
*/
|
||||
__XIP_BASE = 0x10000000;
|
||||
__XIP_SIZE = 32M;
|
||||
|
||||
__SRAM_BASE = 0x20000000;
|
||||
__SRAM_SIZE = 520K;
|
||||
__STACK_SIZE = 32K;
|
||||
|
||||
/**
|
||||
* Memory layout.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
RAM (rwx) : ORIGIN = __SRAM_BASE, LENGTH = __SRAM_SIZE
|
||||
FLASH (rx) : ORIGIN = __XIP_BASE, LENGTH = __XIP_SIZE
|
||||
}
|
||||
|
||||
/**
|
||||
* Program headers.
|
||||
*/
|
||||
PHDRS
|
||||
{
|
||||
text PT_LOAD FLAGS(5);
|
||||
data PT_LOAD FLAGS(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Section placement.
|
||||
*/
|
||||
SECTIONS
|
||||
{
|
||||
. = ORIGIN(FLASH);
|
||||
|
||||
/**
|
||||
* Vector table MUST be first at 0x10000000.
|
||||
*/
|
||||
.vectors :
|
||||
{
|
||||
KEEP(*(.vectors))
|
||||
} > FLASH :text
|
||||
|
||||
/**
|
||||
* Verify vector table placement.
|
||||
*/
|
||||
ASSERT((ADDR(.vectors) == ORIGIN(FLASH)),
|
||||
"Vector table must be at start of flash (0x10000000)")
|
||||
|
||||
/**
|
||||
* Text and read-only data.
|
||||
*/
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
KEEP(*(.ARM.attributes))
|
||||
} > FLASH :text
|
||||
|
||||
/**
|
||||
* IMAGE_DEF block at end of code.
|
||||
*/
|
||||
.embedded_block :
|
||||
{
|
||||
KEEP(*(.embedded_block))
|
||||
} > FLASH :text
|
||||
|
||||
/**
|
||||
* Initialized data and RAM-resident code (LMA in flash, VMA in RAM).
|
||||
* Startup copies from __data_lma to __data_start..__data_end.
|
||||
*/
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__data_start = .;
|
||||
*(.ram_func*)
|
||||
*(.data*)
|
||||
. = ALIGN(4);
|
||||
__data_end = .;
|
||||
} > RAM AT> FLASH :data
|
||||
|
||||
__data_lma = LOADADDR(.data);
|
||||
|
||||
/**
|
||||
* Uninitialized data (BSS) in RAM.
|
||||
*/
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
} > RAM
|
||||
|
||||
/**
|
||||
* Non-secure stack symbols.
|
||||
*/
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - __STACK_SIZE;
|
||||
__stack = __StackTop;
|
||||
_stack_top = __StackTop;
|
||||
|
||||
/**
|
||||
* Stack section (no load).
|
||||
*/
|
||||
.stack (NOLOAD) : { . = ALIGN(8); } > RAM
|
||||
|
||||
/**
|
||||
* Provide vector table symbol to startup code.
|
||||
*/
|
||||
PROVIDE(__Vectors = ADDR(.vectors));
|
||||
}
|
||||
Reference in New Issue
Block a user