mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-09-24 02:10:44 +02:00
Fixed improper _
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
* @param buf destination buffer (FLASH_PAGE_SIZE bytes in RAM)
|
||||
* @retval None
|
||||
*/
|
||||
static void _prepare_write_buf(uint8_t *buf)
|
||||
static void prepare_write_buf(uint8_t *buf)
|
||||
{
|
||||
uint32_t i;
|
||||
const char *msg = "Embedded Hacking flash driver demo";
|
||||
@@ -54,11 +54,11 @@ static void _prepare_write_buf(uint8_t *buf)
|
||||
* @brief Write the demo string to flash and print the read-back.
|
||||
* @retval None
|
||||
*/
|
||||
static void _write_and_verify(void)
|
||||
static void write_and_verify(void)
|
||||
{
|
||||
uint8_t write_buf[FLASH_PAGE_SIZE];
|
||||
uint8_t read_buf[FLASH_PAGE_SIZE];
|
||||
_prepare_write_buf(write_buf);
|
||||
prepare_write_buf(write_buf);
|
||||
flash_write(FLASH_TARGET_OFFSET, write_buf, FLASH_PAGE_SIZE);
|
||||
flash_read(FLASH_TARGET_OFFSET, read_buf, FLASH_PAGE_SIZE);
|
||||
uart_puts("Flash readback: ");
|
||||
@@ -68,7 +68,7 @@ static void _write_and_verify(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
_write_and_verify();
|
||||
write_and_verify();
|
||||
while (1)
|
||||
__asm volatile ("wfi");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ typedef struct
|
||||
* @param code ROM_FUNC_* code from rp2350.h
|
||||
* @retval void* pointer to the ROM function
|
||||
*/
|
||||
static void *_rom_func_lookup(uint32_t code)
|
||||
static void *rom_func_lookup(uint32_t code)
|
||||
{
|
||||
rom_table_lookup_fn fn =
|
||||
(rom_table_lookup_fn)(uintptr_t)(*(uint16_t *)BOOTROM_TABLE_LOOKUP_OFFSET);
|
||||
@@ -76,14 +76,14 @@ static void *_rom_func_lookup(uint32_t code)
|
||||
* @param fns pointer to the struct to fill
|
||||
* @retval None
|
||||
*/
|
||||
static void _lookup_rom_fns(FlashRomFns *fns)
|
||||
static void lookup_rom_fns(FlashRomFns *fns)
|
||||
{
|
||||
fns->connect = (rom_void_fn)_rom_func_lookup(ROM_FUNC_CONNECT_INTERNAL_FLASH);
|
||||
fns->exit_xip = (rom_void_fn)_rom_func_lookup(ROM_FUNC_FLASH_EXIT_XIP);
|
||||
fns->erase = (rom_flash_erase_fn)_rom_func_lookup(ROM_FUNC_FLASH_RANGE_ERASE);
|
||||
fns->program = (rom_flash_program_fn)_rom_func_lookup(ROM_FUNC_FLASH_RANGE_PROGRAM);
|
||||
fns->flush_cache = (rom_void_fn)_rom_func_lookup(ROM_FUNC_FLASH_FLUSH_CACHE);
|
||||
fns->enter_xip = (rom_void_fn)_rom_func_lookup(ROM_FUNC_FLASH_ENTER_CMD_XIP);
|
||||
fns->connect = (rom_void_fn)rom_func_lookup(ROM_FUNC_CONNECT_INTERNAL_FLASH);
|
||||
fns->exit_xip = (rom_void_fn)rom_func_lookup(ROM_FUNC_FLASH_EXIT_XIP);
|
||||
fns->erase = (rom_flash_erase_fn)rom_func_lookup(ROM_FUNC_FLASH_RANGE_ERASE);
|
||||
fns->program = (rom_flash_program_fn)rom_func_lookup(ROM_FUNC_FLASH_RANGE_PROGRAM);
|
||||
fns->flush_cache = (rom_void_fn)rom_func_lookup(ROM_FUNC_FLASH_FLUSH_CACHE);
|
||||
fns->enter_xip = (rom_void_fn)rom_func_lookup(ROM_FUNC_FLASH_ENTER_CMD_XIP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ static void _lookup_rom_fns(FlashRomFns *fns)
|
||||
* @retval None
|
||||
*/
|
||||
__attribute__((section(".ram_func"), noinline))
|
||||
static void _flash_erase_program_ram(const FlashRomFns *fns, uint32_t offset,
|
||||
static void flash_erase_program_ram(const FlashRomFns *fns, uint32_t offset,
|
||||
const uint8_t *data, uint32_t len)
|
||||
{
|
||||
fns->connect();
|
||||
@@ -115,11 +115,11 @@ static void _flash_erase_program_ram(const FlashRomFns *fns, uint32_t offset,
|
||||
void flash_write(uint32_t offset, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
FlashRomFns fns;
|
||||
_lookup_rom_fns(&fns);
|
||||
lookup_rom_fns(&fns);
|
||||
uint32_t primask;
|
||||
__asm volatile ("mrs %0, primask" : "=r" (primask));
|
||||
__asm volatile ("cpsid i");
|
||||
_flash_erase_program_ram(&fns, offset, data, len);
|
||||
flash_erase_program_ram(&fns, offset, data, len);
|
||||
__asm volatile ("msr primask, %0" :: "r" (primask));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ extern uint32_t __data_end;
|
||||
* @brief Copy initialized data and RAM-resident code from flash to RAM.
|
||||
* @retval None
|
||||
*/
|
||||
static void _data_copy_init(void)
|
||||
static void data_copy_init(void)
|
||||
{
|
||||
uint32_t *src = &__data_lma;
|
||||
uint32_t *dst = &__data_start;
|
||||
@@ -59,7 +59,7 @@ static void _data_copy_init(void)
|
||||
void ram_init(void)
|
||||
{
|
||||
stack_init();
|
||||
_data_copy_init();
|
||||
data_copy_init();
|
||||
}
|
||||
|
||||
void __attribute__((naked, noreturn)) Reset_Handler(void)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* @brief Clear the UART0 reset bit in the reset controller.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_clear_reset_bit(void)
|
||||
static void uart_clear_reset_bit(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = RESETS->RESET;
|
||||
@@ -40,7 +40,7 @@ static void _uart_clear_reset_bit(void)
|
||||
* @brief Wait until the UART0 block is out of reset.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_wait_reset_done(void)
|
||||
static void uart_wait_reset_done(void)
|
||||
{
|
||||
while ((RESETS->RESET_DONE & (1U << RESETS_RESET_UART0_SHIFT)) == 0) {}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ static void _uart_wait_reset_done(void)
|
||||
* @brief Configure GPIO pins 0 (TX) and 1 (RX) for UART function.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_configure_pins(void)
|
||||
static void uart_configure_pins(void)
|
||||
{
|
||||
IO_BANK0->GPIO[0].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
IO_BANK0->GPIO[1].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
@@ -61,7 +61,7 @@ static void _uart_configure_pins(void)
|
||||
* @brief Set UART0 baud rate divisors for 115200 at 12 MHz.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_set_baud(void)
|
||||
static void uart_set_baud(void)
|
||||
{
|
||||
UART_BASE[UART_CR_OFFSET] = 0;
|
||||
UART_BASE[UART_IBRD_OFFSET] = 6;
|
||||
@@ -72,7 +72,7 @@ static void _uart_set_baud(void)
|
||||
* @brief Configure line control and enable UART0.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_enable(void)
|
||||
static void uart_enable(void)
|
||||
{
|
||||
UART_BASE[UART_LCR_H_OFFSET] = UART_LCR_H_8N1_FIFO;
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
@@ -80,15 +80,15 @@ static void _uart_enable(void)
|
||||
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
uart_clear_reset_bit();
|
||||
uart_wait_reset_done();
|
||||
}
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
_uart_set_baud();
|
||||
_uart_enable();
|
||||
uart_configure_pins();
|
||||
uart_set_baud();
|
||||
uart_enable();
|
||||
}
|
||||
|
||||
bool uart_is_readable(void)
|
||||
|
||||
Reference in New Issue
Block a user