This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Rattler - Fix LEDs


Note: this requires a rebuild of RedBoot to take effect.

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: hal/powerpc/rattler/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/rattler/current/ChangeLog,v
retrieving revision 1.7
diff -u -5 -p -r1.7 ChangeLog
--- hal/powerpc/rattler/current/ChangeLog	22 Oct 2003 21:12:01 -0000	1.7
+++ hal/powerpc/rattler/current/ChangeLog	7 Nov 2003 15:34:46 -0000
@@ -1,5 +1,10 @@
+2003-11-07  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/hal_aux.c (_rattler_leds): New function.  Also set up I/O bits
+	properly to support LEDs.
+
 2003-10-22  Gary Thomas  <gary@mlbassoc.com>
 
 	* cdl/hal_powerpc_rattler.cdl: Add CDL to identify board model.
 
 2003-09-21  Gary Thomas  <gary@mlbassoc.com>
Index: hal/powerpc/rattler/current/src/hal_aux.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/rattler/current/src/hal_aux.c,v
retrieving revision 1.4
diff -u -5 -p -r1.4 hal_aux.c
--- hal/powerpc/rattler/current/src/hal_aux.c	8 Sep 2003 17:54:53 -0000	1.4
+++ hal/powerpc/rattler/current/src/hal_aux.c	7 Nov 2003 15:30:58 -0000
@@ -156,20 +156,20 @@ hal_platform_init(void)
     //          +------------------------
     //         +-------------------------
     //        +--------------------------
     //       +---------------------------
     //      +----------------------------
-    //     +-----------------------------
-    //    +------------------------------
-    //   +-------------------------------
+    //     +-----------------------------  LED2
+    //    +------------------------------  LED1
+    //   +-------------------------------  LED0
     //   ++++ ++++ ++++ ++AA AACC CC++ ++BB DDBB
     //   0000 0000 0000 0011 1111 1100 0011 1111 PAR
     //   0000 0000 0000 0000 0000 0000 0011 1111 SOR
     //   0000 0000 0000 0000 0011 1100 0000 1100 DIR
     IMM->io_regs[PORT_A].ppar = 0x0003FC3F;
     IMM->io_regs[PORT_A].psor = 0x0000003F;
-    IMM->io_regs[PORT_A].pdir = 0x00003C0C;
+    IMM->io_regs[PORT_A].pdir = 0xE0003C0C;
     IMM->io_regs[PORT_A].podr = 0x00000000;
 
     // Port B
     //             1111111111222222222233
     //   01234567890123456789012345678901
@@ -419,8 +419,26 @@ _rattler_reset(void)
     CYGARC_MFSPR(CYGARC_REG_HID0, hid0); 
     hid0 |= 0x30000000;
     CYGARC_MTSPR(CYGARC_REG_HID0, hid0); 
     diag_printf("...RESET\n");
     while (1) ;
+}
+
+//
+// Display a value in the LEDs
+// Note: the values used/returned by this function are positive
+// i.e. a value of 0 is all LEDs off, 0x7 is all on
+//
+#define LED_SHIFT 29  // LEDs are in bits A0..A2
+#define LED_MASK   7  // 3 bits total
+int
+_rattler_leds(int val)
+{
+    volatile t_PQ2IMM  *IMM = (volatile t_PQ2IMM *)CYGARC_IMM_BASE;
+    unsigned int old_val = ~(IMM->io_regs[PORT_A].pdat >> LED_SHIFT) & LED_MASK;
+    unsigned int new_val = (old_val & ~(LED_MASK<<LED_SHIFT)) | ((~val&LED_MASK)<<LED_SHIFT);
+
+    IMM->io_regs[PORT_A].pdat = new_val;
+    return old_val;
 }
 
 // EOF hal_aux.c

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]