尊敬的 TI:
我的 lwIP 有问题。 我正在使用 noSys 环境和 RawAPI、并在微控制器上创建了一个侦听 PCB。 我尝试点亮状态 LED -它工作正常。 之后、我尝试使用 NTC 定期(每秒)测量温度-它也可以正常工作、但在这种情况下、我无法再通过以太网(TCP/IP)连接到 MCU、但我成功地在没有以太网连接的情况下进行调试、并且可以正常工作。 这就是我认为 RTI 模块导致问题的原因。
之后、我进行了一些研究并尝试创建活动连接、控制器在该连接中定期、每秒或每十秒向计算机发送温度数据。 现在、在这之后、我甚至无法对其进行调试。 我尝试使用 NCat 连接到它、它在第一种情况下工作、但在第二种和第三种情况下(RTI 激活第二种情况、并且使用活动连接、也是第三种情况)、它只是发回一个点(.)。
问题可能出在哪呢? 我想、它与 RTI 有关、在我激活它之前、一切都很好。 我附上代码。 我的项目基于最小 lwIP 实施项目
提前感谢您的帮助。
此致、
Zsolt
hL_sys_main.c:
/*用户代码开始(0)*/
/*用户代码结束*/
/*包含文件*/
#include "hL_sys_common.h"
/*用户代码开始(1)*/
#include "hL_system.h"
#include "HL_Gio.h"
#include "HL_EMAC.h"
#include "HL_ESM.h"
#include "lwiplib.h"
#include "hL_het.h"
#include "hL_reg_het.h"
#include "HL_ADC.h"
#include "HL_RTI.h"
#include "hL_sci.h"
extern void EMAC_LwIP_Main (uint8_t * emacAddress);
/*用户代码结束*/
/**@fn void main (void)
* @应用程序主函数简介
* @请注意、默认情况下、此函数为空。
*
* 此函数在启动后调用。
* 用户可以使用此函数来实现应用程序。
*
/*用户代码开始(2)*/
/*用户代码结束*/
uint8 emacAddress[6U]= {0x11U、0x22U、0x33U、0x44U、0x55U、 0x66U};
uint32 emacPhyAddress = 1U;
int main (空)
{
/*用户代码开始(3)*/
esmInit();
gioInit();
hetInit();
gioSetDirection (hetPORT1、0xFFFFFFFF);
EMACHWInit (emacAddress);
EMAC_LwIP_Main (emacAddress);
while (1);
/*用户代码结束*/
返回0;
}
/*用户代码开始(4)*/
/*用户代码结束*/
lwip_functions.c:
/*
* lwip_functions.c
*
/*
**内核0接收中断的中断处理程序
*
/*
**用于 HDK 的 lwIP 编译时间选项。
*
#include "lwiplib.h"
#include "hL_sci.h"
#include "lwip\inet.h"
#include "locator.h"
#include "lwip\tcp.h"
#include "lwip/tcp_impl.h"
#include "lwip\timers.h"
#include "HL_ADC.h"
#include "HL_RTI.h"
#include "modules.h"
#define sciREGx sciREG1
uint8_t txtCRLF[] ={'\r\n'};
uint8_t txtErrorInit[] ={"--- 初始化硬件时出错--- "};
uint8_t txtIPAddrTxt[] ={"器件 IP 地址:"};
uint8_t * txtIPAddrItoA;
uint8_t seconds = 0、tenseconds = 0;
双温度= 0;
char buffer[30];
struct tcp_pcb *apcb;
ERR_t recv_callback (void * arg、struct tcp_pcb * pcb、struct pbuf * p、err_t err){
int i = 0、j = 0、number = 0、乘法器= 1、processedata[4];
char *data、*step、*begin;
if (err =ERR_OK && p!= NULL){
tcp_recved (pcb、p->t_t_len);
数据=(char *)(p->payload);
readata (data、proprocessedata);
statusLED1(程序数据);
statusLED2(监考数据);
statusLED3(proc 数据);
statusLED4(监考数据);
pbuf_free (p);
}
否则{
pbuf_free (p);
}
返回 ERR_OK;
}
/*接受注册端口上的来电*/
ERR_t ACCEP_CALLBACK (void *arg、struct tcp_pcb、err_t err){
LWIP_unused_arg (arg);
/*订阅接收回调函数*/
tcp_recv (npcb、&recv_callback);
/*不要惊慌! 一切都好。 *
返回 ERR_OK;
}
ERR_t connected 回调(void *arg、struct tcp_pcb、err_t err){
LWIP_unused_arg (arg);
if (tcp_write (apcb、"连接成功"、strlen ("连接成功")、1)= ERR_OK){
tcp_output (apcb);
返回 ERR_OK;
}
}
volatile int countEMACCore0RxIsr = 0;
#pragma INTERRUPT (EMACCore0RxIsr、IRQ)
空 EMACCore0RxIsr (空)
{
countEMACCore0RxIsr++;
lwIPRxIntHandler (0);
}
/*
**内核0发送中断的中断处理程序
*
volatile int countEMACCore0TxIsr = 0;
#pragma INTERRUPT (EMACCore0TxIsr、IRQ)
空 EMACCore0TxIsr (空)
{
countEMACCore0TxIsr++;
lwIPTxIntHandler (0);
}
空 IntMasterIRQEnable (空)
{
_enable_IRQ ();
返回;
}
空 IntMasterIRQDisable (空)
{
disable_IRQ ();
返回;
}
unsigned int IntMasterStatusGet (空)
{
返回(0xC0 &_get_CPSR ());
}
void sciDisplayText (sciBASE-t * sci、uint8_t *文本、uint32_t 长度)
{
while (length---)(while (l
{
while ((sci->FLR & 0x4)== 4);//等待忙*/
sciSendByte (sci、* text++); /*发送文本 */
};
}
void EMAC_LwIP_Main (uint8_t * macAddress)
{
unsigned int ipaddr;
struct in_addr devIPAddress;
ip_addr_t connIPAddress;
struct tcp_pcb *pcb;
ERR_t 错误;
sciInit();
/*启用 CPSR 寄存器中的中断生成*/
IntMasterIRQEnable();
_enable_FIQ ();
/*使用 DHCP 初始化 lwIP 库。*/
ipaddr = lwIPInit (0、macAddress、0xC0A80199、0xFFFFFF00、0、 ipaddr_use_static);
如果(0 = ipaddr){
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
sciDisplayText (sciREGx、txtErrorInit、sizeof (txtErrorInit));
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
}否则{
/*将 IP 地址转换为字符串*/
devIPAddress.s_addr = ipaddr;
TxtIPAddrItoA =(uint8_t *) inet_ntoA (devIPAddress);
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
sciDisplayText (sciREGx、txtIPAddrTxt、sizeof (txtIPAddrTxt));
sciDisplayText (sciREGx、txtIPAddrItoA、16);
sciDisplayText (sciREGx、txtCRLF、sizeof (txtCRLF));
connIPAddress.addr = ipaddr;
PCB = tcp_new();
if (tcp_bind (PCB、IP_ADDR_ANY、21)=ERR_OK){
PCB = tcp_listen (PCB);
tcp_accept (PCB、&Accept_callback);
}
apcb = tcp_new();
if (tcp_bind (apcb、ip_ADDR_ANY、904)=ERR_OK){
tcp_connect (apcb、0xC0A80102、904、已连接回调);
}
rtiInit();
adcInit();
_enable_IRQ_interrupt_();
adcCalibration (adcREG1);
adcMidPointCalibration (adcREG1);
rtiEnableNotification (rtiREG1、rtiNOTIFICATION_COMPARE0);
rtiStartCounter (rtiREG1、rtiCOUNTER_BLOCK0);
/*永久循环。 所有工作都在中断处理程序中完成。 *
while (1)
{
sys_check_timeouts();
}
}
}
void rtiNotification (rtibase_t * rtiREG、uint32通知)
{
温度= NTCs();
秒++;
如果(秒==10){
if (tcp_write (apcb、&temperature、sizeof (temperature)、1)=ERR_OK) tcp_output (apcb);
秒= 0;
}
}