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

📄 console.c

📁 本程序是基于Zigbee协议的无线温度传感器网络系统
💻 C
字号:
/*
*2006/08/16 WXL 2.0
 *
 */

/*
V0.2 added PC-based binding         21/July/2006
V0.1 Initial Release                10/July/2006
*/


#include "compiler.h"               //compiler specific
#include "hal.h"
#include "halStack.h"
#include "lrwpan_config.h"
#include "console.h"
#include "wx_lrwpan.h"

//utility print functions that do not use printf and expect ROM strings
//these assume that constants and strings are stored in code memory

void conPCRLF(void){
	conPrintROMString("\n");
}

void conPrintROMString_func (ROMCHAR *s) {
  while(*s) {
    if (*s == '\n') halPutch('\r');
    halPutch(*s);
    s++;
  }
}

void conPrintString (char *s) {
  while(*s) {
    if (*s == '\n') halPutch('\r');
    halPutch(*s);
    s++;
  }
}

void conPrintUINT8_noleader (UINT8 x) {
  BYTE c;
  c = (x>>4)& 0xf;
  if (c > 9) halPutch('A'+c-10);
   else halPutch('0'+c);
  //LSDigit
  c = x & 0xf;
  if (c > 9) halPutch('A'+c-10);
   else halPutch('0'+c);
}
void conPrintUINT8 (UINT8 x) {
  conPrintROMString("0x");
  conPrintUINT8_noleader(x);
}

void conPrintUINT16 (UINT16 x) {
 BYTE c;

 conPrintROMString("0x");
 c = (x >> 8);
 conPrintUINT8_noleader(c);
 c = (BYTE) x;
 conPrintUINT8_noleader(c);
}

void conPrintUINT32 (UINT32 x) {
 BYTE c;
 conPrintROMString("0x");
 c = (x >> 24);
 conPrintUINT8_noleader(c);
 c = (x >> 16);
 conPrintUINT8_noleader(c);
 c = (x >> 8);
 conPrintUINT8_noleader(c);
 c = x;
 conPrintUINT8_noleader(c);
}
//assumed little endian
void conPrintLADDR_bytes(BYTE *ptr) {
char i;
 conPrintROMString("0x");
 for (i=8;i!=0;i--){
   conPrintUINT8_noleader(*(ptr+i-1));

  }
}
void conPrintLADDR(LADDR *laddr){
 BYTE *ptr;

 ptr = &laddr->bytes[0];
 conPrintLADDR_bytes(ptr);
}



#ifdef LRWPAN_COORDINATOR
void LcdPrintUINT8_noleader(UINT8 x,UINT8 i,UINT8 j)
{
  BYTE c;
  c = (x>>4)& 0xf;
  if (c > 9) PrintCh(i,j,('A'+c-10),1);
   else PrintCh(i,j,('0'+c),1);
  //LSDigit
  j += 6;
  c = x & 0xf;
  if (c > 9) PrintCh(i,j,('A'+c-10),1);
   else PrintCh(i,j,('0'+c),1);
}

void LcdPrintUINT8(UINT8 x,UINT8 i,UINT8 j)
{
  Print6(i,j,"0x",1);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  LcdPrintUINT8_noleader(x,i,j);
}


void LcdPrintUINT16(UINT16 x,UINT8 i,UINT8 j)
{
  BYTE c;
  Print6(i,j,"0x",1);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = (x >> 8);
  LcdPrintUINT8_noleader(c,i,j);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = (BYTE) x;
  LcdPrintUINT8_noleader(c,i,j);
}

void LcdPrintUINT32(UINT32 x, UINT8 i, UINT8 j)
{
  BYTE c;
  Print6(i,j,"0x",1);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = (x >> 24);
  LcdPrintUINT8_noleader(c,i,j);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = (x >> 16);
  LcdPrintUINT8_noleader(c,i,j);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = (x >> 8);
  LcdPrintUINT8_noleader(c,i,j);
  j += 12;
  if( j >= 120)
  {
    j = 3;
    i++;
  }
  c = x;
  LcdPrintUINT8_noleader(c,i,j);
}


void LcdPrintLADDR_bytes(BYTE *ptr, UINT8 i, UINT8 j)
{
  char u;
  Print6(i,j,"0x",1);
  j += 12;
  for (u=8;u!=0;u--)
  {
    LcdPrintUINT8_noleader(*(ptr+u-1),i,j);
    j += 12;
    if( j >= 120)
    {
      j = 3;
      i++;
    }
  }
}
void LcdPrintLADDR(LADDR *laddr, UINT8 i, UINT8 j)
{
  BYTE *ptr;

  ptr = &laddr->bytes[0];
  LcdPrintLADDR_bytes(ptr,i,j);
}

#endif

void conPrintConfig(void){
  BYTE b[8];

  conPrintROMString("MSState LRWPAN Version ");
  conPrintROMString(LRWPAN_VERSION)
  conPCRLF();
#ifdef LRWPAN_COORDINATOR
  conPrintROMString("Coordinator, ");
  Print8(0,29,"--COORD-- ",1);
#endif
  conPrintROMString("Address: ");
  halGetProcessorIEEEAddress(b);
  conPrintLADDR_bytes(b);
#ifdef LRWPAN_COORDINATOR
  Print6(2,3,"Address: ",1);
  LcdPrintLADDR_bytes(b,2,57);
#endif
  conPCRLF();
  conPrintROMString("Default PAN: ");
  conPrintUINT32(LRWPAN_DEFAULT_PANID);
#ifdef LRWPAN_COORDINATOR
  Print6(4,3,"Default PAN: ",1);
  LcdPrintUINT16(LRWPAN_DEFAULT_PANID,4,81);
#endif
  conPrintROMString(",Default Channel: ");
  conPrintUINT8(LRWPAN_DEFAULT_START_CHANNEL);
#ifdef LRWPAN_COORDINATOR
  Print6(5,3,"Default Channel: ",1);
  LcdPrintUINT8(LRWPAN_DEFAULT_START_CHANNEL,5,102);
#endif
  conPCRLF();
  conPCRLF();
}

⌨️ 快捷键说明

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