mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(usb): watchdog de reception HID et assouplissement de la taille des rapports
This commit is contained in:
1 parent
b6d6645199
commit
87854b6e9b
1 file changed
+18
-8
+18
-8
@@ -122,6 +122,8 @@ volatile bool failsafeActif = true; // Écrit uniquement par le cœur 0
|
|||||||
volatile bool demandeRetourNeutre = false; // Cœur 0 -> Cœur 1 : forcer le point mort
|
volatile bool demandeRetourNeutre = false; // Cœur 0 -> Cœur 1 : forcer le point mort
|
||||||
volatile uint32_t compteurRapportsOK = 0; // Écrit uniquement par le cœur 1
|
volatile uint32_t compteurRapportsOK = 0; // Écrit uniquement par le cœur 1
|
||||||
volatile uint32_t compteurRapportsRejetes = 0;
|
volatile uint32_t compteurRapportsRejetes = 0;
|
||||||
|
volatile uint16_t dernierRejetLen = 0;
|
||||||
|
volatile uint8_t dernierRejetId = 0;
|
||||||
volatile bool logRejetRequis = false;
|
volatile bool logRejetRequis = false;
|
||||||
volatile uint16_t rejet_vid = 0;
|
volatile uint16_t rejet_vid = 0;
|
||||||
volatile uint16_t rejet_pid = 0;
|
volatile uint16_t rejet_pid = 0;
|
||||||
@@ -723,11 +725,12 @@ void loop() {
|
|||||||
uint32_t compteOK = compteurRapportsOK;
|
uint32_t compteOK = compteurRapportsOK;
|
||||||
uint32_t rapportsParSec = ((compteOK - dernierCompteOK) * 1000UL) / (dt ? dt : 1);
|
uint32_t rapportsParSec = ((compteOK - dernierCompteOK) * 1000UL) / (dt ? dt : 1);
|
||||||
dernierCompteOK = compteOK;
|
dernierCompteOK = compteOK;
|
||||||
Serial.printf("[ETAT] G29_Pret=%d (PID=%04X) | InitFFB=%d/%d | Durete=%d/255 | Vib=%d%% | Rugosite=%d | Plage=%d deg | Rapport=%d | Arme=%d | Statut_LED=%d | USB=%lu rap/s | Rejetes=%lu | Failsafe=%d\n",
|
Serial.printf("[ETAT] G29_Pret=%d (PID=%04X) | InitFFB=%d/%d | Durete=%d/255 | Vib=%d%% | Rugosite=%d | Plage=%d deg | Rapport=%d | Arme=%d | Statut_LED=%d | USB=%lu rap/s | Rejetes=%lu (L=%d,ID=%02X) | Failsafe=%d\n",
|
||||||
volant_est_pret, g29_pid, etapeInitMoteur, ETAPES_INIT_FFB_TOTAL, configSysteme.forceRessort,
|
volant_est_pret, g29_pid, etapeInitMoteur, ETAPES_INIT_FFB_TOTAL, configSysteme.forceRessort,
|
||||||
configSysteme.intensiteVibration, rugositeTerrainExterne, configSysteme.angleSouhaiteTotal,
|
configSysteme.intensiteVibration, rugositeTerrainExterne, configSysteme.angleSouhaiteTotal,
|
||||||
rapportEngage, estArme, statutEnvoiLed,
|
rapportEngage, estArme, statutEnvoiLed,
|
||||||
(unsigned long)rapportsParSec, (unsigned long)compteurRapportsRejetes, failsafeActif);
|
(unsigned long)rapportsParSec, (unsigned long)compteurRapportsRejetes,
|
||||||
|
dernierRejetLen, dernierRejetId, failsafeActif);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transmission CRSF précise à 166.67 Hz (toutes les 6000 µs sans dérive ni burst)
|
// Transmission CRSF précise à 166.67 Hz (toutes les 6000 µs sans dérive ni burst)
|
||||||
@@ -981,6 +984,13 @@ void loop1() {
|
|||||||
|
|
||||||
if (!volant_est_pret) return;
|
if (!volant_est_pret) return;
|
||||||
|
|
||||||
|
// Watchdog USB-Host : si aucun rapport reçu depuis > 25 ms et endpoint prêt, réarmer !
|
||||||
|
if (millis() - dernierRapportUSB_ms > 25) {
|
||||||
|
if (tuh_hid_receive_ready(g29_dev_addr, g29_instance)) {
|
||||||
|
tuh_hid_receive_report(g29_dev_addr, g29_instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Séquence d'initialisation FFB (6s après connexion USB, espacée de 50 ms)
|
// 1. Séquence d'initialisation FFB (6s après connexion USB, espacée de 50 ms)
|
||||||
static uint32_t dernierTickInit = 0;
|
static uint32_t dernierTickInit = 0;
|
||||||
if (etapeInitMoteur < ETAPES_INIT_FFB_TOTAL) {
|
if (etapeInitMoteur < ETAPES_INIT_FFB_TOTAL) {
|
||||||
@@ -1005,24 +1015,21 @@ void loop1() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Envoi immédiat des trames prioritaires dès que le pipe USB est libre (sans attendre 50 ms)
|
// 4. Envoi immédiat des trames prioritaires dès que le pipe USB est libre (sans bloquer loop1)
|
||||||
if (majRangeRequise) {
|
if (majRangeRequise) {
|
||||||
if (envoyerPlageG29(configSysteme.angleSouhaiteTotal)) {
|
if (envoyerPlageG29(configSysteme.angleSouhaiteTotal)) {
|
||||||
majRangeRequise = false;
|
majRangeRequise = false;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (majRessortRequise) {
|
if (majRessortRequise) {
|
||||||
if (envoyerRessortG29(configSysteme.forceRessort)) {
|
if (envoyerRessortG29(configSysteme.forceRessort)) {
|
||||||
majRessortRequise = false;
|
majRessortRequise = false;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (etapeEnvoiLed != 0) {
|
if (etapeEnvoiLed != 0) {
|
||||||
envoyerLedsPendingG29();
|
envoyerLedsPendingG29();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Moteur de vibration haptique & butée active (cadencé à ~125 Hz, toutes les 8 ms)
|
// 5. Moteur de vibration haptique & butée active (cadencé à ~125 Hz, toutes les 8 ms)
|
||||||
@@ -1112,8 +1119,11 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
|||||||
if (dev_addr != g29_dev_addr || instance != g29_instance) {
|
if (dev_addr != g29_dev_addr || instance != g29_instance) {
|
||||||
return; // Ne pas réarmer la réception d'un périphérique étranger
|
return; // Ne pas réarmer la réception d'un périphérique étranger
|
||||||
}
|
}
|
||||||
if (len < 55 || report[0] != G29_REPORT_ID) {
|
if (len < 51 || report[0] != G29_REPORT_ID) {
|
||||||
compteurRapportsRejetes++;
|
compteurRapportsRejetes++;
|
||||||
|
dernierRejetLen = len;
|
||||||
|
dernierRejetId = (len > 0) ? report[0] : 0;
|
||||||
|
dernierRapportUSB_ms = millis(); // Le périphérique répond, ce n'est pas une perte de liaison !
|
||||||
tuh_hid_receive_report(dev_addr, instance);
|
tuh_hid_receive_report(dev_addr, instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1200,7 +1210,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Réglage de la dureté du volant à la volée via la molette ou boutons [+] / [-]
|
// Réglage de la dureté du volant à la volée via la molette ou boutons [+] / [-]
|
||||||
uint8_t b54 = report[54];
|
uint8_t b54 = (len >= 55) ? report[54] : 0;
|
||||||
bool dialPlusActuel = (b54 & DIAL_CW_MASK) || (b54 & BOUTON_PLUS_MASK);
|
bool dialPlusActuel = (b54 & DIAL_CW_MASK) || (b54 & BOUTON_PLUS_MASK);
|
||||||
bool dialMoinsActuel = (b54 & DIAL_CCW_MASK) || (b54 & BOUTON_MOINS_MASK);
|
bool dialMoinsActuel = (b54 & DIAL_CCW_MASK) || (b54 & BOUTON_MOINS_MASK);
|
||||||
bool dialEnterActuel = (b54 & DIAL_ENTER_MASK);
|
bool dialEnterActuel = (b54 & DIAL_ENTER_MASK);
|
||||||
|
|||||||
Reference in new issue
Block a user