ClearCore Library
Loading...
Searching...
No Matches
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
44namespace ClearCore {
45
62class Connector {
63 friend class SysManager;
64
65public:
166
297
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
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
459 virtual int8_t ExternalInterrupt() {
460 return -1;
461 }
462#endif
463
464protected:
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__
ClearCorePins
ClearCore PIN definitions.
Definition SysConnectors.h:54
Base class for interacting with all ClearCore connector objects.
Definition Connector.h:62
virtual bool IsInHwFault()=0
Get whether the connector is in a hardware fault state.
virtual bool State(int16_t newState)=0
Set the state of a R/W connector.
int32_t ConnectorIndex()
Accessor for the bit index of this connector in the input register.
Definition Connector.h:380
virtual ConnectorModes Mode()
Get the connector's operational mode.
Definition Connector.h:309
uint32_t InputRegMask()
Get a bit mask representing this connector.
Definition Connector.h:448
virtual int16_t State()=0
Get the connector's last sampled value.
ConnectorModes
All possible operational modes for a connector.
Definition Connector.h:74
@ CPM_MODE_A_DIRECT_B_DIRECT
Definition Connector.h:121
@ CCIO
Definition Connector.h:160
@ CPM_MODE_A_PWM_B_PWM
Definition Connector.h:140
@ RS232
Definition Connector.h:151
@ OUTPUT_WAVE
Definition Connector.h:115
@ OUTPUT_PWM
Definition Connector.h:106
@ TTL
Definition Connector.h:145
@ INPUT_DIGITAL
Definition Connector.h:90
@ OUTPUT_H_BRIDGE
Definition Connector.h:102
@ OUTPUT_ANALOG
Definition Connector.h:94
@ INVALID_NONE
Definition Connector.h:78
@ OUTPUT_TONE
Definition Connector.h:111
@ USB_CDC
Definition Connector.h:164
@ CPM_MODE_A_DIRECT_B_PWM
Definition Connector.h:133
@ OUTPUT_DIGITAL
Definition Connector.h:98
@ SPI
Definition Connector.h:156
@ INPUT_ANALOG
Definition Connector.h:84
@ CPM_MODE_STEP_AND_DIR
Definition Connector.h:126
virtual bool IsWritable()=0
Determine whether values can be written to this connector.
virtual bool Mode(ConnectorModes newMode)=0
Set the connector's operational mode.
void Reinitialize()
Reinitialize this connector to the power-up state.
Definition Connector.h:365
ConnectorTypes
The different types of ClearCore connectors.
Definition Connector.h:172
@ ANALOG_IN_DIGITAL_IN_TYPE
Definition Connector.h:218
@ CPM_TYPE
Definition Connector.h:264
@ SERIAL_USB_TYPE
Definition Connector.h:287
@ SHIFT_REG_TYPE
Definition Connector.h:203
@ ANALOG_OUT_DIGITAL_IN_OUT_TYPE
Definition Connector.h:231
@ SERIAL_TYPE
Definition Connector.h:277
@ DIGITAL_IN_TYPE
Definition Connector.h:185
@ DIGITAL_IN_OUT_TYPE
Definition Connector.h:199
@ H_BRIDGE_TYPE
Definition Connector.h:247
@ CCIO_DIGITAL_IN_OUT_TYPE
Definition Connector.h:295
virtual ConnectorTypes Type()=0
Get the connector type.
ClearCore Board Supervisory System Manager.
Definition SysManager.h:58
Namespace to encompass the ClearCore board API.
Definition AdcManager.h:36