Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
fd6925b4
Commit
fd6925b4
authored
Apr 20, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Small bug fixes and simplifications.
parent
f87b35e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
stmhal/extint.c
+7
-9
7 additions, 9 deletions
stmhal/extint.c
stmhal/extint.h
+1
-1
1 addition, 1 deletion
stmhal/extint.h
stmhal/qstrdefsport.h
+1
-1
1 addition, 1 deletion
stmhal/qstrdefsport.h
stmhal/spi.c
+1
-1
1 addition, 1 deletion
stmhal/spi.c
stmhal/usrsw.c
+2
-2
2 additions, 2 deletions
stmhal/usrsw.c
with
12 additions
and
14 deletions
stmhal/extint.c
+
7
−
9
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
;
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/extint.h
+
1
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
stmhal/qstrdefsport.h
+
1
−
1
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
)
...
...
This diff is collapsed.
Click to expand it.
stmhal/spi.c
+
1
−
1
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
;
...
...
This diff is collapsed.
Click to expand it.
stmhal/usrsw.c
+
2
−
2
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
;
...
...
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