瀏覽代碼

Moved CMSIS and other LPC1768 dependencies

Fixes Arduino IDE builds for 8-bit AVR,
misc: Adafruit NeoPixel currently incompatible with Teensy 3.5-6, blacklisted
Christopher Pepper 6 年之前
父節點
當前提交
4183a249b6
共有 98 個檔案被更改,包括 18 行新增30240 行删除
  1. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/Re-ARM/LPC1768.ld
  2. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/Re-ARM/startup_LPC17xx.S
  3. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/Re-ARM/system_LPC17xx.c
  4. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/debug_frmwrk.c
  5. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_adc.c
  6. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_can.c
  7. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_clkpwr.c
  8. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_dac.c
  9. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_emac.c
  10. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_exti.c
  11. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_gpdma.c
  12. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_gpio.c
  13. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_i2c.c
  14. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_i2s.c
  15. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_iap.c
  16. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_libcfg_default.c
  17. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_mcpwm.c
  18. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c
  19. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_pinsel.c
  20. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_pwm.c
  21. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_qei.c
  22. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_rit.c
  23. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_rtc.c
  24. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_spi.c
  25. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_ssp.c
  26. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_systick.c
  27. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_timer.c
  28. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_uart.c
  29. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_wdt.c
  30. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/LPC17xx.h
  31. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/arm_common_tables.h
  32. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/arm_math.h
  33. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/core_cm3.h
  34. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/core_cmFunc.h
  35. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/core_cmInstr.h
  36. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/debug_frmwrk.h
  37. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_adc.h
  38. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_can.h
  39. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_clkpwr.h
  40. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_dac.h
  41. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_emac.h
  42. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_exti.h
  43. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_gpdma.h
  44. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_gpio.h
  45. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_i2c.h
  46. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_i2s.h
  47. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_iap.h
  48. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_libcfg_default.h
  49. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_mcpwm.h
  50. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_nvic.h
  51. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_pinsel.h
  52. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_pwm.h
  53. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_qei.h
  54. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_rit.h
  55. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_rtc.h
  56. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_spi.h
  57. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_ssp.h
  58. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_systick.h
  59. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_timer.h
  60. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_uart.h
  61. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_wdt.h
  62. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/lpc_types.h
  63. 0
    0
      Marlin/frameworks/CMSIS/LPC1768/include/system_LPC17xx.h
  64. 0
    1143
      Marlin/src/HAL/HAL_LPC1768/chanfs/LPC176x.h
  65. 0
    109
      Marlin/src/HAL/HAL_LPC1768/chanfs/diskio.h
  66. 0
    6204
      Marlin/src/HAL/HAL_LPC1768/chanfs/ff.c
  67. 0
    364
      Marlin/src/HAL/HAL_LPC1768/chanfs/ff.h
  68. 0
    269
      Marlin/src/HAL/HAL_LPC1768/chanfs/ffconf.h
  69. 0
    15566
      Marlin/src/HAL/HAL_LPC1768/chanfs/ffunicode.c
  70. 0
    38
      Marlin/src/HAL/HAL_LPC1768/chanfs/integer.h
  71. 0
    745
      Marlin/src/HAL/HAL_LPC1768/chanfs/mmc_ssp.c
  72. 0
    91
      Marlin/src/HAL/HAL_LPC1768/chanfs/rtc176x.c
  73. 0
    22
      Marlin/src/HAL/HAL_LPC1768/chanfs/rtc176x.h
  74. 0
    180
      Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/LPC1768.ld.old
  75. 0
    223
      Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/startup_LPC17xx.S.old
  76. 0
    584
      Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/system_LPC17xx.c.old
  77. 4
    4
      Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py
  78. 9
    9
      Marlin/src/HAL/HAL_LPC1768/main.cpp
  79. 2
    1
      Marlin/src/HAL/HAL_LPC1768/persistent_store.cpp
  80. 0
    36
      Marlin/src/HAL/HAL_LPC1768/usb/Re-ARM_usb_driver.inf
  81. 0
    254
      Marlin/src/HAL/HAL_LPC1768/usb/cdc.h
  82. 0
    258
      Marlin/src/HAL/HAL_LPC1768/usb/cdcuser.cpp
  83. 0
    62
      Marlin/src/HAL/HAL_LPC1768/usb/cdcuser.h
  84. 0
    116
      Marlin/src/HAL/HAL_LPC1768/usb/msc.h
  85. 0
    716
      Marlin/src/HAL/HAL_LPC1768/usb/mscuser.cpp
  86. 0
    69
      Marlin/src/HAL/HAL_LPC1768/usb/mscuser.h
  87. 0
    353
      Marlin/src/HAL/HAL_LPC1768/usb/usb.h
  88. 0
    181
      Marlin/src/HAL/HAL_LPC1768/usb/usbcfg.h
  89. 0
    815
      Marlin/src/HAL/HAL_LPC1768/usb/usbcore.cpp
  90. 0
    52
      Marlin/src/HAL/HAL_LPC1768/usb/usbcore.h
  91. 0
    257
      Marlin/src/HAL/HAL_LPC1768/usb/usbdesc.cpp
  92. 0
    35
      Marlin/src/HAL/HAL_LPC1768/usb/usbdesc.h
  93. 0
    811
      Marlin/src/HAL/HAL_LPC1768/usb/usbhw.cpp
  94. 0
    114
      Marlin/src/HAL/HAL_LPC1768/usb/usbhw.h
  95. 0
    130
      Marlin/src/HAL/HAL_LPC1768/usb/usbreg.h
  96. 0
    353
      Marlin/src/HAL/HAL_LPC1768/usb/usbuser.cpp
  97. 0
    74
      Marlin/src/HAL/HAL_LPC1768/usb/usbuser.h
  98. 3
    2
      platformio.ini

Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/LPC1768.ld → Marlin/frameworks/CMSIS/LPC1768/Re-ARM/LPC1768.ld 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/startup_LPC17xx.S → Marlin/frameworks/CMSIS/LPC1768/Re-ARM/startup_LPC17xx.S 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/system_LPC17xx.c → Marlin/frameworks/CMSIS/LPC1768/Re-ARM/system_LPC17xx.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/debug_frmwrk.c → Marlin/frameworks/CMSIS/LPC1768/driver/debug_frmwrk.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_adc.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_adc.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_can.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_can.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_clkpwr.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_clkpwr.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_dac.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_dac.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_emac.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_emac.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_exti.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_exti.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_gpdma.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_gpdma.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_gpio.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_gpio.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_i2c.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_i2c.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_i2s.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_i2s.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_iap.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_iap.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_libcfg_default.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_libcfg_default.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_mcpwm.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_mcpwm.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_nvic.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_pinsel.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_pinsel.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_pwm.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_pwm.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_qei.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_qei.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_rit.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_rit.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_rtc.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_rtc.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_spi.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_spi.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_ssp.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_ssp.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_systick.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_systick.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_timer.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_timer.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_uart.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_uart.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/source/lpc17xx_wdt.c → Marlin/frameworks/CMSIS/LPC1768/driver/lpc17xx_wdt.c 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Include/LPC17xx.h → Marlin/frameworks/CMSIS/LPC1768/include/LPC17xx.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include/arm_common_tables.h → Marlin/frameworks/CMSIS/LPC1768/include/arm_common_tables.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include/arm_math.h → Marlin/frameworks/CMSIS/LPC1768/include/arm_math.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include/core_cm3.h → Marlin/frameworks/CMSIS/LPC1768/include/core_cm3.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include/core_cmFunc.h → Marlin/frameworks/CMSIS/LPC1768/include/core_cmFunc.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include/core_cmInstr.h → Marlin/frameworks/CMSIS/LPC1768/include/core_cmInstr.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/debug_frmwrk.h → Marlin/frameworks/CMSIS/LPC1768/include/debug_frmwrk.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_adc.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_adc.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_can.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_can.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_clkpwr.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_clkpwr.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_dac.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_dac.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_emac.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_emac.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_exti.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_exti.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_gpdma.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_gpdma.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_gpio.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_gpio.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_i2c.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_i2c.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_i2s.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_i2s.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_iap.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_iap.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_libcfg_default.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_libcfg_default.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_mcpwm.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_mcpwm.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_nvic.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_nvic.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_pinsel.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_pinsel.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_pwm.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_pwm.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_qei.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_qei.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_rit.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_rit.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_rtc.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_rtc.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_spi.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_spi.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_ssp.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_ssp.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_systick.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_systick.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_timer.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_timer.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_uart.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_uart.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc17xx_wdt.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc17xx_wdt.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include/lpc_types.h → Marlin/frameworks/CMSIS/LPC1768/include/lpc_types.h 查看文件


Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Include/system_LPC17xx.h → Marlin/frameworks/CMSIS/LPC1768/include/system_LPC17xx.h 查看文件


+ 0
- 1143
Marlin/src/HAL/HAL_LPC1768/chanfs/LPC176x.h
文件差異過大導致無法顯示
查看文件


+ 0
- 109
Marlin/src/HAL/HAL_LPC1768/chanfs/diskio.h 查看文件

@@ -1,109 +0,0 @@
1
-/*-----------------------------------------------------------------------
2
-/  Low level disk interface modlue include file   (C)ChaN, 2015
3
-/-----------------------------------------------------------------------*/
4
-
5
-#ifndef _DISKIO_DEFINED
6
-#define _DISKIO_DEFINED
7
-
8
-#ifdef __cplusplus
9
-extern "C" {
10
-#endif
11
-
12
-#define _DISKIO_WRITE	1	/* 1: Enable disk_write function */
13
-#define _DISKIO_IOCTL	1	/* 1: Enable disk_ioctl fucntion */
14
-#define _DISKIO_ISDIO	0	/* 1: Enable iSDIO control fucntion */
15
-
16
-#include "integer.h"
17
-
18
-
19
-/* Status of Disk Functions */
20
-typedef BYTE	DSTATUS;
21
-
22
-/* Results of Disk Functions */
23
-typedef enum {
24
-	RES_OK = 0,		/* 0: Successful */
25
-	RES_ERROR,		/* 1: R/W Error */
26
-	RES_WRPRT,		/* 2: Write Protected */
27
-	RES_NOTRDY,		/* 3: Not Ready */
28
-	RES_PARERR		/* 4: Invalid Parameter */
29
-} DRESULT;
30
-
31
-
32
-#if	_DISKIO_ISDIO
33
-/* Command structure for iSDIO ioctl command */
34
-typedef struct {
35
-	BYTE	func;	/* Function number: 0..7 */
36
-	WORD	ndata;	/* Number of bytes to transfer: 1..512, or mask + data */
37
-	DWORD	addr;	/* Register address: 0..0x1FFFF */
38
-	void*	data;	/* Pointer to the data (to be written | read buffer) */
39
-} SDIO_CMD;
40
-#endif
41
-
42
-
43
-/*---------------------------------------*/
44
-/* Prototypes for disk control functions */
45
-
46
-
47
-DSTATUS disk_initialize (BYTE pdrv);
48
-DSTATUS disk_status (BYTE pdrv);
49
-DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
50
-#if	_DISKIO_WRITE
51
-DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
52
-#endif
53
-#if	_DISKIO_IOCTL
54
-DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
55
-#endif
56
-
57
-
58
-/* Disk Status Bits (DSTATUS) */
59
-#define STA_NOINIT		0x01	/* Drive not initialized */
60
-#define STA_NODISK		0x02	/* No medium in the drive */
61
-#define STA_PROTECT		0x04	/* Write protected */
62
-
63
-
64
-/* Command code for disk_ioctrl fucntion */
65
-
66
-/* Generic command (Used by FatFs) */
67
-#define CTRL_SYNC			0	/* Complete pending write process (needed at _FS_READONLY == 0) */
68
-#define GET_SECTOR_COUNT	1	/* Get media size (needed at _USE_MKFS == 1) */
69
-#define GET_SECTOR_SIZE		2	/* Get sector size (needed at _MAX_SS != _MIN_SS) */
70
-#define GET_BLOCK_SIZE		3	/* Get erase block size (needed at _USE_MKFS == 1) */
71
-#define CTRL_TRIM			4	/* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
72
-
73
-/* Generic command (Not used by FatFs) */
74
-#define CTRL_FORMAT			5	/* Create physical format on the media */
75
-#define CTRL_POWER_IDLE		6	/* Put the device idle state */
76
-#define CTRL_POWER_OFF		7	/* Put the device off state */
77
-#define CTRL_LOCK			8	/* Lock media removal */
78
-#define CTRL_UNLOCK			9	/* Unlock media removal */
79
-#define CTRL_EJECT			10	/* Eject media */
80
-
81
-/* MMC/SDC specific ioctl command (Not used by FatFs) */
82
-#define MMC_GET_TYPE		50	/* Get card type */
83
-#define MMC_GET_CSD			51	/* Get CSD */
84
-#define MMC_GET_CID			52	/* Get CID */
85
-#define MMC_GET_OCR			53	/* Get OCR */
86
-#define MMC_GET_SDSTAT		54	/* Get SD status */
87
-#define ISDIO_READ			55	/* Read data form SD iSDIO register */
88
-#define ISDIO_WRITE			56	/* Write data to SD iSDIO register */
89
-#define ISDIO_MRITE			57	/* Masked write data to SD iSDIO register */
90
-
91
-/* ATA/CF specific ioctl command (Not used by FatFs) */
92
-#define ATA_GET_REV			60	/* Get F/W revision */
93
-#define ATA_GET_MODEL		61	/* Get model name */
94
-#define ATA_GET_SN			62	/* Get serial number */
95
-
96
-
97
-/* MMC card type flags (MMC_GET_TYPE) */
98
-#define CT_MMC		0x01		/* MMC ver 3 */
99
-#define CT_SD1		0x02		/* SD ver 1 */
100
-#define CT_SD2		0x04		/* SD ver 2 */
101
-#define CT_SDC		(CT_SD1|CT_SD2)	/* SD */
102
-#define CT_BLOCK	0x08		/* Block addressing */
103
-
104
-
105
-#ifdef __cplusplus
106
-}
107
-#endif
108
-
109
-#endif

+ 0
- 6204
Marlin/src/HAL/HAL_LPC1768/chanfs/ff.c
文件差異過大導致無法顯示
查看文件


+ 0
- 364
Marlin/src/HAL/HAL_LPC1768/chanfs/ff.h 查看文件

@@ -1,364 +0,0 @@
1
-/*----------------------------------------------------------------------------/
2
-/  FatFs - Generic FAT Filesystem module  R0.13                               /
3
-/-----------------------------------------------------------------------------/
4
-/
5
-/ Copyright (C) 2017, ChaN, all right reserved.
6
-/
7
-/ FatFs module is an open source software. Redistribution and use of FatFs in
8
-/ source and binary forms, with or without modification, are permitted provided
9
-/ that the following condition is met:
10
-
11
-/ 1. Redistributions of source code must retain the above copyright notice,
12
-/    this condition and the following disclaimer.
13
-/
14
-/ This software is provided by the copyright holder and contributors "AS IS"
15
-/ and any warranties related to this software are DISCLAIMED.
16
-/ The copyright owner or contributors be NOT LIABLE for any damages caused
17
-/ by use of this software.
18
-/
19
-/----------------------------------------------------------------------------*/
20
-
21
-
22
-#ifndef FF_DEFINED
23
-#define FF_DEFINED	87030	/* Revision ID */
24
-
25
-#ifdef __cplusplus
26
-extern "C" {
27
-#endif
28
-
29
-#include "integer.h"	/* Basic integer types */
30
-#include "ffconf.h"		/* FatFs configuration options */
31
-
32
-#if FF_DEFINED != FFCONF_DEF
33
-#error Wrong configuration file (ffconf.h).
34
-#endif
35
-
36
-
37
-
38
-/* Definitions of volume management */
39
-
40
-#if FF_MULTI_PARTITION		/* Multiple partition configuration */
41
-typedef struct {
42
-	BYTE pd;	/* Physical drive number */
43
-	BYTE pt;	/* Partition: 0:Auto detect, 1-4:Forced partition) */
44
-} PARTITION;
45
-extern PARTITION VolToPart[];	/* Volume - Partition resolution table */
46
-#endif
47
-
48
-
49
-
50
-/* Type of path name strings on FatFs API */
51
-
52
-#if FF_LFN_UNICODE && FF_USE_LFN	/* Unicode (UTF-16) string */
53
-#ifndef _INC_TCHAR
54
-typedef WCHAR TCHAR;
55
-#define _T(x) L ## x
56
-#define _TEXT(x) L ## x
57
-#define _INC_TCHAR
58
-#endif
59
-#else						/* ANSI/OEM string */
60
-#ifndef _INC_TCHAR
61
-typedef char TCHAR;
62
-#define _T(x) x
63
-#define _TEXT(x) x
64
-#define _INC_TCHAR
65
-#endif
66
-#endif
67
-
68
-
69
-
70
-/* Type of file size variables */
71
-
72
-#if FF_FS_EXFAT
73
-#if !FF_USE_LFN
74
-#error LFN must be enabled when enable exFAT
75
-#endif
76
-typedef QWORD FSIZE_t;
77
-#else
78
-typedef DWORD FSIZE_t;
79
-#endif
80
-
81
-
82
-
83
-/* Filesystem object structure (FATFS) */
84
-
85
-typedef struct {
86
-	BYTE	fs_type;		/* Filesystem type (0:N/A) */
87
-	BYTE	pdrv;			/* Physical drive number */
88
-	BYTE	n_fats;			/* Number of FATs (1 or 2) */
89
-	BYTE	wflag;			/* win[] flag (b0:dirty) */
90
-	BYTE	fsi_flag;		/* FSINFO flags (b7:disabled, b0:dirty) */
91
-	WORD	id;				/* Volume mount ID */
92
-	WORD	n_rootdir;		/* Number of root directory entries (FAT12/16) */
93
-	WORD	csize;			/* Cluster size [sectors] */
94
-#if FF_MAX_SS != FF_MIN_SS
95
-	WORD	ssize;			/* Sector size (512, 1024, 2048 or 4096) */
96
-#endif
97
-#if FF_USE_LFN
98
-	WCHAR*	lfnbuf;			/* LFN working buffer */
99
-#endif
100
-#if FF_FS_EXFAT
101
-	BYTE*	dirbuf;			/* Directory entry block scratchpad buffer for exFAT */
102
-#endif
103
-#if FF_FS_REENTRANT
104
-	FF_SYNC_t	sobj;		/* Identifier of sync object */
105
-#endif
106
-#if !FF_FS_READONLY
107
-	DWORD	last_clst;		/* Last allocated cluster */
108
-	DWORD	free_clst;		/* Number of free clusters */
109
-#endif
110
-#if FF_FS_RPATH
111
-	DWORD	cdir;			/* Current directory start cluster (0:root) */
112
-#if FF_FS_EXFAT
113
-	DWORD	cdc_scl;		/* Containing directory start cluster (invalid when cdir is 0) */
114
-	DWORD	cdc_size;		/* b31-b8:Size of containing directory, b7-b0: Chain status */
115
-	DWORD	cdc_ofs;		/* Offset in the containing directory (invalid when cdir is 0) */
116
-#endif
117
-#endif
118
-	DWORD	n_fatent;		/* Number of FAT entries (number of clusters + 2) */
119
-	DWORD	fsize;			/* Size of an FAT [sectors] */
120
-	DWORD	volbase;		/* Volume base sector */
121
-	DWORD	fatbase;		/* FAT base sector */
122
-	DWORD	dirbase;		/* Root directory base sector/cluster */
123
-	DWORD	database;		/* Data base sector */
124
-	DWORD	winsect;		/* Current sector appearing in the win[] */
125
-	BYTE	win[FF_MAX_SS];	/* Disk access window for Directory, FAT (and file data at tiny cfg) */
126
-} FATFS;
127
-
128
-
129
-
130
-/* Object ID and allocation information (FFOBJID) */
131
-
132
-typedef struct {
133
-	FATFS*	fs;				/* Pointer to the hosting volume of this object */
134
-	WORD	id;				/* Hosting volume mount ID */
135
-	BYTE	attr;			/* Object attribute */
136
-	BYTE	stat;			/* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:flagmented in this session, b2:sub-directory stretched) */
137
-	DWORD	sclust;			/* Object data start cluster (0:no cluster or root directory) */
138
-	FSIZE_t	objsize;		/* Object size (valid when sclust != 0) */
139
-#if FF_FS_EXFAT
140
-	DWORD	n_cont;			/* Size of first fragment - 1 (valid when stat == 3) */
141
-	DWORD	n_frag;			/* Size of last fragment needs to be written to FAT (valid when not zero) */
142
-	DWORD	c_scl;			/* Containing directory start cluster (valid when sclust != 0) */
143
-	DWORD	c_size;			/* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
144
-	DWORD	c_ofs;			/* Offset in the containing directory (valid when file object and sclust != 0) */
145
-#endif
146
-#if FF_FS_LOCK
147
-	UINT	lockid;			/* File lock ID origin from 1 (index of file semaphore table Files[]) */
148
-#endif
149
-} FFOBJID;
150
-
151
-
152
-
153
-/* File object structure (FIL) */
154
-
155
-typedef struct {
156
-	FFOBJID	obj;			/* Object identifier (must be the 1st member to detect invalid object pointer) */
157
-	BYTE	flag;			/* File status flags */
158
-	BYTE	err;			/* Abort flag (error code) */
159
-	FSIZE_t	fptr;			/* File read/write pointer (Zeroed on file open) */
160
-	DWORD	clust;			/* Current cluster of fpter (invalid when fptr is 0) */
161
-	DWORD	sect;			/* Sector number appearing in buf[] (0:invalid) */
162
-#if !FF_FS_READONLY
163
-	DWORD	dir_sect;		/* Sector number containing the directory entry (not used at exFAT) */
164
-	BYTE*	dir_ptr;		/* Pointer to the directory entry in the win[] (not used at exFAT) */
165
-#endif
166
-#if FF_USE_FASTSEEK
167
-	DWORD*	cltbl;			/* Pointer to the cluster link map table (nulled on open, set by application) */
168
-#endif
169
-#if !FF_FS_TINY
170
-	BYTE	buf[FF_MAX_SS];	/* File private data read/write window */
171
-#endif
172
-} FIL;
173
-
174
-
175
-
176
-/* Directory object structure (DIR) */
177
-
178
-typedef struct {
179
-	FFOBJID	obj;			/* Object identifier */
180
-	DWORD	dptr;			/* Current read/write offset */
181
-	DWORD	clust;			/* Current cluster */
182
-	DWORD	sect;			/* Current sector (0:Read operation has terminated) */
183
-	BYTE*	dir;			/* Pointer to the directory item in the win[] */
184
-	BYTE	fn[12];			/* SFN (in/out) {body[8],ext[3],status[1]} */
185
-#if FF_USE_LFN
186
-	DWORD	blk_ofs;		/* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
187
-#endif
188
-#if FF_USE_FIND
189
-	const TCHAR* pat;		/* Pointer to the name matching pattern */
190
-#endif
191
-} DIR;
192
-
193
-
194
-
195
-/* File information structure (FILINFO) */
196
-
197
-typedef struct {
198
-	FSIZE_t	fsize;			/* File size */
199
-	WORD	fdate;			/* Modified date */
200
-	WORD	ftime;			/* Modified time */
201
-	BYTE	fattrib;		/* File attribute */
202
-#if FF_USE_LFN
203
-	TCHAR	altname[13];			/* Altenative file name */
204
-	TCHAR	fname[FF_MAX_LFN + 1];	/* Primary file name */
205
-#else
206
-	TCHAR	fname[13];		/* File name */
207
-#endif
208
-} FILINFO;
209
-
210
-
211
-
212
-/* File function return code (FRESULT) */
213
-
214
-typedef enum {
215
-	FR_OK = 0,				/* (0) Succeeded */
216
-	FR_DISK_ERR,			/* (1) A hard error occurred in the low level disk I/O layer */
217
-	FR_INT_ERR,				/* (2) Assertion failed */
218
-	FR_NOT_READY,			/* (3) The physical drive cannot work */
219
-	FR_NO_FILE,				/* (4) Could not find the file */
220
-	FR_NO_PATH,				/* (5) Could not find the path */
221
-	FR_INVALID_NAME,		/* (6) The path name format is invalid */
222
-	FR_DENIED,				/* (7) Access denied due to prohibited access or directory full */
223
-	FR_EXIST,				/* (8) Access denied due to prohibited access */
224
-	FR_INVALID_OBJECT,		/* (9) The file/directory object is invalid */
225
-	FR_WRITE_PROTECTED,		/* (10) The physical drive is write protected */
226
-	FR_INVALID_DRIVE,		/* (11) The logical drive number is invalid */
227
-	FR_NOT_ENABLED,			/* (12) The volume has no work area */
228
-	FR_NO_FILESYSTEM,		/* (13) There is no valid FAT volume */
229
-	FR_MKFS_ABORTED,		/* (14) The f_mkfs() aborted due to any problem */
230
-	FR_TIMEOUT,				/* (15) Could not get a grant to access the volume within defined period */
231
-	FR_LOCKED,				/* (16) The operation is rejected according to the file sharing policy */
232
-	FR_NOT_ENOUGH_CORE,		/* (17) LFN working buffer could not be allocated */
233
-	FR_TOO_MANY_OPEN_FILES,	/* (18) Number of open files > FF_FS_LOCK */
234
-	FR_INVALID_PARAMETER	/* (19) Given parameter is invalid */
235
-} FRESULT;
236
-
237
-
238
-
239
-/*--------------------------------------------------------------*/
240
-/* FatFs module application interface                           */
241
-
242
-FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode);				/* Open or create a file */
243
-FRESULT f_close (FIL* fp);											/* Close an open file object */
244
-FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br);			/* Read data from the file */
245
-FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw);	/* Write data to the file */
246
-FRESULT f_lseek (FIL* fp, FSIZE_t ofs);								/* Move file pointer of the file object */
247
-FRESULT f_truncate (FIL* fp);										/* Truncate the file */
248
-FRESULT f_sync (FIL* fp);											/* Flush cached data of the writing file */
249
-FRESULT f_opendir (DIR* dp, const TCHAR* path);						/* Open a directory */
250
-FRESULT f_closedir (DIR* dp);										/* Close an open directory */
251
-FRESULT f_readdir (DIR* dp, FILINFO* fno);							/* Read a directory item */
252
-FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);	/* Find first file */
253
-FRESULT f_findnext (DIR* dp, FILINFO* fno);							/* Find next file */
254
-FRESULT f_mkdir (const TCHAR* path);								/* Create a sub directory */
255
-FRESULT f_unlink (const TCHAR* path);								/* Delete an existing file or directory */
256
-FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new);	/* Rename/Move a file or directory */
257
-FRESULT f_stat (const TCHAR* path, FILINFO* fno);					/* Get file status */
258
-FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask);			/* Change attribute of a file/dir */
259
-FRESULT f_utime (const TCHAR* path, const FILINFO* fno);			/* Change timestamp of a file/dir */
260
-FRESULT f_chdir (const TCHAR* path);								/* Change current directory */
261
-FRESULT f_chdrive (const TCHAR* path);								/* Change current drive */
262
-FRESULT f_getcwd (TCHAR* buff, UINT len);							/* Get current directory */
263
-FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs);	/* Get number of free clusters on the drive */
264
-FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn);	/* Get volume label */
265
-FRESULT f_setlabel (const TCHAR* label);							/* Set volume label */
266
-FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf);	/* Forward data to the stream */
267
-FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt);					/* Allocate a contiguous block to the file */
268
-FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt);			/* Mount/Unmount a logical drive */
269
-FRESULT f_mkfs (const TCHAR* path, BYTE opt, DWORD au, void* work, UINT len);	/* Create a FAT volume */
270
-FRESULT f_fdisk (BYTE pdrv, const DWORD* szt, void* work);			/* Divide a physical drive into some partitions */
271
-FRESULT f_setcp (WORD cp);											/* Set current code page */
272
-int f_putc (TCHAR c, FIL* fp);										/* Put a character to the file */
273
-int f_puts (const TCHAR* str, FIL* cp);								/* Put a string to the file */
274
-int f_printf (FIL* fp, const TCHAR* str, ...);						/* Put a formatted string to the file */
275
-TCHAR* f_gets (TCHAR* buff, int len, FIL* fp);						/* Get a string from the file */
276
-
277
-#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
278
-#define f_error(fp) ((fp)->err)
279
-#define f_tell(fp) ((fp)->fptr)
280
-#define f_size(fp) ((fp)->obj.objsize)
281
-#define f_rewind(fp) f_lseek((fp), 0)
282
-#define f_rewinddir(dp) f_readdir((dp), 0)
283
-#define f_rmdir(path) f_unlink(path)
284
-#define f_unmount(path) f_mount(0, path, 0)
285
-
286
-#ifndef EOF
287
-#define EOF (-1)
288
-#endif
289
-
290
-
291
-
292
-
293
-/*--------------------------------------------------------------*/
294
-/* Additional user defined functions                            */
295
-
296
-/* RTC function */
297
-#if !FF_FS_READONLY && !FF_FS_NORTC
298
-DWORD get_fattime (void);
299
-#endif
300
-
301
-/* LFN support functions */
302
-#if FF_USE_LFN						/* Code conversion (defined in unicode.c) */
303
-WCHAR ff_oem2uni (WCHAR oem, WORD cp);	/* OEM code to Unicode conversion */
304
-WCHAR ff_uni2oem (WCHAR uni, WORD cp);	/* Unicode to OEM code conversion */
305
-WCHAR ff_wtoupper (WCHAR uni);			/* Unicode upper-case conversion */
306
-#endif
307
-#if FF_USE_LFN == 3						/* Dynamic memory allocation */
308
-void* ff_memalloc (UINT msize);			/* Allocate memory block */
309
-void ff_memfree (void* mblock);			/* Free memory block */
310
-#endif
311
-
312
-/* Sync functions */
313
-#if FF_FS_REENTRANT
314
-int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj);	/* Create a sync object */
315
-int ff_req_grant (FF_SYNC_t sobj);		/* Lock sync object */
316
-void ff_rel_grant (FF_SYNC_t sobj);		/* Unlock sync object */
317
-int ff_del_syncobj (FF_SYNC_t sobj);	/* Delete a sync object */
318
-#endif
319
-
320
-
321
-
322
-
323
-/*--------------------------------------------------------------*/
324
-/* Flags and offset address                                     */
325
-
326
-
327
-/* File access mode and open method flags (3rd argument of f_open) */
328
-#define	FA_READ				0x01
329
-#define	FA_WRITE			0x02
330
-#define	FA_OPEN_EXISTING	0x00
331
-#define	FA_CREATE_NEW		0x04
332
-#define	FA_CREATE_ALWAYS	0x08
333
-#define	FA_OPEN_ALWAYS		0x10
334
-#define	FA_OPEN_APPEND		0x30
335
-
336
-/* Fast seek controls (2nd argument of f_lseek) */
337
-#define CREATE_LINKMAP	((FSIZE_t)0 - 1)
338
-
339
-/* Format options (2nd argument of f_mkfs) */
340
-#define FM_FAT		0x01
341
-#define FM_FAT32	0x02
342
-#define FM_EXFAT	0x04
343
-#define FM_ANY		0x07
344
-#define FM_SFD		0x08
345
-
346
-/* Filesystem type (FATFS.fs_type) */
347
-#define FS_FAT12	1
348
-#define FS_FAT16	2
349
-#define FS_FAT32	3
350
-#define FS_EXFAT	4
351
-
352
-/* File attribute bits for directory entry (FILINFO.fattrib) */
353
-#define	AM_RDO	0x01	/* Read only */
354
-#define	AM_HID	0x02	/* Hidden */
355
-#define	AM_SYS	0x04	/* System */
356
-#define AM_DIR	0x10	/* Directory */
357
-#define AM_ARC	0x20	/* Archive */
358
-
359
-
360
-#ifdef __cplusplus
361
-}
362
-#endif
363
-
364
-#endif /* FF_DEFINED */

+ 0
- 269
Marlin/src/HAL/HAL_LPC1768/chanfs/ffconf.h 查看文件

@@ -1,269 +0,0 @@
1
-/*---------------------------------------------------------------------------/
2
-/  FatFs - Configuration file
3
-/---------------------------------------------------------------------------*/
4
-
5
-#define FFCONF_DEF 87030	/* Revision ID */
6
-
7
-/*---------------------------------------------------------------------------/
8
-/ Function Configurations
9
-/---------------------------------------------------------------------------*/
10
-
11
-#define FF_FS_READONLY	0
12
-/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
13
-/  Read-only configuration removes writing API functions, f_write(), f_sync(),
14
-/  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
15
-/  and optional writing functions as well. */
16
-
17
-
18
-#define FF_FS_MINIMIZE	0
19
-/* This option defines minimization level to remove some basic API functions.
20
-/
21
-/   0: All basic functions are enabled.
22
-/   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
23
-/      are removed.
24
-/   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
25
-/   3: f_lseek() function is removed in addition to 2. */
26
-
27
-
28
-#define FF_USE_STRFUNC	0
29
-/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
30
-/
31
-/  0: Disable string functions.
32
-/  1: Enable without LF-CRLF conversion.
33
-/  2: Enable with LF-CRLF conversion. */
34
-
35
-
36
-#define FF_USE_FIND		1
37
-/* This option switches filtered directory read functions, f_findfirst() and
38
-/  f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
39
-
40
-
41
-#define FF_USE_MKFS		1
42
-/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
43
-
44
-
45
-#define FF_USE_FASTSEEK	0
46
-/* This option switches fast seek function. (0:Disable or 1:Enable) */
47
-
48
-
49
-#define FF_USE_EXPAND	0
50
-/* This option switches f_expand function. (0:Disable or 1:Enable) */
51
-
52
-
53
-#define FF_USE_CHMOD	1
54
-/* This option switches attribute manipulation functions, f_chmod() and f_utime().
55
-/  (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
56
-
57
-
58
-#define FF_USE_LABEL	1
59
-/* This option switches volume label functions, f_getlabel() and f_setlabel().
60
-/  (0:Disable or 1:Enable) */
61
-
62
-
63
-#define FF_USE_FORWARD	0
64
-/* This option switches f_forward() function. (0:Disable or 1:Enable) */
65
-
66
-
67
-/*---------------------------------------------------------------------------/
68
-/ Locale and Namespace Configurations
69
-/---------------------------------------------------------------------------*/
70
-
71
-#define FF_CODE_PAGE	932
72
-/* This option specifies the OEM code page to be used on the target system.
73
-/  Incorrect code page setting can cause a file open failure.
74
-/
75
-/   437 - U.S.
76
-/   720 - Arabic
77
-/   737 - Greek
78
-/   771 - KBL
79
-/   775 - Baltic
80
-/   850 - Latin 1
81
-/   852 - Latin 2
82
-/   855 - Cyrillic
83
-/   857 - Turkish
84
-/   860 - Portuguese
85
-/   861 - Icelandic
86
-/   862 - Hebrew
87
-/   863 - Canadian French
88
-/   864 - Arabic
89
-/   865 - Nordic
90
-/   866 - Russian
91
-/   869 - Greek 2
92
-/   932 - Japanese (DBCS)
93
-/   936 - Simplified Chinese (DBCS)
94
-/   949 - Korean (DBCS)
95
-/   950 - Traditional Chinese (DBCS)
96
-/     0 - Include all code pages above and configured by f_setcp()
97
-*/
98
-
99
-
100
-#define FF_USE_LFN		1
101
-#define FF_MAX_LFN		255
102
-/* The FF_USE_LFN switches the support for LFN (long file name).
103
-/
104
-/   0: Disable LFN. FF_MAX_LFN has no effect.
105
-/   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
106
-/   2: Enable LFN with dynamic working buffer on the STACK.
107
-/   3: Enable LFN with dynamic working buffer on the HEAP.
108
-/
109
-/  To enable the LFN, Unicode handling functions (option/unicode.c) must be added
110
-/  to the project. The working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
111
-/  additional 608 bytes at exFAT enabled. FF_MAX_LFN can be in range from 12 to 255.
112
-/  It should be set 255 to support full featured LFN operations.
113
-/  When use stack for the working buffer, take care on stack overflow. When use heap
114
-/  memory for the working buffer, memory management functions, ff_memalloc() and
115
-/  ff_memfree(), must be added to the project. */
116
-
117
-
118
-#define FF_LFN_UNICODE	0
119
-/* This option switches character encoding on the API, 0:ANSI/OEM or 1:UTF-16,
120
-/  when LFN is enabled. Also behavior of string I/O functions will be affected by
121
-/  this option. When LFN is not enabled, this option has no effect.
122
-*/
123
-
124
-
125
-#define FF_STRF_ENCODE	3
126
-/* When FF_LFN_UNICODE = 1 with LFN enabled, string I/O functions, f_gets(),
127
-/  f_putc(), f_puts and f_printf() convert the character encoding in it.
128
-/  This option selects assumption of character encoding ON THE FILE to be
129
-/  read/written via those functions.
130
-/
131
-/   0: ANSI/OEM
132
-/   1: UTF-16LE
133
-/   2: UTF-16BE
134
-/   3: UTF-8
135
-*/
136
-
137
-
138
-#define FF_FS_RPATH		2
139
-/* This option configures support for relative path.
140
-/
141
-/   0: Disable relative path and remove related functions.
142
-/   1: Enable relative path. f_chdir() and f_chdrive() are available.
143
-/   2: f_getcwd() function is available in addition to 1.
144
-*/
145
-
146
-
147
-/*---------------------------------------------------------------------------/
148
-/ Drive/Volume Configurations
149
-/---------------------------------------------------------------------------*/
150
-
151
-#define FF_VOLUMES		1
152
-/* Number of volumes (logical drives) to be used. (1-10) */
153
-
154
-
155
-#define FF_STR_VOLUME_ID	0
156
-#define FF_VOLUME_STRS		"RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
157
-/* FF_STR_VOLUME_ID switches string support for volume ID.
158
-/  When FF_STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
159
-/  number in the path name. FF_VOLUME_STRS defines the drive ID strings for each
160
-/  logical drives. Number of items must be equal to FF_VOLUMES. Valid characters for
161
-/  the drive ID strings are: A-Z and 0-9. */
162
-
163
-
164
-#define FF_MULTI_PARTITION	0
165
-/* This option switches support for multiple volumes on the physical drive.
166
-/  By default (0), each logical drive number is bound to the same physical drive
167
-/  number and only an FAT volume found on the physical drive will be mounted.
168
-/  When this function is enabled (1), each logical drive number can be bound to
169
-/  arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
170
-/  funciton will be available. */
171
-
172
-
173
-#define FF_MIN_SS		512
174
-#define FF_MAX_SS		512
175
-/* This set of options configures the range of sector size to be supported. (512,
176
-/  1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
177
-/  harddisk. But a larger value may be required for on-board flash memory and some
178
-/  type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
179
-/  for variable sector size mode and disk_ioctl() function needs to implement
180
-/  GET_SECTOR_SIZE command. */
181
-
182
-
183
-#define FF_USE_TRIM		0
184
-/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
185
-/  To enable Trim function, also CTRL_TRIM command should be implemented to the
186
-/  disk_ioctl() function. */
187
-
188
-
189
-#define FF_FS_NOFSINFO	0
190
-/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
191
-/  option, and f_getfree() function at first time after volume mount will force
192
-/  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
193
-/
194
-/  bit0=0: Use free cluster count in the FSINFO if available.
195
-/  bit0=1: Do not trust free cluster count in the FSINFO.
196
-/  bit1=0: Use last allocated cluster number in the FSINFO if available.
197
-/  bit1=1: Do not trust last allocated cluster number in the FSINFO.
198
-*/
199
-
200
-
201
-
202
-/*---------------------------------------------------------------------------/
203
-/ System Configurations
204
-/---------------------------------------------------------------------------*/
205
-
206
-#define FF_FS_TINY		0
207
-/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
208
-/  At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
209
-/  Instead of private sector buffer eliminated from the file object, common sector
210
-/  buffer in the filesystem object (FATFS) is used for the file data transfer. */
211
-
212
-
213
-#define FF_FS_EXFAT		0
214
-/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
215
-/  When enable exFAT, also LFN needs to be enabled.
216
-/  Note that enabling exFAT discards ANSI C (C89) compatibility. */
217
-
218
-
219
-#define FF_FS_NORTC		0
220
-#define FF_NORTC_MON	1
221
-#define FF_NORTC_MDAY	1
222
-#define FF_NORTC_YEAR	2016
223
-/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
224
-/  any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
225
-/  the timestamp function. All objects modified by FatFs will have a fixed timestamp
226
-/  defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
227
-/  To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
228
-/  added to the project to read current time form real-time clock. FF_NORTC_MON,
229
-/  FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
230
-/  These options have no effect at read-only configuration (FF_FS_READONLY = 1). */
231
-
232
-
233
-#define FF_FS_LOCK		0
234
-/* The option FF_FS_LOCK switches file lock function to control duplicated file open
235
-/  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
236
-/  is 1.
237
-/
238
-/  0:  Disable file lock function. To avoid volume corruption, application program
239
-/      should avoid illegal open, remove and rename to the open objects.
240
-/  >0: Enable file lock function. The value defines how many files/sub-directories
241
-/      can be opened simultaneously under file lock control. Note that the file
242
-/      lock control is independent of re-entrancy. */
243
-
244
-
245
-#define FF_FS_REENTRANT	0
246
-#define FF_FS_TIMEOUT	1000
247
-#define FF_SYNC_t		HANDLE
248
-/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
249
-/  module itself. Note that regardless of this option, file access to different
250
-/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
251
-/  and f_fdisk() function, are always not re-entrant. Only file/directory access
252
-/  to the same volume is under control of this function.
253
-/
254
-/   0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
255
-/   1: Enable re-entrancy. Also user provided synchronization handlers,
256
-/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
257
-/      function, must be added to the project. Samples are available in
258
-/      option/syscall.c.
259
-/
260
-/  The FF_FS_TIMEOUT defines timeout period in unit of time tick.
261
-/  The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
262
-/  SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
263
-/  included somewhere in the scope of ff.h. */
264
-
265
-/* #include <windows.h>	// O/S definitions  */
266
-
267
-
268
-
269
-/*--- End of configuration options ---*/

