116
Programming System and Application with Windows CE for Mobile Baek Jong Ho [email protected]

Programming System and Application with Windows CE for Mobile Baek Jong Ho [email protected]

Embed Size (px)

Citation preview

Page 1: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

Programming System and Application

with Windows CE for Mobile

Baek Jong [email protected]

Page 2: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Lecturer’s Info

Devpia Mobile Section SYSOP (2006)데브부산 - 데브피아 시삽과 함께한 SW 콘서트 ( 부산 ) 데브피아 - 데브피아 시삽과 함께하는 S/W 콘서트 ( 서울 )

TecAce Research Engineer (August, 2003 ~ Current)Samsung Festival Project (GSM i720) -Development Environment: MS Windows Mobile PPC Phone 6.0-Development Software: Camera Driver Samsung Qingdao Project (GSM i718)-Development Environment: MS Windows Mobile PPC Phone 5.0-Development Software: Camera ApplicationSamsung Demo Project with Texas Instrument OMAP Processor -Development Environment: MS Windows Mobile PPC 5.0 -Development Software: Camera Application and Driver Samsung Kiron Project-Development Environment: MS Windows Mobile PPC Phone 5.0-Development Software: Camera Device Driver and LCD Driver for MS Windows Mobile 5.0Samsung B-Bop Project (GSM i750)-Development Environment: MS Windows Mobile PPC Phone 2003-Development Software: Camera and Camcorder SoftwareSamsung Magellan Project (GSM i270)-Development Environment: MS Windows Mobile Smart Phone 2003-Development Software: Photo Album, File Explorer, Camera Assist, and Bluetooth Software

Working Experiences: (March, 2001 ~ December, 2001)Development of Security System Software for Yeong-gwang power plant in KoreaDevelopment of Security System Software for Yeo-ju prison in KoreaDevelopment of Digital Card System for Pusan Subway

Page 3: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Agenda

Part I. Building Powerful Platforms with Windows CE for Mobile

Part II. Development of Device Driver and Application with Windows CE for Mobile

Part III. Programming Camera With Windows CE for Mobile

Page 4: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Agenda (Part I)

Part I-1. About Windows Mobile

Part I-2. Build Process of Windows Mobile

Part I-3. Booting Sequence of Windows Mobile

Part I-4. Making Pocket PC with Windows Mobile (Demo)

Page 5: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-1. About Windows Mobile

Windows CE : MS 사가 개발한 PDA, CNS(Car Navigation System), 셋탑박스 , 스마트폰 등에 사용되게 만들어진 임베디드용 운영체제

임베디드 기기에 맞게 사용자의 취향에 맞추어 선택적 제작 가능

임베디드 시스템에 주로 사용되기 때문에 제한적인 하드웨어 환경에서 주로 사용됨

Page 6: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-1. About Windows Mobile (Conts.)

Page 7: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-1. About Windows Mobile (Conts.)

Host PC

AKU and Platform Builder

BSP(Board Support

Package)

Windows CE Basic Sources

+

Build and Makeimgon AKU

New Image(NK.BIN)

Downloading the NK.BIN

Page 8: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-2. Build Process of Windows Mobile

I-2.1 Directory Structure and Initialization Files

I-2.2 Building a Project: Builddemo.bat

I-2.3 Generating the Windows CE System: Sysgen.bat

I-2.4 Building OEM Source code: Build.exe

I-2.5 Making the Windows CE Image: Makeimg.exe

Page 9: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.1 Directory Structure and Initialization Files

PLATFORM(BSP)

OTHERS

PUBLIC

RELEASE

DEVELOPR

WM500(AKU)

Page 10: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.1 Directory Structure and Initialization Files (Cont.)

Binary Image Builder Files (BIB Files)

Registry Initialization (REG Files)

RAM Initialization (DAT Files)

Database initialization (DB Files)

Page 11: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.2 Building a Project: Builddemo.bat

Generate the Windows CE system(Sysgen.bat)

Build All Modules in the _TARGETPLATROOT directory

(Build.exe)

Move Log Files for Build Message Into_WINCEROOT

Copy Built Targets Into_FALSTRELEASEDIR

(Buildrel.bat)

Make the Final Windows CE Image(Makeimg.exe)

Found Errors

Page 12: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.3 Generating the Windows CE System: Sysgen.bat (cefilter.exe)

Read Header Files

Look for @CESYSGEN tag

Read <module>_<component>Label after tag

Keep lines up to next @CESYSGEN tag

Discard lines up to next @CESYSGEN tag

Look for substring <components>In environment variable

<module>_COMPONENTS

Found substring Substring not found

Read BIB File

Look for @CESYSGEN tag

Read CE_MODULES_<module>Label after tag

Keep lines up to next @CESYSGEN tag

Discard lines up to next @CESYSGEN tag

Look for substring <module>Label after tag

Found substring Substring not found

Page 13: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.4 Building OEM Source code: Build.exe

Set Current Working Directory

Look for Dirs file

Look for Sources file

Call Nmake

[Found Sources file][Found Dirs file]

Read next working directory from file

[No Dirs file]

[next working directory found]

Page 14: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-2.5 Making the Windows CE Image: Makeimg.exe

Config.bib

Common.bib

Platform.bib

Project.bib

Common.db

Platform.db

Project.db

Common.dat

Platform.dat

Project.dat

Common.reg

Platform.reg

Project.reg

Create binaryInformationBuilder file

Create databaseInitialization file

Create RAMFile system

Initialization file

Create registry Initialization file

ce.bib

initobj.ini

reginit.ini

initobj.dat

Initobj.tmp

Convert stringsin RAM from ANSI

To Unicode

Compress registry Initialization file

Create binary Image

Default.fdf

Resolve link dependencies

between modules

Nk.bin

Page 15: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-3. Booting Sequence of Windows Mobile

I-3.1 BSP (Board Support Package)

I-3.2 Booting Sequence of Windows Mobile

Page 16: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.1 BSP (Board Support Package)

OAL source codes

Device Driver source codes

Application source codes

Boot Loader source codes

EBOOT OALDevice Driver

Windows CE OS

Application

H/W

BSP Device

Hardware Engineer

System Engineer

Application Engineer

Page 17: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile

ONBL1

ONBL2

EBOOT

IPL(Initial Program Loader)

Kernel

OneNAND Specific

Load Modules and Device Drivers

Test Codes and Download New Image function

ULDR (Update Loader) functionand Launch Kernel

Page 18: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): ONBL

File: Onbl1.bib

MEMORY; Name Start Size Type; ------ ------ ----- ----- ONBL1 00000000 00000800 RAMIMAGE STACK A0100000 00005000 RESERVED RAM A0105000 00005000 RAM

Onbl2.bibMEMORY; Name Start Size Type; ------ ------ ----- ----- ONBL2 A010A000 00020000 RAMIMAGE STACK A012A000 00010000 RESERVED RAM A013A000 00020000 RAM

Page 19: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): ONBL

ONBL1\Startup.s

b ResetHandler ...bl Init_Mem ... Ldr r2,=0x02000110;CCCR;208MHz ...bl OneNandRead ... ONBL2_BASE_ADDRESS EQU 0xA010A000 ... lDR R0,=ONBL2_BASE_ADDRESS Mov pc,r0

ONBL2\Startup.s

ldr sp,=0xA012A000bl main ;Jump to main.c::main(),

ONBL2\Main.c

Main(){ SetupCopySection(); ... InitDebugSerial(); ... BML_Init(); ... BML_Open(); ... ShadowEboot();}

... ReadImage(); ... OEMLaunchImage();EBOOT

Page 20: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): EBOOT

Eboot.bib

MEMORY; Name Start Size Type; ------ ------ ----- ----- RAM 83F00000 00100800 RAM EBOOT 83E00000 00100000 RAMIMAGE

EBOOT\Startup.s

...; Enable the MMU.mcr p15, 0, r1, c1, c0, 0; MMU ON: All memory accesses are now virtaul

