Add LED logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@713 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
d1d8a1f5d5
commit
484699098a
@ -60,9 +60,9 @@
|
||||
#define LED_STACKCREATED 3
|
||||
#define LED_IDLE 4
|
||||
#define LED_INIRQ 5
|
||||
#define LED_ASSERTION 6
|
||||
#define LED_SIGNAL 6
|
||||
#define LED_PANIC 7
|
||||
#define LED_ASSERTION 7
|
||||
#define LED_PANIC 8
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -54,14 +54,142 @@
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Port G: Anode Bit Assignments (1 enables) */
|
||||
|
||||
#define Z8_PORTG_ANODE_MASK 0x7f
|
||||
#define Z8_PORTG_ANODE_ROW0 0x01
|
||||
#define Z8_PORTG_ANODE_ROW1 0x02
|
||||
#define Z8_PORTG_ANODE_ROW2 0x04
|
||||
#define Z8_PORTG_ANODE_ROW3 0x08
|
||||
#define Z8_PORTG_ANODE_ROW4 0x10
|
||||
#define Z8_PORTG_ANODE_ROW5 0x20
|
||||
#define Z8_PORTG_ANODE_ROW6 0x40
|
||||
|
||||
/* Port E: Cathode Bit Assignements (0 enables) */
|
||||
|
||||
#define Z8_PORTE_CATHODE_MASK 0x1f
|
||||
#define Z8_PORTE_CATHODE_COLUMN0 0x01
|
||||
#define Z8_PORTE_CATHODE_COLUMN1 0x02
|
||||
#define Z8_PORTE_CATHODE_COLUMN2 0x04
|
||||
#define Z8_PORTE_CATHODE_COLUMN3 0x08
|
||||
#define Z8_PORTE_CATHODE_COLUMN4 0x10
|
||||
|
||||
/* Port E: LED Addressing */
|
||||
|
||||
#define Z8_PORTE_LED_MASK 0xe0
|
||||
#define Z8_PORTE_LED_D3 0x20
|
||||
#define Z8_PORTE_LED_D4 0x40
|
||||
#define Z8_PORTE_LED_D1 0x80
|
||||
|
||||
/* Port G: LED Addressing */
|
||||
|
||||
#define Z8_PORTG_LED_MASK 0x80
|
||||
#define Z8_PORTG_LED_D2 0x80
|
||||
|
||||
/* Special values for display */
|
||||
|
||||
#define LED_ALLON { Z8_PORTG_ANODE_MASK, 0x00 }
|
||||
#define LED_ALLOFF { 0x00, Z8_PORTE_CATHODE_MASK }
|
||||
#define LED_LEVEL1 { 0x10, 0x00 }
|
||||
#define LED_LEVEL2 { 0x08, 0x00 }
|
||||
#define LED_LEVEL3 { 0x04, 0x00 }
|
||||
#define LED_LEVEL4 { 0x02, 0x00 }
|
||||
#define LED_LEVEL1I { 0x14, 0x00 }
|
||||
#define LED_LEVEL2I { 0x0c, 0x00 }
|
||||
#define LED_LEVEL3I { 0x04, 0x00 }
|
||||
#define LED_LEVEL4I { 0x06, 0x00 }
|
||||
#define LED_LEVEL1S { 0x11, 0x00 }
|
||||
#define LED_LEVEL2S { 0x09, 0x00 }
|
||||
#define LED_LEVEL3S { 0x05, 0x00 }
|
||||
#define LED_LEVEL4S { 0x03, 0x00 }
|
||||
#define LED_LEVEL1A { 0x10, 0x11 }
|
||||
#define LED_LEVEL2A { 0x08, 0x11 }
|
||||
#define LED_LEVEL3A { 0x04, 0x11 }
|
||||
#define LED_LEVEL4A { 0x02, 0x11 }
|
||||
#define LED_SNAKEEYES { 0x06, 0x11 }
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct z8_ledbits_s
|
||||
{
|
||||
ubyte anode;
|
||||
ubyte cathode;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct z8_ledbits_s g_ledarray[10][4] =
|
||||
{
|
||||
{ LED_ALLON, LED_ALLON, LED_ALLON, LED_ALLON },
|
||||
{ LED_ALLOFF, LED_ALLOFF, LED_ALLOFF, LED_ALLOFF },
|
||||
{ LED_LEVEL1, LED_ALLOFF, LED_ALLOFF, LED_ALLOFF },
|
||||
{ LED_LEVEL1, LED_LEVEL2, LED_ALLOFF, LED_ALLOFF },
|
||||
{ LED_LEVEL1, LED_LEVEL2, LED_LEVEL3, LED_ALLOFF },
|
||||
{ LED_LEVEL1, LED_LEVEL2, LED_LEVEL3, LED_LEVEL4 },
|
||||
{ LED_LEVEL1I, LED_LEVEL2I, LED_LEVEL3I, LED_LEVEL4I },
|
||||
{ LED_LEVEL1S, LED_LEVEL2S, LED_LEVEL3S, LED_LEVEL4S },
|
||||
{ LED_LEVEL1A, LED_LEVEL2A, LED_LEVEL3A, LED_LEVEL4A },
|
||||
{ LED_SNAKEEYES, LED_SNAKEEYES, LED_SNAKEEYES, LED_SNAKEEYES }
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: z8_putled134
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
static void z8_putled134(FAR const struct z8_ledbits_s *bits, ubyte addr)
|
||||
{
|
||||
ubyte porte;
|
||||
|
||||
porte = bits->cathode;
|
||||
putreg8(porte, PEOD); /* Load porte data */
|
||||
putreg8(bits->anode, PGOD); /* Load portg data */
|
||||
|
||||
porte |= addr;
|
||||
putreg8(porte, PEOD); /* Latch data */
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: z8_lputed2
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
static void z8_putled2(FAR const struct z8_ledbits_s *bits, ubyte addr)
|
||||
{
|
||||
ubyte portg;
|
||||
|
||||
putreg8(bits->cathode, PEOD); /* Load porte data */
|
||||
portg = bits->anode;
|
||||
putreg8(porte, PGOD); /* Load portg data */
|
||||
|
||||
portg |= addr;
|
||||
putreg8(portg, PGOD); /* Latch data */
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: z8_putarray
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
static void z8_putarray(FAR const struct z8_ledarray_s *array)
|
||||
{
|
||||
z8_putled134(&array->led[0], Z8_PORTE_LED_D1);
|
||||
z8_putled2(&array->led[1], Z8_PORTG_LED_D2);
|
||||
z8_putled134(&array->led[2], Z8_PORTE_LED_D3);
|
||||
z8_putled134(&array->led[3], Z8_PORTE_LED_D4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -73,6 +201,20 @@
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void up_ledinit(void)
|
||||
{
|
||||
putreg8(0x00, PEAF); /* PE Alt func = Port */
|
||||
putreg8(0x00, PGAF); /* PG Alt func = Port */
|
||||
|
||||
putreg8(0x00, PEOC); /* PE Out Ctrl = push-pull */
|
||||
putreg8(0x00, PGOC); /* PG Out Ctrl = push-pull */
|
||||
|
||||
/*putreg8(0x00, PEDD); * PA Data Dir = output */
|
||||
putreg8(0x01, PEADDR); /* PA Data Dir = output */
|
||||
putreg8(0x00, PECTL); /* OUTPUT */
|
||||
/*putreg8(0x00, PGDD); * PA Data Dir = output */
|
||||
putreg8(0x01, PGADDR); /* PA Data Dir = output */
|
||||
putreg8(0x00, PGCTL); /* OUTPUT */
|
||||
|
||||
z8_putarray(&g_ledarray[0][0]);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -81,6 +223,10 @@ void up_ledinit(void)
|
||||
|
||||
void up_ledon(int led)
|
||||
{
|
||||
if ((unsigned)led <= 8)
|
||||
{
|
||||
z8_putarray(&g_ledarray[led+1][0]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -89,5 +235,9 @@ void up_ledon(int led)
|
||||
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
if (led >= 1)
|
||||
{
|
||||
up_ledon(led-1);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
Loading…
Reference in New Issue
Block a user