herosdevices.hardware.raspberrypi.max318xx.max318xx
===================================================

.. py:module:: herosdevices.hardware.raspberrypi.max318xx.max318xx

.. autoapi-nested-parse::

   Implements the MAX31865 resistance-to-digital converter interface.

   The MAX31865 chip communicates via SPI, and in this implementation, SPI communication
   is carried out through bit-banging using the RPi.GPIO library. For better performance,
   using an SPI library such as spidev is recommended, but this code is a first approach.

   Note: numpy is only required if implementing the full Calendar-Van Dusen equations.

   This code is adapted from steve71's work: https://github.com/steve71/MAX31865







Module Contents
---------------

.. py:exception:: FaultError

   Bases: :py:obj:`Exception`


   Exception class for handling faults detected in the RTD or wiring.


.. py:class:: MAX318xx(cs_pins: dict, miso_pin: int = 9, mosi_pin: int | None = 10, clk_pin: int = 11)

   Base class for MAX318xx series resistance-to-digital converters.

   Handles SPI communication via bit-banging using GPIO pins.

   .. attribute:: cs_pin

      {"description": "Chip select GPIO pin number"}.

      :type: dict

   .. attribute:: miso_pin

      Master In Slave Out GPIO pin number.

      :type: int

   .. attribute:: mosi_pin

      Master Out Slave In GPIO pin number.

      :type: int

   .. attribute:: clk_pin

      Clock GPIO pin number.

      :type: int


   .. py:attribute:: cs_pins


   .. py:attribute:: miso_pin
      :value: 9



   .. py:attribute:: mosi_pin
      :value: 10



   .. py:attribute:: clk_pin
      :value: 11



   .. py:method:: write_register(reg_num: int, data_byte: int) -> None

      Write a byte to a specified register.

      :param regNum: Register number to write to.
      :type regNum: int
      :param dataByte: Data byte to write.
      :type dataByte: int



   .. py:method:: read_register(cs_pin: int, num_registers: int, reg_num_start: int | None = None) -> list[int]

      Read one or more bytes starting from a specified register.

      :param cs_pin: Chip select GPIO pin number.
      :type cs_pin: int
      :param numRegisters: Number of bytes to read.
      :type numRegisters: int
      :param regNumStart: Starting register number for the read operation.
      :type regNumStart: int, optional

      :returns: List of bytes read from the device.
      :rtype: list



   .. py:method:: send_byte(byte: int) -> None

      Send a byte via SPI by bit-banging.

      :param byte: Byte value to send.
      :type byte: int



   .. py:method:: recv_byte() -> int

      Receive a byte via SPI by bit-banging.

      :returns: Byte received.
      :rtype: int



   .. py:method:: create_dict(values: list[float], observable: str, unit: str) -> dict

      Build dictionary of observables to be returned by the sensor.



