Direct (unsafe) port access
#1
Posted 06 February 2011 - 04:50 PM
#2
Posted 06 February 2011 - 06:53 PM
I had a similar idea some time ago (inspired by GHI's Register class). There is one important issue with my code, though: it does not verify the address parameter, so it will fail when an attempt is made to access an invalid (reserved) memory region.If we can access the native ports (mem access), we'll be able to create 'native' drivers, without messing with the native fw.
#3
Posted 07 February 2011 - 11:16 AM
public unsafe class Processor { /// <summary> /// Write directly to memory. (Meant for port access) /// </summary> /// <param name="reg"></param> /// <param name="val"></param> public static void Write(uint reg, uint val) { *(uint*)reg = val; } /// <summary> /// Read directly from memory. (Meant for port access) /// </summary> /// <param name="reg"></param> /// <returns></returns> public static uint Read(uint reg) { return *(uint*)reg; } }
It's a pity. It would have been an easy fix. Maybe the .NET assemblies have their own memory space or something. I'll give it a try with your unmanaged version, I think.
#4
Posted 08 February 2011 - 04:13 AM
I think you forgot to set the port enable register (offset 0), and you also swapped CODR and SODR in your routine (not that it really matters ). But even with that, I couldn't get it to work from the managed side either. I wonder what is going on.My first attempt with a managed version doesn't seem to work:
It's a pity. It would have been an easy fix.
#5
Posted 10 February 2011 - 03:29 PM
Attached Files
#6
Posted 10 May 2011 - 03:46 PM
#7
Posted 11 May 2011 - 11:11 AM
#8
Posted 23 November 2012 - 02:38 PM
#9
Posted 13 December 2012 - 10:12 PM
Attached Files
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users