3.2.2.1. Compiling and running C applications¶
You can write simple C algorithms, make executables and run them on the Red Pitaya board. A list of built in functions (APIs) is available providing full control over Red Pitaya board (signal generation and acquisition, digital I/O control, communication: I2C, SPI, UART and other). How to compile a C algorithm is shown in the instructions below, while a list of Examples is available here.
Note
When you copy the source code from our repository (following instructions below) you will also copy all C examples to your Red Pitaya board. After that only the compiling step is needed.
Note
Here is a link to the rp.c which contains all the C functions used in the examples.
Compiling and running on Red Pitaya board
When compiling on the target no special preparations are needed. A native toolchain is available directly on the Debian system.
First connect to your board over SSH (replace the IP, the default password is root).
ssh root@192.168.0.100
You can also use the .local address (not all computers support .local addresses) (replace ‘xxxxxx’ with the last 6 characters of the Red Pitaya’s MAC address):
ssh root@rp-xxxxxx.local
Now make a clone of the Red Pitaya Git repository and enter the project directory.
git clone https://github.com/RedPitaya/RedPitaya.git
cd RedPitaya
In order to compile one example just use the source file name without the .c extension.
cd Examples/C
make digital_led_blink
Warning
Currently, there are some issues with combining the new ecosystem (GitHub release 2023.1) with non-UNIFIED OS versions. If you are using an OS version that is not UNIFIED OS, please use the 2022.2 relase of the ecosystem.
Applications based on the API require a specific FPGA image to be loaded:
redpitaya> cat /opt/redpitaya/fpga/fpga_0.94.bit > /dev/xdevcfg
redpitaya> overlay.sh v0.94
Execute the application.
Note that the path to Red Pitaya shared libraries must be provided explicitly.
LD_LIBRARY_PATH=/opt/redpitaya/lib ./digital_led_blink
Some of the applications run in a continuous loop - press CTRL+C to stop them.
More examples about how to control Red Pitaya using APIs can be found here.