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

Fork of EV-COG-AD3029LZ by JunMo Hong

Files at this revision

API Documentation at this revision

Comitter:
jmhong
Date:
Wed Jul 18 05:44:03 2018 +0000
Parent:
84:45b9ff78a066
Commit message:
cubebite hjm 180718

Changed in this revision

source/SimpleSpirit1.cpp Show annotated file Show diff for this revision Revisions of this file
source/libs/Contiki_STM32_Library/spirit1.h Show annotated file Show diff for this revision Revisions of this file
source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Management.c Show annotated file Show diff for this revision Revisions of this file
source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Radio.c Show annotated file Show diff for this revision Revisions of this file
source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Types.c Show annotated file Show diff for this revision Revisions of this file
stm-spirit1-rf-driver/SimpleSpirit1.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/SimpleSpirit1.cpp	Fri Jun 22 03:42:24 2018 +0000
+++ b/source/SimpleSpirit1.cpp	Wed Jul 18 05:44:03 2018 +0000
@@ -14,7 +14,7 @@
 
 //180619 HJM : init 재시작을 위한 카운팅 변수
 static int iErrorCounting = 0;
-#define	MAX_ERROR_COUNTING	10
+#define	MAX_ERROR_COUNTING	3
 #define RETURN_ERROR_NUMBER     100
 
 
@@ -22,6 +22,8 @@
 //#define SPIRIT_GPIO_IRQ			(SPIRIT_GPIO_2)
 //#define SPIRIT_GPIO_IRQ			(SPIRIT_GPIO_1)	//EV-COG-AD3029LZ -> GPIO 8 -> P0_08
 
+static int iIsResetStartCountingSimpleSpirit1 = 0;
+
 static uint16_t last_state;
 #define SPIRIT1_STATUS()		((last_state = (uint16_t)refresh_state()) & SPIRIT1_STATE_STATEBITS)
 
@@ -81,12 +83,13 @@
 /** Init Function **/
 void SimpleSpirit1::init()
 {
-    printf("[INIT_REVISE]init start...\n");
+    printf("[RF] init start");
     //if (false == isItDoItSPIInit)
 //    {
 //    	isItDoItSPIInit = true;
 
     /*cubebite HJM, reset irq disable counter and irq callback & disable irq */
+    
     _nr_of_irq_disables = 0;		// @@
     disable_spirit_irq();
 
@@ -97,7 +100,7 @@
     _spi.format(8, 0); /* 8-bit, mode = 0, [order = SPI_MSB] only available in mbed3 */
 
     _spi.frequency(_uint32SpiClkSettingValue);	//HJM 초기 값, 6500000
-    printf("Setting spi clk : [%d]\r\n", _uint32SpiClkSettingValue);
+//    printf("Setting spi clk : [%d]\r\n", _uint32SpiClkSettingValue);
 
     //    _spi.frequency(13000000); // 13MHz (i.e. max speed allowed for Spirit1)
     //    _spi.frequency(6500000); // 6.5MHz (i.e. max speed allowed for Spirit1)
@@ -126,7 +129,7 @@
 
 
     /*cubebite HJM, set frequencies */
-    printf("[INIT_REVISE]set frequencies...");
+    printf("\n set frequencies...");
     radio_set_xtal_freq(XTAL_FREQUENCY);			//cubebite HJM, 50MHz, 180619 HJM : 단순히 변수 셋팅
     mgmt_set_freq_base((uint32_t)BASE_FREQUENCY);	// @@
     printf("OK\n");
@@ -147,7 +150,7 @@
     //180619 HJM : 여기서 부터는 init while문이 들어감.
     /*cubebite HJM, Configures the SPIRIT1 radio part */
     //180119 HJM : 433MHz 설정으로 변경 후 테스트.
-    printf("[INIT_REVISE]set SPIRIT1 radio...\n");
+//    printf("[INIT_REVISE]set SPIRIT1 radio...\n");
     SRadioInit x_radio_init = {
         XTAL_OFFSET_PPM,                       // Xtal offset in ppm
         (uint32_t)BASE_FREQUENCY,	// HJM 수정 후 테스트 중 base frequency
@@ -163,10 +166,11 @@
 
 
 
+	printf("\n radio_init()\n");
     uint8_t ui8Return;
     ui8Return = radio_init(&x_radio_init);
     if (RETURN_ERROR_NUMBER == ui8Return) 
-    {//180621 HJM : 여기서는 reset을 해주는게 맞는게, init 은 전역의 spirit1 의 객체가 생성될 때 호출되기 때문이다. 다시 init을 호출해서 종료 시켜야, 아.. return 이 빠졌네
+    {
         reset_board();
         return;
     }
@@ -177,7 +181,7 @@
 
     /*180117 HJM : 송신 신호 세기 */
     radio_set_pa_level_dbm(0,POWER_DBM);	///hjm test
-    //	radio_set_pa_level_dbm(0,10.0);
+//    	radio_set_pa_level_dbm(0,7.0);
     //    radio_set_pa_level_dbm(0,CUBEBITE_OUTPUT_POWER_DBM_TEST);
     radio_set_pa_level_max_index(0);
 
@@ -267,7 +271,7 @@
 #endif // USE_STANDBY_STATE
 
 //	}
-    printf("[INIT_REVISE]init end.\n");
+    printf("(OK)\n");
 }
 
 
@@ -279,11 +283,13 @@
 static const volatile uint8_t *tx_fifo_buffer = NULL; // to be used in irq handler
 int SimpleSpirit1::send(const void *payload, unsigned int payload_len, bool use_csma_ca)
 {
+    int iRet = 0; 
     /* Checks if the payload length is supported */
 //    printf("\r\n[SEND] 1, MAX_PACKET_LEN : [%d]\n", MAX_PACKET_LEN);
 //    printf("[SEND] 2, payload_len : [%d]\n", payload_len);
 
-    if(payload_len > MAX_PACKET_LEN) {
+    if(payload_len > MAX_PACKET_LEN) 
+    {
 //        printf("[SEND] \n");
         return RADIO_TX_ERR;
     }
@@ -296,7 +302,7 @@
 
 
 
-
+	printf("send [1");
     disable_spirit_irq();
 
     BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, STATE_TIMEOUT);
@@ -325,21 +331,19 @@
         	
         }
         //180619 HJM : 아예 여기서 걸리면 흘러가게 냅두면 spirit1 이 꼬인다.
-//        ++iErrorCounting;
-        //if (iErrorCounting >= MAX_ERROR_COUNTING)
-//        {
-//        	iErrorCounting = 0;    	
-//        	return RADIO_TX_ERR_RESET;
-////
-////        	reset_board();
-//        }
+        ++iErrorCounting;
+        if (iErrorCounting >= MAX_ERROR_COUNTING)
+        {
+        	iErrorCounting = 0;    	
+        	return RADIO_TX_ERR_RESET;
+        }
 //
         return RADIO_TX_ERR;
     }
     iErrorCounting = 0;
 
 
-
+	printf(" 2");
     //if (SPIRIT1_STATE_RX == SPIRIT1_STATUS())
 //    {
 //    	printf("[SEND] error \n");
@@ -360,10 +364,24 @@
 
 
     /* Reset State to Ready */
+    printf(" 3");
 //    printf("[SEND] 3, set_ready_state() call,  \n");
-    set_ready_state();
 
+    iRet = set_ready_state();
+    //if (iRet == RETURN_ERROR_NUMBER)
+//    {
+//    	++iErrorCounting;
+//        if (iErrorCounting >= MAX_ERROR_COUNTING)
+//        {
+//        	iErrorCounting = 0;    	
+//        	return RADIO_TX_ERR_RESET;
+//        }
+//        
+//    	return RADIO_TX_ERR;
+//    }
+    
 
+	printf(" 4");
 //	printf("[SEND] 4, cmd_strobe() call, SPIRIT1_STROBE_FTX \n");
     cmd_strobe(SPIRIT1_STROBE_FTX); // flush TX FIFO buffer
 
@@ -371,6 +389,7 @@
     debug_if(!(linear_fifo_read_num_elements_tx_fifo() == 0), "\r\nAssert failed in: %s (%d)\r\n", __func__, __LINE__);
 #endif
 
+	printf(" 5");
 //	printf("[SEND] 5, pkt_basic_set_payload_length() call, \n");
     pkt_basic_set_payload_length(payload_len); // set desired payload len
 
@@ -379,26 +398,32 @@
         csma_ca_state(S_ENABLE); // enable CSMA/CA
     }
 
