usb_api.lst
来自「非常全的nrf2401设计资料」· LST 代码 · 共 199 行
LST
199 行
C51 COMPILER V7.50 USB_API 04/09/2009 10:12:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE USB_API
OBJECT MODULE PLACED IN .\build\usb_api.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE usb_api.c LARGE OMF2 OPTIMIZE(9,SPEED) BROWSE INCDIR(..\common;..\..\..\..\
-comp\protocol\wdp\common\;..\..\..\..\comp\protocol\wdp\host\;..\..\..\..\arch\hal\include;..\..\..\..\arch\hal\nrf24lu1
-;..\..\..\..\arch\nrf24lu1;..\common;..\..\..\..\comp\protocol\fap) DEBUG PRINT(.\lst\usb_api.lst) OBJECT(.\build\usb_ap
-i.obj)
line level source
1 /* Copyright (c) 2007 Nordic Semiconductor. All Rights Reserved.
2 *
3 * The information contained herein is confidential property of
4 * Nordic Semiconductor. The use, copying, transfer or disclosure
5 * of such information is prohibited except by express written
6 * agreement with Nordic Semiconductor.
7 */
8
9 /** @file
10 Implementation of USB interface and callback functions.
11
12 This file contains functions that and an application need to set up and use
13 the USB interface. It also contains implementations of the callback functions
14 demanded by hal_usb.
15 */
16
17 /**@{
18 *@ingroup nordic_usb
19 */
20
21 #include <Nordic\reg24lu1.h>
22
23 #include "hal_nrf.h"
24 #include "cklf.h"
25 #include "cpu.h"
26 #include "hal_usb.h"
27 #include "hal_usb_hid.h"
28 #include "usb_api.h"
29 #include "nordic_common.h"
30
31 static hal_usb_dev_req_resp_t device_req_cb(hal_usb_device_req* req, uint8_t** data_ptr, uint16_t* size) r
-eentrant;
32 static void suspend_cb(uint8_t allow_remote_wu) reentrant;
33 static void resume_cb() reentrant;
34 static void reset_cb() reentrant;
35 static uint8_t ep_1_in_cb(uint8_t *adr_ptr, uint8_t* size) reentrant;
36 static uint8_t ep_2_in_cb(uint8_t *adr_ptr, uint8_t* size) reentrant;
37
38 bool ep1_sent, ep2_sent;
39 volatile usb_state_t usb_state;
40
41 void usb_init(void)
42 {
43 1 hal_usb_init(true, device_req_cb, reset_cb, resume_cb, suspend_cb);
44 1
45 1 hal_usb_endpoint_config(0x81, 32, ep_1_in_cb);
46 1 hal_usb_endpoint_config(0x82, 32, ep_2_in_cb);
47 1
48 1 ep1_sent = true;
49 1 ep2_sent = true;
50 1 usb_state = USB_AWAKE;
51 1 }
C51 COMPILER V7.50 USB_API 04/09/2009 10:12:52 PAGE 2
52
53 void usb_wakeup(void)
54 {
55 1 hal_usb_wakeup();
56 1 usb_state = USB_AWAKE;
57 1 }
58
59 usb_state_t usb_get_state()
60 {
61 1 return usb_state;
62 1 }
63
64 void usb_wait_for_configuration(void)
65 {
66 1 volatile hal_usb_state_t usb_hal_state;
67 1 do
68 1 {
69 2 usb_hal_state = hal_usb_get_state();
70 2 }
71 1 while(usb_hal_state != CONFIGURED);
72 1 }
73
74 void usb_send_packet(uint8_t* in_data, uint8_t ep_num, uint8_t size)
75 {
76 1 if(ep_num == USB_EP_MOUSE)
77 1 {
78 2 while(!ep1_sent)
79 2 ;
80 2 ep1_sent = false;
81 2 }
82 1 else
83 1 if(ep_num == USB_EP_KEYBOARD)
84 1 {
85 2 while(!ep2_sent)
86 2 ;
87 2 ep2_sent = false;
88 2 }
89 1
90 1 hal_usb_send_data(0x80 | ep_num, in_data, size);
91 1 }
92
93 static hal_usb_dev_req_resp_t device_req_cb(hal_usb_device_req* req, uint8_t** data_ptr, uint16_t* size) r
-eentrant
94 {
95 1 hal_usb_dev_req_resp_t retval;
96 1
97 1 if( hal_usb_hid_device_req_proc(req, data_ptr, size, &retval) == true )
98 1 {
99 2 // The request was processed with the result stored in the retval variable
100 2 return retval;
101 2 }
102 1 else
103 1 {
104 2 // The request was *not* processed by the HID subsystem
105 2 return STALL;
106 2 }
107 1
108 1 return STALL;
109 1 }
110
111 static void suspend_cb(uint8_t allow_remote_wu) reentrant
112 {
C51 COMPILER V7.50 USB_API 04/09/2009 10:12:52 PAGE 3
113 1 USBSLP = 1; // Disable USB clock (auto clear)
114 1
115 1 if (allow_remote_wu == 1)
116 1 {
117 2 // Enable wake-up on USB and USBWU (bit3:0=1010)
118 2 // Enable MCU_WU (bit5:4=10 ) on RTC
119 2 WUCONF = (BIT_5 | BIT_3 | BIT_1);
120 2 usb_state = USB_REM_WU_ENABLE;
121 2 }
122 1 else
123 1 {
124 2 // Enable wake-up on USB and USBWU (bit3:0=1010)
125 2 WUCONF = (BIT_3 | BIT_1);
126 2 usb_state = USB_REM_WU_DISABLE;
127 2 }
128 1 }
129
130 static void resume_cb() reentrant
131 {
132 1 ep1_sent = true;
133 1 ep2_sent = true;
134 1 usb_state = USB_AWAKE;
135 1 }
136
137 static void reset_cb() reentrant
138 {
139 1 ep1_sent = true;
140 1 ep2_sent = true;
141 1 usb_state = USB_AWAKE;
142 1 }
143
144 static uint8_t ep_1_in_cb(uint8_t *adr_ptr, uint8_t* size) reentrant
145 {
146 1 ep1_sent = true;
147 1 return 0x60; // NAK
148 1 }
*** WARNING C280 IN LINE 144 OF USB_API.C: 'adr_ptr': unreferenced local variable
*** WARNING C280 IN LINE 144 OF USB_API.C: 'size': unreferenced local variable
149
150 static uint8_t ep_2_in_cb(uint8_t *adr_ptr, uint8_t* size) reentrant
151 {
152 1 ep2_sent = true;
153 1 return 0x60; // NAK
154 1 }
*** WARNING C280 IN LINE 150 OF USB_API.C: 'adr_ptr': unreferenced local variable
*** WARNING C280 IN LINE 150 OF USB_API.C: 'size': unreferenced local variable
155
156 /** @} */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 380 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 3 6
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
C51 COMPILER V7.50 USB_API 04/09/2009 10:12:52 PAGE 4
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 4 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?