コード例 #1
0
ファイル: cpu.c プロジェクト: x893/OpenBLT
/************************************************************************************//**
** \brief     Perform a soft reset of the microcontroller by starting from the reset ISR.
** \return    none.
**
****************************************************************************************/
void CpuReset(void)
{
  /* perform a software reset by calling the reset ISR routine. note that this requires
   * access to the processor status registers (PSRs), which works because the entire
   * bootloader runs in supervisor mode.
   */ 
  Reset_Handler();
} /*** end of CpuReset ***/
コード例 #2
0
void OpenOBC::wake()
{
	__disable_irq();
// 	*obcS->clockLight = true;
// 	delay(160); //80 = 2 seconds at 4MHz
// 	SystemInit();
// 	*obcS->lcdLight = true;
// 	*obcS->keypadLight = true;
	__set_MSP(0x10008000);
	Reset_Handler();
}
コード例 #3
0
ファイル: boot.c プロジェクト: lightsfury/GCC-ARM
void Reset_Handler(void)
{
	memcpy(&_staticDataStart, &_staticDataSource, (size_t)&_staticDataLength);
	memset(&_staticZeroStart, 0, (size_t)&_staticZeroLength);
	
	// If requested, call a system initializer
#ifdef _GCC_ARM_SYSTEM_INIT
	SystemInit();
#endif // _GCC_ARM_SYSTEM_INIT
	
	// Call the libc initializer
	__libc_init_array();
	
	// User entry point
	main();
	
	// Tail-call loop
	Reset_Handler();
}
コード例 #4
0
ファイル: STM32Platform.cpp プロジェクト: okertanov/VelaOS
    C++ PAL
*******************************************************************************/
namespace Vela
{
namespace PAL
{

}
}

extern unsigned long _estack;

ATTR_ISR_VECTOR ISRVectorArray =
{
    (ISRCallback)((unsigned long)&_estack),
    Reset_Handler(),
    0
};

