我想通过CAN来控制板子上的LED的闪烁。在HALCoGen中的“Driver Enable ”中我勾选了“Enable GIO Driver,Enable CAN1 driver,Enable CAN2 driver , Enable DCC driver”四个。我写的程序如下,但是LED没有反映,想问下是什么问题??
/* USER CODE BEGIN (0) */
#include "can.h"
#include"het.h"
#include "esm.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
#include "system.h"
/* USER CODE BEGIN (1) */ /* USER CODE END */
/** @fn void main(void) * @brief Application main function * @note This function is empty by default. * * This function is called after startup. * The user can use this function to implement the application. */
/* USER CODE BEGIN (2) */
#define D_SIZE 10
uint8_t tx_data[D_SIZE] = {1,0,1,0,1,0,1,0,1,0};
uint8_t rx_data[D_SIZE] = {0};
uint32_t error = 0;
uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize);
void wait(uint32_t time);
uint8_t i;
/* USER CODE END */
void main(void)
{ /* USER CODE BEGIN (3) */
/* initialize can 1 and 2 */
canInit(); /* can1 -> can2 */
/* transmit on can1 */
canTransmit(canREG1, canMESSAGE_BOX1, tx_data);
/*... wait until message receive on can2 */
while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));
canGetData(canREG2, canMESSAGE_BOX1, rx_data); /* receive on can2 */
/* check received data patterns */
error = checkPackets(&tx_data[D_SIZE],&rx_data[D_SIZE],D_SIZE);
i=D_SIZE;
gioSetDirection(hetPORT1, 0xffffffff);
for(i=0;i<10;i++)
{ gioSetBit(hetPORT1, 0,(uint32_t)rx_data[i]);
wait(5000);
}
/* ... run forever */
while(1);
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize)
{ uint32_t err=0; uint32_t cnt=psize;
while(cnt--)
{ if((*src_packet++) != (*dst_packet++))
{ err++; /* data error */
}
}
return (err);
}
/* USER CODE END */
void wait(uint32_t time)
{ time--;
}