diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2007-10-18 05:14:10 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2007-10-18 05:14:10 +0000 |
commit | fa1a38e7ce1facd0af3e94f51cdf0ec38f9a4b46 (patch) | |
tree | de82c2d42cdc72507b4ba6fdd030e21f1c75104d /firmware/target/arm/tms320dm320 | |
parent | a443614dd20ef0fe7ca7d723d6ea4428a4da522c (diff) |
Some changes to the UART/button driver - reduce the number of interrupts - more work is needed
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15180 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320')
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 58 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-dm320.c | 88 |
2 files changed, 65 insertions, 81 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 21ef7f8534..ab5860ab02 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -69,6 +69,7 @@ static int touch_to_pixels(short val_x, short val_y) y = 0; return (x<<16)|y; } + void button_init_device(void) { last_touch = 0; @@ -102,53 +103,56 @@ int button_get_last_touch(void) } #endif +static void remote_heartbeat(void) +{ + char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; + uart1_puts(data); +} + int button_read_device(void) { - char data[5], c; + char c; int i = 0; int btn = BUTTON_NONE; if (last_touch) btn |= BUTTON_TOUCHPAD; - + if ((IO_GIO_BITSET0&0x01) == 0) btn |= BUTTON_POWER; - - uart1_heartbeat(); - while (uart1_available()) + + remote_heartbeat(); + while (uart1_getch(&c)) { - if (uart1_getch(&c)) + if (i==0 && (c == BUTTON_START_BYTE || c == BUTTON_START_BYTE2) ) { - if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2)) - { - data[i++] = c; - } - else if (c == BUTTON_START_BYTE || - c == BUTTON_START_BYTE2) - { - data[0] = c; - i = 1; - } - - if (i == 5) + i++; + } + else if (i) + { + i++; + if(i==2) { - if (data[1]& (1<<7)) + if (c& (1<<7)) btn |= BUTTON_RC_HEART; - if (data[1]& (1<<6)) + if (c& (1<<6)) btn |= BUTTON_RC_MODE; - if (data[1]& (1<<5)) + if (c& (1<<5)) btn |= BUTTON_RC_VOL_DOWN; - if (data[1]& (1<<4)) + if (c& (1<<4)) btn |= BUTTON_RC_VOL_UP; - if (data[1]& (1<<3)) + if (c& (1<<3)) btn |= BUTTON_RC_REW; - if (data[1]& (1<<2)) + if (c& (1<<2)) btn |= BUTTON_RC_FF; - if (data[1]& (1<<1)) + if (c& (1<<1)) btn |= BUTTON_RC_DOWN; - if (data[1]& (1<<0)) + if (c& (1<<0)) btn |= BUTTON_RC_PLAY; - break; + } + else if(i==5) + { + i=0; } } } diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c index f50add4363..6425b75960 100644 --- a/firmware/target/arm/tms320dm320/uart-dm320.c +++ b/firmware/target/arm/tms320dm320/uart-dm320.c @@ -1,22 +1,21 @@ -/* - * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca> +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. + * Copyright (C) 2007 Catalin Patulea <cat@vv.carleton.ca> * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. * - */ + ****************************************************************************/ #include "config.h" #include "cpu.h" #include "system.h" @@ -24,8 +23,8 @@ /* UART 0/1 */ #define CONFIG_UART_BRSR 87 -#define MAX_UART_BUFFER 32 -static unsigned char uart1buffer[MAX_UART_BUFFER]; +#define MAX_UART_BUFFER 31 +unsigned char uart1buffer[MAX_UART_BUFFER]; int uart1read = 0, uart1write = 0, uart1count = 0; /* @@ -42,17 +41,17 @@ static void do_checksums(char *data, int len, char *xor, char *add) } */ -void uart_init(void) +void uart_init(void) { // 8-N-1 IO_UART1_MSR=0x8000; IO_UART1_BRSR=CONFIG_UART_BRSR; - IO_UART1_RFCR = 0x8000; + IO_UART1_RFCR = 0x8010; /* Trigger later */ /* gio 27 is input, uart1 rx gio 28 is output, uart1 tx */ IO_GIO_DIR1 |= (1<<11); /* gio 27 */ IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */ - + /* init the recieve buffer */ uart1read = 0; uart1write = 0; @@ -101,10 +100,7 @@ void uart1_gets(char *str, unsigned int size) /* Read character */ ch = (char)IO_UART1_DTRR; - - /* Echo character back */ - IO_UART1_DTRR=ch; - + /* If CR, also echo LF, null-terminate, and return */ if (ch == '\r') { IO_UART1_DTRR='\n'; @@ -122,33 +118,14 @@ void uart1_gets(char *str, unsigned int size) } } -int uart1_pollch(unsigned int ticks) -{ - while (ticks--) { - if (IO_UART1_RFCR & 0x3f) { - return IO_UART1_DTRR & 0xff; - } - } - return -1; -} - -bool uart1_available(void) -{ - return uart1count > 0; -} - -void uart1_heartbeat(void) -{ - char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; - uart1_puts(data); -} - bool uart1_getch(char *c) { if (uart1count > 0) { - *c = uart1buffer[uart1read]; - uart1read = (uart1read+1) % MAX_UART_BUFFER; + if(uart1read>MAX_UART_BUFFER) + uart1read=0; + + *c = uart1buffer[uart1read++]; uart1count--; return true; } @@ -158,15 +135,18 @@ bool uart1_getch(char *c) /* UART1 receive intterupt handler */ void UART1(void) { - if (IO_UART1_RFCR & 0x3f) + while (IO_UART1_RFCR & 0x3f) { -/* - if (uart1count >= MAX_UART_BUFFER) + if (uart1count > MAX_UART_BUFFER) panicf("UART1 buffer overflow"); -*/ - uart1buffer[uart1write] = IO_UART1_DTRR & 0xff; - uart1write = (uart1write+1) % MAX_UART_BUFFER; - uart1count++; + else + { + if(uart1write>MAX_UART_BUFFER) + uart1write=0; + + uart1buffer[uart1write++] = IO_UART1_DTRR & 0xff; + uart1count++; + } } IO_INTC_IRQ0 = (1<<IRQ_UART1); |