Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
driverLifiRx.cpp@1:502e5a0c14c3, 2019-03-21 (annotated)
- Committer:
- JongYongPark
- Date:
- Thu Mar 21 00:20:37 2019 +0000
- Revision:
- 1:502e5a0c14c3
- Parent:
- 0:488aa8153e15
- Child:
- 2:e1fd30fce2f8
working RX by fixing with eventqueue
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JongYongPark | 0:488aa8153e15 | 1 | #include "driverLifiRx.h" |
JongYongPark | 0:488aa8153e15 | 2 | |
JongYongPark | 0:488aa8153e15 | 3 | |
JongYongPark | 0:488aa8153e15 | 4 | //typedef enum LIFI_Tx_Rx_Mode LIFI_Tx_Rx_Mode; |
JongYongPark | 0:488aa8153e15 | 5 | //Lifi_RxTx_Mode vlc_tx_rx_mode = LIFI_Tx_Mode; |
JongYongPark | 0:488aa8153e15 | 6 | //int vlc_tx_rx_mode_bool = 0; |
JongYongPark | 0:488aa8153e15 | 7 | // |
JongYongPark | 0:488aa8153e15 | 8 | //// RX 는 ADC PIN을 3.3V 로 연결한다. |
JongYongPark | 0:488aa8153e15 | 9 | //Lifi_RxTx_Mode is_board_vlc_rx_mode_enum() |
JongYongPark | 0:488aa8153e15 | 10 | //{ |
JongYongPark | 0:488aa8153e15 | 11 | // float meas_r1; |
JongYongPark | 0:488aa8153e15 | 12 | // float meas_v1; |
JongYongPark | 0:488aa8153e15 | 13 | // |
JongYongPark | 0:488aa8153e15 | 14 | // meas_r1 = adc_tx_rx_mode_select.read() ; |
JongYongPark | 0:488aa8153e15 | 15 | // meas_v1 = meas_r1 * 3300; |
JongYongPark | 0:488aa8153e15 | 16 | // if( ceil(meas_v1) > 1000 ) return LIFI_Tx_Mode; |
JongYongPark | 0:488aa8153e15 | 17 | // else return Lifi_Rx_Mode; |
JongYongPark | 0:488aa8153e15 | 18 | //} |
JongYongPark | 0:488aa8153e15 | 19 | |
JongYongPark | 0:488aa8153e15 | 20 | // Pull up setting. RX - Connect to GND |
JongYongPark | 0:488aa8153e15 | 21 | int Lifi_IsRxMode() |
JongYongPark | 0:488aa8153e15 | 22 | { |
JongYongPark | 0:488aa8153e15 | 23 | #define USE_MODE_SELECT_BY_ADC 0 |
JongYongPark | 0:488aa8153e15 | 24 | #if USE_MODE_SELECT_BY_ADC |
JongYongPark | 0:488aa8153e15 | 25 | // 연결이 되지 않으면 기본으로 0 이다. |
JongYongPark | 0:488aa8153e15 | 26 | // 따라서 ADC를 이용할 경우 3.3V와 연결하고나 저항을 이용해서 여러 입력값에 따른 모드를 선택할 수 있다. |
JongYongPark | 0:488aa8153e15 | 27 | float meas_r1; |
JongYongPark | 0:488aa8153e15 | 28 | float meas_v1; |
JongYongPark | 0:488aa8153e15 | 29 | |
JongYongPark | 0:488aa8153e15 | 30 | meas_r1 = adc_tx_rx_mode_select.read() ; |
JongYongPark | 0:488aa8153e15 | 31 | meas_v1 = meas_r1 * 3300; |
JongYongPark | 0:488aa8153e15 | 32 | printf("meas_r1 = %f, meas_v1 = %f",meas_r1, meas_v1 ); |
JongYongPark | 0:488aa8153e15 | 33 | if( ceil(meas_v1) > 1000 ) return LIFI_Tx_Mode; |
JongYongPark | 0:488aa8153e15 | 34 | else return Lifi_Rx_Mode; |
JongYongPark | 0:488aa8153e15 | 35 | |
JongYongPark | 0:488aa8153e15 | 36 | #else |
JongYongPark | 0:488aa8153e15 | 37 | int value=1; |
JongYongPark | 0:488aa8153e15 | 38 | value = lifi_TxRx_ModePin.read(); |
JongYongPark | 0:488aa8153e15 | 39 | if( value == 0 ) { |
JongYongPark | 0:488aa8153e15 | 40 | printf("RX mode (%d))", value); |
JongYongPark | 0:488aa8153e15 | 41 | return 1; |
JongYongPark | 0:488aa8153e15 | 42 | } else { |
JongYongPark | 0:488aa8153e15 | 43 | printf("TX mode (%d))", value); |
JongYongPark | 0:488aa8153e15 | 44 | return 0; |
JongYongPark | 0:488aa8153e15 | 45 | } |
JongYongPark | 0:488aa8153e15 | 46 | #endif |
JongYongPark | 0:488aa8153e15 | 47 | } |
JongYongPark | 0:488aa8153e15 | 48 | |
JongYongPark | 0:488aa8153e15 | 49 | |
JongYongPark | 0:488aa8153e15 | 50 | // https://forum.arduino.cc/index.php?topic=185158.0 |
JongYongPark | 0:488aa8153e15 | 51 | float LifiRx_GetLuxFromPdVoltage(float volt_mili) |
JongYongPark | 0:488aa8153e15 | 52 | { |
JongYongPark | 0:488aa8153e15 | 53 | #if 0 |
JongYongPark | 0:488aa8153e15 | 54 | float amps_mili = mili_volt / 10000.0; // across 10,000 Ohms |
JongYongPark | 0:488aa8153e15 | 55 | float microamps = amps_mili * 1000; |
JongYongPark | 0:488aa8153e15 | 56 | float lux = microamps * 2.0; |
JongYongPark | 0:488aa8153e15 | 57 | return lux; |
JongYongPark | 0:488aa8153e15 | 58 | #else |
JongYongPark | 0:488aa8153e15 | 59 | return volt_mili / 5.0 ; |
JongYongPark | 0:488aa8153e15 | 60 | #endif |
JongYongPark | 0:488aa8153e15 | 61 | } |
JongYongPark | 0:488aa8153e15 | 62 | |
JongYongPark | 0:488aa8153e15 | 63 | // https://code.google.com/archive/p/davidegironi/downloads |
JongYongPark | 0:488aa8153e15 | 64 | /* |
JongYongPark | 0:488aa8153e15 | 65 | * get lux from voltage |
JongYongPark | 0:488aa8153e15 | 66 | */ |
JongYongPark | 0:488aa8153e15 | 67 | double LifiRx_GetLux_Temt6000(double vol) |
JongYongPark | 0:488aa8153e15 | 68 | { |
JongYongPark | 0:488aa8153e15 | 69 | //suppose we read the voltage from the emitter of temt6000, with a 10k pulldown resistor connected to gnd |
JongYongPark | 0:488aa8153e15 | 70 | //V[V] = I[A]*R[ohm] = I[uA] * 1[A]/1000000[킕] * 10000[ohm] = I[uA] * 1[A]/1[uA] * 0.01[ohm] |
JongYongPark | 0:488aa8153e15 | 71 | //1[uA] = V[V] / 0.01[ohm] = 100 * V[V/ohm] |
JongYongPark | 0:488aa8153e15 | 72 | //the curve from datasheet seems y=2x+0, so lux = 2 * I[uA] = 2 * 100 * V[V/ohm] |
JongYongPark | 0:488aa8153e15 | 73 | return 2*(100*vol); |
JongYongPark | 0:488aa8153e15 | 74 | } |
JongYongPark | 0:488aa8153e15 | 75 | void LifiRx_PdTunning() |
JongYongPark | 0:488aa8153e15 | 76 | { |
JongYongPark | 0:488aa8153e15 | 77 | float meas_r1; |
JongYongPark | 0:488aa8153e15 | 78 | float meas_v1; |
JongYongPark | 0:488aa8153e15 | 79 | float meas_r2; |
JongYongPark | 0:488aa8153e15 | 80 | float meas_v2; |
JongYongPark | 0:488aa8153e15 | 81 | float meas_r3; |
JongYongPark | 0:488aa8153e15 | 82 | float meas_v3; |
JongYongPark | 0:488aa8153e15 | 83 | float meas_r4; |
JongYongPark | 0:488aa8153e15 | 84 | float meas_v4; |
JongYongPark | 0:488aa8153e15 | 85 | |
JongYongPark | 0:488aa8153e15 | 86 | // note myvalues for "office light" (ca. 200 lux) and direct sunlight, clear day (ca 50000lux) |
JongYongPark | 0:488aa8153e15 | 87 | |
JongYongPark | 0:488aa8153e15 | 88 | |
JongYongPark | 0:488aa8153e15 | 89 | // https://www.dfrobot.com/wiki/index.php/DFRobot_Ambient_Light_Sensor_SKU:DFR0026 |
JongYongPark | 0:488aa8153e15 | 90 | //Specification |
JongYongPark | 0:488aa8153e15 | 91 | //Supply Voltage: 3.3V to 5V |
JongYongPark | 0:488aa8153e15 | 92 | //Illumination range : 1 Lux to 6000 Lux |
JongYongPark | 0:488aa8153e15 | 93 | //Responsive time : 15us |
JongYongPark | 0:488aa8153e15 | 94 | //Interface: Analog |
JongYongPark | 0:488aa8153e15 | 95 | //Size:22x30mm |
JongYongPark | 0:488aa8153e15 | 96 | |
JongYongPark | 0:488aa8153e15 | 97 | |
JongYongPark | 0:488aa8153e15 | 98 | |
JongYongPark | 0:488aa8153e15 | 99 | printf("\n4 LifiRx_PdTunning \n"); |
JongYongPark | 0:488aa8153e15 | 100 | buttonInitSkipLoop(); |
JongYongPark | 0:488aa8153e15 | 101 | while(1) { |
JongYongPark | 0:488aa8153e15 | 102 | if( buttonCanSkipLoop() ) return; |
JongYongPark | 0:488aa8153e15 | 103 | meas_r1 = adc_1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 104 | meas_v1 = meas_r1 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 105 | meas_r2 = adc_2.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 106 | meas_v2 = meas_r2 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 107 | meas_r3 = adc_3.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 108 | meas_v3 = meas_r3 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 109 | meas_r4 = adc_4.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 110 | meas_v4 = meas_r4 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 111 | // Display values |
JongYongPark | 0:488aa8153e15 | 112 | printf("measure 1 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r1, meas_v1, meas_v1/10.0, meas_v1/5.0 ); |
JongYongPark | 0:488aa8153e15 | 113 | printf("measure 2 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r2, meas_v2, meas_v2/10.0, meas_v2/5.0 ); |
JongYongPark | 0:488aa8153e15 | 114 | printf("measure 3 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r3, meas_v3, meas_v3/10.0, meas_v3/5.0 ); |
JongYongPark | 0:488aa8153e15 | 115 | printf("measure 4 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r4, meas_v4, meas_v4/10.0, meas_v4/5.0 ); |
JongYongPark | 0:488aa8153e15 | 116 | printf("\033[4A"); |
JongYongPark | 0:488aa8153e15 | 117 | wait(0.1); |
JongYongPark | 0:488aa8153e15 | 118 | } |
JongYongPark | 0:488aa8153e15 | 119 | } |
JongYongPark | 0:488aa8153e15 | 120 | |
JongYongPark | 0:488aa8153e15 | 121 | int LifiRx_AdcRead(int num) |
JongYongPark | 0:488aa8153e15 | 122 | { |
JongYongPark | 0:488aa8153e15 | 123 | //floor(x) - round down |
JongYongPark | 0:488aa8153e15 | 124 | //ceil(x) - round up |
JongYongPark | 0:488aa8153e15 | 125 | |
JongYongPark | 0:488aa8153e15 | 126 | float meas_r1; |
JongYongPark | 0:488aa8153e15 | 127 | float meas_v1; |
JongYongPark | 0:488aa8153e15 | 128 | float meas_r2; |
JongYongPark | 0:488aa8153e15 | 129 | float meas_v2; |
JongYongPark | 0:488aa8153e15 | 130 | float meas_r3; |
JongYongPark | 0:488aa8153e15 | 131 | float meas_v3; |
JongYongPark | 0:488aa8153e15 | 132 | float meas_r4; |
JongYongPark | 0:488aa8153e15 | 133 | float meas_v4; |
JongYongPark | 0:488aa8153e15 | 134 | float meas_r_average; |
JongYongPark | 0:488aa8153e15 | 135 | float meas_v_average; |
JongYongPark | 0:488aa8153e15 | 136 | int ret = 0; |
JongYongPark | 0:488aa8153e15 | 137 | switch(num) { |
JongYongPark | 0:488aa8153e15 | 138 | case LIFI_CHANNEL_1: |
JongYongPark | 0:488aa8153e15 | 139 | meas_r1 = adc_1.read() ; |
JongYongPark | 0:488aa8153e15 | 140 | meas_v1 = meas_r1 * 3300; |
JongYongPark | 0:488aa8153e15 | 141 | ret = ceil(meas_v1); |
JongYongPark | 0:488aa8153e15 | 142 | break; |
JongYongPark | 0:488aa8153e15 | 143 | case LIFI_CHANNEL_2: |
JongYongPark | 0:488aa8153e15 | 144 | meas_r2 = adc_2.read() ; |
JongYongPark | 0:488aa8153e15 | 145 | meas_v2 = meas_r2 * 3300; |
JongYongPark | 0:488aa8153e15 | 146 | ret = ceil(meas_v2); |
JongYongPark | 0:488aa8153e15 | 147 | break; |
JongYongPark | 0:488aa8153e15 | 148 | case LIFI_CHANNEL_3: |
JongYongPark | 0:488aa8153e15 | 149 | meas_r3 = adc_3.read() ; |
JongYongPark | 0:488aa8153e15 | 150 | meas_v3 = meas_r3 * 3300; |
JongYongPark | 0:488aa8153e15 | 151 | ret = ceil(meas_v3); |
JongYongPark | 0:488aa8153e15 | 152 | break; |
JongYongPark | 0:488aa8153e15 | 153 | case LIFI_CHANNEL_4: |
JongYongPark | 0:488aa8153e15 | 154 | meas_r4 = adc_4.read() ; |
JongYongPark | 0:488aa8153e15 | 155 | meas_v4 = meas_r4 * 3300; |
JongYongPark | 0:488aa8153e15 | 156 | ret = ceil(meas_v4); |
JongYongPark | 0:488aa8153e15 | 157 | break; |
JongYongPark | 0:488aa8153e15 | 158 | case LIFI_CHANNEL_ALL: |
JongYongPark | 0:488aa8153e15 | 159 | default: |
JongYongPark | 0:488aa8153e15 | 160 | meas_r1 = adc_1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 161 | meas_v1 = meas_r1 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 162 | meas_r2 = adc_2.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 163 | meas_v2 = meas_r2 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 164 | meas_r3 = adc_3.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 165 | meas_v3 = meas_r3 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 166 | meas_r4 = adc_4.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
JongYongPark | 0:488aa8153e15 | 167 | meas_v4 = meas_r4 * 3300; // Converts value in the 0V-3.3V range |
JongYongPark | 0:488aa8153e15 | 168 | meas_r_average = ( meas_r1 + meas_r2 + meas_r3 + meas_r4 ) / 4 ; |
JongYongPark | 0:488aa8153e15 | 169 | meas_v_average = meas_r_average * 3300; |
JongYongPark | 0:488aa8153e15 | 170 | ret = ceil(meas_v_average); |
JongYongPark | 0:488aa8153e15 | 171 | break; |
JongYongPark | 0:488aa8153e15 | 172 | } |
JongYongPark | 0:488aa8153e15 | 173 | return ret; |
JongYongPark | 0:488aa8153e15 | 174 | } |
JongYongPark | 0:488aa8153e15 | 175 | |
JongYongPark | 0:488aa8153e15 | 176 | void LifiRx_Run() |
JongYongPark | 0:488aa8153e15 | 177 | { |
JongYongPark | 0:488aa8153e15 | 178 | printf("\n======== LifiRx_Run =========\n"); |
JongYongPark | 0:488aa8153e15 | 179 | #if USE_LOCAL_TICKER |
JongYongPark | 0:488aa8153e15 | 180 | Ticker lifi_rx_timer; |
JongYongPark | 0:488aa8153e15 | 181 | #endif |
JongYongPark | 0:488aa8153e15 | 182 | // us_timestamp_t us_time; |
JongYongPark | 0:488aa8153e15 | 183 | |
JongYongPark | 0:488aa8153e15 | 184 | LifiRx_Init(); |
JongYongPark | 0:488aa8153e15 | 185 | printf("Tx Symbol Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_PERIOD_SEC,LIFI_RX_SYMBOL_PERIOD_US); |
JongYongPark | 0:488aa8153e15 | 186 | printf("Rx Sample Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_SAMPLE_PERIOD_SEC,LIFI_RX_SYMBOL_SAMPLE_PERIOD_US); |
JongYongPark | 0:488aa8153e15 | 187 | printf("Rx Sample/Symbol=%d times / adc edge threshod=%d mV \n",LIFI_RX_SAMPLE_PER_SYMBOL,LIFI_RX_EDGE_THRESHOLD); |
JongYongPark | 0:488aa8153e15 | 188 | printf("MIMO LIFI_MIMO_CHANNEL_NUM=%d / LIFI_ACTUAL_MAX_CHANNEL_NUM=%d \n",LIFI_MIMO_CHANNEL_NUM,LIFI_ACTUAL_MAX_CHANNEL_NUM); |
JongYongPark | 0:488aa8153e15 | 189 | printf("Tx interval = %d sec \n",LIFI_DEMO_TX_PERIOD_SEC); |
JongYongPark | 0:488aa8153e15 | 190 | |
JongYongPark | 0:488aa8153e15 | 191 | lifi_rx_timer.attach(&LifiRx_SampleSignalEdge, LIFI_RX_SYMBOL_SAMPLE_PERIOD_SEC); |
JongYongPark | 0:488aa8153e15 | 192 | printf("1"); |
JongYongPark | 0:488aa8153e15 | 193 | // us_time = LIFI_RX_SYMBOL_SAMPLE_PERIOD_US; |
JongYongPark | 0:488aa8153e15 | 194 | // lifi_rx_timer.attach_us(&LifiRx_SampleSignalEdge, us_time); |
JongYongPark | 0:488aa8153e15 | 195 | //////// main loop /////// |
JongYongPark | 0:488aa8153e15 | 196 | buttonInitSkipLoop(); |
JongYongPark | 0:488aa8153e15 | 197 | //printf("2"); |
JongYongPark | 0:488aa8153e15 | 198 | while(1) { |
JongYongPark | 0:488aa8153e15 | 199 | //printf("3"); |
JongYongPark | 0:488aa8153e15 | 200 | if( buttonCanSkipLoop() ) return; |
JongYongPark | 0:488aa8153e15 | 201 | LifiRx_LoopOOK(); |
JongYongPark | 0:488aa8153e15 | 202 | //printf("4"); |
JongYongPark | 0:488aa8153e15 | 203 | wait_ms(50); |
JongYongPark | 0:488aa8153e15 | 204 | } |
JongYongPark | 0:488aa8153e15 | 205 | } |
JongYongPark | 0:488aa8153e15 | 206 | |
JongYongPark | 0:488aa8153e15 | 207 | ////////////// |
JongYongPark | 0:488aa8153e15 | 208 | |
JongYongPark | 0:488aa8153e15 | 209 | // https://os.mbed.com/blog/entry/Simplify-your-code-with-mbed-events/ |
JongYongPark | 0:488aa8153e15 | 210 | // create an event queue |
JongYongPark | 0:488aa8153e15 | 211 | EventQueue queue; |
JongYongPark | 1:502e5a0c14c3 | 212 | #if USE_LIFI_RX_CHECK_QUEUE |
JongYongPark | 1:502e5a0c14c3 | 213 | EventQueue lifi_tx_check_queue(32 * EVENTS_EVENT_SIZE); |
JongYongPark | 1:502e5a0c14c3 | 214 | #endif |
JongYongPark | 0:488aa8153e15 | 215 | |
JongYongPark | 0:488aa8153e15 | 216 | void do_something() { |
JongYongPark | 0:488aa8153e15 | 217 | // this now runs in the context of eventThread, instead of in the ISR |
JongYongPark | 0:488aa8153e15 | 218 | //printf("!"); |
JongYongPark | 0:488aa8153e15 | 219 | LifiRx_SampleSignalEdge(); |
JongYongPark | 0:488aa8153e15 | 220 | } |
JongYongPark | 0:488aa8153e15 | 221 | |
JongYongPark | 0:488aa8153e15 | 222 | |
JongYongPark | 0:488aa8153e15 | 223 | |
JongYongPark | 0:488aa8153e15 | 224 | void LifiRx_RunWithEventQueue() |
JongYongPark | 0:488aa8153e15 | 225 | { |
JongYongPark | 0:488aa8153e15 | 226 | |
JongYongPark | 0:488aa8153e15 | 227 | #if USE_LOCAL_TICKER |
JongYongPark | 0:488aa8153e15 | 228 | Ticker lifi_rx_timer; |
JongYongPark | 0:488aa8153e15 | 229 | #endif |
JongYongPark | 0:488aa8153e15 | 230 | |
JongYongPark | 0:488aa8153e15 | 231 | // create a thread that'll run the event queue's dispatch function |
JongYongPark | 1:502e5a0c14c3 | 232 | Thread eventThread(osPriorityHigh); |
JongYongPark | 1:502e5a0c14c3 | 233 | //Thread eventThread; |
JongYongPark | 0:488aa8153e15 | 234 | eventThread.start(callback(&queue, &EventQueue::dispatch_forever)); |
JongYongPark | 0:488aa8153e15 | 235 | |
JongYongPark | 1:502e5a0c14c3 | 236 | #if USE_LIFI_RX_CHECK_QUEUE |
JongYongPark | 1:502e5a0c14c3 | 237 | Thread lifiRxCheckThread(osPriorityNormal); |
JongYongPark | 1:502e5a0c14c3 | 238 | lifiRxCheckThread.start(callback(&lifi_tx_check_queue, &EventQueue::dispatch_forever)); |
JongYongPark | 1:502e5a0c14c3 | 239 | #endif |
JongYongPark | 0:488aa8153e15 | 240 | |
JongYongPark | 0:488aa8153e15 | 241 | printf("\n======== LifiRx_RunWithEventQueue =========\n"); |
JongYongPark | 0:488aa8153e15 | 242 | LifiRx_Init(); |
JongYongPark | 0:488aa8153e15 | 243 | printf("Tx Symbol Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_PERIOD_SEC,LIFI_RX_SYMBOL_PERIOD_US); |
JongYongPark | 0:488aa8153e15 | 244 | printf("Rx Sample Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_SAMPLE_PERIOD_SEC,LIFI_RX_SYMBOL_SAMPLE_PERIOD_US); |
JongYongPark | 0:488aa8153e15 | 245 | printf("Rx Sample/Symbol=%d times / adc edge threshod=%d mV \n",LIFI_RX_SAMPLE_PER_SYMBOL,LIFI_RX_EDGE_THRESHOLD); |
JongYongPark | 0:488aa8153e15 | 246 | printf("MIMO LIFI_MIMO_CHANNEL_NUM=%d / LIFI_ACTUAL_MAX_CHANNEL_NUM=%d \n",LIFI_MIMO_CHANNEL_NUM,LIFI_ACTUAL_MAX_CHANNEL_NUM); |
JongYongPark | 0:488aa8153e15 | 247 | printf("Tx interval = %d sec \n",LIFI_DEMO_TX_PERIOD_SEC); |
JongYongPark | 0:488aa8153e15 | 248 | |
JongYongPark | 0:488aa8153e15 | 249 | lifi_rx_timer.attach(queue.event(&do_something), LIFI_RX_SYMBOL_SAMPLE_PERIOD_SEC); |
JongYongPark | 0:488aa8153e15 | 250 | // us_time = LIFI_RX_SYMBOL_SAMPLE_PERIOD_US; |
JongYongPark | 0:488aa8153e15 | 251 | // lifi_rx_timer.attach_us(&LifiRx_SampleSignalEdge, us_time); |
JongYongPark | 0:488aa8153e15 | 252 | //////// main loop /////// |
JongYongPark | 0:488aa8153e15 | 253 | buttonInitSkipLoop(); |
JongYongPark | 0:488aa8153e15 | 254 | //printf("2"); |
JongYongPark | 0:488aa8153e15 | 255 | while(1) { |
JongYongPark | 1:502e5a0c14c3 | 256 | #if (USE_LIFI_RX_CHECK_QUEUE==0) |
JongYongPark | 0:488aa8153e15 | 257 | //printf("3"); |
JongYongPark | 0:488aa8153e15 | 258 | if( buttonCanSkipLoop() ) return; |
JongYongPark | 0:488aa8153e15 | 259 | LifiRx_LoopOOK(); |
JongYongPark | 0:488aa8153e15 | 260 | //printf("4"); |
JongYongPark | 0:488aa8153e15 | 261 | #endif |
JongYongPark | 0:488aa8153e15 | 262 | wait_ms(50); |
JongYongPark | 0:488aa8153e15 | 263 | } |
JongYongPark | 0:488aa8153e15 | 264 | } |
JongYongPark | 0:488aa8153e15 | 265 |