Easily add all supported connectivity methods to your mbed OS project

Dependencies:   type-yd-driver

Committer:
MACRUM
Date:
Wed Jul 12 10:52:58 2017 +0000
Revision:
0:615f90842ce8
Initial commit

Who changed what in which revision?

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