Lines Matching +full:crc +full:- +full:en

5  * SPDX-License-Identifier: Apache-2.0
202 * @param data - Data array to calculate CRC for.
203 * @return CRC result.
214 * This is the C custom implementation of CRC function for MAX22190, and in max22190_crc()
216 * https://www.analog.com/en/design-notes/guidelines-to-implement-crc-algorithm.html in max22190_crc()
230 for (i = 0; i < length - 1; i++) { in max22190_crc()
232 ((datainput >> (length - 2 - i)) & 0x01)); in max22190_crc()
247 * @param dev - MAX22190 device.
248 * @param val - value to be set.
252 struct max22190_data *data = dev->data; in max22190_update_wb_stat()
255 data->wb[ch_n] = (val >> ch_n) & 0x1; in max22190_update_wb_stat()
262 * @param dev - MAX22190 device.
263 * @param val - value to be set.
267 struct max22190_data *data = dev->data; in max22190_update_in_stat()
270 data->channels[ch_n] = (val >> ch_n) & 0x1; in max22190_update_in_stat()
277 * @param dev - MAX22190 device config.
278 * @param addr - Register value to which data is written.
279 * @param val - Value which is to be written to requested register.
284 uint8_t crc; in max22190_reg_transceive() local
290 const struct max22190_config *config = dev->config; in max22190_reg_transceive()
294 .len = config->pkt_size, in max22190_reg_transceive()
300 .len = config->pkt_size, in max22190_reg_transceive()
308 /* If CRC enabled calculate it */ in max22190_reg_transceive()
309 if (config->crc_en) { in max22190_reg_transceive()
314 ret = spi_transceive_dt(&config->spi, &tx, &rx); in max22190_reg_transceive()
321 /* if CRC enabled check readed */ in max22190_reg_transceive()
322 if (config->crc_en) { in max22190_reg_transceive()
323 crc = max22190_crc(&local_rx_buff[0]); in max22190_reg_transceive()
324 if (crc != (local_rx_buff[2] & 0x1F)) { in max22190_reg_transceive()
325 LOG_ERR("READ CRC ERR (%d)-(%d)\n", crc, (local_rx_buff[2] & 0x1F)); in max22190_reg_transceive()
326 return -EINVAL; in max22190_reg_transceive()
350 * @param dev - MAX22190 device.
351 * @param addr - Register valueto wich data is updated.
352 * @param mask - Corresponding mask to the data that will be updated.
353 * @param val - Updated value to be written in the register at update.
373 * @param dev - MAX22190 device
377 struct max22190_data *data = dev->data; in max22190_fault_check()
380 data->fault1.reg_raw = max22190_reg_read(dev, MAX22190_FAULT1_REG); in max22190_fault_check()
382 if (data->fault1.reg_raw) { in max22190_fault_check()
384 data->fault1_en.reg_raw = max22190_reg_read(dev, MAX22190_FAULT1_EN_REG); in max22190_fault_check()
386 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_CRC, in max22190_fault_check()
387 data->fault1_en.reg_bits.max22190_CRCE); in max22190_fault_check()
388 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_POR, in max22190_fault_check()
389 data->fault1_en.reg_bits.max22190_PORE); in max22190_fault_check()
390 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_FAULT2, in max22190_fault_check()
391 data->fault1_en.reg_bits.max22190_FAULT2E); in max22190_fault_check()
392 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_ALRMT2, in max22190_fault_check()
393 data->fault1_en.reg_bits.max22190_ALRMT2E); in max22190_fault_check()
394 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_ALRMT1, in max22190_fault_check()
395 data->fault1_en.reg_bits.max22190_ALRMT1E); in max22190_fault_check()
396 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_24VL, in max22190_fault_check()
397 data->fault1_en.reg_bits.max22190_24VLE); in max22190_fault_check()
398 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_24VM, in max22190_fault_check()
399 data->fault1_en.reg_bits.max22190_24VME); in max22190_fault_check()
400 PRINT_ERR_BIT(data->fault1.reg_bits.max22190_WBG, in max22190_fault_check()
401 data->fault1_en.reg_bits.max22190_WBGE); in max22190_fault_check()
403 if (data->fault1.reg_bits.max22190_WBG & data->fault1_en.reg_bits.max22190_WBGE) { in max22190_fault_check()
409 if (data->fault1.reg_bits.max22190_FAULT2) { in max22190_fault_check()
411 data->fault2.reg_raw = max22190_reg_read(dev, MAX22190_FAULT2_REG); in max22190_fault_check()
414 data->fault2_en.reg_raw = max22190_reg_read(dev, MAX22190_FAULT2_EN_REG); in max22190_fault_check()
416 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_RFWBS, in max22190_fault_check()
417 data->fault2_en.reg_bits.max22190_RFWBSE); in max22190_fault_check()
418 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_RFWBO, in max22190_fault_check()
419 data->fault2_en.reg_bits.max22190_RFWBOE); in max22190_fault_check()
420 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_RFDIS, in max22190_fault_check()
421 data->fault2_en.reg_bits.max22190_RFDISE); in max22190_fault_check()
422 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_RFDIO, in max22190_fault_check()
423 data->fault2_en.reg_bits.max22190_RFDIOE); in max22190_fault_check()
424 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_OTSHDN, in max22190_fault_check()
425 data->fault2_en.reg_bits.max22190_OTSHDNE); in max22190_fault_check()
426 PRINT_ERR_BIT(data->fault2.reg_bits.max22190_FAULT8CK, in max22190_fault_check()
427 data->fault2_en.reg_bits.max22190_FAULT8CKE); in max22190_fault_check()
434 const struct max22190_config *config = dev->config; in max22190_state_get()
436 if (gpio_pin_get_dt(&config->fault_gpio)) { in max22190_state_get()
453 return -ENOTSUP; in gpio_max22190_config()
457 return -ENOTSUP; in gpio_max22190_config()
461 return -ENOTSUP; in gpio_max22190_config()
465 return -ENOTSUP; in gpio_max22190_config()
474 return -ENOTSUP; in gpio_max22190_config()
482 const struct max22190_config *config = dev->config; in max22190_filter_set()
485 max22190_reg_write(dev, MAX22190_FILTER_IN_REG(ch_n), config->filter[ch_n].reg_raw); in max22190_filter_set()
491 const struct max22190_data *data = dev->data; in max22190_fault_set()
494 ret = max22190_reg_write(dev, MAX22190_FAULT1_EN_REG, data->fault1_en.reg_raw); in max22190_fault_set()
499 ret = max22190_reg_write(dev, MAX22190_FAULT1_REG, data->fault1.reg_raw); in max22190_fault_set()
504 ret = max22190_reg_write(dev, MAX22190_FAULT2_EN_REG, data->fault2_en.reg_raw); in max22190_fault_set()
509 ret = max22190_reg_write(dev, MAX22190_FAULT2_REG, data->fault2.reg_raw); in max22190_fault_set()
523 const struct max22190_data *data = dev->data; in gpio_max22190_port_get_raw()
529 *value |= data->channels[ch_n] << ch_n; in gpio_max22190_port_get_raw()
537 const struct max22190_config *config = dev->config; in gpio_max22190_init()
538 struct max22190_data *data = dev->data; in gpio_max22190_init()
544 if (!spi_is_ready_dt(&config->spi)) { in gpio_max22190_init()
546 return -ENODEV; in gpio_max22190_init()
549 /* setup READY gpio - normal low */ in gpio_max22190_init()
550 if (!gpio_is_ready_dt(&config->ready_gpio)) { in gpio_max22190_init()
552 return -ENODEV; in gpio_max22190_init()
555 err = gpio_pin_configure_dt(&config->ready_gpio, GPIO_INPUT); in gpio_max22190_init()
561 /* setup FAULT gpio - normal high */ in gpio_max22190_init()
562 if (!gpio_is_ready_dt(&config->fault_gpio)) { in gpio_max22190_init()
564 return -ENODEV; in gpio_max22190_init()
567 err = gpio_pin_configure_dt(&config->fault_gpio, GPIO_INPUT | GPIO_PULL_UP); in gpio_max22190_init()
573 /* setup LATCH gpio - normal high */ in gpio_max22190_init()
574 if (!gpio_is_ready_dt(&config->latch_gpio)) { in gpio_max22190_init()
576 return -ENODEV; in gpio_max22190_init()
579 err = gpio_pin_configure_dt(&config->latch_gpio, GPIO_OUTPUT_INACTIVE); in gpio_max22190_init()
587 config->filter[i].reg_bits.max22190_WBE, in gpio_max22190_init()
588 config->filter[i].reg_bits.max22190_FBP, in gpio_max22190_init()
589 config->filter[i].reg_bits.max22190_DELAY); in gpio_max22190_init()
592 LOG_DBG(" > MAX22190 MODE: %x", config->mode); in gpio_max22190_init()
593 LOG_DBG(" > MAX22190 PKT SIZE: %dbits (%dbytes)", config->pkt_size * 8, config->pkt_size); in gpio_max22190_init()
594 LOG_DBG(" > MAX22190 CRC: %s", config->crc_en ? "enable" : "disable"); in gpio_max22190_init()
596 data->fault1_en.reg_bits.max22190_WBGE = 1; in gpio_max22190_init()
597 data->fault1_en.reg_bits.max22190_PORE = 1; in gpio_max22190_init()