1////////////////////////////////////////////////////////////////////////////////
2// //
3// This software is supplied under the terms of a license agreement or //
4// nondisclosure agreement with Mitov Software and may not be copied //
5// or disclosed except in accordance with the terms of that agreement. //
6// Copyright(c) 2002-2016 Mitov Software. All Rights Reserved. //
7// //
8////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _MITOV_GOLDILOCKS_DAC_h
11#define _MITOV_GOLDILOCKS_DAC_h
12
13#include <Mitov.h>
14#include <DAC.h>
15
16namespace Mitov
17{
18 class GoldilocksDAC : public OpenWire::Component, public Mitov::ClockingSupport
19 {
20 typedef OpenWire::Component inherited;
21
22 public:
23 OpenWire::VlaueSinkPin<float> InputPins[ 2 ];
24
25 protected:
26 virtual void SystemStart()
27 {
28 inherited::SystemStart();
29 DAC_init(TRUE);
30 }
31
32 protected:
33 void DoReceive( void *_Data )
34 {
35 if( ClockInputPin.IsConnected() )
36 return;
37
38 DoClockReceive( _Data );
39 }
40
41 void DoClockReceive( void *_Data )
42 {
43 uint16_t aValue = InputPins[ 0 ].Value * 1023 + 0.5;
44 uint16_t bValue = InputPins[ 1 ].Value * 1023 + 0.5;
45 DAC_out( &aValue, &bValue );
46 }
47
48 public:
49 GoldilocksDAC()
50 {
51 InputPins[ 0 ].SetCallback( MAKE_CALLBACK( GoldilocksDAC::DoReceive ));
52 InputPins[ 1 ].SetCallback( MAKE_CALLBACK( GoldilocksDAC::DoReceive ));
53 }
54
55 };
56}
57
58#endif