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
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
card10
firmware
Commits
2084b1bc
Commit
2084b1bc
authored
5 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(interrupts): rename api, fix api numbers, fix code style
parent
905f4ecc
No related branches found
No related tags found
No related merge requests found
Pipeline
#1349
failed
5 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/api/interrupt-sender.c
+2
-2
2 additions, 2 deletions
epicardium/api/interrupt-sender.c
epicardium/epicardium.h
+3
-3
3 additions, 3 deletions
epicardium/epicardium.h
pycardium/modules/interrupt.c
+16
-14
16 additions, 14 deletions
pycardium/modules/interrupt.c
with
21 additions
and
19 deletions
epicardium/api/interrupt-sender.c
+
2
−
2
View file @
2084b1bc
...
@@ -26,14 +26,14 @@ void api_interrupt_init(void)
...
@@ -26,14 +26,14 @@ void api_interrupt_init(void)
}
}
}
}
void
a
pi_interrupt_enable
(
api_int_id_t
int_id
)
void
e
pi
c
_interrupt_enable
(
api_int_id_t
int_id
)
{
{
if
(
int_id
<=
API_INT_MAX
)
{
if
(
int_id
<=
API_INT_MAX
)
{
enabled
[
int_id
]
=
true
;
enabled
[
int_id
]
=
true
;
}
}
}
}
void
a
pi_interrupt_disable
(
api_int_id_t
int_id
)
void
e
pi
c
_interrupt_disable
(
api_int_id_t
int_id
)
{
{
if
(
int_id
<=
API_INT_MAX
)
{
if
(
int_id
<=
API_INT_MAX
)
{
enabled
[
int_id
]
=
false
;
enabled
[
int_id
]
=
false
;
...
...
This diff is collapsed.
Click to expand it.
epicardium/epicardium.h
+
3
−
3
View file @
2084b1bc
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#define API_VIBRA_VIBRATE 0x5
#define API_VIBRA_VIBRATE 0x5
#define API_STREAM_READ 0x6
#define API_STREAM_READ 0x6
#define API_INTERRUPT_ENABLE 0x7
#define API_INTERRUPT_ENABLE 0x7
#define API_INTERRUPT_DISABLE 0x
6
#define API_INTERRUPT_DISABLE 0x
8
/* clang-format on */
/* clang-format on */
...
@@ -156,13 +156,13 @@ typedef uint32_t api_int_id_t;
...
@@ -156,13 +156,13 @@ typedef uint32_t api_int_id_t;
*
*
* :param int_id: The interrupt to be enabled
* :param int_id: The interrupt to be enabled
*/
*/
API
(
API_INTERRUPT_ENABLE
,
void
a
pi_interrupt_enable
(
api_int_id_t
int_id
));
API
(
API_INTERRUPT_ENABLE
,
void
e
pi
c
_interrupt_enable
(
api_int_id_t
int_id
));
/**
/**
* Disable/mask an API interrupt
* Disable/mask an API interrupt
*
*
* :param int_id: The interrupt to be disabled
* :param int_id: The interrupt to be disabled
*/
*/
API
(
API_INTERRUPT_DISABLE
,
void
a
pi_interrupt_disable
(
api_int_id_t
int_id
));
API
(
API_INTERRUPT_DISABLE
,
void
e
pi
c
_interrupt_disable
(
api_int_id_t
int_id
));
#endif
/* _EPICARDIUM_H */
#endif
/* _EPICARDIUM_H */
This diff is collapsed.
Click to expand it.
pycardium/modules/interrupt.c
+
16
−
14
View file @
2084b1bc
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include
"api/common.h"
#include
"api/common.h"
#include
"mphalport.h"
#include
"mphalport.h"
// TODO: these should be intialized as mp_const_none
// TODO: these should be intialized as mp_const_none
mp_obj_t
callbacks
[
API_INT_MAX
+
1
]
=
{
mp_obj_t
callbacks
[
API_INT_MAX
+
1
]
=
{
0
,
0
,
...
@@ -13,12 +12,22 @@ mp_obj_t callbacks[API_INT_MAX + 1] = {
...
@@ -13,12 +12,22 @@ mp_obj_t callbacks[API_INT_MAX + 1] = {
void
api_interrupt_handler_catch_all
(
api_int_id_t
id
)
void
api_interrupt_handler_catch_all
(
api_int_id_t
id
)
{
{
// TODO: check if id is out of rante
// TOOD: check against mp_const_none
if
(
id
<=
API_INT_MAX
)
{
if
(
callbacks
[
id
])
{
mp_sched_schedule
(
callbacks
[
id
],
MP_OBJ_NEW_SMALL_INT
(
id
)
);
}
}
}
}
STATIC
mp_obj_t
mp_interrupt_set_callback
(
mp_obj_t
id_in
,
mp_obj_t
callback_obj
)
STATIC
mp_obj_t
mp_interrupt_set_callback
(
mp_obj_t
id_in
,
mp_obj_t
callback_obj
)
{
{
api_int_id_t
id
=
mp_obj_get_int
(
id_in
);
api_int_id_t
id
=
mp_obj_get_int
(
id_in
);
if
(
callback_obj
!=
mp_const_none
&&
!
mp_obj_is_callable
(
callback_obj
))
{
if
(
callback_obj
!=
mp_const_none
&&
!
mp_obj_is_callable
(
callback_obj
))
{
mp_raise_ValueError
(
"handler must be None or callable"
);
mp_raise_ValueError
(
"handler must be None or callable"
);
}
}
...
@@ -34,15 +43,8 @@ STATIC mp_obj_t mp_interrupt_enable_callback(mp_obj_t id_in)
...
@@ -34,15 +43,8 @@ STATIC mp_obj_t mp_interrupt_enable_callback(mp_obj_t id_in)
{
{
api_int_id_t
id
=
mp_obj_get_int
(
id_in
);
api_int_id_t
id
=
mp_obj_get_int
(
id_in
);
// TODO: throw error if id is out of range or mp_sched_schedule fails
// TODO: throw error if id is out of range or epic_interrupt_enable failed
// TOOD: check against mp_const_none
epic_interrupt_enable
(
id
);
if
(
id
<=
API_INT_MAX
)
{
if
(
callbacks
[
id
])
{
mp_sched_schedule
(
callbacks
[
id
],
MP_OBJ_NEW_SMALL_INT
(
id
)
);
}
}
return
mp_const_none
;
return
mp_const_none
;
}
}
...
...
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