Shield Code 6.0
|
Main file for the 317 lab project. More...
#include <Arduino.h>
#include <Pip.hpp>
#include <PDC.hpp>
#include <AT25M02.hpp>
#include <PipController.hpp>
#include <IMU.hpp>
#include <Wire.h>
#include <LSM6.h>
#include <LIS3MDL.h>
#include "sweep_values_v5_1.h"
Go to the source code of this file.
Macros | |
#define | BUFFER 1000 |
#define | SWEEP_OFFSET 500 |
#define | RAM_BUFFER_DELAY 10 |
#define | SWEEP_STEPS 28 |
#define | SHIELD_NUMBER 5 |
#define | SWEEP_DELAY 46.875 |
#define | SWEEP_AVERAGES 8 |
#define | IMU_TIMESTAMP_OFFSET 0 |
#define | IMU_DATA_OFFSET (sizeof(IMUTimeStamp) + IMU_TIMESTAMP_OFFSET) |
#define | SWEEP_TIMESTAMP_OFFSET (sizeof(IMUData) + IMU_DATA_OFFSET) |
#define | SWEEP_DATA_OFFSET (sizeof(sweepTimeStamp) + SWEEP_TIMESTAMP_OFFSET) |
#define | RAM_BUF_LEN (sizeof(IMUTimeStamp) + sizeof(IMUData) + sizeof(sweepTimeStamp) + sizeof(sweep_buffer)) |
#define | SYNC_PIN 53 |
Enumerations | |
enum | BobState { idle , startSweep , sendSweep , takeIMU , sendIMU , sendStored , sendTimeStamps , waitForNewCycle , interrupted , store , read } |
Functions | |
void | blink () |
Blinks the onboard LED. Used for debugging. | |
void | configureTimerInterrupt () |
Configures timer counter for interrupt Documentation for internal functions - see tc.c (system/libsam/source/tc.c at https://github.com/swallace23/framework-arduino-sam) The processor has 3 clocks, each have 3 channels and 3 registers (RA, RB, RC). This is set up to use TC0 and channel 0. RC is used to store the compare value. The interrupt is triggered when the counter reaches the compare value. Calculate interrupt frequency with: interrupt frequency = clock frequency / (RC+1) Note that the clock frequency for TC0 is configured to be 656.25 kHz. | |
void | syncHandler () |
void | FSMUpdate () |
Finite State Machine update function. | |
void | FSMAction () |
Finite State Machine action function. | |
void | startSweepOnShield () |
Attaches last data buffer to UART PDC, runs DAC sweep, and saves pip data into a combined buffer. | |
void | sendIMUData () |
void | sendSweepData () |
void | takeIMUData () |
void | sendStoredData () |
void | storeData () |
void | readData () |
void | sendData () |
void | setup () |
void | loop () |
void | TC0_Handler () |
Main file for the 317 lab project.
Contains shield initialization, state machine implementation and functions, and interrupt handling.
Definition in file main.cpp.
#define IMU_DATA_OFFSET (sizeof(IMUTimeStamp) + IMU_TIMESTAMP_OFFSET) |
#define RAM_BUF_LEN (sizeof(IMUTimeStamp) + sizeof(IMUData) + sizeof(sweepTimeStamp) + sizeof(sweep_buffer)) |
#define SWEEP_DATA_OFFSET (sizeof(sweepTimeStamp) + SWEEP_TIMESTAMP_OFFSET) |
#define SWEEP_TIMESTAMP_OFFSET (sizeof(IMUData) + IMU_DATA_OFFSET) |
enum BobState |
void configureTimerInterrupt | ( | ) |
Configures timer counter for interrupt Documentation for internal functions - see tc.c (system/libsam/source/tc.c at https://github.com/swallace23/framework-arduino-sam) The processor has 3 clocks, each have 3 channels and 3 registers (RA, RB, RC). This is set up to use TC0 and channel 0. RC is used to store the compare value. The interrupt is triggered when the counter reaches the compare value. Calculate interrupt frequency with: interrupt frequency = clock frequency / (RC+1) Note that the clock frequency for TC0 is configured to be 656.25 kHz.
void FSMAction | ( | ) |
void FSMUpdate | ( | ) |
void sendIMUData | ( | ) |
void sendStoredData | ( | ) |
void sendSweepData | ( | ) |
void startSweepOnShield | ( | ) |
Max1148 adc0(Channel::CHAN2) | ( | Channel::CHAN2 | ) |
Max1148 adc1(Channel::CHAN1) | ( | Channel::CHAN1 | ) |
uint32_t* p_IMUTimeStamp = &IMUTimeStamp |
uint8_t* p_memory_block = memory_block |
uint32_t* p_sweepTimeStamp = &sweepTimeStamp |
Pip pip0(SWEEP_DELAY, SWEEP_AVERAGES, SWEEP_STEPS, 339, 3752, DAC0, adc0) | ( | SWEEP_DELAY | , |
SWEEP_AVERAGES | , | ||
SWEEP_STEPS | , | ||
339 | , | ||
3752 | , | ||
DAC0 | , | ||
adc0 | |||
) |
Pip pip1(SWEEP_DELAY, SWEEP_AVERAGES, SWEEP_STEPS, 339, 3752, DAC1, adc1) | ( | SWEEP_DELAY | , |
SWEEP_AVERAGES | , | ||
SWEEP_STEPS | , | ||
339 | , | ||
3752 | , | ||
DAC1 | , | ||
adc1 | |||
) |
PipController pipController(pip0, pip1) | ( | pip0 | , |
pip1 | |||
) |
uint8_t ramBuf[RAM_BUF_LEN] |
int shortSize = sizeof(sweepSentinel)+sizeof(sweepTimeStamp)+sizeof(sweep_buffer)+sizeof(imuSentinel)+sizeof(IMUTimeStamp)+sizeof(IMUData) |
uint16_t sweep_buffer[2 *SWEEP_STEPS] |