Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 2000,2001 Microsoft Corporation
  3. Module Name:
  4. battinfo.h
  5. Abstract: Contains Smart Battery Information definitions.
  6. Environment:
  7. User mode
  8. Author:
  9. Michael Tsang (MikeTs) 23-Jan-2001
  10. Revision History:
  11. --*/
  12. #ifndef _BATTINFO_H
  13. #define _BATTINFO_H
  14. //
  15. // Constants
  16. //
  17. #define SMB_BATTERY_ADDRESS 0x0b //Address on bus (0x16)
  18. // Battery commands
  19. #define BATTCMD_MANUFACTURER_ACCESS 0x00
  20. #define BATTCMD_REMAININGCAP_ALARM 0x01
  21. #define BATTCMD_REMAININGTIME_ALARM 0x02
  22. #define BATTCMD_BATTERY_MODE 0x03
  23. #define BATTCMD_ATRATE 0x04
  24. #define BATTCMD_ATRATE_TIMETOFULL 0x05
  25. #define BATTCMD_ATRATE_TIMETOEMPTY 0x06
  26. #define BATTCMD_ATRATE_OK 0x07
  27. #define BATTCMD_TEMPERATURE 0x08
  28. #define BATTCMD_VOLTAGE 0x09
  29. #define BATTCMD_CURRENT 0x0a
  30. #define BATTCMD_AVG_CURRENT 0x0b
  31. #define BATTCMD_MAX_ERROR 0x0c
  32. #define BATTCMD_REL_STATEOFCHARGE 0x0d
  33. #define BATTCMD_ABS_STATEOFCHARGE 0x0e
  34. #define BATTCMD_REMAININGCAP 0x0f
  35. #define BATTCMD_FULLCHARGECAP 0x10
  36. #define BATTCMD_RUNTIMETOEMPTY 0x11
  37. #define BATTCMD_AVGTIMETOEMPTY 0x12
  38. #define BATTCMD_AVGTIMETOFULL 0x13
  39. #define BATTCMD_CHARGING_CURRENT 0x14
  40. #define BATTCMD_CHARGING_VOLTAGE 0x15
  41. #define BATTCMD_BATTERY_STATUS 0x16
  42. #define BATTCMD_CYCLE_COUNT 0x17
  43. #define BATTCMD_DESIGN_CAP 0x18
  44. #define BATTCMD_DESIGN_VOLTAGE 0x19
  45. #define BATTCMD_SPEC_INFO 0x1a
  46. #define BATTCMD_MANUFACTURE_DATE 0x1b
  47. #define BATTCMD_SERIAL_NUM 0x1c
  48. #define BATTCMD_MANUFACTURER_NAME 0x20
  49. #define BATTCMD_DEVICE_NAME 0x21
  50. #define BATTCMD_DEVICE_CHEMISTRY 0x22
  51. #define BATTCMD_MANUFACTURER_DATA 0x23
  52. // Battery Mode bits
  53. #define BATTCAP_INTERNAL_CHARGE_CTRLER 0x0001
  54. #define BATTCAP_PRIMARY_BATT_SUPPORT 0x0002
  55. #define BATTMODE_CONDITIONING_REQUESTED 0x0080
  56. #define BATTMODE_CHARGE_CTRLER_ENABLED 0x0100
  57. #define BATTMODE_PRIMARY_BATTERY 0x0200
  58. #define BATTMODE_DIS_BROADCAST_CHARGER 0x4000
  59. #define BATTMODE_CAPMODE_POWER 0x8000
  60. //Battery Status bits
  61. #define BATTSTATUS_ERRCODE_MASK 0x000f
  62. #define BATTSTATUS_FULLY_DISCHARGED 0x0010
  63. #define BATTSTATUS_FULLY_CHARGED 0x0020
  64. #define BATTSTATUS_DISCHARGING 0x0040
  65. #define BATTSTATUS_INITIALIZED 0x0080
  66. #define BATTALARM_REMAINING_TIME 0x0100
  67. #define BATTALARM_REMAINING_CAP 0x0200
  68. #define BATTALARM_TERMINATE_DISCHARGE 0x0800
  69. #define BATTALARM_OVER_TEMP 0x1000
  70. #define BATTALARM_TERMINATE_CHARGE 0x4000
  71. #define BATTALARM_OVER_CHARGED 0x8000
  72. //Spec. Info bits
  73. #define SPECINFO_REVISION_MASK 0x000f
  74. #define SPECINFO_VERSION_MASK 0x00f0
  75. #define SPECINFO_VSCALE_MASK 0x0f00
  76. #define SPECINFO_IPSCALE_MASK 0xf000
  77. #define SPECINFO_REVISION(x) ((x) & SPECINFO_REVISION_MASK)
  78. #define SPECINFO_VERSION(x) (((x) & SPECINFO_VERSION_MASK) >> 4)
  79. #define SPECINFO_VSCALE(x) (((x) & SPECINFO_VSCALE_MASK) >> 8)
  80. #define SPECINFO_IPSCALE(x) (((x) & SPECINFO_IPSCALE_MASK) >> 12)
  81. //Manufacture Date bits
  82. #define MANUDATE_DAY_MASK 0x001f
  83. #define MANUDATE_MONTH_MASK 0x01e0
  84. #define MANUDATE_YEAR_MASK 0xfe00
  85. #define MANUDATE_DAY(x) ((x) & MANUDATE_DAY_MASK)
  86. #define MANUDATE_MONTH(x) (((x) & MANUDATE_MONTH_MASK) >> 5)
  87. #define MANUDATE_YEAR(x) ((((x) & MANUDATE_YEAR_MASK) >> 9) + \
  88. 1980)
  89. #include <pshpack1.h>
  90. typedef struct _BATT_INFO
  91. {
  92. USHORT wManufacturerAccess; //[00]Word R/W
  93. USHORT wRemainingCapAlarm; //[01]Word R/W (maH/10mwH)
  94. USHORT wRemainingTimeAlarm; //[02]Word R/W (minutes)
  95. USHORT wBatteryMode; //[03]Word R/W
  96. SHORT sAtRate; //[04]Word R/W (ma/10mw)
  97. USHORT wAtRateTimeToFull; //[05]Word R (minutes)
  98. USHORT wAtRateTimeToEmpty; //[06]Word R (minutes)
  99. USHORT wfAtRateOK; //[07]Word R (TRUE/FALSE)
  100. USHORT wTemperature; //[08]Word R (0.1K)
  101. USHORT wVoltage; //[09]Word R (mv)
  102. SHORT sCurrent; //[0a]Word R (ma)
  103. SHORT sAvgCurrent; //[0b]Word R (ma)
  104. USHORT wMaxError; //[0c]Word R (%)
  105. USHORT wRelStateOfCharge; //[0d]Word R (%)
  106. USHORT wAbsStateOfCharge; //[0e]Word R (%)
  107. USHORT wRemainingCap; //[0f]Word R (maH/10mwH)
  108. USHORT wFullChargeCap; //[10]Word R (maH/10mwH)
  109. USHORT wRunTimeToEmpty; //[11]Word R (minutes)
  110. USHORT wAvgTimeToEmpty; //[12]Word R (minutes)
  111. USHORT wAvgTimeToFull; //[13]Word R (minutes)
  112. USHORT wChargingCurrent; //[14]Word R (ma)
  113. USHORT wChargingVoltage; //[15]Word R (mv)
  114. USHORT wBatteryStatus; //[16]Word R
  115. USHORT wCycleCount; //[17]Word R (cycles)
  116. USHORT wDesignCap; //[18]Word R (maH/10mwH)
  117. USHORT wDesignVoltage; //[19]Word R (mv)
  118. USHORT wSpecInfo; //[1a]Word R
  119. USHORT wManufactureDate; //[1b]Word R
  120. USHORT wSerialNum; //[1c]Word R
  121. BLOCK_DATA ManufacturerName; //[20]Block R (string)
  122. BLOCK_DATA DeviceName; //[21]Block R (string)
  123. BLOCK_DATA DeviceChemistry; //[22]Block R (string)
  124. BLOCK_DATA ManufacturerData; //[23]Block R (bytes)
  125. } BATT_INFO, *PBATT_INFO;
  126. #include <poppack.h>
  127. #define TYPEF_WORD_CAP (TYPEF_USER + 0x00)
  128. #define TYPEF_WORD_RATE (TYPEF_USER + 0x01)
  129. #define TYPEF_WORD_STATUS (TYPEF_USER + 0x02)
  130. #define TYPEF_WORD_TEMP (TYPEF_USER + 0x03)
  131. #define TYPEF_WORD_SPECINFO (TYPEF_USER + 0x04)
  132. #define TYPEF_WORD_DATE (TYPEF_USER + 0x05)
  133. #define TYPEF_WORD_TIME (TYPEF_USER + 0x06)
  134. #define TYPEF_MANU_DATA (TYPEF_USER + 0x07)
  135. #define TYPEF_TEMP_CELSIUS (TYPEF_USER + 0x08)
  136. #define TYPEF_WORD_RESISTOR (TYPEF_USER + 0x09)
  137. #define CAP TYPEF_WORD_CAP
  138. #define RAT TYPEF_WORD_RATE
  139. #define MOD TYPEF_WORD_MODE
  140. #define STA TYPEF_WORD_STATUS
  141. #define TMP TYPEF_WORD_TEMP
  142. #define SPI TYPEF_WORD_SPECINFO
  143. #define DAT TYPEF_WORD_DATE
  144. #define TIM TYPEF_WORD_TIME
  145. #define MAN TYPEF_MANU_DATA
  146. #define TPC TYPEF_TEMP_CELSIUS
  147. #define RES TYPEF_WORD_RESISTOR
  148. #endif //ifndef _BATTINFO_H