Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adrian
firmware
Commits
339e74f9
Commit
339e74f9
authored
5 years ago
by
Adrian Schneider
Browse files
Options
Downloads
Patches
Plain Diff
chore(light_sensor) make start and stop functions silently pass if nothing to do
parent
5796f861
No related branches found
No related tags found
No related merge requests found
Pipeline
#1404
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/epicardium.h
+6
-5
6 additions, 5 deletions
epicardium/epicardium.h
epicardium/modules/light_sensor.c
+4
-5
4 additions, 5 deletions
epicardium/modules/light_sensor.c
with
10 additions
and
10 deletions
epicardium/epicardium.h
+
6
−
5
View file @
339e74f9
...
...
@@ -403,14 +403,15 @@ API(API_DISP_CIRC,
/**
* Start continuous readout of the light sensor. Will read light level
* at preconfigured interval and make it available via `epic_light_sensor_get()`
* at preconfigured interval and make it available via `epic_light_sensor_get()`.
*
* If the continuous readout was already running, this function will silently pass.
*
*
* :return: `0` if the start was successful or a negative error value
* if an error occured. Possible errors:
*
* - ``-EBUSY``: The timer could not be scheduled.
* - ``-EALREADY``: The continuous readout is already running. You can ignore
* this error and safely use `epic_light_sensor_get()` anyways.
*/
API
(
API_LIGHT_SENSOR_RUN
,
int
epic_light_sensor_run
());
...
...
@@ -429,12 +430,12 @@ API(API_LIGHT_SENSOR_GET, int epic_light_sensor_get(uint16_t* value));
/**
* Stop continuous readout of the light sensor.
*
* If the continuous readout wasn't running, this function will silently pass.
*
* :return: `0` if the stop was sucessful or a negative error value
* if an error occured. Possible errors:
*
* - ``-EBUSY``: The timer stop could not be scheduled.
* - ``-EINVAL``: The continuous readout was not running. The continuous
* readout can be safely restarted.
*/
API
(
API_LIGHT_SENSOR_STOP
,
int
epic_light_sensor_stop
());
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/light_sensor.c
+
4
−
5
View file @
339e74f9
...
...
@@ -45,20 +45,19 @@ int epic_light_sensor_run()
// since &poll_timer_buffer is not NULL, xTimerCreateStatic should allways succeed, so
// we don't need to check for poll_timer being NULL.
}
if
(
xTimerIsTimerActive
(
poll_timer
)
==
pdTRUE
)
{
return
-
EALREADY
;
}
else
{
if
(
xTimerIsTimerActive
(
poll_timer
)
==
pdFALSE
)
{
if
(
xTimerStart
(
poll_timer
,
0
)
!=
pdPASS
)
{
return
-
EBUSY
;
}
return
0
;
}
return
0
;
}
int
epic_light_sensor_stop
()
{
if
(
!
poll_timer
||
xTimerIsTimerActive
(
poll_timer
)
==
pdFALSE
)
{
return
-
EINVAL
;
// timer wasn't running (or never started), just silently pass
return
0
;
}
if
(
xTimerStop
(
poll_timer
,
0
)
!=
pdPASS
)
{
...
...
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