Tollos – lpcBitIO.c | ||||||||||||
Libraries
Background
|
lpcBitIO.c – bit device functions for LPC These functions take a port (GPIO register) number and a bit mask – all those bits that have a 1 in the mask are affected.bitSetIO sets the configuration of a bit; bitIntIO controls its interrupt capabilities, and bitExistIO checks whether a pin exists in the hardware.
bitExistIO – test whether a bit or bits exist int bitExistIO(uint port, uint mask);
port – port in which the bit or bits reside mask – mask of which bit(s) to test
returns 1 if all the bits in the mask exist in the specified port, or 0 otherwise; 0 is also returned if port is invalid Note: this reports whether the bit exists in a microcontroller, not whether it is brought out to a board pin, or whether it supports interrupts. bitIntIO – effect an interrupt configuration of a bit or bits int bitIntIO(uint port, uint mask, uint action, vector handler);
port – port in which the bit or bits reside mask – mask of which bit(s) to affect action – one of BIT_RISE, _FALL, _RISEFALL, or _DISABLE handler – interrupt handler to call, or NULL if _DISABLE
returns 0 if sucessful or negative if error (e.g., the bit does not exist or does not support interrupts, or handler already in use) This first disables all interrupts for the specified bit(s). It then enables the pins as specified, unless handler is NULL. The bit validity check only tests for whether all the specified bits are valid for interrupts, not whether they are brought out to a physical pin (they could still be used for self-wrought interrupts). bitQueryIO – query the state of a bit or bits int bitQueryIO(uint port, uint mask, uint *bits);
port – port in which the bit or bits reside mask – mask of which bit(s) to query bits – receives the state of the selected bits (other bits will be 0)
returns 0 if OK, −1 if error The result will be −1 if port is not a valid port number. Bits are undefined if the selected bits do not exist. Bits may also be undefined or unpredictable if the pin corresponding to a bit is in alternative use (e.g., for ADC). bitSetIO – effect an action on a bit or bits int bitSetIO(uint port, uint mask, uint action);
port – port in which the bit or bits reside mask – mask of which bit(s) to affect action – one of BIT_ON, BIT_OFF, BIT_INVERT, or BIT_OPENDRAIN for output, or one of BIT_PULLUP, BIT_TRISTATE, or BIT_PULLDOWN for bit input
returns 0 if OK, −1 if error BIT_ON, BIT_OFF, or BIT_INVERT set the specified bit(s) to output mode then sets the bit(s) as appropriate for the request (BIT_OFF sets each bit to 0, BIT_ON sets them to 1, BIT_INVERT flips each bit). BIT_OPENDRAIN sets the bit to open drain output mode and level high. The actions BIT_PULLUP, BIT_TRISTATE, and BIT_PULLDOWN set the specified bit(s) to input mode with pull-up, neither pull-up nor pull-down, or pull-down. After reset, bits are BIT_TRISTATE. For example:
rc=bitSet(PORT1, BIT27, BIT_PULLUP); The result is −1 if port is not a valid port number. Bits are undefined if the selected bits do not exist. |
Tollos and these web pages were written by Mike Cowlishaw; Please send me any corrections, suggestions, etc. | |
All content © Mike Cowlishaw, 2010–2012, except where marked
otherwise. All rights reserved. The pages here are for non-commercial
use only (see the separate licence for Tollos source code).
Privacy policy: the Speleotrove website
records no personal information and sets no ‘cookies’.
However, statistics, etc. might be recorded by the web hosting
service.
This page was last updated on 2010-12-15 by c2wiki. |