180718 HJM : 8 Count sensing data RF send, certTest, temp(cold)Test_

Dependencies:   1_cubebite_ev-cog-ad3029lz_433MHz_1nd_certTest stm-spirit1-rf-driver_for_cubebite2

Fork of cubebite_rnd_ev-cog-ad3029lz_433MHz_2nd_testing2_RF10CountSensingCheckOK_180619_initReviseTest by JunMo Hong

main.cpp

Committer:
jmhong
Date:
2018-03-21
Revision:
0:c2a57b2f934e
Child:
1:04f46755f8af

File content as of revision 0:c2a57b2f934e:

//#include "mbed.h"
#include "ADXL362.h"
//#include "SimpleSpirit1.h"
#include "main.h"


//*************************************************************************************
//Define : Test, Compile 
//*************************************************************************************
/* 180108 cubebite HJM : cubebite Testing define, 1개씩만 켜야 함. */
#define CUBEBITE_RF_SPEED_TEST_SEND_ON
//#define CUBEBITE_RF_SPEED_TEST_RECV_ON


/* 180109 cubebite HJM : cubebite Compile define, 1개씩만 켜야 함. */
//#define CUBEBITE_BOARD_F746ZG
//#define CUBEBITE_BOARD_F401RE
#define CUBEBITE_BOARD_AD3029LZ


#define CUBEBITE_RF_SETTING_VALUE_PRINT
//*************************************************************************************

#define HEAVY_DEBUG



//DigitalOut led1(LED1);
//DigitalOut led2(LED2);
//ADXL362 adxl362(P1_07, P1_08, P1_06, P1_10);  // Accelerometer (mosi, miso, sclk, cs), SPI 1 
//ADXL362 adxl362(P0_01, P0_02, P0_00, P0_03);  // Accelerometer (mosi, miso, sclk, cs), SPI 0


//180321 HJM : IRQ를 GPIO 28 로 사용, send error를 띄움
//static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 ,P2_08, P1_14);  
//                         // P0_01[SPI0_MOSI]
//                          // P0_02[SPI0_MISO], 
//                          // P0_00[SPI0_CLK], 
//                        // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, 
//                        // P2_08[SPI0_CS2], 
//                        // P1_14[GPIO 30, RF (SDN)]


//180321 HJM : IRQ를 GPIO 27 로 사용,
static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_11 ,P2_08, P1_14);  
                        // P0_01[SPI0_MOSI]
                        // P0_02[SPI0_MISO], 
                        // P0_00[SPI0_CLK], 
                        // P1_11[GPIO 27, RF(GPIO 2)]->IRQ로 설정, 
                        // P2_08[SPI0_CS2], 
                        // P1_14[GPIO 30, RF (SDN)]













//static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 ,P2_08, P1_14);  
//                         // P0_01[SPI0_MOSI]
//                          // P0_02[SPI0_MISO], 
//                          // P0_00[SPI0_CLK], 
//                        // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
//                        // P2_08[SPI0_CS2], 
//                        // P1_14[GPIO 30, RF (SDN)]



//static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 , SPI0_CS2, P1_14);  
//                         // P0_01[SPI0_MOSI]
//                          // P0_02[SPI0_MISO], 
//                          // P0_00[SPI0_CLK], 
//                        // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
//                        // P2_08[SPI0_CS2], 
//                        // P1_14[GPIO 30, RF (SDN)]


                        
//static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P1_03, P1_04, P1_02, P1_12 ,P2_10, P1_14);  
                         // P1_03[SPI2_MOSI]
                          // P1_04[SPI2_MISO], 
                          // P1_02[SPI2_CLK], 
                        // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, (이건 맞음, 찍었을때 파형나옴)
                        // P2_10[SPI2_CS2], 
                        // P1_14[GPIO 30, RF (SDN)]




static int ReadRcvdData(SimpleSpirit1& myspirit);
static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit);

static int SendData(SimpleSpirit1& myspirit);
static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit);


enum RecvReturnValue
{
    CUBEBITE_RECV_OK = 0, CUBEBITE_RECV_ERROR_READ_NOTHING, CUBEBITE_RECV_ERROR_READ_NOT_MATCH
};

enum SendReturnValue
{
    CUBEBITE_SEND_OK = 0, CUBEBITE_SEND_ERROR, CUBEBITE_SEND_COLLISION, CUBEBITE_SEND_NOACK, CUBEBITE_SEND_ERROR_UNKNOWN
};


/**
 * @brief  callback_func
 * @param  callback event
 * @retval None.
 */
static void callback_func(int event) 
{
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] callback_func(int event) \n");
#endif

  
    if(event == SimpleSpirit1::RX_DONE) 
    {         
        bRxDoneFlag = 1;
    }
    else if (event == SimpleSpirit1::TX_DONE) 
    {  
        bTxDoneFlag = 1;
    }
}


//HJM I2C PullUp Test
DigitalIn TempSupply(P1_11);


// main() runs in its own thread in the OS
int main() 
{
    // local variables
    int8_t x8 = 0;
    int8_t y8 = 0;
    int8_t z8 = 0;  
    uint8_t reg;
    int iReturn;
    
    printf("Hi Eureka!\r\n");
    
//    TempSupply.write(1);
    
    //// set up SPI interface
//    adxl362.init_spi();
//    
//    // Set up accelerometer
//    adxl362.init_adxl362(); 
//    
//    // Check settings
//    reg = adxl362.ACC_ReadReg(FILTER_CTL);
//    printf("FILTER_CTL = 0x%X\r\n", reg);
//    
    
    printf("P0_00 : [%d]      (0 << GPIO_PORT_SHIFT | 0 ) : [%d]\n", P0_00, (0 << GPIO_PORT_SHIFT | 0 ));
    printf("P1_00 : [%d]      (1 << GPIO_PORT_SHIFT | 0 ) : [%d]\n", P1_00, (1 << GPIO_PORT_SHIFT | 0 ));
    
    
    
    //printf("\n\nPIN Number 16, P2_03, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_03);
//    printf("PIN Number 17, P2_04, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_04);
//    printf("PIN Number 18, P2_05, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_05);
//    printf("PIN Number 19, P2_06, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_06);
//    printf("PIN Number 20, P2_07, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_07);
//    printf("PIN Number 21, P2_08, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_08);
//    printf("PIN Number 22, P2_09, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_09);
//    printf("PIN Number 23, P2_10, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P2_10);
//    printf("PIN Number 24, P0_05, ADC0_VIN0/GPIO35 : 십진수 -> [%d], 십육진수 -> [0x%X]\n", P0_05);
    
/* 180108 cubebite HJM : spirit module, init code  */
    printf("[CUBEBITE] Init ");
    /* LED off */
//    TestLED = 0; 
    myspirit.attach_irq_callback(callback_func);  
    iReturn = myspirit.on();
    if ( 0 == iReturn )
    {
        printf("OK.\n");    
    }
    else
    {
        printf("ERROR.\n");
    }
    
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] CUBEBITE_DEBUG ON. \n");
#endif  //CUBEBITE_DEBUG


#ifdef  CUBEBITE_RF_SETTING_VALUE_PRINT
    printf("Xtal offset in ppm              : [%d]\n", XTAL_OFFSET_PPM);
    printf("base frequency                  : [%d]\n", (uint32_t)BASE_FREQUENCY);
    printf("channel space                   : [%d]\n", (uint32_t)CHANNEL_SPACE);
    printf("channel number                  : [%d]\n", CHANNEL_NUMBER);    
    printf("modulation select               : [%d]\n", MODULATION_SELECT);
    printf("data rate                       : [%d]\n", DATARATE);
    printf("frequency deviation             : [%d]\n", (uint32_t)FREQ_DEVIATION);
    printf("channel filter bandwidth        : [%d]\n", (uint32_t)BANDWIDTH);
    #ifdef  CUBEBITE_RF_SPEED_TEST_SEND_ON    
    printf("\nOutput Power(dBm)             : [%f]\n", POWER_DBM);
//    printf("\nOutput Power(dBm)             : [%f]\n", (float)CUBEBITE_OUTPUT_POWER_DBM_TEST);
    
    #endif  //CUBEBITE_RF_SPEED_TEST_SEND_ON
    
    #ifdef  CUBEBITE_RF_SPEED_TEST_RECV_ON
    printf("\nRSSI threshold Setting value  : [%d]\n", (int)CCA_THRESHOLD);
    #endif  //CUBEBITE_RF_SPEED_TEST_RECV_ON
    
    wait(2);
#endif  //CUBEBITE_RF_SETTING_VALUE_PRINT
    
    while(1) 
    {
        /* low power in idle condition., waiting for an event */
//        __WFE(); 
        
        

        
        
        
        
#ifdef  CUBEBITE_RF_SPEED_TEST_SEND_ON  
        iReturn = SendData(myspirit);
        if (CUBEBITE_SEND_OK == iReturn)
        {
            printf("[DEBUG] send OK.\n");
        }
        else if (CUBEBITE_SEND_ERROR == iReturn)
        {
            printf("[DEBUG] send ERROR.\n");
        }
        
        iReturn = (int)myspirit.get_last_sqi(); //HJM : LQI, 현재 주변 통신 품질 값, 높을수록 좋은 것.
        printf("get_last_sqi() return       : [%d]\n", iReturn);
#endif

#ifdef  CUBEBITE_RF_SPEED_TEST_RECV_ON
        if (bRxDoneFlag)
        {            
            iReturn = ReadRcvdData(myspirit);      
            if (CUBEBITE_RECV_OK == iReturn)
            {
                //통신 속도 체크시, 응답 send code.
                printf("[DEBUG] recv OK.\n");
                
                float fReturn1 = myspirit.get_last_rssi_dbm();
                printf("get_last_rssi_dbm() return       : [%f]\n", fReturn1);  //HJM : 위의 값과 같을 거라고 예상 됨. 나중에 테스트.    
                if (-50 < fReturn1)   //-80 < fReturn1
                {
                    TestLED3 = !TestLED3;     /* Toggle LED at the receiver */                    
                }
                else if (-50 >= fReturn1)
                {
//                    TestLED = !TestLED;     /* Toggle LED at the receiver */
                    TestLED2 = !TestLED2;     /* Toggle LED at the receiver */                    
//                    TestLED3 = !TestLED3;     /* Toggle LED at the receiver */
                }                
                else if (-70 >= fReturn1)    //-100 >= fReturn1
                {
                    TestLED = !TestLED;     /* Toggle LED at the receiver */                    
                }
            }
            bRxDoneFlag = 0;                        
        }
#endif        
        
    }
  /* unreachable */
  // myspirit.off();
  // return 0;
    
}




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//recv






/**
 * @brief  ReadRcvdData
 * @param  None
 * @retval None
 */
static int ReadRcvdData(SimpleSpirit1& myspirit)
{  
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n");  
#endif
 
    for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */
    

    int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf));    
    if (ret == 0) 
    {
        printf("[CUBEBITE] Read() Error : Nothing to read\n");
        return CUBEBITE_RECV_ERROR_READ_NOTHING;
    }
    printf("ReadRcvdData() 1");
    
    printf("[DEBUG]recv -> %s ", uiRendBuf);

    ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf);
    printf(" 3");
    if (0 == ret)
    {        
//        set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정
//        printf("read, send buf collect!!\n");
//        TestLED = !TestLED;     /* Toggle LED at the receiver */
        printf(" 4");
//        bIsAckSended = true;
//        printf("[DEBUG]recv -> %s\n", uiRendBuf);
#ifdef  CUBEBITE_DEBUG
        printf("[DEBUG]recv -> %s\n", uiRendBuf);
#endif

        //746zg 보드        
//        wait(1.0);
/*
        int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen);
        if (iRet == RADIO_TX_OK)
        {
        #ifdef  CUBEBITE_DEBUG
            printf("ACK : [RADIO_TX_OK]\n");
        #endif
        }
        else if (iRet == RADIO_TX_ERR)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_ERR]\n");
        #endif
        }
        else if (iRet == RADIO_TX_COLLISION)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_COLLISION]\n");
        #endif            
        }
        else if (iRet == RADIO_TX_NOACK)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_NOACK]\n");
        #endif
        }                          
        */
        
        return CUBEBITE_RECV_OK;
        printf(" 5 ok\n");
    }


#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n");  
#endif

    return CUBEBITE_RECV_ERROR_READ_NOT_MATCH;
    printf(" 6 error\n");
}



static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit)
{  
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n");  
#endif
 
    for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */

    int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf));
    if (ret == 0) 
    {
        printf("[CUBEBITE] Read() Error : Nothing to read\n");
        return CUBEBITE_RECV_ERROR_READ_NOTHING;
    }
