/*===========================================================================*/ /* Project: F1x StarterKit V3 Sample Software */ /* Module : r_adc.c */ /* Version: V1.00 */ /*===========================================================================*/ /* COPYRIGHT */ /*===========================================================================*/ /* Copyright (c) 2015 by Renesas Electronics Europe GmbH, */ /* a company of the Renesas Electronics Corporation */ /*===========================================================================*/ /* In case of any question please do not hesitate to contact: */ /* */ /* ABG Software Tool Support */ /* */ /* Renesas Electronics Europe GmbH */ /* Arcadiastrasse 10 */ /* D-40472 Duesseldorf, Germany */ /* */ /* e-mail: software_support-eu@lm.renesas.com */ /* FAX: +49 - (0)211 / 65 03 - 11 31 */ /* */ /*===========================================================================*/ /* Warranty Disclaimer */ /* */ /* Because the Product(s) is licensed free of charge, there is no warranty */ /* of any kind whatsoever and expressly disclaimed and excluded by Renesas, */ /* either expressed or implied, including but not limited to those for */ /* non-infringement of intellectual property, merchantability and/or */ /* fitness for the particular purpose. */ /* Renesas shall not have any obligation to maintain, service or provide bug */ /* fixes for the supplied Product(s) and/or the Application. */ /* */ /* Each User is solely responsible for determining the appropriateness of */ /* using the Product(s) and assumes all risks associated with its exercise */ /* of rights under this Agreement, including, but not limited to the risks */ /* and costs of program errors, compliance with applicable laws, damage to */ /* or loss of data, programs or equipment, and unavailability or */ /* interruption of operations. */ /* */ /* Limitation of Liability */ /* */ /* In no event shall Renesas be liable to the User for any incidental, */ /* consequential, indirect, or punitive damage (including but not limited */ /* to lost profits) regardless of whether such liability is based on breach */ /* of contract, tort, strict liability, breach of warranties, failure of */ /* essential purpose or otherwise and even if advised of the possibility of */ /* such damages. Renesas shall not be liable for any services or products */ /* provided by third party vendors, developers or consultants identified or */ /* referred to the User by Renesas in connection with the Product(s) and/or */ /* the Application. */ /* */ /*===========================================================================*/ /* */ /* Source code for the ADC Functions. */ /* */ /*===========================================================================*/ /*===========================================================================*/ /* Includes */ /*===========================================================================*/ #include "r_device.h" #include "r_adc.h" /*===========================================================================*/ /* Variables */ /*===========================================================================*/ /* Call-back function pointer called in ADCA0 error interrupt */ void (*R_ADCA0_LimitErrorCB)(uint32_t) = R_NULL; /*===========================================================================*/ /* Interrupts */ /*===========================================================================*/ /****************************************************************************** ** Function: INTADCA0ERR ** Description: Interrupt is generated when an upper/lower limit error or ** overwrite error occurs. If the interrupt is caused by upper/lower ** limit error, call-back function R_ADCA0_LimitErrorCB is called. ** Content of upper/lower limit error information register is ** passed to the call-back function. ** Parameter: None ** Return: None ******************************************************************************/ #ifdef __IAR__ #pragma vector = NUMINTADCA0ERR __interrupt void INTADCA0ERR(void) #endif /* __IAR__ */ #ifdef __GHS__ #pragma ghs interrupt void INTADCA0ERR(void) #endif /* __GHS__ */ #ifdef __CSP__ #pragma interrupt INTADCA0ERR(enable=manual) void INTADCA0ERR(void) #endif /* __CSP__*/ { if(ADCA0ULER & 0xC000) { if(R_ADCA0_LimitErrorCB != R_NULL) { R_ADCA0_LimitErrorCB(ADCA0ULER); /* Upper/Lower Error information is given to the error call back function */ } ADCA0ECR = 0x08u; /* Set the ULEC bit of the ErrorClearRegister of ADCA0 to clear the upper/lower limit error flag */ } } /*===========================================================================*/ /* Functions */ /*===========================================================================*/ /****************************************************************************** ** Function: R_ADCA0_AssignLimitErrorCB ** Description: Assigns a call-back function to the function pointer which is ** called inside the ADCA0 error interrupt in case of limite error ** detection. ** Parameter : CB_Ptr - Pointer to call back function. ** Return: None ******************************************************************************/ void R_ADCA0_AssignLimitErrorCB(void (CB_Ptr)(uint32_t)) { R_ADCA0_LimitErrorCB = CB_Ptr; } /****************************************************************************** ** Function: R_ADCA0_ConnectPullDown ** Description: Connect internal Pull Down resistance to pin AP0_x. ** Parameter : AP0_x - Analog Port 0 Pin x ** Return: None ******************************************************************************/ void R_ADCA0_ConnectPullDown(enum APorts AP_x) { ADCA0PDCTL1 |= 1<