Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
rci_binary_util.h
00001 /* 00002 * Copyright (c) 2013 Digi International Inc., 00003 * All rights not expressly granted are reserved. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 00007 * You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 00010 * ======================================================================= 00011 */ 00012 00013 #if (defined connector_request_id_remote_config_configurations) 00014 static connector_remote_config_data_t connector_rci_config_data = { 00015 NULL, NULL, connector_rci_error_COUNT, 0 00016 }; 00017 00018 #else 00019 typedef struct { 00020 connector_remote_group_table_t const * group_table; 00021 char const * const * error_table; 00022 unsigned int global_error_count; 00023 uint32_t firmware_target_zero_version; 00024 } connector_remote_config_data_t; 00025 00026 static connector_remote_config_data_t const connector_rci_config_data = { 00027 connector_group_table, 00028 #if defined RCI_PARSER_USES_ERROR_DESCRIPTIONS 00029 connector_rci_errors, 00030 #else 00031 NULL, 00032 #endif 00033 connector_global_error_COUNT, 00034 FIRMWARE_TARGET_ZERO_VERSION 00035 }; 00036 #endif 00037 00038 #define BINARY_RCI_FIELD_LOWER_ID_MASK UINT32_C(0x3F) 00039 #define BINARY_RCI_FIELD_MIDDLE_ID_MASK UINT32_C(0x380) 00040 #define BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK UINT32_C(0x800) 00041 #define BINARY_RCI_FIELD_UPPER_ID_MASK (~UINT32_C(0x1FFF)) 00042 00043 00044 static unsigned int decode_element_id(uint32_t const value) 00045 { 00046 unsigned int id; 00047 00048 id = (value & BINARY_RCI_FIELD_LOWER_ID_MASK); 00049 id |= ((value & BINARY_RCI_FIELD_MIDDLE_ID_MASK) >> 1); 00050 id |= ((value & BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK) >> 2); 00051 id |= ((value & BINARY_RCI_FIELD_UPPER_ID_MASK) >> 3); 00052 00053 return id; 00054 } 00055 00056 static uint32_t encode_element_id(unsigned int const id) 00057 { 00058 00059 uint32_t value; 00060 00061 value = (id & BINARY_RCI_FIELD_LOWER_ID_MASK); 00062 value |= ((id << 1) & BINARY_RCI_FIELD_MIDDLE_ID_MASK); 00063 value |= ((id << 2) & BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK); 00064 value |= ((id << 3) & BINARY_RCI_FIELD_UPPER_ID_MASK); 00065 00066 return value; 00067 } 00068 00069 00070 #define BINARY_RCI_GROUP_ID_LOWER_BIT_MASK UINT32_C(0x03F) /* [5:0] */ 00071 #define BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK UINT32_C(0xF80) /* [11:7] */ 00072 #define BINARY_RCI_GROUP_ID_UPPER_BIT_MASK ~(UINT32_C(0x1FF)) /* [:13] */ 00073 00074 static unsigned int decode_group_id(uint32_t const group_id) 00075 { 00076 00077 unsigned int id = 0; 00078 00079 id = (group_id & BINARY_RCI_GROUP_ID_LOWER_BIT_MASK); 00080 id |= ((group_id & BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK) >> 1); 00081 id |= ((group_id & BINARY_RCI_GROUP_ID_UPPER_BIT_MASK) >> 2); 00082 00083 return id; 00084 } 00085 00086 static uint32_t encode_group_id(unsigned int const group_id) 00087 { 00088 uint32_t id; 00089 00090 id = (group_id & BINARY_RCI_GROUP_ID_LOWER_BIT_MASK); 00091 id |= ((group_id << 1) & BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK); 00092 id |= ((group_id << 2) & BINARY_RCI_GROUP_ID_UPPER_BIT_MASK); 00093 00094 return id; 00095 } 00096 00097
Generated on Tue Jul 12 2022 19:18:38 by
1.7.2