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.
Fork of MX28 by
Utilities.h
00001 /* Copyright (c) 2012 Georgios Petrou, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef MX28_UTILITIES_H 00020 #define MX28_UTILITIES_H 00021 00022 #include "mbed.h" 00023 00024 /** MX28 utility functions class 00025 */ 00026 class Utilities 00027 { 00028 public: 00029 /** Get the checksum for a packet. 00030 * 00031 * @param data The array of bytes. 00032 * @param length The size of the array. 00033 * @return checksum 00034 */ 00035 static uint8_t GetCheckSum(const uint8_t *data, uint8_t length); 00036 00037 /** Convert a UInt16 number to array of chars. 00038 * 00039 * @param value The number value. 00040 * @param data The array to store the conversion. 00041 */ 00042 static void ConvertUInt16ToUInt8Array(uint16_t value, uint8_t* data); 00043 00044 /** Convert an Int16 number to array of chars. 00045 * 00046 * @param value The number value. 00047 * @param data The array to store the conversion. 00048 */ 00049 static void ConvertInt16ToUInt8Array(int16_t value, uint8_t* data); 00050 00051 /** Convert a UInt32 number to array of chars. 00052 * 00053 * @param value The number value. 00054 * @param data The array to store the conversion. 00055 */ 00056 static void ConvertUInt32ToUInt8Array(uint32_t value, uint8_t* data); 00057 00058 /** Convert an Int32 number to array of chars. 00059 * 00060 * @param value The number value. 00061 * @param data The array to store the conversion. 00062 */ 00063 static void ConvertInt32ToUInt8Array(int32_t value, uint8_t* data); 00064 00065 /** Convert an array of char to UInt16. 00066 * 00067 * @param data The array containing the chars. 00068 * @return UInt16 converted number. 00069 */ 00070 static uint16_t ConvertUInt8ArrayToUInt16(uint8_t* data); 00071 00072 /** Convert an array of char to Int16. 00073 * 00074 * @param data The array containing the chars. 00075 * @return Int16 converted number. 00076 */ 00077 static int16_t ConvertUInt8ArrayToInt16(uint8_t* data); 00078 00079 /** Convert an array of char to Int32. 00080 * 00081 * @param data The array containing the chars. 00082 * @return Int32 number. 00083 */ 00084 static int32_t ConvertUInt8ArrayToInt32(uint8_t* data); 00085 }; 00086 00087 #endif // MX28_UTILITIES_H 00088
Generated on Thu Jul 14 2022 04:02:36 by
