I am using the SPI to access a couple of 20 & 24 bit A/D converters which have some digital status bits preceding the reading. I already have some C code written (for another CPU) that defines the incoming data structure as a unsigned long. The Keil compiler, however, says I must use char or integer size bit fields. Is there an easy way around this without having to hand code the byte manipulation code manually?
Here is a simplified example.
typedef struct { unsigned long det_in :4, /*compliance & short detection bits */ Brd_rev :4, /* board / pal revision */ nu :4, /* not used as of 8/2000 */ AD_data :20; /* 0=-max, 0x80000=0v, fffff=+max */ } Bridge_brd_Rx_Type; /* for each bridge card */
{ long reading; char revision; reading = Brdg1.AD_data; revision = Brdg1.Brd_rev; ... }