[rp20xx] quick and dirty early init using pico-sdk driver code
- pull in headers for essential modules - init clocks, gpios, uart0 out of platform_early_init - wire up debug getc/putc to uart0 - comment out "native" uart impl
This commit is contained in:
committed by
Travis Geiselbrecht
parent
9c769f6931
commit
7d3f648e88
@@ -1,31 +1,25 @@
|
||||
// Copyright (c) 2012 Travis Geiselbrecht
|
||||
// Copyright (c) 2020 Brian Swetland
|
||||
//
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <lk/reg.h>
|
||||
#include <lk/debug.h>
|
||||
#include <stdio.h>
|
||||
#include <kernel/thread.h>
|
||||
#include <platform/debug.h>
|
||||
#include <arch/ops.h>
|
||||
#include <dev/uart.h>
|
||||
#include <target/debugconfig.h>
|
||||
#include <arch/arm/cm.h>
|
||||
|
||||
#include <hardware/uart.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void platform_dputc(char c) {
|
||||
if (c == '\n')
|
||||
uart_putc(DEBUG_UART, '\r');
|
||||
uart_putc(DEBUG_UART, c);
|
||||
uart_putc(uart0, '\r');
|
||||
uart_putc(uart0, c);
|
||||
}
|
||||
|
||||
int platform_dgetc(char *c, bool wait) {
|
||||
int ret = uart_getc(DEBUG_UART, wait);
|
||||
if (ret == -1)
|
||||
if (!wait && !uart_is_readable(uart0))
|
||||
return -1;
|
||||
*c = ret;
|
||||
*c = uart_getc(uart0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,23 @@
|
||||
#include <platform.h>
|
||||
#include <arch/arm/cm.h>
|
||||
|
||||
#include <hardware/clocks.h>
|
||||
#include <hardware/gpio.h>
|
||||
#include <hardware/uart.h>
|
||||
#include <hardware/resets.h>
|
||||
|
||||
extern void* vectab;
|
||||
|
||||
void platform_early_init(void) {
|
||||
clocks_init();
|
||||
|
||||
unreset_block_wait(RESETS_RESET_BITS);
|
||||
|
||||
uart_init(uart0, 1000000);
|
||||
gpio_set_function(0, GPIO_FUNC_UART);
|
||||
gpio_set_function(1, GPIO_FUNC_UART);
|
||||
uart_puts(uart0, "Hello World!\n");
|
||||
|
||||
// arch/arm/arm-m/arch.c does this but only for M3 and above...
|
||||
SCB->VTOR = (uint32_t) &vectab;
|
||||
|
||||
@@ -18,3 +32,8 @@ void platform_early_init(void) {
|
||||
|
||||
void platform_init(void) {
|
||||
}
|
||||
|
||||
|
||||
bool running_on_fpga(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ ARM_CPU := cortex-m0plus
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
MEMSIZE=$(MEMSIZE) \
|
||||
PICO_ON_DEVICE=1 \
|
||||
PICO_NO_BINARY_INFO=1
|
||||
|
||||
MODULE_SRCS += \
|
||||
@@ -22,6 +23,32 @@ MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/uart.c \
|
||||
$(LOCAL_DIR)/vectab.c
|
||||
|
||||
MODULE_SRCS += \
|
||||
external/platform/pico/rp2_common/hardware_clocks/clocks.c \
|
||||
external/platform/pico/rp2_common/hardware_gpio/gpio.c \
|
||||
external/platform/pico/rp2_common/hardware_pll/pll.c \
|
||||
external/platform/pico/rp2_common/hardware_uart/uart.c \
|
||||
external/platform/pico/rp2_common/hardware_watchdog/watchdog.c \
|
||||
external/platform/pico/rp2_common/hardware_xosc/xosc.c
|
||||
|
||||
GLOBAL_INCLUDES += \
|
||||
external/platform/pico/common/pico_base/include \
|
||||
external/platform/pico/common/pico_binary_info/include \
|
||||
external/platform/pico/rp2040/hardware_regs/include \
|
||||
external/platform/pico/rp2040/hardware_structs/include \
|
||||
external/platform/pico/rp2_common/pico_platform/include \
|
||||
external/platform/pico/rp2_common/hardware_base/include \
|
||||
external/platform/pico/rp2_common/hardware_clocks/include \
|
||||
external/platform/pico/rp2_common/hardware_gpio/include \
|
||||
external/platform/pico/rp2_common/hardware_irq/include \
|
||||
external/platform/pico/rp2_common/hardware_pll/include \
|
||||
external/platform/pico/rp2_common/hardware_sync/include \
|
||||
external/platform/pico/rp2_common/hardware_resets/include \
|
||||
external/platform/pico/rp2_common/hardware_timer/include \
|
||||
external/platform/pico/rp2_common/hardware_uart/include \
|
||||
external/platform/pico/rp2_common/hardware_watchdog/include \
|
||||
external/platform/pico/rp2_common/hardware_xosc/include
|
||||
|
||||
# use a two segment memory layout, where all of the read-only sections
|
||||
# of the binary reside in rom, and the read/write are in memory. The
|
||||
# ROMBASE, MEMBASE, and MEMSIZE make variables are required to be set
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <lk/reg.h>
|
||||
#include <lib/cbuf.h>
|
||||
|
||||
#if 0
|
||||
void uart_init_early(void) {
|
||||
for (;;) ;
|
||||
}
|
||||
@@ -28,3 +29,4 @@ void uart_flush_rx(int port) {}
|
||||
|
||||
void uart_init_port(int port, uint baud) {}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user