Example #1
0
int main()
{
	init();
	//Test();
	wdt_start(wdt_60ms);
	while(1)
	{
		wdt_feed();
		DoMenu();
		if (isPedal1Pressed() == TRUE && (getCurMenuId() == idPrograms)) // если нажата педаль и активное меню - "Программы"
		{
			StartTaskWelding();
			while(isPedal1Pressed())
			{
				u8 res = DoWelding();
				if (res == WELD_HAS_BROKEN)
					break;
				wdt_feed();
			}
			StopTaskWelding();
			SetMenu(&mPrograms);
		}
	}
	return 0;
}
Example #2
0
cfw_client_t * system_setup(T_QUEUE *q, handle_msg_cb_t cb, void *cb_data)
{
	cfw_client_t * client;

	/* Initialize OS abstraction */
	os_init();

	/* Setup BSP and get main queue */
	*q = bsp_setup();

	/* start Quark watchdog */
	wdt_start(WDT_MAX_TIMEOUT_MS);

	/* Component framework and services setup */
	client = cfw_app_setup(*q, cb, cb_data);
	pr_info(LOG_MODULE_MAIN, "cfw init done");

	/* Cproxy is another (deprecated) way to communicate with the component
	 * framework, used by some test commands and some services. Initialize
	 * it here. */
	cproxy_init(*q);

	/* Initialize ARC shared structure and start it. */
	shared_data->ports = port_get_port_table();
	shared_data->services = services;
	shared_data->service_mgr_port_id = cfw_get_service_mgr_port_id();
	start_arc(0);

	return client;
}
Example #3
0
int board_late_init(void)
{
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
	watchdog_dev = NULL;

	if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) {
		debug("Watchdog: Not found by seq!\n");
		if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
			puts("Watchdog: Not found!\n");
			return 0;
		}
	}

	wdt_start(watchdog_dev, 0, 0);
	puts("Watchdog: Started\n");
#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
	int ret;

	ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
				 "reset_soft", NULL);
	if (ret)
		printf("Warning: No reset driver: ret=%d\n", ret);
#endif
	return 0;
}
Example #4
0
static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
	struct ast_wdt *wdt = ast_get_wdt(AST_WDT_FOR_RESET);
	u32 reset_mode = 0;

	if (IS_ERR(wdt))
		return PTR_ERR(wdt);

	switch (type) {
	case SYSRESET_WARM:
		reset_mode = WDT_CTRL_RESET_CPU;
		break;
	case SYSRESET_COLD:
		reset_mode = WDT_CTRL_RESET_CHIP;
		break;
	default:
		return -EPROTONOSUPPORT;
	}

	/* Clear reset mode bits */
	clrsetbits_le32(&wdt->ctrl,
			(WDT_CTRL_RESET_MODE_MASK << WDT_CTRL_RESET_MODE_SHIFT),
			(reset_mode << WDT_CTRL_RESET_MODE_SHIFT));
	wdt_start(wdt, AST_WDT_RESET_TIMEOUT);

	return -EINPROGRESS;
}
Example #5
0
int timer_testSetup(void)
{
	IRQ_ENABLE;
	wdt_start(7);
	timer_init();
	kdbg_init();
	return 0;
}
Example #6
0
static int __maybe_unused stmp3xxx_wdt_resume(struct device *dev)
{
	struct watchdog_device *wdd = &stmp3xxx_wdd;

	if (watchdog_active(wdd))
		return wdt_start(wdd);

	return 0;
}
Example #7
0
static int wdt_open(struct inode *inode, struct file *file)
{
	/* If the watchdog is alive we don't need to start it again */
	if (test_and_set_bit(0, &timer_alive))
		return -EBUSY;

	if (nowayout)
		__module_get(THIS_MODULE);

	wdt_start();
	return nonseekable_open(inode, file);
}
Example #8
0
void WatchdogTask (void * Parameters)
{
    wdt_start();
    for ( ;; ) {
        if (xSemaphoreTake(watchdog_smphr, 0)) {
            NVIC_SystemReset();
        }
        wdt_feed();
        //printf(" Watchdog fed (again) \n ");
        vTaskDelay(WATCHDOG_FEED_DELAY);
    }
}
Example #9
0
void init()
{
	wdt_start(wdt_250ms);
	initProc();
	initVars();
	initParams();
#ifndef _DEBUG_
	lcd_init(LCD_DISP_ON);
	//init_lcd_simbols();
#ifdef _DEMO_VERSION_
	SplashScreen();
#endif // _DEMO_VERSION_
#endif // _DEBUG_
	SetMenu(&mPrograms);
}
Example #10
0
int board_init(void)
{
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
	if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) {
		debug("Watchdog: Not found by seq!\n");
		if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
			puts("Watchdog: Not found!\n");
			return 0;
		}
	}

	wdt_start(watchdog_dev, 0, 0);
	puts("Watchdog: Started\n");
