Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
e00508472c
13 changed files with 176 additions and 32 deletions
|
@ -94,7 +94,7 @@ extern const struct mac_driver *rime_mac;
|
||||||
struct rime_sniffer {
|
struct rime_sniffer {
|
||||||
struct rime_sniffer *next;
|
struct rime_sniffer *next;
|
||||||
void (* input_callback)(void);
|
void (* input_callback)(void);
|
||||||
void (* output_callback)(void);
|
void (* output_callback)(int mac_status);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RIME_SNIFFER(name, input_callback, output_callback) \
|
#define RIME_SNIFFER(name, input_callback, output_callback) \
|
||||||
|
|
|
@ -151,7 +151,7 @@ static void
|
||||||
packet_sent(void *ptr, int status, int num_tx)
|
packet_sent(void *ptr, int status, int num_tx)
|
||||||
{
|
{
|
||||||
struct channel *c = ptr;
|
struct channel *c = ptr;
|
||||||
|
struct rime_sniffer *s;
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case MAC_TX_COLLISION:
|
case MAC_TX_COLLISION:
|
||||||
|
@ -166,17 +166,14 @@ packet_sent(void *ptr, int status, int num_tx)
|
||||||
default:
|
default:
|
||||||
PRINTF("rime: error %d after %d tx\n", status, num_tx);
|
PRINTF("rime: error %d after %d tx\n", status, num_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status == MAC_TX_OK) {
|
/* Call sniffers, pass along the MAC status code. */
|
||||||
struct rime_sniffer *s;
|
for(s = list_head(sniffers); s != NULL; s = list_item_next(s)) {
|
||||||
/* Call sniffers, but only if the packet was sent. */
|
if(s->output_callback != NULL) {
|
||||||
for(s = list_head(sniffers); s != NULL; s = list_item_next(s)) {
|
s->output_callback(status);
|
||||||
if(s->output_callback != NULL) {
|
|
||||||
s->output_callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abc_sent(c, status, num_tx);
|
abc_sent(c, status, num_tx);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -101,11 +101,12 @@ sent_by_stunicast(struct stunicast_conn *stunicast, int status, int num_tx)
|
||||||
PRINTF("%d.%d: runicast: packet %d timed out\n",
|
PRINTF("%d.%d: runicast: packet %d timed out\n",
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
c->sndnxt);
|
c->sndnxt);
|
||||||
|
c->sndnxt = (c->sndnxt + 1) % (1 << RUNICAST_PACKET_ID_BITS);
|
||||||
} else {
|
} else {
|
||||||
int shift;
|
// int shift;
|
||||||
|
|
||||||
shift = c->rxmit > 4? 4: c->rxmit;
|
// shift = c->rxmit > 4? 4: c->rxmit;
|
||||||
stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
|
// stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,9 +113,11 @@ send(void *ptr)
|
||||||
PRINTF("%d.%d: stunicast: resend to %d.%d\n",
|
PRINTF("%d.%d: stunicast: resend to %d.%d\n",
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
c->receiver.u8[0], c->receiver.u8[1]);
|
c->receiver.u8[0], c->receiver.u8[1]);
|
||||||
queuebuf_to_packetbuf(c->buf);
|
if(c->buf) {
|
||||||
unicast_send(&c->c, &c->receiver);
|
queuebuf_to_packetbuf(c->buf);
|
||||||
stunicast_set_timer(c, CLOCK_SECOND);
|
unicast_send(&c->c, &c->receiver);
|
||||||
|
stunicast_set_timer(c, CLOCK_SECOND);
|
||||||
|
}
|
||||||
/* if(c->u->sent != NULL) {
|
/* if(c->u->sent != NULL) {
|
||||||
c->u->sent(c);
|
c->u->sent(c);
|
||||||
}*/
|
}*/
|
||||||
|
|
|
@ -36,12 +36,13 @@ STRIP = strip
|
||||||
|
|
||||||
ifndef IAR_PATH
|
ifndef IAR_PATH
|
||||||
# This works with cygwin...
|
# This works with cygwin...
|
||||||
IAR_BIN_PATH = $(shell dirname `which $(CC)`)
|
IAR_BIN_PATH = $(shell dirname "`which $(CC)`")
|
||||||
IAR_PATH_C = $(shell dirname $(IAR_BIN_PATH))
|
IAR_PATH_C = $(shell dirname "$(IAR_BIN_PATH)")
|
||||||
IAR_PATH = $(shell cygpath -m $(IAR_PATH_C))
|
IAR_PATH = $(shell cygpath -m "$(IAR_PATH_C)")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGSNO = --dlib_config $(IAR_PATH)/LIB/DLIB/dl430xlfn.h -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model large --double=32
|
CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430xlfn.h" -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model small --double=32
|
||||||
|
# CFLAGSNO = --dlib_config $(IAR_PATH)/LIB/DLIB/dl430xlfn.h -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model large --double=32
|
||||||
CUSTOM_RULE_C_TO_O = 1
|
CUSTOM_RULE_C_TO_O = 1
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
@ -55,7 +56,8 @@ CUSTOM_RULE_C_TO_CO = 1
|
||||||
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
|
||||||
|
|
||||||
AROPTS = -o
|
AROPTS = -o
|
||||||
LDFLAGS += -B $(IAR_PATH)/lib/dlib/dl430xlfn.r43 -f $(IAR_PATH)/config/lnk430f5437.xcl -l contiki-$(TARGET).map -Fintel-extended -s __program_start
|
LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
GCC = 1
|
GCC = 1
|
||||||
|
|
25
cpu/stm32w108/board-sensors.h
Normal file
25
cpu/stm32w108/board-sensors.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Declarations for sensor-related functions that are
|
||||||
|
* common to all stm32w platforms.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \author Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remember state of sensors (if active or not), in order to
|
||||||
|
* resume their original state after calling powerUpSensors().
|
||||||
|
* Useful when entering in sleep mode, since all system
|
||||||
|
* peripherals have to be reinitialized.
|
||||||
|
*/
|
||||||
|
void sensorsPowerDown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume the state of all on-board sensors on to the state
|
||||||
|
* that they had when sensorsPowerDown() was called.
|
||||||
|
* Useful when sensors have to be used after the micro was put
|
||||||
|
* in deep sleep mode.
|
||||||
|
*/
|
||||||
|
void sensorsPowerUp();
|
|
@ -314,7 +314,7 @@ void halBoardPowerDown(void)
|
||||||
(GPIOCFG_IN <<PC7_CFG_BIT); /* OSC32K */
|
(GPIOCFG_IN <<PC7_CFG_BIT); /* OSC32K */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EMBERZNET_HAL
|
|
||||||
/* Configure GPIO for BUTTONSs */
|
/* Configure GPIO for BUTTONSs */
|
||||||
{
|
{
|
||||||
ButtonResourceType *buttons = (ButtonResourceType *) boardDescription->io->buttons;
|
ButtonResourceType *buttons = (ButtonResourceType *) boardDescription->io->buttons;
|
||||||
|
@ -324,9 +324,23 @@ void halBoardPowerDown(void)
|
||||||
halGpioSet(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOOUT_PULLUP);
|
halGpioSet(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOOUT_PULLUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
/* Configure GPIO for LEDs */
|
||||||
|
{
|
||||||
|
LedResourceType *leds = (LedResourceType *) boardDescription->io->leds;
|
||||||
|
int8u i;
|
||||||
|
for (i = 0; i < boardDescription->leds; i++) {
|
||||||
|
/* LED default off */
|
||||||
|
halGpioConfig(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), GPIOCFG_OUT);
|
||||||
|
halGpioSet(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Configure GPIO for power amplifier */
|
/* Configure GPIO for power amplifier */
|
||||||
if (boardDescription->flags & BOARD_HAS_PA) {
|
if (boardDescription->flags & BOARD_HAS_PA) {
|
||||||
|
/* SiGe Ant Sel to output */
|
||||||
|
halGpioConfig(PORTB_PIN(5), GPIOCFG_OUT);
|
||||||
|
halGpioSet(PORTB_PIN(5), 1);
|
||||||
/* SiGe Standby */
|
/* SiGe Standby */
|
||||||
halGpioConfig(PORTB_PIN(6), GPIOCFG_OUT);
|
halGpioConfig(PORTB_PIN(6), GPIOCFG_OUT);
|
||||||
halGpioSet(PORTB_PIN(6), 0);
|
halGpioSet(PORTB_PIN(6), 0);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "board-mb851.h"
|
#include "board-sensors.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
#include "dev/temperature-sensor.h"
|
#include "dev/temperature-sensor.h"
|
||||||
#include "dev/acc-sensor.h"
|
#include "dev/acc-sensor.h"
|
||||||
|
#include "dev/leds.h"
|
||||||
|
|
||||||
void halBoardInit(void)
|
void halBoardInit(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
void sensorsPowerDown();
|
|
||||||
|
|
||||||
void sensorsPowerUp();
|
|
|
@ -4,7 +4,7 @@ ARCH= irq.c sensors.c acc-sensor.c button-sensor.c temperature-sensor.c mems.c
|
||||||
|
|
||||||
CONTIKI_TARGET_DIRS = . dev
|
CONTIKI_TARGET_DIRS = . dev
|
||||||
ifndef CONTIKI_TARGET_MAIN
|
ifndef CONTIKI_TARGET_MAIN
|
||||||
CONTIKI_TARGET_MAIN = contiki-main.c led.c button.c board.c
|
CONTIKI_TARGET_MAIN = contiki-main.c led.c button.c board.c board-mbxxx.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef UIP_CONF_IPV6
|
ifdef UIP_CONF_IPV6
|
||||||
|
|
54
platform/mbxxx/board-mbxxx.c
Normal file
54
platform/mbxxx/board-mbxxx.c
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*#include PLATFORM_HEADER
|
||||||
|
#include BOARD_HEADER
|
||||||
|
#include "hal/micro/micro-common.h"
|
||||||
|
#include "hal/micro/cortexm3/micro-common.h"*/
|
||||||
|
|
||||||
|
#include "dev/button-sensor.h"
|
||||||
|
#include "dev/temperature-sensor.h"
|
||||||
|
#include "dev/acc-sensor.h"
|
||||||
|
|
||||||
|
static uint8_t sensors_status;
|
||||||
|
|
||||||
|
#define BUTTON_STATUS_ACTIVE (1 << 0)
|
||||||
|
#define TEMP_STATUS_ACTIVE (1 << 1)
|
||||||
|
#define ACC_STATUS_ACTIVE (1 << 2)
|
||||||
|
|
||||||
|
/* Remember state of sensors (if active or not), in order to
|
||||||
|
* resume their original state after calling powerUpSensors().
|
||||||
|
* Useful when entering in sleep mode, since all system
|
||||||
|
* peripherals have to be reinitialized. */
|
||||||
|
|
||||||
|
void sensorsPowerDown(){
|
||||||
|
|
||||||
|
sensors_status = 0;
|
||||||
|
|
||||||
|
if(button_sensor.status(SENSORS_READY)){
|
||||||
|
sensors_status |= BUTTON_STATUS_ACTIVE;
|
||||||
|
}
|
||||||
|
if(temperature_sensor.status(SENSORS_READY)){
|
||||||
|
sensors_status |= TEMP_STATUS_ACTIVE;
|
||||||
|
}
|
||||||
|
if(acc_sensor.status(SENSORS_READY)){
|
||||||
|
sensors_status |= ACC_STATUS_ACTIVE;
|
||||||
|
// Power down accelerometer to save power
|
||||||
|
SENSORS_DEACTIVATE(acc_sensor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
void sensorsPowerUp(){
|
||||||
|
|
||||||
|
button_sensor.configure(SENSORS_HW_INIT, 0);
|
||||||
|
temperature_sensor.configure(SENSORS_HW_INIT, 0);
|
||||||
|
acc_sensor.configure(SENSORS_HW_INIT, 0);
|
||||||
|
|
||||||
|
if(sensors_status & BUTTON_STATUS_ACTIVE){
|
||||||
|
SENSORS_ACTIVATE(button_sensor);
|
||||||
|
}
|
||||||
|
if(sensors_status & TEMP_STATUS_ACTIVE){
|
||||||
|
SENSORS_ACTIVATE(temperature_sensor);
|
||||||
|
}
|
||||||
|
if(sensors_status & ACC_STATUS_ACTIVE){
|
||||||
|
SENSORS_ACTIVATE(acc_sensor);
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,12 @@
|
||||||
#include "sys/clock.h"
|
#include "sys/clock.h"
|
||||||
#include "sys/etimer.h"
|
#include "sys/etimer.h"
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
|
#include "uart1.h"
|
||||||
|
#include "dev/leds.h"
|
||||||
|
#include "dev/stm32w-radio.h"
|
||||||
|
|
||||||
|
#define DEBUG DEBUG_NONE
|
||||||
|
#include "net/uip-debug.h"
|
||||||
|
|
||||||
// The value that will be load in the SysTick value register.
|
// The value that will be load in the SysTick value register.
|
||||||
#define RELOAD_VALUE 24000-1 // 1 ms with a 24 MHz clock
|
#define RELOAD_VALUE 24000-1 // 1 ms with a 24 MHz clock
|
||||||
|
@ -86,7 +92,7 @@ void SysTick_Handler(void)
|
||||||
void clock_init(void)
|
void clock_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
INTERRUPTS_OFF();
|
ATOMIC(
|
||||||
|
|
||||||
//Counts the number of ticks.
|
//Counts the number of ticks.
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -96,7 +102,7 @@ void clock_init(void)
|
||||||
SysTick_ITConfig(ENABLE);
|
SysTick_ITConfig(ENABLE);
|
||||||
SysTick_CounterCmd(SysTick_Counter_Enable);
|
SysTick_CounterCmd(SysTick_Counter_Enable);
|
||||||
|
|
||||||
INTERRUPTS_ON();
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -137,3 +143,49 @@ unsigned long clock_seconds(void)
|
||||||
{
|
{
|
||||||
return current_seconds;
|
return current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sleep_seconds(int seconds)
|
||||||
|
{
|
||||||
|
int32u quarter_seconds = seconds * 4;
|
||||||
|
uint8_t radio_on;
|
||||||
|
|
||||||
|
|
||||||
|
halPowerDown();
|
||||||
|
radio_on = stm32w_radio_is_on();
|
||||||
|
stm32w_radio_driver.off();
|
||||||
|
|
||||||
|
halSleepForQsWithOptions(&quarter_seconds, 0);
|
||||||
|
|
||||||
|
|
||||||
|
ATOMIC(
|
||||||
|
|
||||||
|
halPowerUp();
|
||||||
|
|
||||||
|
// Update OS system ticks.
|
||||||
|
current_seconds += seconds - quarter_seconds / 4 ; // Passed seconds
|
||||||
|
count += seconds * CLOCK_SECOND - quarter_seconds * CLOCK_SECOND / 4 ;
|
||||||
|
|
||||||
|
if(etimer_pending()) {
|
||||||
|
etimer_request_poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
|
||||||
|
SysTick_SetReload(RELOAD_VALUE);
|
||||||
|
SysTick_ITConfig(ENABLE);
|
||||||
|
SysTick_CounterCmd(SysTick_Counter_Enable);
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
stm32w_radio_driver.init();
|
||||||
|
if(radio_on){
|
||||||
|
stm32w_radio_driver.on();
|
||||||
|
}
|
||||||
|
|
||||||
|
uart1_init(115200);
|
||||||
|
leds_init();
|
||||||
|
rtimer_init();
|
||||||
|
|
||||||
|
PRINTF("WakeInfo: %04x\r\n", halGetWakeInfo());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue