Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

RockpiS/dev/libmraa

< RockpiS‎ | dev
Revision as of 07:41, 25 February 2020 by Zzl (Talk | contribs)

       ROCK Pi S >  Development >  Install Libmraa 

Libmraa on ROCK Pi S

This guide describes how to use libmraa on ROCK Pi S.

Install essential packages

Package libmraa-rockpis is in the Radxa APT buster-testing repository. Edit file /etc/apt/sources.list.d/apt-radxa-com.list and add the following:

For Debian Buster

   deb http://apt.radxa.com/buster-testing/ buster main

Get the pub key

   wget -O -  apt.radxa.com/buster-testing/public.key | sudo apt-key add -

Install essential packages:

   sudo apt-get update
   sudo apt-get install -y rockchip-overlay rockpis-dtbo libmraa-rockpis

Enable interface

See ROCK Pi S GPIO pintout. ROCK Pi S has a 26-pin colorful expansion header. Each pin is distinguished by color. mraa define follow:

Hardware V10

16 GPIO:

   PIN03      GPIO2_A2
   PIN05      GPIO2_B0
   PIN07      GPIO2_B3
   PIN09      GPIO4_C4
   PIN11      GPIO4_C2
   PIN12      GPIO4_A3
   PIN13      GPIO4_C6
   PIN15      GPIO4_C5
   PIN16      GPIO4_D2
   PIN18      GPIO4_D4
   PIN19      GPIO1_B0
   PIN21      GPIO1_A7
   PIN22      GPIO4_D5
   PIN23      GPIO1_B1
   PIN24      GPIO1_B2
   PIN26      GPIO1_B2

3 I2C:

   PIN23      I2C0_SDA
   PIN24      I2C0_SCL
   PIN3       I2C1_SCL
   PIN5       I2C1_SDA
   PIN13      I2C2_SDA
   PIN15      I2C2_SCL
  

1 SPI:

   PIN19      SPI2TX        //must disable i2c0
   PIN21      SPI2RX        //must disable i2c0
   PIN23      SPI2CLK
   PIN24      SPI2CSN

3 UART:

   PIN8       UART0_TX
   PIN10      UART0_RX
   PIN23      UART1_TX
   PIN24      UART1_RX
   PIN19      UART2_RX
   PIN21      UART2_TX

2 PWM:

   PIN11      PWM2
   PIN13      PWM3

1 ADC:

   PIN26      ADC_IN0          //the measure voltage must lower than 1.8v

modify /boot/hw_intfc.conf to enable pwm2,pwm3,uart1,uart2,i2c0,i2c1,i2c2 for test

   root@rockpis:/# cat boot/hw_intfc.conf
   # Hardware Interface Config
   # Set "on" to enable the optional hardware interfaces while set "off" to disable.
   
   intfc:i2c0=on
   intfc:i2c1=on
   intfc:i2c2=on
   intfc:i2c3=on
   
   intfc:pwm1=on
   intfc:pwm2=on
   intfc:pwm3=on
   
   intfc:spi0=off
   intfc:spi2=off
   
   intfc:uart0=on
   intfc:uart1=on
   intfc:uart2=on
   
  # Devicetree Overlay Enable, uncomment to enable .dtbo under /boot/overlays/.
  
  # Serial console on UART0
  intfc:dtoverlay=console-on-ttyS0
   
  # waveshare 3.5inch lcd (B v2) on SPI2. Need set:
  # intfc:uart1=off intfc:uart2=off intfc:i2c0=off intfc:spi2=on
  #intfc:dtoverlay=spi2-waveshare35b-v2
   
  # waveshare 3.5inch lcd (C) on SPI2. Need set:
  # intfc:uart1=off intfc:uart2=off intfc:i2c0=off intfc:spi2=on
  #intfc:dtoverlay=spi2-waveshare35c
  root@rockpis:/#

then reboot

Test

test gpio

Use mraa-gpio tool to test

   root@rockpis:/# mraa-gpio list
   01         3V3: 
   02          5V: 
   03     I2C_SDA: GPIO I2C  
   04          5V: 
   05     I2C_SCL: GPIO I2C  
   06         GND: 
   07 I2S0_8CH_MC: GPIO 
   08    UART0_TX: GPIO UART 
   09         GND: 
   10    UART0_RX: GPIO UART 
   11 PWM2,I2C3_S: GPIO I2C  PWM  
   12 I2S0_8CH_SC: GPIO 
   13 PWM3,I2C3_S: GPIO I2C  PWM  
   14         GND: 
   15    SPDIF_TX: GPIO 
   16 I2S0_8CH_SD: GPIO 
   17         3V3: 
   18 I2S0_8CH_SD: GPIO 
   19 UART1_RTSN,: GPIO SPI  UART 
   20         GND: 
   21 UART1_CTSN,: GPIO SPI  UART 
   22 I2S0_8CH_LR: GPIO 
   23 UART1_RX,I2: GPIO I2C  SPI  UART 
   24 UART1_TX,I2: GPIO I2C  SPI  UART 
   25         GND: 
   26     ADC_IN0: AIO 
   root@rockpis:/# mraa-gpio set 15 1           #pin15 pull high
   root@rockpis:/# mraa-gpio set 15 0           #pin15 pull high
   root@rockpis:/#
test pwm
test uart
test spi
test adc

Development

More introduction of libmraa can look at libmraa official website.