// change amount of shift
RFCTRL_FECTRL = (0 << 4/*DIG1*/) | (1 << 2/*DIG2*/);
phyWriteRegister(ANT_DIV_REG, (1 << ANT_CTRL) | (1 << ANT_EXT_SW_EN));
extinguishLamp();
tib.antCtrl = DEFAULT_ANTENNA;
tib.channel = DEFAULT_CHANNEL;
tib.txPwr = DEFAULT_ATTENUATION;
tib.xtalTrim = DEFAULT_XTAL_TRIM;
sprintf(replyMessage, "\r\n" SPLASH_STRING " " VERSION_ID "\r\n");
replySendData();
appState = APP_STATE_IDLE;
} break;
case APP_STATE_IDLE:
break;
default:
break;
}
}
以下是时间句柄:
/*************************************************************************//**
*****************************************************************************/
static void appTimerHandler(SYS_Timer_t *timer)
{
appSendData();
(void)timer;
}
以下是发射句柄:
/*************************************************************************//**
*****************************************************************************/
static bool appDataInd(NWK_DataInd_t *ind)
{
newLetter = ind->data[0];
switch(newLetter)
{
case 'T':
{
lightLamp();
appSetCwMode(); // Key up the transmitter.
} break;
case 's':
{
sprintf(replyMessage, "\r\n" "TIB Values:\r\n""CHANNEL = %d\r\n" "TX_PWR = 0x%02X\r\n" "ANT_CTRL =%d\r\n" "XTAL_TRIM = 0x%02X\r\n",tib.channel, tib.txPwr, tib.antCtrl, tib.xtalTrim);
} break;
case 'C':
{
if (tib.channel != 26) //Upper limit CH26 2480 MHz
tib.channel++;
sprintf(replyMessage, "\r\n" "CHANNEL = %d""\r\n", tib.channel);
} break;
case 'c':
{
if (tib.channel != 11) //Lower limit CH11 2405 MHz
tib.channel--;
sprintf(replyMessage, "\r\n" "CHANNEL = %d""\r\n", tib.channel);
} break;
case 'f': //lower frequency =bigger XTAL_TRIM value
{
if(tib.xtalTrim != 0x0f) //Upper limit is 0x0f
tib.xtalTrim++;
sprintf(replyMessage, "\r\n" "XTAL_TRIM = 0x%02X\r\n", tib.xtalTrim);
} break;
case 'F': //higher frequency =smaller XTAL_TRIM value
{
if(tib.xtalTrim != 0x00) //lower limit is 0x00
tib.xtalTrim--;
sprintf(replyMessage, "\r\n" "XTAL_TRIM = 0x%02X\r\n", tib.xtalTrim);
} break;
case 'P': //higher power = lowerTX_PWR value
{
if (tib.txPwr != 0x00)
tib.txPwr--;
sprintf(replyMessage, "\r\n" "TX_PWR = 0x%02X""\r\n", tib.txPwr);
} break;
case 'p': //lower power = higherTX_PWR value
{
if (tib.txPwr != 0x0f)
tib.txPwr++;
sprintf(replyMessage, "\r\n" "TX_PWR = 0x%02X""\r\n", tib.txPwr);
} break;
case 'a':
{
if (tib.antCtrl == 1)
tib.antCtrl = 2;
sprintf(replyMessage, "\r\n" "ANT_CTRL = %d""\r\n", tib.antCtrl);
} break;
default:
{
sprintf(replyMessage, "\r\n" TOP_MENU "\r\n");
} break;
}
replySendData();
return true;
}
由上边可以看出,如果我把一个程序写进两块板,注意地址是不一样的,我想只改下地址就可以,那么谁是主谁是从应都一样,我下程序下进去,好像串口得改一下,具体我再研究一下。上次做的是利用现有的ELF做的。
我在一个发T,另一个LED0亮了,我又把另一个接电脑发T,我这个板也亮了。
由此可见,这个程序是通过定时器来收,通过应用句柄发的一个小系统。
那么自己开发的化只要改变HAL,再加一个旗标,我想就可以了。
本帖最后由 ddllxxrr 于 2015-1-4 21:38 编辑