#if defined(VELA_OWN_NEW_DELETE)
/**
    @fn ::operator new()
    @brief

    @param[in]
    @param[out]
    @param[in,out]
    @return
*/
void* operator new(size_t n)
{
コード例 #5
0
ファイル: shell.c プロジェクト: oujoshua/445M
static int _SH_Reset(void)
{
	Reset_Handler();
	return 0;
}
コード例 #6
0
ファイル: task_controller.c プロジェクト: funshine/LIDAR
/**
 * \brief	Controller Task. Implementation of the controller task with his own loop.
 * \param[in]	pvParameters task parameters. Not used.
 */
void taskController(void* pvParameters) {
	event_t event;
	char str_buffer[64];
	dataacquisition_t data_acquisition_config;
	uint16_t tdc_hits;
	uint8_t hits_error;

	/* Sends the welcome text */
	event.event = Sys_Welcome;
	xQueueSend(queueEvent, &event, portMAX_DELAY);

	/* initialize the system */
	event.event = Sys_Init;
	xQueueSend(queueEvent, &event, portMAX_DELAY);

	/* Loop forever */
	for (;;) {
		/* Wait for an event */
		if (xQueueReceive(queueEvent, &event, 100) == pdTRUE) {

			/* Resolve the event */
			switch (event.event) {

			/* Initialize the system. Called after the system start */
			case Sys_Init:
				/* Set the default system states and configurations */
				g_systemState.comm_echo = 1;
				g_systemState.comm_respmsg = 1;
				g_systemState.scan_bndry_left = DA_AZIMUTH_MIN;
				g_systemState.scan_bndry_right = DA_AZIMUTH_MAX;
				g_systemState.scan_step = DA_AZIMUTH_RES;
				g_systemState.scan_rate = DA_DEF_SCANRATE;
				g_systemState.engine_sleep = 0;
				g_systemState.state = MODE_CMD;
				g_systemState.readcommand = 1;

				/* Reads the first user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Make a system check */
			case Sys_Check:

				break;

			/* Sends the welcome text over the interface */
			case Sys_Welcome:
				sendMessage(MSG_TYPE_STATE, "LIDAR v"LIDAR_VERSION);
				sendMessage(MSG_TYPE_STATE, "BFH Thesis 2014");
				sendMessage(MSG_TYPE_STATE, "By Kevin Gerber, Marcel Baertschi");
				break;

			/* Change into the command mode */
			case UC_Cmd:
				if (g_systemState.state == MODE_DATA) {
					/* Stop the data acquisition */
					data_acquisition_config.state = DATA_ACQUISITION_DISABLE;
					data_acquisition_config.param.engine_sleep = g_systemState.engine_sleep;
					xQueueSend(queueDataAcquisition, &data_acquisition_config, portMAX_DELAY);

					/* Change the state */
					g_systemState.state = MODE_CMD;
					g_systemState.readcommand = g_systemState.comm_echo;
				}

				/* Reset the LED */
				bsp_LedSetOff(LED_LASER_OPERATION);

				/* Send the response message */
				sendMessage(MSG_TYPE_STATE, "cmd");

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Change into the data mode and starts the data acquisition */
			case UC_Data:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.state = MODE_DATA;
					g_systemState.readcommand = 0;

					/* Starts the data acquisition */
					data_acquisition_config.state = DATA_ACQUISITION_ENABLE;
					data_acquisition_config.param.scan.bndry_left = g_systemState.scan_bndry_left;
					data_acquisition_config.param.scan.bndry_right = g_systemState.scan_bndry_right;
					data_acquisition_config.param.scan.step = g_systemState.scan_step;
					data_acquisition_config.param.scan.rate = g_systemState.scan_rate;
					xQueueSend(queueDataAcquisition, &data_acquisition_config, portMAX_DELAY);

					/* Set the LED */
					bsp_LedSetOn(LED_LASER_OPERATION);

					/* Send the response message */
					sendMessage(MSG_TYPE_STATE, "data");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Reboot the system */
			case UC_Reboot:
				/* Send the response message */
				sendMessage(MSG_TYPE_STATE, "rebooting");

				/* Delay to send the output buffer */
				vTaskDelay(10);

				/* Disable all interrupts */
				__disable_irq();

				/* call the reset handler */
				Reset_Handler();
				break;

			/* Enable/disable the command echo */
			case UC_SetCommEcho:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.comm_echo = event.param.echo;
					g_systemState.readcommand = event.param.echo;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Enable/disable the response message */
			case UC_SetCommRespmsg:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.comm_respmsg = event.param.respmsg;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Configure the scan area boundary */
			case UC_SetScanBndry:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.scan_bndry_left = event.param.azimuth_bndry.left;
					g_systemState.scan_bndry_right = event.param.azimuth_bndry.right;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Configure the step size between two measurement points */
			case UC_SetScanStep:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.scan_step = event.param.azimuth_step;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Configure the update rate of the hole room map */
			case UC_SetScanRate:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.scan_rate = event.param.scan_rate;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Sets the time delay before the engine is suspended */
			case UC_SetEngineSleep:
				if (g_systemState.state == MODE_CMD) {
					/* Change the system state */
					g_systemState.engine_sleep = event.param.engine_sleep;

					/* Send the acknowledge to the user */
					sendMessage(MSG_TYPE_RSP, "00 aok");
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Get all configured parameters */
			case UC_GetAll:
				/* Execute all get cases */

			/* Get the version number */
			case UC_GetVer:
				if (g_systemState.state == MODE_CMD) {
					/* Print the version number */
					sendMessage(MSG_TYPE_CONF, "ver "LIDAR_VERSION);
				}

				/* Execute all get cases */
				if (event.event != UC_GetAll) {
					/* Read the next user command */
					xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
					break;
				}

			/* Get the communication configurations */
			case UC_GetComm:
				if (g_systemState.state == MODE_CMD) {
					/* Print communication echo */
					sprintf(str_buffer, "comm echo %s", g_systemState.comm_echo ? "on" : "off");
					sendMessage(MSG_TYPE_CONF, str_buffer);

					/* Print communication response message */
					sprintf(str_buffer, "comm respmsg %s", g_systemState.comm_respmsg ? "on" : "off");
					sendMessage(MSG_TYPE_CONF, str_buffer);
				}

				/* Execute all get cases */
				if (event.event != UC_GetAll) {
					/* Read the next user command */
					xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
					break;
				}

			/* Get the scan configurations */
			case UC_GetScan:
				if (g_systemState.state == MODE_CMD) {
					/* Print scan boundary */
					sprintf(str_buffer, "scan bndry %d %d", g_systemState.scan_bndry_left, g_systemState.scan_bndry_right);
					sendMessage(MSG_TYPE_CONF, str_buffer);

					/* Print scan step */
					sprintf(str_buffer, "scan step %d", g_systemState.scan_step);
					sendMessage(MSG_TYPE_CONF, str_buffer);

					/* Print scan rate */
					sprintf(str_buffer, "scan rate %d", g_systemState.scan_rate);
					sendMessage(MSG_TYPE_CONF, str_buffer);
				}

				/* Execute all get cases */
				if (event.event != UC_GetAll) {
					/* Read the next user command */
					xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
					break;
				}

			/* Get the engine configurations */
			case UC_GetEngine:
				if (g_systemState.state == MODE_CMD) {
					/* Print engine sleep */
					sprintf(str_buffer, "engien sleep %d", g_systemState.engine_sleep);
					sendMessage(MSG_TYPE_CONF, str_buffer);
				}

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Some magic feature */
			case UC_EE:
				triggerMalfunctionLed();
				stopDataAcquisition();
				#ifdef TASK_EE_H_
				taskEEInit();
				#endif

				/* Read the next user command */
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* A unknown command is received */
			case ErrUC_UnknownCommand:
				sprintf(str_buffer, "%d unknown command", 11 + event.param.error_level);
				sendMessage(MSG_TYPE_RSP, str_buffer);
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* To few arguments in the command */
			case ErrUC_TooFewArgs:
				sendMessage(MSG_TYPE_RSP, "21 too few arguments");
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* One or more arguments were in the fault data type */
			case ErrUC_FaultArgType:
				sendMessage(MSG_TYPE_RSP, "22 fault argument type");
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* One or more arguments were out of the allowed bounds */
			case ErrUC_ArgOutOfBounds:
				sendMessage(MSG_TYPE_RSP, "31 argument out of bound");
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Command line overflow detected */
			case ErrUC_LineOverflow:
				/* Trigger the error LED */
				triggerMalfunctionLed();

				/* Send e dummy message to be sure the frame end was sent */
				sendMessage(MSG_TYPE_STATE, "");

				/* Send the error message. */
				sendMessage(MSG_TYPE_RSP, "91 command line overflow");
				xQueueSend(queueReadCommand, &g_systemState.readcommand, portMAX_DELAY);
				break;

			/* Engine overcurrent or thermal shutdown */
			case Malf_EngineDriver:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "engine driver malfunction");

				/* Stop the data acquisition */
				stopDataAcquisition();
			break;

			/* Engine controller timeout */
			case Malf_Engine:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "eingine is blocked");

				/* Stop the data acquisition */
				stopDataAcquisition();
				break;

			/* Laser overcurrent was detected */
			case Malf_LaserDriver:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "laser driver malfunction");

				/* Stop the data acquisition */
				stopDataAcquisition();
				break;

			/* Quadrature encoder malfunction was detected */
			case Malf_QuadEnc:
				/* Trigger the error LED */
				triggerMalfunctionLed();
				sendMessage(MSG_TYPE_STATE, "quadrature encoder malfunction");
				break;

			/* TDC stat register has an unexpected value */
			case Malf_Tdc:
				/* Check the type of error */
				hits_error = 0;
				if (event.param.gp22_stat & 0xE000) {
					sendMessage(MSG_TYPE_STATE, "tdc eeprom malfunction");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}
				if (event.param.gp22_stat & 0x1800) {
					sendMessage(MSG_TYPE_STATE, "tdc temperature sensor malfunction");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}
				if (event.param.gp22_stat & 0x0400) {
					sendMessage(MSG_TYPE_STATE, "tdc precounter timeout");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}
				/* number of hits channel 2 */
				tdc_hits = (event.param.gp22_stat & 0x01C0) >> 6;
				if (tdc_hits > 1) {
					hits_error = 1;
					//sendMessage(MSG_TYPE_STATE, "receiver malfunction");
				}
				/* number of hits channel 1 */
				tdc_hits = (event.param.gp22_stat & 0x0038) >> 3;
				if (tdc_hits > 1) {
					hits_error = 1;
					sendMessage(MSG_TYPE_STATE, "monitor malfunction");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}
				if (tdc_hits == 0) {
					hits_error = 1;
					sendMessage(MSG_TYPE_STATE, "laser diode malfunction");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}
				if (hits_error == 0 && event.param.gp22_stat & 0x0200) {
					hits_error = 1;
					sendMessage(MSG_TYPE_STATE, "tdc timeout");
					/* Trigger the error LED */
					triggerMalfunctionLed();
				}

				break;

			/* Serial interface timeout occurs */
			case Marf_Serial:
				/* Sets the LED forever */
				bsp_LedSetOn(LED_MALFUNCTION);
				/* Error message is not possible due the malfunction in the gatekeeper */

				/* Disable all interrupts */
				__disable_irq();
				/* ... and hang on */
				for (;;) {

				}
				break;

			/* No space available in memory pool */
			case Fault_MemoryPool:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "no space available in memory pool");

				/* Stop the data acquisition */
				stopDataAcquisition();
				break;

			/* Not allowed pointer to raw data memory */
			case Fault_MemoryPoolPtr:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "internal timing malfunction");

				/* Stop the data acquisition */
				stopDataAcquisition();
				break;

			/* Not ready for the next data point */
			case Fault_Timing:
				/* Set the error LED */
				bsp_LedSetOn(LED_MALFUNCTION);
				sendMessage(MSG_TYPE_STATE, "scanner overspeed");

				/* Stop the data acquisition */
				stopDataAcquisition();
				break;

			/* Command error */
			default:
				triggerMalfunctionLed();
				sendMessage(MSG_TYPE_STATE, "unknown controller event");
				break;
			}
		}
	}

	/* Never reach this point */
}