#ifdef  CUBEBITE_RF_SPEED_TEST_RECV_ON
    ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf);
    if (0 == ret)
    {        
//        set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정
//        printf("read, send buf collect!!\n");
        TestLED = !TestLED;     /* Toggle LED at the receiver */
//        bIsAckSended = true;
#ifdef  CUBEBITE_DEBUG
        printf("[DEBUG]recv -> %s\n", uiRendBuf);
#endif

        //746zg 보드        
//        wait(1.0);
/*
        int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen);
        if (iRet == RADIO_TX_OK)
        {
        #ifdef  CUBEBITE_DEBUG
            printf("ACK : [RADIO_TX_OK]\n");
        #endif
        }
        else if (iRet == RADIO_TX_ERR)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_ERR]\n");
        #endif
        }
        else if (iRet == RADIO_TX_COLLISION)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_COLLISION]\n");
        #endif            
        }
        else if (iRet == RADIO_TX_NOACK)
        {
        #ifdef  CUBEBITE_DEBUG            
            printf("ACK : [RADIO_TX_NOACK]\n");
        #endif
        }                          
        */
        
        return CUBEBITE_RECV_OK;
    }
#endif

//#ifdef  CUBEBITE_RF_SPEED_TEST_SEND_ON 
//    //401re 보드
//    if (true == bIsSendFirstClockFunctionStarted)
//    {
//        clocktimeRFSpeedTestEnd = clock();
//    } 
//    //printf("[DEBUG]recv -> %s\n", uiRendBuf);
//#endif    


#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n");  
#endif

    return CUBEBITE_RECV_ERROR_READ_NOT_MATCH;
}






///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//send






/**
 * @brief  SendData
 * @param  None
 * @retval None
 */
static int SendData(SimpleSpirit1& myspirit)
{
//#ifdef  CUBEBITE_DEBUG
//    printf("[CUBEBITE] SendData() 호출 됨.\n");
//#endif
    printf("[CUBEBITE] SendData() 호출 됨.\n");
    while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */

    size_t curr_len = strlen((const char*)uiSendBuf) + 1;
    int iRet = 0;

    printf("SendData() uiSendBuf -> [%s]\n", uiSendBuf);
    iRet = myspirit.send(uiSendBuf, curr_len);
    if (iRet == RADIO_TX_OK)
    {
#ifdef  CUBEBITE_DEBUG        
        printf("[RADIO_TX_OK]\n");
#endif
        return CUBEBITE_SEND_OK;
    }
    else if (iRet == RADIO_TX_ERR)
    {
#ifdef  CUBEBITE_DEBUG
        printf("[RADIO_TX_ERR]\n");
#endif
        return CUBEBITE_SEND_ERROR;
    }
    else if (iRet == RADIO_TX_COLLISION)
    {
#ifdef  CUBEBITE_DEBUG        
        printf("[RADIO_TX_COLLISION]\n");
#endif        
        return CUBEBITE_SEND_COLLISION;
    }
    else if (iRet == RADIO_TX_NOACK)
    {
#ifdef  CUBEBITE_DEBUG                
        printf("[RADIO_TX_NOACK]\n");
#endif  
        return CUBEBITE_SEND_NOACK;              
    }
    
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] SendData() 호출 끝.\n");
#endif

    return CUBEBITE_SEND_ERROR_UNKNOWN;
}


static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit)
{
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] SendData() 호출 됨.\n");
#endif
    while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */

    size_t curr_len = strlen((const char*)uiSendBuf) + 1;
    int iRet = 0;

    iRet = myspirit.send(uiSendBuf, curr_len);
    if (iRet == RADIO_TX_OK)
    {
#ifdef  CUBEBITE_DEBUG        
        printf("[RADIO_TX_OK]\n");
#endif

//#ifdef  CUBEBITE_RF_SPEED_TEST_SEND_ON     
//        if (false == bIsSendFirstClockFunctionStarted)
//        {
//            clocktimeRFSpeedTestStart = clock();    
//            bIsSendFirstClockFunctionStarted = true;            
//        }
//#endif

        return CUBEBITE_SEND_OK;
    }
    else if (iRet == RADIO_TX_ERR)
    {
#ifdef  CUBEBITE_DEBUG
        printf("[RADIO_TX_ERR]\n");
#endif
        return CUBEBITE_SEND_ERROR;
    }
    else if (iRet == RADIO_TX_COLLISION)
    {
#ifdef  CUBEBITE_DEBUG        
        printf("[RADIO_TX_COLLISION]\n");
#endif        
        return CUBEBITE_SEND_COLLISION;
    }
    else if (iRet == RADIO_TX_NOACK)
    {
#ifdef  CUBEBITE_DEBUG                
        printf("[RADIO_TX_NOACK]\n");
#endif  
        return CUBEBITE_SEND_NOACK;              
    }
    
#ifdef  CUBEBITE_DEBUG
    printf("[CUBEBITE] SendData() 호출 끝.\n");
#endif

    return CUBEBITE_SEND_ERROR_UNKNOWN;
}