All pastes #214740 Raw Edit

Anonymous

public text v1 · immutable
#214740 ·published 2006-10-22 05:59 UTC
rendered paste body
typedef struct FSM_State_s { 
  unsigned TPD7 : 1;
  unsigned TPD6 : 1;
  unsigned TPD5 : 1;
  unsigned TPD4 : 1;
  unsigned TPC2 : 1;
  unsigned TPC3 : 1;
  unsigned TPC4 : 1;
  unsigned TPC5 : 1;
} FSM_State_t;



typedef struct stateEntry_s {  
    PTRType       next;
    union {            
        FSM_State_t   state;           
        unsigned stateBits;
    };
 } stateEntry_t;                   


Then bits set in stateBits represent bits in FSM_State_t struct.

The other way is to just forego the complications here, and define each of you states with a flag value, like so:

#define TPD7 0x01
#define TPD6 0x02
#define TPD5 0x04
#define TPD4 0x08
#define TPC2 0x10
#define TPC3 0x12
#define TPC4 0x14
#define TPC5 0x18

Then just have unsigned stateBits in your stateEntry struct.  You can & the flag defined here against the stateBits value to check presents, | to put it in there, etc.


Either way comparison just becomes stateBits == blah if you want to compare the full byte of flags.