[target][pico] switch the uart config to target driven
Uses the target/debugconfig.h file pattern laid down before, which is a bit long in the tooth but for the moment still helps us separate target from platform.
This commit is contained in:
@@ -6,20 +6,22 @@
|
||||
|
||||
#include <platform/debug.h>
|
||||
|
||||
#include <target/debugconfig.h>
|
||||
|
||||
#include <hardware/uart.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void platform_dputc(char c) {
|
||||
if (c == '\n')
|
||||
uart_putc(uart0, '\r');
|
||||
uart_putc(uart0, c);
|
||||
uart_putc(DEBUG_UART, '\r');
|
||||
uart_putc(DEBUG_UART, c);
|
||||
}
|
||||
|
||||
int platform_dgetc(char *c, bool wait) {
|
||||
if (!wait && !uart_is_readable(uart0))
|
||||
if (!wait && !uart_is_readable(DEBUG_UART))
|
||||
return -1;
|
||||
*c = uart_getc(uart0);
|
||||
*c = uart_getc(DEBUG_UART);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <platform.h>
|
||||
#include <arch/arm/cm.h>
|
||||
#include <target/debugconfig.h>
|
||||
|
||||
#include <hardware/clocks.h>
|
||||
#include <hardware/gpio.h>
|
||||
@@ -15,16 +16,22 @@
|
||||
extern void* vectab;
|
||||
|
||||
void platform_early_init(void) {
|
||||
// initialize the clock tree.
|
||||
// gets clock values from defines in SDK at
|
||||
// external/platform/pico/rp2040/hardware_regs/include/hardware/platform_defs.h
|
||||
clocks_init();
|
||||
|
||||
// start the systick timer
|
||||
arm_cm_systick_init(125000000);
|
||||
|
||||
// unreset everything
|
||||
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");
|
||||
|
||||
arm_cm_systick_init(133000000);
|
||||
// target defines drive how we configure the debug uart
|
||||
uart_init(DEBUG_UART, 115200);
|
||||
gpio_set_function(DEBUG_UART_GPIOA, GPIO_FUNC_UART);
|
||||
gpio_set_function(DEBUG_UART_GPIOB, GPIO_FUNC_UART);
|
||||
uart_puts(DEBUG_UART, "Hello World!\n");
|
||||
}
|
||||
|
||||
void platform_init(void) {
|
||||
@@ -32,5 +39,5 @@ void platform_init(void) {
|
||||
|
||||
|
||||
bool running_on_fpga(void) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
// 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#define DEBUG_UART 0
|
||||
#include <hardware/uart.h>
|
||||
|
||||
// define how this target will map the debug uart to hardware and pins
|
||||
#define DEBUG_UART uart0
|
||||
#define DEBUG_UART_GPIOA 0
|
||||
#define DEBUG_UART_GPIOB 1
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include <target.h>
|
||||
#include <target/debugconfig.h>
|
||||
#include <platform/gpio.h>
|
||||
|
||||
|
||||
void target_early_init(void) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user