13 #include "dev/watchdog.h"
15 #include "dev/port2.h"
17 #include "dev/button-sensor.h"
18 #include "dev/adc-sensor.h"
26 #include "contiki-lib.h"
27 #include "contiki-net.h"
33 #if STARTUP_CONF_VERBOSE
34 #define PUTSTRING(...) putstring(__VA_ARGS__)
35 #define PUTHEX(...) puthex(__VA_ARGS__)
36 #define PUTBIN(...) putbin(__VA_ARGS__)
37 #define PUTCHAR(...) putchar(__VA_ARGS__)
39 #define PUTSTRING(...)
45 #if CLOCK_CONF_STACK_FRIENDLY
46 extern volatile uint8_t sleep_flag;
50 static CC_AT_DATA uint16_t len;
53 static unsigned long irq_energest = 0;
54 #define ENERGEST_IRQ_SAVE(a) do { \
55 a = energest_type_time(ENERGEST_TYPE_IRQ); } while(0)
56 #define ENERGEST_IRQ_RESTORE(a) do { \
57 energest_type_set(ENERGEST_TYPE_IRQ, a); } while(0)
59 #define ENERGEST_IRQ_SAVE(a) do {} while(0)
60 #define ENERGEST_IRQ_RESTORE(a) do {} while(0)
64 fade(
int l) CC_NON_BANKED
68 for(k = 0; k < 400; ++k) {
69 j = k > 200 ? 400 - k : k;
72 for(i = 0; i < j; ++i) {
76 for(i = 0; i < 200 - j; ++i) {
83 set_rf_params(
void) CC_NON_BANKED
89 #if CC2530_CONF_MAC_FROM_PRIMARY
90 __xdata
unsigned char *macp = &X_IEEE_ADDR;
92 __code
unsigned char *macp = (__code
unsigned char *)0xFFE8;
95 PUTSTRING(
"Rime is 0x");
96 PUTHEX(
sizeof(linkaddr_t));
97 PUTSTRING(
" bytes long\n");
99 #if CC2530_CONF_MAC_FROM_PRIMARY
100 PUTSTRING(
"Reading MAC from Info Page\n");
102 PUTSTRING(
"Reading MAC from flash\n");
117 FMAP = CC2530_LAST_FLASH_BANK;
124 for(i = 7; i >= 0; --i) {
129 #if !CC2530_CONF_MAC_FROM_PRIMARY
135 short_addr = ext_addr[7];
136 short_addr |= ext_addr[6] << 8;
142 #if STARTUP_CONF_VERBOSE
143 PUTSTRING(
"Rime configured with address ");
144 for(i = 0; i < LINKADDR_SIZE - 1; i++) {
153 NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
154 NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
155 NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2530_RF_CHANNEL);
156 NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
184 #if SLIP_ARCH_CONF_ENABLE
192 PUTSTRING(
"##########################################\n");
193 putstring(CONTIKI_VERSION_STRING
"\n");
194 putstring(MODEL_STRING);
210 putstring(
"-" CC2530_FLAVOR_STRING
", ");
211 puthex(CHIPINFO1 + 1);
212 putstring(
"KB SRAM\n");
214 PUTSTRING(
"\nSDCC Build:\n");
215 #if STARTUP_CONF_VERBOSE
216 #ifdef HAVE_SDCC_BANKING
217 PUTSTRING(
" With Banking.\n");
219 #ifdef SDCC_MODEL_LARGE
220 PUTSTRING(
" --model-large\n");
222 #ifdef SDCC_MODEL_HUGE
223 PUTSTRING(
" --model-huge\n");
225 #ifdef SDCC_STACK_AUTO
226 PUTSTRING(
" --stack-auto\n");
232 PUTSTRING(NETSTACK_NETWORK.name);
235 PUTSTRING(NETSTACK_MAC.name);
238 PUTSTRING(NETSTACK_RDC.name);
241 PUTSTRING(
"##########################################\n");
257 #if BUTTON_SENSOR_ON || ADC_SENSOR_ON
259 BUTTON_SENSOR_ACTIVATE();
260 ADC_SENSOR_ACTIVATE();
274 ENERGEST_ON(ENERGEST_TYPE_CPU);
276 autostart_start(autostart_processes);
288 #if CLOCK_CONF_STACK_FRIENDLY
299 len = NETSTACK_RADIO.pending_packet();
305 NETSTACK_RDC.input();
310 #if (LPM_MODE==LPM_MODE_PM2)
312 while(!(
SLEEP & HFRC_STB));
314 while(!(CLKCON &
OSC));
322 SLEEPCMD = (SLEEPCMD & 0xFC) | (LPM_MODE - 1);
324 #if (LPM_MODE==LPM_MODE_PM2)
335 if(SLEEPCMD & SLEEP_MODE0) {
338 ENERGEST_OFF(ENERGEST_TYPE_CPU);
339 ENERGEST_ON(ENERGEST_TYPE_LPM);
342 ENERGEST_IRQ_RESTORE(irq_energest);
353 ENERGEST_IRQ_SAVE(irq_energest);
355 ENERGEST_ON(ENERGEST_TYPE_CPU);
356 ENERGEST_OFF(ENERGEST_TYPE_LPM);
358 #if (LPM_MODE==LPM_MODE_PM2)
359 SLEEPCMD &= ~SLEEP_OSC_PD;
360 while(!(SLEEPCMD & SLEEP_XOSC_STB));
361 CLKCONCMD &= ~CLKCONCMD_OSC;
367 while(CLKCONCMD & CLKCONCMD_OSC);
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
802.15.4 frame creation and parsing functions
#define OSC
Peripheral OSC base pointer.
#define LEDS_RED
LED1 (Red) -> PC0.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
Header file for the radio API
void rtimer_init(void)
Initialize the real-time scheduler.
#define PROCESS_NAME(name)
Declare the name of a process.
Header file for debugging functions used by the sensinode port.
#define NULL
The null pointer.
Definitions for TI/Chipcon cc2530, cc2531 and cc2533 SFR registers.
void clock_init(void)
Initialize the clock library.
Declaration of the Sleep timer ISR, used by the clock module
int main(void)
This is main...
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
void process_init(void)
Initialize the process module.
Header file for the Rime stack
Header file with definitions of bit masks for some cc2530 SFRs
Header file for platform-specific led functionality
#define LEDS_YELLOW
LED2 (Yellow) -> PC1.
#define LEDS_GREEN
LED3 (Green) -> PC2.
CCIF clock_time_t clock_time(void)
Get the current clock time.
void random_init(unsigned short seed)
Seed the cc2430 random number generator.
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
Generic serial I/O process header filer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Header file for module for automatically starting and exiting a list of processes.
void ctimer_init(void)
Initialize the callback timer library.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
Platform-specific header file which switches between UART and USB input/output, depending on whether we are building for the cc2531 USB dongle or the SmartRF
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
#define SLEEP
Constant SLEEP for sub-register SR_TRX_STATUS.
int etimer_pending(void)
Check if there are any non-expired event timers.
Implementation of the cc2530 RF driver
void packetbuf_clear(void)
Clear and reset the packetbuf.
void process_start(struct process *p, process_data_t data)
Start a process.
int process_run(void)
Run the system once - call poll handlers and process one event.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
Header file with cc253x SoC-specific defines and prototypes
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
#define DISABLE_INTERRUPTS()
Disable interrupts, saving the previous state so it can be later restored with RESTORE_INTERRUPTS().
void watchdog_init(void)
Copyright (c) 2014, Analog Devices, Inc.
Include file for the Contiki low-layer network stack (NETSTACK)