Daniel Knox / RN2483

Dependents:   rn2483-TestProgram

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Utils.h Source File

Utils.h

00001 /*
00002 * Copyright (c) 2016 Dan Knox. All rights reserved.
00003 *
00004 * This file is part of MicrochipLoRaWAN.
00005 *
00006 * MicrochipLoRaWAN is free software: you can redistribute it and/or modify
00007 * it under the terms of the GNU Lesser General Public License as
00008 * published by the Free Software Foundation, either version 3 of
00009 * the License, or(at your option) any later version.
00010 *
00011 * MicrochipLoRaWAN is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014 * GNU Lesser General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Lesser General Public
00017 * License along with MicrochipLoRaWAN.  If not, see
00018 * <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef _UTILS_h
00022 #define _UTILS_h
00023 
00024 #define BOOL_TO_ONOFF(b) (b ? "on" : "off")
00025 #define NIBBLE_TO_HEX_CHAR(i) ((i <= 9) ? ('0' + i) : ('A' - 10 + i))
00026 #define HIGH_NIBBLE(i) ((i >> 4) & 0x0F)
00027 #define LOW_NIBBLE(i) (i & 0x0F)
00028 
00029 #define HEX_CHAR_TO_NIBBLE(c) ((c >= 'A') ? (c - 'A' + 0x0A) : (c - '0'))
00030 #define HEX_PAIR_TO_BYTE(h, l) ((HEX_CHAR_TO_NIBBLE(h) << 4) + HEX_CHAR_TO_NIBBLE(l))
00031 
00032 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
00033 
00034 #endif