+ 0
- 15566
Marlin/src/HAL/HAL_LPC1768/chanfs/ffunicode.c
文件差異過大導致無法顯示
查看文件


+ 0
- 38
Marlin/src/HAL/HAL_LPC1768/chanfs/integer.h 查看文件

@@ -1,38 +0,0 @@
1
-/*-------------------------------------------*/
2
-/* Integer type definitions for FatFs module */
3
-/*-------------------------------------------*/
4
-
5
-#ifndef _FF_INTEGER
6
-#define _FF_INTEGER
7
-
8
-#ifdef _WIN32	/* FatFs development platform */
9
-
10
-#include <windows.h>
11
-#include <tchar.h>
12
-typedef unsigned __int64 QWORD;
13
-
14
-
15
-#else			/* Embedded platform */
16
-
17
-/* These types MUST be 16-bit or 32-bit */
18
-typedef int				INT;
19
-typedef unsigned int	UINT;
20
-
21
-/* This type MUST be 8-bit */
22
-typedef unsigned char	BYTE;
23
-
24
-/* These types MUST be 16-bit */
25
-typedef short			SHORT;
26
-typedef unsigned short	WORD;
27
-typedef unsigned short	WCHAR;
28
-
29
-/* These types MUST be 32-bit */
30
-typedef long			LONG;
31
-typedef unsigned long	DWORD;
32
-
33
-/* This type MUST be 64-bit (Remove this for C89 compatibility) */
34
-typedef unsigned long long QWORD;
35
-
36
-#endif
37
-
38
-#endif

+ 0
- 745
Marlin/src/HAL/HAL_LPC1768/chanfs/mmc_ssp.c 查看文件

@@ -1,745 +0,0 @@
1
-/*------------------------------------------------------------------------*/
2
-/* LPCXpresso176x: MMCv3/SDv1/SDv2 (SPI mode) control module              */
3
-/*------------------------------------------------------------------------*/
4
-/*
5
-/  Copyright (C) 2015, ChaN, all right reserved.
6
-/
7
-/ * This software is a free software and there is NO WARRANTY.
8
-/ * No restriction on use. You can use, modify and redistribute it for
9
-/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
10
-/ * Redistributions of source code must retain the above copyright notice.
11
-/
12
-/-------------------------------------------------------------------------*/
13
-
14
-#define SSP_CH	1	/* SSP channel to use (0:SSP0, 1:SSP1) */
15
-
16
-#define	CCLK		100000000UL	/* cclk frequency [Hz] */
17
-#define PCLK_SSP	50000000UL	/* PCLK frequency to be supplied for SSP [Hz] */
18
-#define SCLK_FAST	25000000UL	/* SCLK frequency under normal operation [Hz] */
19
-#define	SCLK_SLOW	400000UL	/* SCLK frequency under initialization [Hz] */
20
-
21
-//#define	MMC_CD		(!(FIO2PIN1 & _BV(1)))	/* Card detect (yes:true, no:false, default:true) */
22
-#define	MMC_WP		0						/* Write protected (yes:true, no:false, default:false) */
23
-
24
-#if SSP_CH == 0
25
-#define	SSPxDR		SSP0DR
26
-#define	SSPxSR		SSP0SR
27
-#define	SSPxCR0		SSP0CR0
28
-#define	SSPxCR1		SSP0CR1
29
-#define	SSPxCPSR	SSP0CPSR
30
-#define	CS_LOW()	{FIO0CLR2 = _BV(0);}	/* Set P0.16 low */
31
-#define	CS_HIGH()	{FIO0SET2 = _BV(0);}	/* Set P0.16 high */
32
-#define PCSSPx		PCSSP0
33
-#define	PCLKSSPx	PCLK_SSP0
34
-#define ATTACH_SSP() {\
35
-		__set_PINSEL(0, 15, 2);	/* SCK0 */\
36
-		__set_PINSEL(0, 17, 2);	/* MISO0 */\
37
-		__set_PINSEL(0, 18, 2);	/* MOSI0 */\
38
-		FIO0DIR |= _BV(16);		/* CS# (P0.16) */\
39
-		}
40
-#elif SSP_CH == 1
41
-#define	SSPxDR		SSP1DR
42
-#define	SSPxSR		SSP1SR
43
-#define	SSPxCR0		SSP1CR0
44
-#define	SSPxCR1		SSP1CR1
45
-#define	SSPxCPSR	SSP1CPSR
46
-#define	CS_LOW()	{FIO0CLR0 = _BV(6);}	/* Set P0.6 low */
47
-#define	CS_HIGH()	{FIO0SET0 = _BV(6);}	/* Set P0.6 high */
48
-#define PCSSPx		PCSSP1
49
-#define	PCLKSSPx	PCLK_SSP1
50
-#define ATTACH_SSP() {\
51
-		__set_PINSEL(0, 7, 2);	/* SCK1 */\
52
-		__set_PINSEL(0, 8, 2);	/* MISO1 */\
53
-		__set_PINSEL(0, 9, 2);	/* MOSI1 */\
54
-		FIO0DIR |= _BV(6);		/* CS# (P0.6) */\
55
-		}
56
-#endif
57
-
58
-#if PCLK_SSP * 1 == CCLK
59
-#define PCLKDIV_SSP	PCLKDIV_1
60
-#elif PCLK_SSP * 2 == CCLK
61
-#define PCLKDIV_SSP	PCLKDIV_2
62
-#elif PCLK_SSP * 4 == CCLK
63
-#define PCLKDIV_SSP	PCLKDIV_4
64
-#elif PCLK_SSP * 8 == CCLK
65
-#define PCLKDIV_SSP	PCLKDIV_8
66
-#else
67
-#error Invalid CCLK:PCLK_SSP combination.
68
-#endif
69
-
70
-
71
-#define FCLK_FAST() { SSPxCR0 = (SSPxCR0 & 0x00FF) | ((PCLK_SSP / 2 / SCLK_FAST) - 1) << 8; }
72
-#define FCLK_SLOW() { SSPxCR0 = (SSPxCR0 & 0x00FF) | ((PCLK_SSP / 2 / SCLK_SLOW) - 1) << 8; }
73
-
74
-
75
-
76
-/*--------------------------------------------------------------------------
77
-
78
-   Module Private Functions
79
-
80
----------------------------------------------------------------------------*/
81
-
82
-#include "LPC176x.h"
83
-#include "diskio.h"
84
-
85
-
86
-/* MMC/SD command */
87
-#define CMD0	(0)			/* GO_IDLE_STATE */
88
-#define CMD1	(1)			/* SEND_OP_COND (MMC) */
89
-#define	ACMD41	(0x80+41)	/* SEND_OP_COND (SDC) */
90
-#define CMD8	(8)			/* SEND_IF_COND */
91
-#define CMD9	(9)			/* SEND_CSD */
92
-#define CMD10	(10)		/* SEND_CID */
93
-#define CMD12	(12)		/* STOP_TRANSMISSION */
94
-#define ACMD13	(0x80+13)	/* SD_STATUS (SDC) */
95
-#define CMD16	(16)		/* SET_BLOCKLEN */
96
-#define CMD17	(17)		/* READ_SINGLE_BLOCK */
97
-#define CMD18	(18)		/* READ_MULTIPLE_BLOCK */
98
-#define CMD23	(23)		/* SET_BLOCK_COUNT (MMC) */
99
-#define	ACMD23	(0x80+23)	/* SET_WR_BLK_ERASE_COUNT (SDC) */
100
-#define CMD24	(24)		/* WRITE_BLOCK */
101
-#define CMD25	(25)		/* WRITE_MULTIPLE_BLOCK */
102
-#define CMD32	(32)		/* ERASE_ER_BLK_START */
103
-#define CMD33	(33)		/* ERASE_ER_BLK_END */
104
-#define CMD38	(38)		/* ERASE */
105
-#define	CMD48	(48)		/* READ_EXTR_SINGLE */
106
-#define	CMD49	(49)		/* WRITE_EXTR_SINGLE */
107
-#define CMD55	(55)		/* APP_CMD */
108
-#define CMD58	(58)		/* READ_OCR */
109
-
110
-
111
-static volatile
112
-DSTATUS Stat = STA_NOINIT;	/* Physical drive status */
113
-
114
-static volatile
115
-UINT Timer1, Timer2;	/* 1kHz decrement timer stopped at zero (disk_timerproc()) */
116
-
117
-static
118
-BYTE CardType;			/* Card type flags */
119
-
120
-
121
-
122
-/*-----------------------------------------------------------------------*/
123
-/* Send/Receive data to the MMC  (Platform dependent)                    */
124
-/*-----------------------------------------------------------------------*/
125
-
126
-/* Exchange a byte */
127
-static
128
-BYTE xchg_spi (
129
-	BYTE dat	/* Data to send */
130
-)
131
-{
132
-	SSPxDR = dat;
133
-	while (SSPxSR & 0x10) ;
134
-	return SSPxDR;
135
-}
136
-
137
-
138
-/* Receive multiple byte */
139
-static
140
-void rcvr_spi_multi (
141
-	BYTE *buff,		/* Pointer to data buffer */
142
-	UINT btr		/* Number of bytes to receive (16, 64 or 512) */
143
-)
144
-{
145
-	UINT n;
146
-	WORD d;
147
-
148
-
149
-	SSPxCR0 |= 0x000F;	/* Select 16-bit mode */
150
-
151
-	for (n = 0; n < 8; n++)			/* Push 8 frames into pipeline  */
152
-		SSPxDR = 0xFFFF;
153
-	btr -= 16;
154
-
155
-	while (btr >= 2) {				/* Receive the data block into buffer */
156
-		btr -= 2;
157
-		while (!(SSPxSR & _BV(2))) ;	/* Wait for any data in receive FIFO */
158
-		d = SSPxDR;
159
-		SSPxDR = 0xFFFF;
160
-		*buff++ = d >> 8;
161
-		*buff++ = d;
162
-	}
163
-
164
-	for (n = 0; n < 8; n++) {		/* Pop remaining frames from pipeline */
165
-		while (!(SSPxSR & _BV(2))) ;
166
-		d = SSPxDR;
167
-		*buff++ = d >> 8;
168
-		*buff++ = d;
169
-	}
170
-
171
-	SSPxCR0 &= 0xFFF7;				/* Select 8-bit mode */
172
-}
173
-
174
-
175
-#if _DISKIO_WRITE
176
-/* Send multiple byte */
177
-static
178
-void xmit_spi_multi (
179
-	const BYTE *buff,	/* Pointer to the data */
180
-	UINT btx			/* Number of bytes to send (multiple of 16) */
181
-)
182
-{
183
-	UINT n;
184
-	WORD d;
185
-
186
-
187
-	SSPxCR0 |= 0x000F;			/* Select 16-bit mode */
188
-
189
-	for (n = 0; n < 8; n++) {	/* Push 8 frames into pipeline  */
190
-		d = *buff++;
191
-		d = d << 8 | *buff++;
192
-		SSPxDR = d;
193
-	}
194
-	btx -= 16;
195
-
196
-	while (btx >= 2) {			/* Transmit data block */
197
-		btx -= 2;
198
-		d = *buff++;
199
-		d = d << 8 | *buff++;
200
-		while (!(SSPxSR & _BV(2))) ;	/* Wait for any data in receive FIFO */
201
-		SSPxDR; SSPxDR = d;
202
-	}
203
-
204
-	for (n = 0; n < 8; n++) {	/* Flush pipeline */
205
-		while (!(SSPxSR & _BV(2))) ;
206
-		SSPxDR;
207
-	}
208
-
209
-	SSPxCR0 &= 0xFFF7;			/* Select 8-bit mode */
210
-}
211
-#endif
212
-
213
-
214
-/*-----------------------------------------------------------------------*/
215
-/* Wait for card ready                                                   */
216
-/*-----------------------------------------------------------------------*/
217
-
218
-static
219
-int wait_ready (	/* 1:Ready, 0:Timeout */
220
-	UINT wt			/* Timeout [ms] */
221
-)
222
-{
223
-	BYTE d;
224
-
225
-
226
-	Timer2 = wt;
227
-	do {
228
-		d = xchg_spi(0xFF);
229
-
230
-		/* This loop takes a time. Insert rot_rdq() here for multitask envilonment. */
231
-
232
-	} while (d != 0xFF && Timer2);	/* Wait for card goes ready or timeout */
233
-
234
-	return (d == 0xFF) ? 1 : 0;
235
-}
236
-
237
-
238
-
239
-/*-----------------------------------------------------------------------*/
240
-/* Deselect card and release SPI                                         */
241
-/*-----------------------------------------------------------------------*/
242
-
243
-static
244
-void deselect (void)
245
-{
246
-	CS_HIGH();		/* CS = H */
247
-	xchg_spi(0xFF);	/* Dummy clock (force DO hi-z for multiple slave SPI) */
248
-}
249
-
250
-
251
-
252
-/*-----------------------------------------------------------------------*/
253
-/* Select card and wait for ready                                        */
254
-/*-----------------------------------------------------------------------*/
255
-
256
-static
257
-int select (void)	/* 1:OK, 0:Timeout */
258
-{
259
-	CS_LOW();		/* CS = L */
260
-	xchg_spi(0xFF);	/* Dummy clock (force DO enabled) */
261
-
262
-	if (wait_ready(500)) return 1;	/* Leading busy check: Wait for card ready */
263
-
264
-	deselect();		/* Timeout */
265
-	return 0;
266
-}
267
-
268
-
269
-
270
-/*-----------------------------------------------------------------------*/
271
-/* Control SPI module (Platform dependent)                               */
272
-/*-----------------------------------------------------------------------*/
273
-
274
-static
275
-void power_on (void)	/* Enable SSP module and attach it to I/O pads */
276
-{
277
-	__set_PCONP(PCSSPx, 1);	/* Enable SSP module */
278
-	__set_PCLKSEL(PCLKSSPx, PCLKDIV_SSP);	/* Select PCLK frequency for SSP */
279
-	SSPxCPSR = 2;			/* CPSDVSR=2 */
280
-	SSPxCR0 = 0x0007;		/* Set mode: SPI mode 0, 8-bit */
281
-	SSPxCR1 = 0x2;			/* Enable SSP with Master */
282
-	ATTACH_SSP();			/* Attach SSP module to I/O pads */
283
-	CS_HIGH();				/* Set CS# high */
284
-
285
-	for (Timer1 = 10; Timer1; ) ;	/* 10ms */
286
-}
287
-
288
-
289
-static
290
-void power_off (void)		/* Disable SPI function */
291
-{
292
-	select();				/* Wait for card ready */
293
-	deselect();
294
-}
295
-
296
-
297
-
298
-/*-----------------------------------------------------------------------*/
299
-/* Receive a data packet from the MMC                                    */
300
-/*-----------------------------------------------------------------------*/
301
-
302
-static
303
-int rcvr_datablock (	/* 1:OK, 0:Error */
304
-	BYTE *buff,			/* Data buffer */
305
-	UINT btr			/* Data block length (byte) */
306
-)
307
-{
308
-	BYTE token;
309
-
310
-
311
-	Timer1 = 200;
312
-	do {							/* Wait for DataStart token in timeout of 200ms */
313
-		token = xchg_spi(0xFF);
314
-
315
-		/* This loop will take a time. Insert rot_rdq() here for multitask envilonment. */
316
-
317
-	} while ((token == 0xFF) && Timer1);
318
-	if(token != 0xFE) return 0;		/* Function fails if invalid DataStart token or timeout */
319
-
320
-	rcvr_spi_multi(buff, btr);		/* Store trailing data to the buffer */
321
-	xchg_spi(0xFF); xchg_spi(0xFF);	/* Discard CRC */
322
-
323
-	return 1;						/* Function succeeded */
324
-}
325
-
326
-
327
-
328
-/*-----------------------------------------------------------------------*/
329
-/* Send a data packet to the MMC                                         */
330
-/*-----------------------------------------------------------------------*/
331
-
332
-#if _DISKIO_WRITE
333
-static
334
-int xmit_datablock (	/* 1:OK, 0:Failed */
335
-	const BYTE *buff,	/* Ponter to 512 byte data to be sent */
336
-	BYTE token			/* Token */
337
-)
338
-{
339
-	BYTE resp;
340
-
341
-
342
-	if (!wait_ready(500)) return 0;		/* Leading busy check: Wait for card ready to accept data block */
343
-
344
-	xchg_spi(token);					/* Send token */
345
-	if (token == 0xFD) return 1;		/* Do not send data if token is StopTran */
346
-
347
-	xmit_spi_multi(buff, 512);			/* Data */
348
-	xchg_spi(0xFF); xchg_spi(0xFF);		/* Dummy CRC */
349
-
350
-	resp = xchg_spi(0xFF);				/* Receive data resp */
351
-
352
-	return (resp & 0x1F) == 0x05 ? 1 : 0;	/* Data was accepted or not */
353
-
354
-	/* Busy check is done at next transmission */
355
-}
356
-#endif
357
-
358
-
359
-/*-----------------------------------------------------------------------*/
360
-/* Send a command packet to the MMC                                      */
361
-/*-----------------------------------------------------------------------*/
362
-
363
-static
364
-BYTE send_cmd (		/* Return value: R1 resp (bit7==1:Failed to send) */
365
-	BYTE cmd,		/* Command index */
366
-	DWORD arg		/* Argument */
367
-)
368
-{
369
-	BYTE n, res;
370
-
371
-
372
-	if (cmd & 0x80) {	/* Send a CMD55 prior to ACMD<n> */
373
-		cmd &= 0x7F;
374
-		res = send_cmd(CMD55, 0);
375
-		if (res > 1) return res;
376
-	}
377
-
378
-	/* Select the card and wait for ready except to stop multiple block read */
379
-	if (cmd != CMD12) {
380
-		deselect();
381
-		if (!select()) return 0xFF;
382
-	}
383
-
384
-	/* Send command packet */
385
-	xchg_spi(0x40 | cmd);				/* Start + command index */
386
-	xchg_spi((BYTE)(arg >> 24));		/* Argument[31..24] */
387
-	xchg_spi((BYTE)(arg >> 16));		/* Argument[23..16] */
388
-	xchg_spi((BYTE)(arg >> 8));			/* Argument[15..8] */
389
-	xchg_spi((BYTE)arg);				/* Argument[7..0] */
390
-	n = 0x01;							/* Dummy CRC + Stop */
391
-	if (cmd == CMD0) n = 0x95;			/* Valid CRC for CMD0(0) */
392
-	if (cmd == CMD8) n = 0x87;			/* Valid CRC for CMD8(0x1AA) */
393
-	xchg_spi(n);
394
-
395
-	/* Receive command resp */
396
-	if (cmd == CMD12) xchg_spi(0xFF);	/* Diacard following one byte when CMD12 */
397
-	n = 10;								/* Wait for response (10 bytes max) */
398
-	do
399
-		res = xchg_spi(0xFF);
400
-	while ((res & 0x80) && --n);
401
-
402
-	return res;							/* Return received response */
403
-}
404
-
405
-
406
-
407
-/*--------------------------------------------------------------------------
408
-
409
-   Public Functions
410
-
411
----------------------------------------------------------------------------*/
412
-
413
-
414
-/*-----------------------------------------------------------------------*/
415
-/* Initialize disk drive                                                 */
416
-/*-----------------------------------------------------------------------*/
417
-
418
-DSTATUS disk_initialize (
419
-	BYTE drv		/* Physical drive number (0) */
420
-)
421
-{
422
-	BYTE n, cmd, ty, ocr[4];
423
-
424
-
425
-	if (drv) return STA_NOINIT;			/* Supports only drive 0 */
426
-	power_on();							/* Initialize SPI */
427
-
428
-	if (Stat & STA_NODISK) return Stat;	/* Is a card existing in the soket? */
429
-
430
-	FCLK_SLOW();
431
-	for (n = 10; n; n--) xchg_spi(0xFF);	/* Send 80 dummy clocks */
432
-
433
-	ty = 0;
434
-	if (send_cmd(CMD0, 0) == 1) {			/* Put the card SPI state */
435
-		Timer1 = 1000;						/* Initialization timeout = 1 sec */
436
-		if (send_cmd(CMD8, 0x1AA) == 1) {	/* Is the catd SDv2? */
437
-			for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF);	/* Get 32 bit return value of R7 resp */
438
-			if (ocr[2] == 0x01 && ocr[3] == 0xAA) {				/* Does the card support 2.7-3.6V? */
439
-				while (Timer1 && send_cmd(ACMD41, 1UL << 30)) ;	/* Wait for end of initialization with ACMD41(HCS) */
440
-				if (Timer1 && send_cmd(CMD58, 0) == 0) {		/* Check CCS bit in the OCR */
441
-					for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF);
442
-					ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2;	/* Check if the card is SDv2 */
443
-				}
444
-			}
445
-		} else {	/* Not an SDv2 card */
446
-			if (send_cmd(ACMD41, 0) <= 1) 	{	/* SDv1 or MMCv3? */
447
-				ty = CT_SD1; cmd = ACMD41;	/* SDv1 (ACMD41(0)) */
448
-			} else {
449
-				ty = CT_MMC; cmd = CMD1;	/* MMCv3 (CMD1(0)) */
450
-			}
451
-			while (Timer1 && send_cmd(cmd, 0)) ;		/* Wait for the card leaves idle state */
452
-			if (!Timer1 || send_cmd(CMD16, 512) != 0)	/* Set block length: 512 */
453
-				ty = 0;
454
-		}
455
-	}
456
-	CardType = ty;	/* Card type */
457
-	deselect();
458
-
459
-	if (ty) {		/* OK */
460
-		FCLK_FAST();			/* Set fast clock */
461
-		Stat &= ~STA_NOINIT;	/* Clear STA_NOINIT flag */
462
-	} else {		/* Failed */
463
-		power_off();
464
-		Stat = STA_NOINIT;
465
-	}
466
-
467
-	return Stat;
468
-}
469
-
470
-
471
-
472
-/*-----------------------------------------------------------------------*/
473
-/* Get disk status                                                       */
474
-/*-----------------------------------------------------------------------*/
475
-
476
-DSTATUS disk_status (
477
-	BYTE drv		/* Physical drive number (0) */
478
-)
479
-{
480
-	if (drv) return STA_NOINIT;		/* Supports only drive 0 */
481
-
482
-	return Stat;	/* Return disk status */
483
-}
484
-
485
-
486
-
487
-/*-----------------------------------------------------------------------*/
488
-/* Read sector(s)                                                        */
489
-/*-----------------------------------------------------------------------*/
490
-
491
-DRESULT disk_read (
492
-	BYTE drv,		/* Physical drive number (0) */
493
-	BYTE *buff,		/* Pointer to the data buffer to store read data */
494
-	DWORD sector,	/* Start sector number (LBA) */
495
-	UINT count		/* Number of sectors to read (1..128) */
496
-)
497
-{
498
-	BYTE cmd;
499
-
500
-
501
-	if (drv || !count) return RES_PARERR;		/* Check parameter */
502
-	if (Stat & STA_NOINIT) return RES_NOTRDY;	/* Check if drive is ready */
503
-	if (!(CardType & CT_BLOCK)) sector *= 512;	/* LBA ot BA conversion (byte addressing cards) */
504
-
505
-	cmd = count > 1 ? CMD18 : CMD17;			/*  READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */
506
-	if (send_cmd(cmd, sector) == 0) {
507
-		do {
508
-			if (!rcvr_datablock(buff, 512)) break;
509
-			buff += 512;
510
-		} while (--count);
511
-		if (cmd == CMD18) send_cmd(CMD12, 0);	/* STOP_TRANSMISSION */
512
-	}
513
-	deselect();
514
-
515
-	return count ? RES_ERROR : RES_OK;	/* Return result */
516
-}
517
-
518
-
519
-
520
-/*-----------------------------------------------------------------------*/
521
-/* Write sector(s)                                                       */
522
-/*-----------------------------------------------------------------------*/
523
-
524
-#if _DISKIO_WRITE
525
-DRESULT disk_write (
526
-	BYTE drv,			/* Physical drive number (0) */
527
-	const BYTE *buff,	/* Ponter to the data to write */
528
-	DWORD sector,		/* Start sector number (LBA) */
529
-	UINT count			/* Number of sectors to write (1..128) */
530
-)
531
-{
532
-	if (drv || !count) return RES_PARERR;		/* Check parameter */
533
-	if (Stat & STA_NOINIT) return RES_NOTRDY;	/* Check drive status */
534
-	if (Stat & STA_PROTECT) return RES_WRPRT;	/* Check write protect */
535
-
536
-	if (!(CardType & CT_BLOCK)) sector *= 512;	/* LBA ==> BA conversion (byte addressing cards) */
537
-
538
-	if (count == 1) {	/* Single sector write */
539
-		if ((send_cmd(CMD24, sector) == 0)	/* WRITE_BLOCK */
540
-			&& xmit_datablock(buff, 0xFE)) {
541
-			count = 0;
542
-		}
543
-	}
544
-	else {				/* Multiple sector write */
545
-		if (CardType & CT_SDC) send_cmd(ACMD23, count);	/* Predefine number of sectors */
546
-		if (send_cmd(CMD25, sector) == 0) {	/* WRITE_MULTIPLE_BLOCK */
547
-			do {
548
-				if (!xmit_datablock(buff, 0xFC)) break;
549
-				buff += 512;
550
-			} while (--count);
551
-			if (!xmit_datablock(0, 0xFD)) count = 1;	/* STOP_TRAN token */
552
-		}
553
-	}
554
-	deselect();
555
-
556
-	return count ? RES_ERROR : RES_OK;	/* Return result */
557
-}
558
-#endif
559
-
560
-
561
-/*-----------------------------------------------------------------------*/
562
-/* Miscellaneous drive controls other than data read/write               */
563
-/*-----------------------------------------------------------------------*/
564
-
565
-#if _DISKIO_IOCTL
566
-
567
-DRESULT disk_ioctl (
568
-	BYTE drv,		/* Physical drive number (0) */
569
-	BYTE cmd,		/* Control command code */
570
-	void *buff		/* Pointer to the conrtol data */
571
-)
572
-{
573
-	DRESULT res;
574
-	BYTE n, csd[16], *ptr = buff;
575
-	DWORD *dp, st, ed, csize;
576
-#if _DISKIO_ISDIO
577
-	SDIO_CMD *sdio = buff;
578
-	BYTE rc, *buf;
579
-	UINT dc;
580
-#endif
581
-
582
-	if (drv) return RES_PARERR;					/* Check parameter */
583
-	if (Stat & STA_NOINIT) return RES_NOTRDY;	/* Check if drive is ready */
584
-
585
-	res = RES_ERROR;
586
-
587
-	switch (cmd) {
588
-	case CTRL_SYNC:			/* Wait for end of internal write process of the drive */
589
-		if (select()) res = RES_OK;
590
-		break;
591
-
592
-	case GET_SECTOR_COUNT:	/* Get drive capacity in unit of sector (DWORD) */
593
-		if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
594
-			if ((csd[0] >> 6) == 1) {	/* SDC ver 2.00 */
595
-				csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1;
596
-				*(DWORD*)buff = csize << 10;
597
-			} else {					/* SDC ver 1.XX or MMC ver 3 */
598
-				n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
599
-				csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
600
-				*(DWORD*)buff = csize << (n - 9);
601
-			}
602
-			res = RES_OK;
603
-		}
604
-		break;
605
-
606
-	case GET_BLOCK_SIZE:	/* Get erase block size in unit of sector (DWORD) */
607
-		if (CardType & CT_SD2) {	/* SDC ver 2.00 */
608
-			if (send_cmd(ACMD13, 0) == 0) {	/* Read SD status */
609
-				xchg_spi(0xFF);
610
-				if (rcvr_datablock(csd, 16)) {				/* Read partial block */
611
-					for (n = 64 - 16; n; n--) xchg_spi(0xFF);	/* Purge trailing data */
612
-					*(DWORD*)buff = 16UL << (csd[10] >> 4);
613
-					res = RES_OK;
614
-				}
615
-			}
616
-		} else {					/* SDC ver 1.XX or MMC */
617
-			if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {	/* Read CSD */
618
-				if (CardType & CT_SD1) {	/* SDC ver 1.XX */
619
-					*(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
620
-				} else {					/* MMC */
621
-					*(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
622
-				}
623
-				res = RES_OK;
624
-			}
625
-		}
626
-		break;
627
-
628
-	case CTRL_TRIM:		/* Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1) */
629
-		if (!(CardType & CT_SDC)) break;				/* Check if the card is SDC */
630
-		if (disk_ioctl(drv, MMC_GET_CSD, csd)) break;	/* Get CSD */
631
-		if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break;	/* Check if sector erase can be applied to the card */
632
-		dp = buff; st = dp[0]; ed = dp[1];				/* Load sector block */
633
-		if (!(CardType & CT_BLOCK)) {
634
-			st *= 512; ed *= 512;
635
-		}
636
-		if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) {	/* Erase sector block */
637
-			res = RES_OK;	/* FatFs does not check result of this command */
638
-		}
639
-		break;
640
-
641
-	/* Following commands are never used by FatFs module */
642
-
643
-	case MMC_GET_TYPE:		/* Get MMC/SDC type (BYTE) */
644
-		*ptr = CardType;
645
-		res = RES_OK;
646
-		break;
647
-
648
-	case MMC_GET_CSD:		/* Read CSD (16 bytes) */
649
-		if (send_cmd(CMD9, 0) == 0 && rcvr_datablock(ptr, 16)) {	/* READ_CSD */
650
-			res = RES_OK;
651
-		}
652
-		break;
653
-
654
-	case MMC_GET_CID:		/* Read CID (16 bytes) */
655
-		if (send_cmd(CMD10, 0) == 0 && rcvr_datablock(ptr, 16)) {	/* READ_CID */
656
-			res = RES_OK;
657
-		}
658
-		break;
659
-
660
-	case MMC_GET_OCR:		/* Read OCR (4 bytes) */
661
-		if (send_cmd(CMD58, 0) == 0) {	/* READ_OCR */
662
-			for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF);
663
-			res = RES_OK;
664
-		}
665
-		break;
666
-
667
-	case MMC_GET_SDSTAT:	/* Read SD status (64 bytes) */
668
-		if (send_cmd(ACMD13, 0) == 0) {	/* SD_STATUS */
669
-			xchg_spi(0xFF);
670
-			if (rcvr_datablock(ptr, 64)) res = RES_OK;
671
-		}
672
-		break;
673
-#if _DISKIO_ISDIO
674
-	case ISDIO_READ:
675
-		sdio = buff;
676
-		if (send_cmd(CMD48, 0x80000000 | sdio->func << 28 | sdio->addr << 9 | ((sdio->ndata - 1) & 0x1FF)) == 0) {
677
-			for (Timer1 = 1000; (rc = xchg_spi(0xFF)) == 0xFF && Timer1; ) ;
678
-			if (rc == 0xFE) {
679
-				for (buf = sdio->data, dc = sdio->ndata; dc; dc--) *buf++ = xchg_spi(0xFF);
680
-				for (dc = 514 - sdio->ndata; dc; dc--) xchg_spi(0xFF);
681
-				res = RES_OK;
682
-			}
683
-		}
684
-		break;
685
-	case ISDIO_WRITE:
686
-		sdio = buff;
687
-		if (send_cmd(CMD49, 0x80000000 | sdio->func << 28 | sdio->addr << 9 | ((sdio->ndata - 1) & 0x1FF)) == 0) {
688
-			xchg_spi(0xFF); xchg_spi(0xFE);
689
-			for (buf = sdio->data, dc = sdio->ndata; dc; dc--) xchg_spi(*buf++);
690
-			for (dc = 514 - sdio->ndata; dc; dc--) xchg_spi(0xFF);
691
-			if ((xchg_spi(0xFF) & 0x1F) == 0x05) res = RES_OK;
692
-		}
693
-		break;
694
-	case ISDIO_MRITE:
695
-		sdio = buff;
696
-		if (send_cmd(CMD49, 0x84000000 | sdio->func << 28 | sdio->addr << 9 | sdio->ndata >> 8) == 0) {
697
-			xchg_spi(0xFF); xchg_spi(0xFE);
698
-			xchg_spi(sdio->ndata);
699
-			for (dc = 513; dc; dc--) xchg_spi(0xFF);
700
-			if ((xchg_spi(0xFF) & 0x1F) == 0x05) res = RES_OK;
701
-		}
702
-		break;
703
-#endif
704
-	default:
705
-		res = RES_PARERR;
706
-	}
707
-
708
-	deselect();
709
-	return res;
710
-}
711
-#endif
712
-
713
-
714
-/*-----------------------------------------------------------------------*/
715
-/* Device timer function                                                 */
716
-/*-----------------------------------------------------------------------*/
717
-/* This function must be called from timer interrupt routine in period
718
-/  of 1 ms to generate card control timing.
719
-*/
720
-
721
-void disk_timerproc (void)
722
-{
723
-	WORD n;
724
-	BYTE s;
725
-
726
-
727
-	n = Timer1;						/* 1kHz decrement timer stopped at 0 */
728
-	if (n) Timer1 = --n;
729
-	n = Timer2;
730
-	if (n) Timer2 = --n;
731
-
732
-	s = Stat;
733
-	if (MMC_WP) {	/* Write protected */
734
-		s |= STA_PROTECT;
735
-	} else {		/* Write enabled */
736
-		s &= ~STA_PROTECT;
737
-	}
738
-	//if (MMC_CD) {	/* Card is in socket */
739
-		s &= ~STA_NODISK;
740
-	//} else {		/* Socket empty */
741
-	//	s |= (STA_NODISK | STA_NOINIT);
742
-	//}
743
-	Stat = s;
744
-}
745
-

+ 0
- 91
Marlin/src/HAL/HAL_LPC1768/chanfs/rtc176x.c 查看文件

