Add shared emulator services, waveform generation and STM32 USB boot ports

This commit is contained in:
2026-09-28 11:54:17 +03:00
parent 80ba17d77d
commit b7af25a434
56 changed files with 3627 additions and 0 deletions
@@ -0,0 +1,13 @@
# Порт STM32F407 / эмулятор периферии
Добавьте `src/ump_protocol.c` и `ump_stm32f407.c` в сборку.
Порт получает backend с read/write и переводит 8-битные буферы STM32 в
октеты ядра. Приём UART, CRC framing, CAN ID/DLC/RTR-фильтры и очередь
передачи находятся в проекте; ядро проверяет CRC полного RTU кадра.
Вызывать из главного цикла. В эмуляторе SysTick лишь накапливает тики,
поэтому read/write и генератор не выполняются одновременно.
Ответ RTU требует 253 байта; CAN snapshot — 124 uint16_t. Не передавайте
неполный snapshot в fragment, count должен быть фактическим числом слов.
Подключено в `home/407vet6_emul_TMS_Periph/Src/shared_ump.c`.
[Контракт, пример и проверки](../../docs/UMP_PROTOCOL.md).
@@ -0,0 +1,30 @@
#include "ump_stm32f407.h"
size_t ump_stm32f407_rtu(const ump_backend *b, unsigned device,
const uint8_t *request, size_t length, uint8_t *reply, size_t capacity)
{
ump_octet r[8],out[UMP_RTU_CAPACITY];
size_t i,n;
if (!request || !reply || length!=8 || capacity<UMP_RTU_CAPACITY) return 0;
for (i=0;i<8;i++) r[i]=request[i];
n=ump_rtu(b,device,r,8,out,UMP_RTU_CAPACITY);
for (i=0;i<n;i++) reply[i]=(uint8_t)out[i];
return n;
}
unsigned ump_stm32f407_can(const ump_backend *b, const uint8_t *request,
size_t length, uint16_t *words, unsigned *token, unsigned *error)
{
ump_octet r[8];
unsigned i;
if (!request || length!=8) return 0;
for (i=0;i<8;i++) r[i]=request[i];
return ump_can_request(b,r,8,words,token,error);
}
unsigned ump_stm32f407_fragment(const uint16_t *words, unsigned count,
unsigned index, unsigned token, unsigned error, uint8_t reply[8])
{
ump_octet out[8];
unsigned i;
if (!reply || !ump_can_fragment(words,count,index,token,error,out)) return 0;
for (i=0;i<8;i++) reply[i]=(uint8_t)out[i];
return 8;
}
@@ -0,0 +1,11 @@
#ifndef UMP_STM32F407_H
#define UMP_STM32F407_H
#include "../../include/ump_protocol.h"
/* Application owns framing, ID filtering, snapshot lock, and tx buffers. */
size_t ump_stm32f407_rtu(const ump_backend *backend, unsigned device,
const uint8_t *request, size_t length, uint8_t *reply, size_t capacity);
unsigned ump_stm32f407_can(const ump_backend *backend, const uint8_t *request,
size_t length, uint16_t *words, unsigned *token, unsigned *error);
unsigned ump_stm32f407_fragment(const uint16_t *words, unsigned count,
unsigned index, unsigned token, unsigned error, uint8_t reply[8]);
#endif