Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
6abe3e17
Commit
6abe3e17
authored
Apr 10, 2023
by
iabdalkader
Committed by
Damien George
Sep 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rp2/mpbthciport: Switch to static scheduler nodes.
Signed-off-by:
iabdalkader
<
i.abdalkader@gmail.com
>
parent
7087880c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
17 deletions
+5
-17
ports/rp2/mpbthciport.c
ports/rp2/mpbthciport.c
+5
-17
No files found.
ports/rp2/mpbthciport.c
View file @
6abe3e17
...
...
@@ -43,11 +43,9 @@ static alarm_id_t poll_timer_id = 0;
uint8_t
mp_bluetooth_hci_cmd_buf
[
4
+
256
];
// Prevent double-enqueuing of the scheduled task.
STATIC
volatile
bool
events_task_is_scheduled
;
static
mp_sched_node_t
mp_bluetooth_hci_sched_node
;
void
mp_bluetooth_hci_init
(
void
)
{
events_task_is_scheduled
=
false
;
}
static
int64_t
mp_bluetooth_hci_timer_callback
(
alarm_id_t
id
,
void
*
user_data
)
{
...
...
@@ -65,25 +63,16 @@ void mp_bluetooth_hci_poll_in_ms(uint32_t ms) {
// For synchronous mode, we run all BLE stack code inside a scheduled task.
// This task is scheduled periodically via a timer, or immediately after UART RX IRQ.
STATIC
mp_obj_t
run_events_scheduled_task
(
mp_obj_t
none_in
)
{
(
void
)
none_in
;
events_task_is_scheduled
=
false
;
// This will process all HCI data, and run any callouts or events.
STATIC
void
run_events_scheduled_task
(
mp_sched_node_t
*
node
)
{
(
void
)
node
;
// This will process all buffered HCI UART data, and run any callouts or events.
mp_bluetooth_hci_poll
();
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
run_events_scheduled_task_obj
,
run_events_scheduled_task
);
// Called periodically (systick) or directly (e.g. UART RX IRQ) in order to
// request that processing happens ASAP in the scheduler.
void
mp_bluetooth_hci_poll_now
(
void
)
{
if
(
!
events_task_is_scheduled
)
{
events_task_is_scheduled
=
mp_sched_schedule
(
MP_OBJ_FROM_PTR
(
&
run_events_scheduled_task_obj
),
mp_const_none
);
if
(
!
events_task_is_scheduled
)
{
// The schedule queue is full, set callback to try again soon.
mp_bluetooth_hci_poll_in_ms
(
5
);
}
}
mp_sched_schedule_node
(
&
mp_bluetooth_hci_sched_node
,
run_events_scheduled_task
);
}
#if defined(MICROPY_HW_BLE_UART_ID)
...
...
@@ -91,7 +80,6 @@ void mp_bluetooth_hci_poll_now(void) {
mp_obj_t
mp_bthci_uart
;
STATIC
void
mp_bluetooth_hci_start_polling
(
void
)
{
events_task_is_scheduled
=
false
;
mp_bluetooth_hci_poll_now
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment