EV Logger
A MSP430 based datalogger for an electric vehicle
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
logger.h File Reference

Logger header. More...

#include <stdio.h>
#include <msp430.h>
#include <msp430f5529.h>
#include <legacymsp430.h>
#include "typedefs.h"
#include "ff.h"

Go to the source code of this file.

Data Structures

struct  RingBuffer
 A ring buffer which can be attached to given (preallocated) memory area. More...
 
struct  SampleBuffer
 A structure to contain one 'set' of samples from the vehicle. More...
 

Macros

#define S1_PORT_OUT   P1OUT
 
#define S1_PORT_REN   P1REN
 
#define S1_PORT_IES   P1IES
 
#define S1_PORT_IE   P1IE
 
#define S1_PORT_IFG   P1IFG
 
#define S1_PIN   _BV(7)
 
#define S2_PORT_OUT   P2OUT
 
#define S2_PORT_REN   P2REN
 
#define S2_PORT_IES   P2IES
 
#define S2_PORT_IE   P2IE
 
#define S2_PORT_IFG   P2IFG
 
#define S2_PIN   _BV(2)
 
#define SD_RINGBUF_LEN   2048
 Ring buffer length for the SD card, should be a multiple of 2 of the sector size (512 bytes)
 
#define SD_RINGBUF_MASK   (SD_RINGBUF_LEN - 1)
 The ring buffer mask value. More...
 
#define ADC_CHANNELS   7
 The number of ADC channels that we will sample from. More...
 
#define ACCEL_CHANNELS   3
 The number of accelerometer channels (typically 3) to be sampled from. More...
 

Typedefs

typedef struct RingBuffer RingBuffer
 
typedef struct SampleBuffer SampleBuffer
 

Functions

void logger_init (void)
 Set up the hardware for logging functionality, including the configuration of required peripherals such as the ADC and Accelerometer. More...
 
void start_logger (RingBuffer *sdbuf)
 Set up the SD card and the FATFS filesystem handler before commencing the logging service. More...
 
FRESULT sd_write (RingBuffer *rb, char *writebuf, FIL *fil, uint16_t n)
 Write n bytes from a ring buffer to an SD card controlled by fatfs. More...
 
uint8_t ringbuf_write (RingBuffer *buf, char *data, uint16_t n)
 Write n bytes to a RingBuffer. More...
 
uint8_t ringbuf_read (RingBuffer *buf, char *read_buffer, uint16_t n)
 Read n bytes from a ring buffer. More...
 
void update_lcd (RingBuffer *buf)
 Update the LCD with the current status of the logger, including buffer usage, data file size and SD card utilisation. More...
 
void logger_enable (void)
 Enable TA1 to begin logging by setting mode control to "up" mode, counter counts to TAxCCR0. More...
 
void logger_disable (void)
 Disable TA1 to halt logging by setting mode control to STOP. More...
 

Detailed Description

Logger header.

Author
Jon Sowman, University of Southampton j.sow.nosp@m.man@.nosp@m.soton.nosp@m..ac..nosp@m.uk