Signature:
void callback(uint16_t interrupt_mask, uint16_t value_mask, void *user_data)
This callback is triggered whenever a change of the voltage level is detected on pins where the interrupt was activated with industrial_digital_in_4_set_interrupt.
The values are a bitmask that specifies which interrupts occurred and the current value bitmask.
For example:
* (1, 1) or (0b0001, 0b0001) means that an interrupt on pin 0 occurred and currently pin 0 is high and pins 1-3 are low. * (9, 14) or (0b1001, 0b1110) means that interrupts on pins 0 and 3 occurred and currently pin 0 is low and pins 1-3 are high.
Definition at line 109 of file bricklet_industrial_digital_in_4.h.
#define INDUSTRIAL_DIGITAL_IN_4_DEVICE_IDENTIFIER 223 |
This constant is used to identify a IndustrialDigitalIn4 Bricklet.
The industrial_digital_in_4_get_identity function and the IPCON_CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier
parameter to specify the Brick's or Bricklet's type.
Definition at line 136 of file bricklet_industrial_digital_in_4.h.
#define INDUSTRIAL_DIGITAL_IN_4_EDGE_TYPE_BOTH 2 |
Definition at line 125 of file bricklet_industrial_digital_in_4.h.
Definition at line 120 of file bricklet_industrial_digital_in_4.h.
#define INDUSTRIAL_DIGITAL_IN_4_EDGE_TYPE_RISING 0 |
Definition at line 115 of file bricklet_industrial_digital_in_4.h.
Definition at line 49 of file bricklet_industrial_digital_in_4.h.
Definition at line 59 of file bricklet_industrial_digital_in_4.h.
Definition at line 74 of file bricklet_industrial_digital_in_4.h.
Definition at line 84 of file bricklet_industrial_digital_in_4.h.
Definition at line 44 of file bricklet_industrial_digital_in_4.h.
#define INDUSTRIAL_DIGITAL_IN_4_FUNCTION_GET_IDENTITY 255 |
Definition at line 89 of file bricklet_industrial_digital_in_4.h.
Definition at line 69 of file bricklet_industrial_digital_in_4.h.
Definition at line 34 of file bricklet_industrial_digital_in_4.h.
Definition at line 54 of file bricklet_industrial_digital_in_4.h.
Definition at line 79 of file bricklet_industrial_digital_in_4.h.
Definition at line 39 of file bricklet_industrial_digital_in_4.h.
Definition at line 64 of file bricklet_industrial_digital_in_4.h.
typedef Device IndustrialDigitalIn4 |
Device for controlling up to 4 optically coupled digital inputs
Definition at line 29 of file bricklet_industrial_digital_in_4.h.
void industrial_digital_in_4_create | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
const char * | uid, | ||
IPConnection * | ipcon | ||
) |
Creates the device object industrial_digital_in_4
with the unique device ID uid
and adds it to the IPConnection ipcon
.
Definition at line 172 of file bricklet_industrial_digital_in_4.c.
void industrial_digital_in_4_destroy | ( | IndustrialDigitalIn4 * | industrial_digital_in_4 | ) |
Removes the device object industrial_digital_in_4
from its IPConnection and destroys it. The device object cannot be used anymore afterwards.
Definition at line 196 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_api_version | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | ret_api_version[3] | ||
) |
Returns the API version (major, minor, release) of the bindings for this device.
Definition at line 216 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_available_for_group | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t * | ret_available | ||
) |
Returns a bitmask of ports that are available for grouping. For example the value 5 or 0b0101 means: Port A and port C are connected to Bricklets that can be grouped together.
Definition at line 289 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_debounce_period | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint32_t * | ret_debounce | ||
) |
Returns the debounce period as set by industrial_digital_in_4_set_debounce_period.
Definition at line 333 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_edge_count | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | pin, | ||
bool | reset_counter, | ||
uint32_t * | ret_count | ||
) |
Returns the current value of the edge counter for the selected pin. You can configure the edges that are counted with industrial_digital_in_4_set_edge_count_config.
If you set the reset counter to *true*, the count is set back to 0 directly after it is read.
.. versionadded:: 2.0.1~(Plugin)
Definition at line 402 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_edge_count_config | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | pin, | ||
uint8_t * | ret_edge_type, | ||
uint8_t * | ret_debounce | ||
) |
Returns the edge type and debounce time for the selected pin as set by industrial_digital_in_4_set_edge_count_config.
.. versionadded:: 2.0.1~(Plugin)
Definition at line 450 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_group | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
char | ret_group[4] | ||
) |
Returns the group as set by industrial_digital_in_4_set_group
Definition at line 264 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_identity | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
char | ret_uid[8], | ||
char | ret_connected_uid[8], | ||
char * | ret_position, | ||
uint8_t | ret_hardware_version[3], | ||
uint8_t | ret_firmware_version[3], | ||
uint16_t * | ret_device_identifier | ||
) |
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c' or 'd'.
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
Definition at line 477 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_interrupt | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint16_t * | ret_interrupt_mask | ||
) |
Returns the interrupt bitmask as set by industrial_digital_in_4_set_interrupt.
Definition at line 377 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_response_expected | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | function_id, | ||
bool * | ret_response_expected | ||
) |
Returns the response expected flag for the function specified by the function_id
parameter. It is *true* if the function is expected to send a response, *false* otherwise.
For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled via the industrial_digital_in_4_set_response_expected function. For setter functions it is disabled by default and can be enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.
Definition at line 200 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_get_value | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint16_t * | ret_value_mask | ||
) |
Returns the input value with a bitmask. The bitmask is 16bit long, *true* refers to high and *false* refers to low.
For example: The value 3 or 0b0011 means that pins 0-1 are high and the other pins are low.
If no groups are used (see industrial_digital_in_4_set_group), the pins correspond to the markings on the Digital In 4 Bricklet.
If groups are used, the pins correspond to the element in the group. Element 1 in the group will get pins 0-3, element 2 pins 4-7, element 3 pins 8-11 and element 4 pins 12-15.
Definition at line 220 of file bricklet_industrial_digital_in_4.c.
void industrial_digital_in_4_register_callback | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | id, | ||
void * | callback, | ||
void * | user_data | ||
) |
Registers a callback with ID id
to the function callback
. The user_data
will be given as a parameter of the callback.
Definition at line 212 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_debounce_period | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint32_t | debounce | ||
) |
Sets the debounce period of the INDUSTRIAL_DIGITAL_IN_4_CALLBACK_INTERRUPT callback in ms.
For example: If you set this value to 100, you will get the interrupt maximal every 100ms. This is necessary if something that bounces is connected to the Digital In 4 Bricklet, such as a button.
The default value is 100.
Definition at line 314 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_edge_count_config | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint16_t | selection_mask, | ||
uint8_t | edge_type, | ||
uint8_t | debounce | ||
) |
Configures the edge counter for the selected pins. A bitmask of 9 or 0b1001 will enable the edge counter for pins 0 and 3.
The edge type parameter configures if rising edges, falling edges or both are counted if the pin is configured for input. Possible edge types are:
* 0 = rising (default) * 1 = falling * 2 = both
The debounce time is given in ms.
Configuring an edge counter resets its value to 0.
If you don't know what any of this means, just leave it at default. The default configuration is very likely OK for you.
Default values: 0 (edge type) and 100ms (debounce time)
.. versionadded:: 2.0.1~(Plugin)
Definition at line 429 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_group | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
char | group[4] | ||
) |
Sets a group of Digital In 4 Bricklets that should work together. You can find Bricklets that can be grouped together with industrial_digital_in_4_get_available_for_group.
The group consists of 4 elements. Element 1 in the group will get pins 0-3, element 2 pins 4-7, element 3 pins 8-11 and element 4 pins 12-15.
Each element can either be one of the ports ('a' to 'd') or 'n' if it should not be used.
For example: If you have two Digital In 4 Bricklets connected to port A and port B respectively, you could call with ``['a', 'b', 'n', 'n']``.
Now the pins on the Digital In 4 on port A are assigned to 0-3 and the pins on the Digital In 4 on port B are assigned to 4-7. It is now possible to call industrial_digital_in_4_get_value and read out two Bricklets at the same time.
Changing the group configuration resets all edge counter configurations and values.
Definition at line 245 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_interrupt | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint16_t | interrupt_mask | ||
) |
Sets the pins on which an interrupt is activated with a bitmask. Interrupts are triggered on changes of the voltage level of the pin, i.e. changes from high to low and low to high.
For example: An interrupt bitmask of 9 or 0b1001 will enable the interrupt for pins 0 and 3.
The interrupts use the grouping as set by industrial_digital_in_4_set_group.
The interrupt is delivered with the callback INDUSTRIAL_DIGITAL_IN_4_CALLBACK_INTERRUPT.
Definition at line 358 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_response_expected | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
uint8_t | function_id, | ||
bool | response_expected | ||
) |
Changes the response expected flag of the function specified by the function_id
parameter. This flag can only be changed for setter (default value: *false*) and callback configuration functions (default value: *true*). For getter functions it is always enabled and callbacks it is always disabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.
Definition at line 204 of file bricklet_industrial_digital_in_4.c.
int industrial_digital_in_4_set_response_expected_all | ( | IndustrialDigitalIn4 * | industrial_digital_in_4, |
bool | response_expected | ||
) |
Changes the response expected flag for all setter and callback configuration functions of this device at once.
Definition at line 208 of file bricklet_industrial_digital_in_4.c.