請先看『使用說明』
DPC Module:DPC under Linux
From LEXWiKi
| Line 35: | Line 35: | ||
Exit : Exit the program.  | Exit : Exit the program.  | ||
| - | |||
== Sample Code Introduction ==  | == Sample Code Introduction ==  | ||
| - | //----------------------------------------------------------------------------------  | + | 1. Define SMBus register   | 
| - | #define	HST_STS	  | + |   typedef unsigned char  BYTE;  | 
| - | #define	HST_CNT	  | + |   typedef unsigned short WORD;  | 
| - | #define	HST_CMD	  | + |   typedef unsigned long  DWORD;  | 
| - | #define	XMIT_SLVA	0x04	// SMBus Host Address	  | + |   #define m_SMBusMapIoAddr 0x0500  | 
| - | #define	HST_D0	  | + |   //----------------------------------------------------------------------------------  | 
| - | //----------------------------------------------------------------------------------  | + |   #define HST_STS	0x00	// SMBus Host Status        Register Offset  | 
| - | #define SADD	0xb0  | + |   #define HST_CNT	0x02	// SMBus Host Contorl       Register Offset  | 
| - | #define PWMFeq	0x01  | + |   #define HST_CMD	0x03	// SMBus Host Command 	    Register Offset  | 
| - | #define PWMDuty	0x02  | + |   #define XMIT_SLVA	0x04	// SMBus Host Address	    Register Offset  | 
| + |   #define HST_D0	0x05	// SMBus Host Data0         Register Offset  | ||
| + |   //----------------------------------------------------------------------------------  | ||
| + |   #define SADD	        0xb0  | ||
| + |   #define PWMFeq	0x01  | ||
| + |   #define PWMDuty	0x02  | ||
| + | |||
| + | 2. SMBusIoWrite  | ||
| + |   void SMBusIoWrite(BYTE byteOffset,BYTE byteData)  | ||
| + |   {  | ||
| + |       outb( byteData , m_SMBusMapIoAddr + byteOffset);  | ||
| + |   }  | ||
| + | |||
| + | 3. SMBusIoRead  | ||
| + |   BYTE SMBusIoRead(BYTE byteOffset)  | ||
| + |   {  | ||
| + |       DWORD dwAddrVal;  | ||
| + |       dwAddrVal = inb(m_SMBusMapIoAddr + byteOffset);  | ||
| + |       return (BYTE)(dwAddrVal & 0x0FF);  | ||
| + |   }  | ||
| + | |||
| + | 4. SetDutyCycle  | ||
| + |   void SetDutyCycle(gint iDutyValue)  | ||
| + |   {  | ||
| + |       DWORD dwPortVal;  | ||
| + |       SMBusIoWrite(HST_STS, 0xFE);  | ||
| + |       SMBusIoWrite(XMIT_SLVA, SADD);  | ||
| + |       SMBusIoWrite(HST_CMD, PWMDuty);  | ||
| + |       dwPortVal = SMBusIoRead (HST_STS);  | ||
| + |       dwPortVal = dwPortVal & 0x01;  | ||
| + |       SMBusIoWrite(HST_D0, iDutyValue);  | ||
| + |       SMBusIoWrite(HST_CNT, 0x48);  | ||
| + |   }  | ||
| + | |||
| + | 5. SetFrequency  | ||
| + |   void SetFrequency(gint iFrequency)  | ||
| + |   {  | ||
| + |       DWORD dwPortVal;  | ||
| + |       SMBusIoWrite(HST_STS, 0xFE);  | ||
| + |       SMBusIoWrite(XMIT_SLVA, SADD);  | ||
| + |       SMBusIoWrite(HST_CMD, PWMFeq);  | ||
| + |       dwPortVal = SMBusIoRead (HST_STS);  | ||
| + |       dwPortVal = dwPortVal & 0x01;  | ||
| + |       SMBusIoWrite(HST_D0, iFrequency);  | ||
| + |       SMBusIoWrite(HST_CNT, 0x48);  | ||
| + |   }  | ||
Revision as of 11:03, 14 April 2009
The Sample code source you can download from
Source file: DPCv2.4.1L.tar.gz
Binary file: DPC-binv2.4.1L.tar.gz
How to use this Demo Application
1. execute the ap, it will showed in system bar
2. Content explanation
Panel Type : Select panel what you try to adjust
Duty cycle : Brightness control, from 10 to 100
Select Area : After pressed this button, show another dialog which for you can select an area to light on panel
Panel off : light off the panel, (if you try to light on panel again, just click selected area or hotkey)
Hotkey Setting: Setting hotkey to light on panel, press the "OK" button after setting to completed
Install : Set the system to autorun this application when booting
Uninstall : Remove autorun this application when booting.
Exit : Exit the program.
Sample Code Introduction
1. Define SMBus register
typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned long DWORD; #define m_SMBusMapIoAddr 0x0500 //---------------------------------------------------------------------------------- #define HST_STS 0x00 // SMBus Host Status Register Offset #define HST_CNT 0x02 // SMBus Host Contorl Register Offset #define HST_CMD 0x03 // SMBus Host Command Register Offset #define XMIT_SLVA 0x04 // SMBus Host Address Register Offset #define HST_D0 0x05 // SMBus Host Data0 Register Offset //---------------------------------------------------------------------------------- #define SADD 0xb0 #define PWMFeq 0x01 #define PWMDuty 0x02
2. SMBusIoWrite
 void SMBusIoWrite(BYTE byteOffset,BYTE byteData)
 {
     outb( byteData , m_SMBusMapIoAddr + byteOffset);
 }
3. SMBusIoRead
 BYTE SMBusIoRead(BYTE byteOffset)
 {
     DWORD dwAddrVal;
     dwAddrVal = inb(m_SMBusMapIoAddr + byteOffset);
     return (BYTE)(dwAddrVal & 0x0FF);
 }
4. SetDutyCycle
 void SetDutyCycle(gint iDutyValue)
 {
     DWORD dwPortVal;
     SMBusIoWrite(HST_STS, 0xFE);
     SMBusIoWrite(XMIT_SLVA, SADD);
     SMBusIoWrite(HST_CMD, PWMDuty);
     dwPortVal = SMBusIoRead (HST_STS);
     dwPortVal = dwPortVal & 0x01;
     SMBusIoWrite(HST_D0, iDutyValue);
     SMBusIoWrite(HST_CNT, 0x48);
 }
5. SetFrequency
 void SetFrequency(gint iFrequency)
 {
     DWORD dwPortVal;
     SMBusIoWrite(HST_STS, 0xFE);
     SMBusIoWrite(XMIT_SLVA, SADD);
     SMBusIoWrite(HST_CMD, PWMFeq);
     dwPortVal = SMBusIoRead (HST_STS);
     dwPortVal = dwPortVal & 0x01;
     SMBusIoWrite(HST_D0, iFrequency);
     SMBusIoWrite(HST_CNT, 0x48);
 }
						
			
		


