Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Main Page
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
libraries
ShiftRegister
ShiftRegister.h
1
#pragma once
2
#include <
Bela.h
>
// this class acts on the BelaContext directly
3
#include <vector>
4
13
class
ShiftRegister
14
{
15
public
:
19
struct
Pins
{
20
unsigned
int
data
;
21
unsigned
int
clock
;
22
unsigned
int
latch
;
23
};
28
ShiftRegister
();
37
ShiftRegister
(
const
Pins
& pins,
unsigned
int
maxSize);
41
void
setup
(
const
Pins
& pins,
unsigned
int
maxSize);
50
bool
dataReady
();
54
virtual
void
process
(
BelaContext
* context,
unsigned
int
n) = 0;
55
protected
:
56
Pins
pins;
57
typedef
enum
{
58
kStart,
59
kTransmitting,
60
kStop,
61
kIdle,
62
} State;
63
64
State state = kStop;
65
std::vector<bool> data;
66
bool
pinModeSet =
false
;
67
bool
notified =
true
;
68
};
69
70
class
ShiftRegisterOut
:
public
ShiftRegister
71
{
72
public
:
77
void
setClockPeriod
(
unsigned
int
period);
87
void
setData
(
const
std::vector<bool>& dataBuf);
93
void
setData
(
const
bool
* dataBuf,
unsigned
int
length);
97
void
process
(
BelaContext
* context);
98
void
process
(
BelaContext
* context,
unsigned
int
n)
override
;
99
private
:
100
unsigned
int
period = 2;
101
unsigned
int
currentDataFrame;
102
unsigned
int
currentStopFrame;
103
};
104
105
class
ShiftRegisterIn
:
public
ShiftRegister
106
{
107
public
:
115
bool
dataReceived
();
123
const
std::vector<bool>&
getData
();
124
void
process
(
BelaContext
* context,
unsigned
int
n)
override
;
125
private
:
126
bool
pastLatch =
false
;
127
bool
pastClock =
false
;
128
};
ShiftRegister::ShiftRegister
ShiftRegister()
Definition:
ShiftRegister.cpp:3
ShiftRegisterOut
Definition:
ShiftRegister.h:70
ShiftRegisterIn
Definition:
ShiftRegister.h:105
ShiftRegister::Pins::latch
unsigned int latch
latch pin
Definition:
ShiftRegister.h:22
ShiftRegister::Pins::data
unsigned int data
data pin
Definition:
ShiftRegister.h:20
ShiftRegister::Pins::clock
unsigned int clock
clock pin
Definition:
ShiftRegister.h:21
ShiftRegister::dataReady
bool dataReady()
Definition:
ShiftRegister.cpp:15
ShiftRegisterOut::process
void process(BelaContext *context)
Definition:
ShiftRegister.cpp:29
BelaContext
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition:
Bela.h:231
ShiftRegisterIn::process
void process(BelaContext *context, unsigned int n) override
Definition:
ShiftRegister.cpp:110
ShiftRegisterIn::getData
const std::vector< bool > & getData()
Definition:
ShiftRegister.cpp:105
ShiftRegisterOut::setClockPeriod
void setClockPeriod(unsigned int period)
Definition:
ShiftRegister.cpp:22
ShiftRegister::Pins
Definition:
ShiftRegister.h:19
ShiftRegisterIn::dataReceived
bool dataReceived()
ShiftRegister::process
virtual void process(BelaContext *context, unsigned int n)=0
ShiftRegisterOut::setData
void setData(const std::vector< bool > &dataBuf)
Definition:
ShiftRegister.cpp:89
Bela.h
Main Bela public API.
ShiftRegister::setup
void setup(const Pins &pins, unsigned int maxSize)
Definition:
ShiftRegister.cpp:9
ShiftRegister
A class to drive a shift register using Bela's digital I/O.
Definition:
ShiftRegister.h:13
Generated on Thu May 2 2024 05:58:23 for Bela by
1.8.6