11 #include "dev/models.h"
13 #include "dev/watchdog.h"
23 #include "contiki-lib.h"
24 #include "contiki-net.h"
26 unsigned short node_id = 0;
36 #if NETSTACK_CONF_SHORTCUTS
37 static CC_AT_DATA uint16_t len;
40 #ifdef STARTUP_CONF_VERBOSE
41 #define STARTUP_VERBOSE STARTUP_CONF_VERBOSE
43 #define STARTUP_VERBOSE 0
47 #define PUTSTRING(...) putstring(__VA_ARGS__)
48 #define PUTHEX(...) puthex(__VA_ARGS__)
49 #define PUTBIN(...) putbin(__VA_ARGS__)
50 #define PUTCHAR(...) putchar(__VA_ARGS__)
52 #define PUTSTRING(...) do {} while(0)
53 #define PUTHEX(...) do {} while(0)
54 #define PUTBIN(...) do {} while(0)
55 #define PUTCHAR(...) do {} while(0)
58 #if CLOCK_CONF_STACK_FRIENDLY
59 extern volatile uint8_t sleep_flag;
64 static unsigned long irq_energest = 0;
65 #define ENERGEST_IRQ_SAVE(a) do { \
66 a = energest_type_time(ENERGEST_TYPE_IRQ); } while(0)
67 #define ENERGEST_IRQ_RESTORE(a) do { \
68 energest_type_set(ENERGEST_TYPE_IRQ, a); } while(0)
70 #define ENERGEST_IRQ_SAVE(a) do {} while(0)
71 #define ENERGEST_IRQ_RESTORE(a) do {} while(0)
75 fade(
int l) CC_NON_BANKED
79 for(k = 0; k < 400; ++k) {
80 j = k > 200 ? 400 - k : k;
83 for(i = 0; i < j; ++i) {
87 for(i = 0; i < 200 - j; ++i) {
94 set_rime_addr(
void) CC_NON_BANKED
96 uint8_t *addr_long =
NULL;
97 uint16_t addr_short = 0;
99 __code
unsigned char *macp;
101 PUTSTRING(
"Rime is 0x");
102 PUTHEX(
sizeof(linkaddr_t));
103 PUTSTRING(
" bytes long\n");
106 PUTSTRING(
"Reading MAC from flash\n");
122 macp = (__code
unsigned char *)0xFFF8;
124 for(i = (LINKADDR_SIZE - 1); i >= 0; --i) {
134 PUTSTRING(
"Setting manual address from node_id\n");
141 PUTSTRING(
"Rime configured with address ");
142 for(i = 0; i < LINKADDR_SIZE - 1; i++) {
151 #if (LINKADDR_SIZE==8)
187 #if SLIP_ARCH_CONF_ENABLE
195 PUTSTRING(
"##########################################\n");
196 putstring(CONTIKI_VERSION_STRING
"\n");
197 putstring(SENSINODE_MODEL
" (CC24");
198 puthex(((CHIPID >> 3) | 0x20));
199 putstring(
"-" FLASH_SIZE
")\n");
202 #ifdef HAVE_SDCC_BANKING
203 PUTSTRING(
" With Banking.\n");
205 #ifdef SDCC_MODEL_LARGE
206 PUTSTRING(
" --model-large\n");
208 #ifdef SDCC_MODEL_HUGE
209 PUTSTRING(
" --model-huge\n");
211 #ifdef SDCC_STACK_AUTO
212 PUTSTRING(
" --stack-auto\n");
218 PUTSTRING(NETSTACK_NETWORK.name);
221 PUTSTRING(NETSTACK_MAC.name);
224 PUTSTRING(NETSTACK_RDC.name);
227 PUTSTRING(
"##########################################\n");
243 #if BUTTON_SENSOR_ON || ADC_SENSOR_ON
245 sensinode_sensors_activate();
261 #if (!UIP_CONF_IPV6_RPL)
265 uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
276 model_uart_intr_en();
279 ENERGEST_ON(ENERGEST_TYPE_CPU);
287 autostart_start(autostart_processes);
297 #if CLOCK_CONF_STACK_FRIENDLY
308 #if NETSTACK_CONF_SHORTCUTS
309 len = NETSTACK_RADIO.pending_packet();
315 NETSTACK_RDC.input();
321 #if (LPM_MODE==LPM_MODE_PM2)
323 while(!(
SLEEP & HFRC_STB));
325 while(!(CLKCON &
OSC));
335 #if (LPM_MODE==LPM_MODE_PM2)
346 if(
SLEEP & SLEEP_MODE0) {
349 ENERGEST_OFF(ENERGEST_TYPE_CPU);
350 ENERGEST_ON(ENERGEST_TYPE_LPM);
353 ENERGEST_IRQ_RESTORE(irq_energest);
364 ENERGEST_IRQ_SAVE(irq_energest);
366 ENERGEST_ON(ENERGEST_TYPE_CPU);
367 ENERGEST_OFF(ENERGEST_TYPE_LPM);
369 #if (LPM_MODE==LPM_MODE_PM2)
371 while(!(
SLEEP & XOSC_STB));
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
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.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
void rtimer_init(void)
Initialize the real-time scheduler.
#define PROCESS_NAME(name)
Declare the name of a process.
Header file for the Disco server (embedded part of the DISCOBALL project) ...
CC2430 RF driver header file
#define NULL
The null pointer.
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
A brief description of what this file is.
#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.
Hardware-dependent header file for the cc2430 watchdog timer.
void cc2430_rf_set_addr(unsigned pan, unsigned addr, const uint8_t *ieee_addr)
Set MAC addresses.
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.
void packetbuf_clear(void)
Clear and reset the packetbuf.
void process_start(struct process *p, process_data_t data)
Start a process.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
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.
Defines for the sensors on the various Sensinode models.
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().
Header file for debugging functions used by the sensinode port.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
void watchdog_init(void)
Copyright (c) 2014, Analog Devices, Inc.
Include file for the Contiki low-layer network stack (NETSTACK)