前一段时间完成电池驱动,下面是一点心得,贴出来供大家参考:
1.
将样本代码拷到BSP的DRIVERS目录下。
2. 修改DRIVERS目录下dirs文件,加上Battdrvr目录。
3.
修改FILES目录下的platform.reg文件,增加如下
IF BSP_NOBATTERY !
; HIVE BOOT
SECTION
[HKEY_LOCAL_MACHINE\System\Events]
"SYSTEM/BatteryAPIsReady"="Battery Interface APIs"
; END HIVE BOOT
SECTION
; These registry entries load the battery driver. The IClass value
must match
; the BATTERY_DRIVER_CLASS definition in battery.h -- this is how
the system
; knows which device is the battery driver. Note that we are using
; DEVFLAGS_NAKEDENTRIES with this driver. This tells the device manager
;
to instantiate the device with the prefix named in the registry but to look
;
for DLL entry points without the prefix. For example, it will look for Init
;
instead of BAT_Init. This allows the prefix to be changed in the registry
(if
; desired) without editing the driver
code.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery]
"Prefix"="BAT"
"Dll"="battdrvr.dll"
"Flags"=dword:8 ;
DEVFLAGS_NAKEDENTRIES
"Order"=dword:0
"IClass"="{DD176277-CD34-4980-91EE-67DBEF3D8913}"
ENDIF BSP_NOBATTERY !
4.
修改FILE目录下的platform.dat文件,增加如下:
battdrvr.dll
$(_FLATRELEASEDIR)\battdrvr.dll NK
SH
5.修改battif.c文件,在BatteryPDDGetStatus函数中增加获取电池状态的相关代码。
我主要是对BatteryPDDGetStatus做了点修改,去掉了AC的检测。AD的设定。
参考附件:备注:程序版权为wince_lover所有,我仅仅是在他的基础上改了一点点。下次我对这个程序做个分析。
 |
文件: | Battdrvr.rar |
大小: | 17KB |
下载: | 下载 |
|