mbed library sources, with proposed I2C for Seed Arch BLE - not working -

Dependents:   Seeed_Barometer_Sensor_Example

Fork of mbed-src by mbed official

Committer:
emilmont
Date:
Mon Feb 18 11:44:18 2013 +0000
Revision:
2:143cac498751
Update mbed sources to Rev 59

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 2:143cac498751 1 /* mbed Microcontroller Library
emilmont 2:143cac498751 2 * Copyright (c) 2006-2013 ARM Limited
emilmont 2:143cac498751 3 *
emilmont 2:143cac498751 4 * Licensed under the Apache License, Version 2.0 (the "License");
emilmont 2:143cac498751 5 * you may not use this file except in compliance with the License.
emilmont 2:143cac498751 6 * You may obtain a copy of the License at
emilmont 2:143cac498751 7 *
emilmont 2:143cac498751 8 * http://www.apache.org/licenses/LICENSE-2.0
emilmont 2:143cac498751 9 *
emilmont 2:143cac498751 10 * Unless required by applicable law or agreed to in writing, software
emilmont 2:143cac498751 11 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 2:143cac498751 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 2:143cac498751 13 * See the License for the specific language governing permissions and
emilmont 2:143cac498751 14 * limitations under the License.
emilmont 2:143cac498751 15 */
emilmont 2:143cac498751 16 #include "FileBase.h"
emilmont 2:143cac498751 17
emilmont 2:143cac498751 18 namespace mbed {
emilmont 2:143cac498751 19
emilmont 2:143cac498751 20 FileBase *FileBase::_head = NULL;
emilmont 2:143cac498751 21
emilmont 2:143cac498751 22 FileBase::FileBase(const char *name, PathType t) {
emilmont 2:143cac498751 23 _name = name;
emilmont 2:143cac498751 24 _path_type = t;
emilmont 2:143cac498751 25
emilmont 2:143cac498751 26 if (name != NULL) {
emilmont 2:143cac498751 27 // put this object at head of the list
emilmont 2:143cac498751 28 _next = _head;
emilmont 2:143cac498751 29 _head = this;
emilmont 2:143cac498751 30 } else {
emilmont 2:143cac498751 31 _next = NULL;
emilmont 2:143cac498751 32 }
emilmont 2:143cac498751 33 }
emilmont 2:143cac498751 34
emilmont 2:143cac498751 35 FileBase::~FileBase() {
emilmont 2:143cac498751 36 if (_name != NULL) {
emilmont 2:143cac498751 37 // remove this object from the list
emilmont 2:143cac498751 38 if (_head == this) { // first in the list, so just drop me
emilmont 2:143cac498751 39 _head = _next;
emilmont 2:143cac498751 40 } else { // find the object before me, then drop me
emilmont 2:143cac498751 41 FileBase *p = _head;
emilmont 2:143cac498751 42 while (p->_next != this) {
emilmont 2:143cac498751 43 p = p->_next;
emilmont 2:143cac498751 44 }
emilmont 2:143cac498751 45 p->_next = _next;
emilmont 2:143cac498751 46 }
emilmont 2:143cac498751 47 }
emilmont 2:143cac498751 48 }
emilmont 2:143cac498751 49
emilmont 2:143cac498751 50 FileBase *FileBase::lookup(const char *name, unsigned int len) {
emilmont 2:143cac498751 51 FileBase *p = _head;
emilmont 2:143cac498751 52 while (p != NULL) {
emilmont 2:143cac498751 53 /* Check that p->_name matches name and is the correct length */
emilmont 2:143cac498751 54 if (p->_name != NULL && std::strncmp(p->_name, name, len) == 0 && std::strlen(p->_name) == len) {
emilmont 2:143cac498751 55 return p;
emilmont 2:143cac498751 56 }
emilmont 2:143cac498751 57 p = p->_next;
emilmont 2:143cac498751 58 }
emilmont 2:143cac498751 59 return NULL;
emilmont 2:143cac498751 60 }
emilmont 2:143cac498751 61
emilmont 2:143cac498751 62 FileBase *FileBase::get(int n) {
emilmont 2:143cac498751 63 FileBase *p = _head;
emilmont 2:143cac498751 64 int m = 0;
emilmont 2:143cac498751 65 while (p != NULL) {
emilmont 2:143cac498751 66 if (m == n) return p;
emilmont 2:143cac498751 67
emilmont 2:143cac498751 68 m++;
emilmont 2:143cac498751 69 p = p->_next;
emilmont 2:143cac498751 70 }
emilmont 2:143cac498751 71 return NULL;
emilmont 2:143cac498751 72 }
emilmont 2:143cac498751 73
emilmont 2:143cac498751 74 const char* FileBase::getName(void) {
emilmont 2:143cac498751 75 return _name;
emilmont 2:143cac498751 76 }
emilmont 2:143cac498751 77
emilmont 2:143cac498751 78 PathType FileBase::getPathType(void) {
emilmont 2:143cac498751 79 return _path_type;
emilmont 2:143cac498751 80 }
emilmont 2:143cac498751 81
emilmont 2:143cac498751 82 } // namespace mbed
emilmont 2:143cac498751 83