RadioHead
RHSUBGHZSPI.h
1// RHSUBGHZSPI.h
2// Author: Mike McCauley (mikem@airspayce.com)
3// Copyright (C) 2023 Mike McCauley
4
5#ifndef RHSUBGHZSPI_h
6#define RHSUBGHZSPI_h
7
8#include <RHGenericSPI.h>
9
10// Are we building for a suitable STM processor
11#if defined(SUBGHZSPI_BASE)
12
13/////////////////////////////////////////////////////////////////////
14/// \class RHSUBGHZSPI RHSUBGHZSPI.h <RHSUBGHZSPI.h>
15/// \brief Base class for SPI interfacesInterface for SUBGHZSPIClass
16/// as used on eg Wio-E5 mini and other boards that use the Seeed LoRa-E5-HF, LoRa-E5-LF modules
17/// which use the STM32WLE5JC family processors.
18///
19/// SubGhz is the SPI interface used on the STM32WLE5JC to communicate with the internal SX1261 radio,
20/// and it has some special methods needed to talk to the chip.
21///
22class RHSUBGHZSPI : public RHGenericSPI
23{
24public:
25 uint8_t transfer(uint8_t data) { return SubGhz.SPI.transfer(data); };
26
27 /// Initialise the software SPI library
28 /// Call this after configuring the SPI interface and before using it to transfer data.
29 /// Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.
30 void begin() { SubGhz.SPI.begin(); };
31
32 /// Disables the SPI bus usually, in this case
33 /// there is no hardware controller to disable.
34 void end() { SubGhz.SPI.end(); };
35
36 void beginTransaction() {
37 SubGhz.SPI.beginTransaction(SubGhz.spi_settings);
38 SubGhz.setNssActive(true);
39 while (SubGhz.isBusy()) /* wait */;
40 };
41 void endTransaction() {
42 SubGhz.setNssActive(false);
43 SubGhz.SPI.endTransaction();
44 };
45};
46
47#endif
48#endif
Base class for SPI interfaces.
Definition: RHGenericSPI.h:31
virtual void end()=0
virtual uint8_t transfer(uint8_t data)=0
virtual void endTransaction()
Definition: RHGenericSPI.h:160
virtual void begin()=0
virtual void beginTransaction()
Definition: RHGenericSPI.h:155