-
Notifications
You must be signed in to change notification settings - Fork 16
Development Concepts
Every software for the Jennisense consists of two parts. The hardware platform and the application.
The hardware platform includes the sensor definitions, the pin mapping for the sensors and the configuration for contiki. Existing hardware platforms can be found @ JENNISENSE_PATH/contiki-jn51xx/platform/. For example the jndevkit (Jennic demo board).
The application contains the contiki processes, which can use the defined sensors of the hardware platform. Existing applications can be found @ JENNISENSE_PATH/applications/. An application is independent of the hardware platform and can be compiled for each one, as long as the necessary sensors are available.
After the toolchain is installed as described in the getting started, an application can be compiled by following steps.
cd JENNISENSE_PATH/applications/ethbridge make TARGET=jnusb ethbridge.u
The TARGET defines the used hardware platform. Make will compile the application and uses jenprog for serial programming. If another programming method is needed you can use following commands.
make TARGET=jnusb ethbridge ba-elf-objcopy ethbridge.jnusb -O binary ethbridge.jnusb.hex
The resulting HEX file can be used with jenprog.
A basic application has following design:
#include "contiki.h"
#include "dev/leds.h"
PROCESS(basis_process, "basis process"); //process definition
AUTOSTART_PROCESSES(&basis_process); //processes wich will be executed at startup
PROCESS_THREAD(basis_process, ev, data) //process implementation
{
PROCESS_BEGIN();
PROCESS_PAUSE();
while(1)
{
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
//do something
}
PROCESS_END();
}
AUTOSTART_PROCESSES can contain more then one process for example: AUTOSTART_PROCESSES(&basis_process, &another_process);
Here a simple example of a process, which is using the button sensor. The button is checked every 100ms. It is important that process objects are static. Otherwise it won't work. The function sensors_find(SENSOR_NAME) returns a handle to the sensor. With the handle, the sensor can be configured and used.
PROCESS_THREAD(sensor_process, ev, data)
{
static struct sensors_sensor *button_sensor; //sensor object
static struct etimer et; //timer for yield
PROCESS_BEGIN();
PROCESS_PAUSE();
button_sensor = sensors_find(BUTTON_SENSOR); //get handle of sensor
button_sensor->configure(SENSORS_ACTIVE, 1); //activate sensor
etimer_set(&et, CLOCK_SECOND/10);
while (1)
{
if (button_sensor->value(0)) //read sensor
{
//button is pressed
}
etimer_reset(&et);
PROCESS_YIELD_UNTIL(ev==PROCESS_EVENT_TIMER);
}
PROCESS_END();
}
CONTIKI_PROJECT = main all: $(CONTIKI_PROJECT) CONTIKI_TARGET_SOURCEFILES = *additional sourcefiles* UIP_CONF_IPV6=1 DEFINES=WITH_UIP6 CONTIKI = ../../contiki-jn51xx include $(CONTIKI)/Makefile.include
CONTIKI_PROJECT must define the main C source file. Additional source files can be defined with CONTIKI_TARGET_SOURCEFILES.