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.
driverLifiTx.cpp
- Committer:
- JongYongPark
- Date:
- 2019-04-10
- Revision:
- 28:1754d532cb52
- Parent:
- 26:26474003e443
- Child:
- 30:75cb79acdcff
File content as of revision 28:1754d532cb52:
#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_DebugLedOn(){
// online compile error
//led_tx_debug = 1;
}
void LifiTx_DebugLedOff(){
// online compile error
//led_tx_debug = 0;
}
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);
}
}