例程上只有一个邮箱一个id的数据帧,如何设置成同一邮箱不同id的数据帧发送?我看到函数文件里只有带id的接收数据函数而没有带id的发送数据函数。
原程序:
//
#include "driverlib.h"
#include "device.h"
//
// Defines
//
#define TXCOUNT 100000
#define MSG_DATA_LENGTH 8
#define TX_MSG_OBJ_ID 1
//
// Globals
//
volatile unsigned long i;
volatile uint32_t txMsgCount = 0;
uint16_t txMsgData[8];
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
// on module A
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
//
// Initialize the CAN controllers
//
CAN_initModule(CANB_BASE);
//
// Set up the CAN bus bit rate to 500kHz for each module
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
CAN_setBitRate(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);
//
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// CAN Module: B
// Message Object ID Number: 0
// Message Identifier: 0x00
// Message Frame: standard
// Message Type: Transmit
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 8 Bytes
//
CAN_setupMessageObject(CANB_BASE, TX_MSG_OBJ_ID, 0x00,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);
//
// Initialize the transmit message object data buffer to be sent
//
txMsgData[0] = 0x01;
txMsgData[1] = 0x23;
txMsgData[2] = 0x45;
txMsgData[3] = 0x67;
txMsgData[4] = 0x89;
txMsgData[5] = 0xAB;
txMsgData[6] = 0xCD;
txMsgData[7] = 0xEF;
//
// Start CAN module A operations
//
CAN_startModule(CANB_BASE);
//
// Transmit messages from CAN-A
//
while(1)
//
// Comment for infinite transmissions
//
//for(i = 0; i < TXCOUNT; i++)
//
{
CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);
//
// Poll TxOk bit in CAN_ES register to check completion of transmission
//
//while(((HWREGH(CANB_BASE + CAN_O_ES) & CAN_ES_TXOK)) != CAN_ES_TXOK)
//{
//}
}
//
// Stop application
//
//asm("ESTOP0");
}
//
// End of File
//
Green Deng:
你好,可以直接参考这个帖子中的方案:e2e.ti.com/…/tms320f28377d-using-one-mailbox-for-multiple-transmit-messages