Merge pull request #2090 from jamike/fix#2089

Fix#2089
pull/2101/head
Martin Kojtal 2016-07-05 08:36:13 +01:00 committed by GitHub
commit fe3b80aa68
2 changed files with 10 additions and 4 deletions

View File

@ -44,8 +44,8 @@ typedef struct {
PinName pin; PinName pin;
uint32_t mask; uint32_t mask;
__IO uint32_t *reg_in; __IO uint32_t *reg_in;
__IO uint16_t *reg_set; __IO uint32_t *reg_set;
__IO uint16_t *reg_clr; __IO uint32_t *reg_clr;
} gpio_t; } gpio_t;
static inline void gpio_write(gpio_t *obj, int value) static inline void gpio_write(gpio_t *obj, int value)

View File

@ -534,14 +534,20 @@ extern uint32_t __end__[];
#define HEAP_START (__end__) #define HEAP_START (__end__)
#elif defined(__ICCARM__) #elif defined(__ICCARM__)
#pragma section="HEAP" #pragma section="HEAP"
#define HEAP_START (void *)__section_begin("HEAP") #define HEAP_END (void *)__section_end("HEAP")
#endif #endif
void set_main_stack(void) { void set_main_stack(void) {
uint32_t interrupt_stack_size = ((uint32_t)OS_MAINSTKSIZE * 4); uint32_t interrupt_stack_size = ((uint32_t)OS_MAINSTKSIZE * 4);
#if defined(__ICCARM__)
/* For IAR heap is defined .icf file */
uint32_t main_stack_size = ((uint32_t)INITIAL_SP - (uint32_t)HEAP_END) - interrupt_stack_size;
#else
/* For ARM , uARM, or GCC_ARM , heap can grow and reach main stack */
uint32_t heap_plus_stack_size = ((uint32_t)INITIAL_SP - (uint32_t)HEAP_START) - interrupt_stack_size; uint32_t heap_plus_stack_size = ((uint32_t)INITIAL_SP - (uint32_t)HEAP_START) - interrupt_stack_size;
// Main thread's stack is 1/4 of the heap // Main thread's stack is 1/4 of the heap
uint32_t main_stack_size = heap_plus_stack_size / 4; uint32_t main_stack_size = heap_plus_stack_size/4;
#endif
// The main thread must be 4 byte aligned // The main thread must be 4 byte aligned
uint32_t main_stack_start = ((uint32_t)INITIAL_SP - interrupt_stack_size - main_stack_size) & ~0x7; uint32_t main_stack_start = ((uint32_t)INITIAL_SP - interrupt_stack_size - main_stack_size) & ~0x7;