|
Re: Accessing GPIO pins: msg#00099windows.ce.devel
On Fri, 18 Nov 2005 06:24:33 -0800 (PST), Tom Convent <conventag@xxxxxxxxx> wrote: > Hello Rob, > With your hints I got VirtualAlloc and VirtualCopy funtions help. I > have written a sample code and Included here. > #define GPIO 0x40E00068 // physical addess of device You'll want to take a look at your bib files for the mapping of physical memory to virtual memory for the start address to use. > #define size 4800*4 //page size The page size is 4 kilobytes. For any size less than a full page, VA will return full 4K page(s). Check, but PAGE_SIZE should be defined somewhere. Basically, you'll want to find the start address for the physical memory region of your registers that you want to toggle. Look at the mapped address and start with a call to VA using that address and the number of pages necessary to at least encompass your register(s). > int set; You will want to use a DWORD (typedef'd to an unsigned long) for the memory allocation call to VirtualAlloc...and you likely want a DWORD pointer, as you're going to be returning a range of pages. > set = VirtualCopy(lps, GPIO, size, PAGE_READWRITE); // lps is handle > written by VirtualAlloc function > if I understand the functions correctly, I should write values to a > variable "set" to toggle GPIO pins, like > set = 0x64000000; // toggles GPIO pins ?? ...well, that definitely won't work! Look at what VirtualCopy returns...it returns a BOOL, which is typedef'd to int. Once you get a range of pages, you will want to access your pointer such that you use the offset into the range for your register(s). eg: #define BASE 0x40E00000 // physical start addess, should be on an even 4K page boundry #define GPIO 0x68 // offset from base addess of device DWORD dwSize = 4096; // 1 4-KB page DWORD* p_dwGPIO = 0; p_dwGPIO = (DWORD*)VirtualAlloc( 0, dwSize, MEM_RESERVE, PAGE_NOACCESS ); if( p_dwGPIO == 0 ) { ... failure! } BOOL bSuccess = false; bSuccess = VirtualCopy( p_dwGPIO, (VOID*)BASE, dwSize, PAGE_READWRITE | PAGE_NOCACHE ); if( bSuccess ) // true { // use the memory p_dwGPIO[GPIO] = 0x64000000; // register should now have the desired value } ...be sure to VirtualFree p_dwGPIO! > please carify, Also take a look at MmMapIoSpace/MmUnmapIoSpace. > thanks > Tom Convent. Remember all of these are going to be working with the page size and return page(s). Note also that I don't have access to a Windows system or any of my WinCE reference materials as I am currently on a Linux contract, so these are from memory. You *may* find an error or discrepancy in my reply! Take Care. Rob! ------------------------ Yahoo! Groups Sponsor --------------------~--> Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Accessing GPIO pins: 00099, Tom Convent |
|---|---|
| Next by Date: | Re: Getting color using TODAYCOLOR_TITLEBAR_RIGHT: 00099, John Cramer |
| Previous by Thread: | Re: Accessing GPIO pinsi: 00099, Tom Convent |
| Next by Thread: | Re: Accessing GPIO pins: 00099, Tom Convent |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |