Daiki Kato / mbed-dev_tmp

Fork of mbed-dev by mbed official

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /*
bogdanm 0:9b334a45a8ff 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
bogdanm 0:9b334a45a8ff 3 * All rights reserved.
bogdanm 0:9b334a45a8ff 4 *
bogdanm 0:9b334a45a8ff 5 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 0:9b334a45a8ff 6 * are permitted provided that the following conditions are met:
bogdanm 0:9b334a45a8ff 7 *
bogdanm 0:9b334a45a8ff 8 * o Redistributions of source code must retain the above copyright notice, this list
bogdanm 0:9b334a45a8ff 9 * of conditions and the following disclaimer.
bogdanm 0:9b334a45a8ff 10 *
bogdanm 0:9b334a45a8ff 11 * o Redistributions in binary form must reproduce the above copyright notice, this
bogdanm 0:9b334a45a8ff 12 * list of conditions and the following disclaimer in the documentation and/or
bogdanm 0:9b334a45a8ff 13 * other materials provided with the distribution.
bogdanm 0:9b334a45a8ff 14 *
bogdanm 0:9b334a45a8ff 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
bogdanm 0:9b334a45a8ff 16 * contributors may be used to endorse or promote products derived from this
bogdanm 0:9b334a45a8ff 17 * software without specific prior written permission.
bogdanm 0:9b334a45a8ff 18 *
bogdanm 0:9b334a45a8ff 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
bogdanm 0:9b334a45a8ff 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
bogdanm 0:9b334a45a8ff 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 0:9b334a45a8ff 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
bogdanm 0:9b334a45a8ff 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
bogdanm 0:9b334a45a8ff 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
bogdanm 0:9b334a45a8ff 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
bogdanm 0:9b334a45a8ff 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
bogdanm 0:9b334a45a8ff 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
bogdanm 0:9b334a45a8ff 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 0:9b334a45a8ff 29 */
bogdanm 0:9b334a45a8ff 30 #ifndef __FSL_MISC_UTILITIES_H__
bogdanm 0:9b334a45a8ff 31 #define __FSL_MISC_UTILITIES_H__
bogdanm 0:9b334a45a8ff 32
bogdanm 0:9b334a45a8ff 33 #include <stdint.h>
bogdanm 0:9b334a45a8ff 34
bogdanm 0:9b334a45a8ff 35 /*******************************************************************************
bogdanm 0:9b334a45a8ff 36 * Definitions
bogdanm 0:9b334a45a8ff 37 ******************************************************************************/
bogdanm 0:9b334a45a8ff 38
bogdanm 0:9b334a45a8ff 39 /*! @brief Min/max macros */
bogdanm 0:9b334a45a8ff 40 #if !defined(MIN)
bogdanm 0:9b334a45a8ff 41 #define MIN(a, b) ((a) < (b) ? (a) : (b))
bogdanm 0:9b334a45a8ff 42 #endif
bogdanm 0:9b334a45a8ff 43
bogdanm 0:9b334a45a8ff 44 #if !defined(MAX)
bogdanm 0:9b334a45a8ff 45 #define MAX(a, b) ((a) > (b) ? (a) : (b))
bogdanm 0:9b334a45a8ff 46 #endif
bogdanm 0:9b334a45a8ff 47
bogdanm 0:9b334a45a8ff 48 /*! @brief Computes the number of elements in an array.*/
bogdanm 0:9b334a45a8ff 49 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
bogdanm 0:9b334a45a8ff 50
bogdanm 0:9b334a45a8ff 51 /*! @brief Byte swap macros */
bogdanm 0:9b334a45a8ff 52 #define BSWAP_16(x) (uint16_t)((((x) & 0xFF00) >> 0x8) | (((x) & 0xFF) << 0x8))
bogdanm 0:9b334a45a8ff 53 #define BSWAP_32(val) (uint32_t)((BSWAP_16((uint32_t)(val) & (uint32_t)0xFFFF) << 0x10) | \
bogdanm 0:9b334a45a8ff 54 (BSWAP_16((uint32_t)((val) >> 0x10))))
bogdanm 0:9b334a45a8ff 55
bogdanm 0:9b334a45a8ff 56 #endif /* __FSL_MISC_UTILITIES_H__ */
bogdanm 0:9b334a45a8ff 57 /*******************************************************************************
bogdanm 0:9b334a45a8ff 58 * EOF
bogdanm 0:9b334a45a8ff 59 ******************************************************************************/
bogdanm 0:9b334a45a8ff 60