void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_LOOP, COMMAND_SIZE) == 0)
        {
            process_command_loop();
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            hw_reset();
        }
        else
        {
            char err[40];
            snprintf(err, sizeof(err), "ERROR invalid command %.4s\n", received_cmd);
            console_print(err);
        }

        fifo_clear(&uart_rx_fifo);
    }
}
Beispiel #2
0
void emu_reset()
{
	hw_reset();
	lcd_reset();
	cpu_reset();
	mbc_reset();
	sound_reset();
}
static ssize_t hw_reset_set(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	int rc;
	struct  fpc1145_data *fpc1145 = dev_get_drvdata(dev);

	if (!strncmp(buf, "reset", strlen("reset")))
		rc = hw_reset(fpc1145);
	else
		return -EINVAL;
	return rc ? rc : count;
}
Beispiel #4
0
void emu_reset()
{
        sram_save();
        rtc_save();

        hw_reset();
        lcd_reset();
        cpu_reset();
        mbc_reset();
        sound_reset();

        init = 0;
}
static void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_TRAN, COMMAND_SIZE) == 0)
        {
            while(fifo_get_size(&uart_rx_fifo) < COMMAND_TRAN_PARAM_SIZE);

            char param[COMMAND_TRAN_PARAM_SIZE];
            fifo_pop(&uart_rx_fifo, param, COMMAND_TRAN_PARAM_SIZE);
            tx_packet_delay_s = atoi(param);
            DPRINT("performing TRAN command with %d tx_packet_delay_s\r\n",
                   tx_packet_delay_s);

            stop();
            is_mode_rx = false;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RECV, COMMAND_SIZE) == 0)
        {
            DPRINT("entering RECV mode\r\n");
            stop();
            is_mode_rx = true;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            DPRINT("resetting...\r\n");
            hw_reset();
        }
        else
        {
            char err[40];
            DPRINT("ERROR invalid command %.4s\n\r", received_cmd);
        }

        fifo_clear(&uart_rx_fifo);
    }

    timer_post_task_delay(&process_uart_rx_fifo, TIMER_TICKS_PER_SEC);
}
Beispiel #6
0
void emu_reset()
{
	hw_reset();
	lcd_reset();
	cpu_reset();
	mbc_reset();
	sound_reset();
	ccmpl_reset();
	//cop_stop_draw();
	
#ifdef DEBUG
	debug_file = fopen("/out", "w+");
	if(!debug_file) die("no debugging possible... I better die");
	if(lcd_file) close(lcd_file);
#endif
}
static void process_shell_cmd(char cmd)
{
    switch(cmd)
    {
        case 'E':
            echo = ! echo;
            if(echo) { console_print("echo is on\r\n");  }
            else     { console_print("echo is off\r\n"); }
            break;
        case 'R':
            hw_reset();
            break;
        default:
            // TODO log
            break;
    }
}
static void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_TRAN, COMMAND_SIZE) == 0)
        {
            while(fifo_get_size(&uart_rx_fifo) < COMMAND_TRAN_PARAM_SIZE);

            char param[COMMAND_TRAN_PARAM_SIZE];
            fifo_pop(&uart_rx_fifo, param, COMMAND_TRAN_PARAM_SIZE);
            tx_packet_delay_s = atoi(param);

            stop();
            is_mode_rx = false;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RECV, COMMAND_SIZE) == 0)
        {
            stop();
            is_mode_rx = true;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            hw_reset();
        }
        else
        {
            char err[40];
            snprintf(err, sizeof(err), "ERROR invalid command %.4s\n", received_cmd);
            uart_transmit_string(err);
        }

        fifo_clear(&uart_rx_fifo);
    }

    timer_post_task_delay(&process_uart_rx_fifo, TIMER_TICKS_PER_SEC);
}
//we override __assert_func to flash the leds (so we know something bad has happend)
//and to repeat the error message repeatedly (so we have a chance to attach the device to a serial console before the error message is gone)
void __assert_func( const char *file, int line, const char *func, const char *failedexpr)
{
#if defined FRAMEWORK_DEBUG_ASSERT_REBOOT // make sure this parameter is used also when including assert.h instead of debug.h
        hw_reset();
#endif

	start_atomic();
	led_on(0);
	led_on(1);
#ifdef PLATFORM_USE_USB_CDC
	// Dissable all IRQs except the one for USB
	for(uint32_t j=0;j < EMU_IRQn; j++)
		NVIC_DisableIRQ(j);

	NVIC_EnableIRQ( USB_IRQn );

	end_atomic();
#endif

	lcd_clear();
	lcd_write_string("ERROR");
	lcd_write_number(timer_get_counter_value());

    __asm__("BKPT"); // break into debugger

	while(1)
	{
		printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",failedexpr, file, line, func ? ", function: " : "", func ? func : "");

		for(uint32_t j = 0; j < 20; j++)
		{
			//blink at twice the frequency of the _exit call, so we can identify which of the two events has occurred
			for(uint32_t i = 0; i < 0xFFFFF; i++){}
			led_toggle(0);
			led_toggle(1);
		}
	}
	end_atomic();

}
Beispiel #10
0
/*
  This should be the FOURTH function to call.
  It simply resets the hardware engine.
*/
int ti68k_reset(void)
{
	hw_reset();

	return 0;
}
Beispiel #11
0
static void tc3162_machine_power_off(void)
{
	printk("Machine poweroff ... \n");
	hw_reset();
	while (1);
}
Beispiel #12
0
static void tc3162_machine_halt(void)
{
	printk("Machine halted ... \n");
	hw_reset();
	while (1);
}
Beispiel #13
0
static void tc3162_machine_restart(char *command)
{
	printk("Machine restart ... \n");
	hw_reset();
	back_to_prom();
}
/*
 *
 *   Function Name: DSI_PowerControl
 *
 *   Description:	  Display Module Control
 *
 */
Int32 DSI_PowerControl(
	DISPDRV_HANDLE_T drvH,
	DISPLAY_POWER_STATE_T state)
{
	Int32  res = 0;
	DispDrv_PANEL_t *pPanel = (DispDrv_PANEL_t *)drvH;
	DISPDRV_INFO_T *info = pPanel->disp_info;

	switch (state) {
	case CTRL_PWR_ON:
		switch (pPanel->pwrState) {
		case STATE_PWR_OFF:
			res = regulator_enable(disp_reg);
			if (res < 0) {
				DSI_ERR("Couldn't enable regulator, res=%ld\n",
					res);
				res = -1;
				break;
			}
			usleep_range(1000, 1010);
#ifdef CONFIG_LCD_LOW_TEMP_CONVERSION
		if( -50 > get_temp_from_ps_battery())
			DSI_ExecCmndList(pPanel, info->init_lowtemp_seq);	
		else
#endif		
			DSI_ExecCmndList(pPanel, info->init_seq);
			
			DSI_WinSet(drvH, TRUE, &pPanel->win_dim);
			pPanel->pwrState = STATE_SCREEN_OFF;
			DSI_INFO("INIT-SEQ\n");
			break;
		default:
			DSI_ERR("POWER ON req While Not In POWER DOWN State\n");
			break;
		}
		break;

	case CTRL_PWR_OFF:
		if (pPanel->pwrState !=	STATE_PWR_OFF) {
			if (info->vmode && info->vid_cmnds)
				DSI_panel_shut_down(pPanel);
			else
				DSI_ExecCmndList(pPanel, info->scrn_off_seq);
			DSI_ExecCmndList(pPanel, info->slp_in_seq);

			res = regulator_disable(disp_reg);
			if (res < 0) {
				DSI_ERR("Couldn't disable regulator, res=%ld\n",
					res);
				res = -1;
				break;
			}
			hw_reset(drvH, TRUE);
			memset(&pPanel->win_cur, 0, sizeof(DISPDRV_WIN_t));
			pPanel->pwrState = STATE_PWR_OFF;
			DSI_INFO("PWR DOWN\n");
		}
		break;

	case CTRL_SLEEP_IN:
		switch (pPanel->pwrState) {
		case STATE_SCREEN_ON:
			if (info->vmode && info->vid_cmnds)
				DSI_panel_shut_down(pPanel);
			else
				DSI_ExecCmndList(pPanel, info->scrn_off_seq);
			/* Turn OFF and sleep in */
		case STATE_SCREEN_OFF:
			DSI_ExecCmndList(pPanel, info->slp_in_seq);
			pPanel->pwrState = STATE_SLEEP;
			break;
		default:
			DSI_ERR("SLEEP Req, But Not In DISP ON|OFF State\n");
			break;
		}
		break;

	case CTRL_SLEEP_OUT:
		switch (pPanel->pwrState) {
		case STATE_SLEEP:
			DSI_ExecCmndList(pPanel, info->slp_out_seq);
			pPanel->pwrState = STATE_SCREEN_OFF;
			DSI_INFO("SLEEP-OUT\n");
			break;
		default:
			DSI_ERR("SLEEP-OUT Req While Not In SLEEP State\n");
			break;
		}
		break;

	case CTRL_SCREEN_ON:
		switch (pPanel->pwrState) {
		case STATE_SCREEN_OFF:
			if (info->vmode && info->vid_cmnds)
				DSI_panel_turn_on(pPanel);
			else
				DSI_ExecCmndList(pPanel, info->scrn_on_seq);

			pPanel->pwrState = STATE_SCREEN_ON;
			DSI_INFO("SCREEN ON\n");
			break;
		default:
			DSI_ERR("SCRN ON Req While Not In SCRN OFF State\n");
			break;
		}
		break;
	case CTRL_SCREEN_OFF:
		switch (pPanel->pwrState) {
		case STATE_SCREEN_ON:
			if (info->vmode && info->vid_cmnds)
				DSI_panel_shut_down(pPanel);
			else
				DSI_ExecCmndList(pPanel, info->scrn_off_seq);

			pPanel->pwrState = STATE_SCREEN_OFF;
			DSI_INFO("SCREEN OFF\n");
			break;
		default:
			DSI_ERR("SCRN OFF Req While Not In SCRN ON State\n");
			break;
		}
		break;
	default:
		DSI_ERR("Invalid Power State[%d] Requested\n", state);
		res = -1;
		break;
	}
	return res;
}
/*
 *
 *  Function Name: DSI_Open
 *
 *  Description:   disp bus ON
 *
 */
