This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Produces a sawtooth on A0 and samples A1 and A3 into buffers via DMA | |
#include <Adafruit_ZeroDMA.h> | |
#include <wiring_private.h> // for access to pinPeripheral | |
// Create buffers for DMAing data around -- the .dmabuffers section is supposed to | |
// optimize the memory location for the DMA controller | |
__attribute__ ((section(".dmabuffers"), used)) static uint16_t dac_buffer[4096], adc_buffer[2][4096]; | |
void setup() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <utility> | |
namespace Detail { | |
template<typename KeyTy, typename ValueTy> | |
struct Element { | |
using KeyType = KeyTy; | |
using ValueType = ValueTy; | |
using PairType = std::pair<KeyTy, ValueTy>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FNV-1a hash with 64-bit output | |
size_t FNV1a(const uint8_t *data, size_t dataLen) { | |
uint64_t hash = 14695981039346656037ull; | |
for (size_t i = 0; i < dataLen; i++) { | |
hash ^= data[i]; | |
hash *= 1099511628211ull; | |
} | |
return hash; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from datetime import datetime | |
import serial | |
import serial.tools.list_ports | |
import struct | |
import time | |
import math | |
import os | |
# COM port of Arduino Due; leave None for cross-platform auto-detection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from datetime import datetime | |
import numpy as np | |
import serial | |
import struct | |
import time | |
import math | |
import os | |
# Native USB port of Due (use Device Manager to find) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define VERSION_MAJOR 0 | |
#define VERSION_MINOR 2 | |
// 1.6 MHz is the max frequency of the DAC, so it's easiest | |
// just to scale everything off of it. 1 ADC channel runs at | |
// 41.25% (~660 kHz); 2 ADC channels run at 25% (400 kHz each) | |
const int freq = 1.6e6; | |
// Duration of a single chirp | |
const double chirp_duration = 15E-3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from datetime import datetime | |
import numpy as np | |
import serial | |
import struct | |
import time | |
import math | |
import os | |
# Native USB port of Due (use Device Manager to find) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
try: | |
ptu = PTU(PTU_PORT) | |
except serial.serialutil.SerialException: | |
print(f'Could not connect to pan-tilt on port {PTU_PORT}') | |
return | |
# Open connection to device | |
ser = serial.Serial(DUE_PORT) | |
ser.setDTR(False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool flash_read_unique_id(uint32_t *pul_data) { | |
// Initialize the first EEFC bank in 128-bit mode with 4 wait states | |
if (efc_init(EFC0, 0, 4)) { | |
return false; | |
} | |
// Enter the unique identifier mode, copy it, and exit | |
return !efc_perform_read_sequence(EFC0, EFC_FCMD_STUI, EFC_FCMD_SPUI, pul_data, 4); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <BasicStepperDriver.h> | |
// Accept a trigger of 's' over Serial1 or Serial2 | |
#define USE_SERIAL_TRIGGER true | |
// Enable the motors only when they are being moved | |
#define DISABLE_MOTORS false | |
const int EAR_LEFT_DIR = 48, EAR_LEFT_STEP = 46, EAR_LEFT_ENABLE = 62; // Z |