/***********************************************************************************************************************
* 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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
关于陀螺仪6050需要注意以下问题; 1、 IIC数据和时钟需要上拉电阻,电阻的大小与波特率有关,如果通讯不上适当减小波特率。 2、 6050供电电压为3.3V,请确认MCU电压和6050电压是否一致。 3、 MCU和6050最好用两个稳压芯片供电,要不MCU可能会干扰6050. 4、 需要用中断口11 5、主程序里有说明,当进到if(OK==get_mpu6050_mode()) { //此时可以读取陀螺仪数据和加速度数据,采集到的是原始数据 } 读取faccx,faccy,faccz,fgyrox,fgyroy,fgyroz; 其中faccx,faccy,faccz是加速度 fgyrox,fgyroy,fgyroz;是陀螺仪
资源推荐
资源详情
资源评论
收起资源包目录
test6050.rar (31个子文件)
test6050
r_cg_cgc.c 4KB
IIC.c 2KB
r_cg_cgc_user.c 4KB
test6050.yihuachen.mtud 312KB
r_cg_cgc.h 10KB
r_main.c 5KB
r_cg_intc_user.c 4KB
r_cg_userdefine.h 2KB
DefaultBuild
r_cg_intc_user.rel 2KB
r_cg_cgc_user.rel 2KB
IIC.rel 3KB
r_cg_serial_user.rel 4KB
test6050.map 19KB
test6050.sym 3KB
mpu6050.rel 15KB
test6050.lmf 27KB
r_cg_serial.rel 5KB
r_main.rel 2KB
test6050.hex 180KB
r_cg_intc.rel 2KB
r_cg_cgc.rel 2KB
r_systeminit.rel 2KB
r_systeminit.c 4KB
r_cg_intc.h 10KB
r_cg_serial.c 10KB
r_cg_intc.c 6KB
r_cg_serial_user.c 7KB
r_cg_macrodriver.h 5KB
r_cg_serial.h 25KB
mpu6050.c 9KB
test6050.mtpj 339KB
共 31 条
- 1
不对法
- 粉丝: 321
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页