These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frank26080115 0:bf7b9fba3924 1 /*----------------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 2 * U S B - K e r n e l
frank26080115 0:bf7b9fba3924 3 *----------------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 4 * Name: HIDUSER.C
frank26080115 0:bf7b9fba3924 5 * Purpose: HID Custom User Module
frank26080115 0:bf7b9fba3924 6 * Version: V1.10
frank26080115 0:bf7b9fba3924 7 *----------------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 8 * This software is supplied "AS IS" without any warranties, express,
frank26080115 0:bf7b9fba3924 9 * implied or statutory, including but not limited to the implied
frank26080115 0:bf7b9fba3924 10 * warranties of fitness for purpose, satisfactory quality and
frank26080115 0:bf7b9fba3924 11 * noninfringement. Keil extends you a royalty-free right to reproduce
frank26080115 0:bf7b9fba3924 12 * and distribute executable files created using this software for use
frank26080115 0:bf7b9fba3924 13 * on NXP Semiconductors LPC family microcontroller devices only. Nothing
frank26080115 0:bf7b9fba3924 14 * else gives you the right to use this software.
frank26080115 0:bf7b9fba3924 15 *
frank26080115 0:bf7b9fba3924 16 * Copyright (c) 2005-2009 Keil Software.
frank26080115 0:bf7b9fba3924 17 *---------------------------------------------------------------------------*/
frank26080115 0:bf7b9fba3924 18
frank26080115 0:bf7b9fba3924 19
frank26080115 0:bf7b9fba3924 20 #include "lpc_types.h"
frank26080115 0:bf7b9fba3924 21
frank26080115 0:bf7b9fba3924 22 #include "usb.h"
frank26080115 0:bf7b9fba3924 23 #include "hid.h"
frank26080115 0:bf7b9fba3924 24 #include "usbcfg.h"
frank26080115 0:bf7b9fba3924 25 #include "usbcore.h"
frank26080115 0:bf7b9fba3924 26 #include "hiduser.h"
frank26080115 0:bf7b9fba3924 27
frank26080115 0:bf7b9fba3924 28 #include "demo.h"
frank26080115 0:bf7b9fba3924 29
frank26080115 0:bf7b9fba3924 30
frank26080115 0:bf7b9fba3924 31 uint8_t HID_Protocol;
frank26080115 0:bf7b9fba3924 32 uint8_t HID_IdleTime[HID_REPORT_NUM];
frank26080115 0:bf7b9fba3924 33
frank26080115 0:bf7b9fba3924 34
frank26080115 0:bf7b9fba3924 35 /*
frank26080115 0:bf7b9fba3924 36 * HID Get Report Request Callback
frank26080115 0:bf7b9fba3924 37 * Called automatically on HID Get Report Request
frank26080115 0:bf7b9fba3924 38 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 39 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 40 */
frank26080115 0:bf7b9fba3924 41
frank26080115 0:bf7b9fba3924 42 uint32_t HID_GetReport (void) {
frank26080115 0:bf7b9fba3924 43
frank26080115 0:bf7b9fba3924 44 /* ReportID = SetupPacket.wValue.WB.L; */
frank26080115 0:bf7b9fba3924 45 switch (SetupPacket.wValue.WB.H) {
frank26080115 0:bf7b9fba3924 46 case HID_REPORT_INPUT:
frank26080115 0:bf7b9fba3924 47 GetInReport();
frank26080115 0:bf7b9fba3924 48 EP0Buf[0] = InReport;
frank26080115 0:bf7b9fba3924 49 break;
frank26080115 0:bf7b9fba3924 50 case HID_REPORT_OUTPUT:
frank26080115 0:bf7b9fba3924 51 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 52 case HID_REPORT_FEATURE:
frank26080115 0:bf7b9fba3924 53 /* EP0Buf[] = ...; */
frank26080115 0:bf7b9fba3924 54 /* break; */
frank26080115 0:bf7b9fba3924 55 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 56 }
frank26080115 0:bf7b9fba3924 57 return (TRUE);
frank26080115 0:bf7b9fba3924 58 }
frank26080115 0:bf7b9fba3924 59
frank26080115 0:bf7b9fba3924 60
frank26080115 0:bf7b9fba3924 61 /*
frank26080115 0:bf7b9fba3924 62 * HID Set Report Request Callback
frank26080115 0:bf7b9fba3924 63 * Called automatically on HID Set Report Request
frank26080115 0:bf7b9fba3924 64 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 65 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 66 */
frank26080115 0:bf7b9fba3924 67
frank26080115 0:bf7b9fba3924 68 uint32_t HID_SetReport (void) {
frank26080115 0:bf7b9fba3924 69
frank26080115 0:bf7b9fba3924 70 /* ReportID = SetupPacket.wValue.WB.L; */
frank26080115 0:bf7b9fba3924 71 switch (SetupPacket.wValue.WB.H) {
frank26080115 0:bf7b9fba3924 72 case HID_REPORT_INPUT:
frank26080115 0:bf7b9fba3924 73 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 74 case HID_REPORT_OUTPUT:
frank26080115 0:bf7b9fba3924 75 OutReport = EP0Buf[0];
frank26080115 0:bf7b9fba3924 76 SetOutReport();
frank26080115 0:bf7b9fba3924 77 break;
frank26080115 0:bf7b9fba3924 78 case HID_REPORT_FEATURE:
frank26080115 0:bf7b9fba3924 79 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 80 }
frank26080115 0:bf7b9fba3924 81 return (TRUE);
frank26080115 0:bf7b9fba3924 82 }
frank26080115 0:bf7b9fba3924 83
frank26080115 0:bf7b9fba3924 84
frank26080115 0:bf7b9fba3924 85 /*
frank26080115 0:bf7b9fba3924 86 * HID Get Idle Request Callback
frank26080115 0:bf7b9fba3924 87 * Called automatically on HID Get Idle Request
frank26080115 0:bf7b9fba3924 88 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 89 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 90 */
frank26080115 0:bf7b9fba3924 91
frank26080115 0:bf7b9fba3924 92 uint32_t HID_GetIdle (void) {
frank26080115 0:bf7b9fba3924 93
frank26080115 0:bf7b9fba3924 94 EP0Buf[0] = HID_IdleTime[SetupPacket.wValue.WB.L];
frank26080115 0:bf7b9fba3924 95 return (TRUE);
frank26080115 0:bf7b9fba3924 96 }
frank26080115 0:bf7b9fba3924 97
frank26080115 0:bf7b9fba3924 98
frank26080115 0:bf7b9fba3924 99 /*
frank26080115 0:bf7b9fba3924 100 * HID Set Idle Request Callback
frank26080115 0:bf7b9fba3924 101 * Called automatically on HID Set Idle Request
frank26080115 0:bf7b9fba3924 102 * Parameters: None (global SetupPacket)
frank26080115 0:bf7b9fba3924 103 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 104 */
frank26080115 0:bf7b9fba3924 105
frank26080115 0:bf7b9fba3924 106 uint32_t HID_SetIdle (void) {
frank26080115 0:bf7b9fba3924 107
frank26080115 0:bf7b9fba3924 108 HID_IdleTime[SetupPacket.wValue.WB.L] = SetupPacket.wValue.WB.H;
frank26080115 0:bf7b9fba3924 109
frank26080115 0:bf7b9fba3924 110 /* Idle Handling if needed */
frank26080115 0:bf7b9fba3924 111 /* ... */
frank26080115 0:bf7b9fba3924 112
frank26080115 0:bf7b9fba3924 113 return (TRUE);
frank26080115 0:bf7b9fba3924 114 }
frank26080115 0:bf7b9fba3924 115
frank26080115 0:bf7b9fba3924 116
frank26080115 0:bf7b9fba3924 117 /*
frank26080115 0:bf7b9fba3924 118 * HID Get Protocol Request Callback
frank26080115 0:bf7b9fba3924 119 * Called automatically on HID Get Protocol Request
frank26080115 0:bf7b9fba3924 120 * Parameters: None (global SetupPacket)
frank26080115 0:bf7b9fba3924 121 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 122 */
frank26080115 0:bf7b9fba3924 123
frank26080115 0:bf7b9fba3924 124 uint32_t HID_GetProtocol (void) {
frank26080115 0:bf7b9fba3924 125
frank26080115 0:bf7b9fba3924 126 EP0Buf[0] = HID_Protocol;
frank26080115 0:bf7b9fba3924 127 return (TRUE);
frank26080115 0:bf7b9fba3924 128 }
frank26080115 0:bf7b9fba3924 129
frank26080115 0:bf7b9fba3924 130
frank26080115 0:bf7b9fba3924 131 /*
frank26080115 0:bf7b9fba3924 132 * HID Set Protocol Request Callback
frank26080115 0:bf7b9fba3924 133 * Called automatically on HID Set Protocol Request
frank26080115 0:bf7b9fba3924 134 * Parameters: None (global SetupPacket)
frank26080115 0:bf7b9fba3924 135 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 136 */
frank26080115 0:bf7b9fba3924 137
frank26080115 0:bf7b9fba3924 138 uint32_t HID_SetProtocol (void) {
frank26080115 0:bf7b9fba3924 139
frank26080115 0:bf7b9fba3924 140 HID_Protocol = SetupPacket.wValue.WB.L;
frank26080115 0:bf7b9fba3924 141
frank26080115 0:bf7b9fba3924 142 /* Protocol Handling if needed */
frank26080115 0:bf7b9fba3924 143 /* ... */
frank26080115 0:bf7b9fba3924 144
frank26080115 0:bf7b9fba3924 145 return (TRUE);
frank26080115 0:bf7b9fba3924 146 }