23 lines
930 B
C
23 lines
930 B
C
#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);
|
|
}
|