373a8c32b2
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
89 lines
2.6 KiB
C
89 lines
2.6 KiB
C
/* ---------------------------------------------------------------------------
|
|
* Bootloader.c - v0.1 (c) 2008 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description: Activates the bootloader.
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, Feb 21, 2008, FSc
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "types.h"
|
|
#include "sys_config.h"
|
|
#include "Bootloader.h"
|
|
#include "watchdog.h"
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local constant and macro definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
typedef void (*t_bootloader_startup)(void);
|
|
#define BOOTMODE_ADDR 0x4000005C
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Global variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local function definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
//* \brief Jumps to bootloader
|
|
void blActivateBootloader()
|
|
{
|
|
// Set direction pin for storing
|
|
*((UINT32 *)BOOTMODE_ADDR) = STAY_IN_BOOTLOADER;
|
|
|
|
DISABLE_INTERRUPTS();
|
|
|
|
watchdogEnable( 1 ); // force watchdog reset
|
|
}
|
|
|
|
|
|
t_bl_bootmodes blGetBootmode()
|
|
{
|
|
if ( *((UINT32 *)BOOTMODE_ADDR) == (UINT32)STAY_IN_BOOTLOADER)
|
|
{
|
|
return STAY_IN_BOOTLOADER;
|
|
}
|
|
else
|
|
{
|
|
return CONTINUE_APPLICATION;
|
|
}
|
|
}
|
|
|
|
void blResetBootmode()
|
|
{
|
|
*((UINT32 *)BOOTMODE_ADDR) = CONTINUE_APPLICATION;
|
|
|
|
}
|
|
|
|
|