請先看『使用說明』
DPC Module:DPC under Linux
From LEXWiKi
Contents |
The Sample code source you can download from
Source file: DPC_v3.0L_src.tar.gz
Binary file: DPC_v3.0L_bin.tar.gz
64bits
Source file: DPC_v3.0L_x64src.tar.gz
Binary file: DPC_v3.0L_x64bin.tar.gz
How to compile source code
1. Compile source code with Code::Blocks
Download and install the Code::Block with command "apt-get install codeblocks"
Open an exist project(DPC.cbp) in Code::Blocks, click the compile button
2. Compile source code with "make"
Before you make it
you need to install make make-guile pkg-config gcc gtk2.0
- cd DPC_v3.0L_src
- ./configure
- make
- src/dpc // execute the binary file
How to use this Demo Application
1. execute the ap, it will showed in system bar
2. Content explanation
3.Frequency of panel selection.
Sample Code Introduction
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
SMBusIoWrite
void SMBusIoWrite(BYTE byteOffset,BYTE byteData) { outb( byteData , m_SMBusMapIoAddr + byteOffset); }
SMBusIoRead
BYTE SMBusIoRead(BYTE byteOffset) { DWORD dwAddrVal; dwAddrVal = inb(m_SMBusMapIoAddr + byteOffset); return (BYTE)(dwAddrVal & 0x0FF); }
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); }
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); }