chore: readme

This commit is contained in:
2024-11-08 00:46:09 +06:00
parent 1e0915ac08
commit f41661eb7d
8 changed files with 15026 additions and 0 deletions

42
README.md Normal file
View File

@@ -0,0 +1,42 @@
# CH32-16-CH-EXT
A simple CH32V003-based extension board providing 16 GPIO channels, primarily designed for controlling [Chinese 16-relay modules](https://www.uctronics.com/download/Amazon/U604302_print.pdf) ([archive](https://web.archive.org/web/20220709045418/https://www.uctronics.com/download/Amazon/U604302_print.pdf)) over RS485. Uses 64-byte internal flash page for state persistence.
KiCad hardware design files are in the `hw` directory.
![photo](img/ch32_extension_photo.jpg)
![render](img/ch32_extension.png)
## Communication Protocol
### Message Format
The RS485 communication uses a simple 4-byte message format:
```
Byte 0: Board Address (0x01-0xFE, 0xFF for broadcast)
Byte 1: Command (0x01 for SET_OUTPUTS)
Byte 2: Data High Byte
Byte 3: Data Low Byte
```
### Protocol Constants
```c
#define BOARD_ADDRESS 0x01 // Default board address
#define CMD_SET_OUTPUTS 0x01 // Command to set outputs
#define BROADCAST_ADDR 0xFF // Broadcast address
```
### Example Message
To control the outputs, send a 4-byte message:
```rust
let message = [
address, // Board address (0xFF for broadcast)
CMD_SET_OUTPUTS, // Command
(value >> 8) as u8, // Data high byte
value as u8, // Data low byte
];
```