forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDAC.h
44 lines (36 loc) · 1.06 KB
/
DAC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2012 by Cristian Maglie <[email protected]>
* 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.
*/
#ifndef DAC_INCLUDED
#define DAC_INCLUDED
#include "Arduino.h"
typedef void (*OnTransmitEnd_CB)(void *data);
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);
uint32_t *getCurrentQueuePointer();
void setOnTransmitEnd_CB(OnTransmitEnd_CB _cb, void *data);
void onService();
void enableInterrupts() { NVIC_EnableIRQ(isrId); };
void disableInterrupts() { NVIC_DisableIRQ(isrId); };
private:
Dacc *dac;
uint32_t dacId;
IRQn_Type isrId;
OnTransmitEnd_CB cb;
void *cbData;
};
extern DACClass DAC;
#endif