#include "yf2825_comm.h" #include "plt.h" #include "yf2825.h" #include "yf2825_sm.h" void yf2825_comm_dac(int idx) { unsigned char tab_us[128] = {0}; struct yf2825_t *dev = &yf2825[idx]; struct comm_t *comm = &dev->comm; int chanidx = comm->chanidx; int addr = comm->adr; int start, nb, rc, i; int ret = 0; if (comm_get_state(comm) != COMMST_NORMAL) { return; } comm_start_cal_dac_timing(comm); chan_lock(chanidx); nb = 8; start = 8; rc = chan_read_input_bits_with_retry(chanidx, addr, start, nb, tab_us); usleep(100000); // 100ms if (rc != 0) { comm_set_state(comm, COMMST_ERR); goto leave; } else if (rc == 0) { /* read ok */ dev->smoke_detector_alarm = tab_us[0]; dev->temperature_alarm = tab_us[1]; dev->press_alarm = tab_us[2]; dev->spurt_flag = tab_us[3]; } nb = 6; start = 0; rc = chan_read_input_bits_with_retry(chanidx, addr, start, nb, tab_us); usleep(100000); // 100ms if (rc != 0) { comm_set_state(comm, COMMST_ERR); goto leave; } if (rc == 0) { /* read ok */ dev->pack1_on = tab_us[0]; dev->pack2_on = tab_us[1]; dev->pack3_on = tab_us[2]; dev->pack4_on = tab_us[3]; dev->pack5_on = tab_us[4]; dev->pack6_on = tab_us[5]; } leave: chan_unlock(chanidx); comm_stop_cal_dac_timing(comm); } int yf2825_set_dev_mbadr(int idx, int val) { int ret = 0; struct yf2825_t *dev = &yf2825[idx]; struct comm_t *comm = &dev->comm; chan_lock(comm->chanidx); ret = chan_write_single_register_with_retry(comm->chanidx, comm->adr, 0x400, val); chan_unlock(comm->chanidx); log_dbg("%s, idx:%d, val:%d, ret:%d", __func__, idx, val, ret); return ret; } static unsigned char val[6]={0}; int yf2825_set_dev_start(int idx, int startIdx) { //暂时关闭pack级消防喷发 return 0; int ret = 0; if(startIdx<0 || startIdx>=6) { memset(val, 0, 6); } else { val[startIdx] = 1; } struct yf2825_t *dev = &yf2825[idx]; struct comm_t *comm = &dev->comm; chan_lock(comm->chanidx); ret = chan_write_bits(comm->chanidx, comm->adr, 0, 6, val); chan_unlock(comm->chanidx); log_dbg("%s, idx:%d, startidx:%d, ret:%d", __func__, idx, startIdx, ret); return ret; } int yf2825_comm_init(int idx) { struct yf2825_t *dev = &yf2825[idx]; struct comm_t *comm = &dev->comm; comm_set_state(comm, COMMST_ERR); } int yf2825_comm_reset(int idx) { struct yf2825_t *dev = &yf2825[idx]; struct comm_t *comm = &dev->comm; comm_set_state(comm, COMMST_NORMAL); }