mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-07-16 08:57:26 +02:00
style: enforce coding standard — headers, @brief on #define, Doxygen on statics, remove _ prefix, max 8 lines per function
This commit is contained in:
@@ -1,25 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file image_def.c
|
||||
* @author Kevin Thomas
|
||||
* @brief RP2350 IMAGE_DEF block for boot ROM image recognition.
|
||||
*
|
||||
* Must appear within the first 4 KB of flash for the boot ROM
|
||||
* to accept the image.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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))
|
||||
|
||||
@@ -1,41 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file main.c
|
||||
* @author Kevin Thomas
|
||||
* @brief LCD1602 demonstration: static title and live counter display.
|
||||
*
|
||||
* Drives a 16x2 HD44780 LCD via a PCF8574 I2C backpack. Line 0
|
||||
* shows a static title ("Reverse Eng.") and line 1 displays a
|
||||
* counter that increments every second. The counter value is
|
||||
* also printed over UART for debugging.
|
||||
*
|
||||
* Wiring:
|
||||
* GPIO0 -> UART TX (USB-to-UART adapter RX)
|
||||
* GPIO1 -> UART RX (USB-to-UART adapter TX)
|
||||
* GPIO2 -> PCF8574 backpack SDA (4.7 kohm pull-up to 3.3 V)
|
||||
* GPIO3 -> PCF8574 backpack SCL (4.7 kohm pull-up to 3.3 V)
|
||||
* 3.3V -> PCF8574 backpack VCC
|
||||
* GND -> PCF8574 backpack GND
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @file main.c
|
||||
* @brief LCD1602 demonstration: static title and live counter display.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Drives a 16x2 HD44780 LCD via a PCF8574 I2C backpack. Line 0
|
||||
* shows a static title ("Reverse Eng.") and line 1 displays a
|
||||
* counter that increments every second. The counter value is
|
||||
* also printed over UART for debugging.
|
||||
*
|
||||
* Wiring:
|
||||
* GPIO0 -> UART TX (USB-to-UART adapter RX)
|
||||
* GPIO1 -> UART RX (USB-to-UART adapter TX)
|
||||
* GPIO2 -> PCF8574 backpack SDA (4.7 kohm pull-up to 3.3 V)
|
||||
* GPIO3 -> PCF8574 backpack SCL (4.7 kohm pull-up to 3.3 V)
|
||||
* 3.3V -> PCF8574 backpack VCC
|
||||
* GND -> PCF8574 backpack 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.
|
||||
*/
|
||||
#include "rp2350_i2c.h"
|
||||
#include "rp2350_lcd1602.h"
|
||||
#include "rp2350_uart.h"
|
||||
#include "rp2350_xosc.h"
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/** @brief Delay between LCD counter updates in milliseconds */
|
||||
#define COUNT_DELAY_MS 1000
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_delay.c
|
||||
* @author Kevin Thomas
|
||||
* @brief Delay driver implementation for RP2350.
|
||||
*
|
||||
* Busy-wait millisecond and microsecond delays calibrated for
|
||||
* a 12 MHz clock.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @file rp2350_delay.c
|
||||
* @brief Delay driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Busy-wait millisecond and microsecond delays 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.
|
||||
*/
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
void delay_ms(uint32_t ms)
|
||||
|
||||
@@ -1,28 +1,37 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_i2c.c
|
||||
* @author Kevin Thomas
|
||||
* @brief RP2350 I2C1 master-mode driver implementation.
|
||||
*
|
||||
* Bare-metal driver for the RP2350 Synopsys DW APB I2C controller.
|
||||
* Configures I2C1 at 100 kHz on SDA=GPIO2 / SCL=GPIO3 with
|
||||
* internal pull-ups. Provides target selection and single-byte
|
||||
* write. All register accesses verified against the RP2350
|
||||
* datasheet (RP-008373-DS-2).
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @file rp2350_i2c.c
|
||||
* @brief RP2350 I2C1 master-mode driver implementation.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Bare-metal driver for the RP2350 Synopsys DW APB I2C controller.
|
||||
* Configures I2C1 at 100 kHz on SDA=GPIO2 / SCL=GPIO3 with
|
||||
* internal pull-ups. Provides target selection and single-byte
|
||||
* write. All register accesses 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_i2c.h"
|
||||
|
||||
/**
|
||||
@@ -33,7 +42,7 @@
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
static void _i2c_config_pads(void)
|
||||
static void i2c_config_pads(void)
|
||||
{
|
||||
uint32_t pad_val = (1U << PADS_BANK0_IE_SHIFT) | (1U << PADS_BANK0_PUE_SHIFT) | (1U << 4);
|
||||
PADS_BANK0->GPIO[I2C_SDA_PIN] = pad_val;
|
||||
@@ -44,7 +53,7 @@ static void _i2c_config_pads(void)
|
||||
* @brief Set GPIO2 and GPIO3 IO mux function to I2C (FUNCSEL=3).
|
||||
* @retval None
|
||||
*/
|
||||
static void _i2c_config_gpio(void)
|
||||
static void i2c_config_gpio(void)
|
||||
{
|
||||
IO_BANK0->GPIO[I2C_SDA_PIN].CTRL = IO_BANK0_CTRL_FUNCSEL_I2C;
|
||||
IO_BANK0->GPIO[I2C_SCL_PIN].CTRL = IO_BANK0_CTRL_FUNCSEL_I2C;
|
||||
@@ -58,7 +67,7 @@ static void _i2c_config_gpio(void)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
static void _i2c_config_con(void)
|
||||
static void i2c_config_con(void)
|
||||
{
|
||||
I2C1->CON = (1U << I2C_CON_MASTER_MODE_SHIFT)
|
||||
| (I2C_CON_SPEED_FAST << I2C_CON_SPEED_SHIFT)
|
||||
@@ -75,7 +84,7 @@ static void _i2c_config_con(void)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
static void _i2c_config_timing(void)
|
||||
static void i2c_config_timing(void)
|
||||
{
|
||||
I2C1->FS_SCL_HCNT = I2C_FS_SCL_HCNT_VAL;
|
||||
I2C1->FS_SCL_LCNT = I2C_FS_SCL_LCNT_VAL;
|
||||
@@ -115,7 +124,7 @@ static bool check_stop(void)
|
||||
* @brief Wait for a STOP_DET or TX_ABRT interrupt, then clear it.
|
||||
* @retval None
|
||||
*/
|
||||
static void _i2c_wait_done(void)
|
||||
static void i2c_wait_done(void)
|
||||
{
|
||||
uint32_t timeout = I2C_TIMEOUT;
|
||||
while (timeout > 0U)
|
||||
@@ -135,13 +144,13 @@ void i2c_release_reset(void)
|
||||
|
||||
void i2c_init(void)
|
||||
{
|
||||
_i2c_config_pads();
|
||||
_i2c_config_gpio();
|
||||
i2c_config_pads();
|
||||
i2c_config_gpio();
|
||||
I2C1->ENABLE = 0U;
|
||||
_i2c_config_con();
|
||||
i2c_config_con();
|
||||
I2C1->TX_TL = 0U;
|
||||
I2C1->RX_TL = 0U;
|
||||
_i2c_config_timing();
|
||||
i2c_config_timing();
|
||||
I2C1->ENABLE = 1U;
|
||||
}
|
||||
|
||||
@@ -156,5 +165,5 @@ void i2c_write_byte(uint8_t data)
|
||||
{
|
||||
(void)I2C1->CLR_TX_ABRT;
|
||||
I2C1->DATA_CMD = data | (1U << I2C_DATA_CMD_STOP_SHIFT);
|
||||
_i2c_wait_done();
|
||||
i2c_wait_done();
|
||||
}
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_lcd1602.c
|
||||
* @author Kevin Thomas
|
||||
* @brief LCD1602 driver implementation for RP2350.
|
||||
*
|
||||
* Drives a 16x2 HD44780 LCD through a PCF8574 I2C backpack
|
||||
* in 4-bit mode. Each nibble is latched by pulsing the EN
|
||||
* line via single-byte I2C writes to the PCF8574. All
|
||||
* timing margins exceed HD44780 datasheet minimums.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @file rp2350_lcd1602.c
|
||||
* @brief LCD1602 driver implementation for RP2350.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* Drives a 16x2 HD44780 LCD through a PCF8574 I2C backpack
|
||||
* in 4-bit mode. Each nibble is latched by pulsing the EN
|
||||
* line via single-byte I2C writes to the PCF8574. All
|
||||
* timing margins exceed HD44780 datasheet minimums.
|
||||
*
|
||||
* 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_lcd1602.h"
|
||||
#include "rp2350_i2c.h"
|
||||
#include "rp2350_delay.h"
|
||||
@@ -49,7 +58,7 @@ static void lcd_pulse_enable(uint8_t data)
|
||||
* @param mode 0 for command, non-zero for character data
|
||||
* @retval None
|
||||
*/
|
||||
static void _lcd_write4(uint8_t nibble, uint8_t mode)
|
||||
static void lcd_write4(uint8_t nibble, uint8_t mode)
|
||||
{
|
||||
uint8_t data = (nibble & 0x0FU) << LCD_NIBBLE_SHIFT;
|
||||
data |= mode ? LCD_PIN_RS : 0U;
|
||||
@@ -65,8 +74,8 @@ static void _lcd_write4(uint8_t nibble, uint8_t mode)
|
||||
*/
|
||||
static void lcd_send(uint8_t value, uint8_t mode)
|
||||
{
|
||||
_lcd_write4((value >> 4) & 0x0FU, mode);
|
||||
_lcd_write4(value & 0x0FU, mode);
|
||||
lcd_write4((value >> 4) & 0x0FU, mode);
|
||||
lcd_write4(value & 0x0FU, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,15 +86,15 @@ static void lcd_send(uint8_t value, uint8_t mode)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
static void _lcd_hd44780_reset(void)
|
||||
static void lcd_hd44780_reset(void)
|
||||
{
|
||||
_lcd_write4(0x03, 0);
|
||||
lcd_write4(0x03, 0);
|
||||
delay_ms(5);
|
||||
_lcd_write4(0x03, 0);
|
||||
lcd_write4(0x03, 0);
|
||||
delay_us(150);
|
||||
_lcd_write4(0x03, 0);
|
||||
lcd_write4(0x03, 0);
|
||||
delay_us(150);
|
||||
_lcd_write4(0x02, 0);
|
||||
lcd_write4(0x02, 0);
|
||||
delay_us(150);
|
||||
}
|
||||
|
||||
@@ -98,7 +107,7 @@ static void _lcd_hd44780_reset(void)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
static void _lcd_hd44780_configure(void)
|
||||
static void lcd_hd44780_configure(void)
|
||||
{
|
||||
lcd_send(LCD_CMD_FUNCTION_SET_4BIT, 0);
|
||||
lcd_send(LCD_CMD_DISPLAY_ON, 0);
|
||||
@@ -110,8 +119,8 @@ static void _lcd_hd44780_configure(void)
|
||||
void lcd_init(void)
|
||||
{
|
||||
i2c_set_target(LCD_I2C_ADDR);
|
||||
_lcd_hd44780_reset();
|
||||
_lcd_hd44780_configure();
|
||||
lcd_hd44780_reset();
|
||||
lcd_hd44780_configure();
|
||||
}
|
||||
|
||||
void lcd_clear(void)
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_reset.c
|
||||
* @author Kevin Thomas
|
||||
* @brief Reset controller driver implementation for RP2350.
|
||||
*
|
||||
* Releases IO_BANK0 from reset and waits until the subsystem
|
||||
* is ready.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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)
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_reset_handler.c
|
||||
* @author Kevin Thomas
|
||||
* @brief Reset handler implementation for RP2350.
|
||||
*
|
||||
* Entry point after power-on or system reset. Initializes the
|
||||
* stack, XOSC, subsystem resets, UART, then branches
|
||||
* to main().
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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"
|
||||
|
||||
@@ -1,24 +1,33 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_stack.c
|
||||
* @author Kevin Thomas
|
||||
* @brief Stack pointer initialization for RP2350.
|
||||
*
|
||||
* Sets MSP, PSP, MSPLIM, and PSPLIM using inline assembly.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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)
|
||||
|
||||
@@ -1,27 +1,37 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_uart.c
|
||||
* @author Kevin Thomas
|
||||
* @brief UART0 driver implementation for RP2350.
|
||||
*
|
||||
* Configures UART0 on GPIO 0 (TX) and GPIO 1 (RX) at 115200
|
||||
* baud using the 12 MHz XOSC clock.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rp2350_xosc.c
|
||||
* @author Kevin Thomas
|
||||
* @brief XOSC driver implementation for RP2350.
|
||||
*
|
||||
* Configures the external crystal oscillator and enables the
|
||||
* peripheral clock sourced from XOSC.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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)
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file vector_table.c
|
||||
* @author Kevin Thomas
|
||||
* @brief Vector table with initial stack pointer and reset handler.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
* @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;
|
||||
|
||||
Reference in New Issue
Block a user