mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-04-21 10:36:03 +02:00
fix: remove duplicate docstrings from public functions in .c files
Public function docstrings belong exclusively in .h headers per coding convention. Only static helper functions and static variables retain docstrings in .c files. Removed 413 duplicate docstrings across 185 files (15 CBM + 15 C SDK projects). All 30 projects rebuild with zero errors.
This commit is contained in:
@@ -49,14 +49,6 @@
|
||||
/** @brief UART baud rate in bits per second */
|
||||
#define UART_BAUD 115200
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the UART uppercase echo demo
|
||||
*
|
||||
* Initializes UART0 and enters an infinite loop that reads incoming
|
||||
* characters, converts them to uppercase, and echoes them back.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
uart_driver_init(UART_TX_PIN, UART_RX_PIN, UART_BAUD);
|
||||
uart_driver_puts("UART driver ready (115200 8N1)\r\n");
|
||||
|
||||
@@ -35,63 +35,30 @@
|
||||
/** @brief Hardware UART instance used by this driver */
|
||||
#define UART_INST uart0
|
||||
|
||||
/**
|
||||
* @brief Initialize hardware UART0 on the specified TX and RX GPIO pins
|
||||
*
|
||||
* @param tx_pin GPIO pin number to use as UART0 TX
|
||||
* @param rx_pin GPIO pin number to use as UART0 RX
|
||||
* @param baud_rate Desired baud rate in bits per second
|
||||
*/
|
||||
void uart_driver_init(uint32_t tx_pin, uint32_t rx_pin, uint32_t baud_rate) {
|
||||
uart_init(UART_INST, baud_rate);
|
||||
gpio_set_function(tx_pin, GPIO_FUNC_UART);
|
||||
gpio_set_function(rx_pin, GPIO_FUNC_UART);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check whether a received character is waiting in the UART FIFO
|
||||
*
|
||||
* @return bool true if at least one byte is available to read
|
||||
*/
|
||||
bool uart_driver_is_readable(void) {
|
||||
return uart_is_readable(UART_INST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking)
|
||||
*
|
||||
* @return char The received character
|
||||
*/
|
||||
char uart_driver_getchar(void) {
|
||||
return (char)uart_getc(UART_INST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking)
|
||||
*
|
||||
* @param c Character to transmit
|
||||
*/
|
||||
void uart_driver_putchar(char c) {
|
||||
uart_putc_raw(UART_INST, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit a null-terminated string over UART0
|
||||
*
|
||||
* @param str Pointer to the string to transmit
|
||||
*/
|
||||
void uart_driver_puts(const char *str) {
|
||||
while (*str) {
|
||||
uart_putc_raw(UART_INST, *str++);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert a character to uppercase
|
||||
*
|
||||
* @param c Character to convert
|
||||
* @return char Uppercase version if 'a'-'z', otherwise unchanged
|
||||
*/
|
||||
char uart_driver_to_upper(char c) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return (char)(c - 32);
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#include "rp2350_uart.h"
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the UART uppercase echo demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
uart_puts("UART driver ready (115200 8N1)\r\n");
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -45,14 +45,6 @@
|
||||
/** @brief Delay between blink toggles in milliseconds */
|
||||
#define BLINK_DELAY_MS 500
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the LED blink demo
|
||||
*
|
||||
* Initializes the onboard LED and enters an infinite loop that
|
||||
* toggles the LED state every BLINK_DELAY_MS milliseconds.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
blink_init(LED_PIN);
|
||||
|
||||
@@ -37,39 +37,18 @@ void blink_init(uint32_t pin) {
|
||||
gpio_put(pin, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on)
|
||||
*
|
||||
* @param pin GPIO pin number
|
||||
*/
|
||||
void blink_on(uint32_t pin) {
|
||||
gpio_put(pin, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off)
|
||||
*
|
||||
* @param pin GPIO pin number
|
||||
*/
|
||||
void blink_off(uint32_t pin) {
|
||||
gpio_put(pin, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin
|
||||
*
|
||||
* @param pin GPIO pin number
|
||||
*/
|
||||
void blink_toggle(uint32_t pin) {
|
||||
gpio_put(pin, !gpio_get(pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query the current drive state of the output pin
|
||||
*
|
||||
* @param pin GPIO pin number
|
||||
* @return bool true if the pin is driven high, false if low
|
||||
*/
|
||||
bool blink_get_state(uint32_t pin) {
|
||||
return (bool)gpio_get(pin);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -40,10 +40,6 @@ static void _print_led_state(uint32_t pin)
|
||||
uart_puts("LED: OFF\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the LED blink demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
led_init(LED_PIN);
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -62,11 +62,6 @@ static void _gpio_enable_output(uint32_t gpio_num)
|
||||
SIO[SIO_GPIO_OE_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
_gpio_config_pad(gpio_num);
|
||||
@@ -74,41 +69,21 @@ void gpio_config(uint32_t gpio_num)
|
||||
_gpio_enable_output(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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_SET_OFFSET] = (1U << 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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_CLR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle a GPIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_toggle(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_XOR_OFFSET] = (1U << 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)
|
||||
{
|
||||
return (SIO[SIO_GPIO_IN_OFFSET] & (1U << gpio_num)) != 0;
|
||||
|
||||
@@ -22,52 +22,27 @@
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_gpio.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)
|
||||
{
|
||||
gpio_config(pin);
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_on(uint32_t pin)
|
||||
{
|
||||
gpio_set(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_off(uint32_t pin)
|
||||
{
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_toggle(uint32_t pin)
|
||||
{
|
||||
gpio_toggle(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)
|
||||
{
|
||||
return gpio_get(pin);
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -66,14 +66,6 @@ static void _poll_button(bool *last_state) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the button debounce demo
|
||||
*
|
||||
* Initializes button and LED, then continuously polls button state
|
||||
* and mirrors it to the LED with UART reporting on edge transitions.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
button_init(BUTTON_PIN, DEBOUNCE_MS);
|
||||
|
||||
@@ -49,12 +49,6 @@ static bool _debounce_confirm(uint32_t pin) {
|
||||
return !gpio_get(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
void button_init(uint32_t pin, uint32_t debounce_ms) {
|
||||
debounce_delay_ms = debounce_ms;
|
||||
gpio_init(pin);
|
||||
@@ -62,12 +56,6 @@ void button_init(uint32_t pin, uint32_t debounce_ms) {
|
||||
gpio_pull_up(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the debounced state of the button
|
||||
*
|
||||
* @param pin GPIO pin number previously initialized with button_init()
|
||||
* @return bool true if the button is firmly pressed, false if released
|
||||
*/
|
||||
bool button_is_pressed(uint32_t pin) {
|
||||
if (!gpio_get(pin)) {
|
||||
return _debounce_confirm(pin);
|
||||
@@ -75,23 +63,12 @@ bool button_is_pressed(uint32_t pin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize a GPIO pin as a push-pull digital output for an indicator LED
|
||||
*
|
||||
* @param pin GPIO pin number to configure as an LED output
|
||||
*/
|
||||
void button_led_init(uint32_t pin) {
|
||||
gpio_init(pin);
|
||||
gpio_set_dir(pin, GPIO_OUT);
|
||||
gpio_put(pin, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the indicator LED state
|
||||
*
|
||||
* @param pin GPIO pin number
|
||||
* @param on true to turn the LED on, false to turn it off
|
||||
*/
|
||||
void button_led_set(uint32_t pin, bool on) {
|
||||
gpio_put(pin, on);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -77,10 +77,6 @@ static void _poll_button(bool *last_state)
|
||||
_report_edge(pressed, last_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the button debounce demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
button_init(BUTTON_PIN, DEBOUNCE_MS);
|
||||
|
||||
@@ -38,23 +38,12 @@ static bool _debounce_confirm(uint32_t pin)
|
||||
return !gpio_get(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
debounce_delay_ms = debounce_ms;
|
||||
gpio_config_input_pullup(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if (!gpio_get(pin))
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -78,11 +78,6 @@ static void _gpio_enable_output(uint32_t gpio_num)
|
||||
SIO[SIO_GPIO_OE_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
_gpio_config_pad(gpio_num);
|
||||
@@ -90,51 +85,26 @@ void gpio_config(uint32_t gpio_num)
|
||||
_gpio_enable_output(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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_SET_OFFSET] = (1U << 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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_CLR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle a GPIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_toggle(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_XOR_OFFSET] = (1U << 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)
|
||||
{
|
||||
return (SIO[SIO_GPIO_IN_OFFSET] & (1U << gpio_num)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
_gpio_config_pad_input_pullup(gpio_num);
|
||||
|
||||
@@ -22,52 +22,27 @@
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_gpio.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)
|
||||
{
|
||||
gpio_config(pin);
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_on(uint32_t pin)
|
||||
{
|
||||
gpio_set(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_off(uint32_t pin)
|
||||
{
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_toggle(uint32_t pin)
|
||||
{
|
||||
gpio_toggle(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)
|
||||
{
|
||||
return gpio_get(pin);
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -66,15 +66,6 @@ static void _sweep_duty(int start, int end, int step) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the PWM LED breathing demo
|
||||
*
|
||||
* Initializes PWM at 1 kHz on the onboard LED and enters an infinite
|
||||
* loop that sweeps the duty cycle up and down to produce a smooth
|
||||
* breathing effect, reporting each step over UART.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
pwm_driver_init(PWM_PIN, PWM_FREQ_HZ);
|
||||
|
||||
@@ -71,12 +71,6 @@ static void _apply_pwm_config(uint32_t freq_hz) {
|
||||
pwm_set_chan_level(pwm_slice, pwm_chan, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize PWM output on the specified GPIO pin
|
||||
*
|
||||
* @param pin GPIO pin number to drive with PWM output
|
||||
* @param freq_hz Desired PWM frequency in Hz
|
||||
*/
|
||||
void pwm_driver_init(uint32_t pin, uint32_t freq_hz) {
|
||||
gpio_set_function(pin, GPIO_FUNC_PWM);
|
||||
pwm_slice = pwm_gpio_to_slice_num(pin);
|
||||
@@ -85,11 +79,6 @@ void pwm_driver_init(uint32_t pin, uint32_t freq_hz) {
|
||||
_apply_pwm_config(freq_hz);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the PWM duty cycle as an integer percentage
|
||||
*
|
||||
* @param percent Duty cycle from 0 (always low) to 100 (always high)
|
||||
*/
|
||||
void pwm_driver_set_duty_percent(uint8_t percent) {
|
||||
if (percent > 100) {
|
||||
percent = 100;
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -91,10 +91,6 @@ static void _sweep_down(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the PWM LED breathing demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
uart_puts("PWM initialized: GPIO25\r\n");
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -62,11 +62,6 @@ static void _gpio_enable_output(uint32_t gpio_num)
|
||||
SIO[SIO_GPIO_OE_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
_gpio_config_pad(gpio_num);
|
||||
@@ -74,41 +69,21 @@ void gpio_config(uint32_t gpio_num)
|
||||
_gpio_enable_output(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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_SET_OFFSET] = (1U << 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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_CLR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle a GPIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_toggle(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_XOR_OFFSET] = (1U << 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)
|
||||
{
|
||||
return (SIO[SIO_GPIO_IN_OFFSET] & (1U << gpio_num)) != 0;
|
||||
|
||||
@@ -22,52 +22,27 @@
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_gpio.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)
|
||||
{
|
||||
gpio_config(pin);
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_on(uint32_t pin)
|
||||
{
|
||||
gpio_set(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_off(uint32_t pin)
|
||||
{
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_toggle(uint32_t pin)
|
||||
{
|
||||
gpio_toggle(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)
|
||||
{
|
||||
return gpio_get(pin);
|
||||
|
||||
@@ -102,20 +102,12 @@ static void _pwm_enable(void)
|
||||
PWM[PWM_REG(PWM_CH_CSR_OFFSET)] = (1U << PWM_CSR_EN_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release PWM from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void pwm_release_reset(void)
|
||||
{
|
||||
_pwm_clear_reset_bit();
|
||||
_pwm_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize PWM on GPIO 25 at approximately 1 kHz.
|
||||
* @retval None
|
||||
*/
|
||||
void pwm_init(void)
|
||||
{
|
||||
_pwm_configure_pin();
|
||||
@@ -124,11 +116,6 @@ void pwm_init(void)
|
||||
_pwm_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the PWM duty cycle as an integer percentage.
|
||||
* @param percent duty cycle from 0 (off) to 100 (fully on)
|
||||
* @retval None
|
||||
*/
|
||||
void pwm_set_duty(uint8_t percent)
|
||||
{
|
||||
uint32_t level;
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -30,20 +30,12 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize late peripherals (PWM release and init).
|
||||
* @retval None
|
||||
*/
|
||||
void _late_init(void)
|
||||
{
|
||||
pwm_release_reset();
|
||||
pwm_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -68,14 +68,6 @@ static void _sweep_angle(int start, int end, int step) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the servo sweep demo
|
||||
*
|
||||
* Initializes the servo on GPIO and continuously sweeps 0-180-0 degrees
|
||||
* in STEP_DEGREES increments, reporting each angle over UART.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
servo_init(SERVO_GPIO);
|
||||
|
||||
@@ -81,11 +81,6 @@ static void _apply_servo_config(void) {
|
||||
pwm_init(servo_slice, &config, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize servo driver on a given GPIO pin
|
||||
*
|
||||
* @param pin GPIO pin number to use for servo PWM
|
||||
*/
|
||||
void servo_init(uint8_t pin) {
|
||||
servo_pin = pin;
|
||||
gpio_set_function(servo_pin, GPIO_FUNC_PWM);
|
||||
@@ -95,11 +90,6 @@ void servo_init(uint8_t pin) {
|
||||
servo_initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set servo pulse width in microseconds
|
||||
*
|
||||
* @param pulse_us Pulse width in microseconds
|
||||
*/
|
||||
void servo_set_pulse_us(uint16_t pulse_us) {
|
||||
if (!servo_initialized) return;
|
||||
if (pulse_us < SERVO_DEFAULT_MIN_US) pulse_us = SERVO_DEFAULT_MIN_US;
|
||||
@@ -108,11 +98,6 @@ void servo_set_pulse_us(uint16_t pulse_us) {
|
||||
pwm_set_chan_level(servo_slice, servo_chan, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set servo angle in degrees (0 to 180)
|
||||
*
|
||||
* @param degrees Angle in degrees
|
||||
*/
|
||||
void servo_set_angle(float degrees) {
|
||||
if (degrees < 0.0f) degrees = 0.0f;
|
||||
if (degrees > 180.0f) degrees = 180.0f;
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -92,10 +92,6 @@ static void _sweep_down(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the servo sweep demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
uart_puts("Servo driver initialized on GPIO6\r\n");
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -62,11 +62,6 @@ static void _gpio_enable_output(uint32_t gpio_num)
|
||||
SIO[SIO_GPIO_OE_SET_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
_gpio_config_pad(gpio_num);
|
||||
@@ -74,41 +69,21 @@ void gpio_config(uint32_t gpio_num)
|
||||
_gpio_enable_output(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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_SET_OFFSET] = (1U << 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)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_CLR_OFFSET] = (1U << gpio_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle a GPIO output.
|
||||
* @param gpio_num GPIO pin number (0-29)
|
||||
* @retval None
|
||||
*/
|
||||
void gpio_toggle(uint32_t gpio_num)
|
||||
{
|
||||
SIO[SIO_GPIO_OUT_XOR_OFFSET] = (1U << 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)
|
||||
{
|
||||
return (SIO[SIO_GPIO_IN_OFFSET] & (1U << gpio_num)) != 0;
|
||||
|
||||
@@ -22,52 +22,27 @@
|
||||
#include "rp2350_led.h"
|
||||
#include "rp2350_gpio.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)
|
||||
{
|
||||
gpio_config(pin);
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin high (LED on).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_on(uint32_t pin)
|
||||
{
|
||||
gpio_set(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drive the output pin low (LED off).
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_off(uint32_t pin)
|
||||
{
|
||||
gpio_clear(pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle the current state of the output pin.
|
||||
* @param pin GPIO pin number
|
||||
* @retval None
|
||||
*/
|
||||
void led_toggle(uint32_t pin)
|
||||
{
|
||||
gpio_toggle(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)
|
||||
{
|
||||
return gpio_get(pin);
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -30,20 +30,12 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize late peripherals (servo release and init).
|
||||
* @retval None
|
||||
*/
|
||||
void _late_init(void)
|
||||
{
|
||||
servo_release_reset();
|
||||
servo_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -132,20 +132,12 @@ static uint32_t _pulse_us_to_level(uint16_t pulse_us)
|
||||
return ((uint32_t)pulse_us * (SERVO_WRAP + 1)) / 20000U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release PWM from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void servo_release_reset(void)
|
||||
{
|
||||
_servo_clear_reset_bit();
|
||||
_servo_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize servo PWM on GPIO 6 at 50 Hz.
|
||||
* @retval None
|
||||
*/
|
||||
void servo_init(void)
|
||||
{
|
||||
_servo_configure_pin();
|
||||
@@ -154,11 +146,6 @@ void servo_init(void)
|
||||
_servo_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the servo pulse width in microseconds (clamped 1000-2000).
|
||||
* @param pulse_us pulse width in microseconds
|
||||
* @retval None
|
||||
*/
|
||||
void servo_set_pulse_us(uint16_t pulse_us)
|
||||
{
|
||||
uint32_t level;
|
||||
@@ -170,11 +157,6 @@ void servo_set_pulse_us(uint16_t pulse_us)
|
||||
PWM[SERVO_REG(PWM_CH_CC_OFFSET)] = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the servo angle in degrees (clamped 0-180).
|
||||
* @param degrees angle from 0 to 180
|
||||
* @retval None
|
||||
*/
|
||||
void servo_set_angle(uint8_t degrees)
|
||||
{
|
||||
uint16_t pulse;
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -59,14 +59,6 @@ static void _print_adc_readings(void) {
|
||||
printf("ADC0: %4lu mV | Chip temp: %.1f C\r\n", voltage_mv, temp_c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the ADC voltage and temperature demo
|
||||
*
|
||||
* Initializes the ADC on GPIO26 channel 0 and prints readings
|
||||
* every 500 ms over UART.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
adc_driver_init(ADC_GPIO, ADC_CHANNEL);
|
||||
|
||||
@@ -65,12 +65,6 @@ static float _raw_to_celsius(uint16_t raw) {
|
||||
return 27.0f - (voltage - 0.706f) / 0.001721f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the ADC peripheral and configure an analog GPIO pin
|
||||
*
|
||||
* @param gpio GPIO pin number for the analog input
|
||||
* @param channel ADC channel number corresponding to the GPIO
|
||||
*/
|
||||
void adc_driver_init(uint32_t gpio, uint8_t channel) {
|
||||
active_channel = channel;
|
||||
adc_init();
|
||||
@@ -79,20 +73,10 @@ void adc_driver_init(uint32_t gpio, uint8_t channel) {
|
||||
adc_select_input(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform a single ADC conversion and return millivolts
|
||||
*
|
||||
* @return uint32_t Measured voltage in millivolts (0 to 3300)
|
||||
*/
|
||||
uint32_t adc_driver_read_mv(void) {
|
||||
return _raw_to_mv(adc_read());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the on-chip temperature sensor in degrees Celsius
|
||||
*
|
||||
* @return float Die temperature in degrees Celsius
|
||||
*/
|
||||
float adc_driver_read_temp_celsius(void) {
|
||||
adc_select_input(4);
|
||||
float result = _raw_to_celsius(adc_read());
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -95,10 +95,6 @@ static void _print_readings(void)
|
||||
uart_puts(" C\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the ADC voltage and temperature demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
xosc_enable_adc_clk();
|
||||
|
||||
@@ -121,14 +121,6 @@ static int32_t _raw_to_temp_tenths(uint16_t raw)
|
||||
return 270 - (v_mv10 - 7060) * 1000 / 1721;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release the ADC subsystem from reset.
|
||||
*
|
||||
* Clears the ADC bit in the RESETS register and waits until
|
||||
* RESET_DONE confirms the subsystem is running.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void adc_release_reset(void)
|
||||
{
|
||||
RESETS->RESET |= (1U << RESETS_RESET_ADC_SHIFT);
|
||||
@@ -152,16 +144,6 @@ static void _adc_enable(void)
|
||||
ADC->CS |= (1U << ADC_CS_TS_EN_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialise the ADC peripheral for GPIO26 (channel 0).
|
||||
*
|
||||
* Configures GPIO26 pad for analog input (disables digital I/O,
|
||||
* pulls, and pad isolation), sets the IO mux function to NULL,
|
||||
* powers on the ADC, enables the temperature sensor, and selects
|
||||
* channel 0 as the default input.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void adc_init(void)
|
||||
{
|
||||
_adc_config_pad();
|
||||
@@ -171,30 +153,11 @@ void adc_init(void)
|
||||
_adc_select_input(active_channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform a single ADC conversion and return millivolts.
|
||||
*
|
||||
* Triggers a one-shot conversion on the currently selected channel,
|
||||
* waits for the result, and scales the 12-bit value against the
|
||||
* 3.3 V reference.
|
||||
*
|
||||
* @retval uint32_t measured voltage in millivolts (0-3300)
|
||||
*/
|
||||
uint32_t adc_read_mv(void)
|
||||
{
|
||||
return _raw_to_mv(_adc_read_raw());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the on-chip temperature sensor in tenths of degrees Celsius.
|
||||
*
|
||||
* Temporarily switches to ADC channel 4 (temperature sensor),
|
||||
* performs a conversion, applies the RP2350 datasheet formula
|
||||
* T = 27 - (V - 0.706) / 0.001721 using integer arithmetic,
|
||||
* and restores the previously active channel.
|
||||
*
|
||||
* @retval int32_t die temperature in tenths of degrees (e.g. 270 = 27.0 C)
|
||||
*/
|
||||
int32_t adc_read_temp_tenths(void)
|
||||
{
|
||||
_adc_select_input(ADC_TEMP_CHANNEL);
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
@@ -48,10 +40,6 @@ void xosc_enable_peri_clk(void)
|
||||
CLOCKS->CLK_PERI_CTRL = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC ADC clock via CLK_ADC_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_adc_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -53,15 +53,6 @@
|
||||
/** @brief I2C bus clock rate in Hz */
|
||||
#define I2C_BAUD 100000
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the I2C bus scanner demo
|
||||
*
|
||||
* Initializes I2C1 at 100 kHz on SDA=GPIO2 / SCL=GPIO3 and prints
|
||||
* a formatted hex table of all responding device addresses over UART,
|
||||
* repeating every 5 seconds.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
i2c_driver_init(I2C_PORT, I2C_SDA_PIN, I2C_SCL_PIN, I2C_BAUD);
|
||||
|
||||
@@ -43,14 +43,6 @@ static i2c_inst_t *_get_i2c_inst(uint8_t port) {
|
||||
return port == 0 ? i2c0 : i2c1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize an I2C peripheral at the requested baud rate
|
||||
*
|
||||
* @param port I2C port number (0 for i2c0, 1 for i2c1)
|
||||
* @param sda_pin GPIO pin number for SDA
|
||||
* @param scl_pin GPIO pin number for SCL
|
||||
* @param baud_hz Bus clock frequency in Hz
|
||||
*/
|
||||
void i2c_driver_init(uint8_t port, uint32_t sda_pin, uint32_t scl_pin,
|
||||
uint32_t baud_hz) {
|
||||
i2c_inst_t *inst = _get_i2c_inst(port);
|
||||
@@ -61,13 +53,6 @@ void i2c_driver_init(uint8_t port, uint32_t sda_pin, uint32_t scl_pin,
|
||||
gpio_pull_up(scl_pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Probe a 7-bit I2C address and return whether a device responds
|
||||
*
|
||||
* @param port I2C port number (0 for i2c0, 1 for i2c1)
|
||||
* @param addr 7-bit I2C address to probe
|
||||
* @return bool true if a device acknowledged, false otherwise
|
||||
*/
|
||||
bool i2c_driver_probe(uint8_t port, uint8_t addr) {
|
||||
i2c_inst_t *inst = _get_i2c_inst(port);
|
||||
uint8_t dummy;
|
||||
@@ -100,11 +85,6 @@ static void _print_scan_entry(uint8_t port, uint8_t addr) {
|
||||
if (addr % 16 == 15) printf("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Scan all valid 7-bit addresses and print a formatted table
|
||||
*
|
||||
* @param port I2C port number (0 for i2c0, 1 for i2c1)
|
||||
*/
|
||||
void i2c_driver_scan(uint8_t port) {
|
||||
_print_scan_header();
|
||||
for (uint8_t addr = 0; addr < 128; addr++)
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -37,10 +37,6 @@
|
||||
|
||||
#define SCAN_DELAY_MS 5000
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the I2C bus scanner demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
xosc_set_clk_ref();
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
|
||||
@@ -131,10 +131,6 @@ static void _print_scan_entry(uint8_t addr)
|
||||
uart_puts("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release I2C1 from reset and wait for completion.
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_release_reset(void)
|
||||
{
|
||||
RESETS->RESET |= (1U << RESETS_RESET_I2C1_SHIFT);
|
||||
@@ -143,15 +139,6 @@ void i2c_release_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize I2C1 as a 100 kHz master on SDA=GPIO2 / SCL=GPIO3.
|
||||
*
|
||||
* Configures GPIO pads with pull-ups, sets FUNCSEL to I2C,
|
||||
* programs SCL timing for 100 kHz at 12 MHz clk_sys, and
|
||||
* enables the controller in master mode with 7-bit addressing.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_init(void)
|
||||
{
|
||||
_i2c_config_pads();
|
||||
@@ -217,15 +204,6 @@ static void _probe_cleanup(bool aborted)
|
||||
(void)I2C1->DATA_CMD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Probe a 7-bit I2C address and return whether a device responds.
|
||||
*
|
||||
* Sends a 1-byte read to the target address. Returns true if
|
||||
* the device acknowledges, false otherwise.
|
||||
*
|
||||
* @param addr 7-bit I2C address (0x08-0x77)
|
||||
* @retval bool true if a device acknowledged, false otherwise
|
||||
*/
|
||||
bool i2c_probe(uint8_t addr)
|
||||
{
|
||||
_probe_set_target(addr);
|
||||
@@ -235,15 +213,6 @@ bool i2c_probe(uint8_t addr)
|
||||
return !aborted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Scan all valid 7-bit addresses and print a formatted table.
|
||||
*
|
||||
* Iterates addresses 0x00 through 0x7F, probes each valid one
|
||||
* via i2c_probe(), and prints a 16-column hex grid showing
|
||||
* discovered device addresses over UART.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_scan(void)
|
||||
{
|
||||
uart_puts("\r\nI2C bus scan:\r\n");
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_xosc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the external crystal oscillator and wait until stable.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_init(void)
|
||||
{
|
||||
XOSC->STARTUP = 0x00C4U;
|
||||
@@ -34,10 +30,6 @@ void xosc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the XOSC peripheral clock via CLK_PERI_CTRL.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_enable_peri_clk(void)
|
||||
{
|
||||
uint32_t value;
|
||||
@@ -48,10 +40,6 @@ void xosc_enable_peri_clk(void)
|
||||
CLOCKS->CLK_PERI_CTRL = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Switch CLK_REF source to XOSC for a stable 12 MHz clk_sys.
|
||||
* @retval None
|
||||
*/
|
||||
void xosc_set_clk_ref(void)
|
||||
{
|
||||
CLOCKS->CLK_REF_CTRL = CLK_REF_CTRL_SRC_XOSC;
|
||||
|
||||
@@ -28,9 +28,6 @@ extern void Reset_Handler(void);
|
||||
|
||||
typedef void (*vector_func_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Vector table placed in .vectors section
|
||||
*/
|
||||
__attribute__((section(".vectors"), used))
|
||||
const void *_vectors[2] = {
|
||||
&_stack_top,
|
||||
|
||||
@@ -80,14 +80,6 @@ static void _update_counter(uint32_t *count) {
|
||||
sleep_ms(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the LCD 1602 counter demo
|
||||
*
|
||||
* Initializes the LCD over I2C with a static title on line 0 and
|
||||
* continuously increments a counter on line 1 every second.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
_setup_display();
|
||||
|
||||
@@ -150,18 +150,6 @@ static void _lcd_hd44780_configure(void) {
|
||||
_lcd_send(0x06, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the LCD driver over I2C
|
||||
*
|
||||
* Configures the internal driver state and performs the HD44780 initialization
|
||||
* sequence. The driver does not configure I2C pins or call i2c_init; that
|
||||
* must be done by the caller prior to calling this function.
|
||||
*
|
||||
* @param i2c_port I2C port number (0 for i2c0, 1 for i2c1)
|
||||
* @param pcf_addr PCF8574 I2C address (commonly 0x27 or 0x3F)
|
||||
* @param nibble_shift Bit shift applied to 4-bit nibbles (commonly 4 or 0)
|
||||
* @param backlight_mask PCF8574 bit mask that controls the backlight
|
||||
*/
|
||||
void lcd_i2c_init(uint8_t i2c_port, uint8_t pcf_addr, int nibble_shift,
|
||||
uint8_t backlight_mask) {
|
||||
_lcd_store_config(i2c_port, pcf_addr, nibble_shift, backlight_mask);
|
||||
@@ -197,34 +185,17 @@ void lcd_init(uint8_t i2c_port, uint32_t sda_pin, uint32_t scl_pin,
|
||||
lcd_i2c_init(i2c_port, pcf_addr, nibble_shift, backlight_mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the LCD display
|
||||
*
|
||||
* Clears the display and returns the cursor to the home position. This
|
||||
* call blocks for the duration required by the HD44780 controller.
|
||||
*/
|
||||
void lcd_clear(void) {
|
||||
_lcd_send(0x01, 0);
|
||||
sleep_ms(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the cursor position
|
||||
*
|
||||
* @param line Line number (0 or 1)
|
||||
* @param position Column (0..15)
|
||||
*/
|
||||
void lcd_set_cursor(int line, int position) {
|
||||
const uint8_t row_offsets[] = {0x00, 0x40};
|
||||
if (line > 1) line = 1;
|
||||
_lcd_send(0x80 | (position + row_offsets[line]), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a null-terminated string to the display
|
||||
*
|
||||
* @param s The string to write (ASCII)
|
||||
*/
|
||||
void lcd_puts(const char *s) {
|
||||
while (*s)
|
||||
_lcd_send((uint8_t)*s++, 1);
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief IMAGE_DEF block structure placed in flash
|
||||
*/
|
||||
__attribute__((section(".embedded_block"), used))
|
||||
const uint8_t picobin_block[] = {
|
||||
0xD3, 0xDE, 0xFF, 0xFF,
|
||||
|
||||
@@ -139,10 +139,6 @@ static void _display_count(uint32_t count)
|
||||
uart_puts("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the LCD 1602 counter demo.
|
||||
* @retval int does not return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
#include "rp2350_delay.h"
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of milliseconds.
|
||||
* @param ms number of milliseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
if (ms == 0)
|
||||
@@ -43,11 +38,6 @@ void delay_ms(uint32_t ms)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delay for the specified number of microseconds.
|
||||
* @param us number of microseconds to delay
|
||||
* @retval None
|
||||
*/
|
||||
void delay_us(uint32_t us)
|
||||
{
|
||||
if (us == 0)
|
||||
|
||||
@@ -123,10 +123,6 @@ static void _i2c_wait_done(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release I2C1 from reset and wait for completion.
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_release_reset(void)
|
||||
{
|
||||
RESETS->RESET |= (1U << RESETS_RESET_I2C1_SHIFT);
|
||||
@@ -135,15 +131,6 @@ void i2c_release_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize I2C1 as a 100 kHz master on SDA=GPIO2 / SCL=GPIO3.
|
||||
*
|
||||
* Configures GPIO pads with pull-ups, sets FUNCSEL to I2C,
|
||||
* programs SCL timing for 100 kHz at 12 MHz clk_sys, and
|
||||
* enables the controller in master mode with 7-bit addressing.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_init(void)
|
||||
{
|
||||
_i2c_config_pads();
|
||||
@@ -156,15 +143,6 @@ void i2c_init(void)
|
||||
I2C1->ENABLE = 1U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the I2C1 target slave address.
|
||||
*
|
||||
* Disables the controller, writes the 7-bit address into the
|
||||
* TAR register, and re-enables the controller.
|
||||
*
|
||||
* @param addr 7-bit I2C address
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_set_target(uint8_t addr)
|
||||
{
|
||||
I2C1->ENABLE = 0U;
|
||||
@@ -172,15 +150,6 @@ void i2c_set_target(uint8_t addr)
|
||||
I2C1->ENABLE = 1U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write one byte to the current target address with a STOP.
|
||||
*
|
||||
* Sends a single data byte over I2C1 with the STOP condition.
|
||||
* Blocks until the transfer completes or an abort is detected.
|
||||
*
|
||||
* @param data byte to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void i2c_write_byte(uint8_t data)
|
||||
{
|
||||
(void)I2C1->CLR_TX_ABRT;
|
||||
|
||||
@@ -107,15 +107,6 @@ static void _lcd_hd44780_configure(void)
|
||||
_lcd_send(LCD_CMD_ENTRY_MODE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the LCD in 4-bit mode via the PCF8574 backpack.
|
||||
*
|
||||
* Sets the I2C target address to LCD_I2C_ADDR, performs the
|
||||
* HD44780 power-on reset sequence, and configures the display
|
||||
* for 4-bit, 2-line, 5x8 font with backlight on.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void lcd_init(void)
|
||||
{
|
||||
i2c_set_target(LCD_I2C_ADDR);
|
||||
@@ -123,33 +114,18 @@ void lcd_init(void)
|
||||
_lcd_hd44780_configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the LCD display and return cursor to home.
|
||||
* @retval None
|
||||
*/
|
||||
void lcd_clear(void)
|
||||
{
|
||||
_lcd_send(LCD_CMD_CLEAR, 0);
|
||||
delay_ms(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the cursor position on the display.
|
||||
* @param line line number (0 or 1)
|
||||
* @param position column number (0-15)
|
||||
* @retval None
|
||||
*/
|
||||
void lcd_set_cursor(uint8_t line, uint8_t position)
|
||||
{
|
||||
uint8_t offset = (line == 0U) ? LCD_ROW0_OFFSET : LCD_ROW1_OFFSET;
|
||||
_lcd_send(LCD_CMD_SET_DDRAM | (position + offset), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a null-terminated string to the display.
|
||||
* @param str pointer to the string to write (ASCII)
|
||||
* @retval None
|
||||
*/
|
||||
void lcd_puts(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#include "rp2350_reset.h"
|
||||
|
||||
/**
|
||||
* @brief Release IO_BANK0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void reset_init_subsystem(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
extern int main(void);
|
||||
|
||||
/**
|
||||
* @brief Reset handler entry point (naked, noreturn).
|
||||
* @retval None
|
||||
*/
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "rp2350_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize MSP, PSP, MSPLIM, and PSPLIM stack pointers.
|
||||
* @retval None
|
||||
*/
|
||||
void stack_init(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
|
||||
@@ -79,20 +79,12 @@ static void _uart_enable(void)
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release UART0 from reset and wait until ready.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize UART0 pins, baud rate, line control, and enable.
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
@@ -100,19 +92,11 @@ void uart_init(void)
|
||||
_uart_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read one character from UART0 (blocking).
|
||||
* @retval char the received character
|
||||
*/
|
||||
char uart_getchar(void)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_RXFE_MASK) {
|
||||
@@ -120,11 +104,6 @@ char uart_getchar(void)
|
||||
return (char)(UART_BASE[UART_DR_OFFSET] & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit one character over UART0 (blocking).
|
||||
* @param c character to transmit
|
||||
* @retval None
|
||||
*/
|
||||
void uart_putchar(char c)
|
||||
{
|
||||
while (UART_BASE[UART_FR_OFFSET] & UART_FR_TXFF_MASK) {
|
||||
@@ -132,11 +111,6 @@ void uart_putchar(char c)
|
||||
UART_BASE[UART_DR_OFFSET] = (uint32_t)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)
|
||||
{
|
||||
while (*str) {
|
||||
@@ -144,11 +118,6 @@ 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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user