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.
utilities.h
00001 /******************************************************************************* 00002 ################################################################################ 00003 # (C) STMicroelectronics 2014 00004 # 00005 # This program is free software; you can redistribute it and/or modify it under 00006 # the terms of the GNU General Public License version 2 and only version 2 as 00007 # published by the Free Software Foundation. 00008 # 00009 # This program is distributed in the hope that it will be useful, but WITHOUT 00010 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00012 # details. 00013 # 00014 # You should have received a copy of the GNU General Public License along with 00015 # this program; if not, write to the Free Software Foundation, Inc., 00016 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 # 00018 #------------------------------------------------------------------------------ 00019 # Imaging Division 00020 ################################################################################ 00021 ********************************************************************************/ 00022 00023 /*! 00024 *\file utilities.h 00025 *\brief Utilities module to contain common and useful routines. 00026 */ 00027 00028 #ifndef _UTILITIES 00029 #define _UTILITIES 00030 00031 #include "platform.h" 00032 #include "definitions.h" 00033 00034 /** 00035 * @brief This function converts a given array of bytes to a string in hex 00036 * format. To be used when it is desired to display loose bytes as 00037 * a short, int, long long etc. 00038 * 00039 * If a valid length parameter is supplied only this number of bytes 00040 * will be converted. A count of 0 will be ignored. 00041 */ 00042 int32_t array2HexCString(uint8_t *byteArray, char *str, uint32_t count); 00043 00044 /** 00045 * @brief This function unpacks an integer to a given array of bytes. 00046 */ 00047 int32_t unPackBytes(int32_t data, uint8_t *byteArray, int32_t size); 00048 00049 /** 00050 * @brief This function packs an attay of bytes to a given integer. 00051 */ 00052 uint32_t packBytes(uint8_t *byteArray, uint32_t size); 00053 00054 /** 00055 * @brief This function round a float value to an integer value. 00056 */ 00057 int32_t roundFloatToInt(float_t floatVal); 00058 00059 /** 00060 * @brief Method to encode a float to 9:7 format and return as an 00061 * unsigned int. This is performed by shifting the float 7 00062 * bits to the left and then converting to unsigned int. 00063 */ 00064 uint32_t encodeTo9_7_Format(float_t value); 00065 00066 /** 00067 * @brief Method to decode a 9:7 formatted data word into a 00068 * float. The data word is shifted 7 bits to the right and 00069 * converted to float. 00070 */ 00071 float_t decodeFrom9_7_Format(uint32_t value); 00072 00073 /** 00074 * @brief Method to encode a float to 4:4 format and return as an 00075 * unsigned int. This is performed by shifting the float 4 00076 * bits to the left and then converting to unsigned int. 00077 */ 00078 uint32_t encodeTo4_4_Format(float_t value); 00079 00080 /** 00081 * @brief Method to decode a 4:4 formatted data word into a 00082 * float. The data word is shifted 4 bits to the right and 00083 * converted to float. 00084 */ 00085 float_t decodeFrom4_4_Format(uint32_t value); 00086 00087 #endif 00088 00089
Generated on Tue Jul 12 2022 22:19:50 by
1.7.2