Lines Matching +full:len +full:- +full:or +full:- +full:define

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2017-2021 Joel Stanley <joel@jms.id.au>, IBM Corporation
7 * https://www.infineon.com/cms/en/product/sensor/pressure-sensors/pressure-sensors-for-iot/dps310/
17 #define NUM_REGISTERS 0x33
26 uint8_t len; member
31 #define TYPE_DPS310 "dps310"
32 #define DPS310(obj) OBJECT_CHECK(DPS310State, (obj), TYPE_DPS310)
34 #define DPS310_PRS_B2 0x00
35 #define DPS310_PRS_B1 0x01
36 #define DPS310_PRS_B0 0x02
37 #define DPS310_TMP_B2 0x03
38 #define DPS310_TMP_B1 0x04
39 #define DPS310_TMP_B0 0x05
40 #define DPS310_PRS_CFG 0x06
41 #define DPS310_TMP_CFG 0x07
42 #define DPS310_TMP_RATE_BITS (0x70)
43 #define DPS310_MEAS_CFG 0x08
44 #define DPS310_MEAS_CTRL_BITS (0x07)
45 #define DPS310_PRESSURE_EN BIT(0)
46 #define DPS310_TEMP_EN BIT(1)
47 #define DPS310_BACKGROUND BIT(2)
48 #define DPS310_PRS_RDY BIT(4)
49 #define DPS310_TMP_RDY BIT(5)
50 #define DPS310_SENSOR_RDY BIT(6)
51 #define DPS310_COEF_RDY BIT(7)
52 #define DPS310_CFG_REG 0x09
53 #define DPS310_RESET 0x0c
54 #define DPS310_RESET_MAGIC (BIT(0) | BIT(3))
55 #define DPS310_COEF_BASE 0x10
56 #define DPS310_COEF_LAST 0x21
57 #define DPS310_COEF_SRC 0x28
63 static const uint8_t regs_reset_state[sizeof(s->regs)] = { in dps310_reset()
71 memcpy(s->regs, regs_reset_state, sizeof(s->regs)); in dps310_reset()
72 s->pointer = 0; in dps310_reset()
75 s->regs[DPS310_MEAS_CFG] = DPS310_COEF_RDY | DPS310_SENSOR_RDY in dps310_reset()
81 if (reg >= sizeof(s->regs)) { in dps310_read()
83 __func__, s->pointer); in dps310_read()
101 return s->regs[reg]; in dps310_read()
111 if (reg >= sizeof(s->regs)) { in dps310_write()
113 __func__, s->pointer); in dps310_write()
127 s->regs[reg] = data; in dps310_write()
140 if (s->len == 1) { in dps310_rx()
141 return dps310_read(s, s->pointer++); in dps310_rx()
151 if (s->len == 0) { in dps310_tx()
153 * first byte is the register pointer for a read or write in dps310_tx()
156 s->pointer = data; in dps310_tx()
157 s->len++; in dps310_tx()
158 } else if (s->len == 1) { in dps310_tx()
159 dps310_write(s, s->pointer++, data); in dps310_tx()
171 s->pointer = 0xFF; in dps310_event()
172 s->len = 0; in dps310_event()
175 if (s->len != 1) { in dps310_event()
192 VMSTATE_UINT8(len, DPS310State),
205 k->event = dps310_event; in dps310_class_init()
206 k->recv = dps310_rx; in dps310_class_init()
207 k->send = dps310_tx; in dps310_class_init()
209 dc->vmsd = &vmstate_dps310; in dps310_class_init()