@@ -39,7 +39,7 @@ class AD9833:
3939 The AD9833 is a programmable waveform generator that produces sine, square,
4040 and triangular waveform output from 0 MHz to 12.5MHz with 28-bit frequency
4141 resolution. The CircuitPython class sets the waveform generator's frequency,
42- phase, and waveshape properties as well as providing methods for
42+ phase, and wave shape properties as well as providing methods for
4343 resetting, starting, pausing, and stopping the generator."""
4444
4545 # pylint: disable=too-many-arguments
@@ -48,26 +48,30 @@ def __init__(
4848 wave_freq = 440 ,
4949 wave_phase = 0 ,
5050 wave_type = "sine" ,
51- select = "D6" ,
51+ spi = board .SPI (),
52+ select = board .D6 ,
5253 m_clock = 25000000 ,
5354 ):
54- """Initialize SPI bus interconnect, derive chip select pin (to allow
55- multiple class instances), and create the SPIDevice instance. During
56- intialization, the generator is reset and placed in the pause state.
55+ """Initialize SPI bus interconnect and create the SPIDevice instance.
56+ During initialization, the generator is reset and placed in the pause
57+ state.
5758
5859 :param int wave_freq: The 28-bit waveform frequency in Hz ranging from
5960 0 to 2 ** 28. Practical maximum is 12.5MHz (one-half the master clock
6061 frequency). Defaults to 440.
6162 :param int wave_phase: The waveform phase offset in 2π Rad // 4096.
6263 Defaults to 0.
63- :param str wave_type: The "sine", "triangle", or "square" waveshape .
64+ :param str wave_type: The "sine", "triangle", or "square" wave shape .
6465 Defaults to "sine".
65- :param str select: The AD9833 chip select pin designation. Defaults to "D6".
66+ :param busio.SPI spi: The board's `busio.SPI` definition. Defaults to
67+ `board.SPI()`.
68+ :param board select: The AD9833 chip select pin designation. Defaults to
69+ `board.D6`.
6670 :param int m_clock: Master clock frequency in Hz. Defaults to 25MHz.
6771 """
6872
69- self ._spi = board . SPI () # Define SPI bus
70- self ._cs = digitalio .DigitalInOut (getattr ( board , select ) )
73+ self ._spi = spi # Define SPI bus
74+ self ._cs = digitalio .DigitalInOut (select )
7175 self ._device = SPIDevice (
7276 self ._spi , self ._cs , baudrate = 5000000 , polarity = 1 , phase = 0
7377 )
0 commit comments