added v2.0
This commit is contained in:
25
07_Operating_System/02_UART_Test/GPIO.jack
Normal file
25
07_Operating_System/02_UART_Test/GPIO.jack
Normal file
@@ -0,0 +1,25 @@
|
||||
class GPIO {
|
||||
static Array gpio;
|
||||
|
||||
function void init(int addr){
|
||||
let gpio = addr;
|
||||
return;
|
||||
}
|
||||
|
||||
function boolean readBut() {
|
||||
if (gpio[1] & 2){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function void writeLed(int c){
|
||||
let gpio[0] = c;
|
||||
return;
|
||||
}
|
||||
|
||||
function void readLed(){
|
||||
return gpio[0];
|
||||
}
|
||||
|
||||
}
|
18
07_Operating_System/02_UART_Test/Makefile
Normal file
18
07_Operating_System/02_UART_Test/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
all: jack vm asm bin sim
|
||||
|
||||
jack:
|
||||
../../tools/JackCompiler/JackCompiler.pyc ./
|
||||
vm:
|
||||
../../tools/VMTranslator/VMTranslator.pyc ./
|
||||
asm:
|
||||
../../tools/Assembler/assembler.pyc out.asm
|
||||
bin:
|
||||
../../tools/AsciiToBin.py out.hack
|
||||
sim:
|
||||
cp out.hack ../00_HACK/ROM.hack
|
||||
upload:
|
||||
iceprogduino -o 64k -w out.bin
|
||||
clean:
|
||||
rm -f *.vm *.asm *.hack *.bin *~
|
||||
|
||||
.PHONY: all clean
|
54
07_Operating_System/02_UART_Test/Readme.md
Normal file
54
07_Operating_System/02_UART_Test/Readme.md
Normal file
@@ -0,0 +1,54 @@
|
||||
## UART.jack
|
||||
|
||||
Library that provides character based access to `UART_TX` and `UART_RX`.
|
||||
|
||||
### UART_Test
|
||||
|
||||
In the Testfolder `02_UART_Test` you find a minimal version of `Sys.jack` containing the init function `Sys.init()`, which is called after starting JACK-OS. `Sys.init()` is the JACK-OS version of `echo.asm`, which reads the bytes received at `UART_RX` and writes the values to `UART_TX` in an endless loop:
|
||||
|
||||
```
|
||||
class Sys {
|
||||
|
||||
function void init() {
|
||||
do UART.init(4098);
|
||||
while (true){
|
||||
do UART.write(UART.read());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### Project
|
||||
|
||||
* Implement `UART.jack`
|
||||
|
||||
* Test in simulation:
|
||||
|
||||
```
|
||||
$ cd 02_UARTTest
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
|
||||
The test bench will simulate the transmission of "RX" to UART_RX. Check if HACK echoes to `UART_TX`.
|
||||
|
||||

|
||||
|
||||
* run in real hardware with HACK build at `06_IO_Devices/05_GO` (together with the bootloader). Build and upload the UART_Test to iCE40HX1K-EVB with:
|
||||
|
||||
```
|
||||
$ cd 02_UART_Test
|
||||
$ make
|
||||
$ make upload
|
||||
```
|
||||
|
||||
* Connect HACK with your computer over UART, open a terminal program and type some chars. Check if HACK can echo them.
|
||||
|
||||
```
|
||||
$ tio /dev/ttyACM0
|
||||
```
|
46
07_Operating_System/02_UART_Test/Readme.md.backup
Normal file
46
07_Operating_System/02_UART_Test/Readme.md.backup
Normal file
@@ -0,0 +1,46 @@
|
||||
## UART.jack
|
||||
Library that provides access to `UART_TX` and `UART_RX`.
|
||||
|
||||
***
|
||||
## Project
|
||||
In the Testfolder `02_UART_Test` you find a minimal version of `Sys.jack` containing the init function `Sys.init()`, which is called after starting JACK-OS. `Sys.init()` is the JACK-OS version of `echo.asm`, which reads the bytes received at `UART_RX` and writes the values to `UART_TX` in an endless loop:
|
||||
|
||||
```
|
||||
class Sys {
|
||||
|
||||
function void init() {
|
||||
do UART.init(4098);
|
||||
while (true){
|
||||
do UART.write(UART.read());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
* Implement `UART.jack`
|
||||
* Test in simulation:
|
||||
```
|
||||
$ cd 02_UARTTest
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
The test bench will simulate the transmission of "RX" to UART_RX. Check if HACK echoes to `UART_TX`.
|
||||
|
||||

|
||||
|
||||
* run in real hardware with HACK build at `06_IO_Devices/05_GO` (together with the bootloader). Build and upload the UART_Test to iCE40HX1K-EVB with:
|
||||
|
||||
```
|
||||
$ cd 02_UART_Test
|
||||
$ make
|
||||
$ make upload
|
||||
```
|
||||
|
||||
* Connect HACK with your computer over UART, open a terminal program and type some chars. Check if HACK can echo them.
|
||||
|
||||
```
|
||||
$ tio /dev/ttyACM0
|
||||
```
|
17
07_Operating_System/02_UART_Test/Sys.jack
Normal file
17
07_Operating_System/02_UART_Test/Sys.jack
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* A library that supports various program execution services.
|
||||
*/
|
||||
class Sys {
|
||||
|
||||
/** Performs all the initializations required by the OS. */
|
||||
function void init() {
|
||||
do UART.init(4098);
|
||||
do UART.writeChar(71);
|
||||
do UART.writeChar(79);
|
||||
while (true){
|
||||
do UART.writeChar(UART.readChar());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
1
07_Operating_System/02_UART_Test/UART.jack
Symbolic link
1
07_Operating_System/02_UART_Test/UART.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../UART.jack
|
BIN
07_Operating_System/02_UART_Test/uart.png
Normal file
BIN
07_Operating_System/02_UART_Test/uart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
Reference in New Issue
Block a user