Please select To the mobile version | Continue to access the desktop computer version


Hot search: orangepi
View: 1707|Reply: 2

Alternative to WiringPi GPIO programming for 2G-IOT and i96 OPi boards.

[Copy link]







Registered member

Rank: 2

Post time 2021-4-26 20:53:23 | Show all posts |Read mode
Edited by vaton at 2021-4-28 06:10

I have found a nice descriptoin of the direct GPIO programming in this article: ... (Make full use of Orange Pi 2G-IOT GPIO).

Needed some investigation, but seems to work.

Essential is this code:

#define RDA_CONFIG_REGS 0x11a09000
volatile struct config_regs {
  uint32_t chip_id;
  uint32_t build_version;
  uint32_t bb_gpio_mode;       // enable/disable GPIO_C
  uint32_t ap_gpioa_mode;     // enable/disable GPIO_A
  uint32_t ap_gpiob_mode;     // enable/disable GPIO_B
  uint32_t ap_gpiod_mode;     // enable/disable GPIO_D
}* cfg;

#define GPIOA_BASE 0x20930000
volatile struct pio_cfg {
  uint32_t oen_val;           // read/write mode register
  uint32_t oen_set_out;    // set GPIO(s) to OUT mode
  uint32_t oen_set_in;      // set GPIO(s) to IN mode
  uint32_t val;                 // read/write data register
  uint32_t set;                 // set output(s) HIGH
  uint32_t clr;                  // set output(s) LOW
}* pa;

int main(int argc, char** argv) {
  int mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
  if (mem_fd < 0) {
    perror("can not open/dev/mem");

  int prot = PROT_READ | PROT_WRITE;
  size_t size = sysconf(_SC_PAGE_SIZE);

  cfg = mmap(NULL, size, prot, MAP_SHARED, mem_fd, RDA_CONFIG_REGS);
  cfg->ap_gpioa_mode |= (1 << 14) | (1 << 15);      // Enable GPIO A14 and GPIO_A15

  pa = mmap(NULL, size, prot, MAP_SHARED, mem_fd, GPIOA_BASE);
  pa->oen_set_out = 1 << 15;        // Setup GPIO A15 as output pin
  pa->clr = 1 << 15;                      // Drive GPIO A15 = LOW
  pa->set = 1 << 15;                     // Drive GPIO A15 = HIGH
  return 0;

Mising base addresses I have found in the kernel sources (file iomap-rda8810.h):

GPIOC_BASE    0x11A08000
GPIOA_BASE    0x20930000
GPIOB_BASE    0x20931000
GPIOD_BASE    0x20932000

For interrupt and peripherals programming, you will find very handy the full (126 pages) RDA8810 datasheet here: ... Processor.V1.04.pdf .

It is the only full version I have found on internet. Others are preliminary, i.e., almost useless.

It is still unclear whether the same control method as for GPIOA set can be used also for other GPIO sets. I expect it can, just need to check it.

This method allows using as GPIO almost any pin except power, even those on camera connector. Just remember that many GPIO pins have other system functions. Be careful and if you are not sure you can use some pin as GPIO, do not do it. Secure is using just pins marked on the EXPORT header as GPIO. So, you have been warned ........







Intermediate member

Rank: 3Rank: 3

Post time 2021-11-12 22:29:51 | Show all posts
Ich hätte nie gedacht, dass ich Viagra benutze, ich habe für diesen bewährten und zuverlässigen Käufer genommen ! Es hat mir sehr geholfen und jetzt ist meine Frau immer noch so glücklich wie ich! Jungs, wenn Sie von Impotenz überholt werden, versuchen Sie es
Post time 3 day(s) ago | Show all posts

Top Rated Eminence Organic Skin Care Url

To the lady inquiring about organic skin care lines canada, what is the most effective skin care line, eminence organics uk exfoliator, eminence organic skin care ratings, eminence organic skin care hand cream,  I highly suggest this new eminence organics canada site or botani - organic & natural skin care products australia, eminence organic skin care amazon, which is the best cosmetic brands in india, best organic skin care products in ghana, wholesale organic skin care products in nigeria, as well as this excellent eminence organic skin care tips and don't forget eminence organics where to buy canada, top organic skin care brands in nigeria, eminence organic skin care naseberry eye exfoliant, eminence organic skin care reviews, eminence organic skin care hand cream, not to mention this recommended eminence organics canada info which is also great. Also have a look at this excellent eminence organics canada url and don't forget is organic india products safe, where to buy eminence in canada, best organic anti aging skin care uk, best face skin care products 2020, what is the best skin care products for acne, as well as this best eminence organics canada link not to mention eminence organics buy online canada, natural skin care suppliers uk, best korean skin care products in india, top organic skin care brands in nigeria, organic skin care training pdf in nigeria, alongside all awesome eminence organic skin care url which is also worth a look. I also suggest this cool eminence organic skin care url as well as organic skin care online training, best face skin care products uk, organic skin care training in nigeria, eminence organic skin care gift set, what are the best skin care products for acne scars, on top of this great eminence organics canada info alongside all eminence calm skin chamomile cleanser ingredients, what is the most effective skin care line, buy organic skin care products online india, organic skin care doctor lip balm, best face skin care products uk, not to mention awesome eminence organic skin care advice which is also great. Finally, have a look at this top rated eminence organics tips for good measure. Check more High Rated Eminence Organics  Info a6ce6c9
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2022-1-27 16:40 GMT+8 , Processed in 0.030985 second(s), 22 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list