⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezlink_modem_cmd.c

📁 芯科rf资料
💻 C
字号:
/*** ============================================================================**** FILE**  EZLink_Modem_cmd.c**** DESCRIPTION**  Contains all modem functions		    **** CREATED**  Silicon Laboratories Hungary Ltd**** COPYRIGHT**  Copyright 2008 Silicon Laboratories, Inc.  **	http://www.silabs.com**** ============================================================================*///===============================================================================================// Radio modem// ASCIII command interpreter//===============================================================================================#include "EZLink_Modem_cmd.h"#include "Si4421.h" 						/* =========================================================== *						 *						GLOBAL variables					   *						 * =========================================================== */extern xdata uint8 rf_ch;		//frequency channel select  extern xdata uint8 rf_pwr;		//rf output power 	extern xdata uint16 rf_dr;		//data rate selectxdata uint8 cis;            				// CMD interpreter statusxdata uint8 iparam;         				// command parameter, 0-255xdata uint16 lparam;		  				// command parameter	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  +  + FUNCTION NAME:  void CM_init(void)  +  + DESCRIPTION:    initialize the character interpreter statemachine  +  +	INPUT:			None  +  + RETURN:         None  +  + NOTES:          None  +  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/void CMD_init(void)					{  cis = 0;}/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  +  + FUNCTION NAME:  void printAbout(void)  +  + DESCRIPTION:    print the firmware information to UART  +  +	INPUT:			None  +  + RETURN:         None  +  + NOTES:          None  +  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/void printAbout(void)			{  printf("\n\rEZLink demo(C8051F930 + Si4421)");  printf("\n\rRadio modem V");  printf(FW_VERSION);  printf("\n\rSilicon Labs, 2008\n\r");}/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  +  + FUNCTION NAME:  void printOK(void)  +  + DESCRIPTION:    print OK to UART  +  +	INPUT:			None  +  + RETURN:         None  +  + NOTES:          None  +  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/	void printOK(void)									{	  printf("\n\rOK\n\r>");}/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  +  + FUNCTION NAME:  void printHelp(void)  +  + DESCRIPTION:    print help information to UART  +  +	INPUT:			None  +  + RETURN:         None  +  + NOTES:          None  +  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/void printHelp(void)			   {  printf("\n\rF=n      : Set the rf channel (0-");  printf(MAX_FREQ);  printf(")");  printf("\n\rD=n      : Set the rf datarate (0-32000)");  printf("\n\rP=n      : Set the rf output power (0-7)");  printf("\n\rS?       : Print the current settings");  printf("\n\rI        : Print firmware version information");  printOK();  }/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  +  + FUNCTION NAME:  void CmdExec(char CMD)  +  + DESCRIPTION:    CMD character interpreter  +  +	INPUT:			CMD - received character form UART  +  + RETURN:         None  +  + NOTES:          None  +  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/void CmdExec(char CMD)         		                                   {  xdata uint16 Frequency_cmd,Data_rate_cmd,Transmitter_control_cmd;  if ((CMD != '\n') && (CMD != ' '))                            // don't use <space> and <LF>  switch (cis)                                                  // cis: Command Interpreter Status    {    case 0:                                                     // cis=0: basic state      switch (CMD)        {        case '\r':          printOK();          break;        case '?':          cis = 1;          break;        case 'I': case 'i':          cis = 2;          break;        case 'S': case 's':          cis = 3;          break;        case 'F': case 'f':          cis = 10;          iparam = 0;          break;        case 'D': case 'd':          cis = 20;          iparam = 0;          break;        case 'P': case 'p':          cis = 30;          iparam = 0;          break;        default:          cis = 255;          break;        }      break;    case 1:                                                     // cis=2: "?" arrived: print help      if (CMD == '\r')      {        printHelp();        cis = 0;        break;	  }	  else cis = 255;    break;    case 2:                                                     // cis=2: "I" arrived: print version info      if (CMD == '\r')      {      	printAbout();      	cis = 0;      	break;      }	  else cis = 255;		break;    case 3:                                                     // cis=2: "S?" arrived: print current settings      switch( CMD )	  {	  case '=': break;      case '?': break;      case '\r': 	  	printf("\n\rChannel : %bd", rf_ch);       	printf("\n\rDatarate: %u", rf_dr);       	printf("\n\rRF power: %bd", rf_pwr);       	printOK();       	cis = 0;       	break;	  default:        cis = 255;		break;	  }  	    break;  	case 10:                                                    // cis=3: "F" arrived: frequency setting      switch (CMD)        {        case '=': break;        case '0': case '1': case '2': case '3': case '4':        case '5': case '6': case '7': case '8': case '9':          iparam = iparam * 10 + CMD - '0';          break;        case '\r':		  if( iparam > FREQ_maxid )		  {			iparam = 0;		  }		  rf_ch = iparam;	      Frequency_cmd = set_frq(iparam);          send_control_command(Frequency_cmd);          printOK();          cis = 0;	      break;		default:          cis = 255;          break;          }	break;    case 20:                                                    // cis=3: "D" arrived: datarate setting      switch (CMD)        {        case '=': break;        case '0': case '1': case '2': case '3': case '4':        case '5': case '6': case '7': case '8': case '9':          lparam = lparam * 10 + CMD - '0';          		  break;        case '\r':          		  if ( lparam > 32000) lparam = 32000; 		  rf_dr = lparam;		  Data_rate_cmd = set_dr(lparam);		  send_control_command(Data_rate_cmd);		  lparam=0;          printOK();          cis = 0;          break;        default:          cis = 255;          break;        }      break;    case 30:                                                    // cis=3: "P" arrived: output power setting      switch (CMD)        {        case '=': break;        case '0': case '1': case '2': case '3': case '4':        case '5': case '6': case '7': case '8': case '9':          iparam = iparam * 10 + CMD - '0';          break;        case '\r':		  			  if(iparam > 7) iparam = 7;		  rf_pwr = iparam;          Transmitter_control_cmd = set_tx(RF_DEV, iparam);          send_control_command(Transmitter_control_cmd);          printOK();          cis = 0;          break;		default:          cis = 255;          break;        }      break;    case 255:                                                   // Bad command or parameter      printf("\n\rERROR\n\r");      cis = 0;      break;    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -