Examples
Take SHTC3 sensor as an example:
- Download the source code from: SHTC3_dev.c
-
(Optional) Install the tool to compile. The following is an example to install:
sudo apt-get install gcc-riscv64-linux-gnu
Note: This step can be skipped if the tool has been installed. -
Execute the following to compile:
riscv64-linux-gnu-gcc SHTC3_dev.c -o shtc3
Result:The output file is shtc3 in the same directory.
-
Copy the executable codes from the shtc3 file to the board, and change the execution
permission by executing the following command:
chmod +x shtc3
-
Execute the following command to run:
./shtc3
Result:The following output indicates the execution is successful: [root@fedora-starfive riscv]# ./shtc3 SHTC3 Sensor Test Program ... Fopen : /dev/i2c-1 Temperature = 75.61°C , Humidity = 68.55 Temperature = 27.40°C , Humidity = 68.54 Temperature = 27.40°C , Humidity = 68.55 Temperature = 27.40°C , Humidity = 68.54 Temperature = 27.39°C , Humidity = 68.54