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.
Photo

How to get GPIOx address from Cpu.Pin for Interop?

interop native

Best Answer Frank26080115, 25 August 2013 - 05:06 AM

So... is "NetduinoSDKSource_V4.2.0SecretLabs.NETMF.Hardware.NetduinoPlusNetduinoPlusHardwareProvider.cs" meant for Netduino Plus or Plus 2? I don't see any other directories indicating "Plus 2"

 

I have a Plus 2, where should I be looking for these numbers? These files are an absolute maze.

 

EDIT: found it,

GPIO_TypeDef* port = Port(pin >> 4);and#define Port(port) ((GPIO_TypeDef *) (GPIOA_BASE + (port << 10)))inside STM32_GPIO_functions.cpp

I'm baking my native code into the firmware first and calling it using [MethodImpl(MethodImplOptions.InternalCall)]

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 Frank26080115

Frank26080115

    Member

  • Members
  • PipPip
  • 22 posts

Posted 24 August 2013 - 05:37 AM

I am trying to write native C++ code, used interop, to do something with a pin.

 

I am very familiar with STM32's internal peripherals, and I need to map Cpu.Pin to a GPIOx port address so I can manipulate the pin directly

 

I have downloaded and extracted everything, .net mf source code, porting kit, netduino sdk, netduino sdk source, netduino plus firmware, netduino plus firmware source, everything.

 

I can't find any files that reference STM32 internal peripheral registers at all. But I did find NetduinoPlusHardwareProvider, which had some code like

internal const Cpu.Pin GPIO_PIN_A_18 = (Cpu.Pin)18; // PA18/SPI0_SPCKpublic const Cpu.Pin GPIO_PIN_D13 = GPIO_PIN_A_18; // PA18/SPI0_SPCKinternal const Cpu.Pin GPIO_PIN_B_30 = (Cpu.Pin)62; // PB30/PCK2/PWM3/AD3public const Cpu.Pin GPIO_PIN_A3 = GPIO_PIN_B_30; // PB30/PCK2/PWM3/AD3

Does the Cpu.Pin numbers map to this formula?

 

(letter_in_alphabet_of_port - 1) * 32 + bit_number

 

Where for example, GPIO_PIN_D13 maps to GPIO_PIN_A_18, which means Cpu.Pin is

 

(1 - 1) * 32 + 18 = 18

 

and GPIO_PIN_B_30 is

 

(2 - 1) * 32 + 30 = 62

 

Am I right? From this, I might be able to calculate the addresses of the registers I need to manipulate, right?

 

Where is native interop support anyways? You talked about it in 2011 and mentioned it should be supported in firmware v4.2 but I haven't heard about it since...

 

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 August 2013 - 03:12 PM

Hi Frank26080115, On the SAM7X microcontrollers (Netduino gen1), your math is perfect. PA0-31 = pin 0-31 PB0-31 = pin 32-63 PC0-31 = pin 64-95 etc. On native interop...interop is built-in. We've been looking at runtime interop as well. We had some community members who were interested in implementing that, but there were some roadblocks that kept them from contributing under the Apache 2.0 license. We're still looking at ways to expose runtime interop, preferably as an integral part of .NET MF itself. Chris

#3 Frank26080115

Frank26080115

    Member

  • Members
  • PipPip
  • 22 posts

Posted 25 August 2013 - 05:06 AM   Best Answer

So... is "NetduinoSDKSource_V4.2.0SecretLabs.NETMF.Hardware.NetduinoPlusNetduinoPlusHardwareProvider.cs" meant for Netduino Plus or Plus 2? I don't see any other directories indicating "Plus 2"

 

I have a Plus 2, where should I be looking for these numbers? These files are an absolute maze.

 

EDIT: found it,

GPIO_TypeDef* port = Port(pin >> 4);and#define Port(port) ((GPIO_TypeDef *) (GPIOA_BASE + (port << 10)))inside STM32_GPIO_functions.cpp

I'm baking my native code into the firmware first and calling it using [MethodImpl(MethodImplOptions.InternalCall)]


Edited by Frank26080115, 25 August 2013 - 05:22 AM.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.