]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/microcontroller/generic_agnostic_board/spi.py
3012573f574dbeeec2afe6970f79e1fb1bd15974
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / generic_agnostic_board / spi.py
1 # SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
2 #
3 # SPDX-License-Identifier: MIT
4 """SPI class for a generic agnostic board."""
5 # from .rp2040_u2if import rp2040_u2if
6
7
8 # pylint: disable=protected-access, no-self-use
9 class SPI:
10     """SPI Base Class for a generic agnostic board."""
11
12     MSB = 0
13
14     def __init__(self, index, *, baudrate=100000):
15         self._index = index
16         self._frequency = baudrate
17
18     # pylint: disable=too-many-arguments,unused-argument
19     def init(
20         self,
21         baudrate=1000000,
22         polarity=0,
23         phase=0,
24         bits=8,
25         firstbit=MSB,
26         sck=None,
27         mosi=None,
28         miso=None,
29     ):
30         """Initialize the Port"""
31         self._frequency = baudrate
32
33     # pylint: enable=too-many-arguments
34
35     @property
36     def frequency(self):
37         """Return the current frequency"""
38         return self._frequency
39
40     def write(self, buf, start=0, end=None):
41         """Write data from the buffer to SPI"""
42         pass
43
44     def readinto(self, buf, start=0, end=None, write_value=0):
45         """Read data from SPI and into the buffer"""
46         pass
47
48     # pylint: disable=too-many-arguments
49     def write_readinto(
50         self, buffer_out, buffer_in, out_start=0, out_end=None, in_start=0, in_end=None
51     ):
52         """Perform a half-duplex write from buffer_out and then
53         read data into buffer_in
54         """
55         pass