1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-18 12:54:25 +01:00

Bridge library is now platform independent.

This commit is contained in:
Cristian Maglie 2013-11-14 19:38:59 +01:00
parent fdb98f1213
commit 258c7af469
2 changed files with 16 additions and 5 deletions

View File

@ -4,7 +4,7 @@ email=info@arduino.cc
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.
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.
url=http://arduino.cc/en/Reference/YunBridgeLibrary
architectures=avr
architectures=*
version=1.0
dependencies=none
core-dependencies=arduino (>1.5.4)

View File

@ -17,7 +17,6 @@
*/
#include "Bridge.h"
#include <util/crc16.h>
BridgeClass::BridgeClass(Stream &_stream) :
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
return l;
}
void BridgeClass::crcUpdate(uint8_t c) {
#if defined(ARDUINO_ARCH_AVR)
// AVR use an optimized implementation of CRC
#include <util/crc16.h>
#else
// Generic implementation for non-AVR architectures
uint16_t _crc_ccitt_update(uint16_t crc, uint8_t data)
{
data ^= crc & 0xff;
data ^= data << 4;
return ((((uint16_t)data << 8) | ((crc >> 8) & 0xff)) ^
(uint8_t)(data >> 4) ^
((uint16_t)data << 3));
}
#endif
void BridgeClass::crcUpdate(uint8_t c) {
CRC = _crc_ccitt_update(CRC, c);
//CRC = CRC ^ c;
//CRC = (CRC >> 8) + (CRC << 8);
}
void BridgeClass::crcReset() {