Read four adjacent pins as a single port
#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_t Value;
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 );
/*configure pin 21_4 as input*/
IfxPort_setPinMode( &MODULE_P21, 4, IfxPort_Mode_inputNoPullDevice);
IfxPort_setPinPadDriver( &MODULE_P21, 4, IfxPort_PadDriver_cmosAutomotiveSpeed1 )
/*configure pin 21_5 as input*/
IfxPort_setPinMode( &MODULE_P21, 5, IfxPort_Mode_inputNoPullDevice);
IfxPort_setPinPadDriver( &MODULE_P21, 5, IfxPort_PadDriver_cmosAutomotiveSpeed1 )
while(1)
{
/*Read the pins from P21_4 to P21_5*/
Value = IfxPort_getGroupState( &MODULE_P21, 4u, 0x03u );
/*reads the two pins as a single port of two bits*/
if( Value == 0x02 )
{
/*the pin P21_4 to P21_5 as a port is equal to 0x02, do something*/
}
/*this is just a delay to avoid polling the pin to often*/
waitTime( IfxStm_getTicksFromMilliseconds( BSP_DEFAULT_TIMER, 50u ) );
}
}