summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/pin.c
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2014-08-10 23:18:10 -0700
committerDamien George <damien.p.george@gmail.com>2014-08-24 18:21:08 +0100
commit3d945559d4c25b7ce30c5e6b0f443bf32ffe957d (patch)
tree4183b1af14d2d8ea66e435c4b4d7d88efdb6f3d1 /stmhal/pin.c
parentc668d51b08370529f6193e8b1d973fdcecfd7620 (diff)
downloadmicropython-3d945559d4c25b7ce30c5e6b0f443bf32ffe957d.tar.gz
micropython-3d945559d4c25b7ce30c5e6b0f443bf32ffe957d.zip
Added python script to map AF to a pin name
Added some functions to Pin class to query mode, pull, and af
Diffstat (limited to 'stmhal/pin.c')
-rw-r--r--stmhal/pin.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/stmhal/pin.c b/stmhal/pin.c
index bf64d40e87..3cbb3a3b49 100644
--- a/stmhal/pin.c
+++ b/stmhal/pin.c
@@ -508,6 +508,33 @@ STATIC mp_obj_t pin_gpio(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_gpio_obj, pin_gpio);
+/// \method mode()
+/// Returns the currently configured mode of the pin. The integer returned
+/// will match one of the allowed constants for the mode argument to the init
+/// function.
+STATIC mp_obj_t pin_mode(mp_obj_t self_in) {
+ return MP_OBJ_NEW_SMALL_INT(pin_get_mode(self_in));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_mode_obj, pin_mode);
+
+/// \method pull()
+/// Returns the currently configured pull of the pin. The integer returned
+/// will match one of the allowed constants for the pull argument to the init
+/// function.
+STATIC mp_obj_t pin_pull(mp_obj_t self_in) {
+ return MP_OBJ_NEW_SMALL_INT(pin_get_pull(self_in));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_pull_obj, pin_pull);
+
+/// \method af()
+/// Returns the currently configured af of the pin. The integer returned
+/// will match one of the allowed constants for the af argument to the init
+/// function.
+STATIC mp_obj_t pin_af(mp_obj_t self_in) {
+ return MP_OBJ_NEW_SMALL_INT(pin_get_af(self_in));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_af_obj, pin_af);
+
STATIC const mp_map_elem_t pin_locals_dict_table[] = {
// instance methods
{ MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pin_init_obj },
@@ -520,6 +547,9 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_port), (mp_obj_t)&pin_port_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_pin), (mp_obj_t)&pin_pin_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_gpio), (mp_obj_t)&pin_gpio_obj },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_mode), (mp_obj_t)&pin_mode_obj },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_pull), (mp_obj_t)&pin_pull_obj },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_af), (mp_obj_t)&pin_af_obj },
// class methods
{ MP_OBJ_NEW_QSTR(MP_QSTR_mapper), (mp_obj_t)&pin_mapper_obj },