Xbee s2b for lpc11u24

Dependencies:   DigiLogger

Dependents:  

Fork of XBeeLib by Digi International Inc.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Utils.cpp Source File

Utils.cpp

00001 /**
00002  * Copyright (c) 2015 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 #include "Utils.h"
00014 #include <string.h>
00015 
00016 void rmemcpy(uint8_t * const dest, const uint8_t * const src, uint16_t bytes)
00017 {
00018     uint8_t *destp = dest + bytes - 1;
00019     uint8_t *srcp = (uint8_t *)src;
00020 
00021     while (destp >= dest)
00022         *destp-- = *srcp++;
00023 }
00024 
00025 uint64_t addr64_from_uint8_t(const uint8_t * const data, bool big_endian = true)
00026 {
00027     int64_t addr64;
00028     if (big_endian) {
00029         rmemcpy((uint8_t *)&addr64, data, 8);
00030     } else {
00031         memcpy((uint8_t *)&addr64, data, 8);
00032     }
00033     return addr64;
00034 }