Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
f1186497
Commit
f1186497
authored
Feb 28, 2024
by
Paul PERONNARD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ertm14: indicate BIST result with the front panel LED
parent
176b78b8
Pipeline
#5157
passed with stage
in 4 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
9 deletions
+97
-9
board.c
boards/ertm14/board.c
+10
-3
leds.c
dev/leds.c
+75
-5
leds.h
include/dev/leds.h
+12
-1
No files found.
boards/ertm14/board.c
View file @
f1186497
...
...
@@ -433,6 +433,7 @@ int bist_summary( struct bist_stage *bist )
else
if
(
stat
&
BIST_STATUS_ERROR
)
{
pp_printf
(
"ERROR"
);
led_status_set
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
i
,
i
);
n_errors
++
;
}
else
...
...
@@ -448,7 +449,11 @@ int bist_summary( struct bist_stage *bist )
if
(
n_errors
)
pp_printf
(
"--------------------------------
\n
BIST FAILED with %d ERRORS!
\n\n\n
"
,
n_errors
);
else
{
led_status_set
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
0
,
4
);
led_status_set
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
1
,
6
);
pp_printf
(
"BIST PASSED.
\n
"
);
}
return
n_errors
>
0
?
-
1
:
0
;
}
...
...
@@ -2531,6 +2536,8 @@ int wrc_board_early_init()
timer_delay_ms
(
200
);
ep_enable
(
&
wrc_endpoint_dev
,
1
,
1
);
timer_delay_ms
(
200
);
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
LED_STATUS
);
bist_summary
(
ertm_bist
);
return
ll
;
...
...
@@ -2847,17 +2854,17 @@ int ertm14_update_leds( void )
if
(
ptp_servo_state
==
WR_TRACK_PHASE
&&
ptp_state
==
PPS_SLAVE
)
{
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_1
,
LED_ON
);
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
LED_OFF
);
//
led_action( &board.leds.sync, LED_COLOR_2, LED_OFF );
}
else
if
(
ptp_state
==
PPS_LISTENING
||
ptp_state
==
PPS_INITIALIZING
)
{
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_1
,
LED_OFF
);
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
LED_OFF
);
//
led_action( &board.leds.sync, LED_COLOR_2, LED_OFF );
}
else
if
(
ptp_state
==
PPS_SLAVE
)
{
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_1
,
LED_BLINK
);
led_action
(
&
board
.
leds
.
sync
,
LED_COLOR_2
,
LED_OFF
);
//
led_action( &board.leds.sync, LED_COLOR_2, LED_OFF );
}
prev_ptp_servo_state
=
ptp_servo_state
;
...
...
dev/leds.c
View file @
f1186497
...
...
@@ -46,6 +46,13 @@ int led_create(struct led_device *led, struct gpio_pin *pin1, struct gpio_pin *p
led
->
type
=
type
;
led
->
state
[
0
]
=
default_state
;
led
->
state
[
1
]
=
default_state
;
for
(
int
ii
=
0
;
ii
<
LED_STATUS_MAX
;
ii
++
)
{
led
->
status
[
0
].
blink_counters
[
ii
]
=
0
;
led
->
status
[
0
].
nb_blinks
[
ii
]
=
0
;
led
->
status
[
1
].
blink_counters
[
ii
]
=
0
;
led
->
status
[
1
].
nb_blinks
[
ii
]
=
0
;
}
return
0
;
}
...
...
@@ -79,6 +86,51 @@ void leds_init()
leds
[
i
]
=
NULL
;
}
static
void
led_status_update
(
struct
led_device
*
led
,
int
led_idx
,
int32_t
t
)
{
static
int
blink_index
=
0
;
static
int
v_prev
=
0
;
static
int
v_toggled
=
0
;
static
int
led_on
=
0
;
if
(
led
->
blink_period
==
0
)
return
;
if
(
0
==
led
->
status
[
led_idx
].
nb_blinks
[
blink_index
])
{
if
(
++
blink_index
==
LED_STATUS_MAX
)
blink_index
=
0
;
return
;
}
t
%=
led
->
blink_period
;
int
v
=
t
<
led
->
blink_period_on
?
1
:
0
;
if
(
v_prev
!=
v
){
v_toggled
=
1
;
}
v_prev
=
v
;
if
(
v_toggled
)
{
led_on
=
v
;
v_toggled
=
0
;
if
(
led_on
)
led
->
status
[
led_idx
].
blink_counters
[
blink_index
]
++
;
if
(
led
->
status
[
led_idx
].
blink_counters
[
blink_index
]
>
led
->
status
[
led_idx
].
nb_blinks
[
blink_index
])
{
led_on
=
0
;
}
// wait before going to the next status code
if
(
led
->
status
[
led_idx
].
blink_counters
[
blink_index
]
>
led
->
status
[
led_idx
].
nb_blinks
[
blink_index
]
+
1
)
{
led
->
status
[
led_idx
].
blink_counters
[
blink_index
]
=
0
;
if
(
++
blink_index
==
LED_STATUS_MAX
)
blink_index
=
0
;
}
}
gen_gpio_out
(
led
->
pins
[
led_idx
],
led_on
);
}
static
void
led_update_single
(
struct
led_device
*
led
)
{
int
n
=
(
led
->
type
&
0xf
)
==
LED_TYPE_DUAL_COLOR
?
2
:
1
;
...
...
@@ -118,15 +170,20 @@ static void led_update_single(struct led_device *led)
if
(
led
->
blink_period
==
0
)
break
;
t
%=
led
->
blink_period
;
v
=
t
<
led
->
blink_period_on
?
1
:
0
;
if
(
led
->
type
&
LED_TYPE_INVERT
)
v
=
1
-
v
;
t
%=
led
->
blink_period
;
v
=
t
<
led
->
blink_period_on
?
1
:
0
;
if
(
led
->
type
&
LED_TYPE_INVERT
)
v
=
1
-
v
;
gen_gpio_out
(
led
->
pins
[
i
],
v
);
gen_gpio_out
(
led
->
pins
[
i
],
v
);
break
;
}
case
LED_STATUS
:
{
led_status_update
(
led
,
i
,
t
);
break
;
}
default:
break
;
...
...
@@ -141,4 +198,17 @@ void leds_update()
if
(
leds
[
i
])
led_update_single
(
leds
[
i
]);
}
void
led_status_set
(
struct
led_device
*
led
,
uint8_t
colors
,
uint8_t
blink_index
,
uint8_t
nb_blinks
)
{
if
(
colors
&
LED_COLOR_1
)
{
led
->
status
[
0
].
nb_blinks
[
blink_index
]
=
nb_blinks
;
}
if
(
colors
&
LED_COLOR_2
)
{
led
->
status
[
1
].
nb_blinks
[
blink_index
]
=
nb_blinks
;
}
}
#endif
/* BOARD_MAX_LEDS */
include/dev/leds.h
View file @
f1186497
...
...
@@ -35,15 +35,25 @@ struct gpio_pin;
#define LED_BLINK 2
#define LED_BLINK_SINGLE (1<<4)
#define LED_BLINK_SINGLE_NEGATIVE (1<<5)
#define LED_STATUS (1<<6)
#define LED_COLOR_1 (1<<0)
#define LED_COLOR_2 (1<<1)
#define LED_COLOR_BOTH ( (1<<0)|(1<<1) )
#define LED_STATUS_MAX 32
struct
led_status
{
uint8_t
blink_counters
[
LED_STATUS_MAX
];
uint8_t
nb_blinks
[
LED_STATUS_MAX
];
};
struct
led_device
{
uint8_t
type
;
uint8_t
state
[
2
];
struct
led_status
status
[
2
];
uint8_t
color
;
uint16_t
blink_period_on
;
uint16_t
blink_period
;
...
...
@@ -51,7 +61,6 @@ struct led_device
struct
gpio_pin
*
pins
[
2
];
};
int
led_create
(
struct
led_device
*
led
,
struct
gpio_pin
*
pin1
,
struct
gpio_pin
*
pin2
,
int
type
,
int
default_state
);
void
led_action
(
struct
led_device
*
led
,
int
colors
,
int
action
);
void
led_set_blink_timing
(
struct
led_device
*
led
,
int
period
,
int
period_on
);
...
...
@@ -59,4 +68,6 @@ void led_set_blink_timing( struct led_device *led, int period, int period_on );
void
leds_init
(
void
);
void
leds_update
(
void
);
void
led_status_set
(
struct
led_device
*
led
,
uint8_t
led_color
,
uint8_t
blink_index
,
uint8_t
nb_blinks
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment