Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

GB30

Member Since 06 Sep 2010
Offline Last Active Jan 12 2011 04:21 AM
-----

Posts I've Made

In Topic: Using DMA

02 November 2010 - 08:31 AM

Hi.
I tried to investigate how can I use Interop in order to integrate low level code with microframework.
I don't understand this :
1) I use wrapper class to microframework. But how can microframework know what kind of microprocessor is working? How can it compile this C or C++ code?

Thanks











Actually, register access is rather simple - if I omit code that checks address to prevent access to invalid/reserved areas:

// C# Wrapper

using System;
using Microsoft.SPOT;
using System.Runtime.CompilerServices;

namespace XXX.NETMF.Hardware
{
  public static class Register
  {
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern uint Read(uint address);

    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void Write(uint address, uint value);
  }
}

// Native Code (.cpp)

#include "XXX_NETMF_Hardware.h"
#include "XXX_NETMF_Hardware_XXX_NETMF_Hardware_Register.h"

using namespace XXX::NETMF::Hardware;

UINT32 Register::Read(UINT32 address, HRESULT &hr)
{
  // FIXME: Check address
  UINT32 retVal = *(UINT32*)address; 
  return retVal;
}

void Register::Write(UINT32 address, UINT32 value, HRESULT &hr)
{
  // FIXME: Check address
  *(UINT32 *)address = value;
}


In Topic: Using DMA

01 October 2010 - 07:35 AM

Hi GB30,

You can write a native code class for that and compile it into the firmware if you'd like.

We could also add one directly in the SecretLabs namespace--the big reason we haven't is because we didn't want to introduce any "raw power tools" when the board was brand new (as it would be easy for new users to incorporate drivers with raw register access--and not understand the consequences).

Are there particular features you're looking for?

Chris



Hi Chris.
My request is refered to have the complete control of AT91.
For example: I want to use low power mode, but I have to write some uP registers; I want to change PLL configuration in order to change clock; I want to use ADC in 8 bit mode or 10 bit mode... and so on.
I would like to control AT91 and then I would like to work in high level: I work in C or assembler so I understand the consequences of raw register access; working with OOP is useful in order to accelerate programming process and interface with PC world.
So is there an example to follow in order to write a native code class for that and compile it into the firmware ?


Thanks a lot

In Topic: Using DMA

30 September 2010 - 03:19 PM

Hi GB30,

What exactly are you wanting to do? [Read/write directly to memory locations in the AT91SAM7X512?]

Chris



Exact, for example read directly memory locations.

In Topic: Clock - Time to on and off an output pin

30 September 2010 - 03:17 PM

Hi GB30,

Your C# code is running at the managed code layer, so it's being interpreted by the .NET runtime...there is a lot going on behind the scenes. If you'd like to take advantage of the raw speed of the microcontroller, you can write your time-sensitive code in C++ (with a C# wrapper class) and compile it into the Netduino firmware.

You can also erase the Netduino and use C/C++ and SAM-BA for a fast 100% native code solution--but that sort of defeats the purpose of having .NET on there. We put the erase pad on the board so that it's fully "hackable."

Chris




Thank you for the response. Obviously there is a lot going on behind the scenes.
Is there an example of C# wrapper class?

In Topic: More blinking leds

13 September 2010 - 07:39 AM

I think you are right. The classes from SecretLabs.NETMF.Hardware.Netduino namespace should be actually declared as internal classes on Netduino class. Then it would be clear that you have to write for example Netduino.Pins.GPIO_PIN_D3. Currently this code is invalid. If I remmember ut is done this way in GHI and DeviceSolutions SDKs.



Hi. I'm tryng to use Netduino. First Examples run correctly on board, but I controll pin numbers in Netduino dll:

public static class Pins
{
public const Cpu.Pin GPIO_NONE = -1;
public const Cpu.Pin GPIO_PIN_A0 = 59;
public const Cpu.Pin GPIO_PIN_A1 = 60;
public const Cpu.Pin GPIO_PIN_A2 = 61;
public const Cpu.Pin GPIO_PIN_A3 = 62;
public const Cpu.Pin GPIO_PIN_A4 = 10;
public const Cpu.Pin GPIO_PIN_A5 = 11;
public const Cpu.Pin GPIO_PIN_D0 = 27;
public const Cpu.Pin GPIO_PIN_D1 = 28;
public const Cpu.Pin GPIO_PIN_D10 = 54;
public const Cpu.Pin GPIO_PIN_D11 = 17;
public const Cpu.Pin GPIO_PIN_D12 = 16;
public const Cpu.Pin GPIO_PIN_D13 = 18;
public const Cpu.Pin GPIO_PIN_D2 = 0;
public const Cpu.Pin GPIO_PIN_D3 = 1;
public const Cpu.Pin GPIO_PIN_D4 = 12;
public const Cpu.Pin GPIO_PIN_D5 = 51;
public const Cpu.Pin GPIO_PIN_D6 = 52;
public const Cpu.Pin GPIO_PIN_D7 = 3;
public const Cpu.Pin GPIO_PIN_D8 = 4;
public const Cpu.Pin GPIO_PIN_D9 = 53;
public const Cpu.Pin ONBOARD_LED = 55;
public const Cpu.Pin ONBOARD_SW1 = 29;
}
}


They don't match with numbers on schematic : why?
For example onboard_SW1 = 29, but pin on schematic is 75!!!

Thnak you!

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.