Skeleton program for Federico's 4YP project.

Dependencies:   WebSocketClient WiflyInterface mbed messages

Fork of IoT_Ex by Damien Frost

Committer:
defrost
Date:
Tue Nov 29 15:02:01 2016 +0000
Revision:
10:e8b66718a103
Parent:
6:424e225d2a91
- Works

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 6:424e225d2a91 1 /**
defrost 6:424e225d2a91 2 * @author Damien Frost
defrost 6:424e225d2a91 3 *
defrost 6:424e225d2a91 4 * @section LICENSE
defrost 6:424e225d2a91 5 *
defrost 6:424e225d2a91 6 * Copyright (c) 2016 Damien Frost
defrost 6:424e225d2a91 7 *
defrost 6:424e225d2a91 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
defrost 6:424e225d2a91 9 * of this software and associated documentation files (the "Software"), to deal
defrost 6:424e225d2a91 10 * in the Software without restriction, including without limitation the rights
defrost 6:424e225d2a91 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
defrost 6:424e225d2a91 12 * copies of the Software, and to permit persons to whom the Software is
defrost 6:424e225d2a91 13 * furnished to do so, subject to the following conditions:
defrost 6:424e225d2a91 14 *
defrost 6:424e225d2a91 15 * The above copyright notice and this permission notice shall be included in
defrost 6:424e225d2a91 16 * all copies or substantial portions of the Software.
defrost 6:424e225d2a91 17 *
defrost 6:424e225d2a91 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
defrost 6:424e225d2a91 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
defrost 6:424e225d2a91 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
defrost 6:424e225d2a91 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
defrost 6:424e225d2a91 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
defrost 6:424e225d2a91 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
defrost 6:424e225d2a91 24 * THE SOFTWARE.
defrost 6:424e225d2a91 25 *
defrost 6:424e225d2a91 26 * @file "StatusRep.cpp"
defrost 6:424e225d2a91 27 *
defrost 6:424e225d2a91 28 * @section DESCRIPTION
defrost 6:424e225d2a91 29 * StatusReg implementation. A register to hold bit-wise status flags.
defrost 6:424e225d2a91 30 *
defrost 6:424e225d2a91 31 */
defrost 0:c5607b31fb07 32
defrost 0:c5607b31fb07 33
defrost 0:c5607b31fb07 34 #include "StatusReg.h"
defrost 0:c5607b31fb07 35
defrost 0:c5607b31fb07 36 StatusReg::StatusReg()
defrost 0:c5607b31fb07 37 {
defrost 0:c5607b31fb07 38 _reg = 0;
defrost 0:c5607b31fb07 39 return;
defrost 0:c5607b31fb07 40 }
defrost 0:c5607b31fb07 41
defrost 0:c5607b31fb07 42 // Set a flag:
defrost 0:c5607b31fb07 43 void StatusReg::SetFlag(unsigned int flag){
defrost 0:c5607b31fb07 44 _reg |= flag;
defrost 0:c5607b31fb07 45 return;
defrost 0:c5607b31fb07 46 }
defrost 0:c5607b31fb07 47
defrost 0:c5607b31fb07 48 // Clear a flag:
defrost 0:c5607b31fb07 49 void StatusReg::ClearFlag(unsigned int flag){
defrost 0:c5607b31fb07 50 _reg &= (~flag);
defrost 0:c5607b31fb07 51 return;
defrost 0:c5607b31fb07 52 }
defrost 0:c5607b31fb07 53
defrost 0:c5607b31fb07 54 // Check for flag
defrost 0:c5607b31fb07 55 bool StatusReg::CheckFlag(unsigned int flag){
defrost 0:c5607b31fb07 56 if((_reg & flag) > 0){
defrost 0:c5607b31fb07 57 return true;
defrost 0:c5607b31fb07 58 }else{
defrost 0:c5607b31fb07 59 return false;
defrost 0:c5607b31fb07 60 }
defrost 0:c5607b31fb07 61 }
defrost 0:c5607b31fb07 62
defrost 0:c5607b31fb07 63 // Check for no flags
defrost 0:c5607b31fb07 64 bool StatusReg::AllClear(void){
defrost 0:c5607b31fb07 65 if(_reg == 0){
defrost 0:c5607b31fb07 66 return true;
defrost 0:c5607b31fb07 67 }else{
defrost 0:c5607b31fb07 68 return false;
defrost 0:c5607b31fb07 69 }
defrost 0:c5607b31fb07 70 }
defrost 0:c5607b31fb07 71
defrost 0:c5607b31fb07 72 unsigned int StatusReg::GetReg(void){
defrost 0:c5607b31fb07 73 return _reg;
defrost 0:c5607b31fb07 74 }