fix readme, fix Makefile to ability of flash ROM without recompiling code

This commit is contained in:
Edward Emelianov 2024-09-05 08:54:29 +03:00
parent 47cb286585
commit 6f93b146d4
2 changed files with 26 additions and 18 deletions

View File

@ -144,18 +144,18 @@ clean:
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map *.d $(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map *.d
@rmdir $(OBJDIR) 2>/dev/null || true @rmdir $(OBJDIR) 2>/dev/null || true
dfuboot: $(BIN) dfuboot:
@echo " LOAD $(BIN) THROUGH DFU" @echo " LOAD $(BIN) THROUGH DFU"
$(DFUUTIL) -a0 -D $(BIN) -s 0x08000000 $(DFUUTIL) -a0 -D $(BIN) -s 0x08000000
flash: $(BIN) flash:
@echo " FLASH $(BIN)" @echo " FLASH $(BIN)"
$(STFLASH) write $(BIN) 0x8000000 $(STFLASH) write $(BIN) 0x8000000
size: $(ELF) size: $(ELF)
$(SIZE) $(ELF) $(SIZE) $(ELF)
boot: $(BIN) boot:
@echo " LOAD $(BIN) through bootloader" @echo " LOAD $(BIN) through bootloader"
$(STBOOT) -b$(BOOTSPEED) $(BOOTPORT) -w $(BIN) $(STBOOT) -b$(BOOTSPEED) $(BOOTPORT) -w $(BIN)

View File

@ -1,11 +1,11 @@
# Firmware for controllers of thermal sensors # Firmware for controllers of thermal sensors
Network of up to 8 controllers (potentially you can use up to 16 but with some source code changes) for TSYS-01 thermal
Make regular scan of 8 sensors' pairs. sensors (up to 16 sensors per controller).
USART speed 115200. Code for ../../kicad/stm32
## Serial interface commands (ends with '\n'), small letter for only local processing: ## Serial interface commands (ends with '\n'), small letter for only local processing:
- **0...7** send message to Nth controller, not broadcast (after number should be CAN command) - **0...7** send message to Nth controller, not broadcast (after number should be CAN command)
- **@** set/reset debug mode - **@** set/reset debug mode
- **A** allow given node to speak
- **a** get raw ADC values - **a** get raw ADC values
- **B** send dummy CAN messages to broadcast address - **B** send dummy CAN messages to broadcast address
- **b** get/set CAN bus baudrate - **b** get/set CAN bus baudrate
@ -14,33 +14,33 @@ USART speed 115200. Code for ../../kicad/stm32
- **d** get current CAN address of device - **d** get current CAN address of device
- **Ee** end temperature scan - **Ee** end temperature scan
- **Ff** turn sensors off - **Ff** turn sensors off
- **g** group (sniffer) CAN mode (print to USB terminal all incoming CAN messages with alien IDs) - **g** sniffer CAN mode (print to USB terminal all incoming CAN messages with alien IDs)
- **Hh** switch I2C to high speed (100kHz) - **Hh** switch I2C to high speed (100kHz)
- **Ii** (re)init sensors - **Ii** (re)init sensors
- **Jj** get MCU temperature - **Jj** get MCU temperature
- **Kk** get values of U and I - **Kk** get values of U and I
- **Ll** switch I2C to low speed (default, 10kHz) - **Ll** switch I2C to low speed (default, 10kHz)
- **Mm** change master id to 0 (**m**) / broadcast (**M**)
- **N** get build number - **N** get build number
- **Oo** turn onboard diagnostic LEDs **O**n or **o**ff (both commands are local!) - **Oo** turn onboard diagnostic LEDs **O**n or **o**ff (both commands are local!)
- **P** ping everyone over CAN - **P** ping everyone over CAN
- **Qq** get system time - **Qq** get system time
- **Rr** reinit I2C - **Rr** reinit I2C
- **S** shut up given node
- **s** send CAN message (format: ID data[0..8], dec, 0x - hex, 0b - binary) - **s** send CAN message (format: ID data[0..8], dec, 0x - hex, 0b - binary)
- **Tt** start single temperature measurement - **Tt** start single temperature measurement
- **U** USB status of given node (0 - off)
- **u** unique ID (default) CAN mode - **u** unique ID (default) CAN mode
- **Vv** very low speed - **Vv** very low speed
- **Xx** go into temperature scan mode - **Xx** go into temperature scan mode
- **Yy** get sensors state over CAN (data format: 3 - state, 4,5 - presense mask [0,1], 6 - npresent, 7 - ntempmeasured - **Yy** get sensors state over CAN (data format: 3 - state, 4,5 - presense mask [0,1], 6 - npresent, 7 - ntempmeasured
- **z** check CAN status for errors - **z** check CAN status for errors
The command **M** allows to temporaly change master ID of all All capitall letters (except `O`) is CAN-bus commands. Any CAN-bus command should be started from node number. The
controllers to broadcast ID. So all data they sent will be message will be sent to given node and it will answer to inquiring node.
accessed @ any controller.
## PINOUT ## PINOUT
- **I2C**: PB6 (SCL) & PB7 (SDA) - **I2C**: PB6 (SCL) & PB7 (SDA)
- **USART1**: PA9 (Tx) & PA10 (Rx) - **USART1**: PA9 (Tx) & PA10 (Rx) - DEPRECATED
- **CAN bus**: PB8 (Rx), PB9 (Tx) - **CAN bus**: PB8 (Rx), PB9 (Tx)
- **USB bus**: PA11 (DM), PA12 (DP) - **USB bus**: PA11 (DM), PA12 (DP)
- **I2C multiplexer**: PB0..PB2 (0..2 address bits), PB12 (~EN) - **I2C multiplexer**: PB0..PB2 (0..2 address bits), PB12 (~EN)
@ -56,13 +56,25 @@ accessed @ any controller.
## CAN protocol ## CAN protocol
Variable data length: from 1 to 8 bytes. Variable data length: from 1 to 8 bytes.
First (number zero) byte of every sequence is command mark (0xA5) or data mark (0x5A).
## Commands
CAN ID = 0x680 + Controller address (0..15). Controller with address = 0 is master, it translate CAN ID = 0x680 + Controller address (0..15). Controller with address = 0 is master, it translate
all incoming CAN traffic into USB and can send commands to different slaves. Slave answers with its ID. all incoming CAN traffic into USB and can send commands to different slaves. Slave answers with its ID.
Broadcast messages with ID=0 are ignored. Broadcast messages with ID=0 are ignored.
### Commands and data format
- byte 0 - command mark (0xA5) or data mark (0x5A);
- byte 1 - controller number (packet sender both for command or data);
- byte 2 - command code;
- bytes 3..7 - data (answer of command with DATA mark in byte 0).
So if you want to send command with code `xx` to node `N` from node `M`, you should send sequence of bytes with ID=`0x680+N`:
0xA5 M xx
And you will give answer with ID=`0x680+M`:
0x5A N xx [up to 5 data bytes]
### Common commands ### Common commands
- `CMD_PING` (0) request for PONG cmd - `CMD_PING` (0) request for PONG cmd
- `CMD_START_MEASUREMENT` (1) start single temperature measurement - `CMD_START_MEASUREMENT` (1) start single temperature measurement
@ -96,10 +108,6 @@ Broadcast messages with ID=0 are ignored.
- `CMD_DUMMY0` = 0xDA, - `CMD_DUMMY0` = 0xDA,
- `CMD_DUMMY1` = 0xAD - `CMD_DUMMY1` = 0xAD
### Commands and data format
- byte 1 - Controller number (packet sender)
- byte 2 - Command code
- bytes 3..7 - data (answer of command with DATA mark in byte 0)
### Thermal data format ### Thermal data format
- byte 3 - Sensor number (10*N + M, where N is multiplexer number, M - number of sensor in pair, i.e. 0,1,10,11,20,21...70,71) - byte 3 - Sensor number (10*N + M, where N is multiplexer number, M - number of sensor in pair, i.e. 0,1,10,11,20,21...70,71)