|
PiPower
ac0ff3c (Mon Feb 11 21:44:30 2019 -0500)
|
Raspberry Pi/Powerboost 1000c/ATtiny85 power controller. More...
#include <stdint.h>#include <avr/io.h>#include <avr/interrupt.h>#include <avr/sleep.h>#include "bool.h"#include "button.h"#include "millis.h"#include "input.h"#include "pins.h"#include "states.h"Macros | |
| #define | LONG_PRESS_DURATION 2000 |
| Length of long press. | |
| #define | BUTTON_NORMAL 0 |
| Process button events normally. | |
| #define | BUTTON_IGNORE 1 |
| Power button must be released. | |
| #define | ONE_SECOND 1000 |
| #define | TIMER_BUTTON 10 |
| Period for reading button state. | |
| #define | TIMER_POWERWAIT (1 * ONE_SECOND) |
| How long to wait for USB to stabilize. | |
| #define | TIMER_BOOTWAIT (30 * ONE_SECOND) |
| How long to wait for boot. | |
| #define | TIMER_SHUTDOWN (30 * ONE_SECOND) |
| How long to wait for shutdown. | |
| #define | TIMER_POWEROFF (30 * ONE_SECOND) |
| How long to wait for power off. | |
| #define | TIMER_IDLE (5 * ONE_SECOND) |
| How long to wait before returning to SLEEP_PWRDOWN mode. | |
Functions | |
| EMPTY_INTERRUPT (PCINT0_vect) | |
| Trigger wake from power-down mode on pin change interrupt. More... | |
| void | setup () |
| Run once when mc boots. More... | |
| void | enable_pcie () |
| Enable pin change interrupts in GIMS. | |
| void | disable_pcie () |
| Disable pin change interrupts in GIMS. | |
| void | loop () |
| Runs periodically. | |
| int | main () |
Variables | |
| unsigned long | now |
Set to the current value of millis() on each loop iteration. More... | |
| unsigned long | timer_start = 0 |
| Generic timer used in state transitions. | |
| Button | power_button |
| Power button. | |
| uint8_t | power_button_state = BUTTON_NORMAL |
| Power button current state. | |
| unsigned long | time_pressed |
| Current press duration. | |
| enum STATE | state = STATE_START |
| Current run state. More... | |
| bool | quit = false |
| Allow debugger to trigger exit from main loop. | |
| Input | usb |
| USB signal from PowerBoost. | |
| Input | boot |
| BOOT signal from Raspberry Pi. | |
Raspberry Pi/Powerboost 1000c/ATtiny85 power controller.
| EMPTY_INTERRUPT | ( | PCINT0_vect | ) |
Trigger wake from power-down mode on pin change interrupt.
We rely on the pin change interrupt to wake from SLEEP_PWRDOWN mode, but we do not otherwise need to handle the interrupt, so this is a do-nothing routine.
| void setup | ( | ) |
Run once when mc boots.
| unsigned long now |
Set to the current value of millis() on each loop iteration.
| enum STATE state = STATE_START |
Current run state.
1.8.11