PubInv / krake

A wireless alarm device which makes loud noises and flashes lights to alert a human
GNU Affero General Public License v3.0
0 stars 2 forks source link

Add SPI Interface as Peripheral (Formerly Slave) #47

Open nk25719 opened 1 month ago

nk25719 commented 1 month ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] If the Krake™ is to be a replacement for the GPAD, it must be possible to be controlled by SPI interface just as the GPAD was. The GPAD interface is a 5V logic level.

Describe the solution you'd like A clear and concise description of what you want to happen. Add an SPI (Serial Peripheral Interface) to communicate with peripheral devices Serial Peripheral Interface is a four wire interface for bidirectional logic level connection from a Controller to a Peripherial. In a system, the Krake™ is the peripheral. Some other device is the SPI Controller. The SPI interface is so old that when it was defined logic levels were 5 Volt.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

For the Poly Vent the 3.3 Volt Controller (ESP32) SPI interface was level shifted up to 5Volts for the GPAD. The same level shifting technique must be evaluated for the Krake™

Additional context Add any other context or screenshots about the feature request here.

ForrestErickson commented 1 month ago

Reference Data sheet for ESP32 S2:

https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf See section 3.4.2 Serial Peripheral Interface (SPI)

To Do, Prototype SPI As Peripheral

Figure out which of the four SPI peripherals are available (not already in use) on the ESP32 Dev Kit we have. Prototype an SPI Peripheral (formerly Slave) system and control it with an SPI Controller (Formerly Master) and make

ForrestErickson commented 1 month ago

To Do Review ESP32 S2 SPI Libraries

Here is one about which to read: https://github.com/hideakitai/ESP32SPISlave It is the one Lee appears to already have installed: image

Random Nerd Tutorials ESP32 SPI Tutorial

https://randomnerdtutorials.com/esp32-spi-communication-arduino/
image

Sara writes image

Library Master and Slave Examples

https://github.com/hideakitai/ESP32SPISlave/tree/main/examples/transfer_in_the_background

ForrestErickson commented 1 month ago

Added Robert to this issue.

@RobertLRead The GPAD firmware will need to be modified so that it can compile on both the UNO controller and the ESP32-S2. I am assuming a lot of #ifdefine ESP32-S2 else #ifdef Atmega328 will be required.

ForrestErickson commented 1 month ago

SPI Pins on ESP32 DEV

Lee loaded and ran the Random Nerd Tutorials sketch to identify SPI pins on his ESP32-S2 Deve Kit 1 image

Bottom line 05:56:43.509 -> MOSI: 23 05:56:43.509 -> MISO: 19 05:56:43.509 -> SCK: 18 05:56:43.509 -> SS: 5

@nk25719 Please review the MockingKrake for the availability of these pins and any conflict with existing pin usage and report to @RobertLRead and @ForrestErickson

Lee notes that on the PWA Homework2 these pins are brought out to LEDs and so might be easy to solder to for prototyping. image

ForrestErickson commented 5 days ago

@nk25719 Wiring two Homework2 assemblies together would be a prudent thing to do in a way that reflects the SPI buss connections we have put into the KRAKE schematic.

Then one device is programed as a Controller and one as a Peripheral to verify the hardware connection works.

In addition there should be a Peripheral Interrupt Request, a GPIO output on the Peripheral which goes into an input on the Controller to signal the Peripheral needs attention. The Peripheral Interrupt Request needs to be added to the GPAD schematic.