Skip to content

Commit

Permalink
update home and merge licheepi4a changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Aug 14, 2023
1 parent d8e1413 commit ad63c86
Show file tree
Hide file tree
Showing 53 changed files with 3,016 additions and 2,087 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ temp
.vscode
.ipynb_checkpoints
.qiniu_pythonsdk_hostscache.json
*.temp
*.temp
*.mo
4 changes: 2 additions & 2 deletions config/config_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"items": [
{
"label": "Products",
"url": "/#products",
"url": "/hardware/en/",
"position": "left"
},
{
Expand Down Expand Up @@ -184,7 +184,7 @@
"teedoc-plugin-ad-hint": {
"config": {
"type": "hint",
"label": "",
"label": "NEW",
"content": "New MaixHub online, online annotation, one-key to deploy, better experience, support Maix-I, Maix-II, mobile phone, web, <a href='https://maixhub.com'>Go!</a></br>Latest open source project <a href='https://github.com/sipeed/TinyMaix'>TinyMaix</a>, model infer runtime runs on any MCU, even runs on 2KiB RAM chip",
"show_after_s": 432000,
"date": "2022-06-01 14:00"
Expand Down
6 changes: 3 additions & 3 deletions config/config_zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"items": [
{
"label": "产品",
"url": "/#products",
"url": "/hardware/zh/",
"position": "left"
},
{
"label": "软件文档",
"desc": "软件项目或者通用的软件文档和教程",
"label": "开源软件",
"desc": "开源软件项目或者通用的软件文档和教程",
"position": "left",
"type": "list",
"items": [
Expand Down
4 changes: 2 additions & 2 deletions docs/hardware/en/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Sipeed Hardware
keywords: Sipeed, Hardware, Sipeed, Hardware specifications, Documentation, Downloaden, Deeplearning, Artificial Intelligence, K210
desc: Sipeed hardware documentation website
layout: redirect
redirect_url: /
---

> Updating, [Chinese site](https://wiki.sipeed.com/hardware/zh/index.html) is the latest one.
Expand Down
4 changes: 2 additions & 2 deletions docs/hardware/en/lichee/th1520/lpi4a/5_desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ W: GPG error: http://archive.ubuntu.com trusty-updates Release: The following si
You can try the following command to fix it:
```shell
sudo apt-key adv --keyserver keyring.debian.org --recv-keys 'Replace the key value after NO_PUBKEY in the error message here'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 'Replace the key value after NO_PUBKEY in the error message here'
# or
gpg --keyserver keyserver.ubuntu.com --recv-keys 'Replace the key value after NO_PUBKEY in the error message here'
```
Expand Down Expand Up @@ -374,7 +374,7 @@ sipeed@lpi4a:~$ cat /etc/fstab
`/dev/mmcblk1p1: UUID="033173ff-b3ab-494c-ab14-4dcd656a9214" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="8e4e28df-01"`


### VNC Remote Desktop
## VNC Remote Desktop

Install the required packages and remote desktop using the lightweight Xfce desktop environment.
```shell
Expand Down
251 changes: 250 additions & 1 deletion docs/hardware/en/lichee/th1520/lpi4a/6_peripheral.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,201 @@ gpiochip0: GPIOs 504-511, parent: i2c/0-0018, 0-0018, can sleep: IO expend 1
gpio-511 ( |aon:soc_cam2_avdd25_) out lo
``` -->

## Use of gpiod library

The GPiod library is a library that can call GPIO in the same user space, making it convenient for users to operate GPIO in applications.
Firstly, install and deploy the GPIO library:

```shell
sudo apt install wget
wget https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-2.0.tar.gz

tar zxvf libgpiod-2.0.tar.gz

cd libgpiod-2.0
sudo apt-get install build-essential pkg-config m4 automake autoconf libtool autoconf-archive
sudo apt install gcc g++

export CC=gcc
export CXX=g++

#Deploy the relevant files of the library to the project folder: -- The path after prefix should be changed to the path where the project is located for future operations
./autogen.sh --enable-tools=yes --prefix=/home/sipeed/mylib_local
make
sudo make install
```

如果执行:./autogen.sh --enable-tools=yes --prefix=/home/sipeed/mylib_local 出现以下错误:

```shell
aclocal: warning: couldn't open directory 'm4': No such file or directory
#You can execute the following commands
mkdir m4
./autogen.sh --enable-tools=yes --prefix=/home/sipeed/mylib_local
make
make install
```
Start operating GPIO:
```shell
sudo vim gpio.c
#The content of gpio. c is as follows:
#include<stdio.h>
#include<unistd.h>
#include<gpiod.h>
#define PIN_IO1_3 3
#define PIN_IO1_4 4
#define PIN_IO1_5 5
int main() {
struct gpiod_chip *gchip;
struct gpiod_line_info *glinein, *glineout;
struct gpiod_line_settings *gline_settings_in, *gline_settings_out;
struct gpiod_line_config *gline_config_in, *gline_config_out;
struct gpiod_request_config *gline_request_config_in, *gline_request_config_out;
struct gpiod_line_request *gline_request_in, *gline_request_out;
int offset_in[1] = {PIN_IO1_5};
int offset_out[2] = {PIN_IO1_3, PIN_IO1_4};
int value;
if ((gchip=gpiod_chip_open("/dev/gpiochip4")) == NULL) {
perror("gpiod_chip_open");
return 1;
}
gline_settings_in = gpiod_line_settings_new();
if ((value=gpiod_line_settings_set_direction(gline_settings_in, GPIOD_LINE_DIRECTION_INPUT)) != 0) {
perror("gpiod_line_settings_set_direction");
}
gline_config_in = gpiod_line_config_new();
value=gpiod_line_config_add_line_settings(gline_config_in, offset_in, 1, gline_settings_in);
gline_request_config_in = gpiod_request_config_new();
gline_request_in = gpiod_chip_request_lines(gchip, gline_request_config_in, gline_config_in);
value=gpiod_line_request_get_value(gline_request_in, PIN_IO1_5);
printf("IO1-5 = %d\n", value);
gline_settings_out = gpiod_line_settings_new();
if (gpiod_line_settings_set_direction(gline_settings_out, GPIOD_LINE_DIRECTION_OUTPUT) != 0) {
perror("gpiod_line_settings_set_direction");
}
gline_config_out = gpiod_line_config_new();
gpiod_line_config_add_line_settings(gline_config_out, offset_out, 2, gline_settings_out);
gline_request_config_out = gpiod_request_config_new();
gline_request_out = gpiod_chip_request_lines(gchip, gline_request_config_out, gline_config_out);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_3, 1);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_4, 0);
printf("IO1-3 = 1, IO1-4 = 0\n");
sleep(1);
for (int i = 0; i < 10; i++) {
value=gpiod_line_request_get_value(gline_request_in, PIN_IO1_5);
printf("IO1-5 = %d\n", value);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_3, 0);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_4, 1);
printf("IO1-3 = 0, IO1-4 = 1\n");
sleep(1);
value=gpiod_line_request_get_value(gline_request_in, PIN_IO1_5);
printf("IO1-5 = %d\n", value);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_3, 1);
value=gpiod_line_request_set_value(gline_request_out, PIN_IO1_4, 0);
printf("IO1-3 = 1, IO1-4 = 0\n");
sleep(1);
}
gpiod_chip_close(gchip);
return 0;
}
```
Save and compile
```shell
gcc -I/home/sipeed/mylib_local/include -L/home/sipeed/mylib_local/lib -o gpio gpio.c -lgpiod
```
Some device permissions need to be granted before execution
```shell
export LD_LIBRARY_PATH=/home/sipeed/mylib_local/lib:$LD_LIBRARY_PATH
export PATH=/home/sipeed/mylib_local/bin:$PATH
sudo chmod o+rw /dev/gpiochip4
sudo chmod o+rw /dev/spidev2.0
#It can be directly executed in an. sh file
```
Run program:
```shell
./gpio
```
The console output is as follows:
```shell
sipeed@lpi4a:~/gpio$ ./gpio
IO1-5 = 1
IO1-3 = 1, IO1-4 = 0
IO1-5 = 1
IO1-3 = 0, IO1-4 = 1
IO1-5 = 1
IO1-3 = 1, IO1-4 = 0
IO1-5 = 1
IO1-3 = 0, IO1-4 = 1
IO1-5 = 1
IO1-3 = 1, IO1-4 = 0
IO1-5 = 1
IO1-3 = 0, IO1-4 = 1
IO1-5 = 1
IO1-3 = 1, IO1-4 = 0
IO1-5 = 1
IO1-3 = 0, IO1-4 = 1
IO1-5 = 1
IO1-3 = 1, IO1-4 = 0
IO1-5 = 1
IO1-3 = 0, IO1-4 = 1
```
## UART
### System Serial Port
Expand Down Expand Up @@ -304,7 +499,61 @@ sipeed@lpi4a:~$ ls /dev/spidev2.0
/dev/spidev2.0
```
TODO
### Start
Pay attention to the IO drive capability. Licheepi4A requires an external level conversion chip and uses TXS10108E for its own use
All programs of this routine are compiled on the board. If cross coding is necessary, the tool chain can be replaced during compilation.
The GPIO operation of the following routine is based on the GPIOD library above.
#### 1.Download the source code
```shell
git clone https://github.com/fffdee/ST7735_for_Licheepi4A.git
```
#### 2.Building the GPIOD library
Dependencies required for installation:
```shell
sudo apt-get install build-essential pkg-config m4 automake autoconf libtool autoconf-archive
sudo apt install gcc g++ gpiod cmake
```
Install the GPIOD library (the source file is already installed, and the library path needs to be changed. Please refer to the following steps):
```shell
tar zxvf libgpiod-2.0.tar.gz
cd libgpiod-2.0
export CC=gcc
export CXX=g++
#Deploy the relevant files of the library to the project folder: -- The path after prefix should be changed to the path where the project is located for future operations
./autogen.sh --enable-tools=yes --prefix=/home/sipeed/TFT_demo/
make
sudo make install
#Installation completed
```
#### 3.Compile and Run
```shell
cd TFT_demo
cmake .
make -j4
#授予设备权限,每次开机执行一次即可
. exec.sh
./tft_demo
```
#### Renderings
![效果图1](./../../../../zh/lichee/th1520/lpi4a/assets/peripheral/tft_demo.png)
## USB
Expand Down
Loading

0 comments on commit ad63c86

Please sign in to comment.