Skip to content

Commit 258c7af

Browse files
committed
Bridge library is now platform independent.
1 parent fdb98f1 commit 258c7af

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

libraries/Bridge/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ email=info@arduino.cc
44
sentence=The library to use the Arduino YUN. The Bridge library create a link between the 32U4 and the AR9331 enabling to control most of the linux features from the sketch.
55
paragraph=The Bridge library feature: access to the shared storage, run and manage linux processes, open a remote console, access to the linux file system, including the SD card, enstablish http clients or servers.
66
url=http://arduino.cc/en/Reference/YunBridgeLibrary
7-
architectures=avr
7+
architectures=*
88
version=1.0
99
dependencies=none
1010
core-dependencies=arduino (>1.5.4)

libraries/Bridge/src/Bridge.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "Bridge.h"
20-
#include <util/crc16.h>
2120

2221
BridgeClass::BridgeClass(Stream &_stream) :
2322
index(0), stream(_stream), started(false), max_retries(0) {
@@ -94,11 +93,23 @@ unsigned int BridgeClass::get(const char *key, uint8_t *value, unsigned int maxl
9493
return l;
9594
}
9695

97-
void BridgeClass::crcUpdate(uint8_t c) {
96+
#if defined(ARDUINO_ARCH_AVR)
97+
// AVR use an optimized implementation of CRC
98+
#include <util/crc16.h>
99+
#else
100+
// Generic implementation for non-AVR architectures
101+
uint16_t _crc_ccitt_update(uint16_t crc, uint8_t data)
102+
{
103+
data ^= crc & 0xff;
104+
data ^= data << 4;
105+
return ((((uint16_t)data << 8) | ((crc >> 8) & 0xff)) ^
106+
(uint8_t)(data >> 4) ^
107+
((uint16_t)data << 3));
108+
}
109+
#endif
98110

111+
void BridgeClass::crcUpdate(uint8_t c) {
99112
CRC = _crc_ccitt_update(CRC, c);
100-
//CRC = CRC ^ c;
101-
//CRC = (CRC >> 8) + (CRC << 8);
102113
}
103114

104115
void BridgeClass::crcReset() {

0 commit comments

Comments
 (0)