1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include "plt.h"
- int cd1f3300_comm_init(int idx)
- {
- struct cd1f3300_t *dev = &cd1f3300[idx];
- struct comm_t *comm = &dev->comm;
- comm_set_state(comm, COMMST_ERR);
- }
- int cd1f3300_comm_reset(int idx)
- {
- struct cd1f3300_t *dev = &cd1f3300[idx];
- struct comm_t *comm = &dev->comm;
- comm_set_state(comm, COMMST_NORMAL);
- }
- void cd1f3300_comm_dac(int idx)
- {
- unsigned short tab_us[256] = {0};
- struct cd1f3300_t *dev = &cd1f3300[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);
- nb = 2;
- start = 0x0001;
- chan_lock(comm->chanidx);
- ret = chan_read_holdingregisters_with_retry(chanidx, addr, start, nb, tab_us);
- if (ret < 0)
- {
- chan_unlock(comm->chanidx);
- comm_set_state(comm, COMMST_ERR);
- return;
- }
- else
- { /* read ok */
- chan_unlock(comm->chanidx);
- dev->state = tab_us[0x0001 - start];
- dev->co_density = tab_us[0x0002 - start];
- if (dev->state == 0x00)
- {
- sprintf(dev->state_str, "%s", "no alarm");
- }
- else if (dev->state == 0xFF)
- {
- sprintf(dev->state_str, "%s", "CO density alarm");
- }
- else if (dev->state == 0XFE)
- {
- sprintf(dev->state_str, "%s", "sensor fault");
- }
- else if (dev->state == 0XFD)
- {
- sprintf(dev->state_str, "%s", "sensor preheating");
- }
- else
- {
- sprintf(dev->state_str, "%s", "unkown");
- }
- }
- // nb = 1;
- // start = 0x0010;
- // chan_lock(comm->chanidx);
- // ret = chan_read_holdingregisters_with_retry(chanidx, addr, start, nb, tab_us);
- // if (ret < 0)
- // {
- // chan_unlock(comm->chanidx);
- // comm_set_state(comm, COMMST_ERR);
- // return;
- // }
- // else
- // { /* read ok */
- // chan_unlock(comm->chanidx);
- // dev->threshold = tab_us[0x0010 - start];
- // }
- comm_stop_cal_dac_timing(comm);
- }
|