Merge remote-tracking branch 'upstream/master' into stm32nucleo-spirit1

This commit is contained in:
Marco Grella 2015-11-25 12:36:01 +01:00
commit e47c69c170
144 changed files with 3942 additions and 2352 deletions

9
.gitignore vendored
View file

@ -24,7 +24,7 @@
*.c128 *.c128
*.c64 *.c64
*.cc2538dk *.cc2538dk
*.remote *.zoul
*.jn516x *.jn516x
*.srf06-cc26xx *.srf06-cc26xx
*.ev-aducrf101mkxz *.ev-aducrf101mkxz
@ -39,6 +39,7 @@ obj_*
symbols.* symbols.*
Makefile.target Makefile.target
doc/html doc/html
doc/latex
patches-* patches-*
tools/tunslip tools/tunslip
tools/tunslip6 tools/tunslip6
@ -87,8 +88,14 @@ contiki-cc2530dk.lib
*.d71 *.d71
*.d81 *.d81
# Cooja Build Artifacts
*.cooja
#regression tests artifacts #regression tests artifacts
*.testlog *.testlog
*.log.prog
regression-tests/[0-9][0-9]-*/report
regression-tests/[0-9][0-9]-*/org/
# rl78 build artifacts # rl78 build artifacts
*.eval-adf7xxxmb4z *.eval-adf7xxxmb4z

View file

@ -1,19 +1,19 @@
/* /*
* Copyright (c) 2003, Adam Dunkels. * Copyright (c) 2003, Adam Dunkels.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above * 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following * copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided * disclaimer in the documentation and/or other materials provided
* with the distribution. * with the distribution.
* 3. The name of the author may not be used to endorse or promote * 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior * products derived from this software without specific prior
* written permission. * written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -25,7 +25,7 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the Contiki desktop OS * This file is part of the Contiki desktop OS
* *
@ -35,7 +35,7 @@
/** /**
* \file * \file
* The program handler, used for loading programs and starting the * The program handler, used for loading programs and starting the
* screensaver. * screensaver.
* \author Adam Dunkels <adam@dunkels.com> * \author Adam Dunkels <adam@dunkels.com>
* *
* The Contiki program handler is responsible for the Contiki menu and * The Contiki program handler is responsible for the Contiki menu and
@ -45,7 +45,7 @@
* The program handler also is responsible for starting the * The program handler also is responsible for starting the
* screensaver when the CTK detects that it should be started. * screensaver when the CTK detects that it should be started.
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -161,7 +161,7 @@ char program_handler_screensaver[20];
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
program_handler_add(struct dsc *dsc, char *menuname, program_handler_add(struct dsc *dsc, char *menuname,
unsigned char desktop) unsigned char desktop)
{ {
contikidsc[contikidsclast++] = dsc; contikidsc[contikidsclast++] = dsc;
ctk_menuitem_add(&contikimenu, menuname); ctk_menuitem_add(&contikimenu, menuname);
@ -228,7 +228,7 @@ program_handler_load(char *name, char *arg)
{ {
#ifdef WITH_LOADER_ARCH #ifdef WITH_LOADER_ARCH
struct pnarg *pnarg; struct pnarg *pnarg;
pnarg = pnarg_copy(name, arg); pnarg = pnarg_copy(name, arg);
if(pnarg != NULL) { if(pnarg != NULL) {
process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, pnarg); process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, pnarg);
@ -272,17 +272,17 @@ static void
make_windows(void) make_windows(void)
{ {
ctk_window_new(&runwindow, 16, 3, "Run"); ctk_window_new(&runwindow, 16, 3, "Run");
CTK_WIDGET_ADD(&runwindow, &namelabel); CTK_WIDGET_ADD(&runwindow, &namelabel);
CTK_WIDGET_ADD(&runwindow, &nameentry); CTK_WIDGET_ADD(&runwindow, &nameentry);
CTK_WIDGET_ADD(&runwindow, &loadbutton); CTK_WIDGET_ADD(&runwindow, &loadbutton);
CTK_WIDGET_FOCUS(&runwindow, &nameentry); CTK_WIDGET_FOCUS(&runwindow, &nameentry);
ctk_dialog_new(&loadingdialog, 25, 1); ctk_dialog_new(&loadingdialog, 25, 1);
CTK_WIDGET_ADD(&loadingdialog, &loadingmsg); CTK_WIDGET_ADD(&loadingdialog, &loadingmsg);
CTK_WIDGET_ADD(&loadingdialog, &loadingname); CTK_WIDGET_ADD(&loadingdialog, &loadingname);
ctk_dialog_new(&errordialog, 22, 8); ctk_dialog_new(&errordialog, 22, 8);
CTK_WIDGET_ADD(&errordialog, &errormsg); CTK_WIDGET_ADD(&errordialog, &errormsg);
CTK_WIDGET_ADD(&errordialog, &errorfilelabel); CTK_WIDGET_ADD(&errordialog, &errorfilelabel);
@ -302,20 +302,20 @@ PROCESS_THREAD(program_handler_process, ev, data)
struct dsc **dscp; struct dsc **dscp;
PROCESS_BEGIN(); PROCESS_BEGIN();
/* Create the menus */ /* Create the menus */
ctk_menu_add(&contikimenu); ctk_menu_add(&contikimenu);
#if WITH_LOADER_ARCH #if WITH_LOADER_ARCH
runmenuitem = ctk_menuitem_add(&contikimenu, "Run program..."); runmenuitem = ctk_menuitem_add(&contikimenu, "Run program...");
make_windows(); make_windows();
#endif /* WITH_LOADER_ARCH */ #endif /* WITH_LOADER_ARCH */
#if QUIT_MENU #if QUIT_MENU
quitmenuitem = ctk_menuitem_add(&contikimenu, "Quit"); quitmenuitem = ctk_menuitem_add(&contikimenu, "Quit");
#endif /* QUIT_MENU */ #endif /* QUIT_MENU */
displayname = NULL; displayname = NULL;
#if CTK_CONF_SCREENSAVER #if CTK_CONF_SCREENSAVER
program_handler_screensaver[0] = 0; program_handler_screensaver[0] = 0;
#endif /* CTK_CONF_SCREENSAVER */ #endif /* CTK_CONF_SCREENSAVER */
@ -325,106 +325,106 @@ PROCESS_THREAD(program_handler_process, ev, data)
if(ev == ctk_signal_button_activate) { if(ev == ctk_signal_button_activate) {
#ifdef WITH_LOADER_ARCH #ifdef WITH_LOADER_ARCH
if(data == (process_data_t)&loadbutton) { if(data == (process_data_t)&loadbutton) {
ctk_window_close(&runwindow); ctk_window_close(&runwindow);
program_handler_load(name, NULL); program_handler_load(name, NULL);
} else if(data == (process_data_t)&errorokbutton) { } else if(data == (process_data_t)&errorokbutton) {
ctk_dialog_close(); ctk_dialog_close();
} }
#endif /* WITH_LOADER_ARCH */ #endif /* WITH_LOADER_ARCH */
#if QUIT_MENU #if QUIT_MENU
if(data == (process_data_t)&quityesbutton) { if(data == (process_data_t)&quityesbutton) {
ctk_draw_init(); ctk_draw_init();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if(data == (process_data_t)&quitnobutton) { } else if(data == (process_data_t)&quitnobutton) {
ctk_dialog_close(); ctk_dialog_close();
} }
#endif /* QUIT_MENU */ #endif /* QUIT_MENU */
dscp = &contikidsc[0]; dscp = &contikidsc[0];
for(i = 0; i < CTK_MAXMENUITEMS; ++i) { for(i = 0; i < CTK_MAXMENUITEMS; ++i) {
if(*dscp != NULL if(*dscp != NULL
#if CTK_CONF_ICONS #if CTK_CONF_ICONS
&& data == (process_data_t)(*dscp)->icon && data == (process_data_t)(*dscp)->icon
#endif /* CTK_CONF_ICONS */ #endif /* CTK_CONF_ICONS */
) { ) {
RUN((*dscp)->prgname, (*dscp)->process, NULL); RUN((*dscp)->prgname, (*dscp)->process, NULL);
break; break;
} }
++dscp; ++dscp;
} }
} else if(ev == ctk_signal_menu_activate) { } else if(ev == ctk_signal_menu_activate) {
if((struct ctk_menu *)data == &contikimenu) { if((struct ctk_menu *)data == &contikimenu) {
#if WITH_LOADER_ARCH #if WITH_LOADER_ARCH
dsc = contikidsc[contikimenu.active]; dsc = contikidsc[contikimenu.active];
if(dsc != NULL) { if(dsc != NULL) {
RUN(dsc->prgname, dsc->process, NULL); RUN(dsc->prgname, dsc->process, NULL);
} else if(contikimenu.active == runmenuitem) { } else if(contikimenu.active == runmenuitem) {
make_windows(); make_windows();
ctk_window_close(&runwindow); ctk_window_close(&runwindow);
ctk_window_open(&runwindow); ctk_window_open(&runwindow);
CTK_WIDGET_FOCUS(&runwindow, &nameentry); CTK_WIDGET_FOCUS(&runwindow, &nameentry);
} }
#else /* WITH_LOADER_ARCH */ #else /* WITH_LOADER_ARCH */
if(contikidsc[contikimenu.active] != NULL) { if(contikidsc[contikimenu.active] != NULL) {
RUN(contikidsc[contikimenu.active]->prgname, RUN(contikidsc[contikimenu.active]->prgname,
contikidsc[contikimenu.active]->process, contikidsc[contikimenu.active]->process,
NULL); NULL);
} }
#endif /* WITH_LOADER_ARCH */ #endif /* WITH_LOADER_ARCH */
#if QUIT_MENU #if QUIT_MENU
if(contikimenu.active == quitmenuitem) { if(contikimenu.active == quitmenuitem) {
ctk_dialog_new(&quitdialog, 24, 5); ctk_dialog_new(&quitdialog, 24, 5);
CTK_WIDGET_ADD(&quitdialog, &quitdialoglabel); CTK_WIDGET_ADD(&quitdialog, &quitdialoglabel);
CTK_WIDGET_ADD(&quitdialog, &quityesbutton); CTK_WIDGET_ADD(&quitdialog, &quityesbutton);
CTK_WIDGET_ADD(&quitdialog, &quitnobutton); CTK_WIDGET_ADD(&quitdialog, &quitnobutton);
CTK_WIDGET_FOCUS(&quitdialog, &quitnobutton); CTK_WIDGET_FOCUS(&quitdialog, &quitnobutton);
ctk_dialog_open(&quitdialog); ctk_dialog_open(&quitdialog);
} }
#endif /* QUIT_MENU */ #endif /* QUIT_MENU */
} }
#if CTK_CONF_SCREENSAVER #if CTK_CONF_SCREENSAVER
} else if(ev == ctk_signal_screensaver_start) { } else if(ev == ctk_signal_screensaver_start) {
#if WITH_LOADER_ARCH #if WITH_LOADER_ARCH
if(program_handler_screensaver[0] != 0) { if(program_handler_screensaver[0] != 0) {
program_handler_load(program_handler_screensaver, NULL); program_handler_load(program_handler_screensaver, NULL);
} }
#endif /* WITH_LOADER_ARCH */ #endif /* WITH_LOADER_ARCH */
#endif /* CTK_CONF_SCREENSAVER */ #endif /* CTK_CONF_SCREENSAVER */
} else if(ev == LOADER_EVENT_DISPLAY_NAME) { } else if(ev == LOADER_EVENT_DISPLAY_NAME) {
#if WITH_LOADER_ARCH #if WITH_LOADER_ARCH
if(displayname == NULL) { if(displayname == NULL) {
make_windows(); make_windows();
ctk_label_set_text(&loadingname, ((struct pnarg *)data)->name); ctk_label_set_text(&loadingname, ((struct pnarg *)data)->name);
ctk_dialog_open(&loadingdialog); ctk_dialog_open(&loadingdialog);
process_post(&program_handler_process, LOADER_EVENT_LOAD, data); process_post(&program_handler_process, LOADER_EVENT_LOAD, data);
displayname = data; displayname = data;
} else { } else {
/* Try again. */ /* Try again. */
process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, data); process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, data);
} }
#endif /* WITH_LOADER_ARCH */ #endif /* WITH_LOADER_ARCH */
} else if(ev == LOADER_EVENT_LOAD) { } else if(ev == LOADER_EVENT_LOAD) {
#if WITH_LOADER_ARCH #if WITH_LOADER_ARCH
if(displayname == data) { if(displayname == data) {
ctk_dialog_close(); ctk_dialog_close();
displayname = NULL; displayname = NULL;
log_message("Loading ", ((struct pnarg *)data)->name); log_message("Loading ", ((struct pnarg *)data)->name);
err = LOADER_LOAD(((struct pnarg *)data)->name, err = LOADER_LOAD(((struct pnarg *)data)->name,
((struct pnarg *)data)->arg); ((struct pnarg *)data)->arg);
if(err != LOADER_OK) { if(err != LOADER_OK) {
make_windows(); make_windows();
errorfilename[0] = '"'; errorfilename[0] = '"';
strncpy(errorfilename + 1, ((struct pnarg *)data)->name, strncpy(errorfilename + 1, ((struct pnarg *)data)->name,
sizeof(errorfilename) - 2); sizeof(errorfilename) - 2);
errorfilename[1 + strlen(((struct pnarg *)data)->name)] = '"'; errorfilename[1 + strlen(((struct pnarg *)data)->name)] = '"';
ctk_label_set_text(&errortype, (char *)errormsgs[err]); ctk_label_set_text(&errortype, (char *)errormsgs[err]);
ctk_dialog_open(&errordialog); ctk_dialog_open(&errordialog);
log_message((char *)errormsgs[err], errorfilename); log_message((char *)errormsgs[err], errorfilename);
} }
pnarg_free(data); pnarg_free(data);
} else { } else {
/* Try again. */ /* Try again. */
process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, data); process_post(&program_handler_process, LOADER_EVENT_DISPLAY_NAME, data);
} }
#endif /* WITH_LOADEER_ARCH */ #endif /* WITH_LOADEER_ARCH */
} }

View file

@ -64,17 +64,11 @@
#define UIP_TCPH_LEN 20 /* Size of TCP header */ #define UIP_TCPH_LEN 20 /* Size of TCP header */
#define UIP_ICMPH_LEN 4 /* Size of ICMP header */ #define UIP_ICMPH_LEN 4 /* Size of ICMP header */
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + #define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */
* UDP #define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */
* header */
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP +
* TCP
* header */
#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN #define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
#define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN) /* size of ICMP #define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN) /* Size of ICMP + IP header */
+ IP header */ #define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* Size of L2 + IP header */
#define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* size of L2
+ IP header */
#if NETSTACK_CONF_WITH_IPV6 #if NETSTACK_CONF_WITH_IPV6
/** /**
* The sums below are quite used in ND. When used for uip_buf, we * The sums below are quite used in ND. When used for uip_buf, we
@ -99,12 +93,12 @@
* *
*/ */
typedef union uip_ip4addr_t { typedef union uip_ip4addr_t {
uint8_t u8[4]; /* Initializer, must come first. */ uint8_t u8[4]; /* Initializer, must come first. */
uint16_t u16[2]; uint16_t u16[2];
} uip_ip4addr_t; } uip_ip4addr_t;
typedef union uip_ip6addr_t { typedef union uip_ip6addr_t {
uint8_t u8[16]; /* Initializer, must come first. */ uint8_t u8[16]; /* Initializer, must come first. */
uint16_t u16[8]; uint16_t u16[8];
} uip_ip6addr_t; } uip_ip6addr_t;
@ -1057,7 +1051,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport);
* \hideinitializer * \hideinitializer
*/ */
#define uip_ip4addr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \ #define uip_ip4addr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \
(addr1)->u16[1] == (addr2)->u16[1]) (addr1)->u16[1] == (addr2)->u16[1])
#define uip_ip6addr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) #define uip_ip6addr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
#if NETSTACK_CONF_WITH_IPV6 #if NETSTACK_CONF_WITH_IPV6
@ -1358,26 +1352,21 @@ struct uip_conn {
uint16_t lport; /**< The local TCP port, in network byte order. */ uint16_t lport; /**< The local TCP port, in network byte order. */
uint16_t rport; /**< The local remote TCP port, in network byte uint16_t rport; /**< The local remote TCP port, in network byte
order. */ order. */
uint8_t rcv_nxt[4]; /**< The sequence number that we expect to uint8_t rcv_nxt[4]; /**< The sequence number that we expect to
receive next. */ receive next. */
uint8_t snd_nxt[4]; /**< The sequence number that was last sent by uint8_t snd_nxt[4]; /**< The sequence number that was last sent by us. */
us. */
uint16_t len; /**< Length of the data that was previously sent. */ uint16_t len; /**< Length of the data that was previously sent. */
uint16_t mss; /**< Current maximum segment size for the uint16_t mss; /**< Current maximum segment size for the connection. */
connection. */ uint16_t initialmss; /**< Initial maximum segment size for the connection. */
uint16_t initialmss; /**< Initial maximum segment size for the uint8_t sa; /**< Retransmission time-out calculation state variable. */
connection. */ uint8_t sv; /**< Retransmission time-out calculation state variable. */
uint8_t sa; /**< Retransmission time-out calculation state
variable. */
uint8_t sv; /**< Retransmission time-out calculation state
variable. */
uint8_t rto; /**< Retransmission time-out. */ uint8_t rto; /**< Retransmission time-out. */
uint8_t tcpstateflags; /**< TCP state and flags. */ uint8_t tcpstateflags; /**< TCP state and flags. */
uint8_t timer; /**< The retransmission timer. */ uint8_t timer; /**< The retransmission timer. */
uint8_t nrtx; /**< The number of retransmissions for the last uint8_t nrtx; /**< The number of retransmissions for the last
segment sent. */ segment sent. */
/** The application state. */ /** The application state. */
uip_tcp_appstate_t appstate; uip_tcp_appstate_t appstate;
@ -1431,9 +1420,9 @@ struct uip_fallback_interface {
void (*init)(void); void (*init)(void);
/** /**
* \retval >=0 * \retval >=0
* in case of success * in case of success
* \retval <0 * \retval <0
* in case of failure * in case of failure
*/ */
int (*output)(void); int (*output)(void);
}; };
@ -1464,51 +1453,43 @@ extern struct uip_stats uip_stat;
*/ */
struct uip_stats { struct uip_stats {
struct { struct {
uip_stats_t recv; /**< Number of received packets at the IP uip_stats_t recv; /**< Number of received packets at the IP layer. */
layer. */ uip_stats_t sent; /**< Number of sent packets at the IP layer. */
uip_stats_t sent; /**< Number of sent packets at the IP uip_stats_t forwarded;/**< Number of forwarded packets at the IP layer. */
layer. */ uip_stats_t drop; /**< Number of dropped packets at the IP layer. */
uip_stats_t forwarded;/**< Number of forwarded packets at the IP
layer. */
uip_stats_t drop; /**< Number of dropped packets at the IP
layer. */
uip_stats_t vhlerr; /**< Number of packets dropped due to wrong uip_stats_t vhlerr; /**< Number of packets dropped due to wrong
IP version or header length. */ IP version or header length. */
uip_stats_t hblenerr; /**< Number of packets dropped due to wrong uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
IP length, high byte. */ IP length, high byte. */
uip_stats_t lblenerr; /**< Number of packets dropped due to wrong uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
IP length, low byte. */ IP length, low byte. */
uip_stats_t fragerr; /**< Number of packets dropped because they uip_stats_t fragerr; /**< Number of packets dropped because they
were IP fragments. */ were IP fragments. */
uip_stats_t chkerr; /**< Number of packets dropped due to IP uip_stats_t chkerr; /**< Number of packets dropped due to IP
checksum errors. */ checksum errors. */
uip_stats_t protoerr; /**< Number of packets dropped because they uip_stats_t protoerr; /**< Number of packets dropped because they
were neither ICMP, UDP nor TCP. */ were neither ICMP, UDP nor TCP. */
} ip; /**< IP statistics. */ } ip; /**< IP statistics. */
struct { struct {
uip_stats_t recv; /**< Number of received ICMP packets. */ uip_stats_t recv; /**< Number of received ICMP packets. */
uip_stats_t sent; /**< Number of sent ICMP packets. */ uip_stats_t sent; /**< Number of sent ICMP packets. */
uip_stats_t drop; /**< Number of dropped ICMP packets. */ uip_stats_t drop; /**< Number of dropped ICMP packets. */
uip_stats_t typeerr; /**< Number of ICMP packets with a wrong uip_stats_t typeerr; /**< Number of ICMP packets with a wrong type. */
type. */ uip_stats_t chkerr; /**< Number of ICMP packets with a bad checksum. */
uip_stats_t chkerr; /**< Number of ICMP packets with a bad
checksum. */
} icmp; /**< ICMP statistics. */ } icmp; /**< ICMP statistics. */
#if UIP_TCP #if UIP_TCP
struct { struct {
uip_stats_t recv; /**< Number of recived TCP segments. */ uip_stats_t recv; /**< Number of recived TCP segments. */
uip_stats_t sent; /**< Number of sent TCP segments. */ uip_stats_t sent; /**< Number of sent TCP segments. */
uip_stats_t drop; /**< Number of dropped TCP segments. */ uip_stats_t drop; /**< Number of dropped TCP segments. */
uip_stats_t chkerr; /**< Number of TCP segments with a bad uip_stats_t chkerr; /**< Number of TCP segments with a bad checksum. */
checksum. */ uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK number. */
uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK
number. */
uip_stats_t rst; /**< Number of received TCP RST (reset) segments. */ uip_stats_t rst; /**< Number of received TCP RST (reset) segments. */
uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */ uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */
uip_stats_t syndrop; /**< Number of dropped SYNs because too few uip_stats_t syndrop; /**< Number of dropped SYNs because too few
connections were available. */ connections were available. */
uip_stats_t synrst; /**< Number of SYNs for closed ports, uip_stats_t synrst; /**< Number of SYNs for closed ports,
triggering a RST. */ triggering a RST. */
} tcp; /**< TCP statistics. */ } tcp; /**< TCP statistics. */
#endif #endif
#if UIP_UDP #if UIP_UDP
@ -1517,7 +1498,7 @@ struct uip_stats {
uip_stats_t recv; /**< Number of recived UDP segments. */ uip_stats_t recv; /**< Number of recived UDP segments. */
uip_stats_t sent; /**< Number of sent UDP segments. */ uip_stats_t sent; /**< Number of sent UDP segments. */
uip_stats_t chkerr; /**< Number of UDP segments with a bad uip_stats_t chkerr; /**< Number of UDP segments with a bad
checksum. */ checksum. */
} udp; /**< UDP statistics. */ } udp; /**< UDP statistics. */
#endif /* UIP_UDP */ #endif /* UIP_UDP */
#if NETSTACK_CONF_WITH_IPV6 #if NETSTACK_CONF_WITH_IPV6
@ -1554,33 +1535,33 @@ CCIF extern uint8_t uip_flags;
functions/macros. */ functions/macros. */
#define UIP_ACKDATA 1 /* Signifies that the outstanding data was #define UIP_ACKDATA 1 /* Signifies that the outstanding data was
acked and the application should send acked and the application should send
out new data instead of retransmitting out new data instead of retransmitting
the last data. */ the last data. */
#define UIP_NEWDATA 2 /* Flags the fact that the peer has sent #define UIP_NEWDATA 2 /* Flags the fact that the peer has sent
us new data. */ us new data. */
#define UIP_REXMIT 4 /* Tells the application to retransmit the #define UIP_REXMIT 4 /* Tells the application to retransmit the
data that was last sent. */ data that was last sent. */
#define UIP_POLL 8 /* Used for polling the application, to #define UIP_POLL 8 /* Used for polling the application, to
check if the application has data that check if the application has data that
it wants to send. */ it wants to send. */
#define UIP_CLOSE 16 /* The remote host has closed the #define UIP_CLOSE 16 /* The remote host has closed the
connection, thus the connection has connection, thus the connection has
gone away. Or the application signals gone away. Or the application signals
that it wants to close the that it wants to close the
connection. */ connection. */
#define UIP_ABORT 32 /* The remote host has aborted the #define UIP_ABORT 32 /* The remote host has aborted the
connection, thus the connection has connection, thus the connection has
gone away. Or the application signals gone away. Or the application signals
that it wants to abort the that it wants to abort the
connection. */ connection. */
#define UIP_CONNECTED 64 /* We have got a connection from a remote #define UIP_CONNECTED 64 /* We have got a connection from a remote
host and have set up a new connection host and have set up a new connection
for it, or an active connection has for it, or an active connection has
been successfully established. */ been successfully established. */
#define UIP_TIMEDOUT 128 /* The connection has been aborted due to #define UIP_TIMEDOUT 128 /* The connection has been aborted due to
too many retransmissions. */ too many retransmissions. */
/** /**
@ -1606,16 +1587,16 @@ void uip_process(uint8_t flag);
the macros defined in this file. */ the macros defined in this file. */
#define UIP_DATA 1 /* Tells uIP that there is incoming #define UIP_DATA 1 /* Tells uIP that there is incoming
data in the uip_buf buffer. The data in the uip_buf buffer. The
length of the data is stored in the length of the data is stored in the
global variable uip_len. */ global variable uip_len. */
#define UIP_TIMER 2 /* Tells uIP that the periodic timer #define UIP_TIMER 2 /* Tells uIP that the periodic timer
has fired. */ has fired. */
#define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should #define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should
be polled. */ be polled. */
#define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram #define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram
should be constructed in the should be constructed in the
uip_buf buffer. */ uip_buf buffer. */
#if UIP_UDP #if UIP_UDP
#define UIP_UDP_TIMER 5 #define UIP_UDP_TIMER 5
#endif /* UIP_UDP */ #endif /* UIP_UDP */

View file

@ -52,9 +52,9 @@
* FOR HC-06 COMPLIANCE TODO: * FOR HC-06 COMPLIANCE TODO:
* -Add compression options to UDP, currently only supports * -Add compression options to UDP, currently only supports
* both ports compressed or both ports elided * both ports compressed or both ports elided
* *
* -Verify TC/FL compression works * -Verify TC/FL compression works
* *
* -Add stateless multicast option * -Add stateless multicast option
*/ */
@ -317,7 +317,7 @@ set_packet_attrs()
/** Addresses contexts for IPHC. */ /** Addresses contexts for IPHC. */
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 #if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
static struct sicslowpan_addr_context static struct sicslowpan_addr_context
addr_contexts[SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS]; addr_contexts[SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS];
#endif #endif
@ -381,7 +381,7 @@ addr_context_lookup_by_prefix(uip_ipaddr_t *ipaddr)
static struct sicslowpan_addr_context* static struct sicslowpan_addr_context*
addr_context_lookup_by_number(uint8_t number) addr_context_lookup_by_number(uint8_t number)
{ {
/* Remove code to avoid warnings and save flash if no context is used */ /* Remove code to avoid warnings and save flash if no context is used */
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 #if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
int i; int i;
for(i = 0; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) { for(i = 0; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) {
@ -540,11 +540,11 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
* We have to process both in the same time as the offset of traffic class * We have to process both in the same time as the offset of traffic class
* depends on the presence of version and flow label * depends on the presence of version and flow label
*/ */
/* hc06 format of tc is ECN | DSCP , original is DSCP | ECN */ /* hc06 format of tc is ECN | DSCP , original is DSCP | ECN */
tmp = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4); tmp = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
tmp = ((tmp & 0x03) << 6) | (tmp >> 2); tmp = ((tmp & 0x03) << 6) | (tmp >> 2);
if(((UIP_IP_BUF->tcflow & 0x0F) == 0) && if(((UIP_IP_BUF->tcflow & 0x0F) == 0) &&
(UIP_IP_BUF->flow == 0)) { (UIP_IP_BUF->flow == 0)) {
/* flow label can be compressed */ /* flow label can be compressed */
@ -585,7 +585,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
iphc0 |= SICSLOWPAN_IPHC_NH_C; iphc0 |= SICSLOWPAN_IPHC_NH_C;
} }
#endif /*UIP_CONF_UDP*/ #endif /*UIP_CONF_UDP*/
#ifdef SICSLOWPAN_NH_COMPRESSOR #ifdef SICSLOWPAN_NH_COMPRESSOR
if(SICSLOWPAN_NH_COMPRESSOR.is_compressable(UIP_IP_BUF->proto)) { if(SICSLOWPAN_NH_COMPRESSOR.is_compressable(UIP_IP_BUF->proto)) {
iphc0 |= SICSLOWPAN_IPHC_NH_C; iphc0 |= SICSLOWPAN_IPHC_NH_C;
} }
@ -627,7 +627,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
!= NULL) { != NULL) {
/* elide the prefix - indicate by CID and set context + SAC */ /* elide the prefix - indicate by CID and set context + SAC */
PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n", PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n",
context->number); context->number);
iphc1 |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC; iphc1 |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC;
PACKETBUF_IPHC_BUF[2] |= context->number << 4; PACKETBUF_IPHC_BUF[2] |= context->number << 4;
/* compession compare with this nodes address (source) */ /* compession compare with this nodes address (source) */
@ -636,9 +636,9 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr) && } else if(uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr) &&
UIP_IP_BUF->destipaddr.u16[1] == 0 && UIP_IP_BUF->destipaddr.u16[1] == 0 &&
UIP_IP_BUF->destipaddr.u16[2] == 0 && UIP_IP_BUF->destipaddr.u16[2] == 0 &&
UIP_IP_BUF->destipaddr.u16[3] == 0) { UIP_IP_BUF->destipaddr.u16[3] == 0) {
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
} else { } else {
@ -684,12 +684,13 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
/* compession compare with link adress (destination) */ /* compession compare with link adress (destination) */
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)link_destaddr); &UIP_IP_BUF->destipaddr,
(uip_lladdr_t *)link_destaddr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_linklocal(&UIP_IP_BUF->destipaddr) && } else if(uip_is_addr_linklocal(&UIP_IP_BUF->destipaddr) &&
UIP_IP_BUF->destipaddr.u16[1] == 0 && UIP_IP_BUF->destipaddr.u16[1] == 0 &&
UIP_IP_BUF->destipaddr.u16[2] == 0 && UIP_IP_BUF->destipaddr.u16[2] == 0 &&
UIP_IP_BUF->destipaddr.u16[3] == 0) { UIP_IP_BUF->destipaddr.u16[3] == 0) {
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)link_destaddr); &UIP_IP_BUF->destipaddr, (uip_lladdr_t *)link_destaddr);
} else { } else {
@ -706,7 +707,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
/* UDP header compression */ /* UDP header compression */
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) { if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n", PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n",
UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport)); UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport));
/* Mask out the last 4 bits can be used as a mask */ /* Mask out the last 4 bits can be used as a mask */
if(((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) && if(((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) &&
((UIP_HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) { ((UIP_HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) {
@ -714,10 +715,10 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_11; *hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_11;
PRINTF("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n"); PRINTF("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n");
*(hc06_ptr + 1) = *(hc06_ptr + 1) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) - (uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) + SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) - (uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
SICSLOWPAN_UDP_4_BIT_PORT_MIN)); SICSLOWPAN_UDP_4_BIT_PORT_MIN));
hc06_ptr += 2; hc06_ptr += 2;
} else if((UIP_HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { } else if((UIP_HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
/* we can compress 8 bits of dest, leave source. */ /* we can compress 8 bits of dest, leave source. */
@ -725,16 +726,16 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
PRINTF("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n"); PRINTF("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n");
memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 2); memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 2);
*(hc06_ptr + 3) = *(hc06_ptr + 3) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) - (uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
SICSLOWPAN_UDP_8_BIT_PORT_MIN)); SICSLOWPAN_UDP_8_BIT_PORT_MIN));
hc06_ptr += 4; hc06_ptr += 4;
} else if((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { } else if((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
/* we can compress 8 bits of src, leave dest. Copy compressed port */ /* we can compress 8 bits of src, leave dest. Copy compressed port */
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_10; *hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_10;
PRINTF("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr); PRINTF("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr);
*(hc06_ptr + 1) = *(hc06_ptr + 1) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) - (uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
SICSLOWPAN_UDP_8_BIT_PORT_MIN)); SICSLOWPAN_UDP_8_BIT_PORT_MIN));
memcpy(hc06_ptr + 2, &UIP_UDP_BUF->destport, 2); memcpy(hc06_ptr + 2, &UIP_UDP_BUF->destport, 2);
hc06_ptr += 4; hc06_ptr += 4;
} else { } else {
@ -811,13 +812,13 @@ uncompress_hdr_hc06(uint16_t ip_len)
SICSLOWPAN_IP_BUF->vtc = 0x60 | ((tmp >> 2) & 0x0f); SICSLOWPAN_IP_BUF->vtc = 0x60 | ((tmp >> 2) & 0x0f);
/* ECN rolled down two steps + lowest DSCP bits at top two bits */ /* ECN rolled down two steps + lowest DSCP bits at top two bits */
SICSLOWPAN_IP_BUF->tcflow = ((tmp >> 2) & 0x30) | (tmp << 6) | SICSLOWPAN_IP_BUF->tcflow = ((tmp >> 2) & 0x30) | (tmp << 6) |
(SICSLOWPAN_IP_BUF->tcflow & 0x0f); (SICSLOWPAN_IP_BUF->tcflow & 0x0f);
} else { } else {
/* Traffic class is compressed (set version and no TC)*/ /* Traffic class is compressed (set version and no TC)*/
SICSLOWPAN_IP_BUF->vtc = 0x60; SICSLOWPAN_IP_BUF->vtc = 0x60;
/* highest flow label bits + ECN bits */ /* highest flow label bits + ECN bits */
SICSLOWPAN_IP_BUF->tcflow = (*hc06_ptr & 0x0F) | SICSLOWPAN_IP_BUF->tcflow = (*hc06_ptr & 0x0F) |
((*hc06_ptr >> 2) & 0x30); ((*hc06_ptr >> 2) & 0x30);
memcpy(&SICSLOWPAN_IP_BUF->flow, hc06_ptr + 1, 2); memcpy(&SICSLOWPAN_IP_BUF->flow, hc06_ptr + 1, 2);
hc06_ptr += 3; hc06_ptr += 3;
} }
@ -908,14 +909,13 @@ uncompress_hdr_hc06(uint16_t ip_len)
/* no multicast */ /* no multicast */
/* Context based */ /* Context based */
if(iphc1 & SICSLOWPAN_IPHC_DAC) { if(iphc1 & SICSLOWPAN_IPHC_DAC) {
uint8_t dci = (iphc1 & SICSLOWPAN_IPHC_CID) ? uint8_t dci = (iphc1 & SICSLOWPAN_IPHC_CID) ? PACKETBUF_IPHC_BUF[2] & 0x0f : 0;
PACKETBUF_IPHC_BUF[2] & 0x0f : 0;
context = addr_context_lookup_by_number(dci); context = addr_context_lookup_by_number(dci);
/* all valid cases below need the context! */ /* all valid cases below need the context! */
if(context == NULL) { if(context == NULL) {
PRINTF("sicslowpan uncompress_hdr: error context not found\n"); PRINTF("sicslowpan uncompress_hdr: error context not found\n");
return; return;
} }
uncompress_addr(&SICSLOWPAN_IP_BUF->destipaddr, context->prefix, uncompress_addr(&SICSLOWPAN_IP_BUF->destipaddr, context->prefix,
unc_ctxconf[tmp], unc_ctxconf[tmp],
@ -939,56 +939,56 @@ uncompress_hdr_hc06(uint16_t ip_len)
PRINTF("IPHC: Incoming header value: %i\n", *hc06_ptr); PRINTF("IPHC: Incoming header value: %i\n", *hc06_ptr);
switch(*hc06_ptr & SICSLOWPAN_NHC_UDP_CS_P_11) { switch(*hc06_ptr & SICSLOWPAN_NHC_UDP_CS_P_11) {
case SICSLOWPAN_NHC_UDP_CS_P_00: case SICSLOWPAN_NHC_UDP_CS_P_00:
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */ /* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2); memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 3, 2); memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 3, 2);
PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n", PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
hc06_ptr += 5; hc06_ptr += 5;
break; break;
case SICSLOWPAN_NHC_UDP_CS_P_01: case SICSLOWPAN_NHC_UDP_CS_P_01:
/* 1 byte for NHC + source 16bit inline, dest = 0xF0 + 8 bit inline */ /* 1 byte for NHC + source 16bit inline, dest = 0xF0 + 8 bit inline */
PRINTF("IPHC: Decompressing destination\n"); PRINTF("IPHC: Decompressing destination\n");
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2); memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3))); SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3)));
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n", PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
hc06_ptr += 4; hc06_ptr += 4;
break; break;
case SICSLOWPAN_NHC_UDP_CS_P_10: case SICSLOWPAN_NHC_UDP_CS_P_10:
/* 1 byte for NHC + source = 0xF0 + 8bit inline, dest = 16 bit inline*/ /* 1 byte for NHC + source = 0xF0 + 8bit inline, dest = 16 bit inline*/
PRINTF("IPHC: Decompressing source\n"); PRINTF("IPHC: Decompressing source\n");
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN +
(*(hc06_ptr + 1))); (*(hc06_ptr + 1)));
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 2, 2); memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 2, 2);
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n", PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
hc06_ptr += 4; hc06_ptr += 4;
break; break;
case SICSLOWPAN_NHC_UDP_CS_P_11: case SICSLOWPAN_NHC_UDP_CS_P_11:
/* 1 byte for NHC, 1 byte for ports */ /* 1 byte for NHC, 1 byte for ports */
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
(*(hc06_ptr + 1) >> 4)); (*(hc06_ptr + 1) >> 4));
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
((*(hc06_ptr + 1)) & 0x0F)); ((*(hc06_ptr + 1)) & 0x0F));
PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n", PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
hc06_ptr += 2; hc06_ptr += 2;
break; break;
default: default:
PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n"); PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
return; return;
} }
if(!checksum_compressed) { /* has_checksum, default */ if(!checksum_compressed) { /* has_checksum, default */
memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr, 2); memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr, 2);
hc06_ptr += 2; hc06_ptr += 2;
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum included\n"); PRINTF("IPHC: sicslowpan uncompress_hdr: checksum included\n");
} else { } else {
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n"); PRINTF("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n");
} }
uncomp_hdr_len += UIP_UDPH_LEN; uncomp_hdr_len += UIP_UDPH_LEN;
} }
@ -1000,7 +1000,7 @@ uncompress_hdr_hc06(uint16_t ip_len)
} }
packetbuf_hdr_len = hc06_ptr - packetbuf_ptr; packetbuf_hdr_len = hc06_ptr - packetbuf_ptr;
/* IP length field. */ /* IP length field. */
if(ip_len == 0) { if(ip_len == 0) {
int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN; int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
@ -1012,7 +1012,7 @@ uncompress_hdr_hc06(uint16_t ip_len)
SICSLOWPAN_IP_BUF->len[0] = (ip_len - UIP_IPH_LEN) >> 8; SICSLOWPAN_IP_BUF->len[0] = (ip_len - UIP_IPH_LEN) >> 8;
SICSLOWPAN_IP_BUF->len[1] = (ip_len - UIP_IPH_LEN) & 0x00FF; SICSLOWPAN_IP_BUF->len[1] = (ip_len - UIP_IPH_LEN) & 0x00FF;
} }
/* length field in UDP header */ /* length field in UDP header */
if(SICSLOWPAN_IP_BUF->proto == UIP_PROTO_UDP) { if(SICSLOWPAN_IP_BUF->proto == UIP_PROTO_UDP) {
memcpy(&SICSLOWPAN_UDP_BUF->udplen, &SICSLOWPAN_IP_BUF->len[0], 2); memcpy(&SICSLOWPAN_UDP_BUF->udplen, &SICSLOWPAN_IP_BUF->len[0], 2);
@ -1144,7 +1144,7 @@ compress_hdr_hc1(linkaddr_t *link_destaddr)
UIP_HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) { UIP_HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) {
/* HC1 encoding */ /* HC1 encoding */
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_HC1_ENCODING] = 0xFB; PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_HC1_ENCODING] = 0xFB;
/* HC_UDP encoding, ttl, src and dest ports, checksum */ /* HC_UDP encoding, ttl, src and dest ports, checksum */
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_UDP_ENCODING] = 0xE0; PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_UDP_ENCODING] = 0xE0;
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl; PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl;
@ -1192,17 +1192,17 @@ uncompress_hdr_hc1(uint16_t ip_len)
SICSLOWPAN_IP_BUF->vtc = 0x60; SICSLOWPAN_IP_BUF->vtc = 0x60;
SICSLOWPAN_IP_BUF->tcflow = 0; SICSLOWPAN_IP_BUF->tcflow = 0;
SICSLOWPAN_IP_BUF->flow = 0; SICSLOWPAN_IP_BUF->flow = 0;
/* src and dest ip addresses */ /* src and dest ip addresses */
uip_ip6addr(&SICSLOWPAN_IP_BUF->srcipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0); uip_ip6addr(&SICSLOWPAN_IP_BUF->srcipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->srcipaddr, uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->srcipaddr,
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
uip_ip6addr(&SICSLOWPAN_IP_BUF->destipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0); uip_ip6addr(&SICSLOWPAN_IP_BUF->destipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->destipaddr, uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->destipaddr,
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER)); (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
uncomp_hdr_len += UIP_IPH_LEN; uncomp_hdr_len += UIP_IPH_LEN;
/* Next header field */ /* Next header field */
switch(PACKETBUF_HC1_PTR[PACKETBUF_HC1_ENCODING] & 0x06) { switch(PACKETBUF_HC1_PTR[PACKETBUF_HC1_ENCODING] & 0x06) {
case SICSLOWPAN_HC1_NH_ICMP6: case SICSLOWPAN_HC1_NH_ICMP6:
@ -1248,7 +1248,7 @@ uncompress_hdr_hc1(uint16_t ip_len)
/* this shouldn't happen, drop */ /* this shouldn't happen, drop */
return; return;
} }
/* IP length field. */ /* IP length field. */
if(ip_len == 0) { if(ip_len == 0) {
int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN; int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
@ -1363,8 +1363,10 @@ output(const uip_lladdr_t *localdest)
/* The MAC address of the destination of the packet */ /* The MAC address of the destination of the packet */
linkaddr_t dest; linkaddr_t dest;
#if SICSLOWPAN_CONF_FRAG
/* Number of bytes processed. */ /* Number of bytes processed. */
uint16_t processed_ip_out_len; uint16_t processed_ip_out_len;
#endif /* SICSLOWPAN_CONF_FRAG */
/* init */ /* init */
uncomp_hdr_len = 0; uncomp_hdr_len = 0;
@ -1410,7 +1412,7 @@ output(const uip_lladdr_t *localdest)
} else { } else {
linkaddr_copy(&dest, (const linkaddr_t *)localdest); linkaddr_copy(&dest, (const linkaddr_t *)localdest);
} }
PRINTFO("sicslowpan output: sending packet len %d\n", uip_len); PRINTFO("sicslowpan output: sending packet len %d\n", uip_len);
if(uip_len >= COMPRESSION_THRESHOLD) { if(uip_len >= COMPRESSION_THRESHOLD) {
@ -1510,7 +1512,7 @@ output(const uip_lladdr_t *localdest)
/* set processed_ip_out_len to what we already sent from the IP payload*/ /* set processed_ip_out_len to what we already sent from the IP payload*/
processed_ip_out_len = packetbuf_payload_len + uncomp_hdr_len; processed_ip_out_len = packetbuf_payload_len + uncomp_hdr_len;
/* /*
* Create following fragments * Create following fragments
* Datagram tag is already in the buffer, we need to set the * Datagram tag is already in the buffer, we need to set the
@ -1525,7 +1527,7 @@ output(const uip_lladdr_t *localdest)
while(processed_ip_out_len < uip_len) { while(processed_ip_out_len < uip_len) {
PRINTFO("sicslowpan output: fragment "); PRINTFO("sicslowpan output: fragment ");
PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3; PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3;
/* Copy payload and send */ /* Copy payload and send */
if(uip_len - processed_ip_out_len < packetbuf_payload_len) { if(uip_len - processed_ip_out_len < packetbuf_payload_len) {
/* last fragment */ /* last fragment */
@ -1593,8 +1595,8 @@ input(void)
uint16_t frag_size = 0; uint16_t frag_size = 0;
/* offset of the fragment in the IP packet */ /* offset of the fragment in the IP packet */
uint8_t frag_offset = 0; uint8_t frag_offset = 0;
uint8_t is_fragment = 0;
#if SICSLOWPAN_CONF_FRAG #if SICSLOWPAN_CONF_FRAG
uint8_t is_fragment = 0;
/* tag of the fragment */ /* tag of the fragment */
uint16_t frag_tag = 0; uint16_t frag_tag = 0;
uint8_t first_fragment = 0, last_fragment = 0; uint8_t first_fragment = 0, last_fragment = 0;
@ -1757,8 +1759,8 @@ input(void)
PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH]); PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH]);
return; return;
} }
#if SICSLOWPAN_CONF_FRAG #if SICSLOWPAN_CONF_FRAG
copypayload: copypayload:
#endif /*SICSLOWPAN_CONF_FRAG*/ #endif /*SICSLOWPAN_CONF_FRAG*/
@ -1789,7 +1791,7 @@ input(void)
} }
memcpy((uint8_t *)SICSLOWPAN_IP_BUF + uncomp_hdr_len + (uint16_t)(frag_offset << 3), packetbuf_ptr + packetbuf_hdr_len, packetbuf_payload_len); memcpy((uint8_t *)SICSLOWPAN_IP_BUF + uncomp_hdr_len + (uint16_t)(frag_offset << 3), packetbuf_ptr + packetbuf_hdr_len, packetbuf_payload_len);
/* update processed_ip_in_len if fragment, sicslowpan_len otherwise */ /* update processed_ip_in_len if fragment, sicslowpan_len otherwise */
#if SICSLOWPAN_CONF_FRAG #if SICSLOWPAN_CONF_FRAG
@ -1871,13 +1873,13 @@ sicslowpan_init(void)
* The platform contiki-conf.h file can override this using e.g. * The platform contiki-conf.h file can override this using e.g.
* #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xbb;addr_contexts[0].prefix[1]=0xbb;} * #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xbb;addr_contexts[0].prefix[1]=0xbb;}
*/ */
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 #if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
addr_contexts[0].used = 1; addr_contexts[0].used = 1;
addr_contexts[0].number = 0; addr_contexts[0].number = 0;
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_0 #ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_0
SICSLOWPAN_CONF_ADDR_CONTEXT_0; SICSLOWPAN_CONF_ADDR_CONTEXT_0;
#else #else
addr_contexts[0].prefix[0] = 0xaa; addr_contexts[0].prefix[0] = 0xaa;
addr_contexts[0].prefix[1] = 0xaa; addr_contexts[0].prefix[1] = 0xaa;
#endif #endif
#endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 */ #endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 */
@ -1887,23 +1889,22 @@ sicslowpan_init(void)
int i; int i;
for(i = 1; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) { for(i = 1; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) {
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_1 #ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_1
if (i==1) { if (i==1) {
addr_contexts[1].used = 1; addr_contexts[1].used = 1;
addr_contexts[1].number = 1; addr_contexts[1].number = 1;
SICSLOWPAN_CONF_ADDR_CONTEXT_1; SICSLOWPAN_CONF_ADDR_CONTEXT_1;
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_2 #ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_2
} else if (i==2) { } else if (i==2) {
addr_contexts[2].used = 1; addr_contexts[2].used = 1;
addr_contexts[2].number = 2; addr_contexts[2].number = 2;
SICSLOWPAN_CONF_ADDR_CONTEXT_2; SICSLOWPAN_CONF_ADDR_CONTEXT_2;
#endif #endif
} else { } else {
addr_contexts[i].used = 0; addr_contexts[i].used = 0;
} }
#else #else
addr_contexts[i].used = 0; addr_contexts[i].used = 0;
#endif /* SICSLOWPAN_CONF_ADDR_CONTEXT_1 */ #endif /* SICSLOWPAN_CONF_ADDR_CONTEXT_1 */
} }
} }
#endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 1 */ #endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 1 */

View file

@ -203,18 +203,18 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
#if UIP_DS6_LL_NUD #if UIP_DS6_LL_NUD
/* From RFC4861, page 72, last paragraph of section 7.3.3: /* From RFC4861, page 72, last paragraph of section 7.3.3:
* *
* "In some cases, link-specific information may indicate that a path to * "In some cases, link-specific information may indicate that a path to
* a neighbor has failed (e.g., the resetting of a virtual circuit). In * a neighbor has failed (e.g., the resetting of a virtual circuit). In
* such cases, link-specific information may be used to purge Neighbor * such cases, link-specific information may be used to purge Neighbor
* Cache entries before the Neighbor Unreachability Detection would do * Cache entries before the Neighbor Unreachability Detection would do
* so. However, link-specific information MUST NOT be used to confirm * so. However, link-specific information MUST NOT be used to confirm
* the reachability of a neighbor; such information does not provide * the reachability of a neighbor; such information does not provide
* end-to-end confirmation between neighboring IP layers." * end-to-end confirmation between neighboring IP layers."
* *
* However, we assume that receiving a link layer ack ensures the delivery * However, we assume that receiving a link layer ack ensures the delivery
* of the transmitted packed to the IP stack of the neighbour. This is a * of the transmitted packed to the IP stack of the neighbour. This is a
* fair assumption and allows battery powered nodes save some battery by * fair assumption and allows battery powered nodes save some battery by
* not re-testing the state of a neighbour periodically if it * not re-testing the state of a neighbour periodically if it
* acknowledges link packets. */ * acknowledges link packets. */
if(status == MAC_TX_OK) { if(status == MAC_TX_OK) {
uip_ds6_nbr_t *nbr; uip_ds6_nbr_t *nbr;

View file

@ -297,9 +297,9 @@ uip_ds6_prefix_t *
uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen) uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen)
{ {
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_prefix_list, if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_prefix_list,
UIP_DS6_PREFIX_NB, sizeof(uip_ds6_prefix_t), UIP_DS6_PREFIX_NB, sizeof(uip_ds6_prefix_t),
ipaddr, ipaddrlen, ipaddr, ipaddrlen,
(uip_ds6_element_t **)&locprefix) == FOUND) { (uip_ds6_element_t **)&locprefix) == FOUND) {
return locprefix; return locprefix;
} }
return NULL; return NULL;
@ -489,8 +489,8 @@ uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr)
{ {
#if UIP_DS6_AADDR_NB #if UIP_DS6_AADDR_NB
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_if.aaddr_list, if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_if.aaddr_list,
UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128, UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128,
(uip_ds6_element_t **)&locaaddr) == FOUND) { (uip_ds6_element_t **)&locaaddr) == FOUND) {
return locaaddr; return locaaddr;
} }
#endif /* UIP_DS6_AADDR_NB */ #endif /* UIP_DS6_AADDR_NB */

View file

@ -93,7 +93,7 @@ void uip_log(char *msg);
/** \name Pointers to the header structures. /** \name Pointers to the header structures.
* All pointers except UIP_IP_BUF depend on uip_ext_len, which at * All pointers except UIP_IP_BUF depend on uip_ext_len, which at
* packet reception, is the total length of the extension headers. * packet reception, is the total length of the extension headers.
* *
* The pointer to ND6 options header also depends on nd6_opt_offset, * The pointer to ND6 options header also depends on nd6_opt_offset,
* which we set in each function. * which we set in each function.
* *
@ -143,7 +143,7 @@ extract_lladdr_aligned(uip_lladdr_t *dest) {
} }
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ #endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* create a llao */ /* create a llao */
static void static void
create_llao(uint8_t *llao, uint8_t type) { create_llao(uint8_t *llao, uint8_t type) {
llao[UIP_ND6_OPT_TYPE_OFFSET] = type; llao[UIP_ND6_OPT_TYPE_OFFSET] = type;
@ -361,7 +361,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
UIP_IP_BUF->len[0] = 0; /* length will not be more than 255 */ UIP_IP_BUF->len[0] = 0; /* length will not be more than 255 */
/* /*
* check if we add a SLLAO option: for DAD, MUST NOT, for NUD, MAY * check if we add a SLLAO option: for DAD, MUST NOT, for NUD, MAY
* (here yes), for Address resolution , MUST * (here yes), for Address resolution , MUST
*/ */
if(!(uip_ds6_is_my_addr(tgt))) { if(!(uip_ds6_is_my_addr(tgt))) {
if(src != NULL) { if(src != NULL) {
@ -378,7 +378,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN; UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN;
create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_NS_LEN], create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_NS_LEN],
UIP_ND6_OPT_SLLAO); UIP_ND6_OPT_SLLAO);
uip_len = uip_len =
UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN; UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN;
@ -437,9 +437,9 @@ na_input(void)
PRINTF("\n"); PRINTF("\n");
UIP_STAT(++uip_stat.nd6.recv); UIP_STAT(++uip_stat.nd6.recv);
/* /*
* booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20 * booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20
* but it works. Be careful though, do not use tests such as is_router == 1 * but it works. Be careful though, do not use tests such as is_router == 1
*/ */
is_llchange = 0; is_llchange = 0;
is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER)); is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));
@ -505,7 +505,7 @@ na_input(void)
goto discard; goto discard;
} }
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
UIP_LLADDR_LEN); UIP_LLADDR_LEN);
if(is_solicited) { if(is_solicited) {
nbr->state = NBR_REACHABLE; nbr->state = NBR_REACHABLE;
nbr->nscount = 0; nbr->nscount = 0;
@ -528,7 +528,7 @@ na_input(void)
|| nd6_opt_llao == 0) { || nd6_opt_llao == 0) {
if(nd6_opt_llao != 0) { if(nd6_opt_llao != 0) {
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
UIP_LLADDR_LEN); UIP_LLADDR_LEN);
} }
if(is_solicited) { if(is_solicited) {
nbr->state = NBR_REACHABLE; nbr->state = NBR_REACHABLE;
@ -564,7 +564,7 @@ na_input(void)
uip_packetqueue_free(&nbr->packethandle); uip_packetqueue_free(&nbr->packethandle);
return; return;
} }
#endif /*UIP_CONF_IPV6_QUEUE_PKT */ #endif /*UIP_CONF_IPV6_QUEUE_PKT */
discard: discard:
@ -590,7 +590,7 @@ rs_input(void)
#if UIP_CONF_IPV6_CHECKS #if UIP_CONF_IPV6_CHECKS
/* /*
* Check hop limit / icmp code * Check hop limit / icmp code
* target address must not be multicast * target address must not be multicast
* if the NA is solicited, dest must not be multicast * if the NA is solicited, dest must not be multicast
*/ */
@ -796,7 +796,7 @@ uip_nd6_rs_output(void)
UIP_ICMPH_LEN + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN; UIP_ICMPH_LEN + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN;
create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_RS_LEN], create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_RS_LEN],
UIP_ND6_OPT_SLLAO); UIP_ND6_OPT_SLLAO);
} }
UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = 0;
@ -877,9 +877,9 @@ ra_input(void)
nbr->state = NBR_STALE; nbr->state = NBR_STALE;
} }
if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
lladdr, UIP_LLADDR_LEN) != 0) { lladdr, UIP_LLADDR_LEN) != 0) {
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
UIP_LLADDR_LEN); UIP_LLADDR_LEN);
nbr->state = NBR_STALE; nbr->state = NBR_STALE;
} }
nbr->isrouter = 1; nbr->isrouter = 1;
@ -937,7 +937,7 @@ ra_input(void)
if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS) if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)
&& (nd6_opt_prefix_info->validlt != 0) && (nd6_opt_prefix_info->validlt != 0)
&& (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) { && (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {
uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix); uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
addr = uip_ds6_addr_lookup(&ipaddr); addr = uip_ds6_addr_lookup(&ipaddr);

View file

@ -128,9 +128,9 @@
#endif #endif
#ifdef UIP_CONF_ND6_RETRANS_TIMER #ifdef UIP_CONF_ND6_RETRANS_TIMER
#define UIP_ND6_RETRANS_TIMER UIP_CONF_ND6_RETRANS_TIMER #define UIP_ND6_RETRANS_TIMER UIP_CONF_ND6_RETRANS_TIMER
#else #else
#define UIP_ND6_RETRANS_TIMER 1000 #define UIP_ND6_RETRANS_TIMER 1000
#endif #endif
#define UIP_ND6_DELAY_FIRST_PROBE_TIME 5 #define UIP_ND6_DELAY_FIRST_PROBE_TIME 5

View file

@ -103,7 +103,7 @@ void uip_log(char *msg);
#if UIP_STATISTICS == 1 #if UIP_STATISTICS == 1
struct uip_stats uip_stat; struct uip_stats uip_stat;
#endif /* UIP_STATISTICS == 1 */ #endif /* UIP_STATISTICS == 1 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
@ -299,15 +299,15 @@ uip_add32(uint8_t *op32, uint16_t op16)
uip_acc32[2] = op32[2] + (op16 >> 8); uip_acc32[2] = op32[2] + (op16 >> 8);
uip_acc32[1] = op32[1]; uip_acc32[1] = op32[1];
uip_acc32[0] = op32[0]; uip_acc32[0] = op32[0];
if(uip_acc32[2] < (op16 >> 8)) { if(uip_acc32[2] < (op16 >> 8)) {
++uip_acc32[1]; ++uip_acc32[1];
if(uip_acc32[1] == 0) { if(uip_acc32[1] == 0) {
++uip_acc32[0]; ++uip_acc32[0];
} }
} }
if(uip_acc32[3] < (op16 & 0xff)) { if(uip_acc32[3] < (op16 & 0xff)) {
++uip_acc32[2]; ++uip_acc32[2];
if(uip_acc32[2] == 0) { if(uip_acc32[2] == 0) {
@ -332,7 +332,7 @@ chksum(uint16_t sum, const uint8_t *data, uint16_t len)
dataptr = data; dataptr = data;
last_byte = data + len - 1; last_byte = data + len - 1;
while(dataptr < last_byte) { /* At least two more bytes */ while(dataptr < last_byte) { /* At least two more bytes */
t = (dataptr[0] << 8) + dataptr[1]; t = (dataptr[0] << 8) + dataptr[1];
sum += t; sum += t;
@ -341,7 +341,7 @@ chksum(uint16_t sum, const uint8_t *data, uint16_t len)
} }
dataptr += 2; dataptr += 2;
} }
if(dataptr == last_byte) { if(dataptr == last_byte) {
t = (dataptr[0] << 8) + 0; t = (dataptr[0] << 8) + 0;
sum += t; sum += t;
@ -386,11 +386,11 @@ upper_layer_chksum(uint8_t proto)
*/ */
volatile uint16_t upper_layer_len; volatile uint16_t upper_layer_len;
uint16_t sum; uint16_t sum;
upper_layer_len = (((uint16_t)(UIP_IP_BUF->len[0]) << 8) + UIP_IP_BUF->len[1] - uip_ext_len); upper_layer_len = (((uint16_t)(UIP_IP_BUF->len[0]) << 8) + UIP_IP_BUF->len[1] - uip_ext_len);
PRINTF("Upper layer checksum len: %d from: %d\n", upper_layer_len, PRINTF("Upper layer checksum len: %d from: %d\n", upper_layer_len,
UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len); UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len);
/* First sum pseudoheader. */ /* First sum pseudoheader. */
/* IP protocol and length fields. This addition cannot carry. */ /* IP protocol and length fields. This addition cannot carry. */
@ -401,7 +401,7 @@ upper_layer_chksum(uint8_t proto)
/* Sum TCP header and data. */ /* Sum TCP header and data. */
sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len], sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len],
upper_layer_len); upper_layer_len);
return (sum == 0) ? 0xffff : uip_htons(sum); return (sum == 0) ? 0xffff : uip_htons(sum);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -409,7 +409,7 @@ uint16_t
uip_icmp6chksum(void) uip_icmp6chksum(void)
{ {
return upper_layer_chksum(UIP_PROTO_ICMP6); return upper_layer_chksum(UIP_PROTO_ICMP6);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if UIP_TCP #if UIP_TCP
@ -432,7 +432,7 @@ uip_udpchksum(void)
void void
uip_init(void) uip_init(void)
{ {
uip_ds6_init(); uip_ds6_init();
uip_icmp6_init(); uip_icmp6_init();
uip_nd6_init(); uip_nd6_init();
@ -466,7 +466,7 @@ struct uip_conn *
uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport) uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
{ {
register struct uip_conn *conn, *cconn; register struct uip_conn *conn, *cconn;
/* Find an unused local port. */ /* Find an unused local port. */
again: again:
++lastport; ++lastport;
@ -503,7 +503,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
if(conn == 0) { if(conn == 0) {
return 0; return 0;
} }
conn->tcpstateflags = UIP_SYN_SENT; conn->tcpstateflags = UIP_SYN_SENT;
conn->snd_nxt[0] = iss[0]; conn->snd_nxt[0] = iss[0];
@ -517,7 +517,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
conn->rcv_nxt[3] = 0; conn->rcv_nxt[3] = 0;
conn->initialmss = conn->mss = UIP_TCP_MSS; conn->initialmss = conn->mss = UIP_TCP_MSS;
conn->len = 1; /* TCP length of the SYN is one. */ conn->len = 1; /* TCP length of the SYN is one. */
conn->nrtx = 0; conn->nrtx = 0;
conn->timer = 1; /* Send the SYN next time around. */ conn->timer = 1; /* Send the SYN next time around. */
@ -527,7 +527,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
conn->lport = uip_htons(lastport); conn->lport = uip_htons(lastport);
conn->rport = rport; conn->rport = rport;
uip_ipaddr_copy(&conn->ripaddr, ripaddr); uip_ipaddr_copy(&conn->ripaddr, ripaddr);
return conn; return conn;
} }
#endif /* UIP_TCP && UIP_ACTIVE_OPEN */ #endif /* UIP_TCP && UIP_ACTIVE_OPEN */
@ -538,14 +538,14 @@ remove_ext_hdr(void)
/* Remove ext header before TCP/UDP processing. */ /* Remove ext header before TCP/UDP processing. */
if(uip_ext_len > 0) { if(uip_ext_len > 0) {
PRINTF("Cutting ext-header before processing (extlen: %d, uiplen: %d)\n", PRINTF("Cutting ext-header before processing (extlen: %d, uiplen: %d)\n",
uip_ext_len, uip_len); uip_ext_len, uip_len);
if(uip_len < UIP_IPH_LEN + uip_ext_len) { if(uip_len < UIP_IPH_LEN + uip_ext_len) {
PRINTF("ERROR: uip_len too short compared to ext len\n"); PRINTF("ERROR: uip_len too short compared to ext len\n");
uip_clear_buf(); uip_clear_buf();
return; return;
} }
memmove(((uint8_t *)UIP_TCP_BUF), (uint8_t *)UIP_TCP_BUF + uip_ext_len, memmove(((uint8_t *)UIP_TCP_BUF), (uint8_t *)UIP_TCP_BUF + uip_ext_len,
uip_len - UIP_IPH_LEN - uip_ext_len); uip_len - UIP_IPH_LEN - uip_ext_len);
uip_len -= uip_ext_len; uip_len -= uip_ext_len;
@ -561,7 +561,7 @@ struct uip_udp_conn *
uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport) uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
{ {
register struct uip_udp_conn *conn; register struct uip_udp_conn *conn;
/* Find an unused local port. */ /* Find an unused local port. */
again: again:
++lastport; ++lastport;
@ -569,7 +569,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
if(lastport >= 32000) { if(lastport >= 32000) {
lastport = 4096; lastport = 4096;
} }
for(c = 0; c < UIP_UDP_CONNS; ++c) { for(c = 0; c < UIP_UDP_CONNS; ++c) {
if(uip_udp_conns[c].lport == uip_htons(lastport)) { if(uip_udp_conns[c].lport == uip_htons(lastport)) {
goto again; goto again;
@ -587,7 +587,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
if(conn == 0) { if(conn == 0) {
return 0; return 0;
} }
conn->lport = UIP_HTONS(lastport); conn->lport = UIP_HTONS(lastport);
conn->rport = rport; conn->rport = rport;
if(ripaddr == NULL) { if(ripaddr == NULL) {
@ -596,7 +596,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
uip_ipaddr_copy(&conn->ripaddr, ripaddr); uip_ipaddr_copy(&conn->ripaddr, ripaddr);
} }
conn->ttl = uip_ds6_if.cur_hop_limit; conn->ttl = uip_ds6_if.cur_hop_limit;
return conn; return conn;
} }
#endif /* UIP_UDP */ #endif /* UIP_UDP */
@ -668,7 +668,7 @@ uip_reass(void)
uint16_t offset=0; uint16_t offset=0;
uint16_t len; uint16_t len;
uint16_t i; uint16_t i;
/* If ip_reasstmr is zero, no packet is present in the buffer */ /* If ip_reasstmr is zero, no packet is present in the buffer */
/* We first write the unfragmentable part of IP header into the reassembly /* We first write the unfragmentable part of IP header into the reassembly
buffer. The reset the other reassembly variables. */ buffer. The reset the other reassembly variables. */
@ -710,9 +710,9 @@ uip_reass(void)
PRINTF("dest "); PRINTF("dest ");
PRINT6ADDR(&FBUF->destipaddr); PRINT6ADDR(&FBUF->destipaddr);
PRINTF("next %d\n", UIP_IP_BUF->proto); PRINTF("next %d\n", UIP_IP_BUF->proto);
} }
/* If the offset or the offset + fragment length overflows the /* If the offset or the offset + fragment length overflows the
reassembly buffer, we discard the entire packet. */ reassembly buffer, we discard the entire packet. */
if(offset > UIP_REASS_BUFSIZE || if(offset > UIP_REASS_BUFSIZE ||
@ -744,12 +744,12 @@ uip_reass(void)
return uip_len; return uip_len;
} }
} }
/* Copy the fragment into the reassembly buffer, at the right /* Copy the fragment into the reassembly buffer, at the right
offset. */ offset. */
memcpy((uint8_t *)FBUF + UIP_IPH_LEN + uip_ext_len + offset, memcpy((uint8_t *)FBUF + UIP_IPH_LEN + uip_ext_len + offset,
(uint8_t *)UIP_FRAG_BUF + UIP_FRAGH_LEN, len); (uint8_t *)UIP_FRAG_BUF + UIP_FRAGH_LEN, len);
/* Update the bitmap. */ /* Update the bitmap. */
if(offset >> 6 == (offset + len) >> 6) { if(offset >> 6 == (offset + len) >> 6) {
uip_reassbitmap[offset >> 6] |= uip_reassbitmap[offset >> 6] |=
@ -760,18 +760,18 @@ uip_reass(void)
bytes in the endpoints and fill the stuff inbetween with bytes in the endpoints and fill the stuff inbetween with
0xff. */ 0xff. */
uip_reassbitmap[offset >> 6] |= bitmap_bits[(offset >> 3) & 7]; uip_reassbitmap[offset >> 6] |= bitmap_bits[(offset >> 3) & 7];
for(i = (1 + (offset >> 6)); i < ((offset + len) >> 6); ++i) { for(i = (1 + (offset >> 6)); i < ((offset + len) >> 6); ++i) {
uip_reassbitmap[i] = 0xff; uip_reassbitmap[i] = 0xff;
} }
uip_reassbitmap[(offset + len) >> 6] |= uip_reassbitmap[(offset + len) >> 6] |=
~bitmap_bits[((offset + len) >> 3) & 7]; ~bitmap_bits[((offset + len) >> 3) & 7];
} }
/* Finally, we check if we have a full packet in the buffer. We do /* Finally, we check if we have a full packet in the buffer. We do
this by checking if we have the last fragment and if all bits this by checking if we have the last fragment and if all bits
in the bitmap are set. */ in the bitmap are set. */
if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) { if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) {
/* Check all bytes up to and including all but the last byte in /* Check all bytes up to and including all but the last byte in
the bitmap. */ the bitmap. */
@ -798,9 +798,9 @@ uip_reass(void)
UIP_IP_BUF->len[1] = ((uip_reasslen - UIP_IPH_LEN) & 0xff); UIP_IP_BUF->len[1] = ((uip_reasslen - UIP_IPH_LEN) & 0xff);
PRINTF("REASSEMBLED PAQUET %d (%d)\n", uip_reasslen, PRINTF("REASSEMBLED PAQUET %d (%d)\n", uip_reasslen,
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]); (UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
return uip_reasslen; return uip_reasslen;
} }
} else { } else {
PRINTF("Already reassembling another paquet\n"); PRINTF("Already reassembling another paquet\n");
@ -831,7 +831,7 @@ uip_reass_over(void)
memcpy(UIP_IP_BUF, FBUF, UIP_IPH_LEN); /* copy the header for src memcpy(UIP_IP_BUF, FBUF, UIP_IPH_LEN); /* copy the header for src
and dest address*/ and dest address*/
uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_REASSEMBLY, 0); uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_REASSEMBLY, 0);
UIP_STAT(++uip_stat.ip.sent); UIP_STAT(++uip_stat.ip.sent);
uip_flags = 0; uip_flags = 0;
} }
@ -881,14 +881,14 @@ ext_hdr_options_process(void)
uip_ext_opt_offset += UIP_EXT_HDR_OPT_PADN_BUF->opt_len + 2; uip_ext_opt_offset += UIP_EXT_HDR_OPT_PADN_BUF->opt_len + 2;
break; break;
case UIP_EXT_HDR_OPT_RPL: case UIP_EXT_HDR_OPT_RPL:
/* Fixes situation when a node that is not using RPL /* Fixes situation when a node that is not using RPL
* joins a network which does. The received packages will include the * joins a network which does. The received packages will include the
* RPL header and processed by the "default" case of the switch * RPL header and processed by the "default" case of the switch
* (0x63 & 0xC0 = 0x40). Hence, the packet is discarded as the header * (0x63 & 0xC0 = 0x40). Hence, the packet is discarded as the header
* is considered invalid. * is considered invalid.
* Using this fix, the header is ignored, and the next header (if * Using this fix, the header is ignored, and the next header (if
* present) is processed. * present) is processed.
*/ */
#if UIP_CONF_IPV6_RPL #if UIP_CONF_IPV6_RPL
PRINTF("Processing RPL option\n"); PRINTF("Processing RPL option\n");
if(rpl_verify_header(uip_ext_opt_offset)) { if(rpl_verify_header(uip_ext_opt_offset)) {
@ -949,7 +949,7 @@ uip_process(uint8_t flag)
} }
#endif /* UIP_UDP */ #endif /* UIP_UDP */
uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
/* Check if we were invoked because of a poll request for a /* Check if we were invoked because of a poll request for a
particular connection. */ particular connection. */
if(flag == UIP_POLL_REQUEST) { if(flag == UIP_POLL_REQUEST) {
@ -974,7 +974,7 @@ uip_process(uint8_t flag)
#if UIP_TCP #if UIP_TCP
uip_clear_buf(); uip_clear_buf();
uip_slen = 0; uip_slen = 0;
/* Increase the initial sequence number. */ /* Increase the initial sequence number. */
if(++iss[3] == 0) { if(++iss[3] == 0) {
if(++iss[2] == 0) { if(++iss[2] == 0) {
@ -983,7 +983,7 @@ uip_process(uint8_t flag)
} }
} }
} }
/* /*
* Check if the connection is in a state in which we simply wait * Check if the connection is in a state in which we simply wait
* for the connection to time out. If so, we increase the * for the connection to time out. If so, we increase the
@ -1009,7 +1009,7 @@ uip_process(uint8_t flag)
uip_connr->tcpstateflags == UIP_SYN_RCVD) && uip_connr->tcpstateflags == UIP_SYN_RCVD) &&
uip_connr->nrtx == UIP_MAXSYNRTX)) { uip_connr->nrtx == UIP_MAXSYNRTX)) {
uip_connr->tcpstateflags = UIP_CLOSED; uip_connr->tcpstateflags = UIP_CLOSED;
/* /*
* We call UIP_APPCALL() with uip_flags set to * We call UIP_APPCALL() with uip_flags set to
* UIP_TIMEDOUT to inform the application that the * UIP_TIMEDOUT to inform the application that the
@ -1017,18 +1017,18 @@ uip_process(uint8_t flag)
*/ */
uip_flags = UIP_TIMEDOUT; uip_flags = UIP_TIMEDOUT;
UIP_APPCALL(); UIP_APPCALL();
/* We also send a reset packet to the remote host. */ /* We also send a reset packet to the remote host. */
UIP_TCP_BUF->flags = TCP_RST | TCP_ACK; UIP_TCP_BUF->flags = TCP_RST | TCP_ACK;
goto tcp_send_nodata; goto tcp_send_nodata;
} }
/* Exponential backoff. */ /* Exponential backoff. */
uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4? uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4?
4: 4:
uip_connr->nrtx); uip_connr->nrtx);
++(uip_connr->nrtx); ++(uip_connr->nrtx);
/* /*
* Ok, so we need to retransmit. We do this differently * Ok, so we need to retransmit. We do this differently
* depending on which state we are in. In ESTABLISHED, we * depending on which state we are in. In ESTABLISHED, we
@ -1042,14 +1042,14 @@ uip_process(uint8_t flag)
case UIP_SYN_RCVD: case UIP_SYN_RCVD:
/* In the SYN_RCVD state, we should retransmit our SYNACK. */ /* In the SYN_RCVD state, we should retransmit our SYNACK. */
goto tcp_send_synack; goto tcp_send_synack;
#if UIP_ACTIVE_OPEN #if UIP_ACTIVE_OPEN
case UIP_SYN_SENT: case UIP_SYN_SENT:
/* In the SYN_SENT state, we retransmit out SYN. */ /* In the SYN_SENT state, we retransmit out SYN. */
UIP_TCP_BUF->flags = 0; UIP_TCP_BUF->flags = 0;
goto tcp_send_syn; goto tcp_send_syn;
#endif /* UIP_ACTIVE_OPEN */ #endif /* UIP_ACTIVE_OPEN */
case UIP_ESTABLISHED: case UIP_ESTABLISHED:
/* /*
* In the ESTABLISHED state, we call upon the application * In the ESTABLISHED state, we call upon the application
@ -1060,7 +1060,7 @@ uip_process(uint8_t flag)
uip_flags = UIP_REXMIT; uip_flags = UIP_REXMIT;
UIP_APPCALL(); UIP_APPCALL();
goto apprexmit; goto apprexmit;
case UIP_FIN_WAIT_1: case UIP_FIN_WAIT_1:
case UIP_CLOSING: case UIP_CLOSING:
case UIP_LAST_ACK: case UIP_LAST_ACK:
@ -1096,12 +1096,12 @@ uip_process(uint8_t flag)
} }
#endif /* UIP_UDP */ #endif /* UIP_UDP */
/* This is where the input processing starts. */ /* This is where the input processing starts. */
UIP_STAT(++uip_stat.ip.recv); UIP_STAT(++uip_stat.ip.recv);
/* Start of IP input header processing code. */ /* Start of IP input header processing code. */
/* Check validity of the IP header. */ /* Check validity of the IP header. */
if((UIP_IP_BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */ if((UIP_IP_BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */
UIP_STAT(++uip_stat.ip.drop); UIP_STAT(++uip_stat.ip.drop);
@ -1117,7 +1117,7 @@ uip_process(uint8_t flag)
* the packet has been padded and we set uip_len to the correct * the packet has been padded and we set uip_len to the correct
* value.. * value..
*/ */
if((UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] <= uip_len) { if((UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] <= uip_len) {
uip_len = (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + UIP_IPH_LEN; uip_len = (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + UIP_IPH_LEN;
/* /*
@ -1135,7 +1135,7 @@ uip_process(uint8_t flag)
UIP_LOG("ip: packet shorter than reported in IP header."); UIP_LOG("ip: packet shorter than reported in IP header.");
goto drop; goto drop;
} }
PRINTF("IPv6 packet received from "); PRINTF("IPv6 packet received from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to "); PRINTF(" to ");
@ -1168,11 +1168,11 @@ uip_process(uint8_t flag)
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8; uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
break; break;
case 1: case 1:
PRINTF("Dropping packet after extension header processing\n"); PRINTF("Dropping packet after extension header processing\n");
/* silently discard */ /* silently discard */
goto drop; goto drop;
case 2: case 2:
PRINTF("Sending error message after extension header processing\n"); PRINTF("Sending error message after extension header processing\n");
/* send icmp error message (created in ext_hdr_options_process) /* send icmp error message (created in ext_hdr_options_process)
* and discard*/ * and discard*/
goto send; goto send;
@ -1417,7 +1417,7 @@ uip_process(uint8_t flag)
UIP_LOG("ip6: unrecognized header"); UIP_LOG("ip6: unrecognized header");
goto send; goto send;
/* End of headers processing */ /* End of headers processing */
icmp6_input: icmp6_input:
/* This is IPv6 ICMPv6 processing code. */ /* This is IPv6 ICMPv6 processing code. */
PRINTF("icmp6_input: length %d type: %d \n", uip_len, UIP_ICMP_BUF->type); PRINTF("icmp6_input: length %d type: %d \n", uip_len, UIP_ICMP_BUF->type);
@ -1459,14 +1459,14 @@ uip_process(uint8_t flag)
UIP_LOG("icmp6: unknown ICMPv6 message."); UIP_LOG("icmp6: unknown ICMPv6 message.");
uip_clear_buf(); uip_clear_buf();
} }
if(uip_len > 0) { if(uip_len > 0) {
goto send; goto send;
} else { } else {
goto drop; goto drop;
} }
/* End of IPv6 ICMP processing. */ /* End of IPv6 ICMP processing. */
#if UIP_UDP #if UIP_UDP
/* UDP input processing. */ /* UDP input processing. */
@ -1475,7 +1475,7 @@ uip_process(uint8_t flag)
remove_ext_hdr(); remove_ext_hdr();
PRINTF("Receiving UDP packet\n"); PRINTF("Receiving UDP packet\n");
/* UDP processing is really just a hack. We don't do anything to the /* UDP processing is really just a hack. We don't do anything to the
UDP/IP headers, but let the UDP application do all the hard UDP/IP headers, but let the UDP application do all the hard
work. If the application sets uip_slen, it has a packet to work. If the application sets uip_slen, it has a packet to
@ -1538,7 +1538,7 @@ uip_process(uint8_t flag)
udp_found: udp_found:
PRINTF("In udp_found\n"); PRINTF("In udp_found\n");
UIP_STAT(++uip_stat.udp.recv); UIP_STAT(++uip_stat.udp.recv);
uip_conn = NULL; uip_conn = NULL;
uip_flags = UIP_NEWDATA; uip_flags = UIP_NEWDATA;
uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN]; uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN];
@ -1597,7 +1597,7 @@ uip_process(uint8_t flag)
UIP_STAT(++uip_stat.tcp.recv); UIP_STAT(++uip_stat.tcp.recv);
PRINTF("Receiving TCP packet\n"); PRINTF("Receiving TCP packet\n");
/* Start of TCP input header processing code. */ /* Start of TCP input header processing code. */
if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP
checksum. */ checksum. */
UIP_STAT(++uip_stat.tcp.drop); UIP_STAT(++uip_stat.tcp.drop);
@ -1632,7 +1632,7 @@ uip_process(uint8_t flag)
if((UIP_TCP_BUF->flags & TCP_CTL) != TCP_SYN) { if((UIP_TCP_BUF->flags & TCP_CTL) != TCP_SYN) {
goto reset; goto reset;
} }
tmp16 = UIP_TCP_BUF->destport; tmp16 = UIP_TCP_BUF->destport;
/* Next, check listening connections. */ /* Next, check listening connections. */
for(c = 0; c < UIP_LISTENPORTS; ++c) { for(c = 0; c < UIP_LISTENPORTS; ++c) {
@ -1640,7 +1640,7 @@ uip_process(uint8_t flag)
goto found_listen; goto found_listen;
} }
} }
/* No matching connection found, so we send a RST packet. */ /* No matching connection found, so we send a RST packet. */
UIP_STAT(++uip_stat.tcp.synrst); UIP_STAT(++uip_stat.tcp.synrst);
@ -1652,7 +1652,7 @@ uip_process(uint8_t flag)
} }
UIP_STAT(++uip_stat.tcp.rst); UIP_STAT(++uip_stat.tcp.rst);
UIP_TCP_BUF->flags = TCP_RST | TCP_ACK; UIP_TCP_BUF->flags = TCP_RST | TCP_ACK;
uip_len = UIP_IPTCPH_LEN; uip_len = UIP_IPTCPH_LEN;
UIP_TCP_BUF->tcpoffset = 5 << 4; UIP_TCP_BUF->tcpoffset = 5 << 4;
@ -1661,15 +1661,15 @@ uip_process(uint8_t flag)
c = UIP_TCP_BUF->seqno[3]; c = UIP_TCP_BUF->seqno[3];
UIP_TCP_BUF->seqno[3] = UIP_TCP_BUF->ackno[3]; UIP_TCP_BUF->seqno[3] = UIP_TCP_BUF->ackno[3];
UIP_TCP_BUF->ackno[3] = c; UIP_TCP_BUF->ackno[3] = c;
c = UIP_TCP_BUF->seqno[2]; c = UIP_TCP_BUF->seqno[2];
UIP_TCP_BUF->seqno[2] = UIP_TCP_BUF->ackno[2]; UIP_TCP_BUF->seqno[2] = UIP_TCP_BUF->ackno[2];
UIP_TCP_BUF->ackno[2] = c; UIP_TCP_BUF->ackno[2] = c;
c = UIP_TCP_BUF->seqno[1]; c = UIP_TCP_BUF->seqno[1];
UIP_TCP_BUF->seqno[1] = UIP_TCP_BUF->ackno[1]; UIP_TCP_BUF->seqno[1] = UIP_TCP_BUF->ackno[1];
UIP_TCP_BUF->ackno[1] = c; UIP_TCP_BUF->ackno[1] = c;
c = UIP_TCP_BUF->seqno[0]; c = UIP_TCP_BUF->seqno[0];
UIP_TCP_BUF->seqno[0] = UIP_TCP_BUF->ackno[0]; UIP_TCP_BUF->seqno[0] = UIP_TCP_BUF->ackno[0];
UIP_TCP_BUF->ackno[0] = c; UIP_TCP_BUF->ackno[0] = c;
@ -1684,12 +1684,12 @@ uip_process(uint8_t flag)
} }
} }
} }
/* Swap port numbers. */ /* Swap port numbers. */
tmp16 = UIP_TCP_BUF->srcport; tmp16 = UIP_TCP_BUF->srcport;
UIP_TCP_BUF->srcport = UIP_TCP_BUF->destport; UIP_TCP_BUF->srcport = UIP_TCP_BUF->destport;
UIP_TCP_BUF->destport = tmp16; UIP_TCP_BUF->destport = tmp16;
/* Swap IP addresses. */ /* Swap IP addresses. */
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr); uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
@ -1730,7 +1730,7 @@ uip_process(uint8_t flag)
goto drop; goto drop;
} }
uip_conn = uip_connr; uip_conn = uip_connr;
/* Fill in the necessary fields for the new connection. */ /* Fill in the necessary fields for the new connection. */
uip_connr->rto = uip_connr->timer = UIP_RTO; uip_connr->rto = uip_connr->timer = UIP_RTO;
uip_connr->sa = 0; uip_connr->sa = 0;
@ -1771,7 +1771,7 @@ uip_process(uint8_t flag)
(uint16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c]; (uint16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
uip_connr->initialmss = uip_connr->mss = uip_connr->initialmss = uip_connr->mss =
tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
/* And we are done processing options. */ /* And we are done processing options. */
break; break;
} else { } else {
@ -1786,19 +1786,19 @@ uip_process(uint8_t flag)
} }
} }
} }
/* Our response will be a SYNACK. */ /* Our response will be a SYNACK. */
#if UIP_ACTIVE_OPEN #if UIP_ACTIVE_OPEN
tcp_send_synack: tcp_send_synack:
UIP_TCP_BUF->flags = TCP_ACK; UIP_TCP_BUF->flags = TCP_ACK;
tcp_send_syn: tcp_send_syn:
UIP_TCP_BUF->flags |= TCP_SYN; UIP_TCP_BUF->flags |= TCP_SYN;
#else /* UIP_ACTIVE_OPEN */ #else /* UIP_ACTIVE_OPEN */
tcp_send_synack: tcp_send_synack:
UIP_TCP_BUF->flags = TCP_SYN | TCP_ACK; UIP_TCP_BUF->flags = TCP_SYN | TCP_ACK;
#endif /* UIP_ACTIVE_OPEN */ #endif /* UIP_ACTIVE_OPEN */
/* We send out the TCP Maximum Segment Size option with our /* We send out the TCP Maximum Segment Size option with our
SYNACK. */ SYNACK. */
UIP_TCP_BUF->optdata[0] = TCP_OPT_MSS; UIP_TCP_BUF->optdata[0] = TCP_OPT_MSS;
@ -1839,9 +1839,9 @@ uip_process(uint8_t flag)
receive a SYN, in which case we should retransmit our SYNACK receive a SYN, in which case we should retransmit our SYNACK
(which is done futher down). */ (which is done futher down). */
if(!((((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) && if(!((((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) &&
((UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) || ((UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) ||
(((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) && (((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) &&
((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN)))) { ((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN)))) {
if((uip_len > 0 || ((UIP_TCP_BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) && if((uip_len > 0 || ((UIP_TCP_BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) &&
(UIP_TCP_BUF->seqno[0] != uip_connr->rcv_nxt[0] || (UIP_TCP_BUF->seqno[0] != uip_connr->rcv_nxt[0] ||
UIP_TCP_BUF->seqno[1] != uip_connr->rcv_nxt[1] || UIP_TCP_BUF->seqno[1] != uip_connr->rcv_nxt[1] ||
@ -1875,7 +1875,7 @@ uip_process(uint8_t flag)
uip_connr->snd_nxt[1] = uip_acc32[1]; uip_connr->snd_nxt[1] = uip_acc32[1];
uip_connr->snd_nxt[2] = uip_acc32[2]; uip_connr->snd_nxt[2] = uip_acc32[2];
uip_connr->snd_nxt[3] = uip_acc32[3]; uip_connr->snd_nxt[3] = uip_acc32[3];
/* Do RTT estimation, unless we have done retransmissions. */ /* Do RTT estimation, unless we have done retransmissions. */
if(uip_connr->nrtx == 0) { if(uip_connr->nrtx == 0) {
signed char m; signed char m;
@ -1899,7 +1899,7 @@ uip_process(uint8_t flag)
/* Reset length of outstanding data. */ /* Reset length of outstanding data. */
uip_connr->len = 0; uip_connr->len = 0;
} }
} }
/* Do different things depending on in what state the connection is. */ /* Do different things depending on in what state the connection is. */
@ -1927,7 +1927,7 @@ uip_process(uint8_t flag)
} }
/* We need to retransmit the SYNACK */ /* We need to retransmit the SYNACK */
if((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN) { if((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN) {
goto tcp_send_synack; goto tcp_send_synack;
} }
goto drop; goto drop;
#if UIP_ACTIVE_OPEN #if UIP_ACTIVE_OPEN
@ -1991,7 +1991,7 @@ uip_process(uint8_t flag)
uip_conn->tcpstateflags = UIP_CLOSED; uip_conn->tcpstateflags = UIP_CLOSED;
goto reset; goto reset;
#endif /* UIP_ACTIVE_OPEN */ #endif /* UIP_ACTIVE_OPEN */
case UIP_ESTABLISHED: case UIP_ESTABLISHED:
/* In the ESTABLISHED state, we call upon the application to feed /* In the ESTABLISHED state, we call upon the application to feed
data into the uip_buf. If the UIP_ACKDATA flag is set, the data into the uip_buf. If the UIP_ACKDATA flag is set, the
@ -2093,7 +2093,7 @@ uip_process(uint8_t flag)
UIP_APPCALL(); UIP_APPCALL();
appsend: appsend:
if(uip_flags & UIP_ABORT) { if(uip_flags & UIP_ABORT) {
uip_slen = 0; uip_slen = 0;
uip_connr->tcpstateflags = UIP_CLOSED; uip_connr->tcpstateflags = UIP_CLOSED;
@ -2145,7 +2145,7 @@ uip_process(uint8_t flag)
uip_connr->nrtx = 0; uip_connr->nrtx = 0;
apprexmit: apprexmit:
uip_appdata = uip_sappdata; uip_appdata = uip_sappdata;
/* If the application has data to be sent, or if the incoming /* If the application has data to be sent, or if the incoming
packet had new data in it, we must send out a packet. */ packet had new data in it, we must send out a packet. */
if(uip_slen > 0 && uip_connr->len > 0) { if(uip_slen > 0 && uip_connr->len > 0) {
@ -2174,7 +2174,7 @@ uip_process(uint8_t flag)
UIP_APPCALL(); UIP_APPCALL();
} }
break; break;
case UIP_FIN_WAIT_1: case UIP_FIN_WAIT_1:
/* The application has closed the connection, but the remote host /* The application has closed the connection, but the remote host
hasn't closed its end yet. Thus we do nothing but wait for a hasn't closed its end yet. Thus we do nothing but wait for a
@ -2203,7 +2203,7 @@ uip_process(uint8_t flag)
goto tcp_send_ack; goto tcp_send_ack;
} }
goto drop; goto drop;
case UIP_FIN_WAIT_2: case UIP_FIN_WAIT_2:
if(uip_len > 0) { if(uip_len > 0) {
uip_add_rcv_nxt(uip_len); uip_add_rcv_nxt(uip_len);
@ -2223,7 +2223,7 @@ uip_process(uint8_t flag)
case UIP_TIME_WAIT: case UIP_TIME_WAIT:
goto tcp_send_ack; goto tcp_send_ack;
case UIP_CLOSING: case UIP_CLOSING:
if(uip_flags & UIP_ACKDATA) { if(uip_flags & UIP_ACKDATA) {
uip_connr->tcpstateflags = UIP_TIME_WAIT; uip_connr->tcpstateflags = UIP_TIME_WAIT;
@ -2231,7 +2231,7 @@ uip_process(uint8_t flag)
} }
} }
goto drop; goto drop;
/* We jump here when we are ready to send the packet, and just want /* We jump here when we are ready to send the packet, and just want
to set the appropriate TCP sequence numbers in the TCP header. */ to set the appropriate TCP sequence numbers in the TCP header. */
tcp_send_ack: tcp_send_ack:
@ -2249,12 +2249,12 @@ uip_process(uint8_t flag)
packet. */ packet. */
tcp_send: tcp_send:
PRINTF("In tcp_send\n"); PRINTF("In tcp_send\n");
UIP_TCP_BUF->ackno[0] = uip_connr->rcv_nxt[0]; UIP_TCP_BUF->ackno[0] = uip_connr->rcv_nxt[0];
UIP_TCP_BUF->ackno[1] = uip_connr->rcv_nxt[1]; UIP_TCP_BUF->ackno[1] = uip_connr->rcv_nxt[1];
UIP_TCP_BUF->ackno[2] = uip_connr->rcv_nxt[2]; UIP_TCP_BUF->ackno[2] = uip_connr->rcv_nxt[2];
UIP_TCP_BUF->ackno[3] = uip_connr->rcv_nxt[3]; UIP_TCP_BUF->ackno[3] = uip_connr->rcv_nxt[3];
UIP_TCP_BUF->seqno[0] = uip_connr->snd_nxt[0]; UIP_TCP_BUF->seqno[0] = uip_connr->snd_nxt[0];
UIP_TCP_BUF->seqno[1] = uip_connr->snd_nxt[1]; UIP_TCP_BUF->seqno[1] = uip_connr->snd_nxt[1];
UIP_TCP_BUF->seqno[2] = uip_connr->snd_nxt[2]; UIP_TCP_BUF->seqno[2] = uip_connr->snd_nxt[2];
@ -2288,7 +2288,7 @@ uip_process(uint8_t flag)
UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
UIP_TCP_BUF->urgp[0] = UIP_TCP_BUF->urgp[1] = 0; UIP_TCP_BUF->urgp[0] = UIP_TCP_BUF->urgp[1] = 0;
/* Calculate TCP checksum. */ /* Calculate TCP checksum. */
UIP_TCP_BUF->tcpchksum = 0; UIP_TCP_BUF->tcpchksum = 0;
UIP_TCP_BUF->tcpchksum = ~(uip_tcpchksum()); UIP_TCP_BUF->tcpchksum = ~(uip_tcpchksum());
@ -2304,7 +2304,7 @@ uip_process(uint8_t flag)
send: send:
PRINTF("Sending packet with length %d (%d)\n", uip_len, PRINTF("Sending packet with length %d (%d)\n", uip_len,
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]); (UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
UIP_STAT(++uip_stat.ip.sent); UIP_STAT(++uip_stat.ip.sent);
/* Return and let the caller do the actual transmission. */ /* Return and let the caller do the actual transmission. */
uip_flags = 0; uip_flags = 0;

View file

@ -106,7 +106,11 @@ static int we_are_receiving_burst = 0;
/* INTER_PACKET_DEADLINE is the maximum time a receiver waits for the /* INTER_PACKET_DEADLINE is the maximum time a receiver waits for the
next packet of a burst when FRAME_PENDING is set. */ next packet of a burst when FRAME_PENDING is set. */
#ifdef CONTIKIMAC_CONF_INTER_PACKET_DEADLINE
#define INTER_PACKET_DEADLINE CONTIKIMAC_CONF_INTER_PACKET_DEADLINE
#else
#define INTER_PACKET_DEADLINE CLOCK_SECOND / 32 #define INTER_PACKET_DEADLINE CLOCK_SECOND / 32
#endif
/* ContikiMAC performs periodic channel checks. Each channel check /* ContikiMAC performs periodic channel checks. Each channel check
consists of two or more CCA checks. CCA_COUNT_MAX is the number of consists of two or more CCA checks. CCA_COUNT_MAX is the number of
@ -166,12 +170,21 @@ static int we_are_receiving_burst = 0;
/* MAX_SILENCE_PERIODS is the maximum amount of periods (a period is /* MAX_SILENCE_PERIODS is the maximum amount of periods (a period is
CCA_CHECK_TIME + CCA_SLEEP_TIME) that we allow to be silent before CCA_CHECK_TIME + CCA_SLEEP_TIME) that we allow to be silent before
we turn of the radio. */ we turn of the radio. */
#ifdef CONTIKIMAC_CONF_MAX_SILENCE_PERIODS
#define MAX_SILENCE_PERIODS CONTIKIMAC_CONF_MAX_SILENCE_PERIODS
#else
#define MAX_SILENCE_PERIODS 5 #define MAX_SILENCE_PERIODS 5
#endif
/* MAX_NONACTIVITY_PERIODS is the maximum number of periods we allow /* MAX_NONACTIVITY_PERIODS is the maximum number of periods we allow
the radio to be turned on without any packet being received, when the radio to be turned on without any packet being received, when
WITH_FAST_SLEEP is enabled. */ WITH_FAST_SLEEP is enabled. */
#ifdef CONTIKIMAC_CONF_MAX_NONACTIVITY_PERIODS
#define MAX_NONACTIVITY_PERIODS CONTIKIMAC_CONF_MAX_NONACTIVITY_PERIODS
#else
#define MAX_NONACTIVITY_PERIODS 10 #define MAX_NONACTIVITY_PERIODS 10
#endif
@ -181,7 +194,11 @@ static int we_are_receiving_burst = 0;
/* GUARD_TIME is the time before the expected phase of a neighbor that /* GUARD_TIME is the time before the expected phase of a neighbor that
a transmitted should begin transmitting packets. */ a transmitted should begin transmitting packets. */
#ifdef CONTIKIMAC_CONF_GUARD_TIME
#define GUARD_TIME CONTIKIMAC_CONF_GUARD_TIME
#else
#define GUARD_TIME 10 * CHECK_TIME + CHECK_TIME_TX #define GUARD_TIME 10 * CHECK_TIME + CHECK_TIME_TX
#endif
/* INTER_PACKET_INTERVAL is the interval between two successive packet transmissions */ /* INTER_PACKET_INTERVAL is the interval between two successive packet transmissions */
#ifdef CONTIKIMAC_CONF_INTER_PACKET_INTERVAL #ifdef CONTIKIMAC_CONF_INTER_PACKET_INTERVAL
@ -201,7 +218,11 @@ static int we_are_receiving_burst = 0;
/* MAX_PHASE_STROBE_TIME is the time that we transmit repeated packets /* MAX_PHASE_STROBE_TIME is the time that we transmit repeated packets
to a neighbor for which we have a phase lock. */ to a neighbor for which we have a phase lock. */
#ifdef CONTIKIMAC_CONF_MAX_PHASE_STROBE_TIME
#define MAX_PHASE_STROBE_TIME CONTIKIMAC_CONF_MAX_PHASE_STROBE_TIME
#else
#define MAX_PHASE_STROBE_TIME RTIMER_ARCH_SECOND / 60 #define MAX_PHASE_STROBE_TIME RTIMER_ARCH_SECOND / 60
#endif
#ifdef CONTIKIMAC_CONF_SEND_SW_ACK #ifdef CONTIKIMAC_CONF_SEND_SW_ACK
#define CONTIKIMAC_SEND_SW_ACK CONTIKIMAC_CONF_SEND_SW_ACK #define CONTIKIMAC_SEND_SW_ACK CONTIKIMAC_CONF_SEND_SW_ACK

View file

@ -68,6 +68,27 @@ static const uint8_t bitmask[9] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
#define PRINTF(...) #define PRINTF(...)
#endif #endif
/*---------------------------------------------------------------------------*/
/* For get_bits/set_bits functions in this file to work correctly,
* the values contained in packetbuf_attr_t variables (uint16_t internally)
* must be in little endian byte order.
*/
/* Write little endian 16 bit value */
static void CC_INLINE
le16_write(void *ptr, uint16_t v)
{
uint8_t *p = (uint8_t *)ptr;
p[0] = v & 0xff;
p[1] = v >> 8;
}
/*---------------------------------------------------------------------------*/
/* Read little endian 16 bit value */
static uint16_t CC_INLINE
le16_read(const void *ptr)
{
const uint8_t *p = (const uint8_t *)ptr;
return ((uint16_t)p[1] << 8) | p[0];
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
uint8_t CC_INLINE uint8_t CC_INLINE
get_bits_in_byte(uint8_t *from, int bitpos, int vallen) get_bits_in_byte(uint8_t *from, int bitpos, int vallen)
@ -279,10 +300,10 @@ pack_header(struct channel *c)
((uint8_t *)packetbuf_addr(a->type))[0], ((uint8_t *)packetbuf_addr(a->type))[0],
((uint8_t *)packetbuf_addr(a->type))[1]); ((uint8_t *)packetbuf_addr(a->type))[1]);
} else { } else {
packetbuf_attr_t val; uint8_t buffer[2];
val = packetbuf_attr(a->type); packetbuf_attr_t val = packetbuf_attr(a->type);
set_bits(&hdrptr[byteptr], bitptr & 7, le16_write(buffer, val);
(uint8_t *)&val, len); set_bits(&hdrptr[byteptr], bitptr & 7, buffer, len);
PRINTF("value %d\n", PRINTF("value %d\n",
/*linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1],*/ /*linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1],*/
val); val);
@ -349,9 +370,10 @@ unpack_header(void)
a->type, addr.u8[0], addr.u8[1]); a->type, addr.u8[0], addr.u8[1]);
packetbuf_set_addr(a->type, &addr); packetbuf_set_addr(a->type, &addr);
} else { } else {
packetbuf_attr_t val = 0; packetbuf_attr_t val;
get_bits((uint8_t *)&val, &hdrptr[byteptr], bitptr & 7, len); uint8_t buffer[2] = {0};
get_bits(buffer, &hdrptr[byteptr], bitptr & 7, len);
val = le16_read(buffer);
packetbuf_set_attr(a->type, val); packetbuf_set_attr(a->type, val);
PRINTF("%d.%d: unpack_header type %d, val %d\n", PRINTF("%d.%d: unpack_header type %d, val %d\n",
linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1], linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1],

View file

@ -238,7 +238,7 @@
/* /*
* RPL probing. When enabled, probes will be sent periodically to keep * RPL probing. When enabled, probes will be sent periodically to keep
* parent link estimates up to date. * parent link estimates up to date.
* */ */
#ifdef RPL_CONF_WITH_PROBING #ifdef RPL_CONF_WITH_PROBING
#define RPL_WITH_PROBING RPL_CONF_WITH_PROBING #define RPL_WITH_PROBING RPL_CONF_WITH_PROBING
#else #else
@ -247,7 +247,7 @@
/* /*
* RPL probing interval. * RPL probing interval.
* */ */
#ifdef RPL_CONF_PROBING_INTERVAL #ifdef RPL_CONF_PROBING_INTERVAL
#define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL #define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL
#else #else
@ -256,7 +256,7 @@
/* /*
* RPL probing expiration time. * RPL probing expiration time.
* */ */
#ifdef RPL_CONF_PROBING_EXPIRATION_TIME #ifdef RPL_CONF_PROBING_EXPIRATION_TIME
#define RPL_PROBING_EXPIRATION_TIME RPL_CONF_PROBING_EXPIRATION_TIME #define RPL_PROBING_EXPIRATION_TIME RPL_CONF_PROBING_EXPIRATION_TIME
#else #else
@ -265,7 +265,7 @@
/* /*
* Function used to select the next parent to be probed. * Function used to select the next parent to be probed.
* */ */
#ifdef RPL_CONF_PROBING_SELECT_FUNC #ifdef RPL_CONF_PROBING_SELECT_FUNC
#define RPL_PROBING_SELECT_FUNC RPL_CONF_PROBING_SELECT_FUNC #define RPL_PROBING_SELECT_FUNC RPL_CONF_PROBING_SELECT_FUNC
#else #else
@ -279,7 +279,7 @@
* To probe with DIS, use: * To probe with DIS, use:
* #define RPL_CONF_PROBING_SEND_FUNC(instance, addr) dis_output((addr)) * #define RPL_CONF_PROBING_SEND_FUNC(instance, addr) dis_output((addr))
* Any other custom probing function is also acceptable. * Any other custom probing function is also acceptable.
* */ */
#ifdef RPL_CONF_PROBING_SEND_FUNC #ifdef RPL_CONF_PROBING_SEND_FUNC
#define RPL_PROBING_SEND_FUNC RPL_CONF_PROBING_SEND_FUNC #define RPL_PROBING_SEND_FUNC RPL_CONF_PROBING_SEND_FUNC
#else #else
@ -288,7 +288,7 @@
/* /*
* Function used to calculate next RPL probing interval * Function used to calculate next RPL probing interval
* */ */
#ifdef RPL_CONF_PROBING_DELAY_FUNC #ifdef RPL_CONF_PROBING_DELAY_FUNC
#define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC #define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC
#else #else
@ -296,4 +296,22 @@
+ random_rand() % (RPL_PROBING_INTERVAL)) + random_rand() % (RPL_PROBING_INTERVAL))
#endif #endif
/*
* Interval of DIS transmission
*/
#ifdef RPL_CONF_DIS_INTERVAL
#define RPL_DIS_INTERVAL RPL_CONF_DIS_INTERVAL
#else
#define RPL_DIS_INTERVAL 60
#endif
/*
* Added delay of first DIS transmission after boot
*/
#ifdef RPL_CONF_DIS_START_DELAY
#define RPL_DIS_START_DELAY RPL_CONF_DIS_START_DELAY
#else
#define RPL_DIS_START_DELAY 5
#endif
#endif /* RPL_CONF_H */ #endif /* RPL_CONF_H */

View file

@ -729,7 +729,7 @@ dao_input(void)
PRINT6ADDR(&prefix); PRINT6ADDR(&prefix);
PRINTF("\n"); PRINTF("\n");
rep->state.nopath_received = 1; rep->state.nopath_received = 1;
rep->state.lifetime = DAO_EXPIRATION_TIMEOUT; rep->state.lifetime = RPL_NOPATH_REMOVAL_DELAY;
/* We forward the incoming no-path DAO to our parent, if we have /* We forward the incoming no-path DAO to our parent, if we have
one. */ one. */

View file

@ -103,12 +103,19 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Default values for RPL constants and variables. */ /* Default values for RPL constants and variables. */
/* The default value for the DAO timer. */ /* DAO transmissions are always delayed by RPL_DAO_DELAY +/- RPL_DAO_DELAY/2 */
#ifdef RPL_CONF_DAO_LATENCY #ifdef RPL_CONF_DAO_DELAY
#define RPL_DAO_LATENCY RPL_CONF_DAO_LATENCY #define RPL_DAO_DELAY RPL_CONF_DAO_DELAY
#else /* RPL_CONF_DAO_LATENCY */ #else /* RPL_CONF_DAO_DELAY */
#define RPL_DAO_LATENCY (CLOCK_SECOND * 4) #define RPL_DAO_DELAY (CLOCK_SECOND * 4)
#endif /* RPL_DAO_LATENCY */ #endif /* RPL_CONF_DAO_DELAY */
/* Delay between reception of a no-path DAO and actual route removal */
#ifdef RPL_CONF_NOPATH_REMOVAL_DELAY
#define RPL_NOPATH_REMOVAL_DELAY RPL_CONF_NOPATH_REMOVAL_DELAY
#else /* RPL_CONF_NOPATH_REMOVAL_DELAY */
#define RPL_NOPATH_REMOVAL_DELAY 60
#endif /* RPL_CONF_NOPATH_REMOVAL_DELAY */
/* Special value indicating immediate removal. */ /* Special value indicating immediate removal. */
#define RPL_ZERO_LIFETIME 0 #define RPL_ZERO_LIFETIME 0
@ -134,9 +141,6 @@
#define INFINITE_RANK 0xffff #define INFINITE_RANK 0xffff
/* Expire DAOs from neighbors that do not respond in this time. (seconds) */
#define DAO_EXPIRATION_TIMEOUT 60
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define RPL_INSTANCE_LOCAL_FLAG 0x80 #define RPL_INSTANCE_LOCAL_FLAG 0x80
#define RPL_INSTANCE_D_FLAG 0x40 #define RPL_INSTANCE_D_FLAG 0x40
@ -184,12 +188,7 @@
/* DIS related */ /* DIS related */
#define RPL_DIS_SEND 1 #define RPL_DIS_SEND 1
#ifdef RPL_DIS_INTERVAL_CONF
#define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
#else
#define RPL_DIS_INTERVAL 60
#endif
#define RPL_DIS_START_DELAY 5
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Lollipop counters */ /* Lollipop counters */

View file

@ -312,7 +312,7 @@ schedule_dao(rpl_instance_t *instance, clock_time_t latency)
void void
rpl_schedule_dao(rpl_instance_t *instance) rpl_schedule_dao(rpl_instance_t *instance)
{ {
schedule_dao(instance, RPL_DAO_LATENCY); schedule_dao(instance, RPL_DAO_DELAY);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void

File diff suppressed because it is too large Load diff

View file

@ -49,7 +49,7 @@
#define RADIO_SPI_CLK_FREQ 4000000 // 4 MHz SPI CLK for radio interface #define RADIO_SPI_CLK_FREQ 4000000 // 4 MHz SPI CLK for radio interface
#define SYSTEM_UCLK 16000000 // 16 MHz UCLK #define SYSTEM_UCLK 16000000 // 16 MHz UCLK
// Default Radio Parameters // Default Radio Parameters
#define DEFAULT_CHNL_FREQ 915000000 #define DEFAULT_CHNL_FREQ 915000000
#define FREQ_CNVRT_VAL 0.00252061538 #define FREQ_CNVRT_VAL 0.00252061538
// Defines for radio memory mapped areas // Defines for radio memory mapped areas
#define PACKETRAM_START 0x10 #define PACKETRAM_START 0x10
@ -68,14 +68,14 @@
#define MCR_rssi_readback_Adr 0x312 #define MCR_rssi_readback_Adr 0x312
#define MCR_gpio_configure_Adr 0x3fa #define MCR_gpio_configure_Adr 0x3fa
#define MCR_ext_uc_clk_divide_Adr 0x32e #define MCR_ext_uc_clk_divide_Adr 0x32e
#define MCR_interrupt_source_0_Adr 0x336 #define MCR_interrupt_source_0_Adr 0x336
#define MCR_interrupt_source_1_Adr 0x337 #define MCR_interrupt_source_1_Adr 0x337
// Macros for manual GPIO checking of Radio MISO pin P2.0 (SPI0) // Macros for manual GPIO checking of Radio MISO pin P2.0 (SPI0)
#define RADIO_MISO_IN GP2IN_IN0_BBA #define RADIO_MISO_IN GP2IN_IN0_BBA
// Macros for manual GPIO control of P2.3 (Radio SPI CS) (SPI0) // Macros for manual GPIO control of P2.3 (Radio SPI CS) (SPI0)
#define RADIO_CSN_DEASSERT (pADI_GP2->GPSET = GP2SET_SET3) #define RADIO_CSN_DEASSERT (pADI_GP2->GPSET = GP2SET_SET3)
#define RADIO_CSN_ASSERT (pADI_GP2->GPCLR = GP2CLR_CLR3) #define RADIO_CSN_ASSERT (pADI_GP2->GPCLR = GP2CLR_CLR3)
// Macros for Sending\Receiving single bytes via SPI // Macros for Sending\Receiving single bytes via SPI
#define SEND_SPI(x) pADI_SPI0->SPITX = x #define SEND_SPI(x) pADI_SPI0->SPITX = x
#define WAIT_SPI_RX while((pADI_SPI0->SPISTA & SPISTA_RXFSTA_MSK) == 0x0); #define WAIT_SPI_RX while((pADI_SPI0->SPISTA & SPISTA_RXFSTA_MSK) == 0x0);
@ -92,7 +92,7 @@
/*************************************************************************/ /*************************************************************************/
/* Radio Command Codes */ /* Radio Command Codes */
/*************************************************************************/ /*************************************************************************/
typedef enum typedef enum
{ {
CMD_SYNC = 0xA2, // Synchronizatio CMD_SYNC = 0xA2, // Synchronizatio
CMD_PHY_OFF = 0xB0, // Transition to state PHY_OFF CMD_PHY_OFF = 0xB0, // Transition to state PHY_OFF
@ -137,54 +137,54 @@ typedef enum
/*************************************************************************/ /*************************************************************************/
/* Radio Configuration Structure */ /* Radio Configuration Structure */
/*************************************************************************/ /*************************************************************************/
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\var TyRadioConfiguration \var TyRadioConfiguration
**/ **/
typedef struct typedef struct
{ {
RIE_U8 interrupt_mask_0_r; // 0x100 RIE_U8 interrupt_mask_0_r; // 0x100
RIE_U8 cfg_101_r; // 0x101 RIE_U8 cfg_101_r; // 0x101
RIE_U8 cfg_102_r; // 0x102 RIE_U8 cfg_102_r; // 0x102
RIE_U8 cfg_103_r; // 0x103 RIE_U8 cfg_103_r; // 0x103
RIE_U8 cfg_104_r; // 0x104 RIE_U8 cfg_104_r; // 0x104
RIE_U8 cfg_105_r; // 0x105 RIE_U8 cfg_105_r; // 0x105
RIE_U8 cfg_106_r; // 0x106 RIE_U8 cfg_106_r; // 0x106
RIE_U8 cfg_107_r; // 0x107 RIE_U8 cfg_107_r; // 0x107
RIE_U8 cfg_108_r; // 0x108 RIE_U8 cfg_108_r; // 0x108
RIE_U8 channel_freq_0_r; // 0x109 RIE_U8 channel_freq_0_r; // 0x109
RIE_U8 channel_freq_1_r; // 0x10A RIE_U8 channel_freq_1_r; // 0x10A
RIE_U8 channel_freq_2_r; // 0x10B RIE_U8 channel_freq_2_r; // 0x10B
RIE_U8 cfg_10C_r; // 0x10C RIE_U8 cfg_10C_r; // 0x10C
RIE_U8 cfg_10D_r; // 0x10D RIE_U8 cfg_10D_r; // 0x10D
RIE_U8 cfg_10E_r; // 0x10E RIE_U8 cfg_10E_r; // 0x10E
RIE_U8 cfg_10F_r; // 0x10F RIE_U8 cfg_10F_r; // 0x10F
RIE_U8 cfg_110_r; // 0x110 RIE_U8 cfg_110_r; // 0x110
RIE_U8 cfg_111_r; // 0x111 RIE_U8 cfg_111_r; // 0x111
RIE_U8 cfg_112_r; // 0x112 RIE_U8 cfg_112_r; // 0x112
RIE_U8 cfg_113_r; // 0x113 RIE_U8 cfg_113_r; // 0x113
RIE_U8 radio_cfg_8_r; // 0x114 RIE_U8 radio_cfg_8_r; // 0x114
RIE_U8 radio_cfg_9_r; // 0x115 RIE_U8 radio_cfg_9_r; // 0x115
RIE_U8 cfg_116_r; // 0x116 RIE_U8 cfg_116_r; // 0x116
RIE_U8 cfg_117_r; // 0x117 RIE_U8 cfg_117_r; // 0x117
RIE_U8 image_reject_cal_phase_r; // 0x118 RIE_U8 image_reject_cal_phase_r; // 0x118
RIE_U8 image_reject_cal_amplitude_r; // 0x119 RIE_U8 image_reject_cal_amplitude_r; // 0x119
RIE_U8 cfg_11A_r; // 0x11A RIE_U8 cfg_11A_r; // 0x11A
RIE_U8 cfg_11B_r; // 0x11B RIE_U8 cfg_11B_r; // 0x11B
RIE_U8 symbol_mode_r; // 0x11C RIE_U8 symbol_mode_r; // 0x11C
RIE_U8 cfg_11D_r; // 0x11D RIE_U8 cfg_11D_r; // 0x11D
RIE_U8 cfg_11E_r; // 0x11E RIE_U8 cfg_11E_r; // 0x11E
RIE_U8 cfg_11F_r; // 0x11F RIE_U8 cfg_11F_r; // 0x11F
RIE_U8 cfg_120_r; // 0x120 RIE_U8 cfg_120_r; // 0x120
RIE_U8 cfg_121_r; // 0x121 RIE_U8 cfg_121_r; // 0x121
RIE_U8 cfg_122_r; // 0x122 RIE_U8 cfg_122_r; // 0x122
RIE_U8 cfg_123_r; // 0x123 RIE_U8 cfg_123_r; // 0x123
RIE_U8 tx_base_adr_r; // 0x124 RIE_U8 tx_base_adr_r; // 0x124
RIE_U8 rx_base_adr_r; // 0x125 RIE_U8 rx_base_adr_r; // 0x125
RIE_U8 packet_length_control_r; // 0x126 RIE_U8 packet_length_control_r; // 0x126
RIE_U8 packet_length_max_r; // 0x127 RIE_U8 packet_length_max_r; // 0x127
RIE_U8 cfg_128_r; // 0x128 RIE_U8 cfg_128_r; // 0x128
RIE_U8 cfg_129_r; // 0x129 RIE_U8 cfg_129_r; // 0x129
RIE_U8 cfg_12A_r; // 0x12A RIE_U8 cfg_12A_r; // 0x12A
RIE_U8 cfg_12B_r; // 0x12B RIE_U8 cfg_12B_r; // 0x12B
RIE_U8 cfg_12C_r; // 0x12C RIE_U8 cfg_12C_r; // 0x12C
@ -205,14 +205,14 @@ typedef struct
RIE_U8 cfg_13B_r; // 0x13B RIE_U8 cfg_13B_r; // 0x13B
RIE_U8 cfg_13C_r; // 0x13C RIE_U8 cfg_13C_r; // 0x13C
RIE_U8 cfg_13D_r; // 0x13D RIE_U8 cfg_13D_r; // 0x13D
RIE_U8 cfg_13E_r; // 0x13E RIE_U8 cfg_13E_r; // 0x13E
RIE_U8 cfg_13F_r; // 0x13F RIE_U8 cfg_13F_r; // 0x13F
} TyRadioConfiguration; } TyRadioConfiguration;
/*************************************************************************/ /*************************************************************************/
/* Radio Configuration Constants */ /* Radio Configuration Constants */
/*************************************************************************/ /*************************************************************************/
#define interrupt_mask_0_interrupt_tx_eof (0x1 << 4) #define interrupt_mask_0_interrupt_tx_eof (0x1 << 4)
#define interrupt_mask_0_interrupt_crc_correct (0x1 << 2) #define interrupt_mask_0_interrupt_crc_correct (0x1 << 2)
#define packet_length_control_length_offset_offset (0) #define packet_length_control_length_offset_offset (0)
#define packet_length_control_length_offset_minus0 (0x4 << packet_length_control_length_offset_offset) #define packet_length_control_length_offset_minus0 (0x4 << packet_length_control_length_offset_offset)
@ -237,7 +237,7 @@ typedef struct
#define radio_cfg_8_pa_power_setting_63 (0xF << radio_cfg_8_pa_power_offset) #define radio_cfg_8_pa_power_setting_63 (0xF << radio_cfg_8_pa_power_offset)
#define radio_cfg_8_pa_ramp_numbits (3) #define radio_cfg_8_pa_ramp_numbits (3)
#define radio_cfg_8_pa_ramp_offset (0) #define radio_cfg_8_pa_ramp_offset (0)
#define radio_cfg_8_pa_ramp_16 (0x5 << radio_cfg_8_pa_ramp_offset) #define radio_cfg_8_pa_ramp_16 (0x5 << radio_cfg_8_pa_ramp_offset)
#define radio_cfg_9_demod_scheme_offset (0) #define radio_cfg_9_demod_scheme_offset (0)
#define radio_cfg_9_demod_scheme_FSK (0x0 << radio_cfg_9_demod_scheme_offset) #define radio_cfg_9_demod_scheme_FSK (0x0 << radio_cfg_9_demod_scheme_offset)
@ -256,13 +256,13 @@ typedef struct
/* Local Variables */ /* Local Variables */
/*************************************************************************/ /*************************************************************************/
static TyRadioConfiguration RadioConfiguration; static TyRadioConfiguration RadioConfiguration;
static RIE_BOOL bRadioConfigurationChanged = RIE_FALSE; static RIE_BOOL bRadioConfigurationChanged = RIE_FALSE;
static RIE_BOOL bTestModeEnabled = RIE_FALSE; static RIE_BOOL bTestModeEnabled = RIE_FALSE;
static RIE_U32 DataRate = 38400; static RIE_U32 DataRate = 38400;
static volatile RIE_BOOL bPacketTx = RIE_FALSE; static volatile RIE_BOOL bPacketTx = RIE_FALSE;
static volatile RIE_BOOL bPacketRx = RIE_FALSE; static volatile RIE_BOOL bPacketRx = RIE_FALSE;
const RIE_U8 DR_38_4kbps_Dev20kHz_Configuration[] = const RIE_U8 DR_38_4kbps_Dev20kHz_Configuration[] =
{ {
0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21, 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21,
@ -272,11 +272,11 @@ const RIE_U8 DR_38_4kbps_Dev20kHz_Configuration[] =
0x40,0x0C,0x00,0x0C,0x00,0x00, 0x40,0x0C,0x00,0x0C,0x00,0x00,
0x10,0x00,0xC3,0x36,0x10,0x10,0x24,0xF0,0x2A,0x00,0x2F,0x19,0x5E,0x46,0x5F,0x78, 0x10,0x00,0xC3,0x36,0x10,0x10,0x24,0xF0,0x2A,0x00,0x2F,0x19,0x5E,0x46,0x5F,0x78,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
}; };
const RIE_U8 DR_300_0kbps_Dev75_0kHz_Configuration[] = const RIE_U8 DR_300_0kbps_Dev75_0kHz_Configuration[] =
{ {
0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21, 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21,
@ -291,7 +291,7 @@ const RIE_U8 DR_300_0kbps_Dev75_0kHz_Configuration[] =
const RIE_U8 DR_1_0kbps_Dev10_0kHz_Configuration[] = const RIE_U8 DR_1_0kbps_Dev10_0kHz_Configuration[] =
{ {
0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21, 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x76,0x62,0x21,
// 0 1 2 3 4 5 6 7 8 9 A B // 0 1 2 3 4 5 6 7 8 9 A B
@ -312,8 +312,8 @@ static RIE_Responses RadioSendCommandBytes (RIE_U8 * pCmdBytes,
RIE_U8 NumBytes); RIE_U8 NumBytes);
static RIE_Responses RadioSendCommandNoWait (Radio_CmdCodes CmdCode); static RIE_Responses RadioSendCommandNoWait (Radio_CmdCodes CmdCode);
static RIE_Responses RadioSendCommandWait (Radio_CmdCodes CmdCode); static RIE_Responses RadioSendCommandWait (Radio_CmdCodes CmdCode);
static RIE_Responses RadioMMapRead (RIE_U32 ulAdr, static RIE_Responses RadioMMapRead (RIE_U32 ulAdr,
RIE_U32 ulLen, RIE_U32 ulLen,
RIE_U8 * pData); RIE_U8 * pData);
static RIE_Responses RadioMMapWrite (RIE_U32 ulAdr, static RIE_Responses RadioMMapWrite (RIE_U32 ulAdr,
RIE_U32 ulLen, RIE_U32 ulLen,
@ -337,7 +337,7 @@ static RIE_Responses RadioWaitOnCmdLdr (void);
@brief Return the Radio Interface Engine API Version @brief Return the Radio Interface Engine API Version
@param pVersion :{} @param pVersion :{}
pVersion Storage for Radio Interface Engine API version. pVersion Storage for Radio Interface Engine API version.
@code @code
RIE_U32 Version; RIE_U32 Version;
Response = RadioGetAPIVersion(&Version); Response = RadioGetAPIVersion(&Version);
@endcode @endcode
@ -361,8 +361,8 @@ RIE_Responses RadioGetAPIVersion(RIE_U32 *pVersion)
- DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation. - DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
- DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation. - DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
- DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation. - DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
@pre @pre
RadioInit() must be called before this function is called. RadioInit() must be called before this function is called.
@return RIE_Responses Error code. @return RIE_Responses Error code.
**/ **/
@ -388,7 +388,7 @@ RIE_Responses RadioSwitchConfig(RIE_BaseConfigs BaseConfig)
- DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation. - DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
- DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation. - DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
- DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation. - DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
@note @note
This must be called before any other function is called. This must be called before any other function is called.
@return RIE_Responses Error code. @return RIE_Responses Error code.
**/ **/
@ -401,13 +401,13 @@ RIE_Responses RadioInit(RIE_BaseConfigs BaseConfig)
NVIC_DisableIRQ(UHFTRX_IRQn); NVIC_DisableIRQ(UHFTRX_IRQn);
// Initialise GPIO Port 2 for Radio Use // Initialise GPIO Port 2 for Radio Use
pADI_GP2->GPCON = GP2CON_CON0_SPI0MISO | GP2CON_CON1_SPI0SCLK | pADI_GP2->GPCON = GP2CON_CON0_SPI0MISO | GP2CON_CON1_SPI0SCLK |
GP2CON_CON2_SPI0MOSI | GP2CON_CON3_GPIO | GP2CON_CON2_SPI0MOSI | GP2CON_CON3_GPIO |
GP2CON_CON4_IRQ8 | GP2CON_CON5_GPIO | GP2CON_CON4_IRQ8 | GP2CON_CON5_GPIO |
GP2CON_CON6_GPIO | GP2CON_CON7_GPIOIRQ7; GP2CON_CON6_GPIO | GP2CON_CON7_GPIOIRQ7;
pADI_GP2->GPOEN = GP2OEN_OEN0_IN | GP2OEN_OEN1_IN | pADI_GP2->GPOEN = GP2OEN_OEN0_IN | GP2OEN_OEN1_IN |
GP2OEN_OEN2_IN | GP2OEN_OEN3_OUT | GP2OEN_OEN2_IN | GP2OEN_OEN3_OUT |
GP2OEN_OEN4_IN | GP2OEN_OEN5_IN | GP2OEN_OEN4_IN | GP2OEN_OEN5_IN |
GP2OEN_OEN6_IN | GP2OEN_OEN7_IN; GP2OEN_OEN6_IN | GP2OEN_OEN7_IN;
@ -435,8 +435,8 @@ RIE_Responses RadioInit(RIE_BaseConfigs BaseConfig)
// we enable the Cortex interrupt handling of it // we enable the Cortex interrupt handling of it
if(Response == RIE_Success) if(Response == RIE_Success)
Response = RadioPowerOff(); Response = RadioPowerOff();
// Configure a "high level" radio interrupt ... // Configure a "high level" radio interrupt ...
pADI_INTERRUPT->EI2CFG = EI2CFG_IRQ8MDE_HIGHLEVEL | EI2CFG_IRQ8EN; pADI_INTERRUPT->EI2CFG = EI2CFG_IRQ8MDE_HIGHLEVEL | EI2CFG_IRQ8EN;
// ... and set it up in the NVIC so that our interrupt handler is called // ... and set it up in the NVIC so that our interrupt handler is called
// when the radio wants our attention. Clear any pre-existing condition // when the radio wants our attention. Clear any pre-existing condition
// before enabling the interrupt. // before enabling the interrupt.
@ -463,7 +463,7 @@ RIE_Responses RadioInit(RIE_BaseConfigs BaseConfig)
/** /**
@fn RIE_U32 RadioDeInit(void) @fn RIE_U32 RadioDeInit(void)
@brief Deinitialise the Radio, and power it down. @brief Deinitialise the Radio, and power it down.
@note @note
This can be called independently of all other functions to power down This can be called independently of all other functions to power down
the radio the radio
@return RIE_Responses Error code. @return RIE_Responses Error code.
@ -477,13 +477,13 @@ RIE_Responses RadioDeInit(void)
NVIC_DisableIRQ(UHFTRX_IRQn); NVIC_DisableIRQ(UHFTRX_IRQn);
// Initialise GPIO Port 2 for Radio Use // Initialise GPIO Port 2 for Radio Use
pADI_GP2->GPCON = GP2CON_CON0_SPI0MISO | GP2CON_CON1_SPI0SCLK | pADI_GP2->GPCON = GP2CON_CON0_SPI0MISO | GP2CON_CON1_SPI0SCLK |
GP2CON_CON2_SPI0MOSI | GP2CON_CON3_GPIO | GP2CON_CON2_SPI0MOSI | GP2CON_CON3_GPIO |
GP2CON_CON4_IRQ8 | GP2CON_CON5_GPIO | GP2CON_CON4_IRQ8 | GP2CON_CON5_GPIO |
GP2CON_CON6_GPIO | GP2CON_CON7_GPIOIRQ7; GP2CON_CON6_GPIO | GP2CON_CON7_GPIOIRQ7;
pADI_GP2->GPOEN = GP2OEN_OEN0_IN | GP2OEN_OEN1_IN | pADI_GP2->GPOEN = GP2OEN_OEN0_IN | GP2OEN_OEN1_IN |
GP2OEN_OEN2_IN | GP2OEN_OEN3_OUT | GP2OEN_OEN2_IN | GP2OEN_OEN3_OUT |
GP2OEN_OEN4_IN | GP2OEN_OEN5_IN | GP2OEN_OEN4_IN | GP2OEN_OEN5_IN |
GP2OEN_OEN6_IN | GP2OEN_OEN7_IN; GP2OEN_OEN6_IN | GP2OEN_OEN7_IN;
@ -512,8 +512,8 @@ RIE_Responses RadioDeInit(void)
/** /**
@fn RIE_Responses RadioPowerOff(void) @fn RIE_Responses RadioPowerOff(void)
@brief Shutdown the radio and place it in its lowest power sleep mode. @brief Shutdown the radio and place it in its lowest power sleep mode.
@pre @pre
RadioInit() must be called before this function is called. RadioInit() must be called before this function is called.
@return RIE_Response Error code. @return RIE_Response Error code.
**/ **/
@ -532,14 +532,14 @@ RIE_Responses RadioPowerOff(void)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTerminateRadioOp(void) @fn RIE_Responses RadioTerminateRadioOp(void)
@brief Terminate a currently running radio RX or TX operation. @brief Terminate a currently running radio RX or TX operation.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12); RIE_Response = RadioRxPacketFixedLen(12);
// Delay for a while waiting for a packet // Delay for a while waiting for a packet
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
{ {
// Abort the waiting // Abort the waiting
@ -557,15 +557,15 @@ RIE_Responses RadioTerminateRadioOp (void)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioSetFrequency(RIE_U32 Frequency) @fn RIE_Responses RadioSetFrequency(RIE_U32 Frequency)
@brief Set frequency for radio communications @brief Set frequency for radio communications
@param Frequency :{431000000-928000000} @param Frequency :{431000000-928000000}
- This must be within the available bands of the radio: - This must be within the available bands of the radio:
- 431000000Hz to 464000000Hz and - 431000000Hz to 464000000Hz and
- 862000000Hz to 928000000Hz. - 862000000Hz to 928000000Hz.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioSetFrequency(915000000); RIE_Response = RadioSetFrequency(915000000);
@endcode @endcode
@ -584,18 +584,18 @@ RIE_Responses RadioSetFrequency(RIE_U32 Frequency)
RadioConfiguration.channel_freq_2_r = (EncodedFrequency >> 16)& 0xFF; RadioConfiguration.channel_freq_2_r = (EncodedFrequency >> 16)& 0xFF;
if (Frequency >= 862000000) if (Frequency >= 862000000)
{ {
RadioConfiguration.image_reject_cal_amplitude_r = 0x07; RadioConfiguration.image_reject_cal_amplitude_r = 0x07;
RadioConfiguration.image_reject_cal_phase_r = 0x16; RadioConfiguration.image_reject_cal_phase_r = 0x16;
} }
else else
{ {
RadioConfiguration.image_reject_cal_amplitude_r = 0x03; RadioConfiguration.image_reject_cal_amplitude_r = 0x03;
RadioConfiguration.image_reject_cal_phase_r = 0x08; RadioConfiguration.image_reject_cal_phase_r = 0x08;
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioSetModulationType(RIE_ModulationTypes ModulationType) @fn RIE_Responses RadioSetModulationType(RIE_ModulationTypes ModulationType)
@brief Set the Radio Transmitter Modulation Type. Can be FSK_Modulation or GFSK_Modulation. @brief Set the Radio Transmitter Modulation Type. Can be FSK_Modulation or GFSK_Modulation.
@param ModulationType :{DR_1_0kbps_Dev10_0kHz , DR_38_4kbps_Dev20kHz ,DR_300_0kbps_Dev75_0kHz } @param ModulationType :{DR_1_0kbps_Dev10_0kHz , DR_38_4kbps_Dev20kHz ,DR_300_0kbps_Dev75_0kHz }
@ -603,7 +603,7 @@ RIE_Responses RadioSetFrequency(RIE_U32 Frequency)
- DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation. - DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
- DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation. - DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioSetModulationType(GFSK_Modulation); Response = RadioSetModulationType(GFSK_Modulation);
@endcode @endcode
@note FSK_Modulation is used by default. @note FSK_Modulation is used by default.
@ -636,31 +636,31 @@ RIE_Responses RadioSetModulationType(RIE_ModulationTypes ModulationType)
if (ucNewRegVal != RadioConfiguration.radio_cfg_9_r ) if (ucNewRegVal != RadioConfiguration.radio_cfg_9_r )
{ {
bRadioConfigurationChanged = RIE_TRUE; bRadioConfigurationChanged = RIE_TRUE;
RadioConfiguration.radio_cfg_9_r = ucNewRegVal; RadioConfiguration.radio_cfg_9_r = ucNewRegVal;
} }
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioPayldManchesterEncode(RIE_BOOL bEnable) @fn RIE_Responses RadioPayldManchesterEncode(RIE_BOOL bEnable)
@brief Enable or Disable Manchester Encoding of payload data. @brief Enable or Disable Manchester Encoding of payload data.
Manchester encoding can be used to ensure a dc-free (zero mean) Manchester encoding can be used to ensure a dc-free (zero mean)
transmission. transmission.
A Binary 0 is mapped to 10, and a Binary 1 is mapped to 01. A Binary 0 is mapped to 10, and a Binary 1 is mapped to 01.
Manchester encoding and decoding are applied to the payload data
and the CRC.
Manchester encoding and decoding are applied to the payload data
and the CRC.
@param bEnable :{RIE_FALSE,RIE_TRUE} @param bEnable :{RIE_FALSE,RIE_TRUE}
- RIE_TRUE if Manchester Encoding is to be enabled. - RIE_TRUE if Manchester Encoding is to be enabled.
- RIE_FALSE if disabled. - RIE_FALSE if disabled.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioPayldManchesterEncode(RIE_TRUE); Response = RadioPayldManchesterEncode(RIE_TRUE);
@endcode @endcode
@ -689,37 +689,37 @@ RIE_Responses RadioPayldManchesterEncode(RIE_BOOL bEnable)
if (ucNewRegVal != RadioConfiguration.symbol_mode_r ) if (ucNewRegVal != RadioConfiguration.symbol_mode_r )
{ {
bRadioConfigurationChanged = RIE_TRUE; bRadioConfigurationChanged = RIE_TRUE;
RadioConfiguration.symbol_mode_r = ucNewRegVal; RadioConfiguration.symbol_mode_r = ucNewRegVal;
} }
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioPayldDataWhitening(RIE_BOOL bEnable) @fn RIE_Responses RadioPayldDataWhitening(RIE_BOOL bEnable)
@brief Enable or Disable Data Whitening of payload data. @brief Enable or Disable Data Whitening of payload data.
Data whitening can be employed to avoid long runs of 1s or 0s Data whitening can be employed to avoid long runs of 1s or 0s
in the transmitted data stream. in the transmitted data stream.
This ensures sufficient bit transitions in the packet, which This ensures sufficient bit transitions in the packet, which
aids in receiver clock and data recovery because the encoding aids in receiver clock and data recovery because the encoding
breaks up long runs of 1s or 0s in the transmit packet. breaks up long runs of 1s or 0s in the transmit packet.
The data, excluding the preamble and sync word, is automatically The data, excluding the preamble and sync word, is automatically
whitened before transmission by XORing the data with an 8-bit whitened before transmission by XORing the data with an 8-bit
pseudorandom sequence. pseudorandom sequence.
At the receiver, the data is XORed with the same pseudorandom At the receiver, the data is XORed with the same pseudorandom
sequence, thereby reversing the whitening. sequence, thereby reversing the whitening.
The linear feedback shift register polynomial used is x7 + x1 + 1. The linear feedback shift register polynomial used is x7 + x1 + 1.
@param bEnable :{RIE_FALSE, RIE_TRUE} @param bEnable :{RIE_FALSE, RIE_TRUE}
- RIE_TRUE if Manchester Encoding is to be enabled. - RIE_TRUE if Manchester Encoding is to be enabled.
- RIE_FALSE if disabled. - RIE_FALSE if disabled.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioPayldDataWhitening(RIE_TRUE); Response = RadioPayldDataWhitening(RIE_TRUE);
@endcode @endcode
@ -748,19 +748,19 @@ RIE_Responses RadioPayldDataWhitening(RIE_BOOL bEnable)
if (ucNewRegVal != RadioConfiguration.symbol_mode_r ) if (ucNewRegVal != RadioConfiguration.symbol_mode_r )
{ {
bRadioConfigurationChanged = RIE_TRUE; bRadioConfigurationChanged = RIE_TRUE;
RadioConfiguration.symbol_mode_r = ucNewRegVal; RadioConfiguration.symbol_mode_r = ucNewRegVal;
} }
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTxPacketFixedLen(RIE_U8 Len, RIE_U8 *pData) @fn RIE_Responses RadioTxPacketFixedLen(RIE_U8 Len, RIE_U8 *pData)
@brief Transmit a fixed length packet. @brief Transmit a fixed length packet.
@param Len :{1-240} Length of packet to be transmitted. @param Len :{1-240} Length of packet to be transmitted.
@param pData :{} Data bytes to be transmitted. @param pData :{} Data bytes to be transmitted.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15); RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
@ -795,13 +795,13 @@ RIE_Responses RadioTxPacketFixedLen(RIE_U8 Len, RIE_U8 *pData)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTxPacketVariableLen(RIE_U8 Len, RIE_U8 *pData) @fn RIE_Responses RadioTxPacketVariableLen(RIE_U8 Len, RIE_U8 *pData)
@brief Transmit a Variable length packet. @brief Transmit a Variable length packet.
@param Len :{1-240} Length of packet to be transmitted. @param Len :{1-240} Length of packet to be transmitted.
@param pData :{} Data bytes to be transmitted. @param pData :{} Data bytes to be transmitted.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15); RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
@ -841,12 +841,12 @@ RIE_Responses RadioTxPacketVariableLen(RIE_U8 Len, RIE_U8 *pData)
} }
/** /**
@fn RIE_BOOL RadioTxPacketComplete(void) @fn RIE_BOOL RadioTxPacketComplete(void)
@brief Checks if a packet has finished transmitting @brief Checks if a packet has finished transmitting
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@pre RadioRxPacketFixedLen() or equivalent should be called first. @pre RadioRxPacketFixedLen() or equivalent should be called first.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15); RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
@ -860,16 +860,16 @@ RIE_BOOL RadioTxPacketComplete (void)
return bPacketTx; return bPacketTx;
} }
/** /**
@fn RIE_Responses RadioTxSetPA(RIE_PATypes PAType,RIE_PAPowerLevel Power) @fn RIE_Responses RadioTxSetPA(RIE_PATypes PAType,RIE_PAPowerLevel Power)
@brief Set PA Type and the Transmit Power Level for Radio Transmission. @brief Set PA Type and the Transmit Power Level for Radio Transmission.
@param PAType :{DifferentialPA, SingleEndedPA} Select Single Ended or Differential PA Type @param PAType :{DifferentialPA, SingleEndedPA} Select Single Ended or Differential PA Type
@param Power :{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3, @param Power :{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3,
PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7, PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7,
PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11, PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11,
PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15} PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15}
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioTxSetPA(SingleEndedPA,PowerLevel8); Response = RadioTxSetPA(SingleEndedPA,PowerLevel8);
@endcode @endcode
@note Differential PA is enabled by default. @note Differential PA is enabled by default.
@ -940,17 +940,17 @@ RIE_Responses RadioTxSetPA(RIE_PATypes PAType,RIE_PAPowerLevel Power)
if (ucNewRegVal != RadioConfiguration.radio_cfg_8_r ) if (ucNewRegVal != RadioConfiguration.radio_cfg_8_r )
{ {
bRadioConfigurationChanged = RIE_TRUE; bRadioConfigurationChanged = RIE_TRUE;
RadioConfiguration.radio_cfg_8_r = ucNewRegVal; RadioConfiguration.radio_cfg_8_r = ucNewRegVal;
} }
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTxCarrier(void) @fn RIE_Responses RadioTxCarrier(void)
@brief Transmit a carrier tone @brief Transmit a carrier tone
using the current radio configuration. using the current radio configuration.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioTxCarrier(); Response = RadioTxCarrier();
@endcode @endcode
@note Terminate this mode by calling RadioTerminateRadioOp(); @note Terminate this mode by calling RadioTerminateRadioOp();
@ -973,12 +973,12 @@ RIE_Responses RadioTxCarrier (void)
Response = RadioSendCommandWait(CMD_PHY_TX); Response = RadioSendCommandWait(CMD_PHY_TX);
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTxPreamble(void) @fn RIE_Responses RadioTxPreamble(void)
@brief Transmit a pre-amble (alternating ones and zeros) @brief Transmit a pre-amble (alternating ones and zeros)
using the current radio configuration. using the current radio configuration.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioTxPreamble(); Response = RadioTxPreamble();
@endcode @endcode
@note Terminate this mode by calling RadioTerminateRadioOp(); @note Terminate this mode by calling RadioTerminateRadioOp();
@ -1002,14 +1002,14 @@ RIE_Responses RadioTxPreamble (void)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioRxPacketFixedLen(RIE_U8 Len) @fn RIE_Responses RadioRxPacketFixedLen(RIE_U8 Len)
@brief Enter receive mode and wait for a packet to be received. @brief Enter receive mode and wait for a packet to be received.
Radio will stay in Receive Mode until Radio will stay in Receive Mode until
1) A packet is received. 1) A packet is received.
2) User manually exits Receive Mode with a call to RadioTerminateRadioOp() 2) User manually exits Receive Mode with a call to RadioTerminateRadioOp()
@param Len :{1-240} Fixed Length of packet to be received. @param Len :{1-240} Fixed Length of packet to be received.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@return RIE_Responses Error code @return RIE_Responses Error code
@ -1036,14 +1036,14 @@ RIE_Responses RadioRxPacketFixedLen(RIE_U8 Len)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioRxPacketVariableLen(void) @fn RIE_Responses RadioRxPacketVariableLen(void)
@brief Enter receive mode and wait for a packet to be received. @brief Enter receive mode and wait for a packet to be received.
Radio will stay in Receive Mode until Radio will stay in Receive Mode until
1) A packet is received. 1) A packet is received.
2) User manually exits Receive Mode with a call to RadioTerminateRadioOp() 2) User manually exits Receive Mode with a call to RadioTerminateRadioOp()
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@return RIE_Responses Error code @return RIE_Responses Error code
**/ **/
@ -1067,12 +1067,12 @@ RIE_Responses RadioRxPacketVariableLen(void)
return Response; return Response;
} }
/** /**
@fn RIE_BOOL RadioRxPacketAvailable(void) @fn RIE_BOOL RadioRxPacketAvailable(void)
@brief Checks if a packet has been received. @brief Checks if a packet has been received.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@pre RadioRxPacketFixedLen() or equivalent should be called first. @pre RadioRxPacketFixedLen() or equivalent should be called first.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12); RIE_Response = RadioRxPacketFixedLen(12);
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
@ -1095,7 +1095,7 @@ RIE_BOOL RadioRxPacketAvailable(void)
} }
/** /**
@fn RIE_Responses RadioRxPacketRead(RIE_U8 BufferLen,RIE_U8 *pPktLen,RIE_U8 *pData,RIE_S8 *pRSSIdBm) @fn RIE_Responses RadioRxPacketRead(RIE_U8 BufferLen,RIE_U8 *pPktLen,RIE_U8 *pData,RIE_S8 *pRSSIdBm)
@brief Read the packet that was received by the radio. @brief Read the packet that was received by the radio.
@param BufferLen :{1-240} Size of passed in buffer @param BufferLen :{1-240} Size of passed in buffer
@ -1104,7 +1104,7 @@ RIE_BOOL RadioRxPacketAvailable(void)
@param pRSSIdBm :{} RSSI of received packet in dBm. @param pRSSIdBm :{} RSSI of received packet in dBm.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@pre RadioRxPacketFixedLen() or equivalent should be called first. @pre RadioRxPacketFixedLen() or equivalent should be called first.
@code @code
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12); RIE_Response = RadioRxPacketFixedLen(12);
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
@ -1170,13 +1170,13 @@ RIE_Responses RadioRxPacketRead(RIE_U8 BufferLen,RIE_U8 *pPktLen,RIE_U8 *pData,R
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioRxBERTestMode(void) @fn RIE_Responses RadioRxBERTestMode(void)
@brief Enter receiver Bit Error Rate (BER) test mode where the @brief Enter receiver Bit Error Rate (BER) test mode where the
clock and data appear on GPIO pins. clock and data appear on GPIO pins.
Clock on P0.6 and Data on P2.6 Clock on P0.6 and Data on P2.6
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioRxBERTestMode(); Response = RadioRxBERTestMode();
@endcode @endcode
@note Terminate this mode by calling RadioTerminateRadioOp(); @note Terminate this mode by calling RadioTerminateRadioOp();
@ -1187,7 +1187,7 @@ RIE_Responses RadioRxBERTestMode(void)
RIE_Responses Response = RIE_Success; RIE_Responses Response = RIE_Success;
RIE_U8 Data; RIE_U8 Data;
// Enables internal radio signals on external pins // Enables internal radio signals on external pins
// but overrides some of the standard GPIO muxed // but overrides some of the standard GPIO muxed
// functionality (UART?) // functionality (UART?)
pADI_MISC->RFTST = 0x7E1; pADI_MISC->RFTST = 0x7E1;
@ -1211,7 +1211,7 @@ RIE_Responses RadioRxBERTestMode(void)
return Response; return Response;
} }
/** /**
@internal Hide from Doxegen @internal Hide from Doxegen
@fn RIE_Responses RadioCommitRadioConfig(void) @fn RIE_Responses RadioCommitRadioConfig(void)
@brief Configures the radio if any changes were made @brief Configures the radio if any changes were made
@ -1247,7 +1247,7 @@ static RIE_Responses RadioCommitRadioConfig(void)
} }
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioReadState(RadioState *pState) @fn RIE_Responses RadioReadState(RadioState *pState)
@brief Read the current state @brief Read the current state
@param pState Pointer to return storage of state @param pState Pointer to return storage of state
@ -1271,7 +1271,7 @@ static RIE_Responses RadioReadState(RadioState *pState)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioWaitOnState(RadioState FinalState) @fn RIE_Responses RadioWaitOnState(RadioState FinalState)
@brief Wait for Final State to be reached @brief Wait for Final State to be reached
@param FinalState State to wait on @param FinalState State to wait on
@ -1289,7 +1289,7 @@ static RIE_Responses RadioWaitOnState(RadioState FinalState)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioWaitOnCmdLdr(void) @fn RIE_Responses RadioWaitOnCmdLdr(void)
@brief Wait for Final State to be reached @brief Wait for Final State to be reached
@param FinalState State to wait on @param FinalState State to wait on
@ -1307,7 +1307,7 @@ static RIE_Responses RadioWaitOnCmdLdr(void)
Response = RadioSPIXferByte(SPI_NOP,NULL); Response = RadioSPIXferByte(SPI_NOP,NULL);
if (Response == RIE_Success) if (Response == RIE_Success)
Response = RadioSPIXferByte(SPI_NOP,&StatusByte); Response = RadioSPIXferByte(SPI_NOP,&StatusByte);
RADIO_CSN_DEASSERT; RADIO_CSN_DEASSERT;
NVIC_EnableIRQ (UHFTRX_IRQn); NVIC_EnableIRQ (UHFTRX_IRQn);
if ((Response == RIE_Success)) if ((Response == RIE_Success))
if(StatusByte & STATUS_BYTE_CMD_READY) if(StatusByte & STATUS_BYTE_CMD_READY)
@ -1317,13 +1317,13 @@ static RIE_Responses RadioWaitOnCmdLdr(void)
return Response; return Response;
} }
/** /**
@internal Hide from Doxegen @internal Hide from Doxegen
@fn RIE_Responses RadioToOnMode(void) @fn RIE_Responses RadioToOnMode(void)
@brief Transition to On Mode @brief Transition to On Mode
Handle all possible states that the radio could be in Handle all possible states that the radio could be in
and brings it back to PHY_ON state and brings it back to PHY_ON state
@param None @param None
@return RIE_Responses Error code @return RIE_Responses Error code
**/ **/
@ -1365,12 +1365,12 @@ static RIE_Responses RadioToOnMode(void)
} }
return Response; return Response;
} }
/** /**
@internal Hide from Doxegen @internal Hide from Doxegen
@fn RIE_Responses RadioToOffMode(void) @fn RIE_Responses RadioToOffMode(void)
@brief Transition to Off Mode @brief Transition to Off Mode
Handle all possible states that the radio could be in Handle all possible states that the radio could be in
and bring it back to PHY_OFF state. and bring it back to PHY_OFF state.
@param None @param None
@ -1414,7 +1414,7 @@ static RIE_Responses RadioToOffMode(void)
} }
return Response; return Response;
} }
/** /**
@internal Hide from Doxegen @internal Hide from Doxegen
@fn RIE_Responses RadioSyncComms (void) @fn RIE_Responses RadioSyncComms (void)
@brief Sync comms with the radio @brief Sync comms with the radio
@ -1430,7 +1430,7 @@ static RIE_Responses RadioSyncComms (void)
Response = RadioWaitOnCmdLdr(); Response = RadioWaitOnCmdLdr();
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioWaitForPowerUp(void) @fn RIE_Responses RadioWaitForPowerUp(void)
@brief Wake Up the Part @brief Wake Up the Part
@ -1444,7 +1444,7 @@ static RIE_Responses RadioWaitForPowerUp(void)
RIE_Responses Response = RIE_Success; RIE_Responses Response = RIE_Success;
int i = 0x0; int i = 0x0;
RADIO_CSN_ASSERT; RADIO_CSN_ASSERT;
while (!RADIO_MISO_IN && (i < 1000)) while (!RADIO_MISO_IN && (i < 1000))
i++; i++;
if (1000 == i)// Timed out waiting for MISO high? if (1000 == i)// Timed out waiting for MISO high?
Response = RIE_RadioSPICommsFail; Response = RIE_RadioSPICommsFail;
@ -1452,7 +1452,7 @@ static RIE_Responses RadioWaitForPowerUp(void)
return Response; return Response;
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn void Ext_Int8_Handler(void) \fn void Ext_Int8_Handler(void)
\brief Radio Interrupt Handler \brief Radio Interrupt Handler
@ -1482,7 +1482,7 @@ void Ext_Int8_Handler (void)
// Clear the interrupt // Clear the interrupt
pADI_INTERRUPT->EICLR = EICLR_IRQ8; pADI_INTERRUPT->EICLR = EICLR_IRQ8;
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn void RadioSPIXferByte(RIE_U8 ucByte,RIE_U8 *pData) \fn void RadioSPIXferByte(RIE_U8 ucByte,RIE_U8 *pData)
\brief Transfer a byte via SPI to the radio and optionally return \brief Transfer a byte via SPI to the radio and optionally return
@ -1504,13 +1504,13 @@ static RIE_Responses RadioSPIXferByte(RIE_U8 ucByte,RIE_U8 *pData)
(void)READ_SPI; (void)READ_SPI;
return Response; return Response;
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn RIE_Responses RadioSendCommandBytes(RIE_U8 *pCmdBytes,RIE_U8 NumBytes) \fn RIE_Responses RadioSendCommandBytes(RIE_U8 *pCmdBytes,RIE_U8 NumBytes)
\brief Send a complete command to the radio. \brief Send a complete command to the radio.
It is neccessary to disable the radio interrupt when doing this It is neccessary to disable the radio interrupt when doing this
as a command in progress must finish before a radio interrupt as a command in progress must finish before a radio interrupt
can be handled. can be handled.
\param pCmdBytes Pointer to a number of bytes to be transferred. \param pCmdBytes Pointer to a number of bytes to be transferred.
@ -1531,7 +1531,7 @@ static RIE_Responses RadioSendCommandBytes(RIE_U8 *pCmdBytes,RIE_U8 NumBytes)
return Response; return Response;
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn RIE_Responses RadioSendCommandNoWait (Radio_CmdCodes CmdCode ) \fn RIE_Responses RadioSendCommandNoWait (Radio_CmdCodes CmdCode )
\brief Send a single byte command to the radio. \brief Send a single byte command to the radio.
@ -1543,7 +1543,7 @@ static RIE_Responses RadioSendCommandNoWait (Radio_CmdCodes CmdCode )
RIE_U8 Command = (RIE_U8)CmdCode; RIE_U8 Command = (RIE_U8)CmdCode;
return RadioSendCommandBytes(&Command,0x1); return RadioSendCommandBytes(&Command,0x1);
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn RIE_Responses RadioSendCommandWait (Radio_CmdCodes CmdCode ) \fn RIE_Responses RadioSendCommandWait (Radio_CmdCodes CmdCode )
\brief Send a single byte command to the radio. \brief Send a single byte command to the radio.
@ -1561,7 +1561,7 @@ static RIE_Responses RadioSendCommandWait (Radio_CmdCodes CmdCode )
Response = RadioSendCommandBytes(&Command,0x1); Response = RadioSendCommandBytes(&Command,0x1);
return Response; return Response;
} }
/** /**
\fn RIE_Responses RadioMMapRead(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData) \fn RIE_Responses RadioMMapRead(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData)
\brief Read bytes from specified memory map address \brief Read bytes from specified memory map address
\param ulAdr Address to read at. \param ulAdr Address to read at.
@ -1575,7 +1575,7 @@ static RIE_Responses RadioMMapRead(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData)
NVIC_DisableIRQ(UHFTRX_IRQn); NVIC_DisableIRQ(UHFTRX_IRQn);
RADIO_CSN_ASSERT; RADIO_CSN_ASSERT;
if(Response == RIE_Success) // Send first byte (SPI_MEMR_RD + Bytes) if(Response == RIE_Success) // Send first byte (SPI_MEMR_RD + Bytes)
Response = RadioSPIXferByte(SPI_MEM_RD | ((ulAdr & 0x700) >> 8),NULL); Response = RadioSPIXferByte(SPI_MEM_RD | ((ulAdr & 0x700) >> 8),NULL);
if(Response == RIE_Success)// Send Second byte remainder of address if(Response == RIE_Success)// Send Second byte remainder of address
@ -1589,7 +1589,7 @@ static RIE_Responses RadioMMapRead(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData)
return Response; return Response;
} }
/** /**
\fn RIE_Responses RadioMMapWrite(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData) \fn RIE_Responses RadioMMapWrite(RIE_U32 ulAdr, RIE_U32 ulLen, RIE_U8 *pData)
\brief Read bytes from specified memory map address \brief Read bytes from specified memory map address
\param ulAdr Address to read at. \param ulAdr Address to read at.
@ -1615,7 +1615,7 @@ static RIE_Responses RadioMMapWrite(RIE_U32 ulAdr,RIE_U32 ulLen,RIE_U8 * pDat
return Response; return Response;
} }
/** /**
\internal Hide from Doxegen \internal Hide from Doxegen
\fn void SetRadioConfiguration(void) \fn void SetRadioConfiguration(void)
\brief Create a default radio configuration that all base configurations \brief Create a default radio configuration that all base configurations
@ -1654,7 +1654,7 @@ static RIE_Responses SetRadioConfiguration(RIE_BaseConfigs BaseConfig)
} }
return Response; return Response;
} }
/** /**
@internal Hide from Doxegen @internal Hide from Doxegen
@fn RIE_Responses RadioConfigure (void) @fn RIE_Responses RadioConfigure (void)
@brief Configure the Radio as per the current configuration @brief Configure the Radio as per the current configuration
@ -1666,8 +1666,8 @@ RIE_Responses RadioConfigure (void)
if(Response == RIE_Success) if(Response == RIE_Success)
Response = RadioToOffMode(); Response = RadioToOffMode();
if(Response == RIE_Success) // Write the configuration to the radio memory if(Response == RIE_Success) // Write the configuration to the radio memory
Response = RadioMMapWrite(BBRAM_START, Response = RadioMMapWrite(BBRAM_START,
sizeof(TyRadioConfiguration), sizeof(TyRadioConfiguration),
(RIE_U8 *)&RadioConfiguration); (RIE_U8 *)&RadioConfiguration);
if(Response == RIE_Success) // Apply that configuration to the radio if(Response == RIE_Success) // Apply that configuration to the radio
Response = RadioSendCommandWait(CMD_CONFIG_DEV); Response = RadioSendCommandWait(CMD_CONFIG_DEV);
@ -1677,12 +1677,12 @@ RIE_Responses RadioConfigure (void)
} }
/** /**
@fn RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm) @fn RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm)
@brief Return a Received Signal Strength Indicator value @brief Return a Received Signal Strength Indicator value
@param pRSSIdBm :{} detected RSSI in dBm. @param pRSSIdBm :{} detected RSSI in dBm.
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
RIE_S8 RSSIdBm; RIE_S8 RSSIdBm;
if (RIE_Response == RIE_Success) if (RIE_Response == RIE_Success)
RIE_Response = RadioRadioGetRSSI(&RSSIdBm); RIE_Response = RadioRadioGetRSSI(&RSSIdBm);
@ -1700,7 +1700,7 @@ RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm)
if (Response == RIE_Success) if (Response == RIE_Success)
Response = RadioSendCommandWait(CMD_GET_RSSI); Response = RadioSendCommandWait(CMD_GET_RSSI);
if (Response == RIE_Success) if (Response == RIE_Success)
Response = RadioSyncComms(); // Response = RadioSyncComms(); //
if (pRSSIdBm) if (pRSSIdBm)
{ {
if (Response == RIE_Success) if (Response == RIE_Success)
@ -1710,15 +1710,15 @@ RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm)
return Response; return Response;
} }
/** /**
@fn RIE_Responses RadioTxSetPower(RIE_PAPowerLevel Power) @fn RIE_Responses RadioTxSetPower(RIE_PAPowerLevel Power)
@brief Set the Transmit Power Level for Radio Transmission. @brief Set the Transmit Power Level for Radio Transmission.
@param Power :{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3, @param Power :{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3,
PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7, PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7,
PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11, PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11,
PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15} PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15}
@pre RadioInit() must be called before this function is called. @pre RadioInit() must be called before this function is called.
@code @code
Response = RadioTxSetPower(PowerLevel8); Response = RadioTxSetPower(PowerLevel8);
@endcode @endcode
@note Max TX Power is used by default. @note Max TX Power is used by default.
@ -1783,7 +1783,7 @@ RIE_Responses RadioTxSetPower (RIE_PAPowerLevel Power)
// Write directly to the MCR in this case and avoid a reconfigure // Write directly to the MCR in this case and avoid a reconfigure
if (Response == RIE_Success) if (Response == RIE_Success)
Response = RadioMMapWrite(MCR_pa_level_mcr_Adr, 0x1, (RIE_U8 *)&ucNewRegVal); Response = RadioMMapWrite(MCR_pa_level_mcr_Adr, 0x1, (RIE_U8 *)&ucNewRegVal);
RadioConfiguration.radio_cfg_8_r = ucNewRegVal; RadioConfiguration.radio_cfg_8_r = ucNewRegVal;
} }
} }
return Response; return Response;

View file

@ -89,10 +89,10 @@
* processor. * processor.
*/ */
int elfloader_arch_relocate(int input_fd, int elfloader_arch_relocate(int input_fd,
struct elfloader_output *output, struct elfloader_output *output,
unsigned int sectionoffset, unsigned int sectionoffset,
char *sectionaddr, char *sectionaddr,
struct elf32_rela *rela, char *addr); struct elf32_rela *rela, char *addr);
#endif /* ELFLOADER_ARCH_H_ */ #endif /* ELFLOADER_ARCH_H_ */

View file

@ -37,7 +37,7 @@
* Header file for the Contiki ELF loader. * Header file for the Contiki ELF loader.
* \author * \author
* Adam Dunkels <adam@sics.se> * Adam Dunkels <adam@sics.se>
* Simon Berg <ksb@users.sourceforge.net> * Simon Berg <ksb@users.sourceforge.net>
* *
*/ */
@ -132,7 +132,7 @@
* Return value from elfloader_load() indicating that the offset for * Return value from elfloader_load() indicating that the offset for
* a relative addressing mode was too big. * a relative addressing mode was too big.
*/ */
#define ELFLOADER_OUTOF_RANGE 9 #define ELFLOADER_OUTOF_RANGE 9
/** /**
* Return value from elfloader_load() indicating that the relocations * Return value from elfloader_load() indicating that the relocations
@ -144,13 +144,13 @@
* Return value from elfloader_load() indicating that reading from the * Return value from elfloader_load() indicating that reading from the
* ELF file failed in some way. * ELF file failed in some way.
*/ */
#define ELFLOADER_INPUT_ERROR 11 #define ELFLOADER_INPUT_ERROR 11
/** /**
* Return value from elfloader_load() indicating that writing to a segment * Return value from elfloader_load() indicating that writing to a segment
* failed. * failed.
*/ */
#define ELFLOADER_OUTPUT_ERROR 12 #define ELFLOADER_OUTPUT_ERROR 12
#define ELFLOADER_SEG_TEXT 1 #define ELFLOADER_SEG_TEXT 1
@ -164,10 +164,10 @@
* This object defines methods (callbacks) for writing the segments to memory. * This object defines methods (callbacks) for writing the segments to memory.
* It can be extended by the user to include any necessary state. * It can be extended by the user to include any necessary state.
*/ */
struct elfloader_output { struct elfloader_output {
const struct elfloader_output_ops *ops; const struct elfloader_output_ops *ops;
}; };
/** /**
* \brief Allocate a new segment * \brief Allocate a new segment
* \param input The output object * \param input The output object
@ -178,9 +178,8 @@ struct elfloader_output {
* The returned address doesn't need to correspond to any real memory, * The returned address doesn't need to correspond to any real memory,
* since it's only used for calculating the relocations. * since it's only used for calculating the relocations.
*/ */
void *elfloader_allocate_segment(struct elfloader_output *output, void *elfloader_allocate_segment(struct elfloader_output *output,
unsigned int type, int size); unsigned int type, int size);
/** /**
* \brief Start writing to a new segment * \brief Start writing to a new segment
@ -191,15 +190,14 @@ void *elfloader_allocate_segment(struct elfloader_output *output,
* \return Returns ELFLOADER_OK if successful, otherwise an error code * \return Returns ELFLOADER_OK if successful, otherwise an error code
* *
*/ */
int elfloader_start_segment(struct elfloader_output *output, int elfloader_start_segment(struct elfloader_output *output,
unsigned int type, void *addr, int size); unsigned int type, void *addr, int size);
/** /**
* \brief Mark end of segment * \brief Mark end of segment
* \param input The output object * \param input The output object
* \return Zero if successful * \return Zero if successful
*/ */
int elfloader_end_segment(struct elfloader_output *output); int elfloader_end_segment(struct elfloader_output *output);
/** /**
@ -209,9 +207,8 @@ int elfloader_end_segment(struct elfloader_output *output);
* \param len Length of data * \param len Length of data
* \return The number of bytes actually written, or negative if failed. * \return The number of bytes actually written, or negative if failed.
*/ */
int elfloader_write_segment(struct elfloader_output *output, const char *buf, int elfloader_write_segment(struct elfloader_output *output, const char *buf,
unsigned int len); unsigned int len);
/** /**
* \brief Get the current offset in the file where the next data will * \brief Get the current offset in the file where the next data will
@ -219,7 +216,6 @@ int elfloader_write_segment(struct elfloader_output *output, const char *buf,
* \param input The output object * \param input The output object
* \return The current offset. * \return The current offset.
*/ */
unsigned int elfloader_segment_offset(struct elfloader_output *output); unsigned int elfloader_segment_offset(struct elfloader_output *output);
#define elfloader_output_alloc_segment(output, type, size) \ #define elfloader_output_alloc_segment(output, type, size) \
@ -240,12 +236,12 @@ unsigned int elfloader_segment_offset(struct elfloader_output *output);
struct elfloader_output_ops { struct elfloader_output_ops {
void * (*allocate_segment)(struct elfloader_output *output, void * (*allocate_segment)(struct elfloader_output *output,
unsigned int type, int size); unsigned int type, int size);
int (*start_segment)(struct elfloader_output *output, int (*start_segment)(struct elfloader_output *output,
unsigned int type, void *addr, int size); unsigned int type, void *addr, int size);
int (*end_segment)(struct elfloader_output *output); int (*end_segment)(struct elfloader_output *output);
int (*write_segment)(struct elfloader_output *output, const char *buf, int (*write_segment)(struct elfloader_output *output, const char *buf,
unsigned int len); unsigned int len);
unsigned int (*segment_offset)(struct elfloader_output *output); unsigned int (*segment_offset)(struct elfloader_output *output);
}; };
@ -269,8 +265,7 @@ void elfloader_init(void);
* elfloader_loaded_process variable. * elfloader_loaded_process variable.
* *
*/ */
int elfloader_load(int input_fd, int elfloader_load(int input_fd, struct elfloader_output *output);
struct elfloader_output *output);
/** /**
* A pointer to the processes loaded with elfloader_load(). * A pointer to the processes loaded with elfloader_load().

View file

@ -1001,11 +1001,11 @@ static NETBUF *NicGetPacket(void)
* Hack alert: Rev A chips never set the odd frame indicator. * Hack alert: Rev A chips never set the odd frame indicator.
*/ */
fbc -= 3; fbc -= 3;
/* nb = NutNetBufAlloc(0, NBAF_DATALINK, fbc);*/ /* nb = NutNetBufAlloc(0, NBAF_DATALINK, fbc);*/
/* Perform the read. */ /* Perform the read. */
/* if (nb) /* if (nb)
NicRead(nb->nb_dl.vp, fbc);*/ NicRead(nb->nb_dl.vp, fbc);*/
} }
/* Release the packet. */ /* Release the packet. */
@ -1191,12 +1191,12 @@ PROCESS_THREAD(lanc111_process, ev, data)
*/ */
imsk = nic_inlb(NIC_MSK); imsk = nic_inlb(NIC_MSK);
nic_outlb(NIC_MSK, 0); nic_outlb(NIC_MSK, 0);
/* while ((nb = NicGetPacket()) != 0) { /* while ((nb = NicGetPacket()) != 0) {
if (nb != (NETBUF *) 0xFFFF) { if (nb != (NETBUF *) 0xFFFF) {
ni->ni_rx_packets++; ni->ni_rx_packets++;
(*ifn->if_recv) (dev, nb); (*ifn->if_recv) (dev, nb);
} }
}*/ }*/
nic_outlb(NIC_MSK, imsk | INT_RCV | INT_ERCV); nic_outlb(NIC_MSK, imsk | INT_RCV | INT_ERCV);
} }
@ -1351,7 +1351,7 @@ lanc111_init(void)
/* Register interrupt handler and enable interrupts. */ /* Register interrupt handler and enable interrupts. */
/* if (NutRegisterIrqHandler(&LANC111_SIGNAL, NicInterrupt, dev)) /* if (NutRegisterIrqHandler(&LANC111_SIGNAL, NicInterrupt, dev))
return -1;*/ return -1;*/
/* /*
* Start the receiver thread. * Start the receiver thread.

View file

@ -1,31 +1,30 @@
/* /*
* Copyright (c) 2006, Swedish Institute of Computer Science * Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* *
/** /**
* \file * \file

View file

@ -60,6 +60,7 @@ CONTIKI_CPU_SOURCEFILES += ecc-curve.c
CONTIKI_CPU_SOURCEFILES += dbg.c ieee-addr.c CONTIKI_CPU_SOURCEFILES += dbg.c ieee-addr.c
CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c
CONTIKI_CPU_SOURCEFILES += i2c.c cc2538-temp-sensor.c vdd3-sensor.c CONTIKI_CPU_SOURCEFILES += i2c.c cc2538-temp-sensor.c vdd3-sensor.c
CONTIKI_CPU_SOURCEFILES += cfs-coffee.c cfs-coffee-arch.c
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
@ -110,7 +111,8 @@ CUSTOM_RULE_LINK=1
### This rule is used to generate the correct linker script ### This rule is used to generate the correct linker script
LDGENFLAGS += $(addprefix -D,$(subst $(COMMA), ,$(DEFINES))) LDGENFLAGS += $(addprefix -D,$(subst $(COMMA), ,$(DEFINES)))
LDGENFLAGS += $(addprefix -I,$(SOURCEDIRS)) LDGENFLAGS += $(addprefix -I,$(SOURCEDIRS))
LDGENFLAGS += -imacros "contiki-conf.h" LDGENFLAGS += -imacros "contiki-conf.h" -imacros "dev/cc2538-dev.h"
LDGENFLAGS += -imacros "dev/flash.h" -imacros "cfs-coffee-arch.h"
LDGENFLAGS += -x c -P -E LDGENFLAGS += -x c -P -E
# NB: Assumes LDSCRIPT was not overridden and is in $(OBJECTDIR) # NB: Assumes LDSCRIPT was not overridden and is in $(OBJECTDIR)

View file

@ -33,70 +33,61 @@
* stage. Rather, it is used as input for the auto-generation of the actual * stage. Rather, it is used as input for the auto-generation of the actual
* ld script, which is called cc2538.ld and will be in the project directory * ld script, which is called cc2538.ld and will be in the project directory
*/ */
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0)
#define NRSRAM_START 0x20000000
#define NRSRAM_LEN 0x00004000
#define SRAM_START 0x20004000
#define SRAM_LEN 0x00004000
#else
#define SRAM_START 0x20000000
#define SRAM_LEN 0x00008000
#endif
#ifdef FLASH_CONF_ORIGIN
#define FLASH_ORIGIN FLASH_CONF_ORIGIN
#else
#error FLASH_CONF_ORIGIN is not specified. Please define FLASH_CONF_ORIGIN in contiki-conf.h.
#endif
#ifdef FLASH_CONF_SIZE
#define FLASH_SIZE FLASH_CONF_SIZE
#else
#error FLASH_CONF_SIZE is not specified. Please define FLASH_CONF_SIZE in contiki-conf.h.
#endif
#define FLASH_CCA_LENGTH 44
#define FLASH_LENGTH (FLASH_SIZE - FLASH_CCA_LENGTH)
#define FLASH_CCA_ORIGIN (FLASH_ORIGIN + FLASH_LENGTH)
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = FLASH_ORIGIN, LENGTH = FLASH_LENGTH FLASH_FW (rx) : ORIGIN = COFFEE_START + COFFEE_SIZE,
FLASH_CCA (RX) : ORIGIN = FLASH_CCA_ORIGIN, LENGTH = FLASH_CCA_LENGTH LENGTH = FLASH_CCA_ADDR - (COFFEE_START + COFFEE_SIZE)
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0) FLASH_CCA (RX) : ORIGIN = FLASH_CCA_ADDR, LENGTH = FLASH_CCA_SIZE
NRSRAM (RWX) : ORIGIN = NRSRAM_START, LENGTH = NRSRAM_LEN
/*
* If PM2 is enabled, then the PM2 SRAM limitations apply, i.e. the
* regular-leakage SRAM is a non-retention SRAM and the low-leakage SRAM is
* a full-retention SRAM.
* Else, the data in the regular-leakage SRAM is always retained, so there
* are virtually a non-retention SRAM with a size of 0 bytes and a
* full-retention SRAM spanning the whole SRAM, which is more convenient to
* use.
*/
#if LPM_CONF_ENABLE && LPM_CONF_MAX_PM >= 2
NRSRAM (RWX) : ORIGIN = CC2538_DEV_RLSRAM_ADDR,
LENGTH = CC2538_DEV_RLSRAM_SIZE
FRSRAM (RWX) : ORIGIN = CC2538_DEV_LLSRAM_ADDR,
LENGTH = CC2538_DEV_LLSRAM_SIZE
#else
NRSRAM (RWX) : ORIGIN = CC2538_DEV_RLSRAM_ADDR, LENGTH = 0
FRSRAM (RWX) : ORIGIN = CC2538_DEV_SRAM_ADDR, LENGTH = CC2538_DEV_SRAM_SIZE
#endif #endif
SRAM (RWX) : ORIGIN = SRAM_START, LENGTH = SRAM_LEN
} }
ENTRY(flash_cca_lock_page)
SECTIONS SECTIONS
{ {
.text : .text :
{ {
_text = .; _text = .;
KEEP(*(.vectors)) *(.vectors)
*(.text*) *(.text*)
*(.rodata*) *(.rodata*)
_etext = .; _etext = .;
} > FLASH= 0 } > FLASH_FW= 0
.socdata (NOLOAD) : .socdata (NOLOAD) :
{ {
*(.udma_channel_control_table) *(.udma_channel_control_table)
} > SRAM } > FRSRAM
.data : ALIGN(4) .data : ALIGN(4)
{ {
_data = .; _data = .;
*(.data*) *(.data*)
_edata = .; _edata = .;
} > SRAM AT > FLASH } > FRSRAM AT > FLASH_FW
_ldata = LOADADDR(.data); _ldata = LOADADDR(.data);
.ARM.exidx : .ARM.exidx :
{ {
*(.ARM.exidx*) *(.ARM.exidx*)
} > FLASH } > FLASH_FW
.bss : .bss :
{ {
@ -104,24 +95,22 @@ SECTIONS
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
_ebss = .; _ebss = .;
} > SRAM } > FRSRAM
.stack (NOLOAD) : .stack (NOLOAD) :
{ {
*(.stack) *(.stack)
} > SRAM } > FRSRAM
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0)
.nrdata (NOLOAD) : .nrdata (NOLOAD) :
{ {
_nrdata = .; _nrdata = .;
*(.nrdata*) *(.nrdata*)
_enrdata = .; _enrdata = .;
} > NRSRAM } > NRSRAM
#endif
.flashcca : .flashcca :
{ {
KEEP(*(.flashcca)) *(.flashcca)
} > FLASH_CCA } > FLASH_CCA
} }

View file

@ -0,0 +1,144 @@
/*
* Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-cfs-coffee-arch
* @{
*
* \file
* Module for the cc2538 Coffee port
*/
#include "contiki-conf.h"
#include "sys/cc.h"
#include "cfs/cfs-coffee.h"
#include "dev/cc2538-dev.h"
#include "dev/rom-util.h"
#include "dev/flash.h"
#include "dev/watchdog.h"
#include "cpu.h"
#include "cfs-coffee-arch.h"
#include <stdint.h>
#ifndef COFFEE_CONF_CUSTOM_PORT
/*---------------------------------------------------------------------------*/
#if !COFFEE_SECTOR_SIZE || COFFEE_SECTOR_SIZE % FLASH_PAGE_SIZE
#error COFFEE_SECTOR_SIZE must be a non-zero multiple of the flash page size
#endif
#if !COFFEE_PAGE_SIZE || COFFEE_SECTOR_SIZE % COFFEE_PAGE_SIZE
#error COFFEE_PAGE_SIZE must be a divisor of COFFEE_SECTOR_SIZE
#endif
#if COFFEE_PAGE_SIZE % FLASH_WORD_SIZE
#error COFFEE_PAGE_SIZE must be a multiple of the flash word size
#endif
#if COFFEE_START % FLASH_PAGE_SIZE
#error COFFEE_START must be aligned with a flash page boundary
#endif
#if COFFEE_SIZE % COFFEE_SECTOR_SIZE
#error COFFEE_SIZE must be a multiple of COFFEE_SECTOR_SIZE
#endif
#if COFFEE_SIZE / COFFEE_PAGE_SIZE > INT16_MAX
#error Too many Coffee pages for coffee_page_t
#endif
#if COFFEE_START < CC2538_DEV_FLASH_ADDR || \
COFFEE_START + COFFEE_SIZE > FLASH_CCA_ADDR
#error Coffee does not fit in flash
#endif
/*---------------------------------------------------------------------------*/
void
cfs_coffee_arch_erase(uint16_t sector)
{
watchdog_periodic();
INTERRUPTS_DISABLE();
rom_util_page_erase(COFFEE_START + sector * COFFEE_SECTOR_SIZE,
COFFEE_SECTOR_SIZE);
INTERRUPTS_ENABLE();
}
/*---------------------------------------------------------------------------*/
void
cfs_coffee_arch_write(const void *buf, unsigned int size, cfs_offset_t offset)
{
const uint32_t *src = buf;
uint32_t flash_addr = COFFEE_START + offset;
unsigned int align;
uint32_t word, len;
uint32_t page_buf[COFFEE_PAGE_SIZE / FLASH_WORD_SIZE];
unsigned int i;
if(size && (align = flash_addr & (FLASH_WORD_SIZE - 1))) {
len = MIN(FLASH_WORD_SIZE - align, size);
word = ~((*src & ((1 << (len << 3)) - 1)) << (align << 3));
watchdog_periodic();
INTERRUPTS_DISABLE();
rom_util_program_flash(&word, flash_addr & ~(FLASH_WORD_SIZE - 1),
FLASH_WORD_SIZE);
INTERRUPTS_ENABLE();
*(const uint8_t **)&src += len;
size -= len;
flash_addr += len;
}
while(size >= FLASH_WORD_SIZE) {
len = MIN(size & ~(FLASH_WORD_SIZE - 1), COFFEE_PAGE_SIZE);
for(i = 0; i < len / FLASH_WORD_SIZE; i++) {
page_buf[i] = ~*src++;
}
watchdog_periodic();
INTERRUPTS_DISABLE();
rom_util_program_flash(page_buf, flash_addr, len);
INTERRUPTS_ENABLE();
size -= len;
flash_addr += len;
}
if(size) {
word = ~(*src & ((1 << (size << 3)) - 1));
watchdog_periodic();
INTERRUPTS_DISABLE();
rom_util_program_flash(&word, flash_addr, FLASH_WORD_SIZE);
INTERRUPTS_ENABLE();
}
}
/*---------------------------------------------------------------------------*/
void
cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset)
{
const uint8_t *src;
uint8_t *dst;
watchdog_periodic();
for(src = (const void *)(COFFEE_START + offset), dst = buf; size; size--) {
*dst++ = ~*src++;
}
}
#endif /* COFFEE_CONF_CUSTOM_PORT */
/** @} */

View file

@ -0,0 +1,182 @@
/*
* Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538
* @{
*
* \defgroup cc2538-cfs-coffee-arch cc2538 Coffee port module
*
* Module for the cc2538 Coffee port
* @{
*
* \file
* Header file for the cc2538 Coffee port module
*/
#ifndef CFS_COFFEE_ARCH_H_
#define CFS_COFFEE_ARCH_H_
#include "contiki-conf.h"
#include "cfs/cfs-coffee.h"
#include "dev/cc2538-dev.h"
#include "dev/flash.h"
#include <stdint.h>
#ifdef COFFEE_CONF_CUSTOM_PORT
#include COFFEE_CONF_CUSTOM_PORT
#else
/*---------------------------------------------------------------------------*/
/** \name Coffee port constants
* @{
*/
/** Logical sector size */
#ifdef COFFEE_CONF_SECTOR_SIZE
#define COFFEE_SECTOR_SIZE COFFEE_CONF_SECTOR_SIZE
#else
#define COFFEE_SECTOR_SIZE FLASH_PAGE_SIZE
#endif
/** Logical page size */
#ifdef COFFEE_CONF_PAGE_SIZE
#define COFFEE_PAGE_SIZE COFFEE_CONF_PAGE_SIZE
#else
#define COFFEE_PAGE_SIZE (COFFEE_SECTOR_SIZE / 8)
#endif
/** Start offset of the file system */
#ifdef COFFEE_CONF_START
#define COFFEE_START COFFEE_CONF_START
#else
#define COFFEE_START CC2538_DEV_FLASH_ADDR
#endif
/** Total size in bytes of the file system */
#ifdef COFFEE_CONF_SIZE
#define COFFEE_SIZE COFFEE_CONF_SIZE
#else
#define COFFEE_SIZE 0
#endif
/** Maximal filename length */
#ifdef COFFEE_CONF_NAME_LENGTH
#define COFFEE_NAME_LENGTH COFFEE_CONF_NAME_LENGTH
#else
#define COFFEE_NAME_LENGTH 40
#endif
/** Number of file cache entries */
#ifdef COFFEE_CONF_MAX_OPEN_FILES
#define COFFEE_MAX_OPEN_FILES COFFEE_CONF_MAX_OPEN_FILES
#else
#define COFFEE_MAX_OPEN_FILES 5
#endif
/** Number of file descriptor entries */
#ifdef COFFEE_CONF_FD_SET_SIZE
#define COFFEE_FD_SET_SIZE COFFEE_CONF_FD_SET_SIZE
#else
#define COFFEE_FD_SET_SIZE 5
#endif
/** Maximal amount of log table entries read in one batch */
#ifdef COFFEE_CONF_LOG_TABLE_LIMIT
#define COFFEE_LOG_TABLE_LIMIT COFFEE_CONF_LOG_TABLE_LIMIT
#endif
/** Default reserved file size */
#ifdef COFFEE_CONF_DYN_SIZE
#define COFFEE_DYN_SIZE COFFEE_CONF_DYN_SIZE
#else
#define COFFEE_DYN_SIZE (COFFEE_SECTOR_SIZE - 50)
#endif
/** Default micro-log size */
#ifdef COFFEE_CONF_LOG_SIZE
#define COFFEE_LOG_SIZE COFFEE_CONF_LOG_SIZE
#endif
/** Whether Coffee will use micro logs */
#ifdef COFFEE_CONF_MICRO_LOGS
#define COFFEE_MICRO_LOGS COFFEE_CONF_MICRO_LOGS
#else
#define COFFEE_MICRO_LOGS 0
#endif
/** Whether files are expected to be appended to only */
#ifdef COFFEE_CONF_APPEND_ONLY
#define COFFEE_APPEND_ONLY COFFEE_CONF_APPEND_ONLY
#else
#define COFFEE_APPEND_ONLY 1
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Coffee port macros
* @{
*/
/** Erase */
#define COFFEE_ERASE(sector) \
cfs_coffee_arch_erase(sector)
/** Write */
#define COFFEE_WRITE(buf, size, offset) \
cfs_coffee_arch_write((buf), (size), (offset))
/** Read */
#define COFFEE_READ(buf, size, offset) \
cfs_coffee_arch_read((buf), (size), (offset))
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Coffee port types
* @{
*/
typedef int16_t coffee_page_t; /**< Page */
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Coffee port functions
* @{
*/
/** \brief Erases a device sector
* \param sector Sector to erase
*/
void cfs_coffee_arch_erase(uint16_t sector);
/** \brief Writes a buffer to the device
* \param buf Pointer to the buffer
* \param size Byte size of the buffer
* \param offset Device offset to write to
*/
void cfs_coffee_arch_write(const void *buf, unsigned int size,
cfs_offset_t offset);
/** \brief Reads from the device to a buffer
* \param buf Pointer to the buffer
* \param size Byte size of the buffer
* \param offset Device offset to read from
*/
void cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset);
/** @} */
#endif /* COFFEE_CONF_CUSTOM_PORT */
#endif /* CFS_COFFEE_ARCH_H_ */
/**
* @}
* @}
*/

126
cpu/cc2538/dev/cc2538-dev.h Normal file
View file

@ -0,0 +1,126 @@
/*
* Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538
* @{
*
* \defgroup cc2538-devices cc2538 family of devices
*
* Definitions for the cc2538 family of devices
* @{
*
* \file
* Header file for the cc2538 devices definitions
*/
#ifndef CC2538_DEV_H_
#define CC2538_DEV_H_
#include "contiki-conf.h"
#include "sys/cc.h"
/*----------------------------------------------------------------------------*/
/** \name Bit-fields for the CC2538 devices features
* @{
*/
#define CC2538_DEV_ID_M 0x0000000F /**< ID mask */
#define CC2538_DEV_ID_S 0 /**< ID shift */
#define CC2538_DEV_FLASH_SIZE_KB_M 0x0000FFF0 /**< kiB flash size mask */
#define CC2538_DEV_FLASH_SIZE_KB_S 4 /**< kiB flash size shift */
#define CC2538_DEV_SRAM_SIZE_KB_M 0x00FF0000 /**< kiB SRAM size mask */
#define CC2538_DEV_SRAM_SIZE_KB_S 16 /**< kiB SRAM size shift */
#define CC2538_DEV_AES_SHA_M 0x01000000 /**< Security HW AES/SHA */
#define CC2538_DEV_ECC_RSA_M 0x02000000 /**< Security HW ECC/RSA */
/** @} */
/*----------------------------------------------------------------------------*/
/** \name Macro defining a CC2538 device from its features
* @{
*/
#define CC2538_DEV_DEF(id, flash_size_kb, sram_size_kb, aes_sha, ecc_rsa) \
((id) << CC2538_DEV_ID_S | (flash_size_kb) << CC2538_DEV_FLASH_SIZE_KB_S | \
(sram_size_kb) << CC2538_DEV_SRAM_SIZE_KB_S | \
((aes_sha) ? CC2538_DEV_AES_SHA_M : 0) | \
((ecc_rsa) ? CC2538_DEV_ECC_RSA_M : 0))
/** @} */
/*----------------------------------------------------------------------------*/
/** \name Available CC2538 devices
* @{
*/
#define CC2538_DEV_CC2538SF53 CC2538_DEV_DEF(0, 512, 32, 1, 1)
#define CC2538_DEV_CC2538SF23 CC2538_DEV_DEF(1, 256, 32, 1, 1)
#define CC2538_DEV_CC2538NF53 CC2538_DEV_DEF(2, 512, 32, 1, 0)
#define CC2538_DEV_CC2538NF23 CC2538_DEV_DEF(3, 256, 32, 1, 0)
#define CC2538_DEV_CC2538NF11 CC2538_DEV_DEF(4, 128, 16, 1, 0)
/** @} */
/*----------------------------------------------------------------------------*/
/** \name CC2538 device used by Contiki
* @{
*/
#ifdef CC2538_DEV_CONF
#define CC2538_DEV CC2538_DEV_CONF
#else
#define CC2538_DEV CC2538_DEV_CC2538SF53
#endif
/** @} */
/*----------------------------------------------------------------------------*/
/** \name Features of the CC2538 device used by Contiki
* @{
*/
/** Flash address */
#define CC2538_DEV_FLASH_ADDR 0x00200000
/** Flash size in bytes */
#define CC2538_DEV_FLASH_SIZE (((CC2538_DEV & CC2538_DEV_FLASH_SIZE_KB_M) >> \
CC2538_DEV_FLASH_SIZE_KB_S) << 10)
/** SRAM (non-retention + low-leakage) address */
#define CC2538_DEV_SRAM_ADDR (CC2538_DEV_RLSRAM_SIZE ? \
CC2538_DEV_RLSRAM_ADDR : \
CC2538_DEV_LLSRAM_ADDR)
/** SRAM (non-retention + low-leakage) size in bytes */
#define CC2538_DEV_SRAM_SIZE (((CC2538_DEV & CC2538_DEV_SRAM_SIZE_KB_M) >> \
CC2538_DEV_SRAM_SIZE_KB_S) << 10)
/** Regular-leakage SRAM address */
#define CC2538_DEV_RLSRAM_ADDR 0x20000000
/** Regular-leakage SRAM size in bytes */
#define CC2538_DEV_RLSRAM_SIZE (CC2538_DEV_SRAM_SIZE - CC2538_DEV_LLSRAM_SIZE)
/** Low-leakage SRAM address */
#define CC2538_DEV_LLSRAM_ADDR 0x20004000
/** Low-leakage SRAM size in bytes */
#define CC2538_DEV_LLSRAM_SIZE MIN(CC2538_DEV_SRAM_SIZE, 16384)
/** Security HW AES/SHA */
#define CC2538_DEV_AES_SHA (!!(CC2538_DEV & CC2538_DEV_AES_SHA_M))
/** Security HW ECC/RSA */
#define CC2538_DEV_ECC_RSA (!!(CC2538_DEV & CC2538_DEV_ECC_RSA_M))
/** @} */
#endif /* CC2538_DEV_H_ */
/**
* @}
* @}
*/

View file

@ -36,20 +36,36 @@
* \addtogroup cc2538 * \addtogroup cc2538
* @{ * @{
* *
* \defgroup cc2538-flash-cca cc2538 flash CCA * \defgroup cc2538-flash cc2538 flash memory
* *
* Definitions for the cc2538 flash lock bit page and customer configuration * Definitions for the cc2538 flash memory
* area
* @{ * @{
* *
* \file * \file
* Header file for the flash lock bit page and CCA definitions * Header file for the flash memory definitions
*/ */
#ifndef FLASH_CCA_H_ #ifndef FLASH_H_
#define FLASH_CCA_H_ #define FLASH_H_
#include "dev/cc2538-dev.h"
#include <stdint.h> #include <stdint.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** \name Flash memory organization
* @{
*/
#define FLASH_PAGE_SIZE 2048
#define FLASH_WORD_SIZE 4
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Flash lock bit page and CCA location
* @{
*/
#define FLASH_CCA_ADDR (CC2538_DEV_FLASH_ADDR + CC2538_DEV_FLASH_SIZE - \
FLASH_CCA_SIZE) /**< Address */
#define FLASH_CCA_SIZE 0x0000002C /**< Size in bytes */
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Bootloader backdoor configuration bit fields /** \name Bootloader backdoor configuration bit fields
* @{ * @{
*/ */
@ -85,7 +101,7 @@ typedef struct {
} flash_cca_lock_page_t; } flash_cca_lock_page_t;
/** @} */ /** @} */
#endif /* FLASH_CCA_H_ */ #endif /* FLASH_H_ */
/** /**
* @} * @}

View file

@ -57,7 +57,7 @@ nvic_init()
interrupt_unpend = (uint32_t *)NVIC_UNPEND0; interrupt_unpend = (uint32_t *)NVIC_UNPEND0;
/* Provide our interrupt table to the NVIC */ /* Provide our interrupt table to the NVIC */
REG(SCB_VTABLE) = (NVIC_CONF_VTABLE_BASE + NVIC_CONF_VTABLE_OFFSET); REG(SCB_VTABLE) = NVIC_VTABLE_ADDRESS;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void

View file

@ -48,18 +48,14 @@
/** \name NVIC Constants and Configuration /** \name NVIC Constants and Configuration
* @{ * @{
*/ */
#define NVIC_VTABLE_IN_SRAM 0x20000000
#define NVIC_VTABLE_IN_CODE 0x00000000
#define NVIC_INTERRUPT_ENABLED 0x00000001 #define NVIC_INTERRUPT_ENABLED 0x00000001
#define NVIC_INTERRUPT_DISABLED 0x00000000 #define NVIC_INTERRUPT_DISABLED 0x00000000
#ifndef NVIC_CONF_VTABLE_BASE #ifdef NVIC_CONF_VTABLE_ADDRESS
#define NVIC_CONF_VTABLE_BASE NVIC_VTABLE_IN_CODE #define NVIC_VTABLE_ADDRESS NVIC_CONF_VTABLE_ADDRESS
#endif #else
extern void(*const vectors[])(void);
#ifndef NVIC_CONF_VTABLE_OFFSET #define NVIC_VTABLE_ADDRESS ((uint32_t)&vectors)
#define NVIC_CONF_VTABLE_OFFSET 0x200000
#endif #endif
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -38,7 +38,7 @@
*/ */
#include "contiki.h" #include "contiki.h"
#include "reg.h" #include "reg.h"
#include "flash-cca.h" #include "flash.h"
#include "sys-ctrl.h" #include "sys-ctrl.h"
#include "rom-util.h" #include "rom-util.h"
@ -94,22 +94,7 @@ void pka_isr(void);
/* Allocate stack space */ /* Allocate stack space */
static unsigned long stack[512] __attribute__ ((section(".stack"))); static unsigned long stack[512] __attribute__ ((section(".stack")));
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Linker construct indicating .text section location */ __attribute__((__section__(".vectors")))
extern uint8_t _text[0];
/*---------------------------------------------------------------------------*/
__attribute__ ((section(".flashcca"), used))
const flash_cca_lock_page_t __cca = {
FLASH_CCA_BOOTLDR_CFG, /* Boot loader backdoor configuration */
FLASH_CCA_IMAGE_VALID, /* Image valid */
&_text, /* Vector table located at the start of .text */
/* Unlock all pages and debug */
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
};
/*---------------------------------------------------------------------------*/
__attribute__ ((section(".vectors"), used))
void(*const vectors[])(void) = void(*const vectors[])(void) =
{ {
(void (*)(void))((unsigned long)stack + sizeof(stack)), /* Stack pointer */ (void (*)(void))((unsigned long)stack + sizeof(stack)), /* Stack pointer */
@ -277,6 +262,18 @@ void(*const vectors[])(void) =
default_handler, /* 162 MACTimer */ default_handler, /* 162 MACTimer */
}; };
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
__attribute__((__section__(".flashcca")))
const flash_cca_lock_page_t flash_cca_lock_page = {
FLASH_CCA_BOOTLDR_CFG, /* Boot loader backdoor configuration */
FLASH_CCA_IMAGE_VALID, /* Image valid */
&vectors, /* Vector table */
/* Unlock all pages and debug */
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
};
/*---------------------------------------------------------------------------*/
/* Linker constructs indicating .data and .bss segment locations */ /* Linker constructs indicating .data and .bss segment locations */
extern uint8_t _ldata; extern uint8_t _ldata;
extern uint8_t _data; extern uint8_t _data;

View file

@ -647,6 +647,7 @@ static int
transmit(unsigned short transmit_len) transmit(unsigned short transmit_len)
{ {
int ret; int ret;
uint8_t was_off = 0;
uint32_t cmd_status; uint32_t cmd_status;
volatile rfc_CMD_PROP_TX_ADV_t *cmd_tx_adv; volatile rfc_CMD_PROP_TX_ADV_t *cmd_tx_adv;
@ -654,6 +655,7 @@ transmit(unsigned short transmit_len)
uint16_t total_length; uint16_t total_length;
if(!rf_is_on()) { if(!rf_is_on()) {
was_off = 1;
if(on() != RF_CORE_CMD_OK) { if(on() != RF_CORE_CMD_OK) {
PRINTF("transmit: on() failed\n"); PRINTF("transmit: on() failed\n");
return RADIO_TX_ERR; return RADIO_TX_ERR;
@ -739,6 +741,10 @@ transmit(unsigned short transmit_len)
rx_on_prop(); rx_on_prop();
if(was_off) {
off();
}
return ret; return ret;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -971,6 +977,8 @@ off(void)
rx_off_prop(); rx_off_prop();
rf_core_power_down(); rf_core_power_down();
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
/* Switch HF clock source to the RCOSC to preserve power */ /* Switch HF clock source to the RCOSC to preserve power */
oscillators_switch_to_hf_rc(); oscillators_switch_to_hf_rc();
@ -1058,6 +1066,12 @@ set_value(radio_param_t param, radio_value_t value)
return RADIO_RESULT_INVALID_VALUE; return RADIO_RESULT_INVALID_VALUE;
} }
if(get_channel() == (uint8_t)value) {
/* We already have that very same channel configured.
* Nothing to do here. */
return RADIO_RESULT_OK;
}
set_channel((uint8_t)value); set_channel((uint8_t)value);
break; break;
case RADIO_PARAM_TXPOWER: case RADIO_PARAM_TXPOWER:

View file

@ -28,7 +28,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of libmc1322x: see http://mc1322x.devl.org * This file is part of libmc1322x: see http://mc1322x.devl.org
* for details. * for details.
* *
* *
*/ */

View file

@ -80,15 +80,15 @@ ISR(TIMERA1, timera1)
++count; ++count;
/* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure
that the modulo operation below becomes a logical and and not that the modulo operation below becomes a logical and and not
an expensive divide. Algorithm from Wikipedia: an expensive divide. Algorithm from Wikipedia:
http://en.wikipedia.org/wiki/Power_of_two */ http://en.wikipedia.org/wiki/Power_of_two */
#if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
#error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...). #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
#error Change CLOCK_CONF_SECOND in contiki-conf.h. #error Change CLOCK_CONF_SECOND in contiki-conf.h.
#endif #endif
if(count % CLOCK_CONF_SECOND == 0) { if(count % CLOCK_CONF_SECOND == 0) {
++seconds; ++seconds;
energest_flush(); energest_flush();
} }
last_tar = read_tar(); last_tar = read_tar();

View file

@ -52,5 +52,3 @@ enum {
/**@} // End of addtogroup /**@} // End of addtogroup
*/ */

View file

@ -2,7 +2,7 @@
* @brief Cortex-M3 Non-Volatile Memory data storage system. * @brief Cortex-M3 Non-Volatile Memory data storage system.
* See @ref nvm for documentation. * See @ref nvm for documentation.
* *
* The functions in this file return an ::StStatus value. * The functions in this file return an ::StStatus value.
* See error-def.h for definitions of all ::StStatus return values. * See error-def.h for definitions of all ::StStatus return values.
* *
* See hal/micro/cortexm3/nvm.h for source code. * See hal/micro/cortexm3/nvm.h for source code.
@ -27,7 +27,7 @@
* that is a multiple of physical flash pages. There are two pages: LEFT * that is a multiple of physical flash pages. There are two pages: LEFT
* and RIGHT. The term "flash page" is used to refer to a page of * and RIGHT. The term "flash page" is used to refer to a page of
* physical flash. * physical flash.
* *
* NVM data storage works by alternating between two pages: LEFT and RIGHT. * NVM data storage works by alternating between two pages: LEFT and RIGHT.
* The basic algorithm is driven by a call to halCommonSaveToNvm(). It will: * The basic algorithm is driven by a call to halCommonSaveToNvm(). It will:
* - erase the inactive page * - erase the inactive page
@ -58,35 +58,35 @@
* is LEFT then the state machine will advance until state 7 and then exit. * is LEFT then the state machine will advance until state 7 and then exit.
* If "Read from" is RIGHT, then the state machine will advance until * If "Read from" is RIGHT, then the state machine will advance until
* state 3 and then exit. * state 3 and then exit.
* *
* @code * @code
* Starting from erased or invalid mgmt, write to LEFT * Starting from erased or invalid mgmt, write to LEFT
* State # 0 0 1 2 3 * State # 0 0 1 2 3
* Reads from: x x e w L L L * Reads from: x x e w L L L
* Valid xx|xx FF|FF r r 00|FF 00|FF 00|00 * Valid xx|xx FF|FF r r 00|FF 00|FF 00|00
* Active xx|xx FF|FF a i 00|FF 00|FF 00|00 * Active xx|xx FF|FF a i 00|FF 00|FF 00|00
* Dead xx|xx FF|FF s t FF|FF FF|00 FF|00 * Dead xx|xx FF|FF s t FF|FF FF|00 FF|00
* Spare xx|xx FF|FF e e FF|FF FF|FF FF|FF * Spare xx|xx FF|FF e e FF|FF FF|FF FF|FF
* *
* *
* Starting from LEFT page, transition to RIGHT page: * Starting from LEFT page, transition to RIGHT page:
* State # 3 4 5 6 7 * State # 3 4 5 6 7
* Reads from: L e L w R R R * Reads from: L e L w R R R
* Valid 00|00 r 00|FF r 00|00 00|00 00|00 * Valid 00|00 r 00|FF r 00|00 00|00 00|00
* Active 00|00 a 00|FF i 00|FF 00|FF 00|00 * Active 00|00 a 00|FF i 00|FF 00|FF 00|00
* Dead FF|00 s FF|FF t FF|FF 00|FF 00|FF * Dead FF|00 s FF|FF t FF|FF 00|FF 00|FF
* Spare FF|FF e FF|FF e FF|FF FF|FF FF|FF * Spare FF|FF e FF|FF e FF|FF FF|FF FF|FF
* *
* *
* Starting from RIGHT page, transition to LEFT page: * Starting from RIGHT page, transition to LEFT page:
* State # 7 8 9 10 3 * State # 7 8 9 10 3
* Reads from: R e R w L L L * Reads from: R e R w L L L
* Valid 00|00 r FF|00 r 00|00 00|00 00|00 * Valid 00|00 r FF|00 r 00|00 00|00 00|00
* Active 00|00 a FF|00 i FF|00 FF|00 00|00 * Active 00|00 a FF|00 i FF|00 FF|00 00|00
* Dead 00|FF s FF|FF t FF|FF FF|00 FF|00 * Dead 00|FF s FF|FF t FF|FF FF|00 FF|00
* Spare FF|FF e FF|FF e FF|FF FF|FF FF|FF * Spare FF|FF e FF|FF e FF|FF FF|FF FF|FF
* @endcode * @endcode
* *
* Based on the 10 possible states, there are 5 valid 32bit mgmt words: * Based on the 10 possible states, there are 5 valid 32bit mgmt words:
* - 0xFFFFFFFF * - 0xFFFFFFFF
* - 0xFFFFFF00 * - 0xFFFFFF00
@ -95,7 +95,7 @@
* - 0xFF00FFFF * - 0xFF00FFFF
* The algorithm determines the current state by using these 5 mgmt words * The algorithm determines the current state by using these 5 mgmt words
* with the 10 possible combinations of LEFT mgmt and RIGHT mgmt. * with the 10 possible combinations of LEFT mgmt and RIGHT mgmt.
* *
* Detailed State Description: * Detailed State Description:
* - State 0: * - State 0:
* In this state the mgmt bytes do not conform to any of the other states * In this state the mgmt bytes do not conform to any of the other states
@ -135,8 +135,8 @@
* Once at these states, the current page is marked Valid and Active and * Once at these states, the current page is marked Valid and Active and
* the old page is marked as Dead. The algorithm knows which page to * the old page is marked as Dead. The algorithm knows which page to
* read from and which page needs to be erased on the next write to the NVM. * read from and which page needs to be erased on the next write to the NVM.
* *
* *
* Notes on algorithm behavior: * Notes on algorithm behavior:
* - Refer to nvm-def.h for a list of offset/length that define the data * - Refer to nvm-def.h for a list of offset/length that define the data
* stored in NVM storage space. * stored in NVM storage space.
@ -189,14 +189,14 @@
/** /**
* @brief Copy the NVM data from flash into the provided RAM location. * @brief Copy the NVM data from flash into the provided RAM location.
* It is illegal for the offset to be greater than NVM_DATA_SIZE_B. * It is illegal for the offset to be greater than NVM_DATA_SIZE_B.
* *
* @param data A (RAM) pointer to where the data should be copied. * @param data A (RAM) pointer to where the data should be copied.
* *
* @param offset The location from which the data should be copied. Must be * @param offset The location from which the data should be copied. Must be
* 16bit aligned. * 16bit aligned.
* *
* @param length The length of the data in bytes. Must be 16bit aligned. * @param length The length of the data in bytes. Must be 16bit aligned.
* *
* @return An StStatus value indicating the success of the function. * @return An StStatus value indicating the success of the function.
* - ST_SUCCESS if the read completed cleanly. * - ST_SUCCESS if the read completed cleanly.
* - ST_ERR_FATAL if the NVM storage management indicated an invalid * - ST_ERR_FATAL if the NVM storage management indicated an invalid
@ -206,10 +206,10 @@ StStatus halCommonReadFromNvm(void *data, uint32_t offset, uint16_t length);
/** /**
* @brief Return the address of the token in NVM * @brief Return the address of the token in NVM
* *
* @param offset The location offset from which the address should be returned * @param offset The location offset from which the address should be returned
* *
* *
* @return The address requested * @return The address requested
*/ */
uint16_t *halCommonGetAddressFromNvm(uint32_t offset); uint16_t *halCommonGetAddressFromNvm(uint32_t offset);
@ -217,14 +217,14 @@ uint16_t *halCommonGetAddressFromNvm(uint32_t offset);
/** /**
* @brief Write the NVM data from the provided location RAM into flash. * @brief Write the NVM data from the provided location RAM into flash.
* It is illegal for the offset to be greater than NVM_DATA_SIZE_B. * It is illegal for the offset to be greater than NVM_DATA_SIZE_B.
* *
* @param data A (RAM) pointer from where the data should be taken. * @param data A (RAM) pointer from where the data should be taken.
* *
* @param offset The location to which the data should be written. Must be * @param offset The location to which the data should be written. Must be
* 16bit aligned. * 16bit aligned.
* *
* @param length The length of the data in bytes. Must be 16bit aligned. * @param length The length of the data in bytes. Must be 16bit aligned.
* *
* @return An StStatus value indicating the success of the function. * @return An StStatus value indicating the success of the function.
* - ST_SUCCESS if the write completed cleanly. * - ST_SUCCESS if the write completed cleanly.
* - Any other status value is an error code generated by the low level * - Any other status value is an error code generated by the low level

View file

@ -23,14 +23,14 @@ typedef enum
/** /**
* @brief Initialize the UART * @brief Initialize the UART
* *
* @param baudrate The baudrate which will be used for communication. * @param baudrate The baudrate which will be used for communication.
* Ex: 115200 * Ex: 115200
* *
* @param databits The number of data bits used for communication. * @param databits The number of data bits used for communication.
* Valid values are 7 or 8 * Valid values are 7 or 8
* *
* @param parity The type of parity used for communication. * @param parity The type of parity used for communication.
* See the SerialParity enum for possible values * See the SerialParity enum for possible values
* *
* @return stopbits The number of stop bits used for communication. * @return stopbits The number of stop bits used for communication.
@ -45,9 +45,9 @@ void uartInit(uint32_t baudrate, uint8_t databits, SerialParity parity, uint8_t
* instead which does not define fflush(). Therefore, we manually define * instead which does not define fflush(). Therefore, we manually define
* fflush() in the low level UART driver. This function simply redirects * fflush() in the low level UART driver. This function simply redirects
* to the __write() function with a NULL buffer, triggering a flush. * to the __write() function with a NULL buffer, triggering a flush.
* *
* @param handle The output stream. Should be set to 'stdout' like normal. * @param handle The output stream. Should be set to 'stdout' like normal.
* *
* @return Zero, indicating success. * @return Zero, indicating success.
*/ */
size_t fflush(int handle); size_t fflush(int handle);
@ -61,7 +61,7 @@ size_t fflush(int handle);
#define stdout _LLIO_STDOUT #define stdout _LLIO_STDOUT
#endif #endif
/** /**
* @brief Read the input byte if any. * @brief Read the input byte if any.
*/ */
boolean __io_getcharNonBlocking(uint8_t *data); boolean __io_getcharNonBlocking(uint8_t *data);
void __io_putchar( char c ); void __io_putchar( char c );

View file

@ -1,6 +1,6 @@
/** /**
* \brief Compiler and Platform specific definitions and typedefs common to * \brief Compiler and Platform specific definitions and typedefs common to
* all platforms. * all platforms.
* *
* platform-common.h provides PLATFORM_HEADER defaults and common definitions. * platform-common.h provides PLATFORM_HEADER defaults and common definitions.
* This head should never be included directly, it should only be included * This head should never be included directly, it should only be included
@ -20,7 +20,7 @@
* <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. --> * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
*/ */
#ifndef PLATCOMMONOKTOINCLUDE #ifndef PLATCOMMONOKTOINCLUDE
// This header should only be included by a PLATFORM_HEADER // This header should only be included by a PLATFORM_HEADER
#error platform-common.h should not be included directly #error platform-common.h should not be included directly
@ -29,7 +29,7 @@
#ifndef PLATFORMCOMMON_H_ #ifndef PLATFORMCOMMON_H_
#define PLATFORMCOMMON_H_ #define PLATFORMCOMMON_H_
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Many of the common definitions must be explicitly enabled by the // Many of the common definitions must be explicitly enabled by the
// particular PLATFORM_HEADER being used // particular PLATFORM_HEADER being used
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -69,16 +69,16 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifdef _HAL_USE_COMMON_DIVMOD_ #ifdef _HAL_USE_COMMON_DIVMOD_
/** \name Divide and Modulus Operations /** \name Divide and Modulus Operations
* Some platforms can perform divide and modulus operations on 32 bit * Some platforms can perform divide and modulus operations on 32 bit
* quantities more efficiently when the divisor is only a 16 bit quantity. * quantities more efficiently when the divisor is only a 16 bit quantity.
* C compilers will always promote the divisor to 32 bits before performing the * C compilers will always promote the divisor to 32 bits before performing the
* operation, so the following utility functions are instead required to take * operation, so the following utility functions are instead required to take
* advantage of this optimisation. * advantage of this optimisation.
*/ */
//@{ //@{
/** /**
* \brief Provide a portable name for the uint32_t by uint16_t division * \brief Provide a portable name for the uint32_t by uint16_t division
* library function (which can perform the division with only a single * library function (which can perform the division with only a single
* assembly instruction on some platforms) * assembly instruction on some platforms)
*/ */
#define halCommonUDiv32By16(x, y) ((uint16_t) (((uint32_t) (x)) / ((uint16_t) (y)))) #define halCommonUDiv32By16(x, y) ((uint16_t) (((uint32_t) (x)) / ((uint16_t) (y))))
@ -111,12 +111,12 @@
#ifdef _HAL_USE_COMMON_MEMUTILS_ #ifdef _HAL_USE_COMMON_MEMUTILS_
/** \name C Standard Library Memory Utilities /** \name C Standard Library Memory Utilities
* These should be used in place of the standard library functions. * These should be used in place of the standard library functions.
* *
* These functions have the same parameters and expected results as their C * These functions have the same parameters and expected results as their C
* Standard Library equivalents but may take advantage of certain implementation * Standard Library equivalents but may take advantage of certain implementation
* optimizations. * optimizations.
* *
* Unless otherwise noted, these functions are utilized by the StStack and are * Unless otherwise noted, these functions are utilized by the StStack and are
* therefore required to be implemented in the HAL. Additionally, unless otherwise * therefore required to be implemented in the HAL. Additionally, unless otherwise
* noted, applications that find these functions useful may utilze them. * noted, applications that find these functions useful may utilze them.
*/ */
@ -212,22 +212,22 @@
#define SETBIT(reg, bit) reg |= BIT(bit) #define SETBIT(reg, bit) reg |= BIT(bit)
/** /**
* \brief Sets the bits in the \c reg register or the byte * \brief Sets the bits in the \c reg register or the byte
* as specified in the bitmask \c bits. * as specified in the bitmask \c bits.
* @note This is never a single atomic operation. * @note This is never a single atomic operation.
*/ */
#define SETBITS(reg, bits) reg |= (bits) #define SETBITS(reg, bits) reg |= (bits)
/** /**
* \brief Clears a bit in the \c reg register or byte. * \brief Clears a bit in the \c reg register or byte.
* @note Assuming \c reg is an IO register, some platforms (such as the AVR) * @note Assuming \c reg is an IO register, some platforms (such as the AVR)
* can implement this in a single atomic operation. * can implement this in a single atomic operation.
*/ */
#define CLEARBIT(reg, bit) reg &= ~(BIT(bit)) #define CLEARBIT(reg, bit) reg &= ~(BIT(bit))
/** /**
* \brief Clears the bits in the \c reg register or byte * \brief Clears the bits in the \c reg register or byte
* as specified in the bitmask \c bits. * as specified in the bitmask \c bits.
* @note This is never a single atomic operation. * @note This is never a single atomic operation.
*/ */
#define CLEARBITS(reg, bits) reg &= ~(bits) #define CLEARBITS(reg, bits) reg &= ~(bits)
@ -238,7 +238,7 @@
#define READBIT(reg, bit) (reg & (BIT(bit))) #define READBIT(reg, bit) (reg & (BIT(bit)))
/** /**
* \brief Returns the value of the bitmask \c bits within * \brief Returns the value of the bitmask \c bits within
* the register or byte \c reg. * the register or byte \c reg.
*/ */
#define READBITS(reg, bits) (reg & (bits)) #define READBITS(reg, bits) (reg & (bits))
@ -263,13 +263,13 @@
#define HIGH_BYTE(n) ((uint8_t)(LOW_BYTE((n) >> 8))) #define HIGH_BYTE(n) ((uint8_t)(LOW_BYTE((n) >> 8)))
/** /**
* \brief Returns the value built from the two \c uint8_t * \brief Returns the value built from the two \c uint8_t
* values \c high and \c low. * values \c high and \c low.
*/ */
#define HIGH_LOW_TO_INT(high, low) ( \ #define HIGH_LOW_TO_INT(high, low) ( \
(( (uint16_t) (high) ) << 8) + \ (( (uint16_t) (high) ) << 8) + \
( (uint16_t) ( (low) & 0xFF)) \ ( (uint16_t) ( (low) & 0xFF)) \
) )
/** /**
* \brief Returns the low byte of the 32-bit value \c n as an \c uint8_t. * \brief Returns the low byte of the 32-bit value \c n as an \c uint8_t.
@ -301,21 +301,21 @@
//@{ //@{
/** /**
* \brief Returns the elapsed time between two 8 bit values. * \brief Returns the elapsed time between two 8 bit values.
* Result may not be valid if the time samples differ by more than 127 * Result may not be valid if the time samples differ by more than 127
*/ */
#define elapsedTimeInt8u(oldTime, newTime) \ #define elapsedTimeInt8u(oldTime, newTime) \
((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime))) ((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime)))
/** /**
* \brief Returns the elapsed time between two 16 bit values. * \brief Returns the elapsed time between two 16 bit values.
* Result may not be valid if the time samples differ by more than 32767 * Result may not be valid if the time samples differ by more than 32767
*/ */
#define elapsedTimeInt16u(oldTime, newTime) \ #define elapsedTimeInt16u(oldTime, newTime) \
((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime))) ((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime)))
/** /**
* \brief Returns the elapsed time between two 32 bit values. * \brief Returns the elapsed time between two 32 bit values.
* Result may not be valid if the time samples differ by more than 2147483647 * Result may not be valid if the time samples differ by more than 2147483647
*/ */
#define elapsedTimeInt32u(oldTime, newTime) \ #define elapsedTimeInt32u(oldTime, newTime) \

View file

@ -149,4 +149,3 @@ StStatus halBootloaderStart(uint8_t mode, uint8_t channel, uint16_t panId);
/** @} END micro group */ /** @} END micro group */
/** @} */ /** @} */

View file

@ -7,11 +7,11 @@
* \defgroup sicslowpan 6LoWPAN implementation * \defgroup sicslowpan 6LoWPAN implementation
* @{ * @{
6lowpan is a Working Group in IETF which defines the use of IPv6 on 6lowpan is a Working Group in IETF which defines the use of IPv6 on
IEEE 802.15.4 links. IEEE 802.15.4 links.
Our implementation is based on RFC4944 <em>Transmission of IPv6 Our implementation is based on RFC4944 <em>Transmission of IPv6
Packets over IEEE 802.15.4 Networks</em>, draft-hui-6lowpan-interop-00 Packets over IEEE 802.15.4 Networks</em>, draft-hui-6lowpan-interop-00
<em>Interoperability Test for 6LoWPAN</em>, and draft-hui-6lowpan-hc-01 <em>Interoperability Test for 6LoWPAN</em>, and draft-hui-6lowpan-hc-01
<em>Compression format for IPv6 datagrams in 6lowpan Networks</em>. <em>Compression format for IPv6 datagrams in 6lowpan Networks</em>.
@ -24,7 +24,7 @@ Packets over IEEE 802.15.4 Networks</em>, draft-hui-6lowpan-interop-00
\subsection rfc4944 RFC 4944 \subsection rfc4944 RFC 4944
RFC4944 defines address configuration mechanisms based on 802.15.4 RFC4944 defines address configuration mechanisms based on 802.15.4
16-bit and 64-bit addresses, fragmentation of IPv6 packets below IP 16-bit and 64-bit addresses, fragmentation of IPv6 packets below IP
layer, IPv6 and UDP header compression, a mesh header to enable link-layer layer, IPv6 and UDP header compression, a mesh header to enable link-layer
forwarding in a mesh under topology, and a broadcast header to enable forwarding in a mesh under topology, and a broadcast header to enable
broadcast in a mesh under topology. broadcast in a mesh under topology.
@ -32,7 +32,7 @@ broadcast in a mesh under topology.
We implement addressing, fragmentation, and header compression. We support We implement addressing, fragmentation, and header compression. We support
the header compression scenarios defined in draft-hui-6lowpan-interop-00. the header compression scenarios defined in draft-hui-6lowpan-interop-00.
This draft defines an interoperability scenario which was used between This draft defines an interoperability scenario which was used between
ArchRock and Sensinode implementations. ArchRock and Sensinode implementations.
We do not implement mesh under related features, as we target route over We do not implement mesh under related features, as we target route over
@ -40,8 +40,8 @@ techniques.
\subsection hc01 draft-hui-6lowpan-hc-01 \subsection hc01 draft-hui-6lowpan-hc-01
draft-hui-6lowpan-hc-01 defines a stateful header compression mechanism draft-hui-6lowpan-hc-01 defines a stateful header compression mechanism
which should soon deprecate the stateless header compression mechanism which should soon deprecate the stateless header compression mechanism
defined in RFC4944. It is much more powerfull and flexible, in defined in RFC4944. It is much more powerfull and flexible, in
particular it allows compression of some multicast addresses and of all particular it allows compression of some multicast addresses and of all
global unicast addresses. global unicast addresses.
@ -59,7 +59,7 @@ It is initialized from the MAC %process, which calls sicslowpan_init
The main 6lowpan functions are implemented in the sicslowpan.h and The main 6lowpan functions are implemented in the sicslowpan.h and
sicslowpan.c files. They are used to format packets between the sicslowpan.c files. They are used to format packets between the
802.15.4 and the IPv6 layers. 802.15.4 and the IPv6 layers.
6lowpan also creates a few IPv6 and link-layer dependencies which are 6lowpan also creates a few IPv6 and link-layer dependencies which are
detailed in the next section. detailed in the next section.
@ -89,13 +89,13 @@ typedef struct uip_802154_longaddr uip_lladdr_t;
\endcode \endcode
<b>Neighbor Discovery Link Layer Address options </b><br> <b>Neighbor Discovery Link Layer Address options </b><br>
The format of ND link-layer address options depends on the length of The format of ND link-layer address options depends on the length of
the link-layer addresses. the link-layer addresses.
802.15.4 specificities regarding link-layer address options are implemented in uip-nd6.h. 802.15.4 specificities regarding link-layer address options are implemented in uip-nd6.h.
\code \code
#define UIP_ND6_OPT_SHORT_LLAO_LEN 8 #define UIP_ND6_OPT_SHORT_LLAO_LEN 8
#define UIP_ND6_OPT_LONG_LLAO_LEN 16 #define UIP_ND6_OPT_LONG_LLAO_LEN 16
#define UIP_ND6_OPT_LLAO_LEN UIP_ND6_OPT_LONG_LLAO_LEN #define UIP_ND6_OPT_LLAO_LEN UIP_ND6_OPT_LONG_LLAO_LEN
\endcode \endcode
<b>Address Autoconfiguration</b><br> <b>Address Autoconfiguration</b><br>
@ -105,7 +105,7 @@ the link-layer address. The dependency is reflected in the
\code \code
#if (UIP_LLADDR_LEN == 8) #if (UIP_LLADDR_LEN == 8)
memcpy(ipaddr->u8 + 8, lladdr, UIP_LLADDR_LEN); memcpy(ipaddr->u8 + 8, lladdr, UIP_LLADDR_LEN);
ipaddr->u8[8] ^= 0x02; ipaddr->u8[8] ^= 0x02;
\endcode \endcode
\subsection io Packet Input/Output \subsection io Packet Input/Output
@ -119,24 +119,24 @@ destination link-layer addresses as two rime addresses.
\code \code
packetbuf_copyfrom(&rx_frame.payload, rx_frame.payload_length); packetbuf_copyfrom(&rx_frame.payload, rx_frame.payload_length);
packetbuf_set_datalen(rx_frame.payload_length); packetbuf_set_datalen(rx_frame.payload_length);
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (const rimeaddr_t *)&rx_frame.dest_addr); packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (const rimeaddr_t *)&rx_frame.dest_addr);
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (const rimeaddr_t *)&rx_frame.src_addr); packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (const rimeaddr_t *)&rx_frame.src_addr);
\endcode \endcode
It then calls the sicslowpan #input function. Similarly, when the IPv6 layer It then calls the sicslowpan #input function. Similarly, when the IPv6 layer
has a packet to send over the radio, it puts the packet in uip_buf, has a packet to send over the radio, it puts the packet in uip_buf,
sets uip_len and calls the sicslowpan #output function. sets uip_len and calls the sicslowpan #output function.
\subsection frag Fragmentation \subsection frag Fragmentation
\li #output function: When an IP packet, after header compression, is \li #output function: When an IP packet, after header compression, is
too big to fit in a 802.15.4 frame, it is fragmented in several packets too big to fit in a 802.15.4 frame, it is fragmented in several packets
which are sent successively over the radio. The packets are formatted which are sent successively over the radio. The packets are formatted
as defined in RFC 4944. Only the first fragment contains the IP/UDP as defined in RFC 4944. Only the first fragment contains the IP/UDP
compressed or uncompressed header fields. compressed or uncompressed header fields.
\li #input function: This function takes care of fragment \li #input function: This function takes care of fragment
reassembly. We do not assume that the fragments are received in order. reassembly. We do not assume that the fragments are received in order.
When reassembly of a packet is ongoing, we discard any non fragmented When reassembly of a packet is ongoing, we discard any non fragmented
packet or fragment from another packet. Reassembly times out after packet or fragment from another packet. Reassembly times out after
#SICSLOWPAN_REASS_MAXAGE = 20s. #SICSLOWPAN_REASS_MAXAGE = 20s.
@ -145,7 +145,7 @@ compilation option.
\note As we do not support complex buffer allocation mechanism, for now \note As we do not support complex buffer allocation mechanism, for now
we define a new 1280 bytes buffer (#sicslowpan_buf) to reassemble packets. we define a new 1280 bytes buffer (#sicslowpan_buf) to reassemble packets.
At reception, once all the fragments are received, we copy the packet At reception, once all the fragments are received, we copy the packet
to #uip_buf, set #uip_len, and call #tcpip_input. to #uip_buf, set #uip_len, and call #tcpip_input.
\note #MAC_MAX_PAYLOAD defines the maximum payload \note #MAC_MAX_PAYLOAD defines the maximum payload
@ -161,7 +161,7 @@ The #SICSLOWPAN_CONF_COMPRESSION compilation option defines the
HC1 and IPv6 compression are defined in RFC4944, HC01 in HC1 and IPv6 compression are defined in RFC4944, HC01 in
draft-hui-6lowpan-hc. What we call IPv6 compression means sending packets draft-hui-6lowpan-hc. What we call IPv6 compression means sending packets
with no compression, and adding the IPv6 dispatch before the IPv6 header.<br> with no compression, and adding the IPv6 dispatch before the IPv6 header.<br>
If at compile time IPv6 "compression" is chosen, packets sent will never If at compile time IPv6 "compression" is chosen, packets sent will never
be compressed, and compressed packets will not be processed at reception.<br> be compressed, and compressed packets will not be processed at reception.<br>
If at compile time either HC1 or HC01 are chosen, we will try to compress If at compile time either HC1 or HC01 are chosen, we will try to compress
all fields at sending, and will accept packets compressed with the all fields at sending, and will accept packets compressed with the
@ -170,7 +170,7 @@ Note that HC1 and HC01 supports are mutually exclusive. HC01 should soon
deprecate HC1. deprecate HC1.
<b>Compression related functions</b><br> <b>Compression related functions</b><br>
When a packet is received, the #input function is called. Fragmentation When a packet is received, the #input function is called. Fragmentation
issues are handled, then we check the dispatch byte: if it is IPv6, we issues are handled, then we check the dispatch byte: if it is IPv6, we
treat the packet inline. If it is HC1 or HC01, the corresponding treat the packet inline. If it is HC1 or HC01, the corresponding
decompression function (#uncompress_hdr_hc1 or #uncompress_hdr_hc01) decompression function (#uncompress_hdr_hc1 or #uncompress_hdr_hc01)
@ -184,21 +184,21 @@ to compress the packet as much as possible.
<b>HC1 comments</b><br> <b>HC1 comments</b><br>
In HC1, if the IPv6 flow label is not compressed, we would need to copy In HC1, if the IPv6 flow label is not compressed, we would need to copy
the fields after the flow label starting in the middle of a byte (the the fields after the flow label starting in the middle of a byte (the
flow label is 20 bits long). To avoid this, we compress the packets only flow label is 20 bits long). To avoid this, we compress the packets only
if all fields can be compressed. If we cannot, we use the IPv6 dispatch if all fields can be compressed. If we cannot, we use the IPv6 dispatch
and send all headers fields inline. This behavior is the one defined in and send all headers fields inline. This behavior is the one defined in
draft-hui-6lowpan-interop-00.<br> draft-hui-6lowpan-interop-00.<br>
In the same way, if the packet is an UDP packet, we compress the UDP In the same way, if the packet is an UDP packet, we compress the UDP
header only if all fields can be compressed.<br> header only if all fields can be compressed.<br>
Note that HC1 can only compress unicast link local addresses. For this Note that HC1 can only compress unicast link local addresses. For this
reason, we recommend using HC01. reason, we recommend using HC01.
<b>HC01 comments</b><br> <b>HC01 comments</b><br>
HC01 uses address contexts to enable compression of global unicast HC01 uses address contexts to enable compression of global unicast
addresses. All nodes must share context (namely the global prefixes in addresses. All nodes must share context (namely the global prefixes in
use) to compress and uncompress such addresses successfully. The context use) to compress and uncompress such addresses successfully. The context
number is defined by 2 bits. Context 00 is reserved for the link local number is defined by 2 bits. Context 00 is reserved for the link local
context. Other contexts have to be distributed within the LoWPAN context. Other contexts have to be distributed within the LoWPAN
dynamically, by means of ND extensions yet to be defined.<br> dynamically, by means of ND extensions yet to be defined.<br>
Until then, if you want to test global address compression, you need Until then, if you want to test global address compression, you need
to configure the global contexts manually. to configure the global contexts manually.

View file

@ -6,7 +6,7 @@
/** /**
* \defgroup uip6 uIP IPv6 specific features * \defgroup uip6 uIP IPv6 specific features
* *
The uIP IPv6 stack provides new Internet communication abilities to Contiki. The uIP IPv6 stack provides new Internet communication abilities to Contiki.
This document describes Ipv6 specific features. For features that This document describes Ipv6 specific features. For features that
are common to the IPv4 and IPv6 code please refer to \ref uip "uIP". are common to the IPv4 and IPv6 code please refer to \ref uip "uIP".
@ -21,7 +21,7 @@ for extensions and options, and its new QoS and security capabilities.
The uip IPv6 stack implementation targets constrained devices such as The uip IPv6 stack implementation targets constrained devices such as
sensors. The code size is around 11.5Kbyte and the RAM usage around sensors. The code size is around 11.5Kbyte and the RAM usage around
1.7Kbyte (see \ref size "below" for more detailed information). 1.7Kbyte (see \ref size "below" for more detailed information).
Our implementation follows closely RFC 4294 <em>IPv6 Node Requirements</em> Our implementation follows closely RFC 4294 <em>IPv6 Node Requirements</em>
whose goal is to allow "IPv6 to function well and whose goal is to allow "IPv6 to function well and
interoperate in a large number of situations and deployments". interoperate in a large number of situations and deployments".
@ -38,12 +38,12 @@ http://www.ietf.org/rfc.html.
\note The #NETSTACK_CONF_WITH_IPV6 compilation flag is used to enable IPv6. \note The #NETSTACK_CONF_WITH_IPV6 compilation flag is used to enable IPv6.
It is also recommended to set #UIP_CONF_IPV6_CHECKS to 1 It is also recommended to set #UIP_CONF_IPV6_CHECKS to 1
if one cannot guarantee that the incoming packets are correctly formed. if one cannot guarantee that the incoming packets are correctly formed.
\subsection ipv6 IPv6 (RFC 2460) \subsection ipv6 IPv6 (RFC 2460)
The IP packets are processed in the #uip_process function. The IP packets are processed in the #uip_process function.
After a few validity checks on the IPv6 header, the extension headers After a few validity checks on the IPv6 header, the extension headers
are processed until an upper layer (ICMPv6, UDP or TCP) header is found. are processed until an upper layer (ICMPv6, UDP or TCP) header is found.
We support 4 extension headers: We support 4 extension headers:
\li Hop-by-Hop Options: this header is used to carry optional \li Hop-by-Hop Options: this header is used to carry optional
information that need to be examined only by a packet's destination node. information that need to be examined only by a packet's destination node.
@ -81,18 +81,18 @@ typedef union uip_ip6addr_t {
\endcode \endcode
We assume that each node has a <em>single interface</em> of type We assume that each node has a <em>single interface</em> of type
#uip_ds6_netif_t. #uip_ds6_netif_t.
Each interface can have a configurable number of unicast IPv6 Each interface can have a configurable number of unicast IPv6
addresses including its link-local address. It also has a addresses including its link-local address. It also has a
solicited-node multicast address. We assume that the unicast solicited-node multicast address. We assume that the unicast
addresses are obtained via \ref autoconf "stateless address autoconfiguration" addresses are obtained via \ref autoconf "stateless address autoconfiguration"
so that the solicited-node address is the same for all the so that the solicited-node address is the same for all the
unicast addresses. Indeed, the solicited-node multicast address unicast addresses. Indeed, the solicited-node multicast address
is formed by combining the prefix FF02::1:FF00:0/104 and the is formed by combining the prefix FF02::1:FF00:0/104 and the
last 24-bits of the corresponding IPv6 address. When using stateless address last 24-bits of the corresponding IPv6 address. When using stateless address
autoconfiguration these bits are always equal to the last 24-bits of autoconfiguration these bits are always equal to the last 24-bits of
the link-layer address. the link-layer address.
\subsection multicast Multicast support \subsection multicast Multicast support
We do not support applications using multicast. Nevertheless, our node We do not support applications using multicast. Nevertheless, our node
@ -108,7 +108,7 @@ safely skipped and we do so.
other's presence, to determine each other's link-layer addresses, to other's presence, to determine each other's link-layer addresses, to
find routers, and to maintain reachability information about the paths find routers, and to maintain reachability information about the paths
to active neighbors" (citation from the abstract of RFC to active neighbors" (citation from the abstract of RFC
4861). 4861).
\note In IPv6 terminology, a \em link is a communication medium over \note In IPv6 terminology, a \em link is a communication medium over
which nodes can communicate at the link layer, i.e., the layer which nodes can communicate at the link layer, i.e., the layer
@ -157,7 +157,7 @@ different entry fields.
<b>Neighbor discovery processes </b><br> <b>Neighbor discovery processes </b><br>
\li Address resolution\n \li Address resolution\n
Determine the link-layer address of a %neighbor given its IPv6 address.\n Determine the link-layer address of a %neighbor given its IPv6 address.\n
-> send a NS (done in #tcpip_ipv6_output). -> send a NS (done in #tcpip_ipv6_output).
\li Neighbor unreachability detection\n \li Neighbor unreachability detection\n
Verify that a neighbor is still reachable via a cached link-layer Verify that a neighbor is still reachable via a cached link-layer
address.\n address.\n
@ -183,7 +183,7 @@ Configure an address for an interface by combining a received prefix
and the interface ID (see #uip_netif_addr_add). The interface ID is and the interface ID (see #uip_netif_addr_add). The interface ID is
obtained from the link-layer address using #uip_netif_get_interface_id.\n obtained from the link-layer address using #uip_netif_get_interface_id.\n
-> Receive a RA with a prefix information option that has the -> Receive a RA with a prefix information option that has the
autonomous flag set. autonomous flag set.
When an interface becomes active, its link-local address is created When an interface becomes active, its link-local address is created
by combining the FE80::0/64 prefix and the interface ID. DAD is then by combining the FE80::0/64 prefix and the interface ID. DAD is then
@ -196,14 +196,14 @@ performed in #uip_netif_init.
\subsection icmpv6 ICMPv6 (RFC 4443) \subsection icmpv6 ICMPv6 (RFC 4443)
We support ICMPv6 Error messages as well as Echo Reply and Echo Request We support ICMPv6 Error messages as well as Echo Reply and Echo Request
messages. The application used for sending Echo Requests (see ping6.c) messages. The application used for sending Echo Requests (see ping6.c)
is not part of the IP stack. is not part of the IP stack.
\note RFC 4443 stipulates that 'Every ICMPv6 error message MUST \note RFC 4443 stipulates that 'Every ICMPv6 error message MUST
include as much of the IPv6 offending (invoking) packet as include as much of the IPv6 offending (invoking) packet as
possible'. In a constrained environment this is not very resource possible'. In a constrained environment this is not very resource
friendly. friendly.
The ICMPv6 message headers and constants are defined in uip-icmp6.h. The ICMPv6 message headers and constants are defined in uip-icmp6.h.
<HR> <HR>
@ -232,16 +232,16 @@ This could be avoided by using callback timers to handle ND and Netif structures
<HR> <HR>
\section compileflags Compile time flags and variables \section compileflags Compile time flags and variables
This section just lists all IPv6 related compile time flags. Each flag This section just lists all IPv6 related compile time flags. Each flag
function is documented in this page in the appropriate section. function is documented in this page in the appropriate section.
\code \code
/*Boolean flags*/ /*Boolean flags*/
NETSTACK_CONF_WITH_IPV6 NETSTACK_CONF_WITH_IPV6
UIP_CONF_IPV6_CHECKS UIP_CONF_IPV6_CHECKS
UIP_CONF_IPV6_QUEUE_PKT UIP_CONF_IPV6_QUEUE_PKT
UIP_CONF_IPV6_REASSEMBLY UIP_CONF_IPV6_REASSEMBLY
/*Integer flags*/ /*Integer flags*/
UIP_CONF_NETIF_MAX_ADDRESSES UIP_CONF_NETIF_MAX_ADDRESSES
NBR_TABLE_CONF_MAX_NEIGHBORS NBR_TABLE_CONF_MAX_NEIGHBORS
\endcode \endcode
@ -252,7 +252,7 @@ The IPv6 code uses the same \ref memory "single global buffer" as the
IPv4 code. This buffer should be large enough to contain one IPv4 code. This buffer should be large enough to contain one
packet of maximum size, i.e., #UIP_LINK_MTU = 1280 bytes. When \ref packet of maximum size, i.e., #UIP_LINK_MTU = 1280 bytes. When \ref
reass "fragment reassembly" is enabled an additional buffer of the reass "fragment reassembly" is enabled an additional buffer of the
same size is used. same size is used.
The only difference with the IPv4 code is the per %neighbor buffering The only difference with the IPv4 code is the per %neighbor buffering
that is available when #UIP_CONF_IPV6_QUEUE_PKT is set to 1. This that is available when #UIP_CONF_IPV6_QUEUE_PKT is set to 1. This
@ -272,20 +272,20 @@ our code. These numbers are obtained using 'avr-gcc 4.2.2 (WinAVR
\note The following compilation flags were used: \note The following compilation flags were used:
\code \code
UIP_CONF_IPV6 1 UIP_CONF_IPV6 1
UIP_CONF_IPV6_CHECKS 1 UIP_CONF_IPV6_CHECKS 1
UIP_CONF_IPV6_QUEUE_PKT 0 UIP_CONF_IPV6_QUEUE_PKT 0
UIP_CONF_IPV6_REASSEMBLY 0 UIP_CONF_IPV6_REASSEMBLY 0
UIP_NETIF_MAX_ADDRESSES 3 UIP_NETIF_MAX_ADDRESSES 3
UIP_ND6_MAX_PREFIXES 3 UIP_ND6_MAX_PREFIXES 3
UIP_ND6_MAX_NEIGHBORS 4 UIP_ND6_MAX_NEIGHBORS 4
UIP_ND6_MAX_DEFROUTER 2 UIP_ND6_MAX_DEFROUTER 2
\endcode \endcode
The total IPv6 code size is approximately 11.5Kbyte and the RAM usage around The total IPv6 code size is approximately 11.5Kbyte and the RAM usage around
1.8Kbyte. For an additional NEIGHBOR count 35bytes, 25 for an additional 1.8Kbyte. For an additional NEIGHBOR count 35bytes, 25 for an additional
PREFIX, 7 for an additional DEFROUTER, and 25 for an additional ADDRESS. PREFIX, 7 for an additional DEFROUTER, and 25 for an additional ADDRESS.
<HR> <HR>
@ -345,7 +345,7 @@ We will soon support RFC4944 transmission of IPv6 packets over 802.15.4\n
\li ICMPv6 RFC 4443 (MUST): full support \li ICMPv6 RFC 4443 (MUST): full support
\li IPv6 addressing architecture RFC 3513 (MUST): full support \li IPv6 addressing architecture RFC 3513 (MUST): full support
\li Privacy extensions for address autoconfiguration RFC 3041 (SHOULD): no support. \li Privacy extensions for address autoconfiguration RFC 3041 (SHOULD): no support.
\li Default Address Selection RFC 3484 (MUST): full support. \li Default Address Selection RFC 3484 (MUST): full support.
\li MLDv1 (RFC 2710) and MLDv2 (RFC 3810) (conditional MUST applying here): no support. As we run IPv6 over Multicast or broadcast capable links (Ethernet or 802.15.4), the conditional MUST applies. We should be able to send an MLD report when joining a solicited node multicast group at address configuration time. This will be available in a later release. \li MLDv1 (RFC 2710) and MLDv2 (RFC 3810) (conditional MUST applying here): no support. As we run IPv6 over Multicast or broadcast capable links (Ethernet or 802.15.4), the conditional MUST applies. We should be able to send an MLD report when joining a solicited node multicast group at address configuration time. This will be available in a later release.
<b>DNS (RFC 1034, 1035, 3152, 3363, 3596) and DHCPv6 (RFC 3315) (conditional MUST)</b><br> <b>DNS (RFC 1034, 1035, 3152, 3363, 3596) and DHCPv6 (RFC 3315) (conditional MUST)</b><br>

View file

@ -121,7 +121,6 @@ output(void)
} else { } else {
PRINTF("SUT: %u\n", uip_len); PRINTF("SUT: %u\n", uip_len);
slip_send(); slip_send();
printf("\n");
} }
return 0; return 0;
} }

View file

@ -1 +0,0 @@
TARGET = remote

View file

@ -1 +0,0 @@
TARGET = z1

View file

@ -1,15 +0,0 @@
CONTIKI = ../../..
ifndef TARGET
TARGET=z1
endif
CONTIKI_PROJECT = test-phidgets blink test-adxl345 tmp102-test test-battery test-sht11 #test-potent
CONTIKI_SOURCEFILES += cc2420-arch.c sensors.c sht11.c
PROJECT_SOURCEFILES = i2cmaster.c tmp102.c adxl345.c battery-sensor.c sky-sensors.c #potentiometer-sensor.c
all: example-unicast2
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -15,6 +15,6 @@ CONTIKI_PROJECT += test-potent
endif endif
all: $(CONTIKI_PROJECT) all: $(CONTIKI_PROJECT)
CONTIKI = ../.. CONTIKI = ../../..
CONTIKI_WITH_RIME = 1 CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include include $(CONTIKI)/Makefile.include

View file

@ -1,6 +1,6 @@
all: z1-websense all: z1-websense
CONTIKI=../../../.. CONTIKI=../../../../..
SMALL=1 SMALL=1

View file

@ -27,7 +27,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A simple example using HTTP to control and be controlled * A simple example using HTTP to control and be controlled
@ -35,7 +35,7 @@
* Niclas Finne <nfi@sics.se> * Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se> * Joakim Eriksson <joakime@sics.se>
*/ */
/*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/leds.h" #include "dev/leds.h"
@ -43,7 +43,7 @@
#include "webserver-nogui.h" #include "webserver-nogui.h"
#include "httpd-simple.h" #include "httpd-simple.h"
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/
/* The address of the server to register the services for this node */ /* The address of the server to register the services for this node */
#define SERVER "aaaa::1" #define SERVER "aaaa::1"
@ -56,11 +56,9 @@
/* The commands to send to the other node */ /* The commands to send to the other node */
#define SET_LEDS_ON "/1" #define SET_LEDS_ON "/1"
#define SET_LEDS_OFF "/0" #define SET_LEDS_OFF "/0"
/*---------------------------------------------------------------------------*/
PROCESS(websense_remote_process, "Websense Remote"); PROCESS(websense_remote_process, "Websense Remote");
AUTOSTART_PROCESSES(&websense_remote_process); AUTOSTART_PROCESSES(&websense_remote_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static const char *TOP = "<html><head><title>Contiki Websense Remote</title></head><body>\n"; static const char *TOP = "<html><head><title>Contiki Websense Remote</title></head><body>\n";
static const char *BOTTOM = "</body></html>\n"; static const char *BOTTOM = "</body></html>\n";
@ -161,7 +159,6 @@ PROCESS_THREAD(websense_remote_process, ev, data)
} }
/* Alternate between the two commands */ /* Alternate between the two commands */
mode = !mode; mode = !mode;
} else if(ev == PROCESS_EVENT_TIMER && etimer_expired(&timer)) { } else if(ev == PROCESS_EVENT_TIMER && etimer_expired(&timer)) {
printf("Registering services\n"); printf("Registering services\n");
send_command(SERVER, REGISTER_COMMAND); send_command(SERVER, REGISTER_COMMAND);

View file

@ -27,7 +27,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A simple wget implementation * A simple wget implementation
@ -35,28 +35,29 @@
* Niclas Finne <nfi@sics.se> * Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se> * Joakim Eriksson <joakime@sics.se>
*/ */
/*---------------------------------------------------------------------------*/
#include "webclient.h" #include "webclient.h"
#include "wget.h" #include "wget.h"
#include "dev/leds.h" #include "dev/leds.h"
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_NONE #define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h" #include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
#define DEBUG_LEDS 0 #define DEBUG_LEDS 0
#undef LEDS_ON #undef LEDS_ON
#undef LEDS_OFF #undef LEDS_OFF
#if DEBUG_LEDS #if DEBUG_LEDS
#define LEDS_ON(led) leds_on(led) #define LEDS_ON(led) leds_on(led)
#define LEDS_OFF(led) leds_off(led) #define LEDS_OFF(led) leds_off(led)
#else #else
#define LEDS_ON(led) #define LEDS_ON(led)
#define LEDS_OFF(led) #define LEDS_OFF(led)
#endif /* DEBUG */ #endif /* DEBUG_LEDS */
/*---------------------------------------------------------------------------*/
static int fetch_running; static int fetch_running;
#define STATS ((DEBUG) & DEBUG_PRINT) && 1 #define STATS ((DEBUG)&DEBUG_PRINT) && 1
#if STATS #if STATS
static clock_time_t fetch_started; static clock_time_t fetch_started;
static unsigned long fetch_counter; static unsigned long fetch_counter;
@ -66,9 +67,8 @@ static const char *server;
static const char *file; static const char *file;
static uint16_t port; static uint16_t port;
static const struct wget_callbacks *callbacks; static const struct wget_callbacks *callbacks;
/*---------------------------------------------------------------------------*/
PROCESS(wget_process, "wget"); PROCESS(wget_process, "wget");
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
call_done(int status) call_done(int status)
@ -115,11 +115,11 @@ webclient_datahandler(char *data, uint16_t len)
PRINTF("wget: recv %lu bytes during %lu sec (", PRINTF("wget: recv %lu bytes during %lu sec (",
fetch_counter, (elapsed / CLOCK_SECOND)); fetch_counter, (elapsed / CLOCK_SECOND));
#if CLOCK_SECOND == 128 #if CLOCK_SECOND == 128
PRINTF("%lu.%02lus, ", (unsigned long) elapsed >> 7, PRINTF("%lu.%02lus, ", (unsigned long)elapsed >> 7,
(unsigned long)((elapsed & 127) * 100) / 128); (unsigned long)((elapsed & 127) * 100) / 128);
PRINTF("%lu byte/sec ", (fetch_counter * 128L) / elapsed); PRINTF("%lu byte/sec ", (fetch_counter * 128L) / elapsed);
#endif #endif
PRINTF("%lu tick): ", (unsigned long) elapsed); PRINTF("%lu tick): ", (unsigned long)elapsed);
if(elapsed > CLOCK_SECOND) { if(elapsed > CLOCK_SECOND) {
PRINTF("%lu", fetch_counter / (elapsed / CLOCK_SECOND)); PRINTF("%lu", fetch_counter / (elapsed / CLOCK_SECOND));
} else { } else {
@ -132,7 +132,7 @@ webclient_datahandler(char *data, uint16_t len)
fetch_running = 0; fetch_running = 0;
call_done(WGET_OK); call_done(WGET_OK);
LEDS_OFF(LEDS_RED|LEDS_YELLOW); LEDS_OFF(LEDS_RED | LEDS_YELLOW);
} else { } else {
#if STATS #if STATS
fetch_counter += len; fetch_counter += len;
@ -156,7 +156,7 @@ void
webclient_timedout(void) webclient_timedout(void)
{ {
PRINTF("wget: timedout\n"); PRINTF("wget: timedout\n");
LEDS_OFF(LEDS_RED|LEDS_YELLOW); LEDS_OFF(LEDS_RED | LEDS_YELLOW);
fetch_running = 0; fetch_running = 0;
call_done(WGET_TIMEDOUT); call_done(WGET_TIMEDOUT);
} }
@ -165,7 +165,7 @@ void
webclient_aborted(void) webclient_aborted(void)
{ {
PRINTF("wget: aborted\n"); PRINTF("wget: aborted\n");
LEDS_OFF(LEDS_RED|LEDS_YELLOW); LEDS_OFF(LEDS_RED | LEDS_YELLOW);
fetch_running = 0; fetch_running = 0;
call_done(WGET_ABORTED); call_done(WGET_ABORTED);
} }
@ -175,7 +175,7 @@ webclient_closed(void)
{ {
PRINTF("wget: closed\n"); PRINTF("wget: closed\n");
fetch_running = 0; fetch_running = 0;
LEDS_OFF(LEDS_RED|LEDS_YELLOW); LEDS_OFF(LEDS_RED | LEDS_YELLOW);
call_done(WGET_CLOSED); call_done(WGET_CLOSED);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -42,8 +42,8 @@
#include "contiki.h" #include "contiki.h"
struct wget_callbacks { struct wget_callbacks {
void (* data)(const char *data, uint16_t len); void (*data)(const char *data, uint16_t len);
void (* done)(int status); void (*done)(int status);
}; };
void wget_init(void); void wget_init(void);

View file

@ -27,7 +27,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* Battery and Temperature IPv6 Demo for Zolertia Z1 * Battery and Temperature IPv6 Demo for Zolertia Z1
@ -37,7 +37,7 @@
* Joel Hoglund <joel@sics.se> * Joel Hoglund <joel@sics.se>
* Enric M. Calvo <ecalvo@zolertia.com> * Enric M. Calvo <ecalvo@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "httpd-simple.h" #include "httpd-simple.h"
#include "webserver-nogui.h" #include "webserver-nogui.h"
@ -46,22 +46,23 @@
#include "cc2420.h" #include "cc2420.h"
#include "dev/leds.h" #include "dev/leds.h"
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/
float
float floor(float x){ floor(float x)
if(x>=0.0f) return (float) ((int)x); {
else return (float) ((int)x-1); if(x >= 0.0f) {
return (float)((int)x);
} else { return (float)((int)x - 1);
}
} }
/*---------------------------------------------------------------------------*/
PROCESS(web_sense_process, "Sense Web Demo"); PROCESS(web_sense_process, "Sense Web Demo");
AUTOSTART_PROCESSES(&web_sense_process); AUTOSTART_PROCESSES(&web_sense_process);
/*---------------------------------------------------------------------------*/
#define HISTORY 16 #define HISTORY 16
static int temperature[HISTORY]; static int temperature[HISTORY];
static int battery1[HISTORY]; static int battery1[HISTORY];
static int sensors_pos; static int sensors_pos;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_battery(void) get_battery(void)
@ -74,10 +75,16 @@ get_temp(void)
{ {
return temperature_sensor.value(0); return temperature_sensor.value(0);
} }
static float
static float get_mybatt(void){ return (float) ((get_battery()*2.500*2)/4096);} get_mybatt(void)
static float get_mytemp(void){ return (float) (((get_temp()*2.500)/4096)-0.986)*282;} {
return (float)((get_battery() * 2.500 * 2) / 4096);
}
static float
get_mytemp(void)
{
return (float)(((get_temp() * 2.500) / 4096) - 0.986) * 282;
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static const char *TOP = "<html><head><title>Contiki Web Sense</title></head><body>\n"; static const char *TOP = "<html><head><title>Contiki Web Sense</title></head><body>\n";
static const char *BOTTOM = "</body></html>\n"; static const char *BOTTOM = "</body></html>\n";
@ -85,11 +92,13 @@ static const char *BOTTOM = "</body></html>\n";
/* Only one single request at time */ /* Only one single request at time */
static char buf[256]; static char buf[256];
static int blen; static int blen;
#define ADD(...) do { \ #define ADD(...) do { \
blen += snprintf(&buf[blen], sizeof(buf) - blen, __VA_ARGS__); \ blen += snprintf(&buf[blen], sizeof(buf) - blen, __VA_ARGS__); \
} while(0) } while(0)
/*---------------------------------------------------------------------------*/
static void static void
generate_chart(const char *title, const char *unit, int min, int max, int *values) generate_chart(const char *title, const char *unit, int min, int max,
int *values)
{ {
int i; int i;
blen = 0; blen = 0;
@ -103,6 +112,7 @@ generate_chart(const char *title, const char *unit, int min, int max, int *value
} }
ADD("\">"); ADD("\">");
} }
/*---------------------------------------------------------------------------*/
static static
PT_THREAD(send_values(struct httpd_state *s)) PT_THREAD(send_values(struct httpd_state *s))
{ {
@ -120,20 +130,17 @@ PT_THREAD(send_values(struct httpd_state *s))
ADD("<h1>Current readings</h1>\n" ADD("<h1>Current readings</h1>\n"
"Battery: %ld.%03d V<br>" "Battery: %ld.%03d V<br>"
"Temperature: %ld.%03d &deg; C", "Temperature: %ld.%03d &deg; C",
(long) mybatt, (unsigned) ((mybatt-floor(mybatt))*1000), (long)mybatt, (unsigned)((mybatt - floor(mybatt)) * 1000),
(long) mytemp, (unsigned) ((mytemp-floor(mytemp))*1000)); (long)mytemp, (unsigned)((mytemp - floor(mytemp)) * 1000));
SEND_STRING(&s->sout, buf); SEND_STRING(&s->sout, buf);
} else if(s->filename[1] == '0') { } else if(s->filename[1] == '0') {
/* Turn off leds */ /* Turn off leds */
leds_off(LEDS_ALL); leds_off(LEDS_ALL);
SEND_STRING(&s->sout, "Turned off leds!"); SEND_STRING(&s->sout, "Turned off leds!");
} else if(s->filename[1] == '1') { } else if(s->filename[1] == '1') {
/* Turn on leds */ /* Turn on leds */
leds_on(LEDS_ALL); leds_on(LEDS_ALL);
SEND_STRING(&s->sout, "Turned on leds!"); SEND_STRING(&s->sout, "Turned on leds!");
} else { } else {
if(s->filename[1] != 't') { if(s->filename[1] != 't') {
generate_chart("Battery", "mV", 0, 4000, battery1); generate_chart("Battery", "mV", 0, 4000, battery1);
@ -173,7 +180,7 @@ PROCESS_THREAD(web_sense_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
etimer_reset(&timer); etimer_reset(&timer);
battery1[sensors_pos] = get_mybatt()*1000; battery1[sensors_pos] = get_mybatt() * 1000;
temperature[sensors_pos] = get_mytemp(); temperature[sensors_pos] = get_mytemp();
sensors_pos = (sensors_pos + 1) % HISTORY; sensors_pos = (sensors_pos + 1) % HISTORY;
} }

View file

@ -47,36 +47,27 @@
#include "shell-file.h" #include "shell-file.h"
#include "shell-text.h" #include "shell-text.h"
#include "dev/adxl345.h" #include "dev/adxl345.h"
/*---------------------------------------------------------------------------*/
#define LED_INT_ONTIME CLOCK_SECOND/2 #define LED_INT_ONTIME (CLOCK_SECOND / 2)
#define ACCM_READ_INTERVAL CLOCK_SECOND #define ACCM_READ_INTERVAL CLOCK_SECOND
/*---------------------------------------------------------------------------*/
static process_event_t ledOff_event; static process_event_t led_off_event;
static struct etimer led_etimer;
static struct etimer et;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(accel_process, "Test Accel process"); PROCESS(accel_process, "Test Accel process");
PROCESS(led_process, "LED handling process"); PROCESS(led_process, "LED handling process");
AUTOSTART_PROCESSES(&accel_process, &led_process); AUTOSTART_PROCESSES(&accel_process, &led_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* As several interrupts can be mapped to one interrupt pin, when interrupt /* As several interrupts can be mapped to one interrupt pin, when interrupt
strikes, the adxl345 interrupt source register is read. This function prints * strikes, the adxl345 interrupt source register is read. This function prints
out which interrupts occurred. Note that this will include all interrupts, * out which interrupts occurred. Note that this will include all interrupts,
even those mapped to 'the other' pin, and those that will always signal even if * even those mapped to 'the other' pin, and those that will always signal even
not enabled (such as watermark). */ * if not enabled (such as watermark).
*/
void void
print_int(uint16_t reg){ print_int(uint16_t reg)
#define ANNOYING_ALWAYS_THERE_ANYWAY_OUTPUT 0 {
#if ANNOYING_ALWAYS_THERE_ANYWAY_OUTPUT
if(reg & ADXL345_INT_OVERRUN) {
printf("Overrun ");
}
if(reg & ADXL345_INT_WATERMARK) {
printf("Watermark ");
}
if(reg & ADXL345_INT_DATAREADY) {
printf("DataReady ");
}
#endif
if(reg & ADXL345_INT_FREEFALL) { if(reg & ADXL345_INT_FREEFALL) {
printf("Freefall "); printf("Freefall ");
} }
@ -94,74 +85,49 @@ print_int(uint16_t reg){
} }
printf("\n"); printf("\n");
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* accelerometer free fall detection callback */ /* accelerometer free fall detection callback */
void void
accm_ff_cb(uint8_t reg){ accm_ff_cb(uint8_t reg)
{
L_ON(LEDS_B); L_ON(LEDS_B);
process_post(&led_process, ledOff_event, NULL); process_post(&led_process, led_off_event, NULL);
printf("~~[%u] Freefall detected! (0x%02X) -- ", ((uint16_t) clock_time())/128, reg); printf("~~[%u] Freefall detected! (0x%02X) -- ",
((uint16_t)clock_time()) / 128, reg);
print_int(reg); print_int(reg);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* accelerometer tap and double tap detection callback */ /* accelerometer tap and double tap detection callback */
void void
accm_tap_cb(uint8_t reg){ accm_tap_cb(uint8_t reg)
process_post(&led_process, ledOff_event, NULL); {
if(reg & ADXL345_INT_DOUBLETAP){ process_post(&led_process, led_off_event, NULL);
if(reg & ADXL345_INT_DOUBLETAP) {
L_ON(LEDS_G); L_ON(LEDS_G);
printf("~~[%u] DoubleTap detected! (0x%02X) -- ", ((uint16_t) clock_time())/128, reg); printf("~~[%u] DoubleTap detected! (0x%02X) -- ",
((uint16_t)clock_time()) / 128, reg);
} else { } else {
L_ON(LEDS_R); L_ON(LEDS_R);
printf("~~[%u] Tap detected! (0x%02X) -- ", ((uint16_t) clock_time())/128, reg); printf("~~[%u] Tap detected! (0x%02X) -- ",
((uint16_t)clock_time()) / 128, reg);
} }
print_int(reg); print_int(reg);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* When posted an ledOff event, the LEDs will switch off after LED_INT_ONTIME.
static process_event_t ledOff_event;
ledOff_event = process_alloc_event();
process_post(&led_process, ledOff_event, NULL);
*/
static struct etimer ledETimer;
PROCESS_THREAD(led_process, ev, data) { PROCESS_THREAD(led_process, ev, data) {
PROCESS_BEGIN(); PROCESS_BEGIN();
while(1){ while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == ledOff_event); PROCESS_WAIT_EVENT_UNTIL(ev == led_off_event);
etimer_set(&ledETimer, LED_INT_ONTIME); etimer_set(&led_etimer, LED_INT_ONTIME);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ledETimer)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&led_etimer));
L_OFF(LEDS_R + LEDS_G + LEDS_B); L_OFF(LEDS_R + LEDS_G + LEDS_B);
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/
/* Returns a string with the argument byte written in binary.
Example usage:
printf("Port1: %s\n", char2bin(P1IN));
*/
/*
static uint8_t b[9];
static uint8_t
*char2bin(uint8_t x) {
uint8_t z;
b[8] = '\0';
for (z = 0; z < 8; z++) {
b[7-z] = (x & (1 << z)) ? '1' : '0';
}
return b;
}
*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Main process, setups */ /* Main process, setups */
static struct etimer et;
PROCESS_THREAD(accel_process, ev, data) { PROCESS_THREAD(accel_process, ev, data) {
PROCESS_BEGIN(); PROCESS_BEGIN();
{ {
@ -169,11 +135,11 @@ PROCESS_THREAD(accel_process, ev, data) {
serial_shell_init(); serial_shell_init();
shell_ps_init(); shell_ps_init();
shell_file_init(); // for printing out files shell_file_init(); /* for printing out files */
shell_text_init(); // for binprint shell_text_init(); /* for binprint */
/* Register the event used for lighting up an LED when interrupt strikes. */ /* Register the event used for lighting up an LED when interrupt strikes. */
ledOff_event = process_alloc_event(); led_off_event = process_alloc_event();
/* Start and setup the accelerometer with default values, eg no interrupts enabled. */ /* Start and setup the accelerometer with default values, eg no interrupts enabled. */
accm_init(); accm_init();
@ -182,15 +148,15 @@ PROCESS_THREAD(accel_process, ev, data) {
ACCM_REGISTER_INT1_CB(accm_ff_cb); ACCM_REGISTER_INT1_CB(accm_ff_cb);
ACCM_REGISTER_INT2_CB(accm_tap_cb); ACCM_REGISTER_INT2_CB(accm_tap_cb);
/* Set what strikes the corresponding interrupts. Several interrupts per pin is /* Set what strikes the corresponding interrupts. Several interrupts per pin is
possible. For the eight possible interrupts, see adxl345.h and adxl345 datasheet. */ possible. For the eight possible interrupts, see adxl345.h and adxl345 datasheet. */
accm_set_irq(ADXL345_INT_FREEFALL, ADXL345_INT_TAP + ADXL345_INT_DOUBLETAP); accm_set_irq(ADXL345_INT_FREEFALL, ADXL345_INT_TAP + ADXL345_INT_DOUBLETAP);
while (1) { while(1) {
x = accm_read_axis(X_AXIS); x = accm_read_axis(X_AXIS);
y = accm_read_axis(Y_AXIS); y = accm_read_axis(Y_AXIS);
z = accm_read_axis(Z_AXIS); z = accm_read_axis(Z_AXIS);
printf("x: %d y: %d z: %d\n", x, y, z); printf("x: %d y: %d z: %d\n", x, y, z);
etimer_set(&et, ACCM_READ_INTERVAL); etimer_set(&et, ACCM_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
@ -198,6 +164,5 @@ PROCESS_THREAD(accel_process, ev, data) {
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -29,30 +29,27 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* Testing the internal MSP430 battery sensor on the Zolertia Z1 Platform. * Testing the internal MSP430 battery sensor on the Zolertia Z1 Platform.
* \author * \author
* Enric M. Calvo <ecalvo@zolertia.com> * Enric M. Calvo <ecalvo@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/battery-sensor.h" #include "dev/battery-sensor.h"
#include <stdio.h> /* For printf() */ #include <stdio.h>
/*---------------------------------------------------------------------------*/
float float
floor(float x) floor(float x)
{ {
if(x >= 0.0f) { if(x >= 0.0f) {
return (float) ((int) x); return (float)((int)x);
} else { } else {
return (float) ((int) x - 1); return (float)((int)x - 1);
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(test_battery_process, "Battery Sensor Test"); PROCESS(test_battery_process, "Battery Sensor Test");
AUTOSTART_PROCESSES(&test_battery_process); AUTOSTART_PROCESSES(&test_battery_process);
@ -67,13 +64,12 @@ PROCESS_THREAD(test_battery_process, ev, data)
while(1) { while(1) {
uint16_t bateria = battery_sensor.value(0); uint16_t bateria = battery_sensor.value(0);
float mv = (bateria * 2.500 * 2) / 4096; float mv = (bateria * 2.500 * 2) / 4096;
printf("Battery: %i (%ld.%03d mV)\n", bateria, (long) mv, printf("Battery: %i (%ld.%03d mV)\n", bateria, (long)mv,
(unsigned) ((mv - floor(mv)) * 1000)); (unsigned)((mv - floor(mv)) * 1000));
} }
SENSORS_DEACTIVATE(battery_sensor); SENSORS_DEACTIVATE(battery_sensor);
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -29,49 +29,39 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A quick program for testing the light ziglet driver in the Z1 platform * A quick program for testing the light ziglet driver in the Z1 platform
* \author * \author
* Antonio Lignan <alinan@zolertia.com> * Antonio Lignan <alinan@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/i2cmaster.h" #include "dev/i2cmaster.h"
#include "dev/light-ziglet.h" #include "dev/light-ziglet.h"
/*---------------------------------------------------------------------------*/
#if 1
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2) #define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
/*---------------------------------------------------------------------------*/
PROCESS(test_process, "Test light ziglet process"); PROCESS(test_process, "Test light ziglet process");
AUTOSTART_PROCESSES(&test_process); AUTOSTART_PROCESSES(&test_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_process, ev, data) PROCESS_THREAD(test_process, ev, data)
{ {
PROCESS_BEGIN(); PROCESS_BEGIN();
uint16_t light;
/* Initialize driver and set a slower data rate */ /* Initialize driver and set a slower data rate */
light_ziglet_init(); light_ziglet_init();
i2c_setrate(I2C_PRESC_100KHZ_LSB, I2C_PRESC_100KHZ_MSB); i2c_setrate(I2C_PRESC_100KHZ_LSB, I2C_PRESC_100KHZ_MSB);
while(1) { while(1) {
etimer_set(&et, SENSOR_READ_INTERVAL); etimer_set(&et, SENSOR_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
printf("Light = %u\n", light_ziglet_read());
light = light_ziglet_read();
PRINTF("Light = %u\n", light);
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/

View file

@ -29,52 +29,48 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* An example of how to use the button and light sensor on * An example of how to use the button and read the ADC ports
* the Z1 platform.
* \author * \author
* Joakim Eriksson <joakime@sics.se> * Joakim Eriksson <joakime@sics.se>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/z1-phidgets.h" #include "dev/z1-phidgets.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(test_button_process, "Test Button & Phidgets"); PROCESS(test_button_process, "Test Button & ADC");
AUTOSTART_PROCESSES(&test_button_process); AUTOSTART_PROCESSES(&test_button_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_button_process, ev, data) PROCESS_THREAD(test_button_process, ev, data)
{ {
//static struct etimer et; /* static struct etimer et; */
PROCESS_BEGIN(); PROCESS_BEGIN();
SENSORS_ACTIVATE(phidgets); SENSORS_ACTIVATE(phidgets);
SENSORS_ACTIVATE(button_sensor); SENSORS_ACTIVATE(button_sensor);
while(1) { while(1) {
//etimer_set(&et, CLOCK_SECOND/2);
printf("Please press the User Button\n"); printf("Please press the User Button\n");
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event &&
data == &button_sensor); data == &button_sensor);
//PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_toggle(LEDS_GREEN); leds_toggle(LEDS_GREEN);
//printf("Button clicked\n");
printf("Phidget 5V 1:%d\n", phidgets.value(PHIDGET5V_1)); printf("Phidget 5V 1:%d\n", phidgets.value(PHIDGET5V_1));
printf("Phidget 5V 2:%d\n", phidgets.value(PHIDGET5V_2)); printf("Phidget 5V 2:%d\n", phidgets.value(PHIDGET5V_2));
printf("Phidget 3V 1:%d\n", phidgets.value(PHIDGET3V_1)); printf("Phidget 3V 1:%d\n", phidgets.value(PHIDGET3V_1));
printf("Phidget 3V 2:%d\n", phidgets.value(PHIDGET3V_2)); printf("Phidget 3V 2:%d\n", phidgets.value(PHIDGET3V_2));
if (phidgets.value(PHIDGET3V_1) < 100) { if(phidgets.value(PHIDGET3V_1) < 100) {
leds_on(LEDS_RED); leds_on(LEDS_RED);
} else { } else {
leds_off(LEDS_RED); leds_off(LEDS_RED);
} }
} }
PROCESS_END(); PROCESS_END();
} }

View file

@ -29,19 +29,17 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* Testing the Potentiometer in Zolertia Z1 Starter Platform. * Testing the Potentiometer in Zolertia Z1 Starter Platform.
* \author * \author
* Enric M. Calvo <ecalvo@zolertia.com> * Enric M. Calvo <ecalvo@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/potentiometer-sensor.h" #include "dev/potentiometer-sensor.h"
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(test_potent_process, "Testing Potentiometer in Z1SP"); PROCESS(test_potent_process, "Testing Potentiometer in Z1SP");
AUTOSTART_PROCESSES(&test_potent_process); AUTOSTART_PROCESSES(&test_potent_process);
@ -63,6 +61,4 @@ PROCESS_THREAD(test_potent_process, ev, data)
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -29,7 +29,7 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A quick program for testing a generic relay device connected in the * A quick program for testing a generic relay device connected in the
@ -37,25 +37,19 @@
* \author * \author
* Antonio Lignan <alinan@zolertia.com> * Antonio Lignan <alinan@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/relay-phidget.h" #include "dev/relay-phidget.h"
/*---------------------------------------------------------------------------*/
#if 1 #if DEBUG
#define PRINTF(...) printf(__VA_ARGS__) #define PRINTF(...) printf(__VA_ARGS__)
#else #else
#define PRINTF(...) #define PRINTF(...)
#endif #endif
/*---------------------------------------------------------------------------*/
#if 0
#define PRINTFDEBUG(...) printf(__VA_ARGS__)
#else
#define PRINTFDEBUG(...)
#endif
#define RELAY_INTERVAL (CLOCK_SECOND) #define RELAY_INTERVAL (CLOCK_SECOND)
/*---------------------------------------------------------------------------*/
PROCESS(test_process, "Relay test process"); PROCESS(test_process, "Relay test process");
AUTOSTART_PROCESSES(&test_process); AUTOSTART_PROCESSES(&test_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -78,3 +72,4 @@ PROCESS_THREAD(test_process, ev, data)
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/

View file

@ -29,7 +29,7 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* Testing the SHT11 sensor on the Zolertia Z1 Platform. * Testing the SHT11 sensor on the Zolertia Z1 Platform.
@ -37,15 +37,15 @@
* Nicolas Tsiftes <nvt@sics.se> * Nicolas Tsiftes <nvt@sics.se>
* Enric M. Calvo <ecalvo@zolertia.com> * Enric M. Calvo <ecalvo@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/sht11/sht11.h" #include "dev/sht11/sht11.h"
#include <stdio.h> #include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(test_sht11_process, "SHT11 test"); PROCESS(test_sht11_process, "SHT11 test");
AUTOSTART_PROCESSES(&test_sht11_process); AUTOSTART_PROCESSES(&test_sht11_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_sht11_process, ev, data) PROCESS_THREAD(test_sht11_process, ev, data)
{ {
static struct etimer et; static struct etimer et;
@ -54,14 +54,15 @@ PROCESS_THREAD(test_sht11_process, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
sht11_init(); sht11_init();
for (etimer_set(&et, CLOCK_SECOND);; etimer_reset(&et)) { for(etimer_set(&et, CLOCK_SECOND);; etimer_reset(&et)) {
PROCESS_YIELD(); PROCESS_YIELD();
printf("Temperature: %u degrees Celsius\n", printf("Temperature: %u degrees Celsius\n",
(unsigned) (-39.60 + 0.01 * sht11_temp())); (unsigned)(-39.60 + 0.01 * sht11_temp()));
rh = sht11_humidity(); rh = sht11_humidity();
printf("Rel. humidity: %u%%\n", printf("Rel. humidity: %u%%\n",
(unsigned) (-4 + 0.0405*rh - 2.8e-6*(rh*rh))); (unsigned)(-4 + 0.0405 * rh - 2.8e-6 * (rh * rh)));
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/

View file

@ -29,21 +29,23 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A quick program for testing the SHT25 temperature and humidity sensor * A quick program for testing the SHT25 temperature and humidity sensor
* \author * \author
* Antonio Lignan <alinan@zolertia.com> * Antonio Lignan <alinan@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/sht25.h" #include "dev/sht25.h"
/*---------------------------------------------------------------------------*/
PROCESS(test_sht25_process, "SHT25 test"); PROCESS(test_sht25_process, "SHT25 test");
AUTOSTART_PROCESSES(&test_sht25_process); AUTOSTART_PROCESSES(&test_sht25_process);
/*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_sht25_process, ev, data) PROCESS_THREAD(test_sht25_process, ev, data)
{ {
int16_t temperature, humidity; int16_t temperature, humidity;
@ -61,3 +63,4 @@ PROCESS_THREAD(test_sht25_process, ev, data)
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2013, Jelmer Tiete. * Copyright (c) 2013, Jelmer Tiete.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -12,8 +12,8 @@
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote * 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior * products derived from this software without specific prior
* written permission. * written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -25,11 +25,11 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A simple program for testing the TLC59116 I2C led driver. * A simple program for testing the TLC59116 I2C led driver.
@ -37,23 +37,21 @@
* \author * \author
* Jelmer Tiete, VUB <jelmer@tiete.be> * Jelmer Tiete, VUB <jelmer@tiete.be>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/tlc59116.h" #include "dev/tlc59116.h"
/*---------------------------------------------------------------------------*/
#define BLINK_INTERVAL CLOCK_SECOND/25 #define BLINK_INTERVAL (CLOCK_SECOND / 25)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(tlc59116_process, "Test tlc59116 process"); PROCESS(tlc59116_process, "Test tlc59116 process");
AUTOSTART_PROCESSES(&tlc59116_process); AUTOSTART_PROCESSES(&tlc59116_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Main process, setups */ /* Main process, setups */
static struct etimer et; static struct etimer et;
static uint8_t count = 0; static uint8_t count = 0;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tlc59116_process, ev, data) PROCESS_THREAD(tlc59116_process, ev, data)
{ {
PROCESS_BEGIN(); PROCESS_BEGIN();
@ -80,5 +78,4 @@ PROCESS_THREAD(tlc59116_process, ev, data)
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -29,71 +29,40 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \file * \file
* A quick program for testing the tmp102 driver in the Z1 platform * A quick program for testing the tmp102 driver in the Z1 platform
* \author * \author
* Enric M. Calvo <ecalvo@zolertia.com> * Enric M. Calvo <ecalvo@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/i2cmaster.h" #include "dev/i2cmaster.h"
#include "dev/tmp102.h" #include "dev/tmp102.h"
/*---------------------------------------------------------------------------*/
#define TMP102_READ_INTERVAL (CLOCK_SECOND / 2)
#if 1 /*---------------------------------------------------------------------------*/
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#if 0
#define PRINTFDEBUG(...) printf(__VA_ARGS__)
#else
#define PRINTFDEBUG(...)
#endif
#define TMP102_READ_INTERVAL (CLOCK_SECOND/2)
PROCESS(temp_process, "Test Temperature process"); PROCESS(temp_process, "Test Temperature process");
AUTOSTART_PROCESSES(&temp_process); AUTOSTART_PROCESSES(&temp_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(temp_process, ev, data) PROCESS_THREAD(temp_process, ev, data)
{ {
PROCESS_BEGIN(); PROCESS_BEGIN();
int16_t tempint; int16_t temp;
uint16_t tempfrac;
int16_t raw;
uint16_t absraw;
int16_t sign;
char minus = ' ';
tmp102_init(); tmp102_init();
while(1) { while(1) {
etimer_set(&et, TMP102_READ_INTERVAL); etimer_set(&et, TMP102_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
temp = tmp102_read_temp_x100();
sign = 1; printf("Temp = %d\n", temp);
PRINTFDEBUG("Reading Temp...\n");
raw = tmp102_read_temp_raw();
absraw = raw;
if(raw < 0) { // Perform 2C's if sensor returned negative data
absraw = (raw ^ 0xFFFF) + 1;
sign = -1;
}
tempint = (absraw >> 8) * sign;
tempfrac = ((absraw >> 4) % 16) * 625; // Info in 1/10000 of degree
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ';
PRINTF("Temp = %c%d.%04d\n", minus, tempint, tempfrac);
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/

View file

@ -1,9 +1,9 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\" DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = remote-demo test-tsl2563 test-sht25 CONTIKI_PROJECT = zoul-demo test-tsl2563 test-sht25
CONTIKI_TARGET_SOURCEFILES += tsl2563.c sht25.c CONTIKI_TARGET_SOURCEFILES += tsl2563.c sht25.c
all: $(CONTIKI_PROJECT) all: $(CONTIKI_PROJECT)
CONTIKI = ../.. CONTIKI = ../../..
CONTIKI_WITH_RIME = 1 CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include include $(CONTIKI)/Makefile.include

View file

@ -0,0 +1 @@
TARGET = zoul

View file

@ -0,0 +1,8 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = cc1200-demo
all: $(CONTIKI_PROJECT)
CONTIKI = ../../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -0,0 +1 @@
TARGET = zoul

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, Swedish Institute of Computer Science. * Copyright (c) 2015, Zolertia - http://www.zolertia.com
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -26,106 +26,80 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system.
*
*/ */
/*---------------------------------------------------------------------------*/
/** /**
* \addtogroup zoul-cc1200-demo Zoul on-board CC1200 RF transceiver test
*
* Demonstrates the use of the TI CC1200 RF transceiver on Sub-1GHz
* @{
*
* \file * \file
* Best-effort single-hop unicast example * Test file for the CC1200 demo
*
* \author * \author
* Adam Dunkels <adam@sics.se> * Antonio Lignan <alinan@zolertia.com>
*/ */
#include "contiki.h" #include "contiki.h"
#include "net/rime/rime.h" #include "cpu.h"
#include "sys/etimer.h"
#include "dev/button-sensor.h"
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/watchdog.h"
#include "dev/serial-line.h"
#include "dev/sys-ctrl.h"
#include "net/rime/broadcast.h"
#include <stdio.h> #include <stdio.h>
#include "dev/i2cmaster.h" #include <stdint.h>
#include "dev/tmp102.h"
#if 1
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define SENDER 205
#define RECEIVER 200
#define PRINTFDEBUG(...)
#define TMP102_READ_INTERVAL (CLOCK_SECOND/2)
int16_t tempint;
uint16_t tempfrac;
int16_t raw;
uint16_t absraw;
int16_t sign;
char minus = ' ';
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(example_unicast_process, "Example unicast"); #define LOOP_PERIOD 2
AUTOSTART_PROCESSES(&example_unicast_process); #define LOOP_INTERVAL (CLOCK_SECOND * LOOP_PERIOD)
#define BROADCAST_CHANNEL 129
/*---------------------------------------------------------------------------*/
static struct etimer et;
static uint16_t counter;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
recv_uc(struct unicast_conn *c, const linkaddr_t *from) broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
{ {
printf("unicast message received from %d.%d\n", printf("*** Received %u bytes from %u:%u: '0x%04u' ", packetbuf_datalen(),
from->u8[0], from->u8[1]); from->u8[0], from->u8[1], *(uint16_t *)packetbuf_dataptr());
printf("%d - %u\n", (int8_t)packetbuf_attr(PACKETBUF_ATTR_RSSI),
packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY));
leds_toggle(LEDS_GREEN);
} }
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_unicast_process, ev, data) static const struct broadcast_callbacks bc_rx = { broadcast_recv };
static struct broadcast_conn bc;
/*---------------------------------------------------------------------------*/
PROCESS(cc1200_demo_process, "cc1200 demo process");
AUTOSTART_PROCESSES(&cc1200_demo_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc1200_demo_process, ev, data)
{ {
PROCESS_EXITHANDLER(unicast_close(&uc);) PROCESS_EXITHANDLER(broadcast_close(&bc))
PROCESS_BEGIN(); PROCESS_BEGIN();
broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx);
etimer_set(&et, LOOP_INTERVAL);
tmp102_init();
linkaddr_t addr;
unicast_open(&uc, 133, &unicast_callbacks);
SENSORS_ACTIVATE(button_sensor);
while(1) { while(1) {
PROCESS_YIELD();
PROCESS_WAIT_EVENT_UNTIL(ev==sensors_event && data == &button_sensor); if(ev == PROCESS_EVENT_TIMER) {
sign = 1; printf("Broadcast --> %u\n", counter);
leds_toggle(LEDS_RED);
//PRINTFDEBUG ("Reading Temp...\n"); packetbuf_copyfrom(&counter, sizeof(counter));
raw = tmp102_read_temp_raw(); broadcast_send(&bc);
counter++;
absraw = raw; etimer_set(&et, LOOP_INTERVAL);
if (raw < 0) { // Perform 2C's if sensor returned negative data }
absraw = (raw ^ 0xFFFF) + 1;
sign = -1;
}
tempint = (absraw >> 8) * sign;
tempfrac = ((absraw>>4) % 16) * 625; // Info in 1/10000 of degree
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ' ;
PRINTF ("Current Temp = %c%d.%04d\n", minus, tempint, tempfrac);
char s[30];
sprintf(s,"Temp is %c%d.%04d\n", minus, tempint, tempfrac);
printf("sending %s\n",s);
packetbuf_copyfrom(s, 30);
addr.u8[0] = RECEIVER;
addr.u8[1] = 0;
unicast_send(&uc, &addr);
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/**
* @}
*/

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, Swedish Institute of Computer Science. * Copyright (c) 2015, Zolertia - http://www.zolertia.com
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -26,64 +26,36 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system.
*
*/ */
/*---------------------------------------------------------------------------*/
/**
* \addtogroup zoul-examples
* @{
*
* \defgroup remote-cc1200-demo RE-Mote CC1200 RF transceiver test
*
* Demonstrates the use of the TI CC1200 RF transceiver on Sub-1GHz
* @{
*
* \file
* Configuration file for the cc1200 demo
*
* \author
* Antonio Lignan <alinan@zolertia.com>
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#undef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO cc1200_driver
#define NETSTACK_CONF_RDC nullrdc_driver
#define CC1200_CONF_USE_GPIO2 0
#define CC1200_CONF_USE_RX_WATCHDOG 0
#define ANTENNA_SW_SELECT_DEF_CONF ANTENNA_SW_SELECT_SUBGHZ
#endif /* PROJECT_CONF_H_ */
/** /**
* \file * @}
* Best-effort single-hop unicast example * @}
* \author
* Adam Dunkels <adam@sics.se>
*/ */
#include "contiki.h"
#include "net/rime/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
/*---------------------------------------------------------------------------*/
static void
recv_uc(struct unicast_conn *c, const linkaddr_t *from)
{
printf("unicast message received from %d.%d\n",
from->u8[0], from->u8[1]);
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
unicast_open(&uc, 199, &unicast_callbacks);
while(1) {
static struct etimer et;
linkaddr_t addr;
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
//packetbuf_copyfrom("Enric Here!", 12);
//addr.u8[0] = 200;
//addr.u8[1] = 0;
//if(!linkaddr_cmp(&addr, &linkaddr_node_addr)) {
//unicast_send(&uc, &addr);
//}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,4 +1,4 @@
Re-Mote + Node Red README RE-Mote + Node Red README
======================== ========================
A very basic example of how to use MQTT-Demo + Mosquitto + Node Red A very basic example of how to use MQTT-Demo + Mosquitto + Node Red
@ -10,9 +10,9 @@ Install Mosquitto
Fire up a Re-Mote Fire up a Re-Mote
----------------- -----------------
* Compile the MQTT demo example from `../../cc2538dk/mqtt-demo.c` following * Compile the MQTT demo example from `../../../cc2538dk/mqtt-demo.c` following
the instructions of the README.md therein. the instructions of the README.md therein.
* Program your Re-Mote. * Program your RE-Mote.
* If you are running mosquitto with `-v`, a few seconds later you should see * If you are running mosquitto with `-v`, a few seconds later you should see
the Re-Mote connect, subscribe and start publishing. the Re-Mote connect, subscribe and start publishing.

View file

@ -33,7 +33,7 @@
* @{ * @{
* *
* \file * \file
* Project specific configuration defines for the basic Re-Mote examples * Project specific configuration defines for the basic RE-Mote examples
*/ */
#ifndef PROJECT_CONF_H_ #ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_ #define PROJECT_CONF_H_

View file

@ -30,21 +30,30 @@
* *
*/ */
/** /**
* \addtogroup zoul-examples
* @{
*
* \defgroup zoul-sht25-test SHT25 temperature and humidity sensor test
*
* Demonstrates the use of the SHT25 digital temperature and humidity sensor
* @{
*
* \file * \file
* A quick program for testing the SHT25 temperature and humidity sensor * A quick program for testing the SHT25 temperature and humidity sensor
* \author * \author
* Antonio Lignan <alinan@zolertia.com> * Antonio Lignan <alinan@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/sht25.h" #include "dev/sht25.h"
/*---------------------------------------------------------------------------*/
PROCESS(test_sht25_process, "SHT25 test"); PROCESS(remote_sht25_process, "SHT25 test");
AUTOSTART_PROCESSES(&test_sht25_process); AUTOSTART_PROCESSES(&remote_sht25_process);
/*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_sht25_process, ev, data) PROCESS_THREAD(remote_sht25_process, ev, data)
{ {
int16_t temperature, humidity; int16_t temperature, humidity;
@ -61,3 +70,9 @@ PROCESS_THREAD(test_sht25_process, ev, data)
} }
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View file

@ -29,41 +29,41 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \addtogroup remote-examples * \addtogroup zoul-examples
* @{ * @{
* *
* \defgroup remote-tsl2563-test Re-Mote TSL2563 light sensor test * \defgroup zoul-tsl2563-test TSL2563 light sensor test
* *
* Demonstrates the use of the TSL2563 digital ambient light sensor * Demonstrates the use of the TSL2563 digital ambient light sensor
* @{ * @{
* *
* \file * \file
* Driver for the Re-Mote external TSL2563 light sensor (Ziglet) * Driver for the external TSL2563 light sensor
* *
* \author * \author
* Antonio Lignan <alinan@zolertia.com> * Antonio Lignan <alinan@zolertia.com>
* Toni Lozano <tlozano@zolertia.com> * Toni Lozano <tlozano@zolertia.com>
*/ */
/*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "contiki.h" #include "contiki.h"
#include "dev/i2c.h" #include "dev/i2c.h"
#include "dev/tsl2563.h" #include "dev/tsl2563.h"
/*---------------------------------------------------------------------------*/
#if 1 #if 1
#define PRINTF(...) printf(__VA_ARGS__) #define PRINTF(...) printf(__VA_ARGS__)
#else #else
#define PRINTF(...) #define PRINTF(...)
#endif #endif
/*---------------------------------------------------------------------------*/
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2) #define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
/*---------------------------------------------------------------------------*/
PROCESS(test_process, "Test TSL2563 light ziglet process"); PROCESS(remote_tsl2563_process, "TSL2563 test process");
AUTOSTART_PROCESSES(&test_process); AUTOSTART_PROCESSES(&remote_tsl2563_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_process, ev, data) PROCESS_THREAD(remote_tsl2563_process, ev, data)
{ {
PROCESS_BEGIN(); PROCESS_BEGIN();
int light; int light;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,15 +30,16 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* \addtogroup remote * \addtogroup zoul
* @{ * @{
* *
* \defgroup remote-examples Re-Mote Example Projects * \defgroup zoul-examples Zoul examples
* @{ * @{
* *
* \defgroup remote-demo Re-Mote Demo Project * \defgroup zoul-demo Zoul demo application
* *
* Example project demonstrating the Re-Mote functionality * Example project demonstrating the Zoul module on the RE-Mote and Firefly
* platforms.
* *
* - Boot sequence: LEDs flashing (Red, then yellow, finally green) * - Boot sequence: LEDs flashing (Red, then yellow, finally green)
* *
@ -54,13 +56,11 @@
* packet will toggle LEDs defined as LEDS_RF_RX * packet will toggle LEDs defined as LEDS_RF_RX
* - Button : Keeping the button pressed will print a counter that * - Button : Keeping the button pressed will print a counter that
* increments every BUTTON_PRESS_EVENT_INTERVAL ticks * increments every BUTTON_PRESS_EVENT_INTERVAL ticks
* - TMP102 : Built-in digital temperature sensor, every LOOP_INTERVAL
* clock ticks a sensor reading will be taken
* *
* @{ * @{
* *
* \file * \file
* Example demonstrating the Re-Mote platform * Example demonstrating the Zoul module on the RE-Mote & Firefly platforms
*/ */
#include "contiki.h" #include "contiki.h"
#include "cpu.h" #include "cpu.h"
@ -69,13 +69,11 @@
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/uart.h" #include "dev/uart.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/remote-sensors.h" #include "dev/zoul-sensors.h"
#include "dev/watchdog.h" #include "dev/watchdog.h"
#include "dev/serial-line.h" #include "dev/serial-line.h"
#include "dev/sys-ctrl.h" #include "dev/sys-ctrl.h"
#include "net/rime/broadcast.h" #include "net/rime/broadcast.h"
#include "dev/antenna-sw.h"
#include "dev/tmp102.h"
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
@ -94,10 +92,10 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;
static struct rtimer rt; static struct rtimer rt;
static uint16_t counter, temperature; static uint16_t counter;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(cc2538_demo_process, "cc2538 demo process"); PROCESS(zoul_demo_process, "Zoul demo process");
AUTOSTART_PROCESSES(&cc2538_demo_process); AUTOSTART_PROCESSES(&zoul_demo_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from) broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
@ -116,7 +114,7 @@ rt_callback(struct rtimer *t, void *ptr)
leds_off(LEDS_PERIODIC); leds_off(LEDS_PERIODIC);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc2538_demo_process, ev, data) PROCESS_THREAD(zoul_demo_process, ev, data)
{ {
PROCESS_EXITHANDLER(broadcast_close(&bc)) PROCESS_EXITHANDLER(broadcast_close(&bc))
@ -125,15 +123,14 @@ PROCESS_THREAD(cc2538_demo_process, ev, data)
counter = 0; counter = 0;
broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx); broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx);
/* Enable antenna */ /* Configure the user button */
antenna_sw_select(ANTENNA_SW_SELECT_INTERNAL);
button_sensor.configure(BUTTON_SENSOR_CONFIG_TYPE_INTERVAL, button_sensor.configure(BUTTON_SENSOR_CONFIG_TYPE_INTERVAL,
BUTTON_PRESS_EVENT_INTERVAL); BUTTON_PRESS_EVENT_INTERVAL);
tmp102_init(); /* Configure the ADC ports */
adc_sensors.configure(SENSORS_HW_INIT, ZOUL_SENSORS_ADC_ALL);
printf("Re-Mote test application, initial values:\n"); printf("Zoul test application\n");
etimer_set(&et, LOOP_INTERVAL); etimer_set(&et, LOOP_INTERVAL);
@ -153,14 +150,11 @@ PROCESS_THREAD(cc2538_demo_process, ev, data)
printf("Temperature = %d mC\n", printf("Temperature = %d mC\n",
cc2538_temp_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED)); cc2538_temp_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
printf("Phidget ADC2 = %d raw\n", printf("ADC1 = %d raw\n",
phidget_sensor.value(PHIDGET_SENSORS_ADC2)); adc_sensors.value(ZOUL_SENSORS_ADC1));
printf("Phidget ADC3 = %d raw\n", printf("ADC3 = %d raw\n",
phidget_sensor.value(PHIDGET_SENSORS_ADC3)); adc_sensors.value(ZOUL_SENSORS_ADC3));
tmp102_read(&temperature);
printf("TMP102 sensor = %u mC\n", temperature);
etimer_set(&et, LOOP_INTERVAL); etimer_set(&et, LOOP_INTERVAL);
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1, rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,
@ -170,11 +164,11 @@ PROCESS_THREAD(cc2538_demo_process, ev, data)
if(data == &button_sensor) { if(data == &button_sensor) {
if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) == if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
BUTTON_SENSOR_PRESSED_LEVEL) { BUTTON_SENSOR_PRESSED_LEVEL) {
printf("Press\n"); printf("Button pressed\n");
packetbuf_copyfrom(&counter, sizeof(counter)); packetbuf_copyfrom(&counter, sizeof(counter));
broadcast_send(&bc); broadcast_send(&bc);
} else { } else {
printf("Release\n"); printf("...and released!\n");
} }
} }
} else if(ev == serial_line_event_message) { } else if(ev == serial_line_event_message) {

View file

@ -103,7 +103,7 @@ void menu_process(char c);
extern char usb_busy; extern char usb_busy;
//! Counter for USB Serial port //! Counter for USB Serial port
extern U8 tx_counter; extern U8 tx_counter;
//! Timers for LEDs //! Timers for LEDs
uint8_t led3_timer; uint8_t led3_timer;

View file

@ -66,7 +66,7 @@ extract_random_bit_() {
cli(); cli();
#ifdef PRR #ifdef PRR
// Enable ADC module // Enable ADC module
PRR &= ~(1 << PRADC); PRR &= ~(1 << PRADC);
#endif #endif
@ -100,7 +100,7 @@ extract_random_bit_() {
// Toggling the reference voltage // Toggling the reference voltage
// seems to help introduce noise. // seems to help introduce noise.
ADMUX^=(1<<REFS1); ADMUX^=(1<<REFS1);
// We only want to exit the loop if the first // We only want to exit the loop if the first
// and second sampled bits are different. // and second sampled bits are different.
// This is preliminary conditioning. // This is preliminary conditioning.
@ -156,7 +156,7 @@ static uint8_t
extract_random_bit_() { extract_random_bit_() {
uint8_t ret; uint8_t ret;
uint8_t trx_ctrl_0 = hal_register_read(TRX_CTRL_0); uint8_t trx_ctrl_0 = hal_register_read(TRX_CTRL_0);
// Set radio clock output to 8MHz // Set radio clock output to 8MHz
hal_register_write(TRX_CTRL_0,0x8|5); hal_register_write(TRX_CTRL_0,0x8|5);
@ -170,10 +170,10 @@ extract_random_bit_() {
// Toss out the other bit, we only care about one of them. // Toss out the other bit, we only care about one of them.
ret &= 1; ret &= 1;
// Restore the clkm state // Restore the clkm state
hal_register_write(TRX_CTRL_0,trx_ctrl_0); hal_register_write(TRX_CTRL_0,trx_ctrl_0);
return ret; return ret;
} }

View file

@ -28,11 +28,21 @@ MODULES += core/net core/net/mac \
core/net/mac/contikimac \ core/net/mac/contikimac \
core/net/llsec core/net/llsec
PYTHON = python
BSL_FLAGS += -e -w -v
ifdef PORT
BSL_FLAGS += -p $(PORT)
endif
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
%.upload: %.bin %.upload: %.bin %.elf
ifeq ($(wildcard $(BSL)), ) ifeq ($(wildcard $(BSL)), )
@echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?"
else else
python $(BSL) -e -w -v $< $(eval BSL_ADDRESS_ARG := -a $(shell $(OBJDUMP) -h $*.elf | grep -B1 LOAD | \
grep -Ev 'LOAD|\-\-' | awk '{print "0x" $$5}' | \
sort -g | head -1))
$(PYTHON) $(BSL) $(BSL_FLAGS) $(BSL_ADDRESS_ARG) $<
endif endif

View file

@ -31,6 +31,7 @@ In terms of hardware support, the following drivers have been implemented:
* ADC * ADC
* Cryptoprocessor (AES-CCM-256, SHA-256) * Cryptoprocessor (AES-CCM-256, SHA-256)
* Public Key Accelerator (ECDH, ECDSA) * Public Key Accelerator (ECDH, ECDSA)
* Flash-based port of Coffee
* SmartRF06 EB and BB peripherals * SmartRF06 EB and BB peripherals
* LEDs * LEDs
* Buttons * Buttons

View file

@ -57,21 +57,6 @@ typedef uint32_t rtimer_clock_t;
#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */ #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */
#endif #endif
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Flash Memory configuration
*
* @{
*/
#ifndef FLASH_CONF_ORIGIN
#define FLASH_CONF_ORIGIN 0x00200000
#endif
#ifndef FLASH_CONF_SIZE
#define FLASH_CONF_SIZE 0x00080000 /* 512 KiB */
#endif
/** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \name Watchdog Timer configuration * \name Watchdog Timer configuration

View file

@ -191,7 +191,7 @@ contiki_init(void)
/* Initialize communication stack */ /* Initialize communication stack */
netstack_init(); netstack_init();
printf("%s/%s/%s, channel check rate %lu Hz\n", printf("%s/%s/%s, channel check rate %lu Hz\n",
NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval())); NETSTACK_RDC.channel_check_interval()));

View file

@ -228,7 +228,7 @@ contiki_init()
set_rime_addr(); set_rime_addr();
{ {
uint8_t longaddr[8]; uint8_t longaddr[8];
memset(longaddr, 0, sizeof(longaddr)); memset(longaddr, 0, sizeof(longaddr));
linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr); linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
@ -241,7 +241,7 @@ contiki_init()
/* Initialize communication stack */ /* Initialize communication stack */
netstack_init(); netstack_init();
printf("%s/%s/%s, channel check rate %lu Hz\n", printf("%s/%s/%s, channel check rate %lu Hz\n",
NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval())); NETSTACK_RDC.channel_check_interval()));
@ -294,11 +294,11 @@ contiki_init()
int i; int i;
lladdr = uip_ds6_get_link_local(-1); lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) { for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]); lladdr->ipaddr.u8[i * 2 + 1]);
} }
printf("%02x%02x\n", lladdr->ipaddr.u8[14], printf("%02x%02x\n", lladdr->ipaddr.u8[14],
lladdr->ipaddr.u8[15]); lladdr->ipaddr.u8[15]);
} }
if(1) { if(1) {
@ -320,7 +320,7 @@ contiki_init()
/* Initialize eeprom */ /* Initialize eeprom */
eeprom_init(); eeprom_init();
/* Start serial process */ /* Start serial process */
serial_line_init(); serial_line_init();
@ -417,10 +417,9 @@ JNIEXPORT void JNICALL
Java_org_contikios_cooja_corecomm_CLASSNAME_setMemory(JNIEnv *env, jobject obj, jint rel_addr, jint length, jbyteArray mem_arr) Java_org_contikios_cooja_corecomm_CLASSNAME_setMemory(JNIEnv *env, jobject obj, jint rel_addr, jint length, jbyteArray mem_arr)
{ {
jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0); jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0);
memcpy( memcpy((char*) (((long)rel_addr) + referenceVar),
(char*) (((long)rel_addr) + referenceVar), mem,
mem, length);
length);
(*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0); (*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -453,7 +452,7 @@ Java_org_contikios_cooja_corecomm_CLASSNAME_tick(JNIEnv *env, jobject obj)
doActionsBeforeTick(); doActionsBeforeTick();
/* Poll etimer process */ /* Poll etimer process */
if (etimer_pending()) { if(etimer_pending()) {
etimer_request_poll(); etimer_request_poll();
} }
@ -481,9 +480,9 @@ Java_org_contikios_cooja_corecomm_CLASSNAME_tick(JNIEnv *env, jobject obj)
nextRtimer = rtimer_arch_next() - (rtimer_clock_t) simCurrentTime; nextRtimer = rtimer_arch_next() - (rtimer_clock_t) simCurrentTime;
if(etimer_pending() && rtimer_arch_pending()) { if(etimer_pending() && rtimer_arch_pending()) {
simNextExpirationTime = MIN(nextEtimer, nextRtimer); simNextExpirationTime = MIN(nextEtimer, nextRtimer);
} else if (etimer_pending()) { } else if(etimer_pending()) {
simNextExpirationTime = nextEtimer; simNextExpirationTime = nextEtimer;
} else if (rtimer_arch_pending()) { } else if(rtimer_arch_pending()) {
simNextExpirationTime = nextRtimer; simNextExpirationTime = nextRtimer;
} }
} }

View file

@ -327,7 +327,8 @@ init(void)
return 0; return 0;
} else { } else {
rx_frame_buffer = &input_array[put_index]; rx_frame_buffer = &input_array[put_index];
} input_frame_buffer = rx_frame_buffer; }
input_frame_buffer = rx_frame_buffer;
process_start(&micromac_radio_process, NULL); process_start(&micromac_radio_process, NULL);
@ -361,7 +362,8 @@ on(void)
); );
} else { } else {
missed_radio_on_request = 1; missed_radio_on_request = 1;
} ENERGEST_ON(ENERGEST_TYPE_LISTEN); }
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
listen_on = 1; listen_on = 1;
return 1; return 1;
} }
@ -436,7 +438,8 @@ transmit(unsigned short payload_len)
RIMESTATS_ADD(noacktx); RIMESTATS_ADD(noacktx);
} else { } else {
ret = RADIO_TX_ERR; ret = RADIO_TX_ERR;
} return ret; }
return ret;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
@ -452,8 +455,8 @@ prepare(const void *payload, unsigned short payload_len)
} }
if(payload_len > 127 || payload == NULL) { if(payload_len > 127 || payload == NULL) {
return 1; return 1;
/* Copy payload to (soft) Ttx buffer */
} }
/* Copy payload to (soft) Ttx buffer */
memcpy(tx_frame_buffer.uPayload.au8Byte, payload, payload_len); memcpy(tx_frame_buffer.uPayload.au8Byte, payload, payload_len);
i = payload_len; i = payload_len;
#if CRC_SW #if CRC_SW
@ -563,6 +566,7 @@ read(void *buf, unsigned short bufsize)
len = input_frame_buffer->u8PayloadLength; len = input_frame_buffer->u8PayloadLength;
if(len <= CHECKSUM_LEN) { if(len <= CHECKSUM_LEN) {
input_frame_buffer->u8PayloadLength = 0;
return 0; return 0;
} else { } else {
len -= CHECKSUM_LEN; len -= CHECKSUM_LEN;
@ -599,8 +603,9 @@ read(void *buf, unsigned short bufsize)
} }
} else { } else {
len = 0; len = 0;
/* Disable further read attempts */ }
} input_frame_buffer->u8PayloadLength = 0; /* Disable further read attempts */
input_frame_buffer->u8PayloadLength = 0;
} }
return len; return len;

View file

@ -49,8 +49,9 @@
#define RTIMER_ARCH_SECOND (F_CPU / 2) #define RTIMER_ARCH_SECOND (F_CPU / 2)
#endif #endif
#define US_TO_RTIMERTICKS(D) ((int64_t)(D) << 4) #define US_TO_RTIMERTICKS(D) ((int64_t)(D) << 4)
#define RTIMERTICKS_TO_US(T) ((int64_t)(T) >> 4) #define RTIMERTICKS_TO_US(T) ((int64_t)(T) >> 4)
#define RTIMERTICKS_TO_US_64(T) RTIMERTICKS_TO_US(T)
rtimer_clock_t rtimer_arch_now(void); rtimer_clock_t rtimer_arch_now(void);

View file

@ -1,46 +0,0 @@
# Remote platform makefile
ifndef CONTIKI
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
endif
PYTHON = python
BSL_FLAGS += -e -w -v -b 115200
ifdef PORT
BSL_FLAGS += -p $(PORT)
endif
CONTIKI_TARGET_DIRS = . dev
CONTIKI_TARGET_SOURCEFILES += leds.c leds-arch.c
CONTIKI_TARGET_SOURCEFILES += contiki-main.c
CONTIKI_TARGET_SOURCEFILES += sensors.c remote-sensors.c
CONTIKI_TARGET_SOURCEFILES += button-sensor.c antenna-sw.c
CONTIKI_TARGET_SOURCEFILES += phidget-sensor.c tmp102.c
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
CLEAN += *.remote
### Unless the example dictates otherwise, build with code size optimisations
ifndef SMALL
SMALL = 1
endif
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/cc2538
include $(CONTIKI_CPU)/Makefile.cc2538
MODULES += core/net core/net/mac \
core/net/mac/contikimac \
core/net/llsec
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
%.upload: %.bin
ifeq ($(wildcard $(BSL)), )
@echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?"
else
$(PYTHON) $(BSL) $(BSL_FLAGS) $<
endif

View file

@ -1,278 +0,0 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \addtogroup remote
* @{
*
* \defgroup remote-peripherals Re-Mote Peripherals
*
* Defines related to the Re-Mote
*
* This file provides connectivity information on LEDs, Buttons, UART and
* other Re-Mote peripherals
*
* This file can be used as the basis to configure other platforms using the
* cc2538 SoC.
* @{
*
* \file
* Header file with definitions related to the I/O connections on the Zolertia's
* Re-Mote platform, cc2538-based
*
* \note Do not include this file directly. It gets included by contiki-conf
* after all relevant directives have been set.
*/
#ifndef BOARD_H_
#define BOARD_H_
#include "dev/gpio.h"
#include "dev/nvic.h"
/*---------------------------------------------------------------------------*/
/** \name Re-Mote LED configuration
*
* LEDs on the Re-mote are connected as follows:
* - LED1 (Red) -> PD2
* - LED2 (Blue) -> PC3
* - LED3 (Green) -> PD5
*
* LED1 routed also to JP5 connector
* LED2 shares the same pin with Watchdog WDI pulse and routed to JP8 connector
* LED3 routed also to JP5 connector
* @{
*/
/*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN 1 /**< LED1 (Green) -> PD5 */
#define LEDS_BLUE 2 /**< LED2 (Blue) -> PC3 */
#define LEDS_RED 4 /**< LED3 (Red) -> PD2 */
#define LEDS_CONF_ALL 7
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (3) */
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (5) */
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (6) */
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (7) */
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
/** @} */
/*---------------------------------------------------------------------------*/
/** \name USB configuration
*
* The USB pullup is enabled by an external resistor, not mapped to a GPIO
*/
#ifdef USB_PULLUP_PORT
#undef USB_PULLUP_PORT
#endif
#ifdef USB_PULLUP_PIN
#undef USB_PULLUP_PIN
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/** \name UART configuration
*
* On the Re-Mote, the UART is connected to the following ports/pins
* - UART0:
* - RX: PA0
* - TX: PA1
* - UART1:
* - RX: PC6
* - TX: PC5
* - CTS:
* - RTS:
* We configure the port to use UART0 and UART1, CTS/RTS only for UART1,
* both without a HW pull-up resistor
* @{
*/
#define UART0_RX_PORT GPIO_A_NUM
#define UART0_RX_PIN 0
#define UART0_TX_PORT GPIO_A_NUM
#define UART0_TX_PIN 1
#define UART1_RX_PORT GPIO_C_NUM
#define UART1_RX_PIN 6
#define UART1_TX_PORT GPIO_C_NUM
#define UART1_TX_PIN 5
#define UART1_CTS_PORT GPIO_C_NUM
#define UART1_CTS_PIN 1
#define UART1_RTS_PORT GPIO_C_NUM
#define UART1_RTS_PIN 2
/** @} */
/*---------------------------------------------------------------------------*/
/** \name Re-Mote Button configuration
*
* Buttons on the Re-Mote are connected as follows:
* - BUTTON_USER -> PA3, S1 user button, shared with bootloader
* - BUTTON_RESET -> RESET_N line, S2 reset both CC2538 and CoP
* - BUTTON_VBAT -> Power switch, not mounted by default
* @{
*/
/** BUTTON_USER -> PA3 */
#define BUTTON_USER_PORT GPIO_A_NUM
#define BUTTON_USER_PIN 3
#define BUTTON_USER_VECTOR NVIC_INT_GPIO_PORT_A
/* Notify various examples that we have Buttons */
#define PLATFORM_HAS_BUTTON 1
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name ADC configuration
*
* These values configure which CC2538 pins and ADC channels to use for the ADC
* inputs. By default the Re-Mote allows two out-of-the-box ADC ports with a
* phidget-like 3-pin connector (GND/3V3/ADC)
*
* ADC inputs can only be on port A.
* @{
*/
#define ADC_PHIDGET_PORT GPIO_A_NUM /**< Phidget GPIO control port */
#define ADC_PHIDGET_ADC2_PIN 6 /**< ADC2 to PA6, 3V3 */
#define ADC_PHIDGET_ADC3_PIN 7 /**< ADC3 to PA7, 3V3 */
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name SPI (SSI0) configuration
*
* These values configure which CC2538 pins to use for the SPI (SSI0) lines,
* shared with the CC1120 RF transceiver
* TX -> MOSI, RX -> MISO
* @{
*/
#define SPI0_CLK_PORT GPIO_D_NUM
#define SPI0_CLK_PIN 1
#define SPI0_TX_PORT GPIO_D_NUM
#define SPI0_TX_PIN 0
#define SPI0_RX_PORT GPIO_C_NUM
#define SPI0_RX_PIN 4
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name SPI (SSI1) configuration
*
* These values configure which CC2538 pins to use for the SPI (SSI1) lines,
* shared with the microSD, not routed anywhere.
* TX -> MOSI, RX -> MISO
* @{
*/
#define SPI1_CLK_PORT GPIO_B_NUM
#define SPI1_CLK_PIN 5
#define SPI1_TX_PORT GPIO_C_NUM
#define SPI1_TX_PIN 7
#define SPI1_RX_PORT GPIO_A_NUM
#define SPI1_RX_PIN 4
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name I2C configuration
*
* These values configure which CC2538 pins to use for the I2C lines, shared
* with the TMP102 built-in temperature sensor
* @{
*/
#define I2C_SCL_PORT GPIO_B_NUM
#define I2C_SCL_PIN 1
#define I2C_SDA_PORT GPIO_B_NUM
#define I2C_SDA_PIN 0
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Antenna switch configuration
*
* These values configure the required pin to drive the antenna switch, to
* use either the built-in ceramic antenna or an external one over the uFL
* connector
* - Internal antenna: LOW
* - External antenna: HIGH
* @{
*/
#define ANTENNA_2_4GHZ_SW_PORT GPIO_D_NUM
#define ANTENNA_2_4GHZ_SW_PIN 4
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name CC1120/CC1200 configuration
*
* These values configure the required pins to drive the CC1120/CC1200
* @{
*/
#define CC1120_SPI_SCLK_PORT SPI0_CLK_PORT
#define CC1120_SPI_SCLK_PIN SPI0_CLK_PIN
#define CC1120_SPI_MOSI_PORT SPIO0_TX_PORT
#define CC1120_SPI_MOSI_PIN SPIO0_TX_PIN
#define CC1120_SPI_MISO_PORT SPIO0_RX_PORT
#define CC1120_SPI_MISO_PIN SPIO0_RX_PIN
#define CC1120_SPI_CSN_PORT GPIO_D_NUM
#define CC1120_SPI_CSN_PIN 3
#define CC1120_GDO0_PORT GPIO_B_NUM
#define CC1120_GDO0_PIN 4
#define CC1120_GDO2_PORT GPIO_B_NUM
#define CC1120_GDO2_PIN 3
#define CC1120_RESET_PORT GPIO_B_NUM
#define CC1120_RESET_PIN 2
#define CC1120_GPIO0_VECTOR NVIC_INT_GPIO_PORT_B
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name microSD configuration
*
* These values configure the required pins to drive the built-in microSD
* external module, to be used with SSI1
* @{
*/
#define USD_CLK_PORT SPI1_CLK_PORT
#define USD_CLK_PIN SPI1_CLK_PIN
#define USD_MOSI_PORT SPI1_TX_PORT
#define USD_MOSI_PIN SPI1_TX_PIN
#define USD_MISO_PORT SPI1_RX_PORT
#define USD_MISO_PIN SPI1_RX_PIN
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Device string used on startup
* @{
*/
#define BOARD_STRING "Zolertia Re-Mote platform"
/** @} */
#endif /* BOARD_H_ */
/**
* @}
* @}
*/

View file

@ -45,16 +45,64 @@ In terms of hardware support, the following drivers have been implemented:
* Buzzer * Buzzer
* External SPI flash * External SPI flash
Requirements
============
To use the port you need:
* TI's CC26xxware sources. The correct version will be installed automatically
as a submodule when you clone Contiki.
* TI's CC13xxware sources. The correct version will be installed automatically
as a submodule when you clone Contiki.
* Contiki can automatically upload firmware to the nodes over serial with the
included [cc2538-bsl script](https://github.com/JelmerT/cc2538-bsl).
Note that uploading over serial doesn't work for the Sensortag, you can use
TI's SmartRF Flash Programmer in this case.
* A toolchain to build firmware: The port has been developed and tested with
GNU Tools for ARM Embedded Processors <https://launchpad.net/gcc-arm-embedded>.
The port was developed and tested using this version:
$ arm-none-eabi-gcc -v
[...]
gcc version 4.9.3 20141119 (release) [ARM/embedded-4_9-branch revision 218278] (GNU Tools for ARM Embedded Processors)
* srecord (http://srecord.sourceforge.net/)
* You may also need other drivers so that the SmartRF can communicate with your
operating system and so that you can use the chip's UART for I/O. Please read
the section ["Drivers" in the CC2538DK readme](https://github.com/contiki-os/contiki/tree/master/platform/cc2538dk#drivers).
Examples Examples
======== ========
The port comes with two examples: A very basic example and a mode advanced one The port comes with three examples:
(web demo). The former demonstrates how to read sensors and how to use board - A very basic example which demonstrates how to read sensors and how to use board peripherals. It also demonstrates how to send out BLE advertisements.
peripherals. It also demonstrates how to send out BLE advertisements. - A more advanced one (web demo) which includes a CoAP server, an MQTT client which connects and publishes to the IBM quickstart service, a net-based UART and lastly a web server that can be used to configure the rest of the example.
The latter includes a CoAP server, an MQTT client which connects and publishes - An example demonstrating a very sleepy node.
to the IBM quickstart service, a net-based UART and lastly a web server that
can be used to configure the rest of the example.
More details about those two examples can be found in their respective READMEs. More details about those three examples can be found in their respective READMEs.
Build your First Example
------------------------
It is recommended to start with the `cc26xx-demo` example under `examples/cc26xx/`. This is a very simple example which will help you get familiar with the hardware and the environment. This example can be used for the Sensortag and SmartRF06 EB.
Strictly speaking, to build it you need to run `make TARGET=srf06-cc26xx BOARD=srf06/cc26xx`. However, the example directories contain a `Makefile.target` which is automatically included and specifies the correct `TARGET=` argument. The `BOARD=` environment variable defaults to `srf06/cc26xx` (which is the SmartRF06 EB + CC26XXEM). Thus, for examples under the `cc26xx` directory, and when using the SmartRF06 EB, you can simply run `make`.
Other options for the `BOARD` make variable are:
* Srf06+CC26xxEM: Set `BOARD=srf06/cc26xx`
* Srf06+CC13xxEM: Set `BOARD=srf06/cc13xx`
* CC2650 tag: Set `BOARD=sensortag/cc2650`
If the `BOARD` variable is unspecified, an image for the Srf06 CC26XXEM will be built.
If you want to switch between building for one platform to the other, make certain to `make clean` before building for the new one, or you will get linker
errors.
If you want to upload the compiled firmware to a node via the serial boot loader you need to manually enable the boot loader and then use `make cc26xx-demo.upload`. On the SmartRF06 board you enable the boot loader by resetting the board (EM RESET button) while holding the `select` button. (The boot loader backdoor needs to be enabled on the chip, and the chip needs to be configured correctly, for this to work. See README in the `tools/cc2538-bsl` directory for more info). The serial uploader script will automatically pick the first available serial port. If this is not the port where your node is connected, you can force the script to use a specific port by defining the `PORT` argument eg. `make cc26xx-demo.upload PORT=/dev/tty.usbserial`
Note that uploading over serial doesn't work for the Sensortag, you can use TI's SmartRF Flash Programmer in this case.
For the `cc26xx-demo`, the included readme describes in detail what the example does.
To generate an assembly listing of the compiled firmware, run `make cc26xx-demo.lst`. This may be useful for debugging or optimizing your application code. To intersperse the C source code within the assembly listing, you must instruct the compiler to include debugging information by adding `CFLAGS += -g` to the project Makefile and rebuild by running `make clean cc26xx-demo.lst`.
CC13xx/CC26xx Border Router over UART CC13xx/CC26xx Border Router over UART
===================================== =====================================
@ -94,28 +142,6 @@ that limit the size of the uIP buffer. Removing the two lines below from
Do not forget to set the correct channel by defining `RF_CORE_CONF_CHANNEL` as Do not forget to set the correct channel by defining `RF_CORE_CONF_CHANNEL` as
required. required.
Requirements
============
To use the port you need:
* TI's CC26xxware sources. The correct version will be installed automatically
as a submodule when you clone Contiki.
* TI's CC13xxware sources. The correct version will be installed automatically
as a submodule when you clone Contiki.
* Software to program the nodes. Use TI's SmartRF Flash Programmer
* A toolchain to build firmware: The port has been developed and tested with
GNU Tools for ARM Embedded Processors <https://launchpad.net/gcc-arm-embedded>.
The port was developed and tested using this version:
$ arm-none-eabi-gcc -v
[...]
gcc version 4.9.3 20141119 (release) [ARM/embedded-4_9-branch revision 218278] (GNU Tools for ARM Embedded Processors)
* srecord (http://srecord.sourceforge.net/)
* You may also need other drivers so that the SmartRF can communicate with your
operating system and so that you can use the chip's UART for I/O. Please read
the section ["Drivers" in the CC2538DK readme](https://github.com/contiki-os/contiki/tree/master/platform/cc2538dk#drivers).
Filename conflicts between Contiki and CC26xxware Filename conflicts between Contiki and CC26xxware
================================================= =================================================
There is a file called `timer.c` both in Contiki as well as in CC26xxware. The There is a file called `timer.c` both in Contiki as well as in CC26xxware. The
@ -124,25 +150,6 @@ start using it at some point, you will need to rename it:
From `cpu/cc26xx/lib/cc26xxware/driverlib/timer.c` to `driverlib-timer.c` From `cpu/cc26xx/lib/cc26xxware/driverlib/timer.c` to `driverlib-timer.c`
Sensortag vs Srf06
==================
To build for the sensortag, you will need to set the `BOARD` make variable as
follows:
* Srf06+CC26xxEM: Set `BOARD=srf06/cc26xx`
* Srf06+CC13xxEM: Set `BOARD=srf06/cc13xx`
* CC2650 tag: Set `BOARD=sensortag/cc2650`
You can do that by exporting `BOARD` as an environment variable, by adding it
to your Makefile or by adding it to your make command as an argument.
If the `BOARD` variable is unspecified, an image for the Srf06 CC26XXEM will be
built.
If you want to switch between building for one platform to the other, make
certain to `make clean` before building for the new one, or you will get linker
errors.
Sensortag UART usage (with or without the Debugger Devpack) Sensortag UART usage (with or without the Debugger Devpack)
=========================================================== ===========================================================
There are two ways to get debugging (printf etc) output from the Sensortag. There are two ways to get debugging (printf etc) output from the Sensortag.

View file

@ -3,3 +3,19 @@ CFLAGS += -DBOARD_SMARTRF06EB=1
CONTIKI_TARGET_DIRS += srf06 CONTIKI_TARGET_DIRS += srf06
BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c
PYTHON = python
BSL_FLAGS += -e -w -v
ifdef PORT
BSL_FLAGS += -p $(PORT)
endif
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
%.upload: %.bin
ifeq ($(wildcard $(BSL)), )
@echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?"
else
$(PYTHON) $(BSL) $(BSL_FLAGS) $<
endif

View file

@ -122,5 +122,4 @@ status(int type)
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
SENSORS_SENSOR(acc_sensor, ACC_SENSOR, SENSORS_SENSOR(acc_sensor, ACC_SENSOR, value, configure, status);
value, configure, status);

View file

@ -100,5 +100,4 @@ configure(int type, int c)
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
SENSORS_SENSOR(ext_sensor, "Ext", SENSORS_SENSOR(ext_sensor, "Ext", value, configure, status);
value, configure, status);

View file

@ -57,12 +57,11 @@ ifeq ($(HOST_OS),Darwin)
ifndef MOTELIST ifndef MOTELIST
USBDEVPREFIX= USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1-macos MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia-macos
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1 BSL = $(CONTIKI)/tools/zolertia/z1-bsl-nopic --z1
BSL_FILETYPE = -I BSL_FILETYPE = -I
MOTES = $(shell $(MOTELIST) -c 2>&- | \ MOTES = $(shell $(MOTELIST) -b z1 -c 2>&- | \
cut -f 2 -d ,) cut -f 2 -d ,)
CMOTES=$(MOTES)
REFNUM = $(shell $(MOTELIST) -c 2>&- | \ REFNUM = $(shell $(MOTELIST) -c 2>&- | \
cut -f 1 -d , | tail -c5 | sed 's/^0*//') cut -f 1 -d , | tail -c5 | sed 's/^0*//')
ifneq (,$(REFNUM)) ifneq (,$(REFNUM))
@ -77,10 +76,10 @@ else
ifndef MOTELIST ifndef MOTELIST
USBDEVPREFIX= USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1 MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1 BSL = $(CONTIKI)/tools/zolertia/z1-bsl-nopic --z1
BSL_FILETYPE = -I BSL_FILETYPE = -I
MOTES = $(shell $(MOTELIST) -c 2>&- | \ MOTES = $(shell $(MOTELIST) -b z1 -c 2>&- | \
cut -f 2 -d , | \ cut -f 2 -d , | \
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);') perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
CMOTES=$(MOTES) CMOTES=$(MOTES)
@ -95,12 +94,10 @@ else
endif endif
endif endif
motelist:
motelist: z1-motelist
z1-motelist:
$(MOTELIST) $(MOTELIST)
z1-motelist:
$(MOTELIST) -b z1
z1-motes: z1-motes:
@echo $(MOTES) @echo $(MOTES)

100
platform/zoul/Makefile.zoul Normal file
View file

@ -0,0 +1,100 @@
### Zoul Makefile
ifndef CONTIKI
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
endif
### If no board is specified the default option is the RE-Mote
ifeq ($(BOARD),)
BOARD=remote
endif
PYTHON = python
BSL_FLAGS += -e -w -v
ifdef PORT
BSL_FLAGS += -p $(PORT)
endif
### Configure the build for the board and pull in board-specific sources
CONTIKI_TARGET_DIRS += . dev
CONTIKI_TARGET_DIRS += . $(BOARD)
PLATFORM_ROOT_DIR = $(CONTIKI)/platform/$(TARGET)
### Include the board dir if one exists
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD)
### Include
CONTIKI_TARGET_SOURCEFILES += contiki-main.c
CONTIKI_TARGET_SOURCEFILES += leds.c leds-arch.c cc1200-zoul-arch.c
CONTIKI_TARGET_SOURCEFILES += adc-sensors.c button-sensor.c zoul-sensors.c
CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
CLEAN += *.zoul
### Unless the example dictates otherwise, build with code size optimisations
ifndef SMALL
SMALL = 1
endif
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/cc2538
include $(CONTIKI_CPU)/Makefile.cc2538
MODULES += core/net core/net/mac \
core/net/mac/contikimac \
core/net/llsec dev/cc1200
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
### USe the specific Zoul subplatform to query for connected devices
ifdef MOTELIST_ZOLERTIA
MOTELIST_FLAGS += -b $(MOTELIST_ZOLERTIA)
endif
### Detect if a mote is connected over serial port
ifeq ($(HOST_OS),Darwin)
USBDEVPREFIX=
MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia-macos
MOTES = $(shell $(MOTELIST) -c 2>&- | cut -f 2 -d ,)
else
### If we are not running under Mac, we assume Linux
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia
MOTES = $(shell $(MOTELIST) -b $(MOTELIST_ZOLERTIA) -c 2>&- | cut -f 2 -d , | \
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
endif
%.upload: %.bin %.elf
ifeq ($(wildcard $(BSL)), )
@echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?"
else
$(eval BSL_ADDRESS_ARG := -a $(shell $(OBJDUMP) -h $*.elf | grep -B1 LOAD | \
grep -Ev 'LOAD|\-\-' | awk '{print "0x" $$5}' | \
sort -g | head -1))
$(PYTHON) $(BSL) $(BSL_FLAGS) $(BSL_ADDRESS_ARG) $<
endif
motelist:
$(MOTELIST)
zoul-motelist:
$(MOTELIST) $(MOTELIST_FLAGS)
zoul-motes:
@echo $(MOTES)
ifdef PORT
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX) $(PORT) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX) $(PORT)
else
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(MOTES)) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(MOTES))
endif

View file

@ -1,41 +1,48 @@
Zolertia Re-Mote platform Zolertia Zoul core module
============================================ ============================================
<a href="url"><img src="http://goo.gl/3AGZkI" align="center" height="320" ></a> ![Zolertia Zoul Module][zoul]
The Re-Mote platform is a IoT Hardware development platform based on TI's CC2538 The Zoul is a core module developed by Zolertia to target most IoT applications,
system on chip (SoC), featuring an ARM Cortex-M3 with 512KB flash, 32Kb RAM, providing a flexible and affordable module solution to integrate to most
double RF interface, and the following goodies: existing products and solutions, or ease the prototyping and production of new
products in a short time.
The Zoul is based on TI's CC2538 system on chip (SoC), featuring an ARM
Cortex-M3 with 512KB flash, 32Kb RAM, double RF interface, and the following
goodies:
* ISM 2.4-GHz IEEE 802.15.4 & Zigbee compliant. * ISM 2.4-GHz IEEE 802.15.4 & Zigbee compliant.
* ISM 868-, 915-, 920-, 950-MHz ISM/SRD Band. * ISM 868-, 915-, 920-, 950-MHz ISM/SRD Band.
* AES-128/256, SHA2 Hardware Encryption Engine. * AES-128/256, SHA2 Hardware Encryption Engine.
* ECC-128/256, RSA Hardware Acceleration Engine for Secure Key Exchange. * ECC-128/256, RSA Hardware Acceleration Engine for Secure Key Exchange.
* Power consumption down to 3uA using our shutdown mode. * Small form-factor of 16.78 x 30.89 mm.
* Co-Processor to allow peripheral management, programming over BSL without requiring to press any button to enter bootloader mode. * Prototype friendly, to fit on most prototyping boards (breadboard, etc.).
* Built-in battery charger (500mA), Energy Harvesting and Solar Panels to be connected to standards LiPo batteries. * Self-contained and EMI-protected module under a shield.
* Power input with wide range 2-26VDC.
* Built-in TMP102 temperature sensor
* Small form-factor (as the Z1 mote, half the size of an Arduino) 57x35 mm.
The Zoul will be CE/FCC certified (2016) to allow a fast integration and short time to market for new products and solutions.
Zoul pin-out
=============
![Zoul pin-out (front)][zoul-pinout-front]
![Zoul pin-out (back)][zoul-pinout-back]
Port Features Port Features
============= =============
The platform has the following key features: The Zoul has the following key features:
* Deep Sleep support with RAM retention for ultra-low energy consumption. * Deep Sleep support with RAM retention for ultra-low energy consumption.
* Native USB support (CDC-ACM). SLIP over UART for border routers is no longer a bottleneck. * Native USB support (CDC-ACM). SLIP over UART for border routers is no longer a bottleneck.
* DMA transfers for increased performance (RAM to/from RF, RAM to/from USB). * DMA transfers for increased performance (RAM to/from RF, RAM to/from USB).
* Shutdown mode controlled externally by the Co-processor, completely power the
platform OFF, further reducing current consumption.
In terms of hardware support, the following drivers have been implemented: In terms of hardware support, the following drivers have been implemented for the Zoul-based platforms:
* CC2538 System-on-Chip: * CC2538 System-on-Chip:
* Standard Cortex M3 peripherals (NVIC, SCB, SysTick) * Standard Cortex M3 peripherals (NVIC, SCB, SysTick)
* Sleep Timer (underpins rtimers) * Sleep Timer (underpins rtimers)
* SysTick (underpins the platform clock and Contiki's timers infrastructure) * SysTick (underpins the platform clock and Contiki's timers infrastructure)
* RF * RF (2.4GHz)
* UART * UART
* Watchdog (in watchdog mode) * Watchdog (in watchdog mode)
* USB (in CDC-ACM) * USB (in CDC-ACM)
@ -46,28 +53,25 @@ In terms of hardware support, the following drivers have been implemented:
* ADC * ADC
* Cryptoprocessor (AES-CCM-256, SHA-256) * Cryptoprocessor (AES-CCM-256, SHA-256)
* Public Key Accelerator (ECDH, ECDSA) * Public Key Accelerator (ECDH, ECDSA)
* Flash-based port of Coffee
* LEDs * LEDs
* Buttons * Buttons
* Internal/external 2.4GHz antenna switch controllable by SW.
* Built-in core temperature and battery sensor. * Built-in core temperature and battery sensor.
* TMP102 temperature sensor driver. * CC1200 sub-1GHz radio interface.
* CC1120 sub-1GHz radio interface:
* Ported in Contiki, SPI based. There is a Zoul powering the RE-Mote and Firefly platforms, check out its specific README files for more information about on-board features.
* Micro-SD external storage:
* Pending to port, SPI based.
Requirements Requirements
============ ============
To start using Contiki, the following is required: To start using Contiki, the following is required:
* A zoul-based board (RE-Mote, firefly)
* A toolchain to compile Contiki for the CC2538. * A toolchain to compile Contiki for the CC2538.
* Drivers so that your OS can communicate with your hardware. * Drivers so that your OS can communicate with your hardware.
* Software to upload images to the CC2538. * Software to upload images to the CC2538.
Install a Toolchain Install a Toolchain
------------------- -------------------
Forked from `platform/cc2538dk/README.md`.
The toolchain used to build contiki is arm-gcc, also used by other arm-based Contiki ports. If you are using Instant Contiki, you will have a version pre-installed in your system. To find out if this is the case, try this: The toolchain used to build contiki is arm-gcc, also used by other arm-based Contiki ports. If you are using Instant Contiki, you will have a version pre-installed in your system. To find out if this is the case, try this:
$ arm-none-eabi-gcc -v $ arm-none-eabi-gcc -v
@ -87,47 +91,25 @@ The platform is currently being used/tested with the following toolchains:
Drivers Drivers
------- -------
The Re-Mote features a FTDI serial-to-USB module, the driver is commonly found in most OS, but if required it can be downloaded Depending on your Zoul flavour, there are different options. As today the RE-Mote and Firefly platforms host a Zoul with a CP2104 USB-to-serial converter, governed by a low-power PIC to handle resetting and flashing the Zoul over USB, without having to press any button or use external tools.
from <http://www.ftdichip.com/Drivers/VCP.htm>
### For the CC2538EM (USB CDC-ACM) The driver is available at <https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx>
The Re-Mote has built-in support for USB 2.0 USB, Vendor and Product IDs are the following:
* VID 0x0451 Check the board's specific README files for more information.
* PID 0x16C8
The implementation in Contiki is pure CDC-ACM: The Linux and OS X kernels know exactly what to do and drivers are not required. For windows users, if using the USB 2.0 interface (via CDC-ACM driver), there is an available driver in this folder:
On windows, you will need to provide a driver: `zolertia-zoul-cdc-acm`
* Download this LUFA CDC-ACM driver:
<https://github.com/abcminiuser/lufa/blob/master/Demos/Device/LowLevel/VirtualSerial/LUFA%20VirtualSerial.inf>
* Adjust the VID and PID near the end with the values at the start of this section.
* Next time you get prompted for the driver, include the directory containing the .inf file in the search path and the driver will be installed.
### Device Enumerations
For the UART, serial line settings are 115200 8N1, no flow control.
Once all drivers have been installed correctly:
On windows, devices will appear as a virtual COM port.
On Linux and OS X, devices will appear under `/dev/`.
On OS X:
* XDS backchannel: `tty.usbserial-<serial number>`
* EM in CDC-ACM: `tty.usbmodemf<X><ABC>` (X a letter, ABC a number e.g. `tty.usbmodemfd121`)
On Linux:
* Re-Mote over FTDI: `ttyUSB1`
* Re-Mote over USB driver (in CDC-ACM): `ttyACMn` (n=0, 1, ....)
Software to Program the Nodes Software to Program the Nodes
----------------------------- -----------------------------
The Re-Mote can be programmed via the jtag interface or via the serial boot loader on the chip. The Zoul can be programmed via the jtag interface or via the serial boot loader on the chip.
Both the RE-Mote and Firefly has a mini JTAG 10-pin male header, compatible with the `SmartRF06` development board, which can be used to flash and debug the platforms. Alternatively one could use the `JLink` programmer with a 20-to-10 pin converter like the following: <https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/>.
The serial boot loader on the chip is exposed to the user via an USB interface. In the not so distant past we used to press a button sequence to unlock the boot loader, but now an on-board PIC in both RE-Motes and Fireflies handles this on its own, so it will detect the BSL sequence and flash the CC2538 without user intervention.
Instructions to flash for different OS are given below.
* On Windows: * On Windows:
* Nodes can be programmed with TI's ArmProgConsole or the [SmartRF Flash Programmer 2][smart-rf-flashprog]. The README should be self-explanatory. With ArmProgConsole, upload the file with a `.bin` extension. (jtag + serial) * Nodes can be programmed with TI's ArmProgConsole or the [SmartRF Flash Programmer 2][smart-rf-flashprog]. The README should be self-explanatory. With ArmProgConsole, upload the file with a `.bin` extension. (jtag + serial)
@ -140,13 +122,13 @@ The Re-Mote can be programmed via the jtag interface or via the serial boot load
* On OSX: * On OSX:
* The `cc2538-bsl.py` script in `tools/cc2538-bsl/` is the only option. No extra software needs to be installed. (serial) * The `cc2538-bsl.py` script in `tools/cc2538-bsl/` is the only option. No extra software needs to be installed. (serial)
The file with a `.remote` extension is a copy of the `.elf` file. The file with a `.zoul` extension is a copy of the `.elf` file.
Use the Port Use the Port
============ ============
The following examples are intended to work off-the-shelf: The following examples are intended to work off-the-shelf:
* Examples under `examples/remote` * Examples under `examples/zolertia/zoul`
* MQTT example `examples/cc2538dk/mqtt-demo` * MQTT example `examples/cc2538dk/mqtt-demo`
* Border router: `examples/ipv6/rpl-border-router` * Border router: `examples/ipv6/rpl-border-router`
* Webserver: `examples/webserver-ipv6` * Webserver: `examples/webserver-ipv6`
@ -154,24 +136,31 @@ The following examples are intended to work off-the-shelf:
Build your First Examples Build your First Examples
------------------------- -------------------------
It is recommended to start with the `remote-demo`, it is a simple example that walkthroughs the platform features, such as It is recommended to start with the `zoul-demo`, it is a simple example that walkthroughs the zoul features (can be compiled for both the RE-Mote and the Firefly), such as the built-in sensors, LEDs, user button operation modes (press, release, hold-press), radio (Rime broadcast).
the built-in sensors, LEDs, user button operation modes (press, release, hold-press), radio (Rime broadcast).
The `Makefile.target` includes the `TARGET=` argument, predefining which is the target platform to compile for, it is automatically included at compilation. To generate or override an existing one, you can run: The `Makefile.target` includes the `TARGET=` argument, predefining which is the target platform to compile for, it is automatically included at compilation. The `BOARD=` argument is using as a glue switch to pull in specific platform files, for example the specific RE-Mote core drivers. If no `BOARD` argument is given, it will default to `remote` and compile for the RE-Mote platform.
`make TARGET=remote savetarget` To generate or override an existing one, you can run:
Then you can just run `make` to compile an application, otherwise you will need to do `make TARGET=remote`. `make TARGET=zoul savetarget`
Then you can just run `make` to compile an application, otherwise you will need to do `make TARGET=zoul`.
Alternatively you can export the following to your work environment:
`export BOARD=remote` or `export BOARD=firefly`
This will avoid having to type this argument at each compilation.
If you want to upload the compiled firmware to a node via the serial boot loader you need first to either manually enable the boot loader, or just let the Co-Processor detect the flash sequence and do it on your behalf, as simple as not pressing anything at all! If you want to upload the compiled firmware to a node via the serial boot loader you need first to either manually enable the boot loader, or just let the Co-Processor detect the flash sequence and do it on your behalf, as simple as not pressing anything at all!
Then use `make remote-demo.upload PORT=/dev/ttyUSB1`. Then use `make zoul-demo.upload`.
The `PORT` argument is used to specify in which port the device is connected, as we are currently using a dual-channel FTDI chip, at the moment the programming channel is always assigned to the second FTDI channel, so the FTDI will enumerate as `/dev/ttyUSB0`, `/dev/ttyUSB1`, and we would need to use the later one and specify when flashing using the `cc2538-bsl` script, as it will use the first port found by default. This will be improved in the next release. The `PORT` argument could be used to specify in which port the device is connected, in case we have multiple devices connected at the same time.
To manually enable the boot loader, press the `reset` button on the board while holding the `user` button. (The boot loader backdoor needs to be enabled on the chip for this to work, see README in the `tools/cc2538-bsl` directory for more info) To generate an assembly listing of the compiled firmware, run `make zoul-demo.lst`. This may be useful for debugging or optimizing your application code. To intersperse the C source code within the assembly listing, you must instruct the compiler to include debugging information by adding `CFLAGS += -g` to the project Makefile and rebuild by running `make clean zoul-demo.lst`.
To generate an assembly listing of the compiled firmware, run `make remote-demo.lst`. This may be useful for debugging or optimizing your application code. To intersperse the C source code within the assembly listing, you must instruct the compiler to include debugging information by adding `CFLAGS += -g` to the project Makefile and rebuild by running `make clean remote-demo.lst`. To enable printing debug output to your console, use the `make login` to get the information over the USB programming/debugging port, or alternatively use `make serialview` to also add a timestamp in each print.
Node IEEE/RIME/IPv6 Addresses Node IEEE/RIME/IPv6 Addresses
----------------------------- -----------------------------
@ -193,16 +182,12 @@ This will result in the 2 last bytes of the IEEE address getting set to 0x79 0xA
Note: Some early production devices do not have am IEEE address written on the Info Page. For those devices, using value 0 above will result in a Rime address of all 0xFFs. If your device is in this category, define `IEEE_ADDR_CONF_HARDCODED` to 1 and specify `NODEID` to differentiate between devices. Note: Some early production devices do not have am IEEE address written on the Info Page. For those devices, using value 0 above will result in a Rime address of all 0xFFs. If your device is in this category, define `IEEE_ADDR_CONF_HARDCODED` to 1 and specify `NODEID` to differentiate between devices.
Low-Power Modes Low-Power Modes
--------------- ---------------
The CC2538 port supports power modes for low energy consumption. The SoC will enter a low power mode as part of the main loop when there are no more events to service. The CC2538 port supports power modes for low energy consumption. The SoC will enter a low power mode as part of the main loop when there are no more events to service.
LPM support can be disabled in its entirety by setting `LPM_CONF_ENABLE` to 0 in `contiki-conf.h` or `project-conf.h`. LPM support can be disabled in its entirety by setting `LPM_CONF_ENABLE` to 0 in `contiki-conf.h` or `project-conf.h`.
NOTE: If you are using PG2 version of the Evaluation Module, the SoC will refuse to enter Power Modes 1+ if the debugger is connected and will always enter PM0 regardless of configuration. In order to get real low power mode functionality, make sure the debugger is disconnected. The Battery Board is ideal to test this.
The Low-Power module uses a simple heuristic to determine the best power mode, depending on anticipated Deep Sleep duration and the state of various peripherals. The Low-Power module uses a simple heuristic to determine the best power mode, depending on anticipated Deep Sleep duration and the state of various peripherals.
In a nutshell, the algorithm first answers the following questions: In a nutshell, the algorithm first answers the following questions:
@ -232,7 +217,7 @@ LPM is highly related to the operations of the Radio Duty Cycling (RDC) driver o
* When NullRDC is in use, the radio will be always on. As a result, the algorithm discussed above will always choose PM0 and will never attempt to drop to PM1/2. * When NullRDC is in use, the radio will be always on. As a result, the algorithm discussed above will always choose PM0 and will never attempt to drop to PM1/2.
### Shutdown Mode ### Shutdown Mode
The Re-Mote allows to further reduce power consumption by shutting down entirely all the components but the Co-Processor, powering completely of the CC2538 and CC1120 even preventing quiescent current from being drawn, allowing the platform to awake after a given period governed by the Co-Processor and the built-in battery management IC. This effectively reduces the power consumption down to 3-4uA. The RE-Mote has a built-in shutdown mode which effectively reduces the power consumption down to 300nA. Check its specific README file for more information.
Build headless nodes Build headless nodes
-------------------- --------------------
@ -248,7 +233,7 @@ Setting this define to 1 will automatically set the following to 0:
Code Size Optimisations Code Size Optimisations
----------------------- -----------------------
The build system currently uses optimization level `-Os`, which is controlled indirectly through the value of the `SMALL` make variable. This value can be overridden by example makefiles, or it can be changed directly in `platform/remote/Makefile.remote`. The build system currently uses optimization level `-Os`, which is controlled indirectly through the value of the `SMALL` make variable. This value can be overridden by example makefiles, or it can be changed directly in `platform/zoul/Makefile.zoul`.
Historically, the `-Os` flag has caused problems with some toolchains. If you are using one of the toolchains documented in this README, you should be able to use it without issues. If for whatever reason you do come across problems, try setting `SMALL=0` or replacing `-Os` with `-O2` in `cpu/cc2538/Makefile.cc2538`. Historically, the `-Os` flag has caused problems with some toolchains. If you are using one of the toolchains documented in this README, you should be able to use it without issues. If for whatever reason you do come across problems, try setting `SMALL=0` or replacing `-Os` with `-O2` in `cpu/cc2538/Makefile.cc2538`.
@ -258,7 +243,7 @@ This port's code has been documented with doxygen. To build the documentation, n
If you want to build this platform's documentation only and skip the remaining platforms, run this: If you want to build this platform's documentation only and skip the remaining platforms, run this:
make basedirs="platform/remote core cpu/cc2538 examples/remote examples/cc2538dk" make basedirs="platform/zoul core cpu/cc2538 examples/zolertia/zoul examples/cc2538dk"
Once you've built the docs, open `$(CONTIKI)/doc/html/index.html` and enjoy. Once you've built the docs, open `$(CONTIKI)/doc/html/index.html` and enjoy.
@ -271,14 +256,26 @@ If you prefer this guide in other formats, use the excellent [pandoc] to convert
More Reading More Reading
============ ============
1. [Zolertia Re-Mote website][remote-site] 1. [Zolertia website][zolertia-site]
2. [CC2538 System-on-Chip Solution for 2.4-GHz IEEE 802.15.4 and ZigBee&reg;/ZigBee IP&reg; Applications, (SWRU319B)][cc2538] 2. [CC2538 System-on-Chip Solution][cc2538]
3. [CC1120 sub-1GHz RF transceiver][cc1120] 3. [CC1200 sub-1GHz RF transceiver][cc1200]
4. [Zolertia Hackster channel][hackster]
5. [IoT in five days open source and online book][IoT5days]
[remote-site]: http://www.zolertia.io/products "Zolertia Re-Mote" Maintainers
[cc1120]: http://www.ti.com/cc1120 "CC1120" ===========
The Zoul and derived platforms (as well as the Z1 mote) are maintained by Zolertia.
Main contributor: Antonio Lignan <alignan@zolertia.com>
[zolertia-site]: http://www.zolertia.io/products "Zolertia"
[cc1200]: http://www.ti.com/product/cc1200 "CC1200"
[smart-rf-studio]: http://www.ti.com/tool/smartrftm-studio "SmartRF Studio" [smart-rf-studio]: http://www.ti.com/tool/smartrftm-studio "SmartRF Studio"
[smart-rf-flashprog]: http://www.ti.com/tool/flash-programmer "SmartRF Flash Programmer" [smart-rf-flashprog]: http://www.ti.com/tool/flash-programmer "SmartRF Flash Programmer"
[cc2538]: http://www.ti.com/product/cc2538 "CC2538" [cc2538]: http://www.ti.com/product/cc2538 "CC2538"
[uniflash]: http://processors.wiki.ti.com/index.php/Category:CCS_UniFlash "UniFlash" [uniflash]: http://processors.wiki.ti.com/index.php/Category:CCS_UniFlash "UniFlash"
[pandoc]: http://johnmacfarlane.net/pandoc/ "Pandoc - a universal document converter" [pandoc]: http://johnmacfarlane.net/pandoc/ "Pandoc - a universal document converter"
[hackster]: https://www.hackster.io/zolertia "Zolertia Hackster Channel"
[zoul]: images/zoul-front.png "Zolertia Zoul Module"
[zoul-pinout-front]: images/zoul-pinout-front.png "Zoul pin-out (front)"
[zoul-pinout-back]: images/zoul-pinout-back.png "Zoul pin-out (back)"
[IoT5days]: https://github.com/alignan/IPv6-WSN-book "IoT in Five days online book"

View file

@ -1,9 +1,46 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** /**
* \addtogroup remote * \addtogroup zoul
* @{ * @{
* *
* \defgroup zoul-platforms Zolertia platforms based on the Zoul core module
*
* The Zoul allows a fast reuse and easy integration to most applications and
* products. Its small size and module format eases to place in different PCB
* designs and to integrate in existing products. The Zoul-based platforms
* share most of the Zoul core implementation.
*
* \file * \file
* Configuration for the Re-Mote platform * Configuration for the Zoul-based platforms
*/ */
#ifndef CONTIKI_CONF_H_ #ifndef CONTIKI_CONF_H_
#define CONTIKI_CONF_H_ #define CONTIKI_CONF_H_
@ -37,7 +74,7 @@ typedef uint32_t uip_stats_t;
* RTIMER_CLOCK_LT to override this * RTIMER_CLOCK_LT to override this
*/ */
typedef uint32_t rtimer_clock_t; typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0) #define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
@ -46,7 +83,7 @@ typedef uint32_t rtimer_clock_t;
* @{ * @{
*/ */
#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR
#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /**<Enable the boot loader backdoor */ #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /**<Enable the boot loader backdoor */
#endif #endif
#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN
@ -60,17 +97,11 @@ typedef uint32_t rtimer_clock_t;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \name Flash Memory configuration * \name CFS configuration
* *
* @{ * @{
*/ */
#ifndef FLASH_CONF_ORIGIN #define COFFEE_CONF_SIZE (4 * COFFEE_SECTOR_SIZE)
#define FLASH_CONF_ORIGIN 0x00200000
#endif
#ifndef FLASH_CONF_SIZE
#define FLASH_CONF_SIZE 0x00080000 /* 512 KiB */
#endif
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
@ -79,7 +110,7 @@ typedef uint32_t rtimer_clock_t;
* @{ * @{
*/ */
#ifndef WATCHDOG_CONF_ENABLE #ifndef WATCHDOG_CONF_ENABLE
#define WATCHDOG_CONF_ENABLE 1 /**< Enable the watchdog timer */ #define WATCHDOG_CONF_ENABLE 1 /**< Enable the watchdog timer */
#endif #endif
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -194,7 +225,7 @@ typedef uint32_t rtimer_clock_t;
* This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
* keep using SLIP * keep using SLIP
*/ */
#if defined (UIP_FALLBACK_INTERFACE) || defined (CMD_CONF_OUTPUT) #if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
#define SLIP_ARCH_CONF_ENABLED 1 #define SLIP_ARCH_CONF_ENABLED 1
#endif #endif
#endif #endif
@ -323,11 +354,29 @@ typedef uint32_t rtimer_clock_t;
#endif /* NETSTACK_CONF_WITH_IPV6 */ #endif /* NETSTACK_CONF_WITH_IPV6 */
#endif /* NETSTACK_CONF_FRAMER */ #endif /* NETSTACK_CONF_FRAMER */
/* This can be overriden to use the cc1120_driver instead */ /* This can be overriden to use the cc1200_driver instead */
#ifndef NETSTACK_CONF_RADIO #ifndef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO cc2538_rf_driver #define NETSTACK_CONF_RADIO cc2538_rf_driver
#endif #endif
/*
* RE-Mote specific:
* If dual RF enabled, we set the RF switch to enable the CC1200 and use 2.4GHz
* on the available uFl/chip antenna (not mounted as default). In contiki main
* platform routine we set the right antenna depending on NETSTACK_CONF_RADIO,
* but as changing the RF antenna also implies enabling/disabling the CC1200,
* is better to start off with the right configuration
*/
#if REMOTE_DUAL_RF_ENABLED
#define ANTENNA_SW_SELECT_DEFAULT ANTENNA_SW_SELECT_SUBGHZ
#else /* REMOTE_DUAL_RF_ENABLED */
#ifndef ANTENNA_SW_SELECT_DEF_CONF
#define ANTENNA_SW_SELECT_DEFAULT ANTENNA_SW_SELECT_2_4GHZ
#else /* ANTENNA_SW_SELECT_DEF_CONF */
#define ANTENNA_SW_SELECT_DEFAULT ANTENNA_SW_SELECT_DEF_CONF
#endif /* ANTENNA_SW_SELECT_DEF_CONF */
#endif /* REMOTE_DUAL_RF_ENABLED */
/** @} */ /** @} */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
@ -398,7 +447,7 @@ typedef uint32_t rtimer_clock_t;
#endif #endif
#ifndef CC2538_RF_CONF_CHANNEL #ifndef CC2538_RF_CONF_CHANNEL
#define CC2538_RF_CONF_CHANNEL 25 #define CC2538_RF_CONF_CHANNEL 26
#endif /* CC2538_RF_CONF_CHANNEL */ #endif /* CC2538_RF_CONF_CHANNEL */
#ifndef CC2538_RF_CONF_AUTOACK #ifndef CC2538_RF_CONF_AUTOACK

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -32,14 +33,15 @@
* \addtogroup platform * \addtogroup platform
* @{ * @{
* *
* \defgroup remote Zolertia Re-Mote platform * \defgroup zoul Zolertia Zoul core module
* *
* The Re-Mote is the new platform by Zolertia based on the cc2538, featuring a * The Zoul comprises the CC2538SF53 and CC1200 in a single module
* cc2538 SoC with an ARM Cortex-M3 core plus the CC1120 Sub-1Ghz transceiver * format, which allows a fast reuse of its core components in different
* formats and form-factors.
* @{ * @{
* *
* \file * \file
* Main module for the Re-Mote platform * Main module for the Zolertia Zoul core and based platforms
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
@ -66,7 +68,6 @@
#include "reg.h" #include "reg.h"
#include "ieee-addr.h" #include "ieee-addr.h"
#include "lpm.h" #include "lpm.h"
#include "dev/antenna-sw.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@ -84,6 +85,9 @@
#define PUTS(s) #define PUTS(s)
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** \brief Board specific iniatialisation */
void board_init(void);
/*---------------------------------------------------------------------------*/
static void static void
fade(unsigned char l) fade(unsigned char l)
{ {
@ -135,7 +139,7 @@ set_rf_params(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \brief Main routine for the Re-Mote platform * \brief Main routine for the Zoul-based platforms
*/ */
int int
main(void) main(void)
@ -147,14 +151,10 @@ main(void)
lpm_init(); lpm_init();
rtimer_init(); rtimer_init();
gpio_init(); gpio_init();
leds_init(); leds_init();
fade(LEDS_RED); fade(LEDS_RED);
process_init(); process_init();
watchdog_init(); watchdog_init();
SENSORS_ACTIVATE(button_sensor);
/* /*
* Character I/O Initialisation. * Character I/O Initialisation.
@ -185,13 +185,6 @@ main(void)
PUTS(CONTIKI_VERSION_STRING); PUTS(CONTIKI_VERSION_STRING);
PUTS(BOARD_STRING); PUTS(BOARD_STRING);
PRINTF(" Net: ");
PRINTF("%s\n", NETSTACK_NETWORK.name);
PRINTF(" MAC: ");
PRINTF("%s\n", NETSTACK_MAC.name);
PRINTF(" RDC: ");
PRINTF("%s\n", NETSTACK_RDC.name);
/* Initialise the H/W RNG engine. */ /* Initialise the H/W RNG engine. */
random_init(0); random_init(0);
@ -200,8 +193,17 @@ main(void)
process_start(&etimer_process, NULL); process_start(&etimer_process, NULL);
ctimer_init(); ctimer_init();
set_rf_params(); board_init();
netstack_init(); netstack_init();
set_rf_params();
PRINTF(" Net: ");
PRINTF("%s\n", NETSTACK_NETWORK.name);
PRINTF(" MAC: ");
PRINTF("%s\n", NETSTACK_MAC.name);
PRINTF(" RDC: ");
PRINTF("%s\n", NETSTACK_RDC.name);
#if NETSTACK_CONF_WITH_IPV6 #if NETSTACK_CONF_WITH_IPV6
memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr)); memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
@ -209,8 +211,6 @@ main(void)
process_start(&tcpip_process, NULL); process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */ #endif /* NETSTACK_CONF_WITH_IPV6 */
antenna_sw_config();
process_start(&sensors_process, NULL); process_start(&sensors_process, NULL);
SENSORS_ACTIVATE(button_sensor); SENSORS_ACTIVATE(button_sensor);

View file

@ -31,11 +31,11 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \addtogroup remote-phidget-sensor * \addtogroup zoul-adc-sensors
* @{ * @{
* *
* \file * \file
* Generic driver for the Re-Mote Phidget/ADC sensors * Generic driver for the Zoul ADC sensors
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
@ -43,16 +43,13 @@
#include "dev/ioc.h" #include "dev/ioc.h"
#include "dev/gpio.h" #include "dev/gpio.h"
#include "dev/adc.h" #include "dev/adc.h"
#include "dev/phidget-sensor.h" #include "adc-sensors.h"
#include "dev/remote-sensors.h" #include "zoul-sensors.h"
#include <stdint.h> #include <stdint.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define ADC_PHIDGET_PORT_BASE GPIO_PORT_TO_BASE(ADC_PHIDGET_PORT)
#define ADC_PHIDGET_ADC2_PIN_MASK GPIO_PIN_MASK(ADC_PHIDGET_ADC2_PIN)
#define ADC_PHIDGET_ADC3_PIN_MASK GPIO_PIN_MASK(ADC_PHIDGET_ADC3_PIN)
/*---------------------------------------------------------------------------*/
static uint8_t decimation_rate; static uint8_t decimation_rate;
static uint8_t enabled_channels;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
set_decimation_rate(uint8_t rate) set_decimation_rate(uint8_t rate)
@ -65,31 +62,44 @@ set_decimation_rate(uint8_t rate)
decimation_rate = rate; decimation_rate = rate;
break; break;
default: default:
return REMOTE_SENSORS_ERROR; return ZOUL_SENSORS_ERROR;
} }
return decimation_rate; return decimation_rate;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_channel_pin(int type)
{
if((ZOUL_SENSORS_ADC1) && (type == ZOUL_SENSORS_ADC1)) {
return SOC_ADC_ADCCON_CH_AIN0 + ADC_SENSORS_ADC1_PIN;
}
if((ZOUL_SENSORS_ADC2) && (type == ZOUL_SENSORS_ADC2)) {
return SOC_ADC_ADCCON_CH_AIN0 + ADC_SENSORS_ADC2_PIN;
}
if((ZOUL_SENSORS_ADC3) && (type == ZOUL_SENSORS_ADC3)) {
return SOC_ADC_ADCCON_CH_AIN0 + ADC_SENSORS_ADC3_PIN;
}
return ZOUL_SENSORS_ERROR;
}
/*---------------------------------------------------------------------------*/
static int
value(int type) value(int type)
{ {
uint8_t channel; int channel;
int16_t res; int16_t res;
switch(type) { if(!(type & enabled_channels)) {
case PHIDGET_SENSORS_ADC2: return ZOUL_SENSORS_ERROR;
channel = SOC_ADC_ADCCON_CH_AIN0 + ADC_PHIDGET_ADC2_PIN;
break;
case PHIDGET_SENSORS_ADC3:
channel = SOC_ADC_ADCCON_CH_AIN0 + ADC_PHIDGET_ADC3_PIN;
break;
default:
return REMOTE_SENSORS_ERROR;
} }
res = adc_get(channel, SOC_ADC_ADCCON_REF_INT, decimation_rate); channel = get_channel_pin(type);
if(channel == ZOUL_SENSORS_ERROR) {
return ZOUL_SENSORS_ERROR;
}
res = adc_get(channel, SOC_ADC_ADCCON_REF_AVDD5, decimation_rate);
return res; return res;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -98,18 +108,40 @@ configure(int type, int value)
{ {
switch(type) { switch(type) {
case SENSORS_HW_INIT: case SENSORS_HW_INIT:
GPIO_SOFTWARE_CONTROL(GPIO_A_BASE, ADC_PHIDGET_ADC2_PIN_MASK);
GPIO_SET_INPUT(GPIO_A_BASE, ADC_PHIDGET_ADC2_PIN_MASK);
ioc_set_over(GPIO_A_NUM, ADC_PHIDGET_ADC2_PIN, IOC_OVERRIDE_ANA);
GPIO_SOFTWARE_CONTROL(GPIO_A_BASE, ADC_PHIDGET_ADC3_PIN_MASK); /* This should filter out disabled sensors as its value should be zero */
GPIO_SET_INPUT(GPIO_A_BASE, ADC_PHIDGET_ADC3_PIN_MASK); if((value < ZOUL_SENSORS_ADC_MIN) || (value > ZOUL_SENSORS_ADC_ALL)) {
ioc_set_over(GPIO_A_NUM, ADC_PHIDGET_ADC3_PIN, IOC_OVERRIDE_ANA); return ZOUL_SENSORS_ERROR;
}
if((value != ZOUL_SENSORS_ADC1) && (value != ZOUL_SENSORS_ADC2) &&
(value != ZOUL_SENSORS_ADC3) && (value != ZOUL_SENSORS_ADC12) &&
(value != ZOUL_SENSORS_ADC13) && (value != ZOUL_SENSORS_ADC23)) {
return ZOUL_SENSORS_ERROR;
}
GPIO_SOFTWARE_CONTROL(GPIO_A_BASE, value);
GPIO_SET_INPUT(GPIO_A_BASE, value);
if(value & ZOUL_SENSORS_ADC1) {
ioc_set_over(GPIO_A_NUM, ADC_SENSORS_ADC1_PIN, IOC_OVERRIDE_ANA);
}
if(value & ZOUL_SENSORS_ADC2) {
ioc_set_over(GPIO_A_NUM, ADC_SENSORS_ADC2_PIN, IOC_OVERRIDE_ANA);
}
if(value & ZOUL_SENSORS_ADC3) {
ioc_set_over(GPIO_A_NUM, ADC_SENSORS_ADC3_PIN, IOC_OVERRIDE_ANA);
}
adc_init(); adc_init();
set_decimation_rate(SOC_ADC_ADCCON_DIV_512); set_decimation_rate(SOC_ADC_ADCCON_DIV_512);
enabled_channels = value;
break; break;
case REMOTE_SENSORS_CONFIGURE_TYPE_DECIMATION_RATE:
case ZOUL_SENSORS_CONFIGURE_TYPE_DECIMATION_RATE:
return set_decimation_rate((uint8_t)value); return set_decimation_rate((uint8_t)value);
default:
return ZOUL_SENSORS_ERROR;
} }
return 0; return 0;
} }
@ -120,6 +152,7 @@ status(int type)
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
SENSORS_SENSOR(phidget_sensor, PHIDGET_SENSOR, value, configure, status); SENSORS_SENSOR(adc_sensors, ADC_SENSORS, value, configure, status);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** @} */ /** @} */

View file

@ -0,0 +1,133 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup zoul-sensors
* @{
*
* \defgroup zoul-adc-sensors Zoul Generic ADC sensor
*
* Driver for the Zoul ADC sensors
*
* This driver supports analogue sensors connected to ADC1, ADC2 and AND3 inputs
* This is controlled by the type argument of the value() function. Possible
* choices are:
* - ZOUL_SENSORS_ADC1
* - ZOUL_SENSORS_ADC2
* - ZOUL_SENSORS_ADC3
*
* To initialize the ADC sensors use the configure() function, using as first
* argument SENSORS_HW_INIT, and choose which ADC channels to enable passing as
* second argument any single or combined (sum) values as below:
* - ZOUL_SENSORS_ADC1
* - ZOUL_SENSORS_ADC2
* - ZOUL_SENSORS_ADC3
* - ZOUL_SENSORS_ADC_ALL (all channels above)
*
* Using an invalid combination will return ZOUL_SENSORS_ERROR.
*
* The decimation rate can be set by passing
* ZOUL_SENSORS_CONFIGURE_TYPE_DECIMATION_RATE as the type argument to the
* configure() function and then specifying the rate through the value
* argument. Valid values are:
* - SOC_ADC_ADCCON_DIV_64 (64 bit rate)
* - SOC_ADC_ADCCON_DIV_128 (128 bit rate)
* - SOC_ADC_ADCCON_DIV_256 (256 bit rate)
* - SOC_ADC_ADCCON_DIV_512 (512 bit rate)
* @{
*
* \file
* Header file for the Zoul Generic Driver for ADC sensors
*/
/*---------------------------------------------------------------------------*/
#ifndef ADC_SENSORS_H_
#define ADC_SENSORS_H_
/*---------------------------------------------------------------------------*/
#include "lib/sensors.h"
#include "dev/soc-adc.h"
/*---------------------------------------------------------------------------*/
/**
* \name Generic ADC sensors
* @{
*/
#define ADC_SENSORS "ADC sensors"
#define ADC_SENSORS_PORT_BASE GPIO_PORT_TO_BASE(ADC_SENSORS_PORT)
/*
* PA0-PA3 are hardcoded to UART0 and the user button for most Zolertia
* platforms, the following assumes PA0 shall not be used as ADC input, else
* re-write the below definitions
*/
#define ZOUL_SENSORS_ADC_MIN 4
/* ADC phidget-like connector ADC1 */
#if ADC_SENSORS_ADC1_PIN >= ZOUL_SENSORS_ADC_MIN
#define ZOUL_SENSORS_ADC1 GPIO_PIN_MASK(ADC_SENSORS_ADC1_PIN)
#else
#define ZOUL_SENSORS_ADC1 0
#endif
/* ADC phidget-like connector ADC2 */
#if ADC_SENSORS_ADC2_PIN >= ZOUL_SENSORS_ADC_MIN
#define ZOUL_SENSORS_ADC2 GPIO_PIN_MASK(ADC_SENSORS_ADC2_PIN)
#else
#define ZOUL_SENSORS_ADC2 0
#endif
/* ADC phidget-like connector ADC3 */
#if ADC_SENSORS_ADC3_PIN >= ZOUL_SENSORS_ADC_MIN
#define ZOUL_SENSORS_ADC3 GPIO_PIN_MASK(ADC_SENSORS_ADC3_PIN)
#else
#define ZOUL_SENSORS_ADC3 0
#endif
/*
* This is safe as the disabled sensors should have a zero value thus not
* affecting the mask operations
*/
/* Enable all channels */
#define ZOUL_SENSORS_ADC_ALL (ZOUL_SENSORS_ADC1 + ZOUL_SENSORS_ADC2 + \
ZOUL_SENSORS_ADC3)
/* Other allowed combinations */
#define ZOUL_SENSORS_ADC12 (ZOUL_SENSORS_ADC1 + ZOUL_SENSORS_ADC2)
#define ZOUL_SENSORS_ADC13 (ZOUL_SENSORS_ADC1 + ZOUL_SENSORS_ADC3)
#define ZOUL_SENSORS_ADC23 (ZOUL_SENSORS_ADC2 + ZOUL_SENSORS_ADC3)
/** @} */
/*---------------------------------------------------------------------------*/
extern const struct sensors_sensor adc_sensors;
/*---------------------------------------------------------------------------*/
#endif /* ADC_SENSORS_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View file

@ -32,11 +32,11 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \addtogroup remote-button-sensor * \addtogroup zoul-button-sensor
* @{ * @{
* *
* \file * \file
* Driver for the Re-Mote user button * Driver for the Zoul user button
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"

View file

@ -32,17 +32,17 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \addtogroup remote-sensors * \addtogroup zoul-sensors
* @{ * @{
* *
* \defgroup remote-button-sensor Re-Mote User Button Driver * \defgroup zoul-button-sensor Zoul User Button Driver
* *
* Driver for the Re-Mote user button * Driver for the Zoul user button
* *
* The Re-Mote button will generate a sensors_changed event on press as well * The user button (on Zoul-based platforms like the RE-Mote and the Firefly)
* as on release. * will generate a sensors_changed event on press as well as on release.
* *
* Unlike many other platforms, the Re-Mote user button has the ability to * Unlike many other platforms, the user button has the ability to
* generate events when the user keeps the button pressed. The user can * generate events when the user keeps the button pressed. The user can
* configure the button driver with a timer interval in clock ticks. When the * configure the button driver with a timer interval in clock ticks. When the
* button is kept pressed, the driver will then generate a broadcast event * button is kept pressed, the driver will then generate a broadcast event
@ -53,7 +53,7 @@
* @{ * @{
* *
* \file * \file
* Header file for the Re-Mote User Button Driver * Header file for the Zoul User Button Driver
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#ifndef BUTTON_SENSOR_H_ #ifndef BUTTON_SENSOR_H_

Some files were not shown because too many files have changed in this diff Show more