Skip to content

Instantly share code, notes, and snippets.

@mbolivar
Created May 23, 2011 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbolivar/987258 to your computer and use it in GitHub Desktop.
Save mbolivar/987258 to your computer and use it in GitHub Desktop.
newyorkbrass code snippet
// See http://forums.leaflabs.com/topic.php?id=739&page=2
class HardwareResourceParams
{
public:
HardwareResourceParams();
};
class HardwareResource
{
public:
Start();
Stop();
Setup(HardwareResourceParams * params);
};
class DMABuffer
{
};
// There may be multiple ways of implementing DMA for variouss purposes
class DMABase : public HardwareResource
{
public:
DMABase();
buffer
};
// There may be multiple ways of implementing DMA for variouss purposes
// Class implementing DMA Reading with double bouffering
class DMAReader : public HardwareResource
{
public:
DMAReader();
int read(void * buffer, int n);
buffer
};
// Class implementing DMA Writing with double bouffering
class DMAWriter : public HardwareResource
{
public:
DMAWriter();
int write(void * buffer, int n);
DMABuffer buffer;
};
And finally we have:
class ADC : public HardwareResource
{
public:
ADC(){ // }
Setup(...);
// read a single word
int Read();
};
}
class DAC : public HardwareResource
{
public:
DAC(){ // }
Setup(...);
// Send a single word
Write(int data);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment