Skip to content

Commit dc9c5f5

Browse files
authored
Merge pull request #57 from YuzukiHD/dev
[ci] fix ci sync doc
2 parents 18b8eaa + ed6d220 commit dc9c5f5

File tree

5 files changed

+314
-2
lines changed

5 files changed

+314
-2
lines changed

.github/workflows/SyncDocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
private-ssh-key: ${{ secrets.FTP_SERVER_PASSWD }}
3838
destination-path: /www/wwwroot/syterkit.yuzukihd.top/
3939
source-path: ${{ github.workspace }}/docs/
40-
rsync-options: --archive -O --no-perms --compress --human-readable --progress --delete-after --exclude=.git* --exclude=.git/ --exclude=.gitignore
40+
rsync-options: --archive -O --no-perms --compress --human-readable --progress --delete-after --exclude=.well-known --exclude=.git* --exclude=.git/ --exclude=.gitignore

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ SyterKit is a bare-metal framework designed for Allwinner platform. SyterKit uti
2020
| longanpi-4b | sipeed | T527 | Octa-Core Cortex A55 | [board/longanpi-4b](board/longanpi-4b) | `longanpi-4b.cmake` |
2121
| [LT527X](https://www.myir.cn/shows/134/70.html) | myir-tech | T527 | Octa-Core Cortex A55 | [board/lt527x](board/lt527x) | `lt527x.cmake` |
2222
| Avaota A1 | YuzukiHD | T527 | Octa-Core Cortex A55 | [board/avaota-a1](board/avaota-a1) | `avaota-a1.cmake` |
23+
| OrangePi 4A | OrangePi | A527 | Octa-Core Cortex A55 | - | - |
2324

board/longanpi-4b/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ add_subdirectory(smhc_test)
1616

1717
add_subdirectory(smhc2_test)
1818

19-
add_subdirectory(extlinux_boot)
19+
add_subdirectory(extlinux_boot)
20+
21+
add_subdirectory(spi_lcd)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
add_syterkit_app(spi_lcd
4+
main.c
5+
)

board/longanpi-4b/spi_lcd/main.c

+304
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
#include <stdbool.h>
4+
#include <stddef.h>
5+
#include <stdint.h>
6+
#include <types.h>
7+
8+
#include <config.h>
9+
#include <log.h>
10+
#include <timer.h>
11+
12+
#include <common.h>
13+
#include <jmp.h>
14+
#include <mmu.h>
15+
#include <smalloc.h>
16+
#include <sstdlib.h>
17+
#include <string.h>
18+
19+
#include <cli.h>
20+
#include <cli_shell.h>
21+
#include <cli_termesc.h>
22+
23+
#include <sys-clk.h>
24+
#include <sys-dram.h>
25+
#include <sys-i2c.h>
26+
#include <sys-rtc.h>
27+
#include <sys-sdcard.h>
28+
#include <sys-sid.h>
29+
#include <sys-spi.h>
30+
31+
#include <pmu/axp.h>
32+
33+
#include <fdt_wrapper.h>
34+
#include <ff.h>
35+
#include <sys-sdhci.h>
36+
#include <uart.h>
37+
38+
#define CONFIG_HEAP_BASE (0x40800000)
39+
#define CONFIG_HEAP_SIZE (16 * 1024 * 1024)
40+
41+
extern sunxi_serial_t uart_dbg;
42+
43+
extern sunxi_i2c_t i2c_pmu;
44+
45+
extern void set_rpio_power_mode(void);
46+
47+
extern void rtc_set_vccio_det_spare(void);
48+
49+
sunxi_spi_t sunxi_spi0_lcd = {
50+
.base = 0x07092000,
51+
.id = 3,
52+
.clk_rate = 2 * 1000 * 1000,
53+
.gpio_sck = {GPIO_PIN(GPIO_PORTL, 11), GPIO_PERIPH_MUX6},
54+
.gpio_mosi = {GPIO_PIN(GPIO_PORTL, 12), GPIO_PERIPH_MUX6},
55+
};
56+
57+
static gpio_mux_t lcd_dc_pins = {
58+
.pin = GPIO_PIN(GPIO_PORTL, 13),
59+
.mux = GPIO_OUTPUT,
60+
};
61+
62+
static gpio_mux_t lcd_res_pins = {
63+
.pin = GPIO_PIN(GPIO_PORTL, 9),
64+
.mux = GPIO_OUTPUT,
65+
};
66+
67+
static gpio_mux_t lcd_blk_pins = {
68+
.pin = GPIO_PIN(GPIO_PORTL, 8),
69+
.mux = GPIO_OUTPUT,
70+
};
71+
72+
static gpio_mux_t lcd_cs_pins = {
73+
.pin = GPIO_PIN(GPIO_PORTL, 10),
74+
.mux = GPIO_OUTPUT,
75+
};
76+
77+
static void LCD_Set_DC(uint8_t val) {
78+
sunxi_gpio_set_value(lcd_dc_pins.pin, val);
79+
}
80+
81+
static void LCD_Set_RES(uint8_t val) {
82+
sunxi_gpio_set_value(lcd_res_pins.pin, val);
83+
}
84+
85+
static void LCD_Write_Bus(uint8_t dat) {
86+
uint8_t tx[1]; /* Transmit buffer */
87+
int r; /* Return value */
88+
89+
tx[0] = dat;
90+
r = sunxi_spi_transfer(&sunxi_spi0_lcd, SPI_IO_SINGLE, tx, 1, 0, 0); /* Perform SPI transfer */
91+
if (r < 0)
92+
printk(LOG_LEVEL_ERROR, "SPI: SPI Xfer error!\n");
93+
}
94+
95+
void LCD_Write_Data_Bus(void *dat, uint32_t len) {
96+
int r = sunxi_spi_transfer(&sunxi_spi0_lcd, SPI_IO_SINGLE, dat, len, 0, 0); /* Perform SPI transfer */
97+
if (r < 0)
98+
printk(LOG_LEVEL_ERROR, "SPI: SPI Xfer error!\n");
99+
}
100+
101+
void LCD_WR_DATA(uint16_t dat) {
102+
LCD_Write_Bus(dat >> 8);
103+
LCD_Write_Bus(dat);
104+
}
105+
106+
void LCD_WR_DATA8(uint8_t dat) {
107+
LCD_Write_Bus(dat);
108+
}
109+
110+
void LCD_WR_REG(uint8_t dat) {
111+
LCD_Set_DC(0);
112+
LCD_Write_Bus(dat);
113+
LCD_Set_DC(1);
114+
}
115+
116+
void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
117+
LCD_WR_REG(0x2a);
118+
LCD_WR_DATA(x1);
119+
LCD_WR_DATA(x2);
120+
LCD_WR_REG(0x2b);
121+
LCD_WR_DATA(y1);
122+
LCD_WR_DATA(y2);
123+
LCD_WR_REG(0x2c);
124+
}
125+
126+
static void LCD_Init(void) {
127+
LCD_Set_RES(0);//复位
128+
mdelay(100);
129+
LCD_Set_RES(1);
130+
mdelay(100);
131+
132+
LCD_WR_REG(0x11);
133+
mdelay(120);
134+
LCD_WR_REG(0x36);
135+
LCD_WR_DATA8(0x00);
136+
137+
LCD_WR_REG(0x3A);
138+
LCD_WR_DATA8(0x05);
139+
140+
LCD_WR_REG(0xB2);
141+
LCD_WR_DATA8(0x0C);
142+
LCD_WR_DATA8(0x0C);
143+
LCD_WR_DATA8(0x00);
144+
LCD_WR_DATA8(0x33);
145+
LCD_WR_DATA8(0x33);
146+
147+
LCD_WR_REG(0xB7);
148+
LCD_WR_DATA8(0x35);
149+
150+
LCD_WR_REG(0xBB);
151+
LCD_WR_DATA8(0x19);
152+
153+
LCD_WR_REG(0xC0);
154+
LCD_WR_DATA8(0x2C);
155+
156+
LCD_WR_REG(0xC2);
157+
LCD_WR_DATA8(0x01);
158+
159+
LCD_WR_REG(0xC3);
160+
LCD_WR_DATA8(0x12);
161+
162+
LCD_WR_REG(0xC4);
163+
LCD_WR_DATA8(0x20);
164+
165+
LCD_WR_REG(0xC6);
166+
LCD_WR_DATA8(0x0F);
167+
168+
LCD_WR_REG(0xD0);
169+
LCD_WR_DATA8(0xA4);
170+
LCD_WR_DATA8(0xA1);
171+
172+
LCD_WR_REG(0xE0);
173+
LCD_WR_DATA8(0xD0);
174+
LCD_WR_DATA8(0x04);
175+
LCD_WR_DATA8(0x0D);
176+
LCD_WR_DATA8(0x11);
177+
LCD_WR_DATA8(0x13);
178+
LCD_WR_DATA8(0x2B);
179+
LCD_WR_DATA8(0x3F);
180+
LCD_WR_DATA8(0x54);
181+
LCD_WR_DATA8(0x4C);
182+
LCD_WR_DATA8(0x18);
183+
LCD_WR_DATA8(0x0D);
184+
LCD_WR_DATA8(0x0B);
185+
LCD_WR_DATA8(0x1F);
186+
LCD_WR_DATA8(0x23);
187+
188+
LCD_WR_REG(0xE1);
189+
LCD_WR_DATA8(0xD0);
190+
LCD_WR_DATA8(0x04);
191+
LCD_WR_DATA8(0x0C);
192+
LCD_WR_DATA8(0x11);
193+
LCD_WR_DATA8(0x13);
194+
LCD_WR_DATA8(0x2C);
195+
LCD_WR_DATA8(0x3F);
196+
LCD_WR_DATA8(0x44);
197+
LCD_WR_DATA8(0x51);
198+
LCD_WR_DATA8(0x2F);
199+
LCD_WR_DATA8(0x1F);
200+
LCD_WR_DATA8(0x1F);
201+
LCD_WR_DATA8(0x20);
202+
LCD_WR_DATA8(0x23);
203+
204+
LCD_WR_REG(0x21);
205+
206+
LCD_WR_REG(0x29);
207+
}
208+
209+
#define LCD_W 135
210+
#define LCD_H 240
211+
212+
void LCD_Fill_All(uint16_t color) {
213+
uint16_t i, j;
214+
LCD_Address_Set(0, 0, LCD_W - 1, LCD_H - 1);// 设置显示范围
215+
uint16_t *video_mem = smalloc(LCD_W * LCD_H);
216+
217+
for (uint32_t i = 0; i < LCD_W * LCD_H; i++) {
218+
video_mem[i] = color;
219+
}
220+
221+
LCD_Write_Data_Bus(video_mem, LCD_W * LCD_H * (sizeof(uint16_t) / sizeof(uint8_t)));
222+
223+
sfree(video_mem);
224+
}
225+
226+
int main(void) {
227+
sunxi_serial_init(&uart_dbg);
228+
229+
show_banner();
230+
231+
sunxi_clk_init();
232+
233+
sunxi_clk_dump();
234+
235+
rtc_set_vccio_det_spare();
236+
237+
set_rpio_power_mode();
238+
239+
sunxi_i2c_init(&i2c_pmu);
240+
241+
pmu_axp2202_init(&i2c_pmu);
242+
243+
pmu_axp1530_init(&i2c_pmu);
244+
245+
pmu_axp2202_set_vol(&i2c_pmu, "dcdc1", 1100, 1);
246+
247+
pmu_axp1530_set_dual_phase(&i2c_pmu);
248+
pmu_axp1530_set_vol(&i2c_pmu, "dcdc1", 1100, 1);
249+
pmu_axp1530_set_vol(&i2c_pmu, "dcdc2", 1100, 1);
250+
251+
pmu_axp2202_set_vol(&i2c_pmu, "dcdc2", 920, 1);
252+
pmu_axp2202_set_vol(&i2c_pmu, "dcdc3", 1160, 1);
253+
pmu_axp2202_set_vol(&i2c_pmu, "dcdc4", 3300, 1);
254+
255+
pmu_axp2202_dump(&i2c_pmu);
256+
pmu_axp1530_dump(&i2c_pmu);
257+
258+
enable_sram_a3();
259+
260+
/* Initialize the DRAM and enable memory management unit (MMU). */
261+
uint64_t dram_size = sunxi_dram_init(NULL);
262+
263+
sunxi_clk_dump();
264+
265+
arm32_mmu_enable(SDRAM_BASE, dram_size);
266+
267+
/* Initialize the small memory allocator. */
268+
smalloc_init(CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE);
269+
270+
sunxi_nsi_init();
271+
272+
sunxi_clk_dump();
273+
274+
sunxi_gpio_init(lcd_dc_pins.pin, lcd_dc_pins.mux);
275+
sunxi_gpio_init(lcd_res_pins.pin, lcd_res_pins.mux);
276+
sunxi_gpio_init(lcd_blk_pins.pin, lcd_blk_pins.mux);
277+
sunxi_gpio_init(lcd_cs_pins.pin, lcd_cs_pins.mux);
278+
279+
sunxi_gpio_set_value(lcd_blk_pins.pin, 1);
280+
sunxi_gpio_set_value(lcd_cs_pins.pin, 0);
281+
282+
dma_init();
283+
284+
if (sunxi_spi_init(&sunxi_spi0_lcd) != 0) {
285+
printk(LOG_LEVEL_ERROR, "SPI: init failed\n");
286+
}
287+
288+
LCD_Init();
289+
290+
printk(LOG_LEVEL_ERROR, "SPI LCD done\n");
291+
292+
LCD_Fill_All(0xFFFF);
293+
294+
mdelay(100);
295+
296+
mdelay(100);
297+
mdelay(100);
298+
mdelay(100);
299+
mdelay(100);
300+
301+
abort();
302+
303+
return 0;
304+
}

0 commit comments

Comments
 (0)