2012-08-01 11:51:29 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 by Cristian Maglie <c.maglie@bug.st>
|
|
|
|
* DAC library for Arduino Due.
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of either the GNU General Public License version 2
|
|
|
|
* or the GNU Lesser General Public License version 2.1, both as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2012-07-29 01:57:12 +02:00
|
|
|
|
|
|
|
#ifndef DAC_INCLUDED
|
|
|
|
#define DAC_INCLUDED
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
2012-08-01 11:51:29 +02:00
|
|
|
typedef void (*OnTransmitEnd_CB)(void *data);
|
2012-07-29 01:57:12 +02:00
|
|
|
|
|
|
|
class DACClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DACClass(Dacc *_dac, uint32_t _dacId, IRQn_Type _isrId) :
|
|
|
|
dac(_dac), dacId(_dacId), isrId(_isrId), cb(NULL) { };
|
|
|
|
void begin(uint32_t period);
|
|
|
|
void end();
|
|
|
|
bool canQueue();
|
|
|
|
size_t queueBuffer(const uint32_t *buffer, size_t size);
|
2012-08-01 11:51:29 +02:00
|
|
|
uint32_t *getCurrentQueuePointer();
|
|
|
|
void setOnTransmitEnd_CB(OnTransmitEnd_CB _cb, void *data);
|
2012-07-29 01:57:12 +02:00
|
|
|
void onService();
|
|
|
|
|
2012-08-01 11:51:29 +02:00
|
|
|
void enableInterrupts() { NVIC_EnableIRQ(isrId); };
|
|
|
|
void disableInterrupts() { NVIC_DisableIRQ(isrId); };
|
|
|
|
|
2012-07-29 01:57:12 +02:00
|
|
|
private:
|
|
|
|
Dacc *dac;
|
|
|
|
uint32_t dacId;
|
|
|
|
IRQn_Type isrId;
|
2012-08-01 11:51:29 +02:00
|
|
|
OnTransmitEnd_CB cb;
|
|
|
|
void *cbData;
|
2012-07-29 01:57:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern DACClass DAC;
|
|
|
|
|
|
|
|
#endif
|