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
bffb71f5
Commit
bffb71f5
authored
Feb 03, 2021
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/mpbthciport: Only init the uart once, then use uart_set_baudrate.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
d2a34c62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
ports/stm32/mpbthciport.c
ports/stm32/mpbthciport.c
+13
-20
No files found.
ports/stm32/mpbthciport.c
View file @
bffb71f5
...
...
@@ -32,8 +32,6 @@
#include "pendsv.h"
#include "lib/utils/mpirq.h"
#include "py/obj.h"
#if MICROPY_PY_BLUETOOTH
#define DEBUG_printf(...) // printf("mpbthciport.c: " __VA_ARGS__)
...
...
@@ -197,8 +195,18 @@ int mp_bluetooth_hci_uart_init(uint32_t port, uint32_t baudrate) {
mp_bluetooth_hci_uart_obj
.
timeout_char
=
200
;
MP_STATE_PORT
(
pyb_uart_obj_all
)[
mp_bluetooth_hci_uart_obj
.
uart_id
-
1
]
=
&
mp_bluetooth_hci_uart_obj
;
// This also initialises the UART and adds the RXIDLE IRQ handler.
mp_bluetooth_hci_uart_set_baudrate
(
baudrate
);
// Initialise the UART.
uart_init
(
&
mp_bluetooth_hci_uart_obj
,
115200
,
UART_WORDLENGTH_8B
,
UART_PARITY_NONE
,
UART_STOPBITS_1
,
UART_HWCONTROL_RTS
|
UART_HWCONTROL_CTS
);
uart_set_rxbuf
(
&
mp_bluetooth_hci_uart_obj
,
sizeof
(
hci_uart_rxbuf
),
hci_uart_rxbuf
);
// Add IRQ handler for IDLE (i.e. packet finished).
uart_irq_config
(
&
mp_bluetooth_hci_uart_obj
,
false
);
mp_irq_init
(
&
mp_bluetooth_hci_uart_irq_obj
,
&
uart_irq_methods
,
MP_OBJ_FROM_PTR
(
&
mp_bluetooth_hci_uart_obj
));
mp_bluetooth_hci_uart_obj
.
mp_irq_obj
=
&
mp_bluetooth_hci_uart_irq_obj
;
mp_bluetooth_hci_uart_obj
.
mp_irq_trigger
=
UART_FLAG_IDLE
;
mp_bluetooth_hci_uart_irq_obj
.
handler
=
MP_OBJ_FROM_PTR
(
&
mp_uart_interrupt_obj
);
mp_bluetooth_hci_uart_irq_obj
.
ishard
=
true
;
uart_irq_config
(
&
mp_bluetooth_hci_uart_obj
,
true
);
return
0
;
}
...
...
@@ -213,22 +221,7 @@ int mp_bluetooth_hci_uart_deinit(void) {
int
mp_bluetooth_hci_uart_set_baudrate
(
uint32_t
baudrate
)
{
DEBUG_printf
(
"mp_bluetooth_hci_uart_set_baudrate(%lu) (stm32)
\n
"
,
baudrate
);
if
(
!
baudrate
)
{
return
-
1
;
}
uart_init
(
&
mp_bluetooth_hci_uart_obj
,
baudrate
,
UART_WORDLENGTH_8B
,
UART_PARITY_NONE
,
UART_STOPBITS_1
,
UART_HWCONTROL_RTS
|
UART_HWCONTROL_CTS
);
uart_set_rxbuf
(
&
mp_bluetooth_hci_uart_obj
,
sizeof
(
hci_uart_rxbuf
),
hci_uart_rxbuf
);
// Add IRQ handler for IDLE (i.e. packet finished).
uart_irq_config
(
&
mp_bluetooth_hci_uart_obj
,
false
);
mp_irq_init
(
&
mp_bluetooth_hci_uart_irq_obj
,
&
uart_irq_methods
,
MP_OBJ_FROM_PTR
(
&
mp_bluetooth_hci_uart_obj
));
mp_bluetooth_hci_uart_obj
.
mp_irq_obj
=
&
mp_bluetooth_hci_uart_irq_obj
;
mp_bluetooth_hci_uart_obj
.
mp_irq_trigger
=
UART_FLAG_IDLE
;
mp_bluetooth_hci_uart_irq_obj
.
handler
=
MP_OBJ_FROM_PTR
(
&
mp_uart_interrupt_obj
);
mp_bluetooth_hci_uart_irq_obj
.
ishard
=
true
;
uart_irq_config
(
&
mp_bluetooth_hci_uart_obj
,
true
);
uart_set_baudrate
(
&
mp_bluetooth_hci_uart_obj
,
baudrate
);
return
0
;
}
...
...
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