diff --git a/cpu/cc2430/8051def.h b/cpu/cc2430/8051def.h index ce6bc3357..fe82ce9de 100644 --- a/cpu/cc2430/8051def.h +++ b/cpu/cc2430/8051def.h @@ -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; diff --git a/cpu/cc2430/dev/cc2430_rf.c b/cpu/cc2430/dev/cc2430_rf.c index 5339c84cc..7d6d5ecbd 100644 --- a/cpu/cc2430/dev/cc2430_rf.c +++ b/cpu/cc2430/dev/cc2430_rf.c @@ -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 */ diff --git a/cpu/cc2430/dev/cc2430_rf_intr.c b/cpu/cc2430/dev/cc2430_rf_intr.c index 510c93f1a..b19a1156b 100644 --- a/cpu/cc2430/dev/cc2430_rf_intr.c +++ b/cpu/cc2430/dev/cc2430_rf_intr.c @@ -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 /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc2430/dev/clock.c b/cpu/cc2430/dev/clock.c index 8ca969056..e36a11297 100644 --- a/cpu/cc2430/dev/clock.c +++ b/cpu/cc2430/dev/clock.c @@ -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 /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc2430/dev/dma_intr.c b/cpu/cc2430/dev/dma_intr.c index a2f14369d..1e8dbe2aa 100644 --- a/cpu/cc2430/dev/dma_intr.c +++ b/cpu/cc2430/dev/dma_intr.c @@ -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 /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc2430/dev/uart_intr.c b/cpu/cc2430/dev/uart_intr.c index 27803f2a6..8e087791f 100644 --- a/cpu/cc2430/dev/uart_intr.c +++ b/cpu/cc2430/dev/uart_intr.c @@ -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 */ diff --git a/cpu/cc2430/dev/watchdog-cc2430.c b/cpu/cc2430/dev/watchdog-cc2430.c index 2d59d2923..47df7a1c8 100644 --- a/cpu/cc2430/dev/watchdog-cc2430.c +++ b/cpu/cc2430/dev/watchdog-cc2430.c @@ -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 diff --git a/cpu/cc2430/rtimer-arch.c b/cpu/cc2430/rtimer-arch.c index 517886037..d2ec784c9 100644 --- a/cpu/cc2430/rtimer-arch.c +++ b/cpu/cc2430/rtimer-arch.c @@ -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 diff --git a/platform/sensinode/contiki-sensinode-main.c b/platform/sensinode/contiki-sensinode-main.c index 387264e01..6899de9e8 100644 --- a/platform/sensinode/contiki-sensinode-main.c +++ b/platform/sensinode/contiki-sensinode-main.c @@ -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 diff --git a/platform/sensinode/dev/button-sensor.c b/platform/sensinode/dev/button-sensor.c index ac239fe09..a2bda01c2 100644 --- a/platform/sensinode/dev/button-sensor.c +++ b/platform/sensinode/dev/button-sensor.c @@ -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); diff --git a/platform/sensinode/dev/n740.c b/platform/sensinode/dev/n740.c index d47aa3f6a..de1e20fd1 100644 --- a/platform/sensinode/dev/n740.c +++ b/platform/sensinode/dev/n740.c @@ -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: