/***********************************************************************************************************************
* 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
*
* Copyright (C) 2011, 2013 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : r_cg_serial.c
* Version : CodeGenerator for RL78/G13 V2.00.00.07 [22 Feb 2013]
* Device(s) : R5F100LE
* Tool-Chain : CA78K0R
* Description : This file implements device driver for Serial module.
* Creation Date: 2013-9-5
***********************************************************************************************************************/
/***********************************************************************************************************************
Pragma directive
***********************************************************************************************************************/
/* Start user code for pragma. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
/***********************************************************************************************************************
Includes
***********************************************************************************************************************/
#include "r_cg_macrodriver.h"
#include "r_cg_serial.h"
/* Start user code for include. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
#include "r_cg_userdefine.h"
/***********************************************************************************************************************
Global variables and functions
***********************************************************************************************************************/
volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */
volatile uint8_t g_iica0_slave_status_flag; /* iica0 slave flag */
volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */
volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */
volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */
volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */
volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */
/* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
/***********************************************************************************************************************
* Function Name: R_IICA0_Create
* Description : This function initializes the IICA0 module.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_Create(void)
{
IICA0EN = 1U; /* supply IICA0 clock */
IICE0 = 0U; /* disable IICA0 operation */
IICAMK0 = 1U; /* disable INTIICA0 interrupt */
IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */
/* Set INTIICA0 low priority */
IICAPR10 = 1U;
IICAPR00 = 1U;
/* Set SCLA0, SDAA0 pin */
P6 &= 0xFCU;
PM6 |= 0x03U;
SMC0 = 1U;
IICWL0 = _2A_IICA0_IICWL_VALUE;
IICWH0 = _27_IICA0_IICWH_VALUE;
DFC0 = 0U; /* digital filter off */
IICCTL01 |= _01_IICA_fCLK_HALF;
SVA0 = _10_IICA0_MASTERADDRESS;
STCEN0 = 1U;
IICRSV0 = 1U;
SPIE0 = 0U;
WTIM0 = 1U;
ACKE0 = 1U;
IICAMK0 = 0U;
IICE0 = 1U;
LREL0 = 1U;
/* Set SCLA0, SDAA0 pin */
PM6 &= 0xFCU;
}
/***********************************************************************************************************************
* Function Name: R_IICA0_Stop
* Description : This function stops IICA0 module operation.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_Stop(void)
{
IICE0 = 0U; /* disable IICA0 operation */
}
/***********************************************************************************************************************
* Function Name: R_IICA0_StopCondition
* Description : This function sets IICA0 stop condition flag.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_StopCondition(void)
{
SPT0 = 1U; /* set stop condition flag */
}
/***********************************************************************************************************************
* Function Name: R_IICA0_Master_Send
* Description : This function starts to send data as master mode.
* Arguments : adr -
* transfer address
* tx_buf -
* transfer buffer pointer
* tx_num -
* buffer size
* wait -
* wait for start condition
* Return Value : status -
* MD_OK or MD_ERROR1 or MD_ERROR2 or MD_ERROR3
***********************************************************************************************************************/
MD_STATUS R_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait)
{
MD_STATUS status = MD_OK;
IICAMK0 = 1U; /* disable INTIICA0 interrupt */
if (1U == IICBSY0)
{
/* Check bus busy */
IICAMK0 = 0U; /* enable INTIICA0 interrupt */
status = MD_ERROR1;
}
else if ((1U == SPT0) || (1U == STT0))
{
/* Check trigger */
IICAMK0 = 0U; /* enable INTIICA0 interrupt */
status = MD_ERROR2;
}
else
{
STT0 = 1U; /* send IICA0 start condition */
IICAMK0 = 0U; /* enable INTIICA0 interrupt */
/* Wait */
while (wait--)
{
;
}
if (0U == STD0)
{
status = MD_ERROR3;
}
/* Set parameter */
g_iica0_tx_cnt = tx_num;
gp_iica0_tx_address = tx_buf;
g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR;
adr &= (uint8_t)~0x01U; /* set send mode */
IICA0 = adr; /* send address */
}
return (status);
}
/***********************************************************************************************************************
* Function
瑞萨单片机和MPU6050通信测试通过,模拟IIC非硬件IIC
5星 · 超过95%的资源 需积分: 50 98 浏览量
2015-07-18
17:10:22
上传
评论
收藏 109KB RAR 举报
不对法
- 粉丝: 321
- 资源: 28
最新资源
- 基于python+flask+mysql实现的豆瓣电影可视化系统源代码+数据库(高分项目).zip
- 基于pytorch卷积神经网络算法识别猫狗图片项目源码+模型+数据集+使用说明.zip
- 基于C++ QT实现的学生信息管理系统源码+项目说明.zip
- IMG20240425152027.jpg
- 点这里下载真实好友等1个文件.rar.zip
- 基于tensorflow同态加密的联邦学习安全聚合系统源码+运行说明.zip
- 七彩祥云丶看的的好运连连
- 土石方工程采用“南方cass”软件计算工程量的.doc
- mmexport1922918815783c336136a3e10a1bae88_1715378948463.png
- 基于51单片机的室内甲醛测试系统.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页