Lines Matching +full:0 +full:x01 +full:- +full:negative

5  * SPDX-License-Identifier: Apache-2.0
11 #define MAX149x6_READ 0
14 #define MAX149X6_GET_BIT(val, i) (0x1 & ((val) >> (i)))
26 * @param data - array of data to encode
27 * @param encode - action to be performed - true(encode), false(decode)
32 uint8_t crc5_start = 0x1f; in max149x6_crc()
33 uint8_t crc5_poly = 0x15; in max149x6_crc()
35 uint8_t extra_byte = 0x00; in max149x6_crc()
42 * https://www.analog.com/en/app-notes/how-to-program-the-max14906-quadchannel- in max149x6_crc()
43 * industrial-digital-output-digital-input.html in max149x6_crc()
46 for (i = (encode) ? 0 : 2; i < 8; i++) { in max149x6_crc()
47 data_bit = (data[0] >> (7 - i)) & 0x01; in max149x6_crc()
48 result_bit = (crc5_result & 0x10) >> 4; in max149x6_crc()
50 crc5_result = crc5_poly ^ ((crc5_result << 1) & 0x1f); in max149x6_crc()
52 crc5_result = (crc5_result << 1) & 0x1f; in max149x6_crc()
56 for (i = 0; i < 8; i++) { in max149x6_crc()
57 data_bit = (data[1] >> (7 - i)) & 0x01; in max149x6_crc()
58 result_bit = (crc5_result & 0x10) >> 4; in max149x6_crc()
60 crc5_result = crc5_poly ^ ((crc5_result << 1) & 0x1f); in max149x6_crc()
62 crc5_result = (crc5_result << 1) & 0x1f; in max149x6_crc()
66 for (i = 0; i < 3; i++) { in max149x6_crc()
67 data_bit = (extra_byte >> (7 - i)) & 0x01; in max149x6_crc()
68 result_bit = (crc5_result & 0x10) >> 4; in max149x6_crc()
70 crc5_result = crc5_poly ^ ((crc5_result << 1) & 0x1f); in max149x6_crc()
72 crc5_result = (crc5_result << 1) & 0x1f; in max149x6_crc()
82 * @param dev - MAX149x6 device config.
83 * @param addr - Register value to which data is written.
84 * @param val - Value which is to be written to requested register.
85 * @return 0 in case of success, negative error code otherwise.
93 uint8_t local_rx_buff[MAX149x6_MAX_PKT_SIZE] = {0}; in max149x6_reg_transceive()
94 uint8_t local_tx_buff[MAX149x6_MAX_PKT_SIZE] = {0}; in max149x6_reg_transceive()
96 const struct max149x6_config *config = dev->config; in max149x6_reg_transceive()
100 .len = config->pkt_size, in max149x6_reg_transceive()
106 .len = config->pkt_size, in max149x6_reg_transceive()
110 if (config->crc_en & 0) { in max149x6_reg_transceive()
114 local_tx_buff[0] = FIELD_PREP(MAX149x6_ADDR_MASK, addr) | in max149x6_reg_transceive()
115 FIELD_PREP(MAX149x6_CHIP_ADDR_MASK, config->spi_addr) | in max149x6_reg_transceive()
116 FIELD_PREP(MAX149x6_RW_MASK, rw & 0x1); in max149x6_reg_transceive()
120 if (config->crc_en) { in max149x6_reg_transceive()
121 local_tx_buff[2] = max149x6_crc(&local_tx_buff[0], true); in max149x6_reg_transceive()
125 ret = spi_transceive_dt(&config->spi, &tx, &rx); in max149x6_reg_transceive()
133 if (config->crc_en) { in max149x6_reg_transceive()
134 crc = max149x6_crc(&local_rx_buff[0], false); in max149x6_reg_transceive()
135 if (crc != (local_rx_buff[2] & 0x1F)) { in max149x6_reg_transceive()
136 LOG_ERR("READ CRC ERR (%d)-(%d)\n", crc, (local_rx_buff[2] & 0x1F)); in max149x6_reg_transceive()
137 return -EINVAL; in max149x6_reg_transceive()
142 rx_diag_buff[0] = local_rx_buff[0]; in max149x6_reg_transceive()
145 /* In case of write we are getting 2 diagnostic bytes - byte0 & byte1 in max149x6_reg_transceive()