Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
823877bc
Commit
823877bc
authored
Jan 05, 2014
by
Damien George
Browse files
stm: rename sw_xx to switch_xx; change Python bindings to new version.
parent
cd3c1ee3
Changes
3
Hide whitespace changes
Inline
Side-by-side
stm/main.c
View file @
823877bc
...
...
@@ -773,7 +773,7 @@ int main(void) {
led_state
(
PYB_LED_G1
,
1
);
// more sub-system init
sw_init
();
sw
itch
_init
();
storage_init
();
//usart_init(); disabled while wi-fi is enabled
...
...
@@ -822,7 +822,7 @@ soft_reset:
rt_store_attr
(
m
,
qstr_from_str_static
(
"gc"
),
rt_make_function_0
(
pyb_gc
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"delay"
),
rt_make_function_1
(
pyb_delay
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"led"
),
rt_make_function_1
(
pyb_led
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"switch"
),
rt_make_function_0
(
pyb_sw
)
);
rt_store_attr
(
m
,
qstr_from_str_static
(
"switch"
),
(
mp_obj_t
)
&
pyb_switch_obj
);
rt_store_attr
(
m
,
qstr_from_str_static
(
"servo"
),
rt_make_function_2
(
pyb_servo_set
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"pwm"
),
rt_make_function_2
(
pyb_pwm_set
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"accel"
),
(
mp_obj_t
)
&
pyb_mma_read_obj
);
...
...
@@ -848,10 +848,10 @@ soft_reset:
// check if user switch held (initiates reset of filesystem)
bool
reset_filesystem
=
false
;
if
(
sw_get
())
{
if
(
sw
itch
_get
())
{
reset_filesystem
=
true
;
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
if
(
!
sw_get
())
{
if
(
!
sw
itch
_get
())
{
reset_filesystem
=
false
;
break
;
}
...
...
@@ -1122,7 +1122,7 @@ soft_reset:
data
[
2
]
=
-
2
;
data
[
3
]
=
0
;
for
(;;)
{
if
(
sw_get
())
{
if
(
sw
itch
_get
())
{
data
[
0
]
=
0x01
;
// 0x04 is middle, 0x02 is right
}
else
{
data
[
0
]
=
0x00
;
...
...
stm/usrsw.c
View file @
823877bc
...
...
@@ -12,7 +12,7 @@
#define PYB_USRSW_PORT (GPIOA)
#define PYB_USRSW_PIN (GPIO_Pin_13)
void
sw_init
(
void
)
{
void
sw
itch
_init
(
void
)
{
// make it an input with pull-up
GPIO_InitTypeDef
GPIO_InitStructure
;
GPIO_InitStructure
.
GPIO_Pin
=
PYB_USRSW_PIN
;
...
...
@@ -45,7 +45,7 @@ void sw_init(void) {
NVIC_Init
(
&
NVIC_InitStructure
);
}
int
sw_get
(
void
)
{
int
sw
itch
_get
(
void
)
{
if
(
PYB_USRSW_PORT
->
IDR
&
PYB_USRSW_PIN
)
{
// pulled high, so switch is not pressed
return
0
;
...
...
@@ -58,12 +58,12 @@ int sw_get(void) {
/******************************************************************************/
/* Micro Python bindings */
mp_obj_t
pyb_sw
(
void
)
{
if
(
sw_get
())
{
static
mp_obj_t
pyb_sw
itch
(
void
)
{
if
(
sw
itch
_get
())
{
return
mp_const_true
;
}
else
{
return
mp_const_false
;
}
}
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_switch_obj
,
pyb_switch
);
stm/usrsw.h
View file @
823877bc
#ifndef __USRSW_H__
#define __USRSW_H__
void
sw_init
(
void
);
int
sw_get
(
void
);
void
switch_init
(
void
);
int
switch_get
(
void
);
mp_obj_t
pyb_sw
(
void
);
#endif //__USRSW_H__
MP_DECLARE_CONST_FUN_OBJ
(
pyb_switch_obj
);
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