25 #include "VMXResourceConfig.h" 26 #include "VMXErrors.h" 28 #include <unordered_set> 34 class VMXChannelManager;
35 class VMXResourceManager;
37 class VMXIO_PIGPIOInterruptSink;
48 VMXChannelManager& chan_mgr;
49 VMXResourceManager& res_mgr;
51 VMXIO_PIGPIOInterruptSink *p_int_sink;
53 bool DisconnectAnalogInputInterrupt(uint8_t analog_trigger_num);
55 VMXIO(PIGPIOClient& pigpio, IOCXClient& iocx, MISCClient& misc, VMXChannelManager& chan_mgr, VMXResourceManager& res_mgr,
VMXTime& time_ref);
56 void ReleaseResources();
120 bool PWMCapture_GetCount(
VMXResourceHandle pwmcap_res_handle, int32_t& count, VMXErrorCode *errcode = 0);
150 bool UART_Read(
VMXResourceHandle uart_res_handle, uint8_t *p_data, uint16_t max_size, uint16_t& actual_size_read, VMXErrorCode *errcode = 0);
159 bool I2C_Write(
VMXResourceHandle i2c_res_handle, uint8_t deviceAddress, uint8_t* dataToSend, int32_t sendSize, VMXErrorCode *errcode = 0);
160 bool I2C_Read(
VMXResourceHandle i2c_res_handle, uint8_t deviceAddress, uint8_t* buffer, int32_t count, VMXErrorCode *errcode = 0);
162 uint8_t* dataToSend, uint16_t sendSize,
163 uint8_t* dataReceived, uint16_t receiveSize, VMXErrorCode *errcode = 0);
bool ActivateSinglechannelResource(VMXChannelIndex channel_index, VMXChannelCapability channel_capability, VMXResourceHandle &res_handle, const VMXResourceConfig *res_cfg=0, VMXErrorCode *errcode=0)
Attempts to activate the specified VMXResourceHandle, by first allocating the resource, then routing the specified VMX Channel to it, then applying the specified configuration, and then finally performing resource activation.
Definition: VMXIO.cpp:1244
bool AnalogTrigger_GetState(VMXResourceHandle antrig_res_handle, AnalogTriggerState &state, VMXErrorCode *errcode=0)
Returns the current state from a VMX AnalogTrigger Resource.
Definition: VMXIO.cpp:1809
Top-level Library Class providing access to all VMX-pi functionality.
Definition: VMXPi.h:37
EncoderDirection
Enumeration of Encoder Directions.
Definition: VMXIO.h:126
bool GetChannelsCompatibleWithResource(VMXResourceHandle resource_handle, VMXChannelIndex &first_channel_index, uint8_t &num_channels)
Returns a list of VMXChannelIndexes which are compatible with the specified VMXResourceHandle.
Definition: VMXIO.cpp:255
bool ChannelSupportsCapability(VMXChannelIndex channel_index, VMXChannelCapability capability)
Indicates whether the specified VMXChannelIndex supports the specified VMXChannelCapability.
Definition: VMXIO.cpp:333
bool UART_Read(VMXResourceHandle uart_res_handle, uint8_t *p_data, uint16_t max_size, uint16_t &actual_size_read, VMXErrorCode *errcode=0)
Reads data from the specified VMX UART Resource.
Definition: VMXIO.cpp:1878
bool DeallocateResource(VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to deallocate the specified VMXResourceHandle.
Definition: VMXIO.cpp:443
uint8_t GetNumChannelsByType(VMXChannelType channel_type, VMXChannelIndex &first_channel_index)
Returns the number of VMX Channels of the specified VMXChannelType.
Definition: VMXIO.cpp:208
uint16_t VMXResourceHandle
Handle to a particular VMX Resource.
Definition: VMXResource.h:61
bool IsResourceAllocated(VMXResourceHandle resource, bool &allocated, bool &is_shared, VMXErrorCode *errcode=0)
Indicates whether the specified VMXResourceHandle is currently allocated, and whether it is a shared ...
Definition: VMXIO.cpp:355
bool Encoder_GetCount(VMXResourceHandle encoder_res_handle, int32_t &count, VMXErrorCode *errcode=0)
Returns the current Encoder count value from a VMX Encoder Resource.
Definition: VMXIO.cpp:1522
Base structure representing VMXResourceType-specific configuration data that must be set to a valid d...
Definition: VMXResourceConfig.h:33
AnalogTriggerState
Enumeration of Analog Trigger States.
Definition: VMXIO.h:143
bool SPI_Read(VMXResourceHandle spi_res_handle, uint8_t *p_rcv_data, uint16_t size, VMXErrorCode *errcode=0)
Reads data from the specified VMX SPI Resource.
Definition: VMXIO.cpp:1958
uint8_t GetNumChannelsByCapability(VMXChannelCapability channel_capability)
Returns the number of VMX Channels of the specified VMXChannelCapability.
Definition: VMXIO.cpp:196
bool I2C_Transaction(VMXResourceHandle i2c_res_handle, uint8_t deviceAddress, uint8_t *dataToSend, uint16_t sendSize, uint8_t *dataReceived, uint16_t receiveSize, VMXErrorCode *errcode=0)
Simultaneously Writes/Reads data to/from the specified VMX I2C Resource.
Definition: VMXIO.cpp:2073
uint8_t GetNumResourcesByType(VMXResourceType resource_type)
Returns the number of VMX Resources of the specified VMXResourceType.
Definition: VMXIO.cpp:185
bool GetResourceHandle(VMXResourceType resource_type, VMXResourceIndex res_index, VMXResourceHandle &resource_handle, VMXErrorCode *errcode=0)
Returns the VMXResourceHandle of the VMX Resource identified by the specified VMXResourceType and VMX...
Definition: VMXIO.cpp:225
const uint8_t MAX_PWM_GENERATOR_DUTY_CYCLE
Maximum PWM Generator Duty Cycle value.
Definition: VMXIO.h:115
bool GetResourcesCompatibleWithChannelAndCapability(VMXChannelIndex channel_index, VMXChannelCapability capability, std::list< VMXResourceHandle > &compatible_res_handles)
Returns a list of VMXResourceHandles which are compatible with the specified VMXChannelIndex and VMXC...
Definition: VMXIO.cpp:239
bool Accumulator_GetOversampleValue(VMXResourceHandle accum_res_handle, uint32_t &oversample_value, VMXErrorCode *errcode=0)
Returns the current oversample value from a VMX Analog Accumulator Resource.
Definition: VMXIO.cpp:1703
bool RouteChannelToResource(VMXChannelIndex channel, VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to route the specified VMXChannelIndex to the allocated VMXResourceHandle Note: If the resou...
Definition: VMXIO.cpp:521
bool GetResourceDefaultConfig(VMXResourceHandle resource, VMXResourceConfig *&p_config, VMXErrorCode *errcode=0)
Gets the default configuration of the specified VMXResourceHandle.
Definition: VMXIO.cpp:868
bool DIO_Set(VMXResourceHandle dio_res_handle, bool high, VMXErrorCode *errcode=0)
Sets the current signal state of a VMX DigitalIO Resource in Digital Output mode. ...
Definition: VMXIO.cpp:1668
bool Accumulator_GetAverageValue(VMXResourceHandle accum_res_handle, uint32_t &average_value, VMXErrorCode *errcode=0)
Returns the current averaged value from a VMX Analog Accumulator Resource.
Definition: VMXIO.cpp:1731
bool I2C_Write(VMXResourceHandle i2c_res_handle, uint8_t deviceAddress, uint8_t *dataToSend, int32_t sendSize, VMXErrorCode *errcode=0)
Writes the specified data to the specified VMX I2C Resource.
Definition: VMXIO.cpp:2014
uint8_t VMXResourceIndex
Zero-based index of a particular VMX Resource, relative to a specific VMXResourceType.
Definition: VMXResource.h:59
bool SPI_Write(VMXResourceHandle spi_res_handle, uint8_t *p_send_data, uint16_t size, VMXErrorCode *errcode=0)
Writes the specified data to the specified VMX SPI Resource.
Definition: VMXIO.cpp:1931
bool GetResourceConfig(VMXResourceHandle resource, VMXResourceConfig *&p_config, VMXErrorCode *errcode=0)
Gets the configuration of the specified VMXResourceHandle.
Definition: VMXIO.cpp:841
bool ActivateMultichannelResource(uint8_t num_channels, VMXChannelIndex *p_channel_indexes, VMXChannelCapability *p_channel_capabilities, VMXResourceHandle &res_handle, const VMXResourceConfig *res_cfg=0, VMXErrorCode *errcode=0)
Attempts to activate the specified VMXResourceHandle, by first allocating the resource, then routing the specified VMX Channels to it, then applying the specified configuration, and then finally performing resource activation.
Definition: VMXIO.cpp:1270
bool AllocateResource(VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to allocate the specified VMXResourceHandle.
Definition: VMXIO.cpp:399
bool GetChannelCapabilities(VMXChannelIndex channel_index, VMXChannelType &channel_type, VMXChannelCapability &capability_bits)
Returns the VMXChannelType and VMXChannelCapability for the specified VMXChannelIndex.
Definition: VMXIO.cpp:295
bool I2C_Read(VMXResourceHandle i2c_res_handle, uint8_t deviceAddress, uint8_t *buffer, int32_t count, VMXErrorCode *errcode=0)
Reads data from the specified VMX I2C Resource.
Definition: VMXIO.cpp:2041
VMXResourceType
Enumerates the various types of VMXResources.
Definition: VMXResource.h:33
uint8_t VMXChannelIndex
Type representing the 0-based index of a VMX Channel.
Definition: VMXChannel.h:105
bool UART_Write(VMXResourceHandle uart_res_handle, uint8_t *p_data, uint16_t size, VMXErrorCode *errcode=0)
Writes the specified data to the specified VMX UART Resource.
Definition: VMXIO.cpp:1848
bool GetUnallocatedResourcesCompatibleWithChannelAndCapability(VMXChannelIndex channel_index, VMXChannelCapability capability, std::list< VMXResourceHandle > &unallocated_compatible_res_handles)
Returns a list of unallocated VMXResourceHandles which are compatible with the specified VMXChannelIn...
Definition: VMXIO.cpp:270
const uint8_t MIN_PWM_GENERATOR_DUTY_CYCLE
Minimum PWM Generator Duty Cycle value.
Definition: VMXIO.h:113
VMXTime time
The VMXTime object providing access to VMX-pi Time functionality.
Definition: VMXPi.h:46
bool UnrouteChannelFromResource(VMXChannelIndex channel, VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to unroute the specified VMXChannelIndex from the allocated VMXResourceHandle.
Definition: VMXIO.cpp:679
The VMXTime class provides time management functions, including system timestamps, VMX Real-time Clock access, timer notifications and current thread time-delay.
Definition: VMXTime.h:38
bool IsResourceActive(VMXResourceHandle, bool &active, VMXErrorCode *errcode=0)
Indicates whether the specified VMXResourceHandle is currently active.
Definition: VMXIO.cpp:378
bool Encoder_GetDirection(VMXResourceHandle encoder_res_handle, EncoderDirection &direction, VMXErrorCode *errcode=0)
Returns the current EncoderDirection value from a VMX Encoder Resource.
Definition: VMXIO.cpp:1545
bool Encoder_Reset(VMXResourceHandle encoder_res_handle, VMXErrorCode *errcode=0)
Sets the VMX Encoder Resource's count value to 0.
Definition: VMXIO.cpp:1574
The VMXIO class provides access to VMX Analog/Digital IO functions, including VMX Channel and VMX Res...
Definition: VMXIO.h:41
bool DeallocateAllResources(VMXErrorCode *last_errorcode=0)
Attempts to deallocate all currently-allocated VMXResourceHandles.
Definition: VMXIO.cpp:494
bool Accumulator_GetAverageVoltage(VMXResourceHandle accum_res_handle, float &average_value, VMXErrorCode *errcode=0)
Returns the current averaged value in voltage units from a VMX Analog Accumulator Resource...
Definition: VMXIO.cpp:1789
bool Accumulator_GetInstantaneousValue(VMXResourceHandle accum_res_handle, uint32_t &average_value, VMXErrorCode *errcode=0)
Returns the current instantaneous (non-averaged) value from a VMX Analog Accumulator Resource...
Definition: VMXIO.cpp:1757
bool SetResourceConfig(VMXResourceHandle resource, const VMXResourceConfig *p_config, VMXErrorCode *errcode=0)
Sets the configuration to the specified VMXResourceHandle.
Definition: VMXIO.cpp:814
bool UART_GetBytesAvailable(VMXResourceHandle uart_es_handle, uint16_t &size, VMXErrorCode *errcode=0)
Returns the number of data bytes which have been received from VMX UART Resource. ...
Definition: VMXIO.cpp:1904
bool Accumulator_GetFullScaleVoltage(float &full_scale_voltage, VMXErrorCode *errcode=0)
Returns the current VMX Analog Input full-scale voltage level.
Definition: VMXIO.cpp:1771
bool ActivateResource(VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to activate the specified VMXResourceHandle NOTE: VMX Resources can be activated after they ...
Definition: VMXIO.cpp:901
bool UnrouteAllChannelsFromResource(VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to unroute all VMX Channels from the allocated VMXResourceHandle.
Definition: VMXIO.cpp:778
bool DeactivateResource(VMXResourceHandle resource, VMXErrorCode *errcode=0)
Attempts to deactivate the specified VMXResourceHandle.
Definition: VMXIO.cpp:1360
VMXChannelCapability
Enumeration of VMX Channel Capabilities.
Definition: VMXChannel.h:64
VMXChannelType
Enumeration of VMX Channel types.
Definition: VMXChannel.h:42
bool DIO_Get(VMXResourceHandle dio_res_handle, bool &high, VMXErrorCode *errcode=0)
Returns the current signal state from a VMX DigitalIO Resource.
Definition: VMXIO.cpp:1636
bool SPI_Transaction(VMXResourceHandle spi_res_handle, uint8_t *p_send_data, uint8_t *p_rcv_data, uint16_t size, VMXErrorCode *errcode=0)
Simultaneously Writes/Reads data to/from the specified VMX SPI Resource.
Definition: VMXIO.cpp:1986
uint8_t VMXResourcePortIndex
Zero-based index of a particular VMX Resource Port of a VMX Resource.
Definition: VMXResource.h:63
bool PWMGenerator_SetDutyCycle(VMXResourceHandle pwmgen_res_handle, VMXResourcePortIndex port_index, uint8_t duty_cycle, VMXErrorCode *errcode=0)
Sets the VMX PWM Generator Resource's Duty Cycle to the specified value.
Definition: VMXIO.cpp:1601