Rev | Line | |
---|
[136] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 by Cristian Maglie <c.maglie@arduino.cc>
|
---|
| 3 | * DAC library for Arduino Due.
|
---|
| 4 | *
|
---|
| 5 | * This file is free software; you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of either the GNU General Public License version 2
|
---|
| 7 | * or the GNU Lesser General Public License version 2.1, both as
|
---|
| 8 | * published by the Free Software Foundation.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef DAC_INCLUDED
|
---|
| 12 | #define DAC_INCLUDED
|
---|
| 13 |
|
---|
| 14 | #include "Arduino.h"
|
---|
| 15 |
|
---|
| 16 | typedef void (*OnTransmitEnd_CB)(void *data);
|
---|
| 17 |
|
---|
| 18 | class DACClass
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
| 21 | DACClass(Dacc *_dac, uint32_t _dacId, IRQn_Type _isrId) :
|
---|
| 22 | dac(_dac), dacId(_dacId), isrId(_isrId), cb(NULL) { };
|
---|
| 23 | void begin(uint32_t period);
|
---|
| 24 | void end();
|
---|
| 25 | bool canQueue();
|
---|
| 26 | size_t queueBuffer(const uint32_t *buffer, size_t size);
|
---|
| 27 | uint32_t *getCurrentQueuePointer();
|
---|
| 28 | void setOnTransmitEnd_CB(OnTransmitEnd_CB _cb, void *data);
|
---|
| 29 | void onService();
|
---|
| 30 |
|
---|
| 31 | void enableInterrupts() { NVIC_EnableIRQ(isrId); };
|
---|
| 32 | void disableInterrupts() { NVIC_DisableIRQ(isrId); };
|
---|
| 33 |
|
---|
| 34 | private:
|
---|
| 35 | Dacc *dac;
|
---|
| 36 | uint32_t dacId;
|
---|
| 37 | IRQn_Type isrId;
|
---|
| 38 | OnTransmitEnd_CB cb;
|
---|
| 39 | void *cbData;
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | extern DACClass DAC;
|
---|
| 43 |
|
---|
| 44 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.