Sensor monitor program for IO boards.
iomon/lib contains modified, simplified versions of Atmel Software Framework
peripheral drivers. Insofar as possible, unused code and functionality has
been removed; particular remaining areas of bloat include the ADCIFA driver
and the various clock drivers.
iomon/src contains the main program code, divided into files mainly by
peripheral device or support function:
cobsr.cis a serial framing protocol which encodes data packets to ensure null bytes are never found in the content, so they can be used as packet delimiters;
comms.cis the primary serial driver code for sensor monitor output and control input;
crc8.cimplements 8-bit, lookup-table-based CRC calculation;
gp.cimplements ADC and GPIO interfaces;
hmc5883.cimplements an I2C driver for the Honeywell HMC5883L 3-axis magnetometer;
i2cdevice.cprovides a framework for writing I2C device drivers, allowing initialization and read command sequences to be defined as data structures, and handling timeouts and power-down/reset logic;
main.ccontains the main entry point, initialization routine and event loop;
mpu6050.cis an I2C driver for the Invensense MPU-6050 3-axis accelerometer/gyro;
ms5611.cis an I2C driver for the Measurement Specialties MS5611 barometric pressure/temperature sensor;
pwm.cimplements PWM management in response to packets received from the CPU interface;
twim_pdca.cis used by
i2cdevice.cand the various I2C drivers to handle I2C "transactions" (write/read sequences) and DMA-based I2C commands;
ubx_gps.cis a USART-based driver for the u-blox UBX binary protocol.
iomon program is an event loop which aggregates data received from
devices via I2C, SPI, UART, ADC and GPIO interfaces, and transmits
it in packets to a processing device. No interrupts are used, and the
per-packet processing time is guaranteed to be less than 1ms.
Each sensor has a device driver responsible for initializing it (the
*_init(void) procedures) and reading its output (the
procedures). Device driver tick procedures are called every millisecond, and
generally implement a state machine that handles:
- Detection of timeout/error conditions;
- Cycling the device power enable to ensure a hard reset;
- Start-up configuration;
- The primary read sequence and any conversions necessary to obtain usable data.
After sensor data is read, it is written to the output parameter log; at the end of the event loop, the packet is sent via the UART.
The primary configuration mechanism is the board header file, in
iomon/src/boards. These header files provide a mapping of all MCU pins to
the appropriate functions, as well as assignments between internal AVR32
peripherals and the external devices. The board file in use is determined by
The UBX driver requires that the GPS module has been configured appropriately, and the configuration has been saved to Flash. The required settings are:
CFG GNSS: Disable SBAS and QZSS
CFG MSG: Enable NAV PVT on UART1
CFG NAV5: Set dynamics mode to
CFG PRT: Set UART1 to UBX in, UBX out, 921600 baud
CFG RATE: Set measurement period to 250ms (or 100ms if supported)
CFG CFG: save to flash
Requires AVR Studio 6. Configure project for AT32UC3C; 1512 part is currently used but could probably run on any 0* or 1* part.
Only via JTAG at this stage; just flash the MCU using whatever Atmel programmer is convenient.
USB DFU bootloader might be added later depending on how frequently we need to re-flash in the field.
GPS configuration requires u-blox u-center
- Connect CPU board cable to 8-pin port;
- Connect cable harness to 30-pin port.