瑞萨RL78单片机例程 I2C程序

  • i8_643351
    了解作者
  • C/C++
    开发工具
  • 110KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-02-24 15:08
    上传日期
2015年瑞萨RL78单片机例程 I2C程序
瑞萨RL78单片机例程 I2C程序
  • sample_IICA0
  • sample_IICA0
  • DefaultBuild
  • r_cg_cgc_user.rel
    1.8KB
  • r_cg_serial.rel
    4.6KB
  • sample_IICA0.sym
    1.7KB
  • r_systeminit.rel
    2.3KB
  • sample_IICA0.hex
    180.4KB
  • r_cg_cgc.rel
    1.8KB
  • r_main.rel
    3KB
  • sample_IICA0.lmf
    14KB
  • r_cg_serial_user.rel
    5.4KB
  • sample_IICA0.map
    13.4KB
  • r_main.c
    5.1KB
  • r_cg_serial.c
    9.6KB
  • r_cg_serial_user.c
    8.6KB
  • r_systeminit.c
    4.4KB
  • r_cg_cgc_user.c
    4KB
  • r_cg_macrodriver.h
    4.7KB
  • r_cg_cgc.h
    10.2KB
  • r_cg_cgc.c
    4.1KB
  • sample_IICA0.n.mtud
    312.7KB
  • sample_IICA0.mtpj
    296KB
  • r_cg_serial.h
    24.7KB
  • r_cg_userdefine.h
    2.5KB
内容介绍
/*********************************************************************************************************************** * 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-8-6 ***********************************************************************************************************************/ /*********************************************************************************************************************** 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 = _16_IICA0_IICWL_VALUE; IICWH0 = _14_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
评论
    相关推荐
    • 单片机课件
      能够帮助同学们快速的了解单片机并对于单片机的一些设计程序有一定的认知
    • 单片机课件
      单片机的课件及例题, 单片机的课件及例题, 单片机的课件及例题, 单片机的课 件及例题,
    • 爱上单片机
      一本电子爱好者都能看懂,会边看边笑的单片机入门书籍,作者杜洋曾在《无线电》上发表过“趣味单片机制作专题”、“单片机编程魔法学校”等深受读者喜爱、让无数单片机入门者热血沸腾的系列文章。本书通过生动的语言...
    • 单片机资料
      内含30个单片机应用开发的资料,包括配套单片机入门PPT。
    • 单片机课件
      单片机课的课件,对单片机的基础进行了全面的概述,也有非常精细的指导。
    • 单片机工具
      单片机工具 供单片机学习使用 免费资源 日后还会有更多资源 请联系我
    • 单片机课件
      单片机课件 ppt文件格式 介绍了单片机的结构、程序设计、定时器、中断等
    • 单片机教程
      这是一个单片机的教程,可以用于初次学习单片机的人学习。
    • 单片机入门
      很好的单片机学习资源,入门比较好适合对单片机的学习有兴趣的人,而且是名校的精彩讲解,
    • 爱上单片机
      《爱上单片机》本书是一本电子爱好者都能看懂,会边看边笑的单片机入门书籍,作者杜洋曾在《无线电》上发表过“趣味单片机制作专题”、“单片机编程魔法学校”等深受读者喜爱、让无数单片机入门者热血沸腾的系列文章...