; Jump to the virtaul address of the 'VirtualStart‘; label.mov pc, r2 ...; Jump to the C entrypoint;bl main; Jump to main.c::main(), never to return...

EBOOT main()

Page 21: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): EBOOT

EBOOT\Main.c

Main(){ BootloaderMain(); ...}

BLCOMMON\Blcommon.c

BootloaderMain(){ KernelRelocate(); ... OEMDebugInit(); ... OEMPlatformInit(); ... OEMPreDownload(); ... DownloadImage(); ... OEMLaunch(); ...}

... FlashInit(); ... LoadEBootCFG(); ...

... ReadIPL(); ... dwLaunchAddr = IPL_START_VA; ... Launch();IPL

Page 22: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): IPL

IPL.bib

MEMORY; Name Start Size Type; ------ ------ ----- ----- RAM A3D40000 00040000 RAM IPL A3D00000 00040000 RAMIMAGE BPART_BUF A3D80000 00080000 RESERVED

IPL\Startup.s

; Jump to the C entrypoint.;bl main; Jump to main.c::main(), never to return...

IPL\Main.c

Main(){ IPLmain();}

IPLmain(){ OEMIPLInit(); ... OEMGetUpdateMode(); ... OEMTranslateBaseAddress(); ... OEMLaunchImage();}

Kernel

Page 23: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): Kernel

Config.bibMEMORY; Building the traditional 'NK'; Name Start Size Type; ------ ------ ----- ----- RSVD 80000000 000C0000 RESERVED DEBUG_MSG 800C0000 0003E000 RESERVED DRV_GLB 800FE000 00001000 RESERVED ARGS 800FF000 00001000 RESERVED NK 80100000 03000000 RAMIMAGE RAM 83100000 00EFF000 RAM DMA 83FFF000 00001000 RESERVED

OAL\Startup.s

...b KernelStart

OAL\Init.c

OEMInit(){ ... OALIntrInit(); ...}

... OALIoCtlHalInitRTC(); ... OEMSetRealTime(); ... OALIoCtrlPocketStoreCMD(); ... PSII_HALWrapper();

Page 24: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): SDRAM

ONW

DBG_MSG

DRV_GLB

ARGS

ONBL1

ONBL2

DBG_MSG

DRV_GLB

ARGS

Reserved

IPL

EBOOT

RAM

0xA000_0000

0xA00C_0000

0xA00F_E000

0xA00F_F000

0xA010_0000

0xA010_A000

0xA3D0_0000

0xA3E0_0000

0xA3F0_0000

0xA400_0000

0x8000_0000

0x800C_0000

0x800F_E000

0x800F_F000

0x8010_0000

0x8310_0000

0x8400_0000

NK

NK RAM

Physical Address Virtual Address

Booting OS

Page 25: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

I-3.2 Booting Sequence of Windows Mobile (Cont.): OneNAND

#0

#1

#9

#11

#490

#999#1000

#1001

#1024

ONBL1

ONBL2

EBOOT

IPL

OS

File Sys

EBOOT CFG

4 Scts : 2KB

252 Scts : 126KB

8 Blk : 1MB

2 Blk : 256KB

479 Blk : 60MB – 128KB

510 Blk : 63MB

1 Blk : 128KB

1 Blk : 128KB

23 Blk : 2.8MB

128 MB

Page 26: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

Set up Platform Builder for Windows Mobile 5.0

New Build Window Wizard of PB

Build All DEVICEEMULATOR BSP to make diskimage.nb0

Install Microsoft Loopback Adapter

Set up Target Device Connectivity Option of PB

Downloading Image to Device Emulator

Page 27: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 28: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 29: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 30: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 31: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 32: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 33: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 34: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)To install the Microsoft Loopback Adapter in Microsoft

Windows XP

1. Open Control Panel, choose Add Hardware, and then choose Next.

2. Choose Yes, I have already connected the hardware, and then choose Next.

3. From the Installed hardware list, select Add a new hardware device, and then choose Next.

4. Choose Install the hardware that I manually select from a list (Advanced), and then choose Next.

