ClearCore Library
Connector.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 
36 #ifndef __CONNECTOR_H__
37 #define __CONNECTOR_H__
38 
39 #include "SysConnectors.h"
40 #include <stdint.h>
41 
42 
43 #ifdef __cplusplus
44 namespace ClearCore {
45 
62 class Connector {
63  friend class SysManager;
64 
65 public:
74  typedef enum {
165  } ConnectorModes;
166 
172  typedef enum {
296  } ConnectorTypes;
297 
309  virtual ConnectorModes Mode() {
310  return m_mode;
311  }
312 
324  virtual bool Mode(ConnectorModes newMode) = 0;
325 
337  virtual ConnectorTypes Type() = 0;
338 
351  virtual bool IsWritable() = 0;
352 
365  void Reinitialize() {
366  Initialize(m_clearCorePin);
367  }
368 
380  int32_t ConnectorIndex() {
381  return m_clearCorePin;
382  }
383 
403  virtual int16_t State() = 0;
404 
418  virtual bool State(int16_t newState) = 0;
419 
431  virtual bool IsInHwFault() = 0;
432 
448  uint32_t InputRegMask() {
449  return (m_clearCorePin < 0) ? 0 : (1 << m_clearCorePin);
450  }
451 
452 #ifndef HIDE_FROM_DOXYGEN
453 
459  virtual int8_t ExternalInterrupt() {
460  return -1;
461  }
462 #endif
463 
464 protected:
473  ClearCorePins m_clearCorePin;
474 
478  ConnectorModes m_mode;
479 
481  Connector();
482 
491  virtual void Refresh() = 0;
492 
498  virtual void Initialize(ClearCorePins clearCorePin) = 0;
499 
500 }; // Connector
501 
502 } // ClearCore namespace
503 #endif // __cplusplus
504 
505 #endif // __CONNECTOR_H__
Definition: Connector.h:90
Definition: Connector.h:287
Definition: Connector.h:151
void Reinitialize()
Reinitialize this connector to the power-up state.
Definition: Connector.h:365
Definition: Connector.h:84
virtual bool IsInHwFault()=0
Get whether the connector is in a hardware fault state.
Definition: Connector.h:185
Definition: Connector.h:203
uint32_t InputRegMask()
Get a bit mask representing this connector.
Definition: Connector.h:448
int32_t ConnectorIndex()
Accessor for the bit index of this connector in the input register.
Definition: Connector.h:380
virtual bool IsWritable()=0
Determine whether values can be written to this connector.
Definition: Connector.h:247
Definition: Connector.h:156
Base class for interacting with all ClearCore connector objects.
Definition: Connector.h:62
Definition: Connector.h:277
Definition: Connector.h:164
Definition: Connector.h:98
Namespace to encompass the ClearCore board API.
Definition: AdcManager.h:36
Definition: Connector.h:115
ConnectorModes
All possible operational modes for a connector.
Definition: Connector.h:74
Definition: Connector.h:102
virtual ConnectorTypes Type()=0
Get the connector type.
Definition: Connector.h:111
Definition: Connector.h:94
Definition: Connector.h:264
ClearCore Board Supervisory System Manager.
Definition: SysManager.h:58
Definition: Connector.h:78
Definition: Connector.h:145
ClearCorePins
ClearCore PIN definitions.
Definition: SysConnectors.h:54
Definition: Connector.h:160
virtual int16_t State()=0
Get the connector&#39;s last sampled value.
Definition: Connector.h:106
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