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: ADCUSER.C
frank26080115 0:bf7b9fba3924 5 * Purpose: Audio Device Class 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) 2009 Keil - An ARM Company. All rights reserved.
frank26080115 0:bf7b9fba3924 17 *---------------------------------------------------------------------------*/
frank26080115 0:bf7b9fba3924 18
frank26080115 0:bf7b9fba3924 19 #include "lpc_types.h"
frank26080115 0:bf7b9fba3924 20
frank26080115 0:bf7b9fba3924 21 #include "usb.h"
frank26080115 0:bf7b9fba3924 22 #include "audio.h"
frank26080115 0:bf7b9fba3924 23 #include "usbcfg.h"
frank26080115 0:bf7b9fba3924 24 #include "usbcore.h"
frank26080115 0:bf7b9fba3924 25 #include "adcuser.h"
frank26080115 0:bf7b9fba3924 26
frank26080115 0:bf7b9fba3924 27 #include "usbaudio.h"
frank26080115 0:bf7b9fba3924 28
frank26080115 0:bf7b9fba3924 29 uint16_t VolCur = 0x0100; /* Volume Current Value */
frank26080115 0:bf7b9fba3924 30 const uint16_t VolMin = 0x0000; /* Volume Minimum Value */
frank26080115 0:bf7b9fba3924 31 const uint16_t VolMax = 0x0100; /* Volume Maximum Value */
frank26080115 0:bf7b9fba3924 32 const uint16_t VolRes = 0x0004; /* Volume Resolution */
frank26080115 0:bf7b9fba3924 33
frank26080115 0:bf7b9fba3924 34 /*
frank26080115 0:bf7b9fba3924 35 * Audio Device Class Interface Get Request Callback
frank26080115 0:bf7b9fba3924 36 * Called automatically on ADC Interface Get Request
frank26080115 0:bf7b9fba3924 37 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 38 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 39 */
frank26080115 0:bf7b9fba3924 40
frank26080115 0:bf7b9fba3924 41 uint32_t ADC_IF_GetRequest (void) {
frank26080115 0:bf7b9fba3924 42
frank26080115 0:bf7b9fba3924 43 /*
frank26080115 0:bf7b9fba3924 44 Interface = SetupPacket.wIndex.WB.L;
frank26080115 0:bf7b9fba3924 45 EntityID = SetupPacket.wIndex.WB.H;
frank26080115 0:bf7b9fba3924 46 Request = SetupPacket.bRequest;
frank26080115 0:bf7b9fba3924 47 Value = SetupPacket.wValue.W;
frank26080115 0:bf7b9fba3924 48 ...
frank26080115 0:bf7b9fba3924 49 */
frank26080115 0:bf7b9fba3924 50
frank26080115 0:bf7b9fba3924 51 if (SetupPacket.wIndex.W == 0x0200) {
frank26080115 0:bf7b9fba3924 52 /* Feature Unit: Interface = 0, ID = 2 */
frank26080115 0:bf7b9fba3924 53 if (SetupPacket.wValue.WB.L == 0) {
frank26080115 0:bf7b9fba3924 54 /* Master Channel */
frank26080115 0:bf7b9fba3924 55 switch (SetupPacket.wValue.WB.H) {
frank26080115 0:bf7b9fba3924 56 case AUDIO_MUTE_CONTROL:
frank26080115 0:bf7b9fba3924 57 switch (SetupPacket.bRequest) {
frank26080115 0:bf7b9fba3924 58 case AUDIO_REQUEST_GET_CUR:
frank26080115 0:bf7b9fba3924 59 EP0Buf[0] = Mute;
frank26080115 0:bf7b9fba3924 60 return (TRUE);
frank26080115 0:bf7b9fba3924 61 }
frank26080115 0:bf7b9fba3924 62 break;
frank26080115 0:bf7b9fba3924 63 case AUDIO_VOLUME_CONTROL:
frank26080115 0:bf7b9fba3924 64 switch (SetupPacket.bRequest) {
frank26080115 0:bf7b9fba3924 65 case AUDIO_REQUEST_GET_CUR:
frank26080115 0:bf7b9fba3924 66 *((__packed uint16_t *)EP0Buf) = VolCur;
frank26080115 0:bf7b9fba3924 67 return (TRUE);
frank26080115 0:bf7b9fba3924 68 case AUDIO_REQUEST_GET_MIN:
frank26080115 0:bf7b9fba3924 69 *((__packed uint16_t *)EP0Buf) = VolMin;
frank26080115 0:bf7b9fba3924 70 return (TRUE);
frank26080115 0:bf7b9fba3924 71 case AUDIO_REQUEST_GET_MAX:
frank26080115 0:bf7b9fba3924 72 *((__packed uint16_t *)EP0Buf) = VolMax;
frank26080115 0:bf7b9fba3924 73 return (TRUE);
frank26080115 0:bf7b9fba3924 74 case AUDIO_REQUEST_GET_RES:
frank26080115 0:bf7b9fba3924 75 *((__packed uint16_t *)EP0Buf) = VolRes;
frank26080115 0:bf7b9fba3924 76 return (TRUE);
frank26080115 0:bf7b9fba3924 77 }
frank26080115 0:bf7b9fba3924 78 break;
frank26080115 0:bf7b9fba3924 79 }
frank26080115 0:bf7b9fba3924 80 }
frank26080115 0:bf7b9fba3924 81 }
frank26080115 0:bf7b9fba3924 82 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 83 }
frank26080115 0:bf7b9fba3924 84
frank26080115 0:bf7b9fba3924 85
frank26080115 0:bf7b9fba3924 86 /*
frank26080115 0:bf7b9fba3924 87 * Audio Device Class Interface Set Request Callback
frank26080115 0:bf7b9fba3924 88 * Called automatically on ADC Interface Set Request
frank26080115 0:bf7b9fba3924 89 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 90 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 91 */
frank26080115 0:bf7b9fba3924 92
frank26080115 0:bf7b9fba3924 93 uint32_t ADC_IF_SetRequest (void) {
frank26080115 0:bf7b9fba3924 94
frank26080115 0:bf7b9fba3924 95 /*
frank26080115 0:bf7b9fba3924 96 Interface = SetupPacket.wIndex.WB.L;
frank26080115 0:bf7b9fba3924 97 EntityID = SetupPacket.wIndex.WB.H;
frank26080115 0:bf7b9fba3924 98 Request = SetupPacket.bRequest;
frank26080115 0:bf7b9fba3924 99 Value = SetupPacket.wValue.W;
frank26080115 0:bf7b9fba3924 100 ...
frank26080115 0:bf7b9fba3924 101 */
frank26080115 0:bf7b9fba3924 102
frank26080115 0:bf7b9fba3924 103 if (SetupPacket.wIndex.W == 0x0200) {
frank26080115 0:bf7b9fba3924 104 /* Feature Unit: Interface = 0, ID = 2 */
frank26080115 0:bf7b9fba3924 105 if (SetupPacket.wValue.WB.L == 0) {
frank26080115 0:bf7b9fba3924 106 /* Master Channel */
frank26080115 0:bf7b9fba3924 107 switch (SetupPacket.wValue.WB.H) {
frank26080115 0:bf7b9fba3924 108 case AUDIO_MUTE_CONTROL:
frank26080115 0:bf7b9fba3924 109 switch (SetupPacket.bRequest) {
frank26080115 0:bf7b9fba3924 110 case AUDIO_REQUEST_SET_CUR:
frank26080115 0:bf7b9fba3924 111 Mute = EP0Buf[0];
frank26080115 0:bf7b9fba3924 112 return (TRUE);
frank26080115 0:bf7b9fba3924 113 }
frank26080115 0:bf7b9fba3924 114 break;
frank26080115 0:bf7b9fba3924 115 case AUDIO_VOLUME_CONTROL:
frank26080115 0:bf7b9fba3924 116 switch (SetupPacket.bRequest) {
frank26080115 0:bf7b9fba3924 117 case AUDIO_REQUEST_SET_CUR:
frank26080115 0:bf7b9fba3924 118 VolCur = *((__packed uint16_t *)EP0Buf);
frank26080115 0:bf7b9fba3924 119 return (TRUE);
frank26080115 0:bf7b9fba3924 120 }
frank26080115 0:bf7b9fba3924 121 break;
frank26080115 0:bf7b9fba3924 122 }
frank26080115 0:bf7b9fba3924 123 }
frank26080115 0:bf7b9fba3924 124 }
frank26080115 0:bf7b9fba3924 125 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 126 }
frank26080115 0:bf7b9fba3924 127
frank26080115 0:bf7b9fba3924 128
frank26080115 0:bf7b9fba3924 129 /*
frank26080115 0:bf7b9fba3924 130 * Audio Device Class EndPoint Get Request Callback
frank26080115 0:bf7b9fba3924 131 * Called automatically on ADC EndPoint Get Request
frank26080115 0:bf7b9fba3924 132 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 133 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 134 */
frank26080115 0:bf7b9fba3924 135
frank26080115 0:bf7b9fba3924 136 uint32_t ADC_EP_GetRequest (void) {
frank26080115 0:bf7b9fba3924 137
frank26080115 0:bf7b9fba3924 138 /*
frank26080115 0:bf7b9fba3924 139 EndPoint = SetupPacket.wIndex.WB.L;
frank26080115 0:bf7b9fba3924 140 Request = SetupPacket.bRequest;
frank26080115 0:bf7b9fba3924 141 Value = SetupPacket.wValue.W;
frank26080115 0:bf7b9fba3924 142 ...
frank26080115 0:bf7b9fba3924 143 */
frank26080115 0:bf7b9fba3924 144 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 145 }
frank26080115 0:bf7b9fba3924 146
frank26080115 0:bf7b9fba3924 147
frank26080115 0:bf7b9fba3924 148 /*
frank26080115 0:bf7b9fba3924 149 * Audio Device Class EndPoint Set Request Callback
frank26080115 0:bf7b9fba3924 150 * Called automatically on ADC EndPoint Set Request
frank26080115 0:bf7b9fba3924 151 * Parameters: None (global SetupPacket and EP0Buf)
frank26080115 0:bf7b9fba3924 152 * Return Value: TRUE - Success, FALSE - Error
frank26080115 0:bf7b9fba3924 153 */
frank26080115 0:bf7b9fba3924 154
frank26080115 0:bf7b9fba3924 155 uint32_t ADC_EP_SetRequest (void) {
frank26080115 0:bf7b9fba3924 156
frank26080115 0:bf7b9fba3924 157 /*
frank26080115 0:bf7b9fba3924 158 EndPoint = SetupPacket.wIndex.WB.L;
frank26080115 0:bf7b9fba3924 159 Request = SetupPacket.bRequest;
frank26080115 0:bf7b9fba3924 160 Value = SetupPacket.wValue.W;
frank26080115 0:bf7b9fba3924 161 ...
frank26080115 0:bf7b9fba3924 162 */
frank26080115 0:bf7b9fba3924 163 return (FALSE); /* Not Supported */
frank26080115 0:bf7b9fba3924 164 }