def __init__(self, power_down, spi_select, spi_chanel=SPI0): #isinstance self.power_down = gpio.mode(power_down, OUTPUT) self.spi_select = gpio.mode(spi_select, OUTPUT) self.ft00_spi = Spi(drvname=spi_chanel, clock=12000000, bits=Spi.SPI_8_BITS, mode=Spi.SPI_MODE_HIGH_FIRST) self.ChipOn = 1 self.ChipOFF = 0
def verify(bit): print("Verifying output initialization:") for i in range(0, num_bits): if gpio.mode(bit[i]) == "out": continue else: print("Pin {0} was not initialized as output".format(bit[i])) cleanup(bit[0:i]) exit(-1) print("Verification succeed")
def __init__(self, watchdog_time): sfw.watchdog(0, watchdog_time) port_expander = sx1503.SX1503(I2C0, 400000) gpio.add_expander(1, port_expander, pinmap) gpio.mode(LED_R, OUTPUT) gpio.mode(LED_G, OUTPUT) gpio.mode(LED_B, OUTPUT) gpio.mode(RS485EN, OUTPUT) gpio.low(LED_G) gpio.low(LED_R) gpio.high(LED_B) gpio.low(RS485EN) self.port = streams.serial(drvname=SERIAL1, baud=9600, set_default=False)
def init(ser, appeui, appkey, rst, join_lora=True, short_startup=False): """ .. function:: init(ser, appeui, appkey, rst, join_lora=True) Performs basic module configuration and try over-the-air activation. * *ser* is the serial port used for device-to-module communication (ex. SERIAL1) * *appeui*, *appkey* are needed for otaa * *rst* is the module reset pin * if *join_lora* is False the configuration and over-the-air activation attempt are skipped and the module can be configured through the :ref:`config() <config>` function and then the LoRa network can be joined calling the :ref:`join() <join>` function. """ global _ser, _appeui, _appkey, _deveui if _ser is None: gpio.mode(rst, OUTPUT) gpio.high(rst) sleep(100) gpio.low(rst) sleep(100) gpio.high(rst) _ser = streams.serial(ser, set_default=False, baud=57600) _get_startup_msg() if short_startup: return _appeui = appeui _appkey = appkey if join_lora: config(appeui=appeui, appkey=appkey) joined = join() return joined
def mode(pin): if pin in pinMap : return gpio.mode(pinMap[pin]) else : logger.info("pinname " + pin + "is not supported!")