bug fix, But not applied

Dependencies:   ADXL362_bugFix stm-spirit1-rf-driver_for_cubebite

Fork of cubebite_rnd_ev-cog-ad3029lz_433MHz_2nd_testing2_RF10CountSensingCheckOK_180619_initReviseTest by JunMo Hong

Committer:
jmhong
Date:
Wed Mar 21 05:06:15 2018 +0000
Revision:
0:c2a57b2f934e
Child:
1:04f46755f8af
Test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmhong 0:c2a57b2f934e 1 //#include "mbed.h"
jmhong 0:c2a57b2f934e 2 #include "ADXL362.h"
jmhong 0:c2a57b2f934e 3 //#include "SimpleSpirit1.h"
jmhong 0:c2a57b2f934e 4 #include "main.h"
jmhong 0:c2a57b2f934e 5
jmhong 0:c2a57b2f934e 6
jmhong 0:c2a57b2f934e 7 //*************************************************************************************
jmhong 0:c2a57b2f934e 8 //Define : Test, Compile
jmhong 0:c2a57b2f934e 9 //*************************************************************************************
jmhong 0:c2a57b2f934e 10 /* 180108 cubebite HJM : cubebite Testing define, 1개씩만 켜야 함. */
jmhong 0:c2a57b2f934e 11 #define CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 12 //#define CUBEBITE_RF_SPEED_TEST_RECV_ON
jmhong 0:c2a57b2f934e 13
jmhong 0:c2a57b2f934e 14
jmhong 0:c2a57b2f934e 15 /* 180109 cubebite HJM : cubebite Compile define, 1개씩만 켜야 함. */
jmhong 0:c2a57b2f934e 16 //#define CUBEBITE_BOARD_F746ZG
jmhong 0:c2a57b2f934e 17 //#define CUBEBITE_BOARD_F401RE
jmhong 0:c2a57b2f934e 18 #define CUBEBITE_BOARD_AD3029LZ
jmhong 0:c2a57b2f934e 19
jmhong 0:c2a57b2f934e 20
jmhong 0:c2a57b2f934e 21 #define CUBEBITE_RF_SETTING_VALUE_PRINT
jmhong 0:c2a57b2f934e 22 //*************************************************************************************
jmhong 0:c2a57b2f934e 23
jmhong 0:c2a57b2f934e 24 #define HEAVY_DEBUG
jmhong 0:c2a57b2f934e 25
jmhong 0:c2a57b2f934e 26
jmhong 0:c2a57b2f934e 27
jmhong 0:c2a57b2f934e 28 //DigitalOut led1(LED1);
jmhong 0:c2a57b2f934e 29 //DigitalOut led2(LED2);
jmhong 0:c2a57b2f934e 30 //ADXL362 adxl362(P1_07, P1_08, P1_06, P1_10); // Accelerometer (mosi, miso, sclk, cs), SPI 1
jmhong 0:c2a57b2f934e 31 //ADXL362 adxl362(P0_01, P0_02, P0_00, P0_03); // Accelerometer (mosi, miso, sclk, cs), SPI 0
jmhong 0:c2a57b2f934e 32
jmhong 0:c2a57b2f934e 33
jmhong 0:c2a57b2f934e 34 //180321 HJM : IRQ를 GPIO 28 로 사용, send error를 띄움
jmhong 0:c2a57b2f934e 35 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 ,P2_08, P1_14);
jmhong 0:c2a57b2f934e 36 // // P0_01[SPI0_MOSI]
jmhong 0:c2a57b2f934e 37 // // P0_02[SPI0_MISO],
jmhong 0:c2a57b2f934e 38 // // P0_00[SPI0_CLK],
jmhong 0:c2a57b2f934e 39 // // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정,
jmhong 0:c2a57b2f934e 40 // // P2_08[SPI0_CS2],
jmhong 0:c2a57b2f934e 41 // // P1_14[GPIO 30, RF (SDN)]
jmhong 0:c2a57b2f934e 42
jmhong 0:c2a57b2f934e 43
jmhong 0:c2a57b2f934e 44 //180321 HJM : IRQ를 GPIO 27 로 사용,
jmhong 0:c2a57b2f934e 45 static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_11 ,P2_08, P1_14);
jmhong 0:c2a57b2f934e 46 // P0_01[SPI0_MOSI]
jmhong 0:c2a57b2f934e 47 // P0_02[SPI0_MISO],
jmhong 0:c2a57b2f934e 48 // P0_00[SPI0_CLK],
jmhong 0:c2a57b2f934e 49 // P1_11[GPIO 27, RF(GPIO 2)]->IRQ로 설정,
jmhong 0:c2a57b2f934e 50 // P2_08[SPI0_CS2],
jmhong 0:c2a57b2f934e 51 // P1_14[GPIO 30, RF (SDN)]
jmhong 0:c2a57b2f934e 52
jmhong 0:c2a57b2f934e 53
jmhong 0:c2a57b2f934e 54
jmhong 0:c2a57b2f934e 55
jmhong 0:c2a57b2f934e 56
jmhong 0:c2a57b2f934e 57
jmhong 0:c2a57b2f934e 58
jmhong 0:c2a57b2f934e 59
jmhong 0:c2a57b2f934e 60
jmhong 0:c2a57b2f934e 61
jmhong 0:c2a57b2f934e 62
jmhong 0:c2a57b2f934e 63
jmhong 0:c2a57b2f934e 64
jmhong 0:c2a57b2f934e 65 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 ,P2_08, P1_14);
jmhong 0:c2a57b2f934e 66 // // P0_01[SPI0_MOSI]
jmhong 0:c2a57b2f934e 67 // // P0_02[SPI0_MISO],
jmhong 0:c2a57b2f934e 68 // // P0_00[SPI0_CLK],
jmhong 0:c2a57b2f934e 69 // // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
jmhong 0:c2a57b2f934e 70 // // P2_08[SPI0_CS2],
jmhong 0:c2a57b2f934e 71 // // P1_14[GPIO 30, RF (SDN)]
jmhong 0:c2a57b2f934e 72
jmhong 0:c2a57b2f934e 73
jmhong 0:c2a57b2f934e 74
jmhong 0:c2a57b2f934e 75 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 , SPI0_CS2, P1_14);
jmhong 0:c2a57b2f934e 76 // // P0_01[SPI0_MOSI]
jmhong 0:c2a57b2f934e 77 // // P0_02[SPI0_MISO],
jmhong 0:c2a57b2f934e 78 // // P0_00[SPI0_CLK],
jmhong 0:c2a57b2f934e 79 // // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
jmhong 0:c2a57b2f934e 80 // // P2_08[SPI0_CS2],
jmhong 0:c2a57b2f934e 81 // // P1_14[GPIO 30, RF (SDN)]
jmhong 0:c2a57b2f934e 82
jmhong 0:c2a57b2f934e 83
jmhong 0:c2a57b2f934e 84
jmhong 0:c2a57b2f934e 85 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P1_03, P1_04, P1_02, P1_12 ,P2_10, P1_14);
jmhong 0:c2a57b2f934e 86 // P1_03[SPI2_MOSI]
jmhong 0:c2a57b2f934e 87 // P1_04[SPI2_MISO],
jmhong 0:c2a57b2f934e 88 // P1_02[SPI2_CLK],
jmhong 0:c2a57b2f934e 89 // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
jmhong 0:c2a57b2f934e 90 // P2_10[SPI2_CS2],
jmhong 0:c2a57b2f934e 91 // P1_14[GPIO 30, RF (SDN)]
jmhong 0:c2a57b2f934e 92
jmhong 0:c2a57b2f934e 93
jmhong 0:c2a57b2f934e 94
jmhong 0:c2a57b2f934e 95
jmhong 0:c2a57b2f934e 96 static int ReadRcvdData(SimpleSpirit1& myspirit);
jmhong 0:c2a57b2f934e 97 static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit);
jmhong 0:c2a57b2f934e 98
jmhong 0:c2a57b2f934e 99 static int SendData(SimpleSpirit1& myspirit);
jmhong 0:c2a57b2f934e 100 static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit);
jmhong 0:c2a57b2f934e 101
jmhong 0:c2a57b2f934e 102
jmhong 0:c2a57b2f934e 103 enum RecvReturnValue
jmhong 0:c2a57b2f934e 104 {
jmhong 0:c2a57b2f934e 105 CUBEBITE_RECV_OK = 0, CUBEBITE_RECV_ERROR_READ_NOTHING, CUBEBITE_RECV_ERROR_READ_NOT_MATCH
jmhong 0:c2a57b2f934e 106 };
jmhong 0:c2a57b2f934e 107
jmhong 0:c2a57b2f934e 108 enum SendReturnValue
jmhong 0:c2a57b2f934e 109 {
jmhong 0:c2a57b2f934e 110 CUBEBITE_SEND_OK = 0, CUBEBITE_SEND_ERROR, CUBEBITE_SEND_COLLISION, CUBEBITE_SEND_NOACK, CUBEBITE_SEND_ERROR_UNKNOWN
jmhong 0:c2a57b2f934e 111 };
jmhong 0:c2a57b2f934e 112
jmhong 0:c2a57b2f934e 113
jmhong 0:c2a57b2f934e 114 /**
jmhong 0:c2a57b2f934e 115 * @brief callback_func
jmhong 0:c2a57b2f934e 116 * @param callback event
jmhong 0:c2a57b2f934e 117 * @retval None.
jmhong 0:c2a57b2f934e 118 */
jmhong 0:c2a57b2f934e 119 static void callback_func(int event)
jmhong 0:c2a57b2f934e 120 {
jmhong 0:c2a57b2f934e 121 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 122 printf("[CUBEBITE] callback_func(int event) \n");
jmhong 0:c2a57b2f934e 123 #endif
jmhong 0:c2a57b2f934e 124
jmhong 0:c2a57b2f934e 125
jmhong 0:c2a57b2f934e 126 if(event == SimpleSpirit1::RX_DONE)
jmhong 0:c2a57b2f934e 127 {
jmhong 0:c2a57b2f934e 128 bRxDoneFlag = 1;
jmhong 0:c2a57b2f934e 129 }
jmhong 0:c2a57b2f934e 130 else if (event == SimpleSpirit1::TX_DONE)
jmhong 0:c2a57b2f934e 131 {
jmhong 0:c2a57b2f934e 132 bTxDoneFlag = 1;
jmhong 0:c2a57b2f934e 133 }
jmhong 0:c2a57b2f934e 134 }
jmhong 0:c2a57b2f934e 135
jmhong 0:c2a57b2f934e 136
jmhong 0:c2a57b2f934e 137 //HJM I2C PullUp Test
jmhong 0:c2a57b2f934e 138 DigitalIn TempSupply(P1_11);
jmhong 0:c2a57b2f934e 139
jmhong 0:c2a57b2f934e 140
jmhong 0:c2a57b2f934e 141 // main() runs in its own thread in the OS
jmhong 0:c2a57b2f934e 142 int main()
jmhong 0:c2a57b2f934e 143 {
jmhong 0:c2a57b2f934e 144 // local variables
jmhong 0:c2a57b2f934e 145 int8_t x8 = 0;
jmhong 0:c2a57b2f934e 146 int8_t y8 = 0;
jmhong 0:c2a57b2f934e 147 int8_t z8 = 0;
jmhong 0:c2a57b2f934e 148 uint8_t reg;
jmhong 0:c2a57b2f934e 149 int iReturn;
jmhong 0:c2a57b2f934e 150
jmhong 0:c2a57b2f934e 151 printf("Hi Eureka!\r\n");
jmhong 0:c2a57b2f934e 152
jmhong 0:c2a57b2f934e 153 // TempSupply.write(1);
jmhong 0:c2a57b2f934e 154
jmhong 0:c2a57b2f934e 155 //// set up SPI interface
jmhong 0:c2a57b2f934e 156 // adxl362.init_spi();
jmhong 0:c2a57b2f934e 157 //
jmhong 0:c2a57b2f934e 158 // // Set up accelerometer
jmhong 0:c2a57b2f934e 159 // adxl362.init_adxl362();
jmhong 0:c2a57b2f934e 160 //
jmhong 0:c2a57b2f934e 161 // // Check settings
jmhong 0:c2a57b2f934e 162 // reg = adxl362.ACC_ReadReg(FILTER_CTL);
jmhong 0:c2a57b2f934e 163 // printf("FILTER_CTL = 0x%X\r\n", reg);
jmhong 0:c2a57b2f934e 164 //
jmhong 0:c2a57b2f934e 165
jmhong 0:c2a57b2f934e 166 printf("P0_00 : [%d] (0 << GPIO_PORT_SHIFT | 0 ) : [%d]\n", P0_00, (0 << GPIO_PORT_SHIFT | 0 ));
jmhong 0:c2a57b2f934e 167 printf("P1_00 : [%d] (1 << GPIO_PORT_SHIFT | 0 ) : [%d]\n", P1_00, (1 << GPIO_PORT_SHIFT | 0 ));
jmhong 0:c2a57b2f934e 168
jmhong 0:c2a57b2f934e 169
jmhong 0:c2a57b2f934e 170
jmhong 0:c2a57b2f934e 171 //printf("\n\nPIN Number 16, P2_03, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_03);
jmhong 0:c2a57b2f934e 172 // printf("PIN Number 17, P2_04, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_04);
jmhong 0:c2a57b2f934e 173 // printf("PIN Number 18, P2_05, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_05);
jmhong 0:c2a57b2f934e 174 // printf("PIN Number 19, P2_06, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_06);
jmhong 0:c2a57b2f934e 175 // printf("PIN Number 20, P2_07, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_07);
jmhong 0:c2a57b2f934e 176 // printf("PIN Number 21, P2_08, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_08);
jmhong 0:c2a57b2f934e 177 // printf("PIN Number 22, P2_09, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_09);
jmhong 0:c2a57b2f934e 178 // printf("PIN Number 23, P2_10, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_10);
jmhong 0:c2a57b2f934e 179 // printf("PIN Number 24, P0_05, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P0_05);
jmhong 0:c2a57b2f934e 180
jmhong 0:c2a57b2f934e 181 /* 180108 cubebite HJM : spirit module, init code */
jmhong 0:c2a57b2f934e 182 printf("[CUBEBITE] Init ");
jmhong 0:c2a57b2f934e 183 /* LED off */
jmhong 0:c2a57b2f934e 184 // TestLED = 0;
jmhong 0:c2a57b2f934e 185 myspirit.attach_irq_callback(callback_func);
jmhong 0:c2a57b2f934e 186 iReturn = myspirit.on();
jmhong 0:c2a57b2f934e 187 if ( 0 == iReturn )
jmhong 0:c2a57b2f934e 188 {
jmhong 0:c2a57b2f934e 189 printf("OK.\n");
jmhong 0:c2a57b2f934e 190 }
jmhong 0:c2a57b2f934e 191 else
jmhong 0:c2a57b2f934e 192 {
jmhong 0:c2a57b2f934e 193 printf("ERROR.\n");
jmhong 0:c2a57b2f934e 194 }
jmhong 0:c2a57b2f934e 195
jmhong 0:c2a57b2f934e 196 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 197 printf("[CUBEBITE] CUBEBITE_DEBUG ON. \n");
jmhong 0:c2a57b2f934e 198 #endif //CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 199
jmhong 0:c2a57b2f934e 200
jmhong 0:c2a57b2f934e 201 #ifdef CUBEBITE_RF_SETTING_VALUE_PRINT
jmhong 0:c2a57b2f934e 202 printf("Xtal offset in ppm : [%d]\n", XTAL_OFFSET_PPM);
jmhong 0:c2a57b2f934e 203 printf("base frequency : [%d]\n", (uint32_t)BASE_FREQUENCY);
jmhong 0:c2a57b2f934e 204 printf("channel space : [%d]\n", (uint32_t)CHANNEL_SPACE);
jmhong 0:c2a57b2f934e 205 printf("channel number : [%d]\n", CHANNEL_NUMBER);
jmhong 0:c2a57b2f934e 206 printf("modulation select : [%d]\n", MODULATION_SELECT);
jmhong 0:c2a57b2f934e 207 printf("data rate : [%d]\n", DATARATE);
jmhong 0:c2a57b2f934e 208 printf("frequency deviation : [%d]\n", (uint32_t)FREQ_DEVIATION);
jmhong 0:c2a57b2f934e 209 printf("channel filter bandwidth : [%d]\n", (uint32_t)BANDWIDTH);
jmhong 0:c2a57b2f934e 210 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 211 printf("\nOutput Power(dBm) : [%f]\n", POWER_DBM);
jmhong 0:c2a57b2f934e 212 // printf("\nOutput Power(dBm) : [%f]\n", (float)CUBEBITE_OUTPUT_POWER_DBM_TEST);
jmhong 0:c2a57b2f934e 213
jmhong 0:c2a57b2f934e 214 #endif //CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 215
jmhong 0:c2a57b2f934e 216 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON
jmhong 0:c2a57b2f934e 217 printf("\nRSSI threshold Setting value : [%d]\n", (int)CCA_THRESHOLD);
jmhong 0:c2a57b2f934e 218 #endif //CUBEBITE_RF_SPEED_TEST_RECV_ON
jmhong 0:c2a57b2f934e 219
jmhong 0:c2a57b2f934e 220 wait(2);
jmhong 0:c2a57b2f934e 221 #endif //CUBEBITE_RF_SETTING_VALUE_PRINT
jmhong 0:c2a57b2f934e 222
jmhong 0:c2a57b2f934e 223 while(1)
jmhong 0:c2a57b2f934e 224 {
jmhong 0:c2a57b2f934e 225 /* low power in idle condition., waiting for an event */
jmhong 0:c2a57b2f934e 226 // __WFE();
jmhong 0:c2a57b2f934e 227
jmhong 0:c2a57b2f934e 228
jmhong 0:c2a57b2f934e 229
jmhong 0:c2a57b2f934e 230
jmhong 0:c2a57b2f934e 231
jmhong 0:c2a57b2f934e 232
jmhong 0:c2a57b2f934e 233
jmhong 0:c2a57b2f934e 234 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 235 iReturn = SendData(myspirit);
jmhong 0:c2a57b2f934e 236 if (CUBEBITE_SEND_OK == iReturn)
jmhong 0:c2a57b2f934e 237 {
jmhong 0:c2a57b2f934e 238 printf("[DEBUG] send OK.\n");
jmhong 0:c2a57b2f934e 239 }
jmhong 0:c2a57b2f934e 240 else if (CUBEBITE_SEND_ERROR == iReturn)
jmhong 0:c2a57b2f934e 241 {
jmhong 0:c2a57b2f934e 242 printf("[DEBUG] send ERROR.\n");
jmhong 0:c2a57b2f934e 243 }
jmhong 0:c2a57b2f934e 244
jmhong 0:c2a57b2f934e 245 iReturn = (int)myspirit.get_last_sqi(); //HJM : LQI, 현재 주변 통신 품질 값, 높을수록 좋은 것.
jmhong 0:c2a57b2f934e 246 printf("get_last_sqi() return : [%d]\n", iReturn);
jmhong 0:c2a57b2f934e 247 #endif
jmhong 0:c2a57b2f934e 248
jmhong 0:c2a57b2f934e 249 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON
jmhong 0:c2a57b2f934e 250 if (bRxDoneFlag)
jmhong 0:c2a57b2f934e 251 {
jmhong 0:c2a57b2f934e 252 iReturn = ReadRcvdData(myspirit);
jmhong 0:c2a57b2f934e 253 if (CUBEBITE_RECV_OK == iReturn)
jmhong 0:c2a57b2f934e 254 {
jmhong 0:c2a57b2f934e 255 //통신 속도 체크시, 응답 send code.
jmhong 0:c2a57b2f934e 256 printf("[DEBUG] recv OK.\n");
jmhong 0:c2a57b2f934e 257
jmhong 0:c2a57b2f934e 258 float fReturn1 = myspirit.get_last_rssi_dbm();
jmhong 0:c2a57b2f934e 259 printf("get_last_rssi_dbm() return : [%f]\n", fReturn1); //HJM : 위의 값과 같을 거라고 예상 됨. 나중에 테스트.
jmhong 0:c2a57b2f934e 260 if (-50 < fReturn1) //-80 < fReturn1
jmhong 0:c2a57b2f934e 261 {
jmhong 0:c2a57b2f934e 262 TestLED3 = !TestLED3; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 263 }
jmhong 0:c2a57b2f934e 264 else if (-50 >= fReturn1)
jmhong 0:c2a57b2f934e 265 {
jmhong 0:c2a57b2f934e 266 // TestLED = !TestLED; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 267 TestLED2 = !TestLED2; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 268 // TestLED3 = !TestLED3; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 269 }
jmhong 0:c2a57b2f934e 270 else if (-70 >= fReturn1) //-100 >= fReturn1
jmhong 0:c2a57b2f934e 271 {
jmhong 0:c2a57b2f934e 272 TestLED = !TestLED; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 273 }
jmhong 0:c2a57b2f934e 274 }
jmhong 0:c2a57b2f934e 275 bRxDoneFlag = 0;
jmhong 0:c2a57b2f934e 276 }
jmhong 0:c2a57b2f934e 277 #endif
jmhong 0:c2a57b2f934e 278
jmhong 0:c2a57b2f934e 279 }
jmhong 0:c2a57b2f934e 280 /* unreachable */
jmhong 0:c2a57b2f934e 281 // myspirit.off();
jmhong 0:c2a57b2f934e 282 // return 0;
jmhong 0:c2a57b2f934e 283
jmhong 0:c2a57b2f934e 284 }
jmhong 0:c2a57b2f934e 285
jmhong 0:c2a57b2f934e 286
jmhong 0:c2a57b2f934e 287
jmhong 0:c2a57b2f934e 288
jmhong 0:c2a57b2f934e 289 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 290 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 291 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 292 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 293 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 294 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 295 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 296 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 297 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 298 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 299 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 300 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 301 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 302 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 303 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 304 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 305 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 306 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 307 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 308 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 309 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 310 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 311 //recv
jmhong 0:c2a57b2f934e 312
jmhong 0:c2a57b2f934e 313
jmhong 0:c2a57b2f934e 314
jmhong 0:c2a57b2f934e 315
jmhong 0:c2a57b2f934e 316
jmhong 0:c2a57b2f934e 317
jmhong 0:c2a57b2f934e 318 /**
jmhong 0:c2a57b2f934e 319 * @brief ReadRcvdData
jmhong 0:c2a57b2f934e 320 * @param None
jmhong 0:c2a57b2f934e 321 * @retval None
jmhong 0:c2a57b2f934e 322 */
jmhong 0:c2a57b2f934e 323 static int ReadRcvdData(SimpleSpirit1& myspirit)
jmhong 0:c2a57b2f934e 324 {
jmhong 0:c2a57b2f934e 325 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 326 printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n");
jmhong 0:c2a57b2f934e 327 #endif
jmhong 0:c2a57b2f934e 328
jmhong 0:c2a57b2f934e 329 for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */
jmhong 0:c2a57b2f934e 330
jmhong 0:c2a57b2f934e 331
jmhong 0:c2a57b2f934e 332 int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf));
jmhong 0:c2a57b2f934e 333 if (ret == 0)
jmhong 0:c2a57b2f934e 334 {
jmhong 0:c2a57b2f934e 335 printf("[CUBEBITE] Read() Error : Nothing to read\n");
jmhong 0:c2a57b2f934e 336 return CUBEBITE_RECV_ERROR_READ_NOTHING;
jmhong 0:c2a57b2f934e 337 }
jmhong 0:c2a57b2f934e 338 printf("ReadRcvdData() 1");
jmhong 0:c2a57b2f934e 339
jmhong 0:c2a57b2f934e 340 printf("[DEBUG]recv -> %s ", uiRendBuf);
jmhong 0:c2a57b2f934e 341
jmhong 0:c2a57b2f934e 342 ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf);
jmhong 0:c2a57b2f934e 343 printf(" 3");
jmhong 0:c2a57b2f934e 344 if (0 == ret)
jmhong 0:c2a57b2f934e 345 {
jmhong 0:c2a57b2f934e 346 // set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정
jmhong 0:c2a57b2f934e 347 // printf("read, send buf collect!!\n");
jmhong 0:c2a57b2f934e 348 // TestLED = !TestLED; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 349 printf(" 4");
jmhong 0:c2a57b2f934e 350 // bIsAckSended = true;
jmhong 0:c2a57b2f934e 351 // printf("[DEBUG]recv -> %s\n", uiRendBuf);
jmhong 0:c2a57b2f934e 352 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 353 printf("[DEBUG]recv -> %s\n", uiRendBuf);
jmhong 0:c2a57b2f934e 354 #endif
jmhong 0:c2a57b2f934e 355
jmhong 0:c2a57b2f934e 356 //746zg 보드
jmhong 0:c2a57b2f934e 357 // wait(1.0);
jmhong 0:c2a57b2f934e 358 /*
jmhong 0:c2a57b2f934e 359 int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen);
jmhong 0:c2a57b2f934e 360 if (iRet == RADIO_TX_OK)
jmhong 0:c2a57b2f934e 361 {
jmhong 0:c2a57b2f934e 362 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 363 printf("ACK : [RADIO_TX_OK]\n");
jmhong 0:c2a57b2f934e 364 #endif
jmhong 0:c2a57b2f934e 365 }
jmhong 0:c2a57b2f934e 366 else if (iRet == RADIO_TX_ERR)
jmhong 0:c2a57b2f934e 367 {
jmhong 0:c2a57b2f934e 368 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 369 printf("ACK : [RADIO_TX_ERR]\n");
jmhong 0:c2a57b2f934e 370 #endif
jmhong 0:c2a57b2f934e 371 }
jmhong 0:c2a57b2f934e 372 else if (iRet == RADIO_TX_COLLISION)
jmhong 0:c2a57b2f934e 373 {
jmhong 0:c2a57b2f934e 374 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 375 printf("ACK : [RADIO_TX_COLLISION]\n");
jmhong 0:c2a57b2f934e 376 #endif
jmhong 0:c2a57b2f934e 377 }
jmhong 0:c2a57b2f934e 378 else if (iRet == RADIO_TX_NOACK)
jmhong 0:c2a57b2f934e 379 {
jmhong 0:c2a57b2f934e 380 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 381 printf("ACK : [RADIO_TX_NOACK]\n");
jmhong 0:c2a57b2f934e 382 #endif
jmhong 0:c2a57b2f934e 383 }
jmhong 0:c2a57b2f934e 384 */
jmhong 0:c2a57b2f934e 385
jmhong 0:c2a57b2f934e 386 return CUBEBITE_RECV_OK;
jmhong 0:c2a57b2f934e 387 printf(" 5 ok\n");
jmhong 0:c2a57b2f934e 388 }
jmhong 0:c2a57b2f934e 389
jmhong 0:c2a57b2f934e 390
jmhong 0:c2a57b2f934e 391 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 392 printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n");
jmhong 0:c2a57b2f934e 393 #endif
jmhong 0:c2a57b2f934e 394
jmhong 0:c2a57b2f934e 395 return CUBEBITE_RECV_ERROR_READ_NOT_MATCH;
jmhong 0:c2a57b2f934e 396 printf(" 6 error\n");
jmhong 0:c2a57b2f934e 397 }
jmhong 0:c2a57b2f934e 398
jmhong 0:c2a57b2f934e 399
jmhong 0:c2a57b2f934e 400
jmhong 0:c2a57b2f934e 401 static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit)
jmhong 0:c2a57b2f934e 402 {
jmhong 0:c2a57b2f934e 403 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 404 printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n");
jmhong 0:c2a57b2f934e 405 #endif
jmhong 0:c2a57b2f934e 406
jmhong 0:c2a57b2f934e 407 for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */
jmhong 0:c2a57b2f934e 408
jmhong 0:c2a57b2f934e 409 int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf));
jmhong 0:c2a57b2f934e 410 if (ret == 0)
jmhong 0:c2a57b2f934e 411 {
jmhong 0:c2a57b2f934e 412 printf("[CUBEBITE] Read() Error : Nothing to read\n");
jmhong 0:c2a57b2f934e 413 return CUBEBITE_RECV_ERROR_READ_NOTHING;
jmhong 0:c2a57b2f934e 414 }
jmhong 0:c2a57b2f934e 415 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON
jmhong 0:c2a57b2f934e 416 ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf);
jmhong 0:c2a57b2f934e 417 if (0 == ret)
jmhong 0:c2a57b2f934e 418 {
jmhong 0:c2a57b2f934e 419 // set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정
jmhong 0:c2a57b2f934e 420 // printf("read, send buf collect!!\n");
jmhong 0:c2a57b2f934e 421 TestLED = !TestLED; /* Toggle LED at the receiver */
jmhong 0:c2a57b2f934e 422 // bIsAckSended = true;
jmhong 0:c2a57b2f934e 423 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 424 printf("[DEBUG]recv -> %s\n", uiRendBuf);
jmhong 0:c2a57b2f934e 425 #endif
jmhong 0:c2a57b2f934e 426
jmhong 0:c2a57b2f934e 427 //746zg 보드
jmhong 0:c2a57b2f934e 428 // wait(1.0);
jmhong 0:c2a57b2f934e 429 /*
jmhong 0:c2a57b2f934e 430 int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen);
jmhong 0:c2a57b2f934e 431 if (iRet == RADIO_TX_OK)
jmhong 0:c2a57b2f934e 432 {
jmhong 0:c2a57b2f934e 433 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 434 printf("ACK : [RADIO_TX_OK]\n");
jmhong 0:c2a57b2f934e 435 #endif
jmhong 0:c2a57b2f934e 436 }
jmhong 0:c2a57b2f934e 437 else if (iRet == RADIO_TX_ERR)
jmhong 0:c2a57b2f934e 438 {
jmhong 0:c2a57b2f934e 439 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 440 printf("ACK : [RADIO_TX_ERR]\n");
jmhong 0:c2a57b2f934e 441 #endif
jmhong 0:c2a57b2f934e 442 }
jmhong 0:c2a57b2f934e 443 else if (iRet == RADIO_TX_COLLISION)
jmhong 0:c2a57b2f934e 444 {
jmhong 0:c2a57b2f934e 445 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 446 printf("ACK : [RADIO_TX_COLLISION]\n");
jmhong 0:c2a57b2f934e 447 #endif
jmhong 0:c2a57b2f934e 448 }
jmhong 0:c2a57b2f934e 449 else if (iRet == RADIO_TX_NOACK)
jmhong 0:c2a57b2f934e 450 {
jmhong 0:c2a57b2f934e 451 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 452 printf("ACK : [RADIO_TX_NOACK]\n");
jmhong 0:c2a57b2f934e 453 #endif
jmhong 0:c2a57b2f934e 454 }
jmhong 0:c2a57b2f934e 455 */
jmhong 0:c2a57b2f934e 456
jmhong 0:c2a57b2f934e 457 return CUBEBITE_RECV_OK;
jmhong 0:c2a57b2f934e 458 }
jmhong 0:c2a57b2f934e 459 #endif
jmhong 0:c2a57b2f934e 460
jmhong 0:c2a57b2f934e 461 //#ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 462 // //401re 보드
jmhong 0:c2a57b2f934e 463 // if (true == bIsSendFirstClockFunctionStarted)
jmhong 0:c2a57b2f934e 464 // {
jmhong 0:c2a57b2f934e 465 // clocktimeRFSpeedTestEnd = clock();
jmhong 0:c2a57b2f934e 466 // }
jmhong 0:c2a57b2f934e 467 // //printf("[DEBUG]recv -> %s\n", uiRendBuf);
jmhong 0:c2a57b2f934e 468 //#endif
jmhong 0:c2a57b2f934e 469
jmhong 0:c2a57b2f934e 470
jmhong 0:c2a57b2f934e 471 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 472 printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n");
jmhong 0:c2a57b2f934e 473 #endif
jmhong 0:c2a57b2f934e 474
jmhong 0:c2a57b2f934e 475 return CUBEBITE_RECV_ERROR_READ_NOT_MATCH;
jmhong 0:c2a57b2f934e 476 }
jmhong 0:c2a57b2f934e 477
jmhong 0:c2a57b2f934e 478
jmhong 0:c2a57b2f934e 479
jmhong 0:c2a57b2f934e 480
jmhong 0:c2a57b2f934e 481
jmhong 0:c2a57b2f934e 482
jmhong 0:c2a57b2f934e 483 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 484 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 485 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 486 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 487 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 488 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 489 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 490 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 491 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 492 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 493 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 494 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 495 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 496 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 497 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 498 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 499 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 500 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 501 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 502 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 503 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 504 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jmhong 0:c2a57b2f934e 505 //send
jmhong 0:c2a57b2f934e 506
jmhong 0:c2a57b2f934e 507
jmhong 0:c2a57b2f934e 508
jmhong 0:c2a57b2f934e 509
jmhong 0:c2a57b2f934e 510
jmhong 0:c2a57b2f934e 511
jmhong 0:c2a57b2f934e 512 /**
jmhong 0:c2a57b2f934e 513 * @brief SendData
jmhong 0:c2a57b2f934e 514 * @param None
jmhong 0:c2a57b2f934e 515 * @retval None
jmhong 0:c2a57b2f934e 516 */
jmhong 0:c2a57b2f934e 517 static int SendData(SimpleSpirit1& myspirit)
jmhong 0:c2a57b2f934e 518 {
jmhong 0:c2a57b2f934e 519 //#ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 520 // printf("[CUBEBITE] SendData() 호출 됨.\n");
jmhong 0:c2a57b2f934e 521 //#endif
jmhong 0:c2a57b2f934e 522 printf("[CUBEBITE] SendData() 호출 됨.\n");
jmhong 0:c2a57b2f934e 523 while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */
jmhong 0:c2a57b2f934e 524
jmhong 0:c2a57b2f934e 525 size_t curr_len = strlen((const char*)uiSendBuf) + 1;
jmhong 0:c2a57b2f934e 526 int iRet = 0;
jmhong 0:c2a57b2f934e 527
jmhong 0:c2a57b2f934e 528 printf("SendData() uiSendBuf -> [%s]\n", uiSendBuf);
jmhong 0:c2a57b2f934e 529 iRet = myspirit.send(uiSendBuf, curr_len);
jmhong 0:c2a57b2f934e 530 if (iRet == RADIO_TX_OK)
jmhong 0:c2a57b2f934e 531 {
jmhong 0:c2a57b2f934e 532 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 533 printf("[RADIO_TX_OK]\n");
jmhong 0:c2a57b2f934e 534 #endif
jmhong 0:c2a57b2f934e 535 return CUBEBITE_SEND_OK;
jmhong 0:c2a57b2f934e 536 }
jmhong 0:c2a57b2f934e 537 else if (iRet == RADIO_TX_ERR)
jmhong 0:c2a57b2f934e 538 {
jmhong 0:c2a57b2f934e 539 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 540 printf("[RADIO_TX_ERR]\n");
jmhong 0:c2a57b2f934e 541 #endif
jmhong 0:c2a57b2f934e 542 return CUBEBITE_SEND_ERROR;
jmhong 0:c2a57b2f934e 543 }
jmhong 0:c2a57b2f934e 544 else if (iRet == RADIO_TX_COLLISION)
jmhong 0:c2a57b2f934e 545 {
jmhong 0:c2a57b2f934e 546 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 547 printf("[RADIO_TX_COLLISION]\n");
jmhong 0:c2a57b2f934e 548 #endif
jmhong 0:c2a57b2f934e 549 return CUBEBITE_SEND_COLLISION;
jmhong 0:c2a57b2f934e 550 }
jmhong 0:c2a57b2f934e 551 else if (iRet == RADIO_TX_NOACK)
jmhong 0:c2a57b2f934e 552 {
jmhong 0:c2a57b2f934e 553 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 554 printf("[RADIO_TX_NOACK]\n");
jmhong 0:c2a57b2f934e 555 #endif
jmhong 0:c2a57b2f934e 556 return CUBEBITE_SEND_NOACK;
jmhong 0:c2a57b2f934e 557 }
jmhong 0:c2a57b2f934e 558
jmhong 0:c2a57b2f934e 559 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 560 printf("[CUBEBITE] SendData() 호출 끝.\n");
jmhong 0:c2a57b2f934e 561 #endif
jmhong 0:c2a57b2f934e 562
jmhong 0:c2a57b2f934e 563 return CUBEBITE_SEND_ERROR_UNKNOWN;
jmhong 0:c2a57b2f934e 564 }
jmhong 0:c2a57b2f934e 565
jmhong 0:c2a57b2f934e 566
jmhong 0:c2a57b2f934e 567 static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit)
jmhong 0:c2a57b2f934e 568 {
jmhong 0:c2a57b2f934e 569 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 570 printf("[CUBEBITE] SendData() 호출 됨.\n");
jmhong 0:c2a57b2f934e 571 #endif
jmhong 0:c2a57b2f934e 572 while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */
jmhong 0:c2a57b2f934e 573
jmhong 0:c2a57b2f934e 574 size_t curr_len = strlen((const char*)uiSendBuf) + 1;
jmhong 0:c2a57b2f934e 575 int iRet = 0;
jmhong 0:c2a57b2f934e 576
jmhong 0:c2a57b2f934e 577 iRet = myspirit.send(uiSendBuf, curr_len);
jmhong 0:c2a57b2f934e 578 if (iRet == RADIO_TX_OK)
jmhong 0:c2a57b2f934e 579 {
jmhong 0:c2a57b2f934e 580 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 581 printf("[RADIO_TX_OK]\n");
jmhong 0:c2a57b2f934e 582 #endif
jmhong 0:c2a57b2f934e 583
jmhong 0:c2a57b2f934e 584 //#ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON
jmhong 0:c2a57b2f934e 585 // if (false == bIsSendFirstClockFunctionStarted)
jmhong 0:c2a57b2f934e 586 // {
jmhong 0:c2a57b2f934e 587 // clocktimeRFSpeedTestStart = clock();
jmhong 0:c2a57b2f934e 588 // bIsSendFirstClockFunctionStarted = true;
jmhong 0:c2a57b2f934e 589 // }
jmhong 0:c2a57b2f934e 590 //#endif
jmhong 0:c2a57b2f934e 591
jmhong 0:c2a57b2f934e 592 return CUBEBITE_SEND_OK;
jmhong 0:c2a57b2f934e 593 }
jmhong 0:c2a57b2f934e 594 else if (iRet == RADIO_TX_ERR)
jmhong 0:c2a57b2f934e 595 {
jmhong 0:c2a57b2f934e 596 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 597 printf("[RADIO_TX_ERR]\n");
jmhong 0:c2a57b2f934e 598 #endif
jmhong 0:c2a57b2f934e 599 return CUBEBITE_SEND_ERROR;
jmhong 0:c2a57b2f934e 600 }
jmhong 0:c2a57b2f934e 601 else if (iRet == RADIO_TX_COLLISION)
jmhong 0:c2a57b2f934e 602 {
jmhong 0:c2a57b2f934e 603 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 604 printf("[RADIO_TX_COLLISION]\n");
jmhong 0:c2a57b2f934e 605 #endif
jmhong 0:c2a57b2f934e 606 return CUBEBITE_SEND_COLLISION;
jmhong 0:c2a57b2f934e 607 }
jmhong 0:c2a57b2f934e 608 else if (iRet == RADIO_TX_NOACK)
jmhong 0:c2a57b2f934e 609 {
jmhong 0:c2a57b2f934e 610 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 611 printf("[RADIO_TX_NOACK]\n");
jmhong 0:c2a57b2f934e 612 #endif
jmhong 0:c2a57b2f934e 613 return CUBEBITE_SEND_NOACK;
jmhong 0:c2a57b2f934e 614 }
jmhong 0:c2a57b2f934e 615
jmhong 0:c2a57b2f934e 616 #ifdef CUBEBITE_DEBUG
jmhong 0:c2a57b2f934e 617 printf("[CUBEBITE] SendData() 호출 끝.\n");
jmhong 0:c2a57b2f934e 618 #endif
jmhong 0:c2a57b2f934e 619
jmhong 0:c2a57b2f934e 620 return CUBEBITE_SEND_ERROR_UNKNOWN;
jmhong 0:c2a57b2f934e 621 }
jmhong 0:c2a57b2f934e 622