-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* SerialRecieveController * Add serial controller and its test * Add doc and fix some mispelling words * Fix problems found on real board
- Loading branch information
1 parent
b01fb22
commit fd22818
Showing
9 changed files
with
551 additions
and
59 deletions.
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,86 @@ | ||
# Serial | ||
|
||
串口目前仅考虑实现 9600Hz,8N1,无流控的配置。 | ||
|
||
串口由输入部分和输出部分组成。 | ||
|
||
Todo: 支持相关异常(缓冲区空/满)和中断。 | ||
|
||
## Receive | ||
|
||
串口的输入部分负责从外界经过 `rxWire` 接收到的数据送读取到内部环形缓冲区中。 | ||
|
||
串口的输入部分内部有大小可配置的缓冲区,`rxWire` 上接收到的数据会先存在环形缓冲区中,并异步地由内部总线读取。 | ||
|
||
可以从总线上读取状态寄存器,来获得目前缓冲区的使用状况。 | ||
|
||
## Transmit | ||
|
||
串口的输出部分负责将由 CPU 等送来的数据发送经过 `txWire` 发送到外界。 | ||
|
||
串口的输出部分内部有大小可配置的缓冲区,内部总线上送来的数据会先存在环形缓冲区中,并异步地发送到外界。 | ||
|
||
此外可以从总线上读取状态寄存器,来获得目前缓冲区的使用状况。 | ||
|
||
## 地址和寄存器 | ||
|
||
### 基地址 | ||
|
||
串口的基地址为 0x10014_000。 | ||
|
||
Transmit 部分和 Receive 部分使用自最低位,从0开始数起第8位进行区分。 | ||
|
||
#### Receive 部分 | ||
|
||
Receive 部分的基地址为 0x100140_00。 | ||
|
||
##### Receive FIFO 寄存器 | ||
|
||
Receive FIFO 寄存器的地址为 0x10014000。 | ||
|
||
该寄存器为只读。 | ||
|
||
这个寄存器记录了目前串口的输入部分等待被读取的值,长度为 1 字节。 | ||
|
||
读取此寄存器会自增环形缓冲区中的读取 index,使其指向下一个待读取的值。 | ||
|
||
##### Receive 状态寄存器 | ||
|
||
Receive 状态寄存器的地址为 0x10014001。 | ||
|
||
该寄存器为只读。 | ||
|
||
这个寄存器记录了目前串口的输入部分的状态,包括: | ||
- 环形缓冲区写入 index,指向下一个要由 rxWire 写入的值,从最低的第 0 个 bit 开始,长度为 n bit | ||
- 环形缓冲区读取 index,指向下一个等待被内部总线读取的值,从最低的第 n 个 bit 开始,长度为 n bit | ||
|
||
这里的 n 是可配置的,是 “存下最大的 index 需要的 bit 数”,最大的 index 需要是 2 的整数次幂。 | ||
|
||
#### Transmit 部分 | ||
|
||
Transmit 部分的基地址为 0x100141_00。 | ||
|
||
##### Transmit FIFO 寄存器 | ||
|
||
Transmit FIFO 寄存器的地址为 0x10014100。 | ||
|
||
该寄存器为只写。 | ||
|
||
这个寄存器用于向串口的输出部分发送数据,长度为 1 字节。 | ||
|
||
写入此寄存器会自增环形缓冲区中的读取 index,使其指向下一个待输出的值。 | ||
|
||
##### Transmit 状态寄存器 | ||
|
||
Transmit 状态寄存器的地址为 0x10014101。 | ||
|
||
该寄存器为只读。 | ||
|
||
这个寄存器记录了目前串口的输出部分的状态,包括: | ||
- 环形缓冲区读取 index,指向下一个由内部总线写入的值,从最低的第 0 个 bit 开始,长度为 n bit | ||
- 环形缓冲区写入 index,指向下一个要由 txWire 输出的值,从最低的第 n 个 bit 开始,长度为 n bit | ||
|
||
这里的 n 是可配置的,是 “存下最大的 index 需要的 bit 数”,最大的 index 需要是 2 的整数次幂。 | ||
|
||
|
||
|
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
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
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
Oops, something went wrong.