+	printf(" 6");
     /* Init buffer & number of bytes to be send */
 //    printf("[SEND] 7, csma_ca_state() call, \n");
     tx_fifo_remaining = payload_len;
     tx_fifo_buffer = (const uint8_t*)payload;
 
+	printf(" 7");
     int8_t fifo_available = SPIRIT_MAX_FIFO_LEN; // fill-up whole fifo
     int8_t to_send = (tx_fifo_remaining > fifo_available) ? fifo_available : tx_fifo_remaining;
 
+	printf(" 8");
     tx_fifo_remaining -= to_send;
 
+	printf(" 9");
     /* Fill FIFO Buffer */
-    if(to_send > 0) {
+    if(to_send > 0) 
+    {
 //    	printf("[SEND] 8, if(to_send > 0), if(to_send > 0) \n");
         spi_write_linear_fifo(to_send, (uint8_t*)&tx_fifo_buffer[0]);
 //        printf("[SEND] 9, if(to_send > 0), if(to_send > 0) \n");
     }
-
+	printf(" 10");
     tx_buffer_pos = to_send;
     _spirit_tx_started = true;
 
+	printf(" 11");
     enable_spirit_irq();
 //    printf(" 6");
 
@@ -418,8 +443,10 @@
 
     /* Start transmitting */
 //    printf("[SEND] 10, Start transmitting \n");
+	printf(" 12");
     cmd_strobe(SPIRIT1_STROBE_TX);
 
+	printf(" 13");
     while(tx_fifo_remaining != 0); // wait until not everything is yet send (evtl. by irq handler)
 
     /*
@@ -447,7 +474,7 @@
 
 
 
-
+	printf(" 14");
 //	printf("[SEND] 11, Start transmitting end, BUSYWAIT_UNTIL \n");
     BUSYWAIT_UNTIL(!_spirit_tx_started, STATE_TIMEOUT);
 
@@ -479,7 +506,7 @@
     debug("\r\n%s (%d): state=%x, _spirit_tx_started=%d\r\n", __func__, __LINE__, SPIRIT1_STATUS()>>1, _spirit_tx_started);
 #endif
 
-
+	printf(" 15");
     if(use_csma_ca) {
         csma_ca_state(S_DISABLE); // disable CSMA/CA
     }
@@ -496,9 +523,11 @@
 
     //180323 HJM : irq가 작동하지 않아 수동으로 irq 값을 읽어 오기로 결정됬다.
     //이걸 while 로 가둬서 send 하기 전에 검토하면 된다.
-
+	printf(" 16");
     int iCounting = 0;
-    while(1) {
+    while(1) 
+    {
+//        printf(" 16-1");
         st_lib_spirit_irqs x_irq_status;
 
         irq_get_status(&x_irq_status);
@@ -510,29 +539,33 @@
 //	    BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_TX, STATE_TIMEOUT);
 
 
-        if(x_irq_status.IRQ_TX_DATA_SENT) {
-
+//		printf(" 16-2");
+        if(x_irq_status.IRQ_TX_DATA_SENT) 
+        {
 #ifdef DEBUG_IRQ
 //            uint32_t *tmp = (uint32_t*)&x_irq_status;
 //            debug_if(!((*tmp) & IRQ_TX_DATA_SENT_MASK), "\r\nAssert failed in: %s (%d)\r\n", __func__, __LINE__);
 //            debug_if(tx_fifo_remaining != 0, "\r\nAssert failed in: %s (%d)\r\n", __func__, __LINE__);
 #endif
-
-            if(_spirit_tx_started) {
+//			printf(" 16-3");
+            if(_spirit_tx_started) 
+            {
 #ifdef	CUBEBITE_DEBUG
                 printf("[IRQ] if(x_irq_status.IRQ_TX_DATA_SENT) in, if(_spirit_tx_started) in \n");
 #endif
 
             }
 
-
+//			printf(" 16-4");
             x_irq_status.IRQ_TX_FIFO_ALMOST_EMPTY = S_RESET;
             tx_fifo_buffer = NULL;
 
             _spirit_tx_started = false;
 
             break;
-        } else {
+        } 
+        else 
+        {
 #ifdef	CUBEBITE_DEBUG
             printf("not yet sent!!!\n");
 #endif	//CUBEBITE_DEBUG	
@@ -542,9 +575,10 @@
 
 
 
-
+//			printf(" 17");
         /* The IRQ_TX_FIFO_ALMOST_EMPTY notifies an nearly empty TX fifo */
-        if(x_irq_status.IRQ_TX_FIFO_ALMOST_EMPTY) {
+        if(x_irq_status.IRQ_TX_FIFO_ALMOST_EMPTY) 
+        {
 //        	printf("1\n");
 //            printf("[IRQ] if(x_irq_status.IRQ_TX_FIFO_ALMOST_EMPTY) in\n");
 
@@ -559,7 +593,8 @@
             tx_fifo_remaining -= to_send;
 
             /* Fill FIFO Buffer */
-            if(to_send > 0) {
+            if(to_send > 0) 
+            {
                 spi_write_linear_fifo(to_send, (uint8_t*)&tx_fifo_buffer[tx_buffer_pos]);
             }
             tx_buffer_pos += to_send;
@@ -568,7 +603,8 @@
 
 
         /* TX FIFO underflow/overflow error */
-        if(x_irq_status.IRQ_TX_FIFO_ERROR) {
+        if(x_irq_status.IRQ_TX_FIFO_ERROR) 
+        {
 #ifdef	CUBEBITE_DEBUG
             printf("[IRQ] if(x_irq_status.IRQ_TX_FIFO_ERROR) in\n");
 #endif	//CUBEBITE_DEBUG		
@@ -595,18 +631,17 @@
 
 
 
-
-        if (10 == iCounting) {
-            //180327 HJM : 10번이나 검색을 했는데 IRQ가 이상이 있으면 정말 이상이 있다고 생각하고 그냥 break
+		
+        if (50 == iCounting) 
+        {
+            //180327 HJM : 50번이나 검색을 했는데 IRQ가 이상이 있으면 정말 이상이 있다고 생각하고 그냥 break
 #ifdef  CUBEBITE_DEBUG
             printf("if (1000 == iCounting) \n");
 #endif
-            iCounting = 0;
+            iCounting = 0;                    
+            
             return RADIO_TX_ERR;
-
         }
-
-
     }
 
 
@@ -635,27 +670,40 @@
 
 
 
-
+	printf(" 18");
     cmd_strobe(SPIRIT1_STROBE_RX); // Return to RX state
 
 //	printf("[SEND] 12, Start transmitting end, BUSYWAIT_UNTIL \n");
     disable_spirit_irq();
-    if(_spirit_tx_started) {
+    if(_spirit_tx_started) 
+    {
         // in case of state timeout
         _spirit_tx_started = false;
         enable_spirit_irq();
 
 //        printf("[SEND] 13, if(_spirit_tx_started), in case of state timeout, return RADIO_TX_ERR \n");
-
+		printf(" 19, err\n");
+		++iIsResetStartCountingSimpleSpirit1;
+		
+		if (10 < iIsResetStartCountingSimpleSpirit1)
+		{
+			iIsResetStartCountingSimpleSpirit1 = 0;
+			return RADIO_TX_ERR_RESET;
+		}
+		
         return RADIO_TX_ERR;
-    } else {
+    } 
+    else 
+    {
         enable_spirit_irq();
         /* call user callback */
-        if(_current_irq_callback) {
+        if(_current_irq_callback) 
+        {
             _current_irq_callback(TX_DONE);
         }
 //        printf("[SEND] 13, else, in case of state timeout, return RADIO_TX_OK \n");
-
+		printf(" 19, ok\n");
+		iIsResetStartCountingSimpleSpirit1 = 0;
         return RADIO_TX_OK;
     }
 }
@@ -676,14 +724,19 @@
     CLEAR_TXBUF();
 
     state = SPIRIT1_STATUS();
-    if(state == SPIRIT1_STATE_STANDBY) {
+    if(state == SPIRIT1_STATE_STANDBY) 
+    {
 //        printf("[SEND] 3-1, set_ready_state() call, if(state == SPIRIT1_STATE_STANDBY) in \n");
         cmd_strobe(SPIRIT1_STROBE_READY);
-    } else if(state == SPIRIT1_STATE_RX) {
+    } 
+    else if(state == SPIRIT1_STATE_RX) 
+    {
 //        printf("[SEND] 3-2, set_ready_state() call, if(state == SPIRIT1_STATE_RX) in \n");
         cmd_strobe(SPIRIT1_STROBE_SABORT);
     } else if(state != SPIRIT1_STATE_READY) 
     {
+    	return RETURN_ERROR_NUMBER;
+    	
 #ifndef NDEBUG
         debug("\r\nAssert failed in: %s (%d): state=%x\r\n", __func__, __LINE__, state>>1);
 #endif
--- a/source/libs/Contiki_STM32_Library/spirit1.h	Fri Jun 22 03:42:24 2018 +0000
+++ b/source/libs/Contiki_STM32_Library/spirit1.h	Wed Jul 18 05:44:03 2018 +0000
@@ -179,25 +179,83 @@
 
 //------------433Mhz------------
 //작동 되는 셋팅
+//#ifdef	USE_SPIRIT1_433MHz
+//#define CHANNEL_SPACE				20e3	//해봄
+//#define FREQ_DEVIATION              127e3	//recv
+////#define FREQ_DEVIATION              50e3	//send
+////#define BANDWIDTH                   50.0e3	
+////#define BANDWIDTH                   70.0e3	//printf 다 끄니까 1000바이트정도 보내다가 뻗음
+////#define BANDWIDTH                   100.0e3	//printf 다 끄니까 900바이트정도 보내다가 뻗음
+//#define BANDWIDTH                   100.5e3	//printf 다 끄니까 900바이트정도 보내다가 뻗음
+//
+////#define BANDWIDTH                   540.0e3
+//#define MODULATION_SELECT           GFSK_BT1
+//#define DATARATE                    250000	//180326 HJM : 잘 됨
+////#define DATARATE                    500000	//180326 HJM : 잘 안됨
+////#define DATARATE                    300000	//180326 HJM : 잘 안됨
+////#define DATARATE                    38400	
+//#endif	//USE_SPIRIT1_433MHz
+//------------433Mhz------------
+
+
+
+
+
+
+
+
+
+
+
+
+//------------433Mhz------------
+//HJM : 안테나 변경(방수 안테나)로 인한 셋팅 변경
 #ifdef	USE_SPIRIT1_433MHz
 #define CHANNEL_SPACE				20e3	//해봄
 #define FREQ_DEVIATION              127e3	//recv
-//#define FREQ_DEVIATION              50e3	//send
-//#define BANDWIDTH                   50.0e3	
+//#define FREQ_DEVIATION              50.0e3	//send
+#define BANDWIDTH                   50.0e3	
+//#define BANDWIDTH                   60.0e3	//printf 다 끄니까 1000바이트정도 보내다가 뻗음
 //#define BANDWIDTH                   70.0e3	//printf 다 끄니까 1000바이트정도 보내다가 뻗음
 //#define BANDWIDTH                   100.0e3	//printf 다 끄니까 900바이트정도 보내다가 뻗음
-#define BANDWIDTH                   100.5e3	//printf 다 끄니까 900바이트정도 보내다가 뻗음
+//#define BANDWIDTH                   100.5e3	//printf 다 끄니까 900바이트정도 보내다가 뻗음
 
 //#define BANDWIDTH                   540.0e3
-#define MODULATION_SELECT           GFSK_BT1
+//#define MODULATION_SELECT           GFSK_BT1
+#define MODULATION_SELECT			FSK
 #define DATARATE                    250000	//180326 HJM : 잘 됨
 //#define DATARATE                    500000	//180326 HJM : 잘 안됨
 //#define DATARATE                    300000	//180326 HJM : 잘 안됨
+//#define DATARATE                    115200	//180326 HJM : 잘 안됨
 //#define DATARATE                    38400	
 #endif	//USE_SPIRIT1_433MHz
 //------------433Mhz------------
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 //#define CHANNEL_SPACE               100e3
 //#define FREQ_DEVIATION              127e3
 //#define BANDWIDTH                   540.0e3
--- a/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Management.c	Fri Jun 22 03:42:24 2018 +0000
+++ b/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Management.c	Wed Jul 18 05:44:03 2018 +0000
@@ -54,7 +54,7 @@
 
 //180619 HJM : init 재시작을 위한 카운팅 변수
 static int iSpiritManagementErrorCounting = 0;
-#define MAX_ERROR_COUNTING  10
+#define MAX_ERROR_COUNTING  3
 #define RETURN_ERROR_NUMBER     100
 
 
@@ -241,16 +241,16 @@
   SpiritCalibrationVco(S_ENABLE);
   
   SpiritRefreshStatus();
-  printf("test 9-3 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
+//  printf("test 9-3 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
   if(g_xStatus.MC_STATE == MC_STATE_STANDBY)
   {
     cStandby = 1;
     SpiritCmdStrobeReady();
-    printf("test 9-3 1 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);    
+//    printf("test 9-3 1 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);    
     do
     {
       SpiritRefreshStatus();
-      printf("test 9-3 2 g_xStatus.MC_STATE : [0x%02X]\n", g_xStatus.MC_STATE);      
+//      printf("test 9-3 2 g_xStatus.MC_STATE : [0x%02X]\n", g_xStatus.MC_STATE);      
       if(g_xStatus.MC_STATE == 0x13)
       {
         return 1;
@@ -272,11 +272,11 @@
   
   
   SpiritCmdStrobeLockTx();
-  printf("test 9-4 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
+//  printf("test 9-4 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
   do
   {
     SpiritRefreshStatus();
-    printf("test 9-4 1 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
+//    printf("test 9-4 1 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
     if(g_xStatus.MC_STATE == 0x13)
     {
       return 1;
@@ -299,7 +299,7 @@
   s_cVcoWordTx = SpiritCalibrationGetVcoCalData();
   
   SpiritCmdStrobeReady();
-  printf("test 9-5 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
+//  printf("test 9-5 g_xStatus.MC_STATE : [0x%02X] \n", g_xStatus.MC_STATE);
   do{
     SpiritRefreshStatus();
     
--- a/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Radio.c	Fri Jun 22 03:42:24 2018 +0000
+++ b/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Radio.c	Wed Jul 18 05:44:03 2018 +0000
@@ -44,7 +44,7 @@
 
 //180619 HJM : init 재시작을 위한 카운팅 변수
 static int iSpiritRadioErrorCounting = 0;
-#define MAX_ERROR_COUNTING  10
+#define MAX_ERROR_COUNTING  3
 #define RETURN_ERROR_NUMBER     100
 
 /** @addtogroup SPIRIT_Libraries
@@ -192,23 +192,23 @@
 */
 uint8_t SpiritRadioInit(SRadioInit* pxSRadioInitStruct)
 {
-  printf("[INIT_REVISE]SpiritRadioInit start...\n");
+//  printf("[INIT_REVISE]SpiritRadioInit start...\n");
   int32_t FOffsetTmp;
   uint8_t anaRadioRegArray[8], digRadioRegArray[4];
   int16_t xtalOffsetFactor;
   uint8_t drM, drE, FdevM, FdevE, bwM, bwE;
     
   /* Workaround for Vtune */
-  printf("test 9-1\n");
+//  printf("test 9-1\n");
   uint8_t value = 0xA0; 
   SpiritSpiWriteRegisters(0x9F, 1, &value);
   
   /* Calculates the offset respect to RF frequency and according to xtal_ppm parameter: (xtal_ppm*FBase)/10^6 */
-  printf("test 9-2\n");
+//  printf("test 9-2\n");
   FOffsetTmp = (int32_t)(((float)pxSRadioInitStruct->nXtalOffsetPpm*pxSRadioInitStruct->lFrequencyBase)/PPM_FACTOR);
   
   /* Check the parameters */
-  printf("test 9-3\n");
+//  printf("test 9-3\n");
   s_assert_param(IS_FREQUENCY_BAND(pxSRadioInitStruct->lFrequencyBase));
   s_assert_param(IS_MODULATION_SELECTED(pxSRadioInitStruct->xModulationSelect));
   s_assert_param(IS_DATARATE(pxSRadioInitStruct->lDatarate));
@@ -217,7 +217,7 @@
   s_assert_param(IS_F_DEV(pxSRadioInitStruct->lFreqDev,s_lXtalFrequency));
   
   /* Disable the digital, ADC, SMPS reference clock divider if fXO>24MHz or fXO<26MHz */
-  printf("test 9-4\n");
+//  printf("test 9-4\n");
   SpiritSpiCommandStrobes(COMMAND_STANDBY);    
   do{
     /* Delay for state transition */
@@ -225,7 +225,7 @@
     
     /* Reads the MC_STATUS register */
     SpiritRefreshStatus();
-    printf("test 9-4 g_xStatus.MC_STATE : [0x%02X]\n", g_xStatus.MC_STATE);
+//    printf("test 9-4 g_xStatus.MC_STATE : [0x%02X]\n", g_xStatus.MC_STATE);
     ++iSpiritRadioErrorCounting;
     if (iSpiritRadioErrorCounting >= MAX_ERROR_COUNTING)
     {
@@ -259,7 +259,7 @@
   
   
   /* Goes in READY state */
-  printf("test 9-5\n");
+//  printf("test 9-5\n");
   SpiritSpiCommandStrobes(COMMAND_READY);
   do{
     /* Delay for state transition */
@@ -267,7 +267,7 @@
     
     /* Reads the MC_STATUS register */
     SpiritRefreshStatus();
-    printf("test 9-5 g_xStatus.MC_STATE : [%d]\n", g_xStatus.MC_STATE);
+//    printf("test 9-5 g_xStatus.MC_STATE : [%d]\n", g_xStatus.MC_STATE);
     ++iSpiritRadioErrorCounting;
     if (iSpiritRadioErrorCounting >= MAX_ERROR_COUNTING)
     {
@@ -279,13 +279,13 @@
   iSpiritRadioErrorCounting = 0;
   
   /* Calculates the FC_OFFSET parameter and cast as signed int: FOffsetTmp = (Fxtal/2^18)*FC_OFFSET */
-  printf("test 9-6\n");
+//  printf("test 9-6\n");
   xtalOffsetFactor = (int16_t)(((float)FOffsetTmp*FBASE_DIVIDER)/s_lXtalFrequency);
   anaRadioRegArray[2] = (uint8_t)((((uint16_t)xtalOffsetFactor)>>8)&0x0F);
   anaRadioRegArray[3] = (uint8_t)(xtalOffsetFactor);
   
   /* Calculates the channel space factor */
-  printf("test 9-7\n");
+//  printf("test 9-7\n");
   anaRadioRegArray[0] =((uint32_t)pxSRadioInitStruct->nChannelSpace<<9)/(s_lXtalFrequency>>6)+1;
   
   SpiritManagementWaTRxFcMem(pxSRadioInitStruct->lFrequencyBase);
@@ -296,32 +296,32 @@
   
   
   /* 2nd order DEM algorithm enabling */
-  printf("test 9-8\n");
+//  printf("test 9-8\n");
   uint8_t tmpreg; SpiritSpiReadRegisters(0xA3, 1, &tmpreg);
   tmpreg &= ~0x02; SpiritSpiWriteRegisters(0xA3, 1, &tmpreg);
   
   /* Check the channel center frequency is in one of the possible range */
-  printf("test 9-9\n");
+//  printf("test 9-9\n");
   s_assert_param(IS_FREQUENCY_BAND((pxSRadioInitStruct->lFrequencyBase + ((xtalOffsetFactor*s_lXtalFrequency)/FBASE_DIVIDER) + pxSRadioInitStruct->nChannelSpace * pxSRadioInitStruct->cChannelNumber)));  
   
   /* Calculates the datarate mantissa and exponent */
-  printf("test 9-10\n");
+//  printf("test 9-10\n");
   SpiritRadioSearchDatarateME(pxSRadioInitStruct->lDatarate, &drM, &drE);
   digRadioRegArray[0] = (uint8_t)(drM);
   digRadioRegArray[1] = (uint8_t)(0x00 | pxSRadioInitStruct->xModulationSelect |drE);
   
   /* Read the fdev register to preserve the clock recovery algo bit */
-  printf("test 9-11\n");
+//  printf("test 9-11\n");
   SpiritSpiReadRegisters(0x1C, 1, &tmpreg);
   
   /* Calculates the frequency deviation mantissa and exponent */
-  printf("test 9-12\n");
+//  printf("test 9-12\n");
   SpiritRadioSearchFreqDevME(pxSRadioInitStruct->lFreqDev, &FdevM, &FdevE);
   digRadioRegArray[2] = (uint8_t)((FdevE<<4) | (tmpreg&0x08) | FdevM);
   
   
   /* Calculates the channel filter mantissa and exponent */
-  printf("test 9-13\n");
+//  printf("test 9-13\n");
   SpiritRadioSearchChannelBwME(pxSRadioInitStruct->lBandwidth, &bwM, &bwE);
   
   
@@ -376,7 +376,7 @@
 
   
   /* Sets Xtal configuration */
-  printf("test 9-14\n");
+//  printf("test 9-14\n");
   if(s_lXtalFrequency>DOUBLE_XTAL_THR)
   {
     SpiritRadioSetXtalFlag(XTAL_FLAG((s_lXtalFrequency/2)));
@@ -387,28 +387,28 @@
   }
   
   /* Sets the channel number in the corresponding register */
-  printf("test 9-15\n");
+//  printf("test 9-15\n");
   SpiritSpiWriteRegisters(CHNUM_BASE, 1, &pxSRadioInitStruct->cChannelNumber);
   
   /* Configures the Analog Radio registers */
-  printf("test 9-16\n");
+//  printf("test 9-16\n");
   SpiritSpiWriteRegisters(CHSPACE_BASE, 4, anaRadioRegArray);
   
   /* Configures the Digital Radio registers */
-  printf("test 9-17\n");
+//  printf("test 9-17\n");
   g_xStatus = SpiritSpiWriteRegisters(MOD1_BASE, 4, digRadioRegArray);
   
   /* Enable the freeze option of the AFC on the SYNC word */
-  printf("test 9-18\n");
+//  printf("test 9-18\n");
   SpiritRadioAFCFreezeOnSync(S_ENABLE);
   
   /* Set the IQC correction optimal value */
-  printf("test 9-19\n");
+//  printf("test 9-19\n");
   anaRadioRegArray[0]=0x80;
   anaRadioRegArray[1]=0xE3;
   g_xStatus = SpiritSpiWriteRegisters(0x99, 2, anaRadioRegArray);
   
-  printf("[INIT_REVISE]SpiritRadioInit end.\n");
+//  printf("[INIT_REVISE]SpiritRadioInit end.\n");
   
   return SpiritRadioSetFrequencyBase(pxSRadioInitStruct->lFrequencyBase);
 }
@@ -3112,13 +3112,13 @@
   //값을 읽어 왔을때, Reserved 영역의 니블 값이 1011 임.
   int iMask = 1;
   
-  printf("\n !!!!!!!!!!!\n");
-    for (int i = 8; i > 0; --i)
-    {        
-        //값 찍기
-        printf("%d",(tempRegValue & (iMask << i-1))?1:0);
-    }
-  printf("\n !!!!!!!!!!!\n");
+//  printf("\n !!!!!!!!!!!\n");
+//    for (int i = 8; i > 0; --i)
+//    {        
+//        //값 찍기
+//        printf("%d",(tempRegValue & (iMask << i-1))?1:0);
+//    }
+//  printf("\n !!!!!!!!!!!\n");
   
   
   
--- a/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Types.c	Fri Jun 22 03:42:24 2018 +0000
+++ b/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Types.c	Wed Jul 18 05:44:03 2018 +0000
@@ -43,7 +43,7 @@
 
 //180621 HJM : init 재시작을 위한 카운팅 변수
 //static int iSpiritTypesErrorCounting = 0;
-#define MAX_ERROR_COUNTING  10
+#define MAX_ERROR_COUNTING  3
 #define RETURN_ERROR_NUMBER     100
 
 
--- a/stm-spirit1-rf-driver/SimpleSpirit1.h	Fri Jun 22 03:42:24 2018 +0000
+++ b/stm-spirit1-rf-driver/SimpleSpirit1.h	Wed Jul 18 05:44:03 2018 +0000
@@ -15,7 +15,6 @@
 #include "spirit1-config.h"
 #include "spirit1-const.h"
 
-
 // betzw: enable beyond macro if you want debug messages also from IRQ handler
 // #define DEBUG_IRQ
 
@@ -47,6 +46,7 @@
 
 
 
+
 /*** Missing Cube External Declarations ***/
 extern "C" void SpiritManagementSetFrequencyBase(uint32_t);
 
@@ -548,7 +548,8 @@
 
     /** Set Channel
      */
-    void set_channel(uint8_t channel) {
+    void set_channel(uint8_t channel) 
+    {
     	SpiritRadioSetChannel(channel);
     }