8 jida32 windows, Programming, Pitx-sp software guide – Kontron pITX-SP User Manual

Page 46: 1 program language c, Example

Advertising
background image

KTD-S0003-C

Page 42

JIDA32 Interface


p

ITX-SP Software Guide

11.8 JIDA32 Windows

®

Programming

For further information see the actual JIDA32 documentation (JIDA32.pdf).

11.8.1 Program Language C

The demo program reads and shows the board name and the first 16 bytes of SPD EEPROM (SMBus). The
program uses the static linked library JIDA.LIB.

Example:

#include <windows.h>
#include "jida.h"

#define I2C_BUS 1
#define DEV_ADDR 0xA0

INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
BOOL

bRet;

HJIDA hJida = (DWORD) NULL;

CHAR

szStr1

[128],

szStr2

[32],

szVal

[JIDA_BOARD_MAX_SIZE_ID_STRING];

UCHAR

uVal

[32];

if (JidaDllInitialize ())

{

if (JidaDllIsAvailable ())

{

if (JidaBoardOpen (JIDA_BOARD_CLASS_CPU, 0, JIDA_BOARDINFO_FLAGS_DEFAULT, &hJida))

{

bRet = JidaBoardGetName (hJida, (LPTSTR) szVal, JIDA_BOARD_MAX_SIZE_ID_STRING);

wsprintf

(szStr1,

"JidaBoardGetName = %d / %s", bRet, szVal);

lstrcpy

(szStr2,

"DEMO");

MessageBox (NULL, szStr1, szStr2, MB_OK | MB_ICONEXCLAMATION);

JidaI2CRead (hJida, I2C_BUS, DEV_ADDR, (LPBYTE) &uVal[0], 16);

wsprintf (szStr1, "JidaI2CRead = %02X %02X %02X %02X %02X %02X %02X %02X",

uVal[0], uVal [1], uVal[2], uVal [3],

uVal[4], uVal [5], uVal[6], uVal [7]);

MessageBox (NULL, szStr1, szStr2, MB_OK | MB_ICONEXCLAMATION);

JidaBoardClose

(hJida);

}

}

JidaDllUninitialize

();

}

return (INT) FALSE;

}

Advertising