|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // 電源周り
9: //
10:
11: #pragma once
12:
13: #include "device.h"
1.1.1.2 root 14: #include "event.h"
1.1 root 15: #include "message.h"
16:
1.1.1.3 ! root 17: class Syncer;
! 18:
1.1 root 19: class PowerDevice : public Device
20: {
21: using inherited = Device;
22: public:
23: PowerDevice();
24: ~PowerDevice() override;
25:
1.1.1.3 ! root 26: bool Init() override;
! 27:
1.1.1.2 root 28: // 電源ボタンを押す
29: void PowerButton();
1.1 root 30:
31: // リセットを指示
32: // (どのスレッドから呼んでもよい)
33: void MakeResetHard();
34:
35: // リスタートを指示
36: // (どのスレッドから呼んでもよい)
37: void MakeRestart();
38:
1.1.1.2 root 39: // 電源が実際にオンなら true を返す。
1.1 root 40: bool IsPower() const { return ispower; }
41:
1.1.1.2 root 42: // 電源 LED 点灯なら true を返す。
43: bool GetPowerLED() const { return led; }
44:
45: // X68030 では電源ボタンが押されていれば true を返す。
46: // LUNA では意味を持たないので呼ばないこと。
47: bool IsPowerPressed() const { return power_button; }
48:
49: void SetAlarmOut(bool alarm_out_);
50: void SetSystemPowerOn(bool poweron);
1.1 root 51: private:
52: void DoPowerOn();
53: void DoResetHard();
54: void DoPowerOff(MessageID);
1.1.1.2 root 55: void DoPowerButton();
1.1 root 56:
57: // メッセージコールバック
58: void ResetCallback(MessageID, uint32);
59: void PowerOffCallback(MessageID, uint32);
1.1.1.2 root 60: void PowerButtonCallback(MessageID, uint32);
61:
62: void PowerCallback(Event&);
63:
64: void Change();
1.1 root 65:
66: // 電源オンなら true
67: bool ispower {};
1.1.1.2 root 68:
69: // 電源 LED
70: bool led {};
71:
72: // 電源ボタン状態
73: bool power_button {};
74:
75: // ALARM_OUT 信号状態
76: bool alarm_out {};
77:
78: // システム内の電源オン信号に相当
79: bool system_poweron {};
80:
1.1.1.3 ! root 81: Syncer *syncer {};
! 82:
1.1.1.2 root 83: // 電源オフイベント
84: Event event { this };
1.1 root 85: };
86:
1.1.1.3 ! root 87: static inline PowerDevice *GetPowerDevice() {
! 88: return Object::GetObject<PowerDevice>(OBJ_POWER);
! 89: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.