File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change 88 * @author SparkFun Electronics
99 * @date 2024-2025
1010 * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
11- *
11+ *
1212 * SPDX-License-Identifier: MIT
1313 */
1414
@@ -38,7 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3838*/
3939#include " sfToolkit.h"
4040
41-
4241#ifdef ARDUINO
4342#include < Arduino.h>
4443#endif
@@ -87,3 +86,23 @@ uint32_t sftk_byte_swap(uint32_t i)
8786 return ((i << 24 ) & 0xff000000 ) | ((i << 8 ) & 0x00ff0000 ) | ((i >> 8 ) & 0x0000ff00 ) | ((i >> 24 ) & 0x000000ff );
8887#endif
8988}
89+
90+ // ---------------------------------------------------------------------------------
91+ /* *
92+ * @brief function - Byte swap an int 16
93+ */
94+ int16_t sftk_byte_swap (int16_t i)
95+ {
96+ uint16_t tmp = sftk_byte_swap (*(uint16_t *)&i);
97+ return *(int16_t *)&tmp;
98+ }
99+
100+ // ---------------------------------------------------------------------------------
101+ /* *
102+ * @brief function - Byte swap an int 32
103+ */
104+ int32_t sftk_byte_swap (int32_t i)
105+ {
106+ uint32_t tmp = sftk_byte_swap (*(uint32_t *)&i);
107+ return *(int32_t *)&tmp;
108+ }
Original file line number Diff line number Diff line change 99 * @author SparkFun Electronics
1010 * @date 2024-2025
1111 * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
12- *
12+ *
1313 * SPDX-License-Identifier: MIT
1414 */
1515
16-
1716#pragma once
1817
1918#include <stdint.h>
2322*/
2423#include "sfTkError.h"
2524
26-
2725// byte order types/enum
2826enum class sfTkByteOrder : uint8_t
2927{
@@ -39,9 +37,10 @@ sfTkByteOrder sftk_system_byteorder(void);
3937uint8_t sftk_byte_swap (uint8_t i );
4038uint16_t sftk_byte_swap (uint16_t i );
4139uint32_t sftk_byte_swap (uint32_t i );
40+ int16_t sftk_byte_swap (int16_t i );
41+ int32_t sftk_byte_swap (int32_t i );
4242
43-
44- // Area for platform specific implementations. The interface/functions are
43+ // Area for platform specific implementations. The interface/functions are
4544// defined here, with the expectation that the platform provides the implementation.
4645
4746// delay in milliseconds
You can’t perform that action at this time.
0 commit comments