mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Merge branch 'master' of ssh://git.code.sf.net/p/newrpl/sources
This commit is contained in:
commit
6bca832b8e
4 changed files with 78 additions and 35 deletions
|
@ -922,4 +922,7 @@ void reset_gpio();
|
|||
// Magic word "NRPL"
|
||||
#define NEWRPL_MAGIC 0x4c50524e
|
||||
|
||||
void uart_init(void);
|
||||
void debug_print_hex(char *key, uint32_t value);
|
||||
|
||||
#endif // TARGET_PRIME1_H
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
#define left 0
|
||||
#define right 160
|
||||
|
||||
//static int line;
|
||||
//static gglsurface surface;
|
||||
|
||||
// DEBUG ONLY - TURN ON LEDS
|
||||
|
||||
__ARM_MODE__ void blue_led_on();
|
||||
|
@ -60,38 +57,6 @@ void red_led_off()
|
|||
*GPCDAT&=~(1<<7) ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void tohex(uint32_t value, char *buffer) {
|
||||
buffer[8] = 0;
|
||||
|
||||
for (int i = 7; i >= 0; --i) {
|
||||
buffer[i] = "0123456789ABCDEF"[value % 16];
|
||||
value = value / 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void tobin(uint32_t value, char *buffer) {
|
||||
buffer[32] = 0;
|
||||
|
||||
for (int i = 31; i >= 0; --i) {
|
||||
buffer[i] = "01"[value % 2];
|
||||
value = value / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void printline(char *left_text, char *right_text) {
|
||||
if (left_text) {
|
||||
DrawText(left, line * lineheight, left_text, font, black, &surface);
|
||||
}
|
||||
if (right_text) {
|
||||
DrawText(right, line * lineheight, right_text, font, black, &surface);
|
||||
}
|
||||
if (left_text || right_text) {
|
||||
++line;
|
||||
}
|
||||
}
|
||||
*/
|
||||
__ARM_MODE__ void enable_interrupts()
|
||||
{
|
||||
asm volatile (
|
||||
|
@ -996,6 +961,8 @@ void startup(void)
|
|||
|
||||
//red_led_on();
|
||||
|
||||
uart_init();
|
||||
|
||||
main_virtual(prevstate); // never returns
|
||||
}
|
||||
|
||||
|
|
72
firmware/sys/target_prime1/uart.c
Normal file
72
firmware/sys/target_prime1/uart.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2020, Claudio Lapilli and the newRPL Team
|
||||
* All rights reserved.
|
||||
* This file is released under the 3-clause BSD license.
|
||||
* See the file LICENSE.txt that shipped with this distribution.
|
||||
*/
|
||||
|
||||
#include "target_prime1.h"
|
||||
|
||||
// NOTE is identically implemented in nand.c
|
||||
static void uart_busy_wait(unsigned int count)
|
||||
{
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
// asm statement with data dependency and potential side effect
|
||||
// can't be optimized away
|
||||
__asm__ volatile("" : "+g" (i) : :);
|
||||
}
|
||||
}
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
// Enable RXD[0] and TXD[0]
|
||||
*GPHCON &= ~0xf;
|
||||
*GPHCON |= 0xa;
|
||||
|
||||
*UFCON0 = 0; // No FIFO
|
||||
*UMCON0 = 0; // No AFC
|
||||
*ULCON0 = 3; // 8N1
|
||||
*UCON0 = 0x245; // Polling mode; generate error status interrupt
|
||||
*UBRDIV0 = 26; // Baud rate 115.2k; FIXME PRIME.OS uses 35 to get same value
|
||||
*UDIVSLOT0 = 0;
|
||||
|
||||
uart_busy_wait(500);
|
||||
}
|
||||
|
||||
static void uart_write_char(char character)
|
||||
{
|
||||
// Wait until Transmit buffer is empty
|
||||
while ((*UTRSTAT0 & 2) == 0);
|
||||
uart_busy_wait(100);
|
||||
*UTXH0 = character;
|
||||
}
|
||||
|
||||
static void uart_write_string(char *string)
|
||||
{
|
||||
while (*string != 0) {
|
||||
uart_write_char(*string);
|
||||
++string;
|
||||
}
|
||||
uart_busy_wait(100);
|
||||
}
|
||||
|
||||
static void tohex(uint32_t value, char *buffer)
|
||||
{
|
||||
buffer[8] = 0;
|
||||
|
||||
for (int i = 7; i >= 0; --i) {
|
||||
buffer[i] = "0123456789ABCDEF"[value % 16];
|
||||
value = value / 16;
|
||||
}
|
||||
}
|
||||
|
||||
void debug_print_hex(char *key, uint32_t value)
|
||||
{
|
||||
char value_string[9];
|
||||
tohex(value, value_string);
|
||||
uart_write_string(key);
|
||||
uart_write_string(":0x");
|
||||
uart_write_string(value_string);
|
||||
// write carriage return and newline to be compatible to BL1
|
||||
uart_write_string("\r\n");
|
||||
}
|
|
@ -40,6 +40,7 @@ SOURCES +=\
|
|||
firmware/sys/target_prime1/rtc.c \
|
||||
firmware/sys/target_prime1/touch.c \
|
||||
firmware/sys/target_prime1/usbdriver.c \
|
||||
firmware/sys/target_prime1/uart.c \
|
||||
firmware/sys/usbcommon.c \
|
||||
firmware/sys/target_prime1/fwupdate.c \
|
||||
firmware/ggl/cgl/cgl_bitblt.c \
|
||||
|
|
Loading…
Reference in a new issue