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
fpletz
firmware
Commits
3e886c50
Verified
Commit
3e886c50
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
feat(light-sensor): Add ADC locking
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
abe89091
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/modules/light_sensor.c
+26
-6
26 additions, 6 deletions
epicardium/modules/light_sensor.c
epicardium/modules/modules.h
+1
-0
1 addition, 0 deletions
epicardium/modules/modules.h
with
27 additions
and
6 deletions
epicardium/modules/light_sensor.c
+
26
−
6
View file @
3e886c50
#include
"FreeRTOS.h"
#include
"timers.h"
#include
"led.h"
#include
"epicardium.h"
#include
"modules/log.h"
#include
"modules/modules.h"
#include
"mxc_config.h"
#include
"led.h"
#include
"adc.h"
#include
"gpio.h"
#include
<errno.h>
#include
"FreeRTOS.h"
#include
"timers.h"
#define READ_FREQ pdMS_TO_TICKS(100)
...
...
@@ -25,12 +29,25 @@ static int light_sensor_init()
static
void
readAdcCallback
()
{
if
(
hwlock_acquire
(
HWLOCK_ADC
,
0
)
!=
0
)
{
/* Can't do much about this here ... Retry next time */
return
;
}
ADC_StartConvert
(
ADC_CH_7
,
0
,
0
);
ADC_GetData
(
&
last_value
);
hwlock_release
(
HWLOCK_ADC
);
}
int
epic_light_sensor_run
()
{
int
ret
=
0
;
if
(
hwlock_acquire
(
HWLOCK_ADC
,
pdMS_TO_TICKS
(
500
))
!=
0
)
{
return
-
EBUSY
;
}
light_sensor_init
();
if
(
!
poll_timer
)
{
...
...
@@ -47,10 +64,12 @@ int epic_light_sensor_run()
}
if
(
xTimerIsTimerActive
(
poll_timer
)
==
pdFALSE
)
{
if
(
xTimerStart
(
poll_timer
,
0
)
!=
pdPASS
)
{
ret
urn
-
EBUSY
;
ret
=
-
EBUSY
;
}
}
return
0
;
hwlock_release
(
HWLOCK_ADC
);
return
ret
;
}
int
epic_light_sensor_stop
()
...
...
@@ -63,6 +82,7 @@ int epic_light_sensor_stop()
if
(
xTimerStop
(
poll_timer
,
0
)
!=
pdPASS
)
{
return
-
EBUSY
;
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/modules.h
+
1
−
0
View file @
3e886c50
...
...
@@ -42,6 +42,7 @@ void hwlock_init(void);
enum
hwlock_periph
{
HWLOCK_I2C
=
0
,
HWLOCK_ADC
,
_HWLOCK_MAX
,
};
...
...
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