]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/microcontroller/generic_agnostic_board/spi.py
Merge branch 'lgpio-native' of https://github.com/frank-pet/Adafruit_Blinka into...
[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     # pylint: disable=unnecessary-pass
41     def write(self, buf, start=0, end=None):
42         """Write data from the buffer to SPI"""
43         pass
44
45     # pylint: disable=unnecessary-pass
46     def readinto(self, buf, start=0, end=None, write_value=0):
47         """Read data from SPI and into the buffer"""
48         pass
49
50     # pylint: disable=too-many-arguments, unnecessary-pass
51     def write_readinto(
52         self, buffer_out, buffer_in, out_start=0, out_end=None, in_start=0, in_end=None
53     ):
54         """Perform a half-duplex write from buffer_out and then
55         read data into buffer_in
56         """
57         pass