@@ -1,91 +0,0 @@
1
-/*------------------------------------------------------------------------/
2
-/  LPC176x RTC control module
3
-/-------------------------------------------------------------------------/
4
-/
5
-/  Copyright (C) 2011, ChaN, all right reserved.
6
-/
7
-/ * This software is a free software and there is NO WARRANTY.
8
-/ * No restriction on use. You can use, modify and redistribute it for
9
-/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
10
-/ * Redistributions of source code must retain the above copyright notice.
11
-/
12
-/-------------------------------------------------------------------------*/
13
-
14
-#include "rtc176x.h"
15
-
16
-
17
-int rtc_initialize (void)
18
-{
19
-	/* Enable PCLK to the RTC */
20
-	__set_PCONP(PCRTC, 1);
21
-
22
-	/* Start RTC with external XTAL */
23
-	RTC_CCR = 0x11;
24
-
25
-	return 1;
26
-}
27
-
28
-
29
-
30
-int rtc_gettime (RTC *rtc)	/* 1:RTC valid, 0:RTC volatiled */
31
-{
32
-	DWORD d, t;
33
-
34
-
35
-	do {
36
-		t = RTC_CTIME0;
37
-		d = RTC_CTIME1;
38
-	} while (t != RTC_CTIME0 || d != RTC_CTIME1);
39
-
40
-	if (RTC_AUX & _BV(4)) {	/* If power fail has been detected, return default time. */
41
-		rtc->sec = 0; rtc->min = 0; rtc->hour = 0;
42
-		rtc->wday = 0; rtc->mday = 1; rtc->month = 1; rtc->year = 2014;
43
-		return 0;
44
-	}
45
-
46
-	rtc->sec = t & 63;
47
-	rtc->min = (t >> 8) & 63;
48
-	rtc->hour = (t >> 16) & 31;
49
-	rtc->wday = (t >> 24) & 7;
50
-	rtc->mday = d & 31;
51
-	rtc->month = (d >> 8) & 15;
52
-	rtc->year = (d >> 16) & 4095;
53
-	return 1;
54
-}
55
-
56
-
57
-
58
-
59
-int rtc_settime (const RTC *rtc)
60
-{
61
-	RTC_CCR = 0x12;		/* Stop RTC */
62
-
63
-	/* Update RTC registers */
64
-	RTC_SEC = rtc->sec;
65
-	RTC_MIN = rtc->min;
66
-	RTC_HOUR = rtc->hour;
67
-	RTC_DOW = rtc->wday;
68
-	RTC_DOM = rtc->mday;
69
-	RTC_MONTH = rtc->month;
70
-	RTC_YEAR = rtc->year;
71
-
72
-	RTC_AUX = _BV(4);	/* Clear power fail flag */
73
-	RTC_CCR = 0x11;		/* Restart RTC, Disable calibration feature */
74
-
75
-	return 1;
76
-}
77
-
78
-DWORD get_fattime (void) {
79
-  RTC rtc;
80
-
81
-  /* Get local time */
82
-  rtc_gettime(&rtc);
83
-
84
-  /* Pack date and time into a DWORD variable */
85
-  return    ((DWORD)(rtc.year - 1980) << 25)
86
-      | ((DWORD)rtc.month << 21)
87
-      | ((DWORD)rtc.mday << 16)
88
-      | ((DWORD)rtc.hour << 11)
89
-      | ((DWORD)rtc.min << 5)
90
-      | ((DWORD)rtc.sec >> 1);
91
-}

+ 0
- 22
Marlin/src/HAL/HAL_LPC1768/chanfs/rtc176x.h 查看文件

@@ -1,22 +0,0 @@
1
-#ifndef _RTC_DEFINED
2
-#define _RTC_DEFINE
3
-
4
-#include "integer.h"
5
-#include "LPC176x.h"
6
-
7
-typedef struct {
8
-	WORD	year;	/* 1..4095 */
9
-	BYTE	month;	/* 1..12 */
10
-	BYTE	mday;	/* 1.. 31 */
11
-	BYTE	wday;	/* 1..7 */
12
-	BYTE	hour;	/* 0..23 */
13
-	BYTE	min;	/* 0..59 */
14
-	BYTE	sec;	/* 0..59 */
15
-} RTC;
16
-
17
-int rtc_initialize (void);		/* Initialize RTC */
18
-int rtc_gettime (RTC*);			/* Get time */
19
-int rtc_settime (const RTC*);	/* Set time */
20
-DWORD get_fattime (void);
21
-
22
-#endif

+ 0
- 180
Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/LPC1768.ld.old 查看文件

@@ -1,180 +0,0 @@
1
-/* Linker script for mbed LPC1768 */
2
-MEMORY
3
-{
4
-/* FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K */
5
-  FLASH (rx) : ORIGIN = 16K, LENGTH = (512K - 16K)
6
-  RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
7
-
8
-  USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
9
-  ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
10
-}
11
-
12
-/* Linker script to place sections and symbol values. Should be used together
13
- * with other linker script that defines memory regions FLASH and RAM.
14
- * It references following symbols, which must be defined in code:
15
- *   Reset_Handler : Entry of reset handler
16
- * 
17
- * It defines following symbols, which code can use without definition:
18
- *   __exidx_start
19
- *   __exidx_end
20
- *   __etext
21
- *   __data_start__
22
- *   __preinit_array_start
23
- *   __preinit_array_end
24
- *   __init_array_start
25
- *   __init_array_end
26
- *   __fini_array_start
27
- *   __fini_array_end
28
- *   __data_end__
29
- *   __bss_start__
30
- *   __bss_end__
31
- *   __end__
32
- *   end
33
- *   __HeapLimit
34
- *   __StackLimit
35
- *   __StackTop
36
- *   __stack
37
- */
38
-ENTRY(Reset_Handler)
39
-
40
-SECTIONS
41
-{
42
-    .text :
43
-    {
44
-        KEEP(*(.isr_vector))
45
-        *(.text*)
46
-
47
-        KEEP(*(.init))
48
-        KEEP(*(.fini))
49
-
50
-        /* .ctors */
51
-        *crtbegin.o(.ctors)
52
-        *crtbegin?.o(.ctors)
53
-        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
54
-        *(SORT(.ctors.*))
55
-        *(.ctors)
56
-
57
-        /* .dtors */
58
-        *crtbegin.o(.dtors)
59
-        *crtbegin?.o(.dtors)
60
-        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
61
-        *(SORT(.dtors.*))
62
-        *(.dtors)
63
-
64
-        *(.rodata*)
65
-
66
-        KEEP(*(.eh_frame*))
67
-    } > FLASH
68
-
69
-    .ARM.extab : 
70
-    {
71
-        *(.ARM.extab* .gnu.linkonce.armextab.*)
72
-    } > FLASH
73
-
74
-    __exidx_start = .;
75
-    .ARM.exidx :
76
-    {
77
-        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
78
-    } > FLASH
79
-    __exidx_end = .;
80
-
81
-    __etext = .;
82
-        
83
-    .data : AT (__etext)
84
-    {
85
-        __data_start__ = .;
86
-        Image$$RW_IRAM1$$Base = .;
87
-        *(vtable)
88
-        *(.data*)
89
-
90
-        . = ALIGN(4);
91
-        /* preinit data */
92
-        PROVIDE (__preinit_array_start = .);
93
-        KEEP(*(.preinit_array))
94
-        PROVIDE (__preinit_array_end = .);
95
-
96
-        . = ALIGN(4);
97
-        /* init data */
98
-        PROVIDE (__init_array_start = .);
99
-        KEEP(*(SORT(.init_array.*)))
100
-        KEEP(*(.init_array))
101
-        PROVIDE (__init_array_end = .);
102
-
103
-
104
-        . = ALIGN(4);
105
-        /* finit data */
106
-        PROVIDE (__fini_array_start = .);
107
-        KEEP(*(SORT(.fini_array.*)))
108
-        KEEP(*(.fini_array))
109
-        PROVIDE (__fini_array_end = .);
110
-
111
-        . = ALIGN(4);
112
-        /* All data end */
113
-        __data_end__ = .;
114
-
115
-    } > RAM
116
-
117
-    .bss :
118
-    {
119
-        __bss_start__ = .;
120
-        *(.bss*)
121
-        *(COMMON)
122
-        __bss_end__ = .;
123
-        Image$$RW_IRAM1$$ZI$$Limit = . ;
124
-    } > RAM
125
-    
126
-    .heap :
127
-    {
128
-        __end__ = .;
129
-        end = __end__;
130
-        *(.heap*)
131
-        __HeapLimit = .;
132
-    } > RAM
133
-
134
-    /* .stack_dummy section doesn't contains any symbols. It is only
135
-     * used for linker to calculate size of stack sections, and assign
136
-     * values to stack symbols later */
137
-    .stack_dummy :
138
-    {
139
-        *(.stack)
140
-    } > RAM
141
-
142
-    /* Set stack top to end of RAM, and stack limit move down by
143
-     * size of stack_dummy section */
144
-    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
145
-    __StackLimit = __StackTop - SIZEOF(.stack_dummy);
146
-    PROVIDE(__stack = __StackTop);
147
-    PROVIDE(__heapLimit = __HeapLimit);
148
-    PROVIDE(__stackSize = __StackTop - __HeapLimit);
149
-
150
-    /* Area of memory, heap and stack, to fill on startup - 8 bytes at a time. */
151
-    __FillStart = ALIGN(__end__, 8);
152
-    
153
-    /* Check if data + heap + stack exceeds RAM limit */
154
-    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
155
-
156
-
157
-    /* Code can explicitly ask for data to be 
158
-       placed in these higher RAM banks where
159
-       they will be left uninitialized. 
160
-    */
161
-    .AHBSRAM0 (NOLOAD):
162
-    {
163
-        Image$$RW_IRAM2$$Base = . ;
164
-        PROVIDE(__AHB0_block_start = .);
165
-        *(AHBSRAM0)
166
-        Image$$RW_IRAM2$$ZI$$Limit = .;
167
-        PROVIDE(__AHB0_dyn_start = .);
168
-        PROVIDE(__AHB0_end = ORIGIN(USB_RAM) + LENGTH(USB_RAM));
169
-    } > USB_RAM
170
-
171
-    .AHBSRAM1 (NOLOAD):
172
-    {
173
-        Image$$RW_IRAM3$$Base = . ;
174
-        PROVIDE(__AHB1_block_start = .);
175
-        *(AHBSRAM1)
176
-        Image$$RW_IRAM3$$ZI$$Limit = .;
177
-        PROVIDE(__AHB1_dyn_start = .);
178
-        PROVIDE(__AHB1_end = ORIGIN(ETH_RAM) + LENGTH(ETH_RAM));
179
-    } > ETH_RAM
180
-}

+ 0
- 223
Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/startup_LPC17xx.S.old 查看文件

@@ -1,223 +0,0 @@
1
-/* File: startup_ARMCM3.s
2
- * Purpose: startup file for Cortex-M3/M4 devices. Should use with 
3
- *   GNU Tools for ARM Embedded Processors
4
- * Version: V1.1
5
- * Date: 17 June 2011
6
- * 
7
- * Copyright (C) 2011 ARM Limited. All rights reserved.
8
- * ARM Limited (ARM) is supplying this software for use with Cortex-M3/M4 
9
- * processor based microcontrollers.  This file can be freely distributed 
10
- * within development tools that are supporting such ARM based processors. 
11
- *
12
- * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
13
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
14
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
15
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
16
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
17
- */
18
-    .syntax unified
19
-    .arch armv7-m
20
-
21
-/* Memory Model
22
-   The HEAP starts at the end of the DATA section and grows upward.
23
-   
24
-   The STACK starts at the end of the RAM and grows downward.
25
-   
26
-   The HEAP and stack STACK are only checked at compile time:
27
-   (DATA_SIZE + HEAP_SIZE + STACK_SIZE) < RAM_SIZE
28
-   
29
-   This is just a check for the bare minimum for the Heap+Stack area before
30
-   aborting compilation, it is not the run time limit:
31
-   Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100
32
- */
33
-    .section .stack
34
-    .align 3
35
-#ifdef __STACK_SIZE
36
-    .equ    Stack_Size, __STACK_SIZE
37
-#else
38
-    .equ    Stack_Size, 0xc00
39
-#endif
40
-    .globl    __StackTop
41
-    .globl    __StackLimit
42
-__StackLimit:
43
-    .space    Stack_Size
44
-    .size __StackLimit, . - __StackLimit
45
-__StackTop:
46
-    .size __StackTop, . - __StackTop
47
-
48
-    .section .heap
49
-    .align 3
50
-#ifdef __HEAP_SIZE
51
-    .equ    Heap_Size, __HEAP_SIZE
52
-#else
53
-    .equ    Heap_Size, 0x800
54
-#endif
55
-    .globl    __HeapBase
56
-    .globl    __HeapLimit
57
-__HeapBase:
58
-    .space    Heap_Size
59
-    .size __HeapBase, . - __HeapBase
60
-__HeapLimit:
61
-    .size __HeapLimit, . - __HeapLimit
62
-    
63
-    .section .isr_vector
64
-    .align 2
65
-    .globl __isr_vector
66
-__isr_vector:
67
-    .long    __StackTop            /* Top of Stack */
68
-    .long    Reset_Handler         /* Reset Handler */
69
-    .long    NMI_Handler           /* NMI Handler */
70
-    .long    HardFault_Handler     /* Hard Fault Handler */
71
-    .long    MemManage_Handler     /* MPU Fault Handler */
72
-    .long    BusFault_Handler      /* Bus Fault Handler */
73
-    .long    UsageFault_Handler    /* Usage Fault Handler */
74
-    .long    0                     /* Reserved */
75
-    .long    0                     /* Reserved */
76
-    .long    0                     /* Reserved */
77
-    .long    0                     /* Reserved */
78
-    .long    SVC_Handler           /* SVCall Handler */
79
-    .long    DebugMon_Handler      /* Debug Monitor Handler */
80
-    .long    0                     /* Reserved */
81
-    .long    PendSV_Handler        /* PendSV Handler */
82
-    .long    SysTick_Handler       /* SysTick Handler */
83
-
84
-    /* External interrupts */
85
-    .long   WDT_IRQHandler              /* 16: Watchdog Timer               */
86
-    .long   TIMER0_IRQHandler           /* 17: Timer0                       */
87
-    .long   TIMER1_IRQHandler           /* 18: Timer1                       */
88
-    .long   TIMER2_IRQHandler           /* 19: Timer2                       */
89
-    .long   TIMER3_IRQHandler           /* 20: Timer3                       */
90
-    .long   UART0_IRQHandler            /* 21: UART0                        */
91
-    .long   UART1_IRQHandler            /* 22: UART1                        */
92
-    .long   UART2_IRQHandler            /* 23: UART2                        */
93
-    .long   UART3_IRQHandler            /* 24: UART3                        */
94
-    .long   PWM1_IRQHandler             /* 25: PWM1                         */
95
-    .long   I2C0_IRQHandler             /* 26: I2C0                         */
96
-    .long   I2C1_IRQHandler             /* 27: I2C1                         */
97
-    .long   I2C2_IRQHandler             /* 28: I2C2                         */
98
-    .long   SPI_IRQHandler              /* 29: SPI                          */
99
-    .long   SSP0_IRQHandler             /* 30: SSP0                         */
100
-    .long   SSP1_IRQHandler             /* 31: SSP1                         */
101
-    .long   PLL0_IRQHandler             /* 32: PLL0 Lock (Main PLL)         */
102
-    .long   RTC_IRQHandler              /* 33: Real Time Clock              */
103
-    .long   EINT0_IRQHandler            /* 34: External Interrupt 0         */
104
-    .long   EINT1_IRQHandler            /* 35: External Interrupt 1         */
105
-    .long   EINT2_IRQHandler            /* 36: External Interrupt 2         */
106
-    .long   EINT3_IRQHandler            /* 37: External Interrupt 3         */
107
-    .long   ADC_IRQHandler              /* 38: A/D Converter                */
108
-    .long   BOD_IRQHandler              /* 39: Brown-Out Detect             */
109
-    .long   USB_IRQHandler              /* 40: USB                          */
110
-    .long   CAN_IRQHandler              /* 41: CAN                          */
111
-    .long   DMA_IRQHandler              /* 42: General Purpose DMA          */
112
-    .long   I2S_IRQHandler              /* 43: I2S                          */
113
-    .long   ENET_IRQHandler             /* 44: Ethernet                     */
114
-    .long   RIT_IRQHandler              /* 45: Repetitive Interrupt Timer   */
115
-    .long   MCPWM_IRQHandler            /* 46: Motor Control PWM            */
116
-    .long   QEI_IRQHandler              /* 47: Quadrature Encoder Interface */
117
-    .long   PLL1_IRQHandler             /* 48: PLL1 Lock (USB PLL)          */
118
-    .long   USBActivity_IRQHandler      /* 49: USB Activity                 */
119
-    .long   CANActivity_IRQHandler      /* 50: CAN Activity                 */
120
-
121
-    .size    __isr_vector, . - __isr_vector
122
-
123
-    .text
124
-    .thumb
125
-    .thumb_func
126
-    .align 2
127
-    .globl    Reset_Handler
128
-    .type    Reset_Handler, %function
129
-Reset_Handler:
130
-/*     Loop to copy data from read only memory to RAM. The ranges
131
- *      of copy from/to are specified by following symbols evaluated in 
132
- *      linker script.
133
- *      _etext: End of code section, i.e., begin of data sections to copy from.
134
- *      __data_start__/__data_end__: RAM address range that data should be
135
- *      copied to. Both must be aligned to 4 bytes boundary.  */
136
-
137
-    ldr    r1, =__etext
138
-    ldr    r2, =__data_start__
139
-    ldr    r3, =__data_end__
140
-
141
-.Lflash_to_ram_loop:
142
-    cmp     r2, r3
143
-    ittt    lt
144
-    ldrlt   r0, [r1], #4
145
-    strlt   r0, [r2], #4
146
-    blt    .Lflash_to_ram_loop
147
-
148
-    ldr    r0, =SystemInit
149
-    blx    r0
150
-    ldr    r0, =_start
151
-    bx    r0
152
-    .pool
153
-    .size Reset_Handler, . - Reset_Handler
154
-    
155
-    .text
156
-/*    Macro to define default handlers. Default handler
157
- *    will be weak symbol and just dead loops. They can be
158
- *    overwritten by other handlers */
159
-    .macro    def_default_handler    handler_name
160
-    .align 1
161
-    .thumb_func
162
-    .weak    \handler_name
163
-    .type    \handler_name, %function
164
-\handler_name :
165
-    b    .
166
-    .size    \handler_name, . - \handler_name
167
-    .endm
168
-
169
-    def_default_handler    NMI_Handler
170
-    def_default_handler    HardFault_Handler
171
-    def_default_handler    MemManage_Handler
172
-    def_default_handler    BusFault_Handler
173
-    def_default_handler    UsageFault_Handler
174
-    def_default_handler    SVC_Handler
175
-    def_default_handler    DebugMon_Handler
176
-    def_default_handler    PendSV_Handler
177
-    def_default_handler    SysTick_Handler
178
-    def_default_handler    Default_Handler
179
-
180
-    .macro    def_irq_default_handler    handler_name
181
-    .weak     \handler_name
182
-    .set      \handler_name, Default_Handler
183
-    .endm
184
- 
185
-    def_irq_default_handler     WDT_IRQHandler
186
-    def_irq_default_handler     TIMER0_IRQHandler
187
-    def_irq_default_handler     TIMER1_IRQHandler
188
-    def_irq_default_handler     TIMER2_IRQHandler
189
-    def_irq_default_handler     TIMER3_IRQHandler
190
-    def_irq_default_handler     UART0_IRQHandler
191
-    def_irq_default_handler     UART1_IRQHandler
192
-    def_irq_default_handler     UART2_IRQHandler
193
-    def_irq_default_handler     UART3_IRQHandler
194
-    def_irq_default_handler     PWM1_IRQHandler
195
-    def_irq_default_handler     I2C0_IRQHandler
196
-    def_irq_default_handler     I2C1_IRQHandler
197
-    def_irq_default_handler     I2C2_IRQHandler
198
-    def_irq_default_handler     SPI_IRQHandler
199
-    def_irq_default_handler     SSP0_IRQHandler
200
-    def_irq_default_handler     SSP1_IRQHandler
201
-    def_irq_default_handler     PLL0_IRQHandler
202
-    def_irq_default_handler     RTC_IRQHandler
203
-    def_irq_default_handler     EINT0_IRQHandler
204
-    def_irq_default_handler     EINT1_IRQHandler
205
-    def_irq_default_handler     EINT2_IRQHandler
206
-    def_irq_default_handler     EINT3_IRQHandler
207
-    def_irq_default_handler     ADC_IRQHandler
208
-    def_irq_default_handler     BOD_IRQHandler
209
-    def_irq_default_handler     USB_IRQHandler
210
-    def_irq_default_handler     CAN_IRQHandler
211
-    def_irq_default_handler     DMA_IRQHandler
212
-    def_irq_default_handler     I2S_IRQHandler
213
-    def_irq_default_handler     ENET_IRQHandler
214
-    def_irq_default_handler     RIT_IRQHandler
215
-    def_irq_default_handler     MCPWM_IRQHandler
216
-    def_irq_default_handler     QEI_IRQHandler
217
-    def_irq_default_handler     PLL1_IRQHandler
218
-    def_irq_default_handler     USBActivity_IRQHandler
219
-    def_irq_default_handler     CANActivity_IRQHandler
220
-    def_irq_default_handler     DEF_IRQHandler
221
-
222
-    .end
223
-

+ 0
- 584
Marlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/system_LPC17xx.c.old 查看文件

