1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315 |
- /**
- * @file csl_gpioAux.h
- *
- * @brief
- * This is the GPIO Auxilary Header File which exposes the various
- * CSL Functional Layer API's to configure the GPIO Module.
- *
- * \par
- * ============================================================================
- * @n (C) Copyright 2009,2016 Texas Instruments, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
- #ifndef CSL_GPIOAUX_H
- #define CSL_GPIOAUX_H
- #include <ti/csl/csl_gpio.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- /** @addtogroup CSL_GPIO_FUNCTION
- @{ */
- /** ============================================================================
- * @n@b CSL_GPIO_getPID
- *
- * @b Description
- * @n This function reads the peripheral ID register which identifies the
- * scheme of PID encoding, function, rtl id, major id, custom id and minor id.
- *
- * @b Arguments
- @verbatim
- scheme Scheme of PID encoding
- function GPIO function
- rtl RTL ID of GPIO module
- major Major ID of GPIO module
- custom Custom ID of GPIO module
- minor Minor ID of GPIO module
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_PID_SCHEME,GPIO_PID_FUNC,GPIO_PID_RTL,GPIO_PID_MAJOR,GPIO_PID_CUSTOM,GPIO_PID_MINOR
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint16 function;
- Uint8 scheme, rtl, major, custom, minor;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Get the GPIO Peripheral Identification.
- CSL_GPIO_getPID (hGpio, &scheme, &function, &rtl, &major, &custom, &minor);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_getPID
- (
- CSL_GpioHandle hGpio,
- Uint8 *scheme,
- Uint16 *function,
- Uint8 *rtl,
- Uint8 *major,
- Uint8 *custom,
- Uint8 *minor
- );
- static inline void CSL_GPIO_getPID
- (
- CSL_GpioHandle hGpio,
- Uint8 *scheme,
- Uint16 *function,
- Uint8 *rtl,
- Uint8 *major,
- Uint8 *custom,
- Uint8 *minor
- )
- {
- Uint32 value = hGpio->PID;
- *scheme = (Uint8)CSL_FEXT (value, GPIO_PID_SCHEME);
- *function = (Uint16)CSL_FEXT (value, GPIO_PID_FUNC);
- *rtl = (Uint8)CSL_FEXT (value, GPIO_PID_RTL);
- *major = (Uint8)CSL_FEXT (value, GPIO_PID_MAJOR);
- *custom = (Uint8)CSL_FEXT (value, GPIO_PID_CUSTOM);
- *minor = (Uint8)CSL_FEXT (value, GPIO_PID_MINOR);
- }
- /** ============================================================================
- * @n@b CSL_GPIO_getPCR
- *
- * @b Description
- * @n This function reads the peripheral Control register which identifies the
- * emulation mode.
- *
- * @b Arguments
- @verbatim
- soft Used in conjunction with FREE bit to determine
- the emulation suspend mode. GPIO has FREE bit set to 1
- so SOFT bit does not affect functionality.
- free For GPIO, the FREE bit is fixed at 1, which
- means GPIO runs free in emulation suspend.
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_PCR_SOFT,GPIO_PCR_FREE
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 soft, free;
-
- ...
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- // Get the GPIO Peripheral Control register configuration.
- CSL_GPIO_getPCR (hGpio, &soft, &free);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_getPCR
- (
- CSL_GpioHandle hGpio,
- Uint8 *soft,
- Uint8 *free
- );
- static inline void CSL_GPIO_getPCR
- (
- CSL_GpioHandle hGpio,
- Uint8 *soft,
- Uint8 *free
- )
- {
- Uint32 value = hGpio->PCR;
- *soft = (Uint8)CSL_FEXT (value, GPIO_PCR_SOFT);
- *free = (Uint8)CSL_FEXT (value, GPIO_PCR_FREE);
- }
- /** ============================================================================
- * @n@b CSL_GPIO_bankInterruptEnable
- *
- * @b Description
- * @n This function enables the GPIO per bank interrupt. Each bank supports 16 GPIO signals.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- bankNum GPIO Bank Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_BINTEN_EN=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 bankNum = 0;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Enable GPIO per bank interrupt for bank zero
- CSL_GPIO_bankInterruptEnable (hGpio, bankNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_bankInterruptEnable
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- );
- static inline void CSL_GPIO_bankInterruptEnable
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- )
- {
- CSL_FINSR (hGpio->BINTEN, bankNum, bankNum, 1U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_bankInterruptDisable
- *
- * @b Description
- * @n This function disables the GPIO per bank interrupt. Each bank supports 16 GPIO signals.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- bankNum GPIO Bank Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_BINTEN_EN=0
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 bankNum = 0;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Disable GPIO per bank interrupt for bank zero
- CSL_GPIO_bankInterruptDisable (hGpio, bankNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_bankInterruptDisable
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- );
- static inline void CSL_GPIO_bankInterruptDisable
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- )
- {
- CSL_FINSR (hGpio->BINTEN, bankNum, bankNum, 0U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_isBankInterruptEnabled
- *
- * @b Description
- * @n This function returns the status of GPIO per bank interrupt. Each bank supports 16 GPIO signals.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- bankNum GPIO Bank Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n TRUE - Interrupt is enabled
- * @n FALSE - Interrupt is disabled
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_BINTEN_EN
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check if GPIO per bank interrupt is enabled or disabled
- if (CSL_GPIO_isBankInterruptEnabled (hGpio) == TRUE)
- {
- // GPIO per bank interrupt is ENABLED
- }
- else
- {
- // GPIO per bank interrupt is DISABLED
- }
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline Bool CSL_GPIO_isBankInterruptEnabled
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- );
- static inline Bool CSL_GPIO_isBankInterruptEnabled
- (
- CSL_GpioHandle hGpio,
- Uint8 bankNum
- )
- {
- Bool ret_val;
- if (CSL_FEXTR (hGpio->BINTEN, (Uint32)bankNum, (Uint32)bankNum) == 1U)
- {
- ret_val = TRUE;
- }
- else
- {
- ret_val = FALSE;
- }
- return ret_val;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_setPinDirOutput
- *
- * @b Description
- * @n This function sets the direction of GPIO pin as an output pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_DIR_DIR=0
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Set GPIO pin number 1 as an output pin
- CSL_GPIO_setPinDirOutput (hGpio, pinNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_setPinDirOutput
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_setPinDirOutput
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
-
- CSL_FINSR (hGpio->BANK_REGISTERS[bankIndex].DIR, bitPos, bitPos, 0U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_setPinDirInput
- *
- * @b Description
- * @n This function sets the direction of GPIO pin as an input pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_DIR_DIR=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Set GPIO pin number 1 as an input pin
- CSL_GPIO_setPinDirInput (hGpio, pinNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_setPinDirInput
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_setPinDirInput
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
- CSL_FINSR (hGpio->BANK_REGISTERS[bankIndex].DIR, bitPos, bitPos, 1U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_getPinDirection
- *
- * @b Description
- * @n This function gets the direction configuration of GPIO pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n 0 - Pin is configured as output pin
- * @n 1 - Pin is configured as input pin
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_DIR_DIR
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check if pin 1 is configured as input or output pin
- if (CSL_GPIO_getPinDirection (hGpio, pinNum))
- {
- // GPIO pin is configured as INPUT
- }
- else
- {
- // GPIO pin is configured as OUTPUT
- }
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline Bool CSL_GPIO_getPinDirection
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline Bool CSL_GPIO_getPinDirection
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint32 bankIndex, bitPos;
-
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- return ((Bool)(CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].DIR, bitPos, bitPos)));
- }
- /** ============================================================================
- * @n@b CSL_GPIO_getOutputData
- *
- * @b Description
- * @n This function gets the output drive state of GPIO pin when it is configured as an output pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- outData Bit data when GPIO is configured as output pin
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_OUT_DATA_OUT
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1, outData;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Get the output data on pin 1
- CSL_GPIO_getOutputData (hGpio, pinNum, &outData));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_getOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum,
- Uint8 *outData
- );
- static inline void CSL_GPIO_getOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum,
- Uint8 *outData
- )
- {
- Uint32 bankIndex, bitPos;
-
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- *outData = (Uint8)CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].OUT_DATA, bitPos, bitPos);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_setOutputData
- *
- * @b Description
- * @n This function sets the output drive state of GPIO pin when it is configured as an output pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_SET_DATA_SET=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 0;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Set output of GPIO pin number 0 to 1
- CSL_GPIO_setOutputData (hGpio, pinNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_setOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_setOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
- hGpio->BANK_REGISTERS[bankIndex].SET_DATA = (1U) << bitPos;
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_clearOutputData
- *
- * @b Description
- * @n This function clears the output drive state of GPIO pin when it is configured as an output pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_CLR_DATA_CLR=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 0;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Clear output of GPIO pin number 0
- CSL_GPIO_clearOutputData (hGpio, pinNum);
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_clearOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_clearOutputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
-
- hGpio->BANK_REGISTERS[bankIndex].CLR_DATA = (1U) << bitPos;
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_getInputData
- *
- * @b Description
- * @n This function gets the input bit data on GPIO pin when it is configured as an input pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- inData Bit data when GPIO is configured as input pin
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_IN_DATA_IN
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1, inData;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Get the output data on pin 1
- CSL_GPIO_getInputData (hGpio, pinNum, &inData));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_getInputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum,
- Uint8 *inData
- );
- static inline void CSL_GPIO_getInputData
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum,
- Uint8 *inData
- )
- {
- Uint32 bankIndex, bitPos;
-
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- *inData = (Uint8)CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].IN_DATA, bitPos, bitPos);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_setRisingEdgeDetect
- *
- * @b Description
- * @n This function sets rising edge interrupt detection for GPIO pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_SET_RIS_TRIG_SETRIS=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Set interrupt detection on GPIO pin 1 to rising edge
- CSL_GPIO_setRisingEdgeDetect (hGpio, pinNum));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_setRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_setRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
-
- CSL_FINSR (hGpio->BANK_REGISTERS[bankIndex].SET_RIS_TRIG, bitPos, bitPos, 1U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_clearRisingEdgeDetect
- *
- * @b Description
- * @n This function clears rising edge interrupt detection for GPIO pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_CLR_RIS_TRIG_CLRRIS=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Clear rising edge interrupt detection on GPIO pin 1
- CSL_GPIO_clearRisingEdgeDetect (hGpio, pinNum));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_clearRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_clearRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex;
-
- bankIndex = pinNum / 32U;
-
- hGpio->BANK_REGISTERS[bankIndex].CLR_RIS_TRIG = (1U) << pinNum;
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_isRisingEdgeDetect
- *
- * @b Description
- * @n This function checks if the interrupt detection for GPIO pin is set to rising edge or not.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n TRUE - Interrupt detection is set to rising edge
- * @n FALSE - Interrupt detection is not set to rising edge
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_SET_RIS_TRIG_SETRIS
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check interrupt detection state on GPIO pin 1
- if (CSL_GPIO_isRisingEdgeDetect (hGpio, pinNum) == TRUE)
- {
- // Interrupt detection is set to RISING EDGE
- }
- else
- {
- // Interrupt detection is not set to RISING EDGE
- }
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline Bool CSL_GPIO_isRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline Bool CSL_GPIO_isRisingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint32 bankIndex, bitPos;
- Bool ret_val;
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- if (CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].SET_RIS_TRIG, bitPos, bitPos) == 1U)
- {
- ret_val = TRUE;
- }
- else
- {
- ret_val = FALSE;
- }
- return ret_val;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_setFallingEdgeDetect
- *
- * @b Description
- * @n This function sets falling edge interrupt detection for GPIO pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_SET_FAL_TRIG_SETFAL=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Set interrupt detection on GPIO pin 1 to falling edge
- CSL_GPIO_setFallingEdgeDetect (hGpio, pinNum));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_setFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_setFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex, bitPos;
-
- bankIndex = pinNum / 32U;
- bitPos = pinNum % 32U;
-
- CSL_FINSR (hGpio->BANK_REGISTERS[bankIndex].SET_FAL_TRIG, bitPos, bitPos, 1U);
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_clearFallingEdgeDetect
- *
- * @b Description
- * @n This function clears falling edge interrupt detection for GPIO pin.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_CLR_FAL_TRIG_CLRFAL=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Clear falling edge interrupt detection on GPIO pin 1
- CSL_GPIO_clearFallingEdgeDetect (hGpio, pinNum));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_clearFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_clearFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex;
-
- bankIndex = pinNum / 32U;
-
- hGpio->BANK_REGISTERS[bankIndex].CLR_FAL_TRIG = (1U) << pinNum;
- return;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_isFallingEdgeDetect
- *
- * @b Description
- * @n This function checks if the interrupt detection for GPIO pin is set to falling edge or not.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n TRUE - Interrupt detection is set to falling edge
- * @n FALSE - Interrupt detection is not set to falling edge
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_SET_FAL_TRIG_SETFAL
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check interrupt detection state on GPIO pin 1
- if (CSL_GPIO_isFallingEdgeDetect (hGpio, pinNum) == TRUE)
- {
- // Interrupt detection is set to FALLING EDGE
- }
- else
- {
- // Interrupt detection is not set to FALLING EDGE
- }
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline Bool CSL_GPIO_isFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline Bool CSL_GPIO_isFallingEdgeDetect
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint32 bankIndex, bitPos;
- Bool ret_val;
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- if (CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].SET_FAL_TRIG, bitPos, bitPos) == 1U)
- {
- ret_val = TRUE;
- }
- else
- {
- ret_val = FALSE;
- }
- return ret_val;
- }
- /** ============================================================================
- * @n@b CSL_GPIO_getInterruptStatus
- *
- * @b Description
- * @n This function gets the GPIO pin interrupt status.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n 0 - Interrupt has not occurred since last cleared
- * @n 1 - Interrupt has occurred
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Reads
- * @n GPIO_INTSTAT_STAT
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check interrupt status on pin 1
- if (CSL_GPIO_getInterruptStatus (hGpio, pinNum) == 0)
- {
- // Interrupt has not occured
- }
- else
- {
- // Interrupt has occured
- }
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline Bool CSL_GPIO_getInterruptStatus
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline Bool CSL_GPIO_getInterruptStatus
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint32 bankIndex, bitPos;
-
- bankIndex = (Uint32)pinNum / 32U;
- bitPos = (Uint32)pinNum % 32U;
-
- return ((Bool)(CSL_FEXTR (hGpio->BANK_REGISTERS[bankIndex].INTSTAT, bitPos, bitPos)));
- }
- /** ============================================================================
- * @n@b CSL_GPIO_clearInterruptStatus
- *
- * @b Description
- * @n This function clears the GPIO pin interrupt status.
- *
- * @b Arguments
- @verbatim
- hGpio Handle of the GPIO device
- pinNum GPIO Pin Number
- @endverbatim
- *
- * <b> Return Value </b>
- * @n None
- *
- * <b> Pre Condition </b>
- * @n CSL_GPIO_open() must be called
- *
- * <b> Post Condition </b>
- * @n None
- *
- * @b Writes
- * @n GPIO_INTSTAT_STAT=1
- *
- * @b Example
- * @verbatim
- CSL_GpioHandle hGpio;
- Uint8 pinNum = 1;
- // Open the CSL GPIO Module 0
- hGpio = CSL_GPIO_open (0);
- ...
- // Check interrupt status on pin 1
- CSL_GPIO_getInterruptStatus (hGpio, pinNum));
- ...
- // Clear interrupt status on pin 1
- CSL_GPIO_clearInterruptStatus (hGpio, pinNum));
- ...
- @endverbatim
- * =============================================================================
- */
- /*for misra warning*/
- static inline void CSL_GPIO_clearInterruptStatus
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- );
- static inline void CSL_GPIO_clearInterruptStatus
- (
- CSL_GpioHandle hGpio,
- Uint8 pinNum
- )
- {
- Uint8 bankIndex;
-
- bankIndex = pinNum / 32U;
-
- hGpio->BANK_REGISTERS[bankIndex].INTSTAT = (1U) << pinNum;
- return;
- }
- /**
- @}
- */
- #ifdef __cplusplus
- }
- #endif
- #endif /* CSL_GPIOAUX_H */
|