1
1
2
- M-Stack: Free USB Stack for PIC 16F, 18F, 24F, and 32MX Microcontrollers
3
- ==========================================================================
2
+ M-Stack: Free USB Stack for PIC 16F, 18F, 24F, and 32MX Microcontrollers
3
+ ==========================================================================
4
4
5
5
About
6
6
======
@@ -40,7 +40,7 @@ creating a USB device.
40
40
Home
41
41
-----
42
42
The master web page for this project can be found at:
43
- http://www.signal11.us/oss/m-stack/
43
+ http://www.signal11.us/oss/m-stack/
44
44
45
45
License
46
46
========
@@ -86,10 +86,12 @@ Getting Started
86
86
Downloading the Software
87
87
-------------------------
88
88
M-Stack's source code is currently hosted on Github at:
89
- https://github.com/signal11/m-stack
89
+ https://github.com/signal11/m-stack
90
90
91
91
To get the latest version, run:
92
- git clone https://github.com/signal11/m-stack.git
92
+ ```
93
+ git clone https://github.com/signal11/m-stack.git
94
+ ```
93
95
94
96
Documentation
95
97
--------------
@@ -131,48 +133,53 @@ The USB stack is supported by the following software:
131
133
* Microchip MPLAB X IDE
132
134
133
135
Note that the C18 compiler is not currently supported. There are some
134
- #defines in the code for C18 because this project came from code that was
136
+ ` #defines ` in the code for C18 because this project came from code that was
135
137
originally done on a PIC18F4550 using C18. It has not yet been determined
136
138
whether a port to C18 will be made, as C18 has been deprecated by Microchip.
137
139
Further, C18 has some properties which make a port somewhat more difficult
138
140
than other compilers.
139
141
140
142
Building the Unit Test Firmware
141
143
--------------------------------
142
- Open the MPLAB.X project in apps/unit_test in the MPLAB X IDE. Select a
144
+ Open the MPLAB.X project in ` apps/unit_test ` in the MPLAB X IDE. Select a
143
145
configuration and build. Make sure a supported compiler is installed.
144
146
145
147
Building the Test Software
146
148
---------------------------
147
- The host_test/ directory contains Libusb-based test programs for testing the
149
+ The ` host_test/ ` directory contains Libusb-based test programs for testing the
148
150
functionality of a USB device running the unit test firmware. Currently the
149
151
Libusb test software has only been tested Linux, but since its only
150
152
dependency is the cross-platform Libusb library, it is easily portable to
151
153
other operating systems on which Libusb is supported.
152
154
153
- With Libusb installed, run "make" in the host_test/ directory to build the
155
+ With Libusb installed, run "make" in the ` host_test/ ` directory to build the
154
156
test software.
155
157
156
158
Running the Test Software
157
159
--------------------------
158
- ./control_transfer_in [number_of_bytes]
159
- * Execute an IN control transfer requesting number_of_bytes bytes
160
- from the device. The data returned will be printed. The unit test
161
- firmware supports control transfers up to 512 bytes.
162
- ./control_transfer_out [number_of_bytes]
163
- * Execute an OUT control transfer sending number_of_bytes bytes
164
- to the device. A message will be printed. The unit test
165
- firmware supports control transfers up to 512 bytes.
166
- ./test [number_of_bytes]
167
- * Send and then ask for number_of_bytes bytes on EP 1 OUT and EP 1
168
- IN, respectively. The data is printed out. The unit test firmware
169
- will support up to 128-bytes of this kind of operation.
170
- ./feature <clear>
171
- * Set the Endpoint halt feature on Endpoint 1 IN. Passing the
172
- "clear" parameter clears endpoint halt.
160
+ ` ./control_transfer_in [number_of_bytes] `
161
+ * Execute an IN control transfer requesting ` number_of_bytes ` bytes
162
+ from the device. The data returned will be printed. The unit test
163
+ firmware supports control transfers up to 512 bytes.
164
+
165
+ ` ./control_transfer_out [number_of_bytes] `
166
+ * Execute an OUT control transfer sending ` number_of_bytes ` bytes
167
+ to the device. A message will be printed. The unit test
168
+ firmware supports control transfers up to 512 bytes.
169
+
170
+ ` ./test [number_of_bytes] `
171
+ * Send and then ask for ` number_of_bytes ` bytes on EP 1 OUT and EP 1
172
+ IN, respectively. The data is printed out. The unit test firmware
173
+ will support up to 128-bytes of this kind of operation.
174
+
175
+ ` ./feature <clear> `
176
+ * Set the Endpoint halt feature on Endpoint 1 IN. Passing the
177
+ "clear" parameter clears endpoint halt.
173
178
174
179
Source Tree Structure
175
180
----------------------
181
+
182
+ ```
176
183
(root)
177
184
|
178
185
+- usb/ <- USB stack software
@@ -189,9 +196,12 @@ Source Tree Structure
189
196
+- msc_test/ <- Mass Storage Class example
190
197
+- bootloader/ <- USB bootloader firmware and software
191
198
+- host_test/ <- Software applications to run from a PC Host
199
+ ```
192
200
193
201
USB Stack Source Files
194
202
-----------------------
203
+
204
+ ```
195
205
usb/src/usb.c - The implementation of the USB stack.
196
206
usb/src/usb_hal.h - Hardware abstraction layer (HAL) containing
197
207
differences specific to each platform.
@@ -204,9 +214,12 @@ usb/include/usb_ch9.h - Enums and structs from Chapter 9 of the USB
204
214
file from their usb_descriptors.c and from any file
205
215
which deals with control transfers.
206
216
usb/src/usb_hid.h - Enums, structs, and callbacks for the HID class
217
+ ```
207
218
208
219
Application Source Files (Unit Test Example)
209
220
---------------------------------------------
221
+
222
+ ```
210
223
apps/unit_test/main.c - Main program file
211
224
apps/unit_test/usb_config.h - USB stack configuration file. The USB
212
225
stack will include this file and use it
@@ -219,29 +232,32 @@ apps/unit_test/usb_descriptors.c - The application's descriptors. The
219
232
application's needs.
220
233
apps/hid_mouse/* - HID mouse example (same files as above)
221
234
235
+ ```
236
+
222
237
Making Your Own Project
223
238
------------------------
224
239
The easiest way to create a project using M-Stack is to simply copy one of
225
240
the examples and modify it accordingly. Sometimes it's better though to do
226
241
things the hard way in order to understand better.
227
242
228
243
To create a new project, perform the following steps:
244
+
229
245
1 . Create a new project with MPLAB X.
230
- 2. Copy and add the usb/ directory as a subdirectory of your project.
231
- 3. Add the usb/include directory to the include path of your project. (Note
246
+ 2 . Copy and add the ` usb/ ` directory as a subdirectory of your project.
247
+ 3 . Add the ` usb/include ` directory to the include path of your project. (Note
232
248
that the include paths are relative to the Makefile. If you set up your
233
- project like the examples, with an MPLAB.X/ subdirectory, you'll need to
234
- add an additional ../ to the beginning of the include path).
235
- 4. Add . to the include path of your project (same note from #3 applies).
236
- 5. Copy a usb_config.h and a usb_descriptors.c file from one of the example
249
+ project like the examples, with an ` MPLAB.X/ ` subdirectory, you'll need to
250
+ add an additional ` ../ ` to the beginning of the include path).
251
+ 4 . Add ` . ` to the include path of your project (same note from #3 applies).
252
+ 5 . Copy a` usb_config.h ` and a ` usb_descriptors.c ` file from one of the example
237
253
projects into your main project directory.
238
- 6. Modify usb_config.h to match your desired device configuration.
239
- 7. Modify usb_descriptors.c to match your device configuration.
254
+ 6 . Modify ` usb_config.h ` to match your desired device configuration.
255
+ 7 . Modify ` usb_descriptors.c ` to match your device configuration.
240
256
8 . If you're using a PIC16F/18F platform, add an interrupt handler similar
241
257
to one of the examples.
242
- 9. Reference main.c in one of the examples, and the Doxygen-generated
258
+ 9 . Reference ` main.c ` in one of the examples, and the Doxygen-generated
243
259
documentation to add your application logic.
244
- 10. Make sure to configure the MCU for your board (__CONFIG registers, etc.).
260
+ 10 . Make sure to configure the MCU for your board (` __CONFIG ` registers, etc.).
245
261
246
262
247
263
Limitations
@@ -257,9 +273,10 @@ Future Plans
257
273
=============
258
274
259
275
The following features are on the horizon:
260
- * Support for more specific MCUs
261
- * dsPIC33E and PIC24E support
262
- * Isochronous transfers
276
+
277
+ * Support for more specific MCUs
278
+ * dsPIC33E and PIC24E support
279
+ * Isochronous transfers
263
280
264
281
265
282
References
@@ -283,11 +300,11 @@ Contacts
283
300
Please contact Signal 11 Software directly for support or consulting help.
284
301
Sometime in the near future there will be a mailing list.
285
302
286
- Alan Ott
287
- Signal 11 Software
288
-
289
- http://www.signal11.us
290
- +1 407-222-6975
303
+ Alan Ott
304
+ Signal 11 Software
305
+
306
+ http://www.signal11.us
307
+ +1 407-222-6975
291
308
292
- 2013-04-26
309
+ 2013-04-26
293
310
2013-05-20
0 commit comments