Cleanup and refactoring of the STM32w port
This is a general cleanup of things like code style issues and code structure of the STM32w port to make it more like the rest of Contiki is structured.
This commit is contained in:
parent
12b3d02ba1
commit
a5046e83c7
118 changed files with 4470 additions and 4281 deletions
|
@ -84,9 +84,9 @@ typedef struct LedResourceStruct {
|
|||
/** Name of the LED as printed in the board */
|
||||
char *name;
|
||||
/** GPIO port associated with the LED */
|
||||
int8u gpioPort;
|
||||
uint8_t gpioPort;
|
||||
/** GPIO pin associated with the LED */
|
||||
int8u gpioPin;
|
||||
uint8_t gpioPin;
|
||||
} LedResourceType;
|
||||
|
||||
typedef LedResourceType InfraRedLedResourceType;
|
||||
|
@ -98,9 +98,9 @@ typedef struct ButtonResourceStruct {
|
|||
/** Name of the button as printed in the board */
|
||||
char *name;
|
||||
/** GPIO port associated with the button */
|
||||
int8u gpioPort;
|
||||
uint8_t gpioPort;
|
||||
/** GPIO pin associated with the button */
|
||||
int8u gpioPin;
|
||||
uint8_t gpioPin;
|
||||
} ButtonResourceType;
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ typedef struct MemsResourceStruct {
|
|||
/** Name of the MEMS device */
|
||||
char *name;
|
||||
/** Serial communication port associated with the MEMS */
|
||||
int8u scPort;
|
||||
uint8_t scPort;
|
||||
} MemsResourceType;
|
||||
|
||||
/**
|
||||
|
@ -120,9 +120,9 @@ typedef struct TempSensorResourceStruct {
|
|||
/** Name of the temperature sensor device */
|
||||
char *name;
|
||||
/** GPIO port associated with the sensor */
|
||||
int8u gpioPort;
|
||||
uint8_t gpioPort;
|
||||
/** GPIO pin associated with the sensor */
|
||||
int8u gpioPin;
|
||||
uint8_t gpioPin;
|
||||
/** Flag to indicate whether the ADC range extension bug fix is implemented */
|
||||
boolean adcFix;
|
||||
} TempSensorResourceType;
|
||||
|
@ -167,11 +167,11 @@ typedef struct BoardIOStruct {
|
|||
*/
|
||||
typedef struct BoardResourcesStruct {
|
||||
const char *name;
|
||||
const int32u flags;
|
||||
const uint32_t flags;
|
||||
/** Number of buttons */
|
||||
int8u buttons;
|
||||
uint8_t buttons;
|
||||
/** Number of leds */
|
||||
int8u leds;
|
||||
uint8_t leds;
|
||||
/** Board I/O description */
|
||||
const BoardIOType *io;
|
||||
/** Board infrared led description */
|
||||
|
@ -202,7 +202,7 @@ extern BoardResourcesType const *boardDescription;
|
|||
/** Description buttons definition */
|
||||
#define BUTTON_Sn(n) (PORTx_PIN(boardDescription->io->buttons[n].gpioPort, boardDescription->io->buttons[n].gpioPin))
|
||||
#define BUTTON_Sn_WAKE_SOURCE(n) (1 << ((boardDescription->io->buttons[n].gpioPin) + (8 * (boardDescription->io->buttons[n].gpioPort >> 3))))
|
||||
#define BUTTON_INPUT_GPIO(port) *((volatile int32u *) (GPIO_PxIN_BASE + GPIO_Px_OFFSET * port))
|
||||
#define BUTTON_INPUT_GPIO(port) *((volatile uint32_t *) (GPIO_PxIN_BASE + GPIO_Px_OFFSET * port))
|
||||
#define DUMMY_BUTTON 0xff
|
||||
|
||||
#define BUTTON_S1 (boardDescription->buttons>0 ? BUTTON_Sn(0): DUMMY_BUTTON)
|
||||
|
|
|
@ -139,8 +139,8 @@ void (* const g_pfnVectors[])(void) =
|
|||
halDebugIsr, // 32
|
||||
};
|
||||
|
||||
static void setStackPointer(int32u address) __attribute__((noinline));
|
||||
static void setStackPointer(int32u address)
|
||||
static void setStackPointer(uint32_t address) __attribute__((noinline));
|
||||
static void setStackPointer(uint32_t address)
|
||||
{
|
||||
// This code is needed to generate the instruction below
|
||||
// that GNU ASM is refusing to add
|
||||
|
@ -148,7 +148,7 @@ static void setStackPointer(int32u address)
|
|||
asm(".short 0x4685");
|
||||
}
|
||||
|
||||
static const int16u blOffset[] = {
|
||||
static const uint16_t blOffset[] = {
|
||||
0x0715 - 0x03ad - 0x68,
|
||||
0x0719 - 0x03ad - 0x6C
|
||||
};
|
||||
|
@ -277,17 +277,17 @@ void Reset_Handler(void)
|
|||
}
|
||||
|
||||
//USART bootloader software activation check
|
||||
if ((*((int32u *)RAM_BOTTOM) == IAP_BOOTLOADER_APP_SWITCH_SIGNATURE) && (*((int8u *)(RAM_BOTTOM+4)) == IAP_BOOTLOADER_MODE_UART)){
|
||||
int8u cut = *(volatile int8u *) 0x08040798;
|
||||
int16u offset = 0;
|
||||
if ((*((uint32_t *)RAM_BOTTOM) == IAP_BOOTLOADER_APP_SWITCH_SIGNATURE) && (*((uint8_t *)(RAM_BOTTOM+4)) == IAP_BOOTLOADER_MODE_UART)){
|
||||
uint8_t cut = *(volatile uint8_t *) 0x08040798;
|
||||
uint16_t offset = 0;
|
||||
typedef void (*EntryPoint)(void);
|
||||
offset = (halFixedAddressTable.baseTable.version == 3) ? blOffset[cut - 2] : 0;
|
||||
*((int32u *)RAM_BOTTOM) = 0;
|
||||
*((uint32_t *)RAM_BOTTOM) = 0;
|
||||
if (offset) {
|
||||
halInternalSwitchToXtal();
|
||||
}
|
||||
EntryPoint entryPoint = (EntryPoint)(*(int32u *)(FIB_BOTTOM+4) - offset);
|
||||
setStackPointer(*(int32u *)FIB_BOTTOM);
|
||||
EntryPoint entryPoint = (EntryPoint)(*(uint32_t *)(FIB_BOTTOM+4) - offset);
|
||||
setStackPointer(*(uint32_t *)FIB_BOTTOM);
|
||||
entryPoint();
|
||||
}
|
||||
|
|
@ -38,12 +38,12 @@ extern void halInternalSwitchToXtal(void);
|
|||
|
||||
__interwork int __low_level_init(void);
|
||||
|
||||
static void setStackPointer(int32u address)
|
||||
static void setStackPointer(uint32_t address)
|
||||
{
|
||||
asm("MOVS SP, r0");
|
||||
}
|
||||
|
||||
static const int16u blOffset[] = {
|
||||
static const uint16_t blOffset[] = {
|
||||
0x0715 - 0x03ad - 0x68,
|
||||
0x0719 - 0x03ad - 0x6C
|
||||
};
|
||||
|
@ -79,7 +79,7 @@ __interwork int __low_level_init(void)
|
|||
////---- Always remap the vector table ----////
|
||||
// We might be coming from a bootloader at the base of flash, or even in the
|
||||
// NULL_BTL case, the BAT/AAT will be at the beginning of the image
|
||||
SCS_VTOR = (int32u)__vector_table;
|
||||
SCS_VTOR = (uint32_t)__vector_table;
|
||||
|
||||
////---- Always Configure Interrupt Priorities ----////
|
||||
//The STM32W support 5 bits of priority configuration.
|
||||
|
@ -169,17 +169,17 @@ __interwork int __low_level_init(void)
|
|||
}
|
||||
|
||||
//USART bootloader software activation check
|
||||
if ((*((int32u *)RAM_BOTTOM) == IAP_BOOTLOADER_APP_SWITCH_SIGNATURE) && (*((int8u *)(RAM_BOTTOM+4)) == IAP_BOOTLOADER_MODE_UART)){
|
||||
int8u cut = *(volatile int8u *) 0x08040798;
|
||||
int16u offset = 0;
|
||||
if ((*((uint32_t *)RAM_BOTTOM) == IAP_BOOTLOADER_APP_SWITCH_SIGNATURE) && (*((uint8_t *)(RAM_BOTTOM+4)) == IAP_BOOTLOADER_MODE_UART)){
|
||||
uint8_t cut = *(volatile uint8_t *) 0x08040798;
|
||||
uint16_t offset = 0;
|
||||
typedef void (*EntryPoint)(void);
|
||||
offset = (halFixedAddressTable.baseTable.version == 3) ? blOffset[cut - 2] : 0;
|
||||
*((int32u *)RAM_BOTTOM) = 0;
|
||||
*((uint32_t *)RAM_BOTTOM) = 0;
|
||||
if (offset) {
|
||||
halInternalSwitchToXtal();
|
||||
}
|
||||
EntryPoint entryPoint = (EntryPoint)(*(int32u *)(FIB_BOTTOM+4) - offset);
|
||||
setStackPointer(*(int32u *)FIB_BOTTOM);
|
||||
EntryPoint entryPoint = (EntryPoint)(*(uint32_t *)(FIB_BOTTOM+4) - offset);
|
||||
setStackPointer(*(uint32_t *)FIB_BOTTOM);
|
||||
entryPoint();
|
||||
}
|
||||
|
|
@ -46,12 +46,12 @@
|
|||
#define FPEC_KEY2 0xCDEF89AB //magic key defined in hardware
|
||||
|
||||
//Translation between page number and simee (word based) address
|
||||
#define SIMEE_ADDR_TO_PAGE(x) ((int8u)(((int16u)(x)) >> 9))
|
||||
#define PAGE_TO_SIMEE_ADDR(x) (((int16u)(x)) << 9)
|
||||
#define SIMEE_ADDR_TO_PAGE(x) ((uint8_t)(((uint16_t)(x)) >> 9))
|
||||
#define PAGE_TO_SIMEE_ADDR(x) (((uint16_t)(x)) << 9)
|
||||
|
||||
//Translation between page number and code addresses, used by bootloaders
|
||||
#define PROG_ADDR_TO_PAGE(x) ((int8u)((((int32u)(x))&MFB_ADDR_MASK) >> 10))
|
||||
#define PAGE_TO_PROG_ADDR(x) ((((int32u)(x)) << 10)|MFB_BOTTOM)
|
||||
#define PROG_ADDR_TO_PAGE(x) ((uint8_t)((((uint32_t)(x))&MFB_ADDR_MASK) >> 10))
|
||||
#define PAGE_TO_PROG_ADDR(x) ((((uint32_t)(x)) << 10)|MFB_BOTTOM)
|
||||
|
||||
|
||||
#endif //__STM32W108_MEMMAP_H__
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
||||
* File Name : stm32w108_type.h
|
||||
* File Name : stm32w108-type.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V1.0
|
||||
* Date : 10/08/2009
|
Loading…
Add table
Add a link
Reference in a new issue