1 /****************************************************************************** 2 * Filename: hw_types.h 3 * Revised: 2016-09-13 14:21:40 +0200 (Tue, 13 Sep 2016) 4 * Revision: 47152 5 * 6 * Description: Common types and macros. 7 * 8 * Copyright (c) 2015 - 2017, Texas Instruments Incorporated 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions are met: 13 * 14 * 1) Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 17 * 2) Redistributions in binary form must reproduce the above copyright notice, 18 * this list of conditions and the following disclaimer in the documentation 19 * and/or other materials provided with the distribution. 20 * 21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may 22 * be used to endorse or promote products derived from this software without 23 * specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 ******************************************************************************/ 38 39 #ifndef __HW_TYPES_H__ 40 #define __HW_TYPES_H__ 41 42 #include <stdint.h> 43 #include <stdbool.h> 44 #include "../inc/hw_chip_def.h" 45 46 //***************************************************************************** 47 // 48 // Common driverlib types 49 // 50 //***************************************************************************** 51 typedef void (* FPTR_VOID_VOID_T) (void); 52 typedef void (* FPTR_VOID_UINT8_T) (uint8_t); 53 54 //***************************************************************************** 55 // 56 // This symbol forces simple driverlib functions to be inlined in the code 57 // instead of using function calls. 58 // 59 //***************************************************************************** 60 #ifndef __STATIC_INLINE 61 #define __STATIC_INLINE static inline 62 #endif 63 64 //***************************************************************************** 65 // 66 // C99 types only allows bitfield defintions on certain datatypes. 67 // 68 //***************************************************************************** 69 typedef unsigned int __UINT32; 70 71 //***************************************************************************** 72 // 73 // Macros for direct hardware access. 74 // 75 // If using these macros the programmer should be aware of any limitations to 76 // the address accessed i.e. if it supports word and/or byte access. 77 // 78 //***************************************************************************** 79 // Word (32 bit) access to address x 80 // Read example : my32BitVar = HWREG(base_addr + offset) ; 81 // Write example : HWREG(base_addr + offset) = my32BitVar ; 82 #define HWREG(x) \ 83 (*((volatile unsigned long *)(x))) 84 85 // Half word (16 bit) access to address x 86 // Read example : my16BitVar = HWREGH(base_addr + offset) ; 87 // Write example : HWREGH(base_addr + offset) = my16BitVar ; 88 #define HWREGH(x) \ 89 (*((volatile unsigned short *)(x))) 90 91 // Byte (8 bit) access to address x 92 // Read example : my8BitVar = HWREGB(base_addr + offset) ; 93 // Write example : HWREGB(base_addr + offset) = my8BitVar ; 94 #define HWREGB(x) \ 95 (*((volatile unsigned char *)(x))) 96 97 //***************************************************************************** 98 // 99 // Macros for hardware access to bit-band supported addresses via the bit-band region. 100 // 101 // Macros calculate the corresponding address to access in the bit-band region 102 // based on the actual address of the memory/register and the bit number. 103 // 104 // Do NOT use these macros to access the bit-band region directly! 105 // 106 //***************************************************************************** 107 // Bit-band access to address x bit number b using word access (32 bit) 108 #define HWREGBITW(x, b) \ 109 HWREG(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \ 110 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2)) 111 112 // Bit-band access to address x bit number b using half word access (16 bit) 113 #define HWREGBITH(x, b) \ 114 HWREGH(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \ 115 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2)) 116 117 // Bit-band access to address x bit number b using byte access (8 bit) 118 #define HWREGBITB(x, b) \ 119 HWREGB(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \ 120 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2)) 121 122 123 #endif // __HW_TYPES_H__ 124