Upgrade to v0.92
[hackover2013-badge-firmware.git] / core / usbcdc / usbcore.h
1 /*----------------------------------------------------------------------------
2 * U S B - K e r n e l
3 *----------------------------------------------------------------------------
4 * Name: usbcore.h
5 * Purpose: USB Core Definitions
6 * Version: V1.20
7 *----------------------------------------------------------------------------
8 * This software is supplied "AS IS" without any warranties, express,
9 * implied or statutory, including but not limited to the implied
10 * warranties of fitness for purpose, satisfactory quality and
11 * noninfringement. Keil extends you a royalty-free right to reproduce
12 * and distribute executable files created using this software for use
13 * on NXP Semiconductors LPC microcontroller devices only. Nothing else
14 * gives you the right to use this software.
15 *
16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17 *---------------------------------------------------------------------------*/
18
19 #ifndef __USBCORE_H__
20 #define __USBCORE_H__
21
22 #include "usbcfg.h"
23
24 /* USB Endpoint Data Structure */
25 typedef struct _USB_EP_DATA {
26 uint8_t *pData;
27 uint16_t Count;
28 } USB_EP_DATA;
29
30 /* USB Core Global Variables */
31 extern uint16_t USB_DeviceStatus;
32 extern uint8_t USB_DeviceAddress;
33 volatile extern uint8_t USB_Configuration;
34 extern uint32_t USB_EndPointMask;
35 extern uint32_t USB_EndPointHalt;
36 extern uint32_t USB_EndPointStall;
37 extern uint8_t USB_AltSetting[USB_IF_NUM];
38
39
40 /* USB Endpoint 0 Buffer */
41 extern uint8_t EP0Buf[USB_MAX_PACKET0];
42
43 /* USB Endpoint 0 Data Info */
44 extern USB_EP_DATA EP0Data;
45
46 /* USB Setup Packet */
47 extern USB_SETUP_PACKET SetupPacket;
48
49 /* USB Core Functions */
50 extern void USB_ResetCore (void);
51
52 /* Newer C compilers make it really difficult to add
53 * an integer to a pointer */
54 static inline void UsbAddPtr(void **vpptr, uint32_t n);
55
56 /*
57 * Add a number of bytes to a pointer's address
58 * Harder than you might think. Some compilers say:
59 * Expected an lvalue -- Assignment expects its first operand to be
60 * an lvalue. Please note that a cast removes the lvaluedness of an
61 * expression.
62 *
63 * vpptr = void pointer to pointer
64 * n = number of bytes to add to pointer
65 * Call looks like: AddPtr((void **)&myPointer, 8);
66 */
67 static inline void UsbAddPtr(void **vpptr, uint32_t n)
68 {
69 /* Declare a pointer to a pointer to a byte. Only a byte pointer
70 * can be incremented by a number of bytes. Other pointers will
71 * increment by a multiple of what they point to.
72 */
73 uint8_t **bpptr;
74
75 /* Convert our void pointer to a pointer to a byte pointer to a pointer */
76 bpptr = (uint8_t **)vpptr;
77
78 /* Add 'n' bytes to our pointer value */
79 (*bpptr) += n;
80 }
81
82
83
84
85
86
87
88 #endif /* __USBCORE_H__ */
This page took 0.051134 seconds and 5 git commands to generate.