JunMo Hong / Mbed 2 deprecated cubebite_rnd_SPSGRFC433

Dependencies:   mbed

Fork of HelloWorld_IDS01A4 by ST

Committer:
jmhong
Date:
Tue Jan 09 01:58:33 2018 +0000
Revision:
10:cc81b87e005e
Parent:
5:a65ed26b0f98
Child:
11:f8396aa48de6
SPSGRFC433 Module P2P tx/rx

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rosarium 0:2ddc0583bcec 1 /**
rosarium 0:2ddc0583bcec 2 ******************************************************************************
rosarium 0:2ddc0583bcec 3 * @file main.cpp
rosarium 0:2ddc0583bcec 4 * @author Rosarium PILA, STMicroelectronics
rosarium 0:2ddc0583bcec 5 * @version V1.0.0
rosarium 3:29bbb772ee62 6 * @date June 19th, 2017
rosarium 4:cae1fa054b86 7 * @brief mbed test application for the STMicroelectronics X-NUCLEO-IDB01A4/5
rosarium 0:2ddc0583bcec 8 * Spirit1 Expansion Board
rosarium 0:2ddc0583bcec 9 ******************************************************************************
rosarium 0:2ddc0583bcec 10 * @attention
rosarium 0:2ddc0583bcec 11 *
rosarium 0:2ddc0583bcec 12 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
rosarium 0:2ddc0583bcec 13 *
rosarium 0:2ddc0583bcec 14 * Redistribution and use in source and binary forms, with or without modification,
rosarium 0:2ddc0583bcec 15 * are permitted provided that the following conditions are met:
rosarium 0:2ddc0583bcec 16 * 1. Redistributions of source code must retain the above copyright notice,
rosarium 0:2ddc0583bcec 17 * this list of conditions and the following disclaimer.
rosarium 0:2ddc0583bcec 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
rosarium 0:2ddc0583bcec 19 * this list of conditions and the following disclaimer in the documentation
rosarium 0:2ddc0583bcec 20 * and/or other materials provided with the distribution.
rosarium 0:2ddc0583bcec 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
rosarium 0:2ddc0583bcec 22 * may be used to endorse or promote products derived from this software
rosarium 0:2ddc0583bcec 23 * without specific prior written permission.
rosarium 0:2ddc0583bcec 24 *
rosarium 0:2ddc0583bcec 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
rosarium 0:2ddc0583bcec 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
rosarium 0:2ddc0583bcec 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rosarium 0:2ddc0583bcec 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
rosarium 0:2ddc0583bcec 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
rosarium 0:2ddc0583bcec 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
rosarium 0:2ddc0583bcec 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
rosarium 0:2ddc0583bcec 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
rosarium 0:2ddc0583bcec 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
rosarium 0:2ddc0583bcec 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rosarium 0:2ddc0583bcec 35 *
rosarium 0:2ddc0583bcec 36 ******************************************************************************
rosarium 0:2ddc0583bcec 37 */
rosarium 0:2ddc0583bcec 38
rosarium 0:2ddc0583bcec 39 #include "mbed.h"
rosarium 0:2ddc0583bcec 40 #include "SimpleSpirit1.h"
rosarium 0:2ddc0583bcec 41
jmhong 10:cc81b87e005e 42 /* 180108 cubebite HJM : SimpleSpirit1 Debug define */
jmhong 10:cc81b87e005e 43 #define NDEBUG
jmhong 10:cc81b87e005e 44 #define HEAVY_DEBUG
jmhong 10:cc81b87e005e 45
jmhong 10:cc81b87e005e 46
jmhong 10:cc81b87e005e 47 /* 180108 cubebite HJM : cubebite Debug define */
jmhong 10:cc81b87e005e 48 #define CUBEBITE_DEBUG
jmhong 10:cc81b87e005e 49
jmhong 10:cc81b87e005e 50
jmhong 10:cc81b87e005e 51 /* 180108 cubebite HJM : cubebite Testing define */
jmhong 10:cc81b87e005e 52 //#define CUBEBITE_TEST
jmhong 10:cc81b87e005e 53 //#define CUBEBITE_RF_DEVICE_PARTNUMBER_TEST
jmhong 10:cc81b87e005e 54 //#define CUBEBITE_RF_GPIO_0_TEST
jmhong 10:cc81b87e005e 55
jmhong 10:cc81b87e005e 56
jmhong 10:cc81b87e005e 57 /* 180109 cubebite HJM : cubebite Compile define */
jmhong 10:cc81b87e005e 58 //#define CUBEBITE_BOARD_F746ZG
jmhong 10:cc81b87e005e 59 #define CUBEBITE_BOARD_F401RE
jmhong 10:cc81b87e005e 60
jmhong 10:cc81b87e005e 61
jmhong 10:cc81b87e005e 62 /* 180108 cubebite HJM : send testing, orignal code */
rosarium 1:cf2e2f85bf8d 63 #define TEST_STR_LEN (32)
rosarium 0:2ddc0583bcec 64 static uint8_t send_buf[TEST_STR_LEN] ={'S','P','I','R','I','T','1',' ','H','E','L','L','O',' ','W','O','R','L','D',' ','P','2','P',' ','D','E','M','O'};
rosarium 0:2ddc0583bcec 65 static uint8_t read_buf[TEST_STR_LEN] ={'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
jmhong 10:cc81b87e005e 66
jmhong 10:cc81b87e005e 67 /* 180108 cubebite HJM : send testing, testing code */
jmhong 10:cc81b87e005e 68 //#define TEST_STR_LEN (3)
jmhong 10:cc81b87e005e 69 //static uint8_t send_buf[TEST_STR_LEN] ={'H'};
jmhong 10:cc81b87e005e 70 //static uint8_t read_buf[TEST_STR_LEN] ={'0','0','0'};
jmhong 10:cc81b87e005e 71
jmhong 10:cc81b87e005e 72 /* 180108 cubebite HJM : orignal code, backup */
jmhong 10:cc81b87e005e 73 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(D11, D12, D3, D9, D10, D2); /* (SPI_CLK) = (D13:PA5:resistorR7 --> D3:PB3:resistorR4)*/
jmhong 10:cc81b87e005e 74
jmhong 10:cc81b87e005e 75 #ifdef CUBEBITE_BOARD_F401RE
jmhong 10:cc81b87e005e 76 /* 180108 cubebite HJM : F401re borad, AnalogIn PIN Info, A0(PA_0) A1(PA_1) A2(PA_4) A3(PB_0) A4(PC_1) A5(PC_0) */
jmhong 10:cc81b87e005e 77 /* RF Module 과 상관 관계 => A0(PA_0)[SPI GPIO 3] A1(PA_1)[CSN] A2(PA_4)[SPI1 GPIO 2] A3(PB_0)[SPI1 GPIO 1] A4(PC_1)[SPI1_GPIO 0] */
jmhong 10:cc81b87e005e 78 /* 180108 cubebite HJM : F401re borad Init code */
jmhong 10:cc81b87e005e 79 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PA_7, PA_6, PA_5, PC_7, PB_6, PA_10); //F401re borad
jmhong 10:cc81b87e005e 80 static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PA_7, PA_6, PA_5, PA_0, PB_6, PA_10); //F401re borad, IRQ Testing, GPIO 3 -> IRQ
jmhong 10:cc81b87e005e 81 #endif
jmhong 10:cc81b87e005e 82
jmhong 10:cc81b87e005e 83 #ifdef CUBEBITE_BOARD_F401RE
jmhong 10:cc81b87e005e 84 #ifdef CUBEBITE_RF_GPIO_0_TEST
jmhong 10:cc81b87e005e 85 /* 180108 cubebite HJM : F401re borad, PC_1 == RF_MODULE_GPIO 0, Testing code */
jmhong 10:cc81b87e005e 86 static DigitalIn RF_GPIO_0_INPUT(PC_1); //F401re borad
jmhong 10:cc81b87e005e 87 #endif
jmhong 10:cc81b87e005e 88 #endif
jmhong 10:cc81b87e005e 89 //static DigitalIn RF_GPIO_3_INPUT(PA_0); //F401re borad, 사용시, send 정상 동작 안함, Spirit1 IRQ 핀이랑 같이 물려있기 때문
jmhong 10:cc81b87e005e 90
jmhong 10:cc81b87e005e 91
jmhong 10:cc81b87e005e 92
jmhong 10:cc81b87e005e 93
jmhong 10:cc81b87e005e 94
jmhong 10:cc81b87e005e 95 #ifdef CUBEBITE_BOARD_F746ZG
jmhong 10:cc81b87e005e 96 /* 180108 cubebite HJM : F746zg borad, AnalogIn PIN Info, A0(PA_3) A1(PC_0) A2(PC_3) A3(PF_3) A4(PF_5) A5(PF_10) */
jmhong 10:cc81b87e005e 97 /* RF Module 과 상관 관계 => A0(PA_3)[SPI GPIO 3] A1(PC_0)[CSN] A2(PC_3)[SPI1 GPIO 2] A3(PF_3)[SPI1 GPIO 1] A4(PF_5)[SPI1_GPIO 0] */
jmhong 10:cc81b87e005e 98 /* 180108 cubebite HJM : F746zg borad Init code */
jmhong 10:cc81b87e005e 99 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PB_5, PB_4, PB_3, PD_14, PD_5, PD_6); //F746zg borad
jmhong 10:cc81b87e005e 100 static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PB_5, PB_4, PB_3, PA_3, PD_5, PD_6); //F746zg borad, IRQ Testing, GPIO 3 -> IRQ
jmhong 10:cc81b87e005e 101 #endif
jmhong 10:cc81b87e005e 102
jmhong 10:cc81b87e005e 103 #ifdef CUBEBITE_BOARD_F746ZG
jmhong 10:cc81b87e005e 104 #ifdef CUBEBITE_RF_GPIO_0_TEST
jmhong 10:cc81b87e005e 105 /* 180108 cubebite HJM : F746zg borad, PC_1 == RF_MODULE_GPIO 0, Testing code */
jmhong 10:cc81b87e005e 106 static DigitalIn RF_GPIO_0_INPUT(PF_5); //F746zg borad
jmhong 10:cc81b87e005e 107 #endif
jmhong 10:cc81b87e005e 108 #endif
jmhong 10:cc81b87e005e 109
jmhong 10:cc81b87e005e 110 //static DigitalIn RF_GPIO_3_INPUT(PA_3); //F746zg borad, 사용시, send 정상 동작 안함, Spirit1 IRQ 핀이랑 같이 물려있기 때문
jmhong 10:cc81b87e005e 111
jmhong 10:cc81b87e005e 112
jmhong 10:cc81b87e005e 113
jmhong 10:cc81b87e005e 114
rosarium 0:2ddc0583bcec 115
wobetz 5:a65ed26b0f98 116 static volatile bool rx_done_flag = false;
wobetz 5:a65ed26b0f98 117 static volatile bool tx_done_flag = false;
wobetz 5:a65ed26b0f98 118 static volatile bool send_data_flag = false;
rosarium 0:2ddc0583bcec 119
wobetz 5:a65ed26b0f98 120 static DigitalOut TestLED(D5); /* LED of IDS01A4/5 */
wobetz 5:a65ed26b0f98 121 static InterruptIn event(USER_BUTTON); /* Interrupt event to give userinterface to send pkt. */
rosarium 0:2ddc0583bcec 122
jmhong 10:cc81b87e005e 123
jmhong 10:cc81b87e005e 124
rosarium 1:cf2e2f85bf8d 125 /**
rosarium 1:cf2e2f85bf8d 126 * @brief callback_func
rosarium 1:cf2e2f85bf8d 127 * @param callback event
rosarium 1:cf2e2f85bf8d 128 * @retval None.
rosarium 1:cf2e2f85bf8d 129 */
rosarium 0:2ddc0583bcec 130 static void callback_func(int event)
rosarium 0:2ddc0583bcec 131 {
jmhong 10:cc81b87e005e 132 printf("\r\n***EVENT !!!!!!!!!!!!!***\r\n");
jmhong 10:cc81b87e005e 133
rosarium 1:cf2e2f85bf8d 134 if(event == SimpleSpirit1::RX_DONE)
rosarium 1:cf2e2f85bf8d 135 {
rosarium 1:cf2e2f85bf8d 136 rx_done_flag = 1;
rosarium 1:cf2e2f85bf8d 137 }
rosarium 1:cf2e2f85bf8d 138 else if (event == SimpleSpirit1::TX_DONE)
rosarium 1:cf2e2f85bf8d 139 {
rosarium 1:cf2e2f85bf8d 140 tx_done_flag = 1;
rosarium 1:cf2e2f85bf8d 141 }
rosarium 0:2ddc0583bcec 142 }
rosarium 0:2ddc0583bcec 143
rosarium 4:cae1fa054b86 144 /**
rosarium 4:cae1fa054b86 145 * @brief set_send_data_flag
rosarium 4:cae1fa054b86 146 * @param None
rosarium 4:cae1fa054b86 147 * @retval None
rosarium 4:cae1fa054b86 148 */
wobetz 5:a65ed26b0f98 149 static void set_send_data_flag(void)
rosarium 4:cae1fa054b86 150 {
rosarium 4:cae1fa054b86 151 send_data_flag = 1 ;
rosarium 4:cae1fa054b86 152 }
rosarium 1:cf2e2f85bf8d 153
rosarium 1:cf2e2f85bf8d 154 /**
rosarium 1:cf2e2f85bf8d 155 * @brief send_data
rosarium 1:cf2e2f85bf8d 156 * @param None
rosarium 1:cf2e2f85bf8d 157 * @retval None
rosarium 1:cf2e2f85bf8d 158 */
wobetz 5:a65ed26b0f98 159 static void send_data(void)
wobetz 5:a65ed26b0f98 160 {
jmhong 10:cc81b87e005e 161 printf("\r\n***Sending a packet Start***\r\n");
rosarium 0:2ddc0583bcec 162
jmhong 10:cc81b87e005e 163 printf("[CUBEBITE] myspirit, is_receiving()\t......");
rosarium 4:cae1fa054b86 164 while(myspirit.is_receiving()); /* wait for ongoing RX ends */
jmhong 10:cc81b87e005e 165 printf("OK\n");
rosarium 1:cf2e2f85bf8d 166
wobetz 5:a65ed26b0f98 167 size_t curr_len = strlen((const char*)send_buf) + 1;
jmhong 10:cc81b87e005e 168
jmhong 10:cc81b87e005e 169 int iRet = 0;
jmhong 10:cc81b87e005e 170
jmhong 10:cc81b87e005e 171 printf("[CUBEBITE] myspirit, send()\t......");
jmhong 10:cc81b87e005e 172 iRet = myspirit.send(send_buf, curr_len);
jmhong 10:cc81b87e005e 173 if (iRet == RADIO_TX_OK)
jmhong 10:cc81b87e005e 174 {
jmhong 10:cc81b87e005e 175 printf("[RADIO_TX_OK]\n");
jmhong 10:cc81b87e005e 176 }
jmhong 10:cc81b87e005e 177 else if (iRet == RADIO_TX_ERR)
jmhong 10:cc81b87e005e 178 {
jmhong 10:cc81b87e005e 179 printf("[RADIO_TX_ERR]\n");
jmhong 10:cc81b87e005e 180 }
jmhong 10:cc81b87e005e 181 else if (iRet == RADIO_TX_COLLISION)
jmhong 10:cc81b87e005e 182 {
jmhong 10:cc81b87e005e 183 printf("[RADIO_TX_COLLISION]\n");
jmhong 10:cc81b87e005e 184 }
jmhong 10:cc81b87e005e 185 else if (iRet == RADIO_TX_NOACK)
jmhong 10:cc81b87e005e 186 {
jmhong 10:cc81b87e005e 187 printf("[RADIO_TX_NOACK]\n");
jmhong 10:cc81b87e005e 188 }
jmhong 10:cc81b87e005e 189
jmhong 10:cc81b87e005e 190 printf("\r***Sending a packet End***\r\n");
rosarium 0:2ddc0583bcec 191 }
rosarium 4:cae1fa054b86 192
rosarium 4:cae1fa054b86 193 /**
rosarium 4:cae1fa054b86 194 * @brief read_rcvd_data
rosarium 4:cae1fa054b86 195 * @param None
rosarium 4:cae1fa054b86 196 * @retval None
rosarium 4:cae1fa054b86 197 */
wobetz 5:a65ed26b0f98 198 static void read_rcvd_data(void)
rosarium 4:cae1fa054b86 199 {
jmhong 10:cc81b87e005e 200 printf("\r\n***Recving a packet Start***\r\n");
rosarium 4:cae1fa054b86 201
rosarium 4:cae1fa054b86 202 for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) read_buf[flush_count] = 0 ;/* clear the read buffer */
jmhong 10:cc81b87e005e 203 printf("[CUBEBITE][myspirit] read()\t......");
rosarium 4:cae1fa054b86 204 int ret = myspirit.read(read_buf, sizeof(read_buf));
jmhong 10:cc81b87e005e 205 printf("OK => ");
jmhong 10:cc81b87e005e 206 printf("read value : [%s]\n", read_buf);
rosarium 4:cae1fa054b86 207
wobetz 5:a65ed26b0f98 208 TestLED = !TestLED; /* Toggle LED at the receiver */
rosarium 4:cae1fa054b86 209
rosarium 4:cae1fa054b86 210 if(ret == 0)
rosarium 4:cae1fa054b86 211 {
rosarium 4:cae1fa054b86 212 printf("\nNothing to read\n\r");
rosarium 4:cae1fa054b86 213 return;
rosarium 4:cae1fa054b86 214 }
jmhong 10:cc81b87e005e 215 //printf("\r\n***Received a packet***\r\n\rReceived string = '%s' (len=%d) \n\r", read_buf, ret);
jmhong 10:cc81b87e005e 216 printf("\n\rReceived string = '%s' (len=%d) \n\r", read_buf, ret);
jmhong 10:cc81b87e005e 217
jmhong 10:cc81b87e005e 218 printf("\r\n***Recving a packet End***\r\n");
rosarium 4:cae1fa054b86 219 }
rosarium 4:cae1fa054b86 220
rosarium 4:cae1fa054b86 221
rosarium 1:cf2e2f85bf8d 222 /**
rosarium 1:cf2e2f85bf8d 223 * @brief main routine
rosarium 1:cf2e2f85bf8d 224 * @param None
rosarium 1:cf2e2f85bf8d 225 * @retval int
rosarium 1:cf2e2f85bf8d 226 */
rosarium 0:2ddc0583bcec 227 int main()
rosarium 1:cf2e2f85bf8d 228 {
jmhong 10:cc81b87e005e 229 TestLED = 0; /* LED off */
jmhong 10:cc81b87e005e 230
jmhong 10:cc81b87e005e 231 /* 180108 cubebite HJM : function return value print */
jmhong 10:cc81b87e005e 232 int iRet = 0;
jmhong 10:cc81b87e005e 233
jmhong 10:cc81b87e005e 234
jmhong 10:cc81b87e005e 235 /* 180108 cubebite HJM : GPIO 0, init code */
jmhong 10:cc81b87e005e 236 SGpioInit gpioIRQ={
jmhong 10:cc81b87e005e 237 SPIRIT_GPIO_0,
jmhong 10:cc81b87e005e 238 SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_LP,
jmhong 10:cc81b87e005e 239 SPIRIT_GPIO_DIG_OUT_IRQ
jmhong 10:cc81b87e005e 240 };
jmhong 10:cc81b87e005e 241 SpiritGpioInit(&gpioIRQ);
jmhong 10:cc81b87e005e 242
jmhong 10:cc81b87e005e 243
jmhong 10:cc81b87e005e 244
jmhong 10:cc81b87e005e 245 /* 180108 cubebite HJM : GPIO 0, For spiritFunctionalState(), Testing code */
jmhong 10:cc81b87e005e 246 #ifdef CUBEBITE_RF_GPIO_0_TEST
jmhong 10:cc81b87e005e 247 SpiritFunctionalState spiritFunctionalState={
jmhong 10:cc81b87e005e 248 S_DISABLE
jmhong 10:cc81b87e005e 249 };
jmhong 10:cc81b87e005e 250 #endif
jmhong 10:cc81b87e005e 251
jmhong 10:cc81b87e005e 252
jmhong 10:cc81b87e005e 253
jmhong 10:cc81b87e005e 254
jmhong 10:cc81b87e005e 255 /* 180108 cubebite HJM : spirit module, init code */
jmhong 10:cc81b87e005e 256 printf("[CUBEBITE] myspirit, attach_irq_callback()\t......");
jmhong 10:cc81b87e005e 257 myspirit.attach_irq_callback(callback_func);
jmhong 10:cc81b87e005e 258 printf("OK\n");
jmhong 10:cc81b87e005e 259
jmhong 10:cc81b87e005e 260 printf("[CUBEBITE] myspirit, on()\t......");
jmhong 10:cc81b87e005e 261 iRet = myspirit.on();
jmhong 10:cc81b87e005e 262 if ( 0 == iRet )
jmhong 10:cc81b87e005e 263 {
jmhong 10:cc81b87e005e 264 printf("OK\n");
jmhong 10:cc81b87e005e 265 }
jmhong 10:cc81b87e005e 266 else
jmhong 10:cc81b87e005e 267 {
jmhong 10:cc81b87e005e 268 printf("ERROR\n");
jmhong 10:cc81b87e005e 269 }
jmhong 10:cc81b87e005e 270
rosarium 0:2ddc0583bcec 271
jmhong 10:cc81b87e005e 272 // printf("\n**************HelloWorld mbed demo for Spirit1 (X-NUCLEO-IDS01A4/5)**************\r\n");
jmhong 10:cc81b87e005e 273 // printf("\nPress User Button on one of the two boards to send a packaet to the other and the LED D1 on the receiver X-NUCLEO-IDS01A4/5 should toggle \n\r\n");
jmhong 10:cc81b87e005e 274
jmhong 10:cc81b87e005e 275
jmhong 10:cc81b87e005e 276
jmhong 10:cc81b87e005e 277
jmhong 10:cc81b87e005e 278
jmhong 10:cc81b87e005e 279 printf("[CUBEBITE] rise(&set_send_data_flag)\t......");
rosarium 4:cae1fa054b86 280 event.rise(&set_send_data_flag); /*User button interrupt trigger to set send data flag */
jmhong 10:cc81b87e005e 281 printf("OK\n");
jmhong 10:cc81b87e005e 282
jmhong 10:cc81b87e005e 283 #ifdef CUBEBITE_RF_DEVICE_PARTNUMBER_TEST
jmhong 10:cc81b87e005e 284 uint16_t int16SpiritPartNum = 0;
jmhong 10:cc81b87e005e 285 #endif
rosarium 0:2ddc0583bcec 286 while(1)
rosarium 0:2ddc0583bcec 287 {
jmhong 10:cc81b87e005e 288 #ifdef CUBEBITE_RF_DEVICE_PARTNUMBER_TEST
jmhong 10:cc81b87e005e 289 printf("[CUBEBITE][devicePartNumber] SpiritGeneralGetDevicePartNumber()\t......");
jmhong 10:cc81b87e005e 290
jmhong 10:cc81b87e005e 291 int16SpiritPartNum = SpiritGeneralGetDevicePartNumber();
jmhong 10:cc81b87e005e 292 printf("OK => ");
jmhong 10:cc81b87e005e 293 printf("int16SpiritPartNum value : [0x%04X]\n", int16SpiritPartNum);
jmhong 10:cc81b87e005e 294 int16SpiritPartNum = 0;
jmhong 10:cc81b87e005e 295 #endif
jmhong 10:cc81b87e005e 296
rosarium 4:cae1fa054b86 297 __WFE(); /* low power in idle condition., waiting for an event */
rosarium 0:2ddc0583bcec 298
jmhong 10:cc81b87e005e 299 //180108 HJM : For spiritFunctionalState(), testing code
jmhong 10:cc81b87e005e 300 /*
jmhong 10:cc81b87e005e 301 if (S_ENABLE == spiritFunctionalState)
jmhong 10:cc81b87e005e 302 {
jmhong 10:cc81b87e005e 303 spiritFunctionalState = S_DISABLE;
jmhong 10:cc81b87e005e 304 }
jmhong 10:cc81b87e005e 305 else
jmhong 10:cc81b87e005e 306 {
jmhong 10:cc81b87e005e 307 spiritFunctionalState = S_ENABLE;
jmhong 10:cc81b87e005e 308 }
jmhong 10:cc81b87e005e 309 */
jmhong 10:cc81b87e005e 310
jmhong 10:cc81b87e005e 311
jmhong 10:cc81b87e005e 312
jmhong 10:cc81b87e005e 313 #ifdef CUBEBITE_RF_GPIO_0_TEST
jmhong 10:cc81b87e005e 314 /* 180108 cubebite HJM : GPIO 0, For, spiritFunctionalState() => Enables or Disables the output of temperature sensor on SPIRIT GPIO_0. */
jmhong 10:cc81b87e005e 315 SpiritGpioTemperatureSensor(spiritFunctionalState);
jmhong 10:cc81b87e005e 316
jmhong 10:cc81b87e005e 317 /* 180108 cubebite HJM : RF_GPIO_0_INPUT pin value print */
jmhong 10:cc81b87e005e 318 printf("****** RF GPIO_0 Status Testing => [%d] ******\n", (int)RF_GPIO_0_INPUT);
jmhong 10:cc81b87e005e 319 //wait(1);
jmhong 10:cc81b87e005e 320 #endif
jmhong 10:cc81b87e005e 321
jmhong 10:cc81b87e005e 322
jmhong 10:cc81b87e005e 323 /* 180108 cubebite HJM : RF_GPIO_3_INPUT pin value print */
jmhong 10:cc81b87e005e 324 // printf("****** RF GPIO_3 Status Testing => [%d] ******\n", (int)RF_GPIO_3_INPUT);
jmhong 10:cc81b87e005e 325
jmhong 10:cc81b87e005e 326
jmhong 10:cc81b87e005e 327
jmhong 10:cc81b87e005e 328
jmhong 10:cc81b87e005e 329
jmhong 10:cc81b87e005e 330 /* 180108 cubebite HJM : RF 모듈 간 통신 때 사용되는 코드 */
jmhong 10:cc81b87e005e 331 //read_rcvd_data();
rosarium 1:cf2e2f85bf8d 332 if(rx_done_flag)
rosarium 0:2ddc0583bcec 333 {
wobetz 5:a65ed26b0f98 334 rx_done_flag = false;
rosarium 4:cae1fa054b86 335 read_rcvd_data();
rosarium 4:cae1fa054b86 336 }
rosarium 4:cae1fa054b86 337
rosarium 4:cae1fa054b86 338 else if (send_data_flag)
rosarium 4:cae1fa054b86 339 {
wobetz 5:a65ed26b0f98 340 send_data_flag = false;
rosarium 4:cae1fa054b86 341 send_data();
rosarium 1:cf2e2f85bf8d 342 }
rosarium 1:cf2e2f85bf8d 343
rosarium 1:cf2e2f85bf8d 344 else if (tx_done_flag)
rosarium 1:cf2e2f85bf8d 345 {
wobetz 5:a65ed26b0f98 346 tx_done_flag = false;
rosarium 4:cae1fa054b86 347 printf("\r\n***Packet sent ***\r\nSent string ='%s' (len=%d)\n\r", send_buf, strlen((const char*)send_buf) + 1);
rosarium 1:cf2e2f85bf8d 348 }
jmhong 10:cc81b87e005e 349
rosarium 0:2ddc0583bcec 350 }
rosarium 0:2ddc0583bcec 351
wobetz 5:a65ed26b0f98 352 /* unreachable */
wobetz 5:a65ed26b0f98 353 // myspirit.off();
wobetz 5:a65ed26b0f98 354 // return 0;
rosarium 0:2ddc0583bcec 355 }