Example: fetch ADC samples in a ring buffer and save to file. More...
#include "BBB/pruio.bi"
Go to the source code of this file.
Functions | |
int | main () |
Variables | |
const | tSamp = 123401 |
The number of samples in the files (per step). | |
const | tmr = 20000 |
The sampling rate in ns (20000 -> 50 kHz). | |
const | NoStep = 3 |
The number of active steps (must match setStep calls and mask). | |
const | NoFile = 2 |
The number of files to write. | |
const | NamFil = "output." |
The output file names. | |
VAR | io = NEW PruIo() |
Create a PruIo structure, wakeup subsystems. | |
VAR | mask = &b111 SHL 9 |
The active steps (9 to 11). | |
VAR | tInd = tSamp * NoStep |
The maximum total index. | |
VAR | half = ((.ESize SHR 2) \ NoStep) * NoStep |
The maximum index of the half ring buffer. | |
VAR | samp = (half SHL 1) \ NoStep |
The number of samples (per step). | |
VAR | p0 = .Adc->Value |
A pointer to the start of the ring buffer. | |
VAR | p1 = p0 + half |
A pointer to the middle of the ring buffer. | |
VAR | fnam = NamFil & n |
The file name. | |
VAR | fnr = FREEFILE |
The file number. | |
VAR | i = 0 |
Start index. | |
VAR | rest = tInd + half - i |
The rest of the buffer (in bytes) | |
VAR | iEnd = IIF(p1 >= p0, rest, rest + half) |
The last byte of the rest. | |
Example: fetch ADC samples in a ring buffer and save to file.
This file contains an example on how to use the ring buffer mode of libpruio. A fixed step mask of AIN-0, AIN-1 and AIN-2 get configured for maximum speed, sampled in to the ring buffer and from there saved as raw data to some files. Find a functional description in section rb_file.
Licence: GPLv3, Copyright 2014-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net
Compile by: fbc -w all rb_file.bas
Definition in file rb_file.bas.
int main | ( | ) |
The main function.
Definition at line 92 of file rb_file.bas.