Commit 470d0567 authored by Thomas Schöpping's avatar Thomas Schöpping
Browse files

Renamed the interface header file (in ./Target/Source/AMiRo/) from 'interfaces.h' to 'amiroblt.h'.

The interface was additionally modified:
- The magic number for identification has been changed from 0xFF669900 to 0x0x412D424C ("A-BL"), making the interface incompatible to older versions.
- Several macros have been replaced by enums.
- Some structs and enums have been renamed, making the interface incompatible to version 0.3.
The memory layout, however, is unchanged so that required operating system tweaks are minimal.
parent 4cce70a8
......@@ -38,7 +38,7 @@
/*#include "stm32f10x_fsmc.h"*/
#include "stm32f10x_gpio.h" /* needed for configuring the SPI and UART pins */
/*#include "stm32f10x_i2c.h"*/
/*#include "stm32f10x_iwdg.h"*/
#include "stm32f10x_iwdg.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h" /* needed for enabling the SPI and UART peripherals */
#include "stm32f10x_rtc.h"
......
......@@ -23,11 +23,11 @@
* You should have received a copy of the GNU General Public License along with OpenBLT.
* If not, see <http://www.gnu.org/licenses/>.
*
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* proprietary components. The exception text is included at the bottom of the license
* file <license.html>.
*
*
* \endinternal
****************************************************************************************/
......@@ -39,7 +39,7 @@
#include "stm32f10x_conf.h" /* STM32 peripheral drivers */
#include "timer.h"
#include "ARMCM3_STM32/types.h"
#include "AMiRo/interfaces.h"
#include "AMiRo/amiroblt.h"
#include "AMiRo/helper.h"
......@@ -157,7 +157,7 @@ void shutdownToDeepsleep(const blt_bool exec_disambiguation);
void shutdownToHibernate(const blt_bool exec_disambiguation);
void shutdownAndRestart(const blt_bool exec_disambiguation);
volatile BlBackupRegister backup_reg;
volatile blBackupRegister_t backup_reg;
/****************************************************************************************
* Callback configuration
......@@ -168,11 +168,11 @@ void blCallbackShutdownHibernate(void);
void blCallbackShutdownRestart(void);
void blCallbackHandleShutdownRequest(void);
const BlCallbackTable cbtable __attribute ((section ("_callback_table"))) = {
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
.magicNumber = BL_MAGIC_NUMBER,
.versionMajor = BL_VERSION_MAJOR,
.versionMinor = BL_VERSION_MINOR,
.versionHotfix = 0,
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
.cbShutdownHibernate = blCallbackShutdownHibernate,
.cbShutdownDeepsleep = blCallbackShutdownDeepsleep,
.cbShutdownTransportation = blCallbackShutdownTransportation,
......@@ -189,7 +189,7 @@ const BlCallbackTable cbtable __attribute ((section ("_callback_table"))) = {
/************************************************************************************//**
** \brief This is the entry point for the bootloader application and is called
** \brief This is the entry point for the bootloader application and is called
** by the reset interrupt vector after the C-startup routines executed.
** \return Program return code.
**
......@@ -276,7 +276,7 @@ int main(void)
/************************************************************************************//**
** \brief Initializes the microcontroller.
** \brief Initializes the microcontroller.
** \return none.
**
****************************************************************************************/
......@@ -286,8 +286,8 @@ static void Init(void)
blt_int32u pll_multiplier;
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0)
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;
#endif
USART_InitTypeDef USART_InitStruct;
#endif
/* reset the RCC clock configuration to the default reset state (for debug purpose) */
/* set HSION bit */
......@@ -302,14 +302,14 @@ static void Init(void)
RCC->CFGR &= (blt_int32u)0xFF80FFFF;
/* disable all interrupts and clear pending bits */
RCC->CIR = 0x009F0000;
/* enable HSE */
/* enable HSE */
RCC->CR |= ((blt_int32u)RCC_CR_HSEON);
/* wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CR & RCC_CR_HSERDY;
StartUpCounter++;
}
StartUpCounter++;
}
while((HSEStatus == 0) && (StartUpCounter != 1500));
/* check if time out was reached */
if ((RCC->CR & RCC_CR_HSERDY) == RESET)
......@@ -323,10 +323,10 @@ static void Init(void)
FLASH->ACR &= (blt_int32u)((blt_int32u)~FLASH_ACR_LATENCY);
#if (BOOT_CPU_SYSTEM_SPEED_KHZ > 48000)
/* configure 2 flash wait states */
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_2;
#elif (BOOT_CPU_SYSTEM_SPEED_KHZ > 24000)
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_2;
#elif (BOOT_CPU_SYSTEM_SPEED_KHZ > 24000)
/* configure 1 flash wait states */
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_1;
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_1;
#endif
/* HCLK = SYSCLK */
RCC->CFGR |= (blt_int32u)RCC_CFGR_HPRE_DIV1;
......@@ -354,7 +354,7 @@ static void Init(void)
}
/* select PLL as system clock source */
RCC->CFGR &= (blt_int32u)((blt_int32u)~(RCC_CFGR_SW));
RCC->CFGR |= (blt_int32u)RCC_CFGR_SW_PLL;
RCC->CFGR |= (blt_int32u)RCC_CFGR_SW_PLL;
/* wait till PLL is used as system clock source */
while ((RCC->CFGR & (blt_int32u)RCC_CFGR_SWS) != (blt_int32u)0x08)
{
......
......@@ -120,7 +120,7 @@ main.c \
../../../Source/ARMCM3_STM32/flash.h \
../../../Source/ARMCM3_STM32/GCC/vectors.c \
../../../Source/ARMCM3_STM32/GCC/cstart.c \
../../../Source/AMiRo/interfaces.h \
../../../Source/AMiRo/amiroblt.h \
../../../Source/AMiRo/helper.h \
../../../Source/AMiRo/helper.c
......
......@@ -23,11 +23,11 @@
* You should have received a copy of the GNU General Public License along with OpenBLT.
* If not, see <http://www.gnu.org/licenses/>.
*
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* proprietary components. The exception text is included at the bottom of the license
* file <license.html>.
*
*
* \endinternal
****************************************************************************************/
......@@ -39,7 +39,7 @@
#include "stm32f10x_conf.h" /* STM32 peripheral drivers */
#include "timer.h"
#include "ARMCM3_STM32/types.h"
#include "AMiRo/interfaces.h"
#include "AMiRo/amiroblt.h"
#include "AMiRo/helper.h"
......@@ -127,7 +127,7 @@ void shutdownToDeepsleep(const blt_bool exec_disambiguation);
void shutdownToHibernate(const blt_bool exec_disambiguation);
void shutdownAndRestart(const blt_bool exec_disambiguation);
volatile BlBackupRegister backup_reg;
volatile blBackupRegister_t backup_reg;
/****************************************************************************************
* Callback configuration
......@@ -138,11 +138,11 @@ void blCallbackShutdownHibernate(void);
void blCallbackShutdownRestart(void);
void blCallbackHandleShutdownRequest(void);
const BlCallbackTable cbtable __attribute__ ((section ("_callback_table"))) = {
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
.magicNumber = BL_MAGIC_NUMBER,
.versionMajor = BL_VERSION_MAJOR,
.versionMinor = BL_VERSION_MINOR,
.versionHotfix = 0,
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
.cbShutdownHibernate = blCallbackShutdownHibernate,
.cbShutdownDeepsleep = blCallbackShutdownDeepsleep,
.cbShutdownTransportation = blCallbackShutdownTransportation,
......@@ -158,7 +158,7 @@ const BlCallbackTable cbtable __attribute__ ((section ("_callback_table"))) = {
};
/************************************************************************************//**
** \brief This is the entry point for the bootloader application and is called
** \brief This is the entry point for the bootloader application and is called
** by the reset interrupt vector after the C-startup routines executed.
** \return Program return code.
**
......@@ -219,7 +219,7 @@ int main(void)
/************************************************************************************//**
** \brief Initializes the microcontroller.
** \brief Initializes the microcontroller.
** \return none.
**
****************************************************************************************/
......@@ -229,8 +229,8 @@ static void Init(void)
blt_int32u pll_multiplier;
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0) && (BOOT_GATE_UART_ENABLE == 0)
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;
#endif
USART_InitTypeDef USART_InitStruct;
#endif
/* reset the RCC clock configuration to the default reset state (for debug purpose) */
/* set HSION bit */
......@@ -245,14 +245,14 @@ static void Init(void)
RCC->CFGR &= (blt_int32u)0xFF80FFFF;
/* disable all interrupts and clear pending bits */
RCC->CIR = 0x009F0000;
/* enable HSE */
/* enable HSE */
RCC->CR |= ((blt_int32u)RCC_CR_HSEON);
/* wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CR & RCC_CR_HSERDY;
StartUpCounter++;
}
StartUpCounter++;
}
while((HSEStatus == 0) && (StartUpCounter != 1500));
/* check if time out was reached */
if ((RCC->CR & RCC_CR_HSERDY) == RESET)
......@@ -266,10 +266,10 @@ static void Init(void)
FLASH->ACR &= (blt_int32u)((blt_int32u)~FLASH_ACR_LATENCY);
#if (BOOT_CPU_SYSTEM_SPEED_KHZ > 48000)
/* configure 2 flash wait states */
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_2;
#elif (BOOT_CPU_SYSTEM_SPEED_KHZ > 24000)
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_2;
#elif (BOOT_CPU_SYSTEM_SPEED_KHZ > 24000)
/* configure 1 flash wait states */
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_1;
FLASH->ACR |= (blt_int32u)FLASH_ACR_LATENCY_1;
#endif
/* HCLK = SYSCLK */
RCC->CFGR |= (blt_int32u)RCC_CFGR_HPRE_DIV1;
......@@ -297,7 +297,7 @@ static void Init(void)
}
/* select PLL as system clock source */
RCC->CFGR &= (blt_int32u)((blt_int32u)~(RCC_CFGR_SW));
RCC->CFGR |= (blt_int32u)RCC_CFGR_SW_PLL;
RCC->CFGR |= (blt_int32u)RCC_CFGR_SW_PLL;
/* wait till PLL is used as system clock source */
while ((RCC->CFGR & (blt_int32u)RCC_CFGR_SWS) != (blt_int32u)0x08)
{
......@@ -365,7 +365,7 @@ static void Init(void)
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
GPIO_Init(GPIOA, &GPIO_InitStruct);
/* configure UART communcation parameters */
/* configure UART communcation parameters */
USART_InitStruct.USART_BaudRate = BOOT_COM_UART_BAUDRATE;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
......
......@@ -121,7 +121,7 @@ main.c \
../../../Source/ARMCM3_STM32/flash.h \
../../../Source/ARMCM3_STM32/GCC/vectors.c \
../../../Source/ARMCM3_STM32/GCC/cstart.c \
../../../Source/AMiRo/interfaces.h \
../../../Source/AMiRo/amiroblt.h \
../../../Source/AMiRo/helper.h \
../../../Source/AMiRo/helper.c
......
......@@ -23,11 +23,11 @@
* You should have received a copy of the GNU General Public License along with OpenBLT.
* If not, see <http://www.gnu.org/licenses/>.
*
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* A special exception to the GPL is included to allow you to distribute a combined work
* that includes OpenBLT without being obliged to provide the source code for any
* proprietary components. The exception text is included at the bottom of the license
* file <license.html>.
*
*
* \endinternal
****************************************************************************************/
......@@ -39,7 +39,7 @@
#include "stm32f4xx_conf.h" /* STM32 peripheral drivers */
#include "com.h"
#include "ARMCM4_STM32/types.h"
#include "AMiRo/interfaces.h"
#include "AMiRo/amiroblt.h"
#include "AMiRo/helper.h"
/****************************************************************************************
......@@ -180,7 +180,7 @@ void shutdownToDeepsleep();
void shutdownToHibernate();
void shutdownAndRestart();
volatile BlBackupRegister backup_reg;
volatile blBackupRegister_t backup_reg;
/****************************************************************************************
* Callback configuration
......@@ -191,11 +191,11 @@ void blCallbackShutdownHibernate(void);
void blCallbackShutdownRestart(void);
void blCallbackHandleShutdownRequest(void);
const BlCallbackTable cbtable __attribute__ ((section ("_callback_table"))) = {
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
.magicNumber = BL_MAGIC_NUMBER,
.versionMajor = BL_VERSION_MAJOR,
.versionMinor = BL_VERSION_MINOR,
.versionHotfix = 0,
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
.cbShutdownHibernate = blCallbackShutdownHibernate,
.cbShutdownDeepsleep = blCallbackShutdownDeepsleep,
.cbShutdownTransportation = blCallbackShutdownTransportation,
......@@ -211,7 +211,7 @@ const BlCallbackTable cbtable __attribute__ ((section ("_callback_table"))) = {
};
/************************************************************************************//**
** \brief This is the entry point for the bootloader application and is called
** \brief This is the entry point for the bootloader application and is called
** by the reset interrupt vector after the C-startup routines executed.
** \return none.
**
......@@ -321,7 +321,7 @@ void main(void)
/************************************************************************************//**
** \brief Initializes the microcontroller.
** \brief Initializes the microcontroller.
** \return none.
**
****************************************************************************************/
......@@ -334,7 +334,7 @@ static void Init(void)
USART_InitTypeDef USART_InitStructure;
#elif (BOOT_COM_CAN_ENABLE > 0 || BOOT_GATE_CAN_ENABLE > 0)
GPIO_InitTypeDef GPIO_InitStructure;
#endif
#endif
/* initialize the system and its clocks */
SystemInit();
......@@ -399,7 +399,7 @@ static void Init(void)
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* select alternate function for the CAN pins */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_CAN1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_CAN1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_CAN1);
/* configure CAN RX and TX pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
......@@ -413,7 +413,7 @@ static void Init(void)
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif
#endif
} /*** end of Init ***/
......@@ -632,7 +632,7 @@ void shutdownToTransportation() {
IWDG_ReloadCounter();
/* write some information to the backup register */
BlBackupRegister backup;
blBackupRegister_t backup;
backup.shutdown_pri_reason = BL_SHUTDOWN_PRI_RSN_TRANSPORT;
backup.shutdown_sec_reason = BL_SHUTDOWN_SEC_RSN_UNKNOWN;
backup.wakeup_pri_reason = BL_WAKEUP_PRI_RSN_UNKNOWN;
......@@ -668,7 +668,7 @@ void shutdownToDeepsleep() {
*/
/* write some information to the backup register */
BlBackupRegister backup;
blBackupRegister_t backup;
backup.shutdown_pri_reason = BL_SHUTDOWN_PRI_RSN_DEEPSLEEP;
backup.shutdown_sec_reason = BL_SHUTDOWN_SEC_RSN_UNKNOWN;
backup.wakeup_pri_reason = BL_WAKEUP_PRI_RSN_UNKNOWN;
......@@ -701,7 +701,7 @@ void shutdownToHibernate() {
systemPowerDown();
/* write some information to the backup register */
BlBackupRegister backup;
blBackupRegister_t backup;
backup.shutdown_pri_reason = BL_SHUTDOWN_PRI_RSN_HIBERNATE;
backup.shutdown_sec_reason = BL_SHUTDOWN_SEC_RSN_UNKNOWN;
backup.wakeup_pri_reason = BL_WAKEUP_PRI_RSN_UNKNOWN;
......@@ -730,7 +730,7 @@ void shutdownAndRestart() {
systemPowerDown();
/* write some information to the backup register */
BlBackupRegister backup;
blBackupRegister_t backup;
backup.shutdown_pri_reason = BL_SHUTDOWN_PRI_RSN_RESTART;
backup.shutdown_sec_reason = BL_SHUTDOWN_SEC_RSN_UNKNOWN;
backup.wakeup_pri_reason = BL_WAKEUP_PRI_RSN_UNKNOWN;
......
......@@ -139,7 +139,7 @@ main.c \
../../../Source/ARMCM4_STM32/timer.h \
../../../Source/ARMCM4_STM32/GCC/vectors.c \
../../../Source/ARMCM4_STM32/GCC/cstart.c \
../../../Source/AMiRo/interfaces.h \
../../../Source/AMiRo/amiroblt.h \
../../../Source/AMiRo/helper.h \
../../../Source/AMiRo/helper.c
......
......@@ -7,69 +7,110 @@
* @{
*/
#ifndef BL_INTERFACES_H
#define BL_INTERFACES_H
#ifndef _AMIROBLT_H_
#define _AMIROBLT_H_
#include <stdint.h>
/*===========================================================================*/
/*============================================================================*/
/**
* @defgroup AMiRo-BLT-IF Bootloader Interface
* @defgroup AMiRo-BLT-IF AMiRo Bootloader Interface
* @details This interface can be used to interface the AMiRo bootloader from an operating system.
*
* @{
*/
/*===========================================================================*/
/*============================================================================*/
/*===========================================================================*/
/*============================================================================*/
/**
* @name Callback Table
* @details The callback table is a static struct, located at address @ref BL_CALLBACK_TABLE_ADDRESS in the MCUs flash memory (ROM).
* @details The callback table is a static struct, located in the MCUs flash memory (ROM) with offset @ref BL_CALLBACK_TABLE_OFFSET .
* It contains version information and a bunch of callback function pointers.
*/
///@{
/**
* @brief The memory address where the @ref BlCallbackTable struct is located in flash memory.
* @note This address must correspond with the @p _callback_table section in file @p memory.x of the bootloader.
* @brief The offset from the flash memory base address to where the @ref blCallbackTable_t struct is stored.
* @note This offset must correspond with the @p _callback_table section in file @p memory.x of the bootloader.
*/
#define BL_CALLBACK_TABLE_ADDRESS (uint32_t)(0x08000000u + 0x01C0u)
#define BL_CALLBACK_TABLE_OFFSET 0x000001C0u
/**
* @brief A magic number to detect whether the callback table exists.
* @brief The memory address where the @ref blCallbackTable_t struct is located in flash memory.
* @note This adress must correspond with the @p _callback_table section in file @p memory.x of the bootloader.
* @deprecated The @ref BL_CALLBACK_TABLE_OFFSET macro must be used for new software.
*/
#define BL_MAGIC_NUMBER ((uint32_t)0xFF669900u)
#define BL_CALLBACK_TABLE_ADDRESS ((blCallbackTable_t*)(0x08000000u + BL_CALLBACK_TABLE_OFFSET))
/**
* @brief The major version number of the bootloader.
*/
#define BL_VERSION_MAJOR 0
#define BL_VERSION_MAJOR 1
/**
* @brief The minor version number of the bootloader.
*/
#define BL_VERSION_MINOR 3
#define BL_VERSION_MINOR 0
/**
* @brief The major version number of the implemented SSSP (Startup & Synchronization Protocol).
* @brief The major version number of the implemented SSSP (Startup & Shutdown Synchronization Protocol).
*/
#define SSSP_VERSION_MAJOR 1
/**
* @brief The minor version number of the implemented SSSP (Startup & Synchronization Protocol).
* @brief The minor version number of the implemented SSSP (Startup & Shutdown Synchronization Protocol).
*/
#define SSSP_VERSION_MINOR 1
/**
* @brief A struct to define a version in a generic way.
*/
struct blVersion_t {
const uint8_t identifier; /**< The identifier can be used if the version can be ambiguous. */
const uint8_t major; /**< Major version number. */
const uint8_t minor; /**< Minor version number. */
const uint8_t patch; /**< Patch level number. */
} __attribute__((packed));
/**
* @brief Synonym for simplified access.
*/
typedef struct blVersion_t blVersion_t;
/**
* @brief An enum that defines possible values for the 'identifier' member of the @p blVersion_t struct.
* @note The values must be in (unsigned) 8 bit integer range.
*/
enum blVersionIdentifier_t {
BL_VERSION_ID_UNKNOWN = 0x00u, /**< Unknown identifier */
BL_VERSION_ID_NA = 0xFFu, /**< Identifier not applicable */
BL_VERSION_ID_AMiRoBLT_PreAlpha = 0x01u, /**< AMiRo-BLT pre-alpha identifier. */
BL_VERSION_ID_AMiRoBLT_Alpha = 0x02u, /**< AMiRo-BLT alpha version identifier. */
BL_VERSION_ID_AMiRoBLT_Beta = 0x03u, /**< AMiRo-BLT beta version identifier. */
BL_VERSION_ID_AMiRoBLT_ReleaseCandidate = 0x04u, /**< AMiRo-BLT release candidate (RC) identifier. */
BL_VERSION_ID_AMiRoBLT_Release = 0x05u, /**< AMiRo-BLT release version identifier. */
BL_VERSION_ID_SSSP = 0x01u, /**< Startup & Shutdown Synchronization Protocol identifier. */
BL_VERSION_ID_GCC = 0x01u, /**< Gnu Compiler Collection identifier. */
};
/**
* @brief A magic number to detect whether the callback table exists.
* @details The magic number can be interpreted as four character string "A-BL".
* The according hexadecimal values are 0x41, 0x2D, 0x42, and 0x4C.
* The according 32 bit integer is 0x412D424C.
*/
#define BL_MAGIC_NUMBER ((uint32_t)(('A'<<24) | ('-'<<16) | ('B'<<8) | ('L'<<0)))
/**
* @brief This struct contains information about the bootloader version and pointers to several callback function.
* It is located at the constant address @ref BL_CALLBACK_TABLE_ADDRESS in the flash memory.
* It is located at the constant address @ref BL_CALLBACK_TABLE_OFFSET in the flash memory.
* @note Sicne the actual implementations of the callback functions are optional, the pointers must be checked not to be @p NULL before use!
*/
struct BlCallbackTable {
const uint32_t magicNumber; /**< A magic number that can be used for sanity checks. @sa BL_MAGIC_NUMBER */
const uint32_t versionMajor; /**< The major version number of the bootloader. @sa BL_VERSION_MAJOR */
const uint32_t versionMinor; /**< The minor version number of the bootloader. @sa BL_VERSION_MINOR */
const uint32_t versionHotfix; /**< The hotfix indicator of the bootloader. */
struct blCallbackTable_t {
const uint32_t magicNumber; /**< A magic number that can be used for sanity checks. @sa BL_MAGIC_NUMBER. */
const blVersion_t vBootloader; /**< Version information about the bootloader. */
const blVersion_t vSSSP; /**< Version information about the Startup & Shutdown Synchronization Protocol (SSSP). */
const blVersion_t vCompiler; /**< Version information about the used compiler. */
/**
* @brief Callback function pointer to enter hibernate mode.
* @details In hibernate mode, the system enters maximum power-saving mode, but will wake up periodically in order to read some sensors.
......@@ -102,17 +143,17 @@ struct BlCallbackTable {
void (*const cb9)(void); /**< Reserved but currently unused callback function pointer. */
void (*const cb10)(void); /**< Reserved but currently unused callback function pointer. */
void (*const cb11)(void); /**< Reserved but currently unused callback function pointer. */
};
} __attribute__((__packed__));
/**
* @brief Synonym for simplified access.
*/
typedef struct BlCallbackTable BlCallbackTable;
typedef struct blCallbackTable_t blCallbackTable_t;
///@}
/*===========================================================================*/
/*============================================================================*/
/*===========================================================================*/
/*============================================================================*/
/**
* @name Backup Register
* @details For the STM32F4 MCU (PowerManagement), the backup register contains additional information about the last shutdown and wakeup of the system.
......@@ -128,7 +169,7 @@ typedef struct BlCallbackTable BlCallbackTable;
/**
* @brief This union is used for interpretation of the content of the backup register.
*/
union BlBackupRegister {
union blBackupRegister_t {
/**
* @brief The raw data of the register.
*/
......@@ -165,142 +206,152 @@ union BlBackupRegister {
* @sa BL_WAKEUP_SEC_RSN_UNKNOWN, BL_WAKEUP_SEC_RSN_UART, BL_WAKEUP_SEC_RSN_PWRPLUG, BL_WAKEUP_SEC_RSN_VSYSHIGH, BL_WAKEUP_SEC_RSN_VSYSLOW, BL_WAKEUP_SEC_RSN_TOUCH, BL_WAKEUP_SEC_RSN_ACCEL, BL_WAKEUP_SEC_RSN_RSVD
*/
uint8_t wakeup_sec_reason;
};
} __attribute__((__packed__));
};
typedef union BlBackupRegister BlBackupRegister;
/**
* @brief The reason was not set or the register was reset.
*/
#define BL_SHUTDOWN_PRI_RSN_UNKNOWN 0x00u
/**
* @brief The system was shut down to enter hibernate mode.
*/
#define BL_SHUTDOWN_PRI_RSN_HIBERNATE 0x01u
/**
* @brief The system was shut down to enter deepsleep mode.
* @brief Synonym for simplified access.
*/
#define BL_SHUTDOWN_PRI_RSN_DEEPSLEEP 0x02u
typedef union blBackupRegister_t blBackupRegister_t;
/**
* @brief The system was shut down to enter transportation mode.
* @brief An enum defining identifiers for possible reasons for system shutdown.
* @note The values must be in (unsigned) 8 bit integer range.
*/
#define BL_SHUTDOWN_PRI_RSN_TRANSPORT 0x03u
/**
* @brief The system was shut down to restart.
*/
#define BL_SHUTDOWN_PRI_RSN_RESTART 0x04u
/**
* @brief The default shutdown mode.
* @details This mode is used, if the shutdown sequence was triggered by another module than the PowerManagement.
*/
#define BL_SHUTDOWN_PRI_RSN_DEFAULT BL_SHUTDOWN_PRI_RSN_DEEPSLEEP
enum blShutdownReason_t {
/**
* @brief The reason was not set or the register was reset.