takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NanostackRfPhyMcr20a.h Source File

NanostackRfPhyMcr20a.h

00001 /*
00002  * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef NANOSTACK_PHY_MCR20A_H_
00018 #define NANOSTACK_PHY_MCR20A_H_
00019 
00020 #include "mbed.h"
00021 
00022 #if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI
00023 
00024 #include "NanostackRfPhy.h"
00025 
00026 // Arduino pin defaults for convenience
00027 #if !defined(MCR20A_SPI_MOSI)
00028 #define MCR20A_SPI_MOSI   D11
00029 #endif
00030 #if !defined(MCR20A_SPI_MISO)
00031 #define MCR20A_SPI_MISO   D12
00032 #endif
00033 #if !defined(MCR20A_SPI_SCLK)
00034 #define MCR20A_SPI_SCLK   D13
00035 #endif
00036 #if !defined(MCR20A_SPI_CS)
00037 #define MCR20A_SPI_CS     D10
00038 #endif
00039 #if !defined(MCR20A_SPI_RST)
00040 #define MCR20A_SPI_RST    D5
00041 #endif
00042 #if !defined(MCR20A_SPI_IRQ)
00043 #define MCR20A_SPI_IRQ    D2
00044 #endif
00045 
00046 class NanostackRfPhyMcr20a : public NanostackRfPhy {
00047 public:
00048     NanostackRfPhyMcr20a(PinName spi_mosi, PinName spi_miso,
00049                          PinName spi_sclk, PinName spi_cs,  PinName spi_rst,
00050                          PinName spi_irq);
00051     virtual ~NanostackRfPhyMcr20a();
00052     virtual int8_t rf_register();
00053     virtual void rf_unregister();
00054     virtual void get_mac_address(uint8_t *mac);
00055     virtual void set_mac_address(uint8_t *mac);
00056 
00057 private:
00058     SPI _spi;
00059     DigitalOut _rf_cs;
00060     DigitalOut _rf_rst;
00061     InterruptIn _rf_irq;
00062     DigitalIn _rf_irq_pin;
00063     Thread _irq_thread;
00064 
00065     void _pins_set();
00066     void _pins_clear();
00067 };
00068 
00069 #endif /* MBED_CONF_NANOSTACK_CONFIGURATION */
00070 #endif /* NANOSTACK_PHY_MCR20A_H_ */