Read a single pin on port P21_5
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "IfxPort_Io.h"
#include "Bsp.h"
IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;
void core0_main(void)
{
uint32 PinState;
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required */
IfxScuWdt_disableCpuWatchdog( IfxScuWdt_getCpuWatchdogPassword() );
IfxScuWdt_disableSafetyWatchdog( IfxScuWdt_getSafetyWatchdogPassword() );
/* Wait for CPU sync event */
IfxCpu_emitEvent( &g_cpuSyncEvent );
IfxCpu_waitEvent( &g_cpuSyncEvent, 1 );
/*Set pin P21_5 as digital input*/
IfxPort_setPinMode( &MODULE_P21, 5, IfxPort_Mode_inputNoPullDevice);
IfxPort_setPinPadDriver( &MODULE_P21, 5, IfxPort_PadDriver_cmosAutomotiveSpeed1 )
while(1)
{
/*Read the pin P21_5*/
PinState = IfxPort_getPinState( &MODULE_P21, 5u );
if( PinState == 0u )
{
/*the pin is set to low, do something*/
}
/*this is just a delay to avoid polling the pin to often*/
waitTime( IfxStm_getTicksFromMilliseconds( BSP_DEFAULT_TIMER, 50u ) );
}
}