HAB-3/Software Development

From EARS Wiki
Jump to: navigation, search

The software is split into three layers, to make the high level services easy to implement, allow portable code between this and other EARS projects, and give people lots of things to work on.

Layered software architecture example

APL::IMU is a module that is responsible for decoding the data from the inertial sensors on the board. The sensor is on the I2C bus. This module defines an externally visible data structure or set of functions to enable other application modules to use the data it has decoded. Internally, it defines a class derived from ASL::I2C::I2CDevice that allows communication with a specific peripheral. ASL::I2C provides the logic for doing this, enabling abstracted multi-byte reads and removing the need to manually push addresses and commands out from application logic. ASL::I2C uses the hooks provided by HAL::I2C to actually transmit and receive data.

Good tasks to take on

The modules below are suggested for people relatively new to development. If you need any help or have questions, get in touch with James Telfer on the forums, Facebook, or by email.

New to electronics

  • ASL::GPS (NMEA decoding function) - Basic string manipulation.
  • ASL::USM, ASL::SPM, ASL::ICM - Basic understanding of serial and bus communication systems. Descriptions below and Google should be enough to get you kicking!

Previous experience with microcontrollers, but not extensive programming knowledge

  • Everything in HAL aside from DMA and TMR.

Application Layer (APL::XYZ)

The application level contains all of the configuration and processing code specific to the HAB project. APL level code uses the ASL and HAL modules, not the microcontroller interfaces. This means should it be ported to mBed or another device platform, the changes required to support the hardware change are small in scope.

GPS - Global Positioning System Interface

Uses USM to talk to the on-board GPS module. and NMP to decode the returned string.

SEN - Sensors and Inputs

Handles decoding of data from the gyro/accel using ICM, and the temperature sensors using ICM/SPM and ADC.

Application Support Layer (ASL::XYZ)

The support layer contains interfaces for peripherals and other useful parts of the project that do not depend directly on the hardware but are not HAB-specific.

NMP - NMEA Parser

Decodes an NMEA string and returns a structure filled with fun and useful data.

SCH - Scheduler (LOW PRIORITY)

The scheduler is a way to queue up tasks and have them executed once with a given time offset or repeating with a specified period.

ICM - I2C Manager

The I2C interface provides a class and set of functions for working with devices on an I2C bus.

SPM - Serial Peripheral Manager

The SPI interface provides a class and set of functions for working with devices on an SPI bus.

USM - Universal Serial Manager

Provides a nice big (potentially circular) buffer interface and handles the RX/TX interrupt loops.

ADM - Analog to Digital Manager

Provides a named channel interface and allows access to current, de-bounced, and filtered views for each channel. Allows en/disabling of filtering and debouncing per channel.

enum Channel { ... };
enum Operation { Raw, Filter, Debounce };
class AdcChannel {
    void configure (bool reset, Operation op);
    Operation getOp();
    void setEnable (bool enable);
    bool getEnable ();
    uint32 getValue();
void configureModule();
AdcChannel& getChannel (Channel ch); 

FMC - Flash Memory Controller (LOW PRIORITY)

Provides an interface to read/write things from flash memory.

Hardware Abstraction Layer (HAL::XYZ)

The abstraction layer is not much more than a nicely formatted wrapper for the device header file, with some niceties for interacting with specific peripherals. Some files similar to HAL modules are provided along with the microcontroller development environment. These are not being used due to the different style and language they are implemented in.

ADC - Analog to Digital Converter

Provides access to set enable and sample for specific numbered channels. Responsible for ADC configuration and calibration. Also configures the ADC's DMA.

WDT - Watchdog Timer

EFM - Embedded Flash Memory (LOW PRIORITY)

I2C - I2C interface

void configureModule();
void configureTransaction(uint8 address, bool write, uint8 numBytes);
void startTransaction();

SPI - SPI interface

URT - USART/UART interface

RTC - Real time clock (LOW PRIORITY)

TMR - Timer interface

GIO - Digital Input/Output control

PWM - Pulse Width Modulation

CRC - Cyclic Redundancy Check Engine

DMA - Direct Memory Access

enum Channel { ... };
enum Priority { ... };
void configureModule();
void enableChannel(Channel channel, uint32* sourceAddress, uint32* targetAddress, uint16 numBytes);

EIC - Exception and Interrupt Control