Bare Metal Programming Tool Kit
|
open_collector input-output pin interface More...
#include <pins.h>
Public Types | |
enum | { type = type_pin_oc } |
identify this type as a type_pin_oc | |
enum | { features = has_none } |
this type has no additional fatures | |
Static Public Member Functions | |
static void | init () |
initialize the pin | |
static void | set (bool x) |
set the current level on the pin | |
static bool | get () |
get the current level on the pin | |
open_collector input-output pin interface
This class defines the interface of a pin that can only sink (not source) current, and can be an input too. Such a pin is typically used on a multi-drop bus with a pull-up resistor.
This class is to be used as parent class for classes that provide the pin_in_out interface.
|
static |
get the current level on the pin
This method returns the current level on the input pin. When the level is a logic one (high voltage, Vdd) the returned value is true, otherwise (logic zero, low level, Vss) the value false is returned.The init() method must be called first.
Note that after calling set(0) the pin will in all probability read as 0, so this call only makes realy sense after a set(1) call.
|
static |
initialize the pin
This method initializes the pin as an open-collector/input pin. This might involve configuring the pin as gpio, and disabling analog or other special functions. Note that it does not involve setting the pin to a known level, but in general microcontroller pins will default to input after a reset, which corresponds to a high level for an open-collector pin with an external pull-up resistor.
|
static |
set the current level on the pin
This method sets the current level output by the pin. When the value is true a logic one (high voltage, Vdd) will appear on the pin, when the value if false a the pin will output a logic zero (low voltage, Vss).The init() method must be called first.
Setting the pin to 0 causes the pin to be pulled low. Setting a pin to 1 causes the pin to float.