Closed kworsfold closed 10 years ago
You can do both. Are you using C, Python or something else?
Using C
Have a look at Pi/src/gzlib/src/gz_spi.c, specifically the gz_spi_set(int) and gz_spi_reset(int) functions.
You can either use those functions to set and reset individual bits or you can examine the code to write your own code which will write the 3 output lines together. The |= and &= ~ operators are the ones doing the work of setting and resetting respectively. The (1 << (bit_number)) code shifts a '1' into the right bit position for the | (bitwise or) and & (bitwise and) operators to do their thing.
Hope that helps. Let me know if you have follow up questions.
Will look into this... thanks
I am working on a project to read a 4x3 array 12 key matrix keyboard, which uses 3 of the output ports. The question I have is it possible to either read the output port status to then mask off and reset the 3 output lines I need, thus leaving the remaining intact for other outputs, or is there a way I can set individual lines, one output at a time.