feat(gas-logger): добавь непрерывный логгер и JSON-карту
This commit is contained in:
22
c/gas-logger/ports/pm35/gas_logger_pm35.c
Normal file
22
c/gas-logger/ports/pm35/gas_logger_pm35.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user