コード例 #1
0
ファイル: wdt.c プロジェクト: Postlast/webscale
void ICACHE_FLASH_ATTR os_print_reset_error(void)
{
	struct rst_info * rst_inf = (struct rst_info *)&RTC_MEM(0);
//	system_rtc_mem_read(0, &rst_inf, sizeof(struct rst_info));
	if(rst_inf->reason >= RST_EVENT_WDT && rst_inf->reason <= RST_EVENT_MAX) {
		os_printf("Old reset: ");
		switch(rst_inf->reason) {
		case RST_EVENT_WDT:
			os_printf("WDT (%d):\n", rst_inf->exccause);
			os_printf_plus((const char *)aEpc10x08xEpc20, rst_inf->epc1, rst_inf->epc2, rst_inf->epc3, rst_inf->excvaddr, rst_inf->depc);
			break;
		case RST_EVENT_EXP:
			os_printf_plus((const char *)aFatalException, rst_inf->exccause);
			os_printf_plus((const char *)aEpc10x08xEpc20, rst_inf->epc1, rst_inf->epc2, rst_inf->epc3, rst_inf->excvaddr, rst_inf->depc);
			break;
		case RST_EVENT_SOFT_RESET:
			os_printf("SoftReset\n");
			break;
		case RST_EVENT_DEEP_SLEEP:
			os_printf("Deep_Sleep\n");
			break;
		default: {
			char * txt = (char *)rst_inf->epc1;
			if(txt == NULL) txt = aNull;
			os_printf("Error (%u): addr=0x%08x,", rst_inf->reason, rst_inf->exccause);
			os_printf_plus(txt);
			os_printf("\n");
			}
		}
	}
	rst_inf->reason = 0;
}
コード例 #2
0
ファイル: jshardware.c プロジェクト: RobinLin/Espruino
/**
 * Handle a GPIO interrupt.
 * We have arrived in this callback function because the state of a GPIO pin has changed
 * and it is time to record that change.
 */
static void intrHandlerCB(
    uint32 interruptMask, //!< A mask indicating which GPIOs have changed.
    void *arg             //!< Optional argument.
  ) {
  // Given the interrupt mask, we as if bit "x" is on.  If it is, then that is defined as meaning
  // that the state of GPIO "x" has changed so we want to raised an event that indicates that this
  // has happened...
  // Once we have handled the interrupt flags, we need to acknowledge the interrupts so
  // that the ESP8266 will once again cause future interrupts to be processed.

  os_printf_plus(">> intrHandlerCB\n");
  gpio_intr_ack(interruptMask);
  // We have a mask of interrupts that have happened.  Go through each bit in the mask
  // and, if it is on, then an interrupt has occurred on the corresponding pin.
  int pin;
  for (pin=0; pin<16; pin++) {
    if ((interruptMask & (1<<pin)) != 0) {
      // Pin has changed so push the event that says pin has changed.
      jshPushIOWatchEvent(pinToEV_EXTI(pin));
      gpio_pin_intr_state_set(GPIO_ID_PIN(pin), GPIO_PIN_INTR_ANYEDGE);
    }
  }
  os_printf_plus("<< intrHandlerCB\n");
}
コード例 #3
0
ファイル: application.cpp プロジェクト: zhivko/Sming
void playNote()
{

	if (stepDir == 1)
	{
		Serial.println("Direction=1");
		stepper.run(FWD, 40);
		stepDir = 0;
	}
	else
	{
		Serial.println("Direction=0");
		stepper.run(REV, 200);
		stepDir = 1;
	}

	//playNote();
	Serial.println("playNote\r");
	os_printf_plus("Status: %d\r", stepper.getStatus());
}
コード例 #4
0
bool wifi_set_broadcast_if(uint8 interface)
{
	if (interface == 0 || interface >= 4) {
		os_printf_plus("error parameter\n");
		return false;
	}

	switch (interface) {
		case 1:
			if ((wifi_get_opmode() != 1) && (wifi_get_opmode() != 3))
				return false;

			if (((uint8 **)g_ic)[4] == NULL)
				return false;

			netif_set_default(((struct netif **)g_ic)[4]);
			break;

		case 2:
			if ((wifi_get_opmode() != 2) && (wifi_get_opmode() != 3))
				return false;

			if (((uint8 **)g_ic)[5] == NULL)
				return false;

			netif_set_default(((struct netif **)g_ic)[4]);
			break;

		case 3:
			if (wifi_get_opmode() != 3)
				return false;

			break;

		default:
			return true;
	}

	((uint8 *)default_interface)[128] = mode;
	return true;	
}
コード例 #5
0
ファイル: Print.cpp プロジェクト: 4m1g0/Arduino
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size) {

#ifdef DEBUG_ESP_CORE
    static char not_the_best_way [] PROGMEM STORE_ATTR = "Print::write(data,len) should be overridden for better efficiency\r\n";
    static bool once = false;
    if (!once) {
        once = true;
        os_printf_plus(not_the_best_way);
    }
#endif

    size_t n = 0;
    while (size--) {
        size_t ret = write(*buffer++);
        if (ret == 0) {
            // Write of last byte didn't complete, abort additional processing
            break;
        }
        n += ret;
    }
    return n;
}
コード例 #6
0
int func1(int val)
{
	if (!pm_is_open())
		return 0;

	if (((uint8 *)default_interface)[0] == 0) {
		__func2(promiscuous_cb, 0x4024081c, 0);
		((uint8 *)default_interface)[0] = 1;
	}

	if (!pm_is_waked() || (((uint8 *)user_init_flag)[60] == 1)) {
		if (((uint8 *)user_init_flag)[60] == 0) {
			pm_post(1);
			__func3(((uint8 *)user_init_flag)[24]);
			ets_timer_arm_new(((uint8 *)user_init_flag)[24], 10, 0, 1);
			((uint8 *)user_init_flag)[60] = 1;
		}

		((uint8 *)user_init_flag)[61] = (((uint8 *)user_init_flag)[61] + 1) & 0xff;

		if (((uint8 *)user_init_flag)[61] > 10) {
			os_printf_plus("DEFERRED FUNC NUMBER IS BIGGER THAN 10\n");
			((uint8 *)user_init_flag)[61] = 10;
		}

		((uint8 *)user_init_flag)[62] += 9;

		if (((uint8 *)user_init_flag)[62] >= 10) {
			*(((uint8 *)user_init_flag)[62] + ((uint8 *)user_init_flag)[175] + 122) = val;
			return -1;
		}

		*(((uint8 *)user_init_flag)[62] + ((uint8 *)user_init_flag)[175] + 132) = val;
		return -1;
	}

	return 0;
}