Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
nxa66/PowerGood.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (31 sloc)
771 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Andy's Workshop NXA66 controller ATMega328p firmware | |
* Copyright (c) 2017 Andy Brown. http://www.andybrown.me.uk | |
* Please see website for licensing terms. | |
*/ | |
#pragma once | |
namespace nxa66 { | |
/* | |
* The power-good input pin is driven low when the power is bad and pulled high | |
* when it's good | |
*/ | |
struct PowerGood { | |
static void setup(); | |
static void onPowerGoodInterrupt(); | |
static void setLedState(); | |
}; | |
/* | |
* Initialisation | |
*/ | |
inline void PowerGood::setup() { | |
GpioPowerGood::setup(); | |
GpioPowerGoodLed::setup(); | |
setLedState(); | |
} | |
inline void PowerGood::onPowerGoodInterrupt() { | |
setLedState(); | |
} | |
inline void PowerGood::setLedState() { | |
GpioPowerGoodLed::changeTo(GpioPowerGood::read()); | |
} | |
} |