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
BERGCloudMbed.h@0:b4ccb530b9eb, 2013-11-12 (annotated)
- Committer:
 - nickludlam
 - Date:
 - Tue Nov 12 14:38:30 2013 +0000
 - Revision:
 - 0:b4ccb530b9eb
 - Child:
 - 2:9d6a1f2e5118
 
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| nickludlam | 0:b4ccb530b9eb | 1 | /* | 
| nickludlam | 0:b4ccb530b9eb | 2 | |
| nickludlam | 0:b4ccb530b9eb | 3 | BERGCloud library for mbed | 
| nickludlam | 0:b4ccb530b9eb | 4 | |
| nickludlam | 0:b4ccb530b9eb | 5 | Copyright (c) 2013 BERG Cloud Ltd. http://bergcloud.com/ | 
| nickludlam | 0:b4ccb530b9eb | 6 | |
| nickludlam | 0:b4ccb530b9eb | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy | 
| nickludlam | 0:b4ccb530b9eb | 8 | of this software and associated documentation files (the "Software"), to deal | 
| nickludlam | 0:b4ccb530b9eb | 9 | in the Software without restriction, including without limitation the rights | 
| nickludlam | 0:b4ccb530b9eb | 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
| nickludlam | 0:b4ccb530b9eb | 11 | copies of the Software, and to permit persons to whom the Software is | 
| nickludlam | 0:b4ccb530b9eb | 12 | furnished to do so, subject to the following conditions: | 
| nickludlam | 0:b4ccb530b9eb | 13 | |
| nickludlam | 0:b4ccb530b9eb | 14 | The above copyright notice and this permission notice shall be included in | 
| nickludlam | 0:b4ccb530b9eb | 15 | all copies or substantial portions of the Software. | 
| nickludlam | 0:b4ccb530b9eb | 16 | |
| nickludlam | 0:b4ccb530b9eb | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
| nickludlam | 0:b4ccb530b9eb | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
| nickludlam | 0:b4ccb530b9eb | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
| nickludlam | 0:b4ccb530b9eb | 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
| nickludlam | 0:b4ccb530b9eb | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
| nickludlam | 0:b4ccb530b9eb | 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
| nickludlam | 0:b4ccb530b9eb | 23 | THE SOFTWARE. | 
| nickludlam | 0:b4ccb530b9eb | 24 | |
| nickludlam | 0:b4ccb530b9eb | 25 | */ | 
| nickludlam | 0:b4ccb530b9eb | 26 | |
| nickludlam | 0:b4ccb530b9eb | 27 | #ifndef BERGCLOUDMBED_H | 
| nickludlam | 0:b4ccb530b9eb | 28 | #define BERGCLOUDMBED_H | 
| nickludlam | 0:b4ccb530b9eb | 29 | |
| nickludlam | 0:b4ccb530b9eb | 30 | #include "mbed.h" | 
| nickludlam | 0:b4ccb530b9eb | 31 | #include <string> | 
| nickludlam | 0:b4ccb530b9eb | 32 | #include "BERGCloudBase.h" | 
| nickludlam | 0:b4ccb530b9eb | 33 | |
| nickludlam | 0:b4ccb530b9eb | 34 | #ifdef BERGCLOUD_PACK_UNPACK | 
| nickludlam | 0:b4ccb530b9eb | 35 | #include "BERGCloudMessageBase.h" | 
| nickludlam | 0:b4ccb530b9eb | 36 | #endif | 
| nickludlam | 0:b4ccb530b9eb | 37 | |
| nickludlam | 0:b4ccb530b9eb | 38 | class BERGCloudMbed : public BERGCloudBase | 
| nickludlam | 0:b4ccb530b9eb | 39 | { | 
| nickludlam | 0:b4ccb530b9eb | 40 | public: | 
| nickludlam | 0:b4ccb530b9eb | 41 | void begin(PinName _MOSIPin, PinName _MISOPin, PinName _SCLKPin, PinName _nSSELPin); | 
| nickludlam | 0:b4ccb530b9eb | 42 | void end(); | 
| nickludlam | 0:b4ccb530b9eb | 43 | using BERGCloudBase::display; | 
| nickludlam | 0:b4ccb530b9eb | 44 | /* Methods using std::string class */ | 
| nickludlam | 0:b4ccb530b9eb | 45 | bool display(std::string& s); | 
| nickludlam | 0:b4ccb530b9eb | 46 | private: | 
| nickludlam | 0:b4ccb530b9eb | 47 | uint16_t SPITransaction(uint8_t *dataOut, uint8_t *dataIn, uint16_t dataSize, bool finalCS); | 
| nickludlam | 0:b4ccb530b9eb | 48 | void timerReset(void); | 
| nickludlam | 0:b4ccb530b9eb | 49 | uint32_t timerRead_mS(void); | 
| nickludlam | 0:b4ccb530b9eb | 50 | uint16_t getHostType(void); | 
| nickludlam | 0:b4ccb530b9eb | 51 | SPI *spi; | 
| nickludlam | 0:b4ccb530b9eb | 52 | DigitalOut *nSSELPin; | 
| nickludlam | 0:b4ccb530b9eb | 53 | Timer *timer; | 
| nickludlam | 0:b4ccb530b9eb | 54 | }; | 
| nickludlam | 0:b4ccb530b9eb | 55 | |
| nickludlam | 0:b4ccb530b9eb | 56 | #ifdef BERGCLOUD_PACK_UNPACK | 
| nickludlam | 0:b4ccb530b9eb | 57 | |
| nickludlam | 0:b4ccb530b9eb | 58 | class BERGCloudMessage : public BERGCloudMessageBase | 
| nickludlam | 0:b4ccb530b9eb | 59 | { | 
| nickludlam | 0:b4ccb530b9eb | 60 | public: | 
| nickludlam | 0:b4ccb530b9eb | 61 | using BERGCloudMessageBase::pack; | 
| nickludlam | 0:b4ccb530b9eb | 62 | using BERGCloudMessageBase::unpack; | 
| nickludlam | 0:b4ccb530b9eb | 63 | /* Methods using std::string class */ | 
| nickludlam | 0:b4ccb530b9eb | 64 | bool pack(std::string& s); | 
| nickludlam | 0:b4ccb530b9eb | 65 | bool unpack(std::string& s); | 
| nickludlam | 0:b4ccb530b9eb | 66 | }; | 
| nickludlam | 0:b4ccb530b9eb | 67 | |
| nickludlam | 0:b4ccb530b9eb | 68 | #endif // #ifdef BERGCLOUD_PACK_UNPACK | 
| nickludlam | 0:b4ccb530b9eb | 69 | |
| nickludlam | 0:b4ccb530b9eb | 70 | #endif // #ifndef BERGCLOUDMBED_H | 
| nickludlam | 0:b4ccb530b9eb | 71 | 

