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
fd6925b4
Commit
fd6925b4
authored
Apr 20, 2014
by
Damien George
Browse files
stmhal: Small bug fixes and simplifications.
parent
f87b35e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
stmhal/extint.c
View file @
fd6925b4
...
...
@@ -110,7 +110,7 @@ STATIC const uint8_t nvic_irq_channel[EXTI_NUM_VECTORS] = {
//
// NOTE: param is for C callers. Python can use closure to get an object bound
// with the function.
uint
extint_register
(
mp_obj_t
pin_obj
,
mp_obj
_t
mode
_obj
,
mp_obj
_t
pull
_obj
,
mp_obj_t
callback_obj
,
bool
override_callback_obj
,
void
*
param
)
{
uint
extint_register
(
mp_obj_t
pin_obj
,
uint32
_t
mode
,
uint32
_t
pull
,
mp_obj_t
callback_obj
,
bool
override_callback_obj
,
void
*
param
)
{
const
pin_obj_t
*
pin
=
NULL
;
uint
v_line
;
...
...
@@ -129,20 +129,18 @@ uint extint_register(mp_obj_t pin_obj, mp_obj_t mode_obj, mp_obj_t pull_obj, mp_
pin
=
pin_find
(
pin_obj
);
v_line
=
pin
->
pin
;
}
int
mode
=
mp_obj_get_int
(
mode_obj
);
if
(
mode
!=
GPIO_MODE_IT_RISING
&&
mode
!=
GPIO_MODE_IT_FALLING
&&
mode
!=
GPIO_MODE_IT_RISING_FALLING
&&
mode
!=
GPIO_MODE_EVT_RISING
&&
mode
!=
GPIO_MODE_EVT_FALLING
&&
mode
!=
GPIO_MODE_EVT_RISING_FALLING
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
I
nvalid ExtInt Mode: %d"
,
mode
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
i
nvalid ExtInt Mode: %d"
,
mode
));
}
int
pull
=
mp_obj_get_int
(
pull_obj
);
if
(
pull
!=
GPIO_NOPULL
&&
pull
!=
GPIO_PULLUP
&&
pull
!=
GPIO_PULLDOWN
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
I
nvalid ExtInt Pull: %d"
,
pull
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
i
nvalid ExtInt Pull: %d"
,
pull
));
}
extint_vector_t
*
v
=
&
extint_vector
[
v_line
];
...
...
@@ -239,12 +237,12 @@ STATIC mp_obj_t extint_regs(void) {
return
mp_const_none
;
}
// line_obj = pyb.ExtInt(pin, mode,
trigger
, callback)
// line_obj = pyb.ExtInt(pin, mode,
pull
, callback)
STATIC
const
mp_arg_parse_t
pyb_extint_make_new_accepted_args
[]
=
{
{
MP_QSTR_pin
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_mode
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_
OBJ
,
{.
u_
obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_
trigger
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_
OBJ
,
{.
u_
obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_mode
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_
INT
,
{.
u_
int
=
0
}
},
{
MP_QSTR_
pull
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_
INT
,
{.
u_
int
=
0
}
},
{
MP_QSTR_callback
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
};
#define PYB_EXTINT_MAKE_NEW_NUM_ARGS (sizeof(pyb_extint_make_new_accepted_args) / sizeof(pyb_extint_make_new_accepted_args[0]))
...
...
@@ -260,7 +258,7 @@ STATIC mp_obj_t extint_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
extint_obj_t
*
self
=
m_new_obj
(
extint_obj_t
);
self
->
base
.
type
=
type_in
;
self
->
line
=
extint_register
(
vals
[
0
].
u_obj
,
vals
[
1
].
u_
obj
,
vals
[
2
].
u_
obj
,
vals
[
3
].
u_obj
,
false
,
NULL
);
self
->
line
=
extint_register
(
vals
[
0
].
u_obj
,
vals
[
1
].
u_
int
,
vals
[
2
].
u_
int
,
vals
[
3
].
u_obj
,
false
,
NULL
);
return
self
;
}
...
...
stmhal/extint.h
View file @
fd6925b4
...
...
@@ -22,7 +22,7 @@
void
extint_init
(
void
);
uint
extint_register
(
mp_obj_t
pin_obj
,
mp_obj
_t
mode
_obj
,
mp_obj_t
trigger_obj
,
mp_obj_t
callback_obj
,
bool
override_callback_obj
,
void
*
param
);
uint
extint_register
(
mp_obj_t
pin_obj
,
uint32
_t
mode
,
uint32_t
pull
,
mp_obj_t
callback_obj
,
bool
override_callback_obj
,
void
*
param
);
void
extint_enable
(
uint
line
);
void
extint_disable
(
uint
line
);
...
...
stmhal/qstrdefsport.h
View file @
fd6925b4
...
...
@@ -90,7 +90,7 @@ Q(send)
Q
(
ExtInt
)
Q
(
pin
)
Q
(
mode
)
Q
(
trigger
)
Q
(
pull
)
Q
(
callback
)
Q
(
line
)
Q
(
enable
)
...
...
stmhal/spi.c
View file @
fd6925b4
...
...
@@ -189,7 +189,7 @@ STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, cons
else
if
(
br_prescale
<=
32
)
{
init
->
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_32
;
}
else
if
(
br_prescale
<=
64
)
{
init
->
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_64
;
}
else
if
(
br_prescale
<=
128
)
{
init
->
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_128
;
}
else
{
init
->
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_
4
;
}
else
{
init
->
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_
256
;
}
init
->
CLKPolarity
=
vals
[
2
].
u_int
;
init
->
CLKPhase
=
vals
[
3
].
u_int
;
...
...
stmhal/usrsw.c
View file @
fd6925b4
...
...
@@ -69,8 +69,8 @@ static mp_obj_t pyb_switch(uint n_args, mp_obj_t *args) {
// may have been disabled by an exception in the interrupt, or the
// user disabling the line explicitly.
extint_register
((
mp_obj_t
)
&
MICROPY_HW_USRSW_PIN
,
MP_OBJ_NEW_SMALL_INT
(
MICROPY_HW_USRSW_EXTI_MODE
)
,
MP_OBJ_NEW_SMALL_INT
(
MICROPY_HW_USRSW_PULL
)
,
MICROPY_HW_USRSW_EXTI_MODE
,
MICROPY_HW_USRSW_PULL
,
switch_user_callback_obj
==
mp_const_none
?
mp_const_none
:
(
mp_obj_t
)
&
switch_callback_obj
,
true
,
NULL
);
return
mp_const_none
;
...
...
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