5. From the Common hardware types list, select Network adapters, and then choose Next.

6. From the Manufacturer list, select Microsoft. 7. From the Network Adapter list, select Microsoft Loopback

Adapter, and then choose Next. 8. Choose Next, and then choose Finish.

Page 35: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 36: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 37: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 38: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 39: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 40: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 41: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 42: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 43: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 44: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 45: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 46: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 47: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 48: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 49: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 50: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 51: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 52: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 53: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part I-4. Making Pocket PCwith Windows Mobile (Demo)

(Cont.)

Page 54: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Agenda (Part II)

Part II-1. Development of Windows Mobile Device Driver

Part II-2. Development of Windows Mobile Application

Part II-3. Communication Sequence on Windows Mobile

Part II-4. Communication between Device Driver and Application (Demo)

Page 55: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver

Stream Interface Device Driver: 응용 프로그램이 디바이스를 하나의 ‘파일’처럼 관리하는 방식으로 , Device Driver 의 Prefix 및 Index 를 이용 , Driver 로 연결하는 방식을 사용함 .

Application Windows CE H/W MDD

PDD

Device Driver

Page 56: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.)

Prefix and Index of Device Driver in REG file

- File: Hoya_Drv\hoya.reg[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Hoya]"Prefix"="HYA""Dll"="hoya.dll" "Order"=dword:1"Index"=dword:1

- File: DEVICEEMULATOR\FILES\Platform.reg; -----------------------------------------------; Hoya Driver#include "$(_TARGETPLATROOT)\SRC\DRIVERS\Hoya_Drv

\hoya.reg"

Page 57: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.)

MDD Layer of Device Driver HYA_Init <-Windows CE SystemBooting HYA_Open <- CreateFile(L”HYA1:”, ..); HYA_IOControl <- DeviceIoControl(hDevice,..); HYA_Close <- CloseHandle(hDevice); HYA_DeInit <- Windows CE System Down HYA_Read HYA_Write HYA_Seek HYA_PowerDown<- System go to Sleep HYA_PowerUp <- System Wake Up

Page 58: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.) : Hoyamdd.c

BOOL WINAPI HYA_Init(void){

HoyaHW_Init(); InitializeCriticalSection(&csHoya);

return TRUE;}

Page 59: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.) : Hoyamdd.c

BOOL HYA_Open(DWORD dwData, DWORD dwAccess, DWORD dwShareMode){ if(dwAccess == 0x0) return TRUE;

EnterCriticalSection(&csHoya); if(!HoyaHW_Enable()) { LeaveCriticalSection(&csHoya); return FALSE; } LeaveCriticalSection(&csHoya); return TRUE;}

Page 60: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.) : Hoyamdd.c

BOOL HYA_IOControl(., DWORD dwCode, PBYTE pBufIn,., PBYTE pBufOut,..){ P_HOYA_APP_T appContext;

switch( dwCode ) {

case HOYA_IOCTL_APP_RUN: appContext = (P_HOYA_APP_T)pBufIn; HoyaHW_SetAppState(appContext->AppStatus); uError = HOYA_ERROR_SUCCESS; *pBufOut = uError; break;

case HOYA_IOCTL_APP_STOP: appContext = (P_HOYA_APP_T)pBufIn; HoyaHW_SetAppState(appContext->AppStatus); uError = HOYA_ERROR_SUCCESS; *pBufOut = uError; break;:

} return TRUE;}

Page 61: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.) : Hoyamdd.c

BOOL HYA_Close(DWORD dwData) {

EnterCriticalSection(&csHoya); HoyaHW_Disable(); LeaveCriticalSection(&csHoya);

return TRUE; }

Page 62: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-1. Development of Windows Mobile Device Driver (Cont.)

PDD Layer of Device Driver: Hoyapdd.c HoyaHW_Init <- HYA_Init HoyaHW_Enable <- HYA_Open HoyaHW_SetAppState <- HYA_IOControl HoyaHW_Disable <- HYA_Close

Page 63: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-2. Development of Windows Mobile Application