@@ -1,584 +0,0 @@
1
-/**************************************************************************//**
2
- * @file     system_LPC17xx.c
3
- * @brief    CMSIS Cortex-M3 Device System Source File for
4
- *           NXP LPC17xx Device Series
5
- * @version  V1.11
6
- * @date     21. June 2011
7
- *
8
- * @note
9
- * Copyright (C) 2009-2011 ARM Limited. All rights reserved.
10
- *
11
- * @par
12
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
13
- * processor based microcontrollers.  This file can be freely distributed
14
- * within development tools that are supporting such ARM based processors.
15
- *
16
- * @par
17
- * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
21
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22
- *
23
- ******************************************************************************/
24
-
25
-
26
-#include <stdint.h>
27
-#include "LPC17xx.h"
28
-
29
-
30
-/** @addtogroup LPC17xx_System
31
- * @{
32
- */
33
-
34
-/*
35
-//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
36
-*/
37
-
38
-/*--------------------- Clock Configuration ----------------------------------
39
-//
40
-// <e> Clock Configuration
41
-//   <h> System Controls and Status Register (SCS)
42
-//     <o1.4>    OSCRANGE: Main Oscillator Range Select
43
-//                     <0=>  1 MHz to 20 MHz
44
-//                     <1=> 15 MHz to 25 MHz
45
-//     <e1.5>       OSCEN: Main Oscillator Enable
46
-//     </e>
47
-//   </h>
48
-//
49
-//   <h> Clock Source Select Register (CLKSRCSEL)
50
-//     <o2.0..1>   CLKSRC: PLL Clock Source Selection
51
-//                     <0=> Internal RC oscillator
52
-//                     <1=> Main oscillator
53
-//                     <2=> RTC oscillator
54
-//   </h>
55
-//
56
-//   <e3> PLL0 Configuration (Main PLL)
57
-//     <h> PLL0 Configuration Register (PLL0CFG)
58
-//                     <i> F_cco0 = (2 * M * F_in) / N
59
-//                     <i> F_in must be in the range of 32 kHz to 50 MHz
60
-//                     <i> F_cco0 must be in the range of 275 MHz to 550 MHz
61
-//       <o4.0..14>  MSEL: PLL Multiplier Selection
62
-//                     <6-32768><#-1>
63
-//                     <i> M Value
64
-//       <o4.16..23> NSEL: PLL Divider Selection
65
-//                     <1-256><#-1>
66
-//                     <i> N Value
67
-//     </h>
68
-//   </e>
69
-//
70
-//   <e5> PLL1 Configuration (USB PLL)
71
-//     <h> PLL1 Configuration Register (PLL1CFG)
72
-//                     <i> F_usb = M * F_osc or F_usb = F_cco1 / (2 * P)
73
-//                     <i> F_cco1 = F_osc * M * 2 * P
74
-//                     <i> F_cco1 must be in the range of 156 MHz to 320 MHz
75
-//       <o6.0..4>   MSEL: PLL Multiplier Selection
76
-//                     <1-32><#-1>
77
-//                     <i> M Value (for USB maximum value is 4)
78
-//       <o6.5..6>   PSEL: PLL Divider Selection
79
-//                     <0=> 1
80
-//                     <1=> 2
81
-//                     <2=> 4
82
-//                     <3=> 8
83
-//                     <i> P Value
84
-//     </h>
85
-//   </e>
86
-//
87
-//   <h> CPU Clock Configuration Register (CCLKCFG)
88
-//     <o7.0..7>  CCLKSEL: Divide Value for CPU Clock from PLL0
89
-//                     <1-256><#-1>
90
-//   </h>
91
-//
92
-//   <h> USB Clock Configuration Register (USBCLKCFG)
93
-//     <o8.0..3>   USBSEL: Divide Value for USB Clock from PLL0
94
-//                     <0-15>
95
-//                     <i> Divide is USBSEL + 1
96
-//   </h>
97
-//
98
-//   <h> Peripheral Clock Selection Register 0 (PCLKSEL0)
99
-//     <o9.0..1>    PCLK_WDT: Peripheral Clock Selection for WDT
100
-//                     <0=> Pclk = Cclk / 4
101
-//                     <1=> Pclk = Cclk
102
-//                     <2=> Pclk = Cclk / 2
103
-//                     <3=> Pclk = Hclk / 8
104
-//     <o9.2..3>    PCLK_TIMER0: Peripheral Clock Selection for TIMER0
105
-//                     <0=> Pclk = Cclk / 4
106
-//                     <1=> Pclk = Cclk
107
-//                     <2=> Pclk = Cclk / 2
108
-//                     <3=> Pclk = Hclk / 8
109
-//     <o9.4..5>    PCLK_TIMER1: Peripheral Clock Selection for TIMER1
110
-//                     <0=> Pclk = Cclk / 4
111
-//                     <1=> Pclk = Cclk
112
-//                     <2=> Pclk = Cclk / 2
113
-//                     <3=> Pclk = Hclk / 8
114
-//     <o9.6..7>    PCLK_UART0: Peripheral Clock Selection for UART0
115
-//                     <0=> Pclk = Cclk / 4
116
-//                     <1=> Pclk = Cclk
117
-//                     <2=> Pclk = Cclk / 2
118
-//                     <3=> Pclk = Hclk / 8
119
-//     <o9.8..9>    PCLK_UART1: Peripheral Clock Selection for UART1
120
-//                     <0=> Pclk = Cclk / 4
121
-//                     <1=> Pclk = Cclk
122
-//                     <2=> Pclk = Cclk / 2
123
-//                     <3=> Pclk = Hclk / 8
124
-//     <o9.12..13>  PCLK_PWM1: Peripheral Clock Selection for PWM1
125
-//                     <0=> Pclk = Cclk / 4
126
-//                     <1=> Pclk = Cclk
127
-//                     <2=> Pclk = Cclk / 2
128
-//                     <3=> Pclk = Hclk / 8
129
-//     <o9.14..15>  PCLK_I2C0: Peripheral Clock Selection for I2C0
130
-//                     <0=> Pclk = Cclk / 4
131
-//                     <1=> Pclk = Cclk
132
-//                     <2=> Pclk = Cclk / 2
133
-//                     <3=> Pclk = Hclk / 8
134
-//     <o9.16..17>  PCLK_SPI: Peripheral Clock Selection for SPI
135
-//                     <0=> Pclk = Cclk / 4
136
-//                     <1=> Pclk = Cclk
137
-//                     <2=> Pclk = Cclk / 2
138
-//                     <3=> Pclk = Hclk / 8
139
-//     <o9.20..21>  PCLK_SSP1: Peripheral Clock Selection for SSP1
140
-//                     <0=> Pclk = Cclk / 4
141
-//                     <1=> Pclk = Cclk
142
-//                     <2=> Pclk = Cclk / 2
143
-//                     <3=> Pclk = Hclk / 8
144
-//     <o9.22..23>  PCLK_DAC: Peripheral Clock Selection for DAC
145
-//                     <0=> Pclk = Cclk / 4
146
-//                     <1=> Pclk = Cclk
147
-//                     <2=> Pclk = Cclk / 2
148
-//                     <3=> Pclk = Hclk / 8
149
-//     <o9.24..25>  PCLK_ADC: Peripheral Clock Selection for ADC
150
-//                     <0=> Pclk = Cclk / 4
151
-//                     <1=> Pclk = Cclk
152
-//                     <2=> Pclk = Cclk / 2
153
-//                     <3=> Pclk = Hclk / 8
154
-//     <o9.26..27>  PCLK_CAN1: Peripheral Clock Selection for CAN1
155
-//                     <0=> Pclk = Cclk / 4
156
-//                     <1=> Pclk = Cclk
157
-//                     <2=> Pclk = Cclk / 2
158
-//                     <3=> Pclk = Hclk / 6
159
-//     <o9.28..29>  PCLK_CAN2: Peripheral Clock Selection for CAN2
160
-//                     <0=> Pclk = Cclk / 4
161
-//                     <1=> Pclk = Cclk
162
-//                     <2=> Pclk = Cclk / 2
163
-//                     <3=> Pclk = Hclk / 6
164
-//     <o9.30..31>  PCLK_ACF: Peripheral Clock Selection for ACF
165
-//                     <0=> Pclk = Cclk / 4
166
-//                     <1=> Pclk = Cclk
167
-//                     <2=> Pclk = Cclk / 2
168
-//                     <3=> Pclk = Hclk / 6
169
-//   </h>
170
-//
171
-//   <h> Peripheral Clock Selection Register 1 (PCLKSEL1)
172
-//     <o10.0..1>   PCLK_QEI: Peripheral Clock Selection for the Quadrature Encoder Interface
173
-//                     <0=> Pclk = Cclk / 4
174
-//                     <1=> Pclk = Cclk
175
-//                     <2=> Pclk = Cclk / 2
176
-//                     <3=> Pclk = Hclk / 8
177
-//     <o10.2..3>   PCLK_GPIO: Peripheral Clock Selection for GPIOs
178
-//                     <0=> Pclk = Cclk / 4
179
-//                     <1=> Pclk = Cclk
180
-//                     <2=> Pclk = Cclk / 2
181
-//                     <3=> Pclk = Hclk / 8
182
-//     <o10.4..5>   PCLK_PCB: Peripheral Clock Selection for the Pin Connect Block
183
-//                     <0=> Pclk = Cclk / 4
184
-//                     <1=> Pclk = Cclk
185
-//                     <2=> Pclk = Cclk / 2
186
-//                     <3=> Pclk = Hclk / 8
187
-//     <o10.6..7>   PCLK_I2C1: Peripheral Clock Selection for I2C1
188
-//                     <0=> Pclk = Cclk / 4
189
-//                     <1=> Pclk = Cclk
190
-//                     <2=> Pclk = Cclk / 2
191
-//                     <3=> Pclk = Hclk / 8
192
-//     <o10.10..11> PCLK_SSP0: Peripheral Clock Selection for SSP0
193
-//                     <0=> Pclk = Cclk / 4
194
-//                     <1=> Pclk = Cclk
195
-//                     <2=> Pclk = Cclk / 2
196
-//                     <3=> Pclk = Hclk / 8
197
-//     <o10.12..13> PCLK_TIMER2: Peripheral Clock Selection for TIMER2
198
-//                     <0=> Pclk = Cclk / 4
199
-//                     <1=> Pclk = Cclk
200
-//                     <2=> Pclk = Cclk / 2
201
-//                     <3=> Pclk = Hclk / 8
202
-//     <o10.14..15> PCLK_TIMER3: Peripheral Clock Selection for TIMER3
203
-//                     <0=> Pclk = Cclk / 4
204
-//                     <1=> Pclk = Cclk
205
-//                     <2=> Pclk = Cclk / 2
206
-//                     <3=> Pclk = Hclk / 8
207
-//     <o10.16..17> PCLK_UART2: Peripheral Clock Selection for UART2
208
-//                     <0=> Pclk = Cclk / 4
209
-//                     <1=> Pclk = Cclk
210
-//                     <2=> Pclk = Cclk / 2
211
-//                     <3=> Pclk = Hclk / 8
212
-//     <o10.18..19> PCLK_UART3: Peripheral Clock Selection for UART3
213
-//                     <0=> Pclk = Cclk / 4
214
-//                     <1=> Pclk = Cclk
215
-//                     <2=> Pclk = Cclk / 2
216
-//                     <3=> Pclk = Hclk / 8
217
-//     <o10.20..21> PCLK_I2C2: Peripheral Clock Selection for I2C2
218
-//                     <0=> Pclk = Cclk / 4
219
-//                     <1=> Pclk = Cclk
220
-//                     <2=> Pclk = Cclk / 2
221
-//                     <3=> Pclk = Hclk / 8
222
-//     <o10.22..23> PCLK_I2S: Peripheral Clock Selection for I2S
223
-//                     <0=> Pclk = Cclk / 4
224
-//                     <1=> Pclk = Cclk
225
-//                     <2=> Pclk = Cclk / 2
226
-//                     <3=> Pclk = Hclk / 8
227
-//     <o10.26..27> PCLK_RIT: Peripheral Clock Selection for the Repetitive Interrupt Timer
228
-//                     <0=> Pclk = Cclk / 4
229
-//                     <1=> Pclk = Cclk
230
-//                     <2=> Pclk = Cclk / 2
231
-//                     <3=> Pclk = Hclk / 8
232
-//     <o10.28..29> PCLK_SYSCON: Peripheral Clock Selection for the System Control Block
233
-//                     <0=> Pclk = Cclk / 4
234
-//                     <1=> Pclk = Cclk
235
-//                     <2=> Pclk = Cclk / 2
236
-//                     <3=> Pclk = Hclk / 8
237
-//     <o10.30..31> PCLK_MC: Peripheral Clock Selection for the Motor Control PWM
238
-//                     <0=> Pclk = Cclk / 4
239
-//                     <1=> Pclk = Cclk
240
-//                     <2=> Pclk = Cclk / 2
241
-//                     <3=> Pclk = Hclk / 8
242
-//   </h>
243
-//
244
-//   <h> Power Control for Peripherals Register (PCONP)
245
-//     <o11.1>      PCTIM0: Timer/Counter 0 power/clock enable
246
-//     <o11.2>      PCTIM1: Timer/Counter 1 power/clock enable
247
-//     <o11.3>      PCUART0: UART 0 power/clock enable
248
-//     <o11.4>      PCUART1: UART 1 power/clock enable
249
-//     <o11.6>      PCPWM1: PWM 1 power/clock enable
250
-//     <o11.7>      PCI2C0: I2C interface 0 power/clock enable
251
-//     <o11.8>      PCSPI: SPI interface power/clock enable
252
-//     <o11.9>      PCRTC: RTC power/clock enable
253
-//     <o11.10>     PCSSP1: SSP interface 1 power/clock enable
254
-//     <o11.12>     PCAD: A/D converter power/clock enable
255
-//     <o11.13>     PCCAN1: CAN controller 1 power/clock enable
256
-//     <o11.14>     PCCAN2: CAN controller 2 power/clock enable
257
-//     <o11.15>     PCGPIO: GPIOs power/clock enable
258
-//     <o11.16>     PCRIT: Repetitive interrupt timer power/clock enable
259
-//     <o11.17>     PCMC: Motor control PWM power/clock enable
260
-//     <o11.18>     PCQEI: Quadrature encoder interface power/clock enable
261
-//     <o11.19>     PCI2C1: I2C interface 1 power/clock enable
262
-//     <o11.21>     PCSSP0: SSP interface 0 power/clock enable
263
-//     <o11.22>     PCTIM2: Timer 2 power/clock enable
264
-//     <o11.23>     PCTIM3: Timer 3 power/clock enable
265
-//     <o11.24>     PCUART2: UART 2 power/clock enable
266
-//     <o11.25>     PCUART3: UART 3 power/clock enable
267
-//     <o11.26>     PCI2C2: I2C interface 2 power/clock enable
268
-//     <o11.27>     PCI2S: I2S interface power/clock enable
269
-//     <o11.29>     PCGPDMA: GP DMA function power/clock enable
270
-//     <o11.30>     PCENET: Ethernet block power/clock enable
271
-//     <o11.31>     PCUSB: USB interface power/clock enable
272
-//   </h>
273
-//
274
-//   <h> Clock Output Configuration Register (CLKOUTCFG)
275
-//     <o12.0..3>   CLKOUTSEL: Selects clock source for CLKOUT
276
-//                     <0=> CPU clock
277
-//                     <1=> Main oscillator
278
-//                     <2=> Internal RC oscillator
279
-//                     <3=> USB clock
280
-//                     <4=> RTC oscillator
281
-//     <o12.4..7>   CLKOUTDIV: Selects clock divider for CLKOUT
282
-//                     <1-16><#-1>
283
-//     <o12.8>      CLKOUT_EN: CLKOUT enable control
284
-//   </h>
285
-//
286
-// </e>
287
-*/
288
-
289
-
290
-
291
-/** @addtogroup LPC17xx_System_Defines  LPC17xx System Defines
292
-  @{
293
- */
294
-
295
-#define CLOCK_SETUP           1
296
-#define SCS_Val               0x00000020
297
-#define CLKSRCSEL_Val         0x00000001
298
-#define PLL0_SETUP            1
299
-
300
-#ifdef MCB1700
301
-#    define PLL0CFG_Val           0x00050063
302
-#    define PLL1_SETUP            1
303
-#    define PLL1CFG_Val           0x00000023
304
-#    define CCLKCFG_Val           0x00000003
305
-#    define USBCLKCFG_Val         0x00000000
306
-#else
307
-#    define PLL0CFG_Val           0x0000000B
308
-#    define PLL1_SETUP            0
309
-#    define PLL1CFG_Val           0x00000000
310
-#    define CCLKCFG_Val           0x00000002
311
-#    define USBCLKCFG_Val         0x00000005
312
-#endif
313
-
314
-#define PCLKSEL0_Val          0x00000000
315
-#define PCLKSEL1_Val          0x00000000
316
-#define PCONP_Val             0x042887DE
317
-#define CLKOUTCFG_Val         0x00000000
318
-
319
-
320
-/*--------------------- Flash Accelerator Configuration ----------------------
321
-//
322
-// <e> Flash Accelerator Configuration
323
-//   <o1.12..15> FLASHTIM: Flash Access Time
324
-//               <0=> 1 CPU clock (for CPU clock up to 20 MHz)
325
-//               <1=> 2 CPU clocks (for CPU clock up to 40 MHz)
326
-//               <2=> 3 CPU clocks (for CPU clock up to 60 MHz)
327
-//               <3=> 4 CPU clocks (for CPU clock up to 80 MHz)
328
-//               <4=> 5 CPU clocks (for CPU clock up to 100 MHz)
329
-//               <5=> 6 CPU clocks (for any CPU clock)
330
-// </e>
331
-*/
332
-#define FLASH_SETUP           1
333
-#define FLASHCFG_Val          0x0000303A
334
-
335
-/*
336
-//-------- <<< end of configuration section >>> ------------------------------
337
-*/
338
-
339
-/*----------------------------------------------------------------------------
340
-  Check the register settings
341
- *----------------------------------------------------------------------------*/
342
-#define CHECK_RANGE(val, min, max)                ((val < min) || (val > max))
343
-#define CHECK_RSVD(val, mask)                     (val & mask)
344
-
345
-/* Clock Configuration -------------------------------------------------------*/
346
-#if (CHECK_RSVD((SCS_Val),       ~0x00000030))
347
-   #error "SCS: Invalid values of reserved bits!"
348
-#endif
349
-
350
-#if (CHECK_RANGE((CLKSRCSEL_Val), 0, 2))
351
-   #error "CLKSRCSEL: Value out of range!"
352
-#endif
353
-
354
-#if (CHECK_RSVD((PLL0CFG_Val),   ~0x00FF7FFF))
355
-   #error "PLL0CFG: Invalid values of reserved bits!"
356
-#endif
357
-
358
-#if (CHECK_RSVD((PLL1CFG_Val),   ~0x0000007F))
359
-   #error "PLL1CFG: Invalid values of reserved bits!"
360
-#endif
361
-
362
-#if (PLL0_SETUP)            /* if PLL0 is used */
363
-  #if (CCLKCFG_Val < 2)     /* CCLKSEL must be greater then 1 */
364
-    #error "CCLKCFG: CCLKSEL must be greater then 1 if PLL0 is used!"
365
-  #endif
366
-#endif
367
-
368
-#if (CHECK_RANGE((CCLKCFG_Val), 2, 255))
369
-   #error "CCLKCFG: Value out of range!"
370
-#endif
371
-
372
-#if (CHECK_RSVD((USBCLKCFG_Val), ~0x0000000F))
373
-   #error "USBCLKCFG: Invalid values of reserved bits!"
374
-#endif
375
-
376
-#if (CHECK_RSVD((PCLKSEL0_Val),   0x000C0C00))
377
-   #error "PCLKSEL0: Invalid values of reserved bits!"
378
-#endif
379
-
380
-#if (CHECK_RSVD((PCLKSEL1_Val),   0x03000300))
381
-   #error "PCLKSEL1: Invalid values of reserved bits!"
382
-#endif
383
-
384
-#if (CHECK_RSVD((PCONP_Val),      0x10100821))
385
-   #error "PCONP: Invalid values of reserved bits!"
386
-#endif
387
-
388
-#if (CHECK_RSVD((CLKOUTCFG_Val), ~0x000001FF))
389
-   #error "CLKOUTCFG: Invalid values of reserved bits!"
390
-#endif
391
-
392
-/* Flash Accelerator Configuration -------------------------------------------*/
393
-#if (CHECK_RSVD((FLASHCFG_Val), ~0x0000F07F))
394
-   #error "FLASHCFG: Invalid values of reserved bits!"
395
-#endif
396
-
397
-
398
-/*----------------------------------------------------------------------------
399
-  DEFINES
400
- *----------------------------------------------------------------------------*/
401
-
402
-/*----------------------------------------------------------------------------
403
-  Define clocks
404
- *----------------------------------------------------------------------------*/
405
-#define XTAL        (12000000UL)        /* Oscillator frequency               */
406
-#define OSC_CLK     (      XTAL)        /* Main oscillator frequency          */
407
-#define RTC_CLK     (   32000UL)        /* RTC oscillator frequency           */
408
-#define IRC_OSC     ( 4000000UL)        /* Internal RC oscillator frequency   */
409
-
410
-
411
-/* F_cco0 = (2 * M * F_in) / N  */
412
-#define __M               (((PLL0CFG_Val      ) & 0x7FFF) + 1)
413
-#define __N               (((PLL0CFG_Val >> 16) & 0x00FF) + 1)
414
-#define __FCCO(__F_IN)    ((2ULL * __M * __F_IN) / __N)
415
-#define __CCLK_DIV        (((CCLKCFG_Val      ) & 0x00FF) + 1)
416
-
417
-/* Determine core clock frequency according to settings */
418
- #if (PLL0_SETUP)
419
-    #if   ((CLKSRCSEL_Val & 0x03) == 1)
420
-        #define __CORE_CLK (__FCCO(OSC_CLK) / __CCLK_DIV)
421
-    #elif ((CLKSRCSEL_Val & 0x03) == 2)
422
-        #define __CORE_CLK (__FCCO(RTC_CLK) / __CCLK_DIV)
423
-    #else
424
-        #define __CORE_CLK (__FCCO(IRC_OSC) / __CCLK_DIV)
425
-    #endif
426
- #else
427
-    #if   ((CLKSRCSEL_Val & 0x03) == 1)
428
-        #define __CORE_CLK (OSC_CLK         / __CCLK_DIV)
429
-    #elif ((CLKSRCSEL_Val & 0x03) == 2)
430
-        #define __CORE_CLK (RTC_CLK         / __CCLK_DIV)
431
-    #else
432
-        #define __CORE_CLK (IRC_OSC         / __CCLK_DIV)
433
-    #endif
434
- #endif
435
-
436
-/**
437
- * @}
438
- */
439
-
440
-
441
-/** @addtogroup LPC17xx_System_Public_Variables  LPC17xx System Public Variables
442
-  @{
443
- */
444
-/*----------------------------------------------------------------------------
445
-  Clock Variable definitions
446
- *----------------------------------------------------------------------------*/
447
-uint32_t SystemCoreClock = __CORE_CLK;/*!< System Clock Frequency (Core Clock)*/
448
-
449
-/**
450
- * @}
451
- */
452
-
453
-
454
-/** @addtogroup LPC17xx_System_Public_Functions  LPC17xx System Public Functions
455
-  @{
456
- */
457
-
458
-/**
459
- * Update SystemCoreClock variable
460
- *
461
- * @param  none
462
- * @return none
463
- *
464
- * @brief  Updates the SystemCoreClock with current core Clock
465
- *         retrieved from cpu registers.
466
- */void SystemCoreClockUpdate (void)            /* Get Core Clock Frequency      */
467
-{
468
-  /* Determine clock frequency according to clock register values             */
469
-  if (((LPC_SC->PLL0STAT >> 24) & 3) == 3) { /* If PLL0 enabled and connected */
470
-    switch (LPC_SC->CLKSRCSEL & 0x03) {
471
-      case 0:                                /* Int. RC oscillator => PLL0    */
472
-      case 3:                                /* Reserved, default to Int. RC  */
473
-        SystemCoreClock = (IRC_OSC *
474
-                          ((2ULL * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
475
-                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)       /
476
-                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
477
-        break;
478
-      case 1:                                /* Main oscillator => PLL0       */
479
-        SystemCoreClock = (OSC_CLK *
480
-                          ((2ULL * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
481
-                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)       /
482
-                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
483
-        break;
484
-      case 2:                                /* RTC oscillator => PLL0        */
485
-        SystemCoreClock = (RTC_CLK *
486
-                          ((2ULL * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
487
-                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)       /
488
-                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
489
-        break;
490
-    }
491
-  } else {
492
-    switch (LPC_SC->CLKSRCSEL & 0x03) {
493
-      case 0:                                /* Int. RC oscillator => PLL0    */
494
-      case 3:                                /* Reserved, default to Int. RC  */
495
-        SystemCoreClock = IRC_OSC / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
496
-        break;
497
-      case 1:                                /* Main oscillator => PLL0       */
498
-        SystemCoreClock = OSC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
499
-        break;
500
-      case 2:                                /* RTC oscillator => PLL0        */
501
-        SystemCoreClock = RTC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
502
-        break;
503
-    }
504
-  }
505
-
506
-}
507
-
508
-/**
509
- * Initialize the system
510
- *
511
- * @param  none
512
- * @return none
513
- *
514
- * @brief  Setup the microcontroller system.
515
- *         Initialize the System.
516
- */
517
-void SystemInit (void)
518
-{
519
-#if (CLOCK_SETUP)                       /* Clock Setup                        */
520
-  LPC_SC->SCS       = SCS_Val;
521
-  if (LPC_SC->SCS & (1 << 5)) {             /* If Main Oscillator is enabled  */
522
-    while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready    */
523
-  }
524
-
525
-  LPC_SC->CCLKCFG   = CCLKCFG_Val;      /* Setup Clock Divider                */
526
-  /* Periphral clock must be selected before PLL0 enabling and connecting
527
-   * - according errata.lpc1768-16.March.2010 -
528
-   */
529
-  LPC_SC->PCLKSEL0  = PCLKSEL0_Val;     /* Peripheral Clock Selection         */
530
-  LPC_SC->PCLKSEL1  = PCLKSEL1_Val;
531
-
532
-#if (PLL0_SETUP)
533
-  LPC_SC->CLKSRCSEL = CLKSRCSEL_Val;    /* Select Clock Source for PLL0       */
534
-
535
-  LPC_SC->PLL0CFG   = PLL0CFG_Val;      /* configure PLL0                     */
536
-  LPC_SC->PLL0FEED  = 0xAA;
537
-  LPC_SC->PLL0FEED  = 0x55;
538
-
539
-  LPC_SC->PLL0CON   = 0x01;             /* PLL0 Enable                        */
540
-  LPC_SC->PLL0FEED  = 0xAA;
541
-  LPC_SC->PLL0FEED  = 0x55;
542
-  while (!(LPC_SC->PLL0STAT & (1<<26)));/* Wait for PLOCK0                    */
543
-
544
-  LPC_SC->PLL0CON   = 0x03;             /* PLL0 Enable & Connect              */
545
-  LPC_SC->PLL0FEED  = 0xAA;
546
-  LPC_SC->PLL0FEED  = 0x55;
547
-  while (!(LPC_SC->PLL0STAT & ((1<<25) | (1<<24))));/* Wait for PLLC0_STAT & PLLE0_STAT */
548
-#endif
549
-
550
-#if (PLL1_SETUP)
551
-  LPC_SC->PLL1CFG   = PLL1CFG_Val;
552
-  LPC_SC->PLL1FEED  = 0xAA;
553
-  LPC_SC->PLL1FEED  = 0x55;
554
-
555
-  LPC_SC->PLL1CON   = 0x01;             /* PLL1 Enable                        */
556
-  LPC_SC->PLL1FEED  = 0xAA;
557
-  LPC_SC->PLL1FEED  = 0x55;
558
-  while (!(LPC_SC->PLL1STAT & (1<<10)));/* Wait for PLOCK1                    */
559
-
560
-  LPC_SC->PLL1CON   = 0x03;             /* PLL1 Enable & Connect              */
561
-  LPC_SC->PLL1FEED  = 0xAA;
562
-  LPC_SC->PLL1FEED  = 0x55;
563
-  while (!(LPC_SC->PLL1STAT & ((1<< 9) | (1<< 8))));/* Wait for PLLC1_STAT & PLLE1_STAT */
564
-#else
565
-  LPC_SC->USBCLKCFG = USBCLKCFG_Val;    /* Setup USB Clock Divider            */
566
-#endif
567
-
568
-  LPC_SC->PCONP     = PCONP_Val;        /* Power Control for Peripherals      */
569
-
570
-  LPC_SC->CLKOUTCFG = CLKOUTCFG_Val;    /* Clock Output Configuration         */
571
-#endif
572
-
573
-#if (FLASH_SETUP == 1)                  /* Flash Accelerator Setup            */
574
-  LPC_SC->FLASHCFG  = (LPC_SC->FLASHCFG & ~0x0000F000) | FLASHCFG_Val;
575
-#endif
576
-}
577
-
578
-/**
579
- * @}
580
- */
581
-
582
-/**
583
- * @}
584
- */

+ 4
- 4
Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py 查看文件

@@ -14,9 +14,9 @@ if __name__ == "__main__":
14 14
                     "--specs=nano.specs",
15 15
                     "--specs=nosys.specs",
16 16
 
17
-                    "-IMarlin/src/HAL/HAL_LPC1768/framework_cmsis/CMSIS/Include",
18
-                    "-IMarlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Include",
19
-                    "-IMarlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/drivers/include",
17
+                    "-IMarlin/frameworks/CMSIS/LPC1768/include",
18
+                    "-IMarlin/frameworks/CMSIS/LPC1768/lib",
19
+                    "-IMarlin/src/HAL",
20 20
 
21 21
                     "-MMD",
22 22
                     "-MP",
@@ -46,6 +46,6 @@ else:
46 46
           "--specs=nano.specs",
47 47
           "--specs=nosys.specs",
48 48
           "-u_printf_float",
49
-          "-Wl,-TMarlin/src/HAL/HAL_LPC1768/framework_cmsis/Device/NXP/LPC17xx/Source/Re-ARM/LPC1768.ld,--gc-sections"
49
+          "-Wl,-TMarlin/frameworks/CMSIS/LPC1768/Re-ARM/LPC1768.ld,--gc-sections"
50 50
       ],
51 51
   )

+ 9
- 9
Marlin/src/HAL/HAL_LPC1768/main.cpp 查看文件

@@ -10,18 +10,18 @@ extern "C" {
10 10
 #include <lpc17xx_gpio.h>
11 11
 }
12 12
 
13
-#include "usb/usb.h"
14
-#include "usb/usbcfg.h"
15
-#include "usb/usbhw.h"
16
-#include "usb/usbcore.h"
17
-#include "usb/cdc.h"
18
-#include "usb/cdcuser.h"
19
-#include "usb/mscuser.h"
13
+#include <usb/usb.h>
14
+#include <usb/usbcfg.h>
15
+#include <usb/usbhw.h>
16
+#include <usb/usbcore.h>
17
+#include <usb/cdc.h>
18
+#include <usb/cdcuser.h>
19
+#include <usb/mscuser.h>
20 20
 
21 21
 extern "C" {
22 22
 #include <debug_frmwrk.h>
23
-#include "chanfs/diskio.h"
24
-#include "chanfs/ff.h"
23
+#include <chanfs/diskio.h>
24
+#include <chanfs/ff.h>
25 25
 }
26 26
 
27 27
 #include "fastio.h"

+ 2
- 1
Marlin/src/HAL/HAL_LPC1768/persistent_store.cpp 查看文件

@@ -1,3 +1,4 @@
1
+#ifdef TARGET_LPC1768
1 2
 #include "../persistent_store_api.h"
2 3
 
3 4
 #include "../../../types.h"
@@ -8,7 +9,7 @@
8 9
 #include "chanfs/diskio.h"
9 10
 #include "chanfs/ff.h"
10 11
 
11
-#ifdef TARGET_LPC1768
12
+
12 13
 #if ENABLED(EEPROM_SETTINGS)
13 14
 
14 15
 namespace HAL {

+ 0
- 36
Marlin/src/HAL/HAL_LPC1768/usb/Re-ARM_usb_driver.inf 查看文件

@@ -1,36 +0,0 @@
1
-[Version]
2
-Signature="$Windows NT$"
3
-Class=Ports
4
-ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
5
-Provider=%PROVIDER%
6
-DriverVer =04/14/2008, 5.1.2600.5512
7
-
8
-[Manufacturer]
9
-%PROVIDER%=DeviceList,ntamd64
10
-
11
-
12
-[DeviceList]
13
-%DESCRIPTION%=LPC1768USB, USB\VID_1D50&PID_6029&MI_00
14
-
15
-[DeviceList.ntamd64]
16
-%DESCRIPTION%=LPC1768USB, USB\VID_1D50&PID_6029&MI_00
17
-
18
-
19
-[LPC1768USB]
20
-include=mdmcpq.inf
21
-CopyFiles=FakeModemCopyFileSection
22
-AddReg=LowerFilterAddReg,SerialPropPageAddReg
23
-
24
-[LPC1768USB.Services]
25
-include=mdmcpq.inf
26
-AddService=usbser, 0x00000002, LowerFilter_Service_Inst
27
-
28
-[SerialPropPageAddReg]
29
-HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
30
-
31
-
32
-[Strings]
33
-PROVIDER   = "marlinfw.org"
34
-DRIVER.SVC = "Marlin USB Driver"
35
-DESCRIPTION= "Marlin USB Serial"
36
-COMPOSITE  = "Marlin USB VCOM"

+ 0
- 254
Marlin/src/HAL/HAL_LPC1768/usb/cdc.h 查看文件

@@ -1,254 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    CDC.h
5
- *      Purpose: USB Communication Device Class Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __CDC_H
20
-#define __CDC_H
21
-
22
-extern "C" {
23
-#include <lpc_types.h>
24
-}
25
-
26
-#if defined   (  __GNUC__  )
27
-#define __packed __attribute__((__packed__))
28
-#endif
29
-/*----------------------------------------------------------------------------
30
- *      Definitions  based on usbcdc11.pdf (www.usb.org)
31
- *---------------------------------------------------------------------------*/
32
-// Communication device class specification version 1.10
33
-#define CDC_V1_10                               0x0110
34
-
35
-// Communication interface class code
36
-// (usbcdc11.pdf, 4.2, Table 15)
37
-#define CDC_COMMUNICATION_INTERFACE_CLASS       0x02
38
-
39
-// Communication interface class subclass codes
40
-// (usbcdc11.pdf, 4.3, Table 16)
41
-#define CDC_DIRECT_LINE_CONTROL_MODEL           0x01
42
-#define CDC_ABSTRACT_CONTROL_MODEL              0x02
43
-#define CDC_TELEPHONE_CONTROL_MODEL             0x03
44
-#define CDC_MULTI_CHANNEL_CONTROL_MODEL         0x04
45
-#define CDC_CAPI_CONTROL_MODEL                  0x05
46
-#define CDC_ETHERNET_NETWORKING_CONTROL_MODEL   0x06
47
-#define CDC_ATM_NETWORKING_CONTROL_MODEL        0x07
48
-
49
-// Communication interface class control protocol codes
50
-// (usbcdc11.pdf, 4.4, Table 17)
51
-#define CDC_PROTOCOL_COMMON_AT_COMMANDS         0x01
52
-
53
-// Data interface class code
54
-// (usbcdc11.pdf, 4.5, Table 18)
55
-#define CDC_DATA_INTERFACE_CLASS                0x0A
56
-
57
-// Data interface class protocol codes
58
-// (usbcdc11.pdf, 4.7, Table 19)
59
-#define CDC_PROTOCOL_ISDN_BRI                   0x30
60
-#define CDC_PROTOCOL_HDLC                       0x31
61
-#define CDC_PROTOCOL_TRANSPARENT                0x32
62
-#define CDC_PROTOCOL_Q921_MANAGEMENT            0x50
63
-#define CDC_PROTOCOL_Q921_DATA_LINK             0x51
64
-#define CDC_PROTOCOL_Q921_MULTIPLEXOR           0x52
65
-#define CDC_PROTOCOL_V42                        0x90
66
-#define CDC_PROTOCOL_EURO_ISDN                  0x91
67
-#define CDC_PROTOCOL_V24_RATE_ADAPTATION        0x92
68
-#define CDC_PROTOCOL_CAPI                       0x93
69
-#define CDC_PROTOCOL_HOST_BASED_DRIVER          0xFD
70
-#define CDC_PROTOCOL_DESCRIBED_IN_PUFD          0xFE
71
-
72
-// Type values for bDescriptorType field of functional descriptors
73
-// (usbcdc11.pdf, 5.2.3, Table 24)
74
-#define CDC_CS_INTERFACE                        0x24
75
-#define CDC_CS_ENDPOINT                         0x25
76
-
77
-// Type values for bDescriptorSubtype field of functional descriptors
78
-// (usbcdc11.pdf, 5.2.3, Table 25)
79
-#define CDC_HEADER                              0x00
80
-#define CDC_CALL_MANAGEMENT                     0x01
81
-#define CDC_ABSTRACT_CONTROL_MANAGEMENT         0x02
82
-#define CDC_DIRECT_LINE_MANAGEMENT              0x03
83
-#define CDC_TELEPHONE_RINGER                    0x04
84
-#define CDC_REPORTING_CAPABILITIES              0x05
85
-#define CDC_UNION                               0x06
86
-#define CDC_COUNTRY_SELECTION                   0x07
87
-#define CDC_TELEPHONE_OPERATIONAL_MODES         0x08
88
-#define CDC_USB_TERMINAL                        0x09
89
-#define CDC_NETWORK_CHANNEL                     0x0A
90
-#define CDC_PROTOCOL_UNIT                       0x0B
91
-#define CDC_EXTENSION_UNIT                      0x0C
92
-#define CDC_MULTI_CHANNEL_MANAGEMENT            0x0D
93
-#define CDC_CAPI_CONTROL_MANAGEMENT             0x0E
94
-#define CDC_ETHERNET_NETWORKING                 0x0F
95
-#define CDC_ATM_NETWORKING                      0x10
96
-
97
-// CDC class-specific request codes
98
-// (usbcdc11.pdf, 6.2, Table 46)
99
-// see Table 45 for info about the specific requests.
100
-#define CDC_SEND_ENCAPSULATED_COMMAND           0x00
101
-#define CDC_GET_ENCAPSULATED_RESPONSE           0x01
102
-#define CDC_SET_COMM_FEATURE                    0x02
103
-#define CDC_GET_COMM_FEATURE                    0x03
104
-#define CDC_CLEAR_COMM_FEATURE                  0x04
105
-#define CDC_SET_AUX_LINE_STATE                  0x10
106
-#define CDC_SET_HOOK_STATE                      0x11
107
-#define CDC_PULSE_SETUP                         0x12
108
-#define CDC_SEND_PULSE                          0x13
109
-#define CDC_SET_PULSE_TIME                      0x14
110
-#define CDC_RING_AUX_JACK                       0x15
111
-#define CDC_SET_LINE_CODING                     0x20
112
-#define CDC_GET_LINE_CODING                     0x21
113
-#define CDC_SET_CONTROL_LINE_STATE              0x22
114
-#define CDC_SEND_BREAK                          0x23
115
-#define CDC_SET_RINGER_PARMS                    0x30
116
-#define CDC_GET_RINGER_PARMS                    0x31
117
-#define CDC_SET_OPERATION_PARMS                 0x32
118
-#define CDC_GET_OPERATION_PARMS                 0x33
119
-#define CDC_SET_LINE_PARMS                      0x34
120
-#define CDC_GET_LINE_PARMS                      0x35
121
-#define CDC_DIAL_DIGITS                         0x36
122
-#define CDC_SET_UNIT_PARAMETER                  0x37
123
-#define CDC_GET_UNIT_PARAMETER                  0x38
124
-#define CDC_CLEAR_UNIT_PARAMETER                0x39
125
-#define CDC_GET_PROFILE                         0x3A
126
-#define CDC_SET_ETHERNET_MULTICAST_FILTERS      0x40
127
-#define CDC_SET_ETHERNET_PMP_FILTER             0x41
128
-#define CDC_GET_ETHERNET_PMP_FILTER             0x42
129
-#define CDC_SET_ETHERNET_PACKET_FILTER          0x43
130
-#define CDC_GET_ETHERNET_STATISTIC              0x44
131
-#define CDC_SET_ATM_DATA_FORMAT                 0x50
132
-#define CDC_GET_ATM_DEVICE_STATISTICS           0x51
133
-#define CDC_SET_ATM_DEFAULT_VC                  0x52
134
-#define CDC_GET_ATM_VC_STATISTICS               0x53
135
-
136
-// Communication feature selector codes
137
-// (usbcdc11.pdf, 6.2.2..6.2.4, Table 47)
138
-#define CDC_ABSTRACT_STATE                      0x01
139
-#define CDC_COUNTRY_SETTING                     0x02
140
-
141
-// Feature Status returned for ABSTRACT_STATE Selector
142
-// (usbcdc11.pdf, 6.2.3, Table 48)
143
-#define CDC_IDLE_SETTING                        (1 << 0)
144
-#define CDC_DATA_MULTPLEXED_STATE               (1 << 1)
145
-
146
-
147
-// Control signal bitmap values for the SetControlLineState request
148
-// (usbcdc11.pdf, 6.2.14, Table 51)
149
-#define CDC_DTE_PRESENT                         (1 << 0)
150
-#define CDC_ACTIVATE_CARRIER                    (1 << 1)
151
-
152
-// CDC class-specific notification codes
153
-// (usbcdc11.pdf, 6.3, Table 68)
154
-// see Table 67 for Info about class-specific notifications
155
-#define CDC_NOTIFICATION_NETWORK_CONNECTION     0x00
156
-#define CDC_RESPONSE_AVAILABLE                  0x01
157
-#define CDC_AUX_JACK_HOOK_STATE                 0x08
158
-#define CDC_RING_DETECT                         0x09
159
-#define CDC_NOTIFICATION_SERIAL_STATE           0x20
160
-#define CDC_CALL_STATE_CHANGE                   0x28
161
-#define CDC_LINE_STATE_CHANGE                   0x29
162
-#define CDC_CONNECTION_SPEED_CHANGE             0x2A
163
-
164
-// UART state bitmap values (Serial state notification).
165
-// (usbcdc11.pdf, 6.3.5, Table 69)
166
-#define CDC_SERIAL_STATE_OVERRUN                (1 << 6)  // receive data overrun error has occurred
167
-#define CDC_SERIAL_STATE_PARITY                 (1 << 5)  // parity error has occurred
168
-#define CDC_SERIAL_STATE_FRAMING                (1 << 4)  // framing error has occurred
169
-#define CDC_SERIAL_STATE_RING                   (1 << 3)  // state of ring signal detection
170
-#define CDC_SERIAL_STATE_BREAK                  (1 << 2)  // state of break detection
171
-#define CDC_SERIAL_STATE_TX_CARRIER             (1 << 1)  // state of transmission carrier
172
-#define CDC_SERIAL_STATE_RX_CARRIER             (1 << 0)  // state of receiver carrier
173
-
174
-// capabilities callmgmt
175
-#define CDC_CALLMGMT_CAP_CALLMGMT 0x01
176
-#define CDC_CALLMGMT_CAP_DATAINTF 0x02
177
-
178
-// capabilities acm
179
-#define CDC_ACM_CAP_COMM  0x01
180
-#define CDC_ACM_CAP_LINE  0x02
181
-#define CDC_ACM_CAP_BRK   0x04
182
-#define CDC_ACM_CAP_NOTIFY  0x08
183
-
184
-
185
-
186
-/*----------------------------------------------------------------------------
187
- *      Structures  based on usbcdc11.pdf (www.usb.org)
188
- *---------------------------------------------------------------------------*/
189
-
190
-// Header functional descriptor
191
-// (usbcdc11.pdf, 5.2.3.1)
192
-// This header must precede any list of class-specific descriptors.
193
-typedef struct __packed  _CDC_HEADER_DESCRIPTOR{
194
-  uint8_t bFunctionLength;                     // size of this descriptor in bytes
195
-  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
196
-  uint8_t bDescriptorSubtype;                  // Header functional descriptor subtype
197
-  uint16_t bcdCDC;                              // USB CDC specification release version
198
-} CDC_HEADER_DESCRIPTOR;
199
-
200
-//Call management functional descriptor
201
-// (usbcdc11.pdf, 5.2.3.2)
202
-// Describes the processing of calls for the communication class interface.
203
-typedef struct __packed  _CDC_CALL_MANAGEMENT_DESCRIPTOR{
204
-  uint8_t bFunctionLength;                     // size of this descriptor in bytes
205
-  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
206
-  uint8_t bDescriptorSubtype;                  // call management functional descriptor subtype
207
-  uint8_t bmCapabilities;                      // capabilities that this configuration supports
208
-  uint8_t bDataInterface;                      // interface number of the data class interface used for call management (optional)
209
-} CDC_CALL_MANAGEMENT_DESCRIPTOR;
210
-
211
-// Abstract control management functional descriptor
212
-// (usbcdc11.pdf, 5.2.3.3)
213
-// Describes the command supported by the communication interface class with the Abstract Control Model subclass code.
214
-typedef struct __packed  _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
215
-  uint8_t bFunctionLength;                     // size of this descriptor in bytes
216
-  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
217
-  uint8_t bDescriptorSubtype;                  // abstract control management functional descriptor subtype
218
-  uint8_t bmCapabilities;                      // capabilities supported by this configuration
219
-} CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
220
-
221
-// Union functional descriptors
222
-// (usbcdc11.pdf, 5.2.3.8)
223
-// Describes the relationship between a group of interfaces that can be considered to form a functional unit.
224
-typedef struct __packed  _CDC_UNION_DESCRIPTOR{
225
-  uint8_t bFunctionLength;                     // size of this descriptor in bytes
226
-  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
227
-  uint8_t bDescriptorSubtype;                  // union functional descriptor subtype
228
-  uint8_t bMasterInterface;                    // interface number designated as master
229
-} CDC_UNION_DESCRIPTOR;
230
-
231
-// Union functional descriptors with one slave interface
232
-// (usbcdc11.pdf, 5.2.3.8)
233
-typedef struct __packed  _CDC_UNION_1SLAVE_DESCRIPTOR{
234
-  CDC_UNION_DESCRIPTOR sUnion;              // Union functional descriptor
235
-  uint8_t                 bSlaveInterfaces[1]; // Slave interface 0
236
-} CDC_UNION_1SLAVE_DESCRIPTOR;
237
-
238
-//  Line coding structure
239
-//  Format of the data returned when a GetLineCoding request is received
240
-// (usbcdc11.pdf, 6.2.13)
241
-typedef struct __packed  _CDC_LINE_CODING{
242
-  uint32_t dwDTERate;                          // Data terminal rate in bits per second
243
-  uint8_t  bCharFormat;                        // Number of stop bits
244
-  uint8_t  bParityType;                        // Parity bit type
245
-  uint8_t  bDataBits;                          // Number of data bits
246
-} CDC_LINE_CODING;
247
-
248
-// Notification header
249
-// Data sent on the notification endpoint must follow this header.
250
-// see  USB_SETUP_PACKET in file usb.h
251
-typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
252
-
253
-#endif /* __CDC_H */
254
-

+ 0
- 258
Marlin/src/HAL/HAL_LPC1768/usb/cdcuser.cpp 查看文件

@@ -1,258 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    cdcuser.c
5
- *      Purpose: USB Communication Device Class User module
6
- *      Version: V1.10
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
14
- *      gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-extern "C" {
20
-#include <lpc_types.h>
21
-#include <debug_frmwrk.h>
22
-}
23
-
24
-#include "usb.h"
25
-#include "usbhw.h"
26
-#include "usbcfg.h"
27
-#include "usbcore.h"
28
-#include "cdc.h"
29
-#include "cdcuser.h"
30
-
31
-#include "../serial.h"
32
-
33
-unsigned char BulkBufIn[USB_CDC_BUFSIZE];            // Buffer to store USB IN  packet
34
-unsigned char BulkBufOut[USB_CDC_BUFSIZE];            // Buffer to store USB OUT packet
35
-unsigned char NotificationBuf[10];
36
-
37
-CDC_LINE_CODING CDC_LineCoding = { 921600, 0, 0, 8 };
38
-unsigned short CDC_DepInEmpty = 1;                   // Data IN EP is empty
39
-unsigned short CDC_LineState = 0;
40
-unsigned short CDC_SerialState = 0;
41
-
42
-
43
-extern HalSerial usb_serial;
44
-/*----------------------------------------------------------------------------
45
- write data to CDC_OutBuf
46
- *---------------------------------------------------------------------------*/
47
-uint32_t CDC_WrOutBuf(const char *buffer, uint32_t *length) {
48
-  uint32_t bytesToWrite, bytesWritten;
49
-
50
-  // Write *length bytes
51
-  bytesToWrite = *length;
52
-  bytesWritten = bytesToWrite;
53
-
54
-  while (bytesToWrite) {
55
-    usb_serial.receive_buffer.write(*buffer++);           // Copy Data to buffer
56
-    bytesToWrite--;
57
-  }
58
-
59
-  return (bytesWritten);
60
-}
61
-
62
-/*----------------------------------------------------------------------------
63
- check if character(s) are available at CDC_OutBuf
64
- *---------------------------------------------------------------------------*/
65
-uint32_t CDC_OutBufAvailChar(uint32_t *availChar) {
66
-  *availChar = usb_serial.transmit_buffer.available();
67
-  return (0);
68
-}
69
-/* end Buffer handling */
70
-
71
-/*----------------------------------------------------------------------------
72
- CDC Initialisation
73
- Initializes the data structures and serial port
74
- Parameters:   None
75
- Return Value: None
76
- *---------------------------------------------------------------------------*/
77
-void CDC_Init() {
78
-  CDC_DepInEmpty = 1;
79
-}
80
-
81
-/*----------------------------------------------------------------------------
82
- CDC SendEncapsulatedCommand Request Callback
83
- Called automatically on CDC SEND_ENCAPSULATED_COMMAND Request
84
- Parameters:   None                          (global SetupPacket and EP0Buf)
85
- Return Value: TRUE - Success, FALSE - Error
86
- *---------------------------------------------------------------------------*/
87
-uint32_t CDC_SendEncapsulatedCommand(void) {
88
-
89
-  return (TRUE);
90
-}
91
-
92
-/*----------------------------------------------------------------------------
93
- CDC GetEncapsulatedResponse Request Callback
94
- Called automatically on CDC Get_ENCAPSULATED_RESPONSE Request
95
- Parameters:   None                          (global SetupPacket and EP0Buf)
96
- Return Value: TRUE - Success, FALSE - Error
97
- *---------------------------------------------------------------------------*/
98
-uint32_t CDC_GetEncapsulatedResponse(void) {
99
-
100
-  /* ... add code to handle request */
101
-  return (TRUE);
102
-}
103
-
104
-/*----------------------------------------------------------------------------
105
- CDC SetCommFeature Request Callback
106
- Called automatically on CDC Set_COMM_FATURE Request
107
- Parameters:   FeatureSelector
108
- Return Value: TRUE - Success, FALSE - Error
109
- *---------------------------------------------------------------------------*/
110
-uint32_t CDC_SetCommFeature(unsigned short wFeatureSelector) {
111
-
112
-  /* ... add code to handle request */
113
-  return (TRUE);
114
-}
115
-
116
-/*----------------------------------------------------------------------------
117
- CDC GetCommFeature Request Callback
118
- Called automatically on CDC Get_COMM_FATURE Request
119
- Parameters:   FeatureSelector
120
- Return Value: TRUE - Success, FALSE - Error
121
- *---------------------------------------------------------------------------*/
122
-uint32_t CDC_GetCommFeature(unsigned short wFeatureSelector) {
123
-
124
-  /* ... add code to handle request */
125
-  return (TRUE);
126
-}
127
-
128
-/*----------------------------------------------------------------------------
129
- CDC ClearCommFeature Request Callback
130
- Called automatically on CDC CLEAR_COMM_FATURE Request
131
- Parameters:   FeatureSelector
132
- Return Value: TRUE - Success, FALSE - Error
133
- *---------------------------------------------------------------------------*/
134
-uint32_t CDC_ClearCommFeature(unsigned short wFeatureSelector) {
135
-
136
-  /* ... add code to handle request */
137
-  return (TRUE);
138
-}
139
-
140
-/*----------------------------------------------------------------------------
141
- CDC SetLineCoding Request Callback
142
- Called automatically on CDC SET_LINE_CODING Request
143
- Parameters:   none                    (global SetupPacket and EP0Buf)
144
- Return Value: TRUE - Success, FALSE - Error
145
- *---------------------------------------------------------------------------*/
146
-uint32_t CDC_SetLineCoding(void) {
147
-
148
-  CDC_LineCoding.dwDTERate = (EP0Buf[0] << 0) | (EP0Buf[1] << 8) | (EP0Buf[2] << 16) | (EP0Buf[3] << 24);
149
-  CDC_LineCoding.bCharFormat = EP0Buf[4];
150
-  CDC_LineCoding.bParityType = EP0Buf[5];
151
-  CDC_LineCoding.bDataBits = EP0Buf[6];
152
-
153
-  return (TRUE);
154
-}
155
-
156
-/*----------------------------------------------------------------------------
157
- CDC GetLineCoding Request Callback
158
- Called automatically on CDC GET_LINE_CODING Request
159
- Parameters:   None                         (global SetupPacket and EP0Buf)
160
- Return Value: TRUE - Success, FALSE - Error
161
- *---------------------------------------------------------------------------*/
162
-uint32_t CDC_GetLineCoding(void) {
163
-
164
-  EP0Buf[0] = (CDC_LineCoding.dwDTERate >> 0) & 0xFF;
165
-  EP0Buf[1] = (CDC_LineCoding.dwDTERate >> 8) & 0xFF;
166
-  EP0Buf[2] = (CDC_LineCoding.dwDTERate >> 16) & 0xFF;
167
-  EP0Buf[3] = (CDC_LineCoding.dwDTERate >> 24) & 0xFF;
168
-  EP0Buf[4] = CDC_LineCoding.bCharFormat;
169
-  EP0Buf[5] = CDC_LineCoding.bParityType;
170
-  EP0Buf[6] = CDC_LineCoding.bDataBits;
171
-
172
-  return (TRUE);
173
-}
174
-
175
-/*----------------------------------------------------------------------------
176
- CDC SetControlLineState Request Callback
177
- Called automatically on CDC SET_CONTROL_LINE_STATE Request
178
- Parameters:   ControlSignalBitmap
179
- Return Value: TRUE - Success, FALSE - Error
180
- *---------------------------------------------------------------------------*/
181
-uint32_t CDC_SetControlLineState(unsigned short wControlSignalBitmap) {
182
-  CDC_LineState = wControlSignalBitmap;
183
-  usb_serial.host_connected = wControlSignalBitmap > 0 ? true : false;
184
-  return true;
185
-}
186
-
187
-/*----------------------------------------------------------------------------
188
- CDC SendBreak Request Callback
189
- Called automatically on CDC Set_COMM_FATURE Request
190
- Parameters:   0xFFFF  start of Break
191
- 0x0000  stop  of Break
192
- 0x####  Duration of Break
193
- Return Value: TRUE - Success, FALSE - Error
194
- *---------------------------------------------------------------------------*/
195
-uint32_t CDC_SendBreak(unsigned short wDurationOfBreak) {
196
-
197
-  /* ... add code to handle request */
198
-  return (TRUE);
199
-}
200
-
201
-/*----------------------------------------------------------------------------
202
- CDC_BulkIn call on DataIn Request
203
- Parameters:   none
204
- Return Value: none
205
- *---------------------------------------------------------------------------*/
206
-void CDC_BulkIn(void) {
207
-  uint32_t numBytesAvail = usb_serial.transmit_buffer.available();
208
-
209
-  if (numBytesAvail > 0) {
210
-    numBytesAvail = numBytesAvail > (USB_CDC_BUFSIZE - 1) ? (USB_CDC_BUFSIZE - 1) : numBytesAvail;
211
-    for(uint32_t i = 0; i < numBytesAvail; ++i) {
212
-      BulkBufIn[i] = usb_serial.transmit_buffer.read(); //todo: optimise
213
-    }
214
-    USB_WriteEP(CDC_DEP_IN, &BulkBufIn[0], numBytesAvail);
215
-  } else {
216
-    CDC_DepInEmpty = 1;
217
-  }
218
-}
219
-
220
-/*----------------------------------------------------------------------------
221
- CDC_BulkOut call on DataOut Request
222
- Parameters:   none
223
- Return Value: none
224
- *---------------------------------------------------------------------------*/
225
-void CDC_BulkOut(void) {
226
-  uint32_t numBytesRead = USB_ReadEP(CDC_DEP_OUT, &BulkBufOut[0]);
227
-  CDC_WrOutBuf((char *) &BulkBufOut[0], &numBytesRead);
228
-}
229
-
230
-/*----------------------------------------------------------------------------
231
- Get the SERIAL_STATE as defined in usbcdc11.pdf, 6.3.5, Table 69.
232
- Parameters:   none
233
- Return Value: SerialState as defined in usbcdc11.pdf
234
- *---------------------------------------------------------------------------*/
235
-unsigned short CDC_GetSerialState(void) {
236
-  CDC_SerialState = CDC_LineState;
237
-  //todo: detect buffer overrun
238
-  return (CDC_SerialState);
239
-}
240
-
241
-/*----------------------------------------------------------------------------
242
- Send the SERIAL_STATE notification as defined in usbcdc11.pdf, 6.3.5.
243
- *---------------------------------------------------------------------------*/
244
-void CDC_NotificationIn(void) {
245
-
246
-  NotificationBuf[0] = 0xA1;                           // bmRequestType
247
-  NotificationBuf[1] = CDC_NOTIFICATION_SERIAL_STATE;     // bNotification (SERIAL_STATE)
248
-  NotificationBuf[2] = 0x00;                           // wValue
249
-  NotificationBuf[3] = 0x00;
250
-  NotificationBuf[4] = 0x00;                           // wIndex (Interface #, LSB first)
251
-  NotificationBuf[5] = 0x00;
252
-  NotificationBuf[6] = 0x02;                           // wLength (Data length = 2 bytes, LSB first)
253
-  NotificationBuf[7] = 0x00;
254
-  NotificationBuf[8] = (CDC_SerialState >> 0) & 0xFF;     // UART State Bitmap (16bits, LSB first)
255
-  NotificationBuf[9] = (CDC_SerialState >> 8) & 0xFF;
256
-
257
-  USB_WriteEP(CDC_CEP_IN, &NotificationBuf[0], 10);     // send notification
258
-}

+ 0
- 62
Marlin/src/HAL/HAL_LPC1768/usb/cdcuser.h 查看文件

@@ -1,62 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    cdcuser.h
5
- *      Purpose: USB Communication Device Class User module Definitions
6
- *      Version: V1.10
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
14
- *      gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __CDCUSER_H__
20
-#define __CDCUSER_H__
21
-
22
-/* CDC buffer handling */
23
-extern uint32_t CDC_RdOutBuf(char *buffer, const uint32_t *length);
24
-extern uint32_t CDC_WrOutBuf(const char *buffer, uint32_t *length);
25
-extern uint32_t CDC_OutBufAvailChar(uint32_t *availChar);
26
-
27
-/* CDC Data In/Out Endpoint Address */
28
-#define CDC_DEP_IN       0x82
29
-#define CDC_DEP_OUT      0x02
30
-
31
-/* CDC Communication In Endpoint Address */
32
-#define CDC_CEP_IN       0x81
33
-
34
-/* CDC Requests Callback Functions */
35
-extern uint32_t CDC_SendEncapsulatedCommand(void);
36
-extern uint32_t CDC_GetEncapsulatedResponse(void);
37
-extern uint32_t CDC_SetCommFeature(unsigned short wFeatureSelector);
38
-extern uint32_t CDC_GetCommFeature(unsigned short wFeatureSelector);
39
-extern uint32_t CDC_ClearCommFeature(unsigned short wFeatureSelector);
40
-extern uint32_t CDC_GetLineCoding(void);
41
-extern uint32_t CDC_SetLineCoding(void);
42
-extern uint32_t CDC_SetControlLineState(unsigned short wControlSignalBitmap);
43
-extern uint32_t CDC_SendBreak(unsigned short wDurationOfBreak);
44
-
45
-/* CDC Bulk Callback Functions */
46
-extern void CDC_BulkIn(void);
47
-extern void CDC_BulkOut(void);
48
-
49
-/* CDC Notification Callback Function */
50
-extern void CDC_NotificationIn(void);
51
-
52
-/* CDC Initializtion Function */
53
-extern void CDC_Init();
54
-
55
-/* CDC prepare the SERAIAL_STATE */
56
-extern unsigned short CDC_GetSerialState(void);
57
-
58
-/* flow control */
59
-extern unsigned short CDC_DepInEmpty;         // DataEndPoint IN empty
60
-
61
-#endif  /* __CDCUSER_H__ */
62
-

+ 0
- 116
Marlin/src/HAL/HAL_LPC1768/usb/msc.h 查看文件

@@ -1,116 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    MSC.H
5
- *      Purpose: USB Mass Storage Class Definitions
6
- *      Version: V1.10
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- *      Copyright (c) 2005-2009 Keil Software.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __MSC_H__
20
-#define __MSC_H__
21
-
22
-
23
-#if defined   (  __GNUC__  )
24
-#define __packed __attribute__((__packed__))
25
-#endif
26
-
27
-
28
-/* MSC Subclass Codes */
29
-#define MSC_SUBCLASS_RBC                0x01
30
-#define MSC_SUBCLASS_SFF8020I_MMC2      0x02
31
-#define MSC_SUBCLASS_QIC157             0x03
32
-#define MSC_SUBCLASS_UFI                0x04
33
-#define MSC_SUBCLASS_SFF8070I           0x05
34
-#define MSC_SUBCLASS_SCSI               0x06
35
-
36
-/* MSC Protocol Codes */
37
-#define MSC_PROTOCOL_CBI_INT            0x00
38
-#define MSC_PROTOCOL_CBI_NOINT          0x01
39
-#define MSC_PROTOCOL_BULK_ONLY          0x50
40
-
41
-
42
-/* MSC Request Codes */
43
-#define MSC_REQUEST_RESET               0xFF
44
-#define MSC_REQUEST_GET_MAX_LUN         0xFE
45
-
46
-
47
-/* MSC Bulk-only Stage */
48
-#define MSC_BS_CBW                      0       /* Command Block Wrapper */
49
-#define MSC_BS_DATA_OUT                 1       /* Data Out Phase */
50
-#define MSC_BS_DATA_IN                  2       /* Data In Phase */
51
-#define MSC_BS_DATA_IN_LAST             3       /* Data In Last Phase */
52
-#define MSC_BS_DATA_IN_LAST_STALL       4       /* Data In Last Phase with Stall */
53
-#define MSC_BS_CSW                      5       /* Command Status Wrapper */
54
-#define MSC_BS_ERROR                    6       /* Error */
55
-
56
-
57
-/* Bulk-only Command Block Wrapper */
58
-#if defined     (  __CC_ARM  )
59
-typedef __packed struct _MSC_CBW {
60
-#elif defined   (  __GNUC__  )
61
-typedef struct __packed _MSC_CBW {
62
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
63
-typedef __packed struct _MSC_CBW {
64
-#endif
65
-  uint32_t dSignature;
66
-  uint32_t dTag;
67
-  uint32_t dDataLength;
68
-  uint8_t  bmFlags;
69
-  uint8_t  bLUN;
70
-  uint8_t  bCBLength;
71
-  uint8_t  CB[16];
72
-} MSC_CBW;
73
-
74
-/* Bulk-only Command Status Wrapper */
75
-#if defined     (  __CC_ARM  )
76
-typedef __packed struct _MSC_CSW {
77
-#elif defined   (  __GNUC__  )
78
-typedef struct __packed _MSC_CSW {
79
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
80
-typedef __packed struct _MSC_CSW {
81
-#endif
82
-  uint32_t dSignature;
83
-  uint32_t dTag;
84
-  uint32_t dDataResidue;
85
-  uint8_t  bStatus;
86
-} MSC_CSW;
87
-
88
-#define MSC_CBW_Signature               0x43425355
89
-#define MSC_CSW_Signature               0x53425355
90
-
91
-
92
-/* CSW Status Definitions */
93
-#define CSW_CMD_PASSED                  0x00
94
-#define CSW_CMD_FAILED                  0x01
95
-#define CSW_PHASE_ERROR                 0x02
96
-
97
-
98
-/* SCSI Commands */
99
-#define SCSI_TEST_UNIT_READY            0x00
100
-#define SCSI_REQUEST_SENSE              0x03
101
-#define SCSI_FORMAT_UNIT                0x04
102
-#define SCSI_INQUIRY                    0x12
103
-#define SCSI_MODE_SELECT6               0x15
104
-#define SCSI_MODE_SENSE6                0x1A
105
-#define SCSI_START_STOP_UNIT            0x1B
106
-#define SCSI_MEDIA_REMOVAL              0x1E
107
-#define SCSI_READ_FORMAT_CAPACITIES     0x23
108
-#define SCSI_READ_CAPACITY              0x25
109
-#define SCSI_READ10                     0x28
110
-#define SCSI_WRITE10                    0x2A
111
-#define SCSI_VERIFY10                   0x2F
112
-#define SCSI_MODE_SELECT10              0x55
113
-#define SCSI_MODE_SENSE10               0x5A
114
-
115
-
116
-#endif  /* __MSC_H__ */

+ 0
- 716
Marlin/src/HAL/HAL_LPC1768/usb/mscuser.cpp 查看文件

@@ -1,716 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    MSCUSER.C
5
- *      Purpose: Mass Storage Class Custom User Module
6
- *      Version: V1.10
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- *      Copyright (c) 2005-2009 Keil Software.
17
- *---------------------------------------------------------------------------*/
18
-
19
-extern "C" {
20
-#include "LPC17xx.h"
21
-#include "lpc_types.h"
22
-}
23
-#include "usb.h"
24
-#include "msc.h"
25
-#include "usbcfg.h"
26
-#include "usbhw.h"
27
-#include "usbcore.h"
28
-#include "mscuser.h"
29
-
30
-#include "../chanfs/diskio.h"
31
-#include <debug_frmwrk.h>
32
-
33
-DWORD MSC_BlockCount = 0;
34
-
35
-uint32_t MemOK;                   /* Memory OK */
36
-
37
-DWORD lba;                        /* start block */
38
-DWORD transfer_count;             /* blocks to transfer */
39
-DWORD length;
40
-uint32_t block_offset;            /* current block offset*/
41
-
42
-uint8_t  BulkStage;               /* Bulk Stage */
43
-
44
-uint8_t  BulkBuf[MSC_MAX_PACKET]; /* Bulk In/Out Buffer */
45
-uint8_t  block_cache[MSC_BLOCK_SIZE];
46
-uint8_t  BulkLen;                 /* Bulk In/Out Length */
47
-
48
-MSC_CBW CBW;                   /* Command Block Wrapper */
49
-MSC_CSW CSW;                   /* Command Status Wrapper */
50
-uint8_t media_lock = 0;
51
-
52
-uint32_t MSC_SD_Lock() {
53
-  media_lock = CBW.CB[4]; //0x1 - lock, 0x0 - unlock
54
-  // logical_unit = CBW.CB[1] & 0xE0;
55
-  CSW.bStatus = CSW_CMD_PASSED;
56
-  MSC_SetCSW();
57
-  return 0;
58
-}
59
-
60
-uint32_t MSC_SD_Release(uint8_t pdrv) {
61
-  MSC_BlockCount = 0;
62
-  return 0;
63
-}
64
-
65
-uint32_t MSC_SD_Init(uint8_t pdrv) {
66
-  DSTATUS ret = disk_initialize(pdrv);
67
-  if(ret) return ret;
68
-  if(disk_ioctl (pdrv, GET_SECTOR_COUNT, (void *)(&MSC_BlockCount))) return 1;
69
-  return 0;
70
-}
71
-
72
-#define STARTSTOP_STOPMOTOR        0x0
73
-#define STARTSTOP_STARTMOTOR       0x1
74
-#define STARTSTOP_EJECT            0x2
75
-#define STARTSTOP_LOAD             0x3
76
-
77
-void MSC_StartStopUnit() {
78
-  switch (CBW.CB[4] & 0x03) {
79
-    case STARTSTOP_EJECT:
80
-      MSC_SD_Release(0);
81
-      break;
82
-    case STARTSTOP_LOAD:
83
-      if(MSC_BlockCount == 0) {
84
-        if(MSC_SD_Init(0) != 0) {
85
-          CSW.bStatus = CSW_CMD_FAILED;
86
-          MSC_SetCSW();
87
-          return;
88
-        }
89
-      }
90
-      break;
91
-    default:
92
-      _DBG("MSC_StartStopUnit unknown startstopunit sub command\n");
93
-  }
94
-  CSW.bStatus = CSW_CMD_PASSED;
95
-  MSC_SetCSW();
96
-}
97
-
98
-/*
99
- *  MSC Mass Storage Reset Request Callback
100
- *   Called automatically on Mass Storage Reset Request
101
- *    Parameters:      None (global SetupPacket and EP0Buf)
102
- *    Return Value:    TRUE - Success, FALSE - Error
103
- */
104
-
105
-uint32_t MSC_Reset (void) {
106
-  BulkStage = MSC_BS_CBW;
107
-  return (TRUE);
108
-}
109
-
110
-
111
-/*
112
- *  MSC Get Max LUN Request Callback
113
- *   Called automatically on Get Max LUN Request
114
- *    Parameters:      None (global SetupPacket and EP0Buf)
115
- *    Return Value:    TRUE - Success, FALSE - Error
116
- */
117
-
118
-uint32_t MSC_GetMaxLUN (void) {
119
-
120
-  EP0Buf[0] = 0;               /* No LUN associated with this device */
121
-  return (TRUE);
122
-}
123
-
124
-
125
-/*
126
- *  MSC Memory Read Callback
127
- *   Called automatically on Memory Read Event
128
- *    Parameters:      None (global variables)
129
- *    Return Value:    None
130
- */
131
-
132
-void MSC_MemoryRead (void) {
133
-  uint32_t n = (length > MSC_MAX_PACKET) ? MSC_MAX_PACKET : length;
134
-
135
-  if (lba > MSC_BlockCount) {
136
-      n = (MSC_BlockCount - lba) * MSC_BLOCK_SIZE + block_offset;
137
-      BulkStage = MSC_BS_ERROR;
138
-  }
139
-
140
-  if(block_offset == 0) {
141
-    disk_read (0, block_cache, lba, 1);
142
-  }
143
-
144
-  USB_WriteEP(MSC_EP_IN, &block_cache[block_offset], n);
145
-
146
-  block_offset += n;
147
-  length -= n;
148
-  CSW.dDataResidue -= n;
149
-
150
-  if(block_offset >= MSC_BLOCK_SIZE) {
151
-    block_offset = 0;
152
-    ++lba;
153
-  }
154
-
155
-  if (length == 0) {
156
-    BulkStage = MSC_BS_DATA_IN_LAST;
157
-  }
158
-
159
-  if (BulkStage != MSC_BS_DATA_IN) {
160
-    CSW.bStatus = CSW_CMD_PASSED;
161
-  }
162
-}
163
-
164
-
165
-/*
166
- *  MSC Memory Write Callback
167
- *   Called automatically on Memory Write Event
168
- *    Parameters:      None (global variables)
169
- *    Return Value:    None
170
- */
171
-
172
-void MSC_MemoryWrite (void) {
173
-
174
-  for (uint32_t n = 0; n < BulkLen; n++) {
175
-    block_cache[block_offset + n] = BulkBuf[n];
176
-  }
177
-
178
-  if(block_offset + BulkLen >= MSC_BLOCK_SIZE) {
179
-    if(!(disk_status(0) & STA_PROTECT)){
180
-      disk_write(0, block_cache, lba, 1);
181
-    }
182
-  }
183
-
184
-  block_offset += BulkLen;
185
-  length -= BulkLen;
186
-  CSW.dDataResidue -= BulkLen;
187
-
188
-  if(block_offset >= MSC_BLOCK_SIZE) {
189
-    block_offset = 0;
190
-    ++lba;
191
-  }
192
-
193
-  if ((length == 0) || (BulkStage == MSC_BS_CSW)) {
194
-    CSW.bStatus = CSW_CMD_PASSED;
195
-    MSC_SetCSW();
196
-  }
197
-}
198
-
199
-
200
-/*
201
- *  MSC Memory Verify Callback
202
- *   Called automatically on Memory Verify Event
203
- *    Parameters:      None (global variables)
204
- *    Return Value:    None
205
- */
206
-
207
-void MSC_MemoryVerify (void) {
208
-
209
-  if(!block_offset) {
210
-    disk_read(0, block_cache, lba, 1);
211
-  }
212
-
213
-  for (uint32_t n = 0; n < BulkLen; n++) {
214
-    if (block_cache[block_offset + n] != BulkBuf[n]) {
215
-      MemOK = FALSE;
216
-      break;
217
-    }
218
-  }
219
-
220
-  block_offset += BulkLen;
221
-  length -= BulkLen;
222
-  CSW.dDataResidue -= BulkLen;
223
-
224
-  if ((length == 0) || (BulkStage == MSC_BS_CSW)) {
225
-    CSW.bStatus = (MemOK) ? CSW_CMD_PASSED : CSW_CMD_FAILED;
226
-    MSC_SetCSW();
227
-  }
228
-}
229
-
230
-
231
-/*
232
- *  MSC SCSI Read/Write Setup Callback
233
- *    Parameters:      None (global variables)
234
- *    Return Value:    TRUE - Success, FALSE - Error
235
- */
236
-
237
-uint32_t MSC_RWSetup (void) {
238
-  uint32_t n;
239
-
240
-  /* Logical Block Address of First Block */
241
-  lba = (CBW.CB[2] << 24) |
242
-        (CBW.CB[3] << 16) |
243
-        (CBW.CB[4] <<  8) |
244
-        (CBW.CB[5] <<  0);
245
-
246
-  /* Number of Blocks to transfer */
247
-  transfer_count = (CBW.CB[7] <<  8) |
248
-                   (CBW.CB[8] <<  0);
249
-
250
-  block_offset = 0;
251
-  length = transfer_count * MSC_BLOCK_SIZE;
252
-
253
-  if (CBW.dDataLength != (transfer_count * MSC_BLOCK_SIZE)) {
254
-    USB_SetStallEP(MSC_EP_IN);
255
-    USB_SetStallEP(MSC_EP_OUT);
256
-    CSW.bStatus = CSW_PHASE_ERROR;
257
-    MSC_SetCSW();
258
-    return (FALSE);
259
-  }
260
-
261
-  return (TRUE);
262
-}
263
-
264
-
265
-/*
266
- *  Check Data IN Format
267
- *    Parameters:      None (global variables)
268
- *    Return Value:    TRUE - Success, FALSE - Error
269
- */
270
-
271
-uint32_t DataInFormat (void) {
272
-
273
-  if (CBW.dDataLength == 0) {
274
-    CSW.bStatus = CSW_PHASE_ERROR;
275
-    MSC_SetCSW();
276
-    return (FALSE);
277
-  }
278
-  if ((CBW.bmFlags & 0x80) == 0) {
279
-    USB_SetStallEP(MSC_EP_OUT);
280
-    CSW.bStatus = CSW_PHASE_ERROR;
281
-    MSC_SetCSW();
282
-    return (FALSE);
283
-  }
284
-  return (TRUE);
285
-}
286
-
287
-
288
-/*
289
- *  Perform Data IN Transfer
290
- *    Parameters:      None (global variables)
291
- *    Return Value:    TRUE - Success, FALSE - Error
292
- */
293
-
294
-void DataInTransfer (void) {
295
-
296
-  if (BulkLen > CBW.dDataLength) {
297
-    BulkLen = CBW.dDataLength;
298
-  }
299
-
300
-  USB_WriteEP(MSC_EP_IN, BulkBuf, BulkLen);
301
-  BulkStage = MSC_BS_DATA_IN_LAST;
302
-
303
-  CSW.dDataResidue -= BulkLen;
304
-  CSW.bStatus = CSW_CMD_PASSED;
305
-}
306
-
307
-
308
-/*
309
- *  MSC SCSI Test Unit Ready Callback
310
- *    Parameters:      None (global variables)
311
- *    Return Value:    None
312
- */
313
-
314
-void MSC_TestUnitReady (void) {
315
-
316
-  if (CBW.dDataLength != 0) {
317
-    if ((CBW.bmFlags & 0x80) != 0) {
318
-      USB_SetStallEP(MSC_EP_IN);
319
-    } else {
320
-      USB_SetStallEP(MSC_EP_OUT);
321
-    }
322
-  }
323
-
324
-  if(MSC_BlockCount > 0) {
325
-    CSW.bStatus = CSW_CMD_PASSED;
326
-  } else {
327
-    CSW.bStatus = CSW_CMD_FAILED;
328
-  }
329
-
330
-  MSC_SetCSW();
331
-}
332
-
333
-
334
-/*
335
- *  MSC SCSI Request Sense Callback
336
- *    Parameters:      None (global variables)
337
- *    Return Value:    None
338
- */
339
-
340
-void MSC_RequestSense (void) {
341
-
342
-  if (!DataInFormat()) return;
343
-
344
-  BulkBuf[ 0] = 0x70;          /* Response Code */
345
-  BulkBuf[ 1] = 0x00;
346
-  BulkBuf[ 2] = static_cast<uint8_t>(Sense_KEY::ILLEGAL_REQUEST);
347
-  BulkBuf[ 3] = 0x00;
348
-  BulkBuf[ 4] = 0x00;
349
-  BulkBuf[ 5] = 0x00;
350
-  BulkBuf[ 6] = 0x00;
351
-  BulkBuf[ 7] = 0x0A;           /* Additional Length */
352
-
353
-  BulkBuf[ 8] = 0x00;
354
-  BulkBuf[ 9] = 0x00;
355
-  BulkBuf[10] = 0x00;
356
-  BulkBuf[11] = 0x00;
357
-  BulkBuf[12] = static_cast<uint8_t>(Sense_ASC::CANNOT_READ_MEDIUM);
358
-  BulkBuf[13] = static_cast<uint8_t>(Sense_ASCQ::UNKNOWN_FORMAT);
359
-  BulkBuf[14] = 0x00;
360
-  BulkBuf[15] = 0x00;
361
-  BulkBuf[16] = 0x00;
362
-  BulkBuf[17] = 0x00;
363
-
364
-  if (MSC_BlockCount == 0) {
365
-    BulkBuf[ 2] = static_cast<uint8_t>(Sense_KEY::NOT_READY);
366
-    BulkBuf[12] = static_cast<uint8_t>(Sense_ASC::MEDIUM_NOT_PRESENT);
367
-    BulkBuf[13] = static_cast<uint8_t>(Sense_ASCQ::LOADABLE);
368
-  }
369
-
370
-  BulkLen = 18;
371
-  DataInTransfer();
372
-}
373
-
374
-
375
-/*
376
- *  MSC SCSI Inquiry Callback
377
- *  Parameters:      None (global variables)
378
- *  Return Value:    None
379
- */
380
-
381
-void MSC_Inquiry (void) {
382
-
383
-  if (!DataInFormat()) return;
384
-
385
-  BulkBuf[ 0] = 0x00;          /* Direct Access Device */
386
-  BulkBuf[ 1] = 0x80;          /* RMB = 1: Removable Medium */
387
-  BulkBuf[ 2] = 0x00;          /* Version: No conformance claim to standard */
388
-  BulkBuf[ 3] = 0x01;
389
-
390
-  BulkBuf[ 4] = 36-4;          /* Additional Length */
391
-  BulkBuf[ 5] = 0x80;          /* SCCS = 1: Storage Controller Component */
392
-  BulkBuf[ 6] = 0x00;
393
-  BulkBuf[ 7] = 0x00;
394
-
395
-  BulkBuf[ 8] = 'M';           /* Vendor Identification */
396
-  BulkBuf[ 9] = 'a';
397
-  BulkBuf[10] = 'r';
398
-  BulkBuf[11] = 'l';
399
-  BulkBuf[12] = 'i';
400
-  BulkBuf[13] = 'n';
401
-  BulkBuf[14] = ' ';
402
-  BulkBuf[15] = ' ';
403
-
404
-  BulkBuf[16] = 'R';           /* Product Identification */
405
-  BulkBuf[17] = 'e';
406
-  BulkBuf[18] = '-';
407
-  BulkBuf[19] = 'A';
408
-  BulkBuf[20] = 'R';
409
-  BulkBuf[21] = 'M';
410
-  BulkBuf[22] = ' ';
411
-  BulkBuf[23] = 'S';
412
-  BulkBuf[24] = 'D';
413
-  BulkBuf[25] = 'C';
414
-  BulkBuf[26] = 'a';
415
-  BulkBuf[27] = 'r';
416
-  BulkBuf[28] = 'd';
417
-  BulkBuf[29] = ' ';
418
-  BulkBuf[30] = '0';
419
-  BulkBuf[31] = '1';
420
-
421
-  BulkBuf[32] = '1';           /* Product Revision Level */
422
-  BulkBuf[33] = '.';
423
-  BulkBuf[34] = '0';
424
-  BulkBuf[35] = ' ';
425
-
426
-  if(MSC_BlockCount == 0) {
427
-    BulkBuf[0] = 0x20; // Direct Access Device usually available but not currently
428
-  }
429
-
430
-  BulkLen = 36;
431
-  DataInTransfer();
432
-}
433
-
434
-
435
-/*
436
- *  MSC SCSI Mode Sense (6-Byte) Callback
437
- *    Parameters:      None (global variables)
438
- *    Return Value:    None
439
- */
440
-
441
-void MSC_ModeSense6 (void) {
442
-
443
-  if (!DataInFormat()) return;
444
-
445
-  BulkBuf[ 0] = 0x03;
446
-  BulkBuf[ 1] = 0x00;
447
-  BulkBuf[ 2] = 0x00;
448
-  BulkBuf[ 3] = 0x00;
449
-
450
-  BulkLen = 4;
451
-  DataInTransfer();
452
-}
453
-
454
-
455
-/*
456
- *  MSC SCSI Mode Sense (10-Byte) Callback
457
- *    Parameters:      None (global variables)
458
- *    Return Value:    None
459
- */
460
-
461
-void MSC_ModeSense10 (void) {
462
-
463
-  if (!DataInFormat()) return;
464
-
465
-  BulkBuf[ 0] = 0x00;
466
-  BulkBuf[ 1] = 0x06;
467
-  BulkBuf[ 2] = 0x00;
468
-  BulkBuf[ 3] = 0x00;
469
-  BulkBuf[ 4] = 0x00;
470
-  BulkBuf[ 5] = 0x00;
471
-  BulkBuf[ 6] = 0x00;
472
-  BulkBuf[ 7] = 0x00;
473
-
474
-  BulkLen = 8;
475
-  DataInTransfer();
476
-}
477
-
478
-
479
-/*
480
- *  MSC SCSI Read Capacity Callback
481
- *    Parameters:      None (global variables)
482
- *    Return Value:    None
483
- */
484
-
485
-void MSC_ReadCapacity (void) {
486
-
487
-  if (!DataInFormat()) return;
488
-
489
-  /* Last Logical Block */
490
-  BulkBuf[ 0] = ((MSC_BlockCount - 1) >> 24) & 0xFF;
491
-  BulkBuf[ 1] = ((MSC_BlockCount - 1) >> 16) & 0xFF;
492
-  BulkBuf[ 2] = ((MSC_BlockCount - 1) >>  8) & 0xFF;
493
-  BulkBuf[ 3] = ((MSC_BlockCount - 1) >>  0) & 0xFF;
494
-
495
-  /* Block Length */
496
-  BulkBuf[ 4] = (MSC_BLOCK_SIZE >> 24) & 0xFF;
497
-  BulkBuf[ 5] = (MSC_BLOCK_SIZE >> 16) & 0xFF;
498
-  BulkBuf[ 6] = (MSC_BLOCK_SIZE >>  8) & 0xFF;
499
-  BulkBuf[ 7] = (MSC_BLOCK_SIZE >>  0) & 0xFF;
500
-
501
-  BulkLen = 8;
502
-  DataInTransfer();
503
-}
504
-
505
-
506
-/*
507
- *  MSC SCSI Read Format Capacity Callback
508
- *    Parameters:      None (global variables)
509
- *    Return Value:    None
510
- */
511
-
512
-void MSC_ReadFormatCapacity (void) {
513
-
514
-  if (!DataInFormat()) return;
515
-
516
-  BulkBuf[ 0] = 0x00;
517
-  BulkBuf[ 1] = 0x00;
518
-  BulkBuf[ 2] = 0x00;
519
-  BulkBuf[ 3] = 0x08;          /* Capacity List Length */
520
-
521
-  /* Block Count */
522
-  BulkBuf[ 4] = (MSC_BlockCount >> 24) & 0xFF;
523
-  BulkBuf[ 5] = (MSC_BlockCount >> 16) & 0xFF;
524
-  BulkBuf[ 6] = (MSC_BlockCount >>  8) & 0xFF;
525
-  BulkBuf[ 7] = (MSC_BlockCount >>  0) & 0xFF;
526
-
527
-  /* Block Length */
528
-  BulkBuf[ 8] = 0x02;          /* Descriptor Code: Formatted Media */
529
-  BulkBuf[ 9] = (MSC_BLOCK_SIZE >> 16) & 0xFF;
530
-  BulkBuf[10] = (MSC_BLOCK_SIZE >>  8) & 0xFF;
531
-  BulkBuf[11] = (MSC_BLOCK_SIZE >>  0) & 0xFF;
532
-
533
-  BulkLen = 12;
534
-  DataInTransfer();
535
-}
536
-
537
-
538
-/*
539
- *  MSC Get Command Block Wrapper Callback
540
- *    Parameters:      None (global variables)
541
- *    Return Value:    None
542
- */
543
-
544
-void MSC_GetCBW (void) {
545
-  uint32_t n;
546
-
547
-  for (n = 0; n < BulkLen; n++) {
548
-    *((uint8_t *)&CBW + n) = BulkBuf[n];
549
-  }
550
-  if ((BulkLen == sizeof(CBW)) && (CBW.dSignature == MSC_CBW_Signature)) {
551
-    /* Valid CBW */
552
-    CSW.dTag = CBW.dTag;
553
-    CSW.dDataResidue = CBW.dDataLength;
554
-    if ((CBW.bLUN != 0) || (CBW.bCBLength < 1) || CBW.bCBLength > 16) {
555
-fail: CSW.bStatus = CSW_CMD_FAILED;
556
-      MSC_SetCSW();
557
-      _DBG("Failed SCSI OP code ");
558
-      _DBH(CBW.CB[0]);
559
-      _DBG("\n");
560
-    } else {
561
-      switch (CBW.CB[0]) {
562
-        case SCSI_TEST_UNIT_READY:
563
-          MSC_TestUnitReady();
564
-          break;
565
-        case SCSI_REQUEST_SENSE:
566
-          MSC_RequestSense();
567
-          break;
568
-        case SCSI_FORMAT_UNIT:
569
-          goto fail;
570
-        case SCSI_INQUIRY:
571
-          MSC_Inquiry();
572
-          break;
573
-        case SCSI_START_STOP_UNIT:
574
-          MSC_StartStopUnit();
575
-          break;
576
-        case SCSI_MEDIA_REMOVAL:
577
-          MSC_SD_Lock();
578
-          break;
579
-        case SCSI_MODE_SELECT6:
580
-          goto fail;
581
-        case SCSI_MODE_SENSE6:
582
-          MSC_ModeSense6();
583
-          break;
584
-        case SCSI_MODE_SELECT10:
585
-          goto fail;
586
-        case SCSI_MODE_SENSE10:
587
-          MSC_ModeSense10();
588
-          break;
589
-        case SCSI_READ_FORMAT_CAPACITIES:
590
-          MSC_ReadFormatCapacity();
591
-          break;
592
-        case SCSI_READ_CAPACITY:
593
-          MSC_ReadCapacity();
594
-          break;
595
-        case SCSI_READ10:
596
-          if (MSC_RWSetup()) {
597
-            if ((CBW.bmFlags & 0x80) != 0) {
598
-              BulkStage = MSC_BS_DATA_IN;
599
-              MSC_MemoryRead();
600
-            } else {
601
-              USB_SetStallEP(MSC_EP_OUT);
602
-              CSW.bStatus = CSW_PHASE_ERROR;
603
-              MSC_SetCSW();
604
-            }
605
-          }
606
-          break;
607
-        case SCSI_WRITE10:
608
-          if (MSC_RWSetup()) {
609
-            if ((CBW.bmFlags & 0x80) == 0) {
610
-              BulkStage = MSC_BS_DATA_OUT;
611
-            } else {
612
-              USB_SetStallEP(MSC_EP_IN);
613
-              CSW.bStatus = CSW_PHASE_ERROR;
614
-              MSC_SetCSW();
615
-            }
616
-          }
617
-          break;
618
-        case SCSI_VERIFY10:
619
-          if (MSC_RWSetup()) {
620
-            if ((CBW.bmFlags & 0x80) == 0) {
621
-              BulkStage = MSC_BS_DATA_OUT;
622
-              MemOK = TRUE;
623
-            } else {
624
-              USB_SetStallEP(MSC_EP_IN);
625
-              CSW.bStatus = CSW_PHASE_ERROR;
626
-              MSC_SetCSW();
627
-            }
628
-          }
629
-          break;
630
-        default:
631
-          goto fail;
632
-      }
633
-    }
634
-  } else {
635
-    /* Invalid CBW */
636
-    USB_SetStallEP(MSC_EP_IN);
637
-    USB_SetStallEP(MSC_EP_OUT);
638
-    BulkStage = MSC_BS_ERROR;
639
-  }
640
-}
641
-
642
-
643
-/*
644
- *  MSC Set Command Status Wrapper Callback
645
- *    Parameters:      None (global variables)
646
- *    Return Value:    None
647
- */
648
-
649
-void MSC_SetCSW (void) {
650
-
651
-  CSW.dSignature = MSC_CSW_Signature;
652
-  USB_WriteEP(MSC_EP_IN, (uint8_t *)&CSW, sizeof(CSW));
653
-  BulkStage = MSC_BS_CSW;
654
-}
655
-
656
-
657
-/*
658
- *  MSC Bulk In Callback
659
- *    Parameters:      None (global variables)
660
- *    Return Value:    None
661
- */
662
-
663
-void MSC_BulkIn (void) {
664
-
665
-  switch (BulkStage) {
666
-    case MSC_BS_DATA_IN:
667
-      switch (CBW.CB[0]) {
668
-        case SCSI_READ10:
669
-          MSC_MemoryRead();
670
-          break;
671
-      }
672
-      break;
673
-    case MSC_BS_DATA_IN_LAST:
674
-      MSC_SetCSW();
675
-      break;
676
-    case MSC_BS_DATA_IN_LAST_STALL:
677
-      USB_SetStallEP(MSC_EP_IN);
678
-      MSC_SetCSW();
679
-      break;
680
-    case MSC_BS_CSW:
681
-      BulkStage = MSC_BS_CBW;
682
-      break;
683
-  }
684
-}
685
-
686
-
687
-/*
688
- *  MSC Bulk Out Callback
689
- *    Parameters:      None (global variables)
690
- *    Return Value:    None
691
- */
692
-
693
-void MSC_BulkOut (void) {
694
-
695
-  BulkLen = (uint8_t)USB_ReadEP(MSC_EP_OUT, BulkBuf);
696
-  switch (BulkStage) {
697
-    case MSC_BS_CBW:
698
-      MSC_GetCBW();
699
-      break;
700
-    case MSC_BS_DATA_OUT:
701
-      switch (CBW.CB[0]) {
702
-        case SCSI_WRITE10:
703
-          MSC_MemoryWrite();
704
-          break;
705
-        case SCSI_VERIFY10:
706
-          MSC_MemoryVerify();
707
-          break;
708
-      }
709
-      break;
710
-    default:
711
-      USB_SetStallEP(MSC_EP_OUT);
712
-      CSW.bStatus = CSW_PHASE_ERROR;
713
-      MSC_SetCSW();
714
-      break;
715
-  }
716
-}

+ 0
- 69
Marlin/src/HAL/HAL_LPC1768/usb/mscuser.h 查看文件

@@ -1,69 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- *      Name:    MSCUSER.H
5
- *      Purpose: Mass Storage Class Custom User Definitions
6
- *      Version: V1.10
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
14
- *      else gives you the right to use this software.
15
- *
16
- *      Copyright (c) 2005-2009 Keil Software.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __MSCUSER_H__
20
-#define __MSCUSER_H__
21
-
22
-
23
-/* Max In/Out Packet Size */
24
-#define MSC_MAX_PACKET  64
25
-#define MSC_BLOCK_SIZE 512
26
-
27
-/* MSC In/Out Endpoint Address */
28
-#define MSC_EP_IN       0x85
29
-#define MSC_EP_OUT      0x05
30
-
31
-/* MSC Requests Callback Functions */
32
-extern uint32_t MSC_Reset     (void);
33
-extern uint32_t MSC_GetMaxLUN (void);
34
-
35
-/* MSC Bulk Callback Functions */
36
-extern void MSC_GetCBW (void);
37
-extern void MSC_SetCSW (void);
38
-extern void MSC_BulkIn (void);
39
-extern void MSC_BulkOut(void);
40
-
41
-enum class Sense_KEY : uint8_t {
42
-  NO_SENSE,
43
-  RECOVERED_ERROR,
44
-  NOT_READY,
45
-  MEDIUM_ERROR,
46
-  HARDWARE_ERROR,
47
-  ILLEGAL_REQUEST,
48
-  UNIT_ATTENTION,
49
-  DATA_PROTECT
50
-};
51
-
52
-enum class Sense_ASC : uint8_t {
53
-  CANNOT_READ_MEDIUM = 0x30,
54
-  MEDIUM_NOT_PRESENT = 0x3A
55
-};
56
-
57
-enum class Sense_ASCQ : uint8_t {
58
-  // CANNOT_READ_MEDIUM
59
-  UNKNOWN_FORMAT = 0x01,
60
-  // MEDIUM_NOT_PRESENT
61
-  REASON_UNKNOWN = 0x00,
62
-  TRAY_CLOSED,
63
-  TRAY_OPEN,
64
-  LOADABLE,
65
-  AUXILIARY_MEMORY_ACCESSIBLE
66
-};
67
-
68
-
69
-#endif  /* __MSCUSER_H__ */

+ 0
- 353
Marlin/src/HAL/HAL_LPC1768/usb/usb.h 查看文件

@@ -1,353 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usb.h
5
- * Purpose: USB Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __USB_H__
20
-#define __USB_H__
21
-extern "C" {
22
-#include "lpc_types.h"
23
-}
24
-#if defined   (  __GNUC__  )
25
-#define __packed __attribute__((__packed__))
26
-#endif
27
-
28
-#if defined     (  __CC_ARM  )
29
-typedef __packed union {
30
-#elif defined   (  __GNUC__  )
31
-typedef union __packed {
32
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
33
-#pragma pack(1)
34
-typedef union {
35
-#endif
36
-  uint16_t W;
37
-#if defined     (  __CC_ARM  )
38
-  __packed struct {
39
-#elif defined   (  __GNUC__  )
40
-  struct __packed {
41
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
42
-#pragma pack(1)
43
-  struct {
44
-#endif
45
-    uint8_t L;
46
-    uint8_t H;
47
-  } WB;
48
-#ifdef __IAR_SYSTEMS_ICC__
49
-#pragma pack()
50
-#endif
51
-} WORD_BYTE;
52
-#ifdef __IAR_SYSTEMS_ICC__
53
-#pragma pack()
54
-#endif
55
-
56
-
57
-/* bmRequestType.Dir */
58
-#define REQUEST_HOST_TO_DEVICE     0
59
-#define REQUEST_DEVICE_TO_HOST     1
60
-
61
-/* bmRequestType.Type */
62
-#define REQUEST_STANDARD           0
63
-#define REQUEST_CLASS              1
64
-#define REQUEST_VENDOR             2
65
-#define REQUEST_RESERVED           3
66
-
67
-/* bmRequestType.Recipient */
68
-#define REQUEST_TO_DEVICE          0
69
-#define REQUEST_TO_INTERFACE       1
70
-#define REQUEST_TO_ENDPOINT        2
71
-#define REQUEST_TO_OTHER           3
72
-
73
-/* bmRequestType Definition */
74
-#if defined     (  __CC_ARM  )
75
-typedef __packed union _REQUEST_TYPE {
76
-#elif defined   (  __GNUC__  )
77
-typedef union __packed _REQUEST_TYPE {
78
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
79
-#pragma pack(1)
80
-typedef union _REQUEST_TYPE {
81
-#endif
82
-#if defined     (  __CC_ARM  )
83
-  __packed struct _BM {
84
-#elif defined   (  __GNUC__  )
85
-  struct __packed _BM {
86
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
87
-#pragma pack(1)
88
-  struct _BM {
89
-#endif
90
-    uint8_t Recipient : 5;
91
-    uint8_t Type      : 2;
92
-    uint8_t Dir       : 1;
93
-  } BM;
94
-#ifdef __IAR_SYSTEMS_ICC__
95
-#pragma pack()
96
-#endif
97
-  uint8_t B;
98
-} REQUEST_TYPE;
99
-#ifdef __IAR_SYSTEMS_ICC__
100
-#pragma pack()
101
-#endif
102
-
103
-/* USB Standard Request Codes */
104
-#define USB_REQUEST_GET_STATUS                 0
105
-#define USB_REQUEST_CLEAR_FEATURE              1
106
-#define USB_REQUEST_SET_FEATURE                3
107
-#define USB_REQUEST_SET_ADDRESS                5
108
-#define USB_REQUEST_GET_DESCRIPTOR             6
109
-#define USB_REQUEST_SET_DESCRIPTOR             7
110
-#define USB_REQUEST_GET_CONFIGURATION          8
111
-#define USB_REQUEST_SET_CONFIGURATION          9
112
-#define USB_REQUEST_GET_INTERFACE              10
113
-#define USB_REQUEST_SET_INTERFACE              11
114
-#define USB_REQUEST_SYNC_FRAME                 12
115
-
116
-/* USB GET_STATUS Bit Values */
117
-#define USB_GETSTATUS_SELF_POWERED             0x01
118
-#define USB_GETSTATUS_REMOTE_WAKEUP            0x02
119
-#define USB_GETSTATUS_ENDPOINT_STALL           0x01
120
-
121
-/* USB Standard Feature selectors */
122
-#define USB_FEATURE_ENDPOINT_STALL             0
123
-#define USB_FEATURE_REMOTE_WAKEUP              1
124
-
125
-/* USB Default Control Pipe Setup Packet */
126
-#if defined     (  __CC_ARM  )
127
-typedef __packed struct _USB_SETUP_PACKET {
128
-#elif defined   (  __GNUC__  )
129
-typedef struct __packed _USB_SETUP_PACKET {
130
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
131
-#pragma pack(1)
132
-typedef struct _USB_SETUP_PACKET {
133
-#endif
134
-  REQUEST_TYPE bmRequestType;
135
-  uint8_t         bRequest;
136
-  WORD_BYTE    wValue;
137
-  WORD_BYTE    wIndex;
138
-  uint16_t         wLength;
139
-} USB_SETUP_PACKET;
140
-#ifdef __IAR_SYSTEMS_ICC__
141
-#pragma pack()
142
-#endif
143
-
144
-
145
-/* USB Descriptor Types */
146
-#define USB_DEVICE_DESCRIPTOR_TYPE             1
147
-#define USB_CONFIGURATION_DESCRIPTOR_TYPE      2
148
-#define USB_STRING_DESCRIPTOR_TYPE             3
149
-#define USB_INTERFACE_DESCRIPTOR_TYPE          4
150
-#define USB_ENDPOINT_DESCRIPTOR_TYPE           5
151
-#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   6
152
-#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
153
-#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE    8
154
-#define USB_OTG_DESCRIPTOR_TYPE                     9
155
-#define USB_DEBUG_DESCRIPTOR_TYPE                  10
156
-#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11
157
-
158
-/* USB Device Classes */
159
-#define USB_DEVICE_CLASS_RESERVED              0x00
160
-#define USB_DEVICE_CLASS_AUDIO                 0x01
161
-#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02
162
-#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03
163
-#define USB_DEVICE_CLASS_MONITOR               0x04
164
-#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05
165
-#define USB_DEVICE_CLASS_POWER                 0x06
166
-#define USB_DEVICE_CLASS_PRINTER               0x07
167
-#define USB_DEVICE_CLASS_STORAGE               0x08
168
-#define USB_DEVICE_CLASS_HUB                   0x09
169
-#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF
170
-#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF
171
-
172
-/* bmAttributes in Configuration Descriptor */
173
-#define USB_CONFIG_POWERED_MASK                0x40
174
-#define USB_CONFIG_BUS_POWERED                 0x80
175
-#define USB_CONFIG_SELF_POWERED                0xC0
176
-#define USB_CONFIG_REMOTE_WAKEUP               0x20
177
-
178
-/* bMaxPower in Configuration Descriptor */
179
-#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)
180
-
181
-/* bEndpointAddress in Endpoint Descriptor */
182
-#define USB_ENDPOINT_DIRECTION_MASK            0x80
183
-#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)
184
-#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
185
-
186
-/* bmAttributes in Endpoint Descriptor */
187
-#define USB_ENDPOINT_TYPE_MASK                 0x03
188
-#define USB_ENDPOINT_TYPE_CONTROL              0x00
189
-#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01
190
-#define USB_ENDPOINT_TYPE_BULK                 0x02
191
-#define USB_ENDPOINT_TYPE_INTERRUPT            0x03
192
-#define USB_ENDPOINT_SYNC_MASK                 0x0C
193
-#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00
194
-#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04
195
-#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08
196
-#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C
197
-#define USB_ENDPOINT_USAGE_MASK                0x30
198
-#define USB_ENDPOINT_USAGE_DATA                0x00
199
-#define USB_ENDPOINT_USAGE_FEEDBACK            0x10
200
-#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20
201
-#define USB_ENDPOINT_USAGE_RESERVED            0x30
202
-
203
-/* USB Standard Device Descriptor */
204
-#if defined     (  __CC_ARM  )
205
-typedef __packed struct _USB_DEVICE_DESCRIPTOR {
206
-#elif defined   (  __GNUC__  )
207
-typedef struct __packed _USB_DEVICE_DESCRIPTOR {
208
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
209
-#pragma pack(1)
210
-typedef struct _USB_DEVICE_DESCRIPTOR {
211
-#endif
212
-  uint8_t  bLength;
213
-  uint8_t  bDescriptorType;
214
-  uint16_t  bcdUSB;
215
-  uint8_t  bDeviceClass;
216
-  uint8_t  bDeviceSubClass;
217
-  uint8_t  bDeviceProtocol;
218
-  uint8_t  bMaxPacketSize0;
219
-  uint16_t  idVendor;
220
-  uint16_t  idProduct;
221
-  uint16_t  bcdDevice;
222
-  uint8_t  iManufacturer;
223
-  uint8_t  iProduct;
224
-  uint8_t  iSerialNumber;
225
-  uint8_t  bNumConfigurations;
226
-} USB_DEVICE_DESCRIPTOR;
227
-#ifdef __IAR_SYSTEMS_ICC__
228
-#pragma pack()
229
-#endif
230
-
231
-/* USB 2.0 Device Qualifier Descriptor */
232
-#if defined     (  __CC_ARM  )
233
-typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
234
-#elif defined   (  __GNUC__  )
235
-typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR {
236
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
237
-#pragma pack(1)
238
-typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
239
-#endif
240
-  uint8_t  bLength;
241
-  uint8_t  bDescriptorType;
242
-  uint16_t  bcdUSB;
243
-  uint8_t  bDeviceClass;
244
-  uint8_t  bDeviceSubClass;
245
-  uint8_t  bDeviceProtocol;
246
-  uint8_t  bMaxPacketSize0;
247
-  uint8_t  bNumConfigurations;
248
-  uint8_t  bReserved;
249
-} USB_DEVICE_QUALIFIER_DESCRIPTOR;
250
-#ifdef __IAR_SYSTEMS_ICC__
251
-#pragma pack()
252
-#endif
253
-
254
-#if defined     (  __CC_ARM  )
255
-typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
256
-#elif defined   (  __GNUC__  )
257
-typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR {
258
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
259
-#pragma pack(1)
260
-typedef struct _USB_CONFIGURATION_DESCRIPTOR {
261
-#endif
262
-  uint8_t  bLength;
263
-  uint8_t  bDescriptorType;
264
-  uint16_t  wTotalLength;
265
-  uint8_t  bNumInterfaces;
266
-  uint8_t  bConfigurationValue;
267
-  uint8_t  iConfiguration;
268
-  uint8_t  bmAttributes;
269
-  uint8_t  bMaxPower;
270
-} USB_CONFIGURATION_DESCRIPTOR;
271
-#ifdef __IAR_SYSTEMS_ICC__
272
-#pragma pack()
273
-#endif
274
-
275
-/* USB Standard Interface Descriptor */
276
-#if defined     (  __CC_ARM  )
277
-typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
278
-#elif defined   (  __GNUC__  )
279
-typedef struct __packed _USB_INTERFACE_DESCRIPTOR {
280
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
281
-#pragma pack(1)
282
-typedef struct _USB_INTERFACE_DESCRIPTOR {
283
-#endif
284
-  uint8_t  bLength;
285
-  uint8_t  bDescriptorType;
286
-  uint8_t  bInterfaceNumber;
287
-  uint8_t  bAlternateSetting;
288
-  uint8_t  bNumEndpoints;
289
-  uint8_t  bInterfaceClass;
290
-  uint8_t  bInterfaceSubClass;
291
-  uint8_t  bInterfaceProtocol;
292
-  uint8_t  iInterface;
293
-} USB_INTERFACE_DESCRIPTOR;
294
-#ifdef __IAR_SYSTEMS_ICC__
295
-#pragma pack()
296
-#endif
297
-
298
-/* USB Standard Endpoint Descriptor */
299
-#if defined     (  __CC_ARM  )
300
-typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
301
-#elif defined   (  __GNUC__  )
302
-typedef struct __packed _USB_ENDPOINT_DESCRIPTOR {
303
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
304
-#pragma pack(1)
305
-typedef struct _USB_ENDPOINT_DESCRIPTOR {
306
-#endif
307
-  uint8_t  bLength;
308
-  uint8_t  bDescriptorType;
309
-  uint8_t  bEndpointAddress;
310
-  uint8_t  bmAttributes;
311
-  uint16_t  wMaxPacketSize;
312
-  uint8_t  bInterval;
313
-} USB_ENDPOINT_DESCRIPTOR;
314
-#ifdef __IAR_SYSTEMS_ICC__
315
-#pragma pack()
316
-#endif
317
-
318
-/* USB String Descriptor */
319
-#if defined     (  __CC_ARM  )
320
-typedef __packed struct _USB_STRING_DESCRIPTOR {
321
-#elif defined   (  __GNUC__  )
322
-typedef struct __packed _USB_STRING_DESCRIPTOR {
323
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
324
-#pragma pack(1)
325
-typedef struct _USB_STRING_DESCRIPTOR {
326
-#endif
327
-  uint8_t  bLength;
328
-  uint8_t  bDescriptorType;
329
-  uint16_t  bString/*[]*/;
330
-} USB_STRING_DESCRIPTOR;
331
-#ifdef __IAR_SYSTEMS_ICC__
332
-#pragma pack()
333
-#endif
334
-
335
-/* USB Common Descriptor */
336
-#if defined     (  __CC_ARM  )
337
-typedef __packed struct _USB_COMMON_DESCRIPTOR {
338
-#elif defined   (  __GNUC__  )
339
-typedef struct __packed _USB_COMMON_DESCRIPTOR {
340
-#elif defined   (  __IAR_SYSTEMS_ICC__  )
341
-#pragma pack(1)
342
-typedef struct _USB_COMMON_DESCRIPTOR {
343
-#endif
344
-  uint8_t  bLength;
345
-  uint8_t  bDescriptorType;
346
-} USB_COMMON_DESCRIPTOR;
347
-#ifdef __IAR_SYSTEMS_ICC__
348
-#pragma pack()
349
-#endif
350
-
351
-
352
-
353
-#endif  /* __USB_H__ */

+ 0
- 181
Marlin/src/HAL/HAL_LPC1768/usb/usbcfg.h 查看文件

@@ -1,181 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbcfg.h
5
- * Purpose: USB Custom Configuration
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *----------------------------------------------------------------------------
18
- * History:
19
- *          V1.20 Added vendor specific support
20
- *          V1.00 Initial Version
21
- *---------------------------------------------------------------------------*/
22
-
23
-#ifndef __USBCFG_H__
24
-#define __USBCFG_H__
25
-
26
-
27
-//*** <<< Use Configuration Wizard in Context Menu >>> ***
28
-
29
-
30
-/*
31
-// <h> USB Configuration
32
-//   <o0> USB Power
33
-//        <i> Default Power Setting
34
-//        <0=> Bus-powered
35
-//        <1=> Self-powered
36
-//   <o1> Max Number of Interfaces <1-256>
37
-//   <o2> Max Number of Endpoints  <1-32>
38
-//   <o3> Max Endpoint 0 Packet Size
39
-//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
40
-//   <e4> DMA Transfer
41
-//     <i> Use DMA for selected Endpoints
42
-//     <o5.0>  Endpoint 0 Out
43
-//     <o5.1>  Endpoint 0 In
44
-//     <o5.2>  Endpoint 1 Out
45
-//     <o5.3>  Endpoint 1 In
46
-//     <o5.4>  Endpoint 2 Out
47
-//     <o5.5>  Endpoint 2 In
48
-//     <o5.6>  Endpoint 3 Out
49
-//     <o5.7>  Endpoint 3 In
50
-//     <o5.8>  Endpoint 4 Out
51
-//     <o5.9>  Endpoint 4 In
52
-//     <o5.10> Endpoint 5 Out
53
-//     <o5.11> Endpoint 5 In
54
-//     <o5.12> Endpoint 6 Out
55
-//     <o5.13> Endpoint 6 In
56
-//     <o5.14> Endpoint 7 Out
57
-//     <o5.15> Endpoint 7 In
58
-//     <o5.16> Endpoint 8 Out
59
-//     <o5.17> Endpoint 8 In
60
-//     <o5.18> Endpoint 9 Out
61
-//     <o5.19> Endpoint 9 In
62
-//     <o5.20> Endpoint 10 Out
63
-//     <o5.21> Endpoint 10 In
64
-//     <o5.22> Endpoint 11 Out
65
-//     <o5.23> Endpoint 11 In
66
-//     <o5.24> Endpoint 12 Out
67
-//     <o5.25> Endpoint 12 In
68
-//     <o5.26> Endpoint 13 Out
69
-//     <o5.27> Endpoint 13 In
70
-//     <o5.28> Endpoint 14 Out
71
-//     <o5.29> Endpoint 14 In
72
-//     <o5.30> Endpoint 15 Out
73
-//     <o5.31> Endpoint 15 In
74
-//   </e>
75
-// </h>
76
-*/
77
-
78
-#define USB_POWER           0
79
-#define USB_IF_NUM          4
80
-#define USB_EP_NUM          32
81
-#define USB_MAX_PACKET0     64
82
-#define USB_DMA             0
83
-#define USB_DMA_EP          0x00000000
84
-
85
-
86
-/*
87
-// <h> USB Event Handlers
88
-//   <h> Device Events
89
-//     <o0.0> Power Event
90
-//     <o1.0> Reset Event
91
-//     <o2.0> Suspend Event
92
-//     <o3.0> Resume Event
93
-//     <o4.0> Remote Wakeup Event
94
-//     <o5.0> Start of Frame Event
95
-//     <o6.0> Error Event
96
-//   </h>
97
-//   <h> Endpoint Events
98
-//     <o7.0>  Endpoint 0 Event
99
-//     <o7.1>  Endpoint 1 Event
100
-//     <o7.2>  Endpoint 2 Event
101
-//     <o7.3>  Endpoint 3 Event
102
-//     <o7.4>  Endpoint 4 Event
103
-//     <o7.5>  Endpoint 5 Event
104
-//     <o7.6>  Endpoint 6 Event
105
-//     <o7.7>  Endpoint 7 Event
106
-//     <o7.8>  Endpoint 8 Event
107
-//     <o7.9>  Endpoint 9 Event
108
-//     <o7.10> Endpoint 10 Event
109
-//     <o7.11> Endpoint 11 Event
110
-//     <o7.12> Endpoint 12 Event
111
-//     <o7.13> Endpoint 13 Event
112
-//     <o7.14> Endpoint 14 Event
113
-//     <o7.15> Endpoint 15 Event
114
-//   </h>
115
-//   <h> USB Core Events
116
-//     <o8.0>  Set Configuration Event
117
-//     <o9.0>  Set Interface Event
118
-//     <o10.0> Set/Clear Feature Event
119
-//   </h>
120
-// </h>
121
-*/
122
-
123
-#define USB_POWER_EVENT     0
124
-#define USB_RESET_EVENT     1
125
-#define USB_SUSPEND_EVENT   0
126
-#define USB_RESUME_EVENT    0
127
-#define USB_WAKEUP_EVENT    0
128
-#define USB_SOF_EVENT       0
129
-#define USB_ERROR_EVENT     0
130
-#define USB_EP_EVENT        0x0027
131
-#define USB_CONFIGURE_EVENT 1
132
-#define USB_INTERFACE_EVENT 0
133
-#define USB_FEATURE_EVENT   0
134
-
135
-
136
-/*
137
-// <e0> USB Class Support
138
-//   <i> enables USB Class specific Requests
139
-//   <e1> Human Interface Device (HID)
140
-//     <o2> Interface Number <0-255>
141
-//   </e>
142
-//   <e3> Mass Storage
143
-//     <o4> Interface Number <0-255>
144
-//   </e>
145
-//   <e5> Audio Device
146
-//     <o6> Control Interface Number <0-255>
147
-//     <o7> Streaming Interface 1 Number <0-255>
148
-//     <o8> Streaming Interface 2 Number <0-255>
149
-//   </e>
150
-//   <e9> Communication Device
151
-//     <o10> Control Interface Number <0-255>
152
-//     <o11> Bulk Interface Number <0-255>
153
-//     <o12> Max Communication Device Buffer Size
154
-//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes 
155
-//   </e>
156
-// </e>
157
-*/
158
-
159
-#define USB_CLASS           1
160
-#define USB_HID             0
161
-#define USB_HID_IF_NUM      0
162
-#define USB_MSC             1
163
-#define USB_MSC_IF_NUM      2
164
-#define USB_AUDIO           0
165
-#define USB_ADC_CIF_NUM     0
166
-#define USB_ADC_SIF1_NUM    1
167
-#define USB_ADC_SIF2_NUM    2
168
-#define USB_CDC  			1
169
-#define USB_CDC_CIF_NUM     0
170
-#define USB_CDC_DIF_NUM     1
171
-#define USB_CDC_BUFSIZE     64
172
-
173
-/*
174
-// <e0> USB Vendor Support
175
-//   <i> enables USB Vendor specific Requests
176
-// </e>
177
-*/
178
-#define USB_VENDOR          0
179
-
180
-
181
-#endif  /* __USBCFG_H__ */

+ 0
- 815
Marlin/src/HAL/HAL_LPC1768/usb/usbcore.cpp 查看文件

@@ -1,815 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbcore.c
5
- * Purpose: USB Core Module
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *----------------------------------------------------------------------------
18
- * History:
19
- *          V1.20 Added vendor specific requests
20
- *                Changed string descriptor handling
21
- *                Reworked Endpoint0
22
- *          V1.00 Initial Version
23
- *----------------------------------------------------------------------------*/
24
-extern "C" {
25
-#include "lpc_types.h"
26
-}
27
-#include "usb.h"
28
-#include "usbcfg.h"
29
-#include "usbhw.h"
30
-#include "usbcore.h"
31
-#include "usbdesc.h"
32
-#include "usbuser.h"
33
-
34
-#include "msc.h"
35
-#include "mscuser.h"
36
-extern MSC_CSW CSW;
37
-
38
-#include "cdc.h"
39
-#include "cdcuser.h"
40
-
41
-#define __packed __attribute__((__packed__))
42
-
43
-uint16_t USB_DeviceStatus;
44
-uint8_t USB_DeviceAddress;
45
-uint8_t USB_Configuration;
46
-uint32_t USB_EndPointMask;
47
-uint32_t USB_EndPointHalt;
48
-uint32_t USB_EndPointStall; /* EP must stay stalled */
49
-uint8_t USB_NumInterfaces;
50
-uint8_t USB_AltSetting[USB_IF_NUM];
51
-
52
-uint8_t EP0Buf[USB_MAX_PACKET0];
53
-
54
-USB_EP_DATA EP0Data;
55
-
56
-USB_SETUP_PACKET SetupPacket;
57
-
58
-/*
59
- *  Reset USB Core
60
- *    Parameters:      None
61
- *    Return Value:    None
62
- */
63
-
64
-void USB_ResetCore(void) {
65
-
66
-  USB_DeviceStatus = USB_POWER;
67
-  USB_DeviceAddress = 0;
68
-  USB_Configuration = 0;
69
-  USB_EndPointMask = 0x00010001;
70
-  USB_EndPointHalt = 0x00000000;
71
-  USB_EndPointStall = 0x00000000;
72
-}
73
-
74
-/*
75
- *  USB Request - Setup Stage
76
- *    Parameters:      None (global SetupPacket)
77
- *    Return Value:    None
78
- */
79
-
80
-void USB_SetupStage(void) {
81
-  USB_ReadEP(0x00, (uint8_t *) &SetupPacket);
82
-}
83
-
84
-/*
85
- *  USB Request - Data In Stage
86
- *    Parameters:      None (global EP0Data)
87
- *    Return Value:    None
88
- */
89
-
90
-void USB_DataInStage(void) {
91
-  uint32_t cnt;
92
-
93
-  if (EP0Data.Count > USB_MAX_PACKET0) {
94
-    cnt = USB_MAX_PACKET0;
95
-  } else {
96
-    cnt = EP0Data.Count;
97
-  }
98
-  cnt = USB_WriteEP(0x80, EP0Data.pData, cnt);
99
-  EP0Data.pData += cnt;
100
-  EP0Data.Count -= cnt;
101
-}
102
-
103
-/*
104
- *  USB Request - Data Out Stage
105
- *    Parameters:      None (global EP0Data)
106
- *    Return Value:    None
107
- */
108
-
109
-void USB_DataOutStage(void) {
110
-  uint32_t cnt;
111
-
112
-  cnt = USB_ReadEP(0x00, EP0Data.pData);
113
-  EP0Data.pData += cnt;
114
-  EP0Data.Count -= cnt;
115
-}
116
-
117
-/*
118
- *  USB Request - Status In Stage
119
- *    Parameters:      None
120
- *    Return Value:    None
121
- */
122
-
123
-void USB_StatusInStage(void) {
124
-  USB_WriteEP(0x80, nullptr, 0);
125
-}
126
-
127
-/*
128
- *  USB Request - Status Out Stage
129
- *    Parameters:      None
130
- *    Return Value:    None
131
- */
132
-
133
-void USB_StatusOutStage(void) {
134
-  USB_ReadEP(0x00, EP0Buf);
135
-}
136
-
137
-/*
138
- *  Get Status USB Request
139
- *    Parameters:      None (global SetupPacket)
140
- *    Return Value:    TRUE - Success, FALSE - Error
141
- */
142
-
143
-__inline uint32_t USB_ReqGetStatus(void) {
144
-  uint32_t n, m;
145
-
146
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
147
-  case REQUEST_TO_DEVICE:
148
-    EP0Data.pData = (uint8_t *) &USB_DeviceStatus;
149
-    break;
150
-  case REQUEST_TO_INTERFACE:
151
-    if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
152
-      *((__packed uint16_t *) EP0Buf) = 0;
153
-      *((uint16_t *) EP0Buf) = 0;
154
-      EP0Data.pData = EP0Buf;
155
-    } else {
156
-      return (FALSE);
157
-    }
158
-    break;
159
-  case REQUEST_TO_ENDPOINT:
160
-    n = SetupPacket.wIndex.WB.L & 0x8F;
161
-    m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
162
-    if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
163
-      *((__packed uint16_t *) EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
164
-      *((uint16_t *) EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
165
-      EP0Data.pData = EP0Buf;
166
-    } else {
167
-      return (FALSE);
168
-    }
169
-    break;
170
-  default:
171
-    return (FALSE);
172
-  }
173
-  return (TRUE);
174
-}
175
-
176
-/*
177
- *  Set/Clear Feature USB Request
178
- *    Parameters:      sc:    0 - Clear, 1 - Set
179
- *                            (global SetupPacket)
180
- *    Return Value:    TRUE - Success, FALSE - Error
181
- */
182
-
183
-__inline uint32_t USB_ReqSetClrFeature(uint32_t sc) {
184
-  uint32_t n, m;
185
-
186
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
187
-  case REQUEST_TO_DEVICE:
188
-    if (SetupPacket.wValue.W == USB_FEATURE_REMOTE_WAKEUP) {
189
-      if (sc) {
190
-        USB_WakeUpCfg(TRUE);
191
-        USB_DeviceStatus |= USB_GETSTATUS_REMOTE_WAKEUP;
192
-      } else {
193
-        USB_WakeUpCfg(FALSE);
194
-        USB_DeviceStatus &= ~USB_GETSTATUS_REMOTE_WAKEUP;
195
-      }
196
-    } else {
197
-      return (FALSE);
198
-    }
199
-    break;
200
-  case REQUEST_TO_INTERFACE:
201
-    return (FALSE);
202
-  case REQUEST_TO_ENDPOINT:
203
-    n = SetupPacket.wIndex.WB.L & 0x8F;
204
-    m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
205
-    if ((USB_Configuration != 0) && ((n & 0x0F) != 0) && (USB_EndPointMask & m)) {
206
-      if (SetupPacket.wValue.W == USB_FEATURE_ENDPOINT_STALL) {
207
-        if (sc) {
208
-          USB_SetStallEP(n);
209
-          USB_EndPointHalt |= m;
210
-        } else {
211
-          if ((USB_EndPointStall & m) != 0) {
212
-            return (TRUE);
213
-          }
214
-          USB_ClrStallEP(n);
215
-#if (USB_MSC)
216
-          if ((n == MSC_EP_IN) && ((USB_EndPointHalt & m) != 0)) {
217
-            /* Compliance Test: rewrite CSW after unstall */
218
-            if (CSW.dSignature == MSC_CSW_Signature) {
219
-              USB_WriteEP(MSC_EP_IN, (uint8_t *) &CSW, sizeof(CSW));
220
-            }
221
-          }
222
-#endif
223
-          USB_EndPointHalt &= ~m;
224
-        }
225
-      } else {
226
-        return (FALSE);
227
-      }
228
-    } else {
229
-      return (FALSE);
230
-    }
231
-    break;
232
-  default:
233
-    return (FALSE);
234
-  }
235
-  return (TRUE);
236
-}
237
-
238
-/*
239
- *  Set Address USB Request
240
- *    Parameters:      None (global SetupPacket)
241
- *    Return Value:    TRUE - Success, FALSE - Error
242
- */
243
-
244
-__inline uint32_t USB_ReqSetAddress(void) {
245
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
246
-  case REQUEST_TO_DEVICE:
247
-    USB_DeviceAddress = 0x80 | SetupPacket.wValue.WB.L;
248
-    break;
249
-  default:
250
-    return (FALSE);
251
-  }
252
-  return (TRUE);
253
-}
254
-
255
-/*
256
- *  Get Descriptor USB Request
257
- *    Parameters:      None (global SetupPacket)
258
- *    Return Value:    TRUE - Success, FALSE - Error
259
- */
260
-
261
-__inline uint32_t USB_ReqGetDescriptor(void) {
262
-  uint8_t *pD;
263
-  uint32_t len, n;
264
-
265
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
266
-  case REQUEST_TO_DEVICE:
267
-    switch (SetupPacket.wValue.WB.H) {
268
-    case USB_DEVICE_DESCRIPTOR_TYPE:
269
-      EP0Data.pData = (uint8_t *) USB_DeviceDescriptor;
270
-      len = USB_DEVICE_DESC_SIZE;
271
-      break;
272
-    case USB_CONFIGURATION_DESCRIPTOR_TYPE:
273
-      pD = (uint8_t *) USB_ConfigDescriptor;
274
-      for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
275
-        if (((USB_CONFIGURATION_DESCRIPTOR *) pD)->bLength != 0) {
276
-          pD += ((USB_CONFIGURATION_DESCRIPTOR *) pD)->wTotalLength;
277
-        }
278
-      }
279
-      if (((USB_CONFIGURATION_DESCRIPTOR *) pD)->bLength == 0) {
280
-        return (FALSE);
281
-      }
282
-      EP0Data.pData = pD;
283
-      len = ((USB_CONFIGURATION_DESCRIPTOR *) pD)->wTotalLength;
284
-      break;
285
-    case USB_STRING_DESCRIPTOR_TYPE:
286
-      pD = (uint8_t *) USB_StringDescriptor;
287
-      for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
288
-        if (((USB_STRING_DESCRIPTOR *) pD)->bLength != 0) {
289
-          pD += ((USB_STRING_DESCRIPTOR *) pD)->bLength;
290
-        }
291
-      }
292
-      if (((USB_STRING_DESCRIPTOR *) pD)->bLength == 0) {
293
-        return (FALSE);
294
-      }
295
-      EP0Data.pData = pD;
296
-      len = ((USB_STRING_DESCRIPTOR *) EP0Data.pData)->bLength;
297
-      break;
298
-    default:
299
-      return (FALSE);
300
-    }
301
-    break;
302
-  case REQUEST_TO_INTERFACE:
303
-    switch (SetupPacket.wValue.WB.H) {
304
-    default:
305
-      return (FALSE);
306
-    }
307
-//      break;
308
-  default:
309
-    return (FALSE);
310
-  }
311
-
312
-  if (EP0Data.Count > len) {
313
-    EP0Data.Count = len;
314
-  }
315
-
316
-  return (TRUE);
317
-}
318
-
319
-/*
320
- *  Get Configuration USB Request
321
- *    Parameters:      None (global SetupPacket)
322
- *    Return Value:    TRUE - Success, FALSE - Error
323
- */
324
-
325
-__inline uint32_t USB_ReqGetConfiguration(void) {
326
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
327
-  case REQUEST_TO_DEVICE:
328
-    EP0Data.pData = &USB_Configuration;
329
-    break;
330
-  default:
331
-    return (FALSE);
332
-  }
333
-  return (TRUE);
334
-}
335
-
336
-/*
337
- *  Set Configuration USB Request
338
- *    Parameters:      None (global SetupPacket)
339
- *    Return Value:    TRUE - Success, FALSE - Error
340
- */
341
-
342
-__inline uint32_t USB_ReqSetConfiguration(void) {
343
-  USB_COMMON_DESCRIPTOR *pD;
344
-  uint32_t alt = 0;
345
-  uint32_t n, m;
346
-  uint32_t tmp;
347
-
348
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
349
-  case REQUEST_TO_DEVICE:
350
-
351
-    if (SetupPacket.wValue.WB.L) {
352
-      pD = (USB_COMMON_DESCRIPTOR *) USB_ConfigDescriptor;
353
-      while (pD->bLength) {
354
-        switch (pD->bDescriptorType) {
355
-        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
356
-          if (((USB_CONFIGURATION_DESCRIPTOR *) pD)->bConfigurationValue == SetupPacket.wValue.WB.L) {
357
-            USB_Configuration = SetupPacket.wValue.WB.L;
358
-            USB_NumInterfaces = ((USB_CONFIGURATION_DESCRIPTOR *) pD)->bNumInterfaces;
359
-            for (n = 0; n < USB_IF_NUM; n++) {
360
-              USB_AltSetting[n] = 0;
361
-            }
362
-            for (n = 1; n < 16; n++) {
363
-              if (USB_EndPointMask & (1 << n)) {
364
-                USB_DisableEP(n);
365
-              }
366
-              if (USB_EndPointMask & ((1 << 16) << n)) {
367
-                USB_DisableEP(n | 0x80);
368
-              }
369
-            }
370
-            USB_EndPointMask = 0x00010001;
371
-            USB_EndPointHalt = 0x00000000;
372
-            USB_EndPointStall = 0x00000000;
373
-            USB_Configure(TRUE);
374
-            if (((USB_CONFIGURATION_DESCRIPTOR *) pD)->bmAttributes & USB_CONFIG_POWERED_MASK) {
375
-              USB_DeviceStatus |= USB_GETSTATUS_SELF_POWERED;
376
-            } else {
377
-              USB_DeviceStatus &= ~(USB_GETSTATUS_SELF_POWERED);
378
-            }
379
-          } else {
380
-//                (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
381
-            tmp = (uint32_t) pD;
382
-            tmp += ((USB_CONFIGURATION_DESCRIPTOR *) pD)->wTotalLength;
383
-            pD = (USB_COMMON_DESCRIPTOR *) tmp;
384
-            continue;
385
-          }
386
-          break;
387
-        case USB_INTERFACE_DESCRIPTOR_TYPE:
388
-          alt = ((USB_INTERFACE_DESCRIPTOR *) pD)->bAlternateSetting;
389
-          break;
390
-        case USB_ENDPOINT_DESCRIPTOR_TYPE:
391
-          if (alt == 0) {
392
-            n = ((USB_ENDPOINT_DESCRIPTOR *) pD)->bEndpointAddress & 0x8F;
393
-            m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
394
-            USB_EndPointMask |= m;
395
-            USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *) pD);
396
-            USB_EnableEP(n);
397
-            USB_ResetEP(n);
398
-          }
399
-          break;
400
-        }
401
-//          (uint8_t *)pD += pD->bLength;
402
-        tmp = (uint32_t) pD;
403
-        tmp += pD->bLength;
404
-        pD = (USB_COMMON_DESCRIPTOR *) tmp;
405
-      }
406
-    } else {
407
-      USB_Configuration = 0;
408
-      for (n = 1; n < 16; n++) {
409
-        if (USB_EndPointMask & (1 << n)) {
410
-          USB_DisableEP(n);
411
-        }
412
-        if (USB_EndPointMask & ((1 << 16) << n)) {
413
-          USB_DisableEP(n | 0x80);
414
-        }
415
-      }
416
-      USB_EndPointMask = 0x00010001;
417
-      USB_EndPointHalt = 0x00000000;
418
-      USB_EndPointStall = 0x00000000;
419
-      USB_Configure(FALSE);
420
-    }
421
-
422
-    if (USB_Configuration != SetupPacket.wValue.WB.L) {
423
-      return (FALSE);
424
-    }
425
-    break;
426
-  default:
427
-    return (FALSE);
428
-  }
429
-  return (TRUE);
430
-}
431
-
432
-/*
433
- *  Get Interface USB Request
434
- *    Parameters:      None (global SetupPacket)
435
- *    Return Value:    TRUE - Success, FALSE - Error
436
- */
437
-
438
-__inline uint32_t USB_ReqGetInterface(void) {
439
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
440
-  case REQUEST_TO_INTERFACE:
441
-    if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
442
-      EP0Data.pData = USB_AltSetting + SetupPacket.wIndex.WB.L;
443
-    } else {
444
-      return (FALSE);
445
-    }
446
-    break;
447
-  default:
448
-    return (FALSE);
449
-  }
450
-  return (TRUE);
451
-}
452
-
453
-/*
454
- *  Set Interface USB Request
455
- *    Parameters:      None (global SetupPacket)
456
- *    Return Value:    TRUE - Success, FALSE - Error
457
- */
458
-__inline uint32_t USB_ReqSetInterface(void) {
459
-  USB_COMMON_DESCRIPTOR *pD;
460
-  uint32_t ifn = 0, alt = 0, old = 0, msk = 0;
461
-  uint32_t n, m;
462
-  uint32_t set;
463
-  uint32_t tmp;
464
-
465
-  switch (SetupPacket.bmRequestType.BM.Recipient) {
466
-  case REQUEST_TO_INTERFACE:
467
-    if (USB_Configuration == 0)
468
-      return (FALSE);
469
-    set = FALSE;
470
-    pD = (USB_COMMON_DESCRIPTOR *) USB_ConfigDescriptor;
471
-    while (pD->bLength) {
472
-      switch (pD->bDescriptorType) {
473
-      case USB_CONFIGURATION_DESCRIPTOR_TYPE:
474
-        if (((USB_CONFIGURATION_DESCRIPTOR *) pD)->bConfigurationValue != USB_Configuration) {
475
-//              (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
476
-          tmp = (uint32_t) pD;
477
-          tmp += ((USB_CONFIGURATION_DESCRIPTOR *) pD)->wTotalLength;
478
-          pD = (USB_COMMON_DESCRIPTOR *) tmp;
479
-
480
-          continue;
481
-        }
482
-        break;
483
-      case USB_INTERFACE_DESCRIPTOR_TYPE:
484
-        ifn = ((USB_INTERFACE_DESCRIPTOR *) pD)->bInterfaceNumber;
485
-        alt = ((USB_INTERFACE_DESCRIPTOR *) pD)->bAlternateSetting;
486
-        msk = 0;
487
-        if ((ifn == SetupPacket.wIndex.WB.L) && (alt == SetupPacket.wValue.WB.L)) {
488
-          set = TRUE;
489
-          old = USB_AltSetting[ifn];
490
-          USB_AltSetting[ifn] = (uint8_t) alt;
491
-        }
492
-        break;
493
-      case USB_ENDPOINT_DESCRIPTOR_TYPE:
494
-        if (ifn == SetupPacket.wIndex.WB.L) {
495
-          n = ((USB_ENDPOINT_DESCRIPTOR *) pD)->bEndpointAddress & 0x8F;
496
-          m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
497
-          if (alt == SetupPacket.wValue.WB.L) {
498
-            USB_EndPointMask |= m;
499
-            USB_EndPointHalt &= ~m;
500
-            USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *) pD);
501
-            USB_EnableEP(n);
502
-            USB_ResetEP(n);
503
-            msk |= m;
504
-          } else if ((alt == old) && ((msk & m) == 0)) {
505
-            USB_EndPointMask &= ~m;
506
-            USB_EndPointHalt &= ~m;
507
-            USB_DisableEP(n);
508
-          }
509
-        }
510
-        break;
511
-      }
512
-//        (uint8_t *)pD += pD->bLength;
513
-      tmp = (uint32_t) pD;
514
-      tmp += pD->bLength;
515
-      pD = (USB_COMMON_DESCRIPTOR *) tmp;
516
-    }
517
-    break;
518
-  default:
519
-    return (FALSE);
520
-  }
521
-
522
-  return (set);
523
-}
524
-
525
-/*
526
- *  USB Endpoint 0 Event Callback
527
- *    Parameters:      event
528
- *    Return Value:    none
529
- */
530
-
531
-void USB_EndPoint0(uint32_t event) {
532
-
533
-  switch (event) {
534
-  case USB_EVT_SETUP:
535
-    USB_SetupStage();
536
-    USB_DirCtrlEP(SetupPacket.bmRequestType.BM.Dir);
537
-    EP0Data.Count = SetupPacket.wLength; /* Number of bytes to transfer */
538
-    switch (SetupPacket.bmRequestType.BM.Type) {
539
-
540
-    case REQUEST_STANDARD:
541
-      switch (SetupPacket.bRequest) {
542
-      case USB_REQUEST_GET_STATUS:
543
-        if (!USB_ReqGetStatus()) {
544
-          goto stall_i;
545
-        }
546
-        USB_DataInStage();
547
-        break;
548
-
549
-      case USB_REQUEST_CLEAR_FEATURE:
550
-        if (!USB_ReqSetClrFeature(0)) {
551
-          goto stall_i;
552
-        }
553
-        USB_StatusInStage();
554
-#if USB_FEATURE_EVENT
555
-        USB_Feature_Event();
556
-#endif
557
-        break;
558
-
559
-      case USB_REQUEST_SET_FEATURE:
560
-        if (!USB_ReqSetClrFeature(1)) {
561
-          goto stall_i;
562
-        }
563
-        USB_StatusInStage();
564
-#if USB_FEATURE_EVENT
565
-        USB_Feature_Event();
566
-#endif
567
-        break;
568
-
569
-      case USB_REQUEST_SET_ADDRESS:
570
-        if (!USB_ReqSetAddress()) {
571
-          goto stall_i;
572
-        }
573
-        USB_StatusInStage();
574
-        break;
575
-
576
-      case USB_REQUEST_GET_DESCRIPTOR:
577
-        if (!USB_ReqGetDescriptor()) {
578
-          goto stall_i;
579
-        }
580
-        USB_DataInStage();
581
-        break;
582
-
583
-      case USB_REQUEST_SET_DESCRIPTOR:
584
-        USB_SetStallEP(0x00);
585
-        EP0Data.Count = 0;
586
-        break;
587
-
588
-      case USB_REQUEST_GET_CONFIGURATION:
589
-        if (!USB_ReqGetConfiguration()) {
590
-          goto stall_i;
591
-        }
592
-        USB_DataInStage();
593
-        break;
594
-
595
-      case USB_REQUEST_SET_CONFIGURATION:
596
-        if (!USB_ReqSetConfiguration()) {
597
-          goto stall_i;
598
-        }
599
-        USB_StatusInStage();
600
-#if USB_CONFIGURE_EVENT
601
-        USB_Configure_Event();
602
-#endif
603
-        break;
604
-
605
-      case USB_REQUEST_GET_INTERFACE:
606
-        if (!USB_ReqGetInterface()) {
607
-          goto stall_i;
608
-        }
609
-        USB_DataInStage();
610
-        break;
611
-
612
-      case USB_REQUEST_SET_INTERFACE:
613
-        if (!USB_ReqSetInterface()) {
614
-          goto stall_i;
615
-        }
616
-        USB_StatusInStage();
617
-#if USB_INTERFACE_EVENT
618
-        USB_Interface_Event();
619
-#endif
620
-        break;
621
-
622
-      default:
623
-        goto stall_i;
624
-      }
625
-      break; /* end case REQUEST_STANDARD */
626
-
627
-    case REQUEST_CLASS:
628
-      switch (SetupPacket.bmRequestType.BM.Recipient) {
629
-
630
-      case REQUEST_TO_DEVICE:
631
-        goto stall_i;
632
-        /* not supported */
633
-
634
-      case REQUEST_TO_INTERFACE:
635
-        if (SetupPacket.wIndex.WB.L == USB_MSC_IF_NUM) { /* IF number correct? */
636
-          switch (SetupPacket.bRequest) {
637
-          case MSC_REQUEST_RESET:
638
-            if ((SetupPacket.wValue.W == 0) && /* RESET with invalid parameters -> STALL */
639
-            (SetupPacket.wLength == 0)) {
640
-              if (MSC_Reset()) {
641
-                USB_StatusInStage();
642
-                goto setup_class_ok;
643
-              }
644
-            }
645
-            break;
646
-          case MSC_REQUEST_GET_MAX_LUN:
647
-            if ((SetupPacket.wValue.W == 0) && /* GET_MAX_LUN with invalid parameters -> STALL */
648
-            (SetupPacket.wLength == 1)) {
649
-              if (MSC_GetMaxLUN()) {
650
-                EP0Data.pData = EP0Buf;
651
-                USB_DataInStage();
652
-                goto setup_class_ok;
653
-              }
654
-            }
655
-            break;
656
-          }
657
-        }
658
-        if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM) || /* IF number correct? */
659
-        (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
660
-          switch (SetupPacket.bRequest) {
661
-          case CDC_SEND_ENCAPSULATED_COMMAND:
662
-            EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */
663
-            goto setup_class_ok;
664
-          case CDC_GET_ENCAPSULATED_RESPONSE:
665
-            if (CDC_GetEncapsulatedResponse()) {
666
-              EP0Data.pData = EP0Buf; /* point to data to be sent */
667
-              USB_DataInStage(); /* send requested data */
668
-              goto setup_class_ok;
669
-            }
670
-            break;
671
-          case CDC_SET_COMM_FEATURE:
672
-            EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */
673
-            goto setup_class_ok;
674
-          case CDC_GET_COMM_FEATURE:
675
-            if (CDC_GetCommFeature(SetupPacket.wValue.W)) {
676
-              EP0Data.pData = EP0Buf; /* point to data to be sent */
677
-              USB_DataInStage(); /* send requested data */
678
-              goto setup_class_ok;
679
-            }
680
-            break;
681
-          case CDC_CLEAR_COMM_FEATURE:
682
-            if (CDC_ClearCommFeature(SetupPacket.wValue.W)) {
683
-              USB_StatusInStage(); /* send Acknowledge */
684
-              goto setup_class_ok;
685
-            }
686
-            break;
687
-          case CDC_SET_LINE_CODING:
688
-            EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */
689
-            goto setup_class_ok;
690
-          case CDC_GET_LINE_CODING:
691
-            if (CDC_GetLineCoding()) {
692
-              EP0Data.pData = EP0Buf; /* point to data to be sent */
693
-              USB_DataInStage(); /* send requested data */
694
-              goto setup_class_ok;
695
-            }
696
-            break;
697
-          case CDC_SET_CONTROL_LINE_STATE:
698
-            if (CDC_SetControlLineState(SetupPacket.wValue.W)) {
699
-              USB_StatusInStage(); /* send Acknowledge */
700
-              goto setup_class_ok;
701
-            }
702
-            break;
703
-          case CDC_SEND_BREAK:
704
-            if (CDC_SendBreak(SetupPacket.wValue.W)) {
705
-              USB_StatusInStage(); /* send Acknowledge */
706
-              goto setup_class_ok;
707
-            }
708
-            break;
709
-          }
710
-        }
711
-        goto stall_i;
712
-        /* not supported */
713
-        /* end case REQUEST_TO_INTERFACE */
714
-
715
-      case REQUEST_TO_ENDPOINT:
716
-        goto stall_i;
717
-        /* end case REQUEST_TO_ENDPOINT */
718
-
719
-      default:
720
-        goto stall_i;
721
-      }
722
-      setup_class_ok: /* request finished successfully */
723
-      break; /* end case REQUEST_CLASS */
724
-
725
-    default:
726
-      stall_i: USB_SetStallEP(0x80);
727
-      EP0Data.Count = 0;
728
-      break;
729
-    }
730
-    break; /* end case USB_EVT_SETUP */
731
-
732
-  case USB_EVT_OUT:
733
-    if (SetupPacket.bmRequestType.BM.Dir == REQUEST_HOST_TO_DEVICE) {
734
-      if (EP0Data.Count) { /* still data to receive ? */
735
-        USB_DataOutStage(); /* receive data */
736
-        if (EP0Data.Count == 0) { /* data complete ? */
737
-          switch (SetupPacket.bmRequestType.BM.Type) {
738
-
739
-          case REQUEST_STANDARD:
740
-            goto stall_i;
741
-            /* not supported */
742
-
743
-          case REQUEST_CLASS:
744
-            switch (SetupPacket.bmRequestType.BM.Recipient) {
745
-            case REQUEST_TO_DEVICE:
746
-              goto stall_i;
747
-              /* not supported */
748
-
749
-            case REQUEST_TO_INTERFACE:
750
-              if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM) || /* IF number correct? */
751
-              (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
752
-                switch (SetupPacket.bRequest) {
753
-                case CDC_SEND_ENCAPSULATED_COMMAND:
754
-                  if (CDC_SendEncapsulatedCommand()) {
755
-                    USB_StatusInStage(); /* send Acknowledge */
756
-                    goto out_class_ok;
757
-                  }
758
-                  break;
759
-                case CDC_SET_COMM_FEATURE:
760
-                  if (CDC_SetCommFeature(SetupPacket.wValue.W)) {
761
-                    USB_StatusInStage(); /* send Acknowledge */
762
-                    goto out_class_ok;
763
-                  }
764
-                  break;
765
-                case CDC_SET_LINE_CODING:
766
-                  if (CDC_SetLineCoding()) {
767
-                    USB_StatusInStage(); /* send Acknowledge */
768
-                    goto out_class_ok;
769
-                  }
770
-                  break;
771
-                }
772
-              }
773
-              goto stall_i;
774
-              /* end case REQUEST_TO_INTERFACE */
775
-
776
-            case REQUEST_TO_ENDPOINT:
777
-              goto stall_i;
778
-              /* end case REQUEST_TO_ENDPOINT */
779
-
780
-            default:
781
-              goto stall_i;
782
-            }
783
-            out_class_ok: /* request finished successfully */
784
-            break; /* end case REQUEST_CLASS */
785
-          default:
786
-            goto stall_i;
787
-          }
788
-        }
789
-      }
790
-    } else {
791
-      USB_StatusOutStage(); /* receive Acknowledge */
792
-    }
793
-    break; /* end case USB_EVT_OUT */
794
-
795
-  case USB_EVT_IN:
796
-    if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) {
797
-      USB_DataInStage(); /* send data */
798
-    } else {
799
-      if (USB_DeviceAddress & 0x80) {
800
-        USB_DeviceAddress &= 0x7F;
801
-        USB_SetAddress(USB_DeviceAddress);
802
-      }
803
-    }
804
-    break; /* end case USB_EVT_IN */
805
-
806
-  case USB_EVT_OUT_STALL:
807
-    USB_ClrStallEP(0x00);
808
-    break;
809
-
810
-  case USB_EVT_IN_STALL:
811
-    USB_ClrStallEP(0x80);
812
-    break;
813
-
814
-  }
815
-}

+ 0
- 52
Marlin/src/HAL/HAL_LPC1768/usb/usbcore.h 查看文件

@@ -1,52 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbcore.h
5
- * Purpose: USB Core Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
14
- *      gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __USBCORE_H__
20
-#define __USBCORE_H__
21
-
22
-
23
-/* USB Endpoint Data Structure */
24
-typedef struct _USB_EP_DATA {
25
-  uint8_t  *pData;
26
-  uint16_t Count;
27
-} USB_EP_DATA;
28
-
29
-/* USB Core Global Variables */
30
-extern uint16_t USB_DeviceStatus;
31
-extern uint8_t  USB_DeviceAddress;
32
-extern uint8_t  USB_Configuration;
33
-extern uint32_t USB_EndPointMask;
34
-extern uint32_t USB_EndPointHalt;
35
-extern uint32_t USB_EndPointStall;
36
-extern uint8_t  USB_AltSetting[USB_IF_NUM];
37
-
38
-/* USB Endpoint 0 Buffer */
39
-extern uint8_t  EP0Buf[USB_MAX_PACKET0];
40
-
41
-/* USB Endpoint 0 Data Info */
42
-extern USB_EP_DATA EP0Data;
43
-
44
-/* USB Setup Packet */
45
-extern USB_SETUP_PACKET SetupPacket;
46
-
47
-/* USB Core Functions */
48
-extern void USB_ResetCore (void);
49
-
50
-
51
-
52
-#endif  /* __USBCORE_H__ */

+ 0
- 257
Marlin/src/HAL/HAL_LPC1768/usb/usbdesc.cpp 查看文件

@@ -1,257 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbdesc.c
5
- * Purpose: USB Descriptors
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
14
- *      gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *----------------------------------------------------------------------------
18
- * History:
19
- *          V1.20 Changed string descriptor handling
20
- *          V1.00 Initial Version
21
- *---------------------------------------------------------------------------*/
22
-extern "C" {
23
-#include "lpc_types.h"
24
-}
25
-
26
-#include "usb.h"
27
-#include "cdc.h"
28
-#include "msc.h"
29
-#include "usbcfg.h"
30
-#include "usbdesc.h"
31
-
32
-
33
-/* USB Standard Device Descriptor */
34
-const uint8_t USB_DeviceDescriptor[] = {
35
-  USB_DEVICE_DESC_SIZE,              /* bLength */
36
-  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
37
-  WBVAL(0x0200), /* 2.0 */           /* bcdUSB */
38
-  USB_DEVICE_CLASS_MISCELLANEOUS,    /* bDeviceClass Composite*/
39
-  0x02,                              /* bDeviceSubClass */
40
-  0x01,                              /* bDeviceProtocol */
41
-  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
42
-  WBVAL(0x1d50),                     /* idVendor */
43
-  WBVAL(0x6029),                     /* idProduct */
44
-  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
45
-  0x01,                              /* iManufacturer */
46
-  0x02,                              /* iProduct */
47
-  0x03,                              /* iSerialNumber */
48
-  0x01                               /* bNumConfigurations: one possible configuration*/
49
-};
50
-
51
-/* USB Configuration Descriptor */
52
-/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
53
-const uint8_t USB_ConfigDescriptor[] = {
54
-/* Configuration 1 */
55
-  USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
56
-  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
57
-  WBVAL(                             /* wTotalLength */
58
-    1*USB_CONFIGUARTION_DESC_SIZE +
59
-    // Interface Association Descriptor
60
-    8 +
61
-    //CDC Control Interface
62
-    1*USB_INTERFACE_DESC_SIZE     +  /* communication interface */
63
-    0x0013                        +  /* CDC functions */
64
-    1*USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */
65
-    //CDC Data Interface
66
-    1*USB_INTERFACE_DESC_SIZE     +  /* data interface */
67
-    2*USB_ENDPOINT_DESC_SIZE      +  /* bulk endpoints */
68
-    //MSC Interface
69
-    1*USB_INTERFACE_DESC_SIZE     +
70
-    2*USB_ENDPOINT_DESC_SIZE
71
-    ),
72
-  0x03,                              /* bNumInterfaces */
73
-  0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */
74
-  0x00,                              /* iConfiguration: no string to describe this configuration */
75
-  USB_CONFIG_BUS_POWERED,            /* bmAttributes */
76
-  USB_CONFIG_POWER_MA(500),          /* bMaxPower, device power consumption is 500 mA */
77
-
78
-
79
-/* Interface Association Descriptor */
80
-  0x08,
81
-  0x0B, //DescriptorType : Interface Association
82
-  0x00, //FirstInterface
83
-  0x02, //InterfaceCount
84
-  0x02, //FunctionClass
85
-  0x02, //FunctionSubClass
86
-  0x01, //FunctionProtocol
87
-  0x00, //Function
88
-
89
-/* Interface 0, Alternate Setting 0, Communication class interface descriptor */
90
-  USB_INTERFACE_DESC_SIZE,           /* bLength */
91
-  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
92
-  USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */
93
-  0x00,                              /* bAlternateSetting: Alternate setting */
94
-  0x01,                              /* bNumEndpoints: One endpoint used */
95
-  CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
96
-  CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */
97
-  0x00,                              /* bInterfaceProtocol: no protocol used */
98
-  0x00,                              /* iInterface: */
99
-
100
-/*Header Functional Descriptor*/
101
-  0x05,                              /* bLength: Endpoint Descriptor size */
102
-  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
103
-  CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */
104
-  WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */
105
-
106
-/*Call Management Functional Descriptor*/
107
-  0x05,                              /* bFunctionLength */
108
-  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
109
-  CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */
110
-  CDC_CALLMGMT_CAP_CALLMGMT | CDC_CALLMGMT_CAP_DATAINTF,  /* bmCapabilities: device handles call management */
111
-  0x01,                              /* bDataInterface: CDC data IF ID */
112
-
113
-/*Abstract Control Management Functional Descriptor*/
114
-  0x04,                              /* bFunctionLength */
115
-  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
116
-  CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */
117
-  CDC_ACM_CAP_LINE | CDC_ACM_CAP_BRK,/* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
118
-
119
-/*Union Functional Descriptor*/
120
-  0x05,                              /* bFunctionLength */
121
-  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
122
-  CDC_UNION,                         /* bDescriptorSubtype: Union func desc */
123
-  USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */
124
-  USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */
125
-
126
-/*Endpoint 1 Descriptor*/            /* event notification (optional) */
127
-  USB_ENDPOINT_DESC_SIZE,            /* bLength */
128
-  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
129
-  USB_ENDPOINT_IN(1),                /* bEndpointAddress */
130
-  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
131
-  WBVAL(0x0010),                     /* wMaxPacketSize */
132
-  0x10,                              /* bInterval */
133
-
134
-
135
-/* Interface 1, Alternate Setting 0, Data class interface descriptor*/
136
-  USB_INTERFACE_DESC_SIZE,           /* bLength */
137
-  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
138
-  USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */
139
-  0x00,                              /* bAlternateSetting: no alternate setting */
140
-  0x02,                              /* bNumEndpoints: two endpoints used */
141
-  CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */
142
-  0x00,                              /* bInterfaceSubClass: no subclass available */
143
-  0x00,                              /* bInterfaceProtocol: no protocol used */
144
-  0x00,                              /* iInterface: */
145
-/* Endpoint, EP2 Bulk Out */
146
-  USB_ENDPOINT_DESC_SIZE,            /* bLength */
147
-  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
148
-  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
149
-  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
150
-  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
151
-  0x00,                              /* bInterval: ignore for Bulk transfer */
152
-/* Endpoint, EP2 Bulk In */
153
-  USB_ENDPOINT_DESC_SIZE,            /* bLength */
154
-  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
155
-  USB_ENDPOINT_IN(2),                /* bEndpointAddress */
156
-  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
157
-  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
158
-  0x00,                              /* bInterval: ignore for Bulk transfer */
159
-
160
-
161
-  /* MSC Interface */
162
-  /* Interface 2, Alternate Setting 0, Data class interface descriptor*/
163
-  USB_INTERFACE_DESC_SIZE,           /* bLength */
164
-  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
165
-  0x02,                              /* bInterfaceNumber */
166
-  0x00,                              /* bAlternateSetting */
167
-  0x02,                              /* bNumEndpoints */
168
-  USB_DEVICE_CLASS_STORAGE,          /* bInterfaceClass */
169
-  MSC_SUBCLASS_SCSI,                 /* bInterfaceSubClass */
170
-  MSC_PROTOCOL_BULK_ONLY,            /* bInterfaceProtocol */
171
-  0x00,                              /* iInterface */
172
-  /* Bulk In Endpoint */
173
-  USB_ENDPOINT_DESC_SIZE,            /* bLength */
174
-  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
175
-  USB_ENDPOINT_IN(5),                /* bEndpointAddress */
176
-  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
177
-  WBVAL(0x0040),                     /* wMaxPacketSize */
178
-  0x00,                                 /* bInterval */
179
-  /* Bulk Out Endpoint */
180
-  USB_ENDPOINT_DESC_SIZE,            /* bLength */
181
-  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
182
-  USB_ENDPOINT_OUT(5),               /* bEndpointAddress */
183
-  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
184
-  WBVAL(0x0040),                     /* wMaxPacketSize */
185
-  0,
186
-  /* Terminator */
187
-  0                                  /* bLength */
188
-};
189
-
190
-
191
-
192
-
193
-/* USB String Descriptor (optional) */
194
-const uint8_t USB_StringDescriptor[] = {
195
-/* Index 0x00: LANGID Codes */
196
-  0x04,                              /* bLength */
197
-  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
198
-  WBVAL(0x0409), /* US English */    /* wLANGID */
199
-/* Index 0x01: Manufacturer */
200
-  (13*2 + 2),                        /* bLength (13 Char + Type + length) */
201
-  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
202
-  'm',0,
203
-  'a',0,
204
-  'r',0,
205
-  'l',0,
206
-  'i',0,
207
-  'n',0,
208
-  'f',0,
209
-  'w',0,
210
-  '.',0,
211
-  'o',0,
212
-  'r',0,
213
-  'g',0,
214
-  ' ',0,
215
-/* Index 0x02: Product */
216
-  (17*2 + 2),                        /* bLength ( 17 Char + Type + length) */
217
-  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
218
-  'M',0,
219
-  'a',0,
220
-  'r',0,
221
-  'l',0,
222
-  'i',0,
223
-  'n',0,
224
-  ' ',0,
225
-  'U',0,
226
-  'S',0,
227
-  'B',0,
228
-  ' ',0,
229
-  'D',0,
230
-  'e',0,
231
-  'v',0,
232
-  'i',0,
233
-  'c',0,
234
-  'e',0,
235
-/* Index 0x03: Serial Number */
236
-  (12*2 + 2),                        /* bLength (12 Char + Type + length) */
237
-  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
238
-  '1',0,
239
-  '.',0,
240
-  '0',0,
241
-  '0',0,
242
-  '0',0,
243
-  '0',0,
244
-  '0',0,
245
-  '0',0,
246
-  '0',0,
247
-  '0',0,
248
-  '0',0,
249
-  '0',0,
250
-/* Index 0x04: Interface 0, Alternate Setting 0 */
251
-  ( 4*2 + 2),                        /* bLength (4 Char + Type + length) */
252
-  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
253
-  'V',0,
254
-  'C',0,
255
-  'O',0,
256
-  'M',0,
257
-};

+ 0
- 35
Marlin/src/HAL/HAL_LPC1768/usb/usbdesc.h 查看文件

@@ -1,35 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbdesc.h
5
- * Purpose: USB Descriptors Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
14
- *      gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __USBDESC_H__
20
-#define __USBDESC_H__
21
-
22
-
23
-#define WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
24
-
25
-#define USB_DEVICE_DESC_SIZE        (sizeof(USB_DEVICE_DESCRIPTOR))
26
-#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
27
-#define USB_INTERFACE_DESC_SIZE     (sizeof(USB_INTERFACE_DESCRIPTOR))
28
-#define USB_ENDPOINT_DESC_SIZE      (sizeof(USB_ENDPOINT_DESCRIPTOR))
29
-
30
-extern const uint8_t USB_DeviceDescriptor[];
31
-extern const uint8_t USB_ConfigDescriptor[];
32
-extern const uint8_t USB_StringDescriptor[];
33
-
34
-
35
-#endif  /* __USBDESC_H__ */

+ 0
- 811
Marlin/src/HAL/HAL_LPC1768/usb/usbhw.cpp 查看文件

@@ -1,811 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbhw.c
5
- * Purpose: USB Hardware Layer Module for NXP's LPC17xx MCU
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *----------------------------------------------------------------------------
18
- * History:
19
- *          V1.20 Added USB_ClearEPBuf
20
- *          V1.00 Initial Version
21
- *----------------------------------------------------------------------------*/
22
-extern "C" {
23
-#include "LPC17xx.h"                        /* LPC17xx definitions */
24
-}
25
-
26
-#include "usb.h"
27
-#include "usbcfg.h"
28
-#include "usbreg.h"
29
-#include "usbhw.h"
30
-#include "usbcore.h"
31
-#include "usbuser.h"
32
-
33
-#define EP_MSK_CTRL 0x0001      /* Control Endpoint Logical Address Mask */
34
-#define EP_MSK_BULK 0xC924      /* Bulk Endpoint Logical Address Mask */
35
-#define EP_MSK_INT  0x4492      /* Interrupt Endpoint Logical Address Mask */
36
-#define EP_MSK_ISO  0x1248      /* Isochronous Endpoint Logical Address Mask */
37
-
38
-#if USB_DMA
39
-uint32_t UDCA[USB_EP_NUM] __attribute__((section("USB_RAM")));        /* UDCA in USB RAM */
40
-uint32_t DD_NISO_Mem[4*DD_NISO_CNT] __attribute__((section("USB_RAM")));    /* Non-Iso DMA Descriptor Memory */
41
-uint32_t DD_ISO_Mem [5*DD_ISO_CNT] __attribute__((section("USB_RAM")));     /* Iso DMA Descriptor Memory */
42
-uint32_t udca[USB_EP_NUM];                                    /* UDCA saved values */
43
-uint32_t DDMemMap[2];
44
-#endif
45
-
46
-
47
-/*
48
- *  Get Endpoint Physical Address
49
- *    Parameters:      EPNum: Endpoint Number
50
- *                       EPNum.0..3: Address
51
- *                       EPNum.7:    Dir
52
- *    Return Value:    Endpoint Physical Address
53
- */
54
-
55
-uint32_t EPAdr (uint32_t EPNum) {
56
-  uint32_t val;
57
-
58
-  val = (EPNum & 0x0F) << 1;
59
-  if (EPNum & 0x80) {
60
-    val += 1;
61
-  }
62
-  return (val);
63
-}
64
-
65
-
66
-/*
67
- *  Write Command
68
- *    Parameters:      cmd:   Command
69
- *    Return Value:    None
70
- */
71
-
72
-void WrCmd (uint32_t cmd) {
73
-
74
-  LPC_USB->USBDevIntClr = CCEMTY_INT;
75
-  LPC_USB->USBCmdCode = cmd;
76
-  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
77
-}
78
-
79
-
80
-/*
81
- *  Write Command Data
82
- *    Parameters:      cmd:   Command
83
- *                     val:   Data
84
- *    Return Value:    None
85
- */
86
-
87
-void WrCmdDat (uint32_t cmd, uint32_t val) {
88
-
89
-  LPC_USB->USBDevIntClr = CCEMTY_INT;
90
-  LPC_USB->USBCmdCode = cmd;
91
-  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
92
-  LPC_USB->USBDevIntClr = CCEMTY_INT;
93
-  LPC_USB->USBCmdCode = val;
94
-  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
95
-}
96
-
97
-
98
-/*
99
- *  Write Command to Endpoint
100
- *    Parameters:      cmd:   Command
101
- *                     val:   Data
102
- *    Return Value:    None
103
- */
104
-
105
-void WrCmdEP (uint32_t EPNum, uint32_t cmd){
106
-
107
-  LPC_USB->USBDevIntClr = CCEMTY_INT;
108
-  LPC_USB->USBCmdCode = CMD_SEL_EP(EPAdr(EPNum));
109
-  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
110
-  LPC_USB->USBDevIntClr = CCEMTY_INT;
111
-  LPC_USB->USBCmdCode = cmd;
112
-  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
113
-}
114
-
115
-
116
-/*
117
- *  Read Command Data
118
- *    Parameters:      cmd:   Command
119
- *    Return Value:    Data Value
120
- */
121
-
122
-uint32_t RdCmdDat (uint32_t cmd) {
123
-
124
-  LPC_USB->USBDevIntClr = CCEMTY_INT | CDFULL_INT;
125
-  LPC_USB->USBCmdCode = cmd;
126
-  while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
127
-  return (LPC_USB->USBCmdData);
128
-}
129
-
130
-
131
-/*
132
- *  USB Initialize Function
133
- *   Called by the User to initialize USB
134
- *    Return Value:    None
135
- */
136
-
137
-void USB_Init (void) {
138
-
139
-  LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28));   /* P0.29 D+, P0.30 D- */
140
-  LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));   /* PINSEL1 26.27, 28.29  = 01 */
141
-
142
-  //todo: VBUS not used by smoothieboard (though spec requires it for self powered devices), pin used for beeper
143
-  //todo: Goodlink used for servo4?
144
-  //LPC_PINCON->PINSEL3 &= ~((3<< 4)|(3<<28));   /* P1.18 GoodLink, P1.30 VBUS */
145
-  //LPC_PINCON->PINSEL3 |=  ((1<< 4)|(2<<28));   /* PINSEL3 4.5 = 01, 28.29 = 10 */
146
-
147
-  LPC_PINCON->PINSEL4 &= ~((3<<18)        );   /* P2.9 SoftConnect */
148
-  LPC_PINCON->PINSEL4 |=  ((1<<18)        );   /* PINSEL4 18.19 = 01 */
149
-
150
-  LPC_SC->PCONP |= (1UL<<31);                /* USB PCLK -> enable USB Per.       */
151
-
152
-  LPC_USB->USBClkCtrl = 0x1A;                /* Dev, PortSel, AHB clock enable */
153
-  while ((LPC_USB->USBClkSt & 0x1A) != 0x1A);
154
-
155
-  NVIC_EnableIRQ(USB_IRQn);               /* enable USB interrupt */
156
-
157
-  USB_Reset();
158
-  USB_SetAddress(0);
159
-}
160
-
161
-
162
-/*
163
- *  USB Connect Function
164
- *   Called by the User to Connect/Disconnect USB
165
- *    Parameters:      con:   Connect/Disconnect
166
- *    Return Value:    None
167
- */
168
-
169
-void USB_Connect (uint32_t con) {
170
-  WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
171
-}
172
-
173
-
174
-/*
175
- *  USB Reset Function
176
- *   Called automatically on USB Reset
177
- *    Return Value:    None
178
- */
179
-
180
-void USB_Reset (void) {
181
-#if USB_DMA
182
-  uint32_t n;
183
-#endif
184
-
185
-  LPC_USB->USBEpInd = 0;
186
-  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
187
-  LPC_USB->USBEpInd = 1;
188
-  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
189
-  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
190
-
191
-  LPC_USB->USBEpIntClr  = 0xFFFFFFFF;
192
-  LPC_USB->USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
193
-  LPC_USB->USBDevIntClr = 0xFFFFFFFF;
194
-  LPC_USB->USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
195
-               (USB_SOF_EVENT   ? FRAME_INT : 0) |
196
-               (USB_ERROR_EVENT ? ERR_INT   : 0);
197
-
198
-  WrCmdDat(CMD_SET_MODE, DAT_WR_BYTE(INAK_BI));
199
-
200
-
201
-#if USB_DMA
202
-  LPC_USB->USBUDCAH   = USB_RAM_ADR;
203
-  LPC_USB->USBDMARClr = 0xFFFFFFFF;
204
-  LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
205
-  LPC_USB->USBEpDMAEn   = USB_DMA_EP;
206
-  LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
207
-  LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
208
-  LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
209
-  LPC_USB->USBDMAIntEn  = 0x00000007;
210
-  DDMemMap[0] = 0x00000000;
211
-  DDMemMap[1] = 0x00000000;
212
-  for (n = 0; n < USB_EP_NUM; n++) {
213
-    udca[n] = 0;
214
-    UDCA[n] = 0;
215
-  }
216
-#endif
217
-}
218
-
219
-
220
-/*
221
- *  USB Suspend Function
222
- *   Called automatically on USB Suspend
223
- *    Return Value:    None
224
- */
225
-
226
-void USB_Suspend (void) {
227
-  /* Performed by Hardware */
228
-}
229
-
230
-
231
-/*
232
- *  USB Resume Function
233
- *   Called automatically on USB Resume
234
- *    Return Value:    None
235
- */
236
-
237
-void USB_Resume (void) {
238
-  /* Performed by Hardware */
239
-}
240
-
241
-
242
-/*
243
- *  USB Remote Wakeup Function
244
- *   Called automatically on USB Remote Wakeup
245
- *    Return Value:    None
246
- */
247
-
248
-void USB_WakeUp (void) {
249
-
250
-  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
251
-    WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
252
-  }
253
-}
254
-
255
-
256
-/*
257
- *  USB Remote Wakeup Configuration Function
258
- *    Parameters:      cfg:   Enable/Disable
259
- *    Return Value:    None
260
- */
261
-
262
-void USB_WakeUpCfg (uint32_t cfg) {
263
-  /* Not needed */
264
-}
265
-
266
-
267
-/*
268
- *  USB Set Address Function
269
- *    Parameters:      adr:   USB Address
270
- *    Return Value:    None
271
- */
272
-
273
-void USB_SetAddress (uint32_t adr) {
274
-  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
275
-  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
276
-}
277
-
278
-
279
-/*
280
- *  USB Configure Function
281
- *    Parameters:      cfg:   Configure/Deconfigure
282
- *    Return Value:    None
283
- */
284
-
285
-void USB_Configure (uint32_t cfg) {
286
-
287
-  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
288
-
289
-  LPC_USB->USBReEp = 0x00000003;
290
-  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
291
-  LPC_USB->USBDevIntClr = EP_RLZED_INT;
292
-}
293
-
294
-
295
-/*
296
- *  Configure USB Endpoint according to Descriptor
297
- *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
298
- *    Return Value:    None
299
- */
300
-
301
-void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
302
-  uint32_t num;
303
-
304
-  num = EPAdr(pEPD->bEndpointAddress);
305
-  LPC_USB->USBReEp |= (1 << num);
306
-  LPC_USB->USBEpInd = num;
307
-  LPC_USB->USBMaxPSize = pEPD->wMaxPacketSize;
308
-  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
309
-  LPC_USB->USBDevIntClr = EP_RLZED_INT;
310
-}
311
-
312
-
313
-/*
314
- *  Set Direction for USB Control Endpoint
315
- *    Parameters:      dir:   Out (dir == 0), In (dir <> 0)
316
- *    Return Value:    None
317
- */
318
-
319
-void USB_DirCtrlEP (uint32_t dir) {
320
-  /* Not needed */
321
-}
322
-
323
-
324
-/*
325
- *  Enable USB Endpoint
326
- *    Parameters:      EPNum: Endpoint Number
327
- *                       EPNum.0..3: Address
328
- *                       EPNum.7:    Dir
329
- *    Return Value:    None
330
- */
331
-
332
-void USB_EnableEP (uint32_t EPNum) {
333
-  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
334
-}
335
-
336
-
337
-/*
338
- *  Disable USB Endpoint
339
- *    Parameters:      EPNum: Endpoint Number
340
- *                       EPNum.0..3: Address
341
- *                       EPNum.7:    Dir
342
- *    Return Value:    None
343
- */
344
-
345
-void USB_DisableEP (uint32_t EPNum) {
346
-  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
347
-}
348
-
349
-
350
-/*
351
- *  Reset USB Endpoint
352
- *    Parameters:      EPNum: Endpoint Number
353
- *                       EPNum.0..3: Address
354
- *                       EPNum.7:    Dir
355
- *    Return Value:    None
356
- */
357
-
358
-void USB_ResetEP (uint32_t EPNum) {
359
-  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
360
-}
361
-
362
-
363
-/*
364
- *  Set Stall for USB Endpoint
365
- *    Parameters:      EPNum: Endpoint Number
366
- *                       EPNum.0..3: Address
367
- *                       EPNum.7:    Dir
368
- *    Return Value:    None
369
- */
370
-
371
-void USB_SetStallEP (uint32_t EPNum) {
372
-  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
373
-}
374
-
375
-
376
-/*
377
- *  Clear Stall for USB Endpoint
378
- *    Parameters:      EPNum: Endpoint Number
379
- *                       EPNum.0..3: Address
380
- *                       EPNum.7:    Dir
381
- *    Return Value:    None
382
- */
383
-
384
-void USB_ClrStallEP (uint32_t EPNum) {
385
-  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
386
-}
387
-
388
-
389
-/*
390
- *  Clear USB Endpoint Buffer
391
- *    Parameters:      EPNum: Endpoint Number
392
- *                       EPNum.0..3: Address
393
- *                       EPNum.7:    Dir
394
- *    Return Value:    None
395
- */
396
-
397
-void USB_ClearEPBuf (uint32_t EPNum) {
398
-  WrCmdEP(EPNum, CMD_CLR_BUF);
399
-}
400
-
401
-
402
-/*
403
- *  Read USB Endpoint Data
404
- *    Parameters:      EPNum: Endpoint Number
405
- *                       EPNum.0..3: Address
406
- *                       EPNum.7:    Dir
407
- *                     pData: Pointer to Data Buffer
408
- *    Return Value:    Number of bytes read
409
- */
410
-
411
-uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
412
-  uint32_t cnt, n;
413
-
414
-  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
415
-
416
-  do {
417
-    cnt = LPC_USB->USBRxPLen;
418
-  } while ((cnt & PKT_RDY) == 0);
419
-  cnt &= PKT_LNGTH_MASK;
420
-
421
-  for (n = 0; n < (cnt + 3) / 4; n++) {
422
-    *((__packed uint32_t *)pData) = LPC_USB->USBRxData;
423
-    pData += 4;
424
-  }
425
-  LPC_USB->USBCtrl = 0;
426
-
427
-  if (((EP_MSK_ISO >> EPNum) & 1) == 0) {   /* Non-Isochronous Endpoint */
428
-    WrCmdEP(EPNum, CMD_CLR_BUF);
429
-  }
430
-
431
-  return (cnt);
432
-}
433
-
434
-
435
-/*
436
- *  Write USB Endpoint Data
437
- *    Parameters:      EPNum: Endpoint Number
438
- *                       EPNum.0..3: Address
439
- *                       EPNum.7:    Dir
440
- *                     pData: Pointer to Data Buffer
441
- *                     cnt:   Number of bytes to write
442
- *    Return Value:    Number of bytes written
443
- */
444
-
445
-uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
446
-  uint32_t n;
447
-
448
-  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
449
-
450
-  LPC_USB->USBTxPLen = cnt;
451
-
452
-  for (n = 0; n < (cnt + 3) / 4; n++) {
453
-    LPC_USB->USBTxData = *((__packed uint32_t *)pData);
454
-    pData += 4;
455
-  }
456
-  LPC_USB->USBCtrl = 0;
457
-  WrCmdEP(EPNum, CMD_VALID_BUF);
458
-  return (cnt);
459
-}
460
-
461
-#if USB_DMA
462
-
463
-/* DMA Descriptor Memory Layout */
464
-const uint32_t DDAdr[2] = { DD_NISO_ADR, DD_ISO_ADR };
465
-const uint32_t DDSz [2] = { 16,          20         };
466
-
467
-
468
-/*
469
- *  Setup USB DMA Transfer for selected Endpoint
470
- *    Parameters:      EPNum: Endpoint Number
471
- *                     pDD: Pointer to DMA Descriptor
472
- *    Return Value:    TRUE - Success, FALSE - Error
473
- */
474
-
475
-uint32_t USB_DMA_Setup(uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD) {
476
-  uint32_t num, ptr, nxt, iso, n;
477
-
478
-  iso = pDD->Cfg.Type.IsoEP;                /* Iso or Non-Iso Descriptor */
479
-  num = EPAdr(EPNum);                       /* Endpoint's Physical Address */
480
-
481
-  ptr = 0;                                  /* Current Descriptor */
482
-  nxt = udca[num];                          /* Initial Descriptor */
483
-  while (nxt) {                             /* Go through Descriptor List */
484
-    ptr = nxt;                              /* Current Descriptor */
485
-    if (!pDD->Cfg.Type.Link) {              /* Check for Linked Descriptors */
486
-      n = (ptr - DDAdr[iso]) / DDSz[iso];   /* Descriptor Index */
487
-      DDMemMap[iso] &= ~(1 << n);           /* Unmark Memory Usage */
488
-    }
489
-    nxt = *((uint32_t *)ptr);                  /* Next Descriptor */
490
-  }
491
-
492
-  for (n = 0; n < 32; n++) {                /* Search for available Memory */
493
-    if ((DDMemMap[iso] & (1 << n)) == 0) {
494
-      break;                                /* Memory found */
495
-    }
496
-  }
497
-  if (n == 32) return (FALSE);              /* Memory not available */
498
-
499
-  DDMemMap[iso] |= 1 << n;                  /* Mark Memory Usage */
500
-  nxt = DDAdr[iso] + n * DDSz[iso];         /* Next Descriptor */
501
-
502
-  if (ptr && pDD->Cfg.Type.Link) {
503
-    *((uint32_t *)(ptr + 0))  = nxt;           /* Link in new Descriptor */
504
-    *((uint32_t *)(ptr + 4)) |= 0x00000004;    /* Next DD is Valid */
505
-  } else {
506
-    udca[num] = nxt;                        /* Save new Descriptor */
507
-    UDCA[num] = nxt;                        /* Update UDCA in USB */
508
-  }
509
-
510
-  uint32_t * nxt_ptr = (uint32_t *)nxt;
511
-  /* Fill in DMA Descriptor */
512
-  *nxt_ptr++ =  0;   /* Next DD Pointer */
513
-  *nxt_ptr++ = (pDD->Cfg.Type.ATLE) |
514
-               (pDD->Cfg.Type.IsoEP << 4) |
515
-               (pDD->MaxSize <<  5) |
516
-               (pDD->BufLen  << 16);
517
-  *nxt_ptr++ =  pDD->BufAdr;
518
-  *nxt_ptr++ =  pDD->Cfg.Type.LenPos << 8;
519
-  if (iso) {
520
-    *nxt_ptr =  pDD->InfoAdr;
521
-  }
522
-
523
-  return (TRUE); /* Success */
524
-}
525
-
526
-
527
-/*
528
- *  Enable USB DMA Endpoint
529
- *    Parameters:      EPNum: Endpoint Number
530
- *                       EPNum.0..3: Address
531
- *                       EPNum.7:    Dir
532
- *    Return Value:    None
533
- */
534
-
535
-void USB_DMA_Enable (uint32_t EPNum) {
536
-  LPC_USB->USBEpDMAEn = 1 << EPAdr(EPNum);
537
-}
538
-
539
-
540
-/*
541
- *  Disable USB DMA Endpoint
542
- *    Parameters:      EPNum: Endpoint Number
543
- *                       EPNum.0..3: Address
544
- *                       EPNum.7:    Dir
545
- *    Return Value:    None
546
- */
547
-
548
-void USB_DMA_Disable (uint32_t EPNum) {
549
-  LPC_USB->USBEpDMADis = 1 << EPAdr(EPNum);
550
-}
551
-
552
-
553
-/*
554
- *  Get USB DMA Endpoint Status
555
- *    Parameters:      EPNum: Endpoint Number
556
- *                       EPNum.0..3: Address
557
- *                       EPNum.7:    Dir
558
- *    Return Value:    DMA Status
559
- */
560
-
561
-uint32_t USB_DMA_Status (uint32_t EPNum) {
562
-  uint32_t ptr, val;
563
-
564
-  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
565
-  if (ptr == 0)
566
-	return (USB_DMA_INVALID);
567
-
568
-  val = *((uint32_t *)(ptr + 3*4));            /* Status Information */
569
-  switch ((val >> 1) & 0x0F) {
570
-    case 0x00:                              /* Not serviced */
571
-      return (USB_DMA_IDLE);
572
-    case 0x01:                              /* Being serviced */
573
-      return (USB_DMA_BUSY);
574
-    case 0x02:                              /* Normal Completition */
575
-      return (USB_DMA_DONE);
576
-    case 0x03:                              /* Data Under Run */
577
-      return (USB_DMA_UNDER_RUN);
578
-    case 0x08:                              /* Data Over Run */
579
-      return (USB_DMA_OVER_RUN);
580
-    case 0x09:                              /* System Error */
581
-      return (USB_DMA_ERROR);
582
-  }
583
-
584
-  return (USB_DMA_UNKNOWN);
585
-}
586
-
587
-
588
-/*
589
- *  Get USB DMA Endpoint Current Buffer Address
590
- *    Parameters:      EPNum: Endpoint Number
591
- *                       EPNum.0..3: Address
592
- *                       EPNum.7:    Dir
593
- *    Return Value:    DMA Address (or -1 when DMA is Invalid)
594
- */
595
-
596
-uint32_t USB_DMA_BufAdr (uint32_t EPNum) {
597
-  uint32_t ptr, val;
598
-
599
-  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
600
-  if (ptr == 0)
601
-  {
602
-	return ((uint32_t)(-1));                /* DMA Invalid */
603
-  }
604
-
605
-  val = *((uint32_t *)(ptr + 2*4));         /* Buffer Address */
606
-  return (val);                             /* Current Address */
607
-}
608
-
609
-
610
-/*
611
- *  Get USB DMA Endpoint Current Buffer Count
612
- *   Number of transfered Bytes or Iso Packets
613
- *    Parameters:      EPNum: Endpoint Number
614
- *                       EPNum.0..3: Address
615
- *                       EPNum.7:    Dir
616
- *    Return Value:    DMA Count (or -1 when DMA is Invalid)
617
- */
618
-
619
-uint32_t USB_DMA_BufCnt (uint32_t EPNum) {
620
-  uint32_t ptr, val;
621
-
622
-  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
623
-  if (ptr == 0)
624
-  {
625
-	return ((uint32_t)(-1));                /* DMA Invalid */
626
-  }
627
-  val = *((uint32_t *)(ptr + 3*4));         /* Status Information */
628
-  return (val >> 16);                       /* Current Count */
629
-}
630
-
631
-
632
-#endif /* USB_DMA */
633
-
634
-
635
-/*
636
- *  Get USB Last Frame Number
637
- *    Parameters:      None
638
- *    Return Value:    Frame Number
639
- */
640
-
641
-uint32_t USB_GetFrame (void) {
642
-  uint32_t val;
643
-
644
-  WrCmd(CMD_RD_FRAME);
645
-  val = RdCmdDat(DAT_RD_FRAME);
646
-  val = val | (RdCmdDat(DAT_RD_FRAME) << 8);
647
-
648
-  return (val);
649
-}
650
-
651
-
652
-/*
653
- *  USB Interrupt Service Routine
654
- */
655
-
656
-void USB_IRQHandler (void) {
657
-  uint32_t disr, val, n, m;
658
-  uint32_t episr, episrCur;
659
-
660
-  disr = LPC_USB->USBDevIntSt;       /* Device Interrupt Status */
661
-
662
-  /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
663
-  if (disr & DEV_STAT_INT) {
664
-    LPC_USB->USBDevIntClr = DEV_STAT_INT;
665
-    WrCmd(CMD_GET_DEV_STAT);
666
-    val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
667
-    if (val & DEV_RST) {                    /* Reset */
668
-      USB_Reset();
669
-#if   USB_RESET_EVENT
670
-      USB_Reset_Event();
671
-#endif
672
-    }
673
-    if (val & DEV_CON_CH) {                 /* Connect change */
674
-#if   USB_POWER_EVENT
675
-      USB_Power_Event(val & DEV_CON);
676
-#endif
677
-    }
678
-    if (val & DEV_SUS_CH) {                 /* Suspend/Resume */
679
-      if (val & DEV_SUS) {                  /* Suspend */
680
-        USB_Suspend();
681
-#if     USB_SUSPEND_EVENT
682
-        USB_Suspend_Event();
683
-#endif
684
-      } else {                              /* Resume */
685
-        USB_Resume();
686
-#if     USB_RESUME_EVENT
687
-        USB_Resume_Event();
688
-#endif
689
-      }
690
-    }
691
-    goto isr_end;
692
-  }
693
-
694
-#if USB_SOF_EVENT
695
-  /* Start of Frame Interrupt */
696
-  if (disr & FRAME_INT) {
697
-	LPC_USB->USBDevIntClr = FRAME_INT;
698
-    USB_SOF_Event();
699
-  }
700
-#endif
701
-
702
-#if USB_ERROR_EVENT
703
-  /* Error Interrupt */
704
-  if (disr & ERR_INT) {
705
-	LPC_USB->USBDevIntClr = ERR_INT;
706
-    WrCmd(CMD_RD_ERR_STAT);
707
-    val = RdCmdDat(DAT_RD_ERR_STAT);
708
-    USB_Error_Event(val);
709
-  }
710
-#endif
711
-
712
-  /* Endpoint's Slow Interrupt */
713
-  if (disr & EP_SLOW_INT) {
714
-    episrCur = 0;
715
-    episr    = LPC_USB->USBEpIntSt;
716
-    for (n = 0; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
717
-      if (episr == episrCur) break;         /* break if all EP interrupts handled */
718
-      if (episr & (1 << n)) {
719
-        episrCur |= (1 << n);
720
-        m = n >> 1;
721
-
722
-        LPC_USB->USBEpIntClr = (1 << n);
723
-        while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
724
-        val = LPC_USB->USBCmdData;
725
-
726
-        if ((n & 1) == 0) {                 /* OUT Endpoint */
727
-          if (n == 0) {                     /* Control OUT Endpoint */
728
-            if (val & EP_SEL_STP) {         /* Setup Packet */
729
-              if (USB_P_EP[0]) {
730
-                USB_P_EP[0](USB_EVT_SETUP);
731
-                continue;
732
-              }
733
-            }
734
-          }
735
-          if (USB_P_EP[m]) {
736
-            USB_P_EP[m](USB_EVT_OUT);
737
-          }
738
-        } else {                            /* IN Endpoint */
739
-          if (USB_P_EP[m]) {
740
-            USB_P_EP[m](USB_EVT_IN);
741
-          }
742
-        }
743
-      }
744
-    }
745
-    LPC_USB->USBDevIntClr = EP_SLOW_INT;
746
-  }
747
-
748
-#if USB_DMA
749
-
750
-  if (LPC_USB->USBDMAIntSt & 0x00000001) {          /* End of Transfer Interrupt */
751
-    val = LPC_USB->USBEoTIntSt;
752
-    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
753
-      if (val & (1 << n)) {
754
-        m = n >> 1;
755
-        if ((n & 1) == 0) {                 /* OUT Endpoint */
756
-          if (USB_P_EP[m]) {
757
-            USB_P_EP[m](USB_EVT_OUT_DMA_EOT);
758
-          }
759
-        } else {                            /* IN Endpoint */
760
-          if (USB_P_EP[m]) {
761
-            USB_P_EP[m](USB_EVT_IN_DMA_EOT);
762
-          }
763
-        }
764
-      }
765
-    }
766
-    LPC_USB->USBEoTIntClr = val;
767
-  }
768
-
769
-  if (LPC_USB->USBDMAIntSt & 0x00000002) {          /* New DD Request Interrupt */
770
-    val = LPC_USB->USBNDDRIntSt;
771
-    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
772
-      if (val & (1 << n)) {
773
-        m = n >> 1;
774
-        if ((n & 1) == 0) {                 /* OUT Endpoint */
775
-          if (USB_P_EP[m]) {
776
-            USB_P_EP[m](USB_EVT_OUT_DMA_NDR);
777
-          }
778
-        } else {                            /* IN Endpoint */
779
-          if (USB_P_EP[m]) {
780
-            USB_P_EP[m](USB_EVT_IN_DMA_NDR);
781
-          }
782
-        }
783
-      }
784
-    }
785
-    LPC_USB->USBNDDRIntClr = val;
786
-  }
787
-
788
-  if (LPC_USB->USBDMAIntSt & 0x00000004) {          /* System Error Interrupt */
789
-    val = LPC_USB->USBSysErrIntSt;
790
-    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
791
-      if (val & (1 << n)) {
792
-        m = n >> 1;
793
-        if ((n & 1) == 0) {                 /* OUT Endpoint */
794
-          if (USB_P_EP[m]) {
795
-            USB_P_EP[m](USB_EVT_OUT_DMA_ERR);
796
-          }
797
-        } else {                            /* IN Endpoint */
798
-          if (USB_P_EP[m]) {
799
-            USB_P_EP[m](USB_EVT_IN_DMA_ERR);
800
-          }
801
-        }
802
-      }
803
-    }
804
-    LPC_USB->USBSysErrIntClr = val;
805
-  }
806
-
807
-#endif /* USB_DMA */
808
-
809
-isr_end:
810
-  return;
811
-}