# endif

	return 0;
}
Example #11
0
/* Application main entry point */
void main_task (void *param)
{
  /* Init BSP (also init BSP on ARC core) */
  queue = bsp_init ();
  /* start Quark watchdog */
  wdt_start (WDT_MAX_TIMEOUT_MS);
  /* Init the CFW */
  cfw_init (queue);
  jerry_start ();
  /* Loop to process message queue */
  while (1)
  {
    OS_ERR_TYPE err = E_OS_OK;
    /* Process message with a given timeout */
    queue_process_message_wait (queue, 5000, &err);
    /* Acknowledge the system watchdog to prevent panic and reset */
    wdt_keepalive ();
  }
}
Example #12
0
cfw_handle_t system_setup(T_QUEUE *q, handle_msg_cb_t cb, void *cb_data)
{
	cfw_handle_t handle;

	/* Initialize OS abstraction */
	os_init();

	/* Setup IPC and main queue */
	*q = ipc_setup();

	/* General hardware setup function, pass the ipc message handler if you
	 * want to use this feature. */
	soc_setup(ipc_handle_message);

	/* start Quark watchdog */
	wdt_start(WDT_MAX_TIMEOUT_MS);

	/* USB setup */
	usb_app_setup();

	/* Start log infrastructure */
	log_start(log_backend_uart);

	/* Enable test command engine async support through the main queue */
	tcmd_async_init(*q);
	/* Test commands will use the same port as the log system */
	set_tcmd_uart_port(CONFIG_UART_CONSOLE_INDEX);

	/* Component framework and services setup */
	handle = cfw_setup(*q, cb, NULL);
	pr_info(LOG_MODULE_MAIN, "cfw init done");

	/* Initialize ARC shared structure and start it. */
	shared_data->ports = port_get_port_table();
	shared_data->services = services;
	shared_data->service_mgr_port_id = cfw_get_service_mgr_port_id();
	start_arc(0);

	return handle;
}
Example #13
0
int board_init(void)
{
	/* adress of boot parameters */
	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

#ifndef CONFIG_SPL_BUILD
# ifdef CONFIG_WDT_ORION
	if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
		puts("Cannot find Armada 385 watchdog!\n");
	} else {
		puts("Enabling Armada 385 watchdog.\n");
		wdt_start(watchdog_dev, (u32) 25000000 * 120, 0);
	}
# endif

	if (disable_mcu_watchdog())
		puts("Disabled MCU startup watchdog.\n");

	set_regdomain();
#endif

	return 0;
}
Example #14
0
static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int status;
	int new_options, retval = -EINVAL;
	int new_timeout;
	union {
		struct watchdog_info __user *ident;
		int __user *i;
	} uarg;

	uarg.i = (int __user *)arg;

	switch (cmd) {
	case WDIOC_GETSUPPORT:
		return copy_to_user(uarg.ident, &ident,
						sizeof(ident)) ? -EFAULT : 0;

	case WDIOC_GETSTATUS:
		wdt_get_status(&status);
		return put_user(status, uarg.i);

	case WDIOC_GETBOOTSTATUS:
		return put_user(0, uarg.i);

	case WDIOC_SETOPTIONS:
		if (get_user(new_options, uarg.i))
			return -EFAULT;

		if (new_options & WDIOS_DISABLECARD) {
			wdt_stop();
			retval = 0;
		}

		if (new_options & WDIOS_ENABLECARD) {
			wdt_start();
			retval = 0;
		}

		return retval;

	case WDIOC_KEEPALIVE:
		wdt_keepalive();
		return 0;

	case WDIOC_SETTIMEOUT:
		if (get_user(new_timeout, uarg.i))
			return -EFAULT;

		if (wdt_set_timeout(new_timeout))
			return -EINVAL;

		wdt_keepalive();
		/* Fall */

	case WDIOC_GETTIMEOUT:
		return put_user(timeout, uarg.i);

	default:
		return -ENOTTY;

	}
}
Example #15
0
static int mid_wdt_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct watchdog_device *wdt_dev;
	struct intel_mid_wdt_pdata *pdata = dev->platform_data;
	int ret;

	if (!pdata) {
		dev_err(dev, "missing platform data\n");
		return -EINVAL;
	}

	if (pdata->probe) {
		ret = pdata->probe(pdev);
		if (ret)
			return ret;
	}

	wdt_dev = devm_kzalloc(dev, sizeof(*wdt_dev), GFP_KERNEL);
	if (!wdt_dev)
		return -ENOMEM;

	wdt_dev->info = &mid_wdt_info;
	wdt_dev->ops = &mid_wdt_ops;
	wdt_dev->min_timeout = MID_WDT_TIMEOUT_MIN;
	wdt_dev->max_timeout = MID_WDT_TIMEOUT_MAX;
	wdt_dev->timeout = MID_WDT_DEFAULT_TIMEOUT;
	wdt_dev->parent = dev;

	watchdog_set_drvdata(wdt_dev, dev);

	ret = devm_request_irq(dev, pdata->irq, mid_wdt_irq,
			       IRQF_SHARED | IRQF_NO_SUSPEND, "watchdog",
			       wdt_dev);
	if (ret) {
		dev_err(dev, "error requesting warning irq %d\n", pdata->irq);
		return ret;
	}

	/*
	 * The firmware followed by U-Boot leaves the watchdog running
	 * with the default threshold which may vary. When we get here
	 * we should make a decision to prevent any side effects before
	 * user space daemon will take care of it. The best option,
	 * taking into consideration that there is no way to read values
	 * back from hardware, is to enforce watchdog being run with
	 * deterministic values.
	 */
	ret = wdt_start(wdt_dev);
	if (ret)
		return ret;

	/* Make sure the watchdog is serviced */
	set_bit(WDOG_HW_RUNNING, &wdt_dev->status);

	ret = devm_watchdog_register_device(dev, wdt_dev);
	if (ret) {
		dev_err(dev, "error registering watchdog device\n");
		return ret;
	}

	dev_info(dev, "Intel MID watchdog device probed\n");

	return 0;
}
Example #16
0
static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	int __user *p = argp;
	int new_heartbeat;
	int status;

	static struct watchdog_info ident = {
		.options =		WDIOF_SETTIMEOUT|
					WDIOF_MAGICCLOSE|
					WDIOF_KEEPALIVEPING,
		.firmware_version =	1,
		.identity =		"WDT500/501",
	};

	/* Add options according to the card we have */
	ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
