gangclar Posted February 21, 2023 Posted February 21, 2023 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. 0 Quote
schwar3kat Posted February 22, 2023 Posted February 22, 2023 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 0 Quote
gangclar Posted February 23, 2023 Author Posted February 23, 2023 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? 0 Quote
schwar3kat Posted February 23, 2023 Posted February 23, 2023 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. Example: Pin 13 -- gpioNumber: 2, port: 'A', portNumber: 2 0 Quote
gangclar Posted February 23, 2023 Author Posted February 23, 2023 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. 0 Quote
gangclar Posted February 23, 2023 Author Posted February 23, 2023 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 0 Quote
Recommended Posts
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.