summaryrefslogtreecommitdiff
path: root/ports/nrf/common-hal/microcontroller/Pin.h
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-08-30 21:42:25 -0400
committerDan Halbert <halbert@halwitz.org>2018-08-31 18:05:55 -0400
commit585597a252be431fd4efe11a9120329b233ebba5 (patch)
treecdb30b7eff16bbadd9fc32c6e736d99cadd0f894 /ports/nrf/common-hal/microcontroller/Pin.h
parent0e8d14618477de053417fcf7b8c2e72df589cb69 (diff)
pin files rework; implement pin claiming; add more boards
Diffstat (limited to 'ports/nrf/common-hal/microcontroller/Pin.h')
-rw-r--r--ports/nrf/common-hal/microcontroller/Pin.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/ports/nrf/common-hal/microcontroller/Pin.h b/ports/nrf/common-hal/microcontroller/Pin.h
index 954d6e51d..1e751c714 100644
--- a/ports/nrf/common-hal/microcontroller/Pin.h
+++ b/ports/nrf/common-hal/microcontroller/Pin.h
@@ -27,9 +27,10 @@
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PIN_H
#define MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PIN_H
-#include "nrf_pin.h"
#include "py/mphal.h"
+#include "peripherals/nrf/pins.h"
+
#ifdef MICROPY_HW_NEOPIXEL
extern bool neopixel_in_use;
#endif
@@ -38,11 +39,21 @@ extern bool apa102_sck_in_use;
extern bool apa102_mosi_in_use;
#endif
-#define mcu_pin_obj_t pin_obj_t
void reset_all_pins(void);
// reset_pin takes the pin number instead of the pointer so that objects don't
// need to store a full pointer.
void reset_pin(uint8_t pin);
void claim_pin(const mcu_pin_obj_t* pin);
+// Lower 5 bits of a pin number are the pin number in a port.
+// upper bits (just one bit for current chips) is port number.
+
+static inline uint8_t nrf_pin_port(uint8_t absolute_pin) {
+ return absolute_pin >> 5;
+}
+
+static inline uint8_t nrf_relative_pin_number(uint8_t absolute_pin) {
+ return absolute_pin & 0x1f;
+}
+
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PIN_H