Other Parts Discussed in Thread: SYSCONFIG, C2000WARE
/*
* can.c
*
* Created on: 2023年5月6日
* Author: Administrator
*/
/*
* Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "can.h"
void Board_init()
{
EALLOW;
PinMux_init();
CAN_init();
EDIS;
}
void PinMux_init()
{
//
// CANA -> myCAN0 Pinmux
//
GPIO_setPinConfig(GPIO_12_CANA_RX);
GPIO_setPinConfig(GPIO_13_CANA_TX);
}
void CAN_init(){
//myCAN0 initialization
CAN_initModule(myCAN0_BASE);
// 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_setBitTiming(myCAN0_BASE, 7, 0, 15, 7, 3);
// Enable CAN Interrupts
CAN_enableInterrupt(myCAN0_BASE, CAN_INT_IE0);
CAN_enableGlobalInterrupt(myCAN0_BASE, CAN_GLOBAL_INT_CANINT0);
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// Message Object ID Number: 1
// Message Identifier: 100
// Message Frame: CAN_MSG_FRAME_EXT
// Message Type: CAN_MSG_OBJ_TYPE_RX
// Message ID Mask: 0
// Message Object Flags:
// Message Data Length: 0 Bytes
//
CAN_setupMessageObject(myCAN0_BASE, 1, myCAN0_MessageObj1_ID, CAN_MSG_FRAME_EXT,CAN_MSG_OBJ_TYPE_RX, 0, 0,0);
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// Message Object ID Number: 2
// Message Identifier: 200
// Message Frame: CAN_MSG_FRAME_EXT
// Message Type: CAN_MSG_OBJ_TYPE_TX
// Message ID Mask: 0
// Message Object Flags:
// Message Data Length: 0 Bytes
//
CAN_setupMessageObject(myCAN0_BASE, 2, myCAN0_MessageObj2_ID, CAN_MSG_FRAME_EXT,CAN_MSG_OBJ_TYPE_TX, 0, 0,0);
CAN_setInterruptMux(myCAN0_BASE, 0);
//
// Start CAN module operations
//
CAN_startModule(myCAN0_BASE);
}
/* * can.h * * Created on: 2023年5月6日 * Author: Administrator */ /* * Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef CAN_H #define CAN_H // // Included Files // #include "driverlib.h" #include "device.h" #define GPIO_PIN_CANA_RX 12 #define GPIO_PIN_CANA_TX 13 #define myCAN0_BASE CANA_BASE #define myCAN0_MessageObj1_ID 100 #define myCAN0_MessageObj2_ID 200 void Board_init(); void CAN_init(); void PinMux_init(); #endif // end of BOARD_H definition
//############################################################################# // // FILE: driverlib.h // // TITLE: Device setup for examples. // //############################################################################# // // // $Copyright: // Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ //############################################################################# #ifndef DRIVERLIB_H #define DRIVERLIB_H #include "inc/hw_memmap.h" #include "adc.h" #include "asysctl.h" #include "bgcrc.h" #include "can.h" #include "clb.h" #include "cmpss.h" #include "cpu.h" #include "cputimer.h" #include "dcc.h" #include "dcsm.h" #include "debug.h" #include "dma.h" #include "ecap.h" #include "epwm.h" #include "eqep.h" #include "erad.h" #include "flash.h" #include "fsi.h" #include "gpio.h" #include "hrcap.h" #include "hrpwm.h" #include "i2c.h" #include "interrupt.h" #include "lin.h" #include "memcfg.h" #include "pin_map.h" #include "pmbus.h" #include "sci.h" #include "spi.h" #include "sysctl.h" #include "version.h" #include "xbar.h" #include "driver_inclusive_terminology_mapping.h" #endif // end of DRIVERLIB_H definition

工程是28002x的例程,可以正常编译。使用sysconfig生成的CAN外设配置文件错误,编译器没有找到对应该的头文件。



