![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
180622 HJM : 10 Count sensing data RF send
Dependencies: 1_cubebite_ev-cog-ad3029lz_433MHz_1nd_certTest stm-spirit1-rf-driver_for_cubebite2
main.cpp@3:b21a1f982890, 2018-07-18 (annotated)
- Committer:
- jmhong
- Date:
- Wed Jul 18 05:47:52 2018 +0000
- Revision:
- 3:b21a1f982890
- Parent:
- 2:8861d01a78e4
180718 HJM : 8 Count sensing data RF send, certTest, temp(cold)Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmhong | 1:04f46755f8af | 1 | //HJM : 선풍기 에이징 테스트 용 소스임. |
jmhong | 1:04f46755f8af | 2 | //180615 HJM : 선풍기 에이징 용 온도 1개 진동 10개 전송용 테스트 임. |
jmhong | 1:04f46755f8af | 3 | // CUBEBITE_TEMPERATURE_DISABLE define 값으로 온도 센서 (연결 및 미연결) 시 설정을 할 수 있음. |
jmhong | 2:8861d01a78e4 | 4 | //180717 HJM : 인증(온도) 테스트용 소스 버전 관리, 0.1 -> 온도(저온) 테스트 |
jmhong | 2:8861d01a78e4 | 5 | //180717 HJM : 수정 1 |
jmhong | 1:04f46755f8af | 6 | |
jmhong | 1:04f46755f8af | 7 | |
jmhong | 1:04f46755f8af | 8 | #include "mbed.h" |
jmhong | 0:c2a57b2f934e | 9 | #include "ADXL362.h" |
jmhong | 1:04f46755f8af | 10 | #include "SimpleSpirit1.h" |
jmhong | 0:c2a57b2f934e | 11 | #include "main.h" |
jmhong | 0:c2a57b2f934e | 12 | |
jmhong | 0:c2a57b2f934e | 13 | |
jmhong | 2:8861d01a78e4 | 14 | #define FIRMWARE_VERSION_MAJOR 0 |
jmhong | 2:8861d01a78e4 | 15 | #define FIRMWARE_VERSION_MINOR 1 |
jmhong | 2:8861d01a78e4 | 16 | #define FIRMWARE_VERSION_REVISE 0 |
jmhong | 2:8861d01a78e4 | 17 | |
jmhong | 2:8861d01a78e4 | 18 | //#define FIRMWARE_VERSION_PRINT(x) printf(#x " = %s\n", x); |
jmhong | 1:04f46755f8af | 19 | |
jmhong | 0:c2a57b2f934e | 20 | //************************************************************************************* |
jmhong | 0:c2a57b2f934e | 21 | //Define : Test, Compile |
jmhong | 0:c2a57b2f934e | 22 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 23 | //#define CUBEBITE_DEBUG |
jmhong | 1:04f46755f8af | 24 | //#define HEAVY_DEBUG |
jmhong | 1:04f46755f8af | 25 | |
jmhong | 1:04f46755f8af | 26 | |
jmhong | 0:c2a57b2f934e | 27 | /* 180108 cubebite HJM : cubebite Testing define, 1개씩만 켜야 함. */ |
jmhong | 0:c2a57b2f934e | 28 | #define CUBEBITE_RF_SPEED_TEST_SEND_ON |
jmhong | 0:c2a57b2f934e | 29 | //#define CUBEBITE_RF_SPEED_TEST_RECV_ON |
jmhong | 1:04f46755f8af | 30 | //#define CUBEBITE_RF_SPEED_TEST_SEND_AND_RECV_ON //HJM : 추후 만들 예정.. |
jmhong | 0:c2a57b2f934e | 31 | |
jmhong | 0:c2a57b2f934e | 32 | /* 180109 cubebite HJM : cubebite Compile define, 1개씩만 켜야 함. */ |
jmhong | 0:c2a57b2f934e | 33 | #define CUBEBITE_BOARD_AD3029LZ |
jmhong | 0:c2a57b2f934e | 34 | |
jmhong | 0:c2a57b2f934e | 35 | |
jmhong | 0:c2a57b2f934e | 36 | #define CUBEBITE_RF_SETTING_VALUE_PRINT |
jmhong | 1:04f46755f8af | 37 | //#define CUBEBITE_TEMPERATURE_DISABLE |
jmhong | 1:04f46755f8af | 38 | |
jmhong | 1:04f46755f8af | 39 | |
jmhong | 1:04f46755f8af | 40 | //180411 HJM : 현재 1~3 까지 3대까지 가능 -> 게이트웨이에서 3대까지만 처리하게끔 되어있 |
jmhong | 2:8861d01a78e4 | 41 | //#define CUBEBITE_SENSOR_UUID 1 //3180621 HJM : 온도 및 진동 테스트 용 |
jmhong | 2:8861d01a78e4 | 42 | #define CUBEBITE_SENSOR_UUID 2 //180621 HJM : 철기연 테스트 용, 방대리님 테스트 용 |
jmhong | 0:c2a57b2f934e | 43 | //************************************************************************************* |
jmhong | 0:c2a57b2f934e | 44 | |
jmhong | 1:04f46755f8af | 45 | |
jmhong | 1:04f46755f8af | 46 | |
jmhong | 1:04f46755f8af | 47 | |
jmhong | 1:04f46755f8af | 48 | //HJM : 타이머 인터럽트 테스트 용 |
jmhong | 1:04f46755f8af | 49 | #ifdef CUBEBITE_DEBUG |
jmhong | 1:04f46755f8af | 50 | DigitalOut led1(LED1); |
jmhong | 1:04f46755f8af | 51 | #endif |
jmhong | 1:04f46755f8af | 52 | |
jmhong | 1:04f46755f8af | 53 | |
jmhong | 1:04f46755f8af | 54 | |
jmhong | 1:04f46755f8af | 55 | |
jmhong | 1:04f46755f8af | 56 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 57 | //HJM SUDO code : 3개 객체 생성->RF, 온도, 진동 |
jmhong | 1:04f46755f8af | 58 | //************************************************************************************* |
jmhong | 2:8861d01a78e4 | 59 | |
jmhong | 1:04f46755f8af | 60 | |
jmhong | 1:04f46755f8af | 61 | |
jmhong | 1:04f46755f8af | 62 | //온도 객체 |
jmhong | 1:04f46755f8af | 63 | #ifndef CUBEBITE_TEMPERATURE_DISABLE |
jmhong | 1:04f46755f8af | 64 | I2C i2c(I2C_SDA, I2C_SCL); //HJM : 테스트 용 임, 서대리님이 클래스 정리해서 줄 예정 |
jmhong | 1:04f46755f8af | 65 | #endif |
jmhong | 1:04f46755f8af | 66 | |
jmhong | 1:04f46755f8af | 67 | //진동 객체(Accelerometer (mosi, miso, sclk, cs), SPI 1) |
jmhong | 1:04f46755f8af | 68 | ADXL362 adxl362(P1_07, P1_08, P1_06, P1_10); //HJM : 테스트 용 임, 서대리님이 클래스 정리해서 줄 예정 |
jmhong | 1:04f46755f8af | 69 | |
jmhong | 1:04f46755f8af | 70 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 71 | |
jmhong | 1:04f46755f8af | 72 | |
jmhong | 1:04f46755f8af | 73 | |
jmhong | 1:04f46755f8af | 74 | |
jmhong | 1:04f46755f8af | 75 | |
jmhong | 1:04f46755f8af | 76 | |
jmhong | 1:04f46755f8af | 77 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 78 | //HJM SUDO code : main 사용자 함수 선언 |
jmhong | 1:04f46755f8af | 79 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 80 | |
jmhong | 1:04f46755f8af | 81 | |
jmhong | 1:04f46755f8af | 82 | static void callback_func(int event); //RF user callback 함수임. |
jmhong | 1:04f46755f8af | 83 | void UserTimerInterrupt(void); //1초, 타이머 인터럽트 임 |
jmhong | 1:04f46755f8af | 84 | int UserTimerInterrupt_Execution(void); |
jmhong | 2:8861d01a78e4 | 85 | int UserTimerInterrupt_Execution2(void); |
jmhong | 2:8861d01a78e4 | 86 | //void UserTimerInterrupt2(void); |
jmhong | 1:04f46755f8af | 87 | static int SendData(SimpleSpirit1& myspirit); |
jmhong | 1:04f46755f8af | 88 | |
jmhong | 1:04f46755f8af | 89 | |
jmhong | 1:04f46755f8af | 90 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 91 | |
jmhong | 1:04f46755f8af | 92 | |
jmhong | 1:04f46755f8af | 93 | |
jmhong | 1:04f46755f8af | 94 | |
jmhong | 1:04f46755f8af | 95 | |
jmhong | 0:c2a57b2f934e | 96 | |
jmhong | 0:c2a57b2f934e | 97 | |
jmhong | 0:c2a57b2f934e | 98 | |
jmhong | 1:04f46755f8af | 99 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 100 | //(테스트용)HJM SUDO code : 전역 변수, 진동, 온도 쪽 테스트용임. 추후 서대리님이 클래스 재 정의시 없어질 예정 |
jmhong | 1:04f46755f8af | 101 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 102 | |
jmhong | 2:8861d01a78e4 | 103 | //RF 객체 |
jmhong | 2:8861d01a78e4 | 104 | static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(P0_01, P0_02, P0_00, P1_12 ,P2_08, P1_14); |
jmhong | 2:8861d01a78e4 | 105 | // P0_01[SPI0_MOSI] |
jmhong | 2:8861d01a78e4 | 106 | // P0_02[SPI0_MISO], |
jmhong | 2:8861d01a78e4 | 107 | // P0_00[SPI0_CLK], |
jmhong | 2:8861d01a78e4 | 108 | // P1_12[GPIO 28, RF(GPIO 0)]->IRQ로 설정, |
jmhong | 2:8861d01a78e4 | 109 | // P2_08[SPI0_CS2], |
jmhong | 2:8861d01a78e4 | 110 | // P1_14[GPIO 30, RF (SDN)] |
jmhong | 1:04f46755f8af | 111 | |
jmhong | 1:04f46755f8af | 112 | |
jmhong | 1:04f46755f8af | 113 | //진동 |
jmhong | 1:04f46755f8af | 114 | uint16_t vCnt = 0; |
jmhong | 1:04f46755f8af | 115 | uint8_t iCnt = 0; |
jmhong | 1:04f46755f8af | 116 | |
jmhong | 1:04f46755f8af | 117 | //int16_t x16 = 0; |
jmhong | 1:04f46755f8af | 118 | //int16_t y16 = 0; |
jmhong | 1:04f46755f8af | 119 | //int16_t z16 = 0; |
jmhong | 1:04f46755f8af | 120 | int8_t x8 = 0; |
jmhong | 1:04f46755f8af | 121 | int8_t y8 = 0; |
jmhong | 1:04f46755f8af | 122 | int8_t z8 = 0; |
jmhong | 1:04f46755f8af | 123 | |
jmhong | 1:04f46755f8af | 124 | |
jmhong | 1:04f46755f8af | 125 | int8_t int8tX8Result = 0; |
jmhong | 1:04f46755f8af | 126 | int8_t int8tY8Result = 0; |
jmhong | 1:04f46755f8af | 127 | int8_t int8tZ8Result = 0; |
jmhong | 0:c2a57b2f934e | 128 | |
jmhong | 0:c2a57b2f934e | 129 | |
jmhong | 1:04f46755f8af | 130 | int16_t temp_x16[3] = {0,}; |
jmhong | 1:04f46755f8af | 131 | int16_t temp_y16[3] = {0,}; |
jmhong | 1:04f46755f8af | 132 | int16_t temp_z16[3] = {0,}; |
jmhong | 1:04f46755f8af | 133 | |
jmhong | 1:04f46755f8af | 134 | int Comp1_x = 0, Comp2_x = 0; |
jmhong | 1:04f46755f8af | 135 | int Comp1_y = 0, Comp2_y = 0; |
jmhong | 1:04f46755f8af | 136 | int Comp1_z = 0, Comp2_z = 0; |
jmhong | 1:04f46755f8af | 137 | |
jmhong | 1:04f46755f8af | 138 | float float_x = 0; |
jmhong | 1:04f46755f8af | 139 | float float_y = 0; |
jmhong | 1:04f46755f8af | 140 | float float_z = 0; |
jmhong | 1:04f46755f8af | 141 | |
jmhong | 1:04f46755f8af | 142 | float G_x = 0; |
jmhong | 1:04f46755f8af | 143 | float G_y = 0; |
jmhong | 1:04f46755f8af | 144 | float G_z = 0; |
jmhong | 1:04f46755f8af | 145 | |
jmhong | 1:04f46755f8af | 146 | float Output = 0; |
jmhong | 1:04f46755f8af | 147 | |
jmhong | 1:04f46755f8af | 148 | double dVibOutputSqrt = 0; |
jmhong | 0:c2a57b2f934e | 149 | |
jmhong | 0:c2a57b2f934e | 150 | |
jmhong | 1:04f46755f8af | 151 | //온도 |
jmhong | 1:04f46755f8af | 152 | char wReg[2] = {0,}; |
jmhong | 1:04f46755f8af | 153 | char rReg[2] = {0,}; |
jmhong | 1:04f46755f8af | 154 | int wACK = 0; |
jmhong | 1:04f46755f8af | 155 | int rACK = 0; |
jmhong | 1:04f46755f8af | 156 | int16_t Tem16; |
jmhong | 1:04f46755f8af | 157 | float TempData = 0; |
jmhong | 1:04f46755f8af | 158 | |
jmhong | 1:04f46755f8af | 159 | #define busAddr 0x4F |
jmhong | 1:04f46755f8af | 160 | |
jmhong | 1:04f46755f8af | 161 | #define ID_DATA_ADDR 0x00 |
jmhong | 1:04f46755f8af | 162 | #define ID_CON_ADDR 0x01 |
jmhong | 1:04f46755f8af | 163 | #define ID_REG_ADDR 0x07 |
jmhong | 1:04f46755f8af | 164 | |
jmhong | 2:8861d01a78e4 | 165 | #define RESET_HW_OFF 1 |
jmhong | 2:8861d01a78e4 | 166 | #define RESET_HW_ON 0 |
jmhong | 2:8861d01a78e4 | 167 | |
jmhong | 2:8861d01a78e4 | 168 | #define SPIRIT1_POWER_OFF 1 |
jmhong | 2:8861d01a78e4 | 169 | #define SPIRIT1_POWER_ON 2 |
jmhong | 2:8861d01a78e4 | 170 | |
jmhong | 1:04f46755f8af | 171 | |
jmhong | 1:04f46755f8af | 172 | //RF->이거도 클래스 내부에 넣기 |
jmhong | 1:04f46755f8af | 173 | static volatile bool bRxDoneFlag = false; |
jmhong | 1:04f46755f8af | 174 | static volatile bool bTxDoneFlag = false; |
jmhong | 1:04f46755f8af | 175 | static volatile bool bSendDataFlag = false; |
jmhong | 1:04f46755f8af | 176 | |
jmhong | 1:04f46755f8af | 177 | //************************************************************************************* |
jmhong | 0:c2a57b2f934e | 178 | |
jmhong | 0:c2a57b2f934e | 179 | |
jmhong | 0:c2a57b2f934e | 180 | |
jmhong | 0:c2a57b2f934e | 181 | |
jmhong | 0:c2a57b2f934e | 182 | |
jmhong | 0:c2a57b2f934e | 183 | |
jmhong | 0:c2a57b2f934e | 184 | |
jmhong | 0:c2a57b2f934e | 185 | |
jmhong | 0:c2a57b2f934e | 186 | |
jmhong | 1:04f46755f8af | 187 | //HJM : I2C PullUp 용.. RF IRQ 도 이 핀 이지만 사용안하기 때문에 괜찮음. |
jmhong | 2:8861d01a78e4 | 188 | DigitalOut resetHW(P1_12); |
jmhong | 2:8861d01a78e4 | 189 | //prit1(P1_11); //GPIO27 |
jmhong | 0:c2a57b2f934e | 190 | |
jmhong | 1:04f46755f8af | 191 | bool iTempFlag = false; |
jmhong | 1:04f46755f8af | 192 | bool isTimerInterruptStarted = false; |
jmhong | 1:04f46755f8af | 193 | bool bIs1SecTimerSet = false; |
jmhong | 1:04f46755f8af | 194 | int iTempInitCount = 0; |
jmhong | 1:04f46755f8af | 195 | bool isTempInitOk = false; |
jmhong | 2:8861d01a78e4 | 196 | |
jmhong | 2:8861d01a78e4 | 197 | int iMainCounting = 1; |
jmhong | 2:8861d01a78e4 | 198 | static int iIsResetStartCounting = 0; |
jmhong | 2:8861d01a78e4 | 199 | //static int iIsResetStartCountingInterrupt = 0; |
jmhong | 1:04f46755f8af | 200 | int main(void) |
jmhong | 1:04f46755f8af | 201 | { |
jmhong | 1:04f46755f8af | 202 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 203 | //HJM SUDO code : 진동, 온도, RF 초기화 |
jmhong | 1:04f46755f8af | 204 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 205 | |
jmhong | 1:04f46755f8af | 206 | //필수!!! |
jmhong | 2:8861d01a78e4 | 207 | resetHW.write(RESET_HW_OFF); |
jmhong | 2:8861d01a78e4 | 208 | |
jmhong | 2:8861d01a78e4 | 209 | printf("\n\n FIRMWARE_VERSION : %d.%d.%d\n\n", FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_REVISE); |
jmhong | 2:8861d01a78e4 | 210 | |
jmhong | 2:8861d01a78e4 | 211 | |
jmhong | 2:8861d01a78e4 | 212 | |
jmhong | 2:8861d01a78e4 | 213 | |
jmhong | 2:8861d01a78e4 | 214 | // FIRMWARE_VERSION_PRINT(FIRMWARE_VERSION); |
jmhong | 2:8861d01a78e4 | 215 | |
jmhong | 2:8861d01a78e4 | 216 | |
jmhong | 1:04f46755f8af | 217 | |
jmhong | 1:04f46755f8af | 218 | |
jmhong | 1:04f46755f8af | 219 | //진동 init_시작 |
jmhong | 1:04f46755f8af | 220 | // set up SPI interface |
jmhong | 1:04f46755f8af | 221 | adxl362.init_spi(); |
jmhong | 1:04f46755f8af | 222 | // Set up accelerometer |
jmhong | 1:04f46755f8af | 223 | adxl362.init_adxl362(); |
jmhong | 1:04f46755f8af | 224 | |
jmhong | 2:8861d01a78e4 | 225 | // wait_ms(25); |
jmhong | 1:04f46755f8af | 226 | //진동 init_끝 |
jmhong | 1:04f46755f8af | 227 | |
jmhong | 1:04f46755f8af | 228 | |
jmhong | 1:04f46755f8af | 229 | //온도 init_시작 |
jmhong | 1:04f46755f8af | 230 | //Power supply for the sensor is given from GPIO28(VDD_MCU_B). |
jmhong | 2:8861d01a78e4 | 231 | // JMOD Init |
jmhong | 2:8861d01a78e4 | 232 | #ifndef CUBEBITE_TEMPERATURE_DISABLE |
jmhong | 2:8861d01a78e4 | 233 | printf("[Temperature] Init start"); |
jmhong | 1:04f46755f8af | 234 | |
jmhong | 2:8861d01a78e4 | 235 | i2c.frequency(100000); //100khz |
jmhong | 1:04f46755f8af | 236 | wReg[0] = ID_CON_ADDR; |
jmhong | 1:04f46755f8af | 237 | |
jmhong | 1:04f46755f8af | 238 | while(rReg[0] != 0x03) |
jmhong | 1:04f46755f8af | 239 | { |
jmhong | 1:04f46755f8af | 240 | //write 0x00(ID_CON_ADDR) |
jmhong | 1:04f46755f8af | 241 | wReg[1] = 0x00; |
jmhong | 1:04f46755f8af | 242 | wACK = i2c.write(busAddr, wReg, 2); |
jmhong | 0:c2a57b2f934e | 243 | |
jmhong | 1:04f46755f8af | 244 | //read 0x00(ID_CON_ADDR) |
jmhong | 1:04f46755f8af | 245 | wACK = i2c.write(busAddr, wReg, 1); |
jmhong | 1:04f46755f8af | 246 | rACK = i2c.read(busAddr, rReg, 1); |
jmhong | 1:04f46755f8af | 247 | |
jmhong | 1:04f46755f8af | 248 | wait_ms(250); |
jmhong | 1:04f46755f8af | 249 | |
jmhong | 1:04f46755f8af | 250 | //write 0x03(ID_CON_ADDR) |
jmhong | 1:04f46755f8af | 251 | wReg[1] = 0x03; |
jmhong | 1:04f46755f8af | 252 | wACK = i2c.write(busAddr, wReg, 2); |
jmhong | 1:04f46755f8af | 253 | |
jmhong | 1:04f46755f8af | 254 | //read 0x03(ID_CON_ADDR) |
jmhong | 1:04f46755f8af | 255 | wACK = i2c.write(busAddr, wReg, 1); |
jmhong | 1:04f46755f8af | 256 | rACK = i2c.read(busAddr, rReg, 1); |
jmhong | 1:04f46755f8af | 257 | |
jmhong | 1:04f46755f8af | 258 | i2c.write(busAddr, wReg, 2); |
jmhong | 0:c2a57b2f934e | 259 | |
jmhong | 1:04f46755f8af | 260 | if(rReg[0] == 0x03) |
jmhong | 1:04f46755f8af | 261 | { |
jmhong | 2:8861d01a78e4 | 262 | // printf(" (Vib Success!!)\n\n"); |
jmhong | 0:c2a57b2f934e | 263 | |
jmhong | 1:04f46755f8af | 264 | //write 0x00(ID_CON_ADDR) |
jmhong | 1:04f46755f8af | 265 | wReg[1] = 0x00; |
jmhong | 1:04f46755f8af | 266 | wACK = i2c.write(busAddr, wReg, 2); |
jmhong | 1:04f46755f8af | 267 | isTempInitOk = true; |
jmhong | 2:8861d01a78e4 | 268 | // wait_ms(250); |
jmhong | 2:8861d01a78e4 | 269 | // wait_ms(60); |
jmhong | 2:8861d01a78e4 | 270 | wait_ms(150); |
jmhong | 1:04f46755f8af | 271 | } |
jmhong | 2:8861d01a78e4 | 272 | else if (10 == iTempInitCount) |
jmhong | 1:04f46755f8af | 273 | { |
jmhong | 1:04f46755f8af | 274 | isTempInitOk = false; |
jmhong | 1:04f46755f8af | 275 | break; |
jmhong | 1:04f46755f8af | 276 | } |
jmhong | 1:04f46755f8af | 277 | else |
jmhong | 1:04f46755f8af | 278 | { |
jmhong | 1:04f46755f8af | 279 | printf("."); |
jmhong | 1:04f46755f8af | 280 | ++iTempInitCount; |
jmhong | 1:04f46755f8af | 281 | } |
jmhong | 1:04f46755f8af | 282 | |
jmhong | 2:8861d01a78e4 | 283 | // wait_ms(500); |
jmhong | 2:8861d01a78e4 | 284 | // wait_ms(80); |
jmhong | 2:8861d01a78e4 | 285 | wait_ms(200); |
jmhong | 1:04f46755f8af | 286 | } |
jmhong | 1:04f46755f8af | 287 | #endif |
jmhong | 2:8861d01a78e4 | 288 | printf("(OK)\n"); |
jmhong | 1:04f46755f8af | 289 | //온도 init_끝 |
jmhong | 1:04f46755f8af | 290 | |
jmhong | 1:04f46755f8af | 291 | |
jmhong | 1:04f46755f8af | 292 | |
jmhong | 2:8861d01a78e4 | 293 | |
jmhong | 1:04f46755f8af | 294 | //RF init_시작 |
jmhong | 2:8861d01a78e4 | 295 | // myspirit.attach_irq_callback(callback_func); |
jmhong | 1:04f46755f8af | 296 | if (myspirit.on()) |
jmhong | 1:04f46755f8af | 297 | { |
jmhong | 1:04f46755f8af | 298 | printf("ERROR.\n"); |
jmhong | 1:04f46755f8af | 299 | } |
jmhong | 1:04f46755f8af | 300 | else |
jmhong | 1:04f46755f8af | 301 | { |
jmhong | 1:04f46755f8af | 302 | printf("OK.\n"); |
jmhong | 1:04f46755f8af | 303 | } |
jmhong | 1:04f46755f8af | 304 | //RF init_끝 |
jmhong | 1:04f46755f8af | 305 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 306 | |
jmhong | 1:04f46755f8af | 307 | |
jmhong | 1:04f46755f8af | 308 | |
jmhong | 1:04f46755f8af | 309 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 310 | //HJM SUDO code : 1초 타이머 인터럽트 생성, 1초 간격 호출 함수 : UserTimerInterrupt() |
jmhong | 1:04f46755f8af | 311 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 312 | // Timeout timeoutUserInterrupt; //1번만 실행 |
jmhong | 2:8861d01a78e4 | 313 | Ticker timeoutUserInterrupt; //매번 실행 |
jmhong | 2:8861d01a78e4 | 314 | // Ticker timeoutUserInterrupt2; //매번 실행 |
jmhong | 1:04f46755f8af | 315 | // timeoutUserInterrupt.attach(&UserTimerInterrupt, 1.0); //1 sec |
jmhong | 2:8861d01a78e4 | 316 | timeoutUserInterrupt.attach(&UserTimerInterrupt, 900.0); //15 minuite, reset test |
jmhong | 2:8861d01a78e4 | 317 | // timeoutUserInterrupt2.attach(&UserTimerInterrupt2, 1.0); //1 sec |
jmhong | 2:8861d01a78e4 | 318 | // timeoutUserInterrupt.attach(&UserTimerInterrupt, 5.0); //test, 5sec |
jmhong | 1:04f46755f8af | 319 | //************************************************************************************* |
jmhong | 1:04f46755f8af | 320 | |
jmhong | 2:8861d01a78e4 | 321 | // wait(1); |
jmhong | 1:04f46755f8af | 322 | |
jmhong | 1:04f46755f8af | 323 | |
jmhong | 1:04f46755f8af | 324 | while(1) |
jmhong | 1:04f46755f8af | 325 | { |
jmhong | 2:8861d01a78e4 | 326 | __WFE(); //HJM : sleep 모드 ON |
jmhong | 1:04f46755f8af | 327 | |
jmhong | 1:04f46755f8af | 328 | UserTimerInterrupt_Execution(); |
jmhong | 2:8861d01a78e4 | 329 | UserTimerInterrupt_Execution2(); |
jmhong | 2:8861d01a78e4 | 330 | |
jmhong | 2:8861d01a78e4 | 331 | // myspirit.off(); |
jmhong | 2:8861d01a78e4 | 332 | // myspirit.on(); |
jmhong | 2:8861d01a78e4 | 333 | |
jmhong | 2:8861d01a78e4 | 334 | //if (0 == (iMainCounting % 10)) |
jmhong | 2:8861d01a78e4 | 335 | // { |
jmhong | 2:8861d01a78e4 | 336 | //// myspirit.reset_board(); |
jmhong | 2:8861d01a78e4 | 337 | //// iMainCounting = 0; |
jmhong | 2:8861d01a78e4 | 338 | // iMainCounting = 1; |
jmhong | 2:8861d01a78e4 | 339 | // myspirit.off(); |
jmhong | 2:8861d01a78e4 | 340 | // myspirit.on(); |
jmhong | 2:8861d01a78e4 | 341 | // } |
jmhong | 2:8861d01a78e4 | 342 | |
jmhong | 1:04f46755f8af | 343 | if (true == isTimerInterruptStarted) |
jmhong | 1:04f46755f8af | 344 | { |
jmhong | 1:04f46755f8af | 345 | isTimerInterruptStarted = false; |
jmhong | 1:04f46755f8af | 346 | SendData(myspirit); |
jmhong | 1:04f46755f8af | 347 | } |
jmhong | 1:04f46755f8af | 348 | } |
jmhong | 0:c2a57b2f934e | 349 | |
jmhong | 0:c2a57b2f934e | 350 | |
jmhong | 1:04f46755f8af | 351 | // return 0; //unreachable |
jmhong | 1:04f46755f8af | 352 | } |
jmhong | 0:c2a57b2f934e | 353 | |
jmhong | 0:c2a57b2f934e | 354 | static void callback_func(int event) |
jmhong | 0:c2a57b2f934e | 355 | { |
jmhong | 0:c2a57b2f934e | 356 | #ifdef CUBEBITE_DEBUG |
jmhong | 0:c2a57b2f934e | 357 | printf("[CUBEBITE] callback_func(int event) \n"); |
jmhong | 0:c2a57b2f934e | 358 | #endif |
jmhong | 0:c2a57b2f934e | 359 | |
jmhong | 0:c2a57b2f934e | 360 | if(event == SimpleSpirit1::RX_DONE) |
jmhong | 0:c2a57b2f934e | 361 | { |
jmhong | 0:c2a57b2f934e | 362 | bRxDoneFlag = 1; |
jmhong | 0:c2a57b2f934e | 363 | } |
jmhong | 0:c2a57b2f934e | 364 | else if (event == SimpleSpirit1::TX_DONE) |
jmhong | 0:c2a57b2f934e | 365 | { |
jmhong | 0:c2a57b2f934e | 366 | bTxDoneFlag = 1; |
jmhong | 0:c2a57b2f934e | 367 | } |
jmhong | 0:c2a57b2f934e | 368 | } |
jmhong | 0:c2a57b2f934e | 369 | |
jmhong | 0:c2a57b2f934e | 370 | |
jmhong | 0:c2a57b2f934e | 371 | |
jmhong | 1:04f46755f8af | 372 | void UserTimerInterrupt(void) |
jmhong | 0:c2a57b2f934e | 373 | { |
jmhong | 2:8861d01a78e4 | 374 | resetHW.write(RESET_HW_ON); |
jmhong | 1:04f46755f8af | 375 | |
jmhong | 1:04f46755f8af | 376 | return; |
jmhong | 0:c2a57b2f934e | 377 | } |
jmhong | 0:c2a57b2f934e | 378 | |
jmhong | 0:c2a57b2f934e | 379 | |
jmhong | 2:8861d01a78e4 | 380 | |
jmhong | 2:8861d01a78e4 | 381 | int UserTimerInterrupt_Execution(void) |
jmhong | 2:8861d01a78e4 | 382 | { |
jmhong | 2:8861d01a78e4 | 383 | if (true == isTempInitOk) |
jmhong | 2:8861d01a78e4 | 384 | { |
jmhong | 2:8861d01a78e4 | 385 | wReg[0] = ID_DATA_ADDR; |
jmhong | 2:8861d01a78e4 | 386 | |
jmhong | 2:8861d01a78e4 | 387 | i2c.write(busAddr, wReg, 1); |
jmhong | 2:8861d01a78e4 | 388 | i2c.read(busAddr, rReg, 2); |
jmhong | 2:8861d01a78e4 | 389 | |
jmhong | 2:8861d01a78e4 | 390 | Tem16 = (rReg[0] << 8) | (rReg[1]); |
jmhong | 2:8861d01a78e4 | 391 | Tem16 >>= 5; |
jmhong | 2:8861d01a78e4 | 392 | TempData = Tem16; |
jmhong | 2:8861d01a78e4 | 393 | |
jmhong | 2:8861d01a78e4 | 394 | TempData = TempData *0.125; |
jmhong | 2:8861d01a78e4 | 395 | } |
jmhong | 2:8861d01a78e4 | 396 | |
jmhong | 2:8861d01a78e4 | 397 | return 0; |
jmhong | 2:8861d01a78e4 | 398 | } |
jmhong | 2:8861d01a78e4 | 399 | |
jmhong | 2:8861d01a78e4 | 400 | |
jmhong | 1:04f46755f8af | 401 | volatile int iFunctionCallCounting = 0; |
jmhong | 2:8861d01a78e4 | 402 | bool isTempOk = false; |
jmhong | 2:8861d01a78e4 | 403 | int UserTimerInterrupt_Execution2(void) |
jmhong | 1:04f46755f8af | 404 | { |
jmhong | 1:04f46755f8af | 405 | // printf("UserTimerInterrupt_Execution 호출, dataCount : [%d]\n", dataCount); |
jmhong | 1:04f46755f8af | 406 | ++iFunctionCallCounting; |
jmhong | 0:c2a57b2f934e | 407 | |
jmhong | 1:04f46755f8af | 408 | if (false == isTimerInterruptStarted) |
jmhong | 2:8861d01a78e4 | 409 | { |
jmhong | 1:04f46755f8af | 410 | //진동 |
jmhong | 2:8861d01a78e4 | 411 | adxl362.ACC_GetXYZ8(&x8, &y8, &z8); |
jmhong | 1:04f46755f8af | 412 | if (0 == x8) |
jmhong | 1:04f46755f8af | 413 | { |
jmhong | 1:04f46755f8af | 414 | uiSendBuf[dataCount++] = '0'; |
jmhong | 1:04f46755f8af | 415 | uiSendBuf[dataCount++] = 'x'; |
jmhong | 1:04f46755f8af | 416 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 417 | } |
jmhong | 1:04f46755f8af | 418 | else |
jmhong | 1:04f46755f8af | 419 | { |
jmhong | 1:04f46755f8af | 420 | int8tX8Result = x8; |
jmhong | 1:04f46755f8af | 421 | |
jmhong | 1:04f46755f8af | 422 | uiSendBuf[dataCount++] = (uint8_t)int8tX8Result; |
jmhong | 2:8861d01a78e4 | 423 | } |
jmhong | 1:04f46755f8af | 424 | if (0 == y8) |
jmhong | 1:04f46755f8af | 425 | { |
jmhong | 1:04f46755f8af | 426 | uiSendBuf[dataCount++] = '0'; |
jmhong | 1:04f46755f8af | 427 | uiSendBuf[dataCount++] = 'y'; |
jmhong | 1:04f46755f8af | 428 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 429 | } |
jmhong | 1:04f46755f8af | 430 | else |
jmhong | 1:04f46755f8af | 431 | { |
jmhong | 1:04f46755f8af | 432 | int8tY8Result = y8; |
jmhong | 1:04f46755f8af | 433 | |
jmhong | 1:04f46755f8af | 434 | uiSendBuf[dataCount++] = (uint8_t)int8tY8Result; |
jmhong | 2:8861d01a78e4 | 435 | } |
jmhong | 1:04f46755f8af | 436 | if (0 == z8) |
jmhong | 1:04f46755f8af | 437 | { |
jmhong | 1:04f46755f8af | 438 | uiSendBuf[dataCount++] = '0'; |
jmhong | 1:04f46755f8af | 439 | uiSendBuf[dataCount++] = 'z'; |
jmhong | 1:04f46755f8af | 440 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 441 | } |
jmhong | 1:04f46755f8af | 442 | else |
jmhong | 1:04f46755f8af | 443 | { |
jmhong | 1:04f46755f8af | 444 | int8tZ8Result = z8; |
jmhong | 1:04f46755f8af | 445 | |
jmhong | 1:04f46755f8af | 446 | uiSendBuf[dataCount++] = (uint8_t)int8tZ8Result; |
jmhong | 2:8861d01a78e4 | 447 | } |
jmhong | 0:c2a57b2f934e | 448 | |
jmhong | 2:8861d01a78e4 | 449 | wait(0.025); // 25ms, Wait is required in this mode |
jmhong | 1:04f46755f8af | 450 | |
jmhong | 1:04f46755f8af | 451 | //온도 |
jmhong | 1:04f46755f8af | 452 | // temperature data receive |
jmhong | 1:04f46755f8af | 453 | if (true == isTempInitOk) |
jmhong | 2:8861d01a78e4 | 454 | { |
jmhong | 2:8861d01a78e4 | 455 | // wReg[0] = ID_DATA_ADDR; |
jmhong | 2:8861d01a78e4 | 456 | // |
jmhong | 2:8861d01a78e4 | 457 | // i2c.write(busAddr, wReg, 1); |
jmhong | 2:8861d01a78e4 | 458 | // i2c.read(busAddr, rReg, 2); |
jmhong | 2:8861d01a78e4 | 459 | // |
jmhong | 2:8861d01a78e4 | 460 | // Tem16 = (rReg[0] << 8) | (rReg[1]); |
jmhong | 2:8861d01a78e4 | 461 | // Tem16 >>= 5; |
jmhong | 2:8861d01a78e4 | 462 | // TempData = Tem16; |
jmhong | 2:8861d01a78e4 | 463 | // |
jmhong | 2:8861d01a78e4 | 464 | // TempData = TempData *0.125; |
jmhong | 1:04f46755f8af | 465 | |
jmhong | 1:04f46755f8af | 466 | if (0 == rReg[0]) |
jmhong | 1:04f46755f8af | 467 | { |
jmhong | 2:8861d01a78e4 | 468 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 469 | uiSendBuf[dataCount++] = '0'; |
jmhong | 2:8861d01a78e4 | 470 | // uiSendBuf[dataCount++] = '1'; |
jmhong | 1:04f46755f8af | 471 | } |
jmhong | 1:04f46755f8af | 472 | else |
jmhong | 1:04f46755f8af | 473 | { |
jmhong | 1:04f46755f8af | 474 | uiSendBuf[dataCount++] = (uint8_t)rReg[0]; |
jmhong | 1:04f46755f8af | 475 | } |
jmhong | 1:04f46755f8af | 476 | |
jmhong | 2:8861d01a78e4 | 477 | |
jmhong | 2:8861d01a78e4 | 478 | |
jmhong | 1:04f46755f8af | 479 | if (0 == rReg[1]) |
jmhong | 1:04f46755f8af | 480 | { |
jmhong | 2:8861d01a78e4 | 481 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 482 | uiSendBuf[dataCount++] = '0'; |
jmhong | 2:8861d01a78e4 | 483 | // uiSendBuf[dataCount++] = '2'; |
jmhong | 1:04f46755f8af | 484 | } |
jmhong | 1:04f46755f8af | 485 | else |
jmhong | 1:04f46755f8af | 486 | { |
jmhong | 1:04f46755f8af | 487 | uiSendBuf[dataCount++] = (uint8_t)rReg[1]; |
jmhong | 1:04f46755f8af | 488 | } |
jmhong | 1:04f46755f8af | 489 | } |
jmhong | 1:04f46755f8af | 490 | else |
jmhong | 1:04f46755f8af | 491 | { |
jmhong | 2:8861d01a78e4 | 492 | uiSendBuf[dataCount++] = '@'; |
jmhong | 1:04f46755f8af | 493 | uiSendBuf[dataCount++] = '0'; |
jmhong | 2:8861d01a78e4 | 494 | // uiSendBuf[dataCount++] = '1'; |
jmhong | 2:8861d01a78e4 | 495 | uiSendBuf[dataCount++] = '@'; |
jmhong | 2:8861d01a78e4 | 496 | uiSendBuf[dataCount++] = '0'; |
jmhong | 2:8861d01a78e4 | 497 | // uiSendBuf[dataCount++] = '2'; |
jmhong | 1:04f46755f8af | 498 | } |
jmhong | 0:c2a57b2f934e | 499 | |
jmhong | 1:04f46755f8af | 500 | uiSendBuf[dataCount++] = '#'; |
jmhong | 1:04f46755f8af | 501 | uiSendBuf[dataCount++] = '#'; |
jmhong | 0:c2a57b2f934e | 502 | |
jmhong | 1:04f46755f8af | 503 | wait(0.025); // 25ms, Wait is required in this mode |
jmhong | 0:c2a57b2f934e | 504 | } |
jmhong | 1:04f46755f8af | 505 | |
jmhong | 2:8861d01a78e4 | 506 | |
jmhong | 2:8861d01a78e4 | 507 | |
jmhong | 2:8861d01a78e4 | 508 | |
jmhong | 2:8861d01a78e4 | 509 | |
jmhong | 2:8861d01a78e4 | 510 | // if (iFunctionCallCounting >= 10) //10번의 측정이 끝나면, |
jmhong | 2:8861d01a78e4 | 511 | if (iFunctionCallCounting >= 8) //8번의 측정이 끝나면, 180703 온도 0도 표현시 버그 발생.. |
jmhong | 1:04f46755f8af | 512 | { |
jmhong | 1:04f46755f8af | 513 | isTimerInterruptStarted = true; |
jmhong | 1:04f46755f8af | 514 | // printf("if in!!\n"); |
jmhong | 1:04f46755f8af | 515 | |
jmhong | 1:04f46755f8af | 516 | uiSendBuf[dataCount++] = '*'; |
jmhong | 1:04f46755f8af | 517 | uiSendBuf[dataCount++] = '*'; |
jmhong | 1:04f46755f8af | 518 | |
jmhong | 1:04f46755f8af | 519 | uiSendBuf[dataCount] = CUBEBITE_SENSOR_UUID; |
jmhong | 1:04f46755f8af | 520 | |
jmhong | 1:04f46755f8af | 521 | iFunctionCallCounting = 0; |
jmhong | 1:04f46755f8af | 522 | } |
jmhong | 1:04f46755f8af | 523 | |
jmhong | 1:04f46755f8af | 524 | return 0; |
jmhong | 0:c2a57b2f934e | 525 | } |
jmhong | 0:c2a57b2f934e | 526 | |
jmhong | 0:c2a57b2f934e | 527 | |
jmhong | 0:c2a57b2f934e | 528 | |
jmhong | 0:c2a57b2f934e | 529 | |
jmhong | 0:c2a57b2f934e | 530 | |
jmhong | 0:c2a57b2f934e | 531 | |
jmhong | 1:04f46755f8af | 532 | |
jmhong | 1:04f46755f8af | 533 | |
jmhong | 1:04f46755f8af | 534 | |
jmhong | 0:c2a57b2f934e | 535 | |
jmhong | 0:c2a57b2f934e | 536 | |
jmhong | 0:c2a57b2f934e | 537 | |
jmhong | 0:c2a57b2f934e | 538 | |
jmhong | 0:c2a57b2f934e | 539 | |
jmhong | 0:c2a57b2f934e | 540 | |
jmhong | 0:c2a57b2f934e | 541 | /** |
jmhong | 0:c2a57b2f934e | 542 | * @brief SendData |
jmhong | 0:c2a57b2f934e | 543 | * @param None |
jmhong | 0:c2a57b2f934e | 544 | * @retval None |
jmhong | 0:c2a57b2f934e | 545 | */ |
jmhong | 0:c2a57b2f934e | 546 | static int SendData(SimpleSpirit1& myspirit) |
jmhong | 0:c2a57b2f934e | 547 | { |
jmhong | 2:8861d01a78e4 | 548 | // ++iMainCounting; |
jmhong | 2:8861d01a78e4 | 549 | // printf("iMainCounting : %d\n", iMainCounting); |
jmhong | 2:8861d01a78e4 | 550 | // ++iIsResetStartCountingInterrupt; |
jmhong | 2:8861d01a78e4 | 551 | |
jmhong | 2:8861d01a78e4 | 552 | isTempOk = false; |
jmhong | 1:04f46755f8af | 553 | #ifdef CUBEBITE_DEBUG |
jmhong | 1:04f46755f8af | 554 | printf("=========================================\n"); |
jmhong | 1:04f46755f8af | 555 | #endif //CUBEBITE_DEBUG |
jmhong | 0:c2a57b2f934e | 556 | |
jmhong | 1:04f46755f8af | 557 | #ifdef CUBEBITE_DEBUG |
jmhong | 1:04f46755f8af | 558 | printf("[CUBEBITE] SendData() 호출 됨.\n"); |
jmhong | 1:04f46755f8af | 559 | #endif //CUBEBITE_DEBUG |
jmhong | 1:04f46755f8af | 560 | |
jmhong | 1:04f46755f8af | 561 | int iRet; |
jmhong | 2:8861d01a78e4 | 562 | |
jmhong | 2:8861d01a78e4 | 563 | // while(1 == myspirit.channel_clear()); |
jmhong | 2:8861d01a78e4 | 564 | // while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */ |
jmhong | 2:8861d01a78e4 | 565 | |
jmhong | 2:8861d01a78e4 | 566 | |
jmhong | 2:8861d01a78e4 | 567 | |
jmhong | 1:04f46755f8af | 568 | |
jmhong | 0:c2a57b2f934e | 569 | size_t curr_len = strlen((const char*)uiSendBuf) + 1; |
jmhong | 1:04f46755f8af | 570 | // printf("curr_len : [%d]\n", curr_len); |
jmhong | 1:04f46755f8af | 571 | |
jmhong | 1:04f46755f8af | 572 | |
jmhong | 2:8861d01a78e4 | 573 | |
jmhong | 1:04f46755f8af | 574 | iRet = myspirit.send(uiSendBuf, curr_len); |
jmhong | 1:04f46755f8af | 575 | |
jmhong | 1:04f46755f8af | 576 | |
jmhong | 1:04f46755f8af | 577 | dataCount = 0; |
jmhong | 1:04f46755f8af | 578 | for (int iTemp = 0; iTemp < TEST_STR_LEN; ++iTemp) |
jmhong | 1:04f46755f8af | 579 | { |
jmhong | 1:04f46755f8af | 580 | uiSendBuf[iTemp] = 0; |
jmhong | 1:04f46755f8af | 581 | } |
jmhong | 1:04f46755f8af | 582 | |
jmhong | 2:8861d01a78e4 | 583 | printf("iIsResetStartCounting : %d\n", iIsResetStartCounting); |
jmhong | 2:8861d01a78e4 | 584 | if (10 < iIsResetStartCounting) |
jmhong | 2:8861d01a78e4 | 585 | {//HJM : 아예 뻗으면 하드웨어 리셋으로 |
jmhong | 2:8861d01a78e4 | 586 | iIsResetStartCounting = 0; |
jmhong | 2:8861d01a78e4 | 587 | //180709 HJM : 하드웨어 리셋이 아니고 SPIRIT1 만 리셋하는 걸로 수정 |
jmhong | 2:8861d01a78e4 | 588 | resetHW.write(RESET_HW_ON); |
jmhong | 1:04f46755f8af | 589 | |
jmhong | 2:8861d01a78e4 | 590 | return RADIO_TX_ERR_RESET; |
jmhong | 2:8861d01a78e4 | 591 | } |
jmhong | 2:8861d01a78e4 | 592 | |
jmhong | 2:8861d01a78e4 | 593 | |
jmhong | 0:c2a57b2f934e | 594 | if (iRet == RADIO_TX_OK) |
jmhong | 0:c2a57b2f934e | 595 | { |
jmhong | 2:8861d01a78e4 | 596 | iIsResetStartCounting = 0; |
jmhong | 1:04f46755f8af | 597 | return RADIO_TX_OK; |
jmhong | 0:c2a57b2f934e | 598 | } |
jmhong | 0:c2a57b2f934e | 599 | else if (iRet == RADIO_TX_ERR) |
jmhong | 0:c2a57b2f934e | 600 | { |
jmhong | 2:8861d01a78e4 | 601 | myspirit.off(); |
jmhong | 2:8861d01a78e4 | 602 | myspirit.on(); |
jmhong | 2:8861d01a78e4 | 603 | //HJM : 테스트 !!, |
jmhong | 2:8861d01a78e4 | 604 | // while(1 == myspirit.channel_clear()); |
jmhong | 2:8861d01a78e4 | 605 | ++iIsResetStartCounting; |
jmhong | 2:8861d01a78e4 | 606 | return RADIO_TX_ERR; |
jmhong | 0:c2a57b2f934e | 607 | } |
jmhong | 0:c2a57b2f934e | 608 | else if (iRet == RADIO_TX_COLLISION) |
jmhong | 1:04f46755f8af | 609 | { |
jmhong | 1:04f46755f8af | 610 | return RADIO_TX_COLLISION; |
jmhong | 0:c2a57b2f934e | 611 | } |
jmhong | 0:c2a57b2f934e | 612 | else if (iRet == RADIO_TX_NOACK) |
jmhong | 0:c2a57b2f934e | 613 | { |
jmhong | 2:8861d01a78e4 | 614 | ++iIsResetStartCounting; |
jmhong | 1:04f46755f8af | 615 | return RADIO_TX_NOACK; |
jmhong | 0:c2a57b2f934e | 616 | } |
jmhong | 1:04f46755f8af | 617 | else if (iRet == RADIO_TX_ERR_RESET) |
jmhong | 1:04f46755f8af | 618 | { |
jmhong | 2:8861d01a78e4 | 619 | printf("RADIO_TX_ERR_RESET return.\n"); |
jmhong | 2:8861d01a78e4 | 620 | ++iIsResetStartCounting; |
jmhong | 2:8861d01a78e4 | 621 | |
jmhong | 2:8861d01a78e4 | 622 | //소프트웨어 리셋 |
jmhong | 1:04f46755f8af | 623 | myspirit.reset_board(); |
jmhong | 1:04f46755f8af | 624 | myspirit.off(); |
jmhong | 1:04f46755f8af | 625 | myspirit.on(); |
jmhong | 2:8861d01a78e4 | 626 | |
jmhong | 2:8861d01a78e4 | 627 | //180703 HJM : 하드웨어 리셋으로 바꿈 |
jmhong | 2:8861d01a78e4 | 628 | // resetHW.write(SPIRIT1_POWER_OFF); |
jmhong | 2:8861d01a78e4 | 629 | return RADIO_TX_ERR_RESET; |
jmhong | 1:04f46755f8af | 630 | } |
jmhong | 1:04f46755f8af | 631 | |
jmhong | 1:04f46755f8af | 632 | dataCount = 0; |
jmhong | 1:04f46755f8af | 633 | |
jmhong | 1:04f46755f8af | 634 | for (int iTemp = 0; iTemp < TEST_STR_LEN; ++iTemp) |
jmhong | 1:04f46755f8af | 635 | { |
jmhong | 1:04f46755f8af | 636 | uiSendBuf[iTemp] = 0; |
jmhong | 1:04f46755f8af | 637 | } |
jmhong | 2:8861d01a78e4 | 638 | |
jmhong | 2:8861d01a78e4 | 639 | |
jmhong | 2:8861d01a78e4 | 640 | |
jmhong | 2:8861d01a78e4 | 641 | |
jmhong | 0:c2a57b2f934e | 642 | |
jmhong | 0:c2a57b2f934e | 643 | #ifdef CUBEBITE_DEBUG |
jmhong | 0:c2a57b2f934e | 644 | printf("[CUBEBITE] SendData() 호출 끝.\n"); |
jmhong | 0:c2a57b2f934e | 645 | #endif |
jmhong | 0:c2a57b2f934e | 646 | |
jmhong | 1:04f46755f8af | 647 | return -10; |
jmhong | 0:c2a57b2f934e | 648 | } |
jmhong | 0:c2a57b2f934e | 649 | |
jmhong | 0:c2a57b2f934e | 650 | |
jmhong | 0:c2a57b2f934e | 651 |