56#define SWEEP_OFFSET 500
57#define RAM_BUFFER_DELAY 10
67#define SHIELD_NUMBER 5
75#define SWEEP_DELAY 46.875
76#define SWEEP_AVERAGES 8
121#define IMU_TIMESTAMP_OFFSET 0
122#define IMU_DATA_OFFSET (sizeof(IMUTimeStamp) + IMU_TIMESTAMP_OFFSET)
123#define SWEEP_TIMESTAMP_OFFSET (sizeof(IMUData) + IMU_DATA_OFFSET)
124#define SWEEP_DATA_OFFSET (sizeof(sweepTimeStamp) + SWEEP_TIMESTAMP_OFFSET)
125#define RAM_BUF_LEN (sizeof(IMUTimeStamp) + sizeof(IMUData) + sizeof(sweepTimeStamp) + sizeof(sweep_buffer))
174 Serial.begin(230400);
189 pinMode(LED_BUILTIN, OUTPUT);
190 digitalWrite(LED_BUILTIN, LOW);
192 Serial.begin(230400);
242 volatile uint32_t irq_state = __get_PRIMASK();
252 __set_PRIMASK(irq_state);
393 digitalWrite(LED_BUILTIN, HIGH);
395 digitalWrite(LED_BUILTIN, LOW);
408 TC_GetStatus(TC0, 0);
410 if (micros() -
timer >= SAMPLE_PERIOD) {
433 pmc_enable_periph_clk(ID_TC0);
439 TC_Configure(TC0, 0, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
442 TC_SetRC(TC0, 0, 64.625);
445 TC0->TC_CHANNEL[0].TC_IER = TC_IER_CPCS;
447 TC0->TC_CHANNEL[0].TC_IDR = ~TC_IER_CPCS;
448 NVIC_EnableIRQ(TC0_IRQn);
449 NVIC_SetPriority(TC0_IRQn, 0);
467 digitalWrite(6, HIGH);
471 digitalWrite(6, LOW);
Provides a library to interact with Microchip's AT25M02 chip. This treats the chip as a circular queu...
void initIMU(LIS3MDL *mag, LSM6 *gyro_acc)
void sampleIMU(LIS3MDL *mag, LSM6 *imu, int16_t *data)
Header file for the IMU library for Dartmouth's 317 Lab.
Header file for the PDC library for Dartmouth's 317 Lab.
Header file for the Pip library for Dartmouth's 317 Lab.
Interfaces with the AT25M02 EEPROM chip.
int readData(byte *dest, uint32_t length)
Write the given number of bytes from the ram into the destination array. These bytes are taken from t...
void init()
Initialize the AT25M02 EEPROM device. Define spi settings, chip select pin, and set initial variables...
bool writeData(byte *bytes, uint32_t length)
Write from the given array to the memory. This data is appended to the end of the queue....
uint32_t usedBytes()
Returns the number of bytes currently being used.
Manages interfacing with Max1148 ADC.
Manages UART transmits through peripheral DMA controller (PDC).
void init()
Turns on PDC, waits until ready. Must be called AFTER Serial.begin() in setup().
void send(T *buffer, int size)
Adds data to the PDC buffer to be sent out through UART.
Manages simultaneous sweep for two Pip sensors. A bit hacky, but allows easily managing simultaneous ...
void sweep()
Sweeps both DACs simultaneously, reads both ADC channels. Note that ADC sampling alternates between e...
Manages the Pip sensor sweep and associated data.
uint16_t data[SWEEP_MAX_SAMPLES]
The data array for the sweep.
Pip pip0(SWEEP_DELAY, SWEEP_AVERAGES, SWEEP_STEPS, 339, 3752, DAC0, adc0)
bool goLow
Interrupt handler for the TC0 timer.
void FSMAction()
Finite State Machine action function.
PipController pipController(pip0, pip1)
uint8_t memory_block[totalSize]
void configureTimerInterrupt()
Configures timer counter for interrupt Documentation for internal functions - see tc....
void blink()
Blinks the onboard LED. Used for debugging.
uint8_t sweepSentinelBuf[3]
#define SWEEP_TIMESTAMP_OFFSET
uint16_t sweep_buffer[2 *SWEEP_STEPS]
uint8_t ramBuf[RAM_BUF_LEN]
Pip pip1(SWEEP_DELAY, SWEEP_AVERAGES, SWEEP_STEPS, 339, 3752, DAC1, adc1)
void startSweepOnShield()
Attaches last data buffer to UART PDC, runs DAC sweep, and saves pip data into a combined buffer.
void FSMUpdate()
Finite State Machine update function.
uint32_t * p_IMUTimeStamp
Max1148 adc0(Channel::CHAN2)
uint8_t imuSentinelBuf[3]
#define IMU_TIMESTAMP_OFFSET
Max1148 adc1(Channel::CHAN1)
#define SWEEP_DATA_OFFSET
uint32_t * p_sweepTimeStamp