cc2530: Added a method to maximise stack depth

This was oringinally contributed/reported/discussed/patched by
Philippe Retornaz (EPFL) but it's implemented
in a more configurable fashion here.
This commit is contained in:
George Oikonomou 2012-09-05 16:00:23 +01:00
parent a0d2988846
commit c6ec22c4c8
8 changed files with 61 additions and 5 deletions

View file

@ -56,6 +56,26 @@
#define CC_NON_BANKED
#endif
/*
* Max Stack Depth manipulation. It is possible to get up to 247 bytes
* allocated for the stack if:
* - You set this to 1 and
* - You have a patched toolchain and
* - You don't use __bit variables
* - You do not link libraries using BIT registers (e.g. printf_large)
* Enabling this will mean ISRs will NOT push bits (#pragma exclude bits) so
* make sure you know what you're doing
*
* More information on the wiki
*/
#define CC_CONF_OPTIMIZE_STACK_SIZE 0
#if CC_CONF_OPTIMIZE_STACK_SIZE
#define CC_AT_DATA
#else
#define CC_AT_DATA __data
#endif
/* Generic types. */
typedef unsigned short uip_stats_t;

View file

@ -107,7 +107,7 @@ static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
#define CC2530_RF_AUTOACK 1
#endif
/*---------------------------------------------------------------------------*/
static uint8_t __data rf_flags;
static uint8_t CC_AT_DATA rf_flags;
static int on(void); /* prepare() needs our prototype */
static int off(void); /* transmit() needs our prototype */

View file

@ -55,8 +55,8 @@ volatile uint8_t sleep_flag;
/* Do NOT remove the absolute address and do NOT remove the initialiser here */
__xdata __at(0x0000) static unsigned long timer_value = 0;
static volatile __data clock_time_t count = 0; /* Uptime in ticks */
static volatile __data clock_time_t seconds = 0; /* Uptime in secs */
static volatile CC_AT_DATA clock_time_t count = 0; /* Uptime in ticks */
static volatile CC_AT_DATA clock_time_t seconds = 0; /* Uptime in secs */
/*---------------------------------------------------------------------------*/
/**
* Each iteration is ~1.0xy usec, so this function delays for roughly len usec
@ -132,6 +132,11 @@ clock_init(void)
STIE = 1; /* IEN0.STIE interrupt enable */
}
/*---------------------------------------------------------------------------*/
/* avoid referencing bits, we don't call code which use them */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
clock_isr(void) __interrupt(ST_VECTOR)
{
@ -177,4 +182,5 @@ clock_isr(void) __interrupt(ST_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
ENABLE_INTERRUPTS();
}
#pragma restore
/*---------------------------------------------------------------------------*/

View file

@ -32,6 +32,11 @@ extern void spi_rx_dma_callback(void);
*
* if callback defined a poll is made to that process
*/
/* Avoid referencing bits, we don't call code which use them */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
dma_isr(void) __interrupt (DMA_VECTOR)
{
@ -65,4 +70,5 @@ dma_isr(void) __interrupt (DMA_VECTOR)
#endif
EA = 1;
}
#pragma restore
/*---------------------------------------------------------------------------*/

View file

@ -33,6 +33,11 @@ uart0_set_input(int (*input)(unsigned char c))
}
/*---------------------------------------------------------------------------*/
#if UART0_CONF_WITH_INPUT
/* avoid referencing bits since we're not using them */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
uart0_rx_isr(void) __interrupt (URX0_VECTOR)
{
@ -44,6 +49,7 @@ uart0_rx_isr(void) __interrupt (URX0_VECTOR)
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
#pragma restore
#endif
#endif /* UART0_ENABLE */
#if UART1_ENABLE
@ -55,6 +61,11 @@ uart1_set_input(int (*input)(unsigned char c))
}
/*---------------------------------------------------------------------------*/
#if UART_ONE_CONF_WITH_INPUT
/* avoid referencing bits since we're not using them */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
uart1_rx_isr(void) __interrupt (URX1_VECTOR)
{
@ -65,6 +76,7 @@ uart1_rx_isr(void) __interrupt (URX1_VECTOR)
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
#pragma restore
/*---------------------------------------------------------------------------*/
#endif /* UART_ONE_CONF_WITH_INPUT */
#endif /* UART1_ENABLE */

View file

@ -96,6 +96,11 @@ rtimer_arch_schedule(rtimer_clock_t t)
T1CCTL1 |= T1CCTL_IM;
}
/*---------------------------------------------------------------------------*/
/* avoid referencing bits, we don't call code which use them */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
rtimer_isr(void) __interrupt(T1_VECTOR)
{
@ -111,3 +116,4 @@ rtimer_isr(void) __interrupt(T1_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
T1IE = 1; /* Acknowledge Timer 1 Interrupts */
}
#pragma restore