Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
OpenSource
Baitboat
Commits
7343de28
Commit
7343de28
authored
10 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
AP_Notify: avoid suspend_timer_procs() by using atomic updates in ToshibaLED_PX4
parent
7d350735
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
libraries/AP_Notify/ToshibaLED_PX4.cpp
+15
-13
15 additions, 13 deletions
libraries/AP_Notify/ToshibaLED_PX4.cpp
libraries/AP_Notify/ToshibaLED_PX4.h
+12
-1
12 additions, 1 deletion
libraries/AP_Notify/ToshibaLED_PX4.h
with
27 additions
and
14 deletions
libraries/AP_Notify/ToshibaLED_PX4.cpp
+
15
−
13
View file @
7343de28
...
...
@@ -41,8 +41,8 @@ bool ToshibaLED_PX4::hw_init()
return
false
;
}
ioctl
(
_rgbled_fd
,
RGBLED_SET_MODE
,
(
unsigned
long
)
RGBLED_MODE_ON
);
last
.
zero
()
;
next
.
zero
()
;
last
.
v
=
0
;
next
.
v
=
0
;
hal
.
scheduler
->
register_io_process
(
AP_HAL_MEMBERPROC
(
&
ToshibaLED_PX4
::
update_timer
));
return
true
;
}
...
...
@@ -50,28 +50,30 @@ bool ToshibaLED_PX4::hw_init()
// set_rgb - set color as a combination of red, green and blue values
bool
ToshibaLED_PX4
::
hw_set_rgb
(
uint8_t
red
,
uint8_t
green
,
uint8_t
blue
)
{
hal
.
scheduler
->
suspend_timer_procs
();
next
[
0
]
=
red
;
next
[
1
]
=
green
;
next
[
2
]
=
blue
;
hal
.
scheduler
->
resume_timer_procs
();
union
rgb_value
v
;
v
.
r
=
red
;
v
.
g
=
green
;
v
.
b
=
blue
;
// this does an atomic 32 bit update
next
.
v
=
v
.
v
;
return
true
;
}
void
ToshibaLED_PX4
::
update_timer
(
void
)
{
if
(
last
==
next
)
{
if
(
last
.
v
==
next
.
v
)
{
return
;
}
rgbled_rgbset_t
v
;
v
.
red
=
next
[
0
];
v
.
green
=
next
[
1
];
v
.
blue
=
next
[
2
];
union
rgb_value
newv
;
newv
.
v
=
next
.
v
;
v
.
red
=
newv
.
r
;
v
.
green
=
newv
.
g
;
v
.
blue
=
newv
.
b
;
ioctl
(
_rgbled_fd
,
RGBLED_SET_RGB
,
(
unsigned
long
)
&
v
);
last
=
next
;
last
.
v
=
next
.
v
;
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4
This diff is collapsed.
Click to expand it.
libraries/AP_Notify/ToshibaLED_PX4.h
+
12
−
1
View file @
7343de28
...
...
@@ -30,8 +30,19 @@ public:
private:
int
_rgbled_fd
;
void
update_timer
(
void
);
// use a union so that updates can be of a single 32 bit value,
// making it atomic on PX4
union
rgb_value
{
struct
{
uint8_t
r
;
uint8_t
g
;
uint8_t
b
;
};
volatile
uint32_t
v
;
};
VectorN
<
uint8_t
,
3
>
last
,
next
;
union
rgb_value
last
,
next
;
};
#endif // __TOSHIBA_LED_PX4_H__
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