added configuration of MAC driver
added missing initialization of serial-line added periodic DCO/CPU speed re-synch
This commit is contained in:
parent
e8c11209da
commit
c436b99887
|
@ -1,6 +1,13 @@
|
||||||
#ifndef __CONTIKI_CONF_H__
|
#ifndef __CONTIKI_CONF_H__
|
||||||
#define __CONTIKI_CONF_H__
|
#define __CONTIKI_CONF_H__
|
||||||
|
|
||||||
|
/* DCO speed resynchronization for more robust UART, etc. */
|
||||||
|
#define DCOSYNCH_CONF_ENABLED 1
|
||||||
|
#define DCOSYNCH_CONF_PERIOD 30
|
||||||
|
|
||||||
|
/* Specifies the default MAC driver */
|
||||||
|
#define MAC_CONF_DRIVER nullmac_driver
|
||||||
|
|
||||||
#define PACKETBUF_CONF_ATTRS_INLINE 1
|
#define PACKETBUF_CONF_ATTRS_INLINE 1
|
||||||
#define QUEUEBUF_CONF_NUM 1
|
#define QUEUEBUF_CONF_NUM 1
|
||||||
#define QUEUEBUF_CONF_REF_NUM 1
|
#define QUEUEBUF_CONF_REF_NUM 1
|
||||||
|
@ -48,9 +55,6 @@ typedef unsigned short clock_time_t;
|
||||||
|
|
||||||
void clock_wait(int ms10);
|
void clock_wait(int ms10);
|
||||||
|
|
||||||
void clock_set_seconds(unsigned long s);
|
|
||||||
unsigned long clock_seconds(void);
|
|
||||||
|
|
||||||
#define LOG_CONF_ENABLED 0
|
#define LOG_CONF_ENABLED 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,4 +97,8 @@ typedef unsigned short uip_stats_t;
|
||||||
#define LEDS_CONF_GREEN 0x02
|
#define LEDS_CONF_GREEN 0x02
|
||||||
#define LEDS_CONF_YELLOW 0x04
|
#define LEDS_CONF_YELLOW 0x04
|
||||||
|
|
||||||
|
#ifdef PROJECT_CONF_H
|
||||||
|
#include PROJECT_CONF_H
|
||||||
|
#endif /* PROJECT_CONF_H */
|
||||||
|
|
||||||
#endif /* __CONTIKI_CONF_H__ */
|
#endif /* __CONTIKI_CONF_H__ */
|
||||||
|
|
|
@ -28,25 +28,45 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: contiki-esb-default-init-net.c,v 1.12 2009/03/17 20:19:11 adamdunkels Exp $
|
* @(#)$Id: contiki-esb-default-init-net.c,v 1.13 2009/07/07 13:06:56 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-esb.h"
|
#include "contiki-conf.h"
|
||||||
|
#include "dev/tr1001.h"
|
||||||
|
#include "dev/rs232.h"
|
||||||
|
#include "dev/serial-line.h"
|
||||||
#include "net/rime.h"
|
#include "net/rime.h"
|
||||||
#include "net/mac/nullmac.h"
|
#include "node-id.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef MAC_DRIVER
|
||||||
|
#ifdef MAC_CONF_DRIVER
|
||||||
|
#define MAC_DRIVER MAC_CONF_DRIVER
|
||||||
|
#else
|
||||||
|
#define MAC_DRIVER nullmac_driver
|
||||||
|
#endif /* MAC_CONF_DRIVER */
|
||||||
|
#endif /* MAC_DRIVER */
|
||||||
|
|
||||||
|
extern const struct mac_driver MAC_DRIVER;
|
||||||
|
|
||||||
void
|
void
|
||||||
init_net(void)
|
init_net(void)
|
||||||
{
|
{
|
||||||
rimeaddr_t rimeaddr;
|
rimeaddr_t rimeaddr;
|
||||||
|
int i;
|
||||||
|
|
||||||
tr1001_init();
|
tr1001_init();
|
||||||
rime_init(nullmac_init(&tr1001_driver));
|
rime_init(MAC_DRIVER.init(&tr1001_driver));
|
||||||
rimeaddr.u8[0] = node_id & 0xff;
|
rimeaddr.u8[0] = node_id & 0xff;
|
||||||
rimeaddr.u8[1] = node_id >> 8;
|
rimeaddr.u8[1] = node_id >> 8;
|
||||||
rimeaddr_set_node_addr(&rimeaddr);
|
rimeaddr_set_node_addr(&rimeaddr);
|
||||||
|
|
||||||
rs232_set_input(serial_line_input_byte);
|
printf("Rime started with address ");
|
||||||
|
for(i = 0; i < sizeof(rimeaddr.u8) - 1; i++) {
|
||||||
|
printf("%u.", rimeaddr.u8[i]);
|
||||||
|
}
|
||||||
|
printf("%u (%s)\n", rimeaddr.u8[i], MAC_DRIVER.name);
|
||||||
|
|
||||||
|
rs232_set_input(serial_line_input_byte);
|
||||||
|
serial_line_init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: contiki-esb-main.c,v 1.15 2008/03/13 15:58:44 nifi Exp $
|
* @(#)$Id: contiki-esb-main.c,v 1.16 2009/07/07 13:06:56 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
@ -42,6 +42,23 @@
|
||||||
#include "sys/autostart.h"
|
#include "sys/autostart.h"
|
||||||
#include "contiki-esb.h"
|
#include "contiki-esb.h"
|
||||||
|
|
||||||
|
#ifdef DCOSYNCH_CONF_PERIOD
|
||||||
|
#define DCOSYNCH_PERIOD DCOSYNCH_CONF_PERIOD
|
||||||
|
#else
|
||||||
|
#define DCOSYNCH_PERIOD 30
|
||||||
|
#endif /* DCOSYNCH_CONF_PERIOD */
|
||||||
|
|
||||||
|
#ifdef DCOSYNCH_CONF_ENABLED
|
||||||
|
#define DCOSYNCH_ENABLED DCOSYNCH_CONF_ENABLED
|
||||||
|
#else
|
||||||
|
#define DCOSYNCH_ENABLED 0
|
||||||
|
#endif /* DCOSYNCH_CONF_ENABLED */
|
||||||
|
|
||||||
|
#if DCOSYNCH_ENABLED
|
||||||
|
static struct timer dco_timer;
|
||||||
|
static char dco_enabled = 0;
|
||||||
|
#endif /* DCOSYNCH_ENABLED */
|
||||||
|
|
||||||
SENSORS(&button_sensor, &sound_sensor, &vib_sensor,
|
SENSORS(&button_sensor, &sound_sensor, &vib_sensor,
|
||||||
&pir_sensor, &radio_sensor, &battery_sensor, &ctsrts_sensor,
|
&pir_sensor, &radio_sensor, &battery_sensor, &ctsrts_sensor,
|
||||||
&temperature_sensor);
|
&temperature_sensor);
|
||||||
|
@ -55,7 +72,8 @@ print_processes(struct process * const processes[])
|
||||||
printf(" '%s'", (*processes)->name);
|
printf(" '%s'", (*processes)->name);
|
||||||
processes++;
|
processes++;
|
||||||
}
|
}
|
||||||
printf("\n");
|
/* Needed to force link with putchar */
|
||||||
|
putchar('\n');
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init_ports_toberemoved() {
|
static void init_ports_toberemoved() {
|
||||||
|
@ -127,8 +145,6 @@ main(void)
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||||
#endif /* ENERGEST_CONF_ON */
|
#endif /* ENERGEST_CONF_ON */
|
||||||
|
|
||||||
init_net();
|
|
||||||
|
|
||||||
printf(CONTIKI_VERSION_STRING " started. ");
|
printf(CONTIKI_VERSION_STRING " started. ");
|
||||||
if(node_id > 0) {
|
if(node_id > 0) {
|
||||||
printf("Node id is set to %u.\n", node_id);
|
printf("Node id is set to %u.\n", node_id);
|
||||||
|
@ -136,6 +152,8 @@ main(void)
|
||||||
printf("Node id is not set.\n");
|
printf("Node id is not set.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_net();
|
||||||
|
|
||||||
beep_spinup();
|
beep_spinup();
|
||||||
leds_on(LEDS_RED);
|
leds_on(LEDS_RED);
|
||||||
clock_delay(100);
|
clock_delay(100);
|
||||||
|
@ -145,11 +163,15 @@ main(void)
|
||||||
print_processes(autostart_processes);
|
print_processes(autostart_processes);
|
||||||
autostart_start(autostart_processes);
|
autostart_start(autostart_processes);
|
||||||
|
|
||||||
|
#if DCOSYNCH_ENABLED
|
||||||
|
timer_set(&dco_timer, DCOSYNCH_PERIOD * CLOCK_SECOND);
|
||||||
|
#endif /* DCOSYNCH_ENABLED */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the scheduler loop.
|
* This is the scheduler loop.
|
||||||
*/
|
*/
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
while (1) {
|
while(1) {
|
||||||
int r;
|
int r;
|
||||||
#if PROFILE_CONF_ON
|
#if PROFILE_CONF_ON
|
||||||
profile_episode_start();
|
profile_episode_start();
|
||||||
|
@ -172,6 +194,17 @@ main(void)
|
||||||
} else {
|
} else {
|
||||||
#if ENERGEST_CONF_ON
|
#if ENERGEST_CONF_ON
|
||||||
static unsigned long irq_energest = 0;
|
static unsigned long irq_energest = 0;
|
||||||
|
#endif /* ENERGEST_CONF_ON */
|
||||||
|
|
||||||
|
#if DCOSYNCH_CONF_ENABLED
|
||||||
|
/* before going down to sleep possibly do some management */
|
||||||
|
if(timer_expired(&dco_timer)) {
|
||||||
|
timer_reset(&dco_timer);
|
||||||
|
msp430_sync_dco();
|
||||||
|
}
|
||||||
|
#endif /* DCOSYNCH_CONF_ENABLED */
|
||||||
|
|
||||||
|
#if ENERGEST_CONF_ON
|
||||||
/* Re-enable interrupts and go to sleep atomically. */
|
/* Re-enable interrupts and go to sleep atomically. */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||||
|
@ -206,11 +239,10 @@ main(void)
|
||||||
/* void arg_init(void) {} */
|
/* void arg_init(void) {} */
|
||||||
/* void arg_free(char *arg) {} */
|
/* void arg_free(char *arg) {} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if UIP_LOGGING
|
||||||
void
|
void
|
||||||
uip_log(char *m)
|
uip_log(char *m)
|
||||||
{
|
{
|
||||||
printf("uIP log: '%s'", m);
|
printf("uIP log: '%s'\n", m);
|
||||||
/* Needed to force link with putchar */
|
|
||||||
putchar('\n');
|
|
||||||
}
|
}
|
||||||
|
#endif /* UIP_LOGGING */
|
||||||
|
|
Loading…
Reference in a new issue