ClearCore Library
Loading...
Searching...
No Matches
StatusManager.h
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
23#ifndef __STATUSMANAGER_H__
24#define __STATUSMANAGER_H__
25
26#include "ShiftRegister.h"
27#include "BlinkCodeDriver.h"
28#include "SysConnectors.h"
29
30namespace ClearCore {
31
38 friend class CcioBoardManager;
39 friend class DigitalInOut;
40
41public:
51 uint32_t reg;
52
56 struct {
61 uint32_t VSupplyOverVoltage : 1;
66 uint32_t VSupplyUnderVoltage : 1;
71 uint32_t HBridgeOverloaded : 1;
76 uint32_t HBridgeReset : 1;
81 uint32_t Overloaded5V : 1;
86 uint32_t OutputOverloaded : 1;
91 uint32_t CcioOverloaded : 1;
95 uint32_t CcioLinkBroken : 1;
99 uint32_t AdcTimeout : 1;
103 uint32_t EthernetDisconnect : 1;
115 uint32_t SdCardError : 1;
120 uint32_t NvmDesync : 1;
122
127 reg = 0;
128 }
129
133 StatusRegister(uint32_t val) {
134 reg = val;
135 }
136
141 operator bool() const {
142 return reg > 0;
143 }
144 };
145
146#ifndef HIDE_FROM_DOXYGEN
150 static StatusManager &Instance();
151#endif
152
185
214
243
278
308
330 void BlinkCodeClear(uint8_t group, uint8_t code) {
331 m_blinkMgr.BlinkCodeClear(group, code);
332 }
333
349
350#ifndef HIDE_FROM_DOXYGEN
354 bool Initialize(ShiftRegister::Masks faultLed);
355
359 void Refresh();
360
365 void HBridgeState(bool reset);
366#endif
367
381
403
428
458 UINT32_MAX);
459
477 void UserBlinkCode(uint8_t mask) {
478 m_blinkMgr.CodeGroupAdd(
479 BlinkCodeDriver::BLINK_GROUP_APPLICATION, mask);
480 }
481
482private:
483 StatusRegister m_statusRegSinceStartup;
484 StatusRegister m_statusRegRT;
485 StatusRegister m_statusRegAccum;
486 StatusRegister m_statusRegRisen;
487 StatusRegister m_statusRegFallen;
488
489 SysConnectorState m_overloadSinceStartup;
490 SysConnectorState m_overloadAccum;
491 SysConnectorState m_overloadRT;
492
493 ShiftRegister::Masks m_faultLed;
494 BlinkCodeDriver m_blinkMgr;
495
496 bool m_disableMotors;
497 volatile bool m_hbridgeResetting;
498
500 : m_statusRegSinceStartup(),
501 m_statusRegRT(),
502 m_statusRegAccum(),
503 m_statusRegRisen(),
504 m_statusRegFallen(),
505 m_faultLed(ShiftRegister::SR_NO_FEEDBACK_MASK),
506 m_disableMotors(false),
507 m_hbridgeResetting(false) {}
508
518 void BlinkCode(BlinkCodeDriver::BlinkCodeGroups group, uint8_t mask);
519
527 void UpdateBlinkCodes(StatusRegister status);
528
532 void OverloadUpdate(uint32_t mask, bool inFault);
533
534}; // StatusManager
535
536} // ClearCore namespace
537#endif // __STATUSMANAGER_H__
LED shift register access class.
ClearCore I/O Expansion Board Manager Class.
Definition CcioBoardManager.h:91
ClearCore digital output connector class.
Definition DigitalInOut.h:60
ClearCore Status Register Manager class.
Definition StatusManager.h:37
void BlinkCodeClear(uint8_t group, uint8_t code)
Definition StatusManager.h:330
StatusRegister StatusRT(StatusRegister mask=UINT32_MAX)
The real time status register.
StatusRegister SinceStartupAccum(StatusRegister mask=UINT32_MAX)
Access to all accumulated status bits that have asserted since board startup (or since the last board...
StatusRegister StatusRisen(StatusRegister mask=UINT32_MAX)
Clear on read accessor for status bits that have risen (transitioned from deasserted to asserted) som...
StatusRegister StatusFallen(StatusRegister mask=UINT32_MAX)
Clear on read accessor for status bits that have fallen (transitioned from asserted to deasserted) so...
bool AdcIsInTimeout()
Read accessor for whether the ADC has timed out while attempting a conversion.
void UserBlinkCode(uint8_t mask)
Definition StatusManager.h:477
SysConnectorState IoOverloadRT(SysConnectorState mask=UINT32_MAX)
Accessor for the real time overload status of the I/O connectors.
void HBridgeReset()
Starts a reset pulse to the DigitalInOutHBridge connectors.
SysConnectorState IoOverloadAccum(SysConnectorState mask=UINT32_MAX)
Clear on read accessor for connector overload status since the last invocation of this function.
SysConnectorState IoOverloadSinceStartupAccum(SysConnectorState mask=UINT32_MAX)
Accessor for connector overload status since startup (or board reset).
StatusRegister StatusAccum(StatusRegister mask=UINT32_MAX)
Accumulating Clear on read accessor for any status bits that were asserted sometime since the previou...
Namespace to encompass the ClearCore board API.
Definition AdcManager.h:36
Definition StatusManager.h:47
struct ClearCore::StatusManager::StatusRegister::@5 bit
uint32_t EthernetDisconnect
Definition StatusManager.h:103
uint32_t reg
Definition StatusManager.h:51
uint32_t SdCardError
Definition StatusManager.h:115
uint32_t HBridgeReset
Definition StatusManager.h:76
uint32_t CcioOverloaded
Definition StatusManager.h:91
uint32_t VSupplyUnderVoltage
Definition StatusManager.h:66
uint32_t EthernetPhyInitFailed
Definition StatusManager.h:111
uint32_t OutputOverloaded
Definition StatusManager.h:86
uint32_t VSupplyOverVoltage
Definition StatusManager.h:61
uint32_t CcioLinkBroken
Definition StatusManager.h:95
uint32_t HBridgeOverloaded
Definition StatusManager.h:71
StatusRegister()
Definition StatusManager.h:126
uint32_t EthernetRemoteFault
Definition StatusManager.h:107
uint32_t AdcTimeout
Definition StatusManager.h:99
uint32_t Overloaded5V
Definition StatusManager.h:81
uint32_t NvmDesync
Definition StatusManager.h:120
StatusRegister(uint32_t val)
Definition StatusManager.h:133
Definition SysConnectors.h:174