project de marde si tu touch le no-homo s'applique pas
Fork of XBeeLib by
Utils/Utils.cpp@0:fcaad0dfa051, 2015-05-08 (annotated)
- Committer:
- spastor
- Date:
- Fri May 08 11:50:56 2015 +0200
- Revision:
- 0:fcaad0dfa051
- Child:
- 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 | 0:fcaad0dfa051 | 12 | |
spastor | 0:fcaad0dfa051 | 13 | #include "Utils.h" |
spastor | 0:fcaad0dfa051 | 14 | #include <cstring> |
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 | } |