close the command shell
Posted: Thu Sep 18, 2014 2:18 pm
Hello all,
I am trying to close the command shell in order to make a system restart/reset.
The command shell prompts on sd2.
The way I do it is:
where:
I had to comment the shellExit stuff because otherwise system hangs.
Is this way the right one?
Thank you in advance.
-g
I am trying to close the command shell in order to make a system restart/reset.
The command shell prompts on sd2.
The way I do it is:
Code: Select all
int main(void) {
uint32_t ApplicationAddress = FLASH_BASE;
uint32_t stack = *(__IO uint32_t*) ApplicationAddress;
pFunction Jump_To_Application = (pFunction) (*(__IO uint32_t*) (ApplicationAddress + 4));
halInit();
chSysInit();
/* init dshell */
dshell_init();
while (!restart_flag) {
/* create shell */
dshell_create();
chThdSleepMicroseconds(200);
} /* main while */
dshell_exit();
chSysDisable();
/* Clear pending interrupts just to be on the save side*/
SCB_ICSR = ICSR_PENDSVCLR;
/* Disable all interrupts */
for(i=0; i<8; i++)
NVIC->ICER[i] = NVIC->IABR[i];
__set_MSP(stack);
Jump_To_Application();
return 0;
}
where:
Code: Select all
void dshell_init(void) {
/*
* Shell manager initialization.
*/
shellInit();
/*
* Activates the serial driver 6 and SDC driver 1 using default
* configuration.
*/
/*
* Activates the serial driver 1 using the driver default configuration.
* PA2(TX) and PA3(RX) are routed to USART2.
*/
sdStart(&SD2, NULL);
palSetPadMode(GPIOA, GPIOA_USART2_TXD, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, GPIOA_USART2_RXD, PAL_MODE_ALTERNATE(7));
}
void dshell_create(void) {
if (!shelltp)// && (SDU1.config->usbp->state == USB_ACTIVE))
shelltp = shellCreateStatic(&shell_cfg1, waShellThread, sizeof(waShellThread), NORMALPRIO);
else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
}
void dshell_exit(void) {
/* shellExit(RDY_OK); */
sdStop(&SD2);
}
I had to comment the shellExit stuff because otherwise system hangs.
Is this way the right one?
Thank you in advance.
-g