Making Program sources using Windows API

MUI (Multilingual User Interface) for each countryEx) Camera.exeCamera.exe.0409.mui (English), Camera.exe.040c.mui (France), Camera.exe.0407.mui (German)

Using eMbedded Visual C++ 4.0 and Visual Studio 2005

Page 64: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-2. Development of Windows Mobile Application (Cont.): Hoya_DrvApi.cpp

static HANDLE hDevice = NULL;

HOYARESULT HYA_Open(HDRIVER *hDrv){

hDevice = CreateFile(L"HYA1:", GENERIC_READ|GENERIC_WRITE, 0, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,

NULL);

if(hDevice)*hDrv = hDevice;

elsereturn HDRIVER_ERROR;

return HDRIVER_SUCCESS;}

Page 65: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-2. Development of Windows Mobile Application (Cont.): Hoya_DrvApi.cpp

HOYARESULT HYA_Close(HDRIVER hDrv){

CloseHandle(hDrv);return HDRIVER_SUCCESS;

}

- File: Hoya_App\Hoya_ioctl.henum{

HOYA_IOCTL_APP_RUN = 0,HOYA_IOCTL_APP_STOP

};

Page 66: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-2. Development of Windows Mobile Application (Cont.): Hoya_DrvApi.cpp

HOYARESULT HYA_SetAppState(P_HOYA_APP_T pApp){

HOYARESULT nHoyaResult = 0;BYTE pECode;

if(pApp->AppStatus == APP_STATE_RUN)DeviceIoControl(hDevice, HOYA_IOCTL_APP_RUN, pApp, 0, &pECode, 1, NULL,

NULL);else if(pApp->AppStatus == APP_STATE_STOP)

DeviceIoControl(hDevice, HOYA_IOCTL_APP_STOP, pApp, 0, &pECode, 1, NULL,

NULL);

switch( (int) pECode ){case HDRIVER_SUCCESS:

nHoyaResult = HDRIVER_SUCCESS;break;

case HDRIVER_ERROR:nHoyaResult = HDRIVER_ERROR;break;

}return nHoyaResult;

}

Page 67: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-3. Communication Sequence on Windows Mobile

CE Kernel

Registry

Perform basic Platform initialization

Initialize object store

Device ManagerLoad Device Manager EXE Enumerate

HKLM\Drivers\Builtin

Return Builtin keys

Determine load order

Assign device file Name prefix Using Prefix and Index subkeys

RegisterDevice

Page 68: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-3. Communication Sequence on Windows Mobile

(Cont.)CE Kernel

Device Manager

Onboard DeviceStream-Interface

DriverLoad stream-interfaceDriver

HYA_Init Initialize built-in device

Place device contextIn heap memory

Pointer to device context cast as DWORD

CreateFile(L"HYA1:",..);HYA_Open

Perform secondary initialization of built-in device

Pointer to device contextas DWORDPointer to device context

As HANDLEHandlereturn from CreateFile

Page 69: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) Making Directory and Source files of Hoya_Drv Driver

Making Dir, Sources, Def, REG files for Hoya_Drv Driver

Modification of Platform BIB and REG files

Build Hoya_Drv Driver and Makeimg

Run Hoya_App

Page 70: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 71: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 72: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 73: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 74: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 75: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 76: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 77: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 78: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 79: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 80: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 81: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 82: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 83: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 84: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 85: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 86: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 87: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part II-4. Communication between Device Driver and Application

(Demo) (Cont.)

Page 88: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Agenda (Part III)

Part III-1. Camera Architecture

Part III-2. Camera Application Architecture

Part III-3. Camera on My Pocket PC (Demo)

Part III-4. Summary

Part III-5. Q&A

Page 89: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-1. Camera Architecture

Three-pin camera driver Two-pin camera driver

Page 90: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-2. Camera Application Architecture

III-2.1 Capture Device Selection

III-2.2 Build Graph with Capture Graph Builder

III-2.4 Set Up Video Window

III-2.5 Start Preview

Page 91: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.1 Capture Device Selection

Create Capture Filter

Capture Device Selection

Send Device Name to Capture Filter

Page 92: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.1 Capture Device Selection (Cont.)

// Create Capture Filterhr = CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC_SERVER,IID_IBaseFilter, (void **)&gcap.pCap);

GUID clsid = DEVCLASS_CAMERA_GUID;DEVMGR_DEVICE_INFORMATION pdi;HANDLE hand = FindFirstDevice(DeviceSearchByGuid,&clsid,&pdi);

hr = gcap.pCap->QueryInterface(IID_IPersistPropertyBag, (void **)&pPropertyBag);

VARIANT varCamName;IPropertyBag *propBag = NULL;varCamName.byref = L"CAM1:" ;

pPrepertyBag->Write( L"VCapName", &varCamName ); hr = pPropertyBag->Load(propBag,NULL);pPropertyBag->Release();

Page 93: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.2 Build Graph with Capture Graph Builder

Create Filter Graph Manager

Create Capture Graph Builder

Create Video Renderer for Preview

Add Filters to Filter Graph Manager

Connect Video Source filter to Render Filter for Preview

Page 94: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.2 Build Graph with Capture Graph Builder (Cont.)

hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&gcap.pGraph);

hr = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,

(void **)&gcap.pBuilder);

gcap.pBuilder->SetFiltergraph(gcap.pGraph);

hr = CoCreateInstance(CLSID_VideoRenderer, NULL,CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&gcap.pRenderP);

hr = gcap.pGraph->AddFilter(gcap.pCap,L"Video Capture Source");hr = gcap.pGraph->AddFilter(gcap.pRenderP,L"Video Render1");

Page 95: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.2 Build Graph with Capture Graph Builder (Cont.)

hr = gcap.pBuilder->RenderStream (&PIN_CATEGORY_PREVIEW,

&MEDIATYPE_Video, gcap.pCap, NULL, gcap.pRenderP);

hr = gcap.pRenderP->QueryInterface (IID_IVideoWindow, (void**)&gcap.pVWP);

hr = gcap.pRenderP->QueryInterface (IID_IDirectDrawVideo, (void **)&gcap.pDdrawVideoP);

Page 96: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.4 Set Up Video Window

Set Up Owner of Video Window

Set Up Window Style of Video Window

Put Window Size using IVideoWindow Interface

Page 97: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.4 Set Up Video Window (Cont.)

IVideoWindow *pVW

hr = pVW->put_Owner((OAHWND)hWndApp) ;hr = pVW->put_WindowStyle(WS_CHILD);

GetClientRect(hWndApp, &rt);pVW->put_Left(rt.left);pVW->put_Top(rt.top);pVW->put_Width(rt.right-rt.left);pVW->put_Height(rt.bottom-rt.top);

Page 98: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.5 Start Preview

Get Media Control Interface of Filter Graph Manager

Control Media Stream using IMediaControl Interface

Page 99: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

III-2.5 Start Preview (Cont.)

IMediaControl *pMC = NULL; hr = gcap.pGraph->QueryInterface(IID_IMediaControl, (void **)&pMC); if(SUCCEEDED(hr)) { hr = pMC->Run(); if(FAILED(hr))

pMC->Stop();

pMC->Release(); }

if(FAILED(hr)) { return FALSE; }

gcap.pVWP->put_WindowState(SW_SHOW);

Page 100: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo)

Making Directory and Source files of Camera Driver

Making Dir, Sources, Def, REG files for Camea Driver

Modification of Platform BIB and REG files

Build Camera Driver and Makeimg

Run DDCam Application

Page 101: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 102: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 103: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 104: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 105: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 106: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 107: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 108: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 109: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 110: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 111: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 112: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 113: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 114: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-3. Camera on My Pocket PC (Demo) (Cont.)

Page 115: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-4. Summary

Build Process and Booting Sequence

Device Driver and Application Programming

Camera Programming

Page 116: Programming System and Application with Windows CE for Mobile Baek Jong Ho icanmobile@tecace.com

[email protected]

Part III-5. Q&A