-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
892cf74
commit 3352770
Showing
20 changed files
with
1,658 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
EXTRA_CFLAGS = -Wall | ||
KDIR = /lib/modules/`uname -r`/build | ||
obj-m = lcd_driver.o | ||
all: ko app_test | ||
|
||
ko: | ||
make -C $(KDIR) M=`pwd` | ||
|
||
app_test: app_test.o lcd_lib.o | ||
gcc -o app_test app_test.o lcd_lib.o | ||
|
||
app_test.o: app_test.c | ||
gcc -c app_test.c | ||
lcd_lib.o: lcd_lib.c lcd_lib.h | ||
gcc -c lcd_lib.c | ||
clean: | ||
make -C $(KDIR) M=`pwd` clean | ||
rm app_test |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
.data | ||
|
||
|
||
filepath: .asciz "/dev/lcd_1602" | ||
r: .ascii "r" | ||
a: .ascii "a" | ||
i: .ascii "i" | ||
e: .ascii "e" | ||
l: .ascii "l" | ||
p: .ascii "p" | ||
u: .ascii "u" | ||
c: .ascii "c" | ||
n: .ascii "n" | ||
P: .ascii "P" | ||
person: .ascii "¥" | ||
bloco: .ascii "#" | ||
excl: .ascii "!" | ||
esp: .ascii " " | ||
|
||
@my struct | ||
.align 4 | ||
x: .word 2 | ||
y: .word 1 | ||
cenario: .word 0,0,1,1,0,0,0,1,1,1,0,0,1,1,1,1 | ||
.equ count, 80000000 | ||
|
||
.text | ||
.global main | ||
|
||
main: | ||
LDR r11,=count | ||
BL clear | ||
BL gameplay | ||
LDR R1,=i | ||
MOV R7, #4 | ||
MOV R0, #1 | ||
MOV R2, #12 | ||
SWI 0 | ||
B end | ||
gameplay: | ||
BL set_position_DOWN | ||
LDR R10, =cenario | ||
MOV R3,#16 | ||
B moveCen | ||
|
||
moveCen: | ||
CMP R3, #0 | ||
BEQ movingOn | ||
LDR R6, [R10, #0] | ||
CMP R6, #0 | ||
BEQ adsEsp @ Se for 0 escreve espaço | ||
B adsBlo | ||
|
||
adsEsp: | ||
LDR R9,=esp | ||
BL write | ||
ADD R10, R10, #4 | ||
SUB R3, R3, #1 | ||
B moveCen | ||
|
||
adsBlo: | ||
LDR R9,=bloco | ||
BL write | ||
ADD R10, R10, #4 | ||
SUB R3, R3, #1 | ||
B moveCen | ||
|
||
movingOn: | ||
LDR r10,=cenario @ Move a base do vetor para o registrador r9 | ||
MOV R3, #16 | ||
B moving @ O objetivo dele é colocar a primeira posição do vetor para a ultima sem comprometer a ordem do array | ||
|
||
moving: | ||
CMP R3, #0 | ||
BEQ delay @ Se r2 for igual a 0 o processo vai para o delay | ||
BL swap | ||
ADD R10, R10, #4 @ Vai para a proxima posição do array "r9[i] = r9[i+1]" | ||
B moving | ||
|
||
swap: @ Ele troca a primeira posição para a segunda posição | ||
LDR R6, [R10, #0] | ||
LDR R7, [R10, #4] | ||
STR R7, [R10, #0] | ||
STR R6, [R10, #4] | ||
SUB R3, R3, #1 | ||
LDR R1,=i | ||
MOV R7, #4 | ||
MOV R0, #1 | ||
MOV R2, #1 | ||
SWI 0 | ||
BX LR | ||
|
||
delay: | ||
SUB r11, r11, #1 | ||
CMP r11, #0 | ||
BNE delay | ||
LDR r11,=count | ||
B gameplay | ||
|
||
|
||
end: | ||
B end | ||
|
||
write: | ||
SUB sp, sp, #8 | ||
STR lr, [sp] | ||
BL open | ||
MOV R7, #54 @IOCTL | ||
MOV R1, #4 @put flag | ||
MOV R2,R9 @Valor deve ser atribuido antes da chamada da função | ||
SWI 0 | ||
BL close | ||
LDR LR, [sp] | ||
ADD sp, sp, #8 | ||
BX LR | ||
|
||
set_position_DOWN: | ||
SUB sp, sp, #8 | ||
STR lr, [sp] | ||
BL open | ||
MOV R7, #54 @IOCTL | ||
MOV R1, #10 | ||
LDR R2,=x | ||
SWI 0 | ||
LDR LR, [sp] | ||
ADD sp, sp, #8 | ||
BX LR | ||
|
||
set_position_UP: | ||
SUB sp, sp, #8 | ||
STR lr, [sp] | ||
BL open | ||
MOV R7, #54 @IOCTL | ||
MOV R1, #10 | ||
LDR R2,=y | ||
SWI 0 | ||
LDR LR, [sp] | ||
ADD sp, sp, #8 | ||
BX LR | ||
|
||
open: | ||
MOV R7, #5 @ função open | ||
LDR R0, =filepath @ file pointer | ||
MOV R1, #0 @Permissão de adm | ||
MOV R2, #00700 @flag | ||
SWI 0 | ||
BX LR | ||
|
||
close: | ||
|
||
MOV R0, R9 | ||
MOV R7, #6 | ||
SWI 0 @Close | ||
BX LR | ||
|
||
clear: | ||
SUB sp, sp, #8 | ||
STR LR, [sp] | ||
BL open | ||
MOV R7, #54 @IOCTL | ||
MOV R1, #1 @clear flag | ||
SWI 0 | ||
BL close | ||
LDR LR, [sp] | ||
ADD sp, sp, #8 | ||
BX LR | ||
|
||
home_title: | ||
SUB sp, sp, #8 | ||
STR LR, [sp] | ||
LDR R9,=esp | ||
BL write | ||
BL write | ||
BL write | ||
LDR R9,=P | ||
BL write | ||
LDR R9,=u | ||
BL write | ||
LDR R9,=l | ||
BL write | ||
LDR R9,=e | ||
BL write | ||
|
||
LDR R9,=esp | ||
BL write | ||
LDR R9,=p | ||
BL write | ||
LDR R9,=a | ||
BL write | ||
LDR R9,=r | ||
BL write | ||
LDR R9,=a | ||
BL write | ||
BL set_position_DOWN | ||
LDR R9,=esp | ||
BL write | ||
BL write | ||
BL write | ||
BL write | ||
LDR R9,=i | ||
BL write | ||
LDR R9,=n | ||
BL write | ||
LDR R9,=i | ||
BL write | ||
LDR R9,=c | ||
BL write | ||
LDR R9,=i | ||
BL write | ||
LDR R9,=a | ||
BL write | ||
LDR R9,=r | ||
BL write | ||
LDR R9,=excl | ||
BL write | ||
LDR LR, [sp] | ||
ADD sp, sp, #8 | ||
BX LR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
# JumpGameSBC | ||
# LCD16x2_Driver | ||
|
||
This is a kernel level Linux Device driver to control a 16x2 character LCD (with HD44780 LCD controller) with 4 bit mode. | ||
|
||
- Provide API for app in userspace to comminicate with LCD | ||
- The LCD is interfaced with a micro-controller using GPIO pins. | ||
- Driver is written on the Raspberry Pi 3 B, the kernel version 4.19.75-v7+ | ||
|
||
# List of APIs | ||
|
||
| Function | Description | | ||
| ------ | ------ | | ||
| __void _lcd_init_(void)__ | __Init LCD, set default configure (display + cursor + blink on)__ | | ||
| __void _lcd_clear_display_(void)__ | __Clear display and set cursor to home position__ | | ||
| __void _lcd_put_char_(char c)__ | __Display character at current cursor position__ | | ||
| __void _lcd_put_string_(const char *s)__ | __Display string at current cursor position__ | | ||
| __void _lcd_put_string_super_(const char *s)__ | __Clear display and display on 2 line if string length > 16__ | | ||
| __void _lcd_goto_xy_(unsigned char x, unsigned char y)__ | __Set cursor to specified position__ | | ||
| __void _lcd_scroll_left_(void)__ | __scroll text to left__ | | ||
| __void _lcd_scroll_right_(void)__ | __scroll 2 line text to right__ | | ||
| __void _lcd_set_display_(unsigned char display, unsigned char cursor, unsigned char blink)__ | __Set cursor to home position__ | | ||
| __void _lcd_upload_custom_char_(unsigned char location, unsigned char *charmap)__ | __Upload data for custom char to CGRAM__ | | ||
| __void _lcd_set_auto_scroll_(unsigned char status)__ | __Set enable or disable auto move all the text one space to the left each time a letter is added__ | |
Oops, something went wrong.