Example #1
0
//----------------------------------------------------------
// SFI EXCEPTION HANDLER
//----------------------------------------------------------
void sfi_jmptbl_exception()
{
  uint16_t val;
  uint8_t ledcnt;
  ker_led(LED_RED_ON);
  ker_led(LED_GREEN_OFF);
  ker_led(LED_YELLOW_OFF);
  val = 0xffff;
  ledcnt = 0;
  while (1){
#ifndef DISABLE_WDT
    watchdog_reset();
#endif
    if (val == 0){
      switch (ledcnt){
      case 0: ker_led(LED_RED_TOGGLE); ker_led(LED_GREEN_TOGGLE); break;
      case 1: ker_led(LED_GREEN_TOGGLE); ker_led(LED_YELLOW_TOGGLE); break;
      case 2: ker_led(LED_YELLOW_TOGGLE); ker_led(LED_RED_TOGGLE); break;
      default: break;
      }
      ledcnt++;
      if (ledcnt == 3) 
	ledcnt = 0;
    }
    val--;
  }
  return;
}
Example #2
0
void watchdog_timer_device::device_reset()
{
	// set up the watchdog timer; only start off enabled if explicitly configured
	m_enabled = (m_vblank_count != 0 || m_time != attotime::zero);
	watchdog_reset();
	m_enabled = true;
}
Example #3
0
void sfi_exception(uint8_t errcode)
{
  uint8_t clrdisp;
  uint16_t val;
  val = 0xffff;

  sfi_err_code_led_display(errcode);
  clrdisp = 0;

  while (1){
#ifndef DISABLE_WDT
    watchdog_reset();
#endif
    if (val == 0){
      if (clrdisp){
	sfi_err_code_led_display(errcode);
	clrdisp = 0;
      }
      else {
	sfi_err_code_led_display(0);
	clrdisp = 1;
      }
    }
    val--;
  }
  return;
}
Example #4
0
static void watchdog_internal_reset(running_machine &machine)
{
	/* set up the watchdog timer; only start off enabled if explicitly configured */
	watchdog_enabled = (machine.m_config.m_watchdog_vblank_count != 0 || machine.m_config.m_watchdog_time != attotime::zero);
	watchdog_reset(&machine);
	watchdog_enabled = TRUE;
}
Example #5
0
static void watchdog_internal_reset(running_machine *machine)
{
	/* set up the watchdog timer; only start off enabled if explicitly configured */
	watchdog_enabled = (machine->config->watchdog_vblank_count != 0 || attotime_compare(machine->config->watchdog_time, attotime_zero) != 0);
	watchdog_reset(machine);
	watchdog_enabled = TRUE;
}
void run_electronics_test()
{
    cli();
    
    //Disable times and PWM, except for timer5, which controls the motor current PWM levels.
    TCCR1A = 0;
    TCCR2A = 0;
    TCCR3A = 0;
    TCCR4A = 0;
    
    uint8_t idx = 0;
    char command_buffer[32];
    send_P(PSTR("TEST\r\n"));
    while(true)
    {
        watchdog_reset();
        if (UCSR0A & _BV(RXC0))
        {
            uint8_t recv = UDR0;
            if (recv == '\n' || recv == '\r')
            {
                command_buffer[idx] = 0;
                idx = 0;
                
                handleCommand(command_buffer);
            }
            else
            {
                command_buffer[idx++] = recv;
            }
        }
    }
}
Example #7
0
static WRITE16_HANDLER( unk880000_w )
{
	tecmosys_state *state = space->machine().driver_data<tecmosys_state>();
	COMBINE_DATA(&state->m_880000regs[offset]);

	switch( offset )
	{
		case 0x00/2:
			break; // global x scroll for sprites?

		case 0x02/2:
			break; // global y scroll for sprites

		case 0x08/2:
			state->m_spritelist = data & 0x3; // which of the 4 spritelists to use (buffering)
			break;

		case 0x22/2:
			watchdog_reset( space->machine() );
			//logerror( "watchdog_w( %06x, %04x ) @ %06x\n", (offset * 2)+0x880000, data, cpu_get_pc(&space->device()) );
			break;

		default:
			logerror( "unk880000_w( %06x, %04x ) @ %06x\n", (offset * 2)+0x880000, data, cpu_get_pc(&space->device()) );
			break;
	}
}
Example #8
0
void bsp_reset( void)
{
  watchdog_reset();

  while (true) {
    /* Do nothing */
  }
}
Example #9
0
//==========================================================================================
// pmbus_write_rom_mode() 
//	Erases the program integrity word in FLASH, then waits for watchdog timer to reset the 
// CPU.  There is no return code or return from this function.  
//==========================================================================================
int32 pmbus_write_rom_mode(void)
{
	clear_integrity_word();			// Call a SWI to clear the integrity word.

	watchdog_reset();				// Wait for watchdog to expire and force CPU reset.
							
	return PMBUS_SUCCESS;			// Note: This line is never reached.  
}
Example #10
0
	AM_RANGE(0xe800, 0xffff) AM_ROM