+ 0
- 114
Marlin/src/HAL/HAL_LPC1768/usb/usbhw.h 查看文件

@@ -1,114 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbhw.h
5
- * Purpose: USB Hardware Layer Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *----------------------------------------------------------------------------
18
- * History:
19
- *          V1.20 Added USB_ClearEPBuf
20
- *          V1.00 Initial Version
21
- *----------------------------------------------------------------------------*/
22
-
23
-#ifndef __USBHW_H__
24
-#define __USBHW_H__
25
-extern "C" {
26
-#include "lpc_types.h"
27
-}
28
-/* USB RAM Definitions */
29
-#define USB_RAM_ADR     0x2007C000  /* USB RAM Start Address */
30
-#define USB_RAM_SZ      0x00004000  /* USB RAM Size (16kB) */
31
-
32
-/* DMA Endpoint Descriptors */
33
-#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
34
-#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
35
-#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
36
-#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
37
-#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
38
-#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
39
-#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
40
-
41
-/* DMA Buffer Memory Definitions */
42
-#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
43
-#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
44
-
45
-/* USB Error Codes */
46
-#define USB_ERR_PID         0x0001  /* PID Error */
47
-#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
48
-#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
49
-#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
50
-#define USB_ERR_EOP         0x0010  /* End of Packet Error */
51
-#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
52
-#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
53
-#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
54
-
55
-/* USB DMA Status Codes */
56
-#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
57
-#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
58
-#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
59
-#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
60
-#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
61
-#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
62
-#define USB_DMA_ERROR       0x0006  /* Error */
63
-#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
64
-
65
-/* USB DMA Descriptor */
66
-typedef struct _USB_DMA_DESCRIPTOR {
67
-  uint32_t BufAdr;                     /* DMA Buffer Address */
68
-  uint16_t  BufLen;                     /* DMA Buffer Length */
69
-  uint16_t  MaxSize;                    /* Maximum Packet Size */
70
-  uint32_t InfoAdr;                    /* Packet Info Memory Address */
71
-  union {                           /* DMA Configuration */
72
-    struct {
73
-      uint32_t Link   : 1;             /* Link to existing Descriptors */
74
-      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
75
-      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
76
-      uint32_t Rsrvd  : 5;             /* Reserved */
77
-      uint32_t LenPos : 8;             /* Length Position (ATLE) */
78
-    } Type;
79
-    uint32_t Val;
80
-  } Cfg;
81
-} USB_DMA_DESCRIPTOR;
82
-
83
-extern "C" {
84
-/* USB Hardware Functions */
85
-extern void  USB_Init       (void);
86
-extern void  USB_Connect    (uint32_t  con);
87
-extern void  USB_Reset      (void);
88
-extern void  USB_Suspend    (void);
89
-extern void  USB_Resume     (void);
90
-extern void  USB_WakeUp     (void);
91
-extern void  USB_WakeUpCfg  (uint32_t  cfg);
92
-extern void  USB_SetAddress (uint32_t adr);
93
-extern void  USB_Configure  (uint32_t  cfg);
94
-extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
95
-extern void  USB_DirCtrlEP  (uint32_t dir);
96
-extern void  USB_EnableEP   (uint32_t EPNum);
97
-extern void  USB_DisableEP  (uint32_t EPNum);
98
-extern void  USB_ResetEP    (uint32_t EPNum);
99
-extern void  USB_SetStallEP (uint32_t EPNum);
100
-extern void  USB_ClrStallEP (uint32_t EPNum);
101
-extern void USB_ClearEPBuf  (uint32_t  EPNum);
102
-extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
103
-extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
104
-extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
105
-extern void  USB_DMA_Enable (uint32_t EPNum);
106
-extern void  USB_DMA_Disable(uint32_t EPNum);
107
-extern uint32_t USB_DMA_Status (uint32_t EPNum);
108
-extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
109
-extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
110
-extern uint32_t USB_GetFrame   (void);
111
-extern void  USB_IRQHandler (void);
112
-}
113
-
114
-#endif  /* __USBHW_H__ */

+ 0
- 130
Marlin/src/HAL/HAL_LPC1768/usb/usbreg.h 查看文件

@@ -1,130 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbreg.h
5
- * Purpose: USB Hardware Layer Definitions for NXP LPC Family MCUs
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __USBREG_H
20
-#define __USBREG_H
21
-
22
-/* Device Interrupt Bit Definitions */
23
-#define FRAME_INT           0x00000001
24
-#define EP_FAST_INT         0x00000002
25
-#define EP_SLOW_INT         0x00000004
26
-#define DEV_STAT_INT        0x00000008
27
-#define CCEMTY_INT          0x00000010
28
-#define CDFULL_INT          0x00000020
29
-#define RxENDPKT_INT        0x00000040
30
-#define TxENDPKT_INT        0x00000080
31
-#define EP_RLZED_INT        0x00000100
32
-#define ERR_INT             0x00000200
33
-
34
-/* Rx & Tx Packet Length Definitions */
35
-#define PKT_LNGTH_MASK      0x000003FF
36
-#define PKT_DV              0x00000400
37
-#define PKT_RDY             0x00000800
38
-
39
-/* USB Control Definitions */
40
-#define CTRL_RD_EN          0x00000001
41
-#define CTRL_WR_EN          0x00000002
42
-
43
-/* Command Codes */
44
-#define CMD_SET_ADDR        0x00D00500
45
-#define CMD_CFG_DEV         0x00D80500
46
-#define CMD_SET_MODE        0x00F30500
47
-#define CMD_RD_FRAME        0x00F50500
48
-#define DAT_RD_FRAME        0x00F50200
49
-#define CMD_RD_TEST         0x00FD0500
50
-#define DAT_RD_TEST         0x00FD0200
51
-#define CMD_SET_DEV_STAT    0x00FE0500
52
-#define CMD_GET_DEV_STAT    0x00FE0500
53
-#define DAT_GET_DEV_STAT    0x00FE0200
54
-#define CMD_GET_ERR_CODE    0x00FF0500
55
-#define DAT_GET_ERR_CODE    0x00FF0200
56
-#define CMD_RD_ERR_STAT     0x00FB0500
57
-#define DAT_RD_ERR_STAT     0x00FB0200
58
-#define DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
59
-#define CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
60
-#define DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
61
-#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
62
-#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
63
-#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
64
-#define CMD_CLR_BUF         0x00F20500
65
-#define DAT_CLR_BUF         0x00F20200
66
-#define CMD_VALID_BUF       0x00FA0500
67
-
68
-/* Device Address Register Definitions */
69
-#define DEV_ADDR_MASK       0x7F
70
-#define DEV_EN              0x80
71
-
72
-/* Device Configure Register Definitions */
73
-#define CONF_DVICE          0x01
74
-
75
-/* Device Mode Register Definitions */
76
-#define AP_CLK              0x01
77
-#define INAK_CI             0x02
78
-#define INAK_CO             0x04
79
-#define INAK_II             0x08
80
-#define INAK_IO             0x10
81
-#define INAK_BI             0x20
82
-#define INAK_BO             0x40
83
-
84
-/* Device Status Register Definitions */
85
-#define DEV_CON             0x01
86
-#define DEV_CON_CH          0x02
87
-#define DEV_SUS             0x04
88
-#define DEV_SUS_CH          0x08
89
-#define DEV_RST             0x10
90
-
91
-/* Error Code Register Definitions */
92
-#define ERR_EC_MASK         0x0F
93
-#define ERR_EA              0x10
94
-
95
-/* Error Status Register Definitions */
96
-#define ERR_PID             0x01
97
-#define ERR_UEPKT           0x02
98
-#define ERR_DCRC            0x04
99
-#define ERR_TIMOUT          0x08
100
-#define ERR_EOP             0x10
101
-#define ERR_B_OVRN          0x20
102
-#define ERR_BTSTF           0x40
103
-#define ERR_TGL             0x80
104
-
105
-/* Endpoint Select Register Definitions */
106
-#define EP_SEL_F            0x01
107
-#define EP_SEL_ST           0x02
108
-#define EP_SEL_STP          0x04
109
-#define EP_SEL_PO           0x08
110
-#define EP_SEL_EPN          0x10
111
-#define EP_SEL_B_1_FULL     0x20
112
-#define EP_SEL_B_2_FULL     0x40
113
-
114
-/* Endpoint Status Register Definitions */
115
-#define EP_STAT_ST          0x01
116
-#define EP_STAT_DA          0x20
117
-#define EP_STAT_RF_MO       0x40
118
-#define EP_STAT_CND_ST      0x80
119
-
120
-/* Clear Buffer Register Definitions */
121
-#define CLR_BUF_PO          0x01
122
-
123
-
124
-/* DMA Interrupt Bit Definitions */
125
-#define EOT_INT             0x01
126
-#define NDD_REQ_INT         0x02
127
-#define SYS_ERR_INT         0x04
128
-
129
-
130
-#endif  /* __USBREG_H */

