Fork of my original MQTTGateway
easy-connect/atmel-rf-driver/atmel-rf-driver/NanostackRfPhyAtmel.h@0:a1734fe1ec4b, 2017-04-08 (annotated)
- Committer:
- vpcola
- Date:
- Sat Apr 08 14:43:14 2017 +0000
- Revision:
- 0:a1734fe1ec4b
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| vpcola | 0:a1734fe1ec4b | 1 | /* |
| vpcola | 0:a1734fe1ec4b | 2 | * Copyright (c) 2014-2015 ARM Limited. All rights reserved. |
| vpcola | 0:a1734fe1ec4b | 3 | * SPDX-License-Identifier: Apache-2.0 |
| vpcola | 0:a1734fe1ec4b | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| vpcola | 0:a1734fe1ec4b | 5 | * not use this file except in compliance with the License. |
| vpcola | 0:a1734fe1ec4b | 6 | * You may obtain a copy of the License at |
| vpcola | 0:a1734fe1ec4b | 7 | * |
| vpcola | 0:a1734fe1ec4b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| vpcola | 0:a1734fe1ec4b | 9 | * |
| vpcola | 0:a1734fe1ec4b | 10 | * Unless required by applicable law or agreed to in writing, software |
| vpcola | 0:a1734fe1ec4b | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| vpcola | 0:a1734fe1ec4b | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| vpcola | 0:a1734fe1ec4b | 13 | * See the License for the specific language governing permissions and |
| vpcola | 0:a1734fe1ec4b | 14 | * limitations under the License. |
| vpcola | 0:a1734fe1ec4b | 15 | */ |
| vpcola | 0:a1734fe1ec4b | 16 | |
| vpcola | 0:a1734fe1ec4b | 17 | #ifndef NANOSTACK_RF_PHY_ATMEL_H_ |
| vpcola | 0:a1734fe1ec4b | 18 | #define NANOSTACK_RF_PHY_ATMEL_H_ |
| vpcola | 0:a1734fe1ec4b | 19 | |
| vpcola | 0:a1734fe1ec4b | 20 | #include "NanostackRfPhy.h" |
| vpcola | 0:a1734fe1ec4b | 21 | #include "at24mac.h" |
| vpcola | 0:a1734fe1ec4b | 22 | #include "PinNames.h" |
| vpcola | 0:a1734fe1ec4b | 23 | |
| vpcola | 0:a1734fe1ec4b | 24 | // Arduino pin defaults for convenience |
| vpcola | 0:a1734fe1ec4b | 25 | #if !defined(ATMEL_SPI_MOSI) |
| vpcola | 0:a1734fe1ec4b | 26 | #define ATMEL_SPI_MOSI D11 |
| vpcola | 0:a1734fe1ec4b | 27 | #endif |
| vpcola | 0:a1734fe1ec4b | 28 | #if !defined(ATMEL_SPI_MISO) |
| vpcola | 0:a1734fe1ec4b | 29 | #define ATMEL_SPI_MISO D12 |
| vpcola | 0:a1734fe1ec4b | 30 | #endif |
| vpcola | 0:a1734fe1ec4b | 31 | #if !defined(ATMEL_SPI_SCLK) |
| vpcola | 0:a1734fe1ec4b | 32 | #define ATMEL_SPI_SCLK D13 |
| vpcola | 0:a1734fe1ec4b | 33 | #endif |
| vpcola | 0:a1734fe1ec4b | 34 | #if !defined(ATMEL_SPI_CS) |
| vpcola | 0:a1734fe1ec4b | 35 | #define ATMEL_SPI_CS D10 |
| vpcola | 0:a1734fe1ec4b | 36 | #endif |
| vpcola | 0:a1734fe1ec4b | 37 | #if !defined(ATMEL_SPI_RST) |
| vpcola | 0:a1734fe1ec4b | 38 | #define ATMEL_SPI_RST D5 |
| vpcola | 0:a1734fe1ec4b | 39 | #endif |
| vpcola | 0:a1734fe1ec4b | 40 | #if !defined(ATMEL_SPI_SLP) |
| vpcola | 0:a1734fe1ec4b | 41 | #define ATMEL_SPI_SLP D7 |
| vpcola | 0:a1734fe1ec4b | 42 | #endif |
| vpcola | 0:a1734fe1ec4b | 43 | #if !defined(ATMEL_SPI_IRQ) |
| vpcola | 0:a1734fe1ec4b | 44 | #define ATMEL_SPI_IRQ D9 |
| vpcola | 0:a1734fe1ec4b | 45 | #endif |
| vpcola | 0:a1734fe1ec4b | 46 | #if !defined(ATMEL_I2C_SDA) |
| vpcola | 0:a1734fe1ec4b | 47 | #define ATMEL_I2C_SDA D14 |
| vpcola | 0:a1734fe1ec4b | 48 | #endif |
| vpcola | 0:a1734fe1ec4b | 49 | #if !defined(ATMEL_I2C_SCL) |
| vpcola | 0:a1734fe1ec4b | 50 | #define ATMEL_I2C_SCL D15 |
| vpcola | 0:a1734fe1ec4b | 51 | #endif |
| vpcola | 0:a1734fe1ec4b | 52 | |
| vpcola | 0:a1734fe1ec4b | 53 | class RFBits; |
| vpcola | 0:a1734fe1ec4b | 54 | |
| vpcola | 0:a1734fe1ec4b | 55 | class NanostackRfPhyAtmel : public NanostackRfPhy { |
| vpcola | 0:a1734fe1ec4b | 56 | public: |
| vpcola | 0:a1734fe1ec4b | 57 | NanostackRfPhyAtmel(PinName spi_mosi, PinName spi_miso, |
| vpcola | 0:a1734fe1ec4b | 58 | PinName spi_sclk, PinName spi_cs, PinName spi_rst, PinName spi_slp, PinName spi_irq, |
| vpcola | 0:a1734fe1ec4b | 59 | PinName i2c_sda, PinName i2c_scl); |
| vpcola | 0:a1734fe1ec4b | 60 | ~NanostackRfPhyAtmel(); |
| vpcola | 0:a1734fe1ec4b | 61 | int8_t rf_register(); |
| vpcola | 0:a1734fe1ec4b | 62 | void rf_unregister(); |
| vpcola | 0:a1734fe1ec4b | 63 | void get_mac_address(uint8_t *mac); |
| vpcola | 0:a1734fe1ec4b | 64 | void set_mac_address(uint8_t *mac); |
| vpcola | 0:a1734fe1ec4b | 65 | |
| vpcola | 0:a1734fe1ec4b | 66 | private: |
| vpcola | 0:a1734fe1ec4b | 67 | AT24Mac _mac; |
| vpcola | 0:a1734fe1ec4b | 68 | uint8_t _mac_addr[8]; |
| vpcola | 0:a1734fe1ec4b | 69 | RFBits *_rf; |
| vpcola | 0:a1734fe1ec4b | 70 | bool _mac_set; |
| vpcola | 0:a1734fe1ec4b | 71 | |
| vpcola | 0:a1734fe1ec4b | 72 | const PinName _spi_mosi; |
| vpcola | 0:a1734fe1ec4b | 73 | const PinName _spi_miso; |
| vpcola | 0:a1734fe1ec4b | 74 | const PinName _spi_sclk; |
| vpcola | 0:a1734fe1ec4b | 75 | const PinName _spi_cs; |
| vpcola | 0:a1734fe1ec4b | 76 | const PinName _spi_rst; |
| vpcola | 0:a1734fe1ec4b | 77 | const PinName _spi_slp; |
| vpcola | 0:a1734fe1ec4b | 78 | const PinName _spi_irq; |
| vpcola | 0:a1734fe1ec4b | 79 | }; |
| vpcola | 0:a1734fe1ec4b | 80 | |
| vpcola | 0:a1734fe1ec4b | 81 | #endif /* NANOSTACK_RF_PHY_ATMEL_H_ */ |