Dependencies:   MMA7660 LM75B

Committer:
MACRUM
Date:
Sat Jun 30 01:40:30 2018 +0000
Revision:
0:119624335925
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:119624335925 1 /*
MACRUM 0:119624335925 2 * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
MACRUM 0:119624335925 3 * SPDX-License-Identifier: Apache-2.0
MACRUM 0:119624335925 4 * Licensed under the Apache License, Version 2.0 (the License); you may
MACRUM 0:119624335925 5 * not use this file except in compliance with the License.
MACRUM 0:119624335925 6 * You may obtain a copy of the License at
MACRUM 0:119624335925 7 *
MACRUM 0:119624335925 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 0:119624335925 9 *
MACRUM 0:119624335925 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 0:119624335925 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
MACRUM 0:119624335925 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 0:119624335925 13 * See the License for the specific language governing permissions and
MACRUM 0:119624335925 14 * limitations under the License.
MACRUM 0:119624335925 15 */
MACRUM 0:119624335925 16 #ifndef AT24MAC_H
MACRUM 0:119624335925 17 #define AT24MAC_H
MACRUM 0:119624335925 18
MACRUM 0:119624335925 19 #include "PinNames.h"
MACRUM 0:119624335925 20 #include "I2C.h"
MACRUM 0:119624335925 21 #include "drivers/DigitalInOut.h"
MACRUM 0:119624335925 22 #include "platform/mbed_wait_api.h"
MACRUM 0:119624335925 23
MACRUM 0:119624335925 24 /*
MACRUM 0:119624335925 25 * AT24MAC drivers.
MACRUM 0:119624335925 26 *
MACRUM 0:119624335925 27 * This is a EEPROM chip designed to contain factory programmed read-only EUI-64 or EUI-48,
MACRUM 0:119624335925 28 * a 128bit serial number and some user programmable EEPROM.
MACRUM 0:119624335925 29 *
MACRUM 0:119624335925 30 * AT24MAC602 contains EUI-64, use read_eui64()
MACRUM 0:119624335925 31 * AT24MAC402 contains EUI-64, use read_eui48()
MACRUM 0:119624335925 32 *
MACRUM 0:119624335925 33 * NOTE: You cannot use both EUI-64 and EUI-48. Chip contains only one of those.
MACRUM 0:119624335925 34 */
MACRUM 0:119624335925 35
MACRUM 0:119624335925 36 class AT24Mac {
MACRUM 0:119624335925 37 public:
MACRUM 0:119624335925 38 AT24Mac(PinName sda, PinName scl);
MACRUM 0:119624335925 39
MACRUM 0:119624335925 40 /**
MACRUM 0:119624335925 41 * Read unique serial number from chip.
MACRUM 0:119624335925 42 * \param buf pointer to write serial number to. Must have space for 16 bytes.
MACRUM 0:119624335925 43 * \return zero on success, negative number on failure
MACRUM 0:119624335925 44 */
MACRUM 0:119624335925 45 int read_serial(void *buf);
MACRUM 0:119624335925 46
MACRUM 0:119624335925 47 /**
MACRUM 0:119624335925 48 * Read EUI-64 from chip.
MACRUM 0:119624335925 49 * \param buf pointer to write EUI-64 to. Must have space for 8 bytes.
MACRUM 0:119624335925 50 * \return zero on success, negative number on failure
MACRUM 0:119624335925 51 */
MACRUM 0:119624335925 52 int read_eui64(void *buf);
MACRUM 0:119624335925 53
MACRUM 0:119624335925 54 /**
MACRUM 0:119624335925 55 * Read EUI-48 from chip.
MACRUM 0:119624335925 56 * \param buf pointer to write EUI-48 to. Must have space for 6 bytes.
MACRUM 0:119624335925 57 * \return zero on success, negative number on failure
MACRUM 0:119624335925 58 */
MACRUM 0:119624335925 59 int read_eui48(void *buf);
MACRUM 0:119624335925 60
MACRUM 0:119624335925 61 private:
MACRUM 0:119624335925 62 /*
MACRUM 0:119624335925 63 * Dummy class to allow us to reset I2C before the I2C constructor is called in
MACRUM 0:119624335925 64 * the initializer list of AT24Mac's constructor
MACRUM 0:119624335925 65 */
MACRUM 0:119624335925 66 class I2CReset {
MACRUM 0:119624335925 67 public:
MACRUM 0:119624335925 68 I2CReset(PinName sda, PinName scl);
MACRUM 0:119624335925 69 };
MACRUM 0:119624335925 70 I2CReset i2c_reset;
MACRUM 0:119624335925 71 mbed::I2C _i2c;
MACRUM 0:119624335925 72 };
MACRUM 0:119624335925 73
MACRUM 0:119624335925 74 #endif /* AT24MAC_H */