Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
baafb290
Commit
baafb290
authored
Feb 13, 2015
by
Damien George
Browse files
stmhal: Add uart.sendbreak() method, to send a break condition.
parent
089c3f32
Changes
4
Hide whitespace changes
Inline
Side-by-side
docs/library/pyb.UART.rst
View file @
baafb290
...
...
@@ -134,3 +134,9 @@ Methods
Write a single character on the bus. ``char`` is an integer to write.
Return value: ``None``.
.. method:: uart.sendbreak()
Send a break condition on the bus. This drives the bus low for a duration
of 13 bits.
Return value: ``None``.
stmhal/qstrdefsport.h
View file @
baafb290
...
...
@@ -186,6 +186,7 @@ Q(any)
Q
(
writechar
)
Q
(
readchar
)
Q
(
readinto
)
Q
(
sendbreak
)
Q
(
RTS
)
Q
(
CTS
)
...
...
stmhal/uart.c
View file @
baafb290
...
...
@@ -614,6 +614,14 @@ STATIC mp_obj_t pyb_uart_readchar(mp_obj_t self_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_uart_readchar_obj
,
pyb_uart_readchar
);
// uart.sendbreak()
STATIC
mp_obj_t
pyb_uart_sendbreak
(
mp_obj_t
self_in
)
{
pyb_uart_obj_t
*
self
=
self_in
;
self
->
uart
.
Instance
->
CR1
|=
USART_CR1_SBK
;
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_uart_sendbreak_obj
,
pyb_uart_sendbreak
);
STATIC
const
mp_map_elem_t
pyb_uart_locals_dict_table
[]
=
{
// instance methods
...
...
@@ -634,6 +642,7 @@ STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_writechar
),
(
mp_obj_t
)
&
pyb_uart_writechar_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_readchar
),
(
mp_obj_t
)
&
pyb_uart_readchar_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_sendbreak
),
(
mp_obj_t
)
&
pyb_uart_sendbreak_obj
},
// class constants
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_RTS
),
MP_OBJ_NEW_SMALL_INT
(
UART_HWCONTROL_RTS
)
},
...
...
tests/pyb/uart.py
View file @
baafb290
...
...
@@ -12,3 +12,6 @@ print(uart.any())
print
(
uart
.
write
(
'123'
))
print
(
uart
.
write
(
b
'abcd'
))
print
(
uart
.
writechar
(
1
))
# make sure this method exists
uart
.
sendbreak
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment