/******************************************************************************* * 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_lps_Analog.c * Version : 1.0 * Device(s) : R7F701007 RH850/F1L * Tool-Chain : IAR Embedded Workbench 1.30.1 * Description : This file is a sample of the low power sampler (LPS Analog input mode). * Operation : - ******************************************************************************* ******************************************************************************* * History : DD.MM.YYYY Version Description * : 20.03.2014 1.00 First Release ******************************************************************************/ /****************************************************************************** Includes ******************************************************************************/ #include "r_typedefs.h" #include "iodefine.h" #ifdef __ghs__ #include "device.h" #endif #ifdef __IAR_SYSTEMS_ICC__ #include #endif /****************************************************************************** Imported global variables and functions (from other files) ******************************************************************************/ /****************************************************************************** Macro definitions ******************************************************************************/ /****************************************************************************** Exported global variables and functions (to be accessed by other files) ******************************************************************************/ void R_LPS_Init( void ); void R_LPS_Start( void ); void R_LPS_Stop( void ); /****************************************************************************** Private global variables and functions ******************************************************************************/ /****************************************************************************** * Function Name : void R_LPS_Init( void ) * Description : This function initializes the LPS. * Argument : none * Return Value : none ******************************************************************************/ void R_LPS_Init( void ) { /* APO (P0_1) CN2A-30pin */ PFCAE0 &= 0xFFFDU; PFCE0 |= 0x0002U; PFC0 |= 0x0002U; PM0 &= 0xFFFDU; PMC0 |= 0x0002U; /* Set the lead number of times and the trigger signal of the port in the digital input mode. SCTLR - LPS Control Registers b31:b 7 - Reserved set to 0 b 6:b 4 NUMDP - Set the number of times the port is read in digital input mode. - Unused. Set to 000'b b 3:b 2 TJIS - Sequence Start Trigger Select - INTTAUJ0I0 b 1 ADEN - Analog input mode is stopped / enabled - stopped b 0 DPEN - Digital input mode is stopped / enabled - Unused. Set to 0'b */ SCTLR = 0x00000000UL; /* Set intervaltimer function of TAUJ0. */ /* Set stabilization time (More than 1 us) CNTVAL - Count Value Register b15:b 8 CNT - set the stabilization time of the external circuit (analog signal source). - 1 / fRH x 16 x 01H b 7:b 0 CNT - set the stabilization time of the external circuit (digital signal source). - Unused. Set to 00H */ CNTVAL = 0x0100U; } /****************************************************************************** * Function Name : void R_LPS_Start( void ) * Description : This function start the LPS. * Argument : none * Return Value : none ******************************************************************************/ void R_LPS_Start( void ) { /* Set SCTLR.DPEN bit */ SCTLR |= 0x00000002UL; /* Analog input mode enable */ } /****************************************************************************** * Function Name : void R_LPS_Stop( void ) * Description : This function stop the LPS. * Argument : none * Return Value : none ******************************************************************************/ void R_LPS_Stop( void ) { /* Clear SCTLR.DPEN bit */ SCTLR &= 0xFFFFFFFDUL; /* Analog input mode disable */ }