Producer and Consumer class for Node Card's IO, both input and output GPIO pins.
More...
#include <NodeCardIoConfiguredPC.h>
|
| | NodeCardIoConfiguredPC (openlcb::Node *pNode, const CardConfig_type &configOffset, uint8_t numDevicesPerCard, EventDeviceTypes eventDeviceType) |
| |
| openlcb::Polling * | polling () |
| |
|
void | poll_33hz (openlcb::WriteHelper *helper, Notifiable *done) override |
| | Call from the refresh loop.
|
| |
| void | notify () override |
| | Polls the state of input pins on Input/Output Cards and triggers events on state changes. More...
|
| |
| UpdateAction | apply_configuration (int fd, bool initial_load, BarrierNotifiable *done) OVERRIDE |
| | Invoked on initial load of CDI and when CDI is udpated. Register configured events with OpenMRN. More...
|
| |
| void | factory_reset (int fd) OVERRIDE |
| | Reset CDI configuration entries to their initial (default) values. More...
|
| |
| void | handle_event_report (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
| | Process consumed event for the a pin configured for output on the Node Card I/O line configured pins. Use args passed with the event to determine which pin to set on or off. More...
|
| |
| bool | ensureUniqueI2cOffset (uint8_t cardIndex, uint8_t bus, uint8_t offset) |
| |
|
|
void | handle_identify_consumer (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
| | Process request to identify produced events.
|
| |
|
void | handle_identify_producer (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
| | Process request to identify produced events.
|
| |
| virtual void | SendEventIdentified (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) |
| | Sends Producer- or Consumer-Identified for registry_entry. More...
|
| |
| void | applyI2cInfo (int fd, uint8_t cardIndex, i2cInfoConfig_type cfgI2cInfoRef) |
| | sets up the MCP card's I2C connection using the user provided (CDI) configuration information (bus and address offset) More...
|
| |
| void | resetCardInfo (int fd, cardInfoConfig_type cfgI2cInfoRef) |
| | resets the card configuration information (description field). More...
|
| |
| void | resetI2cInfo (int fd, i2cInfoConfig_type cfgI2cInfoRef) |
| | resets the card's I2C configuration information (bus and address fields). More...
|
| |
| virtual void | drive_pin (uint8_t card, uint8_t pin, bool set) |
| |
| virtual void | drive_pin_ext (uint8_t card, uint8_t pin, bool set, uint8_t intArg) |
| |
|
EventUserArgsUnion | unpack_user_args (const openlcb::EventRegistryEntry &re) const |
| | Small helper to unpack our 4-byte user_arg payload from the registry entry.
|
| |
|
|
void | _do_unregister () |
| | Removes registration of this event handler from the global event registry.
|
| |
| void | _initI2cCards (bool isProducer) |
| | Initializes the array of I2C card objects using the configured card type. More...
|
| |
|
|
uint8_t | nextCardToPoll_ |
| | Shadow copy of the event IDs produced by each of the UOD cards.
|
| |
Producer and Consumer class for Node Card's IO, both input and output GPIO pins.
Definition at line 89 of file NodeCardIoConfiguredPC.h.
◆ CardConfig_type
◆ LineConfig_type
◆ NodeCardIoConfiguredPC()
| NodeCardIoConfiguredPC::NodeCardIoConfiguredPC |
( |
openlcb::Node * |
pNode, |
|
|
const CardConfig_type & |
configOffset, |
|
|
uint8_t |
numDevicesPerCard, |
|
|
EventDeviceTypes |
eventDeviceType |
|
) |
| |
|
inline |
- Parameters
-
| pNode | is the OpenLCB node object from the stack. |
| configOffset | is the repeated group object from the configuration space that represents the locations of the events. |
| numDevicesPerCard | is the number of devices per card. |
| eventDeviceType | is the logical type of event device (used for logging, diagnostics, and naming). |
Definition at line 113 of file NodeCardIoConfiguredPC.h.
◆ _initI2cCards()
| void I2cCardHelper::_initI2cCards |
( |
bool |
isProducer | ) |
|
|
inlineprivateinherited |
Initializes the array of I2C card objects using the configured card type.
Allocates and initializes each I2C card in the array to the type specified by the cardType_ member. If isProducer is true, registers each card's polling callback.
- Parameters
-
| isProducer | True if the card is used as a producer and requires polling. |
Definition at line 460 of file I2cCardHelper.h.
◆ apply_configuration()
| UpdateAction NodeCardIoConfiguredPC::apply_configuration |
( |
int |
fd, |
|
|
bool |
initial_load, |
|
|
BarrierNotifiable * |
done |
|
) |
| |
|
inline |
Invoked on initial load of CDI and when CDI is udpated. Register configured events with OpenMRN.
- Parameters
-
| fd | file descriptor used to access CDI data |
| initial_load | is true when CDI is loaded after a reboot |
| done | |
Definition at line 234 of file NodeCardIoConfiguredPC.h.
◆ applyI2cInfo()
| void I2cCardHelper::applyI2cInfo |
( |
int |
fd, |
|
|
uint8_t |
cardIndex, |
|
|
i2cInfoConfig_type |
cfgI2cInfoRef |
|
) |
| |
|
inlineprotectedinherited |
sets up the MCP card's I2C connection using the user provided (CDI) configuration information (bus and address offset)
- Note
- producer/consumers apply_configuration() callback invoke this method to initialize the I2C / MCP connection information for the card
-
all I2C connected cards have CDI section for user provided bus and address information (which must match the settings of the I2C enabeled card)
-
HOOK: Typical call site is within your apply_configuration() loop:
- read bus & offset from CDI
- initialize the corresponding i2cCards[cardIndex]
- Parameters
-
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cardIndex | specifies which card the configuration is for. Used to update the i2cCards[] array and initialize the connection |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration for the MCP card |
Definition at line 295 of file I2cCardHelper.h.
◆ drive_pin()
| virtual void I2cCardHelper::drive_pin |
( |
uint8_t |
card, |
|
|
uint8_t |
pin, |
|
|
bool |
set |
|
) |
| |
|
inlineprotectedvirtualinherited |
◆ drive_pin_ext()
| virtual void I2cCardHelper::drive_pin_ext |
( |
uint8_t |
card, |
|
|
uint8_t |
pin, |
|
|
bool |
set, |
|
|
uint8_t |
intArg |
|
) |
| |
|
inlineprotectedvirtualinherited |
Extended hook for consumers that also need the CDI intArg (e.g., audio message index). Default forwards to drive_pin(...) so existing consumers remain unchanged.
Reimplemented in AudioConfiguredConsumer.
Definition at line 402 of file I2cCardHelper.h.
◆ ensureUniqueI2cOffset()
| bool I2cCardHelper::ensureUniqueI2cOffset |
( |
uint8_t |
cardIndex, |
|
|
uint8_t |
bus, |
|
|
uint8_t |
offset |
|
) |
| |
|
inlineinherited |
Check for duplicate offsets on the same I2C bus. Automatically resets the tracker on the first call per config pass.
- Parameters
-
| cardIndex | Index of the card in the config loop. |
| bus | I2C bus number (0 or 1). |
| offset | I2C offset (0–7). |
- Returns
- true if this (bus, offset) was already claimed.
Definition at line 183 of file I2cCardHelper.h.
◆ factory_reset()
| void NodeCardIoConfiguredPC::factory_reset |
( |
int |
fd | ) |
|
|
inline |
Reset CDI configuration entries to their initial (default) values.
- Parameters
-
| fd | used to access the CDI information in the file system |
Definition at line 339 of file NodeCardIoConfiguredPC.h.
◆ handle_event_report()
| void NodeCardIoConfiguredPC::handle_event_report |
( |
const openlcb::EventRegistryEntry & |
registry_entry, |
|
|
openlcb::EventReport * |
event, |
|
|
BarrierNotifiable * |
done |
|
) |
| |
|
inline |
Process consumed event for the a pin configured for output on the Node Card I/O line configured pins. Use args passed with the event to determine which pin to set on or off.
- Parameters
-
| registry_entry | contains information about the event, including the 'user' argument set during apply_configuration() |
| event | object handle for the event |
| done | |
Definition at line 367 of file NodeCardIoConfiguredPC.h.
◆ notify()
| void NodeCardIoConfiguredPC::notify |
( |
| ) |
|
|
inlineoverride |
Polls the state of input pins on Input/Output Cards and triggers events on state changes.
Asynchronous callback when the previous polling message has left via the bus. Used as a poor man's iterative state machine.
Iteratively checks each pin of every connected to the input point set of all Input/Output Cards for state changes. When a change in state is detected, it triggers a corresponding event. This function maintains state across calls, allowing it to resume polling where it left off in the previous call. Only one state change is handled per call to ensure load distribution over time.
- Note
- This function is repeatedly invoked by openMRN stack (registered via poll_33hz)
-
After processing all cards, the function resets to start from the first card in the next call.
Definition at line 169 of file NodeCardIoConfiguredPC.h.
◆ polling()
| openlcb::Polling * NodeCardIoConfiguredPC::polling |
( |
| ) |
|
|
inline |
◆ resetCardInfo()
| void I2cCardHelper::resetCardInfo |
( |
int |
fd, |
|
|
cardInfoConfig_type |
cfgI2cInfoRef |
|
) |
| |
|
inlineprotectedinherited |
resets the card configuration information (description field).
- Note
- invoke from the consumer/producer factory_reset() to reset the card configuration
- Parameters
-
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration block for the card's info (description, etc) |
Definition at line 309 of file I2cCardHelper.h.
◆ resetI2cInfo()
| void I2cCardHelper::resetI2cInfo |
( |
int |
fd, |
|
|
i2cInfoConfig_type |
cfgI2cInfoRef |
|
) |
| |
|
inlineprotectedinherited |
resets the card's I2C configuration information (bus and address fields).
- Note
- invoke from the consumer/producer factory_reset() to reset the card configuration
- Parameters
-
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration for card's I2C info (bus/offset) |
Definition at line 321 of file I2cCardHelper.h.
◆ SendEventIdentified()
| virtual void I2cCardHelper::SendEventIdentified |
( |
const openlcb::EventRegistryEntry & |
registry_entry, |
|
|
openlcb::EventReport * |
event, |
|
|
BarrierNotifiable * |
done |
|
) |
| |
|
inlineprotectedvirtualinherited |
Sends Producer- or Consumer-Identified for registry_entry.
Identification type is inferred from the registry entry’s packed user args (see
- See also
- isProducer). Override to customize the MTI or payload.
Reimplemented in TurnoutConfiguredPC.
Definition at line 273 of file I2cCardHelper.h.
◆ userArgs
The documentation for this class was generated from the following file: