/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* (c) 2014 Renesas Electronics Corporation All rights reserved.
*******************************************************************************/
/******************************************************************************
* File Name : r_can.c
* Version : 1.0
* Device(s) : R7F701035xAFP RH850/F1L
* Tool-Chain : CubeSuite+(V2.01.00)
* Description : This file is a sample of RS-CAN.
* Operation : -
*******************************************************************************
*******************************************************************************
* History : DD.MM.YYYY Version Description
* : 20.03.2014 1.00 First Release
******************************************************************************/
/******************************************************************************
Includes <System Includes> , �gProject Includes�h
******************************************************************************/
#include "iodefine.h"
#include "r_typedefs.h"
/******************************************************************************
Imported global variables and functions (from other files)
******************************************************************************/
/******************************************************************************
Macro definitions
******************************************************************************/
#define R_CAN_GRAMINIT_ON (0x8UL)
#define R_CAN_GSLPSTS_ON (0x4UL)
#define R_CAN_GRSTSTS_ON (0x1UL)
#define R_CAN_CSLPSTS_ON (0x4UL)
#define R_CAN_CHLTSTS_ON (0x2UL)
#define R_CAN_CRSTSTS_ON (0x1UL)
#define R_CAN_TMTRM_ON (0x8U)
#define R_CAN_TMTR_ON (0x1U)
#define R_CAN_AFLDAE_ON (0x100UL)
#define R_CAN_GSLPR_MASK (0x4UL)
#define R_CAN_GMDC_MASK (0x3UL)
#define R_CAN_CSLPR_MASK (0x4UL)
#define R_CAN_CHMDC_MASK (0x3UL)
/******************************************************************************
Exported global variables and functions (to be accessed by other files)
******************************************************************************/
void R_CAN_Init( void );
bool R_CANc0_Send_TxBuf(uint32_t can_id, uint8_t dlc, uint32_t msg[2],uint8_t RoD);
bool R_CAN_Receive_RxBuf0(uint32_t * p_can_id, uint8_t * p_dlc, uint32_t msg[2]);
bool R_CANc1_Send_TxBuf(uint32_t can_id, uint8_t dlc, uint32_t msg[2],uint8_t RoD);
/******************************************************************************
Private global variables and functions
******************************************************************************/
/******************************************************************************
* Function Name : void CAN_port_setting( void )
* Description : This function initializes RS-CAN ports.
* Argument : none
* Return Value : none
******************************************************************************/
static void CAN_port_setting(void)
{
/*
RS-CAN port settings (Channel 0)
*/
/*
P10_0 (CAN0RX)
*/
PFCAE10 &= ~0x0001U; // 0:ALT1-4 1:ALT5
PFCE10 &= ~0x0001U; // 0:ALT1,2,5 1:ALT3,4
PFC10 |= 0x0001U; // 0:ALT1,3,5 1:ALT2,4
PM10 |= 0x0001U; // 0:OUT 1:IN
PMC10 |= 0x0001U; // 0:Port mode 1:ALT mode
//PIPCn =Value after reset: 0000H
/*
P10_1 (CAN0TX)
*/
PFCAE10 &= ~0x0002U; // 0:ALT1-4 1:ALT5
PFCE10 &= ~0x0002U; // 0:ALT1,2,5 1:ALT3,4
PFC10 |= 0x0002U; // 0:ALT1,3,5 1:ALT2,4
P10 |= 0x0002U; // 0: Outputs low leve 1: Outputs high level
PM10 &= ~0x0002U; // 0:OUT 1:IN
PMC10 |= 0x0002U; // 0:Port mode 1:ALT mode
/* P2_0 (Low output -> TJA1040T MODE=normal) */
/*PSRn
31 to 16 PSRn_[31:16] --Specifies whether the value of the corresponding lower bit PSRn_m
(PSRn_[15:0]) is written to Pn_m.
0: Pn_m is not affected by PSRn_m.
1: Pn_m is PSRn_m ---bit 16 set
15 to 0 PSRn_[15:0] --Specifies the Pn_m value if the corresponding upper bit (PSRn_[31:16])
PSRn_m is 1.
0: Pn_m = 0 ---bit 0 set
1: Pn_m = 1
//Pn 0: Outputs low level 1: Outputs high level
*/
// PSR2 = 0x00010000UL;
/*PMSRn
31 to 16 PMSRn_[31:16] ---Enable bits that specify whether the value of the corresponding lower bit
PMSRn_m (PMSRn_[15:0]) is written to PMn_m.
0: PMn_m is not affected by PMSRn_m.
1: PMn_m is PMSRn_m. ---bit 16 set
15 to 0 PMSRn_[15:0] ---Data bits that specifies the value of PMn_m if PMSRn_m of the corresponding
upper bit (PMCSRn_[31:16]) is 1.
0: PMn_m is 0. ---bit 0 set
1: PMn_m is 1.
//PMn 0:OUT 1:IN
*/
// PMSR2 = 0x00010000UL;
/*PMCSRn
31 to 16 PMCSRn_[31:16] ---Enable bits that specify whether the value of the corresponding lower bit
PMCSRn_m (PMCSRn_[15:0]) is written to PMCn_m.
0: PMCn_m is not affected by PMCSRn_m.
1: PMCn_m is PMCSRn_m. ---bit 16 set
15 to 0 PMCSRn_[15:0] ---Data bits that specify the value of PMCn_m if PMCSRn_m of the corresponding
upper bit (PMCSRn_[31:16]) is 1.
0: PMCn_m is 0. ---bit 0 set
1: PMCn_m is 1.
//PMCn 0:Port mode 1:ALT mode
*/
// PMCSR2 = 0x00010000UL;
/*
RS-CAN port settings (Channel 1)
*/
/*
P10_7 (CAN1TX)
*/
PFCAE10 &= ~0x0080U; // 0:ALT1-4 1:ALT5
PFCE10 |= 0x0080U; // 0:ALT1,2,5 1:ALT3,4
PFC10 |= 0x0080U; // 0:ALT1,3,5 1:ALT2,4
P10 |= 0x0080U; // 0: Outputs low leve 1: Outputs high level
PM10 &= ~0x0080U; // 0:OUT 1:IN
PMC10 |= 0x0080U; // 0:Port mode 1:ALT mode
/*
P10_6 (CAN1RX)
*/
PFCAE10 &= ~0x0040U; // 0:ALT1-4 1:ALT5
PFCE10 |= 0x0040U; // 0:ALT1,2,5 1:ALT3,4
PFC10 |= 0x0040U; // 0:ALT1,3,5 1:ALT2,4
PM10 |= 0x0040U; // 0:OUT 1:IN
PMC10 |= 0x0040U; // 0:Port mode 1:ALT mode
//PIPCn =Value after reset: 0000H
}
/******************************************************************************
* Function Name : void CAN_clock( void )
* Description : This function initializes RS-CAN clock.
* Argument : none
* Return Value : none
******************************************************************************/
static void CAN_clock(void)
{
//clkc PPLLCLK2 (40MHz)
//pclk CKSCLK_ICAN (80MHz)
/* CKSC_ICANS_CTL
1, 0 ICANSCSID[1:0] Source Clock Setting for C_ISO_CAN*(Note 1)
00B: Disabled
01B: MainOSC
10B: CPLLCLK
11B: CPUCLK (default) ---set
Note 1: Before shifting to standby mode, select one other than CPLLCLK.
*/
do
{
PROTCMD1 = 0x000000A5UL;
S,D
- 粉丝: 3
- 资源: 35
最新资源
- 基于mmse的不确定电力系统有限次测量的分析估计 源代码, matlab代码按照高水平文章复现,保证正确 大量可再生分布式能源的预期渗透正推动下一代电力系统走向不确定性,这可能对状态估计的可靠性和复杂
- 西南科技大学数据分析期末大作业.zip
- 西门子PLC1200立体库机器人码垛机伺服视觉AGV程序 包括2台西门子PLC1215程序和2台西门子触摸屏TP700程序 PLC和基恩士相机视觉定位Modbus TCP通讯(SCL语言) PLC和A
- 知名扫地机代码方案 某知名大厂扫地机代码 适合需要学习项目与代码规范的工程师 硬件驱动包含 陀螺仪姿态传感器bmi160、电源管理bq24733等 软件驱动包括 IIC、PWM、SPI、多路A
- siddhi-execution-json jar包用于在处理事件中对json字符串进行处理
- 直流充电桩,双枪控制板方案,需要的砸单
- 埃斯顿量产控制器 埃斯顿量产伺服控制器C代码和硬件图纸 1)TMS320F28335+FPGA全套代码;全C写的DSP代码,VHDL写的FPGA代码(Lattice MXO1200) 2)AD电
- 信捷XC PLC与西门子V20变频器通讯程序 原创可直接用于生产的程序,程序带注释,并附送触摸屏程序,有接线方式和设置,通讯地址说明等 程序采用轮询,可靠稳定 器件:信捷XC3的PLC,西门子V20
- 台达DVP ES系列PLC与3台英威腾GD变频器通讯 程序带注释,并附送昆仑通态和威纶通触摸屏程序,有接线方式,设置 器件:台达DVP ES系列的PLC,3台英威腾GD系列变频器,昆仑通态,威纶通触
- 控制系统的数学建模,被控对象的数学模型建立,simulink模型实现 提供四旋翼和带尾翼直升机,共轴式直升机的数学模型、simulink模型,推导 提供资料,文献 刚体飞行动力学模型,运动学模型
- 深度学习中的Fashion-MNIST数据集与卷积神经网络实现及其训练分析
- MPC控制器设计,模型预测控制,线性时变模型预测控制,LTV MPC,提供理论讲解与应用实现 提供MPC算法、LTV MPC 算法在直升机和四旋翼中的应用实例 提供模型预测控制资料 提供matl
- Flink Forward Asia 2024 上海站(脱敏)PPT合集.zip
- Node.js安装与环境配置指南:覆盖Windows、macOS及Linux系统全流程
- 微信小程序开发全流程详解:从准备到发布的全面指南与关键技术解析
- 斑马打印机C#控制程序源代码,适合自己进行二次开发 文档齐全,包括驱动程序和如何设置斑马打印机的说明文档 源代码可以打印条形码标签和二维码标签
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页