-130-
v6.3
Working environment
26.3. API
An API (Application Programming Interface) has been developed to facilitate applications programming using Waspmote. This
API includes all the modules integrated in Waspmote, as well as the handling of other functionalities such as interruptions or
the different energy modes.
The API has been developed in C/C++, structured in the following way:
core
folder and
libraries
folder.
26.3.1. Cores folder
The
‘hardware/cores’
folder contains the different source cores folders (boards) which might be selected in the IDE window.
The core folder contains the general API files which are always compiled, such as:
General configuration
Files: WaspClasses.h, WaspVariables.h, WaspConstants.h, Wconstants.h, pins_waspmote.h, pins_waspmote.c, WaspUtils.h, WaspUtils.
cpp, WProgram.h
The basis for correct API operation is defined in these files.
1. WaspClasses.h: all the types to be run on the Waspmote API are defined. If any new type wants to be added, it will be necessary
to include it in this file for correct compilation.
2. WaspVariables.h: 4 global variables used as flags for interruptions are defined. These variables are accessible from the files in
C, C++ or the main code in the Waspmote compiler.
3. WaspConstants.h: multiple general constants used in the API are defined, as well as all the pins and constants related to the
interruptions.
4. Wconstants.h: more constants are defined.
5. pins_waspmote.h, pins_waspmote.c: the microcontroller’s pins and the names to which they are associated are defined.
6. WaspUtils.h, WaspUtils.cpp: series of functions for generic use such as light up LEDs, number conversions, strings handling,
EEPROM memory, etc.
7. Waspmote.h: is the file which runs when launching the Waspmote compiler. WaspClasses.h and WaspVariables.h are included
in it.
Shared
Files: binary.h, HardwareSerial.h, HardwareSerial.cpp, WaspRegisters.h, WaspRegisters.c, wiring_analog.c, wiring.h, wiring.c, wiring_
digital.c, wiring_private.h, wiring_pulse.c, wiring_serial.c, wiring_shift.c
Generic functions used are defined in these files, such as the treatment of number types, writing in the UARTs, etc.
SD Storage
Files: Sd2Card.h, Sd2Card.cpp, Sd2Fat.h, Sd2FatStructs.h, Sd2File.cpp, Sd2Info.h, Sd2PinMap.h, Sd2Volume.cpp, WaspSD.h, WaspSD.
cpp
The functions needed for storing writing and reading the SD card are defined in these files.
•
Sd2Card.h, Sd2Card.cpp, Sd2Fat.h, Sd2FatStructs.h, Sd2File.cpp, Sd2Info.h, Sd2PinMap.h, Sd2Volume.cpp: files that ma-
nage the SD card at a low level.
•
WaspSD.h, WaspSD.cpp: files that define the necessary functions to read and write information on the SD card.
I2C communication
Files: twi.h, twi.c, Wire.h, Wire.cpp
The functions needed for communication using the I2C bus. These functions are subsequently used by the modules which work
with the I2C, such as the accelerometer, the RTC and the sensors.