The open source OpenXR runtime
at prediction-2 90 lines 1.7 kB view raw
1// Copyright 2020-2021, N Madsen. 2// Copyright 2020-2021, Collabora, Ltd. 3// SPDX-License-Identifier: BSL-1.0 4/*! 5 * @file 6 * @brief WMR Motion Controller protocol constants, structures and helpers 7 * @author Nis Madsen <nima_zero_one@protonmail.com> 8 * @ingroup drv_wmr 9 */ 10 11#pragma once 12 13#include "xrt/xrt_byte_order.h" 14 15#include "wmr_protocol.h" 16 17 18#ifdef __cplusplus 19extern "C" { 20#endif 21 22#ifdef XRT_DOXYGEN 23#define WMR_PACKED 24#else 25#define WMR_PACKED __attribute__((packed)) 26#endif 27 28/*! 29 * WMR Motion Controller protocol constant and structures 30 * 31 * @addtogroup drv_wmr 32 * @{ 33 */ 34 35// Todo: Is this enough? 36#define WMR_MOTION_CONTROLLER_MSG_BUFFER_SIZE 256 37#define WMR_MOTION_CONTROLLER_NS_PER_TICK 100 38 39 40// Messages types for WMR motion controllers 41#define WMR_MOTION_CONTROLLER_STATUS_MSG 0x01 42 43struct wmr_controller_fw_cmd 44{ 45 union { 46 struct 47 { 48 uint8_t prefix; 49 uint8_t cmd_id; 50 uint8_t block_id; 51 52 __le32 addr; 53 } WMR_PACKED cmd; 54 uint8_t buf[64]; 55 }; 56}; 57 58#define WMR_CONTROLLER_FW_CMD_INIT(p, c, b, a) \ 59 ((struct wmr_controller_fw_cmd){ \ 60 .cmd = {.prefix = (p), .cmd_id = (c), .block_id = (b), .addr = __cpu_to_le32((a))}}) 61 62struct wmr_controller_fw_cmd_response 63{ 64 union { 65 struct 66 { 67 uint8_t prefix; 68 uint8_t zero; 69 uint8_t cmd_id_echo; 70 uint8_t zero1; 71 uint8_t block_id_echo; 72 73 __le32 blk_remain; /* Remaining bytes available in the block */ 74 uint8_t len; /* Bytes in this response data */ 75 76 uint8_t data[68]; 77 } WMR_PACKED response; 78 uint8_t buf[78]; 79 }; 80}; 81 82/*! 83 * @} 84 */ 85 86#undef WMR_PACKED 87 88#ifdef __cplusplus 89} 90#endif