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
#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

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

View File

@ -56,6 +56,10 @@ PROCESS_NAME(cc2430_rf_process);
* RF interrupt service routine.
*
*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
{
@ -75,6 +79,7 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
EA = 1;
}
#pragma restore
#endif
/*---------------------------------------------------------------------------*/
#if CC2430_RFERR_INTERRUPT
@ -82,6 +87,10 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
* RF error interrupt service routine.
* 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
cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
{
@ -98,5 +107,6 @@ cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
RF_TX_LED_OFF();
EA = 1;
}
#pragma restore
#endif
/*---------------------------------------------------------------------------*/

View File

@ -51,8 +51,8 @@ volatile uint8_t sleep_flag;
/*---------------------------------------------------------------------------*/
/* Used in sleep timer interrupt for calculating the next interrupt time */
static unsigned long timer_value;
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
@ -109,6 +109,10 @@ clock_init(void)
IEN0_STIE = 1; /* IEN0.STIE acknowledge Sleep Timer Interrupt */
}
/*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
clock_ISR(void) __interrupt(ST_VECTOR)
{
@ -161,4 +165,5 @@ clock_ISR(void) __interrupt(ST_VECTOR)
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
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
*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
dma_ISR(void) __interrupt (DMA_VECTOR)
{
@ -65,4 +69,5 @@ dma_ISR(void) __interrupt (DMA_VECTOR)
#endif
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
uart0_rx_ISR(void) __interrupt (URX0_VECTOR)
{
@ -51,6 +55,7 @@ void
uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR)
{
}
#pragma restore
#endif /* UART_ZERO_ENABLE */
#if UART_ONE_ENABLE
/*---------------------------------------------------------------------------*/
@ -61,6 +66,10 @@ uart1_set_input(int (*input)(unsigned char c))
}
/*---------------------------------------------------------------------------*/
#if UART_ONE_CONF_WITH_INPUT
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
uart1_rx_ISR(void) __interrupt (URX1_VECTOR)
{
@ -76,6 +85,7 @@ void
uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR)
{
}
#pragma restore
/*---------------------------------------------------------------------------*/
#endif /* UART_ONE_CONF_WITH_INPUT */
#endif /* UART_ONE_ENABLE */

View File

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

View File

@ -104,6 +104,10 @@ rtimer_arch_schedule(rtimer_clock_t t)
T1CCTL1 |= T1IM;
}
/*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
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);
IEN1_T1IE = 1; /* Acknowledge Timer 1 Interrupts */
}
#pragma restore

View File

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

View File

@ -42,7 +42,7 @@
#if BUTTON_SENSOR_ON
static uint8_t p0ien;
static uint8_t p2ien;
static __data struct timer debouncetimer[2];
static CC_AT_DATA struct timer debouncetimer[2];
#ifdef MODEL_N740
HWCONF_PIN(BUTTON_1, 1, 0)
@ -143,6 +143,10 @@ int configure_b2(int type, int value)
return 0;
}
/*---------------------------------------------------------------------------*/
#pragma save
#if CC_CONF_OPTIMIZE_STACK_SIZE
#pragma exclude bits
#endif
void
port_0_ISR(void) __interrupt (P0INT_VECTOR)
{
@ -194,6 +198,7 @@ port_1_ISR(void) __interrupt (P1INT_VECTOR)
EA = 1;
}
#endif /* MODEL_N740 */
#pragma restore
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);

View File

@ -65,12 +65,13 @@
#include "dev/n740.h"
#include "dev/uart1.h"
#include "8051def.h"
/*
* 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().
*/
static __data uint8_t ser_par_status;
static CC_AT_DATA uint8_t ser_par_status;
/*---------------------------------------------------------------------------*/
/* Init the serial-parallel chip: