Change the way the UART recieves data and how buttons pressed are processed. Also move some of the debug menu into the target tree and allow rockblox to build when the screen is rotated.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15560 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a5e4cc9e68
commit
d3c0a7f169
|
@ -88,6 +88,10 @@
|
|||
#endif
|
||||
#include "hwcompat.h"
|
||||
|
||||
#if CONFIG_CPU == DM320
|
||||
#include "debug-target.h"
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/* SPECIAL DEBUG STUFF */
|
||||
/*---------------------------------------------------*/
|
||||
|
@ -656,45 +660,9 @@ static bool dbg_hw_info(void)
|
|||
lcd_update();
|
||||
|
||||
while (!(action_userabort(TIMEOUT_BLOCK)));
|
||||
#elif CONFIG_CPU == DM320
|
||||
int line = 0, button;
|
||||
int *address=0x0;
|
||||
bool done=false;
|
||||
char buf[100];
|
||||
|
||||
lcd_setmargins(0, 0);
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
lcd_clear_display();
|
||||
lcd_puts(0, line++, "[Hardware info]");
|
||||
|
||||
while(!done)
|
||||
{
|
||||
button = button_get(false);
|
||||
button&=~BUTTON_REPEAT;
|
||||
if (button == BUTTON_POWER)
|
||||
done=true;
|
||||
if(button==BUTTON_RC_PLAY)
|
||||
address+=0x01;
|
||||
else if (button==BUTTON_RC_DOWN)
|
||||
address-=0x01;
|
||||
else if (button==BUTTON_RC_FF)
|
||||
address+=0x800;
|
||||
else if (button==BUTTON_RC_REW)
|
||||
address-=0x800;
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "current tick: %04x", (unsigned int)current_tick);
|
||||
lcd_puts(0, line++, buf);
|
||||
snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)address, *address);
|
||||
lcd_puts(0, line++, buf);
|
||||
snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+1), *(address+1));
|
||||
lcd_puts(0, line++, buf);
|
||||
snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+2), *(address+2));
|
||||
lcd_puts(0, line++, buf);
|
||||
line -= 4;
|
||||
}
|
||||
lcd_update();
|
||||
}
|
||||
|
||||
#else
|
||||
/* Define this function in your target tree */
|
||||
return __dbg_hw_info();
|
||||
#endif /* CONFIG_CPU */
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,23 @@ PLUGIN_HEADER
|
|||
|
||||
#define BOARD_HEIGHT 20
|
||||
|
||||
#if (LCD_WIDTH == 480) && (LCD_HEIGHT == 640)
|
||||
#if (LCD_WIDTH == 640) && (LCD_HEIGHT == 480)
|
||||
|
||||
#define BLOCK_WIDTH 30
|
||||
#define BLOCK_HEIGHT 30
|
||||
#define BOARD_X 14
|
||||
#define BOARD_Y 2
|
||||
#define PREVIEW_X 342
|
||||
#define PREVIEW_Y 482
|
||||
#define LABEL_X 344
|
||||
#define SCORE_Y 58
|
||||
#define LEVEL_Y 142
|
||||
#define LINES_Y 218
|
||||
#define HIGH_LABEL_X 344
|
||||
#define HIGH_SCORE_Y 326
|
||||
#define HIGH_LEVEL_Y 344
|
||||
|
||||
#elif (LCD_WIDTH == 480) && (LCD_HEIGHT == 640)
|
||||
|
||||
#define BLOCK_WIDTH 30
|
||||
#define BLOCK_HEIGHT 30
|
||||
|
|
|
@ -647,6 +647,7 @@ target/arm/tms320dm320/mrobe-500/pcm-mr500.c
|
|||
target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
|
||||
target/arm/tms320dm320/mrobe-500/power-mr500.c
|
||||
target/arm/tms320dm320/mrobe-500/usb-mr500.c
|
||||
target/arm/tms320dm320/debug-dm320.c
|
||||
target/arm/tms320dm320/i2c-dm320.c
|
||||
target/arm/tms320dm320/kernel-dm320.c
|
||||
target/arm/tms320dm320/spi-dm320.c
|
||||
|
|
|
@ -113,13 +113,11 @@ static void remote_heartbeat(void)
|
|||
#define TOUCH_MARGIN 8
|
||||
int button_read_device(int *data)
|
||||
{
|
||||
char c;
|
||||
int i = 0;
|
||||
int btn = BUTTON_NONE;
|
||||
char buffer[5];
|
||||
int button = BUTTON_NONE, retval;
|
||||
static int oldbutton = BUTTON_NONE;
|
||||
*data = 0;
|
||||
|
||||
if ((IO_GIO_BITSET0&0x01) == 0)
|
||||
btn |= BUTTON_POWER;
|
||||
|
||||
if (touch_available)
|
||||
{
|
||||
short x,y;
|
||||
|
@ -143,47 +141,31 @@ int button_read_device(int *data)
|
|||
last_x = x;
|
||||
last_y = y;
|
||||
*data = touch_to_pixels(x, y);
|
||||
btn |= BUTTON_TOUCHPAD;
|
||||
button |= BUTTON_TOUCHPAD;
|
||||
}
|
||||
last_touch = current_tick;
|
||||
touch_available = false;
|
||||
}
|
||||
remote_heartbeat();
|
||||
while (uart1_getch(&c))
|
||||
|
||||
if ((IO_GIO_BITSET0&0x01) == 0)
|
||||
button |= BUTTON_POWER;
|
||||
|
||||
retval=uart1_gets_queue(buffer, 5);
|
||||
do
|
||||
{
|
||||
if (i==0 && (c == BUTTON_START_BYTE || c == BUTTON_START_BYTE2) )
|
||||
if(retval>=0)
|
||||
{
|
||||
i++;
|
||||
button |= buffer[1];
|
||||
oldbutton=button;
|
||||
}
|
||||
else if (i)
|
||||
else
|
||||
{
|
||||
i++;
|
||||
if(i==2)
|
||||
{
|
||||
if (c& (1<<7))
|
||||
btn |= BUTTON_RC_HEART;
|
||||
if (c& (1<<6))
|
||||
btn |= BUTTON_RC_MODE;
|
||||
if (c& (1<<5))
|
||||
btn |= BUTTON_RC_VOL_DOWN;
|
||||
if (c& (1<<4))
|
||||
btn |= BUTTON_RC_VOL_UP;
|
||||
if (c& (1<<3))
|
||||
btn |= BUTTON_RC_REW;
|
||||
if (c& (1<<2))
|
||||
btn |= BUTTON_RC_FF;
|
||||
if (c& (1<<1))
|
||||
btn |= BUTTON_RC_DOWN;
|
||||
if (c& (1<<0))
|
||||
btn |= BUTTON_RC_PLAY;
|
||||
}
|
||||
else if(i==5)
|
||||
{
|
||||
i=0;
|
||||
}
|
||||
button=oldbutton;
|
||||
}
|
||||
}
|
||||
return btn;
|
||||
} while((retval=uart1_gets_queue(buffer, 5))>=5);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
/* Touchpad data available interupt */
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef _BUTTON_TARGET_H_
|
||||
#define _BUTTON_TARGET_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
#define HAS_BUTTON_HOLD
|
||||
|
@ -37,22 +36,21 @@ struct touch_calibration_point {
|
|||
};
|
||||
void use_calibration(bool enable);
|
||||
|
||||
/* m:robe 500 specific button codes */
|
||||
/* M:Robe 500 specific button codes */
|
||||
|
||||
#define BUTTON_POWER 0x00000001
|
||||
#define BUTTON_POWER 0x00000100
|
||||
|
||||
/* Remote control buttons */
|
||||
|
||||
#define BUTTON_RC_HEART 0x00000002
|
||||
#define BUTTON_RC_MODE 0x00000004
|
||||
#define BUTTON_RC_VOL_DOWN 0x00000008
|
||||
#define BUTTON_RC_PLAY 0x00000001
|
||||
#define BUTTON_RC_DOWN 0x00000002
|
||||
#define BUTTON_RC_FF 0x00000004
|
||||
#define BUTTON_RC_REW 0x00000008
|
||||
#define BUTTON_RC_VOL_UP 0x00000010
|
||||
#define BUTTON_RC_VOL_DOWN 0x00000020
|
||||
#define BUTTON_RC_MODE 0x00000040
|
||||
#define BUTTON_RC_HEART 0x00000080
|
||||
|
||||
|
||||
#define BUTTON_RC_PLAY 0x00000020
|
||||
#define BUTTON_RC_REW 0x00000040
|
||||
#define BUTTON_RC_FF 0x00000080
|
||||
#define BUTTON_RC_DOWN 0x00000100
|
||||
#define BUTTON_TOUCH 0x00000200
|
||||
|
||||
/* compatibility hacks */
|
||||
|
|
|
@ -19,34 +19,25 @@
|
|||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "string.h"
|
||||
#include "panic.h"
|
||||
|
||||
/* UART 0/1 */
|
||||
|
||||
#define CONFIG_UART_BRSR 87
|
||||
#define MAX_UART_BUFFER 31
|
||||
static unsigned char uart1buffer[MAX_UART_BUFFER], uart1_send_buffer_ring[512];
|
||||
int uart1_send_count=0,uart1_send_point=0;
|
||||
int uart1read = 0, uart1write = 0, uart1count = 0;
|
||||
#define SEND_RING_SIZE 256
|
||||
#define RECIEVE_RING_SIZE 20
|
||||
|
||||
/*
|
||||
static void do_checksums(char *data, int len, char *xor, char *add)
|
||||
{
|
||||
int i;
|
||||
*xor = data[0];
|
||||
*add = data[0];
|
||||
for(i=1;i<len;i++)
|
||||
{
|
||||
*xor ^= data[i];
|
||||
*add += data[i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
char
|
||||
// uart1_send_buffer_ring[SEND_RING_SIZE],
|
||||
uart1_recieve_buffer_ring[RECIEVE_RING_SIZE];
|
||||
|
||||
//static unsigned int uart1_send_count, uart1_send_read, uart1_send_write;
|
||||
static unsigned int uart1_recieve_count, uart1_recieve_read, uart1_recieve_write;
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
// 8-N-1
|
||||
IO_UART1_MSR=0x8000;
|
||||
IO_UART1_BRSR=CONFIG_UART_BRSR;
|
||||
IO_UART1_BRSR=0x0057;
|
||||
IO_UART1_RFCR = 0x8010; /* Trigger later */
|
||||
/* gio 27 is input, uart1 rx
|
||||
gio 28 is output, uart1 tx */
|
||||
|
@ -54,10 +45,10 @@ void uart_init(void)
|
|||
IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */
|
||||
|
||||
/* init the recieve buffer */
|
||||
uart1read = 0;
|
||||
uart1write = 0;
|
||||
uart1count = 0;
|
||||
|
||||
uart1_recieve_count=0;
|
||||
uart1_recieve_read=0;
|
||||
uart1_recieve_write=0;
|
||||
|
||||
/* Enable the interrupt */
|
||||
IO_INTC_EINT0 |= (1<<IRQ_UART1);
|
||||
}
|
||||
|
@ -71,18 +62,6 @@ void uart1_putc(char ch)
|
|||
IO_UART1_DTRR=ch;
|
||||
}
|
||||
|
||||
/* Unsigned integer to ASCII hexadecimal conversion */
|
||||
void uart1_putHex(unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 8; i != 0; i--) {
|
||||
unsigned int digit = n >> 28;
|
||||
uart1_putc(digit >= 10 ? digit - 10 + 'A' : digit + '0');
|
||||
n <<= 4;
|
||||
}
|
||||
}
|
||||
|
||||
void uart1_puts(const char *str)
|
||||
{
|
||||
char ch;
|
||||
|
@ -91,62 +70,47 @@ void uart1_puts(const char *str)
|
|||
}
|
||||
}
|
||||
|
||||
void uart1_gets(char *str, unsigned int size)
|
||||
/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/
|
||||
int uart1_gets_queue(char *str, unsigned int size)
|
||||
{
|
||||
for (;;) {
|
||||
char ch;
|
||||
|
||||
/* Wait for FIFO to contain something */
|
||||
while ((IO_UART1_RFCR & 0x3f) == 0);
|
||||
|
||||
/* Read character */
|
||||
ch = (char)IO_UART1_DTRR;
|
||||
if(uart1_recieve_count<size)
|
||||
return -uart1_recieve_count;
|
||||
|
||||
/* If CR, also echo LF, null-terminate, and return */
|
||||
if (ch == '\r') {
|
||||
IO_UART1_DTRR='\n';
|
||||
if (size) {
|
||||
*str++ = '\0';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Append to buffer */
|
||||
if (size) {
|
||||
*str++ = ch;
|
||||
--size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool uart1_getch(char *c)
|
||||
{
|
||||
if (uart1count > 0)
|
||||
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
||||
{
|
||||
if(uart1read>MAX_UART_BUFFER)
|
||||
uart1read=0;
|
||||
|
||||
*c = uart1buffer[uart1read++];
|
||||
uart1count--;
|
||||
return true;
|
||||
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size);
|
||||
}
|
||||
return false;
|
||||
else
|
||||
{
|
||||
int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read);
|
||||
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount);
|
||||
memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount);
|
||||
}
|
||||
|
||||
uart1_recieve_count-=size;
|
||||
|
||||
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
||||
uart1_recieve_read+=size;
|
||||
else
|
||||
uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
|
||||
|
||||
return uart1_recieve_count;
|
||||
}
|
||||
|
||||
/* UART1 receive intterupt handler */
|
||||
/* UART1 receive interupt handler */
|
||||
void UART1(void)
|
||||
{
|
||||
while (IO_UART1_RFCR & 0x3f)
|
||||
{
|
||||
if (uart1count > MAX_UART_BUFFER)
|
||||
if (uart1_recieve_count > RECIEVE_RING_SIZE)
|
||||
panicf("UART1 buffer overflow");
|
||||
else
|
||||
{
|
||||
if(uart1write>MAX_UART_BUFFER)
|
||||
uart1write=0;
|
||||
if(uart1_recieve_write==RECIEVE_RING_SIZE)
|
||||
uart1_recieve_write=0;
|
||||
|
||||
uart1buffer[uart1write++] = IO_UART1_DTRR & 0xff;
|
||||
uart1count++;
|
||||
uart1_recieve_buffer_ring[uart1_recieve_write++] = IO_UART1_DTRR & 0xff;
|
||||
uart1_recieve_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ bool uart1_getch(char *c);
|
|||
void uart1_heartbeat(void);
|
||||
bool uart1_available(void);
|
||||
|
||||
int uart1_gets_queue(char *, unsigned int);
|
||||
void uart1_puts(const char *str);
|
||||
void uart1_gets(char *str, unsigned int size);
|
||||
int uart1_pollch(unsigned int ticks);
|
||||
|
|
Loading…
Reference in New Issue
Block a user