A "bit" pin which is TRUE can have any nonzero value, not just 1.  So
the line
    bit_shifted = (bit_in << which_bit);
is incorrect.  Instead, you may wish to write something like
    if(bit_in)
        accum = accum | (1 << which_bit);
to avoid the confusion.  (I prefer "|" (bitwise OR) to "+" (addition) in
this case, to emphasize the nature of the operation.  But either should
work the same way)

For example, here's the way that the parport bits are read into HAL
pins:
        *(port->status_in[b]) = indata & mask;
so if the pin corresponds to the '8' bit in indata, then that HAL pin
will have the value 8 if it is TRUE and 0 if it is false.

Jeff

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to