+ 0
- 353
Marlin/src/HAL/HAL_LPC1768/usb/usbuser.cpp 查看文件

@@ -1,353 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbuser.c
5
- * Purpose: USB Custom User Module
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-extern "C" {
20
-#include "lpc_types.h"
21
-#include <debug_frmwrk.h>
22
-}
23
-
24
-#include "usb.h"
25
-#include "usbcfg.h"
26
-#include "usbhw.h"
27
-#include "usbcore.h"
28
-#include "usbuser.h"
29
-#include "cdcuser.h"
30
-#include "mscuser.h"
31
-
32
-
33
-/*
34
- *  USB Power Event Callback
35
- *   Called automatically on USB Power Event
36
- *    Parameter:       power: On(TRUE)/Off(FALSE)
37
- */
38
-
39
-#if USB_POWER_EVENT
40
-void USB_Power_Event (uint32_t  power) {
41
-}
42
-#endif
43
-
44
-
45
-/*
46
- *  USB Reset Event Callback
47
- *   Called automatically on USB Reset Event
48
- */
49
-
50
-#if USB_RESET_EVENT
51
-void USB_Reset_Event (void) {
52
-  USB_ResetCore();
53
-}
54
-#endif
55
-
56
-
57
-/*
58
- *  USB Suspend Event Callback
59
- *   Called automatically on USB Suspend Event
60
- */
61
-
62
-#if USB_SUSPEND_EVENT
63
-void USB_Suspend_Event (void) {
64
-}
65
-#endif
66
-
67
-
68
-/*
69
- *  USB Resume Event Callback
70
- *   Called automatically on USB Resume Event
71
- */
72
-
73
-#if USB_RESUME_EVENT
74
-void USB_Resume_Event (void) {
75
-}
76
-#endif
77
-
78
-
79
-/*
80
- *  USB Remote Wakeup Event Callback
81
- *   Called automatically on USB Remote Wakeup Event
82
- */
83
-
84
-#if USB_WAKEUP_EVENT
85
-void USB_WakeUp_Event (void) {
86
-}
87
-#endif
88
-
89
-
90
-/*
91
- *  USB Start of Frame Event Callback
92
- *   Called automatically on USB Start of Frame Event
93
- */
94
-
95
-#if USB_SOF_EVENT
96
-void USB_SOF_Event (void) {
97
-}
98
-#endif
99
-
100
-
101
-/*
102
- *  USB Error Event Callback
103
- *   Called automatically on USB Error Event
104
- *    Parameter:       error: Error Code
105
- */
106
-
107
-#if USB_ERROR_EVENT
108
-void USB_Error_Event (uint32_t error) {
109
-}
110
-#endif
111
-
112
-
113
-/*
114
- *  USB Set Configuration Event Callback
115
- *   Called automatically on USB Set Configuration Request
116
- */
117
-
118
-#if USB_CONFIGURE_EVENT
119
-void USB_Configure_Event (void) {
120
-
121
-  if (USB_Configuration) {                  /* Check if USB is configured */
122
-    /* add your code here */
123
-  }
124
-}
125
-#endif
126
-
127
-
128
-/*
129
- *  USB Set Interface Event Callback
130
- *   Called automatically on USB Set Interface Request
131
- */
132
-
133
-#if USB_INTERFACE_EVENT
134
-void USB_Interface_Event (void) {
135
-}
136
-#endif
137
-
138
-
139
-/*
140
- *  USB Set/Clear Feature Event Callback
141
- *   Called automatically on USB Set/Clear Feature Request
142
- */
143
-
144
-#if USB_FEATURE_EVENT
145
-void USB_Feature_Event (void) {
146
-}
147
-#endif
148
-
149
-
150
-#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : nullptr)
151
-
152
-/* USB Endpoint Events Callback Pointers */
153
-void (* const USB_P_EP[16]) (uint32_t event) = {
154
-  P_EP(0),
155
-  P_EP(1),
156
-  P_EP(2),
157
-  P_EP(3),
158
-  P_EP(4),
159
-  P_EP(5),
160
-  P_EP(6),
161
-  P_EP(7),
162
-  P_EP(8),
163
-  P_EP(9),
164
-  P_EP(10),
165
-  P_EP(11),
166
-  P_EP(12),
167
-  P_EP(13),
168
-  P_EP(14),
169
-  P_EP(15),
170
-};
171
-
172
-
173
-/*
174
- *  USB Endpoint 1 Event Callback
175
- *   Called automatically on USB Endpoint 1 Event
176
- *    Parameter:       event
177
- */
178
-
179
-void USB_EndPoint1 (uint32_t event) {
180
-  uint16_t temp;
181
-  static uint16_t serialState;
182
-
183
-  switch (event) {
184
-    case USB_EVT_IN:
185
-      temp = CDC_GetSerialState();
186
-      if (serialState != temp) {
187
-         serialState = temp;
188
-         CDC_NotificationIn();            /* send SERIAL_STATE notification */
189
-      }
190
-      break;
191
-    default:
192
-      _DBG("Unhandled EP1 event: ");
193
-      _DBH(event);
194
-      _DBG("\n");
195
-  }
196
-}
197
-
198
-
199
-/*
200
- *  USB Endpoint 2 Event Callback
201
- *   Called automatically on USB Endpoint 2 Event
202
- *    Parameter:       event
203
- */
204
-
205
-void USB_EndPoint2 (uint32_t event) {
206
-
207
-  switch (event) {
208
-    case USB_EVT_OUT:
209
-      CDC_BulkOut ();                /* data received from Host */
210
-      break;
211
-    case USB_EVT_IN:
212
-      CDC_BulkIn ();                 /* data expected from Host */
213
-      break;
214
-  }
215
-}
216
-
217
-
218
-/*
219
- *  USB Endpoint 3 Event Callback
220
- *   Called automatically on USB Endpoint 3 Event
221
- *    Parameter:       event
222
- */
223
-
224
-void USB_EndPoint3 (uint32_t event) {
225
-}
226
-
227
-
228
-/*
229
- *  USB Endpoint 4 Event Callback
230
- *   Called automatically on USB Endpoint 4 Event
231
- *    Parameter:       event
232
- */
233
-
234
-void USB_EndPoint4 (uint32_t event) {
235
-}
236
-
237
-
238
-/*
239
- *  USB Endpoint 5 Event Callback
240
- *   Called automatically on USB Endpoint 5 Event
241
- *    Parameter:       event
242
- */
243
-
244
-void USB_EndPoint5 (uint32_t event) {
245
-  switch (event) {
246
-    case USB_EVT_OUT:
247
-      MSC_BulkOut();
248
-      break;
249
-    case USB_EVT_IN:
250
-      MSC_BulkIn();
251
-      break;
252
-  }
253
-}
254
-
255
-
256
-/*
257
- *  USB Endpoint 6 Event Callback
258
- *   Called automatically on USB Endpoint 6 Event
259
- *    Parameter:       event
260
- */
261
-
262
-void USB_EndPoint6 (uint32_t event) {
263
-}
264
-
265
-
266
-/*
267
- *  USB Endpoint 7 Event Callback
268
- *   Called automatically on USB Endpoint 7 Event
269
- *    Parameter:       event
270
- */
271
-
272
-void USB_EndPoint7 (uint32_t event) {
273
-}
274
-
275
-
276
-/*
277
- *  USB Endpoint 8 Event Callback
278
- *   Called automatically on USB Endpoint 8 Event
279
- *    Parameter:       event
280
- */
281
-
282
-void USB_EndPoint8 (uint32_t event) {
283
-}
284
-
285
-
286
-/*
287
- *  USB Endpoint 9 Event Callback
288
- *   Called automatically on USB Endpoint 9 Event
289
- *    Parameter:       event
290
- */
291
-
292
-void USB_EndPoint9 (uint32_t event) {
293
-}
294
-
295
-
296
-/*
297
- *  USB Endpoint 10 Event Callback
298
- *   Called automatically on USB Endpoint 10 Event
299
- *    Parameter:       event
300
- */
301
-
302
-void USB_EndPoint10 (uint32_t event) {
303
-}
304
-
305
-
306
-/*
307
- *  USB Endpoint 11 Event Callback
308
- *   Called automatically on USB Endpoint 11 Event
309
- *    Parameter:       event
310
- */
311
-
312
-void USB_EndPoint11 (uint32_t event) {
313
-}
314
-
315
-
316
-/*
317
- *  USB Endpoint 12 Event Callback
318
- *   Called automatically on USB Endpoint 12 Event
319
- *    Parameter:       event
320
- */
321
-
322
-void USB_EndPoint12 (uint32_t event) {
323
-}
324
-
325
-
326
-/*
327
- *  USB Endpoint 13 Event Callback
328
- *   Called automatically on USB Endpoint 13 Event
329
- *    Parameter:       event
330
- */
331
-
332
-void USB_EndPoint13 (uint32_t event) {
333
-}
334
-
335
-
336
-/*
337
- *  USB Endpoint 14 Event Callback
338
- *   Called automatically on USB Endpoint 14 Event
339
- *    Parameter:       event
340
- */
341
-
342
-void USB_EndPoint14 (uint32_t event) {
343
-}
344
-
345
-
346
-/*
347
- *  USB Endpoint 15 Event Callback
348
- *   Called automatically on USB Endpoint 15 Event
349
- *    Parameter:       event
350
- */
351
-
352
-void USB_EndPoint15 (uint32_t event) {
353
-}

