PIC24 Support Libraries
pic24_unions.h
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3  * All rights reserved.
4  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without written agreement is
10  * hereby granted, provided that the above copyright notice, the following
11  * two paragraphs and the authors appear in all copies of this software.
12  *
13  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17  *
18  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23  *
24  * Please maintain this header in its entirety when copying/modifying
25  * these files.
26  *
27  *
28  */
29 
30 
31 // Documentation for this file. If the \file tag isn't present,
32 // this file won't be documented.
33 /** \file
34  * Typedefs and structures to allow for generic 8-, 16-, 32-, and 64-bit
35  * variables.
36  */
37 
38 #pragma once
39 
40 #include <stdint.h>
41 
42 /// A union type for byte or word access for 16 bit values.
43 typedef union _union16 {
44  uint16_t u16;
45  uint8_t u8[2];
46 } union16;
47 
48 /// A union type for byte, word, or dword access for 32 bit values.
49 typedef union _union32 {
50  uint32_t u32;
51 
52  struct {
53  uint16_t ls16;
54  uint16_t ms16;
55  } u16;
56 
57  uint8_t u8[4];
58 } union32;
59 
60 /// A union type for byte, word, or dword access for 64 bit values.
61 typedef union _union64 {
62  uint32_t u32[2];
63  uint16_t u16[4];
64  uint8_t u8[8];
65 } union64;
A union type for byte or word access for 16 bit values.
Definition: pic24_unions.h:43
A union type for byte, word, or dword access for 32 bit values.
Definition: pic24_unions.h:49
A union type for byte, word, or dword access for 64 bit values.
Definition: pic24_unions.h:61
unsigned char uint8_t
An abbreviation for an 8-bit unsigned integer.
Definition: dataXferImpl.h:194