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.
Diff: driverLifiTx.cpp
- Revision:
- 0:488aa8153e15
- Child:
- 21:82b5759f5047
- Child:
- 26:26474003e443
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/driverLifiTx.cpp Wed Mar 20 09:24:35 2019 +0000 @@ -0,0 +1,164 @@ +#include "driverLifiTx.h" + +void LifiTx_LedBlink(int num) +{ + switch(num) { + case LIFI_CHANNEL_1: + led_1 = ! led_1; + break; + case LIFI_CHANNEL_2: + led_2 = ! led_2; + break; + case LIFI_CHANNEL_3: + led_3 = ! led_3; + break; + case LIFI_CHANNEL_4: + led_4 = ! led_4; + break; + default: + led_1 = ! led_1; + led_2 = ! led_2; + led_3 = ! led_3; + led_4 = ! led_4; + break; + } +} +void LifiTx_LedOn(int num) +{ + switch(num) { + case LIFI_CHANNEL_1: + led_1 = 1; + break; + case LIFI_CHANNEL_2: + led_2 = 1; + break; + case LIFI_CHANNEL_3: + led_3 = 1; + break; + case LIFI_CHANNEL_4: + led_4 = 1; + break; + case LIFI_CHANNEL_ALL: + default: + led_1 = 1; + led_2 = 1; + led_3 = 1; + led_4 = 1; + break; + } +} + +void LifiTx_LedOff(int num) +{ + switch(num) { + case LIFI_CHANNEL_1: + led_1 = 0; + break; + case LIFI_CHANNEL_2: + led_2 = 0; + break; + case LIFI_CHANNEL_3: + led_3 = 0; + break; + case LIFI_CHANNEL_4: + led_4 = 0; + break; + case LIFI_CHANNEL_ALL: + default: + led_1 = 0; + led_2 = 0; + led_3 = 0; + led_4 = 0; + break; + } +} + +void LifiTx_LedTuning() +{ + printf("\n ====== LifiTx_LedTuning === Press Long key to skip this function == \n"); + LifiTx_LedOff(LIFI_CHANNEL_ALL); + + printf("\n => Turn On All LED \n"); + LifiTx_LedOn(LIFI_CHANNEL_ALL); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn Off All LED \n"); + LifiTx_LedOff(LIFI_CHANNEL_ALL); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn On - 1 LED \n"); + LifiTx_LedOn(LIFI_CHANNEL_1); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn On - 2 LED \n"); + LifiTx_LedOn(LIFI_CHANNEL_2); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn On - 3 LED \n"); + LifiTx_LedOn(LIFI_CHANNEL_3); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn On - 4 LED \n"); + LifiTx_LedOn(LIFI_CHANNEL_4); + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) break; + if( buttonCanSkipSuperLoop() ) return; + wait(1); + } + printf("\n => Turn Off All LED \n"); + LifiTx_LedOff(LIFI_CHANNEL_ALL); +} + +void LifiTx_Run() +{ +#if USE_LOCAL_TICKER + Ticker lifi_tx_timer; +#endif + + printf("\n======== LifiTx_Run =========\n"); +// us_timestamp_t us_time; + + LifiTx_Init(); + printf("Tx Symbol Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_PERIOD_SEC,LIFI_RX_SYMBOL_PERIOD_US); + printf("Rx Sample Feq=%f sec / %d us \n",LIFI_RX_SYMBOL_SAMPLE_PERIOD_SEC,LIFI_RX_SYMBOL_SAMPLE_PERIOD_US); + printf("Rx Sample/Symbol=%d times / adc edge threshod=%d mV \n",LIFI_RX_SAMPLE_PER_SYMBOL,LIFI_RX_EDGE_THRESHOLD); + printf("MIMO LIFI_MIMO_CHANNEL_NUM=%d / LIFI_ACTUAL_MAX_CHANNEL_NUM=%d \n",LIFI_MIMO_CHANNEL_NUM,LIFI_ACTUAL_MAX_CHANNEL_NUM); + printf("Tx interval = %d sec \n",LIFI_DEMO_TX_PERIOD_SEC); + + lifi_tx_timer.attach(&LifiTx_OokEmitHalfBit, LIFI_RX_SYMBOL_PERIOD_SEC); + + //printf("TimerFeq=%f us \n",); + //us_time = LIFI_RX_SYMBOL_PERIOD_US; + //lifi_tx_timer.attach_us(&LifiTx_OokEmitHalfBit, us_time); + //////// main loop /////// + buttonInitSkipLoop(); + while(1) { + if( buttonCanSkipLoop() ) return; + LifiTx_SendHelloMsg(); + wait(LIFI_DEMO_TX_PERIOD_SEC); + if(LifiTx_IsBusy()) wait(1); + if(LifiTx_IsBusy()) wait(1); + if(LifiTx_IsBusy()) wait(1); + } +} \ No newline at end of file