+ 0
- 74
Marlin/src/HAL/HAL_LPC1768/usb/usbuser.h 查看文件

@@ -1,74 +0,0 @@
1
-/*----------------------------------------------------------------------------
2
- *      U S B  -  K e r n e l
3
- *----------------------------------------------------------------------------
4
- * Name:    usbuser.h
5
- * Purpose: USB Custom User Definitions
6
- * Version: V1.20
7
- *----------------------------------------------------------------------------
8
- *      This software is supplied "AS IS" without any warranties, express,
9
- *      implied or statutory, including but not limited to the implied
10
- *      warranties of fitness for purpose, satisfactory quality and
11
- *      noninfringement. Keil extends you a royalty-free right to reproduce
12
- *      and distribute executable files created using this software for use
13
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
14
- *      else gives you the right to use this software.
15
- *
16
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17
- *---------------------------------------------------------------------------*/
18
-
19
-#ifndef __USBUSER_H__
20
-#define __USBUSER_H__
21
-
22
-
23
-/* USB Device Events Callback Functions */
24
-extern void USB_Power_Event     (uint32_t power);
25
-extern void USB_Reset_Event     (void);
26
-extern void USB_Suspend_Event   (void);
27
-extern void USB_Resume_Event    (void);
28
-extern void USB_WakeUp_Event    (void);
29
-extern void USB_SOF_Event       (void);
30
-extern void USB_Error_Event     (uint32_t error);
31
-
32
-/* USB Endpoint Callback Events */
33
-#define USB_EVT_SETUP       1   /* Setup Packet */
34
-#define USB_EVT_OUT         2   /* OUT Packet */
35
-#define USB_EVT_IN          3   /*  IN Packet */
36
-#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
37
-#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
38
-#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
39
-#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
40
-#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
41
-#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
42
-#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
43
-#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
44
-#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
45
-#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */
46
-
47
-/* USB Endpoint Events Callback Pointers */
48
-extern void (* const USB_P_EP[16])(uint32_t event);
49
-
50
-/* USB Endpoint Events Callback Functions */
51
-extern void USB_EndPoint0  (uint32_t event);
52
-extern void USB_EndPoint1  (uint32_t event);
53
-extern void USB_EndPoint2  (uint32_t event);
54
-extern void USB_EndPoint3  (uint32_t event);
55
-extern void USB_EndPoint4  (uint32_t event);
56
-extern void USB_EndPoint5  (uint32_t event);
57
-extern void USB_EndPoint6  (uint32_t event);
58
-extern void USB_EndPoint7  (uint32_t event);
59
-extern void USB_EndPoint8  (uint32_t event);
60
-extern void USB_EndPoint9  (uint32_t event);
61
-extern void USB_EndPoint10 (uint32_t event);
62
-extern void USB_EndPoint11 (uint32_t event);
63
-extern void USB_EndPoint12 (uint32_t event);
64
-extern void USB_EndPoint13 (uint32_t event);
65
-extern void USB_EndPoint14 (uint32_t event);
66
-extern void USB_EndPoint15 (uint32_t event);
67
-
68
-/* USB Core Events Callback Functions */
69
-extern void USB_Configure_Event (void);
70
-extern void USB_Interface_Event (void);
71
-extern void USB_Feature_Event   (void);
72
-
73
-
74
-#endif  /* __USBUSER_H__ */

+ 3
- 2
platformio.ini 查看文件

@@ -25,7 +25,7 @@ lib_deps =
25 25
   https://github.com/lincomatic/LiquidTWI2.git
26 26
   https://github.com/teemuatlut/TMC2130Stepper.git
27 27
   https://github.com/adafruit/Adafruit_NeoPixel.git
28
-default_src_filter = +<*> -<example_configurations> -<src/HAL/HAL_*>
28
+default_src_filter = +<*> -<example_configurations> -<src/HAL/HAL_*> -<frameworks>
29 29
 
30 30
 [env:megaatmega2560]
31 31
 platform = atmelavr
@@ -106,6 +106,7 @@ framework = arduino
106 106
 board = teensy35
107 107
 build_flags = -I $BUILDSRC_DIR
108 108
 lib_deps = ${common.lib_deps}
109
+lib_ignore = Adafruit NeoPixel
109 110
 src_filter = ${common.default_src_filter} +<src/HAL/HAL_TEENSY35_36>
110 111
 
111 112
 [env:Re-ARM]
@@ -114,5 +115,5 @@ board_f_cpu = 100000000L
114 115
 build_flags = !python Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py
115 116
 lib_ldf_mode = off
116 117
 lib_deps = U8glib-ARM
117
-src_filter = ${common.default_src_filter} +<src/HAL/HAL_LPC1768>
118
+src_filter = ${common.default_src_filter} +<src/HAL/HAL_LPC1768> +<frameworks/CMSIS/LPC1768>
118 119
 extra_scripts = Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py

Loading…
取消
儲存