Int32 DSI_Open(DISPDRV_HANDLE_T drvH)
{
	Int32 res = 0;
	DispDrv_PANEL_t	*pPanel;

	pPanel = (DispDrv_PANEL_t *) drvH;

	DSI_INFO("enter\n");

	if (pPanel->drvState !=	DRV_STATE_INIT)	{
		DSI_ERR("ERROR State != Init\n");
		return -1;
	}

	if (brcm_enable_dsi_pll_clocks(pPanel->busNo,
		pPanel->dsi_cfg->hsBitClk.clkIn_MHz * 1000000,
		pPanel->dsi_cfg->hsBitClk.clkInDiv,
		pPanel->disp_info->desense_offset,
		pPanel->dsi_cfg->escClk.clkIn_MHz   * 1000000
		/ pPanel->dsi_cfg->escClk.clkInDiv)) {

		DSI_ERR("ERROR enabling clock\n");
	}

	if (pPanel->isTE && DSI_TeOn(pPanel) == -1) {
		DSI_ERR("Failed to Configure TE Input\n");
		goto err_te_on;
	}

	if (CSL_DSI_Init(pPanel->dsi_cfg) != CSL_LCD_OK) {
		DSI_ERR("DSI CSL Init Failed\n");
		goto err_dsi_init;
	}

	if (CSL_DSI_OpenClient(pPanel->busNo, &pPanel->clientH)	!= CSL_LCD_OK) {
		DSI_ERR("CSL_DSI_OpenClient Failed\n");
		goto err_dsi_open_cl;
	}

	if (CSL_DSI_OpenCmVc(pPanel->clientH,
		pPanel->cmnd_mode, &pPanel->dsiCmVcHandle) != CSL_LCD_OK) {

		DSI_ERR("CSL_DSI_OpenCmVc Failed\n");
		goto err_dsi_open_cm;
	}

	if (!pPanel->dsi_cfg->dispEngine && pPanel->dsi_cfg->pixTxporter) {
		DSI_ERR("Cannot transfer pixels via MMDMA to DispEngine 0.");
		DSI_ERR("Default to Display Engine 1\n");
		pPanel->dsi_cfg->dispEngine = 1;
	}

	if (pPanel->dsi_cfg->dispEngine && pPanel->dsi_cfg->pixTxporter) {
		if (csl_dma_vc4lite_init() != DMA_VC4LITE_STATUS_SUCCESS) {
			DSI_ERR("csl_dma_vc4lite_init Failed\n");
			goto err_dma_init;
		}
	}
	if (!disp_reg) {
		/*CAM2 LDO */
		disp_reg = regulator_get(NULL, pPanel->disp_info->reg_name);
		if (IS_ERR_OR_NULL(disp_reg)) {
			DSI_ERR("Failed to get disp_reg\n");
			goto err_reg_init;
		}
		if (g_display_enabled)
			regulator_enable(disp_reg); /* Turn ON disp_reg to increase use count */
	}
	res = gpio_request(pPanel->disp_info->rst->gpio, "LCD_RST");
	if (res < 0) {
		DSI_ERR("gpio_request failed %ld\n", res);
		goto err_gpio_request;
	}

	if (!g_display_enabled)
		hw_reset(drvH, FALSE);
#if 0	// SS & DS not used
	if (DSI_ReadPanelID(pPanel) < 0) {
		DSI_ERR("ID read failed\n");
		goto err_id_read;
	}
#endif
	pPanel->win_dim.l = 0;
	pPanel->win_dim.r = pPanel->disp_info->width-1;
	pPanel->win_dim.t = 0;
	pPanel->win_dim.b = pPanel->disp_info->height-1;
	pPanel->win_dim.w = pPanel->disp_info->width;
	pPanel->win_dim.h = pPanel->disp_info->height;

	pPanel->drvState = DRV_STATE_OPEN;

	DSI_INFO("OK\n");

	return res;
#if 0
err_id_read:
	gpio_free(pPanel->disp_info->rst->gpio);
#endif
err_gpio_request:
err_reg_init:
err_dma_init:
	CSL_DSI_CloseCmVc(pPanel->dsiCmVcHandle);
err_dsi_open_cm:
	CSL_DSI_CloseClient(pPanel->clientH);
err_dsi_open_cl:
	CSL_DSI_Close(pPanel->busNo);
err_dsi_init:
	if (pPanel->isTE)
		DSI_TeOff(pPanel);
err_te_on:
	return -1;
}