nopnop2002 / Arduino-SI4432

Arduino library for SILICON LABS SI443x
MIT License
15 stars 5 forks source link

Make SPI class and SDN pin optional #3

Closed itsmevjnk closed 1 year ago

itsmevjnk commented 1 year ago

Some platforms (e.g. ESP32) have multiple SPI buses; therefore, it would be nice if the user can choose which SPI bus to use. Also, I've made the SDN pin optional since there are also cases when the user may want to use external circuitry to perform automatic POR for the Si4432.

nopnop2002 commented 1 year ago

Only certain platforms, such as the ESP32, allow multiple SPI buses. This library is generic. No specific platform support is provided. Hardware SPI must also be available.

We need the following two functions

bool init(SPIClass* spi = &SPI); // use specific spi
bool init(); // use Hardware spi

We will not accept your PR. Once the two functions are complete, you can create a new PR.

itsmevjnk commented 1 year ago

The SPI object that is referenced in the function I modified is the default hardware SPI object for Arduino, and as such, it is still generic. Also, since it's an optional parameter, the library will still be compatible with older code. For reference, Adafruit also does something like that for their generic PCD8544 library: https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/blob/master/Adafruit_PCD8544.h#L69

nopnop2002 commented 1 year ago

What you presented provides functions that use SPIClass and functions that don't.

We also need two initialization functions like this.

Adafruit_PCD8544 ( int8_t sclk_pin, int8_t din_pin, int8_t dc_pin,
                   int8_t cs_pin, int8_t rst_pin);
Adafruit_PCD8544 ( int8_t dc_pin, int8_t cs_pin, int8_t rst_pin,
                   SPIClass *theSPI = &SPI);
nopnop2002 commented 1 year ago

We need to apologize to you

I noticed that specifying the SPIClass is optional.

bool init(SPIClass* spi = &SPI);

We accept PR.

Please make a PR again.

itsmevjnk commented 1 year ago

I just made a new PR. Also, thank you for taking a look into my code and accepting it. Have a good day!