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