[platform][lpc43xx] hook up debug uart
For the moment, just a trivial implementation in debug.c. To be replaced with a standard lk uart "driver" later on.
This commit is contained in:
@@ -24,8 +24,31 @@
|
||||
#include <debug.h>
|
||||
#include <reg.h>
|
||||
|
||||
#include <platform/lpc43xx-uart.h>
|
||||
|
||||
#if TARGET_DEBUG_UART == 1
|
||||
#define UART_BASE UART0_BASE
|
||||
#elif TARGET_DEBUG_UART == 2
|
||||
#define UART_BASE UART1_BASE
|
||||
#elif TARGET_DEBUG_UART == 3
|
||||
#define UART_BASE UART2_BASE
|
||||
#elif TARGET_DEBUG_UART == 4
|
||||
#define UART_BASE UART3_BASE
|
||||
#else
|
||||
#warning TARGET_DEBUG_UART unspecified
|
||||
#endif
|
||||
|
||||
void lpc43xx_debug_early_init(void)
|
||||
{
|
||||
#ifdef UART_BASE
|
||||
// config for 115200-n-8-1 from 12MHz clock
|
||||
writel(LCR_DLAB, UART_BASE + REG_LCR);
|
||||
writel(4, UART_BASE + REG_DLL);
|
||||
writel(0, UART_BASE + REG_DLM);
|
||||
writel(FDR_DIVADDVAL(5) | FDR_MULVAL(8), UART_BASE + REG_FDR);
|
||||
writel(LCR_WLS_8 | LCR_SBS_1, UART_BASE + REG_LCR);
|
||||
writel(FCR_FIFOEN | FCR_RX_TRIG_1, UART_BASE + REG_FCR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lpc43xx_debug_init(void)
|
||||
@@ -34,13 +57,28 @@ void lpc43xx_debug_init(void)
|
||||
|
||||
void platform_dputc(char c)
|
||||
{
|
||||
#ifdef UART_BASE
|
||||
while (!(readl(UART_BASE + REG_LSR) & LSR_THRE)) ;
|
||||
writel(c, UART_BASE + REG_THR);
|
||||
#endif
|
||||
}
|
||||
|
||||
int platform_dgetc(char *c, bool wait)
|
||||
{
|
||||
#ifdef UART_BASE
|
||||
while (!(readl(UART_BASE + REG_LSR) & LSR_RDR)) {
|
||||
if (!wait) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
*c = readl(UART_BASE + REG_RBR);
|
||||
return 0;
|
||||
#else
|
||||
if (wait) {
|
||||
for (;;) ;
|
||||
}
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,11 @@
|
||||
#include <debug.h>
|
||||
#include <arch/arm/cm.h>
|
||||
|
||||
void lpc43xx_debug_early_init(void);
|
||||
|
||||
void platform_early_init(void)
|
||||
{
|
||||
lpc43xx_debug_early_init();
|
||||
arm_cm_systick_init(96000000);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,16 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <reg.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <platform/lpc43xx-gpio.h>
|
||||
|
||||
void target_early_init(void)
|
||||
{
|
||||
// UART2 on P1.15 (TX) and P1.16 (RX)
|
||||
writel(PIN_MODE(1) | PIN_PLAIN, PIN_CFG(1, 15));
|
||||
writel(PIN_MODE(1) | PIN_PLAIN | PIN_INPUT, PIN_CFG(1, 16));
|
||||
}
|
||||
|
||||
void target_init(void)
|
||||
|
||||
@@ -5,7 +5,8 @@ MODULE := $(LOCAL_DIR)
|
||||
PLATFORM := lpc43xx
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
CRYSTAL_FREQ=12000000
|
||||
CRYSTAL_FREQ=12000000 \
|
||||
TARGET_DEBUG_UART=3
|
||||
|
||||
GLOBAL_INCLUDES += \
|
||||
$(LOCAL_DIR)/include
|
||||
|
||||
Reference in New Issue
Block a user