forked from letscontrolit/RFLinkSmall
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,004 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// ************************************* // | ||
// * Arduino Project RFLink-esp * // | ||
// * https://github.com/couin3/RFLink * // | ||
// * 2018..2020 Stormteam - Marc RIVES * // | ||
// * More details in RFLink.ino file * // | ||
// ************************************* // | ||
|
||
#include <Arduino.h> | ||
#include "RFLink.h" | ||
#include "1_Radio.h" | ||
#ifdef AUTOCONNECT_ENABLED | ||
#include "9_AutoConnect.h" | ||
#else | ||
uint8_t PIN_RF_RX_PMOS = PIN_RF_RX_PMOS_0; | ||
uint8_t PIN_RF_RX_NMOS = PIN_RF_RX_NMOS_0; | ||
uint8_t PIN_RF_RX_VCC = PIN_RF_RX_VCC_0; | ||
uint8_t PIN_RF_RX_GND = PIN_RF_RX_GND_0; | ||
uint8_t PIN_RF_RX_NA = PIN_RF_RX_NA_0; | ||
uint8_t PIN_RF_RX_DATA = PIN_RF_RX_DATA_0; | ||
uint8_t PIN_RF_TX_PMOS = PIN_RF_TX_PMOS_0; | ||
uint8_t PIN_RF_TX_NMOS = PIN_RF_TX_NMOS_0; | ||
uint8_t PIN_RF_TX_VCC = PIN_RF_TX_VCC_0; | ||
uint8_t PIN_RF_TX_GND = PIN_RF_TX_GND_0; | ||
uint8_t PIN_RF_TX_DATA = PIN_RF_TX_DATA_0; | ||
boolean PULLUP_RF_RX_DATA = PULLUP_RF_RX_DATA_0; | ||
#endif //AUTOCONNECT_ENABLED | ||
|
||
// Prototype | ||
void enableRX(); | ||
void disableRX(); | ||
void enableTX(); | ||
void disableTX(); | ||
|
||
Radio_State current_State = Radio_NA; | ||
|
||
void set_Radio_mode(Radio_State new_State) | ||
{ | ||
if (current_State != new_State) | ||
{ | ||
switch (new_State) | ||
{ | ||
case Radio_OFF: | ||
disableTX(); | ||
disableRX(); | ||
break; | ||
|
||
case Radio_RX: | ||
disableTX(); | ||
enableRX(); | ||
break; | ||
|
||
case Radio_TX: | ||
disableRX(); | ||
enableTX(); | ||
break; | ||
|
||
case Radio_NA: | ||
break; | ||
} | ||
current_State = new_State; | ||
} | ||
} | ||
|
||
void enableRX() | ||
{ | ||
// RX pins | ||
pinMode(PIN_RF_RX_NA, INPUT); // Initialise in/output ports | ||
pinMode(PIN_RF_RX_DATA, INPUT); // Initialise in/output ports | ||
pinMode(PIN_RF_RX_NMOS, OUTPUT); // MOSFET, always output | ||
pinMode(PIN_RF_RX_PMOS, OUTPUT); // MOSFET, always output | ||
digitalWrite(PIN_RF_RX_NMOS, HIGH); // turn GND to RF receiver ON | ||
digitalWrite(PIN_RF_RX_PMOS, LOW); // turn VCC to RF receiver ON | ||
pinMode(PIN_RF_RX_GND, OUTPUT); // Initialise in/output ports | ||
pinMode(PIN_RF_RX_VCC, OUTPUT); // Initialise in/output ports | ||
digitalWrite(PIN_RF_RX_GND, LOW); // turn GND to RF receiver ON | ||
digitalWrite(PIN_RF_RX_VCC, HIGH); // turn VCC to RF receiver ON | ||
if (PULLUP_RF_RX_DATA) | ||
pinMode(PIN_RF_RX_DATA, INPUT_PULLUP); // Initialise in/output ports | ||
delayMicroseconds(TRANSMITTER_STABLE_DELAY_US); | ||
} | ||
|
||
void disableRX() | ||
{ | ||
// RX pins | ||
pinMode(PIN_RF_RX_DATA, INPUT); | ||
pinMode(PIN_RF_RX_NA, INPUT); | ||
pinMode(PIN_RF_RX_PMOS, OUTPUT); // MOSFET, always output | ||
pinMode(PIN_RF_RX_NMOS, OUTPUT); // MOSFET, always output | ||
digitalWrite(PIN_RF_RX_PMOS, HIGH); // turn VCC to RF receiver OFF | ||
digitalWrite(PIN_RF_RX_NMOS, LOW); // turn GND to RF receiver OFF | ||
pinMode(PIN_RF_RX_VCC, INPUT); | ||
pinMode(PIN_RF_RX_GND, INPUT); | ||
} | ||
|
||
void enableTX() | ||
{ | ||
// TX Pins | ||
pinMode(PIN_RF_TX_DATA, OUTPUT); // Initialise in/output ports | ||
digitalWrite(PIN_RF_TX_DATA, LOW); // No signal yet | ||
pinMode(PIN_RF_TX_NMOS, OUTPUT); // MOSFET, always output | ||
pinMode(PIN_RF_TX_PMOS, OUTPUT); // MOSFET, always output | ||
digitalWrite(PIN_RF_TX_NMOS, HIGH); // turn GND to TX receiver ON | ||
digitalWrite(PIN_RF_TX_PMOS, LOW); // turn VCC to TX receiver ON | ||
pinMode(PIN_RF_TX_GND, OUTPUT); // Initialise in/output ports | ||
pinMode(PIN_RF_TX_VCC, OUTPUT); // Initialise in/output ports | ||
digitalWrite(PIN_RF_TX_GND, LOW); // turn GND to TX receiver ON | ||
digitalWrite(PIN_RF_TX_VCC, HIGH); // turn VCC to TX receiver ON | ||
delayMicroseconds(TRANSMITTER_STABLE_DELAY_US); | ||
} | ||
|
||
void disableTX() | ||
{ | ||
// TX Pins | ||
delayMicroseconds(TRANSMITTER_STABLE_DELAY_US); | ||
digitalWrite(PIN_RF_TX_DATA, LOW); // No more signal | ||
pinMode(PIN_RF_TX_DATA, INPUT); // | ||
pinMode(PIN_RF_TX_NMOS, OUTPUT); // MOSFET, always output | ||
pinMode(PIN_RF_TX_PMOS, OUTPUT); // MOSFET, always output | ||
digitalWrite(PIN_RF_TX_PMOS, HIGH); // turn VCC to TX receiver OFF | ||
digitalWrite(PIN_RF_TX_NMOS, LOW); // turn GND to TX receiver OFF | ||
pinMode(PIN_RF_TX_VCC, INPUT); | ||
pinMode(PIN_RF_TX_GND, INPUT); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// ************************************* // | ||
// * Arduino Project RFLink-esp * // | ||
// * https://github.com/couin3/RFLink * // | ||
// * 2018..2020 Stormteam - Marc RIVES * // | ||
// * More details in RFLink.ino file * // | ||
// ************************************* // | ||
|
||
#ifndef Radio_h | ||
#define Radio_h | ||
|
||
#include <Arduino.h> | ||
|
||
#define TRANSMITTER_STABLE_DELAY_US 500 // 500 // Delay to let the transmitter become stable (Note: Aurel RTX MID needs 500µS/0,5ms). | ||
#define PULLUP_RF_RX_DATA_0 false // false // Sometimes a pullup in needed on RX data pin | ||
|
||
// PIN Definition | ||
// | ||
extern uint8_t PIN_RF_RX_PMOS; | ||
extern uint8_t PIN_RF_RX_NMOS; | ||
extern uint8_t PIN_RF_RX_VCC; | ||
extern uint8_t PIN_RF_RX_GND; | ||
extern uint8_t PIN_RF_RX_NA; | ||
extern uint8_t PIN_RF_RX_DATA; | ||
extern uint8_t PIN_RF_TX_PMOS; | ||
extern uint8_t PIN_RF_TX_NMOS; | ||
extern uint8_t PIN_RF_TX_VCC; | ||
extern uint8_t PIN_RF_TX_GND; | ||
extern uint8_t PIN_RF_TX_DATA; | ||
extern boolean PULLUP_RF_RX_DATA; | ||
|
||
#ifdef ESP8266 | ||
// ESP8266 D1 Mini | ||
#define PIN_RF_RX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_RX_NMOS_0 D5 // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_RX_VCC_0 NOT_A_PIN // Power to the receiver on this pin | ||
#define PIN_RF_RX_GND_0 NOT_A_PIN // Ground to the receiver on this pin | ||
#define PIN_RF_RX_NA_0 NOT_A_PIN // Alt. RX_DATA. Forced as input | ||
#define PIN_RF_RX_DATA_0 D6 // On this input, the 433Mhz-RF signal is received. LOW when no signal. | ||
#define PIN_RF_TX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_TX_NMOS_0 D7 // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_TX_VCC_0 NOT_A_PIN // +5 volt / Vcc power to the transmitter on this pin | ||
#define PIN_RF_TX_GND_0 NOT_A_PIN // Ground power to the transmitter on this pin | ||
#define PIN_RF_TX_DATA_0 D4 // Data to the 433Mhz transmitter on this pin | ||
#endif | ||
|
||
#ifdef ESP32 | ||
#define PIN_RF_RX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_RX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_RX_VCC_0 NOT_A_PIN // Power to the receiver on this pin | ||
#define PIN_RF_RX_GND_0 NOT_A_PIN // Ground to the receiver on this pin | ||
#define PIN_RF_RX_NA_0 NOT_A_PIN // Alt. RX_DATA. Forced as input | ||
#define PIN_RF_RX_DATA_0 NOT_A_PIN // On this input, the 433Mhz-RF signal is received. LOW when no signal. | ||
#define PIN_RF_TX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_TX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_TX_VCC_0 NOT_A_PIN // +5 volt / Vcc power to the transmitter on this pin | ||
#define PIN_RF_TX_GND_0 NOT_A_PIN // Ground power to the transmitter on this pin | ||
#define PIN_RF_TX_DATA_0 NOT_A_PIN // Data to the 433Mhz transmitter on this pin | ||
#endif | ||
|
||
#ifdef __AVR_ATmega328P__ | ||
#define PIN_RF_RX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_RX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_RX_VCC_0 NOT_A_PIN // Power to the receiver on this pin | ||
#define PIN_RF_RX_GND_0 NOT_A_PIN // Ground to the receiver on this pin | ||
#define PIN_RF_RX_NA_0 NOT_A_PIN // Alt. RX_DATA. Forced as input | ||
#define PIN_RF_RX_DATA_0 2 // On this input, the 433Mhz-RF signal is received. LOW when no signal. | ||
#define PIN_RF_TX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_TX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_TX_VCC_0 NOT_A_PIN // +5 volt / Vcc power to the transmitter on this pin | ||
#define PIN_RF_TX_GND_0 NOT_A_PIN // Ground power to the transmitter on this pin | ||
#define PIN_RF_TX_DATA_0 NOT_A_PIN // Data to the 433Mhz transmitter on this pin | ||
#endif | ||
|
||
#ifdef __AVR_ATmega2560__ | ||
#define PIN_RF_RX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_RX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_RX_VCC_0 16 // Power to the receiver on this pin | ||
#define PIN_RF_RX_GND_0 NOT_A_PIN // Ground to the receiver on this pin | ||
#define PIN_RF_RX_NA_0 NOT_A_PIN // Alt. RX_DATA. Forced as input | ||
#define PIN_RF_RX_DATA_0 19 // On this input, the 433Mhz-RF signal is received. LOW when no signal. | ||
#define PIN_RF_TX_PMOS_0 NOT_A_PIN // High Side P-MOSFET, active on LOW level | ||
#define PIN_RF_TX_NMOS_0 NOT_A_PIN // Low Side N-MOSFET, active on HIGH level | ||
#define PIN_RF_TX_VCC_0 15 // +5 volt / Vcc power to the transmitter on this pin | ||
#define PIN_RF_TX_GND_0 NOT_A_PIN // Ground power to the transmitter on this pin | ||
#define PIN_RF_TX_DATA_0 14 // Data to the 433Mhz transmitter on this pin | ||
#endif | ||
|
||
enum Radio_State | ||
{ | ||
Radio_OFF, | ||
Radio_RX, | ||
Radio_TX, | ||
Radio_NA | ||
}; | ||
|
||
void set_Radio_mode(Radio_State new_state); | ||
|
||
#endif // Radio_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.