Commit e24e03b4 authored by Damien George's avatar Damien George
Browse files

stmhal/pin: Add C-level pin ioctl method.

parent b039d93d
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "py/nlr.h" #include "py/nlr.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/mphal.h" #include "py/mphal.h"
#include "extmod/virtpin.h"
#include "pin.h" #include "pin.h"
/// \moduleref pyb /// \moduleref pyb
...@@ -542,12 +543,33 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = { ...@@ -542,12 +543,33 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pin_locals_dict, pin_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(pin_locals_dict, pin_locals_dict_table);
STATIC mp_uint_t pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
pin_obj_t *self = self_in;
switch (request) {
case MP_PIN_READ: {
return mp_hal_pin_read(self);
}
case MP_PIN_WRITE: {
mp_hal_pin_write(self, arg);
return 0;
}
}
return -1;
}
STATIC const mp_pin_p_t pin_pin_p = {
.ioctl = pin_ioctl,
};
const mp_obj_type_t pin_type = { const mp_obj_type_t pin_type = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_Pin, .name = MP_QSTR_Pin,
.print = pin_print, .print = pin_print,
.make_new = pin_make_new, .make_new = pin_make_new,
.call = pin_call, .call = pin_call,
.protocol = &pin_pin_p,
.locals_dict = (mp_obj_t)&pin_locals_dict, .locals_dict = (mp_obj_t)&pin_locals_dict,
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment