Jump to content

Recommended Posts

Posted

I'm attempt to do two simple switches via GPIO on OrangePi R1 LTS Plus using RK3328 using .Net Core and here my code snippet.

 

GpioController ioc = new GpioController(PinNumberingScheme.Logical, new RockchipDriver(gpioRegisterAddresses: new uint[] { 0xFF21_0000, 0xFF22_0000, 0xFF23_0000, 0xFF24_0000 })); 

int iPin=RockchipDriver.MapPinNumber(???) //  where do I find the information to do logical pin number mapping?

 

ioc.OpenPin(iPin);

ioc.SetPinMode(iPin, PinMode.InputPullUp);

PinValue v=ioc.Read(iPin);

 

Thanks for reading and any suggestion is appreciated.

Posted
On 2/22/2023 at 11:30 AM, gangclar said:

where do I find the information to do logical pin number mapping?

Hi gangclar,

I assume that you mean OrangePi R1 Plus LTS ?  (not LTS plus).

This board is usually used as a router or firewall, so I don't think that the community has done much with GPIO.  
I don't use GPIO, and know very little about it.

Page 5 of the user manual gives you the GPIO pin mapping on the board image.

There are other things to take into account. 
Device tree mappings will almost certainly not exist, because only devices included by default are included in the default device tree. 
You will probably need to develop a specific device tree overlay for your application place it in the overlay directory, and select it in armbian-config or in the armbianEnv.txt  boot file. 

https://docs.armbian.com/User-Guide_Allwinner_overlays/ (This is for allwinner.  Rockchip is similar).

Kat

Posted

Thanks Kat, it's OrangePi R1 Plus LTS and has 8 GPIO when not connected to an adapter board.

I did find a sample at https://github.com/ZhangGaoxing/rockchip-gpio-driver where the author stated an example as follow

 

int pinNumber = RockchipDriver.MapPinNumber(gpioNumber: 4, port: 'C', portNumber: 6);

 

I am puzzled if the gpioNumber: 4 refers to the GPIO serial number in page 130 of the manual?

Any ideal what is port: 'C', portNumber: 6?

 

Posted
On 2/23/2023 at 1:25 PM, gangclar said:

I am puzzled if the gpioNumber: 4 refers to the GPIO serial number in page 130 of the manual?

Which manual are you using.  My manual doesn't have anything about GPIOs on pg130. (orangepi_r1_plus_lts_rk3328_user manual_v1.4)

Only ports A and D are exposed according to the manual image.

Correction: GPIO C0 is exposed on pin 10, I just didn't spot it.

image.png.47d008570b24456b30f858aa5996c644.png


Example: Pin 13 --  gpioNumber: 2, port: 'A', portNumber: 2

Posted

I suppose it's version 2(OrangePi_R1_Plus_LTS_RK3328_User Manual_v2.0.pdf)

I'll setup and try out Pin13 with your suggestion.

 

Thanks again for reading and providing suggestion.

 

image.png.31c99bc7a8488f926da2afd8dd4d9b75.png

 

 

Posted

GpioController io =new GpioController(PinNumberingScheme.Logical, new RockchipDriver(gpioRegisterAddresses: new uint[] { 0xFF21_0000, 0xFF22_0000, 0xFF23_0000, 0xFF24_0000 })); 

 

int iPin=RockchipDriver.MapPinNumber(gpioNumber: 2, port: 'A', portNumber: 2);

io.OpenPin(iPin);
io.SetPinMode(iPin, PinMode.InputPullDown);
PinValue value = io.Read(iPin);

 

Running the above and get error as follow... I wonder where did Pin 66 come from?

 

Unhandled exception. System.InvalidOperationException: Pin 66 does not support mode InputPullDown.
   at System.Device.Gpio.GpioController.SetPinMode(Int32 pinNumber, PinMode mode)
   at Program.<Main>$(String[] args)
Aborted

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines