Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NanostackRfPhys2lp.h Source File

NanostackRfPhys2lp.h

00001 /*
00002  * Copyright (c) 2018 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_S2LP_H_
00018 #define NANOSTACK_PHY_S2LP_H_
00019 
00020 #if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI  && defined(MBED_CONF_RTOS_PRESENT)
00021 #include "inttypes.h"
00022 #include "NanostackRfPhy.h"
00023 #include "DigitalIn.h"
00024 #include "DigitalOut.h"
00025 #include "InterruptIn.h"
00026 #include "SPI.h"
00027 
00028 // Uncomment to use testing gpios attached to TX/RX processes
00029 //#define TEST_GPIOS_ENABLED
00030 
00031 #if defined(TARGET_MTB_STM_S2LP)
00032 #if !defined(S2LP_SPI_SDI)
00033 #define S2LP_SPI_SDI   PA_7
00034 #endif
00035 #if !defined(S2LP_SPI_SDO)
00036 #define S2LP_SPI_SDO   PA_6
00037 #endif
00038 #if !defined(S2LP_SPI_SCLK)
00039 #define S2LP_SPI_SCLK   PA_5
00040 #endif
00041 #if !defined(S2LP_SPI_CS)
00042 #define S2LP_SPI_CS     PC_0
00043 #endif
00044 #if !defined(S2LP_SPI_SDN)
00045 #define S2LP_SPI_SDN    PF_13
00046 #endif
00047 #if !defined(S2LP_SPI_GPIO0)
00048 #define S2LP_SPI_GPIO0    PA_3
00049 #endif
00050 #if !defined(S2LP_SPI_GPIO1)
00051 #define S2LP_SPI_GPIO1    PC_3
00052 #endif
00053 #if !defined(S2LP_SPI_GPIO2)
00054 #define S2LP_SPI_GPIO2    PF_3
00055 #endif
00056 #if !defined(S2LP_SPI_GPIO3)
00057 #define S2LP_SPI_GPIO3    PF_10
00058 #endif
00059 #if !defined(S2LP_I2C_SDA)
00060 #define S2LP_I2C_SDA    PB_7
00061 #endif
00062 #if !defined(S2LP_I2C_SCL)
00063 #define S2LP_I2C_SCL    PB_6
00064 #endif
00065 #define AT24MAC
00066 #else
00067 #if !defined(S2LP_SPI_SDI)
00068 #define S2LP_SPI_SDI   D11
00069 #endif
00070 #if !defined(S2LP_SPI_SDO)
00071 #define S2LP_SPI_SDO   D12
00072 #endif
00073 #if !defined(S2LP_SPI_SCLK)
00074 #define S2LP_SPI_SCLK   D13
00075 #endif
00076 #if !defined(S2LP_SPI_CS)
00077 #define S2LP_SPI_CS     A1
00078 #endif
00079 #if !defined(S2LP_SPI_SDN)
00080 #define S2LP_SPI_SDN    D7
00081 #endif
00082 #if !defined(S2LP_SPI_TEST1)
00083 #define S2LP_SPI_TEST1    D6
00084 #endif
00085 #if !defined(S2LP_SPI_TEST2)
00086 #define S2LP_SPI_TEST2    D5
00087 #endif
00088 #if !defined(S2LP_SPI_TEST3)
00089 #define S2LP_SPI_TEST3    D4
00090 #endif
00091 #if !defined(S2LP_SPI_TEST4)
00092 #define S2LP_SPI_TEST4    D2
00093 #endif
00094 #if !defined(S2LP_SPI_TEST5)
00095 #define S2LP_SPI_TEST5    D8
00096 #endif
00097 #if !defined(S2LP_SPI_GPIO0)
00098 #define S2LP_SPI_GPIO0    A0
00099 #endif
00100 #if !defined(S2LP_SPI_GPIO1)
00101 #define S2LP_SPI_GPIO1    A2
00102 #endif
00103 #if !defined(S2LP_SPI_GPIO2)
00104 #define S2LP_SPI_GPIO2    A3
00105 #endif
00106 #if !defined(S2LP_SPI_GPIO3)
00107 #define S2LP_SPI_GPIO3    A5
00108 #endif
00109 #endif
00110 
00111 #include "at24mac_s2lp.h"
00112 
00113 class RFPins;
00114 
00115 class NanostackRfPhys2lp : public NanostackRfPhy {
00116 public:
00117     NanostackRfPhys2lp(PinName spi_sdi, PinName spi_sdo, PinName spi_sclk, PinName spi_cs, PinName spi_sdn
00118 #ifdef TEST_GPIOS_ENABLED
00119                        ,PinName spi_test1, PinName spi_test2, PinName spi_test3, PinName spi_test4, PinName spi_test5
00120 #endif //TEST_GPIOS_ENABLED
00121                        ,PinName spi_gpio0, PinName spi_gpio1, PinName spi_gpio2, PinName spi_gpio3
00122 #ifdef AT24MAC
00123                        ,PinName i2c_sda, PinName i2c_scl
00124 #endif //AT24MAC
00125                        );
00126     virtual ~NanostackRfPhys2lp();
00127     virtual int8_t rf_register();
00128     virtual void rf_unregister();
00129     virtual void get_mac_address(uint8_t *mac);
00130     virtual void set_mac_address(uint8_t *mac);
00131 
00132 private:
00133 #ifdef AT24MAC
00134     AT24Mac_s2lp _mac;
00135 #endif //AT24MAC
00136     uint8_t _mac_addr[8];
00137     RFPins *_rf;
00138     bool _mac_set;
00139 
00140     const PinName _spi_sdi;
00141     const PinName _spi_sdo;
00142     const PinName _spi_sclk;
00143     const PinName _spi_cs;
00144     const PinName _spi_sdn;
00145 #ifdef TEST_GPIOS_ENABLED
00146     const PinName _spi_test1;
00147     const PinName _spi_test2;
00148     const PinName _spi_test3;
00149     const PinName _spi_test4;
00150     const PinName _spi_test5;
00151 #endif //TEST_GPIOS_ENABLED
00152     const PinName _spi_gpio0;
00153     const PinName _spi_gpio1;
00154     const PinName _spi_gpio2;
00155     const PinName _spi_gpio3;
00156 };
00157 #endif /* MBED_CONF_NANOSTACK_CONFIGURATION && DEVICE_SPI */
00158 #endif /* NANOSTACK_PHY_S2LP_H_ */