Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
cb4390a8
Commit
cb4390a8
authored
17 years ago
by
patacongo
Browse files
Options
Downloads
Patches
Plain Diff
Add LED logic
git-svn-id:
svn://svn.code.sf.net/p/nuttx/code/trunk@713
42af7a65-404d-4744-a932-0658087f49c3
parent
da700355
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
configs/z16f2800100zcog/include/board.h
+2
-2
2 additions, 2 deletions
configs/z16f2800100zcog/include/board.h
configs/z8encore000zco/src/z8_leds.c
+150
-0
150 additions, 0 deletions
configs/z8encore000zco/src/z8_leds.c
with
152 additions
and
2 deletions
configs/z16f2800100zcog/include/board.h
+
2
−
2
View file @
cb4390a8
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
configs/z8encore000zco/src/z8_leds.c
+
150
−
0
View file @
cb4390a8
...
...
@@ -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 */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment