TI中文支持网
TI专业的中文技术问题搜集分享网站

请教TI大神帮我看看这段代码的问题?????

/**** txTask.c ****/

#include <ti/sysbios/knl/Task.h>
#include <xdc/runtime/System.h>
#include <ti/drivers/UART.h>
#include "easylink/EasyLink.h"

#include "txTask_init.h"

static Task_Params txTaskParams;
static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
UART_Handle uartHandle;
UART_Params uartParams;
Task_Struct txTaskStruct;
EasyLink_TxPacket txPacket = {{0}, 0, 0, {0}};
char input;

void uart_init(void){

UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartHandle = UART_open(Board_UART0, &uartParams);
if(uartHandle == NULL){
while(1);
}
}

void EasyLink_Send(void){
txPacket.absTime = 0;
txPacket.dstAddr[0] = 0xaa;
txPacket.len = 1;
memcpy(txPacket.payload, &input, 1);
EasyLink_Status result = EasyLink_transmit(&txPacket);
if(result == EasyLink_Status_Success){
uart_beenWrite(txPacket.payload, txPacket.len);
}
}

void txTaskFnx(UArg arg0, UArg arg1)
{

uart_init();
while(1)
{
uart_read();
EasyLink_Send();
}
}

void txtask_init(void){
Task_Params_init(&txTaskParams);
txTaskParams.stackSize = TX_TASK_STACK_SIZE;
txTaskParams.priority = TX_TASK_PRIORITY;
txTaskParams.stack = &txTaskStack;
txTaskParams.arg0 = (UInt)1000000;

Task_construct(&txTaskStruct, txTaskFnx, &txTaskParams, NULL);
}

void uart_beenWrite(void *buff, uint8_t send_length){
UART_write(uartHandle, buff, send_length);
}

void uart_write(void){
UART_write(uartHandle, &input, 1);
}
void uart_read(void){
UART_read(uartHandle, &input, 1);
}

/*****rxTask.c******/

#include <Juszou/rxTask_init.h>
#include <ti/sysbios/knl/Task.h>
#include "txTask_init.h"
#include "easylink/EasyLink.h"
#include <xdc/runtime/System.h>

static Task_Params rxtaskParams;
static uint8_t rxtaskStack[RX_TASK_STACK_SIZE];
Task_Struct rxtaskStruct;
EasyLink_RxPacket rxPacket = {0};

void rxtaskFnx(UArg arg0, UArg arg1)
{
EasyLink_Params txEasyLink_Params;
EasyLink_Params_init(&txEasyLink_Params);
EasyLink_Status result = EasyLink_init(&txEasyLink_Params);
if(result != EasyLink_Status_Success){
System_abort("EasyLink_init failed");
}
while(1)
{
EasyLink_Receive();
}
}

void rxtask_init(void){
Task_Params_init(&rxtaskParams);
rxtaskParams.stackSize = RX_TASK_STACK_SIZE;
rxtaskParams.priority = RX_TASK_PRIORITY;
rxtaskParams.stack = &rxtaskStack;
rxtaskParams.arg0 = (UInt)1000000;

Task_construct(&rxtaskStruct, rxtaskFnx, &rxtaskParams, NULL);
}

void EasyLink_Receive(void){
// EasyLink_setCtrl(EasyLink_Ctrl_AddSize, 1);
// EasyLink_enableRxAddrFilter(desertAddress, 1, 1);
rxPacket.absTime = 0;
EasyLink_Status result = EasyLink_receive(&rxPacket);
if(result == EasyLink_Status_Success){
uart_beenWrite(rxPacket.payload, rxPacket.len);
}
}

zou Jus:

回复 Alvin Chen:

这个工程怎么导入CCS呢?

zou Jus:

回复 Alvin Chen:

能请教大神帮我分析一下上面代码的问题吗?它一直是EasyLink_Status_Config_Error

Alvin Chen:

回复 zou Jus:

这是iar开发环境,你可直接参考里面的源文件移植到你的工程中。

zou Jus:

回复 Alvin Chen:

本人刚入门,能请教大神帮我分析分析我上面代码为什么一直返回EasyLink_Status_Config_Error吗?感谢

Alvin Chen:

回复 zou Jus:

上面不是说了,你收发切换有问题,需要调用EasyLink_abort()。具体如何切换请去看我贴给你的工程

zou Jus:

回复 Alvin Chen:

谢谢大神的指导

赞(0)
未经允许不得转载:TI中文支持网 » 请教TI大神帮我看看这段代码的问题?????
分享到: 更多 (0)