ADDRESS_MAP_END


static WRITE8_DEVICE_HANDLER( watchdog_w )
{
	watchdog_reset(device->machine());
}
Example #11
0
static WRITE16_HANDLER(io_w)
{
	switch(offset)
	{
		case 2: watchdog_reset(space->machine); break;

		default: logerror("IO W %x %x %x\n", offset, data, mem_mask);
	}
}
Example #12
0
void running_machine::watchdog_enable(bool enable)
{
	// when re-enabled, we reset our state
	if (m_watchdog_enabled != enable)
	{
		m_watchdog_enabled = enable;
		watchdog_reset();
	}
}
Example #13
0
void watchdog_enable(running_machine *machine, int enable)
{
	/* when re-enabled, we reset our state */
	if (watchdog_enabled != enable)
	{
		watchdog_enabled = enable;
		watchdog_reset(machine);
	}
}
Example #14
0
void idler() {
  /* Debug code. Look at P3.0 on an oscilloscope to
   * measure main loop period, to get an idea of max
   * latency for things serviced from here.
   */
  P3_0 = !P3_0;

  watchdog_reset();
}
Example #15
0
void watchdog_timer_device::watchdog_enable(bool enable)
{
	// when re-enabled, we reset our state
	if (m_enabled != enable)
	{
		m_enabled = enable;
		watchdog_reset();
	}
}
Example #16
0
/* disable watchdog time, mainly to save power */
void watchdog_disable(void)
{
  wdt_disable();
}

#else /* !WITH_WATCHDOG */
#define watchdog_start() ((void)0)
#define watchdog_reset() ((void)0)
#define watchdog_disable() ((void)0)
#endif /* WITH_WATCHDOG */

#ifdef HAS_LCD
static void print_idle(void)
{
  uint8_t station_id[STATION_ID_BYTES];

  eeprom_read_station_id(station_id);
  lcd_puts(0, "Base Station");
  lcd_print_hex(1, station_id, sizeof(station_id));
}
#else /* !HAS_LCD */
#define print_idle()
#endif /* HAS_LCD */
static void sleep_until_melody_completes(void)
{
  set_sleep_mode(SLEEP_MODE_IDLE);
  // In this tight loop we are guaranteed one last interrupt
  // after is_melody_playing() returns false
  while (is_melody_playing()) {
    sleep_mode();
    watchdog_reset();
  }
}
Example #17
0
static void sleep_after_timeout(void)
{
  watchdog_reset();
  rcs956_rf_off();

  // Active sleep if blinking, deep sleep otherwise.
  for (uint8_t i = 0; i < SLEEP_COUNT_CLK_DOWN(SLEEP_AFTER_TIMEOUT); i++) {
    sleep_until_timer(SLEEP_MODE_PWR_SAVE, true);
  }
}
Example #18
0
void driver_tick(void)
{
    watchdog_reset();
#ifdef CONFIG_HW_UART
    hw_uart_tick();
#endif
#ifdef CONFIG_USBDEV
    usbdev_tick();
#endif

    console_tick();
    led_tick(tick_get());
}
Example #19
0
static WRITE32_HANDLER( gunbustr_input_w )
{
	gunbustr_state *state = space->machine().driver_data<gunbustr_state>();

#if 0
{
char t[64];
COMBINE_DATA(&state->m_mem[offset]);

sprintf(t,"%08x %08x",state->m_mem[0],state->m_mem[1]);
popmessage(t);
}
#endif

	switch (offset)
	{
		case 0x00:
		{
			if (ACCESSING_BITS_24_31)	/* $400000 is watchdog */
			{
				watchdog_reset(space->machine());
			}

			if (ACCESSING_BITS_0_7)
			{
				eeprom_device *eeprom = space->machine().device<eeprom_device>("eeprom");
				eeprom->set_clock_line((data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
				eeprom->write_bit(data & 0x40);
				eeprom->set_cs_line((data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
				return;
			}
			return;
		}

		case 0x01:
		{
			if (ACCESSING_BITS_24_31)
			{
				/* game does not write a separate counter for coin 2!
                   It should disable both coins when 9 credits reached
                   see code $1d8a-f6... but for some reason it's not */
				coin_lockout_w(space->machine(), 0, data & 0x01000000);
				coin_lockout_w(space->machine(), 1, data & 0x02000000);
				coin_counter_w(space->machine(), 0, data & 0x04000000);
				coin_counter_w(space->machine(), 1, data & 0x04000000);
				state->m_coin_word = (data >> 16) &0xffff;
			}
//logerror("CPU #0 PC %06x: write input %06x\n",cpu_get_pc(&space->device()),offset);
		}
	}
}
Example #20
0
static WRITE32_HANDLER( superchs_input_w )
{
	superchs_state *state = space->machine().driver_data<superchs_state>();

	#if 0
	{
	char t[64];
	COMBINE_DATA(&state->m_mem[offset]);
	sprintf(t,"%08x %08x",state->m_mem[0],state->m_mem[1]);
	//popmessage(t);
	}
	#endif

	switch (offset)
	{
		case 0x00:
		{
			if (ACCESSING_BITS_24_31)	/* $300000 is watchdog */
			{
				watchdog_reset(space->machine());
			}

			if (ACCESSING_BITS_0_7)
			{
				eeprom_device *eeprom = space->machine().device<eeprom_device>("eeprom");
				eeprom->set_clock_line((data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
				eeprom->write_bit(data & 0x40);
				eeprom->set_cs_line((data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
				return;
			}

			return;
		}

		/* there are 'vibration' control bits somewhere! */

		case 0x01:
		{
			if (ACCESSING_BITS_24_31)
			{
				coin_lockout_w(space->machine(), 0,~data & 0x01000000);
				coin_lockout_w(space->machine(), 1,~data & 0x02000000);
				coin_counter_w(space->machine(), 0, data & 0x04000000);
				coin_counter_w(space->machine(), 1, data & 0x08000000);
				state->m_coin_word=(data >> 16) &0xffff;
			}
		}
	}
}
Example #21
0
void watchdog_set(int timeout)
{
	static struct sunxi_wdog *const wdog =
		&((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;

	/* Set timeout, reset & enable */
	if (timeout >= 0) {
		writel(WDT_MODE_TIMEOUT(timeout) |
				WDT_MODE_RESET_EN | WDT_MODE_EN,
		       &wdog->mode);
	} else {
		writel(0, &wdog->mode);
	}
	watchdog_reset();
}
void WDT_Prescaler_Change(void)
{
  //__disable_interrupt();
   	cli();
  watchdog_reset();
  
  /* Start timed  equence */
  WDTCSR |= (1<<WDCE) | (1<<WDE);

  // PREDEFINED TIMEOUT HERE!!!...  
  /* Set new prescaler(time-out) value = 64K cycles (~0.5 s) */
  WDTCSR  = (1<<WDE) | (1<<WDP2) | (1<<WDP0);
  //__enable_interrupt();
  sei();
}
void WDT_off()
{
  //__disable_interrupt();
  cli();
  watchdog_reset();
  
  /* Clear WDRF in MCUSR */
  MCUSR &= ~(1<<WDRF);
  /* Write logical one to WDCE and WDE */
  /* Keep old prescaler setting to prevent unintentional time-out
*/
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  /* Turn off WDT */
  WDTCSR = 0x00;
  //__enable_interrupt();
  	sei();
}
Example #24
0
void running_machine::soft_reset(void *ptr, INT32 param)
{
	logerror("Soft reset\n");

	// temporarily in the reset phase
	m_current_phase = MACHINE_PHASE_RESET;

	// set up the watchdog timer; only start off enabled if explicitly configured
	m_watchdog_enabled = (config().m_watchdog_vblank_count != 0 || config().m_watchdog_time != attotime::zero);
	watchdog_reset();
	m_watchdog_enabled = true;

	// call all registered reset callbacks
	call_notifiers(MACHINE_NOTIFY_RESET);

	// now we're running
	m_current_phase = MACHINE_PHASE_RUNNING;
}
Example #25
0
static void watchdog_event_handler(struct tevent_context *ev,
                                   struct tevent_timer *te,
                                   struct timeval current_time,
                                   void *private_data)
{
    /* first thing reset the watchdog ticks */
    watchdog_reset();

    /* then set a new watchodg event */
    watchdog_ctx.te = tevent_add_timer(ev, ev,
        tevent_timeval_current_ofs(watchdog_ctx.interval.tv_sec, 0),
        watchdog_event_handler, NULL);
    /* if the function fails the watchdog will kill the
     * process soon enough, so we just warn */
    if (!watchdog_ctx.te) {
        DEBUG(SSSDBG_FATAL_FAILURE,
              "Failed to create a watchdog timer event!\n");
    }
}
int main(void)
{	
	init();
	BOOL motors_stopped = FALSE;
	
	send_welcome();
	        
    while (1)
    {	
		if (motors_stopped)
		{
			led_on ( STOP_LED );
			led_off ( GO_LED );
		} else
		{
			led_on( GO_LED );
			led_off( STOP_LED );
		}
		
		read_buttons();
		if (stop_button_pressed)
		{
			motors_stopped = TRUE;
			stop_motors();
		}
		if (prog_button_pressed)
		{
			motors_stopped = FALSE; 
			resume_motors();
		}

		encoder_timeslice();		
		limit_switch_timeslice();
		motor_timeslice_10ms();		
		serial_timeslice();		// handle incoming messages (if avail)

		watchdog_reset();
		//delay(one_second/10);
    }
    return (0);
}
Example #27
0
uint8_t hw_i2c_read_bit(void)
{
    uint8_t bit;

    cpu_disable_int();

    delay_T2();
    sda_hi();
    scl_hi();

    // wait for slave (clock stretching)
    do {
        delay_T2();
        watchdog_reset();   // FIXME, add timeout
    } while ((SCL_IN & _BV(SCL)) == 0);
    bit = SDA_IN & _BV(SDA) ? 1 : 0;
    delay_T2();
    scl_low();

    cpu_enable_int();

    return bit;
}
Example #28
0
/* Use SSL. Must be entirely different since the return
 * type is a pointer to an SSL structure.
 */
BIO *
urlinstStartSSLTransfer(struct iurlinfo * ui, char * filename, 
                         char *extraHeaders, int silentErrors,
                         int flags, char *nextServer) {

	extern  void watchdog_reset();
	int	tries = 1;
	int	rc;
	int	errorcode = -1;
	int	sleepmin = KS_RETRY_MIN;
	char	*returnedHeaders;
	BIO	*sbio = 0;

	logMessage(INFO, "ROCKS:transferring https://%s/%s\nHeaders:%s\n",
	       ui->address, filename, extraHeaders);

	/* Add 'public' path element if we dont have a cert. */
	if (!haveCertificate())
		addPublic(&filename);

	while ((errorcode < 0) && (tries < 10)) {
		sbio = httpsGetFileDesc(ui->address, -1, filename,
			extraHeaders, &errorcode, &returnedHeaders);

		if (errorcode == 0) {
			char	*ptr;
			char	trackers[256];
			char	pkgservers[256];

			if ((ptr = strstr(returnedHeaders,
					"X-Avalanche-Trackers:")) != NULL) {
				sscanf(ptr, "X-Avalanche-Trackers: %256s",
					trackers);
			} else {
				if (nextServer != NULL) {
					snprintf(trackers, sizeof(trackers) - 1,
						"%s", nextServer);
				} else {
					strcpy(trackers, "127.0.0.1");
				}
			}

			if ((ptr = strstr(returnedHeaders,
					"X-Avalanche-Pkg-Servers:")) != NULL) {
				sscanf(ptr, "X-Avalanche-Pkg-Servers: %256s",
					pkgservers);
			} else {
				if (nextServer != NULL) {
					snprintf(pkgservers,
						sizeof(pkgservers) - 1, "%s",
						nextServer);
				} else {
					strcpy(pkgservers, "127.0.0.1");
				}
			}

			writeAvalancheInfo(trackers, pkgservers);

		} else if (errorcode == FTPERR_FAILED_DATA_CONNECT) {
			/*
			 * read the retry value from the return message
			 */
			char	*ptr;
			int	sleeptime = 0;

			if ((ptr = strstr(returnedHeaders, "Retry-After:"))
					!= NULL) {
				sscanf(ptr, "Retry-After: %d", &sleeptime);
			}

			if (sleeptime <= 0) {
				/*
				 * Backoff a random interval between
				 * KS_RETRY_MIN and KS_RETRY_MAX
				 */
				sleeptime = sleepmin +
					((KS_RETRY_MAX - sleepmin) *
					(rand()/(float)RAND_MAX));
			}

			winStatus(55, 3, _("Server Busy"), _("I will retry "
				"for a ks file after a %d sec sleep..."), 
				sleeptime, 0);

			/*
			 * this must be in a loop, as the alarm associated
			 * with the watchdog timer is sending a signal which
			 * interrupts the sleep().
			 */
			while ((sleeptime = sleep(sleeptime)) != 0) {
				;
			}

			newtPopWindow();

			tries = 1;
			/* Don't let the watchdog fire if the kickstart
			   server is reporting busy */
			watchdog_reset();
			continue;
		} else if (errorcode == FTPERR_REFUSED) {
			/*
			 * always accept the parent credentials
			 */
			forceParentAuth();
			continue;
		}

		logMessage(INFO, "ROCKS:urlinstStartSSLTransfer:attempt (%d)",
			tries);

		sleep(1);

		++tries;
	}

	if (errorcode < 0) {
		logMessage(ERROR, "ROCKS:urlinstStartSSLTransfer:Failed");
		rc = 0;

		/* Go through the public door automatically, but only
		 * if we have not tried it already. */
		if (errorcode == FTPERR_SERVER_SECURITY && !addPublic(&filename)) {
			rc = 1;
		}
		else {
			rc = newtWinChoice(_("GET File Error"), 
				_("Retry"), _("Cancel"), 
				_("Could not get file:\n\nhttps://%s/%s\n\n%s"),
				ui->address, filename, 
				ftpStrerror(errorcode, URL_METHOD_HTTP));
		}
		if (rc==1) 	/* Retry */
			return urlinstStartSSLTransfer(ui, filename,
				extraHeaders, silentErrors, flags, nextServer);
		else	/* Cancel */
			return NULL;
	}

	if (!FL_CMDLINE(flags))
		winStatus(70, 3, _("Retrieving"), "%s %.*s...", 
			_("Retrieving"), 60, filename);

	return sbio;
}
void FatFs_task(void)
{
	portTickType xDelayPeriod = (portTickType)500 / portTICK_RATE_MS;
	sub_net_init();
	while(1)
	{
	 	vTaskDelay(xDelayPeriod);
		if(sd_status == 1)  // parse hex file, and read it to RAM
		{
			f_mount(0, &fs);
//			scan_files("0:/");
		    f_open(&file, "0:/64K.hex", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
			read_ptr = 0;

//			file_size = f_size(&file);
//			printd("\r\nfile_size = %lu", file_size);

			file_end_flag = FALSE;
			memset(hex_ram_0, 0xff, HEX_BANK_SIZE);
			memset(hex_ram_1, 0xff, HEX_BANK_SIZE);

			max_data_length = 0;
			max_package = 0;

			while(1)
			{
				if(FR_OK == f_lseek(&file, read_ptr))
				{
					if((FR_OK == f_read(&file, read_buf, READ_SIZE, &br)) && (br != 0))
					{
						read_buf[br] = '\0';
						if(getstr = strtok(read_buf, token))
						{
							do
							{
								if(parse(getstr, hex_buf, &hex_bytes, &valid_length) == TRUE)
								{
									if(hexline.type == 0)
									{
										uint8 i;
										for(i = 0; i < hex_bytes; i++)
										{
											if(hexline.length < HEX_BANK_SIZE)
											{
												hex_ram_0[hexline.address + i] = hex_buf[i];
											}
											else
											{
												hex_ram_1[hexline.address + i - HEX_BANK_SIZE] = hex_buf[i];
											} 
										}
									}
									else if(hexline.type == 1)
									{
										file_end_flag = TRUE;
										break;
									}
									else
									{

									}

									read_ptr += valid_length;
									
									if(max_data_length < (hexline.address + hexline.length))
									{
										max_data_length = hexline.address + hexline.length;
									}
								}
							} while(getstr = strtok(NULL, token));
						}

//						printd("\r\nread_ptr = %lu", read_ptr);
					}
					else
					{
						printd("\r\nf_read() failed..");
					}
				}
				else
				{
					printd("\r\nf_lseek() failed..");
				}
				
				if(file_end_flag == TRUE)
				{
					max_package = (max_data_length >> 7);
					if(max_data_length & 0x0000007f)
						max_package++;
					break;
				}

				watchdog_reset();
				vTaskDelay(5);
			}

			f_close(&file);

			sd_status = 2;
		}
Example #30
0
int main(void)
{
  disable_unused_circuits();
  _delay_ms(50);

#ifdef HAS_CHARGER
  reset_on_power_change();
#endif /* HAS_CHARGER */

  /* Shut off right away if battery is very low. Do not power on NFC module */
  adc_init();
  (void)read_voltage();
  // Read one more time in case first reading is corrupted
  uint8_t voltage = read_voltage();
  adc_disable();
  if (is_battery_dead(voltage)) {
    //beep_n_times_and_wait(4);
    //sleep_forever();
  }

  lcd_init();
  print_idle();

  // Initialize and self-test
  module_power_up();
  led_on();
#ifdef WITH_TARGET
  // We may have come out of target power down mode
  //(void)pasori_wake_up();
#endif

  while (!rcs956_reset()) {};

  if (!eeprom_has_station_info()) {
    beep_n_times_and_wait(3);
    sleep_forever();
  }
  if (is_on_external_power()) {
    play_song_and_wait(melody_start_up_external,
                       sizeof(melody_start_up_external) / sizeof(struct note));
  } else {
    play_song_and_wait(melody_start_up_battery,
                       sizeof(melody_start_up_battery) / sizeof(struct note));
  }
  led_off();
  initiator_set_defaults();
  watchdog_start();

  for (;;) {
    watchdog_reset();
    // initiator exits after polling times out (false) or URL is pushed (true)
    if (initiator(PUSH_URL_LABEL)) {
      lcd_puts(0, "PUSH SLEEP");
      play_url_push_success_song_and_wait();
    }
#ifdef WITH_TARGET
    uint8_t loop;
    // Loop here to not skip watchdog timer
    for (loop = 0; loop < TARGET_MODE_RETRY; loop++) {
      watchdog_reset();
      (void)rcs956_reset();
      enum target_res res = target(PUSH_URL_LABEL_ENGLISH);
      if (res == TGT_COMPLETE) {
        led_off();
        play_url_push_success_song_and_wait();
        break;
      } else if (res == TGT_TIMEOUT || res == TGT_ERROR) {
        break;
      } // loop on TGT_RETRY
    }
    led_off();
    (void)rcs956_reset();
    low_battery_check();
#else /* !WITH_TARGET */
    // Check battery level while RF field is still on
    low_battery_check();
    sleep_after_timeout();
#endif /* WITH_TARGET */

    // Reconfigure Felica module if communication timed out,
    // e.g. due to temporary disconnect.
    if (protocol_errno == TIMEOUT) {
      initiator_set_defaults();
      eeprom_increment_usart_fail();
    }
    protocol_errno = SUCCESS;
  }

  /* NOT REACHABLE */
  return 0;
}