Sensinode/cc2430 stack depth optimisation

This replicates the method used by the cc2530 port
This commit is contained in:
George Oikonomou 2012-09-07 14:48:15 +01:00
parent 067fabe0f9
commit 95b9d4ee29
11 changed files with 72 additions and 6 deletions

View file

@ -51,6 +51,26 @@
#define CC_NON_BANKED #define CC_NON_BANKED
#endif #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. */ /* Generic types. */
typedef unsigned short uip_stats_t; typedef unsigned short uip_stats_t;

View file

@ -105,7 +105,7 @@ uint8_t rf_error = 0;
PROCESS(cc2430_rf_process, "CC2430 RF driver"); PROCESS(cc2430_rf_process, "CC2430 RF driver");
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint8_t __data rf_flags; static uint8_t CC_AT_DATA rf_flags;
static uint8_t rf_channel; static uint8_t rf_channel;
static int on(void); /* prepare() needs our prototype */ static int on(void); /* prepare() needs our prototype */

View file

@ -56,6 +56,10 @@ PROCESS_NAME(cc2430_rf_process);
* RF interrupt service routine. * RF interrupt service routine.
* *
*/ */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
cc2430_rf_ISR( void ) __interrupt (RF_VECTOR) cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
{ {
@ -75,6 +79,7 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
EA = 1; EA = 1;
} }
#pragma restore
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if CC2430_RFERR_INTERRUPT #if CC2430_RFERR_INTERRUPT
@ -82,6 +87,10 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
* RF error interrupt service routine. * RF error interrupt service routine.
* Turned off by default, can be turned on in contiki-conf.h * Turned off by default, can be turned on in contiki-conf.h
*/ */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR) cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
{ {
@ -98,5 +107,6 @@ cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
RF_TX_LED_OFF(); RF_TX_LED_OFF();
EA = 1; EA = 1;
} }
#pragma restore
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -51,8 +51,8 @@ volatile uint8_t sleep_flag;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Used in sleep timer interrupt for calculating the next interrupt time */ /* Used in sleep timer interrupt for calculating the next interrupt time */
static unsigned long timer_value; static unsigned long timer_value;
static volatile __data clock_time_t count = 0; /* Uptime in ticks */ static volatile CC_AT_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 seconds = 0; /* Uptime in secs */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* Each iteration is ~1.0xy usec, so this function delays for roughly len usec * Each iteration is ~1.0xy usec, so this function delays for roughly len usec
@ -109,6 +109,10 @@ clock_init(void)
IEN0_STIE = 1; /* IEN0.STIE acknowledge Sleep Timer Interrupt */ IEN0_STIE = 1; /* IEN0.STIE acknowledge Sleep Timer Interrupt */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
clock_ISR(void) __interrupt(ST_VECTOR) clock_ISR(void) __interrupt(ST_VECTOR)
{ {
@ -161,4 +165,5 @@ clock_ISR(void) __interrupt(ST_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
ENABLE_INTERRUPTS(); ENABLE_INTERRUPTS();
} }
#pragma restore
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -32,6 +32,10 @@ extern void spi_rx_dma_callback(void);
* *
* if callback defined a poll is made to that process * if callback defined a poll is made to that process
*/ */
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
dma_ISR(void) __interrupt (DMA_VECTOR) dma_ISR(void) __interrupt (DMA_VECTOR)
{ {
@ -65,4 +69,5 @@ dma_ISR(void) __interrupt (DMA_VECTOR)
#endif #endif
EA = 1; EA = 1;
} }
#pragma restore
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -36,6 +36,10 @@ uart0_set_input(int (*input)(unsigned char c))
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
uart0_rx_ISR(void) __interrupt (URX0_VECTOR) uart0_rx_ISR(void) __interrupt (URX0_VECTOR)
{ {
@ -51,6 +55,7 @@ void
uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR) uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR)
{ {
} }
#pragma restore
#endif /* UART_ZERO_ENABLE */ #endif /* UART_ZERO_ENABLE */
#if UART_ONE_ENABLE #if UART_ONE_ENABLE
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -61,6 +66,10 @@ uart1_set_input(int (*input)(unsigned char c))
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if UART_ONE_CONF_WITH_INPUT #if UART_ONE_CONF_WITH_INPUT
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
uart1_rx_ISR(void) __interrupt (URX1_VECTOR) uart1_rx_ISR(void) __interrupt (URX1_VECTOR)
{ {
@ -76,6 +85,7 @@ void
uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR) uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR)
{ {
} }
#pragma restore
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#endif /* UART_ONE_CONF_WITH_INPUT */ #endif /* UART_ONE_CONF_WITH_INPUT */
#endif /* UART_ONE_ENABLE */ #endif /* UART_ONE_ENABLE */

View file

@ -47,6 +47,10 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* The watchdog only throws interrupts in timer mode */ /* The watchdog only throws interrupts in timer mode */
#if WDT_TIMER_MODE #if WDT_TIMER_MODE
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
cc4230_watchdog_ISR(void) __interrupt (WDT_VECTOR) cc4230_watchdog_ISR(void) __interrupt (WDT_VECTOR)
{ {
@ -57,6 +61,7 @@ cc4230_watchdog_ISR(void) __interrupt (WDT_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
EA = 1; EA = 1;
} }
#pragma restore
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void

View file

@ -104,6 +104,10 @@ rtimer_arch_schedule(rtimer_clock_t t)
T1CCTL1 |= T1IM; T1CCTL1 |= T1IM;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
cc2430_timer_1_ISR(void) __interrupt (T1_VECTOR) cc2430_timer_1_ISR(void) __interrupt (T1_VECTOR)
{ {
@ -120,3 +124,4 @@ cc2430_timer_1_ISR(void) __interrupt (T1_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
IEN1_T1IE = 1; /* Acknowledge Timer 1 Interrupts */ IEN1_T1IE = 1; /* Acknowledge Timer 1 Interrupts */
} }
#pragma restore

View file

@ -33,7 +33,7 @@ PROCESS_NAME(batmon_process);
#endif #endif
#if NETSTACK_CONF_SHORTCUTS #if NETSTACK_CONF_SHORTCUTS
static __data uint16_t len; static CC_AT_DATA uint16_t len;
#endif #endif
#ifdef STARTUP_CONF_VERBOSE #ifdef STARTUP_CONF_VERBOSE

View file

@ -42,7 +42,7 @@
#if BUTTON_SENSOR_ON #if BUTTON_SENSOR_ON
static uint8_t p0ien; static uint8_t p0ien;
static uint8_t p2ien; static uint8_t p2ien;
static __data struct timer debouncetimer[2]; static CC_AT_DATA struct timer debouncetimer[2];
#ifdef MODEL_N740 #ifdef MODEL_N740
HWCONF_PIN(BUTTON_1, 1, 0) HWCONF_PIN(BUTTON_1, 1, 0)
@ -143,6 +143,10 @@ int configure_b2(int type, int value)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void void
port_0_ISR(void) __interrupt (P0INT_VECTOR) port_0_ISR(void) __interrupt (P0INT_VECTOR)
{ {
@ -194,6 +198,7 @@ port_1_ISR(void) __interrupt (P1INT_VECTOR)
EA = 1; EA = 1;
} }
#endif /* MODEL_N740 */ #endif /* MODEL_N740 */
#pragma restore
SENSORS_SENSOR(button_1_sensor, BUTTON_1_SENSOR, value_b1, configure_b1, status_b1); SENSORS_SENSOR(button_1_sensor, BUTTON_1_SENSOR, value_b1, configure_b1, status_b1);
SENSORS_SENSOR(button_2_sensor, BUTTON_2_SENSOR, value_b2, configure_b2, status_b2); SENSORS_SENSOR(button_2_sensor, BUTTON_2_SENSOR, value_b2, configure_b2, status_b2);

View file

@ -65,12 +65,13 @@
#include "dev/n740.h" #include "dev/n740.h"
#include "dev/uart1.h" #include "dev/uart1.h"
#include "8051def.h"
/* /*
* This variable stores the most recent instruction sent to the ser-par chip. * This variable stores the most recent instruction sent to the ser-par chip.
* We declare it as static and return its value through n740_ser_par_get(). * We declare it as static and return its value through n740_ser_par_get().
*/ */
static __data uint8_t ser_par_status; static CC_AT_DATA uint8_t ser_par_status;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Init the serial-parallel chip: /* Init the serial-parallel chip: