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
823877bc
Commit
823877bc
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stm: rename sw_xx to switch_xx; change Python bindings to new version.
parent
cd3c1ee3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
stm/main.c
+5
-5
5 additions, 5 deletions
stm/main.c
stm/usrsw.c
+5
-5
5 additions, 5 deletions
stm/usrsw.c
stm/usrsw.h
+3
-6
3 additions, 6 deletions
stm/usrsw.h
with
13 additions
and
16 deletions
stm/main.c
+
5
−
5
View file @
823877bc
...
@@ -773,7 +773,7 @@ int main(void) {
...
@@ -773,7 +773,7 @@ int main(void) {
led_state
(
PYB_LED_G1
,
1
);
led_state
(
PYB_LED_G1
,
1
);
// more sub-system init
// more sub-system init
sw_init
();
sw
itch
_init
();
storage_init
();
storage_init
();
//usart_init(); disabled while wi-fi is enabled
//usart_init(); disabled while wi-fi is enabled
...
@@ -822,7 +822,7 @@ soft_reset:
...
@@ -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
(
"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
(
"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
(
"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
(
"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
(
"pwm"
),
rt_make_function_2
(
pyb_pwm_set
));
rt_store_attr
(
m
,
qstr_from_str_static
(
"accel"
),
(
mp_obj_t
)
&
pyb_mma_read_obj
);
rt_store_attr
(
m
,
qstr_from_str_static
(
"accel"
),
(
mp_obj_t
)
&
pyb_mma_read_obj
);
...
@@ -848,10 +848,10 @@ soft_reset:
...
@@ -848,10 +848,10 @@ soft_reset:
// check if user switch held (initiates reset of filesystem)
// check if user switch held (initiates reset of filesystem)
bool
reset_filesystem
=
false
;
bool
reset_filesystem
=
false
;
if
(
sw_get
())
{
if
(
sw
itch
_get
())
{
reset_filesystem
=
true
;
reset_filesystem
=
true
;
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
if
(
!
sw_get
())
{
if
(
!
sw
itch
_get
())
{
reset_filesystem
=
false
;
reset_filesystem
=
false
;
break
;
break
;
}
}
...
@@ -1122,7 +1122,7 @@ soft_reset:
...
@@ -1122,7 +1122,7 @@ soft_reset:
data
[
2
]
=
-
2
;
data
[
2
]
=
-
2
;
data
[
3
]
=
0
;
data
[
3
]
=
0
;
for
(;;)
{
for
(;;)
{
if
(
sw_get
())
{
if
(
sw
itch
_get
())
{
data
[
0
]
=
0x01
;
// 0x04 is middle, 0x02 is right
data
[
0
]
=
0x01
;
// 0x04 is middle, 0x02 is right
}
else
{
}
else
{
data
[
0
]
=
0x00
;
data
[
0
]
=
0x00
;
...
...
This diff is collapsed.
Click to expand it.
stm/usrsw.c
+
5
−
5
View file @
823877bc
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
#define PYB_USRSW_PORT (GPIOA)
#define PYB_USRSW_PORT (GPIOA)
#define PYB_USRSW_PIN (GPIO_Pin_13)
#define PYB_USRSW_PIN (GPIO_Pin_13)
void
sw_init
(
void
)
{
void
sw
itch
_init
(
void
)
{
// make it an input with pull-up
// make it an input with pull-up
GPIO_InitTypeDef
GPIO_InitStructure
;
GPIO_InitTypeDef
GPIO_InitStructure
;
GPIO_InitStructure
.
GPIO_Pin
=
PYB_USRSW_PIN
;
GPIO_InitStructure
.
GPIO_Pin
=
PYB_USRSW_PIN
;
...
@@ -45,7 +45,7 @@ void sw_init(void) {
...
@@ -45,7 +45,7 @@ void sw_init(void) {
NVIC_Init
(
&
NVIC_InitStructure
);
NVIC_Init
(
&
NVIC_InitStructure
);
}
}
int
sw_get
(
void
)
{
int
sw
itch
_get
(
void
)
{
if
(
PYB_USRSW_PORT
->
IDR
&
PYB_USRSW_PIN
)
{
if
(
PYB_USRSW_PORT
->
IDR
&
PYB_USRSW_PIN
)
{
// pulled high, so switch is not pressed
// pulled high, so switch is not pressed
return
0
;
return
0
;
...
@@ -58,12 +58,12 @@ int sw_get(void) {
...
@@ -58,12 +58,12 @@ int sw_get(void) {
/******************************************************************************/
/******************************************************************************/
/* Micro Python bindings */
/* Micro Python bindings */
mp_obj_t
pyb_sw
(
void
)
{
static
mp_obj_t
pyb_sw
itch
(
void
)
{
if
(
sw_get
())
{
if
(
sw
itch
_get
())
{
return
mp_const_true
;
return
mp_const_true
;
}
else
{
}
else
{
return
mp_const_false
;
return
mp_const_false
;
}
}
}
}
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_switch_obj
,
pyb_switch
);
This diff is collapsed.
Click to expand it.
stm/usrsw.h
+
3
−
6
View file @
823877bc
#ifndef __USRSW_H__
void
switch_init
(
void
);
#define __USRSW_H__
int
switch_get
(
void
);
void
sw_init
(
void
);
int
sw_get
(
void
);
mp_obj_t
pyb_sw
(
void
);
MP_DECLARE_CONST_FUN_OBJ
(
pyb_switch_obj
);
#endif //__USRSW_H__
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