-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsomfyconfig.h
114 lines (91 loc) · 3.49 KB
/
somfyconfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* this file is part of Somfy RTS communication protocol
*
* Copyright (c) 2017, yogui
*
* code inspired from culfw http://culfw.de/culfw.html
* and from this arduino forum thread : https://forum.arduino.cc/index.php?topic=208346.0
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _SomfyConfig_H
#define _SomfyConfig_H
//#define DEBUG_SOMFY_RECIVE // Enable this line for debug
//#define DEBUG_PULSE // Enable this line to see pulse
//#define DEBUG_CC1101 // Enable this line for debug CC1101
#if ARDUINO >= 100
#include <Arduino.h> // Arduino 1.0
#else
#include <WProgram.h> // Arduino 0022
#endif
#define SOMFY_RTS_FRAME_SIZE 7
#if defined (__arc__)
Serial.print("arc mode");
#define CC1101_CS_PIN 2 // Pin 2 for chip select
#define CC1101_TX_PIN 3 // Pin 3 for TX
#define CC1101_RX_PIN 7 // Pin 7 for RX
#define led_init() pinMode(8, OUTPUT);
#define LED_ON() digitalWrite(8, HIGH);
#define LED_OFF() digitalWrite(8, LOW);
#else // defined (__arc__)
//configuration output
#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__)
/*TX */
#define _TX_DDR DDRD
#define _TX_PORT PORTD
#define _TX_PIN PD3 // Pin 3
/*RX */
#define _RX_PORT PORTC
//#define _RX_PIN PC1 // Pin A1
#define _RX_PIN 5 // Pin D2 RBE
/*SPI*/
#define SPI_PORT PORTD
#define SPI_DDR DDRD
#define SPI_SS PD2 //Pin 2
#else
/*TX */
#define _TX_DDR DDRE
#define _TX_PORT PORTE
#define _TX_PIN PE5 // Pin 3
/*RX */
#define _RX_PORT PORTD
#define _RX_DDR DDRD
#define _RX_PIN PD3 // Pin 18
/*SPI*/
#define SPI_PORT PORTB
#define SPI_DDR DDRB
#define SPI_SS PB0 //Pin 53
#endif
#ifdef __AVR_ATmega168__ || __AVR_ATmega328P__
SCK_PIN = 13; MISO_PIN = 12; MOSI_PIN = 11; SS_PIN = 10;
#elif __AVR_ATmega1280__ || __AVR_ATmega2560__
SCK_PIN = 52; MISO_PIN = 50; MOSI_PIN = 51; SS_PIN = 53;
#elif ESP8266
SCK_PIN = 14; MISO_PIN = 12; MOSI_PIN = 13; SS_PIN = 15; SPI_SS = 15;
#elif ESP32
SCK_PIN = 18; MISO_PIN = 19; MOSI_PIN = 23; SS_PIN = 5;
#endif
/* external LED */
#define _LED_DDR DDRB
#define _LED_PORT PORTB
#define _LED_PIN PB0 //Pin 8 atmega328 / Pin 53 atmega1280 and atmega2560
#define led_init() _LED_DDR |= _BV(_LED_PIN)
#define LED_ON() _LED_PORT |= _BV(_LED_PIN)
#define LED_OFF() _LED_PORT &= ~_BV(_LED_PIN)
/*SPI*/
#define CC1101_CS_DDR SPI_DDR
#define CC1101_CS_PORT SPI_PORT
#define CC1101_CS_PIN SPI_SS
#endif // defined (__arc__)
#endif