mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-24 21:13:20 +02:00
258 lines
8.6 KiB
Diff
258 lines
8.6 KiB
Diff
|
Index: rtems/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h
|
||
|
===================================================================
|
||
|
--- rtems.orig/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h 2011-08-01 10:48:11.000000000 -0300
|
||
|
+++ rtems/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h 2011-11-20 16:02:10.000000000 -0300
|
||
|
@@ -26,6 +26,16 @@
|
||
|
/* UART */
|
||
|
#define MM_UART_RXTX (0xe0000000)
|
||
|
#define MM_UART_DIV (0xe0000004)
|
||
|
+#define MM_UART_STAT (0xe0000008)
|
||
|
+#define MM_UART_CTRL (0xe000000c)
|
||
|
+
|
||
|
+#define UART_STAT_THRE (0x1)
|
||
|
+#define UART_STAT_RX_EVT (0x2)
|
||
|
+#define UART_STAT_TX_EVT (0x4)
|
||
|
+
|
||
|
+#define UART_CTRL_RX_INT (0x1)
|
||
|
+#define UART_CTRL_TX_INT (0x2)
|
||
|
+#define UART_CTRL_THRU (0x4)
|
||
|
|
||
|
/* Timers */
|
||
|
#define MM_TIMER1_COMPARE (0xe0001024)
|
||
|
@@ -225,8 +235,17 @@
|
||
|
|
||
|
/* MIDI */
|
||
|
#define MM_MIDI_RXTX (0xe000b000)
|
||
|
-#define MM_MIDI_DIVISOR (0xe000b004)
|
||
|
-#define MM_MIDI_THRU (0xe000b008)
|
||
|
+#define MM_MIDI_DIV (0xe000b004)
|
||
|
+#define MM_MIDI_STAT (0xe000b008)
|
||
|
+#define MM_MIDI_CTRL (0xe000b00c)
|
||
|
+
|
||
|
+#define MIDI_STAT_THRE (0x1)
|
||
|
+#define MIDI_STAT_RX_EVT (0x2)
|
||
|
+#define MIDI_STAT_TX_EVT (0x4)
|
||
|
+
|
||
|
+#define MIDI_CTRL_RX_INT (0x1)
|
||
|
+#define MIDI_CTRL_TX_INT (0x2)
|
||
|
+#define MIDI_CTRL_THRU (0x4)
|
||
|
|
||
|
/* IR */
|
||
|
#define MM_IR_RX (0xe000e000)
|
||
|
@@ -248,24 +267,22 @@
|
||
|
#define BT656_FILTER_INFRAME (0x4)
|
||
|
|
||
|
/* Interrupts */
|
||
|
-#define MM_IRQ_UARTRX (0)
|
||
|
-#define MM_IRQ_UARTTX (1)
|
||
|
-#define MM_IRQ_GPIO (2)
|
||
|
-#define MM_IRQ_TIMER0 (3)
|
||
|
-#define MM_IRQ_TIMER1 (4)
|
||
|
-#define MM_IRQ_AC97CRREQUEST (5)
|
||
|
-#define MM_IRQ_AC97CRREPLY (6)
|
||
|
-#define MM_IRQ_AC97DMAR (7)
|
||
|
-#define MM_IRQ_AC97DMAW (8)
|
||
|
-#define MM_IRQ_PFPU (9)
|
||
|
-#define MM_IRQ_TMU (10)
|
||
|
-#define MM_IRQ_ETHRX (11)
|
||
|
-#define MM_IRQ_ETHTX (12)
|
||
|
-#define MM_IRQ_VIDEOIN (13)
|
||
|
-#define MM_IRQ_MIDIRX (14)
|
||
|
-#define MM_IRQ_MIDITX (15)
|
||
|
-#define MM_IRQ_IR (16)
|
||
|
-#define MM_IRQ_USB (17)
|
||
|
+#define MM_IRQ_UART (0)
|
||
|
+#define MM_IRQ_GPIO (1)
|
||
|
+#define MM_IRQ_TIMER0 (2)
|
||
|
+#define MM_IRQ_TIMER1 (3)
|
||
|
+#define MM_IRQ_AC97CRREQUEST (4)
|
||
|
+#define MM_IRQ_AC97CRREPLY (5)
|
||
|
+#define MM_IRQ_AC97DMAR (6)
|
||
|
+#define MM_IRQ_AC97DMAW (7)
|
||
|
+#define MM_IRQ_PFPU (8)
|
||
|
+#define MM_IRQ_TMU (9)
|
||
|
+#define MM_IRQ_ETHRX (10)
|
||
|
+#define MM_IRQ_ETHTX (11)
|
||
|
+#define MM_IRQ_VIDEOIN (12)
|
||
|
+#define MM_IRQ_MIDI (13)
|
||
|
+#define MM_IRQ_IR (14)
|
||
|
+#define MM_IRQ_USB (15)
|
||
|
|
||
|
/* Flash layout */
|
||
|
#define FLASH_BASE (0x80000000)
|
||
|
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
|
||
|
===================================================================
|
||
|
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c 2011-08-01 10:48:39.000000000 -0300
|
||
|
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c 2011-11-20 16:02:10.000000000 -0300
|
||
|
@@ -119,25 +119,24 @@
|
||
|
rtems_interrupt_level level;
|
||
|
|
||
|
rtems_interrupt_disable(level);
|
||
|
- BSP_uart_txbusy = true;
|
||
|
MM_WRITE(MM_UART_RXTX, *buf);
|
||
|
rtems_interrupt_enable(level);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static rtems_isr mmconsole_txdone(rtems_vector_number n)
|
||
|
-{
|
||
|
- BSP_uart_txbusy = false;
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
|
||
|
- rtems_termios_dequeue_characters(tty, 1);
|
||
|
-}
|
||
|
-
|
||
|
-static rtems_isr mmconsole_rxdone(rtems_vector_number n)
|
||
|
+static rtems_isr mmconsole_interrupt(rtems_vector_number n)
|
||
|
{
|
||
|
char c;
|
||
|
- c = MM_READ(MM_UART_RXTX);
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_UARTRX);
|
||
|
- rtems_termios_enqueue_raw_characters(tty, &c, 1);
|
||
|
+ while (MM_READ(MM_UART_STAT) & UART_STAT_RX_EVT) {
|
||
|
+ c = MM_READ(MM_UART_RXTX);
|
||
|
+ MM_WRITE(MM_UART_STAT, UART_STAT_RX_EVT);
|
||
|
+ rtems_termios_enqueue_raw_characters(tty, &c, 1);
|
||
|
+ }
|
||
|
+ if (MM_READ(MM_UART_STAT) & UART_STAT_TX_EVT) {
|
||
|
+ MM_WRITE(MM_UART_STAT, UART_STAT_TX_EVT);
|
||
|
+ rtems_termios_dequeue_characters(tty, 1);
|
||
|
+ }
|
||
|
+ lm32_interrupt_ack(1 << MM_IRQ_UART);
|
||
|
}
|
||
|
|
||
|
static const rtems_termios_callbacks mmconsole_callbacks = {
|
||
|
@@ -166,10 +165,9 @@
|
||
|
if (status != RTEMS_SUCCESSFUL)
|
||
|
rtems_fatal_error_occurred(status);
|
||
|
|
||
|
- rtems_interrupt_catch(mmconsole_txdone, MM_IRQ_UARTTX, &dummy);
|
||
|
- rtems_interrupt_catch(mmconsole_rxdone, MM_IRQ_UARTRX, &dummy);
|
||
|
- bsp_interrupt_vector_enable(MM_IRQ_UARTTX);
|
||
|
- bsp_interrupt_vector_enable(MM_IRQ_UARTRX);
|
||
|
+ rtems_interrupt_catch(mmconsole_interrupt, MM_IRQ_UART, &dummy);
|
||
|
+ bsp_interrupt_vector_enable(MM_IRQ_UART);
|
||
|
+ MM_WRITE(MM_UART_CTRL, UART_CTRL_RX_INT|UART_CTRL_TX_INT);
|
||
|
|
||
|
return RTEMS_SUCCESSFUL;
|
||
|
}
|
||
|
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c
|
||
|
===================================================================
|
||
|
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c 2011-08-01 10:48:39.000000000 -0300
|
||
|
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c 2011-11-20 16:02:10.000000000 -0300
|
||
|
@@ -17,8 +17,6 @@
|
||
|
#include "../include/system_conf.h"
|
||
|
#include "uart.h"
|
||
|
|
||
|
-bool BSP_uart_txbusy;
|
||
|
-
|
||
|
void BSP_uart_init(int baud)
|
||
|
{
|
||
|
MM_WRITE(MM_UART_DIV, CPU_FREQUENCY/baud/16);
|
||
|
@@ -26,40 +24,24 @@
|
||
|
|
||
|
void BSP_uart_polled_write(char ch)
|
||
|
{
|
||
|
- int ip;
|
||
|
rtems_interrupt_level level;
|
||
|
|
||
|
rtems_interrupt_disable(level);
|
||
|
- if (BSP_uart_txbusy) {
|
||
|
- /* wait for the end of the transmission by the IRQ-based driver */
|
||
|
- do {
|
||
|
- lm32_read_interrupts(ip);
|
||
|
- } while (!(ip & (1 << MM_IRQ_UARTTX)));
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
|
||
|
- }
|
||
|
+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_THRE));
|
||
|
MM_WRITE(MM_UART_RXTX, ch);
|
||
|
- do {
|
||
|
- lm32_read_interrupts(ip);
|
||
|
- } while (!(ip & (1 << MM_IRQ_UARTTX)));
|
||
|
- /* if TX was busy, do not ack the IRQ
|
||
|
- * so that the IRQ-based driver ISR is run */
|
||
|
- if (!BSP_uart_txbusy)
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
|
||
|
+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_THRE));
|
||
|
rtems_interrupt_enable(level);
|
||
|
}
|
||
|
|
||
|
int BSP_uart_polled_read(void)
|
||
|
{
|
||
|
- int ip;
|
||
|
char r;
|
||
|
rtems_interrupt_level level;
|
||
|
|
||
|
rtems_interrupt_disable(level);
|
||
|
- do {
|
||
|
- lm32_read_interrupts(ip);
|
||
|
- } while (!(ip & (1 << MM_IRQ_UARTRX)));
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_UARTRX);
|
||
|
+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_RX_EVT));
|
||
|
r = MM_READ(MM_UART_RXTX);
|
||
|
+ MM_WRITE(MM_UART_STAT, UART_STAT_RX_EVT);
|
||
|
rtems_interrupt_enable(level);
|
||
|
|
||
|
return r;
|
||
|
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h
|
||
|
===================================================================
|
||
|
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h 2011-08-01 10:48:39.000000000 -0300
|
||
|
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h 2011-11-20 16:02:10.000000000 -0300
|
||
|
@@ -1,21 +1,16 @@
|
||
|
/*
|
||
|
- * This file contains definitions for LatticeMico32 UART
|
||
|
+ * This file contains definitions for the Milkymist UART
|
||
|
*
|
||
|
* The license and distribution terms for this file may be
|
||
|
* found in the file LICENSE in this distribution or at
|
||
|
* http://www.rtems.com/license/LICENSE.
|
||
|
*
|
||
|
* $Id: uart.h,v 1.2 2011/08/01 13:48:39 joel Exp $
|
||
|
- *
|
||
|
- * COPYRIGHT (c) Yann Sionneau <yann.sionneau@telecom-sudparis.eu> (GSoC 2010)
|
||
|
- * Telecom SudParis
|
||
|
*/
|
||
|
|
||
|
#ifndef _BSPUART_H
|
||
|
#define _BSPUART_H
|
||
|
|
||
|
-extern bool BSP_uart_txbusy;
|
||
|
-
|
||
|
void BSP_uart_init(int baud);
|
||
|
void BSP_uart_polled_write(char ch);
|
||
|
int BSP_uart_polled_read(void);
|
||
|
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c
|
||
|
===================================================================
|
||
|
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c 2011-08-01 10:48:40.000000000 -0300
|
||
|
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c 2011-11-20 16:02:10.000000000 -0300
|
||
|
@@ -31,9 +31,12 @@
|
||
|
{
|
||
|
unsigned char msg;
|
||
|
|
||
|
- lm32_interrupt_ack(1 << MM_IRQ_MIDIRX);
|
||
|
- msg = MM_READ(MM_MIDI_RXTX);
|
||
|
- rtems_message_queue_send(midi_q, &msg, 1);
|
||
|
+ while (MM_READ(MM_MIDI_STAT) & MIDI_STAT_RX_EVT) {
|
||
|
+ msg = MM_READ(MM_MIDI_RXTX);
|
||
|
+ MM_WRITE(MM_MIDI_STAT, MIDI_STAT_RX_EVT);
|
||
|
+ rtems_message_queue_send(midi_q, &msg, 1);
|
||
|
+ }
|
||
|
+ lm32_interrupt_ack(1 << MM_IRQ_MIDI);
|
||
|
}
|
||
|
|
||
|
rtems_device_driver midi_initialize(
|
||
|
@@ -57,11 +60,10 @@
|
||
|
);
|
||
|
RTEMS_CHECK_SC(sc, "create MIDI queue");
|
||
|
|
||
|
- rtems_interrupt_catch(interrupt_handler, MM_IRQ_MIDIRX, &dummy);
|
||
|
- bsp_interrupt_vector_enable(MM_IRQ_MIDIRX);
|
||
|
-
|
||
|
+ rtems_interrupt_catch(interrupt_handler, MM_IRQ_MIDI, &dummy);
|
||
|
+ bsp_interrupt_vector_enable(MM_IRQ_MIDI);
|
||
|
/* Only MIDI THRU mode is supported atm */
|
||
|
- MM_WRITE(MM_MIDI_THRU, 1);
|
||
|
+ MM_WRITE(MM_MIDI_CTRL, MIDI_CTRL_RX_INT|MIDI_CTRL_THRU);
|
||
|
|
||
|
return RTEMS_SUCCESSFUL;
|
||
|
}
|