ClearCore Library
DigitalInOutAnalogOut.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Teknic, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
29 #ifndef __DIGITALINOUTANALOGOUT_H__
30 #define __DIGITALINOUTANALOGOUT_H__
31 
32 #include <stdint.h>
33 #include "Connector.h"
34 #include "DigitalInOut.h"
35 #include "PeripheralRoute.h"
36 #include "ShiftRegister.h"
37 
38 namespace ClearCore {
39 
54  friend class SysManager;
55 
56 public:
57 #ifndef HIDE_FROM_DOXYGEN
58 
65 #endif
66 
70  virtual ConnectorModes Mode() override {
71  return Connector::Mode();
72  }
73 
90  bool Mode(ConnectorModes newMode) override;
91 
107  }
108 
120  bool IsWritable() override;
121 
137  int16_t State() override;
138 
157  bool State(int16_t newState) override;
158 
174  void AnalogWrite(uint16_t value);
175 
188  void OutputCurrent(uint16_t currentuA);
189 
190 #ifndef HIDE_FROM_DOXYGEN
191 
200  void AnalogWriteUncalibrated(uint16_t value);
201 
221  bool DacStoreCalibration(uint16_t zero, uint16_t span);
222 #endif // HIDE_FROM_DOXYGEN
223 
224 private:
225  uint32_t m_analogPort;
226  uint32_t m_analogDataBit;
227  uint16_t m_dacZero;
228  uint16_t m_dacSpan;
229 
230 #ifndef HIDE_FROM_DOXYGEN
231 
234  DigitalInOutAnalogOut(enum ShiftRegister::Masks ledMask,
235  const PeripheralRoute *inputInfo,
236  const PeripheralRoute *outputInfo,
237  const PeripheralRoute *outputAnalogInfo,
238  bool digitalLogicInversion);
239 #endif
240 
249  void Refresh() override;
250 
254  void Initialize(ClearCorePins clearCorePin) override;
255 
260  void DacInitialize();
261 
266  void DacEnable();
267 
272  void DacDisable();
273 
277  void DacLoadCalibration();
278 
287  void DacRegisterWrite(uint16_t value);
288 
289 }; // DigitalInOutAnalogOut class
290 
291 } // ClearCore namespace
292 
293 #endif // __ANALOGOUTDIGITALINOUT_H__
void OutputCurrent(uint16_t currentuA)
Command the DAC to output the given number of microamps (uA).
ClearCore digital input/output with analog current output Connector class.
Definition: DigitalInOutAnalogOut.h:53
Defines the Peripheral Route structure, used in HardwareMapping.
virtual ConnectorModes Mode() override
Get the connector&#39;s operational mode.
Definition: DigitalInOutAnalogOut.h:70
bool IsWritable() override
Get R/W status of the connector.
Connector::ConnectorTypes Type() override
Get connector type.
Definition: DigitalInOutAnalogOut.h:105
ClearCore Digital Output Connector class.
Namespace to encompass the ClearCore board API.
Definition: AdcManager.h:36
void AnalogWrite(uint16_t value)
Command the DAC to output a (calibrated) value.
LED shift register access class.
Base class for all connector classes.
ConnectorModes
All possible operational modes for a connector.
Definition: Connector.h:74
int16_t State() override
Get connector&#39;s last sampled digital value.
ClearCore digital output connector class.
Definition: DigitalInOut.h:60
ClearCore Board Supervisory System Manager.
Definition: SysManager.h:58
ClearCorePins
ClearCore PIN definitions.
Definition: SysConnectors.h:54
virtual ConnectorModes Mode()
Get the connector&#39;s operational mode.
Definition: Connector.h:309
ConnectorTypes
The different types of ClearCore connectors.
Definition: Connector.h:172