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
90e7191e
Commit
90e7191e
authored
5 years ago
by
Adrian Schneider
Browse files
Options
Downloads
Patches
Plain Diff
chore(light_sensor) make code style compliant
parent
15ceddd3
No related branches found
No related tags found
No related merge requests found
Pipeline
#1402
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/modules/light_sensor.c
+35
-40
35 additions, 40 deletions
epicardium/modules/light_sensor.c
pycardium/modules/light_sensor.c
+33
-28
33 additions, 28 deletions
pycardium/modules/light_sensor.c
with
68 additions
and
68 deletions
epicardium/modules/light_sensor.c
+
35
−
40
View file @
90e7191e
...
...
@@ -14,7 +14,8 @@ static StaticTimer_t poll_timer_buffer;
int
epic_light_sensor_init
()
{
const
sys_cfg_adc_t
sys_adc_cfg
=
NULL
;
/* No system specific configuration needed. */
const
sys_cfg_adc_t
sys_adc_cfg
=
NULL
;
/* No system specific configuration needed. */
if
(
ADC_Init
(
0x9
,
&
sys_adc_cfg
)
!=
E_NO_ERROR
)
{
return
-
EINVAL
;
}
...
...
@@ -32,8 +33,7 @@ int epic_light_sensor_run()
{
epic_light_sensor_init
();
if
(
!
poll_timer
)
{
if
(
!
poll_timer
)
{
poll_timer
=
xTimerCreateStatic
(
"light_sensor_adc"
,
READ_FREQ
,
...
...
@@ -44,14 +44,11 @@ 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
)
{
if
(
xTimerIsTimerActive
(
poll_timer
)
==
pdTRUE
)
{
return
-
EALREADY
;
}
else
{
if
(
xTimerStart
(
poll_timer
,
0
)
!=
pdPASS
)
{
if
(
xTimerStart
(
poll_timer
,
0
)
!=
pdPASS
)
{
return
-
EBUSY
;
}
return
0
;
...
...
@@ -64,8 +61,7 @@ int epic_light_sensor_stop()
return
-
EINVAL
;
}
if
(
xTimerStop
(
poll_timer
,
0
)
!=
pdPASS
)
{
if
(
xTimerStop
(
poll_timer
,
0
)
!=
pdPASS
)
{
return
-
EBUSY
;
}
return
0
;
...
...
@@ -73,8 +69,7 @@ int epic_light_sensor_stop()
int
epic_light_sensor_get
(
uint16_t
*
value
)
{
if
(
!
poll_timer
||
!
xTimerIsTimerActive
(
poll_timer
))
{
if
(
!
poll_timer
||
!
xTimerIsTimerActive
(
poll_timer
))
{
return
-
ENODATA
;
}
*
value
=
last_value
;
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/light_sensor.c
+
33
−
28
View file @
90e7191e
...
...
@@ -6,9 +6,10 @@
STATIC
mp_obj_t
mp_light_sensor_start
()
{
int
status
=
epic_light_sensor_run
();
if
(
status
==
-
EBUSY
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
"timer could not be scheduled"
);
if
(
status
==
-
EBUSY
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
"timer could not be scheduled"
);
}
return
mp_const_none
;
}
...
...
@@ -18,21 +19,23 @@ STATIC mp_obj_t mp_light_sensor_get_reading()
{
uint16_t
last
;
int
status
=
epic_light_sensor_get
(
&
last
);
if
(
status
==
-
ENODATA
)
{
if
(
status
==
-
ENODATA
)
{
mp_raise_ValueError
(
"sensor not running"
);
return
mp_const_none
;
}
return
mp_obj_new_int_from_uint
(
last
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
light_sensor_get_obj
,
mp_light_sensor_get_reading
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
light_sensor_get_obj
,
mp_light_sensor_get_reading
);
STATIC
mp_obj_t
mp_light_sensor_stop
()
{
int
status
=
epic_light_sensor_stop
();
if
(
status
==
-
EBUSY
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
"timer could not be stopped"
);
if
(
status
==
-
EBUSY
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
"timer could not be stopped"
);
}
return
mp_const_none
;
}
...
...
@@ -44,7 +47,9 @@ STATIC const mp_rom_map_elem_t light_sensor_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_stop
),
MP_ROM_PTR
(
&
light_sensor_stop_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_reading
),
MP_ROM_PTR
(
&
light_sensor_get_obj
)
}
};
STATIC
MP_DEFINE_CONST_DICT
(
light_sensor_module_globals
,
light_sensor_module_globals_table
);
STATIC
MP_DEFINE_CONST_DICT
(
light_sensor_module_globals
,
light_sensor_module_globals_table
);
const
mp_obj_module_t
light_sensor_module
=
{
.
base
=
{
&
mp_type_module
},
...
...
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