/* * pt-msc : peripheralTest-MassStorageClass * by uratan! 2012.12.30 */ LPC18xx 用の CMSIS (lpc18xx-2012-12-11.zip) に含まれる Examples/USBDEV/Usb_MassStoraga/ を LPC1830-Xplorer に お気軽移植してみました。 I had ported 'Examples/USBDEV/Usb_MassStorage/' (which is from CMSIS lpc18xx-2012-12-11.zip) for LPC1830-Xplorer by corner-cutting. (visit http://LPCware.com/ to find the package) usb0(HS) を使うか usb1(FS) を使うか usb.h で選択します。 You can choice which interface usb0(HS) or usb1(FS) to use in usb.h. usb0 は調子いいけど usb1 はなんか微妙ではあります。 usb0 works very well, but usb1 not so well at my environment... /* * FILES */ 00README.txt --- this file Makefile --- Makefile for make.exe link.awk --- a AWK script to generate linker script LPC1830.h --- register difinitions for mine Startup.S --- CPU start up main.c --- main entry and a interrupt-console common.h --- system shared difinitions common.c --- system shared functions (GPIO, uart) rprintf.c --- simple printf() (from sample of WinARM_20060606.zip) zz-boot_header.exe --- a tool to convert bin for boot-image zz-boot_header.c --- and its source usbdesc.S --- converted from usbdesc.c (others) --- based 'Examples/USBDEV/Usb_MassStorage/' of CMSIS lpc18xx-2012-12-11.zip (line-terminaters are converted to uniform, use GNU diff.exe) w-orig-srcs/ --- see here how collect files from original package (LPC18xx.h --- how big is this !) (pt-msc.elf --- build result (pt-msc.bin --- its binary image boot-pt-msc.bin --- convert pt-msc.bin for uart-boot pt-msc.hex --- hex file image (pt-msc.hex-@1a00.hex --- hex image on addr 0x1A00_0000 for magicFlash Compiler used is gcc-4.7.1(2012-0616) from yagarto You may need sh.exe and rm.exe, seek it from web please. GNU awk を持ってない? これを使いなさい。 Don't you have GNU awk ? use this. /* * speed and power consumption as a drive */ pt-msc-005 @ DELL (ICH10, winXP) (0.16A @ uart-boot) ===================================================== |connec| run | READ(10) |power-con| transfer PHY | tion | on |512x16(8kB)| sumption| rate ======+======+=====+===========+=========+========== | HS | rom | 4.0msec | 0.20A | 2000kB/s usb0 | HS | RAM | 0.9msec | 0.19A | 8889kB/s (HS) +------+-----+-----------+---------+---------- | FShub| rom | 23.5msec | 0.19A | 340kB/s | FShub| RAM | 13.5msec | 0.19A | 593kB/s ------+------+-----+-----------+---------+---------- usb1 |HSport| rom | 23.4msec | 0.18A | 342kB/s (FS) |HSport| RAM | 13.5msec | 0.18A | 593kB/s ===================================================== /* * structure of source files */ Makefile link.awk(link.cmd) +--------------------------------------------------------+ | Startup.S ===> main.c ========> memory.c | | +--------------------+ +--------------------------+ | | LPC1830.h common.h | | mscuser.h | | | common.c rprintf.c | | mscuser.c (SCSI) | | +--------------------+ | DiskImg.c | | +---------------+ +--------------------------+ | | | | usbuser.h usbuser.c (glue funcs) | | lpc18xx_scu.h | | usbdesc.h usbdesc.S | | | lpc18xx_scu.c | | usbcore.h usbcore.c (control pipe) | | | | usbhw.h usbhw.c | | | lpc18xx_cgu.h | +--------------------------+ | | lpc18xx_cgu c | | usbcfg.h / usb.h / msc.h | | +---------------+----------+--------------------------+ | lpc_types.h / LPC18xx.h | | (core_cm3.h core_cmFunc.h core_cmInstr.h)| +--------------------------------------------------------+ /* * execution structure */ USB の処理はすべて割込みハンドラ内で行われるようです。 All processes as USB Mass Storage Device are done in Handler Mode (interrupt context). なので通常タスクとして割り込みのもろもろをチューンする機能を付けました。 So I have added a-console-to-tune-interrupt on Thread Mode (normal context). 割込みに関連する各種設定がどう効くのか遊んでみてください。 Let's play with this console, how misc interrupt related settings will effect. -- uratan@st.rim.or.jp