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 XBeeLib by
Utils/Utils.cpp@4:629712865107, 2015-06-01 (annotated)
- Committer:
- spastor
- Date:
- Mon Jun 01 18:59:43 2015 +0200
- Revision:
- 4:629712865107
- Parent:
- 2:2ee1b6d51df2
Automatic upload
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
spastor | 0:fcaad0dfa051 | 1 | /** |
spastor | 0:fcaad0dfa051 | 2 | * Copyright (c) 2015 Digi International Inc., |
spastor | 0:fcaad0dfa051 | 3 | * All rights not expressly granted are reserved. |
spastor | 0:fcaad0dfa051 | 4 | * |
spastor | 0:fcaad0dfa051 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
spastor | 0:fcaad0dfa051 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
spastor | 0:fcaad0dfa051 | 7 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
spastor | 0:fcaad0dfa051 | 8 | * |
spastor | 0:fcaad0dfa051 | 9 | * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 |
spastor | 0:fcaad0dfa051 | 10 | * ======================================================================= |
spastor | 0:fcaad0dfa051 | 11 | */ |
spastor | 4:629712865107 | 12 | |
spastor | 0:fcaad0dfa051 | 13 | #include "Utils.h" |
hbujanda | 2:2ee1b6d51df2 | 14 | #include <string.h> |
spastor | 0:fcaad0dfa051 | 15 | |
spastor | 0:fcaad0dfa051 | 16 | void rmemcpy(uint8_t * const dest, const uint8_t * const src, uint16_t bytes) |
spastor | 0:fcaad0dfa051 | 17 | { |
spastor | 0:fcaad0dfa051 | 18 | uint8_t *destp = dest + bytes - 1; |
spastor | 0:fcaad0dfa051 | 19 | uint8_t *srcp = (uint8_t *)src; |
spastor | 0:fcaad0dfa051 | 20 | |
spastor | 0:fcaad0dfa051 | 21 | while (destp >= dest) |
spastor | 0:fcaad0dfa051 | 22 | *destp-- = *srcp++; |
spastor | 0:fcaad0dfa051 | 23 | } |
spastor | 0:fcaad0dfa051 | 24 | |
spastor | 0:fcaad0dfa051 | 25 | uint64_t addr64_from_uint8_t(const uint8_t * const data, bool big_endian = true) |
spastor | 0:fcaad0dfa051 | 26 | { |
spastor | 0:fcaad0dfa051 | 27 | int64_t addr64; |
spastor | 0:fcaad0dfa051 | 28 | if (big_endian) { |
spastor | 0:fcaad0dfa051 | 29 | rmemcpy((uint8_t *)&addr64, data, 8); |
spastor | 0:fcaad0dfa051 | 30 | } else { |
spastor | 0:fcaad0dfa051 | 31 | memcpy((uint8_t *)&addr64, data, 8); |
spastor | 0:fcaad0dfa051 | 32 | } |
spastor | 0:fcaad0dfa051 | 33 | return addr64; |
spastor | 0:fcaad0dfa051 | 34 | } |