1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-21/Bootloader Small change. Now turns off interrupts before jumping to code.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1393 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-08-23 21:30:09 +00:00 committed by zedamota
parent 8adbd76a4e
commit f91ae974a7

View File

@ -44,17 +44,8 @@ void DelayWithDown(__IO uint32_t nCount);
* Output : None.
* Return : None.
*******************************************************************************/
int main(void)
{
if (((*(__IO uint32_t*)StartOfUserCode) & 0x2FFE0000 ) == 0x20000000)
{ /* Jump to user application */
int main(void) {
JumpAddress = *(__IO uint32_t*) (StartOfUserCode + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) StartOfUserCode);
Jump_To_Application();
}
Set_System();
USB_Interrupts_Config();
@ -64,14 +55,18 @@ int main(void)
USB_Init();
DeviceState = idle;
while (JumpToApp==0)
{
while (JumpToApp == 0) {
STM_EVAL_LEDToggle(LED1);
DelayWithDown(10);//1000000);
}
if (((*(__IO uint32_t*)StartOfUserCode) & 0x2FFE0000 ) == 0x20000000)
{ /* Jump to user application */
if (((*(__IO uint32_t*) StartOfUserCode) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
FLASH_Lock();
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
RCC_APB2PeriphResetCmd(0xffffffff, DISABLE);
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
_SetCNTR(0); // clear interrupt mask
_SetISTR(0); // clear all requests
JumpAddress = *(__IO uint32_t*) (StartOfUserCode + 4);
Jump_To_Application = (pFunction) JumpAddress;
@ -79,8 +74,7 @@ int main(void)
__set_MSP(*(__IO uint32_t*) StartOfUserCode);
Jump_To_Application();
}
while(1)
{
while (1) {
STM_EVAL_LEDToggle(LED1);
STM_EVAL_LEDToggle(LED2);
Delay(1000000);
@ -94,10 +88,8 @@ int main(void)
* Output : None
* Return : None
*******************************************************************************/
void Delay(__IO uint32_t nCount)
{
for(; nCount!= 0;nCount--)
{
void Delay(__IO uint32_t nCount) {
for (; nCount != 0; nCount--) {
}
}
@ -108,11 +100,10 @@ void Delay(__IO uint32_t nCount)
* Output : None
* Return : None
*******************************************************************************/
void DelayWithDown(__IO uint32_t nCount)
{
for(; nCount!= 0;nCount--)
{
for(__IO uint32_t delay=DownloadDelay ; delay!=0 ; delay--){}
void DelayWithDown(__IO uint32_t nCount) {
for (; nCount != 0; nCount--) {
for (__IO uint32_t delay = DownloadDelay; delay != 0; delay--) {
}
FLASH_Download();
}
}