示例#1
0
文件: jsdevices.c 项目: tve/Espruino
/** Reset any devices that could have been set up differently by JS code.
 * Called from jshReset */
void jshResetDevices() {
  unsigned int i;
  // Reset list of pins that were set manually
  jshResetPinStateIsManual();
  // setup flow control
  for (i=0;i<sizeof(jshSerialDeviceStates) / sizeof(JshSerialDeviceState);i++)
    jshSerialDeviceStates[i] = SDS_NONE;
  jshSerialDeviceStates[TO_SERIAL_DEVICE_STATE(EV_USBSERIAL)] = SDS_FLOW_CONTROL_XON_XOFF;
  // set up callbacks for events
  for (i=EV_EXTI0;i<=EV_EXTI_MAX;i++)
    jshEventCallbacks[i-EV_EXTI0] = 0;

}
示例#2
0
/** Reset any devices that could have been set up differently by JS code.
 * Called from jshReset */
void jshResetDevices() {
  unsigned int i;
  // Reset list of pins that were set manually
  jshResetPinStateIsManual();
  // setup flow control
  for (i=0;i<sizeof(jshSerialDeviceStates) / sizeof(JshSerialDeviceState);i++)
    jshSerialDeviceStates[i] = SDS_NONE;
  jshSerialDeviceStates[TO_SERIAL_DEVICE_STATE(EV_USBSERIAL)] = SDS_FLOW_CONTROL_XON_XOFF;
  // reset callbacks for events
  for (i=EV_EXTI0;i<=EV_EXTI_MAX;i++)
    jshEventCallbacks[i-EV_EXTI0] = 0;
  // Reset pin state for button
#ifdef BTN1_PININDEX
#ifdef BTN1_PINSTATE
  jshSetPinStateIsManual(BTN1_PININDEX, true); // so subsequent reads don't overwrite the state
  jshPinSetState(BTN1_PININDEX, BTN1_PINSTATE);
#else
  jshPinSetState(BTN1_PININDEX, JSHPINSTATE_GPIO_IN);
#endif
#endif
}