# HG changeset patch # User gthomas # Date 1068226448 0 # Node ID c93f753dce60d8bfb819ff5be2ae206dccab0cef # Parent 5853b9c805581251ed18ce44a6ba8346682a2ae8 Fix for LEDs diff --git a/packages/hal/powerpc/rattler/current/ChangeLog b/packages/hal/powerpc/rattler/current/ChangeLog --- a/packages/hal/powerpc/rattler/current/ChangeLog +++ b/packages/hal/powerpc/rattler/current/ChangeLog @@ -1,3 +1,8 @@ +2003-11-07 Gary Thomas + + * src/hal_aux.c (_rattler_leds): New function. Also set up I/O bits + properly to support LEDs. + 2003-10-22 Gary Thomas * cdl/hal_powerpc_rattler.cdl: Add CDL to identify board model. diff --git a/packages/hal/powerpc/rattler/current/src/hal_aux.c b/packages/hal/powerpc/rattler/current/src/hal_aux.c --- a/packages/hal/powerpc/rattler/current/src/hal_aux.c +++ b/packages/hal/powerpc/rattler/current/src/hal_aux.c @@ -158,16 +158,16 @@ 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 @@ -423,4 +423,22 @@ void 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<io_regs[PORT_A].pdat = new_val; + return old_val; +} + // EOF hal_aux.c