├── .github
└── workflows
│ ├── stale.yml
│ └── sync_issues.yml
├── .gitlab-ci.yml
├── .travis.yml
├── License.txt
├── README.md
├── examples
├── Config
│ └── Config.ino
├── RFBee
│ └── RFBee.ino
├── TestIO
│ └── TestIO.ino
├── rfBeeCore
│ └── rfBeeCore.ino
└── rfBeeSerial
│ └── rfBeeSerial.ino
├── library.properties
├── license
├── gpl-2.0.txt
└── lgpl-2.1.txt
└── src
├── CCx.cpp
├── CCx.h
├── CCxCfg.h
├── Config.h
├── Spi.cpp
├── Spi.h
├── TestIO.h
├── debug.h
├── globals.h
├── rfBeeCore.h
└── rfBeeSerial.h
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | name: 'Close stale issues and PRs'
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: '0 4 * * *'
7 |
8 | jobs:
9 | stale:
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - name: Checkout repository
14 | uses: actions/checkout@v4
15 |
16 | - name: Checkout script repository
17 | uses: actions/checkout@v4
18 | with:
19 | repository: Seeed-Studio/sync-github-all-issues
20 | path: ci
21 |
22 | - name: Run script
23 | run: ./ci/tools/stale.sh
24 | env:
25 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 |
--------------------------------------------------------------------------------
/.github/workflows/sync_issues.yml:
--------------------------------------------------------------------------------
1 | name: Automate Issue Management
2 |
3 | on:
4 | issues:
5 | types:
6 | - opened
7 | - edited
8 | - assigned
9 | - unassigned
10 | - labeled
11 | - unlabeled
12 | - reopened
13 |
14 | jobs:
15 | add_issue_to_project:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - name: Add issue to GitHub Project
19 | uses: actions/add-to-project@v1.0.2
20 | with:
21 | project-url: https://github.com/orgs/Seeed-Studio/projects/17
22 | github-token: ${{ secrets.ISSUE_ASSEMBLE }}
23 | labeled: bug
24 | label-operator: NOT
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | build:
2 | tags:
3 | - nas
4 | script:
5 | - wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh
6 | - chmod +x seeed-arduino-ci.sh
7 | - bash $PWD/seeed-arduino-ci.sh test
8 |
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | language: generic
3 | dist: bionic
4 | sudo: false
5 | cache:
6 | directories:
7 | - ~/arduino_ide
8 | - ~/.arduino15/packages/
9 |
10 | before_install:
11 | - wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh
12 |
13 | script:
14 | - chmod +x seeed-arduino-ci.sh
15 | - cat $PWD/seeed-arduino-ci.sh
16 | - bash $PWD/seeed-arduino-ci.sh test
17 |
18 | notifications:
19 | email:
20 | on_success: change
21 | on_failure: change
22 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | refer to “license” directory.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | RFBeeV1.1 [](https://travis-ci.com/Seeed-Studio/RFBee)
2 | ---------------------------------------------------------
3 |
4 | This software is for seeedstudio's RFBeeV1.1.
5 | The RFBee is a RF module providing easy and flexible wireless data transmission between devices.
6 | It is based on a AVR Atmega168 working as a fully functional Arduino connected via SPI to a TI CC1101 RF transceiver.
7 |
8 | 
9 |
10 | [RFbee V1.1 - Wireless arduino compatible node](https://www.seeedstudio.com/rfbee-v11-wireless-arduino-compatible-node-p-614.html)
11 |
12 | ### Usage:
13 | This firmware is a arduino sketch. It can be build under Arduino IDE ver 1.0.5.
14 | Just build it and then upload it to rfbeev1.1 board with a UartSBee or a XbeeShield.
15 |
16 | For more information, please refer to [wiki page](http://wiki.seeedstudio.com/RFbee_V1.1-Wireless_Arduino_compatible_node/).
17 |
18 |
19 | ----
20 |
21 | This software is written by community contributors and modified by seeed studio.
22 | It is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php) by getting grant from the author. Check License.txt for more information.
23 |
24 | Contributing to this software is warmly welcomed. You can do this basically by
25 | [forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above
26 | for operating guide). Adding change log and your contact into file header is encouraged.
27 | Thanks for your contribution.
28 |
29 | Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
30 | Benefiting from local manufacture power and convenient global logistic system,
31 | we integrate resources to serve new era of innovation. Seeed also works with
32 | global distributors and partners to push open hardware movement.
33 |
34 |
35 |
36 | [](https://github.com/igrigorik/ga-beacon)
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/Config/Config.ino:
--------------------------------------------------------------------------------
1 | // Config.pde Simple config library for rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: August 27, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 |
23 | #include "Config.h"
24 | #include "globals.h"
25 | #include
26 |
27 | //---------- constructor ----------------------------------------------------
28 |
29 | CONFIG::CONFIG() {}
30 |
31 |
32 | //------------------ reset ---------------------------------------------------
33 |
34 | void CONFIG::reset() {
35 | EEPROM.write(CONFIG_RFBEE_MARKER, CONFIG_RFBEE_MARKER_VALUE);
36 | EEPROM.write(CONFIG_FW_VERSION, FIRMWAREVERSION);
37 | EEPROM.write(CONFIG_DEST_ADDR, 0);
38 | EEPROM.write(CONFIG_MY_ADDR, 0);
39 | EEPROM.write(CONFIG_ADDR_CHECK, 0x00);
40 | EEPROM.write(CONFIG_TX_THRESHOLD, 0x01);
41 | EEPROM.write(CONFIG_BDINDEX, 0x00);
42 | EEPROM.write(CONFIG_PAINDEX, 0x07);
43 | EEPROM.write(CONFIG_CONFIG_ID, 0x00);
44 | if (EEPROM.read(CONFIG_HW_VERSION) < 11) {
45 | EEPROM.write(CONFIG_HW_VERSION,
46 | 11); // dirty hack to ensure rfBee's without a hardware version get their hardware version set to 1.0
47 | }
48 | EEPROM.write(CONFIG_OUTPUT_FORMAT, 0x00);
49 | EEPROM.write(CONFIG_RFBEE_MODE, 0x00);
50 | }
51 |
52 | //------------------ get -----------------------------------------------
53 |
54 | byte CONFIG::get(byte idx) {
55 | return _cfg[idx];
56 | }
57 | byte CONFIG::get_eep(byte idx) {
58 | return (EEPROM.read(idx));
59 | }
60 |
61 |
62 | //------------------ get Select ---------------------------------------------
63 | void CONFIG::set(byte idx, byte value) {
64 | _cfg[idx] = value;
65 | EEPROM.write(idx, value);
66 | }
67 |
68 | int CONFIG::initialized() {
69 | if ((EEPROM.read(CONFIG_RFBEE_MARKER) == CONFIG_RFBEE_MARKER_VALUE) &&
70 | (EEPROM.read(CONFIG_FW_VERSION) == FIRMWAREVERSION)) {
71 | return OK;
72 | }
73 | return ERR;
74 | }
75 |
76 | void CONFIG::load_default() {
77 | for (int i = 0; i <= CONFIG_RFBEE_MODE; i++) {
78 | _cfg[i] = EEPROM.read(i);
79 | }
80 | }
81 | //---------- preinstantiate Config object --------------------------------------
82 |
83 | CONFIG Config = CONFIG();
84 |
--------------------------------------------------------------------------------
/examples/RFBee/RFBee.ino:
--------------------------------------------------------------------------------
1 | // Firmware for rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: July 14, 2010
7 | //
8 | // This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
9 | // as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
10 | //
11 | // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | // See the GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License along with this program;
16 | // if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 |
19 |
20 | #define FIRMWAREVERSION 11 // 1.1 , version number needs to fit in byte (0~255) to be able to store it into config
21 | //#define FACTORY_SELFTEST
22 | //#define DEBUG
23 |
24 |
25 | #include "debug.h"
26 | #include "globals.h"
27 | #include "Config.h"
28 | #include "CCx.h"
29 | #include "rfBeeSerial.h"
30 |
31 | #ifdef FACTORY_SELFTEST
32 | #include "TestIO.h" // factory selftest
33 | #endif
34 |
35 | #define GDO0 2 // used for polling the RF received data
36 |
37 |
38 | void setup() {
39 | if (Config.initialized() != OK) {
40 | Serial.begin(9600);
41 | Serial.println("Initializing config");
42 | #ifdef FACTORY_SELFTEST
43 | if (TestIO() != OK) {
44 | return;
45 | }
46 | #endif
47 | Config.reset();
48 | }
49 | Config.load_default();
50 | setUartBaudRate();
51 | rfBeeInit();
52 | Serial.println("ok");
53 | }
54 |
55 | void loop() {
56 |
57 | byte mode = Config.get(CONFIG_RFBEE_MODE);
58 |
59 | if (Serial.available() > 0) {
60 | sleepCounter = 1000; // reset the sleep counter
61 | if (serialMode == SERIALCMDMODE) {
62 | readSerialCmd();
63 | return;
64 | } else {
65 | txDataFromSerialToRf();
66 | }
67 | }
68 |
69 | if (mode != TRANSMIT_MODE) {
70 | if (digitalRead(GDO0) == HIGH) {
71 | rxDataFromRfToSerial();
72 | sleepCounter++; // delay sleep
73 | } else if (millis() - CCx.lastCalibrate > 60000) { //re-calibrate cc when its idle after 1min
74 | CCx.Strobe(CCx_SIDLE);
75 | CCx.Strobe(CCx_SRX);
76 | CCx.lastCalibrate = millis();
77 | }
78 | }
79 |
80 | sleepCounter--;
81 |
82 | // check if we can go to sleep again, going into low power too early will result in lost data in the CCx fifo.
83 | if ((sleepCounter == 0) && (mode == LOWPOWER_MODE)) {
84 | DEBUGPRINT("low power on")
85 | lowPowerOn();
86 | DEBUGPRINT("woke up")
87 | }
88 | }
89 |
90 |
91 | void rfBeeInit() {
92 | DEBUGPRINT()
93 |
94 | CCx.PowerOnStartUp();
95 | setCCxConfig();
96 |
97 | serialMode = SERIALDATAMODE;
98 | sleepCounter = 0;
99 |
100 | attachInterrupt(0, ISRVreceiveData, RISING); //GD00 is located on pin 2, which results in INT 0
101 |
102 | pinMode(GDO0, INPUT); // used for polling the RF received data
103 |
104 | }
105 |
106 | // handle interrupt
107 | void ISRVreceiveData() {
108 | //DEBUGPRINT()
109 | sleepCounter = 10;
110 | }
111 |
112 |
113 |
--------------------------------------------------------------------------------
/examples/TestIO/TestIO.ino:
--------------------------------------------------------------------------------
1 | // rfBee selftest
2 | // optimized for least RAM usage
3 | #include "TestIO.h"
4 |
5 |
6 | #define numPins 5
7 |
8 | #define IO_PD_4 4
9 | #define IO_PC_4 18
10 |
11 | #define IO_PB_1 9
12 | #define IO_PC_5 19
13 |
14 | #define IO_PB_0 8
15 | #define IO_PD_6 6
16 |
17 | #define IO_PD_7 7
18 | #define IO_PD_5 5
19 |
20 | #define IO_PC_0 14
21 | #define IO_PC_2 16
22 |
23 |
24 | #define IO_PC_1 15
25 | #define IO_ADC_7 7
26 | #define IO_PC_3 17
27 |
28 |
29 | int TestIoPins() {
30 | byte pin[numPins * 2] = {
31 | IO_PD_4,
32 | IO_PB_1,
33 | IO_PB_0,
34 | IO_PD_7,
35 | IO_PC_0,
36 |
37 | IO_PC_4,
38 | IO_PC_5,
39 | IO_PD_6,
40 | IO_PD_5,
41 | IO_PC_2,
42 | };
43 | byte i = 0;
44 |
45 | pinMode(IO_PC_1, OUTPUT); //used for lighting the led
46 | digitalWrite(IO_PC_1, LOW);
47 |
48 | pinMode(IO_PC_3, OUTPUT);
49 | digitalWrite(IO_PC_3, HIGH);
50 | if (analogRead(IO_ADC_7) < 500) {
51 | return ERR;
52 | }
53 |
54 | for (i = 0; i < numPins; i++) {
55 | pinMode(pin[i], INPUT);
56 | pinMode(pin[i + numPins], OUTPUT);
57 | digitalWrite(pin[i + numPins], HIGH);
58 | }
59 | for (i = 0; i < numPins; i++) {
60 | if (digitalRead(pin[i]) != HIGH) {
61 | return ERR;
62 | }
63 | }
64 |
65 | //if all io is ok, light the led
66 | digitalWrite(IO_PC_1, HIGH);
67 |
68 | return OK;
69 | }
70 |
71 | int TestIO() {
72 | int result = TestIoPins();
73 | if (result == OK) {
74 | Config.set(CONFIG_HW_VERSION, HARDWAREVERSION); // write the hardware version to eeprom
75 | Serial.println("IO ok");
76 | } else {
77 | Serial.println("IO error");
78 | }
79 | return result;
80 | }
81 |
--------------------------------------------------------------------------------
/examples/rfBeeCore/rfBeeCore.ino:
--------------------------------------------------------------------------------
1 | // rfBeeCore.cpp core routines for the rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: July 14, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 | #include "rfBeeCore.h"
23 |
24 | // send data via RF
25 | void transmitData(byte* txData, byte len, byte srcAddress, byte destAddress) {
26 | DEBUGPRINT()
27 | byte stat;
28 | unsigned long t;
29 |
30 | //Serial.println(len,DEC);
31 | CCx.Strobe(CCx_SIDLE);
32 | CCx.Strobe(CCx_SFTX);
33 | CCx.Write(CCx_TXFIFO, len + 2);
34 | CCx.Write(CCx_TXFIFO, destAddress);
35 | CCx.Write(CCx_TXFIFO, srcAddress);
36 | CCx.WriteBurst(CCx_TXFIFO, txData, len); // write len bytes of the serialData buffer into the CCx txfifo
37 | CCx.Strobe(CCx_STX);
38 |
39 | t = millis();
40 |
41 | while (1) {
42 | byte size;
43 | stat = CCx.Read(CCx_TXBYTES, &size);
44 |
45 | if (0 == (size & 0x7f)) {
46 | break;
47 | } else if (millis() - t > 100) {
48 | CCx.Strobe(CCx_SFTX);
49 | DEBUGPRINT("timeout")
50 | break;
51 | }
52 | }
53 |
54 | #ifdef DEBUG
55 | txData[len] = '\0';
56 | Serial.println((char*)txData);
57 | Serial.println("----");
58 | #endif
59 |
60 | }
61 |
62 | // read available txFifo size and handle underflow (which should not have occured anyway)
63 | byte txFifoFree() {
64 | DEBUGPRINT()
65 | byte stat;
66 | byte size;
67 |
68 | stat = CCx.Read(CCx_TXBYTES, &size);
69 | // handle a potential TX underflow by flushing the TX FIFO as described in section 10.1 of the CC 1100 datasheet
70 | if (size >= 64) { //state got here seems not right, so using size to make sure it no more than 64
71 | CCx.Strobe(CCx_SFTX);
72 | stat = CCx.Read(CCx_TXBYTES, &size);
73 | #ifdef DEBUG
74 | Serial.println(stat, HEX);
75 | #endif
76 | }
77 | #ifdef DEBUG
78 | //Serial.println(stat,HEX);
79 | Serial.println(CCx_FIFO_SIZE - size, DEC);
80 | #endif
81 | return (CCx_FIFO_SIZE - size);
82 | }
83 |
84 | // receive data via RF, rxData must be at least CCx_PACKT_LEN bytes long
85 | int receiveData(byte* rxData, byte* len, byte* srcAddress, byte* destAddress, byte* rssi, byte* lqi) {
86 | DEBUGPRINT()
87 |
88 | byte stat;
89 |
90 | stat = CCx.Read(CCx_RXFIFO, len);
91 | #ifdef DEBUG
92 | Serial.print("length:");
93 | Serial.println(*len, DEC);
94 | #endif
95 | CCx.Read(CCx_RXFIFO, destAddress);
96 | CCx.Read(CCx_RXFIFO, srcAddress);
97 | *len -= 2; // discard address bytes from payloadLen
98 | CCx.ReadBurst(CCx_RXFIFO, rxData, *len);
99 | CCx.Read(CCx_RXFIFO, rssi);
100 | *rssi = CCx.RSSIdecode(*rssi);
101 | stat = CCx.Read(CCx_RXFIFO, lqi);
102 | // check checksum ok
103 | if ((*lqi & 0x80) == 0) {
104 | return NOTHING;
105 | }
106 | *lqi = *lqi & 0x7F; // strip off the CRC bit
107 |
108 | // handle potential RX overflows by flushing the RF FIFO as described in section 10.1 of the CC 1100 datasheet
109 | if ((stat & 0xF0) == 0x60) { //Modified by Icing. When overflows, STATE[2:0] = 110
110 | errNo = 3; //Error RX overflow
111 | CCx.Strobe(CCx_SFRX); // flush the RX buffer
112 | CCx.Strobe(CCx_SIDLE);
113 | CCx.Strobe(CCx_SRX);
114 | return ERR;
115 | }
116 | return OK;
117 | }
118 |
119 | // power saving
120 | void sleepNow(byte mode) {
121 | /* Now is the time to set the sleep mode. In the Atmega8 datasheet
122 | http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35
123 | there is a list of sleep modes which explains which clocks and
124 | wake up sources are available in which sleep modus.
125 |
126 | In the avr/sleep.h file, the call names of these sleep modus are to be found:
127 |
128 | The 5 different modes are:
129 | SLEEP_MODE_IDLE -the least power savings
130 | SLEEP_MODE_ADC
131 | SLEEP_MODE_PWR_SAVE
132 | SLEEP_MODE_STANDBY
133 | SLEEP_MODE_PWR_DOWN -the most power savings
134 |
135 | the power reduction management is described in
136 | http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html
137 | */
138 | DEBUGPRINT()
139 |
140 | set_sleep_mode(mode); // sleep mode is set here
141 |
142 | sleep_enable(); // enables the sleep bit in the mcucr register
143 | // so sleep is possible. just a safety pin
144 |
145 | power_adc_disable();
146 | power_spi_disable();
147 | power_timer0_disable();
148 | power_timer1_disable();
149 | power_timer2_disable();
150 | power_twi_disable();
151 |
152 |
153 | sleep_mode(); // here the device is actually put to sleep!!
154 |
155 | // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
156 | sleep_disable(); // first thing after waking from sleep:
157 | // disable sleep...
158 |
159 | power_all_enable();
160 |
161 | }
162 |
163 | void lowPowerOn() {
164 | DEBUGPRINT()
165 | CCx.Write(CCx_WORCTRL, 0x78); // set WORCRTL.RC_PD to 0 to enable the wakeup oscillator
166 | CCx.Strobe(CCx_SWOR);
167 | sleepNow(SLEEP_MODE_IDLE);
168 | //CCx.Strobe(CCx_SIDLE);
169 | }
170 |
171 |
172 |
173 |
174 |
175 |
--------------------------------------------------------------------------------
/examples/rfBeeSerial/rfBeeSerial.ino:
--------------------------------------------------------------------------------
1 | // rfBeeSerial.pde serial interface to rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: August 18, 2010
7 | // ChangeLog: Jack Shao, seeedstudio, 2013/8
8 | //
9 | // This library is free software; you can redistribute it and/or
10 | // modify it under the terms of the GNU Lesser General Public
11 | // License as published by the Free Software Foundation; either
12 | // version 2.1 of the License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful,
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 |
23 |
24 |
25 | #include "rfBeeSerial.h"
26 |
27 | //
28 | byte getNumParamData(int* result, int size) {
29 | DEBUGPRINT()
30 | // try to read a number
31 | byte c;
32 | int value = 0;
33 | boolean valid = false;
34 | int pos = 4; // we start to read at pos 5 as 0-1 = AT and 2-3 = CMD
35 |
36 | if (serialData[pos] == SERIALCMDTERMINATOR) { // no data was available
37 | return NOTHING;
38 | }
39 |
40 | while (size-- > 0) {
41 | c = serialData[pos++];
42 | if (c == SERIALCMDTERMINATOR) { // no more data available
43 | break;
44 | }
45 | if ((c < '0') || (c > '9')) { // illegal char
46 | return ERR;
47 | }
48 | // got a digit
49 | valid = true;
50 | value = (value * 10) + (c - '0');
51 | }
52 | if (valid) {
53 | *result = value;
54 | return OK;
55 | }
56 | return ERR;
57 | }
58 |
59 | // simple standardized setup for commands that only modify config
60 | int modifyConfig(byte configLabel, byte paramSize, byte paramMaxValue) {
61 | DEBUGPRINT()
62 | int param;
63 |
64 | byte result = getNumParamData(¶m, paramSize);
65 | if (result == OK) {
66 | if (param <= paramMaxValue) {
67 | Config.set(configLabel, param);
68 | return MODIFIED;
69 | }
70 | }
71 | if (result == NOTHING) {
72 | // return current setting
73 | Serial.println(Config.get(configLabel), DEC);
74 | return (OK);
75 | }
76 | return ERR;
77 | }
78 |
79 | int processSerialCmd(byte size) {
80 | DEBUGPRINT()
81 | int result = MODIFIED;
82 |
83 | byte configItem; // the ID used in the EEPROM
84 | byte paramDigits; // how many digits for the parameter
85 | byte maxValue; // maximum value of the parameter
86 | byte postProcess; // do we need to call the function to perform extra actions on change
87 | AT_Command_Function_t function; // the function which does the real work on change
88 |
89 | // read the AT
90 | if (strncasecmp("AT", (char*)serialData, 2) == 0) {
91 | // read the command
92 | for (int i = 0; i <= sizeof(atCommands) / sizeof(AT_Command_t); i++) {
93 | // do we have a known command
94 | if (strncasecmp_P((char*)serialData + 2, (PGM_P)pgm_read_word(&(atCommands[i].name)), 2) == 0) {
95 | // get the data from PROGMEM
96 | configItem = pgm_read_byte(&(atCommands[i].configItem));
97 | paramDigits = pgm_read_byte(&(atCommands[i].paramDigits));
98 | maxValue = pgm_read_byte(&(atCommands[i].maxValue));
99 | postProcess = pgm_read_byte(&(atCommands[i].postProcess));
100 | function = (AT_Command_Function_t)pgm_read_word(&(atCommands[i].function));
101 | if (paramDigits > 0) {
102 | result = modifyConfig(configItem, paramDigits, maxValue);
103 | }
104 | if (result == MODIFIED) {
105 | result = OK; // config only commands always return OK
106 | if (postProcess == true) {
107 | result = function(); // call the command function
108 | }
109 | }
110 | return (result); // return the result of the execution of the function linked to the command
111 | }
112 | }
113 | }
114 | return ERR;
115 | }
116 |
117 | void readSerialCmd() {
118 | DEBUGPRINT()
119 | int result;
120 | char data;
121 | static byte pos = 0;
122 |
123 | while (Serial.available()
124 | && (serialMode == SERIALCMDMODE)) { //ATSL changes commandmode while there is a char waiting in the serial buffer.
125 | result = NOTHING;
126 | data = Serial.read();
127 | serialData[pos++] = data; //serialData is our global serial buffer
128 | if (data == SERIALCMDTERMINATOR) {
129 | if (pos > 3) { // we need 4 bytes
130 | result = processSerialCmd(pos);
131 | } else {
132 | result = ERR;
133 | }
134 | pos = 0;
135 | }
136 | // check if we don't overrun the buffer, if so empty it
137 | if (pos > BUFFLEN) {
138 | result = ERR;
139 | pos = 0;
140 | }
141 | if (result == OK) {
142 | Serial.println("ok");
143 | }
144 | if (result == ERR) {
145 | Serial.println("error");
146 | }
147 | }
148 | }
149 | void txDataFromSerialToRf() {
150 | DEBUGPRINT()
151 | static byte h = 0; //push char into head
152 | static byte t = 0; //pop char out of tail
153 | static byte plus_cnt = 0;
154 | byte ring_len = 0;
155 | byte free_len = 0;
156 | byte d;
157 |
158 | ring_len = (h >= t) ? (h - t) : (h + BUFFLEN - t);
159 | free_len = BUFFLEN - ring_len;
160 | DEBUGPRINT(ring_len)
161 |
162 | //fill in data
163 | while (free_len > 0 && Serial.available() > 0) {
164 | d = Serial.read();
165 | if (d == '+') {
166 | plus_cnt++;
167 | } else {
168 | plus_cnt = 0;
169 | //advance head
170 | /*
171 | if (h == t)
172 | {
173 | Serial.println("impsb");
174 | break;
175 | }
176 | */
177 | serialData[h] = d;
178 | h = (h + 1) % BUFFLEN;
179 | ring_len++;
180 | free_len--;
181 | }
182 |
183 | if (plus_cnt == 3) {
184 | plus_cnt = 0;
185 | serialMode = SERIALCMDMODE;
186 | Serial.println("ok, starting cmd mode");
187 | break; // jump out of the loop, but still send the remaining chars in the buffer
188 | }
189 | }
190 |
191 | DEBUGPRINT(ring_len)
192 |
193 | //tx out sth.
194 | if (ring_len > Config.get(CONFIG_TX_THRESHOLD)) {
195 | byte rfBeeMode = Config.get(CONFIG_RFBEE_MODE);
196 | if (rfBeeMode == TRANSMIT_MODE || rfBeeMode == TRANSCEIVE_MODE) {
197 | byte tx_len = txFifoFree();
198 | tx_len = (ring_len > tx_len) ? tx_len : ring_len;
199 | if (tx_len == 0) {
200 | return;
201 | }
202 |
203 | DEBUGPRINT(tx_len)
204 | byte buf[BUFFLEN + 1]; //wish the ram is ok...
205 | for (int i = 0; i < tx_len; i++) {
206 | /*
207 | if (t == h)
208 | {
209 | Serial.println("impsb2");
210 | break;
211 | }
212 | */
213 | *(buf + i) = serialData[t];
214 | t = (t + 1) % BUFFLEN;
215 | }
216 | transmitData(buf, tx_len, Config.get(CONFIG_MY_ADDR), Config.get(CONFIG_DEST_ADDR));
217 | }
218 | }
219 | //end
220 | }
221 | //sorry, but i dont think the implementation is a good one -shao,T_T
222 | /* {
223 | DEBUGPRINT()
224 | byte len;
225 | byte data;
226 | byte fifoSize=0;
227 | static byte plus=0;
228 | static byte pos=0;
229 | byte rfBeeMode;
230 |
231 | // insert any plusses from last round
232 | for(int i=pos; i< plus;i++) //be careful, i should start from pos, -changed by Icing
233 | serialData[i]='+';
234 |
235 | len=Serial.available()+plus+pos;
236 | if (len > BUFFLEN ) len=BUFFLEN; //only process at most BUFFLEN chars
237 | // check how much space we have in the TX fifo
238 | fifoSize=txFifoFree();
239 |
240 | if(fifoSize <= 0){
241 | Serial.flush();
242 | //CCx.Strobe(CCx_SFTX);
243 | plus = 0;
244 | pos = 0;
245 | return;
246 | }
247 | if (len > fifoSize) len=fifoSize; // don't overflow the TX fifo
248 |
249 | for(byte i=plus+pos; i< len;i++){
250 | data=Serial.read();
251 | serialData[i]=data; //serialData is our global serial buffer
252 | if (data == '+')
253 | plus++;
254 | else
255 | plus=0;
256 |
257 | if (plus == 3){
258 | len=i-2; // do not send the last 2 plusses
259 | plus=0;
260 | serialMode=SERIALCMDMODE;
261 | CCx.Strobe(CCx_SIDLE);
262 | Serial.println("ok, starting cmd mode");
263 | break; // jump out of the loop, but still send the remaining chars in the buffer
264 | }
265 | }
266 |
267 | if (plus > 0) // save any trailing plusses for the next round
268 | len-=plus;
269 |
270 | // check if we have more input than the transmitThreshold, if we have just switched to commandmode send the current buffer anyway.
271 | if ((serialMode!=SERIALCMDMODE) && (len < Config.get(CONFIG_TX_THRESHOLD))){
272 | pos=len; // keep the current bytes in the buffer and wait till next round.
273 | return;
274 | }
275 |
276 | if (len > 0){
277 | rfBeeMode=Config.get(CONFIG_RFBEE_MODE);
278 | //only when TRANSMIT_MODE or TRANSCEIVE,transmit the buffer data,otherwise ignore
279 | if( rfBeeMode == TRANSMIT_MODE || rfBeeMode == TRANSCEIVE_MODE )
280 | transmitData(serialData,len,Config.get(CONFIG_MY_ADDR),Config.get(CONFIG_DEST_ADDR));
281 | pos=0; // serial databuffer is free again.
282 | }
283 | }*/
284 |
285 | // write a text label from progmem, uses less bytes than individual Serial.println()
286 | //void writeSerialLabel(byte i){
287 | // char buffer[64];
288 | // strcpy_P(buffer, (char * )pgm_read_word(&(labels[i])));
289 | // Serial.println(buffer);
290 | //}
291 |
292 | //
293 | void writeSerialError() {
294 | DEBUGPRINT()
295 | char buffer[64];
296 | strcpy_P(buffer, (char*)pgm_read_word(&(error_codes[errNo])));
297 | Serial.print("error: ");
298 | Serial.println(buffer);
299 | }
300 |
301 |
302 |
303 | // read data from CCx and write it to Serial based on the selected output format
304 | void rxDataFromRfToSerial() {
305 | DEBUGPRINT()
306 | byte rxData[CCx_PACKT_LEN];
307 | byte len;
308 | byte srcAddress;
309 | byte destAddress;
310 | char rssi;
311 | byte lqi;
312 | int result;
313 | byte of;
314 |
315 |
316 | result = receiveData(rxData, &len, &srcAddress, &destAddress, (byte*)&rssi, &lqi);
317 | DEBUGPRINT(result)
318 |
319 | if (result == ERR) {
320 | writeSerialError();
321 | return;
322 | }
323 |
324 | if (result == NOTHING) {
325 | return;
326 | }
327 | // write to serial based on output format:
328 | // 0: payload only
329 | // 1: source, dest, payload
330 | // 2: payload len, source, dest, payload, rssi, lqi
331 | // 3: payload len, source, dest, payload,",", rssi (DEC),",",lqi (DEC)
332 | of = Config.get(CONFIG_OUTPUT_FORMAT);
333 | if (of == 3) {
334 | Serial.print(len, DEC); // len is size of data EXCLUDING address bytes !
335 | Serial.print(',');
336 | // write source & destination
337 | Serial.print(srcAddress, DEC);
338 | Serial.print(',');
339 | Serial.print(destAddress, DEC);
340 | Serial.print(',');
341 | // write data
342 | Serial.write(rxData, len);
343 | Serial.print(',');
344 | // write rssi en lqi
345 | Serial.print((int)rssi);
346 | Serial.print(',');
347 | Serial.println(lqi, DEC);
348 | } else {
349 | if (of > 1) {
350 | Serial.print(len); // len is size of data EXCLUDING address bytes !
351 | }
352 | if (of > 0) {
353 | // write source & destination
354 | Serial.print(srcAddress);
355 | Serial.print(destAddress);
356 | }
357 | // write data
358 | Serial.write(rxData, len);
359 | // write rssi en lqi
360 | if (of > 1) {
361 | Serial.print(rssi);
362 | Serial.print(lqi);
363 | }
364 | }
365 | }
366 |
367 |
368 | int setMyAddress() {
369 | DEBUGPRINT();
370 | CCx.Write(CCx_ADDR, Config.get(CONFIG_MY_ADDR));
371 | return OK;
372 | }
373 |
374 | int setAddressCheck() {
375 | DEBUGPRINT();
376 | CCx.Write(CCx_PKTCTRL1, Config.get(CONFIG_ADDR_CHECK) | 0x04);
377 | return OK;
378 | }
379 |
380 | int setPowerAmplifier() {
381 | DEBUGPRINT();
382 | CCx.setPA(Config.get(CONFIG_CONFIG_ID), Config.get(CONFIG_PAINDEX));
383 | return OK;
384 | }
385 |
386 | int changeUartBaudRate() {
387 | DEBUGPRINT()
388 | Serial.println("ok");
389 | Serial.flush();
390 | delay(1);
391 | setUartBaudRate();
392 | }
393 |
394 | int setUartBaudRate() {
395 | Serial.begin(pgm_read_dword(&baudRateTable[Config.get(CONFIG_BDINDEX)]));
396 | return NOTHING; // we already sent an ok.
397 | }
398 |
399 | int showFirmwareVersion() {
400 | DEBUGPRINT()
401 | Serial.println(((float)FIRMWAREVERSION) / 10, 1);
402 | return OK;
403 | }
404 |
405 | int showHardwareVersion() {
406 | DEBUGPRINT()
407 | Serial.println(((float)Config.get(CONFIG_HW_VERSION)) / 10, 1);
408 | return OK;
409 | }
410 |
411 | int resetConfig() {
412 | DEBUGPRINT()
413 | Config.reset();
414 | return OK;
415 | }
416 |
417 | int setCCxConfig() {
418 | DEBUGPRINT()
419 | // load the appropriate config table
420 | byte cfg = Config.get(CONFIG_CONFIG_ID);
421 | CCx.Setup(cfg);
422 | //CCx.ReadSetup();
423 | // and restore the config settings
424 | setMyAddress();
425 | setAddressCheck();
426 | setPowerAmplifier();
427 | setRFBeeMode();
428 | CCx.lastCalibrate = millis(); //add by shao
429 | return OK;
430 | }
431 |
432 |
433 | int setSerialDataMode() {
434 | DEBUGPRINT()
435 | serialMode = SERIALDATAMODE;
436 | return OK;
437 | }
438 |
439 | int setRFBeeMode() {
440 | DEBUGPRINT()
441 | // CCx_MCSM1 is configured to have TX and RX return to proper state on completion or timeout
442 | switch (Config.get(CONFIG_RFBEE_MODE)) {
443 | case TRANSMIT_MODE:
444 | CCx.Strobe(CCx_SIDLE);
445 | delay(1);
446 | CCx.Write(CCx_MCSM1, 0x00); //TXOFF_MODE->stay in IDLE
447 | CCx.Strobe(CCx_SFTX);
448 | break;
449 | case RECEIVE_MODE:
450 | CCx.Strobe(CCx_SIDLE);
451 | delay(1);
452 | CCx.Write(CCx_MCSM1, 0x0c); //RXOFF_MODE->stay in rx
453 | CCx.Strobe(CCx_SFRX);
454 | CCx.Strobe(CCx_SRX);
455 | break;
456 | case TRANSCEIVE_MODE:
457 | CCx.Strobe(CCx_SIDLE);
458 | delay(1);
459 | CCx.Write(CCx_MCSM1, 0x0f); //RXOFF_MODE and TXOFF_MODE goto RX
460 | CCx.Strobe(CCx_SFTX);
461 | CCx.Strobe(CCx_SFRX);
462 | CCx.Strobe(CCx_SRX);
463 | break;
464 | case LOWPOWER_MODE:
465 | CCx.Strobe(CCx_SIDLE);
466 | break;
467 | default:
468 | break;
469 | }
470 | return OK;
471 | }
472 |
473 | // put the rfbee into sleep
474 | int setSleepMode() {
475 | DEBUGPRINT("going to sleep")
476 | CCx.Strobe(CCx_SIDLE);
477 | CCx.Strobe(CCx_SPWD);
478 | sleepNow(SLEEP_MODE_IDLE);
479 | //sleepNow(SLEEP_MODE_PWR_DOWN);
480 | DEBUGPRINT("just woke up")
481 | setRFBeeMode();
482 | setSerialDataMode();
483 | return NOTHING;
484 | }
485 |
486 |
487 |
--------------------------------------------------------------------------------
/library.properties:
--------------------------------------------------------------------------------
1 | name=RFbee V1.1 - Wireless arduino compatible node
2 | version=1.0.0
3 | author=Seeed Studio
4 | maintainer=Seeed Studio
5 | sentence=Arduino library to control RFbee V1.1 - Wireless Arduino compatible node.
6 | paragraph=The RFBee is a RF module providing easy and flexible wireless data transmission between devices. It is based on a AVR ATmega168 working as a fully functional Arduino connected via SPI to a TI CC1101 RF transceiver..
7 | category=Communication
8 | url=https://github.com/Seeed-Studio/RFBee
9 | architectures=*
--------------------------------------------------------------------------------
/license/gpl-2.0.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/license/lgpl-2.1.txt:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489 |
490 | Also add information on how to contact you by electronic and paper mail.
491 |
492 | You should also get your employer (if you work as a programmer) or your
493 | school, if any, to sign a "copyright disclaimer" for the library, if
494 | necessary. Here is a sample; alter the names:
495 |
496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498 |
499 | , 1 April 1990
500 | Ty Coon, President of Vice
501 |
502 | That's all there is to it!
503 |
--------------------------------------------------------------------------------
/src/CCx.cpp:
--------------------------------------------------------------------------------
1 | // CCx.cpp Class to control the chipcon CCxxxx series transceivers
2 | // see http://focus.ti.com/lit/ds/symlink/cc1101.pdf for details on the CC1101
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: May 22, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 | #include "Arduino.h"
23 | #include "CCx.h"
24 | #include "CCxCfg.h"
25 | #include "Spi.h"
26 |
27 |
28 | //---------- constructor ----------------------------------------------------
29 |
30 | CCX::CCX(): lastCalibrate(0)
31 | {}
32 |
33 | // Power On Reset as described in 19.1.2 of cc1100 datasheet, tried APOR as described in 19.1.1 but that did not work :-(
34 | void CCX::PowerOnStartUp() {
35 | DEBUGPRINT()
36 | Spi.mode((1 << SPR1) | (1 << SPR0));//SPICLK=CPU/64
37 |
38 | // start manual Power On Reset
39 | Spi.slaveSelect(HIGH);
40 | delayMicroseconds(1);
41 |
42 | Spi.slaveSelect(LOW);
43 | delayMicroseconds(10);
44 |
45 | Spi.slaveSelect(HIGH);
46 | delayMicroseconds(41);
47 |
48 | Spi.slaveSelect(LOW);
49 |
50 | // wait for MISO to go low
51 | while (digitalRead(MISO_PIN));
52 |
53 | Spi.transfer(CCx_SRES);
54 |
55 | DEBUGPRINT("Waiting for CCx to complete POR")
56 |
57 | // wait for MISO to go low
58 | while (digitalRead(MISO_PIN));
59 |
60 | Spi.slaveSelect(HIGH);
61 |
62 | DEBUGPRINT("CCx POR complete")
63 | }
64 |
65 | byte CCX::Read(byte addr, byte* data) {
66 | DEBUGPRINT()
67 | byte result;
68 |
69 | Spi.slaveSelect(LOW);
70 | // wait for MISO to go low
71 | while (digitalRead(MISO_PIN));
72 |
73 | result = Spi.transfer(addr | 0x80);
74 | *data = Spi.transfer(0);
75 |
76 | Spi.slaveSelect(HIGH);
77 | return result;
78 | }
79 |
80 | byte CCX::ReadBurst(byte addr, byte* dataPtr, byte size) {
81 | DEBUGPRINT()
82 | byte result;
83 |
84 | Spi.slaveSelect(LOW);
85 | // wait for MISO to go low
86 | while (digitalRead(MISO_PIN));
87 |
88 | result = Spi.transfer(addr | 0xc0);
89 |
90 | while (size) {
91 | *dataPtr++ = Spi.transfer(0);
92 | size--;
93 | }
94 |
95 | Spi.slaveSelect(HIGH);
96 |
97 | return result;
98 | }
99 |
100 | byte CCX::Write(byte addr, byte dat) {
101 | DEBUGPRINT()
102 | byte result;
103 |
104 | Spi.slaveSelect(LOW);
105 | // wait for MISO to go low
106 | while (digitalRead(MISO_PIN));
107 |
108 | result = Spi.transfer(addr);
109 | result = Spi.transfer(dat);
110 |
111 | Spi.slaveSelect(HIGH);
112 |
113 | return result;
114 | }
115 |
116 | byte CCX::WriteBurst(byte addr, const byte* dataPtr, byte size) {
117 | DEBUGPRINT()
118 | byte result;
119 |
120 | Spi.slaveSelect(LOW);
121 | // wait for MISO to go low
122 | while (digitalRead(MISO_PIN));
123 |
124 | result = Spi.transfer(addr | 0x40);
125 |
126 | while (size) {
127 | result = Spi.transfer(*dataPtr++);
128 | size--;
129 | }
130 |
131 | Spi.slaveSelect(HIGH);
132 |
133 | return result;
134 | }
135 |
136 | byte CCX::Strobe(byte addr) {
137 | DEBUGPRINT()
138 | byte result;
139 |
140 | Spi.slaveSelect(LOW);
141 | // wait for MISO to go low
142 | while (digitalRead(MISO_PIN));
143 |
144 | result = Spi.transfer(addr);
145 |
146 | Spi.slaveSelect(HIGH);
147 |
148 | return result;
149 | }
150 |
151 | //configure registers of cc1100 making it work in specific mode
152 | void CCX::Setup(byte configId) {
153 | DEBUGPRINT()
154 | byte reg;
155 | byte val;
156 | if (configId < CCX_NR_OF_CONFIGS)
157 | for (byte i = 0; i < CCX_NR_OF_REGISTERS; i++) {
158 | reg = pgm_read_byte(&CCx_registers[i]);
159 | val = pgm_read_byte(&CCx_registerSettings[configId][i]); //read flash data no problem
160 | byte temp = Write(reg, val);
161 | //Serial.print(temp,HEX);
162 | //Serial.print(" ");
163 | }
164 | }
165 |
166 |
167 | // to aid debugging
168 | //#ifdef DEBUG
169 | void CCX::ReadSetup() {
170 | DEBUGPRINT()
171 | byte reg;
172 | byte value;
173 | for (byte i = 0; i < CCX_NR_OF_REGISTERS; i++) {
174 | reg = pgm_read_byte(&CCx_registers[i]);
175 | Read(reg, &value);
176 | Serial.print(reg, HEX);
177 | Serial.print(':');
178 | Serial.println(value, HEX);
179 | }
180 | }
181 | //#endif
182 |
183 | void CCX::setPA(byte configId, byte paIndex) {
184 | DEBUGPRINT()
185 | byte PAval = pgm_read_byte(&CCx_paTable[configId][paIndex]);
186 | CCx.Write(CCx_PATABLE, PAval);
187 | }
188 |
189 |
190 | void CCX::Mode(byte md) {
191 |
192 | }
193 |
194 | byte CCX::NrOfConfigs() {
195 | return CCX_NR_OF_CONFIGS;
196 | }
197 |
198 | byte CCX::RSSIdecode(byte rssiEnc) {
199 | byte rssi;
200 | byte rssiOffset = 74; // is actually dataRate dependant, but for simplicity assumed to be fixed.
201 |
202 | // RSSI is coded as 2's complement see section 17.3 RSSI of the cc1100 datasheet
203 | if (rssiEnc >= 128) {
204 | rssi = ((rssiEnc - 256) >> 1) - rssiOffset;
205 | } else {
206 | rssi = (rssiEnc >> 1) - rssiOffset;
207 | }
208 | return rssi;
209 | }
210 |
211 | //---------- preinstantiate CCx object --------------------------------------
212 |
213 | CCX CCx = CCX();
214 |
215 |
--------------------------------------------------------------------------------
/src/CCx.h:
--------------------------------------------------------------------------------
1 | // CCx.h Class to control the chipcon CCxxxx series transceivers
2 | // see http://focus.ti.com/lit/ds/symlink/cc1101.pdf for details on the CC1101
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: June 28, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 | #ifndef _CCX_H
23 | #define _CCX_H 1
24 | #include "Arduino.h"
25 | #include "debug.h"
26 |
27 |
28 | #define CCx_PA_TABLESIZE 8
29 |
30 |
31 | // CC2500/CC1100/CC1101 STROBE, CONTROL AND STATUS REGISTER
32 | #define CCx_IOCFG2 0x00 // GDO2 output pin configuration
33 | #define CCx_IOCFG1 0x01 // GDO1 output pin configuration
34 | #define CCx_IOCFG0D 0x02 // GDO0 output pin configuration
35 | #define CCx_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
36 | #define CCx_SYNC1 0x04 // Sync word, high byte
37 | #define CCx_SYNC0 0x05 // Sync word, low byte
38 | #define CCx_PKTLEN 0x06 // Packet length
39 | #define CCx_PKTCTRL1 0x07 // Packet automation control
40 | #define CCx_PKTCTRL0 0x08 // Packet automation control
41 | #define CCx_ADDR 0x09 // Device address
42 | #define CCx_CHANNR 0x0A // Channel number
43 | #define CCx_FSCTRL1 0x0B // Frequency synthesizer control
44 | #define CCx_FSCTRL0 0x0C // Frequency synthesizer control
45 | #define CCx_FREQ2 0x0D // Frequency control word, high byte
46 | #define CCx_FREQ1 0x0E // Frequency control word, middle byte
47 | #define CCx_FREQ0 0x0F // Frequency control word, low byte
48 | #define CCx_MDMCFG4 0x10 // Modem configuration
49 | #define CCx_MDMCFG3 0x11 // Modem configuration
50 | #define CCx_MDMCFG2 0x12 // Modem configuration
51 | #define CCx_MDMCFG1 0x13 // Modem configuration
52 | #define CCx_MDMCFG0 0x14 // Modem configuration
53 | #define CCx_DEVIATN 0x15 // Modem deviation setting
54 | #define CCx_MCSM2 0x16 // Main Radio Control State Machine configuration
55 | #define CCx_MCSM1 0x17 // Main Radio Control State Machine configuration
56 | #define CCx_MCSM0 0x18 // Main Radio Control State Machine configuration
57 | #define CCx_FOCCFG 0x19 // Frequency Offset Compensation configuration
58 | #define CCx_BSCFG 0x1A // Bit Synchronization configuration
59 | #define CCx_AGCCTRL2 0x1B // AGC control
60 | #define CCx_AGCCTRL1 0x1C // AGC control
61 | #define CCx_AGCCTRL0 0x1D // AGC control
62 | #define CCx_WOREVT1 0x1E // High byte Event 0 timeout
63 | #define CCx_WOREVT0 0x1F // Low byte Event 0 timeout
64 | #define CCx_WORCTRL 0x20 // Wake On Radio control
65 | #define CCx_FREND1 0x21 // Front end RX configuration
66 | #define CCx_FREND0 0x22 // Front end TX configuration
67 | #define CCx_FSCAL3 0x23 // Frequency synthesizer calibration
68 | #define CCx_FSCAL2 0x24 // Frequency synthesizer calibration
69 | #define CCx_FSCAL1 0x25 // Frequency synthesizer calibration
70 | #define CCx_FSCAL0 0x26 // Frequency synthesizer calibration
71 | #define CCx_RCCTRL1 0x27 // RC oscillator configuration
72 | #define CCx_RCCTRL0 0x28 // RC oscillator configuration
73 | #define CCx_FSTEST 0x29 // Frequency synthesizer calibration control
74 | #define CCx_PTEST 0x2A // Production test
75 | #define CCx_AGCTEST 0x2B // AGC test
76 | #define CCx_TEST2 0x2C // Various test settings
77 | #define CCx_TEST1 0x2D // Various test settings
78 | #define CCx_TEST0 0x2E // Various test settings
79 |
80 | // Strobe commands
81 | #define CCx_SRES 0x30 // Reset chip.
82 | #define CCx_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
83 | // If in RX/TX: Go to a wait state where only the synthesizer is
84 | // running (for quick RX / TX turnaround).
85 | #define CCx_SXOFF 0x32 // Turn off crystal oscillator.
86 | #define CCx_SCAL 0x33 // Calibrate frequency synthesizer and turn it off
87 | // (enables quick start).
88 | #define CCx_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and
89 | // MCSM0.FS_AUTOCAL=1.
90 | #define CCx_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if
91 | // MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
92 | // Only go to TX if channel is clear.
93 | #define CCx_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit
94 | // Wake-On-Radio mode if applicable.
95 | #define CCx_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
96 | #define CCx_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
97 | #define CCx_SPWD 0x39 // Enter power down mode when CSn goes high.
98 | #define CCx_SFRX 0x3A // Flush the RX FIFO buffer.
99 | #define CCx_SFTX 0x3B // Flush the TX FIFO buffer.
100 | #define CCx_SWORRST 0x3C // Reset real time clock.
101 | #define CCx_SNOP 0x3D // No operation. May be used to pad strobe commands to two
102 | // bytes for simpler software.
103 | // Status registers (read & burst)
104 | #define CCx_PARTNUM (0x30 | 0xc0)
105 | #define CCx_VERSION (0x31 | 0xc0)
106 | #define CCx_FREQEST (0x32 | 0xc0)
107 | #define CCx_LQI (0x33 | 0xc0)
108 | #define CCx_RSSI (0x34 | 0xc0)
109 | #define CCx_MARCSTATE (0x35 | 0xc0)
110 | #define CCx_WORTIME1 (0x36 | 0xc0)
111 | #define CCx_WORTIME0 (0x37 | 0xc0)
112 | #define CCx_PKTSTATUS (0x38 | 0xc0)
113 | #define CCx_VCO_VC_DAC (0x39 | 0xc0)
114 | #define CCx_TXBYTES (0x3A | 0xc0)
115 | #define CCx_RXBYTES (0x3B | 0xc0)
116 |
117 | #define CCx_PATABLE 0x3E
118 | #define CCx_TXFIFO 0x3F
119 | #define CCx_RXFIFO 0x3F
120 |
121 | #define CCx_FIFO_SIZE 0x40 // 64 bytes
122 |
123 | #define CCx_PACKT_LEN (CCx_FIFO_SIZE - 3) // see section 15.3 of the datasheet
124 |
125 | class CCX {
126 | public:
127 | CCX(void);
128 | byte Read(byte addr, byte* data);
129 | byte ReadBurst(byte addr, byte* dataPtr, byte dataCount);
130 | byte Write(byte addr, byte dat);
131 | byte WriteBurst(byte addr, const byte* dataPtr, byte dataCount);
132 | byte Strobe(byte addr);
133 |
134 | //power on reset as discribed in 27.1 of cc1100 datasheet
135 | void PowerOnStartUp();
136 |
137 | //configure registers of cc1100 making it work in specific mode
138 | byte NrOfConfigs(void);
139 | void Setup(byte configId);
140 | void ReadSetup(void);
141 | // set power amplification using a table
142 | void setPA(byte configId, byte paIndex);
143 | // switch radio mode
144 | void Mode(byte);
145 | // decode RSSI value
146 | byte RSSIdecode(byte rssiEnc);
147 | unsigned long lastCalibrate;
148 | };
149 |
150 | extern CCX CCx;
151 |
152 | #endif
153 |
--------------------------------------------------------------------------------
/src/CCxCfg.h:
--------------------------------------------------------------------------------
1 | // CCxCfg.h Configuration settings for the chipcon CCxxxx series transceivers
2 | //
3 | // Copyright (c) 2010 Hans Klunder
4 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
5 | // Version: August 27, 2010
6 | //
7 | // This library is free software; you can redistribute it and/or
8 | // modify it under the terms of the GNU Lesser General Public
9 | // License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | //
12 | // This library is distributed in the hope that it will be useful,
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | // Lesser General Public License for more details.
16 | //
17 | // You should have received a copy of the GNU Lesser General Public
18 | // License along with this library; if not, write to the Free Software
19 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 |
21 | #ifndef CCXCFG_H
22 | #define CCXCFG_H
23 |
24 | #include "CCx.h"
25 | #include
26 |
27 |
28 | #define CCX_NR_OF_REGISTERS 35
29 | // list the registers in the same order as CCxRegisterSettings
30 | // stored in progmem to save on RAM
31 | static const byte CCx_registers[CCX_NR_OF_REGISTERS] PROGMEM = {
32 | CCx_FSCTRL1 ,
33 | CCx_FSCTRL0 ,
34 | CCx_FREQ2 ,
35 | CCx_FREQ1 ,
36 | CCx_FREQ0 ,
37 | CCx_MDMCFG4 ,
38 | CCx_MDMCFG3 ,
39 | CCx_MDMCFG2 ,
40 | CCx_MDMCFG1 ,
41 | CCx_MDMCFG0 ,
42 | CCx_CHANNR ,
43 | CCx_DEVIATN ,
44 | CCx_FREND1 ,
45 | CCx_FREND0 ,
46 | CCx_MCSM0 ,
47 | CCx_FOCCFG ,
48 | CCx_BSCFG ,
49 | CCx_AGCCTRL2 ,
50 | CCx_AGCCTRL1 ,
51 | CCx_AGCCTRL0 ,
52 | CCx_FSCAL3 ,
53 | CCx_FSCAL2 ,
54 | CCx_FSCAL1 ,
55 | CCx_FSCAL0 ,
56 | CCx_FSTEST ,
57 | CCx_TEST2 ,
58 | CCx_TEST1 ,
59 | CCx_TEST0 ,
60 | CCx_FIFOTHR ,
61 | CCx_IOCFG2 ,
62 | CCx_IOCFG0D ,
63 | CCx_PKTCTRL1 ,
64 | CCx_PKTCTRL0 ,
65 | CCx_ADDR ,
66 | CCx_PKTLEN ,
67 | };
68 |
69 | #define CCX_NR_OF_CONFIGS 6
70 |
71 | // configuration for CC1101 generated by TI's SmartRf studio
72 | // stored in progmem to save on RAM
73 | static const byte CCx_registerSettings[CCX_NR_OF_CONFIGS][CCX_NR_OF_REGISTERS] PROGMEM = {
74 | // Chipcon
75 | // Product = CC1101
76 | // Chip version = A (VERSION = 0x04)
77 | // Crystal accuracy = 10 ppm
78 | // X-tal frequency = 26 MHz
79 | // RF output power = 0 dBm
80 | // RX filterbandwidth = 232.142857 kHz
81 | // Deviation = 32 kHz
82 | // Datarate = 76.766968 kBaud
83 | // Modulation = (0) 2-FSK
84 | // Manchester enable = (0) Manchester disabled
85 | // RF Frequency = 914.999969 MHz
86 | // Channel spacing = 199.951172 kHz
87 | // Channel number = 0
88 | // Optimization = -
89 | // Sync mode = (3) 30/32 sync word bits detected
90 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
91 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
92 | // Forward Error Correction = (0) FEC disabled
93 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
94 | // Packetlength = 64
95 | // Preamble count = (2) 4 bytes
96 | // Append status = 1
97 | // Address check = (0) No address check
98 | // FIFO autoflush = 0
99 | // Device address = 0
100 | // GDO0 signal selection = ( 1) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
101 | // GDO2 signal selection = (46) High impedance (3-state)
102 | {
103 | 0x08, // FSCTRL1 Frequency synthesizer control.
104 | 0x00, // FSCTRL0 Frequency synthesizer control.
105 | 0x23, // FREQ2 Frequency control word, high byte.
106 | 0x31, // FREQ1 Frequency control word, middle byte.
107 | 0x3B, // FREQ0 Frequency control word, low byte.
108 | 0x7B, // MDMCFG4 Modem configuration.
109 | 0x83, // MDMCFG3 Modem configuration.
110 | 0x03, // MDMCFG2 Modem configuration.
111 | 0x22, // MDMCFG1 Modem configuration.
112 | 0xF8, // MDMCFG0 Modem configuration.
113 | 0x00, // CHANNR Channel number.
114 | 0x42, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
115 | 0xB6, // FREND1 Front end RX configuration.
116 | 0x10, // FREND0 Front end TX configuration.
117 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
118 | 0x1D, // FOCCFG Frequency Offset Compensation Configuration.
119 | 0x1C, // BSCFG Bit synchronization Configuration.
120 | 0xC7, // AGCCTRL2 AGC control.
121 | 0x00, // AGCCTRL1 AGC control.
122 | 0xB2, // AGCCTRL0 AGC control.
123 | 0xEA, // FSCAL3 Frequency synthesizer calibration.
124 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
125 | 0x00, // FSCAL1 Frequency synthesizer calibration.
126 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
127 | 0x59, // FSTEST Frequency synthesizer calibration.
128 | 0x81, // TEST2 Various test settings.
129 | 0x35, // TEST1 Various test settings.
130 | 0x09, // TEST0 Various test settings.
131 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
132 | 0x09, // IOCFG2 GDO2 output pin configuration.0x09-CCA mode, 0x2E-High impedance
133 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
134 | 0x04, // PKTCTRL1 Packet automation control. bit2 = 1 append RSSI and LQI ,bit2 = 0 not append
135 | 0x05, // PKTCTRL0 Packet automation control.
136 | 0x00, // ADDR Device address.
137 | CCx_PACKT_LEN, // PKTLEN Packet length.
138 | },
139 |
140 | // Chipcon
141 | // Product = CC1101
142 | // Chip version = A (VERSION = 0x04)
143 | // Crystal accuracy = 10 ppm
144 | // X-tal frequency = 26 MHz
145 | // RF output power = 0 dBm
146 | // RX filterbandwidth = 101.562500 kHz
147 | // Deviation = 25 kHz
148 | // Datarate = 4.797935 kBaud
149 | // Modulation = (1) GFSK
150 | // Manchester enable = (0) Manchester disabled
151 | // RF Frequency = 914.999969 MHz
152 | // Channel spacing = 199.951172 kHz
153 | // Channel number = 0
154 | // Optimization = Sensitivity
155 | // Sync mode = (3) 30/32 sync word bits detected
156 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
157 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
158 | // Forward Error Correction = (0) FEC disabled
159 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
160 | // Packetlength = 64
161 | // Preamble count = (2) 4 bytes
162 | // Append status = 1
163 | // Address check = (0) No address check
164 | // FIFO autoflush = 0
165 | // Device address = 0
166 | // GDO0 signal selection = ( 1) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
167 | // GDO2 signal selection = (46) High impedance (3-state)
168 | {
169 | 0x06, // FSCTRL1 Frequency synthesizer control.
170 | 0x00, // FSCTRL0 Frequency synthesizer control.
171 | 0x23, // FREQ2 Frequency control word, high byte.
172 | 0x31, // FREQ1 Frequency control word, middle byte.
173 | 0x3B, // FREQ0 Frequency control word, low byte.
174 | 0xB7, //0xC7 MDMCFG4 Modem configuration.
175 | 0x83, // MDMCFG3 Modem configuration.
176 | 0x13, // MDMCFG2 Modem configuration.
177 | 0x22, // MDMCFG1 Modem configuration.
178 | 0xF8, // MDMCFG0 Modem configuration.
179 | 0x00, // CHANNR Channel number.
180 | 0x40, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
181 | 0x56, // FREND1 Front end RX configuration.
182 | 0x10, // FREND0 Front end TX configuration.
183 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
184 | 0x16, // FOCCFG Frequency Offset Compensation Configuration.
185 | 0x6C, // BSCFG Bit synchronization Configuration.
186 | 0x43, // AGCCTRL2 AGC control.
187 | 0x40, // AGCCTRL1 AGC control.
188 | 0x91, // AGCCTRL0 AGC control.
189 | 0xE9, // FSCAL3 Frequency synthesizer calibration.
190 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
191 | 0x00, // FSCAL1 Frequency synthesizer calibration.
192 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
193 | 0x59, // FSTEST Frequency synthesizer calibration.
194 | 0x81, // TEST2 Various test settings.
195 | 0x35, // TEST1 Various test settings.
196 | 0x09, // TEST0 Various test settings.
197 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
198 | 0x09, // IOCFG2 GDO2 output pin configuration.0x09-CCA mode, 0x2E-High impedance
199 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
200 | 0x04, // PKTCTRL1 Packet automation control. bit2 = 1 append RSSI and LQI ,bit2 = 0 not append
201 | 0x05, // PKTCTRL0 Packet automation control.
202 | 0x00, // ADDR Device address.
203 | CCx_PACKT_LEN, // PKTLEN Packet length.
204 | },
205 |
206 | // Chipcon
207 | // Product = CC1101
208 | // Chip version = A (VERSION = 0x04)
209 | // Crystal accuracy = 10 ppm
210 | // X-tal frequency = 26 MHz
211 | // RF output power = 0 dBm
212 | // RX filterbandwidth = 101.562500 kHz
213 | // Deviation = 25 kHz
214 | // Datarate = 4.797935 kBaud
215 | // Modulation = (1) GFSK
216 | // Manchester enable = (0) Manchester disabled
217 | // RF Frequency = 914.999969 MHz
218 | // Channel spacing = 199.951172 kHz
219 | // Channel number = 0
220 | // Optimization = Low current
221 | // Sync mode = (3) 30/32 sync word bits detected
222 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
223 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
224 | // Forward Error Correction = (0) FEC disabled
225 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
226 | // Packetlength = 64
227 | // Preamble count = (2) 4 bytes
228 | // Append status = 1
229 | // Address check = (0) No address check
230 | // FIFO autoflush = 0
231 | // Device address = 0
232 | // GDO0 signal selection = ( 1) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
233 | // GDO2 signal selection = (46) High impedance (3-state)
234 | {
235 | 0x08, // FSCTRL1 Frequency synthesizer control.
236 | 0x00, // FSCTRL0 Frequency synthesizer control.
237 | 0x23, // FREQ2 Frequency control word, high byte.
238 | 0x31, // FREQ1 Frequency control word, middle byte.
239 | 0x3B, // FREQ0 Frequency control word, low byte.
240 | 0xB7, // MDMCFG4 Modem configuration.
241 | 0x83, // MDMCFG3 Modem configuration.
242 | 0x93, // MDMCFG2 Modem configuration.
243 | 0x22, // MDMCFG1 Modem configuration.
244 | 0xF8, // MDMCFG0 Modem configuration.
245 | 0x00, // CHANNR Channel number.
246 | 0x40, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
247 | 0x56, // FREND1 Front end RX configuration.
248 | 0x10, // FREND0 Front end TX configuration.
249 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
250 | 0x16, // FOCCFG Frequency Offset Compensation Configuration.
251 | 0x6C, // BSCFG Bit synchronization Configuration.
252 | 0x43, // AGCCTRL2 AGC control.
253 | 0x40, // AGCCTRL1 AGC control.
254 | 0x91, // AGCCTRL0 AGC control.
255 | 0xE9, // FSCAL3 Frequency synthesizer calibration.
256 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
257 | 0x00, // FSCAL1 Frequency synthesizer calibration.
258 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
259 | 0x59, // FSTEST Frequency synthesizer calibration.
260 | 0x81, // TEST2 Various test settings.
261 | 0x35, // TEST1 Various test settings.
262 | 0x09, // TEST0 Various test settings.
263 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
264 | 0x09, // IOCFG2 GDO2 output pin configuration.0x09-CCA mode, 0x2E-High impedance
265 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
266 | 0x04, // PKTCTRL1 Packet automation control. bit2 = 1 append RSSI and LQI ,bit2 = 0 not append
267 | 0x05, // PKTCTRL0 Packet automation control.
268 | 0x00, // ADDR Device address.
269 | CCx_PACKT_LEN, // PKTLEN Packet length.
270 | },
271 | // Chipcon
272 | // Product = CC1100
273 | // Chip version = F (VERSION = 0x03)
274 | // Crystal accuracy = 10 ppm
275 | // X-tal frequency = 26 MHz
276 | // RF output power = 0 dBm
277 | // RX filterbandwidth = 232.142857 kHz
278 | // Deviation = 32 kHz
279 | // Datarate = 76.766968 kBaud
280 | // Modulation = (0) 2-FSK
281 | // Manchester enable = (0) Manchester disabled
282 | // RF Frequency = 867.999939 MHz
283 | // Channel spacing = 199.951172 kHz
284 | // Channel number = 0
285 | // Optimization = -
286 | // Sync mode = (3) 30/32 sync word bits detected
287 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
288 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
289 | // Forward Error Correction = (0) FEC disabled
290 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
291 | // Packetlength = 64
292 | // Preamble count = (2) 4 bytes
293 | // Append status = 1
294 | // Address check = (0) No address check
295 | // FIFO autoflush = 0
296 | // Device address = 0
297 | // GDO0 signal selection = ( 7) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
298 | // GDO2 signal selection = (46) High impedance (3-state)
299 | {
300 | 0x06, // FSCTRL1 Frequency synthesizer control.
301 | 0x00, // FSCTRL0 Frequency synthesizer control.
302 | 0x23, // FREQ2 Frequency control word, high byte.
303 | 0x31, // FREQ1 Frequency control word, middle byte.
304 | 0x3B, // FREQ0 Frequency control word, low byte.
305 | 0x7B, // MDMCFG4 Modem configuration.
306 | 0x83, // MDMCFG3 Modem configuration.
307 | 0x13, // MDMCFG2 Modem configuration.
308 | 0x22, // MDMCFG1 Modem configuration.
309 | 0xF8, // MDMCFG0 Modem configuration.
310 | 0x00, // CHANNR Channel number.
311 | 0x34, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
312 | 0x56, // FREND1 Front end RX configuration.
313 | 0x10, // FREND0 Front end TX configuration.
314 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
315 | 0x16, // FOCCFG Frequency Offset Compensation Configuration.
316 | 0x6C, // BSCFG Bit synchronization Configuration.
317 | 0x43, // AGCCTRL2 AGC control.
318 | 0x40, // AGCCTRL1 AGC control.
319 | 0x91, // AGCCTRL0 AGC control.
320 | 0xE9, // FSCAL3 Frequency synthesizer calibration.
321 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
322 | 0x00, // FSCAL1 Frequency synthesizer calibration.
323 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
324 | 0x59, // FSTEST Frequency synthesizer calibration.
325 | 0x81, // TEST2 Various test settings.
326 | 0x35, // TEST1 Various test settings.
327 | 0x09, // TEST0 Various test settings.
328 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
329 | 0x2E, // IOCFG2 GDO2 output pin configuration.
330 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
331 | 0x04, // PKTCTRL1 Packet automation control.
332 | 0x05, // PKTCTRL0 Packet automation control.
333 | 0x00, // ADDR Device address.
334 | CCx_PACKT_LEN // PKTLEN Packet length.
335 | },
336 |
337 | // Chipcon
338 | // Product = CC1101
339 | // Chip version = A (VERSION = 0x04)
340 | // Crystal accuracy = 10 ppm
341 | // X-tal frequency = 26 MHz
342 | // RF output power = 0 dBm
343 | // RX filterbandwidth = 101.562500 kHz
344 | // Deviation = 25 kHz
345 | // Datarate = 4.797935 kBaud
346 | // Modulation = (1) GFSK
347 | // Manchester enable = (0) Manchester disabled
348 | // RF Frequency = 868.299866 MHz
349 | // Channel spacing = 199.951172 kHz
350 | // Channel number = 0
351 | // Optimization = Sensitivity
352 | // Sync mode = (3) 30/32 sync word bits detected
353 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
354 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
355 | // Forward Error Correction = (0) FEC disabled
356 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
357 | // Packetlength = 64
358 | // Preamble count = (2) 4 bytes
359 | // Append status = 1
360 | // Address check = (0) No address check
361 | // FIFO autoflush = 0
362 | // Device address = 0
363 | // GDO0 signal selection = ( 1) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
364 | // GDO2 signal selection = (46) High impedance (3-state)
365 | {
366 | 0x06, // FSCTRL1 Frequency synthesizer control.
367 | 0x00, // FSCTRL0 Frequency synthesizer control.
368 | 0x21, // FREQ2 Frequency control word, high byte.
369 | 0x65, // FREQ1 Frequency control word, middle byte.
370 | 0x6A, // FREQ0 Frequency control word, low byte.
371 | 0xB7, // MDMCFG4 Modem configuration.
372 | 0x83, // MDMCFG3 Modem configuration.
373 | 0x13, // MDMCFG2 Modem configuration.
374 | 0x22, // MDMCFG1 Modem configuration.
375 | 0xF8, // MDMCFG0 Modem configuration.
376 | 0x00, // CHANNR Channel number.
377 | 0x40, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
378 | 0x56, // FREND1 Front end RX configuration.
379 | 0x10, // FREND0 Front end TX configuration.
380 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
381 | 0x16, // FOCCFG Frequency Offset Compensation Configuration.
382 | 0x6C, // BSCFG Bit synchronization Configuration.
383 | 0x43, // AGCCTRL2 AGC control.
384 | 0x40, // AGCCTRL1 AGC control.
385 | 0x91, // AGCCTRL0 AGC control.
386 | 0xE9, // FSCAL3 Frequency synthesizer calibration.
387 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
388 | 0x00, // FSCAL1 Frequency synthesizer calibration.
389 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
390 | 0x59, // FSTEST Frequency synthesizer calibration.
391 | 0x81, // TEST2 Various test settings.
392 | 0x35, // TEST1 Various test settings.
393 | 0x09, // TEST0 Various test settings.
394 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
395 | 0x09, // IOCFG2 GDO2 output pin configuration.0x09-CCA mode, 0x2E-High impedance
396 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
397 | 0x04, // PKTCTRL1 Packet automation control. bit2 = 1 append RSSI and LQI ,bit2 = 0 not append
398 | 0x05, // PKTCTRL0 Packet automation control.
399 | 0x00, // ADDR Device address.
400 | CCx_PACKT_LEN, // PKTLEN Packet length.
401 | },
402 |
403 | // Chipcon
404 | // Product = CC1101
405 | // Chip version = A (VERSION = 0x04)
406 | // Crystal accuracy = 10 ppm
407 | // X-tal frequency = 26 MHz
408 | // RF output power = 0 dBm
409 | // RX filterbandwidth = 101.562500 kHz
410 | // Deviation = 25 kHz
411 | // Datarate = 4.797935 kBaud
412 | // Modulation = (1) GFSK
413 | // Manchester enable = (0) Manchester disabled
414 | // RF Frequency = 867.999939 MHz
415 | // Channel spacing = 199.951172 kHz
416 | // Channel number = 0
417 | // Optimization = Low current
418 | // Sync mode = (3) 30/32 sync word bits detected
419 | // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
420 | // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
421 | // Forward Error Correction = (0) FEC disabled
422 | // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
423 | // Packetlength = 64
424 | // Preamble count = (2) 4 bytes
425 | // Append status = 1
426 | // Address check = (0) No address check
427 | // FIFO autoflush = 0
428 | // Device address = 0
429 | // GDO0 signal selection = ( 1) Asserts when a packet has been received with OK CRC. De-asserts when the first byte is read from the RX FIFO
430 | // GDO2 signal selection = (46) High impedance (3-state)
431 | {
432 | 0x08, // FSCTRL1 Frequency synthesizer control.
433 | 0x00, // FSCTRL0 Frequency synthesizer control.
434 | 0x21, // FREQ2 Frequency control word, high byte.
435 | 0x62, // FREQ1 Frequency control word, middle byte.
436 | 0x76, // FREQ0 Frequency control word, low byte.
437 | 0xB7, // MDMCFG4 Modem configuration.
438 | 0x83, // MDMCFG3 Modem configuration.
439 | 0x93, // MDMCFG2 Modem configuration.
440 | 0x22, // MDMCFG1 Modem configuration.
441 | 0xF8, // MDMCFG0 Modem configuration.
442 | 0x00, // CHANNR Channel number.
443 | 0x40, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
444 | 0x56, // FREND1 Front end RX configuration.
445 | 0x10, // FREND0 Front end TX configuration.
446 | 0x18, // MCSM0 Main Radio Control State Machine configuration.
447 | 0x16, // FOCCFG Frequency Offset Compensation Configuration.
448 | 0x6C, // BSCFG Bit synchronization Configuration.
449 | 0x43, // AGCCTRL2 AGC control.
450 | 0x40, // AGCCTRL1 AGC control.
451 | 0x91, // AGCCTRL0 AGC control.
452 | 0xE9, // FSCAL3 Frequency synthesizer calibration.
453 | 0x2A, // FSCAL2 Frequency synthesizer calibration.
454 | 0x00, // FSCAL1 Frequency synthesizer calibration.
455 | 0x1F, // FSCAL0 Frequency synthesizer calibration.
456 | 0x59, // FSTEST Frequency synthesizer calibration.
457 | 0x81, // TEST2 Various test settings.
458 | 0x35, // TEST1 Various test settings.
459 | 0x09, // TEST0 Various test settings.
460 | 0x0E, // FIFOTHR RXFIFO and TXFIFO thresholds.
461 | 0x09, // IOCFG2 GDO2 output pin configuration.0x09-CCA mode, 0x2E-High impedance
462 | 0x01, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
463 | 0x04, // PKTCTRL1 Packet automation control. bit2 = 1 append RSSI and LQI ,bit2 = 0 not append
464 | 0x05, // PKTCTRL0 Packet automation control.
465 | 0x00, // ADDR Device address.
466 | CCx_PACKT_LEN, // PKTLEN Packet length.
467 | },
468 |
469 | };
470 |
471 | // PATABLE (dBm output power)
472 |
473 | // stored in progmem to save on RAM
474 | static const byte CCx_paTable[CCX_NR_OF_CONFIGS][CCx_PA_TABLESIZE] PROGMEM = {
475 | // -30 -20 -15 -10 0 5 7 10
476 | {0x03, 0x0E, 0x1E, 0x27, 0x8E, 0xCD, 0xC7, 0xC0}, // Config 0 , 915 Mhz
477 | {0x00, 0x03, 0x0F, 0x25, 0x67, 0x40, 0x60, 0x50}, // Config 1 , 915 Mhz
478 | {0x00, 0x03, 0x0F, 0x25, 0x67, 0x40, 0x60, 0x50}, // Config 2 , 915 Mhz
479 | {0x03, 0x0F, 0x1E, 0x27, 0x50, 0x81, 0xCB, 0xC2}, // Config 3 , 868 Mhz
480 | {0x00, 0x03, 0x0F, 0x25, 0x67, 0x40, 0x60, 0x50}, // Config 4 , 868 Mhz
481 | {0x00, 0x03, 0x0F, 0x25, 0x67, 0x40, 0x60, 0x50}, // Config 5 , 868 Mhz
482 | };
483 |
484 | #endif
485 |
--------------------------------------------------------------------------------
/src/Config.h:
--------------------------------------------------------------------------------
1 | // Config.h Simple config library for RFbee
2 |
3 | // Copyright (c) 2010 Hans Klunder
4 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
5 | // Version: Aug 27, 2010
6 | //
7 | // This library is free software; you can redistribute it and/or
8 | // modify it under the terms of the GNU Lesser General Public
9 | // License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | //
12 | // This library is distributed in the hope that it will be useful,
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | // Lesser General Public License for more details.
16 | //
17 | // You should have received a copy of the GNU Lesser General Public
18 | // License along with this library; if not, write to the Free Software
19 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 |
21 |
22 |
23 | #ifndef Config_h
24 | #define Config_h 1
25 |
26 | #include "Arduino.h"
27 |
28 | // config layout
29 | #define CONFIG_RFBEE_MARKER 0 // Marker
30 | #define CONFIG_HW_VERSION 1 // Hardware version
31 | #define CONFIG_FW_VERSION 2 // Firmware version
32 | #define CONFIG_DEST_ADDR 3 // Receiver address
33 | #define CONFIG_MY_ADDR 4 // Sender address
34 | #define CONFIG_ADDR_CHECK 5 // Address checking
35 | #define CONFIG_TX_THRESHOLD 6 // Transmit threshold
36 | #define CONFIG_BDINDEX 7 // Index to baudrate
37 | #define CONFIG_PAINDEX 8 // Index to PowerAmplifier
38 | #define CONFIG_CONFIG_ID 9 // Selected CCx configuration
39 | #define CONFIG_OUTPUT_FORMAT 10 // output format to use
40 | #define CONFIG_RFBEE_MODE 11 // rfBee operating mode (e.g. transmit/receive/idle)
41 | // marker
42 | #define CONFIG_RFBEE_MARKER_VALUE 0xAA
43 |
44 | class CONFIG {
45 | public:
46 | CONFIG(void);
47 | void reset(void);
48 | byte get(byte);
49 | byte get_eep(byte);
50 | void set(byte, byte);
51 | int initialized();
52 | void load_default();
53 |
54 | private:
55 | byte _cfg[CONFIG_RFBEE_MODE + 1];
56 | };
57 |
58 | extern CONFIG Config;
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/Spi.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Spi.cpp - SPI library
3 | Copyright (c) 2008 Cam Thompson.
4 | Author: Cam Thompson, Micromega Corporation,
5 | Version: December 15, 2008
6 |
7 | This library is free software; you can redistribute it and/or
8 | modify it under the terms of the GNU Lesser General Public
9 | License as published by the Free Software Foundation; either
10 | version 2.1 of the License, or (at your option) any later version.
11 |
12 | This library is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | Lesser General Public License for more details.
16 |
17 | You should have received a copy of the GNU Lesser General Public
18 | License along with this library; if not, write to the Free Software
19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #include "Arduino.h"
23 | #include "Spi.h"
24 |
25 | //---------- constructor ----------------------------------------------------
26 |
27 | SPI::SPI() {
28 | // initialize the SPI pins
29 | pinMode(SCK_PIN, OUTPUT);
30 | pinMode(MOSI_PIN, OUTPUT);
31 | pinMode(MISO_PIN, INPUT);
32 | pinMode(SS_PIN, OUTPUT);
33 |
34 | // enable SPI Master, MSB, SPI mode 0, FOSC/4
35 | mode(0);
36 |
37 | digitalWrite(SS_PIN, HIGH);
38 | digitalWrite(MOSI_PIN, LOW);
39 | digitalWrite(SCK_PIN, HIGH);
40 |
41 | }
42 |
43 | //------------------ mode ---------------------------------------------------
44 |
45 | void SPI::mode(byte config) {
46 | byte tmp;
47 |
48 | // enable SPI master with configuration byte specified
49 | SPCR = 0;
50 | SPCR = (config & 0x7F) | (1 << SPE) | (1 << MSTR);
51 | tmp = SPSR;
52 | tmp = SPDR;
53 | }
54 |
55 | //------------------ transfer -----------------------------------------------
56 |
57 | byte SPI::transfer(byte value) {
58 | byte x;
59 | SPDR = value;
60 | while (!(SPSR & (1 << SPIF))) ;
61 | x = SPDR;
62 | return x;
63 | }
64 |
65 |
66 | //------------------ slave Select ---------------------------------------------
67 | byte SPI::slaveSelect(byte value) {
68 | digitalWrite(SS_PIN, value);
69 | }
70 |
71 | //---------- preinstantiate SPI object --------------------------------------
72 |
73 | SPI Spi = SPI();
74 |
--------------------------------------------------------------------------------
/src/Spi.h:
--------------------------------------------------------------------------------
1 | /*
2 | Spi.h - SPI library
3 | Copyright (c) 2008 Cam Thompson.
4 | Author: Cam Thompson, Micromega Corporation,
5 | Version: December 15, 2008
6 |
7 | This library is free software; you can redistribute it and/or
8 | modify it under the terms of the GNU Lesser General Public
9 | License as published by the Free Software Foundation; either
10 | version 2.1 of the License, or (at your option) any later version.
11 |
12 | This library is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | Lesser General Public License for more details.
16 |
17 | You should have received a copy of the GNU Lesser General Public
18 | License along with this library; if not, write to the Free Software
19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef Spi_h
23 | #define Spi_h 1
24 |
25 | #include "Arduino.h"
26 |
27 | #define SCK_PIN 13
28 | #define MISO_PIN 12
29 | #define MOSI_PIN 11
30 | #define SS_PIN 10
31 |
32 | class SPI {
33 | public:
34 | SPI(void);
35 | void mode(byte);
36 | byte transfer(byte);
37 | byte slaveSelect(byte);
38 | };
39 |
40 | extern SPI Spi;
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/TestIO.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTIO_H
2 | #define TESTIO_H
3 |
4 | #include "globals.h"
5 | #include "Config.h"
6 |
7 | #define HARDWAREVERSION 11 // 1.1 , version number needs to fit in byte (0~255) to be able to store it into config, this should only be changed by the manufacturer!
8 |
9 | int TestIO();
10 |
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/src/debug.h:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG_H
2 | #define DEBUG_H 1
3 |
4 | #ifdef DEBUG
5 | #define DEBUGPRINT( X ) \
6 | Serial.print( __FUNCTION__ ); \
7 | Serial.print( ": " ); \
8 | Serial.println( X );
9 | #else
10 | #define DEBUGPRINT( X )
11 | #endif
12 | #endif
13 |
14 |
--------------------------------------------------------------------------------
/src/globals.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | //return values 0: ok, -1: error, 1: nothing , 2: modified
4 | #define OK 0
5 | #define ERR -1
6 | #define NOTHING 1
7 | #define MODIFIED 2
8 |
--------------------------------------------------------------------------------
/src/rfBeeCore.h:
--------------------------------------------------------------------------------
1 | // rfBeeCore.h core routines for the rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: June 22, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 |
23 | #ifndef RFBEECORE_H
24 | #define RFBEECORE_H 1
25 |
26 | #include "debug.h"
27 | #include "globals.h"
28 | #include "CCx.h"
29 | #include
30 | #include
31 |
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/rfBeeSerial.h:
--------------------------------------------------------------------------------
1 | // rfBeeSerial.h serial interface to rfBee
2 | // see www.seeedstudio.com for details and ordering rfBee hardware.
3 |
4 | // Copyright (c) 2010 Hans Klunder
5 | // Author: Hans Klunder, based on the original Rfbee v1.0 firmware by Seeedstudio
6 | // Version: July 16, 2010
7 | //
8 | // This library is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU Lesser General Public
10 | // License as published by the Free Software Foundation; either
11 | // version 2.1 of the License, or (at your option) any later version.
12 | //
13 | // This library is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | // Lesser General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU Lesser General Public
19 | // License along with this library; if not, write to the Free Software
20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 |
22 |
23 | #ifndef RFBEESERIAL_H
24 | #define RFBEESERIAL_H 1
25 |
26 | #include "debug.h"
27 | #include "globals.h"
28 | #include "Config.h"
29 | #include "CCx.h"
30 | #include "rfBeeCore.h"
31 | #include
32 |
33 | #define BUFFLEN CCx_PACKT_LEN
34 | #define SERIALCMDMODE 1
35 | #define SERIALDATAMODE 0
36 | #define SERIALCMDTERMINATOR 13 // use to terminate commands
37 |
38 | void readSerialCmd();
39 | void txDataFromSerialToRf();
40 | void rxDataFromRfToSerial();
41 |
42 | int setMyAddress();
43 | int setAddressCheck();
44 | int setPowerAmplifier();
45 | int setCCxConfig();
46 | int changeUartBaudRate();
47 | int setSerialDataMode();
48 | int setRFBeeMode();
49 | int showFirmwareVersion();
50 | int showHardwareVersion();
51 | int resetConfig();
52 | int setSleepMode();
53 |
54 |
55 | byte serialData[BUFFLEN + 1]; // 1 extra so we can easily add a /0 when doing a debug print ;-)
56 | byte serialMode;
57 | volatile int sleepCounter;
58 |
59 |
60 | // RFbee AT commands
61 |
62 | // Need to define the labels outside the struct :-(
63 | static const char DA_label[] PROGMEM = "DA";
64 | static const char MA_label[] PROGMEM = "MA";
65 | static const char AC_label[] PROGMEM = "AC";
66 | static const char PA_label[] PROGMEM = "PA";
67 | static const char TH_label[] PROGMEM = "TH";
68 | static const char BD_label[] PROGMEM = "BD";
69 | static const char MD_label[] PROGMEM = "MD";
70 | static const char FV_label[] PROGMEM = "FV";
71 | static const char HV_label[] PROGMEM = "HV";
72 | static const char RS_label[] PROGMEM = "RS";
73 | static const char CF_label[] PROGMEM = "CF";
74 | static const char OF_label[] PROGMEM = "OF";
75 | static const char O0_label[] PROGMEM = "O0";
76 | static const char SL_label[] PROGMEM = "SL";
77 |
78 | // Supported commands, Commands and parameters in ASCII
79 | // Example: ATDA14 means: change the RF module Destination Address to 14
80 |
81 | typedef int (*AT_Command_Function_t)();
82 |
83 | typedef struct {
84 | const char* name;
85 | const byte configItem; // the ID used in the EEPROM
86 | const byte paramDigits; // how many digits for the parameter
87 | const byte maxValue; // maximum value of the parameter
88 | const byte postProcess; // do we need to call the function to perform extra actions on change
89 | AT_Command_Function_t function; // the function which does the real work on change
90 | } AT_Command_t;
91 |
92 |
93 | static const AT_Command_t atCommands[] PROGMEM = {
94 | // Addressing:
95 | { DA_label, CONFIG_DEST_ADDR, 3, 255, false, 0 }, // Destination address (0~255)
96 | { MA_label, CONFIG_MY_ADDR, 3, 255, true, setMyAddress }, // My address (0~255)
97 | { AC_label, CONFIG_ADDR_CHECK, 1, 2, true, setAddressCheck }, // address check option (0: no, 1: address check , 2: address check and 0 broadcast )
98 | // RF
99 | { PA_label, CONFIG_PAINDEX, 1, 7, true, setPowerAmplifier }, // Power amplifier (0: -30 , 1: -20 , 2: -15 , 3: -10 , 4: 0 , 5: 5 , 6: 7 , 7: 10 )
100 | { CF_label, CONFIG_CONFIG_ID, 1, 5, true, setCCxConfig }, // select CCx configuration (0: 915 Mhz - 76.8k, 1: 915 Mhz - 4.8k sensitivity, 2: 915 Mhz - 4.8k low current, 3: 868 Mhz - 76.8k, 4: 868 Mhz - 4.8k sensitivity, 5: 868 Mhz - 4.8k low current )
101 | // Serial
102 | { BD_label, CONFIG_BDINDEX, 1, 4, true, changeUartBaudRate }, // Uart baudrate (0: 9600 , 1:19200, 2:38400 ,3:115200)
103 | { TH_label, CONFIG_TX_THRESHOLD, 2, 32, false, 0 }, // TH- threshold of transmitting (0~32)
104 | { OF_label, CONFIG_OUTPUT_FORMAT, 1, 3, false, 0 }, // Output Format (0: payload only, 1: source, dest, payload , 2: payload len, source, dest, payload, rssi, lqi, 3: same as 2, but all except for payload as decimal and separated by comma's )
105 | // Mode
106 | { MD_label, CONFIG_RFBEE_MODE, 1, 3, true, setRFBeeMode}, // CCx Working mode (0:transceive , 1:transmit , 2:receive, 3:lowpower)
107 | { O0_label, 0, 0, 0, true, setSerialDataMode }, // thats o+ zero, go back to online mode
108 | { SL_label, 0, 0, 0, true, setSleepMode }, // put the rfBee to sleep
109 | // Diagnostics:
110 | { FV_label, 0, 0, 0, true, showFirmwareVersion }, // firmware version
111 | { HV_label, 0, 0, 0, true, showHardwareVersion }, // hardware version
112 | // Miscelaneous
113 | { RS_label, 0, 0, 0, true, resetConfig } // restore default settings
114 | };
115 |
116 | // error codes and labels
117 | byte errNo;
118 |
119 | static const char error_0[] PROGMEM = "no error";
120 | static const char error_1[] PROGMEM = "received invalid RF data size";
121 | static const char error_2[] PROGMEM = "received invalid RF data";
122 | static const char error_3[] PROGMEM = "RX buffer overflow";
123 | static const char error_4[] PROGMEM = "CRC check failed";
124 |
125 | static const char* const error_codes[] PROGMEM = {
126 | error_0,
127 | error_1,
128 | error_2,
129 | error_3,
130 | };
131 |
132 |
133 | const long baudRateTable[] PROGMEM = {9600, 19200, 38400, 115200, 57600};
134 |
135 | // operating modes, used by ATMD
136 |
137 | #define TRANSCEIVE_MODE 0
138 | #define TRANSMIT_MODE 1
139 | #define RECEIVE_MODE 2
140 | #define LOWPOWER_MODE 3
141 |
142 | #ifdef INTERRUPT_RECEIVE
143 | volatile enum state
144 |
145 | #endif
146 |
147 | #endif
148 |
--------------------------------------------------------------------------------