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:
parent
a0d2988846
commit
c6ec22c4c8
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -44,6 +44,7 @@ extern volatile uint8_t sleep_flag;
|
|||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern rimeaddr_t rimeaddr_node_addr;
|
||||
static CC_AT_DATA uint16_t len;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if ENERGEST_CONF_ON
|
||||
static unsigned long irq_energest = 0;
|
||||
|
@ -260,7 +261,6 @@ main(void) CC_NON_BANKED
|
|||
|
||||
while(1) {
|
||||
uint8_t r;
|
||||
static uint16_t len;
|
||||
do {
|
||||
/* Reset watchdog and handle polls and events */
|
||||
watchdog_periodic();
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "dev/button-sensor.h"
|
||||
#include "dev/watchdog.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static __data struct timer debouncetimer;
|
||||
static CC_AT_DATA struct timer debouncetimer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Button 1 - SmartRF and cc2531 USB Dongle */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -133,6 +133,11 @@ int configure_b2(int type, int value)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* ISRs */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* avoid referencing bits, we don't call code which use them */
|
||||
#pragma save
|
||||
#if CC_CONF_OPTIMIZE_STACK_SIZE
|
||||
#pragma exclude bits
|
||||
#endif
|
||||
#if MODEL_CC2531
|
||||
void
|
||||
port_1_isr(void) __interrupt(P1INT_VECTOR)
|
||||
|
@ -187,6 +192,7 @@ port_0_isr(void) __interrupt(P0INT_VECTOR)
|
|||
EA = 1;
|
||||
}
|
||||
#endif
|
||||
#pragma restore
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_1_sensor, BUTTON_SENSOR, value_b1, configure_b1, status_b1);
|
||||
#if MODEL_CC2531
|
||||
|
|
Loading…
Reference in a new issue