feat(gas-logger): добавь непрерывный логгер и JSON-карту

This commit is contained in:
2026-10-01 22:54:29 +03:00
parent 675ce063f0
commit f7a6f767e1
22 changed files with 1250 additions and 0 deletions
@@ -0,0 +1,4 @@
#include "gas_logger_c28x.h"
/* __disable_interrupts/__restore_interrupts are TI C28x compiler intrinsics. */
uint32_t gl_c28x_enter(void *user) { (void)user; return __disable_interrupts(); }
void gl_c28x_leave(void *user,uint32_t state) { (void)user; __restore_interrupts((unsigned int)state); }
@@ -0,0 +1,7 @@
#ifndef GAS_LOGGER_C28X_H
#define GAS_LOGGER_C28X_H
#include <stdint.h>
/* TI C2000 compiler; F2812/F28335. Supply these as gl_port lock callbacks. */
uint32_t gl_c28x_enter(void *user);
void gl_c28x_leave(void *user,uint32_t state);
#endif
+22
View File
@@ -0,0 +1,22 @@
#include "gas_logger_pm35.h"
#include "pm35_map.h"
static uint32_t enter(void *u) { gl_pm35_context *p=u; return p->enter(p->irq_user); }
static void leave(void *u,uint32_t state) { gl_pm35_context *p=u; p->leave(p->irq_user,state); }
static int source(void *u,uint16_t gas,uint16_t *v)
{
gl_pm35_context *p=u;
uint16_t i;
for(i=0;i<gl_pm35_config.channels;i++) if(gl_pm35_channels[i].gas==gas) {
*v=gl_pm35_source_space[i] ? p->pm67_voltage[gl_pm35_source_address[i]] :
p->modbus[gl_pm35_source_address[i]];
return 1;
}
return 0;
}
gl_result gl_pm35_init(gas_logger *l,gl_pm35_context *p,uint16_t *a,uint16_t *b,uint32_t n)
{
gl_port port;
if(!p || !p->modbus || !p->pm67_voltage || !p->enter || !p->leave) return GL_ARGUMENT;
port.user=p;port.enter=enter;port.leave=leave;port.source=source;
return gl_init(l,&gl_pm35_config,&port,a,b,n);
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef GAS_LOGGER_PM35_H
#define GAS_LOGGER_PM35_H
#include "gas_logger.h"
/* Project adapter: pm35_modbus uses the firmware's zero-based modbus[128].
* pm67_voltage[2] is the latest CAN cache, updated under the same IRQ lock.
* No direct CAN requests are performed while capturing. */
typedef struct {
volatile uint16_t *modbus;
volatile uint16_t *pm67_voltage;
uint32_t (*enter)(void *);
void (*leave)(void *,uint32_t);
void *irq_user;
} gl_pm35_context;
gl_result gl_pm35_init(gas_logger *log, gl_pm35_context *context,
uint16_t *bank0, uint16_t *bank1, uint32_t bank_words);
#endif
+19
View File
@@ -0,0 +1,19 @@
/* Generated from pm35.json. Do not edit. */
#ifndef GL_PM35_MAP_H
#define GL_PM35_MAP_H
#include "gas_logger.h"
static const gl_channel gl_pm35_channels[] = {
{20480U, 20480U, 20480U}, /* commands */
{20481U, 20481U, 20481U}, /* current */
{20482U, 20482U, 20482U}, /* dac */
{20483U, 20483U, 20483U}, /* go */
{20484U, 20484U, 20484U}, /* stop */
{20485U, 20485U, 20485U}, /* zpt1 */
{20486U, 20486U, 20486U}, /* zpt2 */
};
static const uint16_t gl_pm35_source_space[] = { 0U, 0U, 0U, 0U, 0U, 1U, 1U };
static const uint16_t gl_pm35_source_address[] = { 127U, 28U, 123U, 80U, 81U, 0U, 1U };
static const gl_config gl_pm35_config = {
24576U, 7U, 760U, 0x635F84CBUL, gl_pm35_channels
};
#endif
@@ -0,0 +1,8 @@
#include "gas_logger_stm32.h"
#ifndef GL_STM32_DEVICE_HEADER
#define GL_STM32_DEVICE_HEADER "stm32f4xx.h"
#endif
#include GL_STM32_DEVICE_HEADER
uint32_t gl_stm32_enter(void *user)
{ uint32_t saved; (void)user; saved=__get_PRIMASK(); __disable_irq(); return saved; }
void gl_stm32_leave(void *user,uint32_t state) { (void)user; __set_PRIMASK(state); }
@@ -0,0 +1,8 @@
#ifndef GAS_LOGGER_STM32_H
#define GAS_LOGGER_STM32_H
#include <stdint.h>
/* Define GL_STM32_DEVICE_HEADER to the project's CMSIS device header.
* F1/F4/G4 use the same PRIMASK contract. No HAL/interrupt handler ownership. */
uint32_t gl_stm32_enter(void *user);
void gl_stm32_leave(void *user,uint32_t state);
#endif