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