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

Adding to Cpu.Pin enumeration


Best Answer CW2, 07 April 2014 - 06:46 AM

You can access those pins via Cpu.Pin enumeration - the ports are treated as consecutive array of pins, so PA is 0 .. 15, PB 16 .. 31, PC 32 .. 47 etc.:

var pa4 = (Cpu.Pin)( 0 + 4);
var pb1 = (Cpu.Pin)(16 + 1);
var pc0 = (Cpu.Pin)(16 + 0);
var pc8 = (Cpu.Pin)(32 + 8);
Go to the full post


  • Please log in to reply
5 replies to this topic

#1 mbrossett

mbrossett

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 06 April 2014 - 09:22 PM

Can someone tell me how to add STM32F4 pins (i.e. PA4, PA5, PC8, PC9, ...) to the Cpu.Pin enumeration and use these I/O? Obviously it would require physical access to these pins, for example a custom Netduino board.

 

I am guessing it would require a modification to the Netduino firmware and a rebuild. Has anyone done this?



#2 mbrossett

mbrossett

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 06 April 2014 - 09:26 PM

Rather, I would like to add to the Netduino.Pins enumeration.



#3 rharding64

rharding64

    New Member

  • Members
  • Pip
  • 8 posts

Posted 06 April 2014 - 09:43 PM

hi there,

 

on investigation of ND1 and ND2, there are pins that don't have external pull up resistors.  Although these are not required, it is best design practice since the internal resistors that you switch on with; 

 

GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; or similar 

 

are considered weak pull ups. 

 

If the final board layout had all pins with external pull ups or pull downs, then you could use the pin right away.  else, if these same pins were hard pulled to Vcc or GND this would effectively render these pins useless for anything down the road. 

 

Ron



#4 mbrossett

mbrossett

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 06 April 2014 - 09:53 PM

Let me try to clear up any confusion...

 

There are pins on the STM32F405RG that are unused in the Netduino design (i.e. PA4, PA5, PC8, PC9,...). I wish to wire up to these pins, however, they are not defined in the Netduino.Pins enumeration and therefore I have no way to control those pins. Does anyone know how I can modify the software/firmware to get access to those STM32F4 pins?



#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 07 April 2014 - 06:46 AM   Best Answer

You can access those pins via Cpu.Pin enumeration - the ports are treated as consecutive array of pins, so PA is 0 .. 15, PB 16 .. 31, PC 32 .. 47 etc.:

var pa4 = (Cpu.Pin)( 0 + 4);
var pb1 = (Cpu.Pin)(16 + 1);
var pc0 = (Cpu.Pin)(16 + 0);
var pc8 = (Cpu.Pin)(32 + 8);


#6 mbrossett

mbrossett

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 07 April 2014 - 01:25 PM

Thank you very much CW2! Also, I have attached a simple class that defines the STM32F405RG pins.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace STM32F4
{
    public static class Pin
    {
        public static Cpu.Pin PA0 { get { return (Cpu.Pin)(0); } }
        public static Cpu.Pin PA1 { get { return (Cpu.Pin)(1); } }
        public static Cpu.Pin PA2 { get { return (Cpu.Pin)(2); } }
        public static Cpu.Pin PA3 { get { return (Cpu.Pin)(3); } }
        public static Cpu.Pin PA4 { get { return (Cpu.Pin)(4); } }
        public static Cpu.Pin PA5 { get { return (Cpu.Pin)(5); } }
        public static Cpu.Pin PA6 { get { return (Cpu.Pin)(6); } }
        public static Cpu.Pin PA7 { get { return (Cpu.Pin)(7); } }
        public static Cpu.Pin PA8 { get { return (Cpu.Pin)(8); } }
        public static Cpu.Pin PA9 { get { return (Cpu.Pin)(9); } }
        public static Cpu.Pin PA10 { get { return (Cpu.Pin)(10); } }
        public static Cpu.Pin PA11 { get { return (Cpu.Pin)(11); } }
        public static Cpu.Pin PA12 { get { return (Cpu.Pin)(12); } }
        public static Cpu.Pin PA13 { get { return (Cpu.Pin)(13); } }
        public static Cpu.Pin PA14 { get { return (Cpu.Pin)(14); } }
        public static Cpu.Pin PA15 { get { return (Cpu.Pin)(15); } }
        public static Cpu.Pin PB0 { get { return (Cpu.Pin)(16 + 0); } }
        public static Cpu.Pin PB1 { get { return (Cpu.Pin)(16 + 1); } }
        public static Cpu.Pin PB2 { get { return (Cpu.Pin)(16 + 2); } }
        public static Cpu.Pin PB3 { get { return (Cpu.Pin)(16 + 3); } }
        public static Cpu.Pin PB4 { get { return (Cpu.Pin)(16 + 4); } }
        public static Cpu.Pin PB5 { get { return (Cpu.Pin)(16 + 5); } }
        public static Cpu.Pin PB6 { get { return (Cpu.Pin)(16 + 6); } }
        public static Cpu.Pin PB7 { get { return (Cpu.Pin)(16 + 7); } }
        public static Cpu.Pin PB8 { get { return (Cpu.Pin)(16 + 8); } }
        public static Cpu.Pin PB9 { get { return (Cpu.Pin)(16 + 9); } }
        public static Cpu.Pin PB10 { get { return (Cpu.Pin)(16 + 10); } }
        public static Cpu.Pin PB11 { get { return (Cpu.Pin)(16 + 11); } }
        public static Cpu.Pin PB12 { get { return (Cpu.Pin)(16 + 12); } }
        public static Cpu.Pin PB13 { get { return (Cpu.Pin)(16 + 13); } }
        public static Cpu.Pin PB14 { get { return (Cpu.Pin)(16 + 14); } }
        public static Cpu.Pin PB15 { get { return (Cpu.Pin)(16 + 15); } }
        public static Cpu.Pin PC0 { get { return (Cpu.Pin)(32 + 0); } }
        public static Cpu.Pin PC1 { get { return (Cpu.Pin)(32 + 1); } }
        public static Cpu.Pin PC2 { get { return (Cpu.Pin)(32 + 2); } }
        public static Cpu.Pin PC3 { get { return (Cpu.Pin)(32 + 3); } }
        public static Cpu.Pin PC4 { get { return (Cpu.Pin)(32 + 4); } }
        public static Cpu.Pin PC5 { get { return (Cpu.Pin)(32 + 5); } }
        public static Cpu.Pin PC6 { get { return (Cpu.Pin)(32 + 6); } }
        public static Cpu.Pin PC7 { get { return (Cpu.Pin)(32 + 7); } }
        public static Cpu.Pin PC8 { get { return (Cpu.Pin)(32 + 8); } }
        public static Cpu.Pin PC9 { get { return (Cpu.Pin)(32 + 9); } }
        public static Cpu.Pin PC10 { get { return (Cpu.Pin)(32 + 10); } }
        public static Cpu.Pin PC11 { get { return (Cpu.Pin)(32 + 11); } }
        public static Cpu.Pin PC12 { get { return (Cpu.Pin)(32 + 12); } }
        public static Cpu.Pin PC13 { get { return (Cpu.Pin)(32 + 13); } }
        public static Cpu.Pin PC14 { get { return (Cpu.Pin)(32 + 14); } }
        public static Cpu.Pin PC15 { get { return (Cpu.Pin)(32 + 15); } }
        public static Cpu.Pin PD2 { get { return (Cpu.Pin)(48 + 2); } }
    }
}





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.