36#include "dev/button-sensor.h"
42#include "dev/watchdog.h"
44#include "lib/random.h"
51#if NETSTACK_CONF_WITH_IPV6
55#include "node-id-z1.h"
59extern unsigned char node_mac[8];
61#if DCOSYNCH_CONF_ENABLED
62static struct timer mgt_timer;
64extern int msp430_dco_required;
66#define UIP_OVER_MESH_CHANNEL 8
67#if NETSTACK_CONF_WITH_IPV4
68static uint8_t is_gateway;
71#ifdef EXPERIMENT_SETUP
72#include "experiment-setup.h"
78#define LOG_MODULE "Z1"
79#define LOG_LEVEL LOG_LEVEL_MAIN
81#ifdef UART0_CONF_BAUD_RATE
82#define UART0_BAUD_RATE UART0_CONF_BAUD_RATE
84#define UART0_BAUD_RATE 115200
89force_float_inclusion()
92 extern int __floatsisf;
96 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
108force_inclusion(
int d1,
int d2)
110 snprintf(NULL, 0,
"%d", d1 % d2);
119 memset(&
addr, 0,
sizeof(linkaddr_t));
120#if NETSTACK_CONF_WITH_IPV6
121 memcpy(
addr.u8, node_mac,
sizeof(
addr.u8));
125 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
126 addr.u8[i] = node_mac[7 - i];
129 addr.u8[0] = node_id & 0xff;
130 addr.u8[1] = node_id >> 8;
163 node_id_z1_restore();
166 if(!(node_mac[0] | node_mac[1] | node_mac[2] | node_mac[3] |
167 node_mac[4] | node_mac[5] | node_mac[6] | node_mac[7])) {
171 LOG_INFO(
"Node id is not set, using Z1 product ID\n");
184 node_mac[6] = node_id >> 8;
185 node_mac[7] = node_id & 0xff;
190#warning "***** CHANGING DEFAULT MAC *****"
200 node_mac[6] = MACID >> 8;
201 node_mac[7] = MACID & 0xff;
204#ifdef IEEE_802154_MAC_ADDRESS
207 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
208 memcpy(node_mac, ieee,
sizeof(
uip_lladdr.addr));
209 node_mac[7] = node_id & 0xff;
225 SENSORS_ACTIVATE(adxl345);
239 memset(longaddr, 0,
sizeof(longaddr));
242 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
244 LOG_INFO(
"CC2420 CCA threshold %i\n", CC2420_CONF_CCA_THRESH);
246#if DCOSYNCH_CONF_ENABLED
262#if DCOSYNCH_CONF_ENABLED
268#if CC2420_CONF_SFD_TIMESTAMPS
269 cc2420_arch_sfd_init();
275 ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
278 if (msp430_dco_required) {
279 _BIS_SR(GIE | CPUOFF);
281 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
289 ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
Device drivers header file for adxl345 accelerometer in Zolertia Z1.
CC2420 driver header file.
Header for the Coffee file system.
Header file for the energy estimation mechanism.
802.15.4 frame creation and parsing functions
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
void watchdog_periodic(void)
Writes the WDT clear sequence.
void platform_init_stage_three()
Final stage of platform driver initialisation.
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
void platform_idle()
The platform's idle/sleep function.
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
void watchdog_stop(void)
Stops the WDT such that it won't timeout and cause MCU reset.
#define CLOCK_SECOND
A second, measured in system clock time.
#define LEDS_ALL
The OR mask representation of all device LEDs.
void leds_init(void)
Initialise the LED HAL.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
static void linkaddr_set_node_addr(linkaddr_t *addr)
Set the address of the current node.
void process_start(struct process *p, process_data_t data)
Start a process.
int process_nevents(void)
Number of events waiting to be processed.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
bool timer_expired(struct timer *t)
Check if a timer has expired.
void timer_reset(struct timer *t)
Reset the timer with the same interval.
uip_lladdr_t uip_lladdr
Host L2 address.
void xmem_init(void)
Initialize the external memory.
Header file for the LED HAL.
Header file for the logging system.
void uart0_init(unsigned long ubr)
Initalize the RS232 port.
Include file for the Contiki low-layer network stack (NETSTACK)
Generic serial I/O process header filer.
Header file for IPv6-related data structures.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Header file to the external flash memory (XMem) API.