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