RockPro64 programing GPIO, I2C,UART and SPI
#1
Photo 
Hello,
 
    I want to interface rockpro64 with external sensors with I2C, UART, SPI   and blinking led using GPIO pins, is there any liberay or example programs. I have installed Armbian_20.05.4 OS.

Regards,
Madhu K S
#2
Give it a try -> https://forum.frank-mankel.org/topic/292...-rp64-gpio
Sry, it's only in german. But i think it's not an problem. Not so many german words  Smile
Sorry for any mistakes. English is not my native language

1. Quartz64 Model B, 4GB RAM

2. Quartz64 Model A, 4GB RAM

3. RockPro64 v2.1

https://linux-nerds.org/
#3
Thumbs Up 
(07-24-2020, 10:00 AM)Bullet64 Wrote: Give it a try -> https://forum.frank-mankel.org/topic/292...-rp64-gpio
Sry, it's only in german. But i think it's not an problem. Not so many german words  Smile

Hi,
 
 Thanks for the reply, I will try GPIO  Python example program  to get started. Mean while I need to write code in C++ language, can you please suggest any example code or library in C++.

Thanks & Regards,
Madhu K S
#4
Hello,
  If you think about handling the registers directly from your code, in user space, you may look at a little library, I have written some time ago for this purpose. It is attached to this thread:
https://forum.pine64.org/showthread.php?...7#pid49547
There is only handling of GPIO in it. I have not worked with I2C or SPI, so far. Please, be aware that you may interfere with the OS drivers, when going this way.
  If you want to handle GPIO through the Linux driver, then it is still much more efficient to do it in C, than in scripts. There is a thread somewhere here, which reports terrible performance with Python. I can confirm the same with Shell.
Handling the old interface, the ‘sysfs’ interface, in C is very easy. You open file, read(), write(). Just remember not to close file for reading new value from an input pin – seek to beginning of the file instead! And write characters to pin-value files, not integers. This means, e.g. write '0' and not 0 ('\0').
With the new Armbian you have also the new interface – libgpiod. Some report this superior to the old interface. But I have never tried myself.

UART has good handling in the standard Linux driver. I recommend using it. You can find plenty of good tutorials how to use UART in C. Just search with 'Linux serial programing'.
However, please take into account that ROCKPro64 exposes only 2 UARTS in the 'GPIO connector': UART2 and UART4.
UART2 is used for console, and you risk halting system, if you transmit anything to this UART. At least it is what happened to me, when I was playing with UART2.
UART4 is not enabled by default in recent Linux releases, because it shares pins with the SPI1. So, you need to activate UART4 in Linux Device Tree, if you want to use the standard driver and hence the file /dev/ttyS4. And you will not have SPI1 simultaneously.
You use the latest Armbian, I suppose? So, it is easy. Just do
echo "overlays=uart4" >> /boot/armbianEnv.txt.
You find more details in:
/boot/dtb-5.4.46-rockchip64/rockchip/overlay/README.rockchip-overlays
I am using UART4 to communicate with Arduino, and it works very well.
  Best regards,
  Gienek.


Possibly Related Threads…
Thread Author Replies Views Last Post
Brick Logical Extensible Gizmo Organizing RockPro64 Enclosure hoarfrosty 0 439 08-06-2023, 09:32 PM
Last Post: hoarfrosty
  RockPro64 programing GPIO by Rust yanagawa3 0 1,453 11-24-2021, 08:43 PM
Last Post: yanagawa3
  RockPro64 as PATA/SATA bridge? Count Omega 1 4,192 12-07-2019, 02:25 PM
Last Post: Count Omega
Question HOW TO fix Wifi on RockPro64 - Recalbox OS and upload roms on SSD External Gouki 6 8,507 08-25-2019, 05:13 AM
Last Post: Gouki
  ROCKPRO64 for SCRAPING Ulthor_31 4 7,348 08-01-2019, 05:19 AM
Last Post: Ulthor_31
  RockPro64 as PVR/DVR bm_00 1 3,792 02-27-2019, 04:46 AM
Last Post: mabs

Forum Jump:


Users browsing this thread: 1 Guest(s)