1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
4 """Binho Nova pin names"""
8 """A basic Pin class for use with Binho Nova."""
20 def __init__(self, pin_id=None):
22 # pylint: disable=import-outside-toplevel
23 from adafruit_blinka.microcontroller.nova import Connection
25 # pylint: enable=import-outside-toplevel
27 Pin._nova = Connection.getInstance()
28 # check if pin is valid
30 raise ValueError("Invalid pin {}.".format(pin_id))
34 def init(self, mode=IN, pull=None):
35 """Initialize the Pin"""
37 raise RuntimeError("Can not init a None type pin.")
38 # Nova does't have configurable internal pulls for
40 raise ValueError("Internal pull up/down not currently supported.")
41 Pin._nova.setIOpinMode(self.id, mode)
43 def value(self, val=None):
44 """Set or return the Pin Value"""
46 raise RuntimeError("Can not access a None type pin.")
49 return int(Pin._nova.getIOpinValue(self.id).split("VALUE ")[1])
51 if val in (self.LOW, self.HIGH):
52 Pin._nova.setIOpinValue(self.id, val)
54 raise RuntimeError("Invalid value for pin")
57 # create pin instances for each pin
73 # No PWM support on IO1
78 # orderd as (channel, pin), id
79 pwmOuts = (((1, 0), PWM0), ((1, 2), PWM2), ((1, 3), PWM3), ((1, 4), PWM4))
84 # ordered as uartId, txId, rxId
85 uartPorts = ((0, UART1_TX, UART1_RX),)