16 #include <msp430f5529.h>
17 #include <legacymsp430.h>
21 #define S1_PORT_OUT P1OUT
22 #define S1_PORT_REN P1REN
23 #define S1_PORT_IES P1IES
24 #define S1_PORT_IE P1IE
25 #define S1_PORT_IFG P1IFG
28 #define S2_PORT_OUT P2OUT
29 #define S2_PORT_REN P2REN
30 #define S2_PORT_IES P2IES
31 #define S2_PORT_IE P2IE
32 #define S2_PORT_IFG P2IFG
39 #define SD_RINGBUF_LEN 2048
44 #define SD_RINGBUF_MASK (SD_RINGBUF_LEN - 1)
76 #define ADC_CHANNELS 7
82 #define ACCEL_CHANNELS 3
#define ACCEL_CHANNELS
The number of accelerometer channels (typically 3) to be sampled from.
Definition: logger.h:82
uint16_t head
A pointer to the head of the ring buffer (the next free byte available for writing).
Definition: logger.h:68
void logger_enable(void)
Enable TA1 to begin logging by setting mode control to "up" mode, counter counts to TAxCCR0...
Definition: logger.c:411
uint16_t mask
This value is a ring buffer intrinsic and is automatically generated.
Definition: logger.h:68
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.
Definition: logger.c:295
A structure to contain one 'set' of samples from the vehicle.
Definition: logger.h:92
void logger_disable(void)
Disable TA1 to halt logging by setting mode control to STOP.
Definition: logger.c:433
uint16_t len
The length of the ring buffer.
Definition: logger.h:68
A ring buffer which can be attached to given (preallocated) memory area.
Definition: logger.h:65
uint8_t overflow
A flag that will be set non-zero if a buffer overflow occurs (the head tries to "overtake" the tail...
Definition: logger.h:69
void logger_init(void)
Set up the hardware for logging functionality, including the configuration of required peripherals su...
Definition: logger.c:80
volatile uint16_t adc[ADC_CHANNELS]
Storage for the ADC channels.
Definition: logger.h:94
void start_logger(RingBuffer *sdbuf)
Set up the SD card and the FATFS filesystem handler before commencing the logging service...
Definition: logger.c:194
uint8_t ringbuf_read(RingBuffer *buf, char *read_buffer, uint16_t n)
Read n bytes from a ring buffer.
Definition: logger.c:371
uint16_t tail
A pointer to the tail of the ring buffer (the next unread byte)
Definition: logger.h:68
void update_lcd(RingBuffer *buf)
Update the LCD with the current status of the logger, including buffer usage, data file size and SD c...
Definition: logger.c:145
static RingBuffer sdbuf
A RingBuffer that we will use to buffer sets of samples that are to be moved to the SD card...
Definition: logger.c:55
Standard data type shorthand defined as with avr-libc.
FIL fil
A pointer to the data file.
Definition: logger.c:65
#define ADC_CHANNELS
The number of ADC channels that we will sample from.
Definition: logger.h:76
volatile uint16_t accel[ACCEL_CHANNELS]
Storage for the accelerometer channels.
Definition: logger.h:95
char * buffer
A pointer to the start of the character buffer to be used by this ring buffer.
Definition: logger.h:67
uint8_t ringbuf_write(RingBuffer *buf, char *data, uint16_t n)
Write n bytes to a RingBuffer.
Definition: logger.c:325