Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LittleCounter-Example
Diff: BERGCloudBase.cpp
- Revision:
- 5:2e04a8b3fc25
- Parent:
- 4:5a04c00b5b6f
- Child:
- 6:79100379d4b4
--- a/BERGCloudBase.cpp Wed Nov 13 18:14:38 2013 +0000
+++ b/BERGCloudBase.cpp Tue Nov 26 17:45:12 2013 +0000
@@ -39,7 +39,7 @@
uint8_t BERGCloudBase::nullKey[BC_KEY_SIZE_BYTES] = {0};
-bool BERGCloudBase::transaction(_BC_SPI_TRANSACTION *tr)
+bool BERGCloudBase::_transaction(_BC_SPI_TRANSACTION *tr)
{
uint16_t i, j;
uint8_t rxByte;
@@ -255,6 +255,18 @@
return (lastResponse == SPI_RSP_SUCCESS);
}
+bool BERGCloudBase::transaction(_BC_SPI_TRANSACTION *tr)
+{
+ bool result;
+
+ /* For thread synchronisation */
+ lockTake();
+ result = _transaction(tr);
+ lockRelease();
+
+ return result;
+}
+
void BERGCloudBase::initTransaction(_BC_SPI_TRANSACTION *tr)
{
memset(tr, 0x00, sizeof(_BC_SPI_TRANSACTION));
@@ -567,16 +579,14 @@
uint16_t BERGCloudBase::Crc16(uint8_t data, uint16_t crc)
{
- /* From Ember's code */
- crc = (crc >> 8) | (crc << 8);
- crc ^= data;
- crc ^= (crc & 0xff) >> 4;
- crc ^= (crc << 8) << 4;
+ /* CRC16 CCITT (0x1021) */
- crc ^= ( (uint8_t) ( (uint8_t) ( (uint8_t) (crc & 0xff) ) << 5)) |
- ((uint16_t) ( (uint8_t) ( (uint8_t) (crc & 0xff)) >> 3) << 8);
+ uint8_t s;
+ uint16_t t;
- return crc;
+ s = data ^ (crc >> 8);
+ t = s ^ (s >> 4);
+ return (crc << 8) ^ t ^ (t << 5) ^ (t << 12);
}
uint8_t BERGCloudBase::SPITransaction(uint8_t dataOut, bool finalCS)
@@ -588,6 +598,14 @@
return dataIn;
}
+void BERGCloudBase::lockTake(void)
+{
+}
+
+void BERGCloudBase::lockRelease(void)
+{
+}
+
void BERGCloudBase::begin(void)
{
synced = false;

