def begin_spi(slaveSelectPin): """Begin the SPI port""" try: ReferenceVal = pythonCallback.set_python_callback_reference(python_cb_func) if ReferenceVal != None: raise RuntimeError, "Fails setting python ctype function reference!" except RuntimeError, arg: print arg
def set_up(port, pin): """Set the pin mode to output""" try: PinPortVal = ValidPort[ os.environ['VARIANT'] ](port) and ValidPin[ os.environ['VARIANT'] ]( port, pin ) ReferenceVal = pythonCallback.set_python_callback_reference(python_cb_func) if PinPortVal == False: raise RuntimeError, "Wrong pin and/or port. Please check the port and pin value!" elif ReferenceVal != None: raise RuntimeError, "Fails setting python ctype function reference!" except RuntimeError, arg: print arg return False
def set_up(baudRate, usart): """Set baud rate for the serial port""" try: USART_VAL = ValidUSART[ os.environ['VARIANT'] ](usart) ReferenceVal = pythonCallback.set_python_callback_reference(python_cb_func) if USART_VAL == False: raise RuntimeError, "Wrong USART port. Please check the USART port value!" elif ReferenceVal != None: raise RuntimeError, "Fails setting python ctype function reference!" except RuntimeError, arg: print arg return False