Difference between revisions of "WiringX"
(4 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
* ROCK (Pi) 4C Plus | * ROCK (Pi) 4C Plus | ||
* ROCK 4 SE | * ROCK 4 SE | ||
+ | * ROCK 3A Hardware 1.31 | ||
+ | * ROCK 3C Hardware V1.1/V1.2 | ||
+ | |||
=== List of Linux Distributions === | === List of Linux Distributions === | ||
* Ubuntu | * Ubuntu | ||
* Debian | * Debian | ||
+ | |||
+ | |||
=== Preparation === | === Preparation === | ||
Line 30: | Line 35: | ||
rock@rock-4c-plus:~$ sudo apt-get install -y git cmake make build-essential | rock@rock-4c-plus:~$ sudo apt-get install -y git cmake make build-essential | ||
</pre> | </pre> | ||
+ | |||
+ | |||
=== Build wiringX with C language version === | === Build wiringX with C language version === | ||
Line 42: | Line 49: | ||
rock@rock-4c-plus:~/wiringX/build$ sudo dpkg -i libwiringx*.deb | rock@rock-4c-plus:~/wiringX/build$ sudo dpkg -i libwiringx*.deb | ||
</pre> | </pre> | ||
+ | |||
+ | |||
=== Build wiringX with Python language version === | === Build wiringX with Python language version === | ||
Line 61: | Line 70: | ||
==== python3 version ==== | ==== python3 version ==== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<pre> | <pre> | ||
+ | rock@rock-4c-plus:~$ git clone https://github.com/nascs/wiringX.git | ||
+ | rock@rock-4c-plus:~$ cd wiringX | ||
+ | rock@rock-4c-plus:~$ git checkout -b radxa_py3.9 origin/radxa_py3.9 | ||
rock@rock-4c-plus:~/wiringX$ cd python/ | rock@rock-4c-plus:~/wiringX$ cd python/ | ||
rock@rock-4c-plus:~/wiringX/python$ mkdir build | rock@rock-4c-plus:~/wiringX/python$ mkdir build | ||
Line 171: | Line 83: | ||
</pre> | </pre> | ||
− | |||
+ | === C version of wiringX's core function === | ||
==== general ==== | ==== general ==== | ||
* int wiringXSetup(char *name, void (*func)(int, char *, int, const char *, ...)); // initialize a platform with wiringX | * int wiringXSetup(char *name, void (*func)(int, char *, int, const char *, ...)); // initialize a platform with wiringX |
Latest revision as of 07:18, 1 March 2023
Contents
wiringX
WiringX is a GPIO library similar to wiringPi, this document describes how to build and use mraa for ROCK Pi boards.
List of ROCK Pi Boards supported
- ROCK (Pi) 4A and 4B
- ROCK (Pi) 4C
- ROCK (Pi) 4A Plus and 4B Plus
- ROCK (Pi) 4C Plus
- ROCK 4 SE
- ROCK 3A Hardware 1.31
- ROCK 3C Hardware V1.1/V1.2
List of Linux Distributions
- Ubuntu
- Debian
Preparation
Essential packages include:
- git
- cmake
- make
- build-essential
Use apt-get to get them.
rock@rock-4c-plus:~$ sudo apt-get install -y git cmake make build-essential
Build wiringX with C language version
rock@rock-4c-plus:~$ git clone https://github.com/wiringX/wiringX.git rock@rock-4c-plus:~$ cd wiringX rock@rock-4c-plus:~/wiringX/$ mkdir build rock@rock-4c-plus:~/wiringX/$ cd build rock@rock-4c-plus:~/wiringX/build$ cmake .. rock@rock-4c-plus:~/wiringX/build$ make -j4 rock@rock-4c-plus:~/wiringX/build$ cpack -G DEB rock@rock-4c-plus:~/wiringX/build$ sudo dpkg -i libwiringx*.deb
Build wiringX with Python language version
python2 version
Please make sure python-dev is installed before generating python version's deb of wiringX.
rock@rock-4c-plus:~$ sudo apt-get install python-dev # for python2.x rock@rock-4c-plus:~$ git clone https://github.com/wiringX/wiringX.git rock@rock-4c-plus:~$ cd wiringX rock@rock-4c-plus:~/wiringX$ cd python/ rock@rock-4c-plus:~/wiringX/python$ mkdir build rock@rock-4c-plus:~/wiringX/python/build$ cmake .. rock@rock-4c-plus:~/wiringX/python/build$ make -j4 rock@rock-4c-plus:~/wiringX/python/build$ cpack -G DEB rock@rock-4c-plus:~/wiringX/python/build$ sudo dpkg -i python-wiringx-*.deb
python3 version
rock@rock-4c-plus:~$ git clone https://github.com/nascs/wiringX.git rock@rock-4c-plus:~$ cd wiringX rock@rock-4c-plus:~$ git checkout -b radxa_py3.9 origin/radxa_py3.9 rock@rock-4c-plus:~/wiringX$ cd python/ rock@rock-4c-plus:~/wiringX/python$ mkdir build rock@rock-4c-plus:~/wiringX/python/build$ cmake .. rock@rock-4c-plus:~/wiringX/python/build$ make -j4 rock@rock-4c-plus:~/wiringX/python/build$ cpack -G DEB rock@rock-4c-plus:~/wiringX/python/build$ sudo dpkg -i python-wiringx-*.deb
C version of wiringX's core function
general
- int wiringXSetup(char *name, void (*func)(int, char *, int, const char *, ...)); // initialize a platform with wiringX
- int pinMode(int pin, enum pinmode_t mode); // set the operating mode of the pin
mode: PINMODE_NOT_SET PINMODE_INPUT PINMODE_OUTPUT PINMODE_INTERRUPT
- int digitalWrite(int pin, enum digital_value_t value); // write a digital_value to the pin
value: LOW, HIGH
- int digitalRead(int pin) // read value of the pin
- int wiringXISR(int pin, enum isr_mode_t mode); // uses a function as an argument to get an interrupt in a particular GPIO pin
mode: ISR_MODE_UNKNOWN ISR_MODE_RISING ISR_MODE_FALLING ISR_MODE_BOTH ISR_MODE_NONE
- int waitForInterrupt(int pin, int ms); // this is the wait event interrupt function,
- int wiringXValidGPIO(int pin); // check that the pin is valid
I2C
- int wiringXI2CSetup(const char *path, int devId) // this function initializes the I2C system with the specified Acura symbol
- int wiringXI2CRead(int fd); // simple device read operation. Some Actos can be read directly without the need to send any register addresses
- int wiringXI2CReadReg8(int fd, int reg); // An 8-bit value can be read from a specified device register
- int wiringXI2CReadReg16(int fd, int reg); // An 16-bit value can be read from a specified device register
- int wiringXI2CWrite(int fd, int data); // simple device write operations. Some devices can accept data without sending any internal register addresses
- int wiringXI2CWriteReg8(int fd, int reg, int data); // An 8-bit value can be written to the specified Acura register
- int wiringXI2CWriteReg8(int fd, int reg, int data); // An 16-bit value can be written to the specified Acura register
SPI
- int wiringXSPISetup(int channel, int speed); // use this function to initialize an SPI channel
- int wiringXSPIDataRW(int channel, unsigned char *data, int len); // This function performs a simultaneous read and write operation through the selected SPI bus. The data in the buffer, will be covered with Hang SPI bus back to the data. For simple read and write operations, you can use standard system functions: read() and write()
Serial
- int wiringXSerialOpen(const char *device, struct wiringXSerial_t wiringXSerial); // this function will open the serial port device initially and set the baud rate of communication
typedef struct wiringXSerial_t { unsigned int baud; unsigned int databits; unsigned int parity; unsigned int stopbits; unsigned int flowcontrol; } wiringXSerial_t;
- void wiringXSerialClose(int fd); // shut down the device with the specified file descriptor
- void wiringXSerialFlush(int fd); // discard all received data or wait for writing to complete on the specified device
- void wiringXSerialPutChar(int fd, unsigned char c); // writes a single byte to the file descriptor of the specified device
- void wiringXSerialPuts(int fd, const char *s); // this function writes a string ending in 0 to the file descriptor of the specified device
- void wiringXSerialPrintf(int fd, const char *message, ...); // used the same way as printf
- int wiringXSerialDataAvail(int fd); // returns the number of bytes available in the serial port receive cache
- int wiringXSerialGetChar(int fd); // returns the next character to be read for the serial port device. If there is no data, the function will wait 10 seconds and return -1 if there is still no data after 10 seconds.
python version of wiringX's core function
the following functions is similar to the C version above
general
- setup(PyObject *self, PyObject *args)
- digitalWrite(PyObject *self, PyObject *args)
- digitalRead(PyObject *self, PyObject *args)
- pinMode(PyObject *self, PyObject *args)
- validGPIO(PyObject *self, PyObject *args)
I2C
- setupI2C(PyObject *self, PyObject *args)
- I2CRead(PyObject *self, PyObject *args)
- I2CReadReg8(PyObject *self, PyObject *args)
- I2CReadReg16(PyObject *self, PyObject *args)
- 2CWrite(PyObject *self, PyObject *args)
- I2CWriteReg8(PyObject *self, PyObject *args)
- I2CWriteReg16(PyObject *self, PyObject *args)
spi
- SPIGetFd(PyObject *self, PyObject *args)
- SPIDataRW(PyObject *self, PyObject *args)
- setupSPI(PyObject *self, PyObject *args)
Troubleshooting
- If you have an issue, start a new post on the forum. https://forum.radxa.com/.