|
Re: Accessing GPIO pins: msg#00114windows.ce.devel
Hello Rob, I tried matching virtual memery to physical memory, but virtualcopy function returns 0. ------------------------------------------------------------------------------------------------------------------------- #define BASE 0x40E00000 #define PAGESIZE 4096 DWORD *pMemBase; BOOL bSucess; pMemBase = (DWORD*) VirtualAlloc(0, PAGESIZE, MEM_COMMIT, PAGE_READWRITE); if(pMemBase != NULL) { bSucess = VirtualCopy(pMemBase, (void*)(BASE >> 8) , PAGESIZE, PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL); } if(bSucess) { printf("Virtualcopy returned %d", bSucess); return TRUE; } else { printf("Virtualcopy returned %d", bSucess); return FALSE; } --------------------------------------------------------------------------------------------------------------------------- I am using evc++ 4.0. After searching on google I got what might be the error it says "VirtualCopy() is not an exported function in eVC++ although it is defined in coredll.lib. Platofrm Builder 3.0 has this function exported. To enable the use of virtualcopy function it should be defined in .h file as fallows extern "C" BOOL VirtualCopy(LPVOID dest, LPVOID src, DWORD size, DWORD flags); I exactly defined like above in .h file. I only have evc++ as an option to develop device drivers. Any help and hints would be greatly helpful for me. I am not able to figure out why virtualcopy function returns zero ?? thanks Tom Rob Wehrli <rwehrli@xxxxxxxxxxx> wrote: 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! Mailing list addresses: Post message: windowsce-dev@xxxxxxxxxxxxxxx Unsubscribe: windowsce-dev-unsubscribe@xxxxxxxxxxxxxxx List owner: windowsce-dev-owner@xxxxxxxxxxxxxxx Website: http://groups.yahoo.com/group/windowsce-dev SPONSORED LINKS Windows ce Win32 programming Window ce development Basic programming language Computer programming languages Microsoft window ce --------------------------------- YAHOO! GROUPS LINKS Visit your group "windowsce-dev" on the web. To unsubscribe from this group, send an email to: windowsce-dev-unsubscribe@xxxxxxxxxxxxxxx Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. --------------------------------- --------------------------------- Yahoo! Music Unlimited - Access over 1 million songs. Try it free. [Non-text portions of this message have been removed] ------------------------ 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: | FastProfit.htm.php: 00114, Arbitrage2.htm.php |
|---|---|
| Next by Date: | RE: Re: Getting color using TODAYCOLOR_TITLEBAR_RIGHT: 00114, Kenny Goers |
| Previous by Thread: | Re: Accessing GPIO pinsi: 00114, Rob Wehrli |
| Next by Thread: | Re: Accessing GPIO pins: 00114, Rob Wehrli |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |