/*******************************************************************************
* 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;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源是RH850/F1L的CAN模块驱动程序。 RH850/F1L是Renesas/瑞萨的一款汽车级的32bit芯片/MCU,其内部集成CAN控制器模块,CAN控制器模块支持多达6路CAN通信:CAN 通道0,CAN通道1,CAN通道2…CAN通道5。该驱动程序,演示了如何使用CAN通道1的发送缓冲器(Transmit buffer)进行CAN报文的发送,使用CAN通道0的接收缓冲器(Receive buffer)进行CAN报文的接收。更重要的是CAN初始化的几个步骤的参考。 适用于使用RH850/F1L芯片进行软件开发的工程师或者单片机学习的人员。
资源推荐
资源详情
资源评论
收起资源包目录
5SD_RH850F1L_CAN(T_TxBuf___R_RxBuf).7z (21个子文件)
5L_RH850F1L_CAN(T_TxBuf___R_RxBuf)
inc
r_typedefs.h 2KB
iodefine.h 1.26MB
cubesuite+_project
RH850F1L_sample.mtpj 124KB
DefaultBuild
RH850F1L_sample.map 2KB
r_taub.obj 4KB
r_clock.obj 5KB
RH850F1L_sample.clnk 632B
r_can.obj 11KB
r_main.obj 6KB
RH850F1L_sample.mot 11KB
RH850F1L_sample.abs 17KB
cstart.obj 4KB
r_interrupt.obj 4KB
vecttbl.obj 8KB
RH850F1L_sample.a5099237.mtud 291KB
src
r_main.c 5KB
r_can.c 84KB
vecttbl.asm 2KB
r_clock.c 12KB
cstart.asm 5KB
ReadMe.docx 13KB
共 21 条
- 1
S,D
- 粉丝: 3
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页