📄 9xtend.c
字号:
//*****************************************************//
// File:9xtend.c for S3C44B0
// Author: yanhc
// Organisition: NUC1200
// Description: Define the common function for RF module 9xtend
// Creat time: 2009.03.10
// Revision:
//*****************************************************//
#include<stdio.h>
#include <string.h>
#include"44blib.h"
#include"system.h"
#include"9xtend.h"
//Initialize 9xtend,word in streaming mode, MY=1,DT=2.;
void Init_9xtend(void)
{
char str[10] = {0};
//Initialize the 9XTend
Uart_Select(0);
Uart_SendString("+++");
Uart_GetString(str); //At this time, arm can get the data, so str may not be OK;
Uart_Select(1);
Uart_SendString(str);
Uart_Select(0);
Uart_SendString("ATMY 1\n");
Uart_GetString(str);
if(strcmp(str,"OK") != 0)
Error(str);
Uart_Select(0);
Uart_SendString("ATDT 2\n");
Uart_GetString(str);
if(strcmp(str,"OK") != 0)
Error(str);
//RR=0,MY=0,streaming mode
Uart_Select(0);
Uart_SendString("ATRR 0\n");
Uart_GetString(str);
if(strcmp(str,"OK") != 0)
Error(str);
Uart_Select(0);
Uart_SendString("ATMT 0\n");
Uart_GetString(str);
if(strcmp(str,"OK") != 0)
Error(str);
Uart_Select(0);
Uart_SendString("ATCN\n");
Uart_GetString(str);
if(strcmp(str,"OK") != 0)
Error(str);
Uart_Select(1);
Uart_SendString("\n9XTend initilized successfully! MODE:stream; MY=1,DT=2.\n");
Delayms(1000); //Esential for 9xtend
}
//Change dBm in hex in string to int, for 9xTend RSSI value
int strHex2Int(char string[])
{
int dBm = 0;
if(string[0] > '9')
dBm = dBm + ((string[0] - 'A') + 10)*16;
else
dBm = dBm + (string[0] - '0')*16;
if(string[1] > '9')
dBm = dBm + ((string[1] - 'A') + 10);
else
dBm = dBm + (string[1] - '0');
return dBm;
}
//AT command error handler function
void Error(char string[])
{
while(1)
{
grnLedBlk();
Uart_Select(1);
Uart_SendString(string);
Uart_SendString("\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -