diff --git a/README.md b/README.md index dabf68b..7d1789c 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,21 @@ Feel free to reach out to me at CodeAllNight@outlook.com with any questions or l ## GPIO +### gpio-pins +[tool](./gpio/pins/README.md) - This is a set of files you can copy to your Flipper Zero so that you can easily lookup the meaning of a pin. + +### hc_sr04 +[project](./gpio/hc_sr04/README.md) - This is an improvement over the original HC_SR04 library so that you can get mm accuracy in measurements. It displays ultrasonic distance in both inches/cm. The readme explains how the code gets more accurate timings. + +### gpio-gpio-7segment +[project](./gpio/gpio_7segment/README.md) - This application can control a common-anode or common-cathode 7-segment display. When you click the OK button the display shows a random dice roll (1-6); but you can modify code to display any number from 0-9. + ### gpio-gpio-polling-demo [tutorial](./gpio/gpio_polling_demo/README.md) - This is a "hello world" demonstration of reading a GPIO pin using polling. + + ## Subghz [folder](./subghz/README.md) ### subghz-plugins-subghz_demo [tutorial](./subghz/plugins/subghz_demo/README.md) - This is a demonstration of sending & receiving radio signals using the subghz_tx_rx worker library. diff --git a/gpio/pins/L1_White_5Volts.txt b/gpio/pins/L1_White_5Volts.txt new file mode 100644 index 0000000..a81d7c6 --- /dev/null +++ b/gpio/pins/L1_White_5Volts.txt @@ -0,0 +1,10 @@ +Connected via USB cable it will have +5 volts OTHERWISE you must enable via GPIO/"5V on GPIO" and click "ON". +Max of 1 watt (1-Amp). + +Look at device datasheet. If 5 volts, connect to "VIN", "VCC" or "+5V" (if NO VIN) on the device. +If datasheet says 3.3 volts, do NOT use this pin! + +Devices: +- HC-SR04 +- Joystick (via a 10K resistor) +- Mx2125 (recommend 3v3 pin) diff --git a/gpio/pins/L2_Orange_MOSI_COPI_PA7.txt b/gpio/pins/L2_Orange_MOSI_COPI_PA7.txt new file mode 100644 index 0000000..126ba01 --- /dev/null +++ b/gpio/pins/L2_Orange_MOSI_COPI_PA7.txt @@ -0,0 +1,11 @@ +For SPI, the naming convetion is changing. You may see "MOSI", "MO", "SI", "COPI", "CO", "PI". This pin is Flipper data out "SDO" (which should connect to the device data in "SDI") pin. "I" refers to "Input" and "O" refers to "Output". "M/C" refers to "Main", "Master" (not used anymore), "Controller". "S/P" refers to "Subnode", "Slave" (not used anymore), "Perpherial". "SD" refers to "Serial Data". + +Generic GPIO uses PA7. + +Devices: +- DHT11[GPIO] (PA7) +- BME280[SPI] (SDI) +- BMP280[SPI] (SDI) +- NRF24L01[SPI] (MO) +- NRF24L02[SPI] (MOSI) +- CC1101[SPI] (SI) diff --git a/gpio/pins/L3_Indigo_MISO_COPI_PA6.txt b/gpio/pins/L3_Indigo_MISO_COPI_PA6.txt new file mode 100644 index 0000000..60aae22 --- /dev/null +++ b/gpio/pins/L3_Indigo_MISO_COPI_PA6.txt @@ -0,0 +1,10 @@ +For SPI, the naming convetion is changing. You may see "MISO", "MI", "SO", "CIPO", "CI", "PO". This pin is Flipper data out "SDI" (which should connect to the device data in "SDO") pin. "I" refers to "Input" and "O" refers to "Output". "M/C" refers to "Main", "Master" (not used anymore), "Controller". "S/P" refers to "Subnode", "Slave" (not used anymore), "Perpherial". "SD" refers to "Serial Data". + +Generic GPIO uses PA6. + +Devices: +- BME280[SPI] (SDO) +- BMP280[SPI] (SDO) +- NRF24L01[SPI] (MI) +- NRF24L02[SPI] (MISO) +- CC1101[SPI] (SO) diff --git a/gpio/pins/L4_Green_CS_CSN_PA4.txt b/gpio/pins/L4_Green_CS_CSN_PA4.txt new file mode 100644 index 0000000..4436bdd --- /dev/null +++ b/gpio/pins/L4_Green_CS_CSN_PA4.txt @@ -0,0 +1,12 @@ +For SPI, this is the Chip Select (which enables the data lines.) Typically LOW to enable -- "CSN" is "Chip Select Not". + +Generic GPIO uses PA4. + +CHECK: "LPTIM2.OUT/ADC1.9/COMP1 IN- COMP2 IN-" + +Devices: +- BME280[SPI] (CS) +- BMP280[SPI] (CS) +- NRF24L01[SPI] (CSN) +- NRF24L02[SPI] (CSN) +- CC1101[SPI] (CSN) \ No newline at end of file diff --git a/gpio/pins/L5_Brown_SCK_RTS_PB3.txt b/gpio/pins/L5_Brown_SCK_RTS_PB3.txt new file mode 100644 index 0000000..06bb9fc --- /dev/null +++ b/gpio/pins/L5_Brown_SCK_RTS_PB3.txt @@ -0,0 +1,13 @@ +For SPI, this is the Serial Clock (which says when to read/write data.) Typically Mode 0 (Idle LOW, Sample Rising Edge, Shift Falling Edge.) + +Generic GPIO uses PB3. + +CHECK: "ADC1.9/COMP1 IN- COMP2 IN-/SWO" + + +Devices: +- BME280[SPI] (SCK) +- BMP280[SPI] (SCK) +- NRF24L01[SPI] (SCK) +- NRF24L02[SPI] (SCK) +- CC1101[SPI] (SCLK) \ No newline at end of file diff --git a/gpio/pins/L6_Blue_CS(CE)_PB2.txt b/gpio/pins/L6_Blue_CS(CE)_PB2.txt new file mode 100644 index 0000000..8d2240c --- /dev/null +++ b/gpio/pins/L6_Blue_CS(CE)_PB2.txt @@ -0,0 +1,10 @@ +For SPI, libraries do not treat as CS (although it is shown in some diagrams.) This is just a GPIO pin, but it typically get connected to "CE" (for Chip Enable -- e.g. take chip out of standby.) It is typically logic LOW. On the CC1101 it is used for GDO0 (general purpose IRQ). + +Generic GPIO uses PB2. + +CHECK: "LPTIM1.OUT/COMP1 IN+" + +Devices: +- NRF24L01[SPI] (CE) +- NRF24L02[SPI] (CE) +- CC1101[SPI] (GDO0) \ No newline at end of file diff --git a/gpio/pins/L7_Brown_PC3.txt b/gpio/pins/L7_Brown_PC3.txt new file mode 100644 index 0000000..cc6e953 --- /dev/null +++ b/gpio/pins/L7_Brown_PC3.txt @@ -0,0 +1,8 @@ +This is just a general purpose GPIO pin. + +Generic GPIO uses PC3. + +CHECK: "LPTIM1.ETR LPTIM2.ETR/ADC1.4" + +Devices: +- None \ No newline at end of file diff --git a/gpio/pins/L8_Black_GND.txt b/gpio/pins/L8_Black_GND.txt new file mode 100644 index 0000000..95afe71 --- /dev/null +++ b/gpio/pins/L8_Black_GND.txt @@ -0,0 +1,4 @@ +This is one of three ground pins on the Flipper Zero. You can use pins 8 (L8), 11 (R3), 18 (R10) interchangeably. + +Devices: +- All \ No newline at end of file diff --git a/gpio/pins/R1(9)_Red_3v3_3.3v_VCC.txt b/gpio/pins/R1(9)_Red_3v3_3.3v_VCC.txt new file mode 100644 index 0000000..10b9bde --- /dev/null +++ b/gpio/pins/R1(9)_Red_3v3_3.3v_VCC.txt @@ -0,0 +1,19 @@ +DANGER: Connect external modules with large capacitive load only when Flipper Zero is powered off. Otherwise, data on the microSD card can be corrupted. + +This pin is 3.3 Volts output. NOTE: Some people recommend using the 5V pin (L1) and a 3.3 volt regulator with output having a parallel 10uF and 100nF capacitor; so that voltage is more stable. + +Max of 1200 mA (3.96 watt). + +Look at device datasheet. If 3.3 volts, connect to "VIN", "VCC", "3.3V/3V3" (if NO VIN) on the device. + +Devices: +- NMEA GPS[USART] (VIN) +- DHT11[GPIO] (VCC) +- BME280[I²C] (VCC) +- BME280[SPI-MODE] (VCC) +- BMP280[SPI] (VIN) +- BH1750[I²C] (VCC) +- NRF24L01[SPI] (VCC) +- NRF24L01[SPI] (VCC) +- CC1101[SPI] (VCC) + diff --git a/gpio/pins/R2(10)_Brown_NC_SWC_PA14.txt b/gpio/pins/R2(10)_Brown_NC_SWC_PA14.txt new file mode 100644 index 0000000..805173e --- /dev/null +++ b/gpio/pins/R2(10)_Brown_NC_SWC_PA14.txt @@ -0,0 +1,6 @@ +This pin is used for general IO, timer & SWD only. + +CHECK: "LPTIM1.OUT/SWCLK" + +Devices: +- None diff --git a/gpio/pins/R3(11)_GND.txt b/gpio/pins/R3(11)_GND.txt new file mode 100644 index 0000000..95afe71 --- /dev/null +++ b/gpio/pins/R3(11)_GND.txt @@ -0,0 +1,4 @@ +This is one of three ground pins on the Flipper Zero. You can use pins 8 (L8), 11 (R3), 18 (R10) interchangeably. + +Devices: +- All \ No newline at end of file diff --git a/gpio/pins/R4(12)_Grey_NC_SWDIO.txt b/gpio/pins/R4(12)_Grey_NC_SWDIO.txt new file mode 100644 index 0000000..0e97893 --- /dev/null +++ b/gpio/pins/R4(12)_Grey_NC_SWDIO.txt @@ -0,0 +1,6 @@ +This pin is used for back key (PA13) and SWD only. + +CHECK: "PA13/SWIO" + +Devices: +- None diff --git a/gpio/pins/R5(13)_Orange_TX_LPTIM1.EXT.txt b/gpio/pins/R5(13)_Orange_TX_LPTIM1.EXT.txt new file mode 100644 index 0000000..5d84c9f --- /dev/null +++ b/gpio/pins/R5(13)_Orange_TX_LPTIM1.EXT.txt @@ -0,0 +1,11 @@ +This pin is Flipper TX on USART (so connect to RX on device). + +The Signal Generator/Clock Generator app uses LPTIM1.EXT (pin 13) for the clock signal. + +Generic GPIO uses PB6. + +CHECK: "COMP2 IN+/MCO" + +Devices: +- NMEA GPS[USART] (RX) +- HC-SR04[GPIO] (Trig) diff --git a/gpio/pins/R6(14)_Indigo_RX.txt b/gpio/pins/R6(14)_Indigo_RX.txt new file mode 100644 index 0000000..e1c450c --- /dev/null +++ b/gpio/pins/R6(14)_Indigo_RX.txt @@ -0,0 +1,9 @@ +This pin is Flipper RX on USART (so connect to TX on device). + +Generic GPIO uses PB7. + +CHECK: "LPTIM1.IN2/COMP2 IN-" + +Devices: +- NMEA GPS[USART] (TX) +- HC-SR04[GPIO] (Echo) diff --git a/gpio/pins/R7(15)_Yellow_LPTX_SDA_ADC1.2_PC1.txt b/gpio/pins/R7(15)_Yellow_LPTX_SDA_ADC1.2_PC1.txt new file mode 100644 index 0000000..8d9983f --- /dev/null +++ b/gpio/pins/R7(15)_Yellow_LPTX_SDA_ADC1.2_PC1.txt @@ -0,0 +1,11 @@ +This pin is Flipper TX on LPUART [Low Power UART] (so connect to RX on device). + +For I2C devices this is SDA (Serial Data) pin. + +Generic GPIO uses PC1. + +CHECK: "LPTIM1.OUT/ADC1.2" + +Devices: +- BME280[I²C] (SDA) +- BH1750[I²C] (SDA) diff --git a/gpio/pins/R8(16)_Brown_LPRX_SCL_ADC1.1_PC0.txt b/gpio/pins/R8(16)_Brown_LPRX_SCL_ADC1.1_PC0.txt new file mode 100644 index 0000000..8eb8885 --- /dev/null +++ b/gpio/pins/R8(16)_Brown_LPRX_SCL_ADC1.1_PC0.txt @@ -0,0 +1,13 @@ +This pin is Flipper RX on LPUART [Low Power UART] (so connect to TX on device). + +For I2C devices this is SCL (Serial Clock) pin. + +For ADC devices this is ADC1.1 pin (flipperscope application uses LL library to show values.) + +Generic GPIO uses PC0. + +CHECK: "LPTIM1.IN LPTIM2.IN" + +Devices: +- BME280[I²C] (SCL) +- BH1750[I²C] (SCL) diff --git a/gpio/pins/R9(17)_Yellow_1W.txt b/gpio/pins/R9(17)_Yellow_1W.txt new file mode 100644 index 0000000..7d734fb --- /dev/null +++ b/gpio/pins/R9(17)_Yellow_1W.txt @@ -0,0 +1,9 @@ +For 1-Wire (iButton) devices this is the wire. It has built-in 1K pull-up resistor to 5 volts. + +Generic GPIO uses PC0. + +CHECK: "PB14/TIM1.2N/I2C3.SDA-Pullup" + +Devices: +- iButton[1Wire] (center of button) +- DS18B20[1Wire] (yellow wire) \ No newline at end of file diff --git a/gpio/pins/README.md b/gpio/pins/README.md new file mode 100644 index 0000000..19fe119 --- /dev/null +++ b/gpio/pins/README.md @@ -0,0 +1,27 @@ +# Pins + +## Description +To help making things easier, I have been trying to use specific colored wires for connecting to various devices. I also made a breakout board that connects to the top of the Flipper Zero and exposes the same colored wires on a breadboard for quick prototyping. The breadboard also exposes a copy of each general output with a 220 ohm series resistor (which is helpful for driving LEDs). + +The pins have different names depending on their meaning, so this +helps me connect to the proper pins. + +I use the following colors (for some usages like LPUART v. I2C it isn't a match; but I think it is more common for the pins to be I2C): +- White = +5V +- Red = +3.3V +- Black = GND +- Orange = OUT [from Flipper perspective] +- Indigo = IN [from Flipper perspective] +- Yellow = IN/OUT +- Green = SELECT [TYPICALLY LOW] +- Brown = CLOCK +- Blue = GENERAL/IRQ +- Grey = TYPICALLY UNUSED +NOTE: For General Purpose Input/Output (like controlling a 7-segment LED display) instead of a specific protocol, the majority of the colors have no meanings. + + +## Installing +I copy these files into a folder on my Flipper Zero (like "pins") so that I can easily browse all of the pins. If you click on a file and chose "Info" so that you see the full name without scrolling. If you click on a file and choose "Show" then you will see details about that pin. + +## Future work +Many devices have printing on the underside, so you have to be careful when connecting to those (or connect wires from breadboard to device - instead of plugging in directly to device.) Some devices have two sets of adjecent pins, so they don't work in breadboard (I'm working on making an adapter soon) so they can go into my breadboard (but you can also connect wires from breadboard to device.) diff --git a/gpio/pins/R_10(18)_Black_GND.txt b/gpio/pins/R_10(18)_Black_GND.txt new file mode 100644 index 0000000..95afe71 --- /dev/null +++ b/gpio/pins/R_10(18)_Black_GND.txt @@ -0,0 +1,4 @@ +This is one of three ground pins on the Flipper Zero. You can use pins 8 (L8), 11 (R3), 18 (R10) interchangeably. + +Devices: +- All \ No newline at end of file