VMX-pi C++ HAL Library for Raspberry Pi
VMX-pi Robotics Controller & Vision/Motion Processor
VMXResource.h
Go to the documentation of this file.
1 /* ============================================
2 VMX-pi HAL source code is placed under the MIT license
3 Copyright (c) 2017 Kauai Labs
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 THE SOFTWARE.
19 ===============================================
20 */
21 
22 #ifndef VMXRESOURCE_H_
23 #define VMXRESOURCE_H_
24 
27 #include <stdint.h>
28 
29 #include "VMXChannel.h"
30 #include "VMXErrors.h"
31 
33 typedef enum {
34  Undefined,
52  SPI,
54  I2C,
55  MaxVMXResourceType = I2C,
57 
59 typedef uint8_t VMXResourceIndex;
61 typedef uint16_t VMXResourceHandle;
63 typedef uint8_t VMXResourcePortIndex;
64 
67 
69 #define INVALID_VMX_RESOURCE_HANDLE(vmx_res_handle) (((uint8_t)vmx_res_handle)==INVALID_VMX_RESOURCE_INDEX)
70 
71 #define CREATE_VMX_RESOURCE_HANDLE(res_type,res_index) ((((uint16_t)res_type)<<8) | (uint8_t)res_index)
72 
73 #define EXTRACT_VMX_RESOURCE_TYPE(res_handle) (VMXResourceType)(res_handle >> 8)
74 
75 #define EXTRACT_VMX_RESOURCE_INDEX(res_handle) (uint8_t)(res_handle & 0x00FF)
76 
77 #endif /* VMXRESOURCE_H_ */
VMX Resource providing Quadrature Encoder of a VMX Channel pair in input mode.
Definition: VMXResource.h:42
uint16_t VMXResourceHandle
Handle to a particular VMX Resource.
Definition: VMXResource.h:61
const VMXResourceIndex INVALID_VMX_RESOURCE_INDEX
Value indicating a VMXResourceIndex is invalid.
Definition: VMXResource.h:66
VMX Resource providing Digital Input and Digital Output Control on a VMX Digital Channel.
Definition: VMXResource.h:36
VMX Resource providing I2C communication via a VMX Channel pair.
Definition: VMXResource.h:54
VMX Resource providing Interrupt generation from a VMX Analog Input Channel.
Definition: VMXResource.h:46
VMX Resource providing SPI communication via a four VMX Channel set.
Definition: VMXResource.h:52
uint8_t VMXResourceIndex
Zero-based index of a particular VMX Resource, relative to a specific VMXResourceType.
Definition: VMXResource.h:59
VMXResourceType
Enumerates the various types of VMXResources.
Definition: VMXResource.h:33
VMX Resource providing PWM Generation Control of a VMX Digital Channel in output mode.
Definition: VMXResource.h:38
VMX Resource providing UART communication via a VMX Channel pair.
Definition: VMXResource.h:50
VMX Resource providing PWM Capture of a VMX FlexIO Digital Channel in input mode. ...
Definition: VMXResource.h:40
uint8_t VMXResourcePortIndex
Zero-based index of a particular VMX Resource Port of a VMX Resource.
Definition: VMXResource.h:63
VMX Resource providing Interrupt generation from a VMX Digital Channel in input mode.
Definition: VMXResource.h:48
VMX Resource providing Oversampling/Averaging of a VMX Analog Input Channel.
Definition: VMXResource.h:44