my customized lib

Committer:
DuyLionTran
Date:
Sun Nov 26 15:08:14 2017 +0000
Revision:
0:8094b249013c
Initial commit

Who changed what in which revision?

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