Adding the avr-rss2 platform based on AtMega256RFR2

This commit is contained in:
Robert Olsson 2016-02-22 20:46:07 +01:00
parent d3980668ee
commit ce8e87d60e
91 changed files with 9349 additions and 0 deletions

View file

@ -0,0 +1,19 @@
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = hello-sensors
all: $(CONTIKI_PROJECT)
# We use floating vars. Add library.
PRINTF_LIB_FLT = -Wl,-u,vfprintf -lprintf_flt -lm
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
PRINTF_LIB = $(PRINTF_LIB_FLT)
CLIBS = $(PRINTF_LIB)
CUSTOM_RULE_LINK = 1
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ $(CLIBS)
CONTIKI = ../../../..
include $(CONTIKI)/Makefile.include

View file

@ -0,0 +1,11 @@
Hello-sensors
=============
Simple demo to read out sensors from the RSS2 mote.
Demo uses double which has the same size as float on Atmel. We sacrifice
some bytes for this.
Build
-----
make TARGET=avr-rss2

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2015, Copyright Robert Olsson / Radio Sensors AB
* 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 Institute 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 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 file is part of the Contiki operating system.
*
*
* Author : Robert Olsson robert@radio-sensors.com
* Created : 2015-11-22
*/
/**
* \file
* A simple application showing sensor reading on RSS2 mote
*/
#include "contiki.h"
#include "sys/etimer.h"
#include <stdio.h>
#include "adc.h"
#include "i2c.h"
#include "dev/leds.h"
#include "dev/battery-sensor.h"
#include "dev/temp-sensor.h"
#include "dev/temp_mcu-sensor.h"
#include "dev/light-sensor.h"
#include "dev/pulse-sensor.h"
#ifdef CO2
#include "dev/co2_sa_kxx-sensor.h"
#endif
/*---------------------------------------------------------------------------*/
PROCESS(hello_sensors_process, "Hello sensor process");
AUTOSTART_PROCESSES(&hello_sensors_process);
static struct etimer et;
static void
read_values(void)
{
char serial[16];
int i;
/* Read out mote unique 128 bit ID */
i2c_at24mac_read((char *) &serial, 0);
printf("128_bit_ID=");
for(i=0; i < 15; i++)
printf("%02x", serial[i]);
printf("%02x\n", serial[15]);
printf("T=%-5.2f", ((double) temp_sensor.value(0)/100.));
printf(" V_MCU=%-3.1f", ((double) battery_sensor.value(0))/1000.);
printf(" V_IN=%-4.2f", adc_read_v_in());
printf(" V_AD1=%-4.2f", adc_read_a1());
printf(" V_AD2=%-4.2f", adc_read_a2());
printf(" T_MCU=%-4.1f", ((double) temp_mcu_sensor.value(0)/10.));
printf(" LIGHT=%-d", light_sensor.value(0));
printf(" PULSE_0=%-d", pulse_sensor.value(0));
printf(" PULSE_1=%-d", pulse_sensor.value(1));
#ifdef CO2
printf(" CO2=%-d", co2_sa_kxx_sensor.value( CO2_SA_KXX_CO2));
#endif
printf("\n");
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_sensors_process, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(temp_sensor);
SENSORS_ACTIVATE(battery_sensor);
SENSORS_ACTIVATE(temp_mcu_sensor);
SENSORS_ACTIVATE(light_sensor);
SENSORS_ACTIVATE(pulse_sensor);
#ifdef CO2
SENSORS_ACTIVATE(co2_sa_kxx_sensor);
#endif
leds_init();
leds_on(LEDS_RED);
leds_on(LEDS_YELLOW);
/*
* Delay 5 sec
* Gives a chance to trigger some pulses
*/
etimer_set(&et, CLOCK_SECOND * 5);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
read_values();
etimer_reset(&et);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2015, Copyright Robert Olsson / Radio Sensors AB
* 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 Institute 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 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 file is part of the Contiki operating system.
*
*
* Author : Robert Olsson robert@radio-sensors.com
* Created : 2015-11-22
*/
/**
* \file
* Project specific configuration defines for example
*
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_MAC nullmac_driver
//#define NETSTACK_CONF_MAC csma_driver
//#define NETSTACK_CONF_RDC contikimac_driver
#endif /* PROJECT_CONF_H_ */