diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2016-12-06 10:31:38 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2016-12-07 15:21:14 -0800 |
| commit | 0ae344841ff048424b886e1f386b16c0c9ba4ee2 (patch) | |
| tree | 358f0e2044672d38dc863b243aea734b2e41337c /shared-bindings/microcontroller/Pin.h | |
| parent | bb9c751b502a7bda49027d5ee195f8110b1493f9 (diff) | |
atmel-samd & esp8266: Make sure pins are not already in use.
This prevents corrupting previous functional objects by stealing their pins
out from under them. It prevents this by ensuring that pins are in default
state before claiming them. It also verifies pins are released correctly and
reset on soft reset.
Fixes #4, instantiating a second class will fail.
Fixes #29, pins are now reset too.
Diffstat (limited to 'shared-bindings/microcontroller/Pin.h')
| -rw-r--r-- | shared-bindings/microcontroller/Pin.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/shared-bindings/microcontroller/Pin.h b/shared-bindings/microcontroller/Pin.h index d31ba040c..46a531a6d 100644 --- a/shared-bindings/microcontroller/Pin.h +++ b/shared-bindings/microcontroller/Pin.h @@ -27,11 +27,15 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PIN_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PIN_H__ +#include "common-hal/microcontroller/types.h" #include "py/obj.h" // Type object used in Python. Should be shared between ports. extern const mp_obj_type_t mcu_pin_type; void assert_pin(mp_obj_t obj, bool none_ok); +void assert_pin_free(const mcu_pin_obj_t* pin); + +bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin); #endif // __MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PIN_H__ |
