Lines Matching refs:addr

25 static int coil_rd(uint16_t addr, bool *state)  in coil_rd()  argument
27 if (addr >= (sizeof(coils) * 8)) { in coil_rd()
31 if (coils & BIT(addr)) { in coil_rd()
37 LOG_DBG("Coil read, addr %u, %d", addr, (int)*state); in coil_rd()
42 static int coil_wr(uint16_t addr, bool state) in coil_wr() argument
44 if (addr >= (sizeof(coils) * 8)) { in coil_wr()
49 coils |= BIT(addr); in coil_wr()
51 coils &= ~BIT(addr); in coil_wr()
54 LOG_DBG("Coil write, addr %u, %d", addr, (int)state); in coil_wr()
59 static int discrete_input_rd(uint16_t addr, bool *state) in discrete_input_rd() argument
61 if (addr >= (sizeof(coils) * 8)) { in discrete_input_rd()
65 if (coils & BIT(addr)) { in discrete_input_rd()
71 LOG_DBG("Discrete input read, addr %u, %d", addr, (int)*state); in discrete_input_rd()
76 static int input_reg_rd(uint16_t addr, uint16_t *reg) in input_reg_rd() argument
78 if (addr >= ARRAY_SIZE(holding_reg)) { in input_reg_rd()
82 *reg = holding_reg[addr]; in input_reg_rd()
84 LOG_DBG("Input register read, addr %u, 0x%04x", addr, *reg); in input_reg_rd()
89 static int input_reg_rd_fp(uint16_t addr, float *reg) in input_reg_rd_fp() argument
91 if (!IN_RANGE(addr, fp_offset, sizeof(holding_fp) / 2 + fp_offset)) { in input_reg_rd_fp()
95 *reg = holding_fp[(addr - fp_offset) / 2]; in input_reg_rd_fp()
97 LOG_DBG("FP input register read, addr %u", addr); in input_reg_rd_fp()
102 static int holding_reg_rd(uint16_t addr, uint16_t *reg) in holding_reg_rd() argument
104 if (addr >= ARRAY_SIZE(holding_reg)) { in holding_reg_rd()
108 *reg = holding_reg[addr]; in holding_reg_rd()
110 LOG_DBG("Holding register read, addr %u", addr); in holding_reg_rd()
115 static int holding_reg_wr(uint16_t addr, uint16_t reg) in holding_reg_wr() argument
117 if (addr >= ARRAY_SIZE(holding_reg)) { in holding_reg_wr()
121 holding_reg[addr] = reg; in holding_reg_wr()
123 LOG_DBG("Holding register write, addr %u", addr); in holding_reg_wr()
128 static int holding_reg_rd_fp(uint16_t addr, float *reg) in holding_reg_rd_fp() argument
130 if (!IN_RANGE(addr, fp_offset, sizeof(holding_fp) / 2 + fp_offset)) { in holding_reg_rd_fp()
134 *reg = holding_fp[(addr - fp_offset) / 2]; in holding_reg_rd_fp()
136 LOG_DBG("FP holding register read, addr %u", addr); in holding_reg_rd_fp()
141 static int holding_reg_wr_fp(uint16_t addr, float reg) in holding_reg_wr_fp() argument
143 if (!IN_RANGE(addr, fp_offset, sizeof(holding_fp) / 2 + fp_offset)) { in holding_reg_wr_fp()
147 holding_fp[(addr - fp_offset) / 2] = reg; in holding_reg_wr_fp()
149 LOG_DBG("FP holding register write, addr %u", addr); in holding_reg_wr_fp()