Forum Discussion
Altera_Forum
Honored Contributor
12 years agoIn this particular case you could write it as
if ((IORD_ALTERA_AVALON_PIO_DATA(PIO_CONTROL_IN_BASE) & 0x02) != 0) {
sample_array = IORD_ALTERA_AVALON_PIO_DATA(PIO_ADC_DATA_BASE);
i++;
} In the more generaL case, avoid reading to the same HW-address multiple times and use a temporary variableuint32 temp = IORD_ALTERA_AVALON_PIO_DATA(PIO_CONTROL_IN_BASE) ;
if ((temp == 0x02) || (temp == 0x03)) {
sample_array = IORD_ALTERA_AVALON_PIO_DATA(PIO_ADC_DATA_BASE);
i++;
}