libElysianVMU 1.6.0
Full-featured, accurate, cross-platform library emulating the Dreamcast's Visual Memory Unit
Loading...
Searching...
No Matches
evmu_battery.h
Go to the documentation of this file.
1/*! \file
2 * \brief EvmuBattery BIOS monitor + low battery detection circuit
3 * \ingroup peripherals
4 *
5 * EvmuBattery is an EvmuPeripheral which encompasses two things:
6 * * A low battery alarm which is asserted on Pin 7.1 when low voltage
7 * is detected
8 * * A monitor within the BIOS which listens for this alarm and tells
9 * you to change the battery
10 *
11 * \warning
12 * The battery alarm is there to ensure that you don't do something like
13 * begin writing to flash with a dying battery, which could result in
14 * loss of data and filesystem corruption.
15 *
16 * \todo
17 * - rig up properties
18 * - battery lifetime profiler API
19 *
20 * \author 2023 Falco Girgis
21 * \copyright MIT License
22 */
23#ifndef EVMU_BATTERY_H
24#define EVMU_BATTERY_H
25
26#include "../types/evmu_peripheral.h"
27
28/*! \name Type System
29 * \brief Type UUID and cast operators
30 * @{
31 */
32#define EVMU_BATTERY_TYPE (GBL_TYPEID(EvmuBattery)) //!< GblType UUID for EvmuBattery
33#define EVMU_BATTERY(self) (GBL_CAST(EvmuBattery, self)) //!< Function-style GblInstance cast
34#define EVMU_BATTERY_CLASS(klass) (GBL_CLASS_CAST(EvmuBattery, klass)) //!< Function-style GblClass cast
35#define EVMU_BATTERY_GET(self) (GBL_CLASSOF(EvmuBattery, self)) //!< Extract EvmuBatteryClass from GblInstance
36//! @}
37
38#define EVMU_BATTERY_NAME "battery" //!< GblObject peripheral name
39
40#define GBL_SELF_TYPE EvmuBattery
41
42GBL_DECLS_BEGIN
43
44/*! \struct EvmuBatteryClass
45 * \extends EvmuPeripheralClass
46 * \brief GblClass VTable structure for EvmuBattery
47 *
48 * Class structure for the EvmuBattery peripheral.
49 * There are no public members.
50 *
51 * \sa EvmuBattery
52 */
53GBL_CLASS_DERIVE_EMPTY(EvmuBattery, EvmuPeripheral)
54
55/*! \struct EvmuBattery
56 * \extends EvmuPeripheral
57 * \ingroup peripherals
58 * \brief GblInstance structure for the battery peripheral
59 *
60 * EvmuBattery represents an instantiable EvmuPeripheral
61 * encapsulating both the low battery alarm/pin as well as the
62 * BIOS logic which monitors it. There are no public members.
63 *
64 * \sa EvmuBatteryClass
65 */
66GBL_INSTANCE_DERIVE_EMPTY(EvmuBattery, EvmuPeripheral)
67
68//!\cond
69GBL_PROPERTIES(EvmuBattery,
70 (lowAlarm, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
71 (monitorEnabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE)
72)
73//!\endcond
74
75//! Returns the GblType UUID associated with EvmuBattery
77
78/*! \name Alarm
79 * \brief Methods for getting and setting the alarm state
80 * \relatesalso EvmuBattery
81 * @{
82 */
83//! Returns GBL_TRUE if the low voltage battery detection signal is asserted
84EVMU_EXPORT GblBool EvmuBattery_lowAlarm (GBL_CSELF) GBL_NOEXCEPT;
85//! Sets the low battery detection circuit alarm to the \p enabled value
86EVMU_EXPORT void EvmuBattery_setLowAlarm (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;
87//! @}
88
89/*! \name Monitor
90 * \brief Methods for getting and setting the monitor state
91 * \relatesalso EvmuBattery
92 * @{
93 */
94//! Returns GBL_TRUE if the system BIOS low battery monitor is enabled
96//! Enables or disables the system BIOS low battery monitor, based on the \p enabled value
97EVMU_EXPORT void EvmuBattery_setMonitorEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;
98//! @}
99
100GBL_DECLS_END
101
102#undef GBL_SELF_TYPE
103
104#endif // EVMU_BATTERY_H
#define EVMU_EXPORT
Define used for adding attributes to export public symbols.
Definition evmu_api.h:18
GblType EvmuBattery_type(void)
Returns the GblType UUID associated with EvmuBattery.
#define GBL_BOOL_TYPE
#define GBL_PROPERTIES(object,...)
uint8_t GblBool
uintptr_t GblType
GblInstance structure for the battery peripheral.
void EvmuBattery_setMonitorEnabled(EvmuBattery *pSelf, GblBool enabled)
Enables or disables the system BIOS low battery monitor, based on the enabled value.
GblBool EvmuBattery_lowAlarm(const EvmuBattery *pSelf)
Returns GBL_TRUE if the low voltage battery detection signal is asserted.
void EvmuBattery_setLowAlarm(EvmuBattery *pSelf, GblBool enabled)
Sets the low battery detection circuit alarm to the enabled value.
GblBool EvmuBattery_monitorEnabled(const EvmuBattery *pSelf)
Returns GBL_TRUE if the system BIOS low battery monitor is enabled.
#define GBL_CLASS_CAST(cType, klass)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)