Add OpenMote-CC2538 platform and examples.

This commit is contained in:
Pere Tuset 2016-02-11 01:34:08 +01:00
parent 99de563e8d
commit 1d3c37d6da
27 changed files with 3166 additions and 0 deletions

View File

@ -0,0 +1,9 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = openmote-demo test-timer test-adxl346 test-max44009 test-sht21
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup openmote-cc2538
* @{
*
* \defgroup openmote-examples OpenMote-CC2538 Example Projects
* @{
*
* \defgroup openmote-demo OpenMote-CC2538 Demo Project
*
* Example project demonstrating the OpenMote-CC2538 functionality
*
* This assumes that you are using an OpenMote-CC2538
*
* - Boot sequence: LEDs flashing, LED2 followed by LED3 then LED4
* - etimer/clock : Every LOOP_INTERVAL clock ticks the LED defined as
* LEDS_PERIODIC will turn on
* - rtimer : Exactly LEDS_OFF_HYSTERISIS rtimer ticks later,
* LEDS_PERIODIC will turn back off
* - UART : Every LOOP_INTERVAL the EM will print something over the
* UART. Receiving an entire line of text over UART (ending
* in \\r) will cause LEDS_SERIAL_IN to toggle
* - Radio comms : BTN_SELECT sends a rime broadcast. Reception of a rime
* packet will toggle LEDs defined as LEDS_RF_RX
*
* @{
*
* \file
* Example demonstrating the OpenMote platform.
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#include "contiki.h"
#include "cpu.h"
#include "sys/etimer.h"
#include "sys/rtimer.h"
#include "dev/leds.h"
#include "dev/uart.h"
#include "dev/button-sensor.h"
#include "dev/watchdog.h"
#include "dev/serial-line.h"
#include "dev/sys-ctrl.h"
#include "net/rime/broadcast.h"
#include <stdio.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define LOOP_INTERVAL CLOCK_SECOND
#define LEDS_OFF_HYSTERISIS (RTIMER_SECOND >> 1)
#define LEDS_PERIODIC LEDS_YELLOW
#define LEDS_BUTTON LEDS_RED
#define LEDS_SERIAL_IN LEDS_ORANGE
#define LEDS_REBOOT LEDS_ALL
#define LEDS_RF_RX (LEDS_YELLOW | LEDS_ORANGE)
#define BROADCAST_CHANNEL 129
/*---------------------------------------------------------------------------*/
static struct etimer et;
static struct rtimer rt;
static uint16_t counter;
/*---------------------------------------------------------------------------*/
PROCESS(openmote_demo_process, "OpenMote-CC2538 demo process");
AUTOSTART_PROCESSES(&openmote_demo_process);
/*---------------------------------------------------------------------------*/
static void
broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
{
leds_toggle(LEDS_RF_RX);
printf("Received %u bytes: '0x%04x'\n", packetbuf_datalen(),
*(uint16_t *)packetbuf_dataptr());
}
/*---------------------------------------------------------------------------*/
static const struct broadcast_callbacks bc_rx = { broadcast_recv };
static struct broadcast_conn bc;
/*---------------------------------------------------------------------------*/
void
rt_callback(struct rtimer *t, void *ptr)
{
leds_off(LEDS_PERIODIC);
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(openmote_demo_process, ev, data)
{
PROCESS_EXITHANDLER(broadcast_close(&bc))
PROCESS_BEGIN();
counter = 0;
broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx);
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_YIELD();
if(ev == PROCESS_EVENT_TIMER) {
leds_on(LEDS_PERIODIC);
printf("Counter = 0x%08x\n", counter);
etimer_set(&et, CLOCK_SECOND);
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,
rt_callback, NULL);
} else if(ev == sensors_event) {
if(data == &button_user_sensor) {
packetbuf_copyfrom(&counter, sizeof(counter));
broadcast_send(&bc);
}
} else if(ev == serial_line_event_message) {
leds_toggle(LEDS_SERIAL_IN);
}
counter++;
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
* @}
*/

View File

@ -0,0 +1,46 @@
/*
* 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-examples
* @{
*
* \file
* Project specific configuration defines for the basic RE-Mote examples
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define BROADCAST_CHANNEL 129
#define NETSTACK_CONF_RDC nullrdc_driver
#endif /* PROJECT_CONF_H_ */
/** @} */

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup openmote-examples
* @{
*
* \defgroup openmote-adxl346
*
* This example tests the correct functionality of the ADXL346 acceleration
* sensor using the I2C bus.
*
* @{
*
* \file
* Testing the ADXL346 sensor on the OpenMote-CC2538 platform.
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#include "contiki.h"
#include "dev/adxl346.h"
#include <stdio.h>
PROCESS(test_adxl346_process, "ADXL346 test");
AUTOSTART_PROCESSES(&test_adxl346_process);
PROCESS_THREAD(test_adxl346_process, ev, data)
{
static struct etimer et;
static unsigned acceleration;
PROCESS_BEGIN();
adxl346_init();
if (!adxl346_is_present()) {
leds_on(LEDS_ORANGE);
}
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_YIELD();
if (ev == PROCESS_EVENT_TIMER) {
acceleration = adxl346_read_x();
printf("X Acceleration: %u\n", acceleration);
acceleration = adxl346_read_y();
printf("Y Acceleration: %u\n", acceleration);
acceleration = adxl346_read_z();
printf("Z Acceleration: %u\n", acceleration);
}
}
PROCESS_END();
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup openmote-examples
* @{
*
* \defgroup openmote-max44009
*
* This example tests the correct functionality of the MAX44009 light
* sensor using the I2C bus.
*
* @{
*
* \file
* Testing the MAX44009 sensor on the OpenMote-CC2538 platform.
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#include "contiki.h"
#include "dev/max44009.h"
#include "dev/leds.h"
#include <stdio.h>
PROCESS(test_max44009_process, "MAX44009 test");
AUTOSTART_PROCESSES(&test_max44009_process);
PROCESS_THREAD(test_max44009_process, ev, data)
{
static struct etimer et;
static unsigned raw;
static float light;
PROCESS_BEGIN();
max44009_init();
if (!max44009_is_present()) {
leds_on(LEDS_ORANGE);
}
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_YIELD();
if (ev == PROCESS_EVENT_TIMER) {
leds_on(LEDS_YELLOW);
raw = max44009_read_light();
light = max44009_convert_light(raw);
printf("Light: %u.%u\n", (unsigned int) light, (unsigned int) (light * 100) % 100);
leds_off(LEDS_YELLOW);
}
}
PROCESS_END();
}

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup openmote-examples
* @{
*
* \defgroup openmote-sht21
*
* This example tests the correct functionality of the SHT21 temperature
* and humidity sensor using the I2C bus.
*
* @{
*
* \file
* Testing the SHT21 sensor on the OpenMote-CC2538 platform.
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#include "contiki.h"
#include "dev/sht21.h"
#include "dev/leds.h"
#include "sys/etimer.h"
#include <stdio.h>
PROCESS(test_sht21_process, "SHT21 test");
AUTOSTART_PROCESSES(&test_sht21_process);
PROCESS_THREAD(test_sht21_process, ev, data)
{
static struct etimer et;
static unsigned raw;
static float temperature;
static float humidity;
PROCESS_BEGIN();
sht21_init();
if (!sht21_is_present()) {
leds_on(LEDS_ORANGE);
}
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_YIELD();
if (ev == PROCESS_EVENT_TIMER) {
leds_on(LEDS_YELLOW);
raw = sht21_read_temperature();
temperature = sht21_convert_temperature(raw);
printf("Temperature: %u.%u degrees Celsius\n", (unsigned int) temperature, (unsigned int) (temperature * 100) % 100);
raw = sht21_read_humidity();
humidity = sht21_convert_humidity(raw);
printf("Rel. humidity: %u.%u%%\n", (unsigned int) humidity, (unsigned int) (humidity * 100) % 100);
leds_off(LEDS_YELLOW );
}
}
PROCESS_END();
}

View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup openmote-examples
* @{
*
* \defgroup openmote-timers OpenMote-CC2538 Timer Test Project
*
* This example tests the correct functionality of clocks and timers.
*
* More specifically, it tests clock_seconds, rtimers, etimers and
* clock_delay_usec.
*
* This is largely-based on the same example of the cc2530 port.
* @{
*
* \file
* Tests related to clocks and timers.
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#include "contiki.h"
#include "sys/clock.h"
#include "sys/rtimer.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#define TIMER_TEST_CONF_TEST_CLOCK_DELAY_USEC 1
#define TIMER_TEST_CONF_TEST_RTIMER 1
#define TIMER_TEST_CONF_TEST_ETIMER 1
#define TIMER_TEST_CONF_TEST_CLOCK_SECONDS 1
/*---------------------------------------------------------------------------*/
static struct etimer et;
#if TIMER_TEST_CONF_TEST_CLOCK_DELAY_USEC
static rtimer_clock_t start_count, end_count, diff;
#endif
#if TIMER_TEST_CONF_TEST_CLOCK_SECONDS
static unsigned long sec;
#endif
#if TIMER_TEST_CONF_TEST_ETIMER
static clock_time_t count;
#endif
#if TIMER_TEST_CONF_TEST_RTIMER
static struct rtimer rt;
rtimer_clock_t rt_now, rt_for;
static clock_time_t ct;
#endif
static uint8_t i;
/*---------------------------------------------------------------------------*/
PROCESS(timer_test_process, "Timer test process");
AUTOSTART_PROCESSES(&timer_test_process);
/*---------------------------------------------------------------------------*/
#if TIMER_TEST_CONF_TEST_RTIMER
void
rt_callback(struct rtimer *t, void *ptr)
{
rt_now = RTIMER_NOW();
ct = clock_time();
printf("Task called at %lu (clock = %lu)\n", rt_now, ct);
}
#endif
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(timer_test_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&et, 2 * CLOCK_SECOND);
PROCESS_YIELD();
#if TIMER_TEST_CONF_TEST_CLOCK_DELAY_USEC
printf("-----------------------------------------\n");
printf("clock_delay_usec test, (10,000 x i) usec:\n");
printf("N.B. clock_delay_usec is more accurate than rtimers\n");
i = 1;
while(i < 7) {
start_count = RTIMER_NOW();
clock_delay_usec(10000 * i);
end_count = RTIMER_NOW();
diff = end_count - start_count;
printf("Requested: %u usec, Real: %lu rtimer ticks = ~%lu us\n",
10000 * i, diff, diff * 1000000 / RTIMER_SECOND);
i++;
}
#endif
#if TIMER_TEST_CONF_TEST_RTIMER
printf("-----------------------------------------\n");
printf("Rtimer Test, 1 sec (%u rtimer ticks):\n", RTIMER_SECOND);
i = 0;
while(i < 5) {
etimer_set(&et, 2 * CLOCK_SECOND);
printf("=======================\n");
ct = clock_time();
rt_now = RTIMER_NOW();
rt_for = rt_now + RTIMER_SECOND;
printf("Now=%lu (clock = %lu) - For=%lu\n", rt_now, ct, rt_for);
if(rtimer_set(&rt, rt_for, 1, rt_callback, NULL) != RTIMER_OK) {
printf("Error setting\n");
}
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
i++;
}
#endif
#if TIMER_TEST_CONF_TEST_ETIMER
printf("-----------------------------------------\n");
printf("Clock tick and etimer test, 1 sec (%u clock ticks):\n",
CLOCK_SECOND);
i = 0;
while(i < 10) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
count = clock_time();
printf("%lu ticks\n", count);
leds_toggle(LEDS_RED);
i++;
}
#endif
#if TIMER_TEST_CONF_TEST_CLOCK_SECONDS
printf("-----------------------------------------\n");
printf("Clock seconds test (5s):\n");
i = 0;
while(i < 10) {
etimer_set(&et, 5 * CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
sec = clock_seconds();
printf("%lu seconds\n", sec);
leds_toggle(LEDS_GREEN);
i++;
}
#endif
printf("Done!\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -0,0 +1,50 @@
# openmote-cc2538 platform makefile
ifndef CONTIKI
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
endif
### Configure the build for the board and pull in board-specific sources
CONTIKI_TARGET_DIRS += . dev
PLATFORM_ROOT_DIR = $(CONTIKI)/platform/$(TARGET)
### Include
CONTIKI_TARGET_SOURCEFILES += contiki-main.c board.c
CONTIKI_TARGET_SOURCEFILES += leds-arch.c button-sensor.c smartrf-sensors.c
CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
CLEAN += *.openmote-cc2538
### 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 core/net/llsec/noncoresec
PYTHON = python
BSL_FLAGS += -e -w --bootloader-invert-lines -b 115200 -v
ifdef PORT
BSL_FLAGS += -p $(PORT)
endif
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
%.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

View File

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2014, 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 openmote-cc2538
* @{
*
* \file
* Board-initialisation for the OpenMote-CC2538 platform
*
*/
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/antenna.h"
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
static void
configure_unused_pins(void)
{
/* FIXME */
}
/*---------------------------------------------------------------------------*/
void
board_init()
{
antenna_init();
configure_unused_pins();
}
/*---------------------------------------------------------------------------*/
/**
* @}
*/

View File

@ -0,0 +1,166 @@
/*
* 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 platform
* @{
*
* \defgroup openmote
*
* \file
* Header file with definitions related to the I/O connections on the
* OpenMote-CC2538 platform. This file provides connectivity information on
* LEDs, Buttons, UART and other peripherals.
*
* \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 OpenMote-CC2538 LED configuration
*
* LEDs on the OpenMote-CC2538 are connected as follows:
* - LED1 (Red) -> PC4
* - LED2 (Yellow) -> PC6
* - LED3 (Green) -> PC7
* - LED4 (Orange) -> PC5
*
* @{
*/
/*---------------------------------------------------------------------------*/
/* 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_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 16 /**< LED1 (Red) -> PC4 */
#define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */
#define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */
#define LEDS_ORANGE 32 /**< LED4 (Orange) -> PC5 */
#define LEDS_CONF_ALL 240
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
/** @} */
/*---------------------------------------------------------------------------*/
/** \name USB configuration
*
* The USB pullup is driven by PC0
*/
#define USB_PULLUP_PORT GPIO_C_NUM
#define USB_PULLUP_PIN 0
/** @} */
/*---------------------------------------------------------------------------*/
/** \name UART configuration
*
* On the OpenMote, the UART is connected to the
* following ports/pins
* - RX: PA0
* - TX: PA1
* - CTS: PB0 (Can only be used with UART1)
* - RTS: PD3 (Can only be used with UART1)
*
* We configure the port to use UART0. To use UART1, replace UART0_* with
* UART1_* below.
* @{
*/
#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_CTS_PORT GPIO_B_NUM
#define UART1_CTS_PIN 0
#define UART1_RTS_PORT GPIO_D_NUM
#define UART1_RTS_PIN 3
/** @} */
/*---------------------------------------------------------------------------*/
/** \name OpenMote-CC2538 Button configuration
*
* Buttons on the OpenMote-CC2538 are connected as follows:
* - BUTTON_USER -> PC3
* @{
*/
/** BUTTON_USER -> PC3 */
#define BUTTON_USER_PORT GPIO_C_NUM
#define BUTTON_USER_PIN 3
#define BUTTON_USER_VECTOR NVIC_INT_GPIO_PORT_C
/* Notify various examples that we have Buttons */
#define PLATFORM_HAS_BUTTON 1
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name SPI configuration
*
* These values configure which CC2538 pins to use for the SPI lines.
* @{
*/
#define SPI_CLK_PORT GPIO_A_NUM
#define SPI_CLK_PIN 2
#define SPI_MOSI_PORT GPIO_A_NUM
#define SPI_MOSI_PIN 5
#define SPI_MISO_PORT GPIO_A_NUM
#define SPI_MISO_PIN 4
#define SPI_SEL_PORT GPIO_A_NUM
#define SPI_SEL_PIN 3
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name I2C configuration
*
* These values configure which CC2538 pins to use for the I2C lines.
* @{
*/
#define I2C_SCL_PORT GPIO_B_NUM
#define I2C_SCL_PIN 3
#define I2C_SDA_PORT GPIO_B_NUM
#define I2C_SDA_PIN 4
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Device string used on startup
* @{
*/
#define BOARD_STRING "OpenMote-CC2538"
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* BOARD_H_ */
/** @} */

View File

@ -0,0 +1,536 @@
/**
* \addtogroup openmote
* @{
*
* \file
* Configuration for the OpenMote-CC2538 platform.
*/
#ifndef CONTIKI_CONF_H_
#define CONTIKI_CONF_H_
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_H
#include PROJECT_CONF_H
#endif /* PROJECT_CONF_H */
/*---------------------------------------------------------------------------*/
/**
* \name Compiler configuration and platform-specific type definitions
*
* Those values are not meant to be modified by the user
* @{
*/
#define CLOCK_CONF_SECOND 128
/* Compiler configurations */
#define CCIF
#define CLIF
/* Platform typedefs */
typedef uint32_t clock_time_t;
typedef uint32_t uip_stats_t;
/*
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
* RTIMER_CLOCK_LT to override this
*/
typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Serial Boot Loader Backdoor configuration
*
* @{
*/
#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR
#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /**<Enable the boot loader backdoor */
#endif
#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN
#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN 6 /**< Pin PA6 (ON/SLEEP on the OpenBase), activates the boot loader */
#endif
#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH
#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name CFS configuration
*
* @{
*/
#define COFFEE_CONF_SIZE (4 * COFFEE_SECTOR_SIZE)
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Watchdog Timer configuration
*
* @{
*/
#ifndef WATCHDOG_CONF_ENABLE
#define WATCHDOG_CONF_ENABLE 1 /**< Enable the watchdog timer */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name USB 'core' configuration
*
* Those values are not meant to be modified by the user, except where stated
* otherwise
* @{
*/
#define CTRL_EP_SIZE 8
#define USB_EP1_SIZE 32
#define USB_EP2_SIZE 64
#define USB_EP3_SIZE 64
#define USB_ARCH_WRITE_NOTIFY 0
#ifndef USB_ARCH_CONF_DMA
#define USB_ARCH_CONF_DMA 1 /**< Change to Enable/Disable USB DMA */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Generic Configuration directives
*
* @{
*/
#ifndef ENERGEST_CONF_ON
#define ENERGEST_CONF_ON 0 /**< Energest Module */
#endif
#ifndef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name uDMA Configuration and channel allocations
*
* @{
*/
#define USB_ARCH_CONF_RX_DMA_CHAN 0 /**< USB -> RAM DMA channel */
#define USB_ARCH_CONF_TX_DMA_CHAN 1 /**< RAM -> USB DMA channel */
#define CC2538_RF_CONF_TX_DMA_CHAN 2 /**< RF -> RAM DMA channel */
#define CC2538_RF_CONF_RX_DMA_CHAN 3 /**< RAM -> RF DMA channel */
#define UDMA_CONF_MAX_CHANNEL CC2538_RF_CONF_RX_DMA_CHAN
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Character I/O Configuration
*
* @{
*/
#ifndef UART_CONF_ENABLE
#define UART_CONF_ENABLE 1 /**< Enable/Disable UART I/O */
#endif
#ifndef UART0_CONF_BAUD_RATE
#define UART0_CONF_BAUD_RATE 115200 /**< Default UART0 baud rate */
#endif
#ifndef UART1_CONF_BAUD_RATE
#define UART1_CONF_BAUD_RATE 115200 /**< Default UART1 baud rate */
#endif
#ifndef SLIP_ARCH_CONF_USB
#define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
#endif
#ifndef CC2538_RF_CONF_SNIFFER_USB
#define CC2538_RF_CONF_SNIFFER_USB 0 /**< Sniffer out over UART by default */
#endif
#ifndef DBG_CONF_USB
#define DBG_CONF_USB 0 /**< All debugging over UART by default */
#endif
#ifndef SERIAL_LINE_CONF_UART
#define SERIAL_LINE_CONF_UART 0 /**< UART to use with serial line */
#endif
#if !SLIP_ARCH_CONF_USB
#ifndef SLIP_ARCH_CONF_UART
#define SLIP_ARCH_CONF_UART 0 /**< UART to use with SLIP */
#endif
#endif
#if !CC2538_RF_CONF_SNIFFER_USB
#ifndef CC2538_RF_CONF_SNIFFER_UART
#define CC2538_RF_CONF_SNIFFER_UART 0 /**< UART to use with sniffer */
#endif
#endif
#if !DBG_CONF_USB
#ifndef DBG_CONF_UART
#define DBG_CONF_UART 0 /**< UART to use for debugging */
#endif
#endif
#ifndef UART1_CONF_UART
#define UART1_CONF_UART 0 /**< UART to use for examples relying on
the uart1_* API */
#endif
/* Turn off example-provided putchars */
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
#define SLIP_RADIO_CONF_NO_PUTCHAR 1
#ifndef SLIP_ARCH_CONF_ENABLED
/*
* Determine whether we need SLIP
* This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
* keep using SLIP
*/
#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
#define SLIP_ARCH_CONF_ENABLED 1
#endif
#endif
/*
* When set, the radio turns off address filtering and sends all captured
* frames down a peripheral (UART or USB, depending on the value of
* CC2538_RF_CONF_SNIFFER_USB)
*/
#ifndef CC2538_RF_CONF_SNIFFER
#define CC2538_RF_CONF_SNIFFER 0
#endif
/**
* \brief Define this as 1 to build a headless node.
*
* The UART will not be initialised its clock will be gated, offering some
* energy savings. The USB will not be initialised either
*/
#ifndef CC2538_CONF_QUIET
#define CC2538_CONF_QUIET 0
#endif
/* CC2538_CONF_QUIET is hard and overrides all other related defines */
#if CC2538_CONF_QUIET
#undef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE 0
#undef UART_CONF_ENABLE
#define UART_CONF_ENABLE 0
#undef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 0
/* Little sanity check: We can't have quiet sniffers */
#if CC2538_RF_CONF_SNIFFER
#error "CC2538_RF_CONF_SNIFFER == 1 and CC2538_CONF_QUIET == 1"
#error "These values are conflicting. Please set either to 0"
#endif
#endif /* CC2538_CONF_QUIET */
/**
* \brief Enable the USB core only if we need it
*/
#ifndef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE \
((SLIP_ARCH_CONF_USB & SLIP_ARCH_CONF_ENABLED) | \
DBG_CONF_USB | \
(CC2538_RF_CONF_SNIFFER & CC2538_RF_CONF_SNIFFER_USB))
#endif
/*
* If debugging and SLIP use the same peripheral, this will be 1. Don't modify
* this
*/
#if SLIP_ARCH_CONF_ENABLED
#define DBG_CONF_SLIP_MUX (SLIP_ARCH_CONF_USB == DBG_CONF_USB && \
(SLIP_ARCH_CONF_USB || \
SLIP_ARCH_CONF_UART == DBG_CONF_UART))
#endif
/*
* Automatic detection of whether a specific UART is in use
*/
#define UART_IN_USE_BY_SERIAL_LINE(u) (SERIAL_LINE_CONF_UART == (u))
#define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
!SLIP_ARCH_CONF_USB && \
SLIP_ARCH_CONF_UART == (u))
#define UART_IN_USE_BY_RF_SNIFFER(u) (CC2538_RF_CONF_SNIFFER && \
!CC2538_RF_CONF_SNIFFER_USB && \
CC2538_RF_CONF_SNIFFER_UART == (u))
#define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
#define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
#define UART_IN_USE(u) ( \
UART_CONF_ENABLE && \
(UART_IN_USE_BY_SERIAL_LINE(u) || \
UART_IN_USE_BY_SLIP(u) || \
UART_IN_USE_BY_RF_SNIFFER(u) || \
UART_IN_USE_BY_DBG(u) || \
UART_IN_USE_BY_UART1(u)) \
)
/** @} */
/*---------------------------------------------------------------------------*/
/* board.h assumes that basic configuration is done */
#include "board.h"
/*---------------------------------------------------------------------------*/
/**
* \name Network Stack Configuration
*
* @{
*/
#ifndef NETSTACK_CONF_NETWORK
#if NETSTACK_CONF_WITH_IPV6
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#else
#define NETSTACK_CONF_NETWORK rime_driver
#endif /* NETSTACK_CONF_WITH_IPV6 */
#endif /* NETSTACK_CONF_NETWORK */
#ifndef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC csma_driver
#endif
#ifndef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC contikimac_driver
#endif
/* Configure NullRDC for when it's selected */
#define NULLRDC_802154_AUTOACK 1
#define NULLRDC_802154_AUTOACK_HW 1
/* Configure ContikiMAC for when it's selected */
#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0
#define WITH_FAST_SLEEP 1
#ifndef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
#endif
#ifndef NETSTACK_CONF_FRAMER
#if NETSTACK_CONF_WITH_IPV6
#define NETSTACK_CONF_FRAMER framer_802154
#else /* NETSTACK_CONF_WITH_IPV6 */
#define NETSTACK_CONF_FRAMER contikimac_framer
#endif /* NETSTACK_CONF_WITH_IPV6 */
#endif /* NETSTACK_CONF_FRAMER */
#ifndef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO cc2538_rf_driver
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name LPM configuration
* @{
*/
#ifndef LPM_CONF_ENABLE
#define LPM_CONF_ENABLE 1 /**< Set to 0 to disable LPM entirely */
#endif
/**
* \brief Maximum PM
*
* The SoC will never drop to a Power Mode deeper than the one specified here.
* 0 for PM0, 1 for PM1 and 2 for PM2
*/
#ifndef LPM_CONF_MAX_PM
#define LPM_CONF_MAX_PM 1
#endif
#ifndef LPM_CONF_STATS
#define LPM_CONF_STATS 0 /**< Set to 1 to enable LPM-related stats */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name IEEE address configuration
*
* Used to generate our RIME & IPv6 address
* @{
*/
/**
* \brief Location of the IEEE address
* 0 => Read from InfoPage,
* 1 => Use a hardcoded address, configured by IEEE_ADDR_CONF_ADDRESS
*/
#ifndef IEEE_ADDR_CONF_HARDCODED
#define IEEE_ADDR_CONF_HARDCODED 0
#endif
/**
* \brief The hardcoded IEEE address to be used when IEEE_ADDR_CONF_HARDCODED
* is defined as 1
*/
#ifndef IEEE_ADDR_CONF_ADDRESS
#define IEEE_ADDR_CONF_ADDRESS { 0x00, 0x12, 0x4B, 0x00, 0x89, 0xAB, 0xCD, 0xEF }
#endif
/**
* \brief Location of the IEEE address in the InfoPage when
* IEEE_ADDR_CONF_HARDCODED is defined as 0
* 0 => Use the primary address location
* 1 => Use the secondary address location
*/
#ifndef IEEE_ADDR_CONF_USE_SECONDARY_LOCATION
#define IEEE_ADDR_CONF_USE_SECONDARY_LOCATION 0
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name RF configuration
*
* @{
*/
/* RF Config */
#ifndef IEEE802154_CONF_PANID
#define IEEE802154_CONF_PANID 0xABCD
#endif
#ifndef CC2538_RF_CONF_CHANNEL
#define CC2538_RF_CONF_CHANNEL 26
#endif /* CC2538_RF_CONF_CHANNEL */
#ifndef CC2538_RF_CONF_AUTOACK
#define CC2538_RF_CONF_AUTOACK 1 /**< RF H/W generates ACKs */
#endif /* CC2538_CONF_AUTOACK */
#ifndef CC2538_RF_CONF_TX_USE_DMA
#define CC2538_RF_CONF_TX_USE_DMA 1 /**< RF TX over DMA */
#endif
#ifndef CC2538_RF_CONF_RX_USE_DMA
#define CC2538_RF_CONF_RX_USE_DMA 1 /**< RF RX over DMA */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name IPv6, RIME and network buffer configuration
*
* @{
*/
/* Don't let contiki-default-conf.h decide if we are an IPv6 build */
#ifndef NETSTACK_CONF_WITH_IPV6
#define NETSTACK_CONF_WITH_IPV6 0
#endif
#if NETSTACK_CONF_WITH_IPV6
/* Addresses, Sizes and Interfaces */
/* 8-byte addresses here, 2 otherwise */
#define LINKADDR_CONF_SIZE 8
#define UIP_CONF_LL_802154 1
#define UIP_CONF_LLH_LEN 0
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
/* TCP, UDP, ICMP */
#ifndef UIP_CONF_TCP
#define UIP_CONF_TCP 1
#endif
#ifndef UIP_CONF_TCP_MSS
#define UIP_CONF_TCP_MSS 64
#endif
#define UIP_CONF_UDP 1
#define UIP_CONF_UDP_CHECKSUMS 1
#define UIP_CONF_ICMP6 1
/* ND and Routing */
#ifndef UIP_CONF_ROUTER
#define UIP_CONF_ROUTER 1
#endif
#define UIP_CONF_ND6_SEND_RA 0
#define UIP_CONF_IP_FORWARD 0
#define RPL_CONF_STATS 0
#ifndef RPL_CONF_OF
#define RPL_CONF_OF rpl_mrhof
#endif
#define UIP_CONF_ND6_REACHABLE_TIME 600000
#define UIP_CONF_ND6_RETRANS_TIMER 10000
#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#endif
#ifndef UIP_CONF_MAX_ROUTES
#define UIP_CONF_MAX_ROUTES 20
#endif
/* uIP */
#ifndef UIP_CONF_BUFFER_SIZE
#define UIP_CONF_BUFFER_SIZE 1300
#endif
#define UIP_CONF_IPV6_QUEUE_PKT 0
#define UIP_CONF_IPV6_CHECKS 1
#define UIP_CONF_IPV6_REASSEMBLY 0
#define UIP_CONF_MAX_LISTENPORTS 8
/* 6lowpan */
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
#ifndef SICSLOWPAN_CONF_COMPRESSION_THRESHOLD
#define SICSLOWPAN_CONF_COMPRESSION_THRESHOLD 63
#endif
#ifndef SICSLOWPAN_CONF_FRAG
#define SICSLOWPAN_CONF_FRAG 1
#endif
#define SICSLOWPAN_CONF_MAXAGE 8
/* Define our IPv6 prefixes/contexts here */
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
#ifndef SICSLOWPAN_CONF_ADDR_CONTEXT_0
#define SICSLOWPAN_CONF_ADDR_CONTEXT_0 { \
addr_contexts[0].prefix[0] = 0xaa; \
addr_contexts[0].prefix[1] = 0xaa; \
}
#endif
#define MAC_CONF_CHANNEL_CHECK_RATE 8
#ifndef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 8
#endif
/*---------------------------------------------------------------------------*/
#else /* NETSTACK_CONF_WITH_IPV6 */
/* Network setup for non-IPv6 (rime). */
#define UIP_CONF_IP_FORWARD 1
#ifndef UIP_CONF_BUFFER_SIZE
#define UIP_CONF_BUFFER_SIZE 108
#endif
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
#ifndef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 8
#endif
#endif /* NETSTACK_CONF_WITH_IPV6 */
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Security
*
* @{
*/
#ifndef CRYPTO_CONF_INIT
#define CRYPTO_CONF_INIT 1 /**< Whether to init cryptoprocessor */
#endif
#ifndef AES_128_CONF
#define AES_128_CONF cc2538_aes_128_driver /**< AES-128 driver */
#endif
#ifndef CCM_STAR_CONF
#define CCM_STAR_CONF cc2538_ccm_star_driver /**< AES-CCM* driver */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* CONTIKI_CONF_H_ */
/** @} */

View File

@ -0,0 +1,248 @@
/*
* 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 cc2538-platforms
* @{
*
* \defgroup openmote The OpenMote-CC2538 platform
*
* The OpenMote-CC2538 is based on the CC2538, the new platform by Texas Instruments
* based on an ARM Cortex-M3 core and a IEEE 802.15.4 radio.
* @{
*
* \file
* Main module for the OpenMote-CC2538 platform
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/sys-ctrl.h"
#include "dev/scb.h"
#include "dev/nvic.h"
#include "dev/uart.h"
#include "dev/watchdog.h"
#include "dev/ioc.h"
#include "dev/button-sensor.h"
#include "dev/serial-line.h"
#include "dev/slip.h"
#include "dev/cc2538-rf.h"
#include "dev/udma.h"
#include "dev/crypto.h"
#include "usb/usb-serial.h"
#include "lib/random.h"
#include "net/netstack.h"
#include "net/queuebuf.h"
#include "net/ip/tcpip.h"
#include "net/ip/uip.h"
#include "net/mac/frame802154.h"
#include "cpu.h"
#include "reg.h"
#include "ieee-addr.h"
#include "lpm.h"
#include <stdint.h>
#include <string.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#if STARTUP_CONF_VERBOSE
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#if UART_CONF_ENABLE
#define PUTS(s) puts(s)
#else
#define PUTS(s)
#endif
/*---------------------------------------------------------------------------*/
/** \brief Board specific iniatialisation */
void board_init(void);
/*---------------------------------------------------------------------------*/
static void
fade(unsigned char l)
{
volatile int i;
int k, j;
for(k = 0; k < 800; ++k) {
j = k > 400 ? 800 - k : k;
leds_on(l);
for(i = 0; i < j; ++i) {
asm("nop");
}
leds_off(l);
for(i = 0; i < 400 - j; ++i) {
asm("nop");
}
}
}
/*---------------------------------------------------------------------------*/
static void
set_rf_params(void)
{
uint16_t short_addr;
uint8_t ext_addr[8];
ieee_addr_cpy_to(ext_addr, 8);
short_addr = ext_addr[7];
short_addr |= ext_addr[6] << 8;
/* Populate linkaddr_node_addr. Maintain endianness */
memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE);
#if STARTUP_CONF_VERBOSE
{
int i;
printf("Rime configured with address ");
for(i = 0; i < LINKADDR_SIZE - 1; i++) {
printf("%02x:", linkaddr_node_addr.u8[i]);
}
printf("%02x\n", linkaddr_node_addr.u8[i]);
}
#endif
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Main routine for the OpenMote-CC2538 platforms
*/
int
main(void)
{
nvic_init();
ioc_init();
sys_ctrl_init();
clock_init();
lpm_init();
rtimer_init();
gpio_init();
leds_init();
fade(LEDS_RED);
process_init();
watchdog_init();
/*
* Character I/O Initialisation.
* When the UART receives a character it will call serial_line_input_byte to
* notify the core. The same applies for the USB driver.
*
* If slip-arch is also linked in afterwards (e.g. if we are a border router)
* it will overwrite one of the two peripheral input callbacks. Characters
* received over the relevant peripheral will be handled by
* slip_input_byte instead
*/
#if UART_CONF_ENABLE
uart_init(0);
uart_init(1);
uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);
#endif
#if USB_SERIAL_CONF_ENABLE
usb_serial_init();
usb_serial_set_input(serial_line_input_byte);
#endif
serial_line_init();
INTERRUPTS_ENABLE();
fade(LEDS_BLUE);
PUTS(CONTIKI_VERSION_STRING);
PUTS(BOARD_STRING);
/* Initialise the H/W RNG engine. */
random_init(0);
udma_init();
process_start(&etimer_process, NULL);
ctimer_init();
board_init();
#if CRYPTO_CONF_INIT
crypto_init();
crypto_disable();
#endif
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
memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
queuebuf_init();
process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
process_start(&sensors_process, NULL);
SENSORS_ACTIVATE(button_sensor);
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
autostart_start(autostart_processes);
watchdog_start();
fade(LEDS_GREEN);
while(1) {
uint8_t r;
do {
/* Reset watchdog and handle polls and events */
watchdog_periodic();
r = process_run();
} while(r > 0);
/* We have serviced all pending events. Enter a Low-Power mode. */
lpm_enter();
}
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -0,0 +1,252 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the ADXL346 acceleration sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
/*---------------------------------------------------------------------------*/
#include "dev/i2c.h"
#include "dev/adxl346.h"
/*---------------------------------------------------------------------------*/
/* ADDRESS AND IDENTIFIER */
#define ADXL346_ADDRESS (0x53)
#define ADXL346_DEVID_VALUE (0xE6)
/* REGISTER ADDRESSES */
#define ADXL346_DEVID_ADDR (0x00)
#define ADXL346_THRES_TAP_ADDR (0x1D)
#define ADXL346_OFSX_ADDR (0x1E)
#define ADXL346_OFSY_ADDR (0x1F)
#define ADXL346_OFSZ_ADDR (0x20)
#define ADXL346_DUR_ADDR (0x21)
#define ADXL346_LATENT_ADDR (0x22)
#define ADXL346_WINDOW_ADDR (0x23)
#define ADXL346_THRESH_ACT_ADDR (0x24)
#define ADXL346_THRESH_INACT_ADDR (0x25)
#define ADXL346_TIME_INACT_ADDR (0x26)
#define ADXL346_ACT_INACT_CTL_ADDR (0x27)
#define ADXL346_THRESH_FF_ADDR (0x28)
#define ADXL346_TIME_FF_ADDR (0x29)
#define ADXL346_TAP_AXES_ADDR (0x2A)
#define ADXL346_ACT_TAP_STATUS_ADDR (0x2B)
#define ADXL346_BW_RATE_ADDR (0x2C)
#define ADXL346_POWER_CTL_ADDR (0x2D)
#define ADXL346_INT_ENABLE_ADDR (0x2E)
#define ADXL346_INT_MAP_ADDR (0x2F)
#define ADXL346_INT_SOURCE_ADDR (0x30)
#define ADXL346_DATA_FORMAT_ADDR (0x31)
#define ADXL346_DATAX0_ADDR (0x32)
#define ADXL346_DATAX1_ADDR (0x33)
#define ADXL346_DATAY0_ADDR (0x34)
#define ADXL346_DATAY1_ADDR (0x35)
#define ADXL346_DATAZ0_ADDR (0x36)
#define ADXL346_DATAZ1_ADDR (0x37)
#define ADXL346_FIFO_CTL_ADDR (0x38)
#define ADXL346_FIFO_STATUS_ADDR (0x39)
#define ADXL346_TAP_SIGN_ADDR (0x3A)
#define ADXL346_ORIENT_CONF_ADDR (0x3B)
#define ADXL346_ORIENT_ADDR (0x3C)
/* INT_ENABLE/INT_MAP/INT_SOURCE */
#define ADXL346_INT_ENABLE_DATA_READY (1 << 7)
#define ADXL346_INT_ENABLE_SINGLE_TAP (1 << 6)
#define ADXL346_INT_ENABLE_DOUBLE_TAP (1 << 5)
#define ADXL346_INT_ENABLE_ACTIVITY (1 << 4)
#define ADXL346_INT_ENABLE_INACTIVITY (1 << 3)
#define ADXL346_INT_ENABLE_FREE_FALL (1 << 2)
#define ADXL346_INT_ENABLE_WATERMARK (1 << 1)
#define ADXL346_INT_ENABLE_OVERRUN (1 << 0)
/* ACT_INACT_CONTROL */
#define ADXL346_ACT_INACT_CTL_ACT_ACDC (1 << 7)
#define ADXL346_ACT_INACT_CTL_ACT_X_EN (1 << 6)
#define ADXL346_ACT_INACT_CTL_ACT_Y_EN (1 << 5)
#define ADXL346_ACT_INACT_CTL_ACT_Z_EN (1 << 4)
#define ADXL346_ACT_INACT_CTL_INACT_ACDC (1 << 3)
#define ADXL346_ACT_INACT_CTL_INACT_X_EN (1 << 2)
#define ADXL346_ACT_INACT_CTL_INACT_Y_EN (1 << 1)
#define ADXL346_ACT_INACT_CTL_INACT_Z_EN (1 << 0)
/* TAP_AXES */
#define ADXL346_TAP_AXES_SUPPRESS (1 << 3)
#define ADXL346_TAP_AXES_TAP_X_EN (1 << 2)
#define ADXL346_TAP_AXES_TAP_Y_EN (1 << 1)
#define ADXL346_TAP_AXES_TAP_Z_EN (1 << 0)
/* ACT_TAP_STATUS */
#define ADXL346_ACT_TAP_STATUS_ACT_X_SRC (1 << 6)
#define ADXL346_ACT_TAP_STATUS_ACT_Y_SRC (1 << 5)
#define ADXL346_ACT_TAP_STATUS_ACT_Z_SRC (1 << 4)
#define ADXL346_ACT_TAP_STATUS_ASLEEP (1 << 3)
#define ADXL346_ACT_TAP_STATUS_TAP_X_SRC (1 << 2)
#define ADXL346_ACT_TAP_STATUS_TAP_Y_SRC (1 << 1)
#define ADXL346_ACT_TAP_STATUS_TAP_Z_SRC (1 << 0)
/* BW_RATE */
#define ADXL346_BW_RATE_POWER (1 << 4)
#define ADXL346_BW_RATE_RATE(x) ((x) & 0x0F)
/* POWER CONTROL */
#define ADXL346_POWER_CTL_LINK (1 << 5)
#define ADXL346_POWER_CTL_AUTO_SLEEP (1 << 4)
#define ADXL346_POWER_CTL_MEASURE (1 << 3)
#define ADXL346_POWER_CTL_SLEEP (1 << 2)
#define ADXL346_POWER_CTL_WAKEUP(x) ((x) & 0x03)
/* DATA_FORMAT */
#define ADXL346_DATA_FORMAT_SELF_TEST (1 << 7)
#define ADXL346_DATA_FORMAT_SPI (1 << 6)
#define ADXL346_DATA_FORMAT_INT_INVERT (1 << 5)
#define ADXL346_DATA_FORMAT_FULL_RES (1 << 3)
#define ADXL346_DATA_FORMAT_JUSTIFY (1 << 2)
#define ADXL346_DATA_FORMAT_RANGE(x) ((x) & 0x03)
#define ADXL346_DATA_FORMAT_RANGE_PM_2g (0)
#define ADXL346_DATA_FORMAT_RANGE_PM_4g (1)
#define ADXL346_DATA_FORMAT_RANGE_PM_8g (2)
#define ADXL346_DATA_FORMAT_RANGE_PM_16g (3)
/*---------------------------------------------------------------------------*/
/**
*
*/
void
adxl346_init(void)
{
uint8_t config[2];
i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN,
I2C_SCL_NORMAL_BUS_SPEED);
config[0] = ADXL346_BW_RATE_ADDR;
config[1] = (ADXL346_BW_RATE_RATE(11));
i2c_burst_send(ADXL346_ADDRESS, config, sizeof(config));
config[0] = ADXL346_DATA_FORMAT_ADDR;
config[1] = (ADXL346_DATA_FORMAT_SELF_TEST |
ADXL346_DATA_FORMAT_FULL_RES |
ADXL346_DATA_FORMAT_RANGE_PM_16g);
i2c_burst_send(ADXL346_ADDRESS, config, sizeof(config));
config[0] = ADXL346_POWER_CTL_ADDR;
config[1] = (ADXL346_POWER_CTL_MEASURE);
i2c_burst_send(ADXL346_ADDRESS, config, sizeof(config));
}
/*---------------------------------------------------------------------------*/
/**
*
*/
void
adxl346_reset(void)
{
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint8_t
adxl346_is_present(void)
{
uint8_t is_present;
i2c_single_send(ADXL346_ADDRESS, ADXL346_DEVID_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &is_present);
return is_present == ADXL346_DEVID_VALUE;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
adxl346_read_x(void)
{
uint8_t acceleration[2];
uint16_t x;
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAX0_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[0]);
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAX1_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[1]);
x = (acceleration[0] << 8) | acceleration[1];
return x;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
adxl346_read_y(void)
{
uint8_t acceleration[2];
uint16_t y;
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAY0_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[0]);
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAY1_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[1]);
y = (acceleration[0] << 8) | acceleration[1];
return y;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
adxl346_read_z(void)
{
uint8_t acceleration[2];
uint16_t z;
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAZ0_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[0]);
i2c_single_send(ADXL346_ADDRESS, ADXL346_DATAZ1_ADDR);
i2c_single_receive(ADXL346_ADDRESS, &acceleration[1]);
z = (acceleration[0] << 8) | acceleration[1];
return z;
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the ADXL346 acceleration sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#ifndef __ADXL346_H__
#define __ADXL346_H__
/*---------------------------------------------------------------------------*/
void adxl346_init(void);
void adxl346_reset(void);
uint8_t adxl346_is_present(void);
uint16_t adxl346_read_x(void);
uint16_t adxl346_read_y(void);
uint16_t adxl346_read_z(void);
/*---------------------------------------------------------------------------*/
#endif /* ifndef __ADXL346_H__ */
/** @} */

View File

@ -0,0 +1,99 @@
/*
* Copyright (c) 2014, Thingsquare, http://www.thingsquare.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 platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the antenna selection on the OpenMote-CC2538 platform.
*/
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/gpio.h"
#include "dev/antenna.h"
/*---------------------------------------------------------------------------*/
#define BSP_RADIO_BASE (GPIO_D_BASE)
#define BSP_RADIO_INT (1 << 5)
#define BSP_RADIO_EXT (1 << 4)
/*---------------------------------------------------------------------------*/
static void
gpio_set(int port, int bit)
{
REG((port | GPIO_DATA) + (bit << 2)) = bit;
}
/*---------------------------------------------------------------------------*/
static void
gpio_reset(int port, int bit)
{
REG((port | GPIO_DATA) + (bit << 2)) = 0;
}
/*---------------------------------------------------------------------------*/
/**
* Configure the antenna using the RF switch
* INT is the internal antenna (chip) configured through ANT1_SEL (V1)
* EXT is the external antenna (connector) configured through ANT2_SEL (V2)
*/
void
antenna_init(void)
{
/* Configure the ANT1 and ANT2 GPIO as output */
GPIO_SET_OUTPUT(BSP_RADIO_BASE, BSP_RADIO_INT);
GPIO_SET_OUTPUT(BSP_RADIO_BASE, BSP_RADIO_EXT);
/* Select external antenna by default. */
antenna_external();
}
/*---------------------------------------------------------------------------*/
/**
* Select the external (connector) antenna
*/
void
antenna_external(void)
{
gpio_reset(BSP_RADIO_BASE, BSP_RADIO_INT);
gpio_set(BSP_RADIO_BASE, BSP_RADIO_EXT);
}
/*---------------------------------------------------------------------------*/
/**
* Select the internal (chip) antenna
*/
void
antenna_internal(void)
{
gpio_reset(BSP_RADIO_BASE, BSP_RADIO_EXT);
gpio_set(BSP_RADIO_BASE, BSP_RADIO_INT);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2014, Thingsquare, http://www.thingsquare.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 platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the antenna selection on the OpenMote-CC2538 platform.
*/
#ifndef ANTENNA_H_
#define ANTENNA_H_
/*---------------------------------------------------------------------------*/
void antenna_init(void);
void antenna_internal(void);
void antenna_external(void);
/*---------------------------------------------------------------------------*/
#endif /* ANTENNA_H_ */
/** @} */

View File

@ -0,0 +1,136 @@
/*
* 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 platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the OpenMote-CC2538 buttons
*
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/nvic.h"
#include "dev/ioc.h"
#include "dev/gpio.h"
#include "dev/button-sensor.h"
#include "sys/timer.h"
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
#define BUTTON_USER_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_USER_PORT)
#define BUTTON_USER_PIN_MASK GPIO_PIN_MASK(BUTTON_USER_PIN)
/*---------------------------------------------------------------------------*/
static struct timer debouncetimer;
/*---------------------------------------------------------------------------*/
/**
* \brief Common initialiser for all buttons
* \param port_base GPIO port's register offset
* \param pin_mask Pin mask corresponding to the button's pin
*/
static void
config(uint32_t port_base, uint32_t pin_mask)
{
/* Software controlled */
GPIO_SOFTWARE_CONTROL(port_base, pin_mask);
/* Set pin to input */
GPIO_SET_INPUT(port_base, pin_mask);
/* Enable edge detection */
GPIO_DETECT_EDGE(port_base, pin_mask);
/* Single edge */
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
/* Trigger interrupt on Falling edge */
GPIO_DETECT_RISING(port_base, pin_mask);
GPIO_ENABLE_INTERRUPT(port_base, pin_mask);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Callback registered with the GPIO module. Gets fired with a button
* port/pin generates an interrupt
* \param port The port number that generated the interrupt
* \param pin The pin number that generated the interrupt. This is the pin
* absolute number (i.e. 0, 1, ..., 7), not a mask
*/
static void
btn_callback(uint8_t port, uint8_t pin)
{
if(!timer_expired(&debouncetimer)) {
return;
}
timer_set(&debouncetimer, CLOCK_SECOND / 8);
if(port == GPIO_C_NUM) {
sensors_changed(&button_user_sensor);
}
}
/*---------------------------------------------------------------------------*/
/**
* \brief Init function for the select button.
*
* Parameters are ignored. They have been included because the prototype is
* dictated by the core sensor api. The return value is also not required by
* the API but otherwise ignored.
*
* \param type ignored
* \param value ignored
* \return ignored
*/
static int
config_user(int type, int value)
{
config(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
ioc_set_over(BUTTON_USER_PORT, BUTTON_USER_PIN, IOC_OVERRIDE_PUE);
nvic_interrupt_enable(BUTTON_USER_VECTOR);
gpio_register_callback(btn_callback, BUTTON_USER_PORT, BUTTON_USER_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/
void
button_sensor_init()
{
timer_set(&debouncetimer, 0);
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(button_user_sensor, BUTTON_SENSOR, NULL, config_user, NULL);
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,59 @@
/*
* 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 platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the OpenMote-CC2538 buttons
*
*/
#ifndef BUTTON_SENSOR_H_
#define BUTTON_SENSOR_H_
/*---------------------------------------------------------------------------*/
#include "lib/sensors.h"
#include "dev/gpio.h"
/*---------------------------------------------------------------------------*/
#define BUTTON_SENSOR "Button"
/*---------------------------------------------------------------------------*/
#define button_sensor button_user_sensor
extern const struct sensors_sensor button_user_sensor;
/*---------------------------------------------------------------------------*/
#endif /* BUTTON_SENSOR_H_ */
/** \brief Common initialiser for all SmartRF Buttons */
void button_sensor_init();
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,69 @@
/*
* 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 platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the OpenMote-CC2538 LEDs
*
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "reg.h"
#include "dev/leds.h"
#include "dev/gpio.h"
/*---------------------------------------------------------------------------*/
#define LEDS_GPIO_PIN_MASK LEDS_ALL
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,197 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the MAX44009 light sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
/*---------------------------------------------------------------------------*/
#include "dev/i2c.h"
#include "dev/max44009.h"
/*---------------------------------------------------------------------------*/
/* ADDRESS AND NOT_FOUND VALUE */
#define MAX44009_ADDRESS (0x4A)
#define MAX44009_NOT_FOUND (0x00)
/* REGISTER ADDRESSES */
#define MAX44009_INT_STATUS_ADDR (0x00) /* R */
#define MAX44009_INT_ENABLE_ADDR (0x01) /* R/W */
#define MAX44009_CONFIG_ADDR (0x02) /* R/W */
#define MAX44009_LUX_HIGH_ADDR (0x03) /* R */
#define MAX44009_LUX_LOW_ADDR (0x04) /* R */
#define MAX44009_THR_HIGH_ADDR (0x05) /* R/W */
#define MAX44009_THR_LOW_ADDR (0x06) /* R/W */
#define MAX44009_THR_TIMER_ADDR (0x07) /* R/W */
/* INTERRUPT VALUES */
#define MAX44009_INT_STATUS_OFF (0x00)
#define MAX44009_INT_STATUS_ON (0x01)
#define MAX44009_INT_DISABLED (0x00)
#define MAX44009_INT_ENABLED (0x01)
/* CONFIGURATION VALUES */
#define MAX44009_CONFIG_DEFAULT (0 << 7)
#define MAX44009_CONFIG_CONTINUOUS (1 << 7)
#define MAX44009_CONFIG_AUTO (0 << 6)
#define MAX44009_CONFIG_MANUAL (1 << 6)
#define MAX44009_CONFIG_CDR_NORMAL (0 << 5)
#define MAX44009_CONFIG_CDR_DIVIDED (1 << 5)
#define MAX44009_CONFIG_INTEGRATION_800ms (0 << 0)
#define MAX44009_CONFIG_INTEGRATION_400ms (1 << 0)
#define MAX44009_CONFIG_INTEGRATION_200ms (2 << 0)
#define MAX44009_CONFIG_INTEGRATION_100ms (3 << 0)
#define MAX44009_CONFIG_INTEGRATION_50ms (4 << 0)
#define MAX44009_CONFIG_INTEGRATION_25ms (5 << 0)
#define MAX44009_CONFIG_INTEGRATION_12ms (6 << 0)
#define MAX44009_CONFIG_INTEGRATION_6ms (7 << 0)
/* DEFAULT CONFIGURATION */
#define MAX44009_DEFAULT_CONFIGURATION (MAX44009_CONFIG_DEFAULT | \
MAX44009_CONFIG_AUTO | \
MAX44009_CONFIG_CDR_NORMAL | \
MAX44009_CONFIG_INTEGRATION_100ms)
/*---------------------------------------------------------------------------*/
/**
*
*/
void
max44009_init(void)
{
uint8_t max44009_address[5] = { MAX44009_INT_ENABLE_ADDR, MAX44009_CONFIG_ADDR, \
MAX44009_THR_HIGH_ADDR, MAX44009_THR_LOW_ADDR, \
MAX44009_THR_TIMER_ADDR };
uint8_t max44009_value[5];
uint8_t max44009_data[2];
uint8_t i;
max44009_value[0] = (MAX44009_INT_STATUS_ON);
max44009_value[1] = (MAX44009_DEFAULT_CONFIGURATION);
max44009_value[2] = (0xFF);
max44009_value[3] = (0x00);
max44009_value[4] = (0xFF);
i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN,
I2C_SCL_NORMAL_BUS_SPEED);
for(i = 0; i < sizeof(max44009_address); i++) {
max44009_data[0] = max44009_value[i];
max44009_data[1] = max44009_data[i];
i2c_burst_send(MAX44009_ADDRESS, max44009_data, 2);
}
}
/*---------------------------------------------------------------------------*/
/**
*
*/
void
max44009_reset(void)
{
uint8_t max44009_address[5] = { MAX44009_INT_ENABLE_ADDR, MAX44009_CONFIG_ADDR, \
MAX44009_THR_HIGH_ADDR, MAX44009_THR_LOW_ADDR, \
MAX44009_THR_TIMER_ADDR };
uint8_t max44009_value[5] = { 0x00, 0x03, 0xFF, 0x00, 0xFF };
uint8_t max44009_data[2];
uint8_t i;
for(i = 0; i < sizeof(max44009_address); i++) {
max44009_data[0] = max44009_value[i];
max44009_data[1] = max44009_data[i];
i2c_burst_send(MAX44009_ADDRESS, max44009_data, 2);
}
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint8_t
max44009_is_present(void)
{
uint8_t is_present;
i2c_single_send(MAX44009_ADDRESS, MAX44009_CONFIG_ADDR);
i2c_single_receive(MAX44009_ADDRESS, &is_present);
return is_present != MAX44009_NOT_FOUND;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
max44009_read_light(void)
{
uint8_t exponent, mantissa;
uint8_t max44009_data[2];
uint16_t result;
i2c_single_send(MAX44009_ADDRESS, MAX44009_LUX_HIGH_ADDR);
i2c_single_receive(MAX44009_ADDRESS, &max44009_data[0]);
i2c_single_send(MAX44009_ADDRESS, MAX44009_LUX_LOW_ADDR);
i2c_single_receive(MAX44009_ADDRESS, &max44009_data[1]);
exponent = ((max44009_data[0] >> 4) & 0x0E);
mantissa = ((max44009_data[0] & 0x0F) << 4) | (max44009_data[1] & 0x0F);
result = ((uint16_t)exponent << 8) | ((uint16_t)mantissa << 0);
return result;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
float
max44009_convert_light(uint16_t lux)
{
uint8_t exponent, mantissa;
float result = 0.045;
exponent = (lux >> 8) & 0xFF;
exponent = (exponent == 0x0F ? exponent & 0x0E : exponent);
mantissa = (lux >> 0) & 0xFF;
result *= 2 ^ exponent * mantissa;
return result;
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the MAX44009 light sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#ifndef __MAX44009_H__
#define __MAX44009_H__
/*---------------------------------------------------------------------------*/
void max44009_init(void);
void max44009_reset(void);
uint8_t max44009_is_present(void);
uint16_t max44009_read_light(void);
float max44009_convert_light(uint16_t light);
/*---------------------------------------------------------------------------*/
#endif /* ifndef __MAX44009_H__ */
/** @} */

View File

@ -0,0 +1,208 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the SHT21 temperature and humidity sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
/*---------------------------------------------------------------------------*/
#include "i2c.h"
#include "sht21.h"
/*---------------------------------------------------------------------------*/
#define SHT21_ADDRESS (0x40)
#define SHT21_USER_REG_READ (0xE7)
#define SHT21_USER_REG_WRITE (0xE6)
#define SHT21_USER_REG_RESERVED_BITS (0x38)
#define SHT21_RESOLUTION_12b_14b ((0 << 7) | (0 << 0))
#define SHT21_RESOLUTION_8b_12b ((0 << 7) | (1 << 0))
#define SHT21_RESOLUTION_10b_13b ((1 << 7) | (0 << 0))
#define SHT21_RESOLUTION_11b_11b ((1 << 7) | (1 << 0))
#define SHT21_BATTERY_ABOVE_2V25 (0 << 6)
#define SHT21_BATTERY_BELOW_2V25 (1 << 6)
#define SHT21_ONCHIP_HEATER_ENABLE (1 << 2)
#define SHT21_ONCHIP_HEATER_DISABLE (0 << 2)
#define SHT21_OTP_RELOAD_ENABLE (0 << 1)
#define SHT21_OTP_RELOAD_DISABLE (1 << 1)
#define SHT21_TEMPERATURE_HM_CMD (0xE3)
#define SHT21_HUMIDITY_HM_CMD (0xE5)
#define SHT21_TEMPERATURE_NHM_CMD (0xF3)
#define SHT21_HUMIDITY_NHM_CMD (0xF5)
#define SHT21_RESET_CMD (0xFE)
#define SHT21_STATUS_MASK ( 0xFC )
#define SHT21_DEFAULT_CONFIG (SHT21_RESOLUTION_12b_14b | \
SHT21_ONCHIP_HEATER_DISABLE | \
SHT21_BATTERY_ABOVE_2V25 | \
SHT21_OTP_RELOAD_DISABLE)
#define SHT21_USER_CONFIG (SHT21_RESOLUTION_8b_12b | \
SHT21_ONCHIP_HEATER_DISABLE | \
SHT21_BATTERY_ABOVE_2V25 | \
SHT21_OTP_RELOAD_DISABLE)
/*---------------------------------------------------------------------------*/
/**
*
*/
void
sht21_init(void)
{
uint8_t config[2];
i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN,
I2C_SCL_NORMAL_BUS_SPEED);
/* Setup the configuration vector, the first position holds address */
/* and the second position holds the actual configuration */
config[0] = SHT21_USER_REG_WRITE;
config[1] = 0;
/* Read the current configuration according to the datasheet (pag. 9, fig. 18) */
i2c_single_send(SHT21_ADDRESS, SHT21_USER_REG_READ);
i2c_single_receive(SHT21_ADDRESS, &config[1]);
/* Clean all the configuration bits except those reserved */
config[1] &= SHT21_USER_REG_RESERVED_BITS;
/* Set the configuration bits without changing those reserved */
config[1] |= SHT21_USER_CONFIG;
i2c_burst_send(SHT21_ADDRESS, config, sizeof(config));
}
/*---------------------------------------------------------------------------*/
/**
*
*/
void
sht21_reset(void)
{
/* Send a soft-reset command according to the datasheet (pag. 9, fig. 17) */
i2c_single_send(SHT21_ADDRESS, SHT21_RESET_CMD);
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint8_t
sht21_is_present(void)
{
uint8_t is_present;
/* Read the current configuration according to the datasheet (pag. 9, fig. 18) */
i2c_single_send(SHT21_ADDRESS, SHT21_USER_REG_READ);
i2c_single_receive(SHT21_ADDRESS, &is_present);
/* Clear the reserved bits according to the datasheet (pag. 9, tab. 8) */
is_present &= ~SHT21_USER_REG_RESERVED_BITS;
is_present = ((is_present == SHT21_USER_CONFIG) || (is_present == SHT21_DEFAULT_CONFIG));
return is_present;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
sht21_read_temperature(void)
{
uint8_t sht21_temperature[2];
uint16_t temperature;
/* Read the current temperature according to the datasheet (pag. 8, fig. 15) */
i2c_single_send(SHT21_ADDRESS, SHT21_TEMPERATURE_HM_CMD);
i2c_burst_receive(SHT21_ADDRESS, sht21_temperature, sizeof(sht21_temperature));
temperature = (sht21_temperature[0] << 8) | (sht21_temperature[1] & SHT21_STATUS_MASK);
return temperature;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
float
sht21_convert_temperature(uint16_t temperature)
{
float result;
result = -46.85;
result += 175.72 * (float) temperature / 65536.0;
return result;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
uint16_t
sht21_read_humidity(void)
{
uint8_t sht21_humidity[2];
uint16_t humidity;
/* Read the current humidity according to the datasheet (pag. 8, fig. 15) */
i2c_single_send(SHT21_ADDRESS, SHT21_HUMIDITY_HM_CMD);
i2c_burst_receive(SHT21_ADDRESS, sht21_humidity, sizeof(sht21_humidity));
humidity = (sht21_humidity[0] << 8) | (sht21_humidity[1] & SHT21_STATUS_MASK);
return humidity;
}
/*---------------------------------------------------------------------------*/
/**
*
*/
float
sht21_convert_humidity(uint16_t humidity)
{
float result;
result = -6.0;
result += 125.0 * (float) humidity / 65536.0;
return result;
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the SHT21 temperature and humidity sensor in OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#ifndef __SHT21_H__
#define __SHT21_H__
/*---------------------------------------------------------------------------*/
void sht21_init(void);
void sht21_reset(void);
uint8_t sht21_is_present(void);
uint16_t sht21_read_temperature(void);
float sht21_convert_temperature(uint16_t temperature);
uint16_t sht21_read_humidity(void);
float sht21_convert_humidity(uint16_t humidity);
/*---------------------------------------------------------------------------*/
#endif /* ifndef __SHT21_H__ */
/** @} */

View File

@ -0,0 +1,53 @@
/*
* 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 platform
* @{
*
* \defgroup openmote
*
* \file
* Implementation of a generic module controlling OpenMote-CC2538 sensors.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/button-sensor.h"
#include <string.h>
/*---------------------------------------------------------------------------*/
/**
*\brief Exports a global symbol to be used by the sensor API
*/
SENSORS(&button_user_sensor);
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Driver for the TPS62730 voltage regulator on the OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/gpio.h"
#include "dev/tps62730.h"
/*---------------------------------------------------------------------------*/
#define BSP_TPS62730_BASE (GPIO_B_BASE)
#define BSP_TPS62730_ON (1 << 1)
#define BSP_TPS62730_STATUS (1 << 0)
/*---------------------------------------------------------------------------*/
static void
gpio_set(int port, int bit)
{
REG((port | GPIO_DATA) + (bit << 2)) = bit;
}
/*---------------------------------------------------------------------------*/
static void
gpio_reset(int port, int bit)
{
REG((port | GPIO_DATA) + (bit << 2)) = 0;
}
/*---------------------------------------------------------------------------*/
/**
* Initializes the TPS62730 voltage regulator
* By default it is in bypass mode, Vout = Vin, Iq < 1 uA
*/
void
tps62730_init(void)
{
GPIO_SET_OUTPUT(BSP_TPS62730_BASE, BSP_TPS62730_ON);
GPIO_SET_INPUT(BSP_TPS62730_BASE, BSP_TPS62730_STATUS);
tps62730_bypass();
}
/*---------------------------------------------------------------------------*/
/**
* Enables the TPS62730, Vout = 2.2V, Iq = 30 uA
*/
void
tps62730_on(void)
{
gpio_set(BSP_TPS62730_BASE, BSP_TPS62730_ON);
}
/*---------------------------------------------------------------------------*/
/**
* Disables the TPS62730, Vout = Vin, Iq < 1 uA
*/
void
tps62730_bypass(void)
{
gpio_reset(BSP_TPS62730_BASE, BSP_TPS62730_ON);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2014, OpenMote Technologies, S.L.
* 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.
*
*/
/**
* \addtogroup platform
* @{
*
* \defgroup openmote
*
* \file
* Header for the TPS62730 voltage regulator on the OpenMote-CC2538.
*
* \author
* Pere Tuset <peretuset@openmote.com>
*/
#ifndef TPS62730_H_
#define TPS62730_H_
/*---------------------------------------------------------------------------*/
void tps62730_init(void);
void tps62730_on(void);
void tps62730_bypass(void);
/*---------------------------------------------------------------------------*/
#endif /* TPS62730_H_ */
/** @} */