Serial Wombat Arduino Library
SerialWombatProtectedOutput.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 Copyright 2020-2021 Broadwell Consulting Inc.
4 
5 "Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
6 the United States. See SerialWombat.com for usage guidance.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25 */
26 
27 #include "SerialWombat.h"
32 typedef enum
33 {
37 } PO_COMPARE_t;
38 
39 
69 {
70 public:
77  void begin(uint8_t pin, uint8_t monitoredPin);
84  void configure(PO_COMPARE_t compareMode, uint16_t compareValue, uint8_t debounceTime, SerialWombatPinState_t activeState, SerialWombatPinState_t safeState);
87  bool isInSafeState();
89  void makeInput();
95  void digitalWrite(uint8_t state);
96 
97 private:
98 
99  uint8_t _monitoredPin = 255;
100  PO_COMPARE_t _compareMode = PO_FAULT_IF_NOT_EQUAL;
101  uint8_t _debounceTime = 0;
102  SerialWombatPinState_t _safeState = SW_INPUT;
103  SerialWombatPinState_t _activeState = SW_INPUT;
104  uint16_t _compareValue;
105 };
106 
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:272
SerialWombatProtectedOutput::isInSafeState
bool isInSafeState()
Queries the Serial Wombat to see if the protected output has entered safe mode due to a fault.
Definition: SerialWombatProtectedOutput.cpp:31
PO_FAULT_IF_NOT_EQUAL
@ PO_FAULT_IF_NOT_EQUAL
Definition: SerialWombatProtectedOutput.h:34
SerialWombat.h
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombat.h:799
SerialWombatProtectedOutput::begin
void begin(uint8_t pin, uint8_t monitoredPin)
Definition: SerialWombatProtectedOutput.cpp:8
PO_FAULT_IF_FEEDBACK_LESS_THAN_EXPECTED
@ PO_FAULT_IF_FEEDBACK_LESS_THAN_EXPECTED
Definition: SerialWombatProtectedOutput.h:35
SerialWombatProtectedOutput::digitalWrite
void digitalWrite(uint8_t state)
Turn off the protection features and make the protected pin an unprotected output.
Definition: SerialWombatProtectedOutput.cpp:42
SerialWombatPinState_t
SerialWombatPinState_t
Definition: SerialWombat.h:40
PO_COMPARE_t
PO_COMPARE_t
Definition: SerialWombatProtectedOutput.h:32
SW_INPUT
@ SW_INPUT
Definition: SerialWombat.h:44
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition: SerialWombat.h:861
PO_FAULT_IF_FEEDBACK_GREATER_THAN_EXPECTED
@ PO_FAULT_IF_FEEDBACK_GREATER_THAN_EXPECTED
Definition: SerialWombatProtectedOutput.h:36
SerialWombatProtectedOutput::configure
void configure(PO_COMPARE_t compareMode, uint16_t compareValue, uint8_t debounceTime, SerialWombatPinState_t activeState, SerialWombatPinState_t safeState)
Definition: SerialWombatProtectedOutput.cpp:14
SerialWombatProtectedOutput::SerialWombatProtectedOutput
SerialWombatProtectedOutput(SerialWombatChip &serialWombat)
Constructor for SerialWombatProtectedOutput.
Definition: SerialWombatProtectedOutput.cpp:3
SerialWombatProtectedOutput::makeInput
void makeInput()
Turn off protection features and make the protected pin an input.
Definition: SerialWombatProtectedOutput.cpp:37
SerialWombatProtectedOutput
Combine and input and output pin for a protected output.
Definition: SerialWombatProtectedOutput.h:68