Forum Discussion
Altera_Forum
Honored Contributor
20 years agoSet a bit
hi in my statement i declare static alt_u8 count ;//8 digital input static alt_u8 mem;# define bit0 count&0x01 //first bit of byte count # define fp mem&0x01 //first bit of byte me...
Altera_Forum
Honored Contributor
20 years agoi made like this
typedef struct sBit { alt_u8 B0 :1; alt_u8 B1 :1; alt_u8 B2 :1; alt_u8 B3 :1; alt_u8 B4 :1; alt_u8 B5 :1; alt_u8 B6 :1; alt_u8 B7 :1; alt_u8 B8 :1; alt_u8 B9 :1; alt_u8 B10 :1; alt_u8 B11 :1; alt_u8 B12 :1; alt_u8 B13 :1; alt_u8 B14 :1; alt_u8 B15 :1; }sBit; typedef union sDato // Una Union differisce dalla struct per il fatto che il dato e' condiviso { alt_u8 W; sBit B; }sDato; sDato count; sDato mem; ..... ..... while(1) { count.W=IORD_ALTERA_AVALON_PIO_DATA(PM_IN_BASE); if(count.B.B0) & (!mem.B.B0) { //execute code mem.B.B0=true; } if(!count.B.B0) { mem.B.B0=false; } } //now it's functionally ciao walter