#ifdef CONFIG_WDT_501
	ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER);
	if (tachometer)
		ident.options |= WDIOF_FANFAULT;
#endif /* CONFIG_WDT_501 */

	switch (cmd) {
	case WDIOC_GETSUPPORT:
		return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
	case WDIOC_GETSTATUS:
		wdt_get_status(&status);
		return put_user(status, p);
	case WDIOC_GETBOOTSTATUS:
		return put_user(0, p);
	case WDIOC_KEEPALIVE:
		wdt_ping();
		return 0;
	case WDIOC_SETTIMEOUT:
		if (get_user(new_heartbeat, p))
			return -EFAULT;
		if (wdt_set_heartbeat(new_heartbeat))
			return -EINVAL;
		wdt_ping();
		/* Fall */
	case WDIOC_GETTIMEOUT:
		return put_user(heartbeat, p);
	default:
		return -ENOTTY;
	}
}

/**
 *	wdt_open:
 *	@inode: inode of device
 *	@file: file handle to device
 *
 *	The watchdog device has been opened. The watchdog device is single
 *	open and on opening we load the counters. Counter zero is a 100Hz
 *	cascade, into counter 1 which downcounts to reboot. When the counter
 *	triggers counter 2 downcounts the length of the reset pulse which
 *	set set to be as long as possible.
 */

static int wdt_open(struct inode *inode, struct file *file)
{
	if (test_and_set_bit(0, &wdt_is_open))
		return -EBUSY;
	/*
	 *	Activate
	 */
	wdt_start();
	return nonseekable_open(inode, file);
}

/**
 *	wdt_release:
 *	@inode: inode to board
 *	@file: file handle to board
 *
 *	The watchdog has a configurable API. There is a religious dispute
 *	between people who want their watchdog to be able to shut down and
 *	those who want to be sure if the watchdog manager dies the machine
 *	reboots. In the former case we disable the counters, in the latter
 *	case you have to open it again very soon.
 */

static int wdt_release(struct inode *inode, struct file *file)
{
	if (expect_close == 42) {
		wdt_stop();
		clear_bit(0, &wdt_is_open);
	} else {
		printk(KERN_CRIT
		 "wdt: WDT device closed unexpectedly.  WDT will not stop!\n");
		wdt_ping();
	}
	expect_close = 0;
	return 0;
}

#ifdef CONFIG_WDT_501
/**
 *	wdt_temp_read:
 *	@file: file handle to the watchdog board
 *	@buf: buffer to write 1 byte into
 *	@count: length of buffer
 *	@ptr: offset (no seek allowed)
 *
 *	Temp_read reports the temperature in degrees Fahrenheit. The API is in
 *	farenheit. It was designed by an imperial measurement luddite.
 */

static ssize_t wdt_temp_read(struct file *file, char __user *buf,
						size_t count, loff_t *ptr)
{
	int temperature;

	if (wdt_get_temperature(&temperature))
		return -EFAULT;

	if (copy_to_user(buf, &temperature, 1))
		return -EFAULT;

	return 1;
}
static int wdt_set_timeout(struct watchdog_device *wdd, unsigned new_timeout)
{
	wdd->timeout = new_timeout;
	return wdt_start(wdd);
}
/**@brief Function for application main entry.
 */
int main(void)
{

    // Initialize	
//		nrf_gpio_cfg_output(23);
//		nrf_gpio_pin_write(23, 0);
//		nrf_gpio_pin_write(23, 1);
//		nrf_delay_ms(1000);
//		nrf_gpio_pin_write(23, 0);
		uart_init();
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
		app_button_enable();
		wdt_init();	
#ifdef  DEBUG_LOG
		printf("uart_init\r\n");
		printf("leds_init\r\n");
		printf("timers_init\r\n");
		printf("gpiote_init\r\n");
		printf("buttons_init\r\n");
		printf("wdt_init\r\n");
#endif	
	
    bond_manager_init();
    ble_stack_init();
    gap_params_init();
#ifdef  DEBUG_LOG
		printf("bond_manager_init\r\n");
		printf("ble_stack_init\r\n");
		printf("gap_params_init\r\n");
#endif


    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    conn_params_init();
    sec_params_init();	
    radio_notification_init();
#ifdef  DEBUG_LOG
		printf("advertising_init\r\n");
		printf("services_init\r\n");
		printf("conn_params_init\r\n");
		printf("radio_notification_init\r\n");
#endif

    advertising_start();
#ifdef  DEBUG_LOG
		printf("advertising_start\r\n");
#endif		
		
		
			
		HTU21D_Init();
		
#ifdef  DEBUG_LOG
		printf("HTU21D_Init\r\n");
		printf("OLED_Init\r\n");
#endif		
		
		my_timer_init();
		Auto_Time_Set();
		
#ifdef  DEBUG_LOG
		printf("rtc my_timer_init\r\n");
		printf("Auto_Time_Set\r\n");
#endif
	
		wdt_start();
#ifdef  DEBUG_LOG
		printf("wdt_start\r\n");
		printf("Enter main loop\r\n");		
#endif	

		OLED_POWER_CONTROL(1);
		nrf_delay_ms(2000);
		OLED_POWER_CONTROL(0);
    for (;;)
    {
			
			updata_by_min();
			updata_by_hour();
			power_manage();
    }
}
Example #19
0
void brick_init(void) {
	// Wait 5ms so everything can power up
	SLEEP_MS(5);
	logging_init();

	logsi("Booting %d\n\r", BRICK_DEVICE_IDENTIFIER);
	logsi("Compiled on %s %s\n\r", __DATE__, __TIME__);
	logsi("Processor family %s\n\r", IS_SAM3() ? "SAM3S" : "SAM4S");

    led_init();
	led_on(LED_STD_BLUE);
#ifdef LED_STD_RED
#if LOGGING_LEVEL == LOGGING_NONE
	led_off(LED_STD_RED);
#else
	led_on(LED_STD_RED);
#endif
#endif
	logsi("LEDs initialized\n\r");

	com_info.uid = uid_get_uid32();

	// Add 0 at end for printing
    char sn[MAX_BASE58_STR_SIZE] = {'\0'};
    uid_to_serial_number(com_info.uid, sn);
    set_serial_number_descriptor(sn, MAX_BASE58_STR_SIZE);
    logsi("Unique ID %s (%lu)\n\r\n\r", sn, com_info.uid);

    wdt_start();
    logsi("Watchdog disabled\n\r");

    mutex_init();
    logsi("Mutexes initialized\n\r");

	// Disable JTAG (Pins are needed for i2c)
#ifdef DISABLE_JTAG_ON_STARTUP
	MATRIX->CCFG_SYSIO |= (CCFG_SYSIO_SYSIO12 |
	                       CCFG_SYSIO_SYSIO4  |
	                       CCFG_SYSIO_SYSIO5  |
	                       CCFG_SYSIO_SYSIO6  |
	                       CCFG_SYSIO_SYSIO7);
	logsi("JTAG disabled\n\r");
#endif

	com_info.current = COM_NONE;
    PIO_InitializeInterrupts(15);

    bricklet_clear_eeproms();
    i2c_eeprom_master_init(TWI_BRICKLET);
    logsi("I2C for Bricklets initialized\n\r");

	usb_detect_configure();

	adc_init();
	adc_enable_temperature_sensor();
#ifndef NO_PERIODIC_ADC_CONVERISION
	adc_start_periodic_conversion();
#endif
    logsi("A/D converter initialized\n\r");

	bricklet_init();
}
Example #20
0
void reset_cpu(ulong addr)
{
	clk_enable(TNETV107X_LPSC_WDT_ARM);
	wdt_start(1);
	wdt_kick();
}