changeset 1049:d0c85774766f

* src/eb40a_misc.c: LED routines were using the wrong bits. * include/plf_io.h LED defines were using the wrong bits Added defines for the EB40a board push buttons
author asl
date Thu, 12 Jun 2003 17:03:56 +0000
parents 4d9dfbffc2d1
children c07b9a1eed80
files packages/hal/arm/at91/eb40a/current/ChangeLog packages/hal/arm/at91/eb40a/current/include/plf_io.h packages/hal/arm/at91/eb40a/current/src/eb40a_misc.c
diffstat 3 files changed, 38 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/arm/at91/eb40a/current/ChangeLog
+++ b/packages/hal/arm/at91/eb40a/current/ChangeLog
@@ -1,3 +1,12 @@
+2003-06-11  Oyvind Harboe  <oyvind.harboe@zylin.com>
+	
+	* src/eb40a_misc.c:
+	LED routines were using the wrong bits.
+	
+	* include/plf_io.h
+	LED defines were using the wrong bits
+	Added defines for the EB40a board push buttons
+	
 2003-05-12  Nick Garnett  <nickg@balti.calivar.com>
 
 	* src/eb40a_misc.c:
--- a/packages/hal/arm/at91/eb40a/current/include/plf_io.h
+++ b/packages/hal/arm/at91/eb40a/current/include/plf_io.h
@@ -53,15 +53,30 @@
 //
 //=============================================================================
 
-// EB40A onboard LEDs mapped to PIO pins
-#define EB40A_LED1 0x00010000
-#define EB40A_LED2 0x00020000
-#define EB40A_LED3 0x00040000
-#define EB40A_LED4 0x00080000
-#define EB40A_LED5 0x00000008
-#define EB40A_LED6 0x00000010
-#define EB40A_LED7 0x00000020
-#define EB40A_LED8 0x00000040
+// these io pins are for the LEDs.
+#define EB40A_LED1 0x00000008
+#define EB40A_LED2 0x00000010
+#define EB40A_LED3 0x00000020
+#define EB40A_LED4 0x00000040
+// these PIOs double as TCLK1, TIOA1, TIOB1, TCLK2 respectively.
+#define EB40A_LED5 0x00010000
+#define EB40A_LED6 0x00020000
+#define EB40A_LED7 0x00040000
+#define EB40A_LED8 0x00080000
+
+#define EB40A_LED_ALL 0x00f00078
+
+// Push buttons. Note that these are connected to interrupt lines.
+#define EB40A_SW1 0x00001000
+#define EB40A_SW2 0x00000100
+#define EB40A_SW3 0x00000002
+#define EB40A_SW4 0x00000004
+
+// Push buttons. Note that these are connected to interrupt lines.
+#define EB40A_SW1 0x00001000 
+#define EB40A_SW2 0x00000100 
+#define EB40A_SW3 0x00000002
+#define EB40A_SW4 0x00000004
 
 //-----------------------------------------------------------------------------
 // end of plf_io.h
--- a/packages/hal/arm/at91/eb40a/current/src/eb40a_misc.c
+++ b/packages/hal/arm/at91/eb40a/current/src/eb40a_misc.c
@@ -62,16 +62,16 @@
 void
 hal_at91_set_leds(int val)
 {
-    HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR, 0x000F0078); // turn all LEDs off
+    HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR, EB40A_LED_ALL); // turn all LEDs off
     HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,
-                     ((val&0xf)<<3)|((val&0xf0)<<12));        // turn desired LEDs on
+                     ((val&0xf)<<16)|(((val&0xf0)>>4)<<3));        // turn desired LEDs on
 }
 
 void
 hal_at91_led_on(int val)
 {
     HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,
-                     ((val&0xf)<<3)|((val&0xf0)<<12));
+                     ((val&0xf)<<16)|(((val&0xf0)>>4)<<3));
 }
 
 void
@@ -82,11 +82,11 @@ hal_at91_led_off(int val)
 }
 
 int
-hal_at91_get_leds()
+hal_at91_get_leds(void)
 {
     int leds = 0;
     HAL_READ_UINT32(AT91_PIO+AT91_PIO_PDSR, leds);
-    return ((leds>>3)&0xf)|((leds>>12)&0xf0);
+    return (((leds>>3)&0xf)<<4)|((leds>>16)&0xf);
 }
 
 //--------------------------------------------------------------------------