From 121c41719d94738047c00d9a5c6a3d11dd06bfcb Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 28 Sep 2012 16:02:13 +0000 Subject: [PATCH] [sky9x] All fields in SD info submenu now displayed [sky9x] Model Backup / Restore should be ok [sky9x] SD unmounted when USB masstorage [sky9x / gruvin9x] Header added to Model Backups [sky9x / gruvin9x] Log file closed when Logging function stopped + Cleaning session --- src/Makefile | 24 +- src/board_ersky9x.h | 4 +- src/eeprom_arm.cpp | 53 +- src/eeprom_avr.cpp | 34 +- .../{libraries/memories => }/MEDSdcard.c | 0 src/ersky9x/{libraries/memories => }/Media.h | 0 src/ersky9x/audio.cpp | 12 +- src/ersky9x/audio.h | 2 + src/ersky9x/board.h | 58 +- src/ersky9x/diskio.c | 35 +- .../libraries/board/at91sam3s4/AT91SAM3S4.h | 7010 ----------------- src/ersky9x/libraries/board/at91sam3s4/chip.h | 130 - .../libraries/board/at91sam3s4/flash.icf | 30 - .../libraries/board/at91sam3s4/flash.lds | 81 - .../libraries/board/at91sam3s4/sram.icf | 27 - .../libraries/board/at91sam3s4/sram.lds | 81 - src/ersky9x/libraries/board/board.h | 673 -- .../libraries/board/board_cstartup_iar.c | 143 - src/ersky9x/libraries/board/board_lowlevel.c | 195 - src/ersky9x/libraries/board/board_lowlevel.h | 49 - src/ersky9x/libraries/board/board_memories.c | 96 - src/ersky9x/libraries/board/board_memories.h | 49 - src/ersky9x/libraries/board/exceptions.c | 385 - src/ersky9x/libraries/board/exceptions.h | 103 - src/ersky9x/libraries/cmsis/core_cm3.c | 804 -- src/ersky9x/libraries/cmsis/core_cm3.h | 1265 --- .../libraries/components/ads7843/ads7843.c | 212 - .../libraries/components/ads7843/ads7843.h | 58 - .../libraries/components/wm8731/wm8731.c | 140 - .../libraries/components/wm8731/wm8731.h | 195 - src/ersky9x/libraries/drivers/acc/acc.c | 164 - src/ersky9x/libraries/drivers/acc/acc.h | 144 - src/ersky9x/libraries/drivers/adc/adc.c | 231 - src/ersky9x/libraries/drivers/adc/adc.h | 158 - src/ersky9x/libraries/drivers/async/async.c | 54 - src/ersky9x/libraries/drivers/async/async.h | 67 - src/ersky9x/libraries/drivers/crccu/crccu.c | 134 - src/ersky9x/libraries/drivers/crccu/crccu.h | 66 - src/ersky9x/libraries/drivers/dacc/dacc.c | 172 - src/ersky9x/libraries/drivers/dacc/dacc.h | 133 - src/ersky9x/libraries/drivers/efc/efc.c | 286 - src/ersky9x/libraries/drivers/efc/efc.h | 112 - src/ersky9x/libraries/drivers/flash/flashd.c | 494 -- src/ersky9x/libraries/drivers/flash/flashd.h | 84 - src/ersky9x/libraries/drivers/lcd/color.h | 85 - src/ersky9x/libraries/drivers/lcd/draw.c | 333 - src/ersky9x/libraries/drivers/lcd/draw.h | 114 - src/ersky9x/libraries/drivers/lcd/font.c | 95 - src/ersky9x/libraries/drivers/lcd/font.h | 92 - src/ersky9x/libraries/drivers/lcd/font10x14.h | 236 - src/ersky9x/libraries/drivers/lcd/lcdd.c | 149 - src/ersky9x/libraries/drivers/lcd/lcdd.h | 52 - src/ersky9x/libraries/drivers/pio/pio.c | 464 -- src/ersky9x/libraries/drivers/pio/pio.h | 215 - src/ersky9x/libraries/drivers/pio/pio_it.c | 411 - src/ersky9x/libraries/drivers/pio/pio_it.h | 153 - .../libraries/drivers/pio/pio_keypad.c | 147 - .../libraries/drivers/pio/pio_keypad.h | 153 - src/ersky9x/libraries/drivers/pmc/pmc.c | 143 - src/ersky9x/libraries/drivers/pmc/pmc.h | 62 - src/ersky9x/libraries/drivers/pwmc/pwmc.c | 648 -- src/ersky9x/libraries/drivers/pwmc/pwmc.h | 159 - .../drivers/qtouch/libQTouchGnuCfg3SRevB.a | Bin 53640 -> 0 bytes .../qtouch/libQTouchIarCfg3SRevABeta1.a | Bin 25168 -> 0 bytes .../qtouch/libQTouchIarCfg3SRevABeta1.txt | 6 - .../qtouch/libQTouchIarCfg3SRevABeta2.a | Bin 18058 -> 0 bytes .../qtouch/libQTouchIarCfg3SRevABeta2.txt | 10 - .../drivers/qtouch/libQTouchIarCfg3SRevB.a | Bin 25190 -> 0 bytes .../drivers/qtouch/libQTouchIarCfg3SRevB.txt | 11 - src/ersky9x/libraries/drivers/rtc/rtc.c | 467 -- src/ersky9x/libraries/drivers/rtc/rtc.h | 99 - src/ersky9x/libraries/drivers/rtt/rtt.c | 136 - src/ersky9x/libraries/drivers/rtt/rtt.h | 80 - .../libraries/drivers/spi-flash/at45d.c | 253 - .../libraries/drivers/spi-flash/at45d.h | 72 - .../libraries/drivers/spi-flash/spi_at45.c | 311 - .../libraries/drivers/spi-flash/spi_at45.h | 202 - .../libraries/drivers/spi-flash/spi_pdc.c | 275 - .../libraries/drivers/spi-flash/spi_pdc.h | 133 - src/ersky9x/libraries/drivers/spi/spi.c | 241 - src/ersky9x/libraries/drivers/spi/spi.h | 104 - src/ersky9x/libraries/drivers/ssc/ssc.c | 248 - src/ersky9x/libraries/drivers/ssc/ssc.h | 58 - src/ersky9x/libraries/drivers/tc/tc.c | 148 - src/ersky9x/libraries/drivers/tc/tc.h | 70 - src/ersky9x/libraries/drivers/tsd/tsd.h | 69 - .../libraries/drivers/tsd/tsd_ads7843.c | 302 - .../libraries/drivers/tsd/tsd_ads7843.h | 20 - src/ersky9x/libraries/drivers/tsd/tsd_com.c | 380 - src/ersky9x/libraries/drivers/tsd/tsd_com.h | 54 - src/ersky9x/libraries/drivers/twi/twi.c | 377 - src/ersky9x/libraries/drivers/twi/twi.h | 95 - src/ersky9x/libraries/drivers/twi/twid.c | 342 - src/ersky9x/libraries/drivers/twi/twid.h | 86 - .../libraries/drivers/usart/uart_console.c | 288 - .../libraries/drivers/usart/uart_console.h | 38 - src/ersky9x/libraries/drivers/usart/usart.c | 395 - src/ersky9x/libraries/drivers/usart/usart.h | 129 - .../libraries/drivers/utility/assert.h | 114 - .../libraries/drivers/utility/bitbanding.h | 108 - src/ersky9x/libraries/drivers/utility/bmp.c | 322 - src/ersky9x/libraries/drivers/utility/bmp.h | 130 - src/ersky9x/libraries/drivers/utility/clock.c | 259 - src/ersky9x/libraries/drivers/utility/clock.h | 47 - .../drivers/utility/encryption/aes_hardware.c | 316 - .../drivers/utility/encryption/aes_hardware.h | 100 - .../utility/encryption/aes_reference.c | 801 -- .../utility/encryption/aes_reference.h | 132 - .../drivers/utility/encryption/encryption.h | 98 - .../drivers/utility/encryption/libtomcrypt.c | 445 -- .../drivers/utility/encryption/libtomcrypt.h | 149 - .../utility/encryption/tdes_hardware.c | 520 -- .../utility/encryption/tdes_hardware.h | 125 - .../libraries/drivers/utility/hamming.c | 335 - .../libraries/drivers/utility/hamming.h | 72 - src/ersky9x/libraries/drivers/utility/iap.c | 98 - src/ersky9x/libraries/drivers/utility/iap.h | 51 - src/ersky9x/libraries/drivers/utility/led.c | 164 - src/ersky9x/libraries/drivers/utility/led.h | 70 - src/ersky9x/libraries/drivers/utility/math.c | 91 - src/ersky9x/libraries/drivers/utility/math.h | 41 - src/ersky9x/libraries/drivers/utility/rand.c | 60 - src/ersky9x/libraries/drivers/utility/rand.h | 49 - .../libraries/drivers/utility/retarget.c | 88 - src/ersky9x/libraries/drivers/utility/stdio.c | 511 -- .../libraries/drivers/utility/string.c | 239 - src/ersky9x/libraries/drivers/utility/trace.c | 45 - src/ersky9x/libraries/drivers/utility/trace.h | 246 - src/ersky9x/libraries/drivers/utility/util.c | 223 - src/ersky9x/libraries/drivers/utility/util.h | 48 - .../libraries/drivers/utility/utility.dir | 50 - src/ersky9x/libraries/drivers/utility/video.c | 130 - src/ersky9x/libraries/drivers/utility/video.h | 89 - src/ersky9x/libraries/drivers/utility/wav.c | 84 - src/ersky9x/libraries/drivers/utility/wav.h | 82 - src/ersky9x/libraries/drivers/wdt/wdt.c | 141 - src/ersky9x/libraries/drivers/wdt/wdt.h | 61 - src/ersky9x/libraries/memories/.project | 11 - src/ersky9x/libraries/memories/Media.c | 57 - .../sam-gui/common/sam_gui_bitmap_raw.c | 66 - .../sam-gui/common/sam_gui_bitmap_raw.h | 20 - .../libraries/sam-gui/common/sam_gui_color.c | 39 - .../libraries/sam-gui/common/sam_gui_color.h | 32 - .../libraries/sam-gui/common/sam_gui_colors.c | 2 - .../libraries/sam-gui/common/sam_gui_colors.h | 45 - .../libraries/sam-gui/common/sam_gui_errors.h | 42 - .../libraries/sam-gui/common/sam_gui_font.c | 11 - .../libraries/sam-gui/common/sam_gui_font.h | 23 - .../sam-gui/common/sam_gui_font10x14.c | 235 - .../sam-gui/common/sam_gui_font10x14.h | 44 - .../libraries/sam-gui/common/sam_gui_point.c | 2 - .../libraries/sam-gui/common/sam_gui_point.h | 10 - .../libraries/sam-gui/common/sam_gui_size.c | 3 - .../libraries/sam-gui/common/sam_gui_size.h | 12 - .../disp/backends/HX8347/backend_HX8347.c | 411 - .../disp/backends/HX8347/backend_HX8347.h | 90 - .../disp/backends/ILI9325/backend_ILI9325.c | 1620 ---- .../disp/backends/ILI9325/backend_ILI9325.h | 52 - .../libraries/sam-gui/disp/disp_backend.c | 80 - .../libraries/sam-gui/disp/disp_backend.h | 78 - .../libraries/sam-gui/disp/disp_core.c | 29 - .../libraries/sam-gui/disp/disp_core.h | 41 - src/ersky9x/libraries/sam-gui/docs/pcx.txt | 585 -- src/ersky9x/libraries/sam-gui/file/file_fs.h | 13 - .../libraries/sam-gui/porting/sam_gui_embos.c | 0 .../sam-gui/porting/sam_gui_freertos.c | 23 - .../libraries/sam-gui/porting/sam_gui_nuttx.c | 0 .../sam-gui/porting/sam_gui_porting.h | 37 - .../libraries/sam-gui/wgt/core/wgt_core.c | 198 - .../libraries/sam-gui/wgt/core/wgt_core.h | 72 - .../sam-gui/wgt/core/wgt_core_behaviour.c | 29 - .../sam-gui/wgt/core/wgt_core_behaviour.h | 35 - .../wgt/core/wgt_core_behaviour_default.c | 130 - .../sam-gui/wgt/core/wgt_core_frontend.c | 84 - .../sam-gui/wgt/core/wgt_core_frontend.h | 61 - .../sam-gui/wgt/core/wgt_core_message.c | 112 - .../sam-gui/wgt/core/wgt_core_message.h | 80 - .../sam-gui/wgt/core/wgt_core_pointer.c | 54 - .../sam-gui/wgt/core/wgt_core_pointer.h | 40 - .../sam-gui/wgt/core/wgt_core_screen.c | 307 - .../sam-gui/wgt/core/wgt_core_screen.h | 81 - .../sam-gui/wgt/core/wgt_core_timer.c | 33 - .../sam-gui/wgt/core/wgt_core_timer.h | 63 - .../sam-gui/wgt/core/wgt_core_widget.c | 225 - .../sam-gui/wgt/core/wgt_core_widget.h | 99 - .../sam-gui/wgt/frontends/frontend_ADS7843.c | 303 - .../sam-gui/wgt/frontends/frontend_ADS7843.h | 52 - .../wgt/frontends/frontend_potentiometer.c | 220 - .../wgt/frontends/frontend_potentiometer.h | 42 - .../wgt/frontends/frontend_pushbuttons.c | 66 - .../wgt/frontends/frontend_pushbuttons.h | 49 - .../sam-gui/wgt/frontends/frontend_qtouch.c | 50 - .../sam-gui/wgt/frontends/frontend_qtouch.h | 42 - .../sam-gui/wgt/widgets/wgt_widget_button.c | 1 - .../sam-gui/wgt/widgets/wgt_widget_button.h | 5 - .../sam-gui/wgt/widgets/wgt_widget_page.c | 0 .../sam-gui/wgt/widgets/wgt_widget_page.h | 0 .../sam-gui/wgt/widgets/wgt_widget_static.c | 1 - .../sam-gui/wgt/widgets/wgt_widget_static.h | 5 - .../usb/USBFrameworkArchitecture.png | Bin 5288 -> 0 bytes .../audio/AUDControlInterfaceDescriptor.h | 72 - .../common/audio/AUDDataEndpointDescriptor.h | 104 - .../usb/common/audio/AUDDeviceDescriptor.h | 72 - .../usb/common/audio/AUDEndpointDescriptor.h | 86 - .../common/audio/AUDFeatureUnitDescriptor.h | 116 - .../usb/common/audio/AUDFeatureUnitRequest.c | 60 - .../usb/common/audio/AUDFeatureUnitRequest.h | 81 - .../common/audio/AUDFormatTypeOneDescriptor.h | 101 - .../usb/common/audio/AUDGenericDescriptor.h | 121 - .../usb/common/audio/AUDGenericRequest.c | 57 - .../usb/common/audio/AUDGenericRequest.h | 94 - .../usb/common/audio/AUDHeaderDescriptor.h | 100 - .../common/audio/AUDInputTerminalDescriptor.h | 139 - .../audio/AUDOutputTerminalDescriptor.h | 112 - .../audio/AUDStreamingInterfaceDescriptor.h | 129 - .../libraries/usb/common/audio/audio.dir | 40 - .../CDCAbstractControlManagementDescriptor.h | 104 - .../common/cdc/CDCCallManagementDescriptor.h | 97 - .../cdc/CDCCommunicationInterfaceDescriptor.h | 65 - .../common/cdc/CDCDataInterfaceDescriptor.h | 65 - .../usb/common/cdc/CDCDeviceDescriptor.h | 64 - .../usb/common/cdc/CDCGenericDescriptor.h | 91 - .../usb/common/cdc/CDCGenericRequest.h | 63 - .../usb/common/cdc/CDCHeaderDescriptor.h | 77 - .../libraries/usb/common/cdc/CDCLineCoding.c | 78 - .../libraries/usb/common/cdc/CDCLineCoding.h | 136 - .../cdc/CDCSetControlLineStateRequest.c | 84 - .../cdc/CDCSetControlLineStateRequest.h | 59 - .../usb/common/cdc/CDCUnionDescriptor.h | 79 - src/ersky9x/libraries/usb/common/cdc/cdc.dir | 39 - src/ersky9x/libraries/usb/common/common.dir | 55 - .../usb/common/core/USBConfigurationOTG.c | 51 - .../usb/common/core/USBConfigurationOTG.h | 118 - .../libraries/usb/common/core/core.dir | 53 - .../libraries/usb/common/hid/HIDButton.h | 55 - .../libraries/usb/common/hid/HIDDescriptor.h | 93 - .../usb/common/hid/HIDDeviceDescriptor.h | 68 - .../usb/common/hid/HIDGenericDescriptor.h | 63 - .../usb/common/hid/HIDGenericDesktop.h | 98 - .../usb/common/hid/HIDGenericRequest.h | 75 - .../libraries/usb/common/hid/HIDIdleRequest.c | 56 - .../libraries/usb/common/hid/HIDIdleRequest.h | 68 - .../usb/common/hid/HIDInterfaceDescriptor.h | 77 - .../libraries/usb/common/hid/HIDKeypad.c | 56 - .../libraries/usb/common/hid/HIDKeypad.h | 276 - .../libraries/usb/common/hid/HIDLeds.h | 79 - .../libraries/usb/common/hid/HIDReport.h | 231 - .../usb/common/hid/HIDReportRequest.c | 68 - .../usb/common/hid/HIDReportRequest.h | 86 - src/ersky9x/libraries/usb/common/hid/hid.dir | 39 - .../USBDCallbackInvocationFlowchart.png | Bin 11380 -> 0 bytes .../usb/device/USBDeviceStateDiagram.png | Bin 8827 -> 0 bytes .../device/audio-looprec/AUDDLoopRecChannel.c | 129 - .../device/audio-looprec/AUDDLoopRecChannel.h | 92 - .../device/audio-looprec/AUDDLoopRecDriver.c | 493 -- .../device/audio-looprec/AUDDLoopRecDriver.h | 163 - .../AUDDLoopRecDriverDescriptors.c | 1461 ---- .../AUDDLoopRecDriverDescriptors.h | 148 - .../device/audio-looprec/audio-looprec.dir | 51 - .../device/audio-speaker/AUDDSpeakerChannel.c | 129 - .../device/audio-speaker/AUDDSpeakerChannel.h | 92 - .../device/audio-speaker/AUDDSpeakerDriver.c | 378 - .../device/audio-speaker/AUDDSpeakerDriver.h | 201 - .../AUDDSpeakerDriverDescriptors.c | 620 -- .../AUDDSpeakerDriverDescriptors.h | 146 - .../device/audio-speaker/USBAudioSpeaker.png | Bin 3711 -> 0 bytes .../USBAudioSpeakerDescriptors.png | Bin 8026 -> 0 bytes .../audio-speaker/USBAudioSpeakerRecorder.png | Bin 5053 -> 0 bytes .../USBAudioSpeakerRecorderDescriptors.png | Bin 10906 -> 0 bytes .../device/audio-speaker/audio-speaker.dir | 617 -- .../libraries/usb/device/ccid/cciddriver.c | 1503 ---- .../libraries/usb/device/ccid/cciddriver.h | 378 - .../usb/device/ccid/cciddriverdescriptors.h | 152 - .../usb/device/cdc-serial/CDCDSerialDriver.c | 300 - .../usb/device/cdc-serial/CDCDSerialDriver.h | 117 - .../cdc-serial/CDCDSerialDriverDescriptors.c | 661 -- .../cdc-serial/CDCDSerialDriverDescriptors.h | 77 - .../usb/device/cdc-serial/CDCarchitecture.png | Bin 28223 -> 0 bytes .../device/cdc-serial/USB-SerialConverter.png | Bin 10177 -> 0 bytes .../usb/device/cdc-serial/cdc-serial.dir | 646 -- .../usb/device/cdc-serial/drv/6119.inf | 45 - .../usb/device/cdc-serial/drv/drv.dir | 41 - .../usb/device/composite/AUDDFunctionDriver.c | 282 - .../usb/device/composite/AUDDFunctionDriver.h | 105 - .../composite/AUDDFunctionDriverDescriptors.h | 69 - .../usb/device/composite/CDCDFunctionDriver.c | 337 - .../usb/device/composite/CDCDFunctionDriver.h | 128 - .../composite/CDCDFunctionDriverDescriptors.h | 65 - .../usb/device/composite/CDCHIDDDriver.c | 227 - .../usb/device/composite/CDCHIDDDriver.h | 78 - .../composite/CDCHIDDDriverDescriptors.c | 592 -- .../composite/CDCHIDDDriverDescriptors.h | 70 - .../usb/device/composite/CDCMSDDDriver.c | 213 - .../usb/device/composite/CDCMSDDDriver.h | 77 - .../composite/CDCMSDDDriverDescriptors.c | 568 -- .../composite/CDCMSDDDriverDescriptors.h | 71 - .../usb/device/composite/COMPOSITEDDriver.c | 292 - .../usb/device/composite/COMPOSITEDDriver.h | 93 - .../composite/COMPOSITEDDriverDescriptors.c | 954 --- .../composite/COMPOSITEDDriverDescriptors.h | 61 - .../usb/device/composite/DUALCDCDDriver.c | 189 - .../usb/device/composite/DUALCDCDDriver.h | 77 - .../composite/DUALCDCDDriverDescriptors.c | 702 -- .../composite/DUALCDCDDriverDescriptors.h | 72 - .../usb/device/composite/HIDDFunctionDriver.c | 477 -- .../usb/device/composite/HIDDFunctionDriver.h | 64 - .../composite/HIDDFunctionDriverDescriptors.c | 118 - .../composite/HIDDFunctionDriverDescriptors.h | 86 - .../usb/device/composite/HIDMSDDDriver.c | 227 - .../usb/device/composite/HIDMSDDDriver.h | 79 - .../composite/HIDMSDDDriverDescriptors.c | 449 -- .../composite/HIDMSDDDriverDescriptors.h | 66 - .../usb/device/composite/MSDDFunctionDriver.c | 327 - .../usb/device/composite/MSDDFunctionDriver.h | 72 - .../composite/MSDDFunctionDriverDescriptors.h | 69 - .../composite/drv/CompositeCDCSerial.inf | 57 - .../usb/device/composite/drv/drv.dir | 45 - .../core/USBDCallbacks_RequestReceived.c | 49 - .../usb/device/core/USBDCallbacks_Reset.c | 47 - .../usb/device/core/USBDCallbacks_Resumed.c | 54 - .../usb/device/core/USBDCallbacks_Suspended.c | 51 - .../usb/device/core/USBDDriverCb_CfgChanged.c | 49 - .../core/USBDDriverCb_IfSettingChanged.c | 52 - .../libraries/usb/device/core/USBD_OTGHS.c | 1696 ---- .../libraries/usb/device/core/USBD_UDPHS.c | 2360 ------ .../libraries/usb/device/core/core.dir | 41 - src/ersky9x/libraries/usb/device/device.dir | 655 -- .../usb/device/hid-keyboard/HIDClassArch.png | Bin 3495 -> 0 bytes .../hid-keyboard/HIDDKeyboardCallbacks.h | 57 - .../HIDDKeyboardCallbacks_LedsChanged.c | 59 - .../device/hid-keyboard/HIDDKeyboardDriver.c | 477 -- .../device/hid-keyboard/HIDDKeyboardDriver.h | 75 - .../HIDDKeyboardDriverDescriptors.c | 420 - .../HIDDKeyboardDriverDescriptors.h | 114 - .../hid-keyboard/HIDDKeyboardInputReport.c | 164 - .../hid-keyboard/HIDDKeyboardInputReport.h | 149 - .../hid-keyboard/HIDDKeyboardOutputReport.c | 94 - .../hid-keyboard/HIDDKeyboardOutputReport.h | 96 - .../usb/device/hid-keyboard/hid-keyboard.dir | 787 -- .../usb/device/hid-mouse/HIDDMouseDriver.c | 392 - .../usb/device/hid-mouse/HIDDMouseDriver.h | 107 - .../hid-mouse/HIDDMouseDriverDescriptors.c | 385 - .../hid-mouse/HIDDMouseDriverDescriptors.h | 86 - .../device/hid-mouse/HIDDMouseInputReport.c | 72 - .../device/hid-mouse/HIDDMouseInputReport.h | 93 - .../usb/device/hid-mouse/hid-mouse.dir | 544 -- .../device/hid-transfer/HIDDTransferDriver.c | 453 -- .../device/hid-transfer/HIDDTransferDriver.h | 87 - .../hid-transfer/HIDDTransferDriverDesc.c | 417 - .../hid-transfer/HIDDTransferDriverDesc.h | 87 - .../usb/device/hid-transfer/hid-transfer.dir | 473 -- .../usb/device/massstorage/MSDAppArch.png | Bin 7248 -> 0 bytes .../usb/device/massstorage/MSDDriverArch.png | Bin 4889 -> 0 bytes .../device/massstorage/MSDDriverClasses.png | Bin 12031 -> 0 bytes .../device/massstorage/MSDDriverStates.png | Bin 7920 -> 0 bytes .../usb/device/massstorage/MSDMediaArch.png | Bin 3622 -> 0 bytes .../usb/device/massstorage/massstorage.dir | 1005 --- src/ersky9x/libraries/usb/host/core/USBH.h | 73 - src/ersky9x/libraries/usb/host/core/USB_UHP.c | 223 - src/ersky9x/libraries/usb/host/ohci/ohci.c | 124 - src/ersky9x/libraries/usb/host/ohci/ohci.h | 139 - src/ersky9x/libraries/usb/otg/compiler.h | 65 - src/ersky9x/libraries/usb/otg/usb_drv.c | 246 - src/ersky9x/libraries/usb/otg/usb_drv.h | 859 -- src/ersky9x/libraries/usb/otg/usb_host_enum.c | 670 -- src/ersky9x/libraries/usb/otg/usb_host_enum.h | 329 - .../usb/otg/usb_host_enum_with_srp_hnp.c | 754 -- src/ersky9x/libraries/usb/otg/usb_host_task.c | 1260 --- src/ersky9x/libraries/usb/otg/usb_host_task.h | 230 - .../usb/otg/usb_host_task_with_srp_hnp.c | 1493 ---- src/ersky9x/libraries/usb/otg/usb_task.c | 999 --- src/ersky9x/libraries/usb/otg/usb_task.h | 232 - .../libraries/usb/otg/usb_task_host_only.c | 287 - .../libraries/usb/otg/usb_task_with_SRP_HNP.c | 852 -- src/ersky9x/libraries/usb/usb.dir | 532 -- src/ersky9x/massstorage.cpp | 154 + .../common/core/USBConfigurationDescriptor.c | 0 .../common/core/USBConfigurationDescriptor.h | 0 .../usb/common/core/USBDeviceDescriptor.h | 0 .../core/USBDeviceQualifierDescriptor.h | 0 .../usb/common/core/USBEndpointDescriptor.c | 0 .../usb/common/core/USBEndpointDescriptor.h | 0 .../usb/common/core/USBFeatureRequest.c | 0 .../usb/common/core/USBFeatureRequest.h | 0 .../usb/common/core/USBGenericDescriptor.c | 0 .../usb/common/core/USBGenericDescriptor.h | 0 .../usb/common/core/USBGenericRequest.c | 0 .../usb/common/core/USBGenericRequest.h | 0 .../usb/common/core/USBGetDescriptorRequest.c | 0 .../usb/common/core/USBGetDescriptorRequest.h | 0 .../core/USBInterfaceAssociationDescriptor.h | 0 .../usb/common/core/USBInterfaceDescriptor.h | 0 .../usb/common/core/USBInterfaceRequest.c | 0 .../usb/common/core/USBInterfaceRequest.h | 0 .../usb/common/core/USBIrqHandler.c | 0 .../usb/common/core/USBIrqHandler.h | 0 .../usb/common/core/USBSetAddressRequest.c | 0 .../usb/common/core/USBSetAddressRequest.h | 0 .../common/core/USBSetConfigurationRequest.c | 0 .../common/core/USBSetConfigurationRequest.h | 0 .../usb/common/core/USBStringDescriptor.h | 0 .../common/massstorage/MSDeviceDescriptor.h | 0 .../massstorage/MSInterfaceDescriptor.h | 0 .../{libraries => }/usb/device/core/USBD.h | 0 .../device/core/USBDCallbacks.c} | 46 +- .../usb/device/core/USBDCallbacks.h | 0 .../usb/device/core/USBDDriver.c | 2 +- .../usb/device/core/USBDDriver.h | 0 .../usb/device/core/USBDDriverCallbacks.h | 0 .../usb/device/core/USBDDriverDescriptors.h | 0 .../usb/device/core/USBD_UDP.c | 118 +- .../usb/device/massstorage/MSD.h | 0 .../usb/device/massstorage/MSDDStateMachine.c | 0 .../usb/device/massstorage/MSDDStateMachine.h | 2 +- .../usb/device/massstorage/MSDDriver.c | 4 +- .../usb/device/massstorage/MSDDriver.h | 0 .../device/massstorage/MSDDriverDescriptors.c | 0 .../device/massstorage/MSDDriverDescriptors.h | 0 .../usb/device/massstorage/MSDIOFifo.h | 0 .../usb/device/massstorage/MSDLun.c | 2 +- .../usb/device/massstorage/MSDLun.h | 2 +- .../usb/device/massstorage/SBC.h | 0 .../usb/device/massstorage/SBCMethods.c | 0 .../usb/device/massstorage/SBCMethods.h | 0 .../device/massstorage/_MSDIOFifo.c} | 0 src/general_menus.cpp | 32 +- src/logs.cpp | 31 +- src/open9x.cpp | 119 +- src/sdcard.h | 12 + 429 files changed, 467 insertions(+), 78062 deletions(-) rename src/ersky9x/{libraries/memories => }/MEDSdcard.c (100%) rename src/ersky9x/{libraries/memories => }/Media.h (100%) delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/AT91SAM3S4.h delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/chip.h delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/flash.icf delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/flash.lds delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/sram.icf delete mode 100644 src/ersky9x/libraries/board/at91sam3s4/sram.lds delete mode 100644 src/ersky9x/libraries/board/board.h delete mode 100644 src/ersky9x/libraries/board/board_cstartup_iar.c delete mode 100644 src/ersky9x/libraries/board/board_lowlevel.c delete mode 100644 src/ersky9x/libraries/board/board_lowlevel.h delete mode 100644 src/ersky9x/libraries/board/board_memories.c delete mode 100644 src/ersky9x/libraries/board/board_memories.h delete mode 100644 src/ersky9x/libraries/board/exceptions.c delete mode 100644 src/ersky9x/libraries/board/exceptions.h delete mode 100644 src/ersky9x/libraries/cmsis/core_cm3.c delete mode 100644 src/ersky9x/libraries/cmsis/core_cm3.h delete mode 100644 src/ersky9x/libraries/components/ads7843/ads7843.c delete mode 100644 src/ersky9x/libraries/components/ads7843/ads7843.h delete mode 100644 src/ersky9x/libraries/components/wm8731/wm8731.c delete mode 100644 src/ersky9x/libraries/components/wm8731/wm8731.h delete mode 100644 src/ersky9x/libraries/drivers/acc/acc.c delete mode 100644 src/ersky9x/libraries/drivers/acc/acc.h delete mode 100644 src/ersky9x/libraries/drivers/adc/adc.c delete mode 100644 src/ersky9x/libraries/drivers/adc/adc.h delete mode 100644 src/ersky9x/libraries/drivers/async/async.c delete mode 100644 src/ersky9x/libraries/drivers/async/async.h delete mode 100644 src/ersky9x/libraries/drivers/crccu/crccu.c delete mode 100644 src/ersky9x/libraries/drivers/crccu/crccu.h delete mode 100644 src/ersky9x/libraries/drivers/dacc/dacc.c delete mode 100644 src/ersky9x/libraries/drivers/dacc/dacc.h delete mode 100644 src/ersky9x/libraries/drivers/efc/efc.c delete mode 100644 src/ersky9x/libraries/drivers/efc/efc.h delete mode 100644 src/ersky9x/libraries/drivers/flash/flashd.c delete mode 100644 src/ersky9x/libraries/drivers/flash/flashd.h delete mode 100644 src/ersky9x/libraries/drivers/lcd/color.h delete mode 100644 src/ersky9x/libraries/drivers/lcd/draw.c delete mode 100644 src/ersky9x/libraries/drivers/lcd/draw.h delete mode 100644 src/ersky9x/libraries/drivers/lcd/font.c delete mode 100644 src/ersky9x/libraries/drivers/lcd/font.h delete mode 100644 src/ersky9x/libraries/drivers/lcd/font10x14.h delete mode 100644 src/ersky9x/libraries/drivers/lcd/lcdd.c delete mode 100644 src/ersky9x/libraries/drivers/lcd/lcdd.h delete mode 100644 src/ersky9x/libraries/drivers/pio/pio.c delete mode 100644 src/ersky9x/libraries/drivers/pio/pio.h delete mode 100644 src/ersky9x/libraries/drivers/pio/pio_it.c delete mode 100644 src/ersky9x/libraries/drivers/pio/pio_it.h delete mode 100644 src/ersky9x/libraries/drivers/pio/pio_keypad.c delete mode 100644 src/ersky9x/libraries/drivers/pio/pio_keypad.h delete mode 100644 src/ersky9x/libraries/drivers/pmc/pmc.c delete mode 100644 src/ersky9x/libraries/drivers/pmc/pmc.h delete mode 100644 src/ersky9x/libraries/drivers/pwmc/pwmc.c delete mode 100644 src/ersky9x/libraries/drivers/pwmc/pwmc.h delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchGnuCfg3SRevB.a delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.a delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.txt delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.a delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.txt delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.a delete mode 100644 src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.txt delete mode 100644 src/ersky9x/libraries/drivers/rtc/rtc.c delete mode 100644 src/ersky9x/libraries/drivers/rtc/rtc.h delete mode 100644 src/ersky9x/libraries/drivers/rtt/rtt.c delete mode 100644 src/ersky9x/libraries/drivers/rtt/rtt.h delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/at45d.c delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/at45d.h delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/spi_at45.c delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/spi_at45.h delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/spi_pdc.c delete mode 100644 src/ersky9x/libraries/drivers/spi-flash/spi_pdc.h delete mode 100644 src/ersky9x/libraries/drivers/spi/spi.c delete mode 100644 src/ersky9x/libraries/drivers/spi/spi.h delete mode 100644 src/ersky9x/libraries/drivers/ssc/ssc.c delete mode 100644 src/ersky9x/libraries/drivers/ssc/ssc.h delete mode 100644 src/ersky9x/libraries/drivers/tc/tc.c delete mode 100644 src/ersky9x/libraries/drivers/tc/tc.h delete mode 100644 src/ersky9x/libraries/drivers/tsd/tsd.h delete mode 100644 src/ersky9x/libraries/drivers/tsd/tsd_ads7843.c delete mode 100644 src/ersky9x/libraries/drivers/tsd/tsd_ads7843.h delete mode 100644 src/ersky9x/libraries/drivers/tsd/tsd_com.c delete mode 100644 src/ersky9x/libraries/drivers/tsd/tsd_com.h delete mode 100644 src/ersky9x/libraries/drivers/twi/twi.c delete mode 100644 src/ersky9x/libraries/drivers/twi/twi.h delete mode 100644 src/ersky9x/libraries/drivers/twi/twid.c delete mode 100644 src/ersky9x/libraries/drivers/twi/twid.h delete mode 100644 src/ersky9x/libraries/drivers/usart/uart_console.c delete mode 100644 src/ersky9x/libraries/drivers/usart/uart_console.h delete mode 100644 src/ersky9x/libraries/drivers/usart/usart.c delete mode 100644 src/ersky9x/libraries/drivers/usart/usart.h delete mode 100644 src/ersky9x/libraries/drivers/utility/assert.h delete mode 100644 src/ersky9x/libraries/drivers/utility/bitbanding.h delete mode 100644 src/ersky9x/libraries/drivers/utility/bmp.c delete mode 100644 src/ersky9x/libraries/drivers/utility/bmp.h delete mode 100644 src/ersky9x/libraries/drivers/utility/clock.c delete mode 100644 src/ersky9x/libraries/drivers/utility/clock.h delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.c delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.h delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/aes_reference.c delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/aes_reference.h delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/encryption.h delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.c delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.h delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.c delete mode 100644 src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.h delete mode 100644 src/ersky9x/libraries/drivers/utility/hamming.c delete mode 100644 src/ersky9x/libraries/drivers/utility/hamming.h delete mode 100644 src/ersky9x/libraries/drivers/utility/iap.c delete mode 100644 src/ersky9x/libraries/drivers/utility/iap.h delete mode 100644 src/ersky9x/libraries/drivers/utility/led.c delete mode 100644 src/ersky9x/libraries/drivers/utility/led.h delete mode 100644 src/ersky9x/libraries/drivers/utility/math.c delete mode 100644 src/ersky9x/libraries/drivers/utility/math.h delete mode 100644 src/ersky9x/libraries/drivers/utility/rand.c delete mode 100644 src/ersky9x/libraries/drivers/utility/rand.h delete mode 100644 src/ersky9x/libraries/drivers/utility/retarget.c delete mode 100644 src/ersky9x/libraries/drivers/utility/stdio.c delete mode 100644 src/ersky9x/libraries/drivers/utility/string.c delete mode 100644 src/ersky9x/libraries/drivers/utility/trace.c delete mode 100644 src/ersky9x/libraries/drivers/utility/trace.h delete mode 100644 src/ersky9x/libraries/drivers/utility/util.c delete mode 100644 src/ersky9x/libraries/drivers/utility/util.h delete mode 100644 src/ersky9x/libraries/drivers/utility/utility.dir delete mode 100644 src/ersky9x/libraries/drivers/utility/video.c delete mode 100644 src/ersky9x/libraries/drivers/utility/video.h delete mode 100644 src/ersky9x/libraries/drivers/utility/wav.c delete mode 100644 src/ersky9x/libraries/drivers/utility/wav.h delete mode 100644 src/ersky9x/libraries/drivers/wdt/wdt.c delete mode 100644 src/ersky9x/libraries/drivers/wdt/wdt.h delete mode 100644 src/ersky9x/libraries/memories/.project delete mode 100644 src/ersky9x/libraries/memories/Media.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_color.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_color.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_colors.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_colors.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_errors.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_font.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_font.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_point.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_point.h delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_size.c delete mode 100644 src/ersky9x/libraries/sam-gui/common/sam_gui_size.h delete mode 100644 src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.c delete mode 100644 src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.h delete mode 100644 src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.c delete mode 100644 src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.h delete mode 100644 src/ersky9x/libraries/sam-gui/disp/disp_backend.c delete mode 100644 src/ersky9x/libraries/sam-gui/disp/disp_backend.h delete mode 100644 src/ersky9x/libraries/sam-gui/disp/disp_core.c delete mode 100644 src/ersky9x/libraries/sam-gui/disp/disp_core.h delete mode 100644 src/ersky9x/libraries/sam-gui/docs/pcx.txt delete mode 100644 src/ersky9x/libraries/sam-gui/file/file_fs.h delete mode 100644 src/ersky9x/libraries/sam-gui/porting/sam_gui_embos.c delete mode 100644 src/ersky9x/libraries/sam-gui/porting/sam_gui_freertos.c delete mode 100644 src/ersky9x/libraries/sam-gui/porting/sam_gui_nuttx.c delete mode 100644 src/ersky9x/libraries/sam-gui/porting/sam_gui_porting.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour_default.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.h delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.c delete mode 100644 src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.h delete mode 100644 src/ersky9x/libraries/usb/USBFrameworkArchitecture.png delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDControlInterfaceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDDataEndpointDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDDeviceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDEndpointDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.c delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDFormatTypeOneDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDGenericDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.c delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDHeaderDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDInputTerminalDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDOutputTerminalDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/AUDStreamingInterfaceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/audio/audio.dir delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCAbstractControlManagementDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCCallManagementDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCDataInterfaceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCDeviceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCGenericDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCGenericRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCHeaderDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.c delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.c delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/CDCUnionDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/cdc/cdc.dir delete mode 100644 src/ersky9x/libraries/usb/common/common.dir delete mode 100644 src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.c delete mode 100644 src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.h delete mode 100644 src/ersky9x/libraries/usb/common/core/core.dir delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDButton.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDDeviceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDGenericDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDGenericDesktop.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDGenericRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.c delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDInterfaceDescriptor.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDKeypad.c delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDKeypad.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDLeds.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDReport.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDReportRequest.c delete mode 100644 src/ersky9x/libraries/usb/common/hid/HIDReportRequest.h delete mode 100644 src/ersky9x/libraries/usb/common/hid/hid.dir delete mode 100644 src/ersky9x/libraries/usb/device/USBDCallbackInvocationFlowchart.png delete mode 100644 src/ersky9x/libraries/usb/device/USBDeviceStateDiagram.png delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecChannel.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecChannel.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-looprec/audio-looprec.dir delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeaker.png delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerDescriptors.png delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorder.png delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorderDescriptors.png delete mode 100644 src/ersky9x/libraries/usb/device/audio-speaker/audio-speaker.dir delete mode 100644 src/ersky9x/libraries/usb/device/ccid/cciddriver.c delete mode 100644 src/ersky9x/libraries/usb/device/ccid/cciddriver.h delete mode 100644 src/ersky9x/libraries/usb/device/ccid/cciddriverdescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/CDCarchitecture.png delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/USB-SerialConverter.png delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/cdc-serial.dir delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/drv/6119.inf delete mode 100644 src/ersky9x/libraries/usb/device/cdc-serial/drv/drv.dir delete mode 100644 src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/composite/drv/CompositeCDCSerial.inf delete mode 100644 src/ersky9x/libraries/usb/device/composite/drv/drv.dir delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDCallbacks_RequestReceived.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDDriverCb_CfgChanged.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBD_OTGHS.c delete mode 100644 src/ersky9x/libraries/usb/device/core/USBD_UDPHS.c delete mode 100644 src/ersky9x/libraries/usb/device/core/core.dir delete mode 100644 src/ersky9x/libraries/usb/device/device.dir delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDClassArch.png delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks_LedsChanged.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-keyboard/hid-keyboard.dir delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-mouse/hid-mouse.dir delete mode 100644 src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.c delete mode 100644 src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.h delete mode 100644 src/ersky9x/libraries/usb/device/hid-transfer/hid-transfer.dir delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/MSDAppArch.png delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/MSDDriverArch.png delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/MSDDriverClasses.png delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/MSDDriverStates.png delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/MSDMediaArch.png delete mode 100644 src/ersky9x/libraries/usb/device/massstorage/massstorage.dir delete mode 100644 src/ersky9x/libraries/usb/host/core/USBH.h delete mode 100644 src/ersky9x/libraries/usb/host/core/USB_UHP.c delete mode 100644 src/ersky9x/libraries/usb/host/ohci/ohci.c delete mode 100644 src/ersky9x/libraries/usb/host/ohci/ohci.h delete mode 100644 src/ersky9x/libraries/usb/otg/compiler.h delete mode 100644 src/ersky9x/libraries/usb/otg/usb_drv.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_drv.h delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_enum.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_enum.h delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_enum_with_srp_hnp.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_task.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_task.h delete mode 100644 src/ersky9x/libraries/usb/otg/usb_host_task_with_srp_hnp.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_task.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_task.h delete mode 100644 src/ersky9x/libraries/usb/otg/usb_task_host_only.c delete mode 100644 src/ersky9x/libraries/usb/otg/usb_task_with_SRP_HNP.c delete mode 100644 src/ersky9x/libraries/usb/usb.dir create mode 100644 src/ersky9x/massstorage.cpp rename src/ersky9x/{libraries => }/usb/common/core/USBConfigurationDescriptor.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBConfigurationDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBDeviceDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBDeviceQualifierDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBEndpointDescriptor.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBEndpointDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBFeatureRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBFeatureRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGenericDescriptor.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGenericDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGenericRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGenericRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGetDescriptorRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBGetDescriptorRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBInterfaceAssociationDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBInterfaceDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBInterfaceRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBInterfaceRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBIrqHandler.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBIrqHandler.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBSetAddressRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBSetAddressRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBSetConfigurationRequest.c (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBSetConfigurationRequest.h (100%) rename src/ersky9x/{libraries => }/usb/common/core/USBStringDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/massstorage/MSDeviceDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/common/massstorage/MSInterfaceDescriptor.h (100%) rename src/ersky9x/{libraries => }/usb/device/core/USBD.h (100%) rename src/ersky9x/{libraries/usb/device/core/USBDCallbacks_Initialized.c => usb/device/core/USBDCallbacks.c} (73%) rename src/ersky9x/{libraries => }/usb/device/core/USBDCallbacks.h (100%) rename src/ersky9x/{libraries => }/usb/device/core/USBDDriver.c (97%) rename src/ersky9x/{libraries => }/usb/device/core/USBDDriver.h (100%) rename src/ersky9x/{libraries => }/usb/device/core/USBDDriverCallbacks.h (100%) rename src/ersky9x/{libraries => }/usb/device/core/USBDDriverDescriptors.h (100%) rename src/ersky9x/{libraries => }/usb/device/core/USBD_UDP.c (91%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSD.h (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDStateMachine.c (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDStateMachine.h (97%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDriver.c (96%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDriver.h (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDriverDescriptors.c (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDDriverDescriptors.h (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDIOFifo.h (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDLun.c (97%) rename src/ersky9x/{libraries => }/usb/device/massstorage/MSDLun.h (97%) rename src/ersky9x/{libraries => }/usb/device/massstorage/SBC.h (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/SBCMethods.c (100%) rename src/ersky9x/{libraries => }/usb/device/massstorage/SBCMethods.h (100%) rename src/ersky9x/{libraries/usb/device/massstorage/MSDIOFifo.c => usb/device/massstorage/_MSDIOFifo.c} (100%) diff --git a/src/Makefile b/src/Makefile index 1ae663fce..0eab6e307 100644 --- a/src/Makefile +++ b/src/Makefile @@ -431,16 +431,15 @@ ifeq ($(PCB), X9D) # X9D, so ... OPT = 2 CPPDEFS += -DPCBX9D -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 - EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/drivers CoOS/kernel CoOS/portable + EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable BOARDSRC = board_ersky9x.cpp SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c - SRC += ersky9x/libraries/usb/device/core/USBD_UDP.c ersky9x/libraries/drivers/pmc/pmc.c ersky9x/libraries/drivers/pio/pio.c ersky9x/libraries/drivers/pio/pio_it.c ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c ersky9x/libraries/usb/common/core/USBGenericRequest.c ersky9x/libraries/usb/device/massstorage/MSDDriver.c ersky9x/libraries/usb/device/core/USBDDriver.c ersky9x/libraries/usb/common/core/USBFeatureRequest.c ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c - SRC += ersky9x/libraries/usb/common/core/USBInterfaceRequest.c ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.c ersky9x/libraries/usb/common/core/USBSetAddressRequest.c ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.c ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.c ersky9x/libraries/usb/common/core/USBGenericDescriptor.c - SRC += ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c # TODO remove them - SRC += ersky9x/libraries/usb/device/massstorage/MSDLun.c ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c + SRC += ersky9x/usb/device/core/USBD_UDP.c ersky9x/usb/device/core/USBDDriver.c ersky9x/usb/device/core/USBDCallbacks.c + SRC += ersky9x/usb/device/massstorage/MSDDriver.c ersky9x/usb/device/massstorage/MSDDStateMachine.c ersky9x/usb/device/massstorage/MSDLun.c ersky9x/usb/device/massstorage/MSDDriverDescriptors.c ersky9x/usb/device/massstorage/SBCMethods.c + SRC += ersky9x/usb/common/core/USBEndpointDescriptor.c ersky9x/usb/common/core/USBGenericRequest.c ersky9x/usb/common/core/USBFeatureRequest.c ersky9x/usb/common/core/USBInterfaceRequest.c ersky9x/usb/common/core/USBGetDescriptorRequest.c ersky9x/usb/common/core/USBSetAddressRequest.c ersky9x/usb/common/core/USBSetConfigurationRequest.c ersky9x/usb/common/core/USBConfigurationDescriptor.c ersky9x/usb/common/core/USBGenericDescriptor.c SRC += ersky9x/syscalls.c - SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/MEDSdcard.c + SRC += ersky9x/MEDSdcard.c EEPROMSRC = eeprom_arm.cpp PULSESSRC = pulses_arm.cpp CPPSRC += ersky9x/audio.cpp haptic.cpp @@ -466,20 +465,19 @@ ifeq ($(PCB), ARM) # ARM, so ... OPT = 2 CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 - EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/drivers CoOS/kernel CoOS/portable + EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable BOARDSRC = board_ersky9x.cpp SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c - SRC += ersky9x/libraries/usb/device/core/USBD_UDP.c ersky9x/libraries/drivers/pmc/pmc.c ersky9x/libraries/drivers/pio/pio.c ersky9x/libraries/drivers/pio/pio_it.c ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c ersky9x/libraries/usb/common/core/USBGenericRequest.c ersky9x/libraries/usb/device/massstorage/MSDDriver.c ersky9x/libraries/usb/device/core/USBDDriver.c ersky9x/libraries/usb/common/core/USBFeatureRequest.c ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c - SRC += ersky9x/libraries/usb/common/core/USBInterfaceRequest.c ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.c ersky9x/libraries/usb/common/core/USBSetAddressRequest.c ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.c ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.c ersky9x/libraries/usb/common/core/USBGenericDescriptor.c - SRC += ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c # TODO remove them - SRC += ersky9x/libraries/usb/device/massstorage/MSDLun.c ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c + SRC += ersky9x/usb/device/core/USBD_UDP.c ersky9x/usb/device/core/USBDDriver.c ersky9x/usb/device/core/USBDCallbacks.c + SRC += ersky9x/usb/device/massstorage/MSDDriver.c ersky9x/usb/device/massstorage/MSDDStateMachine.c ersky9x/usb/device/massstorage/MSDLun.c ersky9x/usb/device/massstorage/MSDDriverDescriptors.c ersky9x/usb/device/massstorage/SBCMethods.c + SRC += ersky9x/usb/common/core/USBEndpointDescriptor.c ersky9x/usb/common/core/USBGenericRequest.c ersky9x/usb/common/core/USBFeatureRequest.c ersky9x/usb/common/core/USBInterfaceRequest.c ersky9x/usb/common/core/USBGetDescriptorRequest.c ersky9x/usb/common/core/USBSetAddressRequest.c ersky9x/usb/common/core/USBSetConfigurationRequest.c ersky9x/usb/common/core/USBConfigurationDescriptor.c ersky9x/usb/common/core/USBGenericDescriptor.c SRC += ersky9x/syscalls.c - SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/MEDSdcard.c + SRC += ersky9x/MEDSdcard.c EEPROMSRC = eeprom_arm.cpp PULSESSRC = pulses_arm.cpp CPPSRC += ersky9x/audio.cpp haptic.cpp - CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard_driver.cpp + CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard_driver.cpp ersky9x/massstorage.cpp ifeq ($(SDCARD), YES) SRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c ersky9x/diskio.c diff --git a/src/board_ersky9x.h b/src/board_ersky9x.h index 80d02e347..7b18cb69d 100644 --- a/src/board_ersky9x.h +++ b/src/board_ersky9x.h @@ -50,6 +50,8 @@ extern void sdInit(); extern void sdPoll10mS(); } +void usbMassStorage(); + #define PIN_ENABLE 0x001 #define PIN_PERIPHERAL 0x000 #define PIN_INPUT 0x002 @@ -87,8 +89,6 @@ extern uint32_t read_keys(); #define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10)) #define DBLKEYS_PRESSED_LFT_DWN(i) ((in & (0x40 + 0x08)) == (0x40 + 0x08)) -#define usbPlugged() (PIOC->PIO_PDSR & PIO_PC25) - #if defined(REVB) extern uint16_t Current_analogue; extern uint16_t Current_max; diff --git a/src/eeprom_arm.cpp b/src/eeprom_arm.cpp index d92859df5..995655a39 100644 --- a/src/eeprom_arm.cpp +++ b/src/eeprom_arm.cpp @@ -982,21 +982,26 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc) return SDCARD_ERROR(result); } - result = f_write(&archiveFile, &g_eeGeneral.myVers, 1, &written); - if (result != FR_OK) { + uint16_t size = File_system[i_fileSrc+1].size; + + *(uint32_t*)&buf[0] = O9X_FOURCC; + buf[4] = g_eeGeneral.myVers; + buf[5] = 'M'; + *(uint16_t*)&buf[6] = size; + + result = f_write(&archiveFile, buf, 8, &written); + if (result != FR_OK || written != 8) { + f_close(&archiveFile); return SDCARD_ERROR(result); } - uint16_t size = File_system[i_fileSrc+1].size ; read32_eeprom_data( (File_system[i_fileSrc+1].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&Eeprom_buffer.data.model_data, size) ; - result = f_write(&archiveFile, (uint8_t *)&Eeprom_buffer.data.model_data, size, &written); - if (result != FR_OK) { + f_close(&archiveFile); + if (result != FR_OK || written != size) { return SDCARD_ERROR(result); } - f_close(&archiveFile); - strcpy(statusLineMsg, PSTR("File ")); strcpy(statusLineMsg+5, &buf[sizeof(MODELS_PATH)]); showStatusLine(); @@ -1024,26 +1029,34 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) return SDCARD_ERROR(result); } - result = f_read(&restoreFile, (uint8_t *)buf, 1, &read); - if (result != FR_OK || read != 1) { - return SDCARD_ERROR(result); - } - - if ((uint8_t)buf[0] != EEPROM_VER) { - // TODO conversions + if (f_size(&restoreFile) < 8) { f_close(&restoreFile); return STR_INCOMPATIBLE; } + result = f_read(&restoreFile, (uint8_t *)buf, 8, &read); + if (result != FR_OK || read != 8) { + f_close(&restoreFile); + return SDCARD_ERROR(result); + } + + if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') { + f_close(&restoreFile); + return STR_INCOMPATIBLE; + } + + uint16_t size = max((uint16_t)sizeof(g_model), *(uint16_t*)&buf[6]); + if (eeModelExists(i_fileDst)) { eeDeleteModel(i_fileDst); } - result = f_read(&restoreFile, ( uint8_t *)&Eeprom_buffer.data.model_data, sizeof(g_model), &read); + memset((uint8_t *)&Eeprom_buffer.data.model_data, 0, sizeof(g_model)); + result = f_read(&restoreFile, ( uint8_t *)&Eeprom_buffer.data.model_data, size, &read); f_close(&restoreFile); - if (result != FR_OK) { - return SDCARD_ERROR(result); + if (result != FR_OK || read != read) { + return STR_INCOMPATIBLE; } // TODO flash saving ... @@ -1053,9 +1066,9 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) memset(ModelNames[i_fileDst], 0, sizeof(g_model.name)); Eeprom32_source_address = (uint8_t *)&Eeprom_buffer.data.model_data; // Get data from here - Eeprom32_data_size = sizeof(g_model) ; // This much - Eeprom32_file_index = i_fileDst + 1 ; // This file system entry - Eeprom32_process_state = E32_BLANKCHECK ; + Eeprom32_data_size = sizeof(g_model); // This much + Eeprom32_file_index = i_fileDst + 1; // This file system entry + Eeprom32_process_state = E32_BLANKCHECK; eeWaitFinished(); return NULL; diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index c40012405..b43f41405 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -578,17 +578,24 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc) return SDCARD_ERROR(result); } - result = f_write(&archiveFile, &g_eeGeneral.myVers, 1, &written); - if (result != FR_OK) { - return SDCARD_ERROR(result); - } - EFile theFile2; theFile2.openRd(FILE_MODEL(i_fileSrc)); + *(uint32_t*)&buf[0] = O9X_FOURCC; + buf[4] = g_eeGeneral.myVers; + buf[5] = 'M'; + *(uint16_t*)&buf[6] = theFile2.size(); + + result = f_write(&archiveFile, buf, 8, &written); + if (result != FR_OK || written != 8) { + f_close(&archiveFile); + return SDCARD_ERROR(result); + } + while ((len=theFile2.read((uint8_t *)buf, 15))) { result = f_write(&archiveFile, (uint8_t *)buf, len, &written); - if (result != FR_OK) { + if (result != FR_OK || written != len) { + f_close(&archiveFile); return SDCARD_ERROR(result); } } @@ -613,13 +620,18 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) return SDCARD_ERROR(result); } - result = f_read(&restoreFile, (uint8_t *)buf, 1, &read); - if (result != FR_OK || read != 1) { + if (f_size(&restoreFile) < 8) { + f_close(&restoreFile); + return STR_INCOMPATIBLE; + } + + result = f_read(&restoreFile, (uint8_t *)buf, 8, &read); + if (result != FR_OK || read != 8) { + f_close(&restoreFile); return SDCARD_ERROR(result); } - if ((uint8_t)buf[0] != EEPROM_VER) { - // TODO conversions + if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') { f_close(&restoreFile); return STR_INCOMPATIBLE; } @@ -634,12 +646,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) result = f_read(&restoreFile, (uint8_t *)buf, 15, &read); if (result != FR_OK) { s_sync_write = false; + f_close(&restoreFile); return SDCARD_ERROR(result); } if (read > 0) { theFile.write((uint8_t *)buf, read); if (write_errno() != 0) { s_sync_write = false; + f_close(&restoreFile); return STR_EEPROMOVERFLOW; } } diff --git a/src/ersky9x/libraries/memories/MEDSdcard.c b/src/ersky9x/MEDSdcard.c similarity index 100% rename from src/ersky9x/libraries/memories/MEDSdcard.c rename to src/ersky9x/MEDSdcard.c diff --git a/src/ersky9x/libraries/memories/Media.h b/src/ersky9x/Media.h similarity index 100% rename from src/ersky9x/libraries/memories/Media.h rename to src/ersky9x/Media.h diff --git a/src/ersky9x/audio.cpp b/src/ersky9x/audio.cpp index 53bf34162..b9d42e7a7 100644 --- a/src/ersky9x/audio.cpp +++ b/src/ersky9x/audio.cpp @@ -428,7 +428,6 @@ void AudioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlag { CoEnterMutexSection(audioMutex); - if (tFlags & PLAY_SOUND_VARIO) { background.freq = tFreq * 2; background.duration = tLen; @@ -496,6 +495,17 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id) CoLeaveMutexSection(audioMutex); #endif } + +void AudioQueue::stopSD() +{ + sdAvailableAudioFiles = 0; + + CoEnterMutexSection(audioMutex); + widx = ridx; // clean the queue + CoLeaveMutexSection(audioMutex); + + play(0, 0, 100, PLAY_NOW); // insert a 100ms pause +} #endif void audioEvent(uint8_t e, uint8_t f) diff --git a/src/ersky9x/audio.h b/src/ersky9x/audio.h index 8c667f669..5abb7bc1d 100644 --- a/src/ersky9x/audio.h +++ b/src/ersky9x/audio.h @@ -77,6 +77,8 @@ class AudioQueue { void pause(uint8_t tLen); + void stopSD(); + bool isPlaying(uint8_t id); bool busy() diff --git a/src/ersky9x/board.h b/src/ersky9x/board.h index 6f9d5fcae..019b5cc5d 100644 --- a/src/ersky9x/board.h +++ b/src/ersky9x/board.h @@ -31,6 +31,8 @@ * */ +// TODO merge this file with board_ersky9x.h + #ifndef board_h #define board_h @@ -89,7 +91,7 @@ #define BOARD_MAINOSC 12000000 /// Master clock frequency (when using board_lowlevel.c). -#define BOARD_MCK 64000000 +// #define BOARD_MCK 64000000 //------------------------------------------------------------------------------ // ADC @@ -358,6 +360,8 @@ #define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} #endif +#define usbPlugged() (PIOC->PIO_PDSR & PIO_PC25) + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ @@ -539,56 +543,12 @@ extern uint32_t transSpeed; #define SD_CSD_BLOCKNR_HC(pSd) ((SD_CSD_C_SIZE_HC(pSd) + 1) * 1024) -/* -#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \ - PIN_EBI_PSRAM_ADDR_BUS, PIN_EBI_PSRAM_NBS, PIN_EBI_A1 -*/ +#define SD_IS_HC() (Cmd_A41_resp & OCR_SD_CCS) +#define SD_GET_BLOCKNR() (SD_IS_HC() ? (SD_CSD_BLOCKNR_HC(Card_CSD)) : (SD_CSD_BLOCKNR(Card_CSD))) -/** Indicates board has an ILI9325 external component to manage LCD. */ -#define BOARD_LCD_ILI9325 +#define SD_GET_SPEED() (transSpeed) -/** LCD pins definition. */ -#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, \ - PIN_EBI_NCS1, PIN_EBI_LCD_RS -/** Backlight pin definition. */ -#define BOARD_BACKLIGHT_PIN {1 << 13, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT} -/** Define ILI9325 base address. */ -#define BOARD_LCD_BASE 0x61000000 -/** Define ILI9325 register select signal. */ -#define BOARD_LCD_RS (1 << 1) -/** Display width in pixels. */ -#define BOARD_LCD_WIDTH 240 -/** Display height in pixels. */ -#define BOARD_LCD_HEIGHT 320 - -/** Indicates board has an ADS7843 external component to manage Touch Screen */ -#define BOARD_TSC_ADS7843 - -#ifdef BOARD_REV_A -/** Touchscreen controller IRQ pin definition. */ -#define PIN_TCS_IRQ {PIO_PA4, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE} -#define PIN_TCS_IRQ_WUP_ID (1 << 3) -/** Touchscreen controller Busy pin definition. */ -#define PIN_TCS_BUSY {PIO_PA5, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP} -#endif -#ifdef BOARD_REV_B -/** Touchscreen controller IRQ pin definition. */ -#define PIN_TCS_IRQ {PIO_PA16, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE} -#define PIN_TCS_IRQ_WUP_ID (1 << 15) -/** Touchscreen controller Busy pin definition. */ -#define PIN_TCS_BUSY {PIO_PA17, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP} -#endif - -/** Base address of SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_BASE SPI -/** Identifier of SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_ID ID_SPI -/** Pins of the SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_PINS PINS_SPI -/** Chip select connected to the touchscreen controller. */ -#define BOARD_TSC_NPCS 0 -/** Chip select pin connected to the touchscreen controller. */ -#define BOARD_TSC_NPCS_PIN PIN_SPI_NPCS0_PA11 +#define SD_GET_SIZE_MB() (SD_GET_BLOCKNR() / 2) //------------------------------------------------------------------------------ diff --git a/src/ersky9x/diskio.c b/src/ersky9x/diskio.c index 6f2244b50..f1359b46d 100644 --- a/src/ersky9x/diskio.c +++ b/src/ersky9x/diskio.c @@ -38,6 +38,7 @@ /* are platform dependent. */ /*-----------------------------------------------------------------------*/ +#include #include "board.h" #include "debug.h" #include "../FatFs/diskio.h" @@ -146,9 +147,9 @@ uint32_t GetTransSpeedValue() { // CSD register, TRANS_SPEED bit const unsigned int units[4] = {10, 100, 1000, 10000 }; // *Kbit/s - const unsigned int values_emmc[16] = {0, 10, 12, 13, 15, 20, +/* const unsigned int values_emmc[16] = {0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, - 55, 60, 70, 80}; + 55, 60, 70, 80}; */ const unsigned int values_sdmmc[16] = {0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80}; @@ -1011,7 +1012,7 @@ void sdPoll10mS() break; case SD_ST_DATA: - if (f_mount(0, &g_FATFS_Obj) == FR_OK) { + if (!usbPlugged() && f_mount(0, &g_FATFS_Obj) == FR_OK) { retrieveAvailableAudioFiles(); Card_state = SD_ST_MOUNTED; } @@ -1115,7 +1116,6 @@ uint32_t sd_read_block(uint32_t block_no, uint32_t *data) while (((status & STATUS_READY_FOR_DATA) == 0) || ((status & STATUS_STATE) != STATUS_TRAN) ); - // Block size = 512, nblocks = 1 HSMCI->HSMCI_BLKR = ((512) << 16) | 1; HSMCI->HSMCI_MR = (HSMCI->HSMCI_MR & (~(HSMCI_MR_BLKLEN_Msk|HSMCI_MR_FBYTE))) | (HSMCI_MR_PDCMODE|HSMCI_MR_WRPROOF|HSMCI_MR_RDPROOF) | (512 << 16); @@ -1124,9 +1124,13 @@ uint32_t sd_read_block(uint32_t block_no, uint32_t *data) HSMCI->HSMCI_RCR = 512 / 4; HSMCI->HSMCI_PTCR = HSMCI_PTCR_RXTEN; HSMCI->HSMCI_CMDR = SD_READ_SINGLE_BLOCK; - + + while (!(HSMCI->HSMCI_SR & HSMCI_SR_CMDRDY)); + + (void) HSMCI->HSMCI_RSPR[0]; + while (1) { - if ((HSMCI->HSMCI_SR & (HSMCI_SR_ENDRX|HSMCI_SR_XFRDONE|HSMCI_SR_CMDRDY)) == (HSMCI_SR_ENDRX|HSMCI_SR_XFRDONE|HSMCI_SR_CMDRDY)) { + if ((HSMCI->HSMCI_SR & (HSMCI_SR_ENDRX|HSMCI_SR_XFRDONE)) == (HSMCI_SR_ENDRX|HSMCI_SR_XFRDONE)) { result = 1; break; } @@ -1137,8 +1141,6 @@ uint32_t sd_read_block(uint32_t block_no, uint32_t *data) HSMCI->HSMCI_MR &= ~(uint32_t)HSMCI_MR_PDCMODE; HSMCI->HSMCI_PTCR = HSMCI_PTCR_RXTDIS | HSMCI_PTCR_TXTDIS; - (void) HSMCI->HSMCI_RSPR[0]; - // TRACE_ERROR("ok %.2X %.4Xd\n\r", HSMCI->HSMCI_SR, HSMCI->HSMCI_RSPR[0]); return result; @@ -1169,16 +1171,16 @@ uint32_t sd_write_block( uint32_t block_no, uint32_t *data ) while (!(HSMCI->HSMCI_SR & HSMCI_SR_CMDRDY)); + (void) HSMCI->HSMCI_RSPR[0]; + HSMCI->HSMCI_PTCR = HSMCI_PTCR_TXTEN; while (1) { - if ((HSMCI->HSMCI_SR & (HSMCI_SR_NOTBUSY|HSMCI_SR_XFRDONE|HSMCI_SR_CMDRDY)) == (HSMCI_SR_NOTBUSY|HSMCI_SR_XFRDONE|HSMCI_SR_CMDRDY)) { + if ((HSMCI->HSMCI_SR & (HSMCI_SR_NOTBUSY|HSMCI_SR_XFRDONE)) == (HSMCI_SR_NOTBUSY|HSMCI_SR_XFRDONE)) { result = 1; break; } } - - (void) HSMCI->HSMCI_RSPR[0]; } /* Disable PDC */ @@ -1309,13 +1311,16 @@ DRESULT disk_read ( ) { uint32_t result ; + BYTE copy[512]; + if (drv || !count) return RES_PARERR; if ( sd_card_ready() == 0 ) return RES_NOTRDY; do { - result = sd_read_block( sector, ( uint32_t *)buff ) ; + result = sd_read_block( sector, (uint32_t *)copy) ; if (result) { + memcpy(buff, copy, 512); sector += 1 ; buff += 512 ; count -= 1 ; @@ -1352,7 +1357,6 @@ DRESULT disk_write ( uint32_t result ; BYTE copy[512]; - if (drv || !count) return RES_PARERR; if ( sd_card_ready() == 0 ) return RES_NOTRDY; @@ -1367,14 +1371,9 @@ DRESULT disk_write ( result = sd_write_block( sector, ( uint32_t *)copy ) ; - if (memcmp(copy, buff, 512)) - s_warning = "Mem overflow"; - sd_read_block( sector, ( uint32_t *)copy ) ; if (!memcmp(copy, buff, 512)) - /*s_warning = "Read != Write"; - else*/ break; else { TRACE_ERROR("Block %d ko SR=%.2X\r\n", sector, HSMCI->HSMCI_SR); diff --git a/src/ersky9x/libraries/board/at91sam3s4/AT91SAM3S4.h b/src/ersky9x/libraries/board/at91sam3s4/AT91SAM3S4.h deleted file mode 100644 index d2af5f483..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/AT91SAM3S4.h +++ /dev/null @@ -1,7010 +0,0 @@ -/* ---------------------------------------------------------------------------- */ -/* Atmel Microcontroller Software Support */ -/* ---------------------------------------------------------------------------- */ -/* Copyright (c) 2009, Atmel Corporation */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following condition is met: */ -/* */ -/* - Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the disclaimer below. */ -/* */ -/* Atmel's name may not be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ -/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ -/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ -/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ -/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ -/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ -/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ -/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* ---------------------------------------------------------------------------- */ -/* */ -/* File Name : AT91SAM3S.h */ -/* Object : AT91SAM3S definitions */ -/* Generated by : AT91 SW Application Group */ -/* Generated on : 2009-10-26 */ - -#ifndef AT91SAM3S_H -#define AT91SAM3S_H - -/** \addtogroup AT91SAM3S_definitions AT91SAM3S definitions - This file defines all structures and symbols for AT91SAM3S: - - registers and bitfields - - peripheral base address - - peripheral ID - - PIO definitions -*/ -/*@{*/ - -#ifdef __cplusplus - extern "C" { -#endif - -#ifndef __ASSEMBLY__ -#include -#ifndef __cplusplus -typedef volatile const uint32_t RoReg; /**< Read only 32-bit register (volatile const unsigned int) */ -#else -typedef volatile uint32_t RoReg; /**< Read only 32-bit register (volatile const unsigned int) */ -#endif -typedef volatile uint32_t WoReg; /**< Write only 32-bit register (volatile unsigned int) */ -typedef volatile uint32_t RwReg; /**< Read-Write 32-bit register (volatile unsigned int) */ -#define CAST(type, value) ((type *) value) -#define REG_ACCESS(type, address) (*(type*)address) /**< C code: Register value */ -#else -#define CAST(type, value) (value) -#define REG_ACCESS(type, address) (address) /**< Assembly code: Register address */ -#endif - -/* ***************************************************************************** */ -/* CMSIS DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_cmsis CMSIS Definitions */ - -/*@{*/ - -/** - * \brief Configuration of the Cortex-M3 Processor and Core Peripherals - */ -#define __MPU_PRESENT 0 /**< AT91SAM3S does not provide a MPU present or not */ -#define __NVIC_PRIO_BITS 4 /**< AT91SAM3S uses 4 Bits for the Priority Levels */ -#define __Vendor_SysTickConfig 0 /**< Set to 1 if different SysTick Config is used */ - -/**< Interrupt Number Definition */ -typedef enum IRQn -{ -/****** Cortex-M3 Processor Exceptions Numbers ***************************************/ - NonMaskableInt_IRQn = -14, /**< 2 Non Maskable Interrupt */ - MemoryManagement_IRQn = -12, /**< 4 Cortex-M3 Memory Management Interrupt */ - BusFault_IRQn = -11, /**< 5 Cortex-M3 Bus Fault Interrupt */ - UsageFault_IRQn = -10, /**< 6 Cortex-M3 Usage Fault Interrupt */ - SVCall_IRQn = -5, /**< 11 Cortex-M3 SV Call Interrupt */ - DebugMonitor_IRQn = -4, /**< 12 Cortex-M3 Debug Monitor Interrupt */ - PendSV_IRQn = -2, /**< 14 Cortex-M3 Pend SV Interrupt */ - SysTick_IRQn = -1, /**< 15 Cortex-M3 System Tick Interrupt */ -/****** AT91SAM3S specific Interrupt Numbers *****************************************/ - - SUPC_IRQn = 0, /**< 0 AT91SAM3S Supply Controller (SUPC) */ - RSTC_IRQn = 1, /**< 1 AT91SAM3S Reset Controller (RSTC) */ - RTC_IRQn = 2, /**< 2 AT91SAM3S Real Time Clock (RTC) */ - RTT_IRQn = 3, /**< 3 AT91SAM3S Real Time Timer (RTT) */ - WDT_IRQn = 4, /**< 4 AT91SAM3S Watchdog Timer (WDT) */ - PMC_IRQn = 5, /**< 5 AT91SAM3S Power Management Controller (PMC) */ - EFC_IRQn = 6, /**< 6 AT91SAM3S Enhanced Flash Controller (EFC) */ - UART0_IRQn = 8, /**< 8 AT91SAM3S UART 0 (UART0) */ - UART1_IRQn = 9, /**< 9 AT91SAM3S UART 1 (UART1) */ - SMC_IRQn = 10, /**< 10 AT91SAM3S Static Memory Controller (SMC) */ - PIOA_IRQn = 11, /**< 11 AT91SAM3S Parallel I/O Controller A (PIOA) */ - PIOB_IRQn = 12, /**< 12 AT91SAM3S Parallel I/O Controller B (PIOB) */ - PIOC_IRQn = 13, /**< 13 AT91SAM3S Parallel I/O Controller C (PIOC) */ - USART0_IRQn = 14, /**< 14 AT91SAM3S USART 0 (USART0) */ - USART1_IRQn = 15, /**< 15 AT91SAM3S USART 1 (USART1) */ - HSMCI_IRQn = 18, /**< 18 AT91SAM3S Multimedia Card Interface (HSMCI) */ - TWI0_IRQn = 19, /**< 19 AT91SAM3S Two Wire Interface 0 (TWI0) */ - TWI1_IRQn = 20, /**< 20 AT91SAM3S Two Wire Interface 1 (TWI1) */ - SPI_IRQn = 21, /**< 21 AT91SAM3S Serial Peripheral Interface (SPI) */ - SSC_IRQn = 22, /**< 22 AT91SAM3S Synchronous Serial Controler (SSC) */ - TC0_IRQn = 23, /**< 23 AT91SAM3S Timer/Counter 0 (TC0) */ - TC1_IRQn = 24, /**< 24 AT91SAM3S Timer/Counter 1 (TC1) */ - TC2_IRQn = 25, /**< 25 AT91SAM3S Timer/Counter 2 (TC2) */ - TC3_IRQn = 26, /**< 26 AT91SAM3S Timer/Counter 3 (TC3) */ - TC4_IRQn = 27, /**< 27 AT91SAM3S Timer/Counter 4 (TC4) */ - TC5_IRQn = 28, /**< 28 AT91SAM3S Timer/Counter 5 (TC5) */ - ADC_IRQn = 29, /**< 29 AT91SAM3S Analog To Digital Converter (ADC) */ - DACC_IRQn = 30, /**< 30 AT91SAM3S Digital To Analog Converter (DACC) */ - PWM_IRQn = 31, /**< 31 AT91SAM3S Pulse Width Modulation (PWM) */ - CRCCU_IRQn = 32, /**< 32 AT91SAM3S CRC Calculation Unit (CRCCU) */ - ACC_IRQn = 33, /**< 33 AT91SAM3S Analog Comparator (ACC) */ - UDP_IRQn = 34 /**< 34 AT91SAM3S USB Device Port (UDP) */ -} IRQn_Type; -/*@}*/ - -/* ***************************************************************************** */ -/** SOFTWARE PERIPHERAL API DEFINITION FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_api Peripheral Software API */ -/*@{*/ -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Analog Comparator Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_ACC Analog Comparator Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Acc hardware registers */ -typedef struct { - WoReg ACC_CR; /**< \brief (Acc Offset: 0x00) Control Register */ - RwReg ACC_MR; /**< \brief (Acc Offset: 0x04) Mode Register */ - RwReg Reserved1[7]; - WoReg ACC_IER; /**< \brief (Acc Offset: 0x24) Interrupt Enable Register */ - WoReg ACC_IDR; /**< \brief (Acc Offset: 0x28) Interrupt Disable Register */ - RoReg ACC_IMR; /**< \brief (Acc Offset: 0x2C) Interrupt Mask Register */ - RoReg ACC_ISR; /**< \brief (Acc Offset: 0x30) Interrupt Status Register */ - RwReg Reserved2[24]; - RwReg ACC_ACR; /**< \brief (Acc Offset: 0x94) Analog Control Register */ - RwReg Reserved3[19]; - RwReg ACC_WPMR; /**< \brief (Acc Offset: 0xE4) Write Protect Mode Register */ - RoReg ACC_WPSR; /**< \brief (Acc Offset: 0xE8) Write Protect Status Register */ -} Acc; -#endif /* __ASSEMBLY__ */ -/* -------- ACC_CR : (ACC Offset: 0x00) Control Register -------- */ -#define ACC_CR_SWRST (0x1 << 0) /**< \brief (ACC_CR) SoftWare ReSeT */ -/* -------- ACC_MR : (ACC Offset: 0x04) Mode Register -------- */ -#define ACC_MR_SELPLUS (0x7 << 0) /**< \brief (ACC_MR) SELection for PLUS comparator input */ -#define ACC_MR_SELMINUS (0x7 << 4) /**< \brief (ACC_MR) SELection for MINUS comparator input */ -#define ACC_MR_ACEN (0x1 << 8) /**< \brief (ACC_MR) Analog Comparator ENable */ -#define ACC_MR_ACEN_EN (0x1 << 8) /**< \brief (ACC_MR) Analog Comparator ENable */ -#define ACC_MR_ACEN_DIS (0x0 << 8) /**< \brief (ACC_MR) Analog Comparator Disable */ -#define ACC_MR_EDGETYP (0x3 << 9) /**< \brief (ACC_MR) EDGE TYPe */ -#define ACC_MR_EDGETYP_RISING (0x0 << 9) /**< \brief (ACC_MR) EDGE TYPe ,RISING edge*/ -#define ACC_MR_EDGETYP_FALLING (0x1 << 9) /**< \brief (ACC_MR) EDGE TYPe,falling edge */ -#define ACC_MR_EDGETYP_ANY (0x2 << 9) /**< \brief (ACC_MR) EDGE TYPe,any edge */ -#define ACC_MR_INV (0x1 << 12) /**< \brief (ACC_MR) INVert comparator output */ -#define ACC_MR_INV_EN (0x1 << 12) /**< \brief (ACC_MR) INVert comparator output */ -#define ACC_MR_INV_DIS (0x0 << 12) /**< \brief (ACC_MR) DIRECTLY */ -#define ACC_MR_SELFS (0x1 << 13) /**< \brief (ACC_MR) SELection of Fault Source */ -#define ACC_MR_SELFS_CF (0x0 << 13) /**< \brief (ACC_MR) SELection of Fault Source */ -#define ACC_MR_SELFS_OUTPUT (0x1 << 13) /**< \brief (ACC_MR) SELection of Fault Source */ -#define ACC_MR_FE (0x1 << 14) /**< \brief (ACC_MR) Fault Enable */ -#define ACC_MR_FE_EN (0x1 << 14) /**< \brief (ACC_MR) Fault Enable */ -#define ACC_MR_FE_DIS (0x0 << 14) /**< \brief (ACC_MR) Fault Enable */ -/* -------- ACC_IER : (ACC Offset: 0x24) Interrupt Enable Register -------- */ -#define ACC_IER_CE (0x1 << 0) /**< \brief (ACC_IER) Comparison Edge */ -/* -------- ACC_IDR : (ACC Offset: 0x28) Interrupt Disable Register -------- */ -#define ACC_IDR_CE (0x1 << 0) /**< \brief (ACC_IDR) Comparison Edge */ -/* -------- ACC_IMR : (ACC Offset: 0x2C) Interrupt Mask Register -------- */ -#define ACC_IMR_CE (0x1 << 0) /**< \brief (ACC_IMR) Comparison Edge */ -/* -------- ACC_ISR : (ACC Offset: 0x30) Interrupt Status Register -------- */ -#define ACC_ISR_CE (0x1 << 0) /**< \brief (ACC_ISR) Comparison Edge */ -#define ACC_ISR_SCO (0x1 << 1) /**< \brief (ACC_ISR) Synchronized Comparator Output */ -#define ACC_ISR_MASK (0x1 << 31) /**< \brief (ACC_ISR) */ -/* -------- ACC_ACR : (ACC Offset: 0x94) Analog Control Register -------- */ -#define ACC_ACR_ISEL (0x1 << 0) /**< \brief (ACC_ACR) Current SELection */ -#define ACC_ACR_HYST (0x3 << 1) /**< \brief (ACC_ACR) HYSTeresis selection */ -/* -------- ACC_WPMR : (ACC Offset: 0xE4) Write Protect Mode Register -------- */ -#define ACC_WPMR_WPEN (0x1 << 0) /**< \brief (ACC_WPMR) Write Protect Enable */ -#define ACC_WPMR_WPKEY (0xffffff << 8) /**< \brief (ACC_WPMR) Write Protect KEY */ -/* -------- ACC_WPSR : (ACC Offset: 0xE8) Write Protect Status Register -------- */ -#define ACC_WPSR_WPROTERR (0x1 << 0) /**< \brief (ACC_WPSR) Write PROTection ERRor */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Analog-to-digital Converter */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_ADC Analog-to-digital Converter */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Adc hardware registers */ -typedef struct { - WoReg ADC_CR; /**< \brief (Adc Offset: 0x00) Control Register */ - RwReg ADC_MR; /**< \brief (Adc Offset: 0x04) Mode Register */ - RwReg ADC_SEQ1R; /**< \brief (Adc Offset: 0x08) Channel Sequence 1Register */ - RwReg ADC_SEQ2R; /**< \brief (Adc Offset: 0x0C) Channel Sequence 2 Register */ - WoReg ADC_CHER; /**< \brief (Adc Offset: 0x10) Channel Enable Register */ - WoReg ADC_CHDR; /**< \brief (Adc Offset: 0x14) Channel Disable Register */ - RoReg ADC_CHSR; /**< \brief (Adc Offset: 0x18) Channel Status Register */ - RwReg Reserved1[1]; - RoReg ADC_LCDR; /**< \brief (Adc Offset: 0x20) Last Converted Data Register */ - WoReg ADC_IER; /**< \brief (Adc Offset: 0x24) Interrupt Enable Register */ - WoReg ADC_IDR; /**< \brief (Adc Offset: 0x28) Interrupt Disable Register */ - RoReg ADC_IMR; /**< \brief (Adc Offset: 0x2C) Interrupt Mask Register */ - RoReg ADC_ISR; /**< \brief (Adc Offset: 0x30) Interrupt Status Register */ - RwReg Reserved2[2]; - RoReg ADC_OVER; /**< \brief (Adc Offset: 0x3C) Overrun Status Register */ - RwReg ADC_EMR; /**< \brief (Adc Offset: 0x40) Extended Mode Register */ - RwReg ADC_CWR; /**< \brief (Adc Offset: 0x44) Compare Window Register */ - RwReg ADC_CGR; /**< \brief (Adc Offset: 0x48) Channel Gain Register */ - RwReg ADC_COR; /**< \brief (Adc Offset: 0x4C) Channel Offset Register */ - RoReg ADC_CDR0; /**< \brief (Adc Offset: 0x50) Channel Data Register 0 */ - RoReg ADC_CDR1; /**< \brief (Adc Offset: 0x54) Channel Data Register 1 */ - RoReg ADC_CDR2; /**< \brief (Adc Offset: 0x58) Channel Data Register 2 */ - RoReg ADC_CDR3; /**< \brief (Adc Offset: 0x5C) Channel Data Register 3 */ - RoReg ADC_CDR4; /**< \brief (Adc Offset: 0x60) Channel Data Register 4 */ - RoReg ADC_CDR5; /**< \brief (Adc Offset: 0x64) Channel Data Register 5 */ - RoReg ADC_CDR6; /**< \brief (Adc Offset: 0x68) Channel Data Register 6 */ - RoReg ADC_CDR7; /**< \brief (Adc Offset: 0x6C) Channel Data Register 7 */ - RoReg ADC_CDR8; /**< \brief (Adc Offset: 0x70) Channel Data Register 8 */ - RoReg ADC_CDR9; /**< \brief (Adc Offset: 0x74) Channel Data Register 9 */ - RoReg ADC_CDR10; /**< \brief (Adc Offset: 0x78) Channel Data Register 10 */ - RoReg ADC_CDR11; /**< \brief (Adc Offset: 0x7C) Channel Data Register 11 */ - RoReg ADC_CDR12; /**< \brief (Adc Offset: 0x80) Channel Data Register 12 */ - RoReg ADC_CDR13; /**< \brief (Adc Offset: 0x84) Channel Data Register 13 */ - RoReg ADC_CDR14; /**< \brief (Adc Offset: 0x88) Channel Data Register 14 */ - RoReg ADC_CDR15; /**< \brief (Adc Offset: 0x8C) Channel Data Register 15 */ - RwReg Reserved3[1]; - RwReg ADC_ACR; /**< \brief (Adc Offset: 0x94) Analog Control Register */ - RwReg Reserved4[19]; - RwReg ADC_WPMR; /**< \brief (Adc Offset: 0xE4) Write Protect Mode Register */ - RoReg ADC_WPSR; /**< \brief (Adc Offset: 0xE8) Write Protect Status Register */ - RwReg Reserved5[5]; - RwReg ADC_RPR; /**< \brief (Adc Offset: 0x100) Receive Pointer Register */ - RwReg ADC_RCR; /**< \brief (Adc Offset: 0x104) Receive Counter Register */ - RwReg ADC_TPR; /**< \brief (Adc Offset: 0x108) Transmit Pointer Register */ - RwReg ADC_TCR; /**< \brief (Adc Offset: 0x10C) Transmit Counter Register */ - RwReg ADC_RNPR; /**< \brief (Adc Offset: 0x110) Receive Next Pointer Register */ - RwReg ADC_RNCR; /**< \brief (Adc Offset: 0x114) Receive Next Counter Register */ - RwReg ADC_TNPR; /**< \brief (Adc Offset: 0x118) Transmit Next Pointer Register */ - RwReg ADC_TNCR; /**< \brief (Adc Offset: 0x11C) Transmit Next Counter Register */ - WoReg ADC_PTCR; /**< \brief (Adc Offset: 0x120) Transfer Control Register */ - RoReg ADC_PTSR; /**< \brief (Adc Offset: 0x124) Transfer Status Register */ -} Adc; -#endif /* __ASSEMBLY__ */ -/* -------- ADC_CR : (ADC Offset: 0x00) Control Register -------- */ -#define ADC_CR_SWRST (0x1 << 0) /**< \brief (ADC_CR) Software Reset */ -#define ADC_CR_START (0x1 << 1) /**< \brief (ADC_CR) Start Conversion */ -/* -------- ADC_MR : (ADC Offset: 0x04) Mode Register -------- */ -#define ADC_MR_TRGEN (0x1 << 0) /**< \brief (ADC_MR) Trigger Enable */ -#define ADC_MR_TRGEN_DIS (0x0 << 0) /**< \brief (ADC_MR) Hardware triggers are disabled. Starting a conversion is only possible by software.*/ -#define ADC_MR_TRGEN_EN (0x1) /**< (ADC) Hardware trigger selected by TRGSEL field is enabled.*/ -#define ADC_MR_TRGSEL (0x7 << 1) /**< \brief (ADC_MR) Trigger Selection */ -#define ADC_MR_TRGSEL_EXT (0x0 << 1) /**< \brief (ADC_MR) Selected TRGSEL = External Trigger*/ -#define ADC_MR_TRGSEL_TIOA0 (0x1 << 1) /**< \brief (ADC_MR) Selected TRGSEL = TIAO0*/ -#define ADC_MR_TRGSEL_TIOA1 (0x2 << 1) /**< \brief (ADC_MR) Selected TRGSEL = TIAO1*/ -#define ADC_MR_TRGSEL_TIOA2 (0x3 << 1) /**< \brief (ADC_MR) Selected TRGSEL = TIAO2*/ -#define ADC_MR_TRGSEL_PWM0_TRIG (0x4 << 1) /**< \brief (ADC_MR) Selected TRGSEL = PWM trigger*/ -#define ADC_MR_TRGSEL_PWM1_TRIG (0x5 << 1) /**< \brief (ADC_MR) Selected TRGSEL = PWM Trigger*/ -#define ADC_MR_TRGSEL_RESERVED (0x6 << 1) /**< \brief (ADC_MR) Selected TRGSEL = Reserved*/ -#define ADC_MR_LOWRES (0x1 << 4) /**< \brief (ADC_MR) Resolution */ -#define ADC_MR_LOWRES_12_BIT (0x0 << 4) /**< \brief (ADC_MR) 12-bit resolution*/ -#define ADC_MR_LOWRES_10_BIT (0x1 << 4) /**< \brief (ADC_MR) 10-bit resolution*/ -#define ADC_MR_SLEEP (0x1 << 5) /**< \brief (ADC_MR) Sleep Mode */ -#define ADC_MR_SLEEP_NORMAL (0x0 << 5) /**< \brief (ADC12B) Normal Mode*/ -#define ADC_MR_FWUP (0x1 << 6) /**< \brief (ADC_MR) Fast Wake Up */ -#define ADC_MR_FREERUN (0x1 << 7) /**< \brief (ADC_MR) Free Run Mode */ -#define ADC_MR_PRESCAL (0xff << 8) /**< \brief (ADC_MR) Prescaler Rate Selection */ -#define ADC_MR_STARTUP (0xf << 16) /**< \brief (ADC_MR) Start Up Time */ -#define ADC_MR_SETTLING (0x3 << 20) /**< \brief (ADC_MR) Analog Settling Time */ -#define ADC_MR_ANACH (0x1 << 23) /**< \brief (ADC_MR) Analog Change */ -#define ADC_MR_TRACKTIM (0xf << 24) /**< \brief (ADC_MR) Tracking Time */ -#define ADC_MR_TRANSFER (0x3 << 28) /**< \brief (ADC_MR) */ -#define ADC_MR_USEQ (0x1 << 31) /**< \brief (ADC_MR) User Sequence Enable */ -/* -------- ADC_SEQ1R : (ADC Offset: 0x08) Channel Sequence 1Register -------- */ -#define ADC_SEQ1R_USCH1 (0x7 << 0) /**< \brief (ADC_SEQ1R) User Sequence Number 1 */ -#define ADC_SEQ1R_USCH2 (0x7 << 4) /**< \brief (ADC_SEQ1R) User Sequence Number 2 */ -#define ADC_SEQ1R_USCH3 (0x7 << 8) /**< \brief (ADC_SEQ1R) User Sequence Number 3 */ -#define ADC_SEQ1R_USCH4 (0x7 << 12) /**< \brief (ADC_SEQ1R) User Sequence Number 4 */ -#define ADC_SEQ1R_USCH5 (0x7 << 16) /**< \brief (ADC_SEQ1R) User Sequence Number 5 */ -#define ADC_SEQ1R_USCH6 (0x7 << 20) /**< \brief (ADC_SEQ1R) User Sequence Number 6 */ -#define ADC_SEQ1R_USCH7 (0x7 << 24) /**< \brief (ADC_SEQ1R) User Sequence Number 7 */ -#define ADC_SEQ1R_USCH8 (0x7 << 28) /**< \brief (ADC_SEQ1R) User Sequence Number 8 */ -/* -------- ADC_SEQ2R : (ADC Offset: 0x0C) Channel Sequence 2 Register -------- */ -#define ADC_SEQ2R_USCH9 (0x7 << 0) /**< \brief (ADC_SEQ2R) User Sequence Number 9 */ -#define ADC_SEQ2R_USCH10 (0x7 << 4) /**< \brief (ADC_SEQ2R) User Sequence Number 10 */ -#define ADC_SEQ2R_USCH11 (0x7 << 8) /**< \brief (ADC_SEQ2R) User Sequence Number 11 */ -#define ADC_SEQ2R_USCH12 (0x7 << 12) /**< \brief (ADC_SEQ2R) User Sequence Number 12 */ -#define ADC_SEQ2R_USCH13 (0x7 << 16) /**< \brief (ADC_SEQ2R) User Sequence Number 13 */ -#define ADC_SEQ2R_USCH14 (0x7 << 20) /**< \brief (ADC_SEQ2R) User Sequence Number 14 */ -#define ADC_SEQ2R_USCH15 (0x7 << 24) /**< \brief (ADC_SEQ2R) User Sequence Number 15 */ -#define ADC_SEQ2R_USCH16 (0x7 << 28) /**< \brief (ADC_SEQ2R) User Sequence Number 16 */ -/* -------- ADC_CHER : (ADC Offset: 0x10) Channel Enable Register -------- */ -#define ADC_CHER_CH0 (0x1 << 0) /**< \brief (ADC_CHER) Channel 0 Enable */ -#define ADC_CHER_CH1 (0x1 << 1) /**< \brief (ADC_CHER) Channel 1 Enable */ -#define ADC_CHER_CH2 (0x1 << 2) /**< \brief (ADC_CHER) Channel 2 Enable */ -#define ADC_CHER_CH3 (0x1 << 3) /**< \brief (ADC_CHER) Channel 3 Enable */ -#define ADC_CHER_CH4 (0x1 << 4) /**< \brief (ADC_CHER) Channel 4 Enable */ -#define ADC_CHER_CH5 (0x1 << 5) /**< \brief (ADC_CHER) Channel 5 Enable */ -#define ADC_CHER_CH6 (0x1 << 6) /**< \brief (ADC_CHER) Channel 6 Enable */ -#define ADC_CHER_CH7 (0x1 << 7) /**< \brief (ADC_CHER) Channel 7 Enable */ -#define ADC_CHER_CH8 (0x1 << 8) /**< \brief (ADC_CHER) Channel 8 Enable */ -#define ADC_CHER_CH9 (0x1 << 9) /**< \brief (ADC_CHER) Channel 9 Enable */ -#define ADC_CHER_CH10 (0x1 << 10) /**< \brief (ADC_CHER) Channel 10 Enable */ -#define ADC_CHER_CH11 (0x1 << 11) /**< \brief (ADC_CHER) Channel 11 Enable */ -#define ADC_CHER_CH12 (0x1 << 12) /**< \brief (ADC_CHER) Channel 12 Enable */ -#define ADC_CHER_CH13 (0x1 << 13) /**< \brief (ADC_CHER) Channel 13 Enable */ -#define ADC_CHER_CH14 (0x1 << 14) /**< \brief (ADC_CHER) Channel 14 Enable */ -#define ADC_CHER_CH15 (0x1 << 15) /**< \brief (ADC_CHER) Channel 15 Enable */ -/* -------- ADC_CHDR : (ADC Offset: 0x14) Channel Disable Register -------- */ -#define ADC_CHDR_CH0 (0x1 << 0) /**< \brief (ADC_CHDR) Channel 0 Disable */ -#define ADC_CHDR_CH1 (0x1 << 1) /**< \brief (ADC_CHDR) Channel 1 Disable */ -#define ADC_CHDR_CH2 (0x1 << 2) /**< \brief (ADC_CHDR) Channel 2 Disable */ -#define ADC_CHDR_CH3 (0x1 << 3) /**< \brief (ADC_CHDR) Channel 3 Disable */ -#define ADC_CHDR_CH4 (0x1 << 4) /**< \brief (ADC_CHDR) Channel 4 Disable */ -#define ADC_CHDR_CH5 (0x1 << 5) /**< \brief (ADC_CHDR) Channel 5 Disable */ -#define ADC_CHDR_CH6 (0x1 << 6) /**< \brief (ADC_CHDR) Channel 6 Disable */ -#define ADC_CHDR_CH7 (0x1 << 7) /**< \brief (ADC_CHDR) Channel 7 Disable */ -#define ADC_CHDR_CH8 (0x1 << 8) /**< \brief (ADC_CHDR) Channel 8 Disable */ -#define ADC_CHDR_CH9 (0x1 << 9) /**< \brief (ADC_CHDR) Channel 9 Disable */ -#define ADC_CHDR_CH10 (0x1 << 10) /**< \brief (ADC_CHDR) Channel 10 Disable */ -#define ADC_CHDR_CH11 (0x1 << 11) /**< \brief (ADC_CHDR) Channel 11 Disable */ -#define ADC_CHDR_CH12 (0x1 << 12) /**< \brief (ADC_CHDR) Channel 12 Disable */ -#define ADC_CHDR_CH13 (0x1 << 13) /**< \brief (ADC_CHDR) Channel 13 Disable */ -#define ADC_CHDR_CH14 (0x1 << 14) /**< \brief (ADC_CHDR) Channel 14 Disable */ -#define ADC_CHDR_CH15 (0x1 << 15) /**< \brief (ADC_CHDR) Channel 15 Disable */ -/* -------- ADC_CHSR : (ADC Offset: 0x18) Channel Status Register -------- */ -#define ADC_CHSR_CH0 (0x1 << 0) /**< \brief (ADC_CHSR) Channel 0 Status */ -#define ADC_CHSR_CH1 (0x1 << 1) /**< \brief (ADC_CHSR) Channel 1 Status */ -#define ADC_CHSR_CH2 (0x1 << 2) /**< \brief (ADC_CHSR) Channel 2 Status */ -#define ADC_CHSR_CH3 (0x1 << 3) /**< \brief (ADC_CHSR) Channel 3 Status */ -#define ADC_CHSR_CH4 (0x1 << 4) /**< \brief (ADC_CHSR) Channel 4 Status */ -#define ADC_CHSR_CH5 (0x1 << 5) /**< \brief (ADC_CHSR) Channel 5 Status */ -#define ADC_CHSR_CH6 (0x1 << 6) /**< \brief (ADC_CHSR) Channel 6 Status */ -#define ADC_CHSR_CH7 (0x1 << 7) /**< \brief (ADC_CHSR) Channel 7 Status */ -#define ADC_CHSR_CH8 (0x1 << 8) /**< \brief (ADC_CHSR) Channel 8 Status */ -#define ADC_CHSR_CH9 (0x1 << 9) /**< \brief (ADC_CHSR) Channel 9 Status */ -#define ADC_CHSR_CH10 (0x1 << 10) /**< \brief (ADC_CHSR) Channel 10 Status */ -#define ADC_CHSR_CH11 (0x1 << 11) /**< \brief (ADC_CHSR) Channel 11 Status */ -#define ADC_CHSR_CH12 (0x1 << 12) /**< \brief (ADC_CHSR) Channel 12 Status */ -#define ADC_CHSR_CH13 (0x1 << 13) /**< \brief (ADC_CHSR) Channel 13 Status */ -#define ADC_CHSR_CH14 (0x1 << 14) /**< \brief (ADC_CHSR) Channel 14 Status */ -#define ADC_CHSR_CH15 (0x1 << 15) /**< \brief (ADC_CHSR) Channel 15 Status */ -/* -------- ADC_LCDR : (ADC Offset: 0x20) Last Converted Data Register -------- */ -#define ADC_LCDR_LDATA (0xfff << 0) /**< \brief (ADC_LCDR) Last Data Converted */ -#define ADC_LCDR_CHNB (0xf << 12) /**< \brief (ADC_LCDR) Channel Number */ -/* -------- ADC_IER : (ADC Offset: 0x24) Interrupt Enable Register -------- */ -#define ADC_IER_EOC0 (0x1 << 0) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 0 */ -#define ADC_IER_EOC1 (0x1 << 1) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 1 */ -#define ADC_IER_EOC2 (0x1 << 2) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 2 */ -#define ADC_IER_EOC3 (0x1 << 3) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 3 */ -#define ADC_IER_EOC4 (0x1 << 4) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 4 */ -#define ADC_IER_EOC5 (0x1 << 5) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 5 */ -#define ADC_IER_EOC6 (0x1 << 6) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 6 */ -#define ADC_IER_EOC7 (0x1 << 7) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 7 */ -#define ADC_IER_EOC8 (0x1 << 8) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 8 */ -#define ADC_IER_EOC9 (0x1 << 9) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 9 */ -#define ADC_IER_EOC10 (0x1 << 10) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 10 */ -#define ADC_IER_EOC11 (0x1 << 11) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 11 */ -#define ADC_IER_EOC12 (0x1 << 12) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 12 */ -#define ADC_IER_EOC13 (0x1 << 13) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 13 */ -#define ADC_IER_EOC14 (0x1 << 14) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 14 */ -#define ADC_IER_EOC15 (0x1 << 15) /**< \brief (ADC_IER) End of Conversion Interrupt Enable 15 */ -#define ADC_IER_DRDY (0x1 << 24) /**< \brief (ADC_IER) Data Ready Interrupt Enable */ -#define ADC_IER_GOVRE (0x1 << 25) /**< \brief (ADC_IER) General Overrun Error Interrupt Enable */ -#define ADC_IER_COMPE (0x1 << 26) /**< \brief (ADC_IER) Comparison Event Interrupt Enable */ -#define ADC_IER_ENDRX (0x1 << 27) /**< \brief (ADC_IER) End of Receive Buffer Interrupt Enable */ -#define ADC_IER_RXBUFF (0x1 << 28) /**< \brief (ADC_IER) Receive Buffer Full Interrupt Enable */ -/* -------- ADC_IDR : (ADC Offset: 0x28) Interrupt Disable Register -------- */ -#define ADC_IDR_EOC0 (0x1 << 0) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 0 */ -#define ADC_IDR_EOC1 (0x1 << 1) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 1 */ -#define ADC_IDR_EOC2 (0x1 << 2) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 2 */ -#define ADC_IDR_EOC3 (0x1 << 3) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 3 */ -#define ADC_IDR_EOC4 (0x1 << 4) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 4 */ -#define ADC_IDR_EOC5 (0x1 << 5) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 5 */ -#define ADC_IDR_EOC6 (0x1 << 6) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 6 */ -#define ADC_IDR_EOC7 (0x1 << 7) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 7 */ -#define ADC_IDR_EOC8 (0x1 << 8) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 8 */ -#define ADC_IDR_EOC9 (0x1 << 9) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 9 */ -#define ADC_IDR_EOC10 (0x1 << 10) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 10 */ -#define ADC_IDR_EOC11 (0x1 << 11) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 11 */ -#define ADC_IDR_EOC12 (0x1 << 12) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 12 */ -#define ADC_IDR_EOC13 (0x1 << 13) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 13 */ -#define ADC_IDR_EOC14 (0x1 << 14) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 14 */ -#define ADC_IDR_EOC15 (0x1 << 15) /**< \brief (ADC_IDR) End of Conversion Interrupt Disable 15 */ -#define ADC_IDR_DRDY (0x1 << 24) /**< \brief (ADC_IDR) Data Ready Interrupt Disable */ -#define ADC_IDR_GOVRE (0x1 << 25) /**< \brief (ADC_IDR) General Overrun Error Interrupt Disable */ -#define ADC_IDR_COMPE (0x1 << 26) /**< \brief (ADC_IDR) Comparison Event Interrupt Disable */ -#define ADC_IDR_ENDRX (0x1 << 27) /**< \brief (ADC_IDR) End of Receive Buffer Interrupt Disable */ -#define ADC_IDR_RXBUFF (0x1 << 28) /**< \brief (ADC_IDR) Receive Buffer Full Interrupt Disable */ -/* -------- ADC_IMR : (ADC Offset: 0x2C) Interrupt Mask Register -------- */ -#define ADC_IMR_EOC0 (0x1 << 0) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 0 */ -#define ADC_IMR_EOC1 (0x1 << 1) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 1 */ -#define ADC_IMR_EOC2 (0x1 << 2) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 2 */ -#define ADC_IMR_EOC3 (0x1 << 3) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 3 */ -#define ADC_IMR_EOC4 (0x1 << 4) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 4 */ -#define ADC_IMR_EOC5 (0x1 << 5) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 5 */ -#define ADC_IMR_EOC6 (0x1 << 6) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 6 */ -#define ADC_IMR_EOC7 (0x1 << 7) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 7 */ -#define ADC_IMR_EOC8 (0x1 << 8) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 8 */ -#define ADC_IMR_EOC9 (0x1 << 9) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 9 */ -#define ADC_IMR_EOC10 (0x1 << 10) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 10 */ -#define ADC_IMR_EOC11 (0x1 << 11) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 11 */ -#define ADC_IMR_EOC12 (0x1 << 12) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 12 */ -#define ADC_IMR_EOC13 (0x1 << 13) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 13 */ -#define ADC_IMR_EOC14 (0x1 << 14) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 14 */ -#define ADC_IMR_EOC15 (0x1 << 15) /**< \brief (ADC_IMR) End of Conversion Interrupt Mask 15 */ -#define ADC_IMR_DRDY (0x1 << 24) /**< \brief (ADC_IMR) Data Ready Interrupt Mask */ -#define ADC_IMR_GOVRE (0x1 << 25) /**< \brief (ADC_IMR) General Overrun Error Interrupt Mask */ -#define ADC_IMR_COMPE (0x1 << 26) /**< \brief (ADC_IMR) Comparison Event Interrupt Mask */ -#define ADC_IMR_ENDRX (0x1 << 27) /**< \brief (ADC_IMR) End of Receive Buffer Interrupt Mask */ -#define ADC_IMR_RXBUFF (0x1 << 28) /**< \brief (ADC_IMR) Receive Buffer Full Interrupt Mask */ -/* -------- ADC_ISR : (ADC Offset: 0x30) Interrupt Status Register -------- */ -#define ADC_ISR_EOC0 (0x1 << 0) /**< \brief (ADC_ISR) End of Conversion 0 */ -#define ADC_ISR_EOC1 (0x1 << 1) /**< \brief (ADC_ISR) End of Conversion 1 */ -#define ADC_ISR_EOC2 (0x1 << 2) /**< \brief (ADC_ISR) End of Conversion 2 */ -#define ADC_ISR_EOC3 (0x1 << 3) /**< \brief (ADC_ISR) End of Conversion 3 */ -#define ADC_ISR_EOC4 (0x1 << 4) /**< \brief (ADC_ISR) End of Conversion 4 */ -#define ADC_ISR_EOC5 (0x1 << 5) /**< \brief (ADC_ISR) End of Conversion 5 */ -#define ADC_ISR_EOC6 (0x1 << 6) /**< \brief (ADC_ISR) End of Conversion 6 */ -#define ADC_ISR_EOC7 (0x1 << 7) /**< \brief (ADC_ISR) End of Conversion 7 */ -#define ADC_ISR_EOC8 (0x1 << 8) /**< \brief (ADC_ISR) End of Conversion 8 */ -#define ADC_ISR_EOC9 (0x1 << 9) /**< \brief (ADC_ISR) End of Conversion 9 */ -#define ADC_ISR_EOC10 (0x1 << 10) /**< \brief (ADC_ISR) End of Conversion 10 */ -#define ADC_ISR_EOC11 (0x1 << 11) /**< \brief (ADC_ISR) End of Conversion 11 */ -#define ADC_ISR_EOC12 (0x1 << 12) /**< \brief (ADC_ISR) End of Conversion 12 */ -#define ADC_ISR_EOC13 (0x1 << 13) /**< \brief (ADC_ISR) End of Conversion 13 */ -#define ADC_ISR_EOC14 (0x1 << 14) /**< \brief (ADC_ISR) End of Conversion 14 */ -#define ADC_ISR_EOC15 (0x1 << 15) /**< \brief (ADC_ISR) End of Conversion 15 */ -#define ADC_ISR_DRDY (0x1 << 24) /**< \brief (ADC_ISR) Data Ready */ -#define ADC_ISR_GOVRE (0x1 << 25) /**< \brief (ADC_ISR) General Overrun Error */ -#define ADC_ISR_COMPE (0x1 << 26) /**< \brief (ADC_ISR) Comparison Error */ -#define ADC_ISR_ENDRX (0x1 << 27) /**< \brief (ADC_ISR) End of RX Buffer */ -#define ADC_ISR_RXBUFF (0x1 << 28) /**< \brief (ADC_ISR) RX Buffer Full */ -/* -------- ADC_OVER : (ADC Offset: 0x3C) Overrun Status Register -------- */ -#define ADC_OVER_OVRE0 (0x1 << 0) /**< \brief (ADC_OVER) Overrun Error 0 */ -#define ADC_OVER_OVRE1 (0x1 << 1) /**< \brief (ADC_OVER) Overrun Error 1 */ -#define ADC_OVER_OVRE2 (0x1 << 2) /**< \brief (ADC_OVER) Overrun Error 2 */ -#define ADC_OVER_OVRE3 (0x1 << 3) /**< \brief (ADC_OVER) Overrun Error 3 */ -#define ADC_OVER_OVRE4 (0x1 << 4) /**< \brief (ADC_OVER) Overrun Error 4 */ -#define ADC_OVER_OVRE5 (0x1 << 5) /**< \brief (ADC_OVER) Overrun Error 5 */ -#define ADC_OVER_OVRE6 (0x1 << 6) /**< \brief (ADC_OVER) Overrun Error 6 */ -#define ADC_OVER_OVRE7 (0x1 << 7) /**< \brief (ADC_OVER) Overrun Error 7 */ -#define ADC_OVER_OVRE8 (0x1 << 8) /**< \brief (ADC_OVER) Overrun Error 8 */ -#define ADC_OVER_OVRE9 (0x1 << 9) /**< \brief (ADC_OVER) Overrun Error 9 */ -#define ADC_OVER_OVRE10 (0x1 << 10) /**< \brief (ADC_OVER) Overrun Error 10 */ -#define ADC_OVER_OVRE11 (0x1 << 11) /**< \brief (ADC_OVER) Overrun Error 11 */ -#define ADC_OVER_OVRE12 (0x1 << 12) /**< \brief (ADC_OVER) Overrun Error 12 */ -#define ADC_OVER_OVRE13 (0x1 << 13) /**< \brief (ADC_OVER) Overrun Error 13 */ -#define ADC_OVER_OVRE14 (0x1 << 14) /**< \brief (ADC_OVER) Overrun Error 14 */ -#define ADC_OVER_OVRE15 (0x1 << 15) /**< \brief (ADC_OVER) Overrun Error 15 */ -/* -------- ADC_EMR : (ADC Offset: 0x40) Extended Mode Register -------- */ -#define ADC_EMR_CMPMODE (0x3 << 0) /**< \brief (ADC_EMR) Comparison Mode */ -#define ADC_EMR_CMPMODE_LOW (0x0 << 0) /**< \brief (ADC_EMR) Comparison Mode,lower than low threshold */ -#define ADC_EMR_CMPMODE_HIGH (0x1 << 0) /**< \brief (ADC_EMR) Comparison Mode,higher than high threshold */ -#define ADC_EMR_CMPMODE_IN (0x2 << 0) /**< \brief (ADC_EMR) Comparison Mode, in the comparison window */ -#define ADC_EMR_CMPMODE_OUT (0x3 << 0) /**< \brief (ADC_EMR) Comparison Mode, out of the comparison window */ -#define ADC_EMR_CMPSEL (0xf << 4) /**< \brief (ADC_EMR) Comparison Selected Channel */ -#define ADC_EMR_CMPALL (0x1 << 9) /**< \brief (ADC_EMR) Compare All Channels */ -#define ADC_EMR_TAG (0x1 << 24) /**< \brief (ADC_EMR) TAG of ADC_LDCR register */ -/* -------- ADC_CWR : (ADC Offset: 0x44) Compare Window Register -------- */ -#define ADC_CWR_LOWTHRES (0xfff << 0) /**< \brief (ADC_CWR) Low Threshold */ -#define ADC_CWR_HIGHTHRES (0xfff << 16) /**< \brief (ADC_CWR) High Threshold */ -/* -------- ADC_CGR : (ADC Offset: 0x48) Channel Gain Register -------- */ -#define ADC_CGR_GAIN0 (0x3 << 0) /**< \brief (ADC_CGR) Gain for channel 0 */ -#define ADC_CGR_GAIN1 (0x3 << 2) /**< \brief (ADC_CGR) Gain for channel 1 */ -#define ADC_CGR_GAIN2 (0x3 << 4) /**< \brief (ADC_CGR) Gain for channel 2 */ -#define ADC_CGR_GAIN3 (0x3 << 6) /**< \brief (ADC_CGR) Gain for channel 3 */ -#define ADC_CGR_GAIN4 (0x3 << 8) /**< \brief (ADC_CGR) Gain for channel 4 */ -#define ADC_CGR_GAIN5 (0x3 << 10) /**< \brief (ADC_CGR) Gain for channel 5 */ -#define ADC_CGR_GAIN6 (0x3 << 12) /**< \brief (ADC_CGR) Gain for channel 6 */ -#define ADC_CGR_GAIN7 (0x3 << 14) /**< \brief (ADC_CGR) Gain for channel 7 */ -#define ADC_CGR_GAIN8 (0x3 << 16) /**< \brief (ADC_CGR) Gain for channel 8 */ -#define ADC_CGR_GAIN9 (0x3 << 18) /**< \brief (ADC_CGR) Gain for channel 9 */ -#define ADC_CGR_GAIN10 (0x3 << 20) /**< \brief (ADC_CGR) Gain for channel 10 */ -#define ADC_CGR_GAIN11 (0x3 << 22) /**< \brief (ADC_CGR) Gain for channel 11 */ -#define ADC_CGR_GAIN12 (0x3 << 24) /**< \brief (ADC_CGR) Gain for channel 12 */ -#define ADC_CGR_GAIN13 (0x3 << 26) /**< \brief (ADC_CGR) Gain for channel 13 */ -#define ADC_CGR_GAIN14 (0x3 << 28) /**< \brief (ADC_CGR) Gain for channel 14 */ -#define ADC_CGR_GAIN15 (0x3 << 30) /**< \brief (ADC_CGR) Gain for channel 15 */ -/* -------- ADC_COR : (ADC Offset: 0x4C) Channel Offset Register -------- */ -#define ADC_COR_OFF0 (0x1 << 0) /**< \brief (ADC_COR) Offset for channel 0 */ -#define ADC_COR_OFF1 (0x1 << 1) /**< \brief (ADC_COR) Offset for channel 1 */ -#define ADC_COR_OFF2 (0x1 << 2) /**< \brief (ADC_COR) Offset for channel 2 */ -#define ADC_COR_OFF3 (0x1 << 3) /**< \brief (ADC_COR) Offset for channel 3 */ -#define ADC_COR_OFF4 (0x1 << 4) /**< \brief (ADC_COR) Offset for channel 4 */ -#define ADC_COR_OFF5 (0x1 << 5) /**< \brief (ADC_COR) Offset for channel 5 */ -#define ADC_COR_OFF6 (0x1 << 6) /**< \brief (ADC_COR) Offset for channel 6 */ -#define ADC_COR_OFF7 (0x1 << 7) /**< \brief (ADC_COR) Offset for channel 7 */ -#define ADC_COR_OFF8 (0x1 << 8) /**< \brief (ADC_COR) Offset for channel 8 */ -#define ADC_COR_OFF9 (0x1 << 9) /**< \brief (ADC_COR) Offset for channel 9 */ -#define ADC_COR_OFF10 (0x1 << 10) /**< \brief (ADC_COR) Offset for channel 10 */ -#define ADC_COR_OFF11 (0x1 << 11) /**< \brief (ADC_COR) Offset for channel 11 */ -#define ADC_COR_OFF12 (0x1 << 12) /**< \brief (ADC_COR) Offset for channel 12 */ -#define ADC_COR_OFF13 (0x1 << 13) /**< \brief (ADC_COR) Offset for channel 13 */ -#define ADC_COR_OFF14 (0x1 << 14) /**< \brief (ADC_COR) Offset for channel 14 */ -#define ADC_COR_OFF15 (0x1 << 15) /**< \brief (ADC_COR) Offset for channel 15 */ -#define ADC_COR_DIFF0 (0x1 << 16) /**< \brief (ADC_COR) Differential inputs for channel 0 */ -#define ADC_COR_DIFF1 (0x1 << 17) /**< \brief (ADC_COR) Differential inputs for channel 1 */ -#define ADC_COR_DIFF2 (0x1 << 18) /**< \brief (ADC_COR) Differential inputs for channel 2 */ -#define ADC_COR_DIFF3 (0x1 << 19) /**< \brief (ADC_COR) Differential inputs for channel 3 */ -#define ADC_COR_DIFF4 (0x1 << 20) /**< \brief (ADC_COR) Differential inputs for channel 4 */ -#define ADC_COR_DIFF5 (0x1 << 21) /**< \brief (ADC_COR) Differential inputs for channel 5 */ -#define ADC_COR_DIFF6 (0x1 << 22) /**< \brief (ADC_COR) Differential inputs for channel 6 */ -#define ADC_COR_DIFF7 (0x1 << 23) /**< \brief (ADC_COR) Differential inputs for channel 7 */ -#define ADC_COR_DIFF8 (0x1 << 24) /**< \brief (ADC_COR) Differential inputs for channel 8 */ -#define ADC_COR_DIFF9 (0x1 << 25) /**< \brief (ADC_COR) Differential inputs for channel 9 */ -#define ADC_COR_DIFF10 (0x1 << 26) /**< \brief (ADC_COR) Differential inputs for channel 10 */ -#define ADC_COR_DIFF11 (0x1 << 27) /**< \brief (ADC_COR) Differential inputs for channel 11 */ -#define ADC_COR_DIFF12 (0x1 << 28) /**< \brief (ADC_COR) Differential inputs for channel 12 */ -#define ADC_COR_DIFF13 (0x1 << 29) /**< \brief (ADC_COR) Differential inputs for channel 13 */ -#define ADC_COR_DIFF14 (0x1 << 30) /**< \brief (ADC_COR) Differential inputs for channel 14 */ -#define ADC_COR_DIFF15 (0x1 << 31) /**< \brief (ADC_COR) Differential inputs for channel 15 */ -/* -------- ADC_CDR0 : (ADC Offset: 0x50) Channel Data Register 0 -------- */ -#define ADC_CDR0_DATA (0x3ff << 0) /**< \brief (ADC_CDR0) Converted Data */ -/* -------- ADC_CDR1 : (ADC Offset: 0x54) Channel Data Register 1 -------- */ -#define ADC_CDR1_DATA (0x3ff << 0) /**< \brief (ADC_CDR1) Converted Data */ -/* -------- ADC_CDR2 : (ADC Offset: 0x58) Channel Data Register 2 -------- */ -#define ADC_CDR2_DATA (0x3ff << 0) /**< \brief (ADC_CDR2) Converted Data */ -/* -------- ADC_CDR3 : (ADC Offset: 0x5C) Channel Data Register 3 -------- */ -#define ADC_CDR3_DATA (0x3ff << 0) /**< \brief (ADC_CDR3) Converted Data */ -/* -------- ADC_CDR4 : (ADC Offset: 0x60) Channel Data Register 4 -------- */ -#define ADC_CDR4_DATA (0x3ff << 0) /**< \brief (ADC_CDR4) Converted Data */ -/* -------- ADC_CDR5 : (ADC Offset: 0x64) Channel Data Register 5 -------- */ -#define ADC_CDR5_DATA (0x3ff << 0) /**< \brief (ADC_CDR5) Converted Data */ -/* -------- ADC_CDR6 : (ADC Offset: 0x68) Channel Data Register 6 -------- */ -#define ADC_CDR6_DATA (0x3ff << 0) /**< \brief (ADC_CDR6) Converted Data */ -/* -------- ADC_CDR15 : (ADC Offset: 0x6C) Channel Data Register 15 -------- */ -#define ADC_CDR15_DATA (0x3ff << 0) /**< \brief (ADC_CDR15) Converted Data */ -/* -------- ADC_ACR : (ADC Offset: 0x94) Analog Control Register -------- */ -#define ADC_ACR_TSON (0x1 << 4) /**< \brief (ADC_ACR) Temperature Sensor On */ -#define ADC_ACR_IBCTL (0x3 << 8) /**< \brief (ADC_ACR) ADC Bias Current Control */ -/* -------- ADC_WPMR : (ADC Offset: 0xE4) Write Protect Mode Register -------- */ -#define ADC_WPMR_WPEN (0x1 << 0) /**< \brief (ADC_WPMR) Write Protect Enable */ -#define ADC_WPMR_WPKEY (0xffffff << 8) /**< \brief (ADC_WPMR) Write Protect KEY */ -/* -------- ADC_WPSR : (ADC Offset: 0xE8) Write Protect Status Register -------- */ -#define ADC_WPSR_WPVS (0x1 << 0) /**< \brief (ADC_WPSR) Write Protect Violation Status */ -#define ADC_WPSR_WPVSRC (0xffff << 8) /**< \brief (ADC_WPSR) Write Protect Violation Source */ -/* -------- ADC_RPR : (ADC Offset: 0x100) Receive Pointer Register -------- */ -#define ADC_RPR_RXPTR (0xffffffff << 0) /**< \brief (ADC_RPR) Receive Pointer Register */ -/* -------- ADC_RCR : (ADC Offset: 0x104) Receive Counter Register -------- */ -#define ADC_RCR_RXCTR (0xffff << 0) /**< \brief (ADC_RCR) Receive Counter Register */ -/* -------- ADC_TPR : (ADC Offset: 0x108) Transmit Pointer Register -------- */ -#define ADC_TPR_TXPTR (0xffffffff << 0) /**< \brief (ADC_TPR) Transmit Counter Register */ -/* -------- ADC_TCR : (ADC Offset: 0x10C) Transmit Counter Register -------- */ -#define ADC_TCR_TXCTR (0xffff << 0) /**< \brief (ADC_TCR) Transmit Counter Register */ -/* -------- ADC_RNPR : (ADC Offset: 0x110) Receive Next Pointer Register -------- */ -#define ADC_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (ADC_RNPR) Receive Next Pointer */ -/* -------- ADC_RNCR : (ADC Offset: 0x114) Receive Next Counter Register -------- */ -#define ADC_RNCR_RXNCTR (0xffff << 0) /**< \brief (ADC_RNCR) Receive Next Counter */ -/* -------- ADC_TNPR : (ADC Offset: 0x118) Transmit Next Pointer Register -------- */ -#define ADC_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (ADC_TNPR) Transmit Next Pointer */ -/* -------- ADC_TNCR : (ADC Offset: 0x11C) Transmit Next Counter Register -------- */ -#define ADC_TNCR_TXNCTR (0xffff << 0) /**< \brief (ADC_TNCR) Transmit Counter Next */ -/* -------- ADC_PTCR : (ADC Offset: 0x120) Transfer Control Register -------- */ -#define ADC_PTCR_RXTEN (0x1 << 0) /**< \brief (ADC_PTCR) Receiver Transfer Enable */ -#define ADC_PTCR_RXTDIS (0x1 << 1) /**< \brief (ADC_PTCR) Receiver Transfer Disable */ -#define ADC_PTCR_TXTEN (0x1 << 8) /**< \brief (ADC_PTCR) Transmitter Transfer Enable */ -#define ADC_PTCR_TXTDIS (0x1 << 9) /**< \brief (ADC_PTCR) Transmitter Transfer Disable */ -/* -------- ADC_PTSR : (ADC Offset: 0x124) Transfer Status Register -------- */ -#define ADC_PTSR_RXTEN (0x1 << 0) /**< \brief (ADC_PTSR) Receiver Transfer Enable */ -#define ADC_PTSR_TXTEN (0x1 << 8) /**< \brief (ADC_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Chip Identifier */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_CHIPID Chip Identifier */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Chipid hardware registers */ -typedef struct { - RoReg CHIPID_CIDR; /**< \brief (Chipid Offset: 0x0) Chip ID Register */ - RoReg CHIPID_EXID; /**< \brief (Chipid Offset: 0x4) Chip ID Extension Register */ -} Chipid; -#endif /* __ASSEMBLY__ */ -/* -------- CHIPID_CIDR : (CHIPID Offset: 0x0) Chip ID Register -------- */ -#define CHIPID_CIDR_VERSION (0x1f << 0) /**< \brief (CHIPID_CIDR) Version of the Device */ -#define CHIPID_CIDR_EPROC (0x7 << 5) /**< \brief (CHIPID_CIDR) Embedded Processor */ -#define CHIPID_CIDR_NVPSIZ (0xf << 8) /**< \brief (CHIPID_CIDR) Nonvolatile Program Memory Size */ -#define CHIPID_CIDR_NVPSIZ2 (0xf << 12) /**< \brief (CHIPID_CIDR) */ -#define CHIPID_CIDR_SRAMSIZ (0xf << 16) /**< \brief (CHIPID_CIDR) Internal SRAM Size */ -#define CHIPID_CIDR_ARCH (0xff << 20) /**< \brief (CHIPID_CIDR) Architecture Identifier */ -#define CHIPID_CIDR_NVPTYP (0x7 << 28) /**< \brief (CHIPID_CIDR) Nonvolatile Program Memory Type */ -#define CHIPID_CIDR_EXT (0x1 << 31) /**< \brief (CHIPID_CIDR) Extension Flag */ -/* -------- CHIPID_EXID : (CHIPID Offset: 0x4) Chip ID Extension Register -------- */ -#define CHIPID_EXID_EXID (0xffffffff << 0) /**< \brief (CHIPID_EXID) Chip ID Extension */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Cyclic Redundancy Check Calculation Unit */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_CRCCU Cyclic Redundancy Check Calculation Unit */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Crccu hardware registers */ -typedef struct { - RwReg CRCCU_DSCR; /**< \brief (Crccu Offset: 0x00000000) CRCCU Descriptor Base Register */ - RwReg Reserved1[1]; - WoReg CRCCU_DMA_EN; /**< \brief (Crccu Offset: 0x00000008) CRCCU DMA Enable Register */ - WoReg CRCCU_DMA_DIS; /**< \brief (Crccu Offset: 0x0000000C) CRCCU DMA Disable Register */ - RoReg CRCCU_DMA_SR; /**< \brief (Crccu Offset: 0x00000010) CRCCU DMA Status Register */ - WoReg CRCCU_DMA_IER; /**< \brief (Crccu Offset: 0x00000014) CRCCU DMA Interrupt Enable Register */ - WoReg CRCCU_DMA_IDR; /**< \brief (Crccu Offset: 0x00000018) CRCCU DMA Interrupt Disable Register */ - RoReg CRCCU_DMA_IMR; /**< \brief (Crccu Offset: 0x0000001C) CRCCU DMA Interrupt Mask Register */ - RoReg CRCCU_DMA_ISR; /**< \brief (Crccu Offset: 0x00000020) CRCCU DMA Interrupt Status Register */ - RwReg Reserved2[4]; - WoReg CRCCU_CR; /**< \brief (Crccu Offset: 0x00000034) CRCCU Control Register */ - RwReg CRCCU_MR; /**< \brief (Crccu Offset: 0x00000038) CRCCU Mode Register */ - RoReg CRCCU_SR; /**< \brief (Crccu Offset: 0x0000003C) CRCCU Status Register */ - WoReg CRCCU_IER; /**< \brief (Crccu Offset: 0x00000040) CRCCU Interrupt Enable Register */ - WoReg CRCCU_IDR; /**< \brief (Crccu Offset: 0x00000044) CRCCU Interrupt Disable Register */ - RoReg CRCCU_IMR; /**< \brief (Crccu Offset: 0x00000048) CRCCU Interrupt Mask Register */ - RoReg CRCCU_ISR; /**< \brief (Crccu Offset: 0x0000004C) CRCCU Interrupt Status Register */ -} Crccu; -#endif /* __ASSEMBLY__ */ -/* -------- CRCCU_DSCR : (CRCCU Offset: 0x00000000) CRCCU Descriptor Base Register -------- */ -#define CRCCU_DSCR_DSCR (0x7fffff << 9) /**< \brief (CRCCU_DSCR) Descriptor Base Address */ -/* -------- CRCCU_DMA_EN : (CRCCU Offset: 0x00000008) CRCCU DMA Enable Register -------- */ -#define CRCCU_DMA_EN_DMAEN (0x1 << 0) /**< \brief (CRCCU_DMA_EN) DMA Enable Register */ -/* -------- CRCCU_DMA_DIS : (CRCCU Offset: 0x0000000C) CRCCU DMA Disable Register -------- */ -#define CRCCU_DMA_DIS_DMADIS (0x1 << 0) /**< \brief (CRCCU_DMA_DIS) DMA Disable Register */ -/* -------- CRCCU_DMA_SR : (CRCCU Offset: 0x00000010) CRCCU DMA Status Register -------- */ -#define CRCCU_DMA_SR_DMASR (0x1 << 0) /**< \brief (CRCCU_DMA_SR) DMA Status Register */ -/* -------- CRCCU_DMA_IER : (CRCCU Offset: 0x00000014) CRCCU DMA Interrupt Enable Register -------- */ -#define CRCCU_DMA_IER_DMAIER (0x1 << 0) /**< \brief (CRCCU_DMA_IER) Interrupt Enable register */ -/* -------- CRCCU_DMA_IDR : (CRCCU Offset: 0x00000018) CRCCU DMA Interrupt Disable Register -------- */ -#define CRCCU_DMA_IDR_DMAIDR (0x1 << 0) /**< \brief (CRCCU_DMA_IDR) Interrupt Disable register */ -/* -------- CRCCU_DMA_IMR : (CRCCU Offset: 0x0000001C) CRCCU DMA Interrupt Mask Register -------- */ -#define CRCCU_DMA_IMR_DMAIMR (0x1 << 0) /**< \brief (CRCCU_DMA_IMR) Interrupt Mask Register */ -/* -------- CRCCU_DMA_ISR : (CRCCU Offset: 0x00000020) CRCCU DMA Interrupt Status Register -------- */ -#define CRCCU_DMA_ISR_DMAISR (0x1 << 0) /**< \brief (CRCCU_DMA_ISR) Interrupt Status register */ -/* -------- CRCCU_CR : (CRCCU Offset: 0x00000034) CRCCU Control Register -------- */ -#define CRCCU_CR_RESET (0x1 << 0) /**< \brief (CRCCU_CR) CRC Computation Reset */ -/* -------- CRCCU_MR : (CRCCU Offset: 0x00000038) CRCCU Mode Register -------- */ -#define CRCCU_MR_ENABLE (0x1 << 0) /**< \brief (CRCCU_MR) CRC Enable */ -#define CRCCU_MR_COMPARE (0x1 << 1) /**< \brief (CRCCU_MR) CRC Compare */ -#define CRCCU_MR_PTYPE (0x3 << 2) /**< \brief (CRCCU_MR) Primitive Polynomial */ -#define CRCCU_MR_PTYPE_CCIT8023 (0x0 << 2) /**< \brief (CRCCU_MR) Polynom 0x04C11DB7 */ -#define CRCCU_MR_PTYPE_CASTAGNOLI (0x1 << 2) /**< \brief (CRCCU_MR) Polynom 0x1EDC6F41 */ -#define CRCCU_MR_PTYPE_CCIT16 (0x2 << 2) /**< \brief (CRCCU_MR) Polynom 0x1021 */ -#define CRCCU_MR_DIVIDER (0xf << 4) /**< \brief (CRCCU_MR) Request Divider */ -/* -------- CRCCU_SR : (CRCCU Offset: 0x0000003C) CRCCU Status Register -------- */ -#define CRCCU_SR_CRC (0xffffffff << 0) /**< \brief (CRCCU_SR) Cyclic Redundancy Check Value */ -/* -------- CRCCU_IER : (CRCCU Offset: 0x00000040) CRCCU Interrupt Enable Register -------- */ -#define CRCCU_IER_ERRIER (0x1 << 0) /**< \brief (CRCCU_IER) CRC Error Interrupt Enable */ -/* -------- CRCCU_IDR : (CRCCU Offset: 0x00000044) CRCCU Interrupt Disable Register -------- */ -#define CRCCU_IDR_ERRIDR (0x1 << 0) /**< \brief (CRCCU_IDR) CRC Error Interrupt Disable */ -/* -------- CRCCU_IMR : (CRCCU Offset: 0x00000048) CRCCU Interrupt Mask Register -------- */ -#define CRCCU_IMR_ERRIMR (0x1 << 0) /**< \brief (CRCCU_IMR) CRC Error Interrupt Mask */ -/* -------- CRCCU_ISR : (CRCCU Offset: 0x0000004C) CRCCU Interrupt Status Register -------- */ -#define CRCCU_ISR_ERRISR (0x1 << 0) /**< \brief (CRCCU_ISR) CRC Error Interrupt Status */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Digital-to-Analog Converter Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_DACC Digital-to-Analog Converter Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Dacc hardware registers */ -typedef struct { - WoReg DACC_CR; /**< \brief (Dacc Offset: 0x00) Control Register */ - RwReg DACC_MR; /**< \brief (Dacc Offset: 0x04) Mode Register */ - RwReg Reserved1[2]; - WoReg DACC_CHER; /**< \brief (Dacc Offset: 0x10) Channel Enable Register */ - WoReg DACC_CHDR; /**< \brief (Dacc Offset: 0x14) Channel Disable Register */ - RoReg DACC_CHSR; /**< \brief (Dacc Offset: 0x18) Channel Status Register */ - RwReg Reserved2[1]; - WoReg DACC_CDR; /**< \brief (Dacc Offset: 0x20) Conversion Data Register */ - WoReg DACC_IER; /**< \brief (Dacc Offset: 0x24) Interrupt Enable Register */ - WoReg DACC_IDR; /**< \brief (Dacc Offset: 0x28) Interrupt Disable Register */ - RoReg DACC_IMR; /**< \brief (Dacc Offset: 0x2C) Interrupt Mask Register */ - RoReg DACC_ISR; /**< \brief (Dacc Offset: 0x30) Interrupt Status Register */ - RwReg Reserved3[24]; - RwReg DACC_ACR; /**< \brief (Dacc Offset: 0x94) Analog Current Register */ - RwReg Reserved4[19]; - RwReg DACC_WPMR; /**< \brief (Dacc Offset: 0xE4) Write Protect Mode register */ - RoReg DACC_WPSR; /**< \brief (Dacc Offset: 0xE8) Write Protect Status register */ - RwReg Reserved5[5]; - RwReg DACC_RPR; /**< \brief (Dacc Offset: 0x100) Receive Pointer Register */ - RwReg DACC_RCR; /**< \brief (Dacc Offset: 0x104) Receive Counter Register */ - RwReg DACC_TPR; /**< \brief (Dacc Offset: 0x108) Transmit Pointer Register */ - RwReg DACC_TCR; /**< \brief (Dacc Offset: 0x10C) Transmit Counter Register */ - RwReg DACC_RNPR; /**< \brief (Dacc Offset: 0x110) Receive Next Pointer Register */ - RwReg DACC_RNCR; /**< \brief (Dacc Offset: 0x114) Receive Next Counter Register */ - RwReg DACC_TNPR; /**< \brief (Dacc Offset: 0x118) Transmit Next Pointer Register */ - RwReg DACC_TNCR; /**< \brief (Dacc Offset: 0x11C) Transmit Next Counter Register */ - WoReg DACC_PTCR; /**< \brief (Dacc Offset: 0x120) Transfer Control Register */ - RoReg DACC_PTSR; /**< \brief (Dacc Offset: 0x124) Transfer Status Register */ -} Dacc; -#endif /* __ASSEMBLY__ */ -/* -------- DACC_CR : (DACC Offset: 0x00) Control Register -------- */ -#define DACC_CR_SWRST (0x1 << 0) /**< \brief (DACC_CR) Software Reset */ -/* -------- DACC_MR : (DACC Offset: 0x04) Mode Register -------- */ -#define DACC_MR_TRGEN (0x1 << 0) /**< \brief (DACC_MR) Trigger Enable */ -#define DACC_MR_TRGEN_DIS (0x0 << 0) // (DACC_MR) Hardware triggers are disabled. Starting a conversion is only possible by software. -#define DACC_MR_TRGEN_EN (0x1 << 0) // (DACC_MR) Hardware trigger selected by TRGSEL field is enabled. - -#define DACC_MR_TRGSEL (0x7 << 1) /**< \brief (DACC_MR) Trigger Selection */ -#define DACC_MR_TRGSEL_EXT_TRIG (0x0 << 1) // (DACC_MR) External trigger -#define DACC_MR_TRGSEL_TIOA_0 (0x1 << 1) // (DACC_MR) TIO Output of the Timer Counter Channel 0 -#define DACC_MR_TRGSEL_TIOA_1 (0x2 << 1) // (DACC_MR) TIO Output of the Timer Counter Channel 1 -#define DACC_MR_TRGSEL_TIOA_2 (0x3 << 1) // (DACC_MR) TIO Output of the Timer Counter Channel 2 -#define DACC_MR_TRGSEL_PWM_0 (0x4 << 1) // (DACC_MR) PWM Event Line 0 -#define DACC_MR_TRGSEL_PWM_1 (0x5 << 1) // (DACC_MR) PWM Event Line 1 -#define DACC_MR_WORD (0x1 << 4) /**< \brief (DACC_MR) Word Transfer */ -#define DACC_MR_WORD_HALF (0x0 << 4) /**< \brief (DACC_MR) Half-Word Transfer */ -#define DACC_MR_WORD_WORLD (0x1 << 4) /**< \brief (DACC_MR) Word Transfer */ -#define DACC_MR_SLEEP (0x1 << 5) /**< \brief (DACC_MR) Sleep Mode */ -#define DACC_MR_SLEEP_NORMAL (0x0 << 5) // (DACC_MR) Normal Mode -#define DACC_MR_SLEEP_SLEEP (0x1 << 5) // (DACC_MR) Sleep Modes -#define DACC_MR_FASTWKUP (0x1 << 6) /**< \brief (DACC_MR) Fast Wake up Mode */ -#define DACC_MR_REFRESH (0xff << 8) /**< \brief (DACC_MR) Refresh Period */ -#define DACC_MR_USER_SEL (0x3 << 16) /**< \brief (DACC_MR) User Channel Selection */ -#define DACC_MR_USER_SEL_0 (0x0 << 16) /**< \brief (DACC_MR) User Channel Selection */ -#define DACC_MR_USER_SEL_1 (0x1 << 16) /**< \brief (DACC_MR) User Channel Selection */ -#define DACC_MR_TAG (0x1 << 20) /**< \brief (DACC_MR) Tag Selection Mode */ -#define DACC_MR_MAXS (0x1 << 21) /**< \brief (DACC_MR) Max Speed Mode */ -#define DACC_MR_STARTUP (0x3f << 24) /**< \brief (DACC_MR) Startup Time Selection */ -/* -------- DACC_CHER : (DACC Offset: 0x10) Channel Enable Register -------- */ -#define DACC_CHER_CH0 (0x1 << 0) /**< \brief (DACC_CHER) Channel 0 Enable */ -#define DACC_CHER_CH1 (0x1 << 1) /**< \brief (DACC_CHER) Channel 1 Enable */ -#define DACC_CHER_CH2 (0x1 << 2) /**< \brief (DACC_CHER) Channel 2 Enable */ -/* -------- DACC_CHDR : (DACC Offset: 0x14) Channel Disable Register -------- */ -#define DACC_CHDR_CH0 (0x1 << 0) /**< \brief (DACC_CHDR) Channel 0 Disable */ -#define DACC_CHDR_CH1 (0x1 << 1) /**< \brief (DACC_CHDR) Channel 1 Disable */ -#define DACC_CHDR_CH2 (0x1 << 2) /**< \brief (DACC_CHDR) Channel 2 Disable */ -/* -------- DACC_CHSR : (DACC Offset: 0x18) Channel Status Register -------- */ -#define DACC_CHSR_CH0 (0x1 << 0) /**< \brief (DACC_CHSR) Channel 0 Status */ -#define DACC_CHSR_CH1 (0x1 << 1) /**< \brief (DACC_CHSR) Channel 1 Status */ -#define DACC_CHSR_CH2 (0x1 << 2) /**< \brief (DACC_CHSR) Channel 2 Status */ -/* -------- DACC_CDR : (DACC Offset: 0x20) Conversion Data Register -------- */ -#define DACC_CDR_DATA (0xffffffff << 0) /**< \brief (DACC_CDR) Data to Convert */ -/* -------- DACC_IER : (DACC Offset: 0x24) Interrupt Enable Register -------- */ -#define DACC_IER_TXRDY (0x1 << 0) /**< \brief (DACC_IER) Transmit Ready Interrupt Enable */ -#define DACC_IER_EOC (0x1 << 1) /**< \brief (DACC_IER) End of Conversion Interrupt Enable */ -#define DACC_IER_ENDTX (0x1 << 2) /**< \brief (DACC_IER) End of Transmit Buffer Interrupt Enable */ -#define DACC_IER_TXBUFE (0x1 << 3) /**< \brief (DACC_IER) Transmit Buffer Empty Interrupt Enable */ -/* -------- DACC_IDR : (DACC Offset: 0x28) Interrupt Disable Register -------- */ -#define DACC_IDR_TXRDY (0x1 << 0) /**< \brief (DACC_IDR) Transmit Ready Interrupt Disable. */ -#define DACC_IDR_EOC (0x1 << 1) /**< \brief (DACC_IDR) End of Conversion Interrupt Disable */ -#define DACC_IDR_ENDTX (0x1 << 2) /**< \brief (DACC_IDR) End of Transmit Buffer Interrupt Disable */ -#define DACC_IDR_TXBUFE (0x1 << 3) /**< \brief (DACC_IDR) Transmit Buffer Empty Interrupt Disable */ -/* -------- DACC_IMR : (DACC Offset: 0x2C) Interrupt Mask Register -------- */ -#define DACC_IMR_TXRDY (0x1 << 0) /**< \brief (DACC_IMR) Transmit Ready Interrupt Mask */ -#define DACC_IMR_EOC (0x1 << 1) /**< \brief (DACC_IMR) End of Conversion Interrupt Mask */ -#define DACC_IMR_ENDTX (0x1 << 2) /**< \brief (DACC_IMR) End of Transmit Buffer Interrupt Mask */ -#define DACC_IMR_TXBUFE (0x1 << 3) /**< \brief (DACC_IMR) Transmit Buffer Empty Interrupt Mask */ -/* -------- DACC_ISR : (DACC Offset: 0x30) Interrupt Status Register -------- */ -#define DACC_ISR_TXRDY (0x1 << 0) /**< \brief (DACC_ISR) Transmit Ready Interrupt Flag */ -#define DACC_ISR_EOC (0x1 << 1) /**< \brief (DACC_ISR) End of Conversion Interrupt Flag */ -#define DACC_ISR_ENDTX (0x1 << 2) /**< \brief (DACC_ISR) End of DMA Interrupt Flag */ -#define DACC_ISR_TXBUFE (0x1 << 3) /**< \brief (DACC_ISR) Transmit Buffer Empty */ -/* -------- DACC_ACR : (DACC Offset: 0x94) Analog Current Register -------- */ -#define DACC_ACR_IBCTLCH0 (0x3 << 0) /**< \brief (DACC_ACR) Analog Output Current Control */ -#define DACC_ACR_IBCTLCH1 (0x3 << 2) /**< \brief (DACC_ACR) Analog Output Current Control */ -#define DACC_ACR_IBCTLDACCORE (0x3 << 8) /**< \brief (DACC_ACR) Bias Current Control for DAC Core */ -/* -------- DACC_WPMR : (DACC Offset: 0xE4) Write Protect Mode register -------- */ -#define DACC_WPMR_WPEN (0x1 << 0) /**< \brief (DACC_WPMR) Write Protect Enable */ -#define DACC_WPMR_WPKEY (0xffffff << 8) /**< \brief (DACC_WPMR) Write Protect KEY */ -/* -------- DACC_WPSR : (DACC Offset: 0xE8) Write Protect Status register -------- */ -#define DACC_WPSR_WPROTERR (0x1 << 0) /**< \brief (DACC_WPSR) Write protection error */ -#define DACC_WPSR_WPROTADDR (0xff << 8) /**< \brief (DACC_WPSR) Write protection error address */ -/* -------- DACC_RPR : (DACC Offset: 0x100) Receive Pointer Register -------- */ -#define DACC_RPR_RXPTR (0xffffffff << 0) /**< \brief (DACC_RPR) Receive Pointer Register */ -/* -------- DACC_RCR : (DACC Offset: 0x104) Receive Counter Register -------- */ -#define DACC_RCR_RXCTR (0xffff << 0) /**< \brief (DACC_RCR) Receive Counter Register */ -/* -------- DACC_TPR : (DACC Offset: 0x108) Transmit Pointer Register -------- */ -#define DACC_TPR_TXPTR (0xffffffff << 0) /**< \brief (DACC_TPR) Transmit Counter Register */ -/* -------- DACC_TCR : (DACC Offset: 0x10C) Transmit Counter Register -------- */ -#define DACC_TCR_TXCTR (0xffff << 0) /**< \brief (DACC_TCR) Transmit Counter Register */ -/* -------- DACC_RNPR : (DACC Offset: 0x110) Receive Next Pointer Register -------- */ -#define DACC_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (DACC_RNPR) Receive Next Pointer */ -/* -------- DACC_RNCR : (DACC Offset: 0x114) Receive Next Counter Register -------- */ -#define DACC_RNCR_RXNCTR (0xffff << 0) /**< \brief (DACC_RNCR) Receive Next Counter */ -/* -------- DACC_TNPR : (DACC Offset: 0x118) Transmit Next Pointer Register -------- */ -#define DACC_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (DACC_TNPR) Transmit Next Pointer */ -/* -------- DACC_TNCR : (DACC Offset: 0x11C) Transmit Next Counter Register -------- */ -#define DACC_TNCR_TXNCTR (0xffff << 0) /**< \brief (DACC_TNCR) Transmit Counter Next */ -/* -------- DACC_PTCR : (DACC Offset: 0x120) Transfer Control Register -------- */ -#define DACC_PTCR_RXTEN (0x1 << 0) /**< \brief (DACC_PTCR) Receiver Transfer Enable */ -#define DACC_PTCR_RXTDIS (0x1 << 1) /**< \brief (DACC_PTCR) Receiver Transfer Disable */ -#define DACC_PTCR_TXTEN (0x1 << 8) /**< \brief (DACC_PTCR) Transmitter Transfer Enable */ -#define DACC_PTCR_TXTDIS (0x1 << 9) /**< \brief (DACC_PTCR) Transmitter Transfer Disable */ -/* -------- DACC_PTSR : (DACC Offset: 0x124) Transfer Status Register -------- */ -#define DACC_PTSR_RXTEN (0x1 << 0) /**< \brief (DACC_PTSR) Receiver Transfer Enable */ -#define DACC_PTSR_TXTEN (0x1 << 8) /**< \brief (DACC_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Embedded Flash Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_EFC Embedded Flash Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Efc hardware registers */ -typedef struct { - RwReg EEFC_FMR; /**< \brief (Efc Offset: 0x00) EEFC Flash Mode Register */ - WoReg EEFC_FCR; /**< \brief (Efc Offset: 0x04) EEFC Flash Command Register */ - RoReg EEFC_FSR; /**< \brief (Efc Offset: 0x08) EEFC Flash Status Register */ - RoReg EEFC_FRR; /**< \brief (Efc Offset: 0x0C) EEFC Flash Result Register */ -} Efc; -#endif /* __ASSEMBLY__ */ -/* -------- EEFC_FMR : (EFC Offset: 0x00) EEFC Flash Mode Register -------- */ -#define EEFC_FMR_FRDY (0x1 << 0) /**< \brief (EEFC_FMR) Ready Interrupt Enable */ -#define EEFC_FMR_FWS (0xf << 8) /**< \brief (EEFC_FMR) Flash Wait State */ -#define EEFC_FMR_FAM (0x1 << 24) /**< \brief (EEFC_FMR) Flash Access Mode */ -/* -------- EEFC_FCR : (EFC Offset: 0x04) EEFC Flash Command Register -------- */ -#define EEFC_FCR_FCMD (0xff << 0) /**< \brief (EEFC_FCR) Flash Command */ -#define EEFC_FCR_FARG (0xffff << 8) /**< \brief (EEFC_FCR) Flash Command Argument */ -#define EEFC_FCR_FKEY (0xff << 24) /**< \brief (EEFC_FCR) Flash Writing Protection Key */ -/* -------- EEFC_FSR : (EFC Offset: 0x08) EEFC Flash Status Register -------- */ -#define EEFC_FSR_FRDY (0x1 << 0) /**< \brief (EEFC_FSR) Flash Ready Status */ -#define EEFC_FSR_FCMDE (0x1 << 1) /**< \brief (EEFC_FSR) Flash Command Error Status */ -#define EEFC_FSR_FLOCKE (0x1 << 2) /**< \brief (EEFC_FSR) Flash Lock Error Status */ -/* -------- EEFC_FRR : (EFC Offset: 0x0C) EEFC Flash Result Register -------- */ -#define EEFC_FRR_FVALUE (0xffffffff << 0) /**< \brief (EEFC_FRR) Flash Result Value */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR General Purpose Backup Register */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_GPBR General Purpose Backup Register */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Gpbr hardware registers */ -typedef struct { - RwReg SYS_GPBR0; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register 0 */ - RwReg SYS_GPBR1; /**< \brief (Gpbr Offset: 0x4) General Purpose Backup Register 1 */ - RwReg SYS_GPBR2; /**< \brief (Gpbr Offset: 0x8) General Purpose Backup Register 2 */ - RwReg SYS_GPBR3; /**< \brief (Gpbr Offset: 0xC) General Purpose Backup Register 3 */ -} Gpbr; -#endif /* __ASSEMBLY__ */ -/* -------- SYS_GPBR0 : (GPBR Offset: 0x0) General Purpose Backup Register 0 -------- */ -#define SYS_GPBR0_GPBR_VALUE0 (0xffffffff << 0) /**< \brief (SYS_GPBR0) Value of GPBR x */ -/* -------- SYS_GPBR1 : (GPBR Offset: 0x4) General Purpose Backup Register 1 -------- */ -#define SYS_GPBR1_GPBR_VALUE1 (0xffffffff << 0) /**< \brief (SYS_GPBR1) Value of GPBR x */ -/* -------- SYS_GPBR2 : (GPBR Offset: 0x8) General Purpose Backup Register 2 -------- */ -#define SYS_GPBR2_GPBR_VALUE2 (0xffffffff << 0) /**< \brief (SYS_GPBR2) Value of GPBR x */ -/* -------- SYS_GPBR3 : (GPBR Offset: 0xC) General Purpose Backup Register 3 -------- */ -#define SYS_GPBR3_GPBR_VALUE3 (0xffffffff << 0) /**< \brief (SYS_GPBR3) Value of GPBR x */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR High Speed MultiMedia Card Interface */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_HSMCI High Speed MultiMedia Card Interface */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Hsmci hardware registers */ -typedef struct { - WoReg HSMCI_CR; /**< \brief (Hsmci Offset: 0x00) Control Register */ - RwReg HSMCI_MR; /**< \brief (Hsmci Offset: 0x04) Mode Register */ - RwReg HSMCI_DTOR; /**< \brief (Hsmci Offset: 0x08) Data Timeout Register */ - RwReg HSMCI_SDCR; /**< \brief (Hsmci Offset: 0x0C) SD/SDIO Card Register */ - RwReg HSMCI_ARGR; /**< \brief (Hsmci Offset: 0x10) Argument Register */ - WoReg HSMCI_CMDR; /**< \brief (Hsmci Offset: 0x14) Command Register */ - RwReg HSMCI_BLKR; /**< \brief (Hsmci Offset: 0x18) Block Register */ - RwReg HSMCI_CSTOR; /**< \brief (Hsmci Offset: 0x1C) Completion Signal Timeout Register */ - RoReg HSMCI_RSPR[4]; /**< \brief (Hsmci Offset: 0x20) Response Register */ - RoReg HSMCI_RDR; /**< \brief (Hsmci Offset: 0x30) Receive Data Register */ - WoReg HSMCI_TDR; /**< \brief (Hsmci Offset: 0x34) Transmit Data Register */ - RwReg Reserved1[2]; - RoReg HSMCI_SR; /**< \brief (Hsmci Offset: 0x40) Status Register */ - WoReg HSMCI_IER; /**< \brief (Hsmci Offset: 0x44) Interrupt Enable Register */ - WoReg HSMCI_IDR; /**< \brief (Hsmci Offset: 0x48) Interrupt Disable Register */ - RoReg HSMCI_IMR; /**< \brief (Hsmci Offset: 0x4C) Interrupt Mask Register */ - RwReg Reserved2[1]; - RwReg HSMCI_CFG; /**< \brief (Hsmci Offset: 0x54) Configuration Register */ - RwReg Reserved3[35]; - RwReg HSMCI_WPMR; /**< \brief (Hsmci Offset: 0xE4) Write Protection Mode Register */ - RoReg HSMCI_WPSR; /**< \brief (Hsmci Offset: 0xE8) Write Protection Status Register */ - RwReg Reserved4[5]; - RwReg HSMCI_RPR; /**< \brief (Hsmci Offset: 0x100) Receive Pointer Register */ - RwReg HSMCI_RCR; /**< \brief (Hsmci Offset: 0x104) Receive Counter Register */ - RwReg HSMCI_TPR; /**< \brief (Hsmci Offset: 0x108) Transmit Pointer Register */ - RwReg HSMCI_TCR; /**< \brief (Hsmci Offset: 0x10C) Transmit Counter Register */ - RwReg HSMCI_RNPR; /**< \brief (Hsmci Offset: 0x110) Receive Next Pointer Register */ - RwReg HSMCI_RNCR; /**< \brief (Hsmci Offset: 0x114) Receive Next Counter Register */ - RwReg HSMCI_TNPR; /**< \brief (Hsmci Offset: 0x118) Transmit Next Pointer Register */ - RwReg HSMCI_TNCR; /**< \brief (Hsmci Offset: 0x11C) Transmit Next Counter Register */ - WoReg HSMCI_PTCR; /**< \brief (Hsmci Offset: 0x120) Transfer Control Register */ - RoReg HSMCI_PTSR; /**< \brief (Hsmci Offset: 0x124) Transfer Status Register */ -} Hsmci; -#endif /* __ASSEMBLY__ */ -/* -------- HSMCI_CR : (HSMCI Offset: 0x00) Control Register -------- */ -#define HSMCI_CR_MCIEN (0x1 << 0) /**< \brief (HSMCI_CR) Multi-Media Interface Enable */ -#define HSMCI_CR_MCIDIS (0x1 << 1) /**< \brief (HSMCI_CR) Multi-Media Interface Disable */ -#define HSMCI_CR_PWSEN (0x1 << 2) /**< \brief (HSMCI_CR) Power Save Mode Enable */ -#define HSMCI_CR_PWSDIS (0x1 << 3) /**< \brief (HSMCI_CR) Power Save Mode Disable */ -#define HSMCI_CR_SWRST (0x1 << 7) /**< \brief (HSMCI_CR) Software Reset */ -/* -------- HSMCI_MR : (HSMCI Offset: 0x04) Mode Register -------- */ -#define HSMCI_MR_CLKDIV (0xff << 0) /**< \brief (HSMCI_MR) Clock Divider */ -#define HSMCI_MR_PWSDIV (0x7 << 8) /**< \brief (HSMCI_MR) Power Saving Divider */ -#define HSMCI_MR_RDPROOF (0x1 << 11) /**< \brief (HSMCI_MR) */ -#define HSMCI_MR_WRPROOF (0x1 << 12) /**< \brief (HSMCI_MR) */ -#define HSMCI_MR_FBYTE (0x1 << 13) /**< \brief (HSMCI_MR) Force Byte Transfer */ -#define HSMCI_MR_PADV (0x1 << 14) /**< \brief (HSMCI_MR) Padding Value */ -#define HSMCI_MR_PDCMODE (0x1 << 15) /**< \brief (HSMCI_MR) PDC-oriented Mode */ -#define HSMCI_MR_BLKLEN (0xffff << 16) /**< \brief (HSMCI_MR) Data Block Length */ -/* -------- HSMCI_DTOR : (HSMCI Offset: 0x08) Data Timeout Register -------- */ -#define HSMCI_DTOR_DTOCYC (0xf << 0) /**< \brief (HSMCI_DTOR) Data Timeout Cycle Number */ -#define HSMCI_DTOR_DTOMUL (0x7 << 4) /**< \brief (HSMCI_DTOR) Data Timeout Multiplier */ -/* -------- HSMCI_SDCR : (HSMCI Offset: 0x0C) SD/SDIO Card Register -------- */ -#define HSMCI_SDCR_SDCSEL (0x3 << 0) /**< \brief (HSMCI_SDCR) SDCard/SDIO Slot */ -#define HSMCI_SDCR_SDCBUS (0x3 << 6) /**< \brief (HSMCI_SDCR) SDCard/SDIO Bus Width */ -/* -------- HSMCI_ARGR : (HSMCI Offset: 0x10) Argument Register -------- */ -#define HSMCI_ARGR_ARG (0xffffffff << 0) /**< \brief (HSMCI_ARGR) Command Argument */ -/* -------- HSMCI_CMDR : (HSMCI Offset: 0x14) Command Register -------- */ -#define HSMCI_CMDR_CMDNB (0x3f << 0) /**< \brief (HSMCI_CMDR) Command Number */ -#define HSMCI_CMDR_RSPTYP (0x3 << 6) /**< \brief (HSMCI_CMDR) Response Type */ -#define HSMCI_CMDR_SPCMD (0x7 << 8) /**< \brief (HSMCI_CMDR) Special Command */ -#define HSMCI_CMDR_OPDCMD (0x1 << 11) /**< \brief (HSMCI_CMDR) Open Drain Command */ -#define HSMCI_CMDR_MAXLAT (0x1 << 12) /**< \brief (HSMCI_CMDR) Max Latency for Command to Response */ -#define HSMCI_CMDR_TRCMD (0x3 << 16) /**< \brief (HSMCI_CMDR) Transfer Command */ -#define HSMCI_CMDR_TRDIR (0x1 << 18) /**< \brief (HSMCI_CMDR) Transfer Direction */ -#define HSMCI_CMDR_TRTYP (0x7 << 19) /**< \brief (HSMCI_CMDR) Transfer Type */ -#define HSMCI_CMDR_IOSPCMD (0x3 << 24) /**< \brief (HSMCI_CMDR) SDIO Special Command */ -#define HSMCI_CMDR_ATACS (0x1 << 26) /**< \brief (HSMCI_CMDR) ATA with Command Completion Signal */ -#define HSMCI_CMDR_BOOT_ACK (0x1 << 27) /**< \brief (HSMCI_CMDR) Boot Operation Acknowledge. */ -/* -------- HSMCI_BLKR : (HSMCI Offset: 0x18) Block Register -------- */ -#define HSMCI_BLKR_BCNT (0xffff << 0) /**< \brief (HSMCI_BLKR) MMC/SDIO Block Count - SDIO Byte Count */ -#define HSMCI_BLKR_BLKLEN (0xffff << 16) /**< \brief (HSMCI_BLKR) Data Block Length */ -/* -------- HSMCI_CSTOR : (HSMCI Offset: 0x1C) Completion Signal Timeout Register -------- */ -#define HSMCI_CSTOR_CSTOCYC (0xf << 0) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Cycle Number */ -#define HSMCI_CSTOR_CSTOMUL (0x7 << 4) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Multiplier */ -/* -------- HSMCI_RSPR[4] : (HSMCI Offset: 0x20) Response Register -------- */ -#define HSMCI_RSPR_RSP (0xffffffff << 0) /**< \brief (HSMCI_RSPR[4]) Response */ -/* -------- HSMCI_RDR : (HSMCI Offset: 0x30) Receive Data Register -------- */ -#define HSMCI_RDR_DATA (0xffffffff << 0) /**< \brief (HSMCI_RDR) Data to Read */ -/* -------- HSMCI_TDR : (HSMCI Offset: 0x34) Transmit Data Register -------- */ -#define HSMCI_TDR_DATA (0xffffffff << 0) /**< \brief (HSMCI_TDR) Data to Write */ -/* -------- HSMCI_SR : (HSMCI Offset: 0x40) Status Register -------- */ -#define HSMCI_SR_CMDRDY (0x1 << 0) /**< \brief (HSMCI_SR) Command Ready */ -#define HSMCI_SR_RXRDY (0x1 << 1) /**< \brief (HSMCI_SR) Receiver Ready */ -#define HSMCI_SR_TXRDY (0x1 << 2) /**< \brief (HSMCI_SR) Transmit Ready */ -#define HSMCI_SR_BLKE (0x1 << 3) /**< \brief (HSMCI_SR) Data Block Ended */ -#define HSMCI_SR_DTIP (0x1 << 4) /**< \brief (HSMCI_SR) Data Transfer in Progress */ -#define HSMCI_SR_NOTBUSY (0x1 << 5) /**< \brief (HSMCI_SR) HSMCI Not Busy */ -#define HSMCI_SR_ENDRX (0x1 << 6) /**< \brief (HSMCI_SR) End of RX Buffer */ -#define HSMCI_SR_ENDTX (0x1 << 7) /**< \brief (HSMCI_SR) End of TX Buffer */ -#define HSMCI_SR_SDIOIRQA (0x1 << 8) /**< \brief (HSMCI_SR) SDIO Interrupt for Slot A */ -#define HSMCI_SR_SDIOWAIT (0x1 << 12) /**< \brief (HSMCI_SR) SDIO Read Wait Operation Status */ -#define HSMCI_SR_CSRCV (0x1 << 13) /**< \brief (HSMCI_SR) CE-ATA Completion Signal Received */ -#define HSMCI_SR_RXBUFF (0x1 << 14) /**< \brief (HSMCI_SR) RX Buffer Full */ -#define HSMCI_SR_TXBUFE (0x1 << 15) /**< \brief (HSMCI_SR) TX Buffer Empty */ -#define HSMCI_SR_RINDE (0x1 << 16) /**< \brief (HSMCI_SR) Response Index Error */ -#define HSMCI_SR_RDIRE (0x1 << 17) /**< \brief (HSMCI_SR) Response Direction Error */ -#define HSMCI_SR_RCRCE (0x1 << 18) /**< \brief (HSMCI_SR) Response CRC Error */ -#define HSMCI_SR_RENDE (0x1 << 19) /**< \brief (HSMCI_SR) Response End Bit Error */ -#define HSMCI_SR_RTOE (0x1 << 20) /**< \brief (HSMCI_SR) Response Time-out Error */ -#define HSMCI_SR_DCRCE (0x1 << 21) /**< \brief (HSMCI_SR) Data CRC Error */ -#define HSMCI_SR_DTOE (0x1 << 22) /**< \brief (HSMCI_SR) Data Time-out Error */ -#define HSMCI_SR_CSTOE (0x1 << 23) /**< \brief (HSMCI_SR) Completion Signal Time-out Error */ -#define HSMCI_SR_FIFOEMPTY (0x1 << 26) /**< \brief (HSMCI_SR) FIFO empty flag */ -#define HSMCI_SR_XFRDONE (0x1 << 27) /**< \brief (HSMCI_SR) Transfer Done flag */ -#define HSMCI_SR_ACKRCV (0x1 << 28) /**< \brief (HSMCI_SR) Boot Operation Acknowledge Received */ -#define HSMCI_SR_ACKRCVE (0x1 << 29) /**< \brief (HSMCI_SR) Boot Operation Acknowledge Error */ -#define HSMCI_SR_OVRE (0x1 << 30) /**< \brief (HSMCI_SR) Overrun */ -#define HSMCI_SR_UNRE (0x1 << 31) /**< \brief (HSMCI_SR) Underrun */ -/* -------- HSMCI_IER : (HSMCI Offset: 0x44) Interrupt Enable Register -------- */ -#define HSMCI_IER_CMDRDY (0x1 << 0) /**< \brief (HSMCI_IER) Command Ready Interrupt Enable */ -#define HSMCI_IER_RXRDY (0x1 << 1) /**< \brief (HSMCI_IER) Receiver Ready Interrupt Enable */ -#define HSMCI_IER_TXRDY (0x1 << 2) /**< \brief (HSMCI_IER) Transmit Ready Interrupt Enable */ -#define HSMCI_IER_BLKE (0x1 << 3) /**< \brief (HSMCI_IER) Data Block Ended Interrupt Enable */ -#define HSMCI_IER_DTIP (0x1 << 4) /**< \brief (HSMCI_IER) Data Transfer in Progress Interrupt Enable */ -#define HSMCI_IER_NOTBUSY (0x1 << 5) /**< \brief (HSMCI_IER) Data Not Busy Interrupt Enable */ -#define HSMCI_IER_ENDRX (0x1 << 6) /**< \brief (HSMCI_IER) End of Receive Buffer Interrupt Enable */ -#define HSMCI_IER_ENDTX (0x1 << 7) /**< \brief (HSMCI_IER) End of Transmit Buffer Interrupt Enable */ -#define HSMCI_IER_SDIOIRQA (0x1 << 8) /**< \brief (HSMCI_IER) SDIO Interrupt for Slot A Interrupt Enable */ -#define HSMCI_IER_SDIOWAIT (0x1 << 12) /**< \brief (HSMCI_IER) SDIO Read Wait Operation Status Interrupt Enable */ -#define HSMCI_IER_CSRCV (0x1 << 13) /**< \brief (HSMCI_IER) Completion Signal Received Interrupt Enable */ -#define HSMCI_IER_RXBUFF (0x1 << 14) /**< \brief (HSMCI_IER) Receive Buffer Full Interrupt Enable */ -#define HSMCI_IER_TXBUFE (0x1 << 15) /**< \brief (HSMCI_IER) Transmit Buffer Empty Interrupt Enable */ -#define HSMCI_IER_RINDE (0x1 << 16) /**< \brief (HSMCI_IER) Response Index Error Interrupt Enable */ -#define HSMCI_IER_RDIRE (0x1 << 17) /**< \brief (HSMCI_IER) Response Direction Error Interrupt Enable */ -#define HSMCI_IER_RCRCE (0x1 << 18) /**< \brief (HSMCI_IER) Response CRC Error Interrupt Enable */ -#define HSMCI_IER_RENDE (0x1 << 19) /**< \brief (HSMCI_IER) Response End Bit Error Interrupt Enable */ -#define HSMCI_IER_RTOE (0x1 << 20) /**< \brief (HSMCI_IER) Response Time-out Error Interrupt Enable */ -#define HSMCI_IER_DCRCE (0x1 << 21) /**< \brief (HSMCI_IER) Data CRC Error Interrupt Enable */ -#define HSMCI_IER_DTOE (0x1 << 22) /**< \brief (HSMCI_IER) Data Time-out Error Interrupt Enable */ -#define HSMCI_IER_CSTOE (0x1 << 23) /**< \brief (HSMCI_IER) Completion Signal Timeout Error Interrupt Enable */ -#define HSMCI_IER_FIFOEMPTY (0x1 << 26) /**< \brief (HSMCI_IER) FIFO empty Interrupt enable */ -#define HSMCI_IER_XFRDONE (0x1 << 27) /**< \brief (HSMCI_IER) Transfer Done Interrupt enable */ -#define HSMCI_IER_ACKRCV (0x1 << 28) /**< \brief (HSMCI_IER) Boot Acknowledge Interrupt Enable */ -#define HSMCI_IER_ACKRCVE (0x1 << 29) /**< \brief (HSMCI_IER) Boot Acknowledge Error Interrupt Enable */ -#define HSMCI_IER_OVRE (0x1 << 30) /**< \brief (HSMCI_IER) Overrun Interrupt Enable */ -#define HSMCI_IER_UNRE (0x1 << 31) /**< \brief (HSMCI_IER) Underrun Interrupt Enable */ -/* -------- HSMCI_IDR : (HSMCI Offset: 0x48) Interrupt Disable Register -------- */ -#define HSMCI_IDR_CMDRDY (0x1 << 0) /**< \brief (HSMCI_IDR) Command Ready Interrupt Disable */ -#define HSMCI_IDR_RXRDY (0x1 << 1) /**< \brief (HSMCI_IDR) Receiver Ready Interrupt Disable */ -#define HSMCI_IDR_TXRDY (0x1 << 2) /**< \brief (HSMCI_IDR) Transmit Ready Interrupt Disable */ -#define HSMCI_IDR_BLKE (0x1 << 3) /**< \brief (HSMCI_IDR) Data Block Ended Interrupt Disable */ -#define HSMCI_IDR_DTIP (0x1 << 4) /**< \brief (HSMCI_IDR) Data Transfer in Progress Interrupt Disable */ -#define HSMCI_IDR_NOTBUSY (0x1 << 5) /**< \brief (HSMCI_IDR) Data Not Busy Interrupt Disable */ -#define HSMCI_IDR_ENDRX (0x1 << 6) /**< \brief (HSMCI_IDR) End of Receive Buffer Interrupt Disable */ -#define HSMCI_IDR_ENDTX (0x1 << 7) /**< \brief (HSMCI_IDR) End of Transmit Buffer Interrupt Disable */ -#define HSMCI_IDR_SDIOIRQA (0x1 << 8) /**< \brief (HSMCI_IDR) SDIO Interrupt for Slot A Interrupt Disable */ -#define HSMCI_IDR_SDIOWAIT (0x1 << 12) /**< \brief (HSMCI_IDR) SDIO Read Wait Operation Status Interrupt Disable */ -#define HSMCI_IDR_CSRCV (0x1 << 13) /**< \brief (HSMCI_IDR) Completion Signal received interrupt Disable */ -#define HSMCI_IDR_RXBUFF (0x1 << 14) /**< \brief (HSMCI_IDR) Receive Buffer Full Interrupt Disable */ -#define HSMCI_IDR_TXBUFE (0x1 << 15) /**< \brief (HSMCI_IDR) Transmit Buffer Empty Interrupt Disable */ -#define HSMCI_IDR_RINDE (0x1 << 16) /**< \brief (HSMCI_IDR) Response Index Error Interrupt Disable */ -#define HSMCI_IDR_RDIRE (0x1 << 17) /**< \brief (HSMCI_IDR) Response Direction Error Interrupt Disable */ -#define HSMCI_IDR_RCRCE (0x1 << 18) /**< \brief (HSMCI_IDR) Response CRC Error Interrupt Disable */ -#define HSMCI_IDR_RENDE (0x1 << 19) /**< \brief (HSMCI_IDR) Response End Bit Error Interrupt Disable */ -#define HSMCI_IDR_RTOE (0x1 << 20) /**< \brief (HSMCI_IDR) Response Time-out Error Interrupt Disable */ -#define HSMCI_IDR_DCRCE (0x1 << 21) /**< \brief (HSMCI_IDR) Data CRC Error Interrupt Disable */ -#define HSMCI_IDR_DTOE (0x1 << 22) /**< \brief (HSMCI_IDR) Data Time-out Error Interrupt Disable */ -#define HSMCI_IDR_CSTOE (0x1 << 23) /**< \brief (HSMCI_IDR) Completion Signal Time out Error Interrupt Disable */ -#define HSMCI_IDR_FIFOEMPTY (0x1 << 26) /**< \brief (HSMCI_IDR) FIFO empty Interrupt Disable */ -#define HSMCI_IDR_XFRDONE (0x1 << 27) /**< \brief (HSMCI_IDR) Transfer Done Interrupt Disable */ -#define HSMCI_IDR_ACKRCV (0x1 << 28) /**< \brief (HSMCI_IDR) Boot Acknowledge Interrupt Disable */ -#define HSMCI_IDR_ACKRCVE (0x1 << 29) /**< \brief (HSMCI_IDR) Boot Acknowledge Error Interrupt Disable */ -#define HSMCI_IDR_OVRE (0x1 << 30) /**< \brief (HSMCI_IDR) Overrun Interrupt Disable */ -#define HSMCI_IDR_UNRE (0x1 << 31) /**< \brief (HSMCI_IDR) Underrun Interrupt Disable */ -/* -------- HSMCI_IMR : (HSMCI Offset: 0x4C) Interrupt Mask Register -------- */ -#define HSMCI_IMR_CMDRDY (0x1 << 0) /**< \brief (HSMCI_IMR) Command Ready Interrupt Mask */ -#define HSMCI_IMR_RXRDY (0x1 << 1) /**< \brief (HSMCI_IMR) Receiver Ready Interrupt Mask */ -#define HSMCI_IMR_TXRDY (0x1 << 2) /**< \brief (HSMCI_IMR) Transmit Ready Interrupt Mask */ -#define HSMCI_IMR_BLKE (0x1 << 3) /**< \brief (HSMCI_IMR) Data Block Ended Interrupt Mask */ -#define HSMCI_IMR_DTIP (0x1 << 4) /**< \brief (HSMCI_IMR) Data Transfer in Progress Interrupt Mask */ -#define HSMCI_IMR_NOTBUSY (0x1 << 5) /**< \brief (HSMCI_IMR) Data Not Busy Interrupt Mask */ -#define HSMCI_IMR_ENDRX (0x1 << 6) /**< \brief (HSMCI_IMR) End of Receive Buffer Interrupt Mask */ -#define HSMCI_IMR_ENDTX (0x1 << 7) /**< \brief (HSMCI_IMR) End of Transmit Buffer Interrupt Mask */ -#define HSMCI_IMR_SDIOIRQA (0x1 << 8) /**< \brief (HSMCI_IMR) SDIO Interrupt for Slot A Interrupt Mask */ -#define HSMCI_IMR_SDIOWAIT (0x1 << 12) /**< \brief (HSMCI_IMR) SDIO Read Wait Operation Status Interrupt Mask */ -#define HSMCI_IMR_CSRCV (0x1 << 13) /**< \brief (HSMCI_IMR) Completion Signal Received Interrupt Mask */ -#define HSMCI_IMR_RXBUFF (0x1 << 14) /**< \brief (HSMCI_IMR) Receive Buffer Full Interrupt Mask */ -#define HSMCI_IMR_TXBUFE (0x1 << 15) /**< \brief (HSMCI_IMR) Transmit Buffer Empty Interrupt Mask */ -#define HSMCI_IMR_RINDE (0x1 << 16) /**< \brief (HSMCI_IMR) Response Index Error Interrupt Mask */ -#define HSMCI_IMR_RDIRE (0x1 << 17) /**< \brief (HSMCI_IMR) Response Direction Error Interrupt Mask */ -#define HSMCI_IMR_RCRCE (0x1 << 18) /**< \brief (HSMCI_IMR) Response CRC Error Interrupt Mask */ -#define HSMCI_IMR_RENDE (0x1 << 19) /**< \brief (HSMCI_IMR) Response End Bit Error Interrupt Mask */ -#define HSMCI_IMR_RTOE (0x1 << 20) /**< \brief (HSMCI_IMR) Response Time-out Error Interrupt Mask */ -#define HSMCI_IMR_DCRCE (0x1 << 21) /**< \brief (HSMCI_IMR) Data CRC Error Interrupt Mask */ -#define HSMCI_IMR_DTOE (0x1 << 22) /**< \brief (HSMCI_IMR) Data Time-out Error Interrupt Mask */ -#define HSMCI_IMR_CSTOE (0x1 << 23) /**< \brief (HSMCI_IMR) Completion Signal Time-out Error Interrupt Mask */ -#define HSMCI_IMR_FIFOEMPTY (0x1 << 26) /**< \brief (HSMCI_IMR) FIFO Empty Interrupt Mask */ -#define HSMCI_IMR_XFRDONE (0x1 << 27) /**< \brief (HSMCI_IMR) Transfer Done Interrupt Mask */ -#define HSMCI_IMR_ACKRCV (0x1 << 28) /**< \brief (HSMCI_IMR) Boot Operation Acknowledge Received Interrupt Mask */ -#define HSMCI_IMR_ACKRCVE (0x1 << 29) /**< \brief (HSMCI_IMR) Boot Operation Acknowledge Error Interrupt Mask */ -#define HSMCI_IMR_OVRE (0x1 << 30) /**< \brief (HSMCI_IMR) Overrun Interrupt Mask */ -#define HSMCI_IMR_UNRE (0x1 << 31) /**< \brief (HSMCI_IMR) Underrun Interrupt Mask */ -/* -------- HSMCI_CFG : (HSMCI Offset: 0x54) Configuration Register -------- */ -#define HSMCI_CFG_FIFOMODE (0x1 << 0) /**< \brief (HSMCI_CFG) HSMCI Internal FIFO control mode */ -#define HSMCI_CFG_FERRCTRL (0x1 << 4) /**< \brief (HSMCI_CFG) Flow Error flag reset control mode */ -#define HSMCI_CFG_HSMODE (0x1 << 8) /**< \brief (HSMCI_CFG) High Speed Mode */ -#define HSMCI_CFG_LSYNC (0x1 << 12) /**< \brief (HSMCI_CFG) Synchronize on the last block */ -/* -------- HSMCI_WPMR : (HSMCI Offset: 0xE4) Write Protection Mode Register -------- */ -#define HSMCI_WPMR_WP_EN (0x1 << 0) /**< \brief (HSMCI_WPMR) Write Protection Enable */ -#define HSMCI_WPMR_WP_KEY (0xffffff << 8) /**< \brief (HSMCI_WPMR) Write Protection Key password */ -/* -------- HSMCI_WPSR : (HSMCI Offset: 0xE8) Write Protection Status Register -------- */ -#define HSMCI_WPSR_WP_VS (0xf << 0) /**< \brief (HSMCI_WPSR) Write Protection Violation Status */ -#define HSMCI_WPSR_WP_VSRC (0xffff << 8) /**< \brief (HSMCI_WPSR) Write Protection Violation SouRCe */ -/* -------- HSMCI_RPR : (HSMCI Offset: 0x100) Receive Pointer Register -------- */ -#define HSMCI_RPR_RXPTR (0xffffffff << 0) /**< \brief (HSMCI_RPR) Receive Pointer Register */ -/* -------- HSMCI_RCR : (HSMCI Offset: 0x104) Receive Counter Register -------- */ -#define HSMCI_RCR_RXCTR (0xffff << 0) /**< \brief (HSMCI_RCR) Receive Counter Register */ -/* -------- HSMCI_TPR : (HSMCI Offset: 0x108) Transmit Pointer Register -------- */ -#define HSMCI_TPR_TXPTR (0xffffffff << 0) /**< \brief (HSMCI_TPR) Transmit Counter Register */ -/* -------- HSMCI_TCR : (HSMCI Offset: 0x10C) Transmit Counter Register -------- */ -#define HSMCI_TCR_TXCTR (0xffff << 0) /**< \brief (HSMCI_TCR) Transmit Counter Register */ -/* -------- HSMCI_RNPR : (HSMCI Offset: 0x110) Receive Next Pointer Register -------- */ -#define HSMCI_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (HSMCI_RNPR) Receive Next Pointer */ -/* -------- HSMCI_RNCR : (HSMCI Offset: 0x114) Receive Next Counter Register -------- */ -#define HSMCI_RNCR_RXNCTR (0xffff << 0) /**< \brief (HSMCI_RNCR) Receive Next Counter */ -/* -------- HSMCI_TNPR : (HSMCI Offset: 0x118) Transmit Next Pointer Register -------- */ -#define HSMCI_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (HSMCI_TNPR) Transmit Next Pointer */ -/* -------- HSMCI_TNCR : (HSMCI Offset: 0x11C) Transmit Next Counter Register -------- */ -#define HSMCI_TNCR_TXNCTR (0xffff << 0) /**< \brief (HSMCI_TNCR) Transmit Counter Next */ -/* -------- HSMCI_PTCR : (HSMCI Offset: 0x120) Transfer Control Register -------- */ -#define HSMCI_PTCR_RXTEN (0x1 << 0) /**< \brief (HSMCI_PTCR) Receiver Transfer Enable */ -#define HSMCI_PTCR_RXTDIS (0x1 << 1) /**< \brief (HSMCI_PTCR) Receiver Transfer Disable */ -#define HSMCI_PTCR_TXTEN (0x1 << 8) /**< \brief (HSMCI_PTCR) Transmitter Transfer Enable */ -#define HSMCI_PTCR_TXTDIS (0x1 << 9) /**< \brief (HSMCI_PTCR) Transmitter Transfer Disable */ -/* -------- HSMCI_PTSR : (HSMCI Offset: 0x124) Transfer Status Register -------- */ -#define HSMCI_PTSR_RXTEN (0x1 << 0) /**< \brief (HSMCI_PTSR) Receiver Transfer Enable */ -#define HSMCI_PTSR_TXTEN (0x1 << 8) /**< \brief (HSMCI_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR AHB Bus Matrix */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_MATRIX AHB Bus Matrix */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Matrix hardware registers */ -typedef struct { - RwReg MATRIX_MCFG[4]; /**< \brief (Matrix Offset: 0x0000) Master Configuration Register */ - RwReg Reserved1[12]; - RwReg MATRIX_SCFG[5]; /**< \brief (Matrix Offset: 0x0040) Slave Configuration Register */ - RwReg Reserved2[11]; - RwReg MATRIX_PRAS0; /**< \brief (Matrix Offset: 0x0080) Priority Register A for Slave 0 */ - RwReg Reserved3[1]; - RwReg MATRIX_PRAS1; /**< \brief (Matrix Offset: 0x0088) Priority Register A for Slave 1 */ - RwReg Reserved4[1]; - RwReg MATRIX_PRAS2; /**< \brief (Matrix Offset: 0x0090) Priority Register A for Slave 2 */ - RwReg Reserved5[1]; - RwReg MATRIX_PRAS3; /**< \brief (Matrix Offset: 0x0098) Priority Register A for Slave 3 */ - RwReg Reserved6[1]; - RwReg MATRIX_PRAS4; /**< \brief (Matrix Offset: 0x00A0) Priority Register A for Slave 4 */ - RwReg Reserved7[28]; - RwReg CCFG_SYSIO; /**< \brief (Matrix Offset: 0x0114) System IO Configuration register */ - RwReg Reserved8[1]; - RwReg CCFG_SMCNFCS; /**< \brief (Matrix Offset: 0x011C) SMC Chip Select NAND Flash Assignment Register */ - RwReg Reserved9[49]; - RwReg MATRIX_WPMR; /**< \brief (Matrix Offset: 0x1E4) Write Protect Mode Register */ - RoReg MATRIX_WPSR; /**< \brief (Matrix Offset: 0x1E8) Write Protect Status Register */ -} Matrix; -#endif /* __ASSEMBLY__ */ -/* -------- MATRIX_MCFG[4] : (MATRIX Offset: 0x0000) Master Configuration Register -------- */ -#define MATRIX_MCFG_ULBT (0x7 << 0) /**< \brief (MATRIX_MCFG[4]) Undefined Length Burst Type */ -/* -------- MATRIX_SCFG[5] : (MATRIX Offset: 0x0040) Slave Configuration Register -------- */ -#define MATRIX_SCFG_SLOT_CYCLE (0xff << 0) /**< \brief (MATRIX_SCFG[5]) Maximum Number of Allowed Cycles for a Burst */ -#define MATRIX_SCFG_DEFMSTR_TYPE (0x3 << 16) /**< \brief (MATRIX_SCFG[5]) Default Master Type */ -#define MATRIX_SCFG_FIXED_DEFMSTR (0x7 << 18) /**< \brief (MATRIX_SCFG[5]) Fixed Default Master */ -#define MATRIX_SCFG_ARBT (0x3 << 24) /**< \brief (MATRIX_SCFG[5]) Arbitration Type */ -/* -------- MATRIX_PRAS0 : (MATRIX Offset: 0x0080) Priority Register A for Slave 0 -------- */ -#define MATRIX_PRAS0_M0PR (0x3 << 0) /**< \brief (MATRIX_PRAS0) Master 0 Priority */ -#define MATRIX_PRAS0_M1PR (0x3 << 4) /**< \brief (MATRIX_PRAS0) Master 1 Priority */ -#define MATRIX_PRAS0_M2PR (0x3 << 8) /**< \brief (MATRIX_PRAS0) Master 2 Priority */ -#define MATRIX_PRAS0_M3PR (0x3 << 12) /**< \brief (MATRIX_PRAS0) Master 3 Priority */ -#define MATRIX_PRAS0_M4PR (0x3 << 16) /**< \brief (MATRIX_PRAS0) Master 4 Priority */ -/* -------- MATRIX_PRAS1 : (MATRIX Offset: 0x0088) Priority Register A for Slave 1 -------- */ -#define MATRIX_PRAS1_M0PR (0x3 << 0) /**< \brief (MATRIX_PRAS1) Master 0 Priority */ -#define MATRIX_PRAS1_M1PR (0x3 << 4) /**< \brief (MATRIX_PRAS1) Master 1 Priority */ -#define MATRIX_PRAS1_M2PR (0x3 << 8) /**< \brief (MATRIX_PRAS1) Master 2 Priority */ -#define MATRIX_PRAS1_M3PR (0x3 << 12) /**< \brief (MATRIX_PRAS1) Master 3 Priority */ -#define MATRIX_PRAS1_M4PR (0x3 << 16) /**< \brief (MATRIX_PRAS1) Master 4 Priority */ -/* -------- MATRIX_PRAS2 : (MATRIX Offset: 0x0090) Priority Register A for Slave 2 -------- */ -#define MATRIX_PRAS2_M0PR (0x3 << 0) /**< \brief (MATRIX_PRAS2) Master 0 Priority */ -#define MATRIX_PRAS2_M1PR (0x3 << 4) /**< \brief (MATRIX_PRAS2) Master 1 Priority */ -#define MATRIX_PRAS2_M2PR (0x3 << 8) /**< \brief (MATRIX_PRAS2) Master 2 Priority */ -#define MATRIX_PRAS2_M3PR (0x3 << 12) /**< \brief (MATRIX_PRAS2) Master 3 Priority */ -#define MATRIX_PRAS2_M4PR (0x3 << 16) /**< \brief (MATRIX_PRAS2) Master 4 Priority */ -/* -------- MATRIX_PRAS3 : (MATRIX Offset: 0x0098) Priority Register A for Slave 3 -------- */ -#define MATRIX_PRAS3_M0PR (0x3 << 0) /**< \brief (MATRIX_PRAS3) Master 0 Priority */ -#define MATRIX_PRAS3_M1PR (0x3 << 4) /**< \brief (MATRIX_PRAS3) Master 1 Priority */ -#define MATRIX_PRAS3_M2PR (0x3 << 8) /**< \brief (MATRIX_PRAS3) Master 2 Priority */ -#define MATRIX_PRAS3_M3PR (0x3 << 12) /**< \brief (MATRIX_PRAS3) Master 3 Priority */ -#define MATRIX_PRAS3_M4PR (0x3 << 16) /**< \brief (MATRIX_PRAS3) Master 4 Priority */ -/* -------- MATRIX_PRAS4 : (MATRIX Offset: 0x00A0) Priority Register A for Slave 4 -------- */ -#define MATRIX_PRAS4_M0PR (0x3 << 0) /**< \brief (MATRIX_PRAS4) Master 0 Priority */ -#define MATRIX_PRAS4_M1PR (0x3 << 4) /**< \brief (MATRIX_PRAS4) Master 1 Priority */ -#define MATRIX_PRAS4_M2PR (0x3 << 8) /**< \brief (MATRIX_PRAS4) Master 2 Priority */ -#define MATRIX_PRAS4_M3PR (0x3 << 12) /**< \brief (MATRIX_PRAS4) Master 3 Priority */ -#define MATRIX_PRAS4_M4PR (0x3 << 16) /**< \brief (MATRIX_PRAS4) Master 4 Priority */ -/* -------- CCFG_SYSIO : (MATRIX Offset: 0x0114) System IO Configuration register -------- */ -#define CCFG_SYSIO_SYSIO4 (0x1 << 4) /**< \brief (CCFG_SYSIO) PB4 or TDI Assignment */ -#define CCFG_SYSIO_SYSIO5 (0x1 << 5) /**< \brief (CCFG_SYSIO) PB5 or TDO/TRACESWO Assignment */ -#define CCFG_SYSIO_SYSIO6 (0x1 << 6) /**< \brief (CCFG_SYSIO) PB6 or TMS/SWDIO Assignment */ -#define CCFG_SYSIO_SYSIO7 (0x1 << 7) /**< \brief (CCFG_SYSIO) PB7 or TCK/SWCLK Assignment */ -#define CCFG_SYSIO_SYSIO10 (0x1 << 10) /**< \brief (CCFG_SYSIO) PB10 or DDM Assignment */ -#define CCFG_SYSIO_SYSIO11 (0x1 << 11) /**< \brief (CCFG_SYSIO) PB11 or DDP Assignment */ -#define CCFG_SYSIO_SYSIO12 (0x1 << 12) /**< \brief (CCFG_SYSIO) PB12 or ERASE Assignment */ -/* -------- CCFG_SMCNFCS : (MATRIX Offset: 0x011C) SMC Chip Select NAND Flash Assignment Register -------- */ -#define CCFG_SMCNFCS_SMC_NFCS0 (0x1 << 0) /**< \brief (CCFG_SMCNFCS) SMC NAND Flash Chip Select 0 Assignment */ -#define CCFG_SMCNFCS_SMC_NFCS1 (0x1 << 1) /**< \brief (CCFG_SMCNFCS) SMC NAND Flash Chip Select 1 Assignment */ -#define CCFG_SMCNFCS_SMC_NFCS2 (0x1 << 2) /**< \brief (CCFG_SMCNFCS) SMC NAND Flash Chip Select 2 Assignment */ -#define CCFG_SMCNFCS_SMC_NFCS3 (0x1 << 3) /**< \brief (CCFG_SMCNFCS) SMC NAND Flash Chip Select 3 Assignment */ -/* -------- MATRIX_WPMR : (MATRIX Offset: 0x1E4) Write Protect Mode Register -------- */ -#define MATRIX_WPMR_WPEN (0x1 << 0) /**< \brief (MATRIX_WPMR) Write Protect ENable */ -#define MATRIX_WPMR_WPKEY (0xffffff << 8) /**< \brief (MATRIX_WPMR) Write Protect KEY (Write-only) */ -/* -------- MATRIX_WPSR : (MATRIX Offset: 0x1E8) Write Protect Status Register -------- */ -#define MATRIX_WPSR_WPVS (0x1 << 0) /**< \brief (MATRIX_WPSR) Write Protect Violation Status */ -#define MATRIX_WPSR_WPVSRC (0xffff << 8) /**< \brief (MATRIX_WPSR) Write Protect Violation Source */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Peripheral DMA Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_PDC Peripheral DMA Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Pdc hardware registers */ -typedef struct { - RwReg Reserved1[64]; - RwReg PERIPH_RPR; /**< \brief (Pdc Offset: 0x100) Receive Pointer Register */ - RwReg PERIPH_RCR; /**< \brief (Pdc Offset: 0x104) Receive Counter Register */ - RwReg PERIPH_TPR; /**< \brief (Pdc Offset: 0x108) Transmit Pointer Register */ - RwReg PERIPH_TCR; /**< \brief (Pdc Offset: 0x10C) Transmit Counter Register */ - RwReg PERIPH_RNPR; /**< \brief (Pdc Offset: 0x110) Receive Next Pointer Register */ - RwReg PERIPH_RNCR; /**< \brief (Pdc Offset: 0x114) Receive Next Counter Register */ - RwReg PERIPH_TNPR; /**< \brief (Pdc Offset: 0x118) Transmit Next Pointer Register */ - RwReg PERIPH_TNCR; /**< \brief (Pdc Offset: 0x11C) Transmit Next Counter Register */ - WoReg PERIPH_PTCR; /**< \brief (Pdc Offset: 0x120) Transfer Control Register */ - RoReg PERIPH_PTSR; /**< \brief (Pdc Offset: 0x124) Transfer Status Register */ -} Pdc; -#endif /* __ASSEMBLY__ */ -/* -------- PERIPH_RPR : (PDC Offset: 0x100) Receive Pointer Register -------- */ -#define PERIPH_RPR_RXPTR (0xffffffff << 0) /**< \brief (PERIPH_RPR) Receive Pointer Register */ -/* -------- PERIPH_RCR : (PDC Offset: 0x104) Receive Counter Register -------- */ -#define PERIPH_RCR_RXCTR (0xffff << 0) /**< \brief (PERIPH_RCR) Receive Counter Register */ -/* -------- PERIPH_TPR : (PDC Offset: 0x108) Transmit Pointer Register -------- */ -#define PERIPH_TPR_TXPTR (0xffffffff << 0) /**< \brief (PERIPH_TPR) Transmit Counter Register */ -/* -------- PERIPH_TCR : (PDC Offset: 0x10C) Transmit Counter Register -------- */ -#define PERIPH_TCR_TXCTR (0xffff << 0) /**< \brief (PERIPH_TCR) Transmit Counter Register */ -/* -------- PERIPH_RNPR : (PDC Offset: 0x110) Receive Next Pointer Register -------- */ -#define PERIPH_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (PERIPH_RNPR) Receive Next Pointer */ -/* -------- PERIPH_RNCR : (PDC Offset: 0x114) Receive Next Counter Register -------- */ -#define PERIPH_RNCR_RXNCTR (0xffff << 0) /**< \brief (PERIPH_RNCR) Receive Next Counter */ -/* -------- PERIPH_TNPR : (PDC Offset: 0x118) Transmit Next Pointer Register -------- */ -#define PERIPH_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (PERIPH_TNPR) Transmit Next Pointer */ -/* -------- PERIPH_TNCR : (PDC Offset: 0x11C) Transmit Next Counter Register -------- */ -#define PERIPH_TNCR_TXNCTR (0xffff << 0) /**< \brief (PERIPH_TNCR) Transmit Counter Next */ -/* -------- PERIPH_PTCR : (PDC Offset: 0x120) Transfer Control Register -------- */ -#define PERIPH_PTCR_RXTEN (0x1 << 0) /**< \brief (PERIPH_PTCR) Receiver Transfer Enable */ -#define PERIPH_PTCR_RXTDIS (0x1 << 1) /**< \brief (PERIPH_PTCR) Receiver Transfer Disable */ -#define PERIPH_PTCR_TXTEN (0x1 << 8) /**< \brief (PERIPH_PTCR) Transmitter Transfer Enable */ -#define PERIPH_PTCR_TXTDIS (0x1 << 9) /**< \brief (PERIPH_PTCR) Transmitter Transfer Disable */ -/* -------- PERIPH_PTSR : (PDC Offset: 0x124) Transfer Status Register -------- */ -#define PERIPH_PTSR_RXTEN (0x1 << 0) /**< \brief (PERIPH_PTSR) Receiver Transfer Enable */ -#define PERIPH_PTSR_TXTEN (0x1 << 8) /**< \brief (PERIPH_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Parallel Input/Output */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_PIO Parallel Input/Output */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Pio hardware registers */ -typedef struct { - WoReg PIO_PER; /**< \brief (Pio Offset: 0x0000) PIO Enable Register */ - WoReg PIO_PDR; /**< \brief (Pio Offset: 0x0004) PIO Disable Register */ - RoReg PIO_PSR; /**< \brief (Pio Offset: 0x0008) PIO Status Register */ - RwReg Reserved1[1]; - WoReg PIO_OER; /**< \brief (Pio Offset: 0x0010) Output Enable Register */ - WoReg PIO_ODR; /**< \brief (Pio Offset: 0x0014) Output Disable Register */ - RoReg PIO_OSR; /**< \brief (Pio Offset: 0x0018) Output Status Register */ - RwReg Reserved2[1]; - WoReg PIO_IFER; /**< \brief (Pio Offset: 0x0020) Glitch Input Filter Enable Register */ - WoReg PIO_IFDR; /**< \brief (Pio Offset: 0x0024) Glitch Input Filter Disable Register */ - RoReg PIO_IFSR; /**< \brief (Pio Offset: 0x0028) Glitch Input Filter Status Register */ - RwReg Reserved3[1]; - WoReg PIO_SODR; /**< \brief (Pio Offset: 0x0030) Set Output Data Register */ - WoReg PIO_CODR; /**< \brief (Pio Offset: 0x0034) Clear Output Data Register */ - RwReg PIO_ODSR; /**< \brief (Pio Offset: 0x0038) Output Data Status Register */ - RoReg PIO_PDSR; /**< \brief (Pio Offset: 0x003C) Pin Data Status Register */ - WoReg PIO_IER; /**< \brief (Pio Offset: 0x0040) Interrupt Enable Register */ - WoReg PIO_IDR; /**< \brief (Pio Offset: 0x0044) Interrupt Disable Register */ - RoReg PIO_IMR; /**< \brief (Pio Offset: 0x0048) Interrupt Mask Register */ - RoReg PIO_ISR; /**< \brief (Pio Offset: 0x004C) Interrupt Status Register */ - WoReg PIO_MDER; /**< \brief (Pio Offset: 0x0050) Multi-driver Enable Register */ - WoReg PIO_MDDR; /**< \brief (Pio Offset: 0x0054) Multi-driver Disable Register */ - RoReg PIO_MDSR; /**< \brief (Pio Offset: 0x0058) Multi-driver Status Register */ - RwReg Reserved4[1]; - WoReg PIO_PUDR; /**< \brief (Pio Offset: 0x0060) Pull-up Disable Register */ - WoReg PIO_PUER; /**< \brief (Pio Offset: 0x0064) Pull-up Enable Register */ - RoReg PIO_PUSR; /**< \brief (Pio Offset: 0x0068) Pad Pull-up Status Register */ - RwReg Reserved5[1]; - RwReg PIO_ABCDSR[2]; /**< \brief (Pio Offset: 0x0070) Peripheral Select Register */ - RwReg Reserved6[2]; - WoReg PIO_SCIFSR; /**< \brief (Pio Offset: 0x0080) System Clock Glitch Input Filter Select Register */ - WoReg PIO_DIFSR; /**< \brief (Pio Offset: 0x0084) Debouncing Input Filter Select Register */ - RoReg PIO_IFDGSR; /**< \brief (Pio Offset: 0x0088) Glitch or Debouncing Input Filter Clock Selection Status Register */ - RwReg PIO_SCDR; /**< \brief (Pio Offset: 0x008C) Slow Clock Divider Debouncing Register */ - WoReg PIO_PPDDR; /**< \brief (Pio Offset: 0x0090) Pad Pull-down Disable Register */ - WoReg PIO_PPDER; /**< \brief (Pio Offset: 0x0094) Pad Pull-down Enable Register */ - RoReg PIO_PPDSR; /**< \brief (Pio Offset: 0x0098) Pad Pull-down Status Register */ - RwReg Reserved7[1]; - WoReg PIO_OWER; /**< \brief (Pio Offset: 0x00A0) Output Write Enable */ - WoReg PIO_OWDR; /**< \brief (Pio Offset: 0x00A4) Output Write Disable */ - RoReg PIO_OWSR; /**< \brief (Pio Offset: 0x00A8) Output Write Status Register */ - RwReg Reserved8[1]; - WoReg PIO_AIMER; /**< \brief (Pio Offset: 0x00B0) Additional Interrupt Modes Enable Register */ - WoReg PIO_AIMDR; /**< \brief (Pio Offset: 0x00B4) Additional Interrupt Modes Disables Register */ - RoReg PIO_AIMMR; /**< \brief (Pio Offset: 0x00B8) Additional Interrupt Modes Mask Register */ - RwReg Reserved9[1]; - WoReg PIO_ESR; /**< \brief (Pio Offset: 0x00C0) Edge Select Register */ - WoReg PIO_LSR; /**< \brief (Pio Offset: 0x00C4) Level Select Register */ - RoReg PIO_ELSR; /**< \brief (Pio Offset: 0x00C8) Edge/Level Status Register */ - RwReg Reserved10[1]; - WoReg PIO_FELLSR; /**< \brief (Pio Offset: 0x00D0) Falling Edge/Low Level Select Register */ - WoReg PIO_REHLSR; /**< \brief (Pio Offset: 0x00D4) Rising Edge/ High Level Select Register */ - RoReg PIO_FRLHSR; /**< \brief (Pio Offset: 0x00D8) Fall/Rise - Low/High Status Register */ - RwReg Reserved11[1]; - RoReg PIO_LOCKSR; /**< \brief (Pio Offset: 0x00E0) Lock Status */ - RwReg PIO_WPMR; /**< \brief (Pio Offset: 0x00E4) Write Protect Mode Register */ - RoReg PIO_WPSR; /**< \brief (Pio Offset: 0x00E8) Write Protect Status Register */ - RwReg Reserved12[5]; - RwReg PIO_SCHMITT; /**< \brief (Pio Offset: 0x0100) Schmitt Trigger Register */ - RwReg Reserved13[19]; - RwReg PIO_PCMR; /**< \brief (Pio Offset: 0x150) Parallel Capture Mode Register */ - WoReg PIO_PCIER; /**< \brief (Pio Offset: 0x154) Parallel Capture Interrupt Enable Register */ - WoReg PIO_PCIDR; /**< \brief (Pio Offset: 0x158) Parallel Capture Interrupt Disable Register */ - RoReg PIO_PCIMR; /**< \brief (Pio Offset: 0x15C) Parallel Capture Interrupt Mask Register */ - RoReg PIO_PCISR; /**< \brief (Pio Offset: 0x160) Parallel Capture Interrupt Status Register */ - RoReg PIO_PCRHR; /**< \brief (Pio Offset: 0x164) Parallel Capture Reception Holding Register */ -} Pio; -#endif /* __ASSEMBLY__ */ -/* -------- PIO_PER : (PIO Offset: 0x0000) PIO Enable Register -------- */ -#define PIO_PER_P0 (0x1 << 0) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P1 (0x1 << 1) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P2 (0x1 << 2) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P3 (0x1 << 3) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P4 (0x1 << 4) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P5 (0x1 << 5) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P6 (0x1 << 6) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P7 (0x1 << 7) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P8 (0x1 << 8) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P9 (0x1 << 9) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P10 (0x1 << 10) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P11 (0x1 << 11) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P12 (0x1 << 12) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P13 (0x1 << 13) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P14 (0x1 << 14) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P15 (0x1 << 15) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P16 (0x1 << 16) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P17 (0x1 << 17) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P18 (0x1 << 18) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P19 (0x1 << 19) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P20 (0x1 << 20) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P21 (0x1 << 21) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P22 (0x1 << 22) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P23 (0x1 << 23) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P24 (0x1 << 24) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P25 (0x1 << 25) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P26 (0x1 << 26) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P27 (0x1 << 27) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P28 (0x1 << 28) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P29 (0x1 << 29) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P30 (0x1 << 30) /**< \brief (PIO_PER) PIO Enable */ -#define PIO_PER_P31 (0x1 << 31) /**< \brief (PIO_PER) PIO Enable */ -/* -------- PIO_PDR : (PIO Offset: 0x0004) PIO Disable Register -------- */ -#define PIO_PDR_P0 (0x1 << 0) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P1 (0x1 << 1) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P2 (0x1 << 2) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P3 (0x1 << 3) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P4 (0x1 << 4) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P5 (0x1 << 5) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P6 (0x1 << 6) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P7 (0x1 << 7) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P8 (0x1 << 8) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P9 (0x1 << 9) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P10 (0x1 << 10) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P11 (0x1 << 11) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P12 (0x1 << 12) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P13 (0x1 << 13) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P14 (0x1 << 14) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P15 (0x1 << 15) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P16 (0x1 << 16) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P17 (0x1 << 17) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P18 (0x1 << 18) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P19 (0x1 << 19) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P20 (0x1 << 20) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P21 (0x1 << 21) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P22 (0x1 << 22) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P23 (0x1 << 23) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P24 (0x1 << 24) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P25 (0x1 << 25) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P26 (0x1 << 26) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P27 (0x1 << 27) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P28 (0x1 << 28) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P29 (0x1 << 29) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P30 (0x1 << 30) /**< \brief (PIO_PDR) PIO Disable */ -#define PIO_PDR_P31 (0x1 << 31) /**< \brief (PIO_PDR) PIO Disable */ -/* -------- PIO_PSR : (PIO Offset: 0x0008) PIO Status Register -------- */ -#define PIO_PSR_P0 (0x1 << 0) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P1 (0x1 << 1) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P2 (0x1 << 2) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P3 (0x1 << 3) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P4 (0x1 << 4) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P5 (0x1 << 5) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P6 (0x1 << 6) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P7 (0x1 << 7) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P8 (0x1 << 8) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P9 (0x1 << 9) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P10 (0x1 << 10) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P11 (0x1 << 11) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P12 (0x1 << 12) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P13 (0x1 << 13) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P14 (0x1 << 14) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P15 (0x1 << 15) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P16 (0x1 << 16) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P17 (0x1 << 17) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P18 (0x1 << 18) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P19 (0x1 << 19) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P20 (0x1 << 20) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P21 (0x1 << 21) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P22 (0x1 << 22) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P23 (0x1 << 23) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P24 (0x1 << 24) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P25 (0x1 << 25) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P26 (0x1 << 26) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P27 (0x1 << 27) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P28 (0x1 << 28) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P29 (0x1 << 29) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P30 (0x1 << 30) /**< \brief (PIO_PSR) PIO Status */ -#define PIO_PSR_P31 (0x1 << 31) /**< \brief (PIO_PSR) PIO Status */ -/* -------- PIO_OER : (PIO Offset: 0x0010) Output Enable Register -------- */ -#define PIO_OER_P0 (0x1 << 0) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P1 (0x1 << 1) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P2 (0x1 << 2) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P3 (0x1 << 3) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P4 (0x1 << 4) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P5 (0x1 << 5) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P6 (0x1 << 6) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P7 (0x1 << 7) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P8 (0x1 << 8) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P9 (0x1 << 9) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P10 (0x1 << 10) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P11 (0x1 << 11) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P12 (0x1 << 12) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P13 (0x1 << 13) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P14 (0x1 << 14) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P15 (0x1 << 15) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P16 (0x1 << 16) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P17 (0x1 << 17) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P18 (0x1 << 18) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P19 (0x1 << 19) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P20 (0x1 << 20) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P21 (0x1 << 21) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P22 (0x1 << 22) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P23 (0x1 << 23) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P24 (0x1 << 24) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P25 (0x1 << 25) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P26 (0x1 << 26) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P27 (0x1 << 27) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P28 (0x1 << 28) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P29 (0x1 << 29) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P30 (0x1 << 30) /**< \brief (PIO_OER) Output Enable */ -#define PIO_OER_P31 (0x1 << 31) /**< \brief (PIO_OER) Output Enable */ -/* -------- PIO_ODR : (PIO Offset: 0x0014) Output Disable Register -------- */ -#define PIO_ODR_P0 (0x1 << 0) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P1 (0x1 << 1) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P2 (0x1 << 2) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P3 (0x1 << 3) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P4 (0x1 << 4) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P5 (0x1 << 5) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P6 (0x1 << 6) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P7 (0x1 << 7) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P8 (0x1 << 8) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P9 (0x1 << 9) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P10 (0x1 << 10) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P11 (0x1 << 11) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P12 (0x1 << 12) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P13 (0x1 << 13) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P14 (0x1 << 14) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P15 (0x1 << 15) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P16 (0x1 << 16) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P17 (0x1 << 17) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P18 (0x1 << 18) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P19 (0x1 << 19) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P20 (0x1 << 20) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P21 (0x1 << 21) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P22 (0x1 << 22) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P23 (0x1 << 23) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P24 (0x1 << 24) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P25 (0x1 << 25) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P26 (0x1 << 26) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P27 (0x1 << 27) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P28 (0x1 << 28) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P29 (0x1 << 29) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P30 (0x1 << 30) /**< \brief (PIO_ODR) Output Disable */ -#define PIO_ODR_P31 (0x1 << 31) /**< \brief (PIO_ODR) Output Disable */ -/* -------- PIO_OSR : (PIO Offset: 0x0018) Output Status Register -------- */ -#define PIO_OSR_P0 (0x1 << 0) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P1 (0x1 << 1) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P2 (0x1 << 2) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P3 (0x1 << 3) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P4 (0x1 << 4) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P5 (0x1 << 5) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P6 (0x1 << 6) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P7 (0x1 << 7) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P8 (0x1 << 8) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P9 (0x1 << 9) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P10 (0x1 << 10) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P11 (0x1 << 11) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P12 (0x1 << 12) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P13 (0x1 << 13) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P14 (0x1 << 14) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P15 (0x1 << 15) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P16 (0x1 << 16) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P17 (0x1 << 17) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P18 (0x1 << 18) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P19 (0x1 << 19) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P20 (0x1 << 20) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P21 (0x1 << 21) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P22 (0x1 << 22) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P23 (0x1 << 23) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P24 (0x1 << 24) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P25 (0x1 << 25) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P26 (0x1 << 26) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P27 (0x1 << 27) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P28 (0x1 << 28) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P29 (0x1 << 29) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P30 (0x1 << 30) /**< \brief (PIO_OSR) Output Status */ -#define PIO_OSR_P31 (0x1 << 31) /**< \brief (PIO_OSR) Output Status */ -/* -------- PIO_IFER : (PIO Offset: 0x0020) Glitch Input Filter Enable Register -------- */ -#define PIO_IFER_P0 (0x1 << 0) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P1 (0x1 << 1) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P2 (0x1 << 2) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P3 (0x1 << 3) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P4 (0x1 << 4) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P5 (0x1 << 5) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P6 (0x1 << 6) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P7 (0x1 << 7) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P8 (0x1 << 8) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P9 (0x1 << 9) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P10 (0x1 << 10) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P11 (0x1 << 11) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P12 (0x1 << 12) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P13 (0x1 << 13) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P14 (0x1 << 14) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P15 (0x1 << 15) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P16 (0x1 << 16) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P17 (0x1 << 17) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P18 (0x1 << 18) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P19 (0x1 << 19) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P20 (0x1 << 20) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P21 (0x1 << 21) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P22 (0x1 << 22) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P23 (0x1 << 23) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P24 (0x1 << 24) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P25 (0x1 << 25) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P26 (0x1 << 26) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P27 (0x1 << 27) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P28 (0x1 << 28) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P29 (0x1 << 29) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P30 (0x1 << 30) /**< \brief (PIO_IFER) Input Filter Enable */ -#define PIO_IFER_P31 (0x1 << 31) /**< \brief (PIO_IFER) Input Filter Enable */ -/* -------- PIO_IFDR : (PIO Offset: 0x0024) Glitch Input Filter Disable Register -------- */ -#define PIO_IFDR_P0 (0x1 << 0) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P1 (0x1 << 1) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P2 (0x1 << 2) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P3 (0x1 << 3) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P4 (0x1 << 4) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P5 (0x1 << 5) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P6 (0x1 << 6) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P7 (0x1 << 7) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P8 (0x1 << 8) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P9 (0x1 << 9) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P10 (0x1 << 10) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P11 (0x1 << 11) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P12 (0x1 << 12) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P13 (0x1 << 13) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P14 (0x1 << 14) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P15 (0x1 << 15) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P16 (0x1 << 16) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P17 (0x1 << 17) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P18 (0x1 << 18) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P19 (0x1 << 19) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P20 (0x1 << 20) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P21 (0x1 << 21) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P22 (0x1 << 22) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P23 (0x1 << 23) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P24 (0x1 << 24) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P25 (0x1 << 25) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P26 (0x1 << 26) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P27 (0x1 << 27) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P28 (0x1 << 28) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P29 (0x1 << 29) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P30 (0x1 << 30) /**< \brief (PIO_IFDR) Input Filter Disable */ -#define PIO_IFDR_P31 (0x1 << 31) /**< \brief (PIO_IFDR) Input Filter Disable */ -/* -------- PIO_IFSR : (PIO Offset: 0x0028) Glitch Input Filter Status Register -------- */ -#define PIO_IFSR_P0 (0x1 << 0) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P1 (0x1 << 1) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P2 (0x1 << 2) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P3 (0x1 << 3) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P4 (0x1 << 4) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P5 (0x1 << 5) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P6 (0x1 << 6) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P7 (0x1 << 7) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P8 (0x1 << 8) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P9 (0x1 << 9) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P10 (0x1 << 10) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P11 (0x1 << 11) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P12 (0x1 << 12) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P13 (0x1 << 13) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P14 (0x1 << 14) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P15 (0x1 << 15) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P16 (0x1 << 16) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P17 (0x1 << 17) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P18 (0x1 << 18) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P19 (0x1 << 19) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P20 (0x1 << 20) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P21 (0x1 << 21) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P22 (0x1 << 22) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P23 (0x1 << 23) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P24 (0x1 << 24) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P25 (0x1 << 25) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P26 (0x1 << 26) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P27 (0x1 << 27) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P28 (0x1 << 28) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P29 (0x1 << 29) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P30 (0x1 << 30) /**< \brief (PIO_IFSR) Input Filer Status */ -#define PIO_IFSR_P31 (0x1 << 31) /**< \brief (PIO_IFSR) Input Filer Status */ -/* -------- PIO_SODR : (PIO Offset: 0x0030) Set Output Data Register -------- */ -#define PIO_SODR_P0 (0x1 << 0) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P1 (0x1 << 1) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P2 (0x1 << 2) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P3 (0x1 << 3) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P4 (0x1 << 4) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P5 (0x1 << 5) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P6 (0x1 << 6) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P7 (0x1 << 7) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P8 (0x1 << 8) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P9 (0x1 << 9) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P10 (0x1 << 10) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P11 (0x1 << 11) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P12 (0x1 << 12) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P13 (0x1 << 13) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P14 (0x1 << 14) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P15 (0x1 << 15) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P16 (0x1 << 16) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P17 (0x1 << 17) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P18 (0x1 << 18) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P19 (0x1 << 19) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P20 (0x1 << 20) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P21 (0x1 << 21) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P22 (0x1 << 22) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P23 (0x1 << 23) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P24 (0x1 << 24) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P25 (0x1 << 25) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P26 (0x1 << 26) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P27 (0x1 << 27) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P28 (0x1 << 28) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P29 (0x1 << 29) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P30 (0x1 << 30) /**< \brief (PIO_SODR) Set Output Data */ -#define PIO_SODR_P31 (0x1 << 31) /**< \brief (PIO_SODR) Set Output Data */ -/* -------- PIO_CODR : (PIO Offset: 0x0034) Clear Output Data Register -------- */ -#define PIO_CODR_P0 (0x1 << 0) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P1 (0x1 << 1) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P2 (0x1 << 2) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P3 (0x1 << 3) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P4 (0x1 << 4) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P5 (0x1 << 5) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P6 (0x1 << 6) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P7 (0x1 << 7) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P8 (0x1 << 8) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P9 (0x1 << 9) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P10 (0x1 << 10) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P11 (0x1 << 11) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P12 (0x1 << 12) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P13 (0x1 << 13) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P14 (0x1 << 14) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P15 (0x1 << 15) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P16 (0x1 << 16) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P17 (0x1 << 17) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P18 (0x1 << 18) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P19 (0x1 << 19) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P20 (0x1 << 20) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P21 (0x1 << 21) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P22 (0x1 << 22) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P23 (0x1 << 23) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P24 (0x1 << 24) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P25 (0x1 << 25) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P26 (0x1 << 26) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P27 (0x1 << 27) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P28 (0x1 << 28) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P29 (0x1 << 29) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P30 (0x1 << 30) /**< \brief (PIO_CODR) Clear Output Data */ -#define PIO_CODR_P31 (0x1 << 31) /**< \brief (PIO_CODR) Clear Output Data */ -/* -------- PIO_ODSR : (PIO Offset: 0x0038) Output Data Status Register -------- */ -#define PIO_ODSR_P0 (0x1 << 0) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P1 (0x1 << 1) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P2 (0x1 << 2) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P3 (0x1 << 3) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P4 (0x1 << 4) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P5 (0x1 << 5) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P6 (0x1 << 6) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P7 (0x1 << 7) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P8 (0x1 << 8) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P9 (0x1 << 9) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P10 (0x1 << 10) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P11 (0x1 << 11) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P12 (0x1 << 12) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P13 (0x1 << 13) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P14 (0x1 << 14) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P15 (0x1 << 15) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P16 (0x1 << 16) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P17 (0x1 << 17) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P18 (0x1 << 18) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P19 (0x1 << 19) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P20 (0x1 << 20) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P21 (0x1 << 21) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P22 (0x1 << 22) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P23 (0x1 << 23) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P24 (0x1 << 24) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P25 (0x1 << 25) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P26 (0x1 << 26) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P27 (0x1 << 27) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P28 (0x1 << 28) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P29 (0x1 << 29) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P30 (0x1 << 30) /**< \brief (PIO_ODSR) Output Data Status */ -#define PIO_ODSR_P31 (0x1 << 31) /**< \brief (PIO_ODSR) Output Data Status */ -/* -------- PIO_PDSR : (PIO Offset: 0x003C) Pin Data Status Register -------- */ -#define PIO_PDSR_P0 (0x1 << 0) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P1 (0x1 << 1) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P2 (0x1 << 2) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P3 (0x1 << 3) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P4 (0x1 << 4) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P5 (0x1 << 5) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P6 (0x1 << 6) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P7 (0x1 << 7) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P8 (0x1 << 8) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P9 (0x1 << 9) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P10 (0x1 << 10) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P11 (0x1 << 11) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P12 (0x1 << 12) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P13 (0x1 << 13) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P14 (0x1 << 14) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P15 (0x1 << 15) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P16 (0x1 << 16) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P17 (0x1 << 17) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P18 (0x1 << 18) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P19 (0x1 << 19) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P20 (0x1 << 20) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P21 (0x1 << 21) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P22 (0x1 << 22) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P23 (0x1 << 23) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P24 (0x1 << 24) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P25 (0x1 << 25) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P26 (0x1 << 26) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P27 (0x1 << 27) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P28 (0x1 << 28) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P29 (0x1 << 29) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P30 (0x1 << 30) /**< \brief (PIO_PDSR) Output Data Status */ -#define PIO_PDSR_P31 (0x1 << 31) /**< \brief (PIO_PDSR) Output Data Status */ -/* -------- PIO_IER : (PIO Offset: 0x0040) Interrupt Enable Register -------- */ -#define PIO_IER_P0 (0x1 << 0) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P1 (0x1 << 1) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P2 (0x1 << 2) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P3 (0x1 << 3) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P4 (0x1 << 4) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P5 (0x1 << 5) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P6 (0x1 << 6) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P7 (0x1 << 7) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P8 (0x1 << 8) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P9 (0x1 << 9) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P10 (0x1 << 10) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P11 (0x1 << 11) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P12 (0x1 << 12) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P13 (0x1 << 13) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P14 (0x1 << 14) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P15 (0x1 << 15) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P16 (0x1 << 16) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P17 (0x1 << 17) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P18 (0x1 << 18) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P19 (0x1 << 19) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P20 (0x1 << 20) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P21 (0x1 << 21) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P22 (0x1 << 22) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P23 (0x1 << 23) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P24 (0x1 << 24) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P25 (0x1 << 25) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P26 (0x1 << 26) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P27 (0x1 << 27) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P28 (0x1 << 28) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P29 (0x1 << 29) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P30 (0x1 << 30) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -#define PIO_IER_P31 (0x1 << 31) /**< \brief (PIO_IER) Input Change Interrupt Enable */ -/* -------- PIO_IDR : (PIO Offset: 0x0044) Interrupt Disable Register -------- */ -#define PIO_IDR_P0 (0x1 << 0) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P1 (0x1 << 1) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P2 (0x1 << 2) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P3 (0x1 << 3) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P4 (0x1 << 4) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P5 (0x1 << 5) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P6 (0x1 << 6) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P7 (0x1 << 7) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P8 (0x1 << 8) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P9 (0x1 << 9) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P10 (0x1 << 10) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P11 (0x1 << 11) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P12 (0x1 << 12) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P13 (0x1 << 13) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P14 (0x1 << 14) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P15 (0x1 << 15) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P16 (0x1 << 16) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P17 (0x1 << 17) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P18 (0x1 << 18) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P19 (0x1 << 19) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P20 (0x1 << 20) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P21 (0x1 << 21) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P22 (0x1 << 22) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P23 (0x1 << 23) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P24 (0x1 << 24) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P25 (0x1 << 25) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P26 (0x1 << 26) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P27 (0x1 << 27) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P28 (0x1 << 28) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P29 (0x1 << 29) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P30 (0x1 << 30) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -#define PIO_IDR_P31 (0x1 << 31) /**< \brief (PIO_IDR) Input Change Interrupt Disable */ -/* -------- PIO_IMR : (PIO Offset: 0x0048) Interrupt Mask Register -------- */ -#define PIO_IMR_P0 (0x1 << 0) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P1 (0x1 << 1) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P2 (0x1 << 2) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P3 (0x1 << 3) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P4 (0x1 << 4) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P5 (0x1 << 5) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P6 (0x1 << 6) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P7 (0x1 << 7) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P8 (0x1 << 8) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P9 (0x1 << 9) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P10 (0x1 << 10) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P11 (0x1 << 11) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P12 (0x1 << 12) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P13 (0x1 << 13) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P14 (0x1 << 14) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P15 (0x1 << 15) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P16 (0x1 << 16) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P17 (0x1 << 17) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P18 (0x1 << 18) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P19 (0x1 << 19) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P20 (0x1 << 20) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P21 (0x1 << 21) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P22 (0x1 << 22) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P23 (0x1 << 23) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P24 (0x1 << 24) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P25 (0x1 << 25) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P26 (0x1 << 26) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P27 (0x1 << 27) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P28 (0x1 << 28) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P29 (0x1 << 29) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P30 (0x1 << 30) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -#define PIO_IMR_P31 (0x1 << 31) /**< \brief (PIO_IMR) Input Change Interrupt Mask */ -/* -------- PIO_ISR : (PIO Offset: 0x004C) Interrupt Status Register -------- */ -#define PIO_ISR_P0 (0x1 << 0) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P1 (0x1 << 1) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P2 (0x1 << 2) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P3 (0x1 << 3) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P4 (0x1 << 4) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P5 (0x1 << 5) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P6 (0x1 << 6) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P7 (0x1 << 7) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P8 (0x1 << 8) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P9 (0x1 << 9) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P10 (0x1 << 10) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P11 (0x1 << 11) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P12 (0x1 << 12) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P13 (0x1 << 13) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P14 (0x1 << 14) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P15 (0x1 << 15) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P16 (0x1 << 16) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P17 (0x1 << 17) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P18 (0x1 << 18) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P19 (0x1 << 19) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P20 (0x1 << 20) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P21 (0x1 << 21) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P22 (0x1 << 22) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P23 (0x1 << 23) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P24 (0x1 << 24) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P25 (0x1 << 25) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P26 (0x1 << 26) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P27 (0x1 << 27) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P28 (0x1 << 28) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P29 (0x1 << 29) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P30 (0x1 << 30) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -#define PIO_ISR_P31 (0x1 << 31) /**< \brief (PIO_ISR) Input Change Interrupt Status */ -/* -------- PIO_MDER : (PIO Offset: 0x0050) Multi-driver Enable Register -------- */ -#define PIO_MDER_P0 (0x1 << 0) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P1 (0x1 << 1) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P2 (0x1 << 2) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P3 (0x1 << 3) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P4 (0x1 << 4) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P5 (0x1 << 5) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P6 (0x1 << 6) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P7 (0x1 << 7) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P8 (0x1 << 8) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P9 (0x1 << 9) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P10 (0x1 << 10) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P11 (0x1 << 11) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P12 (0x1 << 12) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P13 (0x1 << 13) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P14 (0x1 << 14) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P15 (0x1 << 15) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P16 (0x1 << 16) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P17 (0x1 << 17) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P18 (0x1 << 18) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P19 (0x1 << 19) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P20 (0x1 << 20) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P21 (0x1 << 21) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P22 (0x1 << 22) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P23 (0x1 << 23) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P24 (0x1 << 24) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P25 (0x1 << 25) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P26 (0x1 << 26) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P27 (0x1 << 27) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P28 (0x1 << 28) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P29 (0x1 << 29) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P30 (0x1 << 30) /**< \brief (PIO_MDER) Multi Drive Enable. */ -#define PIO_MDER_P31 (0x1 << 31) /**< \brief (PIO_MDER) Multi Drive Enable. */ -/* -------- PIO_MDDR : (PIO Offset: 0x0054) Multi-driver Disable Register -------- */ -#define PIO_MDDR_P0 (0x1 << 0) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P1 (0x1 << 1) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P2 (0x1 << 2) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P3 (0x1 << 3) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P4 (0x1 << 4) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P5 (0x1 << 5) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P6 (0x1 << 6) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P7 (0x1 << 7) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P8 (0x1 << 8) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P9 (0x1 << 9) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P10 (0x1 << 10) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P11 (0x1 << 11) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P12 (0x1 << 12) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P13 (0x1 << 13) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P14 (0x1 << 14) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P15 (0x1 << 15) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P16 (0x1 << 16) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P17 (0x1 << 17) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P18 (0x1 << 18) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P19 (0x1 << 19) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P20 (0x1 << 20) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P21 (0x1 << 21) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P22 (0x1 << 22) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P23 (0x1 << 23) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P24 (0x1 << 24) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P25 (0x1 << 25) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P26 (0x1 << 26) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P27 (0x1 << 27) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P28 (0x1 << 28) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P29 (0x1 << 29) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P30 (0x1 << 30) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -#define PIO_MDDR_P31 (0x1 << 31) /**< \brief (PIO_MDDR) Multi Drive Disable. */ -/* -------- PIO_MDSR : (PIO Offset: 0x0058) Multi-driver Status Register -------- */ -#define PIO_MDSR_P0 (0x1 << 0) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P1 (0x1 << 1) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P2 (0x1 << 2) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P3 (0x1 << 3) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P4 (0x1 << 4) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P5 (0x1 << 5) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P6 (0x1 << 6) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P7 (0x1 << 7) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P8 (0x1 << 8) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P9 (0x1 << 9) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P10 (0x1 << 10) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P11 (0x1 << 11) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P12 (0x1 << 12) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P13 (0x1 << 13) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P14 (0x1 << 14) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P15 (0x1 << 15) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P16 (0x1 << 16) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P17 (0x1 << 17) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P18 (0x1 << 18) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P19 (0x1 << 19) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P20 (0x1 << 20) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P21 (0x1 << 21) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P22 (0x1 << 22) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P23 (0x1 << 23) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P24 (0x1 << 24) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P25 (0x1 << 25) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P26 (0x1 << 26) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P27 (0x1 << 27) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P28 (0x1 << 28) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P29 (0x1 << 29) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P30 (0x1 << 30) /**< \brief (PIO_MDSR) Multi Drive Status. */ -#define PIO_MDSR_P31 (0x1 << 31) /**< \brief (PIO_MDSR) Multi Drive Status. */ -/* -------- PIO_PUDR : (PIO Offset: 0x0060) Pull-up Disable Register -------- */ -#define PIO_PUDR_P0 (0x1 << 0) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P1 (0x1 << 1) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P2 (0x1 << 2) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P3 (0x1 << 3) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P4 (0x1 << 4) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P5 (0x1 << 5) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P6 (0x1 << 6) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P7 (0x1 << 7) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P8 (0x1 << 8) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P9 (0x1 << 9) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P10 (0x1 << 10) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P11 (0x1 << 11) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P12 (0x1 << 12) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P13 (0x1 << 13) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P14 (0x1 << 14) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P15 (0x1 << 15) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P16 (0x1 << 16) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P17 (0x1 << 17) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P18 (0x1 << 18) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P19 (0x1 << 19) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P20 (0x1 << 20) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P21 (0x1 << 21) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P22 (0x1 << 22) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P23 (0x1 << 23) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P24 (0x1 << 24) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P25 (0x1 << 25) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P26 (0x1 << 26) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P27 (0x1 << 27) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P28 (0x1 << 28) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P29 (0x1 << 29) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P30 (0x1 << 30) /**< \brief (PIO_PUDR) Pull Up Disable. */ -#define PIO_PUDR_P31 (0x1 << 31) /**< \brief (PIO_PUDR) Pull Up Disable. */ -/* -------- PIO_PUER : (PIO Offset: 0x0064) Pull-up Enable Register -------- */ -#define PIO_PUER_P0 (0x1 << 0) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P1 (0x1 << 1) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P2 (0x1 << 2) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P3 (0x1 << 3) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P4 (0x1 << 4) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P5 (0x1 << 5) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P6 (0x1 << 6) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P7 (0x1 << 7) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P8 (0x1 << 8) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P9 (0x1 << 9) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P10 (0x1 << 10) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P11 (0x1 << 11) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P12 (0x1 << 12) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P13 (0x1 << 13) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P14 (0x1 << 14) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P15 (0x1 << 15) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P16 (0x1 << 16) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P17 (0x1 << 17) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P18 (0x1 << 18) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P19 (0x1 << 19) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P20 (0x1 << 20) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P21 (0x1 << 21) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P22 (0x1 << 22) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P23 (0x1 << 23) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P24 (0x1 << 24) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P25 (0x1 << 25) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P26 (0x1 << 26) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P27 (0x1 << 27) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P28 (0x1 << 28) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P29 (0x1 << 29) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P30 (0x1 << 30) /**< \brief (PIO_PUER) Pull Up Enable. */ -#define PIO_PUER_P31 (0x1 << 31) /**< \brief (PIO_PUER) Pull Up Enable. */ -/* -------- PIO_PUSR : (PIO Offset: 0x0068) Pad Pull-up Status Register -------- */ -#define PIO_PUSR_P0 (0x1 << 0) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P1 (0x1 << 1) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P2 (0x1 << 2) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P3 (0x1 << 3) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P4 (0x1 << 4) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P5 (0x1 << 5) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P6 (0x1 << 6) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P7 (0x1 << 7) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P8 (0x1 << 8) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P9 (0x1 << 9) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P10 (0x1 << 10) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P11 (0x1 << 11) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P12 (0x1 << 12) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P13 (0x1 << 13) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P14 (0x1 << 14) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P15 (0x1 << 15) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P16 (0x1 << 16) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P17 (0x1 << 17) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P18 (0x1 << 18) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P19 (0x1 << 19) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P20 (0x1 << 20) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P21 (0x1 << 21) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P22 (0x1 << 22) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P23 (0x1 << 23) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P24 (0x1 << 24) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P25 (0x1 << 25) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P26 (0x1 << 26) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P27 (0x1 << 27) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P28 (0x1 << 28) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P29 (0x1 << 29) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P30 (0x1 << 30) /**< \brief (PIO_PUSR) Pull Up Status. */ -#define PIO_PUSR_P31 (0x1 << 31) /**< \brief (PIO_PUSR) Pull Up Status. */ -/* -------- PIO_ABCDSR[2] : (PIO Offset: 0x0070) Peripheral Select Register -------- */ -#define PIO_ABCDSR_P0 (0x1 << 0) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P1 (0x1 << 1) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P2 (0x1 << 2) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P3 (0x1 << 3) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P4 (0x1 << 4) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P5 (0x1 << 5) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P6 (0x1 << 6) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P7 (0x1 << 7) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P8 (0x1 << 8) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P9 (0x1 << 9) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P10 (0x1 << 10) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P11 (0x1 << 11) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P12 (0x1 << 12) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P13 (0x1 << 13) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P14 (0x1 << 14) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P15 (0x1 << 15) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P16 (0x1 << 16) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P17 (0x1 << 17) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P18 (0x1 << 18) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P19 (0x1 << 19) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P20 (0x1 << 20) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P21 (0x1 << 21) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P22 (0x1 << 22) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P23 (0x1 << 23) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P24 (0x1 << 24) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P25 (0x1 << 25) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P26 (0x1 << 26) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P27 (0x1 << 27) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P28 (0x1 << 28) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P29 (0x1 << 29) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P30 (0x1 << 30) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -#define PIO_ABCDSR_P31 (0x1 << 31) /**< \brief (PIO_ABCDSR[2]) Peripheral Select. */ -/* -------- PIO_SCIFSR : (PIO Offset: 0x0080) System Clock Glitch Input Filter Select Register -------- */ -#define PIO_SCIFSR_P0 (0x1 << 0) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P1 (0x1 << 1) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P2 (0x1 << 2) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P3 (0x1 << 3) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P4 (0x1 << 4) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P5 (0x1 << 5) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P6 (0x1 << 6) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P7 (0x1 << 7) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P8 (0x1 << 8) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P9 (0x1 << 9) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P10 (0x1 << 10) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P11 (0x1 << 11) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P12 (0x1 << 12) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P13 (0x1 << 13) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P14 (0x1 << 14) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P15 (0x1 << 15) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P16 (0x1 << 16) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P17 (0x1 << 17) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P18 (0x1 << 18) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P19 (0x1 << 19) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P20 (0x1 << 20) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P21 (0x1 << 21) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P22 (0x1 << 22) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P23 (0x1 << 23) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P24 (0x1 << 24) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P25 (0x1 << 25) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P26 (0x1 << 26) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P27 (0x1 << 27) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P28 (0x1 << 28) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P29 (0x1 << 29) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P30 (0x1 << 30) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -#define PIO_SCIFSR_P31 (0x1 << 31) /**< \brief (PIO_SCIFSR) System Clock Glitch Filtering Select. */ -/* -------- PIO_DIFSR : (PIO Offset: 0x0084) Debouncing Input Filter Select Register -------- */ -#define PIO_DIFSR_P0 (0x1 << 0) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P1 (0x1 << 1) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P2 (0x1 << 2) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P3 (0x1 << 3) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P4 (0x1 << 4) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P5 (0x1 << 5) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P6 (0x1 << 6) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P7 (0x1 << 7) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P8 (0x1 << 8) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P9 (0x1 << 9) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P10 (0x1 << 10) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P11 (0x1 << 11) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P12 (0x1 << 12) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P13 (0x1 << 13) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P14 (0x1 << 14) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P15 (0x1 << 15) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P16 (0x1 << 16) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P17 (0x1 << 17) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P18 (0x1 << 18) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P19 (0x1 << 19) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P20 (0x1 << 20) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P21 (0x1 << 21) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P22 (0x1 << 22) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P23 (0x1 << 23) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P24 (0x1 << 24) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P25 (0x1 << 25) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P26 (0x1 << 26) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P27 (0x1 << 27) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P28 (0x1 << 28) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P29 (0x1 << 29) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P30 (0x1 << 30) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -#define PIO_DIFSR_P31 (0x1 << 31) /**< \brief (PIO_DIFSR) Debouncing Filtering Select. */ -/* -------- PIO_IFDGSR : (PIO Offset: 0x0088) Glitch or Debouncing Input Filter Clock Selection Status Register -------- */ -#define PIO_IFDGSR_P0 (0x1 << 0) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P1 (0x1 << 1) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P2 (0x1 << 2) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P3 (0x1 << 3) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P4 (0x1 << 4) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P5 (0x1 << 5) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P6 (0x1 << 6) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P7 (0x1 << 7) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P8 (0x1 << 8) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P9 (0x1 << 9) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P10 (0x1 << 10) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P11 (0x1 << 11) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P12 (0x1 << 12) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P13 (0x1 << 13) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P14 (0x1 << 14) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P15 (0x1 << 15) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P16 (0x1 << 16) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P17 (0x1 << 17) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P18 (0x1 << 18) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P19 (0x1 << 19) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P20 (0x1 << 20) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P21 (0x1 << 21) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P22 (0x1 << 22) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P23 (0x1 << 23) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P24 (0x1 << 24) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P25 (0x1 << 25) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P26 (0x1 << 26) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P27 (0x1 << 27) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P28 (0x1 << 28) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P29 (0x1 << 29) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P30 (0x1 << 30) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -#define PIO_IFDGSR_P31 (0x1 << 31) /**< \brief (PIO_IFDGSR) Glitch or Debouncing Filter Selection Status */ -/* -------- PIO_SCDR : (PIO Offset: 0x008C) Slow Clock Divider Debouncing Register -------- */ -#define PIO_SCDR_DIV0 (0x1 << 0) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV1 (0x1 << 1) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV2 (0x1 << 2) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV3 (0x1 << 3) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV4 (0x1 << 4) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV5 (0x1 << 5) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV6 (0x1 << 6) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV7 (0x1 << 7) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV8 (0x1 << 8) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV9 (0x1 << 9) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV10 (0x1 << 10) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV11 (0x1 << 11) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV12 (0x1 << 12) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -#define PIO_SCDR_DIV13 (0x1 << 13) /**< \brief (PIO_SCDR) Slow Clock Divider Selection for Debouncing */ -/* -------- PIO_PPDDR : (PIO Offset: 0x0090) Pad Pull-down Disable Register -------- */ -#define PIO_PPDDR_P0 (0x1 << 0) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P1 (0x1 << 1) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P2 (0x1 << 2) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P3 (0x1 << 3) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P4 (0x1 << 4) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P5 (0x1 << 5) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P6 (0x1 << 6) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P7 (0x1 << 7) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P8 (0x1 << 8) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P9 (0x1 << 9) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P10 (0x1 << 10) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P11 (0x1 << 11) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P12 (0x1 << 12) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P13 (0x1 << 13) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P14 (0x1 << 14) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P15 (0x1 << 15) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P16 (0x1 << 16) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P17 (0x1 << 17) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P18 (0x1 << 18) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P19 (0x1 << 19) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P20 (0x1 << 20) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P21 (0x1 << 21) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P22 (0x1 << 22) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P23 (0x1 << 23) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P24 (0x1 << 24) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P25 (0x1 << 25) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P26 (0x1 << 26) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P27 (0x1 << 27) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P28 (0x1 << 28) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P29 (0x1 << 29) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P30 (0x1 << 30) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -#define PIO_PPDDR_P31 (0x1 << 31) /**< \brief (PIO_PPDDR) Pull Down Disable. */ -/* -------- PIO_PPDER : (PIO Offset: 0x0094) Pad Pull-down Enable Register -------- */ -#define PIO_PPDER_P0 (0x1 << 0) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P1 (0x1 << 1) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P2 (0x1 << 2) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P3 (0x1 << 3) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P4 (0x1 << 4) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P5 (0x1 << 5) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P6 (0x1 << 6) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P7 (0x1 << 7) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P8 (0x1 << 8) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P9 (0x1 << 9) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P10 (0x1 << 10) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P11 (0x1 << 11) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P12 (0x1 << 12) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P13 (0x1 << 13) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P14 (0x1 << 14) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P15 (0x1 << 15) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P16 (0x1 << 16) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P17 (0x1 << 17) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P18 (0x1 << 18) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P19 (0x1 << 19) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P20 (0x1 << 20) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P21 (0x1 << 21) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P22 (0x1 << 22) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P23 (0x1 << 23) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P24 (0x1 << 24) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P25 (0x1 << 25) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P26 (0x1 << 26) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P27 (0x1 << 27) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P28 (0x1 << 28) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P29 (0x1 << 29) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P30 (0x1 << 30) /**< \brief (PIO_PPDER) Pull Down Enable. */ -#define PIO_PPDER_P31 (0x1 << 31) /**< \brief (PIO_PPDER) Pull Down Enable. */ -/* -------- PIO_PPDSR : (PIO Offset: 0x0098) Pad Pull-down Status Register -------- */ -#define PIO_PPDSR_P0 (0x1 << 0) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P1 (0x1 << 1) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P2 (0x1 << 2) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P3 (0x1 << 3) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P4 (0x1 << 4) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P5 (0x1 << 5) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P6 (0x1 << 6) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P7 (0x1 << 7) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P8 (0x1 << 8) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P9 (0x1 << 9) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P10 (0x1 << 10) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P11 (0x1 << 11) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P12 (0x1 << 12) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P13 (0x1 << 13) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P14 (0x1 << 14) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P15 (0x1 << 15) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P16 (0x1 << 16) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P17 (0x1 << 17) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P18 (0x1 << 18) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P19 (0x1 << 19) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P20 (0x1 << 20) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P21 (0x1 << 21) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P22 (0x1 << 22) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P23 (0x1 << 23) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P24 (0x1 << 24) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P25 (0x1 << 25) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P26 (0x1 << 26) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P27 (0x1 << 27) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P28 (0x1 << 28) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P29 (0x1 << 29) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P30 (0x1 << 30) /**< \brief (PIO_PPDSR) Pull Down Status. */ -#define PIO_PPDSR_P31 (0x1 << 31) /**< \brief (PIO_PPDSR) Pull Down Status. */ -/* -------- PIO_OWER : (PIO Offset: 0x00A0) Output Write Enable -------- */ -#define PIO_OWER_P0 (0x1 << 0) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P1 (0x1 << 1) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P2 (0x1 << 2) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P3 (0x1 << 3) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P4 (0x1 << 4) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P5 (0x1 << 5) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P6 (0x1 << 6) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P7 (0x1 << 7) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P8 (0x1 << 8) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P9 (0x1 << 9) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P10 (0x1 << 10) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P11 (0x1 << 11) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P12 (0x1 << 12) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P13 (0x1 << 13) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P14 (0x1 << 14) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P15 (0x1 << 15) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P16 (0x1 << 16) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P17 (0x1 << 17) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P18 (0x1 << 18) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P19 (0x1 << 19) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P20 (0x1 << 20) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P21 (0x1 << 21) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P22 (0x1 << 22) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P23 (0x1 << 23) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P24 (0x1 << 24) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P25 (0x1 << 25) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P26 (0x1 << 26) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P27 (0x1 << 27) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P28 (0x1 << 28) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P29 (0x1 << 29) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P30 (0x1 << 30) /**< \brief (PIO_OWER) Output Write Enable. */ -#define PIO_OWER_P31 (0x1 << 31) /**< \brief (PIO_OWER) Output Write Enable. */ -/* -------- PIO_OWDR : (PIO Offset: 0x00A4) Output Write Disable -------- */ -#define PIO_OWDR_P0 (0x1 << 0) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P1 (0x1 << 1) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P2 (0x1 << 2) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P3 (0x1 << 3) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P4 (0x1 << 4) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P5 (0x1 << 5) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P6 (0x1 << 6) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P7 (0x1 << 7) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P8 (0x1 << 8) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P9 (0x1 << 9) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P10 (0x1 << 10) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P11 (0x1 << 11) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P12 (0x1 << 12) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P13 (0x1 << 13) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P14 (0x1 << 14) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P15 (0x1 << 15) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P16 (0x1 << 16) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P17 (0x1 << 17) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P18 (0x1 << 18) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P19 (0x1 << 19) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P20 (0x1 << 20) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P21 (0x1 << 21) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P22 (0x1 << 22) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P23 (0x1 << 23) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P24 (0x1 << 24) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P25 (0x1 << 25) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P26 (0x1 << 26) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P27 (0x1 << 27) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P28 (0x1 << 28) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P29 (0x1 << 29) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P30 (0x1 << 30) /**< \brief (PIO_OWDR) Output Write Disable. */ -#define PIO_OWDR_P31 (0x1 << 31) /**< \brief (PIO_OWDR) Output Write Disable. */ -/* -------- PIO_OWSR : (PIO Offset: 0x00A8) Output Write Status Register -------- */ -#define PIO_OWSR_P0 (0x1 << 0) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P1 (0x1 << 1) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P2 (0x1 << 2) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P3 (0x1 << 3) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P4 (0x1 << 4) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P5 (0x1 << 5) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P6 (0x1 << 6) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P7 (0x1 << 7) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P8 (0x1 << 8) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P9 (0x1 << 9) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P10 (0x1 << 10) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P11 (0x1 << 11) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P12 (0x1 << 12) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P13 (0x1 << 13) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P14 (0x1 << 14) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P15 (0x1 << 15) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P16 (0x1 << 16) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P17 (0x1 << 17) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P18 (0x1 << 18) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P19 (0x1 << 19) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P20 (0x1 << 20) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P21 (0x1 << 21) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P22 (0x1 << 22) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P23 (0x1 << 23) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P24 (0x1 << 24) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P25 (0x1 << 25) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P26 (0x1 << 26) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P27 (0x1 << 27) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P28 (0x1 << 28) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P29 (0x1 << 29) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P30 (0x1 << 30) /**< \brief (PIO_OWSR) Output Write Status. */ -#define PIO_OWSR_P31 (0x1 << 31) /**< \brief (PIO_OWSR) Output Write Status. */ -/* -------- PIO_AIMER : (PIO Offset: 0x00B0) Additional Interrupt Modes Enable Register -------- */ -#define PIO_AIMER_P0 (0x1 << 0) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P1 (0x1 << 1) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P2 (0x1 << 2) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P3 (0x1 << 3) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P4 (0x1 << 4) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P5 (0x1 << 5) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P6 (0x1 << 6) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P7 (0x1 << 7) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P8 (0x1 << 8) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P9 (0x1 << 9) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P10 (0x1 << 10) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P11 (0x1 << 11) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P12 (0x1 << 12) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P13 (0x1 << 13) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P14 (0x1 << 14) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P15 (0x1 << 15) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P16 (0x1 << 16) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P17 (0x1 << 17) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P18 (0x1 << 18) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P19 (0x1 << 19) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P20 (0x1 << 20) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P21 (0x1 << 21) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P22 (0x1 << 22) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P23 (0x1 << 23) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P24 (0x1 << 24) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P25 (0x1 << 25) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P26 (0x1 << 26) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P27 (0x1 << 27) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P28 (0x1 << 28) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P29 (0x1 << 29) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P30 (0x1 << 30) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -#define PIO_AIMER_P31 (0x1 << 31) /**< \brief (PIO_AIMER) Additional Interrupt Modes Enable. */ -/* -------- PIO_AIMDR : (PIO Offset: 0x00B4) Additional Interrupt Modes Disables Register -------- */ -#define PIO_AIMDR_P0 (0x1 << 0) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P1 (0x1 << 1) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P2 (0x1 << 2) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P3 (0x1 << 3) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P4 (0x1 << 4) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P5 (0x1 << 5) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P6 (0x1 << 6) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P7 (0x1 << 7) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P8 (0x1 << 8) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P9 (0x1 << 9) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P10 (0x1 << 10) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P11 (0x1 << 11) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P12 (0x1 << 12) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P13 (0x1 << 13) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P14 (0x1 << 14) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P15 (0x1 << 15) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P16 (0x1 << 16) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P17 (0x1 << 17) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P18 (0x1 << 18) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P19 (0x1 << 19) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P20 (0x1 << 20) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P21 (0x1 << 21) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P22 (0x1 << 22) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P23 (0x1 << 23) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P24 (0x1 << 24) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P25 (0x1 << 25) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P26 (0x1 << 26) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P27 (0x1 << 27) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P28 (0x1 << 28) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P29 (0x1 << 29) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P30 (0x1 << 30) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -#define PIO_AIMDR_P31 (0x1 << 31) /**< \brief (PIO_AIMDR) Additional Interrupt Modes Disable. */ -/* -------- PIO_AIMMR : (PIO Offset: 0x00B8) Additional Interrupt Modes Mask Register -------- */ -#define PIO_AIMMR_P0 (0x1 << 0) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P1 (0x1 << 1) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P2 (0x1 << 2) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P3 (0x1 << 3) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P4 (0x1 << 4) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P5 (0x1 << 5) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P6 (0x1 << 6) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P7 (0x1 << 7) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P8 (0x1 << 8) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P9 (0x1 << 9) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P10 (0x1 << 10) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P11 (0x1 << 11) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P12 (0x1 << 12) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P13 (0x1 << 13) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P14 (0x1 << 14) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P15 (0x1 << 15) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P16 (0x1 << 16) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P17 (0x1 << 17) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P18 (0x1 << 18) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P19 (0x1 << 19) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P20 (0x1 << 20) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P21 (0x1 << 21) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P22 (0x1 << 22) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P23 (0x1 << 23) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P24 (0x1 << 24) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P25 (0x1 << 25) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P26 (0x1 << 26) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P27 (0x1 << 27) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P28 (0x1 << 28) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P29 (0x1 << 29) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P30 (0x1 << 30) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -#define PIO_AIMMR_P31 (0x1 << 31) /**< \brief (PIO_AIMMR) Peripheral CD Status. */ -/* -------- PIO_ESR : (PIO Offset: 0x00C0) Edge Select Register -------- */ -#define PIO_ESR_P0 (0x1 << 0) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P1 (0x1 << 1) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P2 (0x1 << 2) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P3 (0x1 << 3) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P4 (0x1 << 4) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P5 (0x1 << 5) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P6 (0x1 << 6) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P7 (0x1 << 7) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P8 (0x1 << 8) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P9 (0x1 << 9) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P10 (0x1 << 10) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P11 (0x1 << 11) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P12 (0x1 << 12) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P13 (0x1 << 13) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P14 (0x1 << 14) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P15 (0x1 << 15) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P16 (0x1 << 16) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P17 (0x1 << 17) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P18 (0x1 << 18) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P19 (0x1 << 19) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P20 (0x1 << 20) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P21 (0x1 << 21) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P22 (0x1 << 22) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P23 (0x1 << 23) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P24 (0x1 << 24) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P25 (0x1 << 25) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P26 (0x1 << 26) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P27 (0x1 << 27) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P28 (0x1 << 28) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P29 (0x1 << 29) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P30 (0x1 << 30) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -#define PIO_ESR_P31 (0x1 << 31) /**< \brief (PIO_ESR) Edge Interrupt Selection. */ -/* -------- PIO_LSR : (PIO Offset: 0x00C4) Level Select Register -------- */ -#define PIO_LSR_P0 (0x1 << 0) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P1 (0x1 << 1) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P2 (0x1 << 2) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P3 (0x1 << 3) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P4 (0x1 << 4) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P5 (0x1 << 5) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P6 (0x1 << 6) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P7 (0x1 << 7) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P8 (0x1 << 8) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P9 (0x1 << 9) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P10 (0x1 << 10) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P11 (0x1 << 11) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P12 (0x1 << 12) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P13 (0x1 << 13) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P14 (0x1 << 14) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P15 (0x1 << 15) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P16 (0x1 << 16) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P17 (0x1 << 17) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P18 (0x1 << 18) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P19 (0x1 << 19) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P20 (0x1 << 20) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P21 (0x1 << 21) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P22 (0x1 << 22) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P23 (0x1 << 23) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P24 (0x1 << 24) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P25 (0x1 << 25) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P26 (0x1 << 26) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P27 (0x1 << 27) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P28 (0x1 << 28) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P29 (0x1 << 29) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P30 (0x1 << 30) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -#define PIO_LSR_P31 (0x1 << 31) /**< \brief (PIO_LSR) Level Interrupt Selection. */ -/* -------- PIO_ELSR : (PIO Offset: 0x00C8) Edge/Level Status Register -------- */ -#define PIO_ELSR_P0 (0x1 << 0) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P1 (0x1 << 1) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P2 (0x1 << 2) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P3 (0x1 << 3) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P4 (0x1 << 4) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P5 (0x1 << 5) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P6 (0x1 << 6) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P7 (0x1 << 7) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P8 (0x1 << 8) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P9 (0x1 << 9) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P10 (0x1 << 10) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P11 (0x1 << 11) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P12 (0x1 << 12) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P13 (0x1 << 13) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P14 (0x1 << 14) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P15 (0x1 << 15) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P16 (0x1 << 16) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P17 (0x1 << 17) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P18 (0x1 << 18) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P19 (0x1 << 19) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P20 (0x1 << 20) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P21 (0x1 << 21) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P22 (0x1 << 22) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P23 (0x1 << 23) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P24 (0x1 << 24) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P25 (0x1 << 25) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P26 (0x1 << 26) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P27 (0x1 << 27) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P28 (0x1 << 28) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P29 (0x1 << 29) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P30 (0x1 << 30) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -#define PIO_ELSR_P31 (0x1 << 31) /**< \brief (PIO_ELSR) Edge/Level Interrupt source selection. */ -/* -------- PIO_FELLSR : (PIO Offset: 0x00D0) Falling Edge/Low Level Select Register -------- */ -#define PIO_FELLSR_P0 (0x1 << 0) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P1 (0x1 << 1) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P2 (0x1 << 2) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P3 (0x1 << 3) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P4 (0x1 << 4) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P5 (0x1 << 5) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P6 (0x1 << 6) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P7 (0x1 << 7) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P8 (0x1 << 8) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P9 (0x1 << 9) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P10 (0x1 << 10) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P11 (0x1 << 11) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P12 (0x1 << 12) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P13 (0x1 << 13) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P14 (0x1 << 14) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P15 (0x1 << 15) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P16 (0x1 << 16) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P17 (0x1 << 17) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P18 (0x1 << 18) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P19 (0x1 << 19) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P20 (0x1 << 20) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P21 (0x1 << 21) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P22 (0x1 << 22) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P23 (0x1 << 23) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P24 (0x1 << 24) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P25 (0x1 << 25) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P26 (0x1 << 26) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P27 (0x1 << 27) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P28 (0x1 << 28) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P29 (0x1 << 29) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P30 (0x1 << 30) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -#define PIO_FELLSR_P31 (0x1 << 31) /**< \brief (PIO_FELLSR) Falling Edge/Low Level Interrupt Selection. */ -/* -------- PIO_REHLSR : (PIO Offset: 0x00D4) Rising Edge/ High Level Select Register -------- */ -#define PIO_REHLSR_P0 (0x1 << 0) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P1 (0x1 << 1) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P2 (0x1 << 2) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P3 (0x1 << 3) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P4 (0x1 << 4) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P5 (0x1 << 5) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P6 (0x1 << 6) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P7 (0x1 << 7) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P8 (0x1 << 8) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P9 (0x1 << 9) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P10 (0x1 << 10) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P11 (0x1 << 11) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P12 (0x1 << 12) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P13 (0x1 << 13) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P14 (0x1 << 14) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P15 (0x1 << 15) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P16 (0x1 << 16) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P17 (0x1 << 17) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P18 (0x1 << 18) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P19 (0x1 << 19) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P20 (0x1 << 20) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P21 (0x1 << 21) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P22 (0x1 << 22) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P23 (0x1 << 23) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P24 (0x1 << 24) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P25 (0x1 << 25) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P26 (0x1 << 26) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P27 (0x1 << 27) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P28 (0x1 << 28) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P29 (0x1 << 29) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P30 (0x1 << 30) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -#define PIO_REHLSR_P31 (0x1 << 31) /**< \brief (PIO_REHLSR) Rising Edge /High Level Interrupt Selection. */ -/* -------- PIO_FRLHSR : (PIO Offset: 0x00D8) Fall/Rise - Low/High Status Register -------- */ -#define PIO_FRLHSR_P0 (0x1 << 0) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P1 (0x1 << 1) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P2 (0x1 << 2) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P3 (0x1 << 3) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P4 (0x1 << 4) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P5 (0x1 << 5) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P6 (0x1 << 6) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P7 (0x1 << 7) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P8 (0x1 << 8) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P9 (0x1 << 9) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P10 (0x1 << 10) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P11 (0x1 << 11) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P12 (0x1 << 12) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P13 (0x1 << 13) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P14 (0x1 << 14) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P15 (0x1 << 15) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P16 (0x1 << 16) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P17 (0x1 << 17) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P18 (0x1 << 18) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P19 (0x1 << 19) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P20 (0x1 << 20) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P21 (0x1 << 21) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P22 (0x1 << 22) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P23 (0x1 << 23) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P24 (0x1 << 24) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P25 (0x1 << 25) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P26 (0x1 << 26) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P27 (0x1 << 27) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P28 (0x1 << 28) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P29 (0x1 << 29) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P30 (0x1 << 30) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -#define PIO_FRLHSR_P31 (0x1 << 31) /**< \brief (PIO_FRLHSR) Edge /Level Interrupt Source Selection. */ -/* -------- PIO_LOCKSR : (PIO Offset: 0x00E0) Lock Status -------- */ -#define PIO_LOCKSR_P0 (0x1 << 0) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P1 (0x1 << 1) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P2 (0x1 << 2) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P3 (0x1 << 3) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P4 (0x1 << 4) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P5 (0x1 << 5) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P6 (0x1 << 6) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P7 (0x1 << 7) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P8 (0x1 << 8) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P9 (0x1 << 9) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P10 (0x1 << 10) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P11 (0x1 << 11) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P12 (0x1 << 12) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P13 (0x1 << 13) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P14 (0x1 << 14) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P15 (0x1 << 15) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P16 (0x1 << 16) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P17 (0x1 << 17) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P18 (0x1 << 18) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P19 (0x1 << 19) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P20 (0x1 << 20) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P21 (0x1 << 21) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P22 (0x1 << 22) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P23 (0x1 << 23) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P24 (0x1 << 24) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P25 (0x1 << 25) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P26 (0x1 << 26) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P27 (0x1 << 27) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P28 (0x1 << 28) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P29 (0x1 << 29) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P30 (0x1 << 30) /**< \brief (PIO_LOCKSR) Lock Status. */ -#define PIO_LOCKSR_P31 (0x1 << 31) /**< \brief (PIO_LOCKSR) Lock Status. */ -/* -------- PIO_WPMR : (PIO Offset: 0x00E4) Write Protect Mode Register -------- */ -#define PIO_WPMR_WPEN (0x1 << 0) /**< \brief (PIO_WPMR) Write Protect Enable */ -#define PIO_WPMR_WPKEY (0xffffff << 8) /**< \brief (PIO_WPMR) Write Protect KEY */ -/* -------- PIO_WPSR : (PIO Offset: 0x00E8) Write Protect Status Register -------- */ -#define PIO_WPSR_WPVS (0x1 << 0) /**< \brief (PIO_WPSR) Write Protect Violation Status */ -#define PIO_WPSR_WPVSRC (0xffff << 8) /**< \brief (PIO_WPSR) Write Protect Violation Source */ -/* -------- PIO_SCHMITT : (PIO Offset: 0x0100) Schmitt Trigger Register -------- */ -#define PIO_SCHMITT_SCHMITT0 (0x1 << 0) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT1 (0x1 << 1) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT2 (0x1 << 2) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT3 (0x1 << 3) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT4 (0x1 << 4) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT5 (0x1 << 5) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT6 (0x1 << 6) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT7 (0x1 << 7) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT8 (0x1 << 8) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT9 (0x1 << 9) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT10 (0x1 << 10) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT11 (0x1 << 11) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT12 (0x1 << 12) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT13 (0x1 << 13) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT14 (0x1 << 14) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT15 (0x1 << 15) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT16 (0x1 << 16) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT17 (0x1 << 17) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT18 (0x1 << 18) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT19 (0x1 << 19) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT20 (0x1 << 20) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT21 (0x1 << 21) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT22 (0x1 << 22) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT23 (0x1 << 23) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT24 (0x1 << 24) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT25 (0x1 << 25) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT26 (0x1 << 26) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT27 (0x1 << 27) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT28 (0x1 << 28) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT29 (0x1 << 29) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT30 (0x1 << 30) /**< \brief (PIO_SCHMITT) */ -#define PIO_SCHMITT_SCHMITT31 (0x1 << 31) /**< \brief (PIO_SCHMITT) */ -/* -------- PIO_PCMR : (PIO Offset: 0x150) Parallel Capture Mode Register -------- */ -#define PIO_PCMR_PCEN (0x1 << 0) /**< \brief (PIO_PCMR) Parallel Capture Mode Enable */ -#define PIO_PCMR_DSIZE (0x3 << 4) /**< \brief (PIO_PCMR) Parallel Capture Mode Data Size */ -#define PIO_PCMR_ALWYS (0x1 << 9) /**< \brief (PIO_PCMR) Parallel Capture Mode Always Sampling */ -#define PIO_PCMR_HALFS (0x1 << 10) /**< \brief (PIO_PCMR) Parallel Capture Mode Half Sampling */ -#define PIO_PCMR_FRSTS (0x1 << 11) /**< \brief (PIO_PCMR) Parallel Capture Mode First Sample */ -/* -------- PIO_PCIER : (PIO Offset: 0x154) Parallel Capture Interrupt Enable Register -------- */ -#define PIO_PCIER_DRDY (0x1 << 0) /**< \brief (PIO_PCIER) Parallel Capture Mode Data Ready Interrupt Enable */ -#define PIO_PCIER_OVRE (0x1 << 1) /**< \brief (PIO_PCIER) Parallel Capture Mode Overrun Error Interrupt Enable */ -#define PIO_PCIER_ENDRX (0x1 << 2) /**< \brief (PIO_PCIER) End of Reception Transfer Interrupt Enable */ -#define PIO_PCIER_RXBUFF (0x1 << 3) /**< \brief (PIO_PCIER) Reception Buffer Full Interrupt Enable */ -/* -------- PIO_PCIDR : (PIO Offset: 0x158) Parallel Capture Interrupt Disable Register -------- */ -#define PIO_PCIDR_DRDY (0x1 << 0) /**< \brief (PIO_PCIDR) Parallel Capture Mode Data Ready Interrupt Disable */ -#define PIO_PCIDR_OVRE (0x1 << 1) /**< \brief (PIO_PCIDR) Parallel Capture Mode Overrun Error Interrupt Disable */ -#define PIO_PCIDR_ENDRX (0x1 << 2) /**< \brief (PIO_PCIDR) End of Reception Transfer Interrupt Disable */ -#define PIO_PCIDR_RXBUFF (0x1 << 3) /**< \brief (PIO_PCIDR) Reception Buffer Full Interrupt Disable */ -/* -------- PIO_PCIMR : (PIO Offset: 0x15C) Parallel Capture Interrupt Mask Register -------- */ -#define PIO_PCIMR_DRDY (0x1 << 0) /**< \brief (PIO_PCIMR) Parallel Capture Mode Data Ready Interrupt Mask */ -#define PIO_PCIMR_OVRE (0x1 << 1) /**< \brief (PIO_PCIMR) Parallel Capture Mode Overrun Error Interrupt Mask */ -#define PIO_PCIMR_ENDRX (0x1 << 2) /**< \brief (PIO_PCIMR) End of Reception Transfer Interrupt Mask */ -#define PIO_PCIMR_RXBUFF (0x1 << 3) /**< \brief (PIO_PCIMR) Reception Buffer Full Interrupt Mask */ -/* -------- PIO_PCISR : (PIO Offset: 0x160) Parallel Capture Interrupt Status Register -------- */ -#define PIO_PCISR_DRDY (0x1 << 0) /**< \brief (PIO_PCISR) Parallel Capture Mode Data Ready */ -#define PIO_PCISR_OVRE (0x1 << 1) /**< \brief (PIO_PCISR) Parallel Capture Mode Overrun Error. */ -#define PIO_PCISR_ENDRX (0x1 << 2) /**< \brief (PIO_PCISR) End of Reception Transfer. */ -#define PIO_PCISR_RXBUFF (0x1 << 3) /**< \brief (PIO_PCISR) Reception Buffer Full */ -/* -------- PIO_PCRHR : (PIO Offset: 0x164) Parallel Capture Reception Holding Register -------- */ -#define PIO_PCRHR_RDATA (0xffffffff << 0) /**< \brief (PIO_PCRHR) Parallel Capture Mode Reception Data. */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Power Management Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_PMC Power Management Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Pmc hardware registers */ -typedef struct { - WoReg PMC_SCER; /**< \brief (Pmc Offset: 0x0000) System Clock Enable Register */ - WoReg PMC_SCDR; /**< \brief (Pmc Offset: 0x0004) System Clock Disable Register */ - RoReg PMC_SCSR; /**< \brief (Pmc Offset: 0x0008) System Clock Status Register */ - RwReg Reserved1[1]; - WoReg PMC_PCER0; /**< \brief (Pmc Offset: 0x0010) Peripheral Clock Enable Register 0 */ - WoReg PMC_PCDR0; /**< \brief (Pmc Offset: 0x0014) Peripheral Clock Disable Register 0 */ - RoReg PMC_PCSR0; /**< \brief (Pmc Offset: 0x0018) Peripheral Clock Status Register 0 */ - RwReg Reserved2[1]; - RwReg CKGR_MOR; /**< \brief (Pmc Offset: 0x0020) Main Oscillator Register */ - RoReg CKGR_MCFR; /**< \brief (Pmc Offset: 0x0024) Main Clock Frequency Register */ - RwReg CKGR_PLLAR; /**< \brief (Pmc Offset: 0x0028) PLLA Register */ - RwReg CKGR_PLLBR; /**< \brief (Pmc Offset: 0x002C) PLLB Register */ - RwReg PMC_MCKR; /**< \brief (Pmc Offset: 0x0030) Master Clock Register */ - RwReg Reserved3[1]; - RwReg PMC_USB; /**< \brief (Pmc Offset: 0x0038) USB Clock Register */ - RwReg Reserved4[1]; - RwReg PMC_PCK[3]; /**< \brief (Pmc Offset: 0x0040) Programmable Clock 0 Register */ - RwReg Reserved5[5]; - WoReg PMC_IER; /**< \brief (Pmc Offset: 0x0060) Interrupt Enable Register */ - WoReg PMC_IDR; /**< \brief (Pmc Offset: 0x0064) Interrupt Disable Register */ - RoReg PMC_SR; /**< \brief (Pmc Offset: 0x0068) Status Register */ - RoReg PMC_IMR; /**< \brief (Pmc Offset: 0x006C) Interrupt Mask Register */ - RwReg PMC_FSMR; /**< \brief (Pmc Offset: 0x0070) Fast Startup Mode Register */ - RwReg PMC_FSPR; /**< \brief (Pmc Offset: 0x0074) Fast Startup Polarity Register */ - WoReg PMC_FOCR; /**< \brief (Pmc Offset: 0x0078) Fault Output Clear Register */ - RwReg Reserved6[26]; - RwReg PMC_WPMR; /**< \brief (Pmc Offset: 0x00E4) Write Protect Mode Register */ - RoReg PMC_WPSR; /**< \brief (Pmc Offset: 0x00E8) Write Protect Status Register */ - RwReg Reserved7[5]; - WoReg PMC_PCER1; /**< \brief (Pmc Offset: 0x0100) Peripheral Clock Enable Register 1 */ - WoReg PMC_PCDR1; /**< \brief (Pmc Offset: 0x0104) Peripheral Clock Disable Register 1 */ - RoReg PMC_PCSR1; /**< \brief (Pmc Offset: 0x0108) Peripheral Clock Status Register 1 */ - RwReg Reserved8[1]; - RwReg PMC_OCR; /**< \brief (Pmc Offset: 0x0110) Oscillator Calibration Register */ -} Pmc; -#endif /* __ASSEMBLY__ */ -/* -------- PMC_SCER : (PMC Offset: 0x0000) System Clock Enable Register -------- */ -#define PMC_SCER_UDP (0x1 << 7) /**< \brief (PMC_SCER) USB Device Port Clock Enable */ -#define PMC_SCER_PCK0 (0x1 << 8) /**< \brief (PMC_SCER) Programmable Clock 0 Output Enable */ -#define PMC_SCER_PCK1 (0x1 << 9) /**< \brief (PMC_SCER) Programmable Clock 1 Output Enable */ -#define PMC_SCER_PCK2 (0x1 << 10) /**< \brief (PMC_SCER) Programmable Clock 2 Output Enable */ -/* -------- PMC_SCDR : (PMC Offset: 0x0004) System Clock Disable Register -------- */ -#define PMC_SCDR_UDP (0x1 << 7) /**< \brief (PMC_SCDR) USB Device Port Clock Disable */ -#define PMC_SCDR_PCK0 (0x1 << 8) /**< \brief (PMC_SCDR) Programmable Clock 0 Output Disable */ -#define PMC_SCDR_PCK1 (0x1 << 9) /**< \brief (PMC_SCDR) Programmable Clock 1 Output Disable */ -#define PMC_SCDR_PCK2 (0x1 << 10) /**< \brief (PMC_SCDR) Programmable Clock 2 Output Disable */ -/* -------- PMC_SCSR : (PMC Offset: 0x0008) System Clock Status Register -------- */ -#define PMC_SCSR_UDP (0x1 << 7) /**< \brief (PMC_SCSR) USB Device Port Clock Status */ -#define PMC_SCSR_PCK0 (0x1 << 8) /**< \brief (PMC_SCSR) Programmable Clock 0 Output Status */ -#define PMC_SCSR_PCK1 (0x1 << 9) /**< \brief (PMC_SCSR) Programmable Clock 1 Output Status */ -#define PMC_SCSR_PCK2 (0x1 << 10) /**< \brief (PMC_SCSR) Programmable Clock 2 Output Status */ -/* -------- PMC_PCER0 : (PMC Offset: 0x0010) Peripheral Clock Enable Register 0 -------- */ -#define PMC_PCER0_PID2 (0x1 << 2) /**< \brief (PMC_PCER0) Peripheral Clock 2 Enable */ -#define PMC_PCER0_PID3 (0x1 << 3) /**< \brief (PMC_PCER0) Peripheral Clock 3 Enable */ -#define PMC_PCER0_PID4 (0x1 << 4) /**< \brief (PMC_PCER0) Peripheral Clock 4 Enable */ -#define PMC_PCER0_PID5 (0x1 << 5) /**< \brief (PMC_PCER0) Peripheral Clock 5 Enable */ -#define PMC_PCER0_PID6 (0x1 << 6) /**< \brief (PMC_PCER0) Peripheral Clock 6 Enable */ -#define PMC_PCER0_PID7 (0x1 << 7) /**< \brief (PMC_PCER0) Peripheral Clock 7 Enable */ -#define PMC_PCER0_PID8 (0x1 << 8) /**< \brief (PMC_PCER0) Peripheral Clock 8 Enable */ -#define PMC_PCER0_PID9 (0x1 << 9) /**< \brief (PMC_PCER0) Peripheral Clock 9 Enable */ -#define PMC_PCER0_PID10 (0x1 << 10) /**< \brief (PMC_PCER0) Peripheral Clock 10 Enable */ -#define PMC_PCER0_PID11 (0x1 << 11) /**< \brief (PMC_PCER0) Peripheral Clock 11 Enable */ -#define PMC_PCER0_PID12 (0x1 << 12) /**< \brief (PMC_PCER0) Peripheral Clock 12 Enable */ -#define PMC_PCER0_PID13 (0x1 << 13) /**< \brief (PMC_PCER0) Peripheral Clock 13 Enable */ -#define PMC_PCER0_PID14 (0x1 << 14) /**< \brief (PMC_PCER0) Peripheral Clock 14 Enable */ -#define PMC_PCER0_PID15 (0x1 << 15) /**< \brief (PMC_PCER0) Peripheral Clock 15 Enable */ -#define PMC_PCER0_PID16 (0x1 << 16) /**< \brief (PMC_PCER0) Peripheral Clock 16 Enable */ -#define PMC_PCER0_PID17 (0x1 << 17) /**< \brief (PMC_PCER0) Peripheral Clock 17 Enable */ -#define PMC_PCER0_PID18 (0x1 << 18) /**< \brief (PMC_PCER0) Peripheral Clock 18 Enable */ -#define PMC_PCER0_PID19 (0x1 << 19) /**< \brief (PMC_PCER0) Peripheral Clock 19 Enable */ -#define PMC_PCER0_PID20 (0x1 << 20) /**< \brief (PMC_PCER0) Peripheral Clock 20 Enable */ -#define PMC_PCER0_PID21 (0x1 << 21) /**< \brief (PMC_PCER0) Peripheral Clock 21 Enable */ -#define PMC_PCER0_PID22 (0x1 << 22) /**< \brief (PMC_PCER0) Peripheral Clock 22 Enable */ -#define PMC_PCER0_PID23 (0x1 << 23) /**< \brief (PMC_PCER0) Peripheral Clock 23 Enable */ -#define PMC_PCER0_PID24 (0x1 << 24) /**< \brief (PMC_PCER0) Peripheral Clock 24 Enable */ -#define PMC_PCER0_PID25 (0x1 << 25) /**< \brief (PMC_PCER0) Peripheral Clock 25 Enable */ -#define PMC_PCER0_PID26 (0x1 << 26) /**< \brief (PMC_PCER0) Peripheral Clock 26 Enable */ -#define PMC_PCER0_PID27 (0x1 << 27) /**< \brief (PMC_PCER0) Peripheral Clock 27 Enable */ -#define PMC_PCER0_PID28 (0x1 << 28) /**< \brief (PMC_PCER0) Peripheral Clock 28 Enable */ -#define PMC_PCER0_PID29 (0x1 << 29) /**< \brief (PMC_PCER0) Peripheral Clock 29 Enable */ -#define PMC_PCER0_PID30 (0x1 << 30) /**< \brief (PMC_PCER0) Peripheral Clock 30 Enable */ -#define PMC_PCER0_PID31 (0x1 << 31) /**< \brief (PMC_PCER0) Peripheral Clock 31 Enable */ -/* -------- PMC_PCDR0 : (PMC Offset: 0x0014) Peripheral Clock Disable Register 0 -------- */ -#define PMC_PCDR0_PID2 (0x1 << 2) /**< \brief (PMC_PCDR0) Peripheral Clock 2 Disable */ -#define PMC_PCDR0_PID3 (0x1 << 3) /**< \brief (PMC_PCDR0) Peripheral Clock 3 Disable */ -#define PMC_PCDR0_PID4 (0x1 << 4) /**< \brief (PMC_PCDR0) Peripheral Clock 4 Disable */ -#define PMC_PCDR0_PID5 (0x1 << 5) /**< \brief (PMC_PCDR0) Peripheral Clock 5 Disable */ -#define PMC_PCDR0_PID6 (0x1 << 6) /**< \brief (PMC_PCDR0) Peripheral Clock 6 Disable */ -#define PMC_PCDR0_PID7 (0x1 << 7) /**< \brief (PMC_PCDR0) Peripheral Clock 7 Disable */ -#define PMC_PCDR0_PID8 (0x1 << 8) /**< \brief (PMC_PCDR0) Peripheral Clock 8 Disable */ -#define PMC_PCDR0_PID9 (0x1 << 9) /**< \brief (PMC_PCDR0) Peripheral Clock 9 Disable */ -#define PMC_PCDR0_PID10 (0x1 << 10) /**< \brief (PMC_PCDR0) Peripheral Clock 10 Disable */ -#define PMC_PCDR0_PID11 (0x1 << 11) /**< \brief (PMC_PCDR0) Peripheral Clock 11 Disable */ -#define PMC_PCDR0_PID12 (0x1 << 12) /**< \brief (PMC_PCDR0) Peripheral Clock 12 Disable */ -#define PMC_PCDR0_PID13 (0x1 << 13) /**< \brief (PMC_PCDR0) Peripheral Clock 13 Disable */ -#define PMC_PCDR0_PID14 (0x1 << 14) /**< \brief (PMC_PCDR0) Peripheral Clock 14 Disable */ -#define PMC_PCDR0_PID15 (0x1 << 15) /**< \brief (PMC_PCDR0) Peripheral Clock 15 Disable */ -#define PMC_PCDR0_PID16 (0x1 << 16) /**< \brief (PMC_PCDR0) Peripheral Clock 16 Disable */ -#define PMC_PCDR0_PID17 (0x1 << 17) /**< \brief (PMC_PCDR0) Peripheral Clock 17 Disable */ -#define PMC_PCDR0_PID18 (0x1 << 18) /**< \brief (PMC_PCDR0) Peripheral Clock 18 Disable */ -#define PMC_PCDR0_PID19 (0x1 << 19) /**< \brief (PMC_PCDR0) Peripheral Clock 19 Disable */ -#define PMC_PCDR0_PID20 (0x1 << 20) /**< \brief (PMC_PCDR0) Peripheral Clock 20 Disable */ -#define PMC_PCDR0_PID21 (0x1 << 21) /**< \brief (PMC_PCDR0) Peripheral Clock 21 Disable */ -#define PMC_PCDR0_PID22 (0x1 << 22) /**< \brief (PMC_PCDR0) Peripheral Clock 22 Disable */ -#define PMC_PCDR0_PID23 (0x1 << 23) /**< \brief (PMC_PCDR0) Peripheral Clock 23 Disable */ -#define PMC_PCDR0_PID24 (0x1 << 24) /**< \brief (PMC_PCDR0) Peripheral Clock 24 Disable */ -#define PMC_PCDR0_PID25 (0x1 << 25) /**< \brief (PMC_PCDR0) Peripheral Clock 25 Disable */ -#define PMC_PCDR0_PID26 (0x1 << 26) /**< \brief (PMC_PCDR0) Peripheral Clock 26 Disable */ -#define PMC_PCDR0_PID27 (0x1 << 27) /**< \brief (PMC_PCDR0) Peripheral Clock 27 Disable */ -#define PMC_PCDR0_PID28 (0x1 << 28) /**< \brief (PMC_PCDR0) Peripheral Clock 28 Disable */ -#define PMC_PCDR0_PID29 (0x1 << 29) /**< \brief (PMC_PCDR0) Peripheral Clock 29 Disable */ -#define PMC_PCDR0_PID30 (0x1 << 30) /**< \brief (PMC_PCDR0) Peripheral Clock 30 Disable */ -#define PMC_PCDR0_PID31 (0x1 << 31) /**< \brief (PMC_PCDR0) Peripheral Clock 31 Disable */ -/* -------- PMC_PCSR0 : (PMC Offset: 0x0018) Peripheral Clock Status Register 0 -------- */ -#define PMC_PCSR0_PID2 (0x1 << 2) /**< \brief (PMC_PCSR0) Peripheral Clock 2 Status */ -#define PMC_PCSR0_PID3 (0x1 << 3) /**< \brief (PMC_PCSR0) Peripheral Clock 3 Status */ -#define PMC_PCSR0_PID4 (0x1 << 4) /**< \brief (PMC_PCSR0) Peripheral Clock 4 Status */ -#define PMC_PCSR0_PID5 (0x1 << 5) /**< \brief (PMC_PCSR0) Peripheral Clock 5 Status */ -#define PMC_PCSR0_PID6 (0x1 << 6) /**< \brief (PMC_PCSR0) Peripheral Clock 6 Status */ -#define PMC_PCSR0_PID7 (0x1 << 7) /**< \brief (PMC_PCSR0) Peripheral Clock 7 Status */ -#define PMC_PCSR0_PID8 (0x1 << 8) /**< \brief (PMC_PCSR0) Peripheral Clock 8 Status */ -#define PMC_PCSR0_PID9 (0x1 << 9) /**< \brief (PMC_PCSR0) Peripheral Clock 9 Status */ -#define PMC_PCSR0_PID10 (0x1 << 10) /**< \brief (PMC_PCSR0) Peripheral Clock 10 Status */ -#define PMC_PCSR0_PID11 (0x1 << 11) /**< \brief (PMC_PCSR0) Peripheral Clock 11 Status */ -#define PMC_PCSR0_PID12 (0x1 << 12) /**< \brief (PMC_PCSR0) Peripheral Clock 12 Status */ -#define PMC_PCSR0_PID13 (0x1 << 13) /**< \brief (PMC_PCSR0) Peripheral Clock 13 Status */ -#define PMC_PCSR0_PID14 (0x1 << 14) /**< \brief (PMC_PCSR0) Peripheral Clock 14 Status */ -#define PMC_PCSR0_PID15 (0x1 << 15) /**< \brief (PMC_PCSR0) Peripheral Clock 15 Status */ -#define PMC_PCSR0_PID16 (0x1 << 16) /**< \brief (PMC_PCSR0) Peripheral Clock 16 Status */ -#define PMC_PCSR0_PID17 (0x1 << 17) /**< \brief (PMC_PCSR0) Peripheral Clock 17 Status */ -#define PMC_PCSR0_PID18 (0x1 << 18) /**< \brief (PMC_PCSR0) Peripheral Clock 18 Status */ -#define PMC_PCSR0_PID19 (0x1 << 19) /**< \brief (PMC_PCSR0) Peripheral Clock 19 Status */ -#define PMC_PCSR0_PID20 (0x1 << 20) /**< \brief (PMC_PCSR0) Peripheral Clock 20 Status */ -#define PMC_PCSR0_PID21 (0x1 << 21) /**< \brief (PMC_PCSR0) Peripheral Clock 21 Status */ -#define PMC_PCSR0_PID22 (0x1 << 22) /**< \brief (PMC_PCSR0) Peripheral Clock 22 Status */ -#define PMC_PCSR0_PID23 (0x1 << 23) /**< \brief (PMC_PCSR0) Peripheral Clock 23 Status */ -#define PMC_PCSR0_PID24 (0x1 << 24) /**< \brief (PMC_PCSR0) Peripheral Clock 24 Status */ -#define PMC_PCSR0_PID25 (0x1 << 25) /**< \brief (PMC_PCSR0) Peripheral Clock 25 Status */ -#define PMC_PCSR0_PID26 (0x1 << 26) /**< \brief (PMC_PCSR0) Peripheral Clock 26 Status */ -#define PMC_PCSR0_PID27 (0x1 << 27) /**< \brief (PMC_PCSR0) Peripheral Clock 27 Status */ -#define PMC_PCSR0_PID28 (0x1 << 28) /**< \brief (PMC_PCSR0) Peripheral Clock 28 Status */ -#define PMC_PCSR0_PID29 (0x1 << 29) /**< \brief (PMC_PCSR0) Peripheral Clock 29 Status */ -#define PMC_PCSR0_PID30 (0x1 << 30) /**< \brief (PMC_PCSR0) Peripheral Clock 30 Status */ -#define PMC_PCSR0_PID31 (0x1 << 31) /**< \brief (PMC_PCSR0) Peripheral Clock 31 Status */ -/* -------- CKGR_MOR : (PMC Offset: 0x0020) Main Oscillator Register -------- */ -#define CKGR_MOR_MOSCXTEN (0x1 << 0) /**< \brief (CKGR_MOR) Main Crystal Oscillator Enable */ -#define CKGR_MOR_MOSCXTBY (0x1 << 1) /**< \brief (CKGR_MOR) Main Crystal Oscillator Bypass */ -#define CKGR_MOR_WAITMODE (0x1 << 2) /**< \brief (CKGR_MOR) Wait Mode Command */ -#define CKGR_MOR_MOSCRCEN (0x1 << 3) /**< \brief (CKGR_MOR) Main On-Chip RC Oscillator Enable */ -#define CKGR_MOR_MOSCRCF (0x7 << 4) /**< \brief (CKGR_MOR) Main On-Chip RC Oscillator Frequency Selection */ -#define CKGR_MOR_MOSCXTST (0xff << 8) /**< \brief (CKGR_MOR) Main Crystal Oscillator Start-up Time */ -#define CKGR_MOR_KEY (0xff << 16) /**< \brief (CKGR_MOR) Password */ -#define CKGR_MOR_MOSCSEL (0x1 << 24) /**< \brief (CKGR_MOR) Main Oscillator Selection */ -#define CKGR_MOR_CFDEN (0x1 << 25) /**< \brief (CKGR_MOR) Clock Failure Detector Enable */ -/* -------- CKGR_MCFR : (PMC Offset: 0x0024) Main Clock Frequency Register -------- */ -#define CKGR_MCFR_MAINF (0xffff << 0) /**< \brief (CKGR_MCFR) Main Clock Frequency */ -#define CKGR_MCFR_MAINFRDY (0x1 << 16) /**< \brief (CKGR_MCFR) Main Clock Ready */ -/* -------- CKGR_PLLAR : (PMC Offset: 0x0028) PLLA Register -------- */ -#define CKGR_PLLAR_DIVA (0xff << 0) /**< \brief (CKGR_PLLAR) Divider */ -#define CKGR_PLLAR_PLLACOUNT (0x3f << 8) /**< \brief (CKGR_PLLAR) PLLA Counter */ -#define CKGR_PLLAR_MULA (0x7ff << 16) /**< \brief (CKGR_PLLAR) PLLA Multiplier */ -#define CKGR_PLLAR_STUCKTO1 (0x1 << 29) /**< \brief (CKGR_PLLAR) */ -/* -------- CKGR_PLLBR : (PMC Offset: 0x002C) PLLB Register -------- */ -#define CKGR_PLLBR_DIVB (0xff << 0) /**< \brief (CKGR_PLLBR) Divider */ -#define CKGR_PLLBR_PLLBCOUNT (0x3f << 8) /**< \brief (CKGR_PLLBR) PLLB Counter */ -#define CKGR_PLLBR_MULB (0x7ff << 16) /**< \brief (CKGR_PLLBR) PLLB Multiplier */ -/* -------- PMC_MCKR : (PMC Offset: 0x0030) Master Clock Register -------- */ -#define PMC_MCKR_CSS (0x3 << 0) /**< \brief (PMC_MCKR) Master Clock Source Selection */ -#define PMC_MCKR_CSS_SLOW_CLK (0x0 << 0) /**< \brief (PMC_MCKR) Slow Clock is selected */ -#define PMC_MCKR_CSS_MAIN_CLK (0x1 << 0) /**< \brief (PMC_MCKR) Main Clock is selected */ -#define PMC_MCKR_CSS_PLLA_CLK (0x2 << 0) /**< \brief (PMC_MCKR) PLLA Clock is selected */ -#define PMC_MCKR_CSS_PLLB_CLK (0x3 << 0) /**< \brief (PMC_MCKR) PLLB Clock is selected */ -#define PMC_MCKR_PRES (0x7 << 4) /**< \brief (PMC_MCKR) Processor Clock Prescaler */ -#define PMC_MCKR_PRES_CLK (0x0 << 4) /**< \brief (PMC_MCKR) Selected clock */ -#define PMC_MCKR_PRES_CLK_2 (0x1 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 2 */ -#define PMC_MCKR_PRES_CLK_4 (0x2 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 4 */ -#define PMC_MCKR_PRES_CLK_8 (0x3 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 8 */ -#define PMC_MCKR_PRES_CLK_16 (0x4 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 16 */ -#define PMC_MCKR_PRES_CLK_32 (0x5 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 32 */ -#define PMC_MCKR_PRES_CLK_64 (0x6 << 4) /**< \brief (PMC_MCKR) Selected clock divided by 64 */ -#define PMC_MCKR_PLLADIV2 (0x1 << 12) /**< \brief (PMC_MCKR) PLLA Divisor by 2 */ -#define PMC_MCKR_PLLBDIV2 (0x1 << 13) /**< \brief (PMC_MCKR) PLLB Divisor by 2 */ -/* -------- PMC_USB : (PMC Offset: 0x0038) USB Clock Register -------- */ -#define PMC_USB_USBS (0x1 << 0) /**< \brief (PMC_USB) USB Input Clock Selection */ -#define PMC_USB_USBDIV (0xf << 8) /**< \brief (PMC_USB) Divider for USB Clock. */ -/* -------- PMC_PCK[3] : (PMC Offset: 0x0040) Programmable Clock 0 Register -------- */ -#define PMC_PCK_CSS (0x7 << 0) /**< \brief (PMC_PCK[3]) Master Clock Source Selection */ -#define PMC_PCK_PRES (0x7 << 4) /**< \brief (PMC_PCK[3]) Programmable Clock Prescaler */ -/* -------- PMC_IER : (PMC Offset: 0x0060) Interrupt Enable Register -------- */ -#define PMC_IER_MOSCXTS (0x1 << 0) /**< \brief (PMC_IER) Main Crystal Oscillator Status Interrupt Enable */ -#define PMC_IER_LOCKA (0x1 << 1) /**< \brief (PMC_IER) PLLA Lock Interrupt Enable */ -#define PMC_IER_LOCKB (0x1 << 2) /**< \brief (PMC_IER) PLLB Lock Interrupt Enable */ -#define PMC_IER_MCKRDY (0x1 << 3) /**< \brief (PMC_IER) Master Clock Ready Interrupt Enable */ -#define PMC_IER_PCKRDY0 (0x1 << 8) /**< \brief (PMC_IER) Programmable Clock Ready 0 Interrupt Enable */ -#define PMC_IER_PCKRDY1 (0x1 << 9) /**< \brief (PMC_IER) Programmable Clock Ready 1 Interrupt Enable */ -#define PMC_IER_PCKRDY2 (0x1 << 10) /**< \brief (PMC_IER) Programmable Clock Ready 2 Interrupt Enable */ -#define PMC_IER_MOSCSELS (0x1 << 16) /**< \brief (PMC_IER) Main Oscillator Selection Status Interrupt Enable */ -#define PMC_IER_MOSCRCS (0x1 << 17) /**< \brief (PMC_IER) Main On-Chip RC Status Interrupt Enable */ -#define PMC_IER_CFDEV (0x1 << 18) /**< \brief (PMC_IER) Clock Failure Detector Event Interrupt Enable */ -/* -------- PMC_IDR : (PMC Offset: 0x0064) Interrupt Disable Register -------- */ -#define PMC_IDR_MOSCXTS (0x1 << 0) /**< \brief (PMC_IDR) Main Crystal Oscillator Status Interrupt Disable */ -#define PMC_IDR_LOCKA (0x1 << 1) /**< \brief (PMC_IDR) PLLA Lock Interrupt Disable */ -#define PMC_IDR_LOCKB (0x1 << 2) /**< \brief (PMC_IDR) PLLB Lock Interrupt Disable */ -#define PMC_IDR_MCKRDY (0x1 << 3) /**< \brief (PMC_IDR) Master Clock Ready Interrupt Disable */ -#define PMC_IDR_PCKRDY0 (0x1 << 8) /**< \brief (PMC_IDR) Programmable Clock Ready 0 Interrupt Disable */ -#define PMC_IDR_PCKRDY1 (0x1 << 9) /**< \brief (PMC_IDR) Programmable Clock Ready 1 Interrupt Disable */ -#define PMC_IDR_PCKRDY2 (0x1 << 10) /**< \brief (PMC_IDR) Programmable Clock Ready 2 Interrupt Disable */ -#define PMC_IDR_MOSCSELS (0x1 << 16) /**< \brief (PMC_IDR) Main Oscillator Selection Status Interrupt Disable */ -#define PMC_IDR_MOSCRCS (0x1 << 17) /**< \brief (PMC_IDR) Main On-Chip RC Status Interrupt Disable */ -#define PMC_IDR_CFDEV (0x1 << 18) /**< \brief (PMC_IDR) Clock Failure Detector Event Interrupt Disable */ -/* -------- PMC_SR : (PMC Offset: 0x0068) Status Register -------- */ -#define PMC_SR_MOSCXTS (0x1 << 0) /**< \brief (PMC_SR) Main XTAL Oscillator Status */ -#define PMC_SR_LOCKA (0x1 << 1) /**< \brief (PMC_SR) PLLA Lock Status */ -#define PMC_SR_LOCKB (0x1 << 2) /**< \brief (PMC_SR) PLLB Lock Status */ -#define PMC_SR_MCKRDY (0x1 << 3) /**< \brief (PMC_SR) Master Clock Status */ -#define PMC_SR_OSCSELS (0x1 << 7) /**< \brief (PMC_SR) Slow Clock Oscillator Selection */ -#define PMC_SR_PCKRDY0 (0x1 << 8) /**< \brief (PMC_SR) Programmable Clock Ready Status */ -#define PMC_SR_PCKRDY1 (0x1 << 9) /**< \brief (PMC_SR) Programmable Clock Ready Status */ -#define PMC_SR_PCKRDY2 (0x1 << 10) /**< \brief (PMC_SR) Programmable Clock Ready Status */ -#define PMC_SR_MOSCSELS (0x1 << 16) /**< \brief (PMC_SR) Main Oscillator Selection Status */ -#define PMC_SR_MOSCRCS (0x1 << 17) /**< \brief (PMC_SR) Main On-Chip RC Oscillator Status */ -#define PMC_SR_CFDEV (0x1 << 18) /**< \brief (PMC_SR) Clock Failure Detector Event */ -#define PMC_SR_CFDS (0x1 << 19) /**< \brief (PMC_SR) Clock Failure Detector Status */ -#define PMC_SR_FOS (0x1 << 20) /**< \brief (PMC_SR) Clock Failure Detector Fault Output Status */ -/* -------- PMC_IMR : (PMC Offset: 0x006C) Interrupt Mask Register -------- */ -#define PMC_IMR_MOSCXTS (0x1 << 0) /**< \brief (PMC_IMR) Main Crystal Oscillator Status Interrupt Mask */ -#define PMC_IMR_LOCKA (0x1 << 1) /**< \brief (PMC_IMR) PLLA Lock Interrupt Mask */ -#define PMC_IMR_LOCKB (0x1 << 2) /**< \brief (PMC_IMR) PLLB Lock Interrupt Mask */ -#define PMC_IMR_MCKRDY (0x1 << 3) /**< \brief (PMC_IMR) Master Clock Ready Interrupt Mask */ -#define PMC_IMR_PCKRDY0 (0x1 << 8) /**< \brief (PMC_IMR) Programmable Clock Ready 0 Interrupt Mask */ -#define PMC_IMR_PCKRDY1 (0x1 << 9) /**< \brief (PMC_IMR) Programmable Clock Ready 1 Interrupt Mask */ -#define PMC_IMR_PCKRDY2 (0x1 << 10) /**< \brief (PMC_IMR) Programmable Clock Ready 2 Interrupt Mask */ -#define PMC_IMR_MOSCSELS (0x1 << 16) /**< \brief (PMC_IMR) Main Oscillator Selection Status Interrupt Mask */ -#define PMC_IMR_MOSCRCS (0x1 << 17) /**< \brief (PMC_IMR) Main On-Chip RC Status Interrupt Mask */ -#define PMC_IMR_CFDEV (0x1 << 18) /**< \brief (PMC_IMR) Clock Failure Detector Event Interrupt Mask */ -/* -------- PMC_FSMR : (PMC Offset: 0x0070) Fast Startup Mode Register -------- */ -#define PMC_FSMR_FSTT0 (0x1 << 0) /**< \brief (PMC_FSMR) Fast Startup Input Enable 0 */ -#define PMC_FSMR_FSTT1 (0x1 << 1) /**< \brief (PMC_FSMR) Fast Startup Input Enable 1 */ -#define PMC_FSMR_FSTT2 (0x1 << 2) /**< \brief (PMC_FSMR) Fast Startup Input Enable 2 */ -#define PMC_FSMR_FSTT3 (0x1 << 3) /**< \brief (PMC_FSMR) Fast Startup Input Enable 3 */ -#define PMC_FSMR_FSTT4 (0x1 << 4) /**< \brief (PMC_FSMR) Fast Startup Input Enable 4 */ -#define PMC_FSMR_FSTT5 (0x1 << 5) /**< \brief (PMC_FSMR) Fast Startup Input Enable 5 */ -#define PMC_FSMR_FSTT6 (0x1 << 6) /**< \brief (PMC_FSMR) Fast Startup Input Enable 6 */ -#define PMC_FSMR_FSTT7 (0x1 << 7) /**< \brief (PMC_FSMR) Fast Startup Input Enable 7 */ -#define PMC_FSMR_FSTT8 (0x1 << 8) /**< \brief (PMC_FSMR) Fast Startup Input Enable 8 */ -#define PMC_FSMR_FSTT9 (0x1 << 9) /**< \brief (PMC_FSMR) Fast Startup Input Enable 9 */ -#define PMC_FSMR_FSTT10 (0x1 << 10) /**< \brief (PMC_FSMR) Fast Startup Input Enable 10 */ -#define PMC_FSMR_FSTT11 (0x1 << 11) /**< \brief (PMC_FSMR) Fast Startup Input Enable 11 */ -#define PMC_FSMR_FSTT12 (0x1 << 12) /**< \brief (PMC_FSMR) Fast Startup Input Enable 12 */ -#define PMC_FSMR_FSTT13 (0x1 << 13) /**< \brief (PMC_FSMR) Fast Startup Input Enable 13 */ -#define PMC_FSMR_FSTT14 (0x1 << 14) /**< \brief (PMC_FSMR) Fast Startup Input Enable 14 */ -#define PMC_FSMR_FSTT15 (0x1 << 15) /**< \brief (PMC_FSMR) Fast Startup Input Enable 15 */ -#define PMC_FSMR_RTTAL (0x1 << 16) /**< \brief (PMC_FSMR) RTT Alarm Enable */ -#define PMC_FSMR_RTCAL (0x1 << 17) /**< \brief (PMC_FSMR) RTC Alarm Enable */ -#define PMC_FSMR_USBAL (0x1 << 18) /**< \brief (PMC_FSMR) USB Alarm Enable */ -#define PMC_FSMR_LPM (0x1 << 20) /**< \brief (PMC_FSMR) Low Power Mode */ -/* -------- PMC_FSPR : (PMC Offset: 0x0074) Fast Startup Polarity Register -------- */ -#define PMC_FSPR_FSTP0 (0x1 << 0) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP1 (0x1 << 1) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP2 (0x1 << 2) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP3 (0x1 << 3) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP4 (0x1 << 4) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP5 (0x1 << 5) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP6 (0x1 << 6) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP7 (0x1 << 7) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP8 (0x1 << 8) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP9 (0x1 << 9) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP10 (0x1 << 10) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP11 (0x1 << 11) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP12 (0x1 << 12) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP13 (0x1 << 13) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP14 (0x1 << 14) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -#define PMC_FSPR_FSTP15 (0x1 << 15) /**< \brief (PMC_FSPR) Fast Startup Input Polarityx */ -/* -------- PMC_FOCR : (PMC Offset: 0x0078) Fault Output Clear Register -------- */ -#define PMC_FOCR_FOCLR (0x1 << 0) /**< \brief (PMC_FOCR) Fault Output Clear */ -/* -------- PMC_WPMR : (PMC Offset: 0x00E4) Write Protect Mode Register -------- */ -#define PMC_WPMR_WPEN (0x1 << 0) /**< \brief (PMC_WPMR) Write Protect Enable */ -#define PMC_WPMR_WPKEY (0xffffff << 8) /**< \brief (PMC_WPMR) Write Protect KEY */ -/* -------- PMC_WPSR : (PMC Offset: 0x00E8) Write Protect Status Register -------- */ -#define PMC_WPSR_WPVS (0x1 << 0) /**< \brief (PMC_WPSR) Write Protect Violation Status */ -#define PMC_WPSR_WPVSRC (0xffff << 8) /**< \brief (PMC_WPSR) Write Protect Violation Source */ -/* -------- PMC_PCER1 : (PMC Offset: 0x0100) Peripheral Clock Enable Register 1 -------- */ -#define PMC_PCER1_PID32 (0x1 << 0) /**< \brief (PMC_PCER1) Peripheral Clock 32 Enable */ -#define PMC_PCER1_PID33 (0x1 << 1) /**< \brief (PMC_PCER1) Peripheral Clock 33 Enable */ -#define PMC_PCER1_PID34 (0x1 << 2) /**< \brief (PMC_PCER1) Peripheral Clock 34 Enable */ -#define PMC_PCER1_PID35 (0x1 << 3) /**< \brief (PMC_PCER1) Peripheral Clock 35 Enable */ -#define PMC_PCER1_PID36 (0x1 << 4) /**< \brief (PMC_PCER1) Peripheral Clock 36 Enable */ -#define PMC_PCER1_PID37 (0x1 << 5) /**< \brief (PMC_PCER1) Peripheral Clock 37 Enable */ -#define PMC_PCER1_PID38 (0x1 << 6) /**< \brief (PMC_PCER1) Peripheral Clock 38 Enable */ -#define PMC_PCER1_PID39 (0x1 << 7) /**< \brief (PMC_PCER1) Peripheral Clock 39 Enable */ -#define PMC_PCER1_PID40 (0x1 << 8) /**< \brief (PMC_PCER1) Peripheral Clock 40 Enable */ -#define PMC_PCER1_PID41 (0x1 << 9) /**< \brief (PMC_PCER1) Peripheral Clock 41 Enable */ -#define PMC_PCER1_PID42 (0x1 << 10) /**< \brief (PMC_PCER1) Peripheral Clock 42 Enable */ -#define PMC_PCER1_PID43 (0x1 << 11) /**< \brief (PMC_PCER1) Peripheral Clock 43 Enable */ -#define PMC_PCER1_PID44 (0x1 << 12) /**< \brief (PMC_PCER1) Peripheral Clock 44 Enable */ -#define PMC_PCER1_PID45 (0x1 << 13) /**< \brief (PMC_PCER1) Peripheral Clock 45 Enable */ -#define PMC_PCER1_PID46 (0x1 << 14) /**< \brief (PMC_PCER1) Peripheral Clock 46 Enable */ -#define PMC_PCER1_PID47 (0x1 << 15) /**< \brief (PMC_PCER1) Peripheral Clock 47 Enable */ -#define PMC_PCER1_PID48 (0x1 << 16) /**< \brief (PMC_PCER1) Peripheral Clock 48 Enable */ -#define PMC_PCER1_PID49 (0x1 << 17) /**< \brief (PMC_PCER1) Peripheral Clock 49 Enable */ -#define PMC_PCER1_PID50 (0x1 << 18) /**< \brief (PMC_PCER1) Peripheral Clock 50 Enable */ -#define PMC_PCER1_PID51 (0x1 << 19) /**< \brief (PMC_PCER1) Peripheral Clock 51 Enable */ -#define PMC_PCER1_PID52 (0x1 << 20) /**< \brief (PMC_PCER1) Peripheral Clock 52 Enable */ -#define PMC_PCER1_PID53 (0x1 << 21) /**< \brief (PMC_PCER1) Peripheral Clock 53 Enable */ -#define PMC_PCER1_PID54 (0x1 << 22) /**< \brief (PMC_PCER1) Peripheral Clock 54 Enable */ -#define PMC_PCER1_PID55 (0x1 << 23) /**< \brief (PMC_PCER1) Peripheral Clock 55 Enable */ -#define PMC_PCER1_PID56 (0x1 << 24) /**< \brief (PMC_PCER1) Peripheral Clock 56 Enable */ -#define PMC_PCER1_PID57 (0x1 << 25) /**< \brief (PMC_PCER1) Peripheral Clock 57 Enable */ -#define PMC_PCER1_PID58 (0x1 << 26) /**< \brief (PMC_PCER1) Peripheral Clock 58 Enable */ -#define PMC_PCER1_PID59 (0x1 << 27) /**< \brief (PMC_PCER1) Peripheral Clock 59 Enable */ -#define PMC_PCER1_PID60 (0x1 << 28) /**< \brief (PMC_PCER1) Peripheral Clock 60 Enable */ -#define PMC_PCER1_PID61 (0x1 << 29) /**< \brief (PMC_PCER1) Peripheral Clock 61 Enable */ -#define PMC_PCER1_PID62 (0x1 << 30) /**< \brief (PMC_PCER1) Peripheral Clock 62 Enable */ -#define PMC_PCER1_PID63 (0x1 << 31) /**< \brief (PMC_PCER1) Peripheral Clock 63 Enable */ -/* -------- PMC_PCDR1 : (PMC Offset: 0x0104) Peripheral Clock Disable Register 1 -------- */ -#define PMC_PCDR1_PID32 (0x1 << 0) /**< \brief (PMC_PCDR1) Peripheral Clock 32 Disable */ -#define PMC_PCDR1_PID33 (0x1 << 1) /**< \brief (PMC_PCDR1) Peripheral Clock 33 Disable */ -#define PMC_PCDR1_PID34 (0x1 << 2) /**< \brief (PMC_PCDR1) Peripheral Clock 34 Disable */ -#define PMC_PCDR1_PID35 (0x1 << 3) /**< \brief (PMC_PCDR1) Peripheral Clock 35 Disable */ -#define PMC_PCDR1_PID36 (0x1 << 4) /**< \brief (PMC_PCDR1) Peripheral Clock 36 Disable */ -#define PMC_PCDR1_PID37 (0x1 << 5) /**< \brief (PMC_PCDR1) Peripheral Clock 37 Disable */ -#define PMC_PCDR1_PID38 (0x1 << 6) /**< \brief (PMC_PCDR1) Peripheral Clock 38 Disable */ -#define PMC_PCDR1_PID39 (0x1 << 7) /**< \brief (PMC_PCDR1) Peripheral Clock 39 Disable */ -#define PMC_PCDR1_PID40 (0x1 << 8) /**< \brief (PMC_PCDR1) Peripheral Clock 40 Disable */ -#define PMC_PCDR1_PID41 (0x1 << 9) /**< \brief (PMC_PCDR1) Peripheral Clock 41 Disable */ -#define PMC_PCDR1_PID42 (0x1 << 10) /**< \brief (PMC_PCDR1) Peripheral Clock 42 Disable */ -#define PMC_PCDR1_PID43 (0x1 << 11) /**< \brief (PMC_PCDR1) Peripheral Clock 43 Disable */ -#define PMC_PCDR1_PID44 (0x1 << 12) /**< \brief (PMC_PCDR1) Peripheral Clock 44 Disable */ -#define PMC_PCDR1_PID45 (0x1 << 13) /**< \brief (PMC_PCDR1) Peripheral Clock 45 Disable */ -#define PMC_PCDR1_PID46 (0x1 << 14) /**< \brief (PMC_PCDR1) Peripheral Clock 46 Disable */ -#define PMC_PCDR1_PID47 (0x1 << 15) /**< \brief (PMC_PCDR1) Peripheral Clock 47 Disable */ -#define PMC_PCDR1_PID48 (0x1 << 16) /**< \brief (PMC_PCDR1) Peripheral Clock 48 Disable */ -#define PMC_PCDR1_PID49 (0x1 << 17) /**< \brief (PMC_PCDR1) Peripheral Clock 49 Disable */ -#define PMC_PCDR1_PID50 (0x1 << 18) /**< \brief (PMC_PCDR1) Peripheral Clock 50 Disable */ -#define PMC_PCDR1_PID51 (0x1 << 19) /**< \brief (PMC_PCDR1) Peripheral Clock 51 Disable */ -#define PMC_PCDR1_PID52 (0x1 << 20) /**< \brief (PMC_PCDR1) Peripheral Clock 52 Disable */ -#define PMC_PCDR1_PID53 (0x1 << 21) /**< \brief (PMC_PCDR1) Peripheral Clock 53 Disable */ -#define PMC_PCDR1_PID54 (0x1 << 22) /**< \brief (PMC_PCDR1) Peripheral Clock 54 Disable */ -#define PMC_PCDR1_PID55 (0x1 << 23) /**< \brief (PMC_PCDR1) Peripheral Clock 55 Disable */ -#define PMC_PCDR1_PID56 (0x1 << 24) /**< \brief (PMC_PCDR1) Peripheral Clock 56 Disable */ -#define PMC_PCDR1_PID57 (0x1 << 25) /**< \brief (PMC_PCDR1) Peripheral Clock 57 Disable */ -#define PMC_PCDR1_PID58 (0x1 << 26) /**< \brief (PMC_PCDR1) Peripheral Clock 58 Disable */ -#define PMC_PCDR1_PID59 (0x1 << 27) /**< \brief (PMC_PCDR1) Peripheral Clock 59 Disable */ -#define PMC_PCDR1_PID60 (0x1 << 28) /**< \brief (PMC_PCDR1) Peripheral Clock 60 Disable */ -#define PMC_PCDR1_PID61 (0x1 << 29) /**< \brief (PMC_PCDR1) Peripheral Clock 61 Disable */ -#define PMC_PCDR1_PID62 (0x1 << 30) /**< \brief (PMC_PCDR1) Peripheral Clock 62 Disable */ -#define PMC_PCDR1_PID63 (0x1 << 31) /**< \brief (PMC_PCDR1) Peripheral Clock 63 Disable */ -/* -------- PMC_PCSR1 : (PMC Offset: 0x0108) Peripheral Clock Status Register 1 -------- */ -#define PMC_PCSR1_PID32 (0x1 << 0) /**< \brief (PMC_PCSR1) Peripheral Clock 32 Status */ -#define PMC_PCSR1_PID33 (0x1 << 1) /**< \brief (PMC_PCSR1) Peripheral Clock 33 Status */ -#define PMC_PCSR1_PID34 (0x1 << 2) /**< \brief (PMC_PCSR1) Peripheral Clock 34 Status */ -#define PMC_PCSR1_PID35 (0x1 << 3) /**< \brief (PMC_PCSR1) Peripheral Clock 35 Status */ -#define PMC_PCSR1_PID36 (0x1 << 4) /**< \brief (PMC_PCSR1) Peripheral Clock 36 Status */ -#define PMC_PCSR1_PID37 (0x1 << 5) /**< \brief (PMC_PCSR1) Peripheral Clock 37 Status */ -#define PMC_PCSR1_PID38 (0x1 << 6) /**< \brief (PMC_PCSR1) Peripheral Clock 38 Status */ -#define PMC_PCSR1_PID39 (0x1 << 7) /**< \brief (PMC_PCSR1) Peripheral Clock 39 Status */ -#define PMC_PCSR1_PID40 (0x1 << 8) /**< \brief (PMC_PCSR1) Peripheral Clock 40 Status */ -#define PMC_PCSR1_PID41 (0x1 << 9) /**< \brief (PMC_PCSR1) Peripheral Clock 41 Status */ -#define PMC_PCSR1_PID42 (0x1 << 10) /**< \brief (PMC_PCSR1) Peripheral Clock 42 Status */ -#define PMC_PCSR1_PID43 (0x1 << 11) /**< \brief (PMC_PCSR1) Peripheral Clock 43 Status */ -#define PMC_PCSR1_PID44 (0x1 << 12) /**< \brief (PMC_PCSR1) Peripheral Clock 44 Status */ -#define PMC_PCSR1_PID45 (0x1 << 13) /**< \brief (PMC_PCSR1) Peripheral Clock 45 Status */ -#define PMC_PCSR1_PID46 (0x1 << 14) /**< \brief (PMC_PCSR1) Peripheral Clock 46 Status */ -#define PMC_PCSR1_PID47 (0x1 << 15) /**< \brief (PMC_PCSR1) Peripheral Clock 47 Status */ -#define PMC_PCSR1_PID48 (0x1 << 16) /**< \brief (PMC_PCSR1) Peripheral Clock 48 Status */ -#define PMC_PCSR1_PID49 (0x1 << 17) /**< \brief (PMC_PCSR1) Peripheral Clock 49 Status */ -#define PMC_PCSR1_PID50 (0x1 << 18) /**< \brief (PMC_PCSR1) Peripheral Clock 50 Status */ -#define PMC_PCSR1_PID51 (0x1 << 19) /**< \brief (PMC_PCSR1) Peripheral Clock 51 Status */ -#define PMC_PCSR1_PID52 (0x1 << 20) /**< \brief (PMC_PCSR1) Peripheral Clock 52 Status */ -#define PMC_PCSR1_PID53 (0x1 << 21) /**< \brief (PMC_PCSR1) Peripheral Clock 53 Status */ -#define PMC_PCSR1_PID54 (0x1 << 22) /**< \brief (PMC_PCSR1) Peripheral Clock 54 Status */ -#define PMC_PCSR1_PID55 (0x1 << 23) /**< \brief (PMC_PCSR1) Peripheral Clock 55 Status */ -#define PMC_PCSR1_PID56 (0x1 << 24) /**< \brief (PMC_PCSR1) Peripheral Clock 56 Status */ -#define PMC_PCSR1_PID57 (0x1 << 25) /**< \brief (PMC_PCSR1) Peripheral Clock 57 Status */ -#define PMC_PCSR1_PID58 (0x1 << 26) /**< \brief (PMC_PCSR1) Peripheral Clock 58 Status */ -#define PMC_PCSR1_PID59 (0x1 << 27) /**< \brief (PMC_PCSR1) Peripheral Clock 59 Status */ -#define PMC_PCSR1_PID60 (0x1 << 28) /**< \brief (PMC_PCSR1) Peripheral Clock 60 Status */ -#define PMC_PCSR1_PID61 (0x1 << 29) /**< \brief (PMC_PCSR1) Peripheral Clock 61 Status */ -#define PMC_PCSR1_PID62 (0x1 << 30) /**< \brief (PMC_PCSR1) Peripheral Clock 62 Status */ -#define PMC_PCSR1_PID63 (0x1 << 31) /**< \brief (PMC_PCSR1) Peripheral Clock 63 Status */ -/* -------- PMC_OCR : (PMC Offset: 0x0110) Oscillator Calibration Register -------- */ -#define PMC_OCR_CAL4 (0x7f << 0) /**< \brief (PMC_OCR) RC Oscillator Calibration bits for 4 Mhz */ -#define PMC_OCR_SEL4 (0x1 << 7) /**< \brief (PMC_OCR) Selection of RC Oscillator Calibration bits for 4 Mhz */ -#define PMC_OCR_CAL8 (0x7f << 8) /**< \brief (PMC_OCR) RC Oscillator Calibration bits for 8 Mhz */ -#define PMC_OCR_SEL8 (0x1 << 15) /**< \brief (PMC_OCR) Selection of RC Oscillator Calibration bits for 8 Mhz */ -#define PMC_OCR_CAL12 (0x7f << 16) /**< \brief (PMC_OCR) RC Oscillator Calibration bits for 12 Mhz */ -#define PMC_OCR_SEL12 (0x1 << 23) /**< \brief (PMC_OCR) Selection of RC Oscillator Calibration bits for 12 Mhz */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Pulse Width Modulation Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_PWM Pulse Width Modulation Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief PwmCh_num hardware registers */ -typedef struct { - RwReg PWM_CMR; /**< \brief (PwmCh_num Offset: 0x0) PWM Channel Mode Register */ - RwReg PWM_CDTY; /**< \brief (PwmCh_num Offset: 0x4) PWM Channel Duty Cycle Register */ - RwReg PWM_CDTYUPD; /**< \brief (PwmCh_num Offset: 0x8) PWM Channel Duty Cycle Update Register */ - RwReg PWM_CPRD; /**< \brief (PwmCh_num Offset: 0xC) PWM Channel Period Register */ - RwReg PWM_CPRDUPD; /**< \brief (PwmCh_num Offset: 0x10) PWM Channel Period Update Register */ - RwReg PWM_CCNT; /**< \brief (PwmCh_num Offset: 0x14) PWM Channel Counter Register */ - RwReg PWM_DT; /**< \brief (PwmCh_num Offset: 0x18) PWM Channel Dead Time Register */ - RwReg PWM_DTUPD; /**< \brief (PwmCh_num Offset: 0x1C) PWM Channel Dead Time Update Register */ -} PwmCh_num; -/** \brief Pwm hardware registers */ -typedef struct { - RwReg PWM_CLK; /**< \brief (Pwm Offset: 0x00) PWM Clock Register */ - WoReg PWM_ENA; /**< \brief (Pwm Offset: 0x04) PWM Enable Register */ - WoReg PWM_DIS; /**< \brief (Pwm Offset: 0x08) PWM Disable Register */ - RoReg PWM_SR; /**< \brief (Pwm Offset: 0x0C) PWM Status Register */ - WoReg PWM_IER1; /**< \brief (Pwm Offset: 0x10) PWM Interrupt Enable Register 1 */ - WoReg PWM_IDR1; /**< \brief (Pwm Offset: 0x14) PWM Interrupt Disable Register 1 */ - RoReg PWM_IMR1; /**< \brief (Pwm Offset: 0x18) PWM Interrupt Mask Register 1 */ - RoReg PWM_ISR1; /**< \brief (Pwm Offset: 0x1C) PWM Interrupt Status Register 1 */ - RwReg PWM_SCM; /**< \brief (Pwm Offset: 0x20) PWM Sync Channels Mode Register */ - RwReg Reserved1[1]; - RwReg PWM_SCUC; /**< \brief (Pwm Offset: 0x28) PWM Sync Channels Update Control Register */ - RwReg PWM_SCUP; /**< \brief (Pwm Offset: 0x2C) PWM Sync Channels Update Period Register */ - WoReg PWM_SCUPUPD; /**< \brief (Pwm Offset: 0x30) PWM Sync Channels Update Period Update Register */ - WoReg PWM_IER2; /**< \brief (Pwm Offset: 0x34) PWM Interrupt Enable Register 2 */ - WoReg PWM_IDR2; /**< \brief (Pwm Offset: 0x38) PWM Interrupt Disable Register 2 */ - RoReg PWM_IMR2; /**< \brief (Pwm Offset: 0x3C) PWM Interrupt Mask Register 2 */ - RoReg PWM_ISR2; /**< \brief (Pwm Offset: 0x40) PWM Interrupt Status Register 2 */ - RwReg PWM_OOV; /**< \brief (Pwm Offset: 0x44) PWM Output Override Value Register */ - RwReg PWM_OS; /**< \brief (Pwm Offset: 0x48) PWM Output Selection Register */ - WoReg PWM_OSS; /**< \brief (Pwm Offset: 0x4C) PWM Output Selection Set Register */ - WoReg PWM_OSC; /**< \brief (Pwm Offset: 0x50) PWM Output Selection Clear Register */ - WoReg PWM_OSSUPD; /**< \brief (Pwm Offset: 0x54) PWM Output Selection Set Update Register */ - WoReg PWM_OSCUPD; /**< \brief (Pwm Offset: 0x58) PWM Output Selection Clear Update Register */ - RwReg PWM_FMR; /**< \brief (Pwm Offset: 0x5C) PWM Fault Mode Register */ - RoReg PWM_FSR; /**< \brief (Pwm Offset: 0x60) PWM Fault Status Register */ - WoReg PWM_FCR; /**< \brief (Pwm Offset: 0x64) PWM Fault Clear Register */ - RwReg PWM_FPV; /**< \brief (Pwm Offset: 0x68) PWM Fault Protection Value Register */ - RwReg PWM_FPE; /**< \brief (Pwm Offset: 0x6C) PWM Fault Protection Enable Register */ - RwReg Reserved2[3]; - RwReg PWM_ELxMR[2]; /**< \brief (Pwm Offset: 0x7C) PWM Event Line 0 Mode Register */ - RwReg Reserved3[11]; - RwReg PWM_SMMR; /**< \brief (Pwm Offset: 0xB0) PWM Stepper Motor Mode Register */ - RwReg Reserved4[12]; - WoReg PWM_WPCR; /**< \brief (Pwm Offset: 0xE4) PWM Write Protect Control Register */ - RoReg PWM_WPSR; /**< \brief (Pwm Offset: 0xE8) PWM Write Protect Status Register */ - RwReg Reserved5[5]; - RwReg PWM_RPR; /**< \brief (Pwm Offset: 0x100) Receive Pointer Register */ - RwReg PWM_RCR; /**< \brief (Pwm Offset: 0x104) Receive Counter Register */ - RwReg PWM_TPR; /**< \brief (Pwm Offset: 0x108) Transmit Pointer Register */ - RwReg PWM_TCR; /**< \brief (Pwm Offset: 0x10C) Transmit Counter Register */ - RwReg PWM_RNPR; /**< \brief (Pwm Offset: 0x110) Receive Next Pointer Register */ - RwReg PWM_RNCR; /**< \brief (Pwm Offset: 0x114) Receive Next Counter Register */ - RwReg PWM_TNPR; /**< \brief (Pwm Offset: 0x118) Transmit Next Pointer Register */ - RwReg PWM_TNCR; /**< \brief (Pwm Offset: 0x11C) Transmit Next Counter Register */ - WoReg PWM_PTCR; /**< \brief (Pwm Offset: 0x120) Transfer Control Register */ - RoReg PWM_PTSR; /**< \brief (Pwm Offset: 0x124) Transfer Status Register */ - RwReg Reserved6[2]; - RwReg PWM_CMP0V; /**< \brief (Pwm Offset: 0x130) PWM Comparison 0 Value Register */ - WoReg PWM_CMP0VUPD; /**< \brief (Pwm Offset: 0x134) PWM Comparison 0 Value Update Register */ - RwReg PWM_CMP0M; /**< \brief (Pwm Offset: 0x138) PWM Comparison 0 Mode Register */ - WoReg PWM_CMP0MUPD; /**< \brief (Pwm Offset: 0x13C) PWM Comparison 0 Mode Update Register */ - RwReg PWM_CMP1V; /**< \brief (Pwm Offset: 0x140) PWM Comparison 1 Value Register */ - WoReg PWM_CMP1VUPD; /**< \brief (Pwm Offset: 0x144) PWM Comparison 1 Value Update Register */ - RwReg PWM_CMP1M; /**< \brief (Pwm Offset: 0x148) PWM Comparison 1 Mode Register */ - WoReg PWM_CMP1MUPD; /**< \brief (Pwm Offset: 0x14C) PWM Comparison 1 Mode Update Register */ - RwReg PWM_CMP2V; /**< \brief (Pwm Offset: 0x150) PWM Comparison 2 Value Register */ - WoReg PWM_CMP2VUPD; /**< \brief (Pwm Offset: 0x154) PWM Comparison 2 Value Update Register */ - RwReg PWM_CMP2M; /**< \brief (Pwm Offset: 0x158) PWM Comparison 2 Mode Register */ - WoReg PWM_CMP2MUPD; /**< \brief (Pwm Offset: 0x15C) PWM Comparison 2 Mode Update Register */ - RwReg PWM_CMP3V; /**< \brief (Pwm Offset: 0x160) PWM Comparison 3 Value Register */ - WoReg PWM_CMP3VUPD; /**< \brief (Pwm Offset: 0x164) PWM Comparison 3 Value Update Register */ - RwReg PWM_CMP3M; /**< \brief (Pwm Offset: 0x168) PWM Comparison 3 Mode Register */ - WoReg PWM_CMP3MUPD; /**< \brief (Pwm Offset: 0x16C) PWM Comparison 3 Mode Update Register */ - RwReg PWM_CMP4V; /**< \brief (Pwm Offset: 0x170) PWM Comparison 4 Value Register */ - WoReg PWM_CMP4VUPD; /**< \brief (Pwm Offset: 0x174) PWM Comparison 4 Value Update Register */ - RwReg PWM_CMP4M; /**< \brief (Pwm Offset: 0x178) PWM Comparison 4 Mode Register */ - WoReg PWM_CMP4MUPD; /**< \brief (Pwm Offset: 0x17C) PWM Comparison 4 Mode Update Register */ - RwReg PWM_CMP5V; /**< \brief (Pwm Offset: 0x180) PWM Comparison 5 Value Register */ - WoReg PWM_CMP5VUPD; /**< \brief (Pwm Offset: 0x184) PWM Comparison 5 Value Update Register */ - RwReg PWM_CMP5M; /**< \brief (Pwm Offset: 0x188) PWM Comparison 5 Mode Register */ - WoReg PWM_CMP5MUPD; /**< \brief (Pwm Offset: 0x18C) PWM Comparison 5 Mode Update Register */ - RwReg PWM_CMP6V; /**< \brief (Pwm Offset: 0x190) PWM Comparison 6 Value Register */ - WoReg PWM_CMP6VUPD; /**< \brief (Pwm Offset: 0x194) PWM Comparison 6 Value Update Register */ - RwReg PWM_CMP6M; /**< \brief (Pwm Offset: 0x198) PWM Comparison 6 Mode Register */ - WoReg PWM_CMP6MUPD; /**< \brief (Pwm Offset: 0x19C) PWM Comparison 6 Mode Update Register */ - RwReg PWM_CMP7V; /**< \brief (Pwm Offset: 0x1A0) PWM Comparison 7 Value Register */ - WoReg PWM_CMP7VUPD; /**< \brief (Pwm Offset: 0x1A4) PWM Comparison 7 Value Update Register */ - RwReg PWM_CMP7M; /**< \brief (Pwm Offset: 0x1A8) PWM Comparison 7 Mode Register */ - WoReg PWM_CMP7MUPD; /**< \brief (Pwm Offset: 0x1AC) PWM Comparison 7 Mode Update Register */ - RwReg Reserved7[20]; - PwmCh_num PWM_CH_NUM[4]; /**< \brief (Pwm Offset: 0x200) ch_num = 0 .. 3 */ -} Pwm; -#endif /* __ASSEMBLY__ */ -/* -------- PWM_CLK : (PWM Offset: 0x00) PWM Clock Register -------- */ -#define PWM_CLK_DIVA (0xff << 0) /**< \brief (PWM_CLK) CLKA, CLKB Divide Factor */ -#define PWM_CLK_PREA (0xf << 8) /**< \brief (PWM_CLK) CLKA, CLKB Source Clock Selection */ -#define PWM_CLK_DIVB (0xff << 16) /**< \brief (PWM_CLK) CLKA, CLKB Divide Factor */ -#define PWM_CLK_PREB (0xf << 24) /**< \brief (PWM_CLK) CLKA, CLKB Source Clock Selection */ -/* -------- PWM_ENA : (PWM Offset: 0x04) PWM Enable Register -------- */ -#define PWM_ENA_CHID0 (0x1 << 0) /**< \brief (PWM_ENA) Channel ID */ -#define PWM_ENA_CHID1 (0x1 << 1) /**< \brief (PWM_ENA) Channel ID */ -#define PWM_ENA_CHID2 (0x1 << 2) /**< \brief (PWM_ENA) Channel ID */ -#define PWM_ENA_CHID3 (0x1 << 3) /**< \brief (PWM_ENA) Channel ID */ -/* -------- PWM_DIS : (PWM Offset: 0x08) PWM Disable Register -------- */ -#define PWM_DIS_CHID0 (0x1 << 0) /**< \brief (PWM_DIS) Channel ID */ -#define PWM_DIS_CHID1 (0x1 << 1) /**< \brief (PWM_DIS) Channel ID */ -#define PWM_DIS_CHID2 (0x1 << 2) /**< \brief (PWM_DIS) Channel ID */ -#define PWM_DIS_CHID3 (0x1 << 3) /**< \brief (PWM_DIS) Channel ID */ -/* -------- PWM_SR : (PWM Offset: 0x0C) PWM Status Register -------- */ -#define PWM_SR_CHID0 (0x1 << 0) /**< \brief (PWM_SR) Channel ID */ -#define PWM_SR_CHID1 (0x1 << 1) /**< \brief (PWM_SR) Channel ID */ -#define PWM_SR_CHID2 (0x1 << 2) /**< \brief (PWM_SR) Channel ID */ -#define PWM_SR_CHID3 (0x1 << 3) /**< \brief (PWM_SR) Channel ID */ -/* -------- PWM_IER1 : (PWM Offset: 0x10) PWM Interrupt Enable Register 1 -------- */ -#define PWM_IER1_CHID0 (0x1 << 0) /**< \brief (PWM_IER1) Counter Event on Channel 0 Interrupt Enable */ -#define PWM_IER1_CHID1 (0x1 << 1) /**< \brief (PWM_IER1) Counter Event on Channel 1 Interrupt Enable */ -#define PWM_IER1_CHID2 (0x1 << 2) /**< \brief (PWM_IER1) Counter Event on Channel 2 Interrupt Enable */ -#define PWM_IER1_CHID3 (0x1 << 3) /**< \brief (PWM_IER1) Counter Event on Channel 3 Interrupt Enable */ -#define PWM_IER1_FCHID0 (0x1 << 16) /**< \brief (PWM_IER1) Fault Protection Trigger on Channel 0 Interrupt Enable */ -#define PWM_IER1_FCHID1 (0x1 << 17) /**< \brief (PWM_IER1) Fault Protection Trigger on Channel 1 Interrupt Enable */ -#define PWM_IER1_FCHID2 (0x1 << 18) /**< \brief (PWM_IER1) Fault Protection Trigger on Channel 2 Interrupt Enable */ -#define PWM_IER1_FCHID3 (0x1 << 19) /**< \brief (PWM_IER1) Fault Protection Trigger on Channel 3 Interrupt Enable */ -/* -------- PWM_IDR1 : (PWM Offset: 0x14) PWM Interrupt Disable Register 1 -------- */ -#define PWM_IDR1_CHID0 (0x1 << 0) /**< \brief (PWM_IDR1) Counter Event on Channel 0 Interrupt Disable */ -#define PWM_IDR1_CHID1 (0x1 << 1) /**< \brief (PWM_IDR1) Counter Event on Channel 1 Interrupt Disable */ -#define PWM_IDR1_CHID2 (0x1 << 2) /**< \brief (PWM_IDR1) Counter Event on Channel 2 Interrupt Disable */ -#define PWM_IDR1_CHID3 (0x1 << 3) /**< \brief (PWM_IDR1) Counter Event on Channel 3 Interrupt Disable */ -#define PWM_IDR1_FCHID0 (0x1 << 16) /**< \brief (PWM_IDR1) Fault Protection Trigger on Channel 0 Interrupt Disable */ -#define PWM_IDR1_FCHID1 (0x1 << 17) /**< \brief (PWM_IDR1) Fault Protection Trigger on Channel 1 Interrupt Disable */ -#define PWM_IDR1_FCHID2 (0x1 << 18) /**< \brief (PWM_IDR1) Fault Protection Trigger on Channel 2 Interrupt Disable */ -#define PWM_IDR1_FCHID3 (0x1 << 19) /**< \brief (PWM_IDR1) Fault Protection Trigger on Channel 3 Interrupt Disable */ -/* -------- PWM_IMR1 : (PWM Offset: 0x18) PWM Interrupt Mask Register 1 -------- */ -#define PWM_IMR1_CHID0 (0x1 << 0) /**< \brief (PWM_IMR1) Counter Event on Channel 0 Interrupt Mask */ -#define PWM_IMR1_CHID1 (0x1 << 1) /**< \brief (PWM_IMR1) Counter Event on Channel 1 Interrupt Mask */ -#define PWM_IMR1_CHID2 (0x1 << 2) /**< \brief (PWM_IMR1) Counter Event on Channel 2 Interrupt Mask */ -#define PWM_IMR1_CHID3 (0x1 << 3) /**< \brief (PWM_IMR1) Counter Event on Channel 3 Interrupt Mask */ -#define PWM_IMR1_FCHID0 (0x1 << 16) /**< \brief (PWM_IMR1) Fault Protection Trigger on Channel 0 Interrupt Mask */ -#define PWM_IMR1_FCHID1 (0x1 << 17) /**< \brief (PWM_IMR1) Fault Protection Trigger on Channel 1 Interrupt Mask */ -#define PWM_IMR1_FCHID2 (0x1 << 18) /**< \brief (PWM_IMR1) Fault Protection Trigger on Channel 2 Interrupt Mask */ -#define PWM_IMR1_FCHID3 (0x1 << 19) /**< \brief (PWM_IMR1) Fault Protection Trigger on Channel 3 Interrupt Mask */ -/* -------- PWM_ISR1 : (PWM Offset: 0x1C) PWM Interrupt Status Register 1 -------- */ -#define PWM_ISR1_CHID0 (0x1 << 0) /**< \brief (PWM_ISR1) Counter Event on Channel 0 */ -#define PWM_ISR1_CHID1 (0x1 << 1) /**< \brief (PWM_ISR1) Counter Event on Channel 1 */ -#define PWM_ISR1_CHID2 (0x1 << 2) /**< \brief (PWM_ISR1) Counter Event on Channel 2 */ -#define PWM_ISR1_CHID3 (0x1 << 3) /**< \brief (PWM_ISR1) Counter Event on Channel 3 */ -#define PWM_ISR1_FCHID0 (0x1 << 16) /**< \brief (PWM_ISR1) Fault Protection Trigger on Channel 0 */ -#define PWM_ISR1_FCHID1 (0x1 << 17) /**< \brief (PWM_ISR1) Fault Protection Trigger on Channel 1 */ -#define PWM_ISR1_FCHID2 (0x1 << 18) /**< \brief (PWM_ISR1) Fault Protection Trigger on Channel 2 */ -#define PWM_ISR1_FCHID3 (0x1 << 19) /**< \brief (PWM_ISR1) Fault Protection Trigger on Channel 3 */ -/* -------- PWM_SCM : (PWM Offset: 0x20) PWM Sync Channels Mode Register -------- */ -#define PWM_SCM_SYNC0 (0x1 << 0) /**< \brief (PWM_SCM) Synchronous Channel 0 */ -#define PWM_SCM_SYNC1 (0x1 << 1) /**< \brief (PWM_SCM) Synchronous Channel 1 */ -#define PWM_SCM_SYNC2 (0x1 << 2) /**< \brief (PWM_SCM) Synchronous Channel 2 */ -#define PWM_SCM_SYNC3 (0x1 << 3) /**< \brief (PWM_SCM) Synchronous Channel 3 */ -#define PWM_SCM_UPDM (0x3 << 16) /**< \brief (PWM_SCM) Synchronous Channels Update Mode */ -#define PWM_SCM_PTRM (0x1 << 20) /**< \brief (PWM_SCM) PDC Transfer Request Mode */ -#define PWM_SCM_PTRCS (0x7 << 21) /**< \brief (PWM_SCM) PDC Transfer Request Comparison Selection */ -/* -------- PWM_SCUC : (PWM Offset: 0x28) PWM Sync Channels Update Control Register -------- */ -#define PWM_SCUC_UPDULOCK (0x1 << 0) /**< \brief (PWM_SCUC) Synchronous Channels Update Unlock */ -/* -------- PWM_SCUP : (PWM Offset: 0x2C) PWM Sync Channels Update Period Register -------- */ -#define PWM_SCUP_UPR (0xf << 0) /**< \brief (PWM_SCUP) Update Period */ -#define PWM_SCUP_UPRCNT (0xf << 4) /**< \brief (PWM_SCUP) Update Period Counter */ -/* -------- PWM_SCUPUPD : (PWM Offset: 0x30) PWM Sync Channels Update Period Update Register -------- */ -#define PWM_SCUPUPD_UPRUPD (0xf << 0) /**< \brief (PWM_SCUPUPD) Update Period Update */ -/* -------- PWM_IER2 : (PWM Offset: 0x34) PWM Interrupt Enable Register 2 -------- */ -#define PWM_IER2_WRDY (0x1 << 0) /**< \brief (PWM_IER2) Write Ready for Synchronous Channels Update Interrupt Enable */ -#define PWM_IER2_ENDTX (0x1 << 1) /**< \brief (PWM_IER2) PDC End of TX Buffer Interrupt Enable */ -#define PWM_IER2_TXBUFE (0x1 << 2) /**< \brief (PWM_IER2) PDC TX Buffer Empty Interrupt Enable */ -#define PWM_IER2_UNRE (0x1 << 3) /**< \brief (PWM_IER2) Synchronous Channels Update Underrun Error Interrupt Enable */ -#define PWM_IER2_CMPM0 (0x1 << 8) /**< \brief (PWM_IER2) Comparison 0 Match Interrupt Enable */ -#define PWM_IER2_CMPM1 (0x1 << 9) /**< \brief (PWM_IER2) Comparison 1 Match Interrupt Enable */ -#define PWM_IER2_CMPM2 (0x1 << 10) /**< \brief (PWM_IER2) Comparison 2 Match Interrupt Enable */ -#define PWM_IER2_CMPM3 (0x1 << 11) /**< \brief (PWM_IER2) Comparison 3 Match Interrupt Enable */ -#define PWM_IER2_CMPM4 (0x1 << 12) /**< \brief (PWM_IER2) Comparison 4 Match Interrupt Enable */ -#define PWM_IER2_CMPM5 (0x1 << 13) /**< \brief (PWM_IER2) Comparison 5 Match Interrupt Enable */ -#define PWM_IER2_CMPM6 (0x1 << 14) /**< \brief (PWM_IER2) Comparison 6 Match Interrupt Enable */ -#define PWM_IER2_CMPM7 (0x1 << 15) /**< \brief (PWM_IER2) Comparison 7 Match Interrupt Enable */ -#define PWM_IER2_CMPU0 (0x1 << 16) /**< \brief (PWM_IER2) Comparison 0 Update Interrupt Enable */ -#define PWM_IER2_CMPU1 (0x1 << 17) /**< \brief (PWM_IER2) Comparison 1 Update Interrupt Enable */ -#define PWM_IER2_CMPU2 (0x1 << 18) /**< \brief (PWM_IER2) Comparison 2 Update Interrupt Enable */ -#define PWM_IER2_CMPU3 (0x1 << 19) /**< \brief (PWM_IER2) Comparison 3 Update Interrupt Enable */ -#define PWM_IER2_CMPU4 (0x1 << 20) /**< \brief (PWM_IER2) Comparison 4 Update Interrupt Enable */ -#define PWM_IER2_CMPU5 (0x1 << 21) /**< \brief (PWM_IER2) Comparison 5 Update Interrupt Enable */ -#define PWM_IER2_CMPU6 (0x1 << 22) /**< \brief (PWM_IER2) Comparison 6 Update Interrupt Enable */ -#define PWM_IER2_CMPU7 (0x1 << 23) /**< \brief (PWM_IER2) Comparison 7 Update Interrupt Enable */ -/* -------- PWM_IDR2 : (PWM Offset: 0x38) PWM Interrupt Disable Register 2 -------- */ -#define PWM_IDR2_WRDY (0x1 << 0) /**< \brief (PWM_IDR2) Write Ready for Synchronous Channels Update Interrupt Disable */ -#define PWM_IDR2_ENDTX (0x1 << 1) /**< \brief (PWM_IDR2) PDC End of TX Buffer Interrupt Disable */ -#define PWM_IDR2_TXBUFE (0x1 << 2) /**< \brief (PWM_IDR2) PDC TX Buffer Empty Interrupt Disable */ -#define PWM_IDR2_UNRE (0x1 << 3) /**< \brief (PWM_IDR2) Synchronous Channels Update Underrun Error Interrupt Disable */ -#define PWM_IDR2_CMPM0 (0x1 << 8) /**< \brief (PWM_IDR2) Comparison 0 Match Interrupt Disable */ -#define PWM_IDR2_CMPM1 (0x1 << 9) /**< \brief (PWM_IDR2) Comparison 1 Match Interrupt Disable */ -#define PWM_IDR2_CMPM2 (0x1 << 10) /**< \brief (PWM_IDR2) Comparison 2 Match Interrupt Disable */ -#define PWM_IDR2_CMPM3 (0x1 << 11) /**< \brief (PWM_IDR2) Comparison 3 Match Interrupt Disable */ -#define PWM_IDR2_CMPM4 (0x1 << 12) /**< \brief (PWM_IDR2) Comparison 4 Match Interrupt Disable */ -#define PWM_IDR2_CMPM5 (0x1 << 13) /**< \brief (PWM_IDR2) Comparison 5 Match Interrupt Disable */ -#define PWM_IDR2_CMPM6 (0x1 << 14) /**< \brief (PWM_IDR2) Comparison 6 Match Interrupt Disable */ -#define PWM_IDR2_CMPM7 (0x1 << 15) /**< \brief (PWM_IDR2) Comparison 7 Match Interrupt Disable */ -#define PWM_IDR2_CMPU0 (0x1 << 16) /**< \brief (PWM_IDR2) Comparison 0 Update Interrupt Disable */ -#define PWM_IDR2_CMPU1 (0x1 << 17) /**< \brief (PWM_IDR2) Comparison 1 Update Interrupt Disable */ -#define PWM_IDR2_CMPU2 (0x1 << 18) /**< \brief (PWM_IDR2) Comparison 2 Update Interrupt Disable */ -#define PWM_IDR2_CMPU3 (0x1 << 19) /**< \brief (PWM_IDR2) Comparison 3 Update Interrupt Disable */ -#define PWM_IDR2_CMPU4 (0x1 << 20) /**< \brief (PWM_IDR2) Comparison 4 Update Interrupt Disable */ -#define PWM_IDR2_CMPU5 (0x1 << 21) /**< \brief (PWM_IDR2) Comparison 5 Update Interrupt Disable */ -#define PWM_IDR2_CMPU6 (0x1 << 22) /**< \brief (PWM_IDR2) Comparison 6 Update Interrupt Disable */ -#define PWM_IDR2_CMPU7 (0x1 << 23) /**< \brief (PWM_IDR2) Comparison 7 Update Interrupt Disable */ -/* -------- PWM_IMR2 : (PWM Offset: 0x3C) PWM Interrupt Mask Register 2 -------- */ -#define PWM_IMR2_WRDY (0x1 << 0) /**< \brief (PWM_IMR2) Write Ready for Synchronous Channels Update Interrupt Mask */ -#define PWM_IMR2_ENDTX (0x1 << 1) /**< \brief (PWM_IMR2) PDC End of TX Buffer Interrupt Mask */ -#define PWM_IMR2_TXBUFE (0x1 << 2) /**< \brief (PWM_IMR2) PDC TX Buffer Empty Interrupt Mask */ -#define PWM_IMR2_UNRE (0x1 << 3) /**< \brief (PWM_IMR2) Synchronous Channels Update Underrun Error Interrupt Mask */ -#define PWM_IMR2_CMPM0 (0x1 << 8) /**< \brief (PWM_IMR2) Comparison 0 Match Interrupt Mask */ -#define PWM_IMR2_CMPM1 (0x1 << 9) /**< \brief (PWM_IMR2) Comparison 1 Match Interrupt Mask */ -#define PWM_IMR2_CMPM2 (0x1 << 10) /**< \brief (PWM_IMR2) Comparison 2 Match Interrupt Mask */ -#define PWM_IMR2_CMPM3 (0x1 << 11) /**< \brief (PWM_IMR2) Comparison 3 Match Interrupt Mask */ -#define PWM_IMR2_CMPM4 (0x1 << 12) /**< \brief (PWM_IMR2) Comparison 4 Match Interrupt Mask */ -#define PWM_IMR2_CMPM5 (0x1 << 13) /**< \brief (PWM_IMR2) Comparison 5 Match Interrupt Mask */ -#define PWM_IMR2_CMPM6 (0x1 << 14) /**< \brief (PWM_IMR2) Comparison 6 Match Interrupt Mask */ -#define PWM_IMR2_CMPM7 (0x1 << 15) /**< \brief (PWM_IMR2) Comparison 7 Match Interrupt Mask */ -#define PWM_IMR2_CMPU0 (0x1 << 16) /**< \brief (PWM_IMR2) Comparison 0 Update Interrupt Mask */ -#define PWM_IMR2_CMPU1 (0x1 << 17) /**< \brief (PWM_IMR2) Comparison 1 Update Interrupt Mask */ -#define PWM_IMR2_CMPU2 (0x1 << 18) /**< \brief (PWM_IMR2) Comparison 2 Update Interrupt Mask */ -#define PWM_IMR2_CMPU3 (0x1 << 19) /**< \brief (PWM_IMR2) Comparison 3 Update Interrupt Mask */ -#define PWM_IMR2_CMPU4 (0x1 << 20) /**< \brief (PWM_IMR2) Comparison 4 Update Interrupt Mask */ -#define PWM_IMR2_CMPU5 (0x1 << 21) /**< \brief (PWM_IMR2) Comparison 5 Update Interrupt Mask */ -#define PWM_IMR2_CMPU6 (0x1 << 22) /**< \brief (PWM_IMR2) Comparison 6 Update Interrupt Mask */ -#define PWM_IMR2_CMPU7 (0x1 << 23) /**< \brief (PWM_IMR2) Comparison 7 Update Interrupt Mask */ -/* -------- PWM_ISR2 : (PWM Offset: 0x40) PWM Interrupt Status Register 2 -------- */ -#define PWM_ISR2_WRDY (0x1 << 0) /**< \brief (PWM_ISR2) Write Ready for Synchronous Channels Update */ -#define PWM_ISR2_ENDTX (0x1 << 1) /**< \brief (PWM_ISR2) PDC End of TX Buffer */ -#define PWM_ISR2_TXBUFE (0x1 << 2) /**< \brief (PWM_ISR2) PDC TX Buffer Empty */ -#define PWM_ISR2_UNRE (0x1 << 3) /**< \brief (PWM_ISR2) Synchronous Channels Update Underrun Error */ -#define PWM_ISR2_CMPM0 (0x1 << 8) /**< \brief (PWM_ISR2) Comparison 0 Match */ -#define PWM_ISR2_CMPM1 (0x1 << 9) /**< \brief (PWM_ISR2) Comparison 1 Match */ -#define PWM_ISR2_CMPM2 (0x1 << 10) /**< \brief (PWM_ISR2) Comparison 2 Match */ -#define PWM_ISR2_CMPM3 (0x1 << 11) /**< \brief (PWM_ISR2) Comparison 3 Match */ -#define PWM_ISR2_CMPM4 (0x1 << 12) /**< \brief (PWM_ISR2) Comparison 4 Match */ -#define PWM_ISR2_CMPM5 (0x1 << 13) /**< \brief (PWM_ISR2) Comparison 5 Match */ -#define PWM_ISR2_CMPM6 (0x1 << 14) /**< \brief (PWM_ISR2) Comparison 6 Match */ -#define PWM_ISR2_CMPM7 (0x1 << 15) /**< \brief (PWM_ISR2) Comparison 7 Match */ -#define PWM_ISR2_CMPU0 (0x1 << 16) /**< \brief (PWM_ISR2) Comparison 0 Update */ -#define PWM_ISR2_CMPU1 (0x1 << 17) /**< \brief (PWM_ISR2) Comparison 1 Update */ -#define PWM_ISR2_CMPU2 (0x1 << 18) /**< \brief (PWM_ISR2) Comparison 2 Update */ -#define PWM_ISR2_CMPU3 (0x1 << 19) /**< \brief (PWM_ISR2) Comparison 3 Update */ -#define PWM_ISR2_CMPU4 (0x1 << 20) /**< \brief (PWM_ISR2) Comparison 4 Update */ -#define PWM_ISR2_CMPU5 (0x1 << 21) /**< \brief (PWM_ISR2) Comparison 5 Update */ -#define PWM_ISR2_CMPU6 (0x1 << 22) /**< \brief (PWM_ISR2) Comparison 6 Update */ -#define PWM_ISR2_CMPU7 (0x1 << 23) /**< \brief (PWM_ISR2) Comparison 7 Update */ -/* -------- PWM_OOV : (PWM Offset: 0x44) PWM Output Override Value Register -------- */ -#define PWM_OOV_OOVH0 (0x1 << 0) /**< \brief (PWM_OOV) Output Override Value for PWMH output of the channel 0 */ -#define PWM_OOV_OOVH1 (0x1 << 1) /**< \brief (PWM_OOV) Output Override Value for PWMH output of the channel 1 */ -#define PWM_OOV_OOVH2 (0x1 << 2) /**< \brief (PWM_OOV) Output Override Value for PWMH output of the channel 2 */ -#define PWM_OOV_OOVH3 (0x1 << 3) /**< \brief (PWM_OOV) Output Override Value for PWMH output of the channel 3 */ -#define PWM_OOV_OOVL0 (0x1 << 16) /**< \brief (PWM_OOV) Output Override Value for PWML output of the channel 0 */ -#define PWM_OOV_OOVL1 (0x1 << 17) /**< \brief (PWM_OOV) Output Override Value for PWML output of the channel 1 */ -#define PWM_OOV_OOVL2 (0x1 << 18) /**< \brief (PWM_OOV) Output Override Value for PWML output of the channel 2 */ -#define PWM_OOV_OOVL3 (0x1 << 19) /**< \brief (PWM_OOV) Output Override Value for PWML output of the channel 3 */ -/* -------- PWM_OS : (PWM Offset: 0x48) PWM Output Selection Register -------- */ -#define PWM_OS_OSH0 (0x1 << 0) /**< \brief (PWM_OS) Output Selection for PWMH output of the channel 0 */ -#define PWM_OS_OSH1 (0x1 << 1) /**< \brief (PWM_OS) Output Selection for PWMH output of the channel 1 */ -#define PWM_OS_OSH2 (0x1 << 2) /**< \brief (PWM_OS) Output Selection for PWMH output of the channel 2 */ -#define PWM_OS_OSH3 (0x1 << 3) /**< \brief (PWM_OS) Output Selection for PWMH output of the channel 3 */ -#define PWM_OS_OSL0 (0x1 << 16) /**< \brief (PWM_OS) Output Selection for PWML output of the channel 0 */ -#define PWM_OS_OSL1 (0x1 << 17) /**< \brief (PWM_OS) Output Selection for PWML output of the channel 1 */ -#define PWM_OS_OSL2 (0x1 << 18) /**< \brief (PWM_OS) Output Selection for PWML output of the channel 2 */ -#define PWM_OS_OSL3 (0x1 << 19) /**< \brief (PWM_OS) Output Selection for PWML output of the channel 3 */ -/* -------- PWM_OSS : (PWM Offset: 0x4C) PWM Output Selection Set Register -------- */ -#define PWM_OSS_OSSH0 (0x1 << 0) /**< \brief (PWM_OSS) Output Selection Set for PWMH output of the channel 0 */ -#define PWM_OSS_OSSH1 (0x1 << 1) /**< \brief (PWM_OSS) Output Selection Set for PWMH output of the channel 1 */ -#define PWM_OSS_OSSH2 (0x1 << 2) /**< \brief (PWM_OSS) Output Selection Set for PWMH output of the channel 2 */ -#define PWM_OSS_OSSH3 (0x1 << 3) /**< \brief (PWM_OSS) Output Selection Set for PWMH output of the channel 3 */ -#define PWM_OSS_OSSL0 (0x1 << 16) /**< \brief (PWM_OSS) Output Selection Set for PWML output of the channel 0 */ -#define PWM_OSS_OSSL1 (0x1 << 17) /**< \brief (PWM_OSS) Output Selection Set for PWML output of the channel 1 */ -#define PWM_OSS_OSSL2 (0x1 << 18) /**< \brief (PWM_OSS) Output Selection Set for PWML output of the channel 2 */ -#define PWM_OSS_OSSL3 (0x1 << 19) /**< \brief (PWM_OSS) Output Selection Set for PWML output of the channel 3 */ -/* -------- PWM_OSC : (PWM Offset: 0x50) PWM Output Selection Clear Register -------- */ -#define PWM_OSC_OSCH0 (0x1 << 0) /**< \brief (PWM_OSC) Output Selection Clear for PWMH output of the channel 0 */ -#define PWM_OSC_OSCH1 (0x1 << 1) /**< \brief (PWM_OSC) Output Selection Clear for PWMH output of the channel 1 */ -#define PWM_OSC_OSCH2 (0x1 << 2) /**< \brief (PWM_OSC) Output Selection Clear for PWMH output of the channel 2 */ -#define PWM_OSC_OSCH3 (0x1 << 3) /**< \brief (PWM_OSC) Output Selection Clear for PWMH output of the channel 3 */ -#define PWM_OSC_OSCL0 (0x1 << 16) /**< \brief (PWM_OSC) Output Selection Clear for PWML output of the channel 0 */ -#define PWM_OSC_OSCL1 (0x1 << 17) /**< \brief (PWM_OSC) Output Selection Clear for PWML output of the channel 1 */ -#define PWM_OSC_OSCL2 (0x1 << 18) /**< \brief (PWM_OSC) Output Selection Clear for PWML output of the channel 2 */ -#define PWM_OSC_OSCL3 (0x1 << 19) /**< \brief (PWM_OSC) Output Selection Clear for PWML output of the channel 3 */ -/* -------- PWM_OSSUPD : (PWM Offset: 0x54) PWM Output Selection Set Update Register -------- */ -#define PWM_OSSUPD_OSSUPH0 (0x1 << 0) /**< \brief (PWM_OSSUPD) Output Selection Set for PWMH output of the channel 0 */ -#define PWM_OSSUPD_OSSUPH1 (0x1 << 1) /**< \brief (PWM_OSSUPD) Output Selection Set for PWMH output of the channel 1 */ -#define PWM_OSSUPD_OSSUPH2 (0x1 << 2) /**< \brief (PWM_OSSUPD) Output Selection Set for PWMH output of the channel 2 */ -#define PWM_OSSUPD_OSSUPH3 (0x1 << 3) /**< \brief (PWM_OSSUPD) Output Selection Set for PWMH output of the channel 3 */ -#define PWM_OSSUPD_OSSUPL0 (0x1 << 16) /**< \brief (PWM_OSSUPD) Output Selection Set for PWML output of the channel 0 */ -#define PWM_OSSUPD_OSSUPL1 (0x1 << 17) /**< \brief (PWM_OSSUPD) Output Selection Set for PWML output of the channel 1 */ -#define PWM_OSSUPD_OSSUPL2 (0x1 << 18) /**< \brief (PWM_OSSUPD) Output Selection Set for PWML output of the channel 2 */ -#define PWM_OSSUPD_OSSUPL3 (0x1 << 19) /**< \brief (PWM_OSSUPD) Output Selection Set for PWML output of the channel 3 */ -/* -------- PWM_OSCUPD : (PWM Offset: 0x58) PWM Output Selection Clear Update Register -------- */ -#define PWM_OSCUPD_OSCUPH0 (0x1 << 0) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWMH output of the channel 0 */ -#define PWM_OSCUPD_OSCUPH1 (0x1 << 1) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWMH output of the channel 1 */ -#define PWM_OSCUPD_OSCUPH2 (0x1 << 2) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWMH output of the channel 2 */ -#define PWM_OSCUPD_OSCUPH3 (0x1 << 3) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWMH output of the channel 3 */ -#define PWM_OSCUPD_OSCUPL0 (0x1 << 16) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWML output of the channel 0 */ -#define PWM_OSCUPD_OSCUPL1 (0x1 << 17) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWML output of the channel 1 */ -#define PWM_OSCUPD_OSCUPL2 (0x1 << 18) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWML output of the channel 2 */ -#define PWM_OSCUPD_OSCUPL3 (0x1 << 19) /**< \brief (PWM_OSCUPD) Output Selection Clear for PWML output of the channel 3 */ -/* -------- PWM_FMR : (PWM Offset: 0x5C) PWM Fault Mode Register -------- */ -#define PWM_FMR_FPOL0 (0x1 << 0) /**< \brief (PWM_FMR) Fault 0 Polarity */ -#define PWM_FMR_FPOL1 (0x1 << 1) /**< \brief (PWM_FMR) Fault 1 Polarity */ -#define PWM_FMR_FPOL2 (0x1 << 2) /**< \brief (PWM_FMR) Fault 2 Polarity */ -#define PWM_FMR_FPOL3 (0x1 << 3) /**< \brief (PWM_FMR) Fault 3 Polarity */ -#define PWM_FMR_FMOD0 (0x1 << 8) /**< \brief (PWM_FMR) Fault 0 Activation Mode */ -#define PWM_FMR_FMOD1 (0x1 << 9) /**< \brief (PWM_FMR) Fault 1 Activation Mode */ -#define PWM_FMR_FMOD2 (0x1 << 10) /**< \brief (PWM_FMR) Fault 2 Activation Mode */ -#define PWM_FMR_FMOD3 (0x1 << 11) /**< \brief (PWM_FMR) Fault 3 Activation Mode */ -#define PWM_FMR_FFIL0 (0x1 << 16) /**< \brief (PWM_FMR) Fault 0 Filtering */ -#define PWM_FMR_FFIL1 (0x1 << 17) /**< \brief (PWM_FMR) Fault 1 Filtering */ -#define PWM_FMR_FFIL2 (0x1 << 18) /**< \brief (PWM_FMR) Fault 2 Filtering */ -#define PWM_FMR_FFIL3 (0x1 << 19) /**< \brief (PWM_FMR) Fault 3 Filtering */ -/* -------- PWM_FSR : (PWM Offset: 0x60) PWM Fault Status Register -------- */ -#define PWM_FSR_FIV0 (0x1 << 0) /**< \brief (PWM_FSR) Fault Input 0 Value */ -#define PWM_FSR_FIV1 (0x1 << 1) /**< \brief (PWM_FSR) Fault Input 1 Value */ -#define PWM_FSR_FIV2 (0x1 << 2) /**< \brief (PWM_FSR) Fault Input 2 Value */ -#define PWM_FSR_FIV3 (0x1 << 3) /**< \brief (PWM_FSR) Fault Input 3 Value */ -#define PWM_FSR_FS0 (0x1 << 8) /**< \brief (PWM_FSR) Fault 0 Status */ -#define PWM_FSR_FS1 (0x1 << 9) /**< \brief (PWM_FSR) Fault 1 Status */ -#define PWM_FSR_FS2 (0x1 << 10) /**< \brief (PWM_FSR) Fault 2 Status */ -#define PWM_FSR_FS3 (0x1 << 11) /**< \brief (PWM_FSR) Fault 3 Status */ -/* -------- PWM_FCR : (PWM Offset: 0x64) PWM Fault Clear Register -------- */ -#define PWM_FCR_FCLR0 (0x1 << 0) /**< \brief (PWM_FCR) Fault 0 Clear */ -#define PWM_FCR_FCLR1 (0x1 << 1) /**< \brief (PWM_FCR) Fault 1 Clear */ -#define PWM_FCR_FCLR2 (0x1 << 2) /**< \brief (PWM_FCR) Fault 2 Clear */ -#define PWM_FCR_FCLR3 (0x1 << 3) /**< \brief (PWM_FCR) Fault 3 Clear */ -/* -------- PWM_FPV : (PWM Offset: 0x68) PWM Fault Protection Value Register -------- */ -#define PWM_FPV_FPVH0 (0x1 << 0) /**< \brief (PWM_FPV) Fault Protection Value for PWMH output on channel 0 */ -#define PWM_FPV_FPVH1 (0x1 << 1) /**< \brief (PWM_FPV) Fault Protection Value for PWMH output on channel 1 */ -#define PWM_FPV_FPVH2 (0x1 << 2) /**< \brief (PWM_FPV) Fault Protection Value for PWMH output on channel 2 */ -#define PWM_FPV_FPVH3 (0x1 << 3) /**< \brief (PWM_FPV) Fault Protection Value for PWMH output on channel 3 */ -#define PWM_FPV_FPVL0 (0x1 << 16) /**< \brief (PWM_FPV) Fault Protection Value for PWML output on channel 0 */ -#define PWM_FPV_FPVL1 (0x1 << 17) /**< \brief (PWM_FPV) Fault Protection Value for PWML output on channel 1 */ -#define PWM_FPV_FPVL2 (0x1 << 18) /**< \brief (PWM_FPV) Fault Protection Value for PWML output on channel 2 */ -#define PWM_FPV_FPVL3 (0x1 << 19) /**< \brief (PWM_FPV) Fault Protection Value for PWML output on channel 3 */ -/* -------- PWM_FPE : (PWM Offset: 0x6C) PWM Fault Protection Enable Register -------- */ -#define PWM_FPE_FPE0 (0xff << 0) /**< \brief (PWM_FPE) Fault Protection Enable with Fault 0 for channel x */ -#define PWM_FPE_FPE1 (0xff << 8) /**< \brief (PWM_FPE) Fault Protection Enable with Fault 1 for channel x */ -#define PWM_FPE_FPE2 (0xff << 16) /**< \brief (PWM_FPE) Fault Protection Enable with Fault 2 for channel x */ -#define PWM_FPE_FPE3 (0xff << 24) /**< \brief (PWM_FPE) Fault Protection Enable with Fault 3 for channel x */ -/* -------- PWM_ELxMR[2] : (PWM Offset: 0x7C) PWM Event Line 0 Mode Register -------- */ -#define PWM_ELxMR_CSEL0 (0x1 << 0) /**< \brief (PWM_ELxMR[2]) Comparison 0 Selection */ -#define PWM_ELxMR_CSEL1 (0x1 << 1) /**< \brief (PWM_ELxMR[2]) Comparison 1 Selection */ -#define PWM_ELxMR_CSEL2 (0x1 << 2) /**< \brief (PWM_ELxMR[2]) Comparison 2 Selection */ -#define PWM_ELxMR_CSEL3 (0x1 << 3) /**< \brief (PWM_ELxMR[2]) Comparison 3 Selection */ -#define PWM_ELxMR_CSEL4 (0x1 << 4) /**< \brief (PWM_ELxMR[2]) Comparison 4 Selection */ -#define PWM_ELxMR_CSEL5 (0x1 << 5) /**< \brief (PWM_ELxMR[2]) Comparison 5 Selection */ -#define PWM_ELxMR_CSEL6 (0x1 << 6) /**< \brief (PWM_ELxMR[2]) Comparison 6 Selection */ -#define PWM_ELxMR_CSEL7 (0x1 << 7) /**< \brief (PWM_ELxMR[2]) Comparison 7 Selection */ -/* -------- PWM_SMMR : (PWM Offset: 0xB0) PWM Stepper Motor Mode Register -------- */ -#define PWM_SMMR_GCEN0 (0x1 << 0) /**< \brief (PWM_SMMR) Gray Count ENable */ -#define PWM_SMMR_GCEN1 (0x1 << 1) /**< \brief (PWM_SMMR) Gray Count ENable */ -#define PWM_SMMR_DOWN0 (0x1 << 16) /**< \brief (PWM_SMMR) DOWN Count */ -#define PWM_SMMR_DOWN1 (0x1 << 17) /**< \brief (PWM_SMMR) DOWN Count */ -/* -------- PWM_WPCR : (PWM Offset: 0xE4) PWM Write Protect Control Register -------- */ -#define PWM_WPCR_WPCMD (0x3 << 0) /**< \brief (PWM_WPCR) Write Protect Command */ -#define PWM_WPCR_WPRG0 (0x1 << 2) /**< \brief (PWM_WPCR) Write Protect Register Group 0 */ -#define PWM_WPCR_WPRG1 (0x1 << 3) /**< \brief (PWM_WPCR) Write Protect Register Group 1 */ -#define PWM_WPCR_WPRG2 (0x1 << 4) /**< \brief (PWM_WPCR) Write Protect Register Group 2 */ -#define PWM_WPCR_WPRG3 (0x1 << 5) /**< \brief (PWM_WPCR) Write Protect Register Group 3 */ -#define PWM_WPCR_WPRG4 (0x1 << 6) /**< \brief (PWM_WPCR) Write Protect Register Group 4 */ -#define PWM_WPCR_WPRG5 (0x1 << 7) /**< \brief (PWM_WPCR) Write Protect Register Group 5 */ -#define PWM_WPCR_WPKEY (0xffffff << 8) /**< \brief (PWM_WPCR) Write Protect Key */ -/* -------- PWM_WPSR : (PWM Offset: 0xE8) PWM Write Protect Status Register -------- */ -#define PWM_WPSR_WPSWS0 (0x1 << 0) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPSWS1 (0x1 << 1) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPSWS2 (0x1 << 2) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPSWS3 (0x1 << 3) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPSWS4 (0x1 << 4) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPSWS5 (0x1 << 5) /**< \brief (PWM_WPSR) Write Protect SW Status */ -#define PWM_WPSR_WPVS (0x1 << 7) /**< \brief (PWM_WPSR) Write Protect Violation Status */ -#define PWM_WPSR_WPHWS0 (0x1 << 8) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPHWS1 (0x1 << 9) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPHWS2 (0x1 << 10) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPHWS3 (0x1 << 11) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPHWS4 (0x1 << 12) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPHWS5 (0x1 << 13) /**< \brief (PWM_WPSR) Write Protect HW Status */ -#define PWM_WPSR_WPVSRC (0xffff << 16) /**< \brief (PWM_WPSR) Write Protect Violation Source */ -/* -------- PWM_RPR : (PWM Offset: 0x100) Receive Pointer Register -------- */ -#define PWM_RPR_RXPTR (0xffffffff << 0) /**< \brief (PWM_RPR) Receive Pointer Register */ -/* -------- PWM_RCR : (PWM Offset: 0x104) Receive Counter Register -------- */ -#define PWM_RCR_RXCTR (0xffff << 0) /**< \brief (PWM_RCR) Receive Counter Register */ -/* -------- PWM_TPR : (PWM Offset: 0x108) Transmit Pointer Register -------- */ -#define PWM_TPR_TXPTR (0xffffffff << 0) /**< \brief (PWM_TPR) Transmit Counter Register */ -/* -------- PWM_TCR : (PWM Offset: 0x10C) Transmit Counter Register -------- */ -#define PWM_TCR_TXCTR (0xffff << 0) /**< \brief (PWM_TCR) Transmit Counter Register */ -/* -------- PWM_RNPR : (PWM Offset: 0x110) Receive Next Pointer Register -------- */ -#define PWM_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (PWM_RNPR) Receive Next Pointer */ -/* -------- PWM_RNCR : (PWM Offset: 0x114) Receive Next Counter Register -------- */ -#define PWM_RNCR_RXNCTR (0xffff << 0) /**< \brief (PWM_RNCR) Receive Next Counter */ -/* -------- PWM_TNPR : (PWM Offset: 0x118) Transmit Next Pointer Register -------- */ -#define PWM_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (PWM_TNPR) Transmit Next Pointer */ -/* -------- PWM_TNCR : (PWM Offset: 0x11C) Transmit Next Counter Register -------- */ -#define PWM_TNCR_TXNCTR (0xffff << 0) /**< \brief (PWM_TNCR) Transmit Counter Next */ -/* -------- PWM_PTCR : (PWM Offset: 0x120) Transfer Control Register -------- */ -#define PWM_PTCR_RXTEN (0x1 << 0) /**< \brief (PWM_PTCR) Receiver Transfer Enable */ -#define PWM_PTCR_RXTDIS (0x1 << 1) /**< \brief (PWM_PTCR) Receiver Transfer Disable */ -#define PWM_PTCR_TXTEN (0x1 << 8) /**< \brief (PWM_PTCR) Transmitter Transfer Enable */ -#define PWM_PTCR_TXTDIS (0x1 << 9) /**< \brief (PWM_PTCR) Transmitter Transfer Disable */ -/* -------- PWM_PTSR : (PWM Offset: 0x124) Transfer Status Register -------- */ -#define PWM_PTSR_RXTEN (0x1 << 0) /**< \brief (PWM_PTSR) Receiver Transfer Enable */ -#define PWM_PTSR_TXTEN (0x1 << 8) /**< \brief (PWM_PTSR) Transmitter Transfer Enable */ -/* -------- PWM_CMP0V : (PWM Offset: 0x130) PWM Comparison 0 Value Register -------- */ -#define PWM_CMP0V_CV (0xffffff << 0) /**< \brief (PWM_CMP0V) Comparison x Value */ -#define PWM_CMP0V_CVM (0x1 << 24) /**< \brief (PWM_CMP0V) Comparison x Value Mode */ -/* -------- PWM_CMP0VUPD : (PWM Offset: 0x134) PWM Comparison 0 Value Update Register -------- */ -#define PWM_CMP0VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP0VUPD) Comparison x Value Update */ -#define PWM_CMP0VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP0VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP0M : (PWM Offset: 0x138) PWM Comparison 0 Mode Register -------- */ -#define PWM_CMP0M_CEN (0x1 << 0) /**< \brief (PWM_CMP0M) Comparison x Enable */ -#define PWM_CMP0M_CTR (0xf << 4) /**< \brief (PWM_CMP0M) Comparison x Trigger */ -#define PWM_CMP0M_CPR (0xf << 8) /**< \brief (PWM_CMP0M) Comparison x Period */ -#define PWM_CMP0M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP0M) Comparison x Period Counter */ -#define PWM_CMP0M_CUPR (0xf << 16) /**< \brief (PWM_CMP0M) Comparison x Update Period */ -#define PWM_CMP0M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP0M) Comparison x Update Period Counter */ -/* -------- PWM_CMP0MUPD : (PWM Offset: 0x13C) PWM Comparison 0 Mode Update Register -------- */ -#define PWM_CMP0MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP0MUPD) Comparison x Enable Update */ -#define PWM_CMP0MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP0MUPD) Comparison x Trigger Update */ -#define PWM_CMP0MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP0MUPD) Comparison x Period Update */ -#define PWM_CMP0MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP0MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP1V : (PWM Offset: 0x140) PWM Comparison 1 Value Register -------- */ -#define PWM_CMP1V_CV (0xffffff << 0) /**< \brief (PWM_CMP1V) Comparison x Value */ -#define PWM_CMP1V_CVM (0x1 << 24) /**< \brief (PWM_CMP1V) Comparison x Value Mode */ -/* -------- PWM_CMP1VUPD : (PWM Offset: 0x144) PWM Comparison 1 Value Update Register -------- */ -#define PWM_CMP1VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP1VUPD) Comparison x Value Update */ -#define PWM_CMP1VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP1VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP1M : (PWM Offset: 0x148) PWM Comparison 1 Mode Register -------- */ -#define PWM_CMP1M_CEN (0x1 << 0) /**< \brief (PWM_CMP1M) Comparison x Enable */ -#define PWM_CMP1M_CTR (0xf << 4) /**< \brief (PWM_CMP1M) Comparison x Trigger */ -#define PWM_CMP1M_CPR (0xf << 8) /**< \brief (PWM_CMP1M) Comparison x Period */ -#define PWM_CMP1M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP1M) Comparison x Period Counter */ -#define PWM_CMP1M_CUPR (0xf << 16) /**< \brief (PWM_CMP1M) Comparison x Update Period */ -#define PWM_CMP1M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP1M) Comparison x Update Period Counter */ -/* -------- PWM_CMP1MUPD : (PWM Offset: 0x14C) PWM Comparison 1 Mode Update Register -------- */ -#define PWM_CMP1MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP1MUPD) Comparison x Enable Update */ -#define PWM_CMP1MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP1MUPD) Comparison x Trigger Update */ -#define PWM_CMP1MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP1MUPD) Comparison x Period Update */ -#define PWM_CMP1MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP1MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP2V : (PWM Offset: 0x150) PWM Comparison 2 Value Register -------- */ -#define PWM_CMP2V_CV (0xffffff << 0) /**< \brief (PWM_CMP2V) Comparison x Value */ -#define PWM_CMP2V_CVM (0x1 << 24) /**< \brief (PWM_CMP2V) Comparison x Value Mode */ -/* -------- PWM_CMP2VUPD : (PWM Offset: 0x154) PWM Comparison 2 Value Update Register -------- */ -#define PWM_CMP2VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP2VUPD) Comparison x Value Update */ -#define PWM_CMP2VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP2VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP2M : (PWM Offset: 0x158) PWM Comparison 2 Mode Register -------- */ -#define PWM_CMP2M_CEN (0x1 << 0) /**< \brief (PWM_CMP2M) Comparison x Enable */ -#define PWM_CMP2M_CTR (0xf << 4) /**< \brief (PWM_CMP2M) Comparison x Trigger */ -#define PWM_CMP2M_CPR (0xf << 8) /**< \brief (PWM_CMP2M) Comparison x Period */ -#define PWM_CMP2M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP2M) Comparison x Period Counter */ -#define PWM_CMP2M_CUPR (0xf << 16) /**< \brief (PWM_CMP2M) Comparison x Update Period */ -#define PWM_CMP2M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP2M) Comparison x Update Period Counter */ -/* -------- PWM_CMP2MUPD : (PWM Offset: 0x15C) PWM Comparison 2 Mode Update Register -------- */ -#define PWM_CMP2MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP2MUPD) Comparison x Enable Update */ -#define PWM_CMP2MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP2MUPD) Comparison x Trigger Update */ -#define PWM_CMP2MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP2MUPD) Comparison x Period Update */ -#define PWM_CMP2MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP2MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP3V : (PWM Offset: 0x160) PWM Comparison 3 Value Register -------- */ -#define PWM_CMP3V_CV (0xffffff << 0) /**< \brief (PWM_CMP3V) Comparison x Value */ -#define PWM_CMP3V_CVM (0x1 << 24) /**< \brief (PWM_CMP3V) Comparison x Value Mode */ -/* -------- PWM_CMP3VUPD : (PWM Offset: 0x164) PWM Comparison 3 Value Update Register -------- */ -#define PWM_CMP3VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP3VUPD) Comparison x Value Update */ -#define PWM_CMP3VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP3VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP3M : (PWM Offset: 0x168) PWM Comparison 3 Mode Register -------- */ -#define PWM_CMP3M_CEN (0x1 << 0) /**< \brief (PWM_CMP3M) Comparison x Enable */ -#define PWM_CMP3M_CTR (0xf << 4) /**< \brief (PWM_CMP3M) Comparison x Trigger */ -#define PWM_CMP3M_CPR (0xf << 8) /**< \brief (PWM_CMP3M) Comparison x Period */ -#define PWM_CMP3M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP3M) Comparison x Period Counter */ -#define PWM_CMP3M_CUPR (0xf << 16) /**< \brief (PWM_CMP3M) Comparison x Update Period */ -#define PWM_CMP3M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP3M) Comparison x Update Period Counter */ -/* -------- PWM_CMP3MUPD : (PWM Offset: 0x16C) PWM Comparison 3 Mode Update Register -------- */ -#define PWM_CMP3MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP3MUPD) Comparison x Enable Update */ -#define PWM_CMP3MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP3MUPD) Comparison x Trigger Update */ -#define PWM_CMP3MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP3MUPD) Comparison x Period Update */ -#define PWM_CMP3MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP3MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP4V : (PWM Offset: 0x170) PWM Comparison 4 Value Register -------- */ -#define PWM_CMP4V_CV (0xffffff << 0) /**< \brief (PWM_CMP4V) Comparison x Value */ -#define PWM_CMP4V_CVM (0x1 << 24) /**< \brief (PWM_CMP4V) Comparison x Value Mode */ -/* -------- PWM_CMP4VUPD : (PWM Offset: 0x174) PWM Comparison 4 Value Update Register -------- */ -#define PWM_CMP4VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP4VUPD) Comparison x Value Update */ -#define PWM_CMP4VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP4VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP4M : (PWM Offset: 0x178) PWM Comparison 4 Mode Register -------- */ -#define PWM_CMP4M_CEN (0x1 << 0) /**< \brief (PWM_CMP4M) Comparison x Enable */ -#define PWM_CMP4M_CTR (0xf << 4) /**< \brief (PWM_CMP4M) Comparison x Trigger */ -#define PWM_CMP4M_CPR (0xf << 8) /**< \brief (PWM_CMP4M) Comparison x Period */ -#define PWM_CMP4M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP4M) Comparison x Period Counter */ -#define PWM_CMP4M_CUPR (0xf << 16) /**< \brief (PWM_CMP4M) Comparison x Update Period */ -#define PWM_CMP4M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP4M) Comparison x Update Period Counter */ -/* -------- PWM_CMP4MUPD : (PWM Offset: 0x17C) PWM Comparison 4 Mode Update Register -------- */ -#define PWM_CMP4MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP4MUPD) Comparison x Enable Update */ -#define PWM_CMP4MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP4MUPD) Comparison x Trigger Update */ -#define PWM_CMP4MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP4MUPD) Comparison x Period Update */ -#define PWM_CMP4MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP4MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP5V : (PWM Offset: 0x180) PWM Comparison 5 Value Register -------- */ -#define PWM_CMP5V_CV (0xffffff << 0) /**< \brief (PWM_CMP5V) Comparison x Value */ -#define PWM_CMP5V_CVM (0x1 << 24) /**< \brief (PWM_CMP5V) Comparison x Value Mode */ -/* -------- PWM_CMP5VUPD : (PWM Offset: 0x184) PWM Comparison 5 Value Update Register -------- */ -#define PWM_CMP5VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP5VUPD) Comparison x Value Update */ -#define PWM_CMP5VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP5VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP5M : (PWM Offset: 0x188) PWM Comparison 5 Mode Register -------- */ -#define PWM_CMP5M_CEN (0x1 << 0) /**< \brief (PWM_CMP5M) Comparison x Enable */ -#define PWM_CMP5M_CTR (0xf << 4) /**< \brief (PWM_CMP5M) Comparison x Trigger */ -#define PWM_CMP5M_CPR (0xf << 8) /**< \brief (PWM_CMP5M) Comparison x Period */ -#define PWM_CMP5M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP5M) Comparison x Period Counter */ -#define PWM_CMP5M_CUPR (0xf << 16) /**< \brief (PWM_CMP5M) Comparison x Update Period */ -#define PWM_CMP5M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP5M) Comparison x Update Period Counter */ -/* -------- PWM_CMP5MUPD : (PWM Offset: 0x18C) PWM Comparison 5 Mode Update Register -------- */ -#define PWM_CMP5MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP5MUPD) Comparison x Enable Update */ -#define PWM_CMP5MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP5MUPD) Comparison x Trigger Update */ -#define PWM_CMP5MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP5MUPD) Comparison x Period Update */ -#define PWM_CMP5MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP5MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP6V : (PWM Offset: 0x190) PWM Comparison 6 Value Register -------- */ -#define PWM_CMP6V_CV (0xffffff << 0) /**< \brief (PWM_CMP6V) Comparison x Value */ -#define PWM_CMP6V_CVM (0x1 << 24) /**< \brief (PWM_CMP6V) Comparison x Value Mode */ -/* -------- PWM_CMP6VUPD : (PWM Offset: 0x194) PWM Comparison 6 Value Update Register -------- */ -#define PWM_CMP6VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP6VUPD) Comparison x Value Update */ -#define PWM_CMP6VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP6VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP6M : (PWM Offset: 0x198) PWM Comparison 6 Mode Register -------- */ -#define PWM_CMP6M_CEN (0x1 << 0) /**< \brief (PWM_CMP6M) Comparison x Enable */ -#define PWM_CMP6M_CTR (0xf << 4) /**< \brief (PWM_CMP6M) Comparison x Trigger */ -#define PWM_CMP6M_CPR (0xf << 8) /**< \brief (PWM_CMP6M) Comparison x Period */ -#define PWM_CMP6M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP6M) Comparison x Period Counter */ -#define PWM_CMP6M_CUPR (0xf << 16) /**< \brief (PWM_CMP6M) Comparison x Update Period */ -#define PWM_CMP6M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP6M) Comparison x Update Period Counter */ -/* -------- PWM_CMP6MUPD : (PWM Offset: 0x19C) PWM Comparison 6 Mode Update Register -------- */ -#define PWM_CMP6MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP6MUPD) Comparison x Enable Update */ -#define PWM_CMP6MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP6MUPD) Comparison x Trigger Update */ -#define PWM_CMP6MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP6MUPD) Comparison x Period Update */ -#define PWM_CMP6MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP6MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMP7V : (PWM Offset: 0x1A0) PWM Comparison 7 Value Register -------- */ -#define PWM_CMP7V_CV (0xffffff << 0) /**< \brief (PWM_CMP7V) Comparison x Value */ -#define PWM_CMP7V_CVM (0x1 << 24) /**< \brief (PWM_CMP7V) Comparison x Value Mode */ -/* -------- PWM_CMP7VUPD : (PWM Offset: 0x1A4) PWM Comparison 7 Value Update Register -------- */ -#define PWM_CMP7VUPD_CVUPD (0xffffff << 0) /**< \brief (PWM_CMP7VUPD) Comparison x Value Update */ -#define PWM_CMP7VUPD_CVMUPD (0x1 << 24) /**< \brief (PWM_CMP7VUPD) Comparison x Value Mode Update */ -/* -------- PWM_CMP7M : (PWM Offset: 0x1A8) PWM Comparison 7 Mode Register -------- */ -#define PWM_CMP7M_CEN (0x1 << 0) /**< \brief (PWM_CMP7M) Comparison x Enable */ -#define PWM_CMP7M_CTR (0xf << 4) /**< \brief (PWM_CMP7M) Comparison x Trigger */ -#define PWM_CMP7M_CPR (0xf << 8) /**< \brief (PWM_CMP7M) Comparison x Period */ -#define PWM_CMP7M_CPRCNT (0xf << 12) /**< \brief (PWM_CMP7M) Comparison x Period Counter */ -#define PWM_CMP7M_CUPR (0xf << 16) /**< \brief (PWM_CMP7M) Comparison x Update Period */ -#define PWM_CMP7M_CUPRCNT (0xf << 20) /**< \brief (PWM_CMP7M) Comparison x Update Period Counter */ -/* -------- PWM_CMP7MUPD : (PWM Offset: 0x1AC) PWM Comparison 7 Mode Update Register -------- */ -#define PWM_CMP7MUPD_CENUPD (0x1 << 0) /**< \brief (PWM_CMP7MUPD) Comparison x Enable Update */ -#define PWM_CMP7MUPD_CTRUPD (0xf << 4) /**< \brief (PWM_CMP7MUPD) Comparison x Trigger Update */ -#define PWM_CMP7MUPD_CPRUPD (0xf << 8) /**< \brief (PWM_CMP7MUPD) Comparison x Period Update */ -#define PWM_CMP7MUPD_CUPRUPD (0xf << 16) /**< \brief (PWM_CMP7MUPD) Comparison x Update Period Update */ -/* -------- PWM_CMR0 : (PWM Offset: 0x200) PWM Channel Mode Register (ch_num = 0) -------- */ -#define PWM_CMR0_CPRE (0xf << 0) /**< \brief (PWM_CMR0) Channel Pre-scaler */ -#define PWM_CMR0_CALG (0x1 << 8) /**< \brief (PWM_CMR0) Channel Alignment */ -#define PWM_CMR0_CPOL (0x1 << 9) /**< \brief (PWM_CMR0) Channel Polarity */ -#define PWM_CMR0_CES (0x1 << 10) /**< \brief (PWM_CMR0) Counter Event Selection */ -#define PWM_CMR0_DTE (0x1 << 16) /**< \brief (PWM_CMR0) Dead-Time Generator Enable */ -#define PWM_CMR0_DTHI (0x1 << 17) /**< \brief (PWM_CMR0) Dead-Time PWMHx Output Inverted */ -#define PWM_CMR0_DTLI (0x1 << 18) /**< \brief (PWM_CMR0) Dead-Time PWMLx Output Inverted */ -/* -------- PWM_CDTY0 : (PWM Offset: 0x204) PWM Channel Duty Cycle Register (ch_num = 0) -------- */ -#define PWM_CDTY0_CDTY (0xffffff << 0) /**< \brief (PWM_CDTY0) Channel Duty-Cycle */ -/* -------- PWM_CDTYUPD0 : (PWM Offset: 0x208) PWM Channel Duty Cycle Update Register (ch_num = 0) -------- */ -#define PWM_CDTYUPD0_CDTYUPD (0xffffff << 0) /**< \brief (PWM_CDTYUPD0) Channel Duty-Cycle Update */ -/* -------- PWM_CPRD0 : (PWM Offset: 0x20C) PWM Channel Period Register (ch_num = 0) -------- */ -#define PWM_CPRD0_CPRD (0xffffff << 0) /**< \brief (PWM_CPRD0) Channel Period */ -/* -------- PWM_CPRDUPD0 : (PWM Offset: 0x210) PWM Channel Period Update Register (ch_num = 0) -------- */ -#define PWM_CPRDUPD0_CPRDUPD (0xffffff << 0) /**< \brief (PWM_CPRDUPD0) Channel Period Update */ -/* -------- PWM_CCNT0 : (PWM Offset: 0x214) PWM Channel Counter Register (ch_num = 0) -------- */ -#define PWM_CCNT0_CNT (0xffffff << 0) /**< \brief (PWM_CCNT0) Channel Counter Register */ -/* -------- PWM_DT0 : (PWM Offset: 0x218) PWM Channel Dead Time Register (ch_num = 0) -------- */ -#define PWM_DT0_DTH (0xffff << 0) /**< \brief (PWM_DT0) Dead-Time Value for PWMHx Output */ -#define PWM_DT0_DTL (0xffff << 16) /**< \brief (PWM_DT0) Dead-Time Value for PWMLx Output */ -/* -------- PWM_DTUPD0 : (PWM Offset: 0x21C) PWM Channel Dead Time Update Register (ch_num = 0) -------- */ -#define PWM_DTUPD0_DTHUPD (0xffff << 0) /**< \brief (PWM_DTUPD0) Dead-Time Value Update for PWMHx Output */ -#define PWM_DTUPD0_DTLUPD (0xffff << 16) /**< \brief (PWM_DTUPD0) Dead-Time Value Update for PWMLx Output */ -/* -------- PWM_CMR1 : (PWM Offset: 0x220) PWM Channel Mode Register (ch_num = 1) -------- */ -#define PWM_CMR1_CPRE (0xf << 0) /**< \brief (PWM_CMR1) Channel Pre-scaler */ -#define PWM_CMR1_CALG (0x1 << 8) /**< \brief (PWM_CMR1) Channel Alignment */ -#define PWM_CMR1_CPOL (0x1 << 9) /**< \brief (PWM_CMR1) Channel Polarity */ -#define PWM_CMR1_CES (0x1 << 10) /**< \brief (PWM_CMR1) Counter Event Selection */ -#define PWM_CMR1_DTE (0x1 << 16) /**< \brief (PWM_CMR1) Dead-Time Generator Enable */ -#define PWM_CMR1_DTHI (0x1 << 17) /**< \brief (PWM_CMR1) Dead-Time PWMHx Output Inverted */ -#define PWM_CMR1_DTLI (0x1 << 18) /**< \brief (PWM_CMR1) Dead-Time PWMLx Output Inverted */ -/* -------- PWM_CDTY1 : (PWM Offset: 0x224) PWM Channel Duty Cycle Register (ch_num = 1) -------- */ -#define PWM_CDTY1_CDTY (0xffffff << 0) /**< \brief (PWM_CDTY1) Channel Duty-Cycle */ -/* -------- PWM_CDTYUPD1 : (PWM Offset: 0x228) PWM Channel Duty Cycle Update Register (ch_num = 1) -------- */ -#define PWM_CDTYUPD1_CDTYUPD (0xffffff << 0) /**< \brief (PWM_CDTYUPD1) Channel Duty-Cycle Update */ -/* -------- PWM_CPRD1 : (PWM Offset: 0x22C) PWM Channel Period Register (ch_num = 1) -------- */ -#define PWM_CPRD1_CPRD (0xffffff << 0) /**< \brief (PWM_CPRD1) Channel Period */ -/* -------- PWM_CPRDUPD1 : (PWM Offset: 0x230) PWM Channel Period Update Register (ch_num = 1) -------- */ -#define PWM_CPRDUPD1_CPRDUPD (0xffffff << 0) /**< \brief (PWM_CPRDUPD1) Channel Period Update */ -/* -------- PWM_CCNT1 : (PWM Offset: 0x234) PWM Channel Counter Register (ch_num = 1) -------- */ -#define PWM_CCNT1_CNT (0xffffff << 0) /**< \brief (PWM_CCNT1) Channel Counter Register */ -/* -------- PWM_DT1 : (PWM Offset: 0x238) PWM Channel Dead Time Register (ch_num = 1) -------- */ -#define PWM_DT1_DTH (0xffff << 0) /**< \brief (PWM_DT1) Dead-Time Value for PWMHx Output */ -#define PWM_DT1_DTL (0xffff << 16) /**< \brief (PWM_DT1) Dead-Time Value for PWMLx Output */ -/* -------- PWM_DTUPD1 : (PWM Offset: 0x23C) PWM Channel Dead Time Update Register (ch_num = 1) -------- */ -#define PWM_DTUPD1_DTHUPD (0xffff << 0) /**< \brief (PWM_DTUPD1) Dead-Time Value Update for PWMHx Output */ -#define PWM_DTUPD1_DTLUPD (0xffff << 16) /**< \brief (PWM_DTUPD1) Dead-Time Value Update for PWMLx Output */ -/* -------- PWM_CMR2 : (PWM Offset: 0x240) PWM Channel Mode Register (ch_num = 2) -------- */ -#define PWM_CMR2_CPRE (0xf << 0) /**< \brief (PWM_CMR2) Channel Pre-scaler */ -#define PWM_CMR2_CALG (0x1 << 8) /**< \brief (PWM_CMR2) Channel Alignment */ -#define PWM_CMR2_CPOL (0x1 << 9) /**< \brief (PWM_CMR2) Channel Polarity */ -#define PWM_CMR2_CES (0x1 << 10) /**< \brief (PWM_CMR2) Counter Event Selection */ -#define PWM_CMR2_DTE (0x1 << 16) /**< \brief (PWM_CMR2) Dead-Time Generator Enable */ -#define PWM_CMR2_DTHI (0x1 << 17) /**< \brief (PWM_CMR2) Dead-Time PWMHx Output Inverted */ -#define PWM_CMR2_DTLI (0x1 << 18) /**< \brief (PWM_CMR2) Dead-Time PWMLx Output Inverted */ -/* -------- PWM_CDTY2 : (PWM Offset: 0x244) PWM Channel Duty Cycle Register (ch_num = 2) -------- */ -#define PWM_CDTY2_CDTY (0xffffff << 0) /**< \brief (PWM_CDTY2) Channel Duty-Cycle */ -/* -------- PWM_CDTYUPD2 : (PWM Offset: 0x248) PWM Channel Duty Cycle Update Register (ch_num = 2) -------- */ -#define PWM_CDTYUPD2_CDTYUPD (0xffffff << 0) /**< \brief (PWM_CDTYUPD2) Channel Duty-Cycle Update */ -/* -------- PWM_CPRD2 : (PWM Offset: 0x24C) PWM Channel Period Register (ch_num = 2) -------- */ -#define PWM_CPRD2_CPRD (0xffffff << 0) /**< \brief (PWM_CPRD2) Channel Period */ -/* -------- PWM_CPRDUPD2 : (PWM Offset: 0x250) PWM Channel Period Update Register (ch_num = 2) -------- */ -#define PWM_CPRDUPD2_CPRDUPD (0xffffff << 0) /**< \brief (PWM_CPRDUPD2) Channel Period Update */ -/* -------- PWM_CCNT2 : (PWM Offset: 0x254) PWM Channel Counter Register (ch_num = 2) -------- */ -#define PWM_CCNT2_CNT (0xffffff << 0) /**< \brief (PWM_CCNT2) Channel Counter Register */ -/* -------- PWM_DT2 : (PWM Offset: 0x258) PWM Channel Dead Time Register (ch_num = 2) -------- */ -#define PWM_DT2_DTH (0xffff << 0) /**< \brief (PWM_DT2) Dead-Time Value for PWMHx Output */ -#define PWM_DT2_DTL (0xffff << 16) /**< \brief (PWM_DT2) Dead-Time Value for PWMLx Output */ -/* -------- PWM_DTUPD2 : (PWM Offset: 0x25C) PWM Channel Dead Time Update Register (ch_num = 2) -------- */ -#define PWM_DTUPD2_DTHUPD (0xffff << 0) /**< \brief (PWM_DTUPD2) Dead-Time Value Update for PWMHx Output */ -#define PWM_DTUPD2_DTLUPD (0xffff << 16) /**< \brief (PWM_DTUPD2) Dead-Time Value Update for PWMLx Output */ -/* -------- PWM_CMR3 : (PWM Offset: 0x260) PWM Channel Mode Register (ch_num = 3) -------- */ -#define PWM_CMR3_CPRE (0xf << 0) /**< \brief (PWM_CMR3) Channel Pre-scaler */ -#define PWM_CMR3_CALG (0x1 << 8) /**< \brief (PWM_CMR3) Channel Alignment */ -#define PWM_CMR3_CPOL (0x1 << 9) /**< \brief (PWM_CMR3) Channel Polarity */ -#define PWM_CMR3_CES (0x1 << 10) /**< \brief (PWM_CMR3) Counter Event Selection */ -#define PWM_CMR3_DTE (0x1 << 16) /**< \brief (PWM_CMR3) Dead-Time Generator Enable */ -#define PWM_CMR3_DTHI (0x1 << 17) /**< \brief (PWM_CMR3) Dead-Time PWMHx Output Inverted */ -#define PWM_CMR3_DTLI (0x1 << 18) /**< \brief (PWM_CMR3) Dead-Time PWMLx Output Inverted */ -/* -------- PWM_CDTY3 : (PWM Offset: 0x264) PWM Channel Duty Cycle Register (ch_num = 3) -------- */ -#define PWM_CDTY3_CDTY (0xffffff << 0) /**< \brief (PWM_CDTY3) Channel Duty-Cycle */ -/* -------- PWM_CDTYUPD3 : (PWM Offset: 0x268) PWM Channel Duty Cycle Update Register (ch_num = 3) -------- */ -#define PWM_CDTYUPD3_CDTYUPD (0xffffff << 0) /**< \brief (PWM_CDTYUPD3) Channel Duty-Cycle Update */ -/* -------- PWM_CPRD3 : (PWM Offset: 0x26C) PWM Channel Period Register (ch_num = 3) -------- */ -#define PWM_CPRD3_CPRD (0xffffff << 0) /**< \brief (PWM_CPRD3) Channel Period */ -/* -------- PWM_CPRDUPD3 : (PWM Offset: 0x270) PWM Channel Period Update Register (ch_num = 3) -------- */ -#define PWM_CPRDUPD3_CPRDUPD (0xffffff << 0) /**< \brief (PWM_CPRDUPD3) Channel Period Update */ -/* -------- PWM_CCNT3 : (PWM Offset: 0x274) PWM Channel Counter Register (ch_num = 3) -------- */ -#define PWM_CCNT3_CNT (0xffffff << 0) /**< \brief (PWM_CCNT3) Channel Counter Register */ -/* -------- PWM_DT3 : (PWM Offset: 0x278) PWM Channel Dead Time Register (ch_num = 3) -------- */ -#define PWM_DT3_DTH (0xffff << 0) /**< \brief (PWM_DT3) Dead-Time Value for PWMHx Output */ -#define PWM_DT3_DTL (0xffff << 16) /**< \brief (PWM_DT3) Dead-Time Value for PWMLx Output */ -/* -------- PWM_DTUPD3 : (PWM Offset: 0x27C) PWM Channel Dead Time Update Register (ch_num = 3) -------- */ -#define PWM_DTUPD3_DTHUPD (0xffff << 0) /**< \brief (PWM_DTUPD3) Dead-Time Value Update for PWMHx Output */ -#define PWM_DTUPD3_DTLUPD (0xffff << 16) /**< \brief (PWM_DTUPD3) Dead-Time Value Update for PWMLx Output */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Reset Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_RSTC Reset Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Rstc hardware registers */ -typedef struct { - WoReg RSTC_CR; /**< \brief (Rstc Offset: 0x00) Control Register */ - RoReg RSTC_SR; /**< \brief (Rstc Offset: 0x04) Status Register */ - RwReg RSTC_MR; /**< \brief (Rstc Offset: 0x08) Mode Register */ -} Rstc; -#endif /* __ASSEMBLY__ */ -/* -------- RSTC_CR : (RSTC Offset: 0x00) Control Register -------- */ -#define RSTC_CR_PROCRST (0x1 << 0) /**< \brief (RSTC_CR) Processor Reset */ -#define RSTC_CR_PERRST (0x1 << 2) /**< \brief (RSTC_CR) Peripheral Reset */ -#define RSTC_CR_EXTRST (0x1 << 3) /**< \brief (RSTC_CR) External Reset */ -#define RSTC_CR_KEY (0xff << 24) /**< \brief (RSTC_CR) Password */ -/* -------- RSTC_SR : (RSTC Offset: 0x04) Status Register -------- */ -#define RSTC_SR_URSTS (0x1 << 0) /**< \brief (RSTC_SR) User Reset Status */ -#define RSTC_SR_RSTTYP (0x7 << 8) /**< \brief (RSTC_SR) Reset Type */ -#define RSTC_SR_NRSTL (0x1 << 16) /**< \brief (RSTC_SR) NRST Pin Level */ -#define RSTC_SR_SRCMP (0x1 << 17) /**< \brief (RSTC_SR) Software Reset Command in Progress */ -/* -------- RSTC_MR : (RSTC Offset: 0x08) Mode Register -------- */ -#define RSTC_MR_URSTEN (0x1 << 0) /**< \brief (RSTC_MR) User Reset Enable */ -#define RSTC_MR_URSTIEN (0x1 << 4) /**< \brief (RSTC_MR) User Reset Interrupt Enable */ -#define RSTC_MR_ERSTL (0xf << 8) /**< \brief (RSTC_MR) External Reset Length */ -#define RSTC_MR_KEY (0xff << 24) /**< \brief (RSTC_MR) Password */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Real-time Clock */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_RTC Real-time Clock */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Rtc hardware registers */ -typedef struct { - RwReg RTC_CR; /**< \brief (Rtc Offset: 0x00) Control Register */ - RwReg RTC_MR; /**< \brief (Rtc Offset: 0x04) Mode Register */ - RwReg RTC_TIMR; /**< \brief (Rtc Offset: 0x08) Time Register */ - RwReg RTC_CALR; /**< \brief (Rtc Offset: 0x0C) Calendar Register */ - RwReg RTC_TIMALR; /**< \brief (Rtc Offset: 0x10) Time Alarm Register */ - RwReg RTC_CALALR; /**< \brief (Rtc Offset: 0x14) Calendar Alarm Register */ - RoReg RTC_SR; /**< \brief (Rtc Offset: 0x18) Status Register */ - WoReg RTC_SCCR; /**< \brief (Rtc Offset: 0x1C) Status Clear Command Register */ - WoReg RTC_IER; /**< \brief (Rtc Offset: 0x20) Interrupt Enable Register */ - WoReg RTC_IDR; /**< \brief (Rtc Offset: 0x24) Interrupt Disable Register */ - RoReg RTC_IMR; /**< \brief (Rtc Offset: 0x28) Interrupt Mask Register */ - RoReg RTC_VER; /**< \brief (Rtc Offset: 0x2C) Valid Entry Register */ -} Rtc; -#endif /* __ASSEMBLY__ */ -/* -------- RTC_CR : (RTC Offset: 0x00) Control Register -------- */ -#define RTC_CR_UPDTIM (0x1 << 0) /**< \brief (RTC_CR) Update Request Time Register */ -#define RTC_CR_UPDCAL (0x1 << 1) /**< \brief (RTC_CR) Update Request Calendar Register */ -#define RTC_CR_TIMEVSEL (0x3 << 8) /**< \brief (RTC_CR) Time Event Selection */ -#define RTC_CR_TIMEVSEL_MINUTE (0x0 << 8) /**< \brief (RTC_CR) Minute change. */ -#define RTC_CR_TIMEVSEL_HOUR (0x1 << 8) /**< \brief (RTC_CR) Hour change. */ -#define RTC_CR_TIMEVSEL_DAY24 (0x2 << 8) /**< \brief (RTC_CR) Every day at midnight. */ -#define RTC_CR_TIMEVSEL_DAY12 (0x3 << 8) /**< \brief (RTC_CR) Every day at noon. */ -#define RTC_CR_CALEVSEL (0x3 << 16) /**< \brief (RTC_CR) Calendar Event Selection */ -#define RTC_CR_CALEVSEL_WEEK (0x0 << 16) /**< \brief (RTC_CR) Week change (every Monday at time 00:00:00). */ -#define RTC_CR_CALEVSEL_MONTH (0x1 << 16) /**< \brief (RTC_CR) Month change (every 01 of each month at time 00:00:00). */ -/* -------- RTC_MR : (RTC Offset: 0x04) Mode Register -------- */ -#define RTC_MR_HRMOD (0x1 << 0) /**< \brief (RTC_MR) 12-/24-hour Mode */ -/* -------- RTC_TIMR : (RTC Offset: 0x08) Time Register -------- */ -#define RTC_TIMR_SEC (0x7f << 0) /**< \brief (RTC_TIMR) Current Second */ -#define RTC_TIMR_MIN (0x7f << 8) /**< \brief (RTC_TIMR) Current Minute */ -#define RTC_TIMR_HOUR (0x3f << 16) /**< \brief (RTC_TIMR) Current Hour */ -#define RTC_TIMR_AMPM (0x1 << 22) /**< \brief (RTC_TIMR) Ante Meridiem Post Meridiem Indicator */ -/* -------- RTC_CALR : (RTC Offset: 0x0C) Calendar Register -------- */ -#define RTC_CALR_CENT (0x7f << 0) /**< \brief (RTC_CALR) Current Century */ -#define RTC_CALR_YEAR (0xff << 8) /**< \brief (RTC_CALR) Current Year */ -#define RTC_CALR_MONTH (0x1f << 16) /**< \brief (RTC_CALR) Current Month */ -#define RTC_CALR_DAY (0x7 << 21) /**< \brief (RTC_CALR) Current Day in Current Week */ -#define RTC_CALR_DATE (0x3f << 24) /**< \brief (RTC_CALR) Current Day in Current Month */ -/* -------- RTC_TIMALR : (RTC Offset: 0x10) Time Alarm Register -------- */ -#define RTC_TIMALR_SEC (0x7f << 0) /**< \brief (RTC_TIMALR) Second Alarm */ -#define RTC_TIMALR_SECEN (0x1 << 7) /**< \brief (RTC_TIMALR) Second Alarm Enable */ -#define RTC_TIMALR_MIN (0x7f << 8) /**< \brief (RTC_TIMALR) Minute Alarm */ -#define RTC_TIMALR_MINEN (0x1 << 15) /**< \brief (RTC_TIMALR) Minute Alarm Enable */ -#define RTC_TIMALR_HOUR (0x3f << 16) /**< \brief (RTC_TIMALR) Hour Alarm */ -#define RTC_TIMALR_AMPM (0x1 << 22) /**< \brief (RTC_TIMALR) AM/PM Indicator */ -#define RTC_TIMALR_HOUREN (0x1 << 23) /**< \brief (RTC_TIMALR) Hour Alarm Enable */ -/* -------- RTC_CALALR : (RTC Offset: 0x14) Calendar Alarm Register -------- */ -#define RTC_CALALR_MONTH (0x1f << 16) /**< \brief (RTC_CALALR) Month Alarm */ -#define RTC_CALALR_MTHEN (0x1 << 23) /**< \brief (RTC_CALALR) Month Alarm Enable */ -#define RTC_CALALR_DATE (0x3f << 24) /**< \brief (RTC_CALALR) Date Alarm */ -#define RTC_CALALR_DATEEN (0x1 << 31) /**< \brief (RTC_CALALR) Date Alarm Enable */ -/* -------- RTC_SR : (RTC Offset: 0x18) Status Register -------- */ -#define RTC_SR_ACKUPD (0x1 << 0) /**< \brief (RTC_SR) Acknowledge for Update */ -#define RTC_SR_ALARM (0x1 << 1) /**< \brief (RTC_SR) Alarm Flag */ -#define RTC_SR_SEC (0x1 << 2) /**< \brief (RTC_SR) Second Event */ -#define RTC_SR_TIMEV (0x1 << 3) /**< \brief (RTC_SR) Time Event */ -#define RTC_SR_CALEV (0x1 << 4) /**< \brief (RTC_SR) Calendar Event */ -/* -------- RTC_SCCR : (RTC Offset: 0x1C) Status Clear Command Register -------- */ -#define RTC_SCCR_ACKCLR (0x1 << 0) /**< \brief (RTC_SCCR) Acknowledge Clear */ -#define RTC_SCCR_ALRCLR (0x1 << 1) /**< \brief (RTC_SCCR) Alarm Clear */ -#define RTC_SCCR_SECCLR (0x1 << 2) /**< \brief (RTC_SCCR) Second Clear */ -#define RTC_SCCR_TIMCLR (0x1 << 3) /**< \brief (RTC_SCCR) Time Clear */ -#define RTC_SCCR_CALCLR (0x1 << 4) /**< \brief (RTC_SCCR) Calendar Clear */ -/* -------- RTC_IER : (RTC Offset: 0x20) Interrupt Enable Register -------- */ -#define RTC_IER_ACKEN (0x1 << 0) /**< \brief (RTC_IER) Acknowledge Update Interrupt Enable */ -#define RTC_IER_ALREN (0x1 << 1) /**< \brief (RTC_IER) Alarm Interrupt Enable */ -#define RTC_IER_SECEN (0x1 << 2) /**< \brief (RTC_IER) Second Event Interrupt Enable */ -#define RTC_IER_TIMEN (0x1 << 3) /**< \brief (RTC_IER) Time Event Interrupt Enable */ -#define RTC_IER_CALEN (0x1 << 4) /**< \brief (RTC_IER) Calendar Event Interrupt Enable */ -/* -------- RTC_IDR : (RTC Offset: 0x24) Interrupt Disable Register -------- */ -#define RTC_IDR_ACKDIS (0x1 << 0) /**< \brief (RTC_IDR) Acknowledge Update Interrupt Disable */ -#define RTC_IDR_ALRDIS (0x1 << 1) /**< \brief (RTC_IDR) Alarm Interrupt Disable */ -#define RTC_IDR_SECDIS (0x1 << 2) /**< \brief (RTC_IDR) Second Event Interrupt Disable */ -#define RTC_IDR_TIMDIS (0x1 << 3) /**< \brief (RTC_IDR) Time Event Interrupt Disable */ -#define RTC_IDR_CALDIS (0x1 << 4) /**< \brief (RTC_IDR) Calendar Event Interrupt Disable */ -/* -------- RTC_IMR : (RTC Offset: 0x28) Interrupt Mask Register -------- */ -#define RTC_IMR_ACK (0x1 << 0) /**< \brief (RTC_IMR) Acknowledge Update Interrupt Mask */ -#define RTC_IMR_ALR (0x1 << 1) /**< \brief (RTC_IMR) Alarm Interrupt Mask */ -#define RTC_IMR_SEC (0x1 << 2) /**< \brief (RTC_IMR) Second Event Interrupt Mask */ -#define RTC_IMR_TIM (0x1 << 3) /**< \brief (RTC_IMR) Time Event Interrupt Mask */ -#define RTC_IMR_CAL (0x1 << 4) /**< \brief (RTC_IMR) Calendar Event Interrupt Mask */ -/* -------- RTC_VER : (RTC Offset: 0x2C) Valid Entry Register -------- */ -#define RTC_VER_NVTIM (0x1 << 0) /**< \brief (RTC_VER) Non-valid Time */ -#define RTC_VER_NVCAL (0x1 << 1) /**< \brief (RTC_VER) Non-valid Calendar */ -#define RTC_VER_NVTIMALR (0x1 << 2) /**< \brief (RTC_VER) Non-valid Time Alarm */ -#define RTC_VER_NVCALALR (0x1 << 3) /**< \brief (RTC_VER) Non-valid Calendar Alarm */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Real-time Timer */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_RTT Real-time Timer */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Rtt hardware registers */ -typedef struct { - RwReg RTT_MR; /**< \brief (Rtt Offset: 0x00) Mode Register */ - RwReg RTT_AR; /**< \brief (Rtt Offset: 0x04) Alarm Register */ - RoReg RTT_VR; /**< \brief (Rtt Offset: 0x08) Value Register */ - RoReg RTT_SR; /**< \brief (Rtt Offset: 0x0C) Status Register */ -} Rtt; -#endif /* __ASSEMBLY__ */ -/* -------- RTT_MR : (RTT Offset: 0x00) Mode Register -------- */ -#define RTT_MR_RTPRES (0xffff << 0) /**< \brief (RTT_MR) Real-time Timer Prescaler Value */ -#define RTT_MR_ALMIEN (0x1 << 16) /**< \brief (RTT_MR) Alarm Interrupt Enable */ -#define RTT_MR_RTTINCIEN (0x1 << 17) /**< \brief (RTT_MR) Real-time Timer Increment Interrupt Enable */ -#define RTT_MR_RTTRST (0x1 << 18) /**< \brief (RTT_MR) Real-time Timer Restart */ -/* -------- RTT_AR : (RTT Offset: 0x04) Alarm Register -------- */ -#define RTT_AR_ALMV (0xffffffff << 0) /**< \brief (RTT_AR) Alarm Value */ -/* -------- RTT_VR : (RTT Offset: 0x08) Value Register -------- */ -#define RTT_VR_CRTV (0xffffffff << 0) /**< \brief (RTT_VR) Current Real-time Value */ -/* -------- RTT_SR : (RTT Offset: 0x0C) Status Register -------- */ -#define RTT_SR_ALMS (0x1 << 0) /**< \brief (RTT_SR) Real-time Alarm Status */ -#define RTT_SR_RTTINC (0x1 << 1) /**< \brief (RTT_SR) Real-time Timer Increment */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Static Memory Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_SMC Static Memory Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief SmcCs_number hardware registers */ -typedef struct { - RwReg SMC_SETUP; /**< \brief (SmcCs_number Offset: 0x0) SMC Setup Register */ - RwReg SMC_PULSE; /**< \brief (SmcCs_number Offset: 0x4) SMC Pulse Register */ - RwReg SMC_CYCLE; /**< \brief (SmcCs_number Offset: 0x8) SMC Cycle Register */ - RwReg SMC_MODE; /**< \brief (SmcCs_number Offset: 0xC) SMC Mode Register */ -} SmcCs_number; -/** \brief Smc hardware registers */ -typedef struct { - SmcCs_number SMC_CS_NUMBER[5]; /**< \brief (Smc Offset: 0x0) CS_number = 0 .. 4 */ - RwReg Reserved1[12]; - RwReg SMC_OCMS; /**< \brief (Smc Offset: 0x80) SMC OCMS MODE Register */ - WoReg SMC_KEY1; /**< \brief (Smc Offset: 0x84) SMC OCMS KEY1 Register */ - WoReg SMC_KEY2; /**< \brief (Smc Offset: 0x88) SMC OCMS KEY2 Register */ - RwReg Reserved2[22]; - RwReg SMC_WPMR; /**< \brief (Smc Offset: 0xE4) SMC Write Protect Mode Register */ - RoReg SMC_WPSR; /**< \brief (Smc Offset: 0xE8) SMC Write Protect Status Register */ -} Smc; -#endif /* __ASSEMBLY__ */ -/* -------- SMC_SETUP0 : (SMC Offset: 0x0) SMC Setup Register (CS_number = 0) -------- */ -#define SMC_SETUP0_NWE_SETUP (0x3f << 0) /**< \brief (SMC_SETUP0) NWE Setup Length */ -#define SMC_SETUP0_NCS_WR_SETUP (0x3f << 8) /**< \brief (SMC_SETUP0) NCS Setup Length in WRITE Access */ -#define SMC_SETUP0_NRD_SETUP (0x3f << 16) /**< \brief (SMC_SETUP0) NRD Setup Length */ -#define SMC_SETUP0_NCS_RD_SETUP (0x3f << 24) /**< \brief (SMC_SETUP0) NCS Setup Length in READ Access */ -/* -------- SMC_PULSE0 : (SMC Offset: 0x4) SMC Pulse Register (CS_number = 0) -------- */ -#define SMC_PULSE0_NWE_PULSE (0x7f << 0) /**< \brief (SMC_PULSE0) NWE Pulse Length */ -#define SMC_PULSE0_NCS_WR_PULSE (0x7f << 8) /**< \brief (SMC_PULSE0) NCS Pulse Length in WRITE Access */ -#define SMC_PULSE0_NRD_PULSE (0x7f << 16) /**< \brief (SMC_PULSE0) NRD Pulse Length */ -#define SMC_PULSE0_NCS_RD_PULSE (0x7f << 24) /**< \brief (SMC_PULSE0) NCS Pulse Length in READ Access */ -/* -------- SMC_CYCLE0 : (SMC Offset: 0x8) SMC Cycle Register (CS_number = 0) -------- */ -#define SMC_CYCLE0_NWE_CYCLE (0x1ff << 0) /**< \brief (SMC_CYCLE0) Total Write Cycle Length */ -#define SMC_CYCLE0_NRD_CYCLE (0x1ff << 16) /**< \brief (SMC_CYCLE0) Total Read Cycle Length */ -/* -------- SMC_MODE0 : (SMC Offset: 0xC) SMC Mode Register (CS_number = 0) -------- */ -#define SMC_MODE0_READ_MODE (0x1 << 0) /**< \brief (SMC_MODE0) */ -#define SMC_MODE0_WRITE_MODE (0x1 << 1) /**< \brief (SMC_MODE0) */ -#define SMC_MODE0_EXNW_MODE (0x3 << 4) /**< \brief (SMC_MODE0) NWAIT Mode */ -#define SMC_MODE0_DBW (0x3 << 12) /**< \brief (SMC_MODE0) Data Bus Width */ -#define SMC_MODE0_TDF_CYCLES (0xf << 16) /**< \brief (SMC_MODE0) Data Float Time */ -#define SMC_MODE0_TDF_MODE (0x1 << 20) /**< \brief (SMC_MODE0) TDF Optimization */ -#define SMC_MODE0_PMEN (0x1 << 24) /**< \brief (SMC_MODE0) Page Mode Enabled */ -#define SMC_MODE0_PS (0x3 << 28) /**< \brief (SMC_MODE0) Page Size */ -/* -------- SMC_SETUP1 : (SMC Offset: 0x10) SMC Setup Register (CS_number = 1) -------- */ -#define SMC_SETUP1_NWE_SETUP (0x3f << 0) /**< \brief (SMC_SETUP1) NWE Setup Length */ -#define SMC_SETUP1_NCS_WR_SETUP (0x3f << 8) /**< \brief (SMC_SETUP1) NCS Setup Length in WRITE Access */ -#define SMC_SETUP1_NRD_SETUP (0x3f << 16) /**< \brief (SMC_SETUP1) NRD Setup Length */ -#define SMC_SETUP1_NCS_RD_SETUP (0x3f << 24) /**< \brief (SMC_SETUP1) NCS Setup Length in READ Access */ -/* -------- SMC_PULSE1 : (SMC Offset: 0x14) SMC Pulse Register (CS_number = 1) -------- */ -#define SMC_PULSE1_NWE_PULSE (0x7f << 0) /**< \brief (SMC_PULSE1) NWE Pulse Length */ -#define SMC_PULSE1_NCS_WR_PULSE (0x7f << 8) /**< \brief (SMC_PULSE1) NCS Pulse Length in WRITE Access */ -#define SMC_PULSE1_NRD_PULSE (0x7f << 16) /**< \brief (SMC_PULSE1) NRD Pulse Length */ -#define SMC_PULSE1_NCS_RD_PULSE (0x7f << 24) /**< \brief (SMC_PULSE1) NCS Pulse Length in READ Access */ -/* -------- SMC_CYCLE1 : (SMC Offset: 0x18) SMC Cycle Register (CS_number = 1) -------- */ -#define SMC_CYCLE1_NWE_CYCLE (0x1ff << 0) /**< \brief (SMC_CYCLE1) Total Write Cycle Length */ -#define SMC_CYCLE1_NRD_CYCLE (0x1ff << 16) /**< \brief (SMC_CYCLE1) Total Read Cycle Length */ -/* -------- SMC_MODE1 : (SMC Offset: 0x1C) SMC Mode Register (CS_number = 1) -------- */ -#define SMC_MODE1_READ_MODE (0x1 << 0) /**< \brief (SMC_MODE1) */ -#define SMC_MODE1_WRITE_MODE (0x1 << 1) /**< \brief (SMC_MODE1) */ -#define SMC_MODE1_EXNW_MODE (0x3 << 4) /**< \brief (SMC_MODE1) NWAIT Mode */ -#define SMC_MODE1_DBW (0x3 << 12) /**< \brief (SMC_MODE1) Data Bus Width */ -#define SMC_MODE1_TDF_CYCLES (0xf << 16) /**< \brief (SMC_MODE1) Data Float Time */ -#define SMC_MODE1_TDF_MODE (0x1 << 20) /**< \brief (SMC_MODE1) TDF Optimization */ -#define SMC_MODE1_PMEN (0x1 << 24) /**< \brief (SMC_MODE1) Page Mode Enabled */ -#define SMC_MODE1_PS (0x3 << 28) /**< \brief (SMC_MODE1) Page Size */ -/* -------- SMC_SETUP2 : (SMC Offset: 0x20) SMC Setup Register (CS_number = 2) -------- */ -#define SMC_SETUP2_NWE_SETUP (0x3f << 0) /**< \brief (SMC_SETUP2) NWE Setup Length */ -#define SMC_SETUP2_NCS_WR_SETUP (0x3f << 8) /**< \brief (SMC_SETUP2) NCS Setup Length in WRITE Access */ -#define SMC_SETUP2_NRD_SETUP (0x3f << 16) /**< \brief (SMC_SETUP2) NRD Setup Length */ -#define SMC_SETUP2_NCS_RD_SETUP (0x3f << 24) /**< \brief (SMC_SETUP2) NCS Setup Length in READ Access */ -/* -------- SMC_PULSE2 : (SMC Offset: 0x24) SMC Pulse Register (CS_number = 2) -------- */ -#define SMC_PULSE2_NWE_PULSE (0x7f << 0) /**< \brief (SMC_PULSE2) NWE Pulse Length */ -#define SMC_PULSE2_NCS_WR_PULSE (0x7f << 8) /**< \brief (SMC_PULSE2) NCS Pulse Length in WRITE Access */ -#define SMC_PULSE2_NRD_PULSE (0x7f << 16) /**< \brief (SMC_PULSE2) NRD Pulse Length */ -#define SMC_PULSE2_NCS_RD_PULSE (0x7f << 24) /**< \brief (SMC_PULSE2) NCS Pulse Length in READ Access */ -/* -------- SMC_CYCLE2 : (SMC Offset: 0x28) SMC Cycle Register (CS_number = 2) -------- */ -#define SMC_CYCLE2_NWE_CYCLE (0x1ff << 0) /**< \brief (SMC_CYCLE2) Total Write Cycle Length */ -#define SMC_CYCLE2_NRD_CYCLE (0x1ff << 16) /**< \brief (SMC_CYCLE2) Total Read Cycle Length */ -/* -------- SMC_MODE2 : (SMC Offset: 0x2C) SMC Mode Register (CS_number = 2) -------- */ -#define SMC_MODE2_READ_MODE (0x1 << 0) /**< \brief (SMC_MODE2) */ -#define SMC_MODE2_WRITE_MODE (0x1 << 1) /**< \brief (SMC_MODE2) */ -#define SMC_MODE2_EXNW_MODE (0x3 << 4) /**< \brief (SMC_MODE2) NWAIT Mode */ -#define SMC_MODE2_DBW (0x3 << 12) /**< \brief (SMC_MODE2) Data Bus Width */ -#define SMC_MODE2_TDF_CYCLES (0xf << 16) /**< \brief (SMC_MODE2) Data Float Time */ -#define SMC_MODE2_TDF_MODE (0x1 << 20) /**< \brief (SMC_MODE2) TDF Optimization */ -#define SMC_MODE2_PMEN (0x1 << 24) /**< \brief (SMC_MODE2) Page Mode Enabled */ -#define SMC_MODE2_PS (0x3 << 28) /**< \brief (SMC_MODE2) Page Size */ -/* -------- SMC_SETUP3 : (SMC Offset: 0x30) SMC Setup Register (CS_number = 3) -------- */ -#define SMC_SETUP3_NWE_SETUP (0x3f << 0) /**< \brief (SMC_SETUP3) NWE Setup Length */ -#define SMC_SETUP3_NCS_WR_SETUP (0x3f << 8) /**< \brief (SMC_SETUP3) NCS Setup Length in WRITE Access */ -#define SMC_SETUP3_NRD_SETUP (0x3f << 16) /**< \brief (SMC_SETUP3) NRD Setup Length */ -#define SMC_SETUP3_NCS_RD_SETUP (0x3f << 24) /**< \brief (SMC_SETUP3) NCS Setup Length in READ Access */ -/* -------- SMC_PULSE3 : (SMC Offset: 0x34) SMC Pulse Register (CS_number = 3) -------- */ -#define SMC_PULSE3_NWE_PULSE (0x7f << 0) /**< \brief (SMC_PULSE3) NWE Pulse Length */ -#define SMC_PULSE3_NCS_WR_PULSE (0x7f << 8) /**< \brief (SMC_PULSE3) NCS Pulse Length in WRITE Access */ -#define SMC_PULSE3_NRD_PULSE (0x7f << 16) /**< \brief (SMC_PULSE3) NRD Pulse Length */ -#define SMC_PULSE3_NCS_RD_PULSE (0x7f << 24) /**< \brief (SMC_PULSE3) NCS Pulse Length in READ Access */ -/* -------- SMC_CYCLE3 : (SMC Offset: 0x38) SMC Cycle Register (CS_number = 3) -------- */ -#define SMC_CYCLE3_NWE_CYCLE (0x1ff << 0) /**< \brief (SMC_CYCLE3) Total Write Cycle Length */ -#define SMC_CYCLE3_NRD_CYCLE (0x1ff << 16) /**< \brief (SMC_CYCLE3) Total Read Cycle Length */ -/* -------- SMC_MODE3 : (SMC Offset: 0x3C) SMC Mode Register (CS_number = 3) -------- */ -#define SMC_MODE3_READ_MODE (0x1 << 0) /**< \brief (SMC_MODE3) */ -#define SMC_MODE3_WRITE_MODE (0x1 << 1) /**< \brief (SMC_MODE3) */ -#define SMC_MODE3_EXNW_MODE (0x3 << 4) /**< \brief (SMC_MODE3) NWAIT Mode */ -#define SMC_MODE3_DBW (0x3 << 12) /**< \brief (SMC_MODE3) Data Bus Width */ -#define SMC_MODE3_TDF_CYCLES (0xf << 16) /**< \brief (SMC_MODE3) Data Float Time */ -#define SMC_MODE3_TDF_MODE (0x1 << 20) /**< \brief (SMC_MODE3) TDF Optimization */ -#define SMC_MODE3_PMEN (0x1 << 24) /**< \brief (SMC_MODE3) Page Mode Enabled */ -#define SMC_MODE3_PS (0x3 << 28) /**< \brief (SMC_MODE3) Page Size */ -/* -------- SMC_SETUP4 : (SMC Offset: 0x40) SMC Setup Register (CS_number = 4) -------- */ -#define SMC_SETUP4_NWE_SETUP (0x3f << 0) /**< \brief (SMC_SETUP4) NWE Setup Length */ -#define SMC_SETUP4_NCS_WR_SETUP (0x3f << 8) /**< \brief (SMC_SETUP4) NCS Setup Length in WRITE Access */ -#define SMC_SETUP4_NRD_SETUP (0x3f << 16) /**< \brief (SMC_SETUP4) NRD Setup Length */ -#define SMC_SETUP4_NCS_RD_SETUP (0x3f << 24) /**< \brief (SMC_SETUP4) NCS Setup Length in READ Access */ -/* -------- SMC_PULSE4 : (SMC Offset: 0x44) SMC Pulse Register (CS_number = 4) -------- */ -#define SMC_PULSE4_NWE_PULSE (0x7f << 0) /**< \brief (SMC_PULSE4) NWE Pulse Length */ -#define SMC_PULSE4_NCS_WR_PULSE (0x7f << 8) /**< \brief (SMC_PULSE4) NCS Pulse Length in WRITE Access */ -#define SMC_PULSE4_NRD_PULSE (0x7f << 16) /**< \brief (SMC_PULSE4) NRD Pulse Length */ -#define SMC_PULSE4_NCS_RD_PULSE (0x7f << 24) /**< \brief (SMC_PULSE4) NCS Pulse Length in READ Access */ -/* -------- SMC_CYCLE4 : (SMC Offset: 0x48) SMC Cycle Register (CS_number = 4) -------- */ -#define SMC_CYCLE4_NWE_CYCLE (0x1ff << 0) /**< \brief (SMC_CYCLE4) Total Write Cycle Length */ -#define SMC_CYCLE4_NRD_CYCLE (0x1ff << 16) /**< \brief (SMC_CYCLE4) Total Read Cycle Length */ -/* -------- SMC_MODE4 : (SMC Offset: 0x4C) SMC Mode Register (CS_number = 4) -------- */ -#define SMC_MODE4_READ_MODE (0x1 << 0) /**< \brief (SMC_MODE4) */ -#define SMC_MODE4_WRITE_MODE (0x1 << 1) /**< \brief (SMC_MODE4) */ -#define SMC_MODE4_EXNW_MODE (0x3 << 4) /**< \brief (SMC_MODE4) NWAIT Mode */ -#define SMC_MODE4_DBW (0x3 << 12) /**< \brief (SMC_MODE4) Data Bus Width */ -#define SMC_MODE4_TDF_CYCLES (0xf << 16) /**< \brief (SMC_MODE4) Data Float Time */ -#define SMC_MODE4_TDF_MODE (0x1 << 20) /**< \brief (SMC_MODE4) TDF Optimization */ -#define SMC_MODE4_PMEN (0x1 << 24) /**< \brief (SMC_MODE4) Page Mode Enabled */ -#define SMC_MODE4_PS (0x3 << 28) /**< \brief (SMC_MODE4) Page Size */ -/* -------- SMC_OCMS : (SMC Offset: 0x80) SMC OCMS MODE Register -------- */ -#define SMC_OCMS_SMSE (0x1 << 0) /**< \brief (SMC_OCMS) Static Memory Controller Scrambling Enable */ -#define SMC_OCMS_CS0SE (0x1 << 16) /**< \brief (SMC_OCMS) Chip Select (x = 0 to 3) Scrambling Enable */ -#define SMC_OCMS_CS1SE (0x1 << 17) /**< \brief (SMC_OCMS) Chip Select (x = 0 to 3) Scrambling Enable */ -#define SMC_OCMS_CS2SE (0x1 << 18) /**< \brief (SMC_OCMS) Chip Select (x = 0 to 3) Scrambling Enable */ -#define SMC_OCMS_CS3SE (0x1 << 19) /**< \brief (SMC_OCMS) Chip Select (x = 0 to 3) Scrambling Enable */ -/* -------- SMC_KEY1 : (SMC Offset: 0x84) SMC OCMS KEY1 Register -------- */ -#define SMC_KEY1_KEY1 (0xffffffff << 0) /**< \brief (SMC_KEY1) Off Chip Memory Scrambling (OCMS) Key Part 1 */ -/* -------- SMC_KEY2 : (SMC Offset: 0x88) SMC OCMS KEY2 Register -------- */ -#define SMC_KEY2_KEY2 (0xffffffff << 0) /**< \brief (SMC_KEY2) Off Chip Memory Scrambling (OCMS) Key Part 2 */ -/* -------- SMC_WPMR : (SMC Offset: 0xE4) SMC Write Protect Mode Register -------- */ -#define SMC_WPMR_WPEN (0x1 << 0) /**< \brief (SMC_WPMR) Write Protect Enable */ -#define SMC_WPMR_WPKEY (0xffffff << 8) /**< \brief (SMC_WPMR) Write Protect KEY */ -/* -------- SMC_WPSR : (SMC Offset: 0xE8) SMC Write Protect Status Register -------- */ -#define SMC_WPSR_WPVS (0x1 << 0) /**< \brief (SMC_WPSR) Write Protect Enable */ -#define SMC_WPSR_WPVSRC (0xffff << 8) /**< \brief (SMC_WPSR) Write Protect Violation Source */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Serial Peripheral Interface */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_SPI Serial Peripheral Interface */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Spi hardware registers */ -typedef struct { - WoReg SPI_CR; /**< \brief (Spi Offset: 0x00) Control Register */ - RwReg SPI_MR; /**< \brief (Spi Offset: 0x04) Mode Register */ - RoReg SPI_RDR; /**< \brief (Spi Offset: 0x08) Receive Data Register */ - WoReg SPI_TDR; /**< \brief (Spi Offset: 0x0C) Transmit Data Register */ - RoReg SPI_SR; /**< \brief (Spi Offset: 0x10) Status Register */ - WoReg SPI_IER; /**< \brief (Spi Offset: 0x14) Interrupt Enable Register */ - WoReg SPI_IDR; /**< \brief (Spi Offset: 0x18) Interrupt Disable Register */ - RoReg SPI_IMR; /**< \brief (Spi Offset: 0x1C) Interrupt Mask Register */ - RwReg Reserved1[4]; - RwReg SPI_CSR[4]; /**< \brief (Spi Offset: 0x30) Chip Select Register */ - RwReg Reserved2[41]; - RwReg SPI_WPMR; /**< \brief (Spi Offset: 0xE4) Write Protection Control Register */ - RoReg SPI_WPSR; /**< \brief (Spi Offset: 0xE8) Write Protection Status Register */ - RwReg Reserved3[5]; - RwReg SPI_RPR; /**< \brief (Spi Offset: 0x100) Receive Pointer Register */ - RwReg SPI_RCR; /**< \brief (Spi Offset: 0x104) Receive Counter Register */ - RwReg SPI_TPR; /**< \brief (Spi Offset: 0x108) Transmit Pointer Register */ - RwReg SPI_TCR; /**< \brief (Spi Offset: 0x10C) Transmit Counter Register */ - RwReg SPI_RNPR; /**< \brief (Spi Offset: 0x110) Receive Next Pointer Register */ - RwReg SPI_RNCR; /**< \brief (Spi Offset: 0x114) Receive Next Counter Register */ - RwReg SPI_TNPR; /**< \brief (Spi Offset: 0x118) Transmit Next Pointer Register */ - RwReg SPI_TNCR; /**< \brief (Spi Offset: 0x11C) Transmit Next Counter Register */ - WoReg SPI_PTCR; /**< \brief (Spi Offset: 0x120) Transfer Control Register */ - RoReg SPI_PTSR; /**< \brief (Spi Offset: 0x124) Transfer Status Register */ -} Spi; -#endif /* __ASSEMBLY__ */ -/* -------- SPI_CR : (SPI Offset: 0x00) Control Register -------- */ -#define SPI_CR_SPIEN (0x1 << 0) /**< \brief (SPI_CR) SPI Enable */ -#define SPI_CR_SPIDIS (0x1 << 1) /**< \brief (SPI_CR) SPI Disable */ -#define SPI_CR_SWRST (0x1 << 7) /**< \brief (SPI_CR) SPI Software Reset */ -#define SPI_CR_LASTXFER (0x1 << 24) /**< \brief (SPI_CR) Last Transfer */ -/* -------- SPI_MR : (SPI Offset: 0x04) Mode Register -------- */ -#define SPI_MR_MSTR (0x1 << 0) /**< \brief (SPI_MR) Master/Slave Mode */ -#define SPI_MR_PS (0x1 << 1) /**< \brief (SPI_MR) Peripheral Select */ -#define SPI_MR_PS_FIXED (0x0 << 1) /**< \brief (SPI_MR) Fixed Peripheral Select. */ -#define SPI_MR_PS_VARIABLE (0x1 << 1) /**< \brief (SPI_MR) Variable Peripheral Select. */ -#define SPI_MR_PCSDEC (0x1 << 2) /**< \brief (SPI_MR) Chip Select Decode */ -#define SPI_MR_MODFDIS (0x1 << 4) /**< \brief (SPI_MR) Mode Fault Detection */ -#define SPI_MR_WDRBT (0x1 << 5) /**< \brief (SPI_MR) Wait Data Read Before Transfer */ -#define SPI_MR_LLB (0x1 << 7) /**< \brief (SPI_MR) Local Loopback Enable */ -#define SPI_MR_PCS (0xf << 16) /**< \brief (SPI_MR) Peripheral Chip Select */ -#define SPI_MR_DLYBCS (0xff << 24) /**< \brief (SPI_MR) Delay Between Chip Selects */ -/* -------- SPI_RDR : (SPI Offset: 0x08) Receive Data Register -------- */ -#define SPI_RDR_RD (0xffff << 0) /**< \brief (SPI_RDR) Receive Data */ -#define SPI_RDR_PCS (0xf << 16) /**< \brief (SPI_RDR) Peripheral Chip Select */ -/* -------- SPI_TDR : (SPI Offset: 0x0C) Transmit Data Register -------- */ -#define SPI_TDR_TD (0xffff << 0) /**< \brief (SPI_TDR) Transmit Data */ -#define SPI_TDR_PCS (0xf << 16) /**< \brief (SPI_TDR) Peripheral Chip Select */ -#define SPI_TDR_LASTXFER (0x1 << 24) /**< \brief (SPI_TDR) Last Transfer */ -/* -------- SPI_SR : (SPI Offset: 0x10) Status Register -------- */ -#define SPI_SR_RDRF (0x1 << 0) /**< \brief (SPI_SR) Receive Data Register Full */ -#define SPI_SR_TDRE (0x1 << 1) /**< \brief (SPI_SR) Transmit Data Register Empty */ -#define SPI_SR_MODF (0x1 << 2) /**< \brief (SPI_SR) Mode Fault Error */ -#define SPI_SR_OVRES (0x1 << 3) /**< \brief (SPI_SR) Overrun Error Status */ -#define SPI_SR_ENDRX (0x1 << 4) /**< \brief (SPI_SR) End of RX buffer */ -#define SPI_SR_ENDTX (0x1 << 5) /**< \brief (SPI_SR) End of TX buffer */ -#define SPI_SR_RXBUFF (0x1 << 6) /**< \brief (SPI_SR) RX Buffer Full */ -#define SPI_SR_TXBUFE (0x1 << 7) /**< \brief (SPI_SR) TX Buffer Empty */ -#define SPI_SR_NSSR (0x1 << 8) /**< \brief (SPI_SR) NSS Rising */ -#define SPI_SR_TXEMPTY (0x1 << 9) /**< \brief (SPI_SR) Transmission Registers Empty */ -#define SPI_SR_UNDES (0x1 << 10) /**< \brief (SPI_SR) Underrun Error Status (Slave Mode Only) */ -#define SPI_SR_SPIENS (0x1 << 16) /**< \brief (SPI_SR) SPI Enable Status */ -/* -------- SPI_IER : (SPI Offset: 0x14) Interrupt Enable Register -------- */ -#define SPI_IER_RDRF (0x1 << 0) /**< \brief (SPI_IER) Receive Data Register Full Interrupt Enable */ -#define SPI_IER_TDRE (0x1 << 1) /**< \brief (SPI_IER) SPI Transmit Data Register Empty Interrupt Enable */ -#define SPI_IER_MODF (0x1 << 2) /**< \brief (SPI_IER) Mode Fault Error Interrupt Enable */ -#define SPI_IER_OVRES (0x1 << 3) /**< \brief (SPI_IER) Overrun Error Interrupt Enable */ -#define SPI_IER_ENDRX (0x1 << 4) /**< \brief (SPI_IER) End of Receive Buffer Interrupt Enable */ -#define SPI_IER_ENDTX (0x1 << 5) /**< \brief (SPI_IER) End of Transmit Buffer Interrupt Enable */ -#define SPI_IER_RXBUFF (0x1 << 6) /**< \brief (SPI_IER) Receive Buffer Full Interrupt Enable */ -#define SPI_IER_TXBUFE (0x1 << 7) /**< \brief (SPI_IER) Transmit Buffer Empty Interrupt Enable */ -#define SPI_IER_NSSR (0x1 << 8) /**< \brief (SPI_IER) NSS Rising Interrupt Enable */ -#define SPI_IER_TXEMPTY (0x1 << 9) /**< \brief (SPI_IER) Transmission Registers Empty Enable */ -#define SPI_IER_UNDES (0x1 << 10) /**< \brief (SPI_IER) Underrun Error Interrupt Enable */ -/* -------- SPI_IDR : (SPI Offset: 0x18) Interrupt Disable Register -------- */ -#define SPI_IDR_RDRF (0x1 << 0) /**< \brief (SPI_IDR) Receive Data Register Full Interrupt Disable */ -#define SPI_IDR_TDRE (0x1 << 1) /**< \brief (SPI_IDR) SPI Transmit Data Register Empty Interrupt Disable */ -#define SPI_IDR_MODF (0x1 << 2) /**< \brief (SPI_IDR) Mode Fault Error Interrupt Disable */ -#define SPI_IDR_OVRES (0x1 << 3) /**< \brief (SPI_IDR) Overrun Error Interrupt Disable */ -#define SPI_IDR_ENDRX (0x1 << 4) /**< \brief (SPI_IDR) End of Receive Buffer Interrupt Disable */ -#define SPI_IDR_ENDTX (0x1 << 5) /**< \brief (SPI_IDR) End of Transmit Buffer Interrupt Disable */ -#define SPI_IDR_RXBUFF (0x1 << 6) /**< \brief (SPI_IDR) Receive Buffer Full Interrupt Disable */ -#define SPI_IDR_TXBUFE (0x1 << 7) /**< \brief (SPI_IDR) Transmit Buffer Empty Interrupt Disable */ -#define SPI_IDR_NSSR (0x1 << 8) /**< \brief (SPI_IDR) NSS Rising Interrupt Disable */ -#define SPI_IDR_TXEMPTY (0x1 << 9) /**< \brief (SPI_IDR) Transmission Registers Empty Disable */ -#define SPI_IDR_UNDES (0x1 << 10) /**< \brief (SPI_IDR) Underrun Error Interrupt Disable */ -/* -------- SPI_IMR : (SPI Offset: 0x1C) Interrupt Mask Register -------- */ -#define SPI_IMR_RDRF (0x1 << 0) /**< \brief (SPI_IMR) Receive Data Register Full Interrupt Mask */ -#define SPI_IMR_TDRE (0x1 << 1) /**< \brief (SPI_IMR) SPI Transmit Data Register Empty Interrupt Mask */ -#define SPI_IMR_MODF (0x1 << 2) /**< \brief (SPI_IMR) Mode Fault Error Interrupt Mask */ -#define SPI_IMR_OVRES (0x1 << 3) /**< \brief (SPI_IMR) Overrun Error Interrupt Mask */ -#define SPI_IMR_ENDRX (0x1 << 4) /**< \brief (SPI_IMR) End of Receive Buffer Interrupt Mask */ -#define SPI_IMR_ENDTX (0x1 << 5) /**< \brief (SPI_IMR) End of Transmit Buffer Interrupt Mask */ -#define SPI_IMR_RXBUFF (0x1 << 6) /**< \brief (SPI_IMR) Receive Buffer Full Interrupt Mask */ -#define SPI_IMR_TXBUFE (0x1 << 7) /**< \brief (SPI_IMR) Transmit Buffer Empty Interrupt Mask */ -#define SPI_IMR_NSSR (0x1 << 8) /**< \brief (SPI_IMR) NSS Rising Interrupt Mask */ -#define SPI_IMR_TXEMPTY (0x1 << 9) /**< \brief (SPI_IMR) Transmission Registers Empty Mask */ -#define SPI_IMR_UNDES (0x1 << 10) /**< \brief (SPI_IMR) Underrun Error Interrupt Mask */ -/* -------- SPI_CSR[4] : (SPI Offset: 0x30) Chip Select Register -------- */ -#define SPI_CSR_CPOL (0x1 << 0) /**< \brief (SPI_CSR[4]) Clock Polarity */ -#define SPI_CSR_NCPHA (0x1 << 1) /**< \brief (SPI_CSR[4]) Clock Phase */ -#define SPI_CSR_CSNAAT (0x1 << 2) /**< \brief (SPI_CSR[4]) Chip Select Not Active After Transfer (Ignored if CSAAT = 1) */ -#define SPI_CSR_CSAAT (0x1 << 3) /**< \brief (SPI_CSR[4]) Chip Select Not Active After Transfer (Ignored if CSAAT = 1) */ -#define SPI_CSR_BITS (0xf << 4) /**< \brief (SPI_CSR[4]) Bits Per Transfer (See the (Note:) below the register table; Section 9.9 "SPI Chip Select Register" on page 35.) */ -#define SPI_CSR_BITS_8 (0x0 << 4) /**< \brief (SPI_CSR[4]) 8 */ -#define SPI_CSR_BITS_9 (0x1 << 4) /**< \brief (SPI_CSR[4]) 9 */ -#define SPI_CSR_BITS_10 (0x2 << 4) /**< \brief (SPI_CSR[4]) 10 */ -#define SPI_CSR_BITS_11 (0x3 << 4) /**< \brief (SPI_CSR[4]) 11 */ -#define SPI_CSR_BITS_12 (0x4 << 4) /**< \brief (SPI_CSR[4]) 12 */ -#define SPI_CSR_BITS_13 (0x5 << 4) /**< \brief (SPI_CSR[4]) 13 */ -#define SPI_CSR_BITS_14 (0x6 << 4) /**< \brief (SPI_CSR[4]) 14 */ -#define SPI_CSR_BITS_15 (0x7 << 4) /**< \brief (SPI_CSR[4]) 15 */ -#define SPI_CSR_BITS_16 (0x8 << 4) /**< \brief (SPI_CSR[4]) 16 */ -#define SPI_CSR_SCBR (0xff << 8) /**< \brief (SPI_CSR[4]) Serial Clock Baud Rate */ -#define SPI_CSR_DLYBS (0xff << 16) /**< \brief (SPI_CSR[4]) Delay Before SPCK */ -#define SPI_CSR_DLYBCT (0xff << 24) /**< \brief (SPI_CSR[4]) Delay Between Consecutive Transfers */ -/* -------- SPI_WPMR : (SPI Offset: 0xE4) Write Protection Control Register -------- */ -#define SPI_WPMR_SPIWPEN (0x1 << 0) /**< \brief (SPI_WPMR) SPI Write Protection Enable */ -#define SPI_WPMR_SPIWPKEY (0xffffff << 8) /**< \brief (SPI_WPMR) SPI Write Protection Key Password */ -/* -------- SPI_WPSR : (SPI Offset: 0xE8) Write Protection Status Register -------- */ -#define SPI_WPSR_SPIWPVS (0x7 << 0) /**< \brief (SPI_WPSR) SPI Write Protection Violation Status */ -#define SPI_WPSR_SPIWPVSRC (0xff << 8) /**< \brief (SPI_WPSR) SPI Write Protection Violation Source */ -/* -------- SPI_RPR : (SPI Offset: 0x100) Receive Pointer Register -------- */ -#define SPI_RPR_RXPTR (0xffffffff << 0) /**< \brief (SPI_RPR) Receive Pointer Register */ -/* -------- SPI_RCR : (SPI Offset: 0x104) Receive Counter Register -------- */ -#define SPI_RCR_RXCTR (0xffff << 0) /**< \brief (SPI_RCR) Receive Counter Register */ -/* -------- SPI_TPR : (SPI Offset: 0x108) Transmit Pointer Register -------- */ -#define SPI_TPR_TXPTR (0xffffffff << 0) /**< \brief (SPI_TPR) Transmit Counter Register */ -/* -------- SPI_TCR : (SPI Offset: 0x10C) Transmit Counter Register -------- */ -#define SPI_TCR_TXCTR (0xffff << 0) /**< \brief (SPI_TCR) Transmit Counter Register */ -/* -------- SPI_RNPR : (SPI Offset: 0x110) Receive Next Pointer Register -------- */ -#define SPI_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (SPI_RNPR) Receive Next Pointer */ -/* -------- SPI_RNCR : (SPI Offset: 0x114) Receive Next Counter Register -------- */ -#define SPI_RNCR_RXNCTR (0xffff << 0) /**< \brief (SPI_RNCR) Receive Next Counter */ -/* -------- SPI_TNPR : (SPI Offset: 0x118) Transmit Next Pointer Register -------- */ -#define SPI_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (SPI_TNPR) Transmit Next Pointer */ -/* -------- SPI_TNCR : (SPI Offset: 0x11C) Transmit Next Counter Register -------- */ -#define SPI_TNCR_TXNCTR (0xffff << 0) /**< \brief (SPI_TNCR) Transmit Counter Next */ -/* -------- SPI_PTCR : (SPI Offset: 0x120) Transfer Control Register -------- */ -#define SPI_PTCR_RXTEN (0x1 << 0) /**< \brief (SPI_PTCR) Receiver Transfer Enable */ -#define SPI_PTCR_RXTDIS (0x1 << 1) /**< \brief (SPI_PTCR) Receiver Transfer Disable */ -#define SPI_PTCR_TXTEN (0x1 << 8) /**< \brief (SPI_PTCR) Transmitter Transfer Enable */ -#define SPI_PTCR_TXTDIS (0x1 << 9) /**< \brief (SPI_PTCR) Transmitter Transfer Disable */ -/* -------- SPI_PTSR : (SPI Offset: 0x124) Transfer Status Register -------- */ -#define SPI_PTSR_RXTEN (0x1 << 0) /**< \brief (SPI_PTSR) Receiver Transfer Enable */ -#define SPI_PTSR_TXTEN (0x1 << 8) /**< \brief (SPI_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Synchronous Serial Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_SSC Synchronous Serial Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Ssc hardware registers */ -typedef struct { - WoReg SSC_CR; /**< \brief (Ssc Offset: 0x0) Control Register */ - RwReg SSC_CMR; /**< \brief (Ssc Offset: 0x4) Clock Mode Register */ - RwReg Reserved1[2]; - RwReg SSC_RCMR; /**< \brief (Ssc Offset: 0x10) Receive Clock Mode Register */ - RwReg SSC_RFMR; /**< \brief (Ssc Offset: 0x14) Receive Frame Mode Register */ - RwReg SSC_TCMR; /**< \brief (Ssc Offset: 0x18) Transmit Clock Mode Register */ - RwReg SSC_TFMR; /**< \brief (Ssc Offset: 0x1C) Transmit Frame Mode Register */ - RoReg SSC_RHR; /**< \brief (Ssc Offset: 0x20) Receive Holding Register */ - WoReg SSC_THR; /**< \brief (Ssc Offset: 0x24) Transmit Holding Register */ - RwReg Reserved2[2]; - RoReg SSC_RSHR; /**< \brief (Ssc Offset: 0x30) Receive Sync. Holding Register */ - RwReg SSC_TSHR; /**< \brief (Ssc Offset: 0x34) Transmit Sync. Holding Register */ - RwReg SSC_RC0R; /**< \brief (Ssc Offset: 0x38) Receive Compare 0 Register */ - RwReg SSC_RC1R; /**< \brief (Ssc Offset: 0x3C) Receive Compare 1 Register */ - RoReg SSC_SR; /**< \brief (Ssc Offset: 0x40) Status Register */ - WoReg SSC_IER; /**< \brief (Ssc Offset: 0x44) Interrupt Enable Register */ - WoReg SSC_IDR; /**< \brief (Ssc Offset: 0x48) Interrupt Disable Register */ - RoReg SSC_IMR; /**< \brief (Ssc Offset: 0x4C) Interrupt Mask Register */ - RwReg Reserved3[37]; - RwReg SSC_WPMR; /**< \brief (Ssc Offset: 0xE4) Write Protect Mode Register */ - RoReg SSC_WPSR; /**< \brief (Ssc Offset: 0xE8) Write Protect Status Register */ - RwReg Reserved4[5]; - RwReg SSC_RPR; /**< \brief (Ssc Offset: 0x100) Receive Pointer Register */ - RwReg SSC_RCR; /**< \brief (Ssc Offset: 0x104) Receive Counter Register */ - RwReg SSC_TPR; /**< \brief (Ssc Offset: 0x108) Transmit Pointer Register */ - RwReg SSC_TCR; /**< \brief (Ssc Offset: 0x10C) Transmit Counter Register */ - RwReg SSC_RNPR; /**< \brief (Ssc Offset: 0x110) Receive Next Pointer Register */ - RwReg SSC_RNCR; /**< \brief (Ssc Offset: 0x114) Receive Next Counter Register */ - RwReg SSC_TNPR; /**< \brief (Ssc Offset: 0x118) Transmit Next Pointer Register */ - RwReg SSC_TNCR; /**< \brief (Ssc Offset: 0x11C) Transmit Next Counter Register */ - WoReg SSC_PTCR; /**< \brief (Ssc Offset: 0x120) Transfer Control Register */ - RoReg SSC_PTSR; /**< \brief (Ssc Offset: 0x124) Transfer Status Register */ -} Ssc; -#endif /* __ASSEMBLY__ */ -/* -------- SSC_CR : (SSC Offset: 0x0) Control Register -------- */ -#define SSC_CR_RXEN (0x1 << 0) /**< \brief (SSC_CR) Receive Enable */ -#define SSC_CR_RXDIS (0x1 << 1) /**< \brief (SSC_CR) Receive Disable */ -#define SSC_CR_TXEN (0x1 << 8) /**< \brief (SSC_CR) Transmit Enable */ -#define SSC_CR_TXDIS (0x1 << 9) /**< \brief (SSC_CR) Transmit Disable */ -#define SSC_CR_SWRST (0x1 << 15) /**< \brief (SSC_CR) Software Reset */ -/* -------- SSC_CMR : (SSC Offset: 0x4) Clock Mode Register -------- */ -#define SSC_CMR_DIV (0xfff << 0) /**< \brief (SSC_CMR) Clock Divider */ -/* -------- SSC_RCMR : (SSC Offset: 0x10) Receive Clock Mode Register -------- */ -#define SSC_RCMR_CKS (0x3 << 0) /**< \brief (SSC_RCMR) Receive Clock Selection */ -#define SSC_RCMR_CKS_DIV (0x0 << 0) /**< \brief (SSC_RCMR) Divided Clock */ -#define SSC_RCMR_CKS_TK (0x1 << 0) /**< \brief (SSC_RCMR) TK Clock signal */ -#define SSC_RCMR_CKS_RK (0x2 << 0) /**< \brief (SSC_RCMR) RK pin */ -#define SSC_RCMR_CKO (0x7 << 2) /**< \brief (SSC_RCMR) Receive Clock Output Mode Selection */ -#define SSC_RCMR_CKI (0x1 << 5) /**< \brief (SSC_RCMR) Receive Clock Inversion */ -#define SSC_RCMR_CKG (0x3 << 6) /**< \brief (SSC_RCMR) Receive Clock Gating Selection */ -#define SSC_RCMR_CKG_NONE (0x0 << 6) /**< \brief (SSC_RCMR) None, continuous clock */ -#define SSC_RCMR_CKG_LOW (0x1 << 6) /**< \brief (SSC_RCMR) Receive Clock enabled only if RF Low */ -#define SSC_RCMR_CKG_HIGH (0x2 << 6) /**< \brief (SSC_RCMR) Receive Clock enabled only if RF High */ -#define SSC_RCMR_START (0xf << 8) /**< \brief (SSC_RCMR) Receive Start Selection */ -#define SSC_RCMR_STOP (0x1 << 12) /**< \brief (SSC_RCMR) Receive Stop Selection */ -#define SSC_RCMR_STTDLY (0xff << 16) /**< \brief (SSC_RCMR) Receive Start Delay */ -#define SSC_RCMR_PERIOD (0xff << 24) /**< \brief (SSC_RCMR) Receive Period Divider Selection */ -/* -------- SSC_RFMR : (SSC Offset: 0x14) Receive Frame Mode Register -------- */ -#define SSC_RFMR_DATLEN (0x1f << 0) /**< \brief (SSC_RFMR) Data Length */ -#define SSC_RFMR_LOOP (0x1 << 5) /**< \brief (SSC_RFMR) Loop Mode */ -#define SSC_RFMR_MSBF (0x1 << 7) /**< \brief (SSC_RFMR) Most Significant Bit First */ -#define SSC_RFMR_DATNB (0xf << 8) /**< \brief (SSC_RFMR) Data Number per Frame */ -#define SSC_RFMR_FSLEN (0xf << 16) /**< \brief (SSC_RFMR) Receive Frame Sync Length */ -#define SSC_RFMR_FSOS (0x7 << 20) /**< \brief (SSC_RFMR) Receive Frame Sync Output Selection */ -#define SSC_RFMR_FSEDGE (0x1 << 24) /**< \brief (SSC_RFMR) Frame Sync Edge Detection */ -#define SSC_RFMR_FSLEN_EXT (0xf << 28) /**< \brief (SSC_RFMR) FSLEN Field Extension */ -/* -------- SSC_TCMR : (SSC Offset: 0x18) Transmit Clock Mode Register -------- */ -#define SSC_TCMR_CKS (0x3 << 0) /**< \brief (SSC_TCMR) Transmit Clock Selection */ -#define SSC_TCMR_CKO (0x7 << 2) /**< \brief (SSC_TCMR) Transmit Clock Output Mode Selection */ -#define SSC_TCMR_CKI (0x1 << 5) /**< \brief (SSC_TCMR) Transmit Clock Inversion */ -#define SSC_TCMR_CKG (0x3 << 6) /**< \brief (SSC_TCMR) Transmit Clock Gating Selection */ -#define SSC_TCMR_START (0xf << 8) /**< \brief (SSC_TCMR) Transmit Start Selection */ -#define SSC_TCMR_STTDLY (0xff << 16) /**< \brief (SSC_TCMR) Transmit Start Delay */ -#define SSC_TCMR_PERIOD (0xff << 24) /**< \brief (SSC_TCMR) Transmit Period Divider Selection */ -/* -------- SSC_TFMR : (SSC Offset: 0x1C) Transmit Frame Mode Register -------- */ -#define SSC_TFMR_DATLEN (0x1f << 0) /**< \brief (SSC_TFMR) Data Length */ -#define SSC_TFMR_DATDEF (0x1 << 5) /**< \brief (SSC_TFMR) Data Default Value */ -#define SSC_TFMR_MSBF (0x1 << 7) /**< \brief (SSC_TFMR) Most Significant Bit First */ -#define SSC_TFMR_DATNB (0xf << 8) /**< \brief (SSC_TFMR) Data Number per frame */ -#define SSC_TFMR_FSLEN (0xf << 16) /**< \brief (SSC_TFMR) Transmit Frame Syn Length */ -#define SSC_TFMR_FSOS (0x7 << 20) /**< \brief (SSC_TFMR) Transmit Frame Sync Output Selection */ -#define SSC_TFMR_FSDEN (0x1 << 23) /**< \brief (SSC_TFMR) Frame Sync Data Enable */ -#define SSC_TFMR_FSEDGE (0x1 << 24) /**< \brief (SSC_TFMR) Frame Sync Edge Detection */ -#define SSC_TFMR_FSLEN_EXT (0xf << 28) /**< \brief (SSC_TFMR) FSLEN Field Extension */ -/* -------- SSC_RHR : (SSC Offset: 0x20) Receive Holding Register -------- */ -#define SSC_RHR_RDAT (0xffffffff << 0) /**< \brief (SSC_RHR) Receive Data */ -/* -------- SSC_THR : (SSC Offset: 0x24) Transmit Holding Register -------- */ -#define SSC_THR_TDAT (0xffffffff << 0) /**< \brief (SSC_THR) Transmit Data */ -/* -------- SSC_RSHR : (SSC Offset: 0x30) Receive Sync. Holding Register -------- */ -#define SSC_RSHR_RSDAT (0xffff << 0) /**< \brief (SSC_RSHR) Receive Synchronization Data */ -/* -------- SSC_TSHR : (SSC Offset: 0x34) Transmit Sync. Holding Register -------- */ -#define SSC_TSHR_TSDAT (0xffff << 0) /**< \brief (SSC_TSHR) Transmit Synchronization Data */ -/* -------- SSC_RC0R : (SSC Offset: 0x38) Receive Compare 0 Register -------- */ -#define SSC_RC0R_CP0 (0xffff << 0) /**< \brief (SSC_RC0R) Receive Compare Data 0 */ -/* -------- SSC_RC1R : (SSC Offset: 0x3C) Receive Compare 1 Register -------- */ -#define SSC_RC1R_CP1 (0xffff << 0) /**< \brief (SSC_RC1R) Receive Compare Data 1 */ -/* -------- SSC_SR : (SSC Offset: 0x40) Status Register -------- */ -#define SSC_SR_TXRDY (0x1 << 0) /**< \brief (SSC_SR) Transmit Ready */ -#define SSC_SR_TXEMPTY (0x1 << 1) /**< \brief (SSC_SR) Transmit Empty */ -#define SSC_SR_ENDTX (0x1 << 2) /**< \brief (SSC_SR) End of Transmission */ -#define SSC_SR_TXBUFE (0x1 << 3) /**< \brief (SSC_SR) Transmit Buffer Empty */ -#define SSC_SR_RXRDY (0x1 << 4) /**< \brief (SSC_SR) Receive Ready */ -#define SSC_SR_OVRUN (0x1 << 5) /**< \brief (SSC_SR) Receive Overrun */ -#define SSC_SR_ENDRX (0x1 << 6) /**< \brief (SSC_SR) End of Reception */ -#define SSC_SR_RXBUFF (0x1 << 7) /**< \brief (SSC_SR) Receive Buffer Full */ -#define SSC_SR_CP0 (0x1 << 8) /**< \brief (SSC_SR) Compare 0 */ -#define SSC_SR_CP1 (0x1 << 9) /**< \brief (SSC_SR) Compare 1 */ -#define SSC_SR_TXSYN (0x1 << 10) /**< \brief (SSC_SR) Transmit Sync */ -#define SSC_SR_RXSYN (0x1 << 11) /**< \brief (SSC_SR) Receive Sync */ -#define SSC_SR_TXEN (0x1 << 16) /**< \brief (SSC_SR) Transmit Enable */ -#define SSC_SR_RXEN (0x1 << 17) /**< \brief (SSC_SR) Receive Enable */ -/* -------- SSC_IER : (SSC Offset: 0x44) Interrupt Enable Register -------- */ -#define SSC_IER_TXRDY (0x1 << 0) /**< \brief (SSC_IER) Transmit Ready Interrupt Enable */ -#define SSC_IER_TXEMPTY (0x1 << 1) /**< \brief (SSC_IER) Transmit Empty Interrupt Enable */ -#define SSC_IER_ENDTX (0x1 << 2) /**< \brief (SSC_IER) End of Transmission Interrupt Enable */ -#define SSC_IER_TXBUFE (0x1 << 3) /**< \brief (SSC_IER) Transmit Buffer Empty Interrupt Enable */ -#define SSC_IER_RXRDY (0x1 << 4) /**< \brief (SSC_IER) Receive Ready Interrupt Enable */ -#define SSC_IER_OVRUN (0x1 << 5) /**< \brief (SSC_IER) Receive Overrun Interrupt Enable */ -#define SSC_IER_ENDRX (0x1 << 6) /**< \brief (SSC_IER) End of Reception Interrupt Enable */ -#define SSC_IER_RXBUFF (0x1 << 7) /**< \brief (SSC_IER) Receive Buffer Full Interrupt Enable */ -#define SSC_IER_CP0 (0x1 << 8) /**< \brief (SSC_IER) Compare 0 Interrupt Enable */ -#define SSC_IER_CP1 (0x1 << 9) /**< \brief (SSC_IER) Compare 1 Interrupt Enable */ -#define SSC_IER_TXSYN (0x1 << 10) /**< \brief (SSC_IER) Tx Sync Interrupt Enable */ -#define SSC_IER_RXSYN (0x1 << 11) /**< \brief (SSC_IER) Rx Sync Interrupt Enable */ -/* -------- SSC_IDR : (SSC Offset: 0x48) Interrupt Disable Register -------- */ -#define SSC_IDR_TXRDY (0x1 << 0) /**< \brief (SSC_IDR) Transmit Ready Interrupt Disable */ -#define SSC_IDR_TXEMPTY (0x1 << 1) /**< \brief (SSC_IDR) Transmit Empty Interrupt Disable */ -#define SSC_IDR_ENDTX (0x1 << 2) /**< \brief (SSC_IDR) End of Transmission Interrupt Disable */ -#define SSC_IDR_TXBUFE (0x1 << 3) /**< \brief (SSC_IDR) Transmit Buffer Empty Interrupt Disable */ -#define SSC_IDR_RXRDY (0x1 << 4) /**< \brief (SSC_IDR) Receive Ready Interrupt Disable */ -#define SSC_IDR_OVRUN (0x1 << 5) /**< \brief (SSC_IDR) Receive Overrun Interrupt Disable */ -#define SSC_IDR_ENDRX (0x1 << 6) /**< \brief (SSC_IDR) End of Reception Interrupt Disable */ -#define SSC_IDR_RXBUFF (0x1 << 7) /**< \brief (SSC_IDR) Receive Buffer Full Interrupt Disable */ -#define SSC_IDR_CP0 (0x1 << 8) /**< \brief (SSC_IDR) Compare 0 Interrupt Disable */ -#define SSC_IDR_CP1 (0x1 << 9) /**< \brief (SSC_IDR) Compare 1 Interrupt Disable */ -#define SSC_IDR_TXSYN (0x1 << 10) /**< \brief (SSC_IDR) Tx Sync Interrupt Enable */ -#define SSC_IDR_RXSYN (0x1 << 11) /**< \brief (SSC_IDR) Rx Sync Interrupt Enable */ -/* -------- SSC_IMR : (SSC Offset: 0x4C) Interrupt Mask Register -------- */ -#define SSC_IMR_TXRDY (0x1 << 0) /**< \brief (SSC_IMR) Transmit Ready Interrupt Mask */ -#define SSC_IMR_TXEMPTY (0x1 << 1) /**< \brief (SSC_IMR) Transmit Empty Interrupt Mask */ -#define SSC_IMR_ENDTX (0x1 << 2) /**< \brief (SSC_IMR) End of Transmission Interrupt Mask */ -#define SSC_IMR_TXBUFE (0x1 << 3) /**< \brief (SSC_IMR) Transmit Buffer Empty Interrupt Mask */ -#define SSC_IMR_RXRDY (0x1 << 4) /**< \brief (SSC_IMR) Receive Ready Interrupt Mask */ -#define SSC_IMR_OVRUN (0x1 << 5) /**< \brief (SSC_IMR) Receive Overrun Interrupt Mask */ -#define SSC_IMR_ENDRX (0x1 << 6) /**< \brief (SSC_IMR) End of Reception Interrupt Mask */ -#define SSC_IMR_RXBUFF (0x1 << 7) /**< \brief (SSC_IMR) Receive Buffer Full Interrupt Mask */ -#define SSC_IMR_CP0 (0x1 << 8) /**< \brief (SSC_IMR) Compare 0 Interrupt Mask */ -#define SSC_IMR_CP1 (0x1 << 9) /**< \brief (SSC_IMR) Compare 1 Interrupt Mask */ -#define SSC_IMR_TXSYN (0x1 << 10) /**< \brief (SSC_IMR) Tx Sync Interrupt Mask */ -#define SSC_IMR_RXSYN (0x1 << 11) /**< \brief (SSC_IMR) Rx Sync Interrupt Mask */ -/* -------- SSC_WPMR : (SSC Offset: 0xE4) Write Protect Mode Register -------- */ -#define SSC_WPMR_WPEN (0x1 << 0) /**< \brief (SSC_WPMR) Write Protect Enable */ -#define SSC_WPMR_WPKEY (0xffffff << 8) /**< \brief (SSC_WPMR) Write Protect KEY */ -/* -------- SSC_WPSR : (SSC Offset: 0xE8) Write Protect Status Register -------- */ -#define SSC_WPSR_WPVS (0x1 << 0) /**< \brief (SSC_WPSR) Write Protect Violation Status */ -#define SSC_WPSR_WPVSRC (0xffff << 8) /**< \brief (SSC_WPSR) Write Protect Violation Source */ -/* -------- SSC_RPR : (SSC Offset: 0x100) Receive Pointer Register -------- */ -#define SSC_RPR_RXPTR (0xffffffff << 0) /**< \brief (SSC_RPR) Receive Pointer Register */ -/* -------- SSC_RCR : (SSC Offset: 0x104) Receive Counter Register -------- */ -#define SSC_RCR_RXCTR (0xffff << 0) /**< \brief (SSC_RCR) Receive Counter Register */ -/* -------- SSC_TPR : (SSC Offset: 0x108) Transmit Pointer Register -------- */ -#define SSC_TPR_TXPTR (0xffffffff << 0) /**< \brief (SSC_TPR) Transmit Counter Register */ -/* -------- SSC_TCR : (SSC Offset: 0x10C) Transmit Counter Register -------- */ -#define SSC_TCR_TXCTR (0xffff << 0) /**< \brief (SSC_TCR) Transmit Counter Register */ -/* -------- SSC_RNPR : (SSC Offset: 0x110) Receive Next Pointer Register -------- */ -#define SSC_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (SSC_RNPR) Receive Next Pointer */ -/* -------- SSC_RNCR : (SSC Offset: 0x114) Receive Next Counter Register -------- */ -#define SSC_RNCR_RXNCTR (0xffff << 0) /**< \brief (SSC_RNCR) Receive Next Counter */ -/* -------- SSC_TNPR : (SSC Offset: 0x118) Transmit Next Pointer Register -------- */ -#define SSC_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (SSC_TNPR) Transmit Next Pointer */ -/* -------- SSC_TNCR : (SSC Offset: 0x11C) Transmit Next Counter Register -------- */ -#define SSC_TNCR_TXNCTR (0xffff << 0) /**< \brief (SSC_TNCR) Transmit Counter Next */ -/* -------- SSC_PTCR : (SSC Offset: 0x120) Transfer Control Register -------- */ -#define SSC_PTCR_RXTEN (0x1 << 0) /**< \brief (SSC_PTCR) Receiver Transfer Enable */ -#define SSC_PTCR_RXTDIS (0x1 << 1) /**< \brief (SSC_PTCR) Receiver Transfer Disable */ -#define SSC_PTCR_TXTEN (0x1 << 8) /**< \brief (SSC_PTCR) Transmitter Transfer Enable */ -#define SSC_PTCR_TXTDIS (0x1 << 9) /**< \brief (SSC_PTCR) Transmitter Transfer Disable */ -/* -------- SSC_PTSR : (SSC Offset: 0x124) Transfer Status Register -------- */ -#define SSC_PTSR_RXTEN (0x1 << 0) /**< \brief (SSC_PTSR) Receiver Transfer Enable */ -#define SSC_PTSR_TXTEN (0x1 << 8) /**< \brief (SSC_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Supply Controller */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_SUPC Supply Controller */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Supc hardware registers */ -typedef struct { - WoReg SUPC_CR; /**< \brief (Supc Offset: 0x00) Supply Controller Control Register */ - RwReg SUPC_SMMR; /**< \brief (Supc Offset: 0x04) Supply Controller Supply Monitor Mode Register */ - RwReg SUPC_MR; /**< \brief (Supc Offset: 0x08) Supply Controller Mode Register */ - RwReg SUPC_WUMR; /**< \brief (Supc Offset: 0x0C) Supply Controller Wake Up Mode Register */ - RwReg SUPC_WUIR; /**< \brief (Supc Offset: 0x10) Supply Controller Wake Up Inputs Register */ - RoReg SUPC_SR; /**< \brief (Supc Offset: 0x14) Supply Controller Status Register */ -} Supc; -#endif /* __ASSEMBLY__ */ -/* -------- SUPC_CR : (SUPC Offset: 0x00) Supply Controller Control Register -------- */ -#define SUPC_CR_VROFF (0x1 << 2) /**< \brief (SUPC_CR) Voltage Regulator Off */ -#define SUPC_CR_VROFF_NO_EFFECT (0x0 << 2) /**< \brief (SUPC_CR) no effect. */ -#define SUPC_CR_VROFF_STOP_VREG (0x1 << 2) /**< \brief (SUPC_CR) if KEY is correct, asserts vddcore_nreset and stops the voltage regulator. */ -#define SUPC_CR_XTALSEL (0x1 << 3) /**< \brief (SUPC_CR) Crystal Oscillator Select */ -#define SUPC_CR_XTALSEL_NO_EFFECT (0x0 << 3) /**< \brief (SUPC_CR) no effect. */ -#define SUPC_CR_XTALSEL_CRYSTAL_SEL (0x1 << 3) /**< \brief (SUPC_CR) if KEY is correct, switches the slow clock on the crystal oscillator output. */ -#define SUPC_CR_KEY (0xff << 24) /**< \brief (SUPC_CR) Password */ -/* -------- SUPC_SMMR : (SUPC Offset: 0x04) Supply Controller Supply Monitor Mode Register -------- */ -#define SUPC_SMMR_SMTH (0xf << 0) /**< \brief (SUPC_SMMR) Supply Monitor Threshold */ -#define SUPC_SMMR_SMTH_1_9V (0x0 << 0) /**< \brief (SUPC_SMMR) 1.9 V */ -#define SUPC_SMMR_SMTH_2_0V (0x1 << 0) /**< \brief (SUPC_SMMR) 2.0 V */ -#define SUPC_SMMR_SMTH_2_1V (0x2 << 0) /**< \brief (SUPC_SMMR) 2.1 V */ -#define SUPC_SMMR_SMTH_2_2V (0x3 << 0) /**< \brief (SUPC_SMMR) 2.2 V */ -#define SUPC_SMMR_SMTH_2_3V (0x4 << 0) /**< \brief (SUPC_SMMR) 2.3 V */ -#define SUPC_SMMR_SMTH_2_4V (0x5 << 0) /**< \brief (SUPC_SMMR) 2.4 V */ -#define SUPC_SMMR_SMTH_2_5V (0x6 << 0) /**< \brief (SUPC_SMMR) 2.5 V */ -#define SUPC_SMMR_SMTH_2_6V (0x7 << 0) /**< \brief (SUPC_SMMR) 2.6 V */ -#define SUPC_SMMR_SMTH_2_7V (0x8 << 0) /**< \brief (SUPC_SMMR) 2.7 V */ -#define SUPC_SMMR_SMTH_2_8V (0x9 << 0) /**< \brief (SUPC_SMMR) 2.8 V */ -#define SUPC_SMMR_SMTH_2_9V (0xA << 0) /**< \brief (SUPC_SMMR) 2.9 V */ -#define SUPC_SMMR_SMTH_3_0V (0xB << 0) /**< \brief (SUPC_SMMR) 3.0 V */ -#define SUPC_SMMR_SMTH_3_1V (0xC << 0) /**< \brief (SUPC_SMMR) 3.1 V */ -#define SUPC_SMMR_SMTH_3_2V (0xD << 0) /**< \brief (SUPC_SMMR) 3.2 V */ -#define SUPC_SMMR_SMTH_3_3V (0xE << 0) /**< \brief (SUPC_SMMR) 3.3 V */ -#define SUPC_SMMR_SMTH_3_4V (0xF << 0) /**< \brief (SUPC_SMMR) 3.4 V */ -#define SUPC_SMMR_SMSMPL (0x7 << 8) /**< \brief (SUPC_SMMR) Supply Monitor Sampling Period */ -#define SUPC_SMMR_SMSMPL_SMD (0x0 << 8) /**< \brief (SUPC_SMMR) Supply Monitor disabled */ -#define SUPC_SMMR_SMSMPL_CSM (0x1 << 8) /**< \brief (SUPC_SMMR) Continuous Supply Monitor */ -#define SUPC_SMMR_SMSMPL_32SLCK (0x2 << 8) /**< \brief (SUPC_SMMR) Supply Monitor enabled one SLCK period every 32 SLCK periods */ -#define SUPC_SMMR_SMSMPL_256SLCK (0x3 << 8) /**< \brief (SUPC_SMMR) Supply Monitor enabled one SLCK period every 256 SLCK periods */ -#define SUPC_SMMR_SMSMPL_2048SLCK (0x4 << 8) /**< \brief (SUPC_SMMR) Supply Monitor enabled one SLCK period every 2,048 SLCK periods */ -#define SUPC_SMMR_SMRSTEN (0x1 << 12) /**< \brief (SUPC_SMMR) Supply Monitor Reset Enable */ -#define SUPC_SMMR_SMRSTEN_NOT_ENABLE (0x0 << 12) /**< \brief (SUPC_SMMR) the core reset signal "vddcore_nreset" is not affected when a supply monitor detection occurs. */ -#define SUPC_SMMR_SMRSTEN_ENABLE (0x1 << 12) /**< \brief (SUPC_SMMR) the core reset signal, vddcore_nreset is asserted when a supply monitor detection occurs. */ -#define SUPC_SMMR_SMIEN (0x1 << 13) /**< \brief (SUPC_SMMR) Supply Monitor Interrupt Enable */ -#define SUPC_SMMR_SMIEN_NOT_ENABLE (0x0 << 13) /**< \brief (SUPC_SMMR) the SUPC interrupt signal is not affected when a supply monitor detection occurs. */ -#define SUPC_SMMR_SMIEN_ENABLE (0x1 << 13) /**< \brief (SUPC_SMMR) the SUPC interrupt signal is asserted when a supply monitor detection occurs. */ -/* -------- SUPC_MR : (SUPC Offset: 0x08) Supply Controller Mode Register -------- */ -#define SUPC_MR_BODRSTEN (0x1 << 12) /**< \brief (SUPC_MR) Brownout Detector Reset Enable */ -#define SUPC_MR_BODRSTEN_NOT_ENABLE (0x0 << 12) /**< \brief (SUPC_MR) the core reset signal "vddcore_nreset" is not affected when a brownout detection occurs. */ -#define SUPC_MR_BODRSTEN_ENABLE (0x1 << 12) /**< \brief (SUPC_MR) the core reset signal, vddcore_nreset is asserted when a brownout detection occurs. */ -#define SUPC_MR_BODDIS (0x1 << 13) /**< \brief (SUPC_MR) Brownout Detector Disable */ -#define SUPC_MR_BODDIS_ENABLE (0x0 << 13) /**< \brief (SUPC_MR) the core brownout detector is enabled. */ -#define SUPC_MR_BODDIS_DISABLE (0x1 << 13) /**< \brief (SUPC_MR) the core brownout detector is disabled. */ -#define SUPC_MR_ONREG (0x1 << 14) /**< \brief (SUPC_MR) Voltage Regulator enable */ -#define SUPC_MR_ONREG_ONREG_UNUSED (0x0 << 14) /**< \brief (SUPC_MR) Voltage Regulator is not used */ -#define SUPC_MR_ONREG_ONREG_USED (0x1 << 14) /**< \brief (SUPC_MR) Voltage Regulator is used */ -#define SUPC_MR_OSCBYPASS (0x1 << 20) /**< \brief (SUPC_MR) Oscillator Bypass */ -#define SUPC_MR_OSCBYPASS_NO_EFFECT (0x0 << 20) /**< \brief (SUPC_MR) no effect. Clock selection depends on XTALSEL value. */ -#define SUPC_MR_OSCBYPASS_BYPASS (0x1 << 20) /**< \brief (SUPC_MR) the 32-KHz XTAL oscillator is selected and is put in bypass mode. */ -#define SUPC_MR_KEY (0xff << 24) /**< \brief (SUPC_MR) Password Key */ -/* -------- SUPC_WUMR : (SUPC Offset: 0x0C) Supply Controller Wake Up Mode Register -------- */ -#define SUPC_WUMR_SMEN (0x1 << 1) /**< \brief (SUPC_WUMR) Supply Monitor Wake Up Enable */ -#define SUPC_WUMR_SMEN_NOT_ENABLE (0x0 << 1) /**< \brief (SUPC_WUMR) the supply monitor detection has no wake up effect. */ -#define SUPC_WUMR_SMEN_ENABLE (0x1 << 1) /**< \brief (SUPC_WUMR) the supply monitor detection forces the wake up of the core power supply. */ -#define SUPC_WUMR_RTTEN (0x1 << 2) /**< \brief (SUPC_WUMR) Real Time Timer Wake Up Enable */ -#define SUPC_WUMR_RTTEN_NOT_ENABLE (0x0 << 2) /**< \brief (SUPC_WUMR) the RTT alarm signal has no wake up effect. */ -#define SUPC_WUMR_RTTEN_ENABLE (0x1 << 2) /**< \brief (SUPC_WUMR) the RTT alarm signal forces the wake up of the core power supply. */ -#define SUPC_WUMR_RTCEN (0x1 << 3) /**< \brief (SUPC_WUMR) Real Time Clock Wake Up Enable */ -#define SUPC_WUMR_RTCEN_NOT_ENABLE (0x0 << 3) /**< \brief (SUPC_WUMR) the RTC alarm signal has no wake up effect. */ -#define SUPC_WUMR_RTCEN_ENABLE (0x1 << 3) /**< \brief (SUPC_WUMR) the RTC alarm signal forces the wake up of the core power supply. */ -#define SUPC_WUMR_WKUPDBC (0x7 << 12) /**< \brief (SUPC_WUMR) Wake Up Inputs Debouncer */ -#define SUPC_WUMR_WKUPDBC_1SCLK (0x0 << 12) /**< \brief (SUPC_WUMR) Immediate, no debouncing, detected active at least on one Slow Clock edge. */ -#define SUPC_WUMR_WKUPDBC_3SCLK (0x1 << 12) /**< \brief (SUPC_WUMR) An enabled wake-up input shall be active for at least 3 SLCK periods */ -#define SUPC_WUMR_WKUPDBC_32SCLK (0x2 << 12) /**< \brief (SUPC_WUMR) An enabled wake-up input shall be active for at least 32 SLCK periods */ -#define SUPC_WUMR_WKUPDBC_512SCLK (0x3 << 12) /**< \brief (SUPC_WUMR) An enabled wake-up input shall be active for at least 512 SLCK periods */ -#define SUPC_WUMR_WKUPDBC_4096SCLK (0x4 << 12) /**< \brief (SUPC_WUMR) An enabled wake-up input shall be active for at least 4,096 SLCK periods */ -#define SUPC_WUMR_WKUPDBC_32768SCLK (0x5 << 12) /**< \brief (SUPC_WUMR) An enabled wake-up input shall be active for at least 32,768 SLCK periods */ -/* -------- SUPC_WUIR : (SUPC Offset: 0x10) Supply Controller Wake Up Inputs Register -------- */ -#define SUPC_WUIR_WKUPEN0 (0x1 << 0) /**< \brief (SUPC_WUIR) Wake Up Input Enable 0 */ -#define SUPC_WUIR_WKUPEN0_NOT_ENABLE (0x0 << 0) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN0_ENABLE (0x1 << 0) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN1 (0x1 << 1) /**< \brief (SUPC_WUIR) Wake Up Input Enable 1 */ -#define SUPC_WUIR_WKUPEN1_NOT_ENABLE (0x0 << 1) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN1_ENABLE (0x1 << 1) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN2 (0x1 << 2) /**< \brief (SUPC_WUIR) Wake Up Input Enable 2 */ -#define SUPC_WUIR_WKUPEN2_NOT_ENABLE (0x0 << 2) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN2_ENABLE (0x1 << 2) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN3 (0x1 << 3) /**< \brief (SUPC_WUIR) Wake Up Input Enable 3 */ -#define SUPC_WUIR_WKUPEN3_NOT_ENABLE (0x0 << 3) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN3_ENABLE (0x1 << 3) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN4 (0x1 << 4) /**< \brief (SUPC_WUIR) Wake Up Input Enable 4 */ -#define SUPC_WUIR_WKUPEN4_NOT_ENABLE (0x0 << 4) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN4_ENABLE (0x1 << 4) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN5 (0x1 << 5) /**< \brief (SUPC_WUIR) Wake Up Input Enable 5 */ -#define SUPC_WUIR_WKUPEN5_NOT_ENABLE (0x0 << 5) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN5_ENABLE (0x1 << 5) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN6 (0x1 << 6) /**< \brief (SUPC_WUIR) Wake Up Input Enable 6 */ -#define SUPC_WUIR_WKUPEN6_NOT_ENABLE (0x0 << 6) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN6_ENABLE (0x1 << 6) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN7 (0x1 << 7) /**< \brief (SUPC_WUIR) Wake Up Input Enable 7 */ -#define SUPC_WUIR_WKUPEN7_NOT_ENABLE (0x0 << 7) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN7_ENABLE (0x1 << 7) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN8 (0x1 << 8) /**< \brief (SUPC_WUIR) Wake Up Input Enable 8 */ -#define SUPC_WUIR_WKUPEN8_NOT_ENABLE (0x0 << 8) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN8_ENABLE (0x1 << 8) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN9 (0x1 << 9) /**< \brief (SUPC_WUIR) Wake Up Input Enable 9 */ -#define SUPC_WUIR_WKUPEN9_NOT_ENABLE (0x0 << 9) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN9_ENABLE (0x1 << 9) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN10 (0x1 << 10) /**< \brief (SUPC_WUIR) Wake Up Input Enable 10 */ -#define SUPC_WUIR_WKUPEN10_NOT_ENABLE (0x0 << 10) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN10_ENABLE (0x1 << 10) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN11 (0x1 << 11) /**< \brief (SUPC_WUIR) Wake Up Input Enable 11 */ -#define SUPC_WUIR_WKUPEN11_NOT_ENABLE (0x0 << 11) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN11_ENABLE (0x1 << 11) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN12 (0x1 << 12) /**< \brief (SUPC_WUIR) Wake Up Input Enable 12 */ -#define SUPC_WUIR_WKUPEN12_NOT_ENABLE (0x0 << 12) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN12_ENABLE (0x1 << 12) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN13 (0x1 << 13) /**< \brief (SUPC_WUIR) Wake Up Input Enable 13 */ -#define SUPC_WUIR_WKUPEN13_NOT_ENABLE (0x0 << 13) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN13_ENABLE (0x1 << 13) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN14 (0x1 << 14) /**< \brief (SUPC_WUIR) Wake Up Input Enable 14 */ -#define SUPC_WUIR_WKUPEN14_NOT_ENABLE (0x0 << 14) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN14_ENABLE (0x1 << 14) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPEN15 (0x1 << 15) /**< \brief (SUPC_WUIR) Wake Up Input Enable 15 */ -#define SUPC_WUIR_WKUPEN15_NOT_ENABLE (0x0 << 15) /**< \brief (SUPC_WUIR) the corresponding wake-up input has no wake up effect. */ -#define SUPC_WUIR_WKUPEN15_ENABLE (0x1 << 15) /**< \brief (SUPC_WUIR) the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT0 (0x1 << 16) /**< \brief (SUPC_WUIR) Wake Up Input Transition 0 */ -#define SUPC_WUIR_WKUPT0_HIGH_TO_LOW (0x0 << 16) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT0_LOW_TO_HIGH (0x1 << 16) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT1 (0x1 << 17) /**< \brief (SUPC_WUIR) Wake Up Input Transition 1 */ -#define SUPC_WUIR_WKUPT1_HIGH_TO_LOW (0x0 << 17) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT1_LOW_TO_HIGH (0x1 << 17) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT2 (0x1 << 18) /**< \brief (SUPC_WUIR) Wake Up Input Transition 2 */ -#define SUPC_WUIR_WKUPT2_HIGH_TO_LOW (0x0 << 18) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT2_LOW_TO_HIGH (0x1 << 18) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT3 (0x1 << 19) /**< \brief (SUPC_WUIR) Wake Up Input Transition 3 */ -#define SUPC_WUIR_WKUPT3_HIGH_TO_LOW (0x0 << 19) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT3_LOW_TO_HIGH (0x1 << 19) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT4 (0x1 << 20) /**< \brief (SUPC_WUIR) Wake Up Input Transition 4 */ -#define SUPC_WUIR_WKUPT4_HIGH_TO_LOW (0x0 << 20) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT4_LOW_TO_HIGH (0x1 << 20) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT5 (0x1 << 21) /**< \brief (SUPC_WUIR) Wake Up Input Transition 5 */ -#define SUPC_WUIR_WKUPT5_HIGH_TO_LOW (0x0 << 21) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT5_LOW_TO_HIGH (0x1 << 21) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT6 (0x1 << 22) /**< \brief (SUPC_WUIR) Wake Up Input Transition 6 */ -#define SUPC_WUIR_WKUPT6_HIGH_TO_LOW (0x0 << 22) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT6_LOW_TO_HIGH (0x1 << 22) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT7 (0x1 << 23) /**< \brief (SUPC_WUIR) Wake Up Input Transition 7 */ -#define SUPC_WUIR_WKUPT7_HIGH_TO_LOW (0x0 << 23) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT7_LOW_TO_HIGH (0x1 << 23) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT8 (0x1 << 24) /**< \brief (SUPC_WUIR) Wake Up Input Transition 8 */ -#define SUPC_WUIR_WKUPT8_HIGH_TO_LOW (0x0 << 24) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT8_LOW_TO_HIGH (0x1 << 24) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT9 (0x1 << 25) /**< \brief (SUPC_WUIR) Wake Up Input Transition 9 */ -#define SUPC_WUIR_WKUPT9_HIGH_TO_LOW (0x0 << 25) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT9_LOW_TO_HIGH (0x1 << 25) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT10 (0x1 << 26) /**< \brief (SUPC_WUIR) Wake Up Input Transition 10 */ -#define SUPC_WUIR_WKUPT10_HIGH_TO_LOW (0x0 << 26) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT10_LOW_TO_HIGH (0x1 << 26) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT11 (0x1 << 27) /**< \brief (SUPC_WUIR) Wake Up Input Transition 11 */ -#define SUPC_WUIR_WKUPT11_HIGH_TO_LOW (0x0 << 27) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT11_LOW_TO_HIGH (0x1 << 27) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT12 (0x1 << 28) /**< \brief (SUPC_WUIR) Wake Up Input Transition 12 */ -#define SUPC_WUIR_WKUPT12_HIGH_TO_LOW (0x0 << 28) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT12_LOW_TO_HIGH (0x1 << 28) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT13 (0x1 << 29) /**< \brief (SUPC_WUIR) Wake Up Input Transition 13 */ -#define SUPC_WUIR_WKUPT13_HIGH_TO_LOW (0x0 << 29) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT13_LOW_TO_HIGH (0x1 << 29) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT14 (0x1 << 30) /**< \brief (SUPC_WUIR) Wake Up Input Transition 14 */ -#define SUPC_WUIR_WKUPT14_HIGH_TO_LOW (0x0 << 30) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT14_LOW_TO_HIGH (0x1 << 30) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT15 (0x1 << 31) /**< \brief (SUPC_WUIR) Wake Up Input Transition 15 */ -#define SUPC_WUIR_WKUPT15_HIGH_TO_LOW (0x0 << 31) /**< \brief (SUPC_WUIR) a high to low level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -#define SUPC_WUIR_WKUPT15_LOW_TO_HIGH (0x1 << 31) /**< \brief (SUPC_WUIR) a low to high level transition on the corresponding wake-up input forces the wake up of the core power supply. */ -/* -------- SUPC_SR : (SUPC Offset: 0x14) Supply Controller Status Register -------- */ -#define SUPC_SR_WKUPS (0x1 << 1) /**< \brief (SUPC_SR) WKUP Wake Up Status */ -#define SUPC_SR_WKUPS_NO (0x0 << 1) /**< \brief (SUPC_SR) no wake up due to the assertion of the WKUP pins has occurred since the last read of SUPC_SR. */ -#define SUPC_SR_WKUPS_PRESENT (0x1 << 1) /**< \brief (SUPC_SR) at least one wake up due to the assertion of the WKUP pins has occurred since the last read of SUPC_SR. */ -#define SUPC_SR_SMWS (0x1 << 2) /**< \brief (SUPC_SR) Supply Monitor Detection Wake Up Status */ -#define SUPC_SR_SMWS_NO (0x0 << 2) /**< \brief (SUPC_SR) no wake up due to a supply monitor detection has occurred since the last read of SUPC_SR. */ -#define SUPC_SR_SMWS_PRESENT (0x1 << 2) /**< \brief (SUPC_SR) at least one wake up due to a supply monitor detection has occurred since the last read of SUPC_SR. */ -#define SUPC_SR_BODRSTS (0x1 << 3) /**< \brief (SUPC_SR) Brownout Detector Reset Status */ -#define SUPC_SR_BODRSTS_NO (0x0 << 3) /**< \brief (SUPC_SR) no core brownout rising edge event has been detected since the last read of the SUPC_SR. */ -#define SUPC_SR_BODRSTS_PRESENT (0x1 << 3) /**< \brief (SUPC_SR) at least one brownout output rising edge event has been detected since the last read of the SUPC_SR. */ -#define SUPC_SR_SMRSTS (0x1 << 4) /**< \brief (SUPC_SR) Supply Monitor Reset Status */ -#define SUPC_SR_SMRSTS_NO (0x0 << 4) /**< \brief (SUPC_SR) no supply monitor detection has generated a core reset since the last read of the SUPC_SR. */ -#define SUPC_SR_SMRSTS_PRESENT (0x1 << 4) /**< \brief (SUPC_SR) at least one supply monitor detection has generated a core reset since the last read of the SUPC_SR. */ -#define SUPC_SR_SMS (0x1 << 5) /**< \brief (SUPC_SR) Supply Monitor Status */ -#define SUPC_SR_SMS_NO (0x0 << 5) /**< \brief (SUPC_SR) no supply monitor detection since the last read of SUPC_SR. */ -#define SUPC_SR_SMS_PRESENT (0x1 << 5) /**< \brief (SUPC_SR) at least one supply monitor detection since the last read of SUPC_SR. */ -#define SUPC_SR_SMOS (0x1 << 6) /**< \brief (SUPC_SR) Supply Monitor Output Status */ -#define SUPC_SR_SMOS_HIGH (0x0 << 6) /**< \brief (SUPC_SR) the supply monitor detected VDDIO higher than its threshold at its last measurement. */ -#define SUPC_SR_SMOS_LOW (0x1 << 6) /**< \brief (SUPC_SR) the supply monitor detected VDDIO lower than its threshold at its last measurement. */ -#define SUPC_SR_OSCSEL (0x1 << 7) /**< \brief (SUPC_SR) 32-kHz Oscillator Selection Status */ -#define SUPC_SR_OSCSEL_RC (0x0 << 7) /**< \brief (SUPC_SR) the slow clock, SLCK is generated by the embedded 32-kHz RC oscillator. */ -#define SUPC_SR_OSCSEL_CRYST (0x1 << 7) /**< \brief (SUPC_SR) the slow clock, SLCK is generated by the 32-kHz crystal oscillator. */ -#define SUPC_SR_WKUPIS0 (0x1 << 16) /**< \brief (SUPC_SR) WKUP Input Status 0 */ -#define SUPC_SR_WKUPIS0_DIS (0x0 << 16) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS0_EN (0x1 << 16) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS1 (0x1 << 17) /**< \brief (SUPC_SR) WKUP Input Status 1 */ -#define SUPC_SR_WKUPIS1_DIS (0x0 << 17) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS1_EN (0x1 << 17) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS2 (0x1 << 18) /**< \brief (SUPC_SR) WKUP Input Status 2 */ -#define SUPC_SR_WKUPIS2_DIS (0x0 << 18) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS2_EN (0x1 << 18) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS3 (0x1 << 19) /**< \brief (SUPC_SR) WKUP Input Status 3 */ -#define SUPC_SR_WKUPIS3_DIS (0x0 << 19) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS3_EN (0x1 << 19) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS4 (0x1 << 20) /**< \brief (SUPC_SR) WKUP Input Status 4 */ -#define SUPC_SR_WKUPIS4_DIS (0x0 << 20) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS4_EN (0x1 << 20) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS5 (0x1 << 21) /**< \brief (SUPC_SR) WKUP Input Status 5 */ -#define SUPC_SR_WKUPIS5_DIS (0x0 << 21) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS5_EN (0x1 << 21) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS6 (0x1 << 22) /**< \brief (SUPC_SR) WKUP Input Status 6 */ -#define SUPC_SR_WKUPIS6_DIS (0x0 << 22) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS6_EN (0x1 << 22) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS7 (0x1 << 23) /**< \brief (SUPC_SR) WKUP Input Status 7 */ -#define SUPC_SR_WKUPIS7_DIS (0x0 << 23) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS7_EN (0x1 << 23) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS8 (0x1 << 24) /**< \brief (SUPC_SR) WKUP Input Status 8 */ -#define SUPC_SR_WKUPIS8_DIS (0x0 << 24) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS8_EN (0x1 << 24) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS9 (0x1 << 25) /**< \brief (SUPC_SR) WKUP Input Status 9 */ -#define SUPC_SR_WKUPIS9_DIS (0x0 << 25) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS9_EN (0x1 << 25) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS10 (0x1 << 26) /**< \brief (SUPC_SR) WKUP Input Status 10 */ -#define SUPC_SR_WKUPIS10_DIS (0x0 << 26) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS10_EN (0x1 << 26) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS11 (0x1 << 27) /**< \brief (SUPC_SR) WKUP Input Status 11 */ -#define SUPC_SR_WKUPIS11_DIS (0x0 << 27) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS11_EN (0x1 << 27) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS12 (0x1 << 28) /**< \brief (SUPC_SR) WKUP Input Status 12 */ -#define SUPC_SR_WKUPIS12_DIS (0x0 << 28) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS12_EN (0x1 << 28) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS13 (0x1 << 29) /**< \brief (SUPC_SR) WKUP Input Status 13 */ -#define SUPC_SR_WKUPIS13_DIS (0x0 << 29) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS13_EN (0x1 << 29) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS14 (0x1 << 30) /**< \brief (SUPC_SR) WKUP Input Status 14 */ -#define SUPC_SR_WKUPIS14_DIS (0x0 << 30) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS14_EN (0x1 << 30) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS15 (0x1 << 31) /**< \brief (SUPC_SR) WKUP Input Status 15 */ -#define SUPC_SR_WKUPIS15_DIS (0x0 << 31) /**< \brief (SUPC_SR) the corresponding wake-up input is disabled, or was inactive at the time the debouncer triggered a wake up event. */ -#define SUPC_SR_WKUPIS15_EN (0x1 << 31) /**< \brief (SUPC_SR) the corresponding wake-up input was active at the time the debouncer triggered a wake up event. */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Timer Counter */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_TC Timer Counter */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief TcChannel hardware registers */ -typedef struct { - RwReg TC_CCR; /**< \brief (TcChannel Offset: 0x0) Channel Control Register */ - RwReg TC_CMR; /**< \brief (TcChannel Offset: 0x4) Channel Mode Register */ - RwReg Reserved1[2]; - RwReg TC_CV; /**< \brief (TcChannel Offset: 0x10) Counter Value */ - RwReg TC_RA; /**< \brief (TcChannel Offset: 0x14) Register A */ - RwReg TC_RB; /**< \brief (TcChannel Offset: 0x18) Register B */ - RwReg TC_RC; /**< \brief (TcChannel Offset: 0x1C) Register C */ - RwReg TC_SR; /**< \brief (TcChannel Offset: 0x20) Status Register */ - RwReg TC_IER; /**< \brief (TcChannel Offset: 0x24) Interrupt Enable Register */ - RwReg TC_IDR; /**< \brief (TcChannel Offset: 0x28) Interrupt Disable Register */ - RwReg TC_IMR; /**< \brief (TcChannel Offset: 0x2C) Interrupt Mask Register */ - RwReg Reserved2[4]; -} TcChannel; -/** \brief Tc hardware registers */ -typedef struct { - TcChannel TC_CHANNEL[3]; /**< \brief (Tc Offset: 0x0) channel = 0 .. 2 */ - WoReg TC_BCR; /**< \brief (Tc Offset: 0xC0) Block Control Register */ - RwReg TC_BMR; /**< \brief (Tc Offset: 0xC4) Block Mode Register */ - WoReg TC_QIER; /**< \brief (Tc Offset: 0xC8) QDEC Interrupt Enable Register */ - WoReg TC_QIDR; /**< \brief (Tc Offset: 0xCC) QDEC Interrupt Disable Register */ - RoReg TC_QIMR; /**< \brief (Tc Offset: 0xD0) QDEC Interrupt Mask Register */ - RoReg TC_QISR; /**< \brief (Tc Offset: 0xD4) QDEC Interrupt Status Register */ - RwReg TC_FMR; /**< \brief (Tc Offset: 0xD8) Fault Mode Register */ - RwReg Reserved1[2]; - RwReg TC_WPMR; /**< \brief (Tc Offset: 0xE4) Write Protect Mode Register */ - RwReg Reserved2[5]; - RoReg TC_VER; /**< \brief (Tc Offset: 0xFC) Version Register */ -} Tc; -#endif /* __ASSEMBLY__ */ -/* -------- TC_CCR0 : (TC Offset: 0x0) Channel Control Register (channel = 0) -------- */ -#define TC_CCR0_CLKEN (0x1 << 0) /**< \brief (TC_CCR0) Counter Clock Enable Command */ -#define TC_CCR0_CLKDIS (0x1 << 1) /**< \brief (TC_CCR0) Counter Clock Disable Command */ -#define TC_CCR0_SWTRG (0x1 << 2) /**< \brief (TC_CCR0) Software Trigger Command */ -/* -------- TC_CMR0 : (TC Offset: 0x4) Channel Mode Register (channel = 0) -------- */ -#define TC_CMR0_TCCLKS (0x7 << 0) /**< \brief (TC_CMR0) Clock Selection */ -#define TC_CM0_TCCLKS_TIMER_DIV1_CLOCK (0x0 << 0) /**< (TC_CMR0) Clock selected: TIMER_DIV1_CLOCK*/ -#define TC_CM0_TCCLKS_TIMER_DIV2_CLOCK (0x1 << 0) /**< (TC_CMR0) Clock selected: TIMER_DIV2_CLOCK*/ -#define TC_CM0_TCCLKS_TIMER_DIV3_CLOCK (0x2 << 0) /**< (TC_CMR0) Clock selected: TIMER_DIV3_CLOCK*/ -#define TC_CM0_TCCLKS_TIMER_DIV4_CLOCK (0x3 << 0) /**< (TC_CMR0) Clock selected: TIMER_DIV4_CLOCK*/ -#define TC_CM0_TCCLKS_TIMER_DIV5_CLOCK (0x4 << 0) /**< (TC_CMR0) Clock selected: TIMER_DIV5_CLOCK*/ -#define TC_CM0_TCCLKS_XC0 (0x5 << 0) /**< (TC_CMR0) Clock selected: XC0*/ -#define TC_CM0_TCCLKS_XC1 (0x6 << 0) /**< (TC_CMR0) Clock selected: XC1*/ -#define TC_CM0_TCCLKS_XC2 (0x7 << 0) /**< (TC_CMR0) Clock selected: XC2*/ -#define TC_CMR0_CLKI (0x1 << 3) /**< \brief (TC_CMR0) Clock Invert */ -#define TC_CMR0_BURST (0x3 << 4) /**< \brief (TC_CMR0) Burst Signal Selection */ -#define TC_CMR0_BURST_NONE (0x0 << 4) /**< \brief (TC_CMR0) The clock is not gated by an external signal. */ -#define TC_CMR0_BURST_XC0 (0x1 << 4) /**< \brief (TC_CMR0) XC0 is ANDed with the selected clock. */ -#define TC_CMR0_BURST_XC1 (0x2 << 4) /**< \brief (TC_CMR0) XC1 is ANDed with the selected clock. */ -#define TC_CMR0_BURST_XC2 (0x3 << 4) /**< \brief (TC_CMR0) XC2 is ANDed with the selected clock. */ -#define TC_CMR0_LDBSTOP (0x1 << 6) /**< \brief (TC_CMR0) Counter Clock Stopped with RB Loading */ -#define TC_CMR0_LDBDIS (0x1 << 7) /**< \brief (TC_CMR0) Counter Clock Disable with RB Loading */ -#define TC_CMR0_ETRGEDG (0x3 << 8) /**< \brief (TC_CMR0) External Trigger Edge Selection */ -#define TC_CMR0_ETRGEDG_NONE (0x0 << 8) /**< \brief (TC_CMR0) none */ -#define TC_CMR0_ETRGEDG_RISING (0x1 << 8) /**< \brief (TC_CMR0) rising edge */ -#define TC_CMR0_ETRGEDG_FALLING (0x2 << 8) /**< \brief (TC_CMR0) falling edge */ -#define TC_CMR0_ETRGEDG_BOTH (0x3 << 8) /**< \brief (TC_CMR0) each edge */ -#define TC_CMR0_ABETRG (0x1 << 10) /**< \brief (TC_CMR0) TIOA or TIOB External Trigger Selection */ -#define TC_CMR0_CPCTRG (0x1 << 14) /**< \brief (TC_CMR0) RC Compare Trigger Enable */ -#define TC_CMR0_WAVE (0x1 << 15) /**< \brief (TC_CMR0) */ -#define TC_CMR0_LDRA (0x3 << 16) /**< \brief (TC_CMR0) RA Loading Selection */ -#define TC_CMR0_LDRA_NONE (0x0 << 16) /**< \brief (TC_CMR0) none */ -#define TC_CMR0_LDRA_RISING (0x1 << 16) /**< \brief (TC_CMR0) rising edge of TIOA */ -#define TC_CMR0_LDRA_FALLING (0x2 << 16) /**< \brief (TC_CMR0) falling edge of TIOA */ -#define TC_CMR0_LDRA_BOTH (0x3 << 16) /**< \brief (TC_CMR0) each edge of TIOA */ -#define TC_CMR0_LDRB (0x3 << 18) /**< \brief (TC_CMR0) RB Loading Selection */ -#define TC_CMR0_LDRB_NONE (0x0 << 18) /**< \brief (TC_CMR0) none */ -#define TC_CMR0_LDRB_RISING (0x1 << 18) /**< \brief (TC_CMR0) rising edge of TIOA */ -#define TC_CMR0_LDRB_FALLING (0x2 << 18) /**< \brief (TC_CMR0) falling edge of TIOA */ -#define TC_CMR0_LDRB_BOTH (0x3 << 18) /**< \brief (TC_CMR0) each edge of TIOA */ - -#define TC_CMR0_ACPA_NONE (0x0 << 16) // (TC) Effect: none -#define TC_CMR0_ACPA_SET (0x1 << 16) // (TC) Effect: set -#define TC_CMR0_ACPA_CLEAR (0x2 << 16) // (TC) Effect: clear -#define TC_CMR0_ACPA_TOGGLE (0x3 << 16) // (TC) Effect: toggle - -#define TC_CMR0_ACPC_NONE (0x0 << 18) // (TC) Effect: none -#define TC_CMR0_ACPC_SET (0x1 << 18) // (TC) Effect: set -#define TC_CMR0_ACPC_CLEAR (0x2 << 18) // (TC) Effect: clear -#define TC_CMR0_ACPC_TOGGLE (0x3 << 18) // (TC) Effect: toggle -/* -------- TC_CV0 : (TC Offset: 0x10) Counter Value (channel = 0) -------- */ -#define TC_CV0_CV (0xffff << 0) /**< \brief (TC_CV0) Counter Value */ -/* -------- TC_RA0 : (TC Offset: 0x14) Register A (channel = 0) -------- */ -#define TC_RA0_RA (0xffff << 0) /**< \brief (TC_RA0) Register A */ -/* -------- TC_RB0 : (TC Offset: 0x18) Register B (channel = 0) -------- */ -#define TC_RB0_RB (0xffff << 0) /**< \brief (TC_RB0) Register B */ -/* -------- TC_RC0 : (TC Offset: 0x1C) Register C (channel = 0) -------- */ -#define TC_RC0_RC (0xffff << 0) /**< \brief (TC_RC0) Register C */ -/* -------- TC_SR0 : (TC Offset: 0x20) Status Register (channel = 0) -------- */ -#define TC_SR0_COVFS (0x1 << 0) /**< \brief (TC_SR0) Counter Overflow Status */ -#define TC_SR0_LOVRS (0x1 << 1) /**< \brief (TC_SR0) Load Overrun Status */ -#define TC_SR0_CPAS (0x1 << 2) /**< \brief (TC_SR0) RA Compare Status */ -#define TC_SR0_CPBS (0x1 << 3) /**< \brief (TC_SR0) RB Compare Status */ -#define TC_SR0_CPCS (0x1 << 4) /**< \brief (TC_SR0) RC Compare Status */ -#define TC_SR0_LDRAS (0x1 << 5) /**< \brief (TC_SR0) RA Loading Status */ -#define TC_SR0_LDRBS (0x1 << 6) /**< \brief (TC_SR0) RB Loading Status */ -#define TC_SR0_ETRGS (0x1 << 7) /**< \brief (TC_SR0) External Trigger Status */ -#define TC_SR0_CLKSTA (0x1 << 16) /**< \brief (TC_SR0) Clock Enabling Status */ -#define TC_SR0_MTIOA (0x1 << 17) /**< \brief (TC_SR0) TIOA Mirror */ -#define TC_SR0_MTIOB (0x1 << 18) /**< \brief (TC_SR0) TIOB Mirror */ -/* -------- TC_IER0 : (TC Offset: 0x24) Interrupt Enable Register (channel = 0) -------- */ -#define TC_IER0_COVFS (0x1 << 0) /**< \brief (TC_IER0) Counter Overflow */ -#define TC_IER0_LOVRS (0x1 << 1) /**< \brief (TC_IER0) Load Overrun */ -#define TC_IER0_CPAS (0x1 << 2) /**< \brief (TC_IER0) RA Compare */ -#define TC_IER0_CPBS (0x1 << 3) /**< \brief (TC_IER0) RB Compare */ -#define TC_IER0_CPCS (0x1 << 4) /**< \brief (TC_IER0) RC Compare */ -#define TC_IER0_LDRAS (0x1 << 5) /**< \brief (TC_IER0) RA Loading */ -#define TC_IER0_LDRBS (0x1 << 6) /**< \brief (TC_IER0) RB Loading */ -#define TC_IER0_ETRGS (0x1 << 7) /**< \brief (TC_IER0) External Trigger */ -/* -------- TC_IDR0 : (TC Offset: 0x28) Interrupt Disable Register (channel = 0) -------- */ -#define TC_IDR0_COVFS (0x1 << 0) /**< \brief (TC_IDR0) Counter Overflow */ -#define TC_IDR0_LOVRS (0x1 << 1) /**< \brief (TC_IDR0) Load Overrun */ -#define TC_IDR0_CPAS (0x1 << 2) /**< \brief (TC_IDR0) RA Compare */ -#define TC_IDR0_CPBS (0x1 << 3) /**< \brief (TC_IDR0) RB Compare */ -#define TC_IDR0_CPCS (0x1 << 4) /**< \brief (TC_IDR0) RC Compare */ -#define TC_IDR0_LDRAS (0x1 << 5) /**< \brief (TC_IDR0) RA Loading */ -#define TC_IDR0_LDRBS (0x1 << 6) /**< \brief (TC_IDR0) RB Loading */ -#define TC_IDR0_ETRGS (0x1 << 7) /**< \brief (TC_IDR0) External Trigger */ -/* -------- TC_IMR0 : (TC Offset: 0x2C) Interrupt Mask Register (channel = 0) -------- */ -#define TC_IMR0_COVFS (0x1 << 0) /**< \brief (TC_IMR0) Counter Overflow */ -#define TC_IMR0_LOVRS (0x1 << 1) /**< \brief (TC_IMR0) Load Overrun */ -#define TC_IMR0_CPAS (0x1 << 2) /**< \brief (TC_IMR0) RA Compare */ -#define TC_IMR0_CPBS (0x1 << 3) /**< \brief (TC_IMR0) RB Compare */ -#define TC_IMR0_CPCS (0x1 << 4) /**< \brief (TC_IMR0) RC Compare */ -#define TC_IMR0_LDRAS (0x1 << 5) /**< \brief (TC_IMR0) RA Loading */ -#define TC_IMR0_LDRBS (0x1 << 6) /**< \brief (TC_IMR0) RB Loading */ -#define TC_IMR0_ETRGS (0x1 << 7) /**< \brief (TC_IMR0) External Trigger */ -/* -------- TC_CCR1 : (TC Offset: 0x40) Channel Control Register (channel = 1) -------- */ -#define TC_CCR1_CLKEN (0x1 << 0) /**< \brief (TC_CCR1) Counter Clock Enable Command */ -#define TC_CCR1_CLKDIS (0x1 << 1) /**< \brief (TC_CCR1) Counter Clock Disable Command */ -#define TC_CCR1_SWTRG (0x1 << 2) /**< \brief (TC_CCR1) Software Trigger Command */ -/* -------- TC_CMR1 : (TC Offset: 0x44) Channel Mode Register (channel = 1) -------- */ -#define TC_CMR1_TCCLKS (0x7 << 0) /**< \brief (TC_CMR1) Clock Selection */ -#define TC_CMR1_CLKI (0x1 << 3) /**< \brief (TC_CMR1) Clock Invert */ -#define TC_CMR1_BURST (0x3 << 4) /**< \brief (TC_CMR1) Burst Signal Selection */ -#define TC_CMR1_BURST_NONE (0x0 << 4) /**< \brief (TC_CMR1) The clock is not gated by an external signal. */ -#define TC_CMR1_BURST_XC0 (0x1 << 4) /**< \brief (TC_CMR1) XC0 is ANDed with the selected clock. */ -#define TC_CMR1_BURST_XC1 (0x2 << 4) /**< \brief (TC_CMR1) XC1 is ANDed with the selected clock. */ -#define TC_CMR1_BURST_XC2 (0x3 << 4) /**< \brief (TC_CMR1) XC2 is ANDed with the selected clock. */ -#define TC_CMR1_LDBSTOP (0x1 << 6) /**< \brief (TC_CMR1) Counter Clock Stopped with RB Loading */ -#define TC_CMR1_LDBDIS (0x1 << 7) /**< \brief (TC_CMR1) Counter Clock Disable with RB Loading */ -#define TC_CMR1_ETRGEDG (0x3 << 8) /**< \brief (TC_CMR1) External Trigger Edge Selection */ -#define TC_CMR1_ETRGEDG_NONE (0x0 << 8) /**< \brief (TC_CMR1) none */ -#define TC_CMR1_ETRGEDG_RISING (0x1 << 8) /**< \brief (TC_CMR1) rising edge */ -#define TC_CMR1_ETRGEDG_FALLING (0x2 << 8) /**< \brief (TC_CMR1) falling edge */ -#define TC_CMR1_ETRGEDG_BOTH (0x3 << 8) /**< \brief (TC_CMR1) each edge */ -#define TC_CMR1_ABETRG (0x1 << 10) /**< \brief (TC_CMR1) TIOA or TIOB External Trigger Selection */ -#define TC_CMR1_CPCTRG (0x1 << 14) /**< \brief (TC_CMR1) RC Compare Trigger Enable */ -#define TC_CMR1_WAVE (0x1 << 15) /**< \brief (TC_CMR1) */ -#define TC_CMR1_LDRA (0x3 << 16) /**< \brief (TC_CMR1) RA Loading Selection */ -#define TC_CMR1_LDRA_NONE (0x0 << 16) /**< \brief (TC_CMR1) none */ -#define TC_CMR1_LDRA_RISING (0x1 << 16) /**< \brief (TC_CMR1) rising edge of TIOA */ -#define TC_CMR1_LDRA_FALLING (0x2 << 16) /**< \brief (TC_CMR1) falling edge of TIOA */ -#define TC_CMR1_LDRA_BOTH (0x3 << 16) /**< \brief (TC_CMR1) each edge of TIOA */ -#define TC_CMR1_LDRB (0x3 << 18) /**< \brief (TC_CMR1) RB Loading Selection */ -#define TC_CMR1_LDRB_NONE (0x0 << 18) /**< \brief (TC_CMR1) none */ -#define TC_CMR1_LDRB_RISING (0x1 << 18) /**< \brief (TC_CMR1) rising edge of TIOA */ -#define TC_CMR1_LDRB_FALLING (0x2 << 18) /**< \brief (TC_CMR1) falling edge of TIOA */ -#define TC_CMR1_LDRB_BOTH (0x3 << 18) /**< \brief (TC_CMR1) each edge of TIOA */ -/* -------- TC_CV1 : (TC Offset: 0x50) Counter Value (channel = 1) -------- */ -#define TC_CV1_CV (0xffff << 0) /**< \brief (TC_CV1) Counter Value */ -/* -------- TC_RA1 : (TC Offset: 0x54) Register A (channel = 1) -------- */ -#define TC_RA1_RA (0xffff << 0) /**< \brief (TC_RA1) Register A */ -/* -------- TC_RB1 : (TC Offset: 0x58) Register B (channel = 1) -------- */ -#define TC_RB1_RB (0xffff << 0) /**< \brief (TC_RB1) Register B */ -/* -------- TC_RC1 : (TC Offset: 0x5C) Register C (channel = 1) -------- */ -#define TC_RC1_RC (0xffff << 0) /**< \brief (TC_RC1) Register C */ -/* -------- TC_SR1 : (TC Offset: 0x60) Status Register (channel = 1) -------- */ -#define TC_SR1_COVFS (0x1 << 0) /**< \brief (TC_SR1) Counter Overflow Status */ -#define TC_SR1_LOVRS (0x1 << 1) /**< \brief (TC_SR1) Load Overrun Status */ -#define TC_SR1_CPAS (0x1 << 2) /**< \brief (TC_SR1) RA Compare Status */ -#define TC_SR1_CPBS (0x1 << 3) /**< \brief (TC_SR1) RB Compare Status */ -#define TC_SR1_CPCS (0x1 << 4) /**< \brief (TC_SR1) RC Compare Status */ -#define TC_SR1_LDRAS (0x1 << 5) /**< \brief (TC_SR1) RA Loading Status */ -#define TC_SR1_LDRBS (0x1 << 6) /**< \brief (TC_SR1) RB Loading Status */ -#define TC_SR1_ETRGS (0x1 << 7) /**< \brief (TC_SR1) External Trigger Status */ -#define TC_SR1_CLKSTA (0x1 << 16) /**< \brief (TC_SR1) Clock Enabling Status */ -#define TC_SR1_MTIOA (0x1 << 17) /**< \brief (TC_SR1) TIOA Mirror */ -#define TC_SR1_MTIOB (0x1 << 18) /**< \brief (TC_SR1) TIOB Mirror */ -/* -------- TC_IER1 : (TC Offset: 0x64) Interrupt Enable Register (channel = 1) -------- */ -#define TC_IER1_COVFS (0x1 << 0) /**< \brief (TC_IER1) Counter Overflow */ -#define TC_IER1_LOVRS (0x1 << 1) /**< \brief (TC_IER1) Load Overrun */ -#define TC_IER1_CPAS (0x1 << 2) /**< \brief (TC_IER1) RA Compare */ -#define TC_IER1_CPBS (0x1 << 3) /**< \brief (TC_IER1) RB Compare */ -#define TC_IER1_CPCS (0x1 << 4) /**< \brief (TC_IER1) RC Compare */ -#define TC_IER1_LDRAS (0x1 << 5) /**< \brief (TC_IER1) RA Loading */ -#define TC_IER1_LDRBS (0x1 << 6) /**< \brief (TC_IER1) RB Loading */ -#define TC_IER1_ETRGS (0x1 << 7) /**< \brief (TC_IER1) External Trigger */ -/* -------- TC_IDR1 : (TC Offset: 0x68) Interrupt Disable Register (channel = 1) -------- */ -#define TC_IDR1_COVFS (0x1 << 0) /**< \brief (TC_IDR1) Counter Overflow */ -#define TC_IDR1_LOVRS (0x1 << 1) /**< \brief (TC_IDR1) Load Overrun */ -#define TC_IDR1_CPAS (0x1 << 2) /**< \brief (TC_IDR1) RA Compare */ -#define TC_IDR1_CPBS (0x1 << 3) /**< \brief (TC_IDR1) RB Compare */ -#define TC_IDR1_CPCS (0x1 << 4) /**< \brief (TC_IDR1) RC Compare */ -#define TC_IDR1_LDRAS (0x1 << 5) /**< \brief (TC_IDR1) RA Loading */ -#define TC_IDR1_LDRBS (0x1 << 6) /**< \brief (TC_IDR1) RB Loading */ -#define TC_IDR1_ETRGS (0x1 << 7) /**< \brief (TC_IDR1) External Trigger */ -/* -------- TC_IMR1 : (TC Offset: 0x6C) Interrupt Mask Register (channel = 1) -------- */ -#define TC_IMR1_COVFS (0x1 << 0) /**< \brief (TC_IMR1) Counter Overflow */ -#define TC_IMR1_LOVRS (0x1 << 1) /**< \brief (TC_IMR1) Load Overrun */ -#define TC_IMR1_CPAS (0x1 << 2) /**< \brief (TC_IMR1) RA Compare */ -#define TC_IMR1_CPBS (0x1 << 3) /**< \brief (TC_IMR1) RB Compare */ -#define TC_IMR1_CPCS (0x1 << 4) /**< \brief (TC_IMR1) RC Compare */ -#define TC_IMR1_LDRAS (0x1 << 5) /**< \brief (TC_IMR1) RA Loading */ -#define TC_IMR1_LDRBS (0x1 << 6) /**< \brief (TC_IMR1) RB Loading */ -#define TC_IMR1_ETRGS (0x1 << 7) /**< \brief (TC_IMR1) External Trigger */ -/* -------- TC_CCR2 : (TC Offset: 0x80) Channel Control Register (channel = 2) -------- */ -#define TC_CCR2_CLKEN (0x1 << 0) /**< \brief (TC_CCR2) Counter Clock Enable Command */ -#define TC_CCR2_CLKDIS (0x1 << 1) /**< \brief (TC_CCR2) Counter Clock Disable Command */ -#define TC_CCR2_SWTRG (0x1 << 2) /**< \brief (TC_CCR2) Software Trigger Command */ -/* -------- TC_CMR2 : (TC Offset: 0x84) Channel Mode Register (channel = 2) -------- */ -#define TC_CMR2_TCCLKS (0x7 << 0) /**< \brief (TC_CMR2) Clock Selection */ -#define TC_CMR2_CLKI (0x1 << 3) /**< \brief (TC_CMR2) Clock Invert */ -#define TC_CMR2_BURST (0x3 << 4) /**< \brief (TC_CMR2) Burst Signal Selection */ -#define TC_CMR2_BURST_NONE (0x0 << 4) /**< \brief (TC_CMR2) The clock is not gated by an external signal. */ -#define TC_CMR2_BURST_XC0 (0x1 << 4) /**< \brief (TC_CMR2) XC0 is ANDed with the selected clock. */ -#define TC_CMR2_BURST_XC1 (0x2 << 4) /**< \brief (TC_CMR2) XC1 is ANDed with the selected clock. */ -#define TC_CMR2_BURST_XC2 (0x3 << 4) /**< \brief (TC_CMR2) XC2 is ANDed with the selected clock. */ -#define TC_CMR2_LDBSTOP (0x1 << 6) /**< \brief (TC_CMR2) Counter Clock Stopped with RB Loading */ -#define TC_CMR2_LDBDIS (0x1 << 7) /**< \brief (TC_CMR2) Counter Clock Disable with RB Loading */ -#define TC_CMR2_ETRGEDG (0x3 << 8) /**< \brief (TC_CMR2) External Trigger Edge Selection */ -#define TC_CMR2_ETRGEDG_NONE (0x0 << 8) /**< \brief (TC_CMR2) none */ -#define TC_CMR2_ETRGEDG_RISING (0x1 << 8) /**< \brief (TC_CMR2) rising edge */ -#define TC_CMR2_ETRGEDG_FALLING (0x2 << 8) /**< \brief (TC_CMR2) falling edge */ -#define TC_CMR2_ETRGEDG_BOTH (0x3 << 8) /**< \brief (TC_CMR2) each edge */ -#define TC_CMR2_ABETRG (0x1 << 10) /**< \brief (TC_CMR2) TIOA or TIOB External Trigger Selection */ -#define TC_CMR2_CPCTRG (0x1 << 14) /**< \brief (TC_CMR2) RC Compare Trigger Enable */ -#define TC_CMR2_WAVE (0x1 << 15) /**< \brief (TC_CMR2) */ -#define TC_CMR2_LDRA (0x3 << 16) /**< \brief (TC_CMR2) RA Loading Selection */ -#define TC_CMR2_LDRA_NONE (0x0 << 16) /**< \brief (TC_CMR2) none */ -#define TC_CMR2_LDRA_RISING (0x1 << 16) /**< \brief (TC_CMR2) rising edge of TIOA */ -#define TC_CMR2_LDRA_FALLING (0x2 << 16) /**< \brief (TC_CMR2) falling edge of TIOA */ -#define TC_CMR2_LDRA_BOTH (0x3 << 16) /**< \brief (TC_CMR2) each edge of TIOA */ -#define TC_CMR2_LDRB (0x3 << 18) /**< \brief (TC_CMR2) RB Loading Selection */ -#define TC_CMR2_LDRB_NONE (0x0 << 18) /**< \brief (TC_CMR2) none */ -#define TC_CMR2_LDRB_RISING (0x1 << 18) /**< \brief (TC_CMR2) rising edge of TIOA */ -#define TC_CMR2_LDRB_FALLING (0x2 << 18) /**< \brief (TC_CMR2) falling edge of TIOA */ -#define TC_CMR2_LDRB_BOTH (0x3 << 18) /**< \brief (TC_CMR2) each edge of TIOA */ -/* -------- TC_CV2 : (TC Offset: 0x90) Counter Value (channel = 2) -------- */ -#define TC_CV2_CV (0xffff << 0) /**< \brief (TC_CV2) Counter Value */ -/* -------- TC_RA2 : (TC Offset: 0x94) Register A (channel = 2) -------- */ -#define TC_RA2_RA (0xffff << 0) /**< \brief (TC_RA2) Register A */ -/* -------- TC_RB2 : (TC Offset: 0x98) Register B (channel = 2) -------- */ -#define TC_RB2_RB (0xffff << 0) /**< \brief (TC_RB2) Register B */ -/* -------- TC_RC2 : (TC Offset: 0x9C) Register C (channel = 2) -------- */ -#define TC_RC2_RC (0xffff << 0) /**< \brief (TC_RC2) Register C */ -/* -------- TC_SR2 : (TC Offset: 0xA0) Status Register (channel = 2) -------- */ -#define TC_SR2_COVFS (0x1 << 0) /**< \brief (TC_SR2) Counter Overflow Status */ -#define TC_SR2_LOVRS (0x1 << 1) /**< \brief (TC_SR2) Load Overrun Status */ -#define TC_SR2_CPAS (0x1 << 2) /**< \brief (TC_SR2) RA Compare Status */ -#define TC_SR2_CPBS (0x1 << 3) /**< \brief (TC_SR2) RB Compare Status */ -#define TC_SR2_CPCS (0x1 << 4) /**< \brief (TC_SR2) RC Compare Status */ -#define TC_SR2_LDRAS (0x1 << 5) /**< \brief (TC_SR2) RA Loading Status */ -#define TC_SR2_LDRBS (0x1 << 6) /**< \brief (TC_SR2) RB Loading Status */ -#define TC_SR2_ETRGS (0x1 << 7) /**< \brief (TC_SR2) External Trigger Status */ -#define TC_SR2_CLKSTA (0x1 << 16) /**< \brief (TC_SR2) Clock Enabling Status */ -#define TC_SR2_MTIOA (0x1 << 17) /**< \brief (TC_SR2) TIOA Mirror */ -#define TC_SR2_MTIOB (0x1 << 18) /**< \brief (TC_SR2) TIOB Mirror */ -/* -------- TC_IER2 : (TC Offset: 0xA4) Interrupt Enable Register (channel = 2) -------- */ -#define TC_IER2_COVFS (0x1 << 0) /**< \brief (TC_IER2) Counter Overflow */ -#define TC_IER2_LOVRS (0x1 << 1) /**< \brief (TC_IER2) Load Overrun */ -#define TC_IER2_CPAS (0x1 << 2) /**< \brief (TC_IER2) RA Compare */ -#define TC_IER2_CPBS (0x1 << 3) /**< \brief (TC_IER2) RB Compare */ -#define TC_IER2_CPCS (0x1 << 4) /**< \brief (TC_IER2) RC Compare */ -#define TC_IER2_LDRAS (0x1 << 5) /**< \brief (TC_IER2) RA Loading */ -#define TC_IER2_LDRBS (0x1 << 6) /**< \brief (TC_IER2) RB Loading */ -#define TC_IER2_ETRGS (0x1 << 7) /**< \brief (TC_IER2) External Trigger */ -/* -------- TC_IDR2 : (TC Offset: 0xA8) Interrupt Disable Register (channel = 2) -------- */ -#define TC_IDR2_COVFS (0x1 << 0) /**< \brief (TC_IDR2) Counter Overflow */ -#define TC_IDR2_LOVRS (0x1 << 1) /**< \brief (TC_IDR2) Load Overrun */ -#define TC_IDR2_CPAS (0x1 << 2) /**< \brief (TC_IDR2) RA Compare */ -#define TC_IDR2_CPBS (0x1 << 3) /**< \brief (TC_IDR2) RB Compare */ -#define TC_IDR2_CPCS (0x1 << 4) /**< \brief (TC_IDR2) RC Compare */ -#define TC_IDR2_LDRAS (0x1 << 5) /**< \brief (TC_IDR2) RA Loading */ -#define TC_IDR2_LDRBS (0x1 << 6) /**< \brief (TC_IDR2) RB Loading */ -#define TC_IDR2_ETRGS (0x1 << 7) /**< \brief (TC_IDR2) External Trigger */ -/* -------- TC_IMR2 : (TC Offset: 0xAC) Interrupt Mask Register (channel = 2) -------- */ -#define TC_IMR2_COVFS (0x1 << 0) /**< \brief (TC_IMR2) Counter Overflow */ -#define TC_IMR2_LOVRS (0x1 << 1) /**< \brief (TC_IMR2) Load Overrun */ -#define TC_IMR2_CPAS (0x1 << 2) /**< \brief (TC_IMR2) RA Compare */ -#define TC_IMR2_CPBS (0x1 << 3) /**< \brief (TC_IMR2) RB Compare */ -#define TC_IMR2_CPCS (0x1 << 4) /**< \brief (TC_IMR2) RC Compare */ -#define TC_IMR2_LDRAS (0x1 << 5) /**< \brief (TC_IMR2) RA Loading */ -#define TC_IMR2_LDRBS (0x1 << 6) /**< \brief (TC_IMR2) RB Loading */ -#define TC_IMR2_ETRGS (0x1 << 7) /**< \brief (TC_IMR2) External Trigger */ -/* -------- TC_BCR : (TC Offset: 0xC0) Block Control Register -------- */ -#define TC_BCR_SYNC (0x1 << 0) /**< \brief (TC_BCR) Synchro Command */ -/* -------- TC_BMR : (TC Offset: 0xC4) Block Mode Register -------- */ -#define TC_BMR_TC0XC0S (0x3 << 0) /**< \brief (TC_BMR) External Clock Signal 0 Selection */ -#define TC_BMR_TC0XC0S_TCLK0 (0x0 << 0) /**< \brief (TC_BMR) TCLK0 */ -#define TC_BMR_TC0XC0S_NONE (0x1 << 0) /**< \brief (TC_BMR) none */ -#define TC_BMR_TC0XC0S_TIOA1 (0x2 << 0) /**< \brief (TC_BMR) TIOA1 */ -#define TC_BMR_TC0XC0S_TIOA2 (0x3 << 0) /**< \brief (TC_BMR) TIOA2 */ -#define TC_BMR_TC1XC1S (0x3 << 2) /**< \brief (TC_BMR) External Clock Signal 1 Selection */ -#define TC_BMR_TC1XC1S_TCLK1 (0x0 << 2) /**< \brief (TC_BMR) TCLK1 */ -#define TC_BMR_TC1XC1S_NONE (0x1 << 2) /**< \brief (TC_BMR) none */ -#define TC_BMR_TC1XC1S_TIOA0 (0x2 << 2) /**< \brief (TC_BMR) TIOA0 */ -#define TC_BMR_TC1XC1S_TIOA2 (0x3 << 2) /**< \brief (TC_BMR) TIOA2 */ -#define TC_BMR_TC2XC2S (0x3 << 4) /**< \brief (TC_BMR) External Clock Signal 2 Selection */ -#define TC_BMR_TC2XC2S_TCLK2 (0x0 << 4) /**< \brief (TC_BMR) TCLK2 */ -#define TC_BMR_TC2XC2S_NONE (0x1 << 4) /**< \brief (TC_BMR) none */ -#define TC_BMR_TC2XC2S_TIOA0 (0x2 << 4) /**< \brief (TC_BMR) TIOA0 */ -#define TC_BMR_TC2XC2S_TIOA1 (0x3 << 4) /**< \brief (TC_BMR) TIOA1 */ -#define TC_BMR_QDEN (0x1 << 8) /**< \brief (TC_BMR) Quadrature Decoder ENabled */ -#define TC_BMR_POSEN (0x1 << 9) /**< \brief (TC_BMR) POSition ENabled */ -#define TC_BMR_SPEEDEN (0x1 << 10) /**< \brief (TC_BMR) SPEED ENabled */ -#define TC_BMR_QDTRANS (0x1 << 11) /**< \brief (TC_BMR) Quadrature Decoding TRANSparent */ -#define TC_BMR_EDGPHA (0x1 << 12) /**< \brief (TC_BMR) EDGe on PHA count mode */ -#define TC_BMR_INVA (0x1 << 13) /**< \brief (TC_BMR) INVerted phA */ -#define TC_BMR_INVB (0x1 << 14) /**< \brief (TC_BMR) INVerted phB */ -#define TC_BMR_INVIDX (0x1 << 15) /**< \brief (TC_BMR) INVerted InDeX */ -#define TC_BMR_SWAP (0x1 << 16) /**< \brief (TC_BMR) SWAP PHA and PHB */ -#define TC_BMR_IDXPHB (0x1 << 17) /**< \brief (TC_BMR) InDeX pin is PHB pin */ -#define TC_BMR_FILTER (0x1 << 19) /**< \brief (TC_BMR) */ -#define TC_BMR_MAXFILT (0x3f << 20) /**< \brief (TC_BMR) MAXimum FILTer */ -/* -------- TC_QIER : (TC Offset: 0xC8) QDEC Interrupt Enable Register -------- */ -#define TC_QIER_IDX (0x1 << 0) /**< \brief (TC_QIER) InDeX */ -#define TC_QIER_DIRCHG (0x1 << 1) /**< \brief (TC_QIER) DIRection CHanGe */ -#define TC_QIER_QERR (0x1 << 2) /**< \brief (TC_QIER) Quadrature ERRor */ -/* -------- TC_QIDR : (TC Offset: 0xCC) QDEC Interrupt Disable Register -------- */ -#define TC_QIDR_IDX (0x1 << 0) /**< \brief (TC_QIDR) InDeX */ -#define TC_QIDR_DIRCHG (0x1 << 1) /**< \brief (TC_QIDR) DIRection CHanGe */ -#define TC_QIDR_QERR (0x1 << 2) /**< \brief (TC_QIDR) Quadrature ERRor */ -/* -------- TC_QIMR : (TC Offset: 0xD0) QDEC Interrupt Mask Register -------- */ -#define TC_QIMR_IDX (0x1 << 0) /**< \brief (TC_QIMR) InDeX */ -#define TC_QIMR_DIRCHG (0x1 << 1) /**< \brief (TC_QIMR) DIRection CHanGe */ -#define TC_QIMR_QERR (0x1 << 2) /**< \brief (TC_QIMR) Quadrature ERRor */ -/* -------- TC_QISR : (TC Offset: 0xD4) QDEC Interrupt Status Register -------- */ -#define TC_QISR_IDX (0x1 << 0) /**< \brief (TC_QISR) InDeX */ -#define TC_QISR_DIRCHG (0x1 << 1) /**< \brief (TC_QISR) DIRection CHanGe */ -#define TC_QISR_QERR (0x1 << 2) /**< \brief (TC_QISR) Quadrature ERRor */ -#define TC_QISR_DIR (0x1 << 8) /**< \brief (TC_QISR) Direction */ -/* -------- TC_FMR : (TC Offset: 0xD8) Fault Mode Register -------- */ -#define TC_FMR_ENCF0 (0x1 << 0) /**< \brief (TC_FMR) ENable Compare Fault Channel 0 */ -#define TC_FMR_ENCF1 (0x1 << 1) /**< \brief (TC_FMR) ENable Compare Fault Channel 1 */ -/* -------- TC_WPMR : (TC Offset: 0xE4) Write Protect Mode Register -------- */ -#define TC_WPMR_WPEN (0x1 << 0) /**< \brief (TC_WPMR) Write Protect Enable */ -#define TC_WPMR_WPKEY (0xffffff << 8) /**< \brief (TC_WPMR) Write Protect KEY */ -/* -------- TC_VER : (TC Offset: 0xFC) Version Register -------- */ -#define TC_VER_VERSION (0xfff << 0) /**< \brief (TC_VER) */ -#define TC_VER_MFN (0x7 << 16) /**< \brief (TC_VER) */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Two-wire Interface */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_TWI Two-wire Interface */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Twi hardware registers */ -typedef struct { - WoReg TWI_CR; /**< \brief (Twi Offset: 0x00) Control Register */ - RwReg TWI_MMR; /**< \brief (Twi Offset: 0x04) Master Mode Register */ - RwReg TWI_SMR; /**< \brief (Twi Offset: 0x08) Slave Mode Register */ - RwReg TWI_IADR; /**< \brief (Twi Offset: 0x0C) Internal Address Register */ - RwReg TWI_CWGR; /**< \brief (Twi Offset: 0x10) Clock Waveform Generator Register */ - RwReg Reserved1[3]; - RoReg TWI_SR; /**< \brief (Twi Offset: 0x20) Status Register */ - WoReg TWI_IER; /**< \brief (Twi Offset: 0x24) Interrupt Enable Register */ - WoReg TWI_IDR; /**< \brief (Twi Offset: 0x28) Interrupt Disable Register */ - RoReg TWI_IMR; /**< \brief (Twi Offset: 0x2C) Interrupt Mask Register */ - RoReg TWI_RHR; /**< \brief (Twi Offset: 0x30) Receive Holding Register */ - WoReg TWI_THR; /**< \brief (Twi Offset: 0x34) Transmit Holding Register */ - RwReg Reserved2[50]; - RwReg TWI_RPR; /**< \brief (Twi Offset: 0x100) Receive Pointer Register */ - RwReg TWI_RCR; /**< \brief (Twi Offset: 0x104) Receive Counter Register */ - RwReg TWI_TPR; /**< \brief (Twi Offset: 0x108) Transmit Pointer Register */ - RwReg TWI_TCR; /**< \brief (Twi Offset: 0x10C) Transmit Counter Register */ - RwReg TWI_RNPR; /**< \brief (Twi Offset: 0x110) Receive Next Pointer Register */ - RwReg TWI_RNCR; /**< \brief (Twi Offset: 0x114) Receive Next Counter Register */ - RwReg TWI_TNPR; /**< \brief (Twi Offset: 0x118) Transmit Next Pointer Register */ - RwReg TWI_TNCR; /**< \brief (Twi Offset: 0x11C) Transmit Next Counter Register */ - WoReg TWI_PTCR; /**< \brief (Twi Offset: 0x120) Transfer Control Register */ - RoReg TWI_PTSR; /**< \brief (Twi Offset: 0x124) Transfer Status Register */ -} Twi; -#endif /* __ASSEMBLY__ */ -/* -------- TWI_CR : (TWI Offset: 0x00) Control Register -------- */ -#define TWI_CR_START (0x1 << 0) /**< \brief (TWI_CR) Send a START Condition */ -#define TWI_CR_STOP (0x1 << 1) /**< \brief (TWI_CR) Send a STOP Condition */ -#define TWI_CR_MSEN (0x1 << 2) /**< \brief (TWI_CR) TWI Master Mode Enabled */ -#define TWI_CR_MSDIS (0x1 << 3) /**< \brief (TWI_CR) TWI Master Mode Disabled */ -#define TWI_CR_SVEN (0x1 << 4) /**< \brief (TWI_CR) TWI Slave Mode Enabled */ -#define TWI_CR_SVDIS (0x1 << 5) /**< \brief (TWI_CR) TWI Slave Mode Disabled */ -#define TWI_CR_QUICK (0x1 << 6) /**< \brief (TWI_CR) SMBUS Quick Command */ -#define TWI_CR_SWRST (0x1 << 7) /**< \brief (TWI_CR) Software Reset */ -/* -------- TWI_MMR : (TWI Offset: 0x04) Master Mode Register -------- */ -#define TWI_MMR_IADRSZ (0x3 << 8) /**< \brief (TWI_MMR) Internal Device Address Size */ -#define TWI_MMR_IADRSZ_NO (0x0 << 8) /**< \brief (TWI_MMR) No internal device address */ -#define TWI_MMR_IADRSZ_1_BYTE (0x1 << 8) /**< \brief (TWI_MMR) One-byte internal device address */ -#define TWI_MMR_IADRSZ_2_BYTE (0x2 << 8) /**< \brief (TWI_MMR) Two-byte internal device address */ -#define TWI_MMR_IADRSZ_3_BYTE (0x3 << 8) /**< \brief (TWI_MMR) Three-byte internal device address */ -#define TWI_MMR_MREAD (0x1 << 12) /**< \brief (TWI_MMR) Master Read Direction */ -#define TWI_MMR_DADR (0x7f << 16) /**< \brief (TWI_MMR) Device Address */ -/* -------- TWI_SMR : (TWI Offset: 0x08) Slave Mode Register -------- */ -#define TWI_SMR_SADR (0x7f << 16) /**< \brief (TWI_SMR) Slave Address */ -/* -------- TWI_IADR : (TWI Offset: 0x0C) Internal Address Register -------- */ -#define TWI_IADR_IADR (0xffffff << 0) /**< \brief (TWI_IADR) Internal Address */ -/* -------- TWI_CWGR : (TWI Offset: 0x10) Clock Waveform Generator Register -------- */ -#define TWI_CWGR_CLDIV (0xff << 0) /**< \brief (TWI_CWGR) Clock Low Divider */ -#define TWI_CWGR_CHDIV (0xff << 8) /**< \brief (TWI_CWGR) Clock High Divider */ -#define TWI_CWGR_CKDIV (0x7 << 16) /**< \brief (TWI_CWGR) Clock Divider */ -/* -------- TWI_SR : (TWI Offset: 0x20) Status Register -------- */ -#define TWI_SR_TXCOMP (0x1 << 0) /**< \brief (TWI_SR) Transmission Completed (automatically set / reset) */ -#define TWI_SR_RXRDY (0x1 << 1) /**< \brief (TWI_SR) Receive Holding Register Ready (automatically set / reset) */ -#define TWI_SR_TXRDY (0x1 << 2) /**< \brief (TWI_SR) Transmit Holding Register Ready (automatically set / reset) */ -#define TWI_SR_SVREAD (0x1 << 3) /**< \brief (TWI_SR) Slave Read (automatically set / reset) */ -#define TWI_SR_SVACC (0x1 << 4) /**< \brief (TWI_SR) Slave Access (automatically set / reset) */ -#define TWI_SR_GACC (0x1 << 5) /**< \brief (TWI_SR) General Call Access (clear on read) */ -#define TWI_SR_OVRE (0x1 << 6) /**< \brief (TWI_SR) Overrun Error (clear on read) */ -#define TWI_SR_NACK (0x1 << 8) /**< \brief (TWI_SR) Not Acknowledged (clear on read) */ -#define TWI_SR_ARBLST (0x1 << 9) /**< \brief (TWI_SR) Arbitration Lost (clear on read) */ -#define TWI_SR_SCLWS (0x1 << 10) /**< \brief (TWI_SR) Clock Wait State (automatically set / reset) */ -#define TWI_SR_EOSACC (0x1 << 11) /**< \brief (TWI_SR) End Of Slave Access (clear on read) */ -#define TWI_SR_ENDRX (0x1 << 12) /**< \brief (TWI_SR) End of RX buffer */ -#define TWI_SR_ENDTX (0x1 << 13) /**< \brief (TWI_SR) End of TX buffer */ -#define TWI_SR_RXBUFF (0x1 << 14) /**< \brief (TWI_SR) RX Buffer Full */ -#define TWI_SR_TXBUFE (0x1 << 15) /**< \brief (TWI_SR) TX Buffer Empty */ -/* -------- TWI_IER : (TWI Offset: 0x24) Interrupt Enable Register -------- */ -#define TWI_IER_TXCOMP (0x1 << 0) /**< \brief (TWI_IER) Transmission Completed Interrupt Enable */ -#define TWI_IER_RXRDY (0x1 << 1) /**< \brief (TWI_IER) Receive Holding Register Ready Interrupt Enable */ -#define TWI_IER_TXRDY (0x1 << 2) /**< \brief (TWI_IER) Transmit Holding Register Ready Interrupt Enable */ -#define TWI_IER_SVACC (0x1 << 4) /**< \brief (TWI_IER) Slave Access Interrupt Enable */ -#define TWI_IER_GACC (0x1 << 5) /**< \brief (TWI_IER) General Call Access Interrupt Enable */ -#define TWI_IER_OVRE (0x1 << 6) /**< \brief (TWI_IER) Overrun Error Interrupt Enable */ -#define TWI_IER_NACK (0x1 << 8) /**< \brief (TWI_IER) Not Acknowledge Interrupt Enable */ -#define TWI_IER_ARBLST (0x1 << 9) /**< \brief (TWI_IER) Arbitration Lost Interrupt Enable */ -#define TWI_IER_SCL_WS (0x1 << 10) /**< \brief (TWI_IER) Clock Wait State Interrupt Enable */ -#define TWI_IER_EOSACC (0x1 << 11) /**< \brief (TWI_IER) End Of Slave Access Interrupt Enable */ -#define TWI_IER_ENDRX (0x1 << 12) /**< \brief (TWI_IER) End of Receive Buffer Interrupt Enable */ -#define TWI_IER_ENDTX (0x1 << 13) /**< \brief (TWI_IER) End of Transmit Buffer Interrupt Enable */ -#define TWI_IER_RXBUFF (0x1 << 14) /**< \brief (TWI_IER) Receive Buffer Full Interrupt Enable */ -#define TWI_IER_TXBUFE (0x1 << 15) /**< \brief (TWI_IER) Transmit Buffer Empty Interrupt Enable */ -/* -------- TWI_IDR : (TWI Offset: 0x28) Interrupt Disable Register -------- */ -#define TWI_IDR_TXCOMP (0x1 << 0) /**< \brief (TWI_IDR) Transmission Completed Interrupt Disable */ -#define TWI_IDR_RXRDY (0x1 << 1) /**< \brief (TWI_IDR) Receive Holding Register Ready Interrupt Disable */ -#define TWI_IDR_TXRDY (0x1 << 2) /**< \brief (TWI_IDR) Transmit Holding Register Ready Interrupt Disable */ -#define TWI_IDR_SVACC (0x1 << 4) /**< \brief (TWI_IDR) Slave Access Interrupt Disable */ -#define TWI_IDR_GACC (0x1 << 5) /**< \brief (TWI_IDR) General Call Access Interrupt Disable */ -#define TWI_IDR_OVRE (0x1 << 6) /**< \brief (TWI_IDR) Overrun Error Interrupt Disable */ -#define TWI_IDR_NACK (0x1 << 8) /**< \brief (TWI_IDR) Not Acknowledge Interrupt Disable */ -#define TWI_IDR_ARBLST (0x1 << 9) /**< \brief (TWI_IDR) Arbitration Lost Interrupt Disable */ -#define TWI_IDR_SCL_WS (0x1 << 10) /**< \brief (TWI_IDR) Clock Wait State Interrupt Disable */ -#define TWI_IDR_EOSACC (0x1 << 11) /**< \brief (TWI_IDR) End Of Slave Access Interrupt Disable */ -#define TWI_IDR_ENDRX (0x1 << 12) /**< \brief (TWI_IDR) End of Receive Buffer Interrupt Disable */ -#define TWI_IDR_ENDTX (0x1 << 13) /**< \brief (TWI_IDR) End of Transmit Buffer Interrupt Disable */ -#define TWI_IDR_RXBUFF (0x1 << 14) /**< \brief (TWI_IDR) Receive Buffer Full Interrupt Disable */ -#define TWI_IDR_TXBUFE (0x1 << 15) /**< \brief (TWI_IDR) Transmit Buffer Empty Interrupt Disable */ -/* -------- TWI_IMR : (TWI Offset: 0x2C) Interrupt Mask Register -------- */ -#define TWI_IMR_TXCOMP (0x1 << 0) /**< \brief (TWI_IMR) Transmission Completed Interrupt Mask */ -#define TWI_IMR_RXRDY (0x1 << 1) /**< \brief (TWI_IMR) Receive Holding Register Ready Interrupt Mask */ -#define TWI_IMR_TXRDY (0x1 << 2) /**< \brief (TWI_IMR) Transmit Holding Register Ready Interrupt Mask */ -#define TWI_IMR_SVACC (0x1 << 4) /**< \brief (TWI_IMR) Slave Access Interrupt Mask */ -#define TWI_IMR_GACC (0x1 << 5) /**< \brief (TWI_IMR) General Call Access Interrupt Mask */ -#define TWI_IMR_OVRE (0x1 << 6) /**< \brief (TWI_IMR) Overrun Error Interrupt Mask */ -#define TWI_IMR_NACK (0x1 << 8) /**< \brief (TWI_IMR) Not Acknowledge Interrupt Mask */ -#define TWI_IMR_ARBLST (0x1 << 9) /**< \brief (TWI_IMR) Arbitration Lost Interrupt Mask */ -#define TWI_IMR_SCL_WS (0x1 << 10) /**< \brief (TWI_IMR) Clock Wait State Interrupt Mask */ -#define TWI_IMR_EOSACC (0x1 << 11) /**< \brief (TWI_IMR) End Of Slave Access Interrupt Mask */ -#define TWI_IMR_ENDRX (0x1 << 12) /**< \brief (TWI_IMR) End of Receive Buffer Interrupt Mask */ -#define TWI_IMR_ENDTX (0x1 << 13) /**< \brief (TWI_IMR) End of Transmit Buffer Interrupt Mask */ -#define TWI_IMR_RXBUFF (0x1 << 14) /**< \brief (TWI_IMR) Receive Buffer Full Interrupt Mask */ -#define TWI_IMR_TXBUFE (0x1 << 15) /**< \brief (TWI_IMR) Transmit Buffer Empty Interrupt Mask */ -/* -------- TWI_RHR : (TWI Offset: 0x30) Receive Holding Register -------- */ -#define TWI_RHR_RXDATA (0xff << 0) /**< \brief (TWI_RHR) Master or Slave Receive Holding Data */ -/* -------- TWI_THR : (TWI Offset: 0x34) Transmit Holding Register -------- */ -#define TWI_THR_TXDATA (0xff << 0) /**< \brief (TWI_THR) Master or Slave Transmit Holding Data */ -/* -------- TWI_RPR : (TWI Offset: 0x100) Receive Pointer Register -------- */ -#define TWI_RPR_RXPTR (0xffffffff << 0) /**< \brief (TWI_RPR) Receive Pointer Register */ -/* -------- TWI_RCR : (TWI Offset: 0x104) Receive Counter Register -------- */ -#define TWI_RCR_RXCTR (0xffff << 0) /**< \brief (TWI_RCR) Receive Counter Register */ -/* -------- TWI_TPR : (TWI Offset: 0x108) Transmit Pointer Register -------- */ -#define TWI_TPR_TXPTR (0xffffffff << 0) /**< \brief (TWI_TPR) Transmit Counter Register */ -/* -------- TWI_TCR : (TWI Offset: 0x10C) Transmit Counter Register -------- */ -#define TWI_TCR_TXCTR (0xffff << 0) /**< \brief (TWI_TCR) Transmit Counter Register */ -/* -------- TWI_RNPR : (TWI Offset: 0x110) Receive Next Pointer Register -------- */ -#define TWI_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (TWI_RNPR) Receive Next Pointer */ -/* -------- TWI_RNCR : (TWI Offset: 0x114) Receive Next Counter Register -------- */ -#define TWI_RNCR_RXNCTR (0xffff << 0) /**< \brief (TWI_RNCR) Receive Next Counter */ -/* -------- TWI_TNPR : (TWI Offset: 0x118) Transmit Next Pointer Register -------- */ -#define TWI_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (TWI_TNPR) Transmit Next Pointer */ -/* -------- TWI_TNCR : (TWI Offset: 0x11C) Transmit Next Counter Register -------- */ -#define TWI_TNCR_TXNCTR (0xffff << 0) /**< \brief (TWI_TNCR) Transmit Counter Next */ -/* -------- TWI_PTCR : (TWI Offset: 0x120) Transfer Control Register -------- */ -#define TWI_PTCR_RXTEN (0x1 << 0) /**< \brief (TWI_PTCR) Receiver Transfer Enable */ -#define TWI_PTCR_RXTDIS (0x1 << 1) /**< \brief (TWI_PTCR) Receiver Transfer Disable */ -#define TWI_PTCR_TXTEN (0x1 << 8) /**< \brief (TWI_PTCR) Transmitter Transfer Enable */ -#define TWI_PTCR_TXTDIS (0x1 << 9) /**< \brief (TWI_PTCR) Transmitter Transfer Disable */ -/* -------- TWI_PTSR : (TWI Offset: 0x124) Transfer Status Register -------- */ -#define TWI_PTSR_RXTEN (0x1 << 0) /**< \brief (TWI_PTSR) Receiver Transfer Enable */ -#define TWI_PTSR_TXTEN (0x1 << 8) /**< \brief (TWI_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Universal Asynchronous Receiver Transmitter */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_UART Universal Asynchronous Receiver Transmitter */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Uart hardware registers */ -typedef struct { - WoReg UART_CR; /**< \brief (Uart Offset: 0x0000) Control Register */ - RwReg UART_MR; /**< \brief (Uart Offset: 0x0004) Mode Register */ - WoReg UART_IER; /**< \brief (Uart Offset: 0x0008) Interrupt Enable Register */ - WoReg UART_IDR; /**< \brief (Uart Offset: 0x000C) Interrupt Disable Register */ - RoReg UART_IMR; /**< \brief (Uart Offset: 0x0010) Interrupt Mask Register */ - RoReg UART_SR; /**< \brief (Uart Offset: 0x0014) Status Register */ - RoReg UART_RHR; /**< \brief (Uart Offset: 0x0018) Receive Holding Register */ - WoReg UART_THR; /**< \brief (Uart Offset: 0x001C) Transmit Holding Register */ - RwReg UART_BRGR; /**< \brief (Uart Offset: 0x0020) Baud Rate Generator Register */ - RwReg Reserved1[55]; - RwReg UART_RPR; /**< \brief (Uart Offset: 0x100) Receive Pointer Register */ - RwReg UART_RCR; /**< \brief (Uart Offset: 0x104) Receive Counter Register */ - RwReg UART_TPR; /**< \brief (Uart Offset: 0x108) Transmit Pointer Register */ - RwReg UART_TCR; /**< \brief (Uart Offset: 0x10C) Transmit Counter Register */ - RwReg UART_RNPR; /**< \brief (Uart Offset: 0x110) Receive Next Pointer Register */ - RwReg UART_RNCR; /**< \brief (Uart Offset: 0x114) Receive Next Counter Register */ - RwReg UART_TNPR; /**< \brief (Uart Offset: 0x118) Transmit Next Pointer Register */ - RwReg UART_TNCR; /**< \brief (Uart Offset: 0x11C) Transmit Next Counter Register */ - WoReg UART_PTCR; /**< \brief (Uart Offset: 0x120) Transfer Control Register */ - RoReg UART_PTSR; /**< \brief (Uart Offset: 0x124) Transfer Status Register */ -} Uart; -#endif /* __ASSEMBLY__ */ -/* -------- UART_CR : (UART Offset: 0x0000) Control Register -------- */ -#define UART_CR_RSTRX (0x1 << 2) /**< \brief (UART_CR) Reset Receiver */ -#define UART_CR_RSTTX (0x1 << 3) /**< \brief (UART_CR) Reset Transmitter */ -#define UART_CR_RXEN (0x1 << 4) /**< \brief (UART_CR) Receiver Enable */ -#define UART_CR_RXDIS (0x1 << 5) /**< \brief (UART_CR) Receiver Disable */ -#define UART_CR_TXEN (0x1 << 6) /**< \brief (UART_CR) Transmitter Enable */ -#define UART_CR_TXDIS (0x1 << 7) /**< \brief (UART_CR) Transmitter Disable */ -#define UART_CR_RSTSTA (0x1 << 8) /**< \brief (UART_CR) Reset Status Bits */ -/* -------- UART_MR : (UART Offset: 0x0004) Mode Register -------- */ -#define UART_MR_PAR (0x7 << 9) /**< \brief (UART_MR) Parity Type */ -#define UART_MR_CHMODE (0x3 << 14) /**< \brief (UART_MR) Channel Mode */ -/* -------- UART_IER : (UART Offset: 0x0008) Interrupt Enable Register -------- */ -#define UART_IER_RXRDY (0x1 << 0) /**< \brief (UART_IER) Enable RXRDY Interrupt */ -#define UART_IER_TXRDY (0x1 << 1) /**< \brief (UART_IER) Enable TXRDY Interrupt */ -#define UART_IER_ENDRX (0x1 << 3) /**< \brief (UART_IER) Enable End of Receive Transfer Interrupt */ -#define UART_IER_ENDTX (0x1 << 4) /**< \brief (UART_IER) Enable End of Transmit Interrupt */ -#define UART_IER_OVRE (0x1 << 5) /**< \brief (UART_IER) Enable Overrun Error Interrupt */ -#define UART_IER_FRAME (0x1 << 6) /**< \brief (UART_IER) Enable Framing Error Interrupt */ -#define UART_IER_PARE (0x1 << 7) /**< \brief (UART_IER) Enable Parity Error Interrupt */ -#define UART_IER_TXEMPTY (0x1 << 9) /**< \brief (UART_IER) Enable TXEMPTY Interrupt */ -#define UART_IER_TXBUFE (0x1 << 11) /**< \brief (UART_IER) Enable Buffer Empty Interrupt */ -#define UART_IER_RXBUFF (0x1 << 12) /**< \brief (UART_IER) Enable Buffer Full Interrupt */ -/* -------- UART_IDR : (UART Offset: 0x000C) Interrupt Disable Register -------- */ -#define UART_IDR_RXRDY (0x1 << 0) /**< \brief (UART_IDR) Disable RXRDY Interrupt */ -#define UART_IDR_TXRDY (0x1 << 1) /**< \brief (UART_IDR) Disable TXRDY Interrupt */ -#define UART_IDR_ENDRX (0x1 << 3) /**< \brief (UART_IDR) Disable End of Receive Transfer Interrupt */ -#define UART_IDR_ENDTX (0x1 << 4) /**< \brief (UART_IDR) Disable End of Transmit Interrupt */ -#define UART_IDR_OVRE (0x1 << 5) /**< \brief (UART_IDR) Disable Overrun Error Interrupt */ -#define UART_IDR_FRAME (0x1 << 6) /**< \brief (UART_IDR) Disable Framing Error Interrupt */ -#define UART_IDR_PARE (0x1 << 7) /**< \brief (UART_IDR) Disable Parity Error Interrupt */ -#define UART_IDR_TXEMPTY (0x1 << 9) /**< \brief (UART_IDR) Disable TXEMPTY Interrupt */ -#define UART_IDR_TXBUFE (0x1 << 11) /**< \brief (UART_IDR) Disable Buffer Empty Interrupt */ -#define UART_IDR_RXBUFF (0x1 << 12) /**< \brief (UART_IDR) Disable Buffer Full Interrupt */ -/* -------- UART_IMR : (UART Offset: 0x0010) Interrupt Mask Register -------- */ -#define UART_IMR_RXRDY (0x1 << 0) /**< \brief (UART_IMR) Mask RXRDY Interrupt */ -#define UART_IMR_TXRDY (0x1 << 1) /**< \brief (UART_IMR) Disable TXRDY Interrupt */ -#define UART_IMR_ENDRX (0x1 << 3) /**< \brief (UART_IMR) Mask End of Receive Transfer Interrupt */ -#define UART_IMR_ENDTX (0x1 << 4) /**< \brief (UART_IMR) Mask End of Transmit Interrupt */ -#define UART_IMR_OVRE (0x1 << 5) /**< \brief (UART_IMR) Mask Overrun Error Interrupt */ -#define UART_IMR_FRAME (0x1 << 6) /**< \brief (UART_IMR) Mask Framing Error Interrupt */ -#define UART_IMR_PARE (0x1 << 7) /**< \brief (UART_IMR) Mask Parity Error Interrupt */ -#define UART_IMR_TXEMPTY (0x1 << 9) /**< \brief (UART_IMR) Mask TXEMPTY Interrupt */ -#define UART_IMR_TXBUFE (0x1 << 11) /**< \brief (UART_IMR) Mask TXBUFE Interrupt */ -#define UART_IMR_RXBUFF (0x1 << 12) /**< \brief (UART_IMR) Mask RXBUFF Interrupt */ -/* -------- UART_SR : (UART Offset: 0x0014) Status Register -------- */ -#define UART_SR_RXRDY (0x1 << 0) /**< \brief (UART_SR) Receiver Ready */ -#define UART_SR_TXRDY (0x1 << 1) /**< \brief (UART_SR) Transmitter Ready */ -#define UART_SR_ENDRX (0x1 << 3) /**< \brief (UART_SR) End of Receiver Transfer */ -#define UART_SR_ENDTX (0x1 << 4) /**< \brief (UART_SR) End of Transmitter Transfer */ -#define UART_SR_OVRE (0x1 << 5) /**< \brief (UART_SR) Overrun Error */ -#define UART_SR_FRAME (0x1 << 6) /**< \brief (UART_SR) Framing Error */ -#define UART_SR_PARE (0x1 << 7) /**< \brief (UART_SR) Parity Error */ -#define UART_SR_TXEMPTY (0x1 << 9) /**< \brief (UART_SR) Transmitter Empty */ -#define UART_SR_TXBUFE (0x1 << 11) /**< \brief (UART_SR) Transmission Buffer Empty */ -#define UART_SR_RXBUFF (0x1 << 12) /**< \brief (UART_SR) Receive Buffer Full */ -/* -------- UART_RHR : (UART Offset: 0x0018) Receive Holding Register -------- */ -#define UART_RHR_RXCHR (0xff << 0) /**< \brief (UART_RHR) Received Character */ -/* -------- UART_THR : (UART Offset: 0x001C) Transmit Holding Register -------- */ -#define UART_THR_TXCHR (0xff << 0) /**< \brief (UART_THR) Character to be Transmitted */ -/* -------- UART_BRGR : (UART Offset: 0x0020) Baud Rate Generator Register -------- */ -#define UART_BRGR_CD (0xffff << 0) /**< \brief (UART_BRGR) Clock Divisor */ -/* -------- UART_RPR : (UART Offset: 0x100) Receive Pointer Register -------- */ -#define UART_RPR_RXPTR (0xffffffff << 0) /**< \brief (UART_RPR) Receive Pointer Register */ -/* -------- UART_RCR : (UART Offset: 0x104) Receive Counter Register -------- */ -#define UART_RCR_RXCTR (0xffff << 0) /**< \brief (UART_RCR) Receive Counter Register */ -/* -------- UART_TPR : (UART Offset: 0x108) Transmit Pointer Register -------- */ -#define UART_TPR_TXPTR (0xffffffff << 0) /**< \brief (UART_TPR) Transmit Counter Register */ -/* -------- UART_TCR : (UART Offset: 0x10C) Transmit Counter Register -------- */ -#define UART_TCR_TXCTR (0xffff << 0) /**< \brief (UART_TCR) Transmit Counter Register */ -/* -------- UART_RNPR : (UART Offset: 0x110) Receive Next Pointer Register -------- */ -#define UART_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (UART_RNPR) Receive Next Pointer */ -/* -------- UART_RNCR : (UART Offset: 0x114) Receive Next Counter Register -------- */ -#define UART_RNCR_RXNCTR (0xffff << 0) /**< \brief (UART_RNCR) Receive Next Counter */ -/* -------- UART_TNPR : (UART Offset: 0x118) Transmit Next Pointer Register -------- */ -#define UART_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (UART_TNPR) Transmit Next Pointer */ -/* -------- UART_TNCR : (UART Offset: 0x11C) Transmit Next Counter Register -------- */ -#define UART_TNCR_TXNCTR (0xffff << 0) /**< \brief (UART_TNCR) Transmit Counter Next */ -/* -------- UART_PTCR : (UART Offset: 0x120) Transfer Control Register -------- */ -#define UART_PTCR_RXTEN (0x1 << 0) /**< \brief (UART_PTCR) Receiver Transfer Enable */ -#define UART_PTCR_RXTDIS (0x1 << 1) /**< \brief (UART_PTCR) Receiver Transfer Disable */ -#define UART_PTCR_TXTEN (0x1 << 8) /**< \brief (UART_PTCR) Transmitter Transfer Enable */ -#define UART_PTCR_TXTDIS (0x1 << 9) /**< \brief (UART_PTCR) Transmitter Transfer Disable */ -/* -------- UART_PTSR : (UART Offset: 0x124) Transfer Status Register -------- */ -#define UART_PTSR_RXTEN (0x1 << 0) /**< \brief (UART_PTSR) Receiver Transfer Enable */ -#define UART_PTSR_TXTEN (0x1 << 8) /**< \brief (UART_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR USB Device Port */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_UDP USB Device Port */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Udp hardware registers */ -typedef struct { - RoReg UDP_FRM_NUM; /**< \brief (Udp Offset: 0x000) Frame Number Register */ - RwReg UDP_GLB_STAT; /**< \brief (Udp Offset: 0x004) Global State Register */ - RwReg UDP_FADDR; /**< \brief (Udp Offset: 0x008) Function Address Register */ - RwReg Reserved1[1]; - WoReg UDP_IER; /**< \brief (Udp Offset: 0x010) Interrupt Enable Register */ - WoReg UDP_IDR; /**< \brief (Udp Offset: 0x014) Interrupt Disable Register */ - RoReg UDP_IMR; /**< \brief (Udp Offset: 0x018) Interrupt Mask Register */ - RoReg UDP_ISR; /**< \brief (Udp Offset: 0x01C) Interrupt Status Register */ - WoReg UDP_ICR; /**< \brief (Udp Offset: 0x020) Interrupt Clear Register */ - RwReg Reserved2[1]; - RwReg UDP_RST_EP; /**< \brief (Udp Offset: 0x028) Reset Endpoint Register */ - RwReg Reserved3[1]; - RwReg UDP_CSR[8]; /**< \brief (Udp Offset: 0x30) Endpoint Control and Status Register (ept_num = 0) */ - RwReg UDP_FDR[8]; /**< \brief (Udp Offset: 0x50) Endpoint FIFO Data Register (ept_num = 0) */ - RwReg Reserved4[1]; - RwReg UDP_TXVC; /**< \brief (Udp Offset: 0x074) Transceiver Control Register */ -} Udp; -#endif /* __ASSEMBLY__ */ -/* -------- UDP_FRM_NUM : (UDP Offset: 0x000) Frame Number Register -------- */ -#define UDP_FRM_NUM_FRM_NUM (0x7ff << 0) /**< \brief (UDP_FRM_NUM) Frame Number as Defined in the Packet Field Formats */ -#define UDP_FRM_NUM_FRM_ERR (0x1 << 16) /**< \brief (UDP_FRM_NUM) Frame Error */ -#define UDP_FRM_NUM_FRM_OK (0x1 << 17) /**< \brief (UDP_FRM_NUM) Frame OK */ -/* -------- UDP_GLB_STAT : (UDP Offset: 0x004) Global State Register -------- */ -#define UDP_GLB_STAT_FADDEN (0x1 << 0) /**< \brief (UDP_GLB_STAT) Function Address Enable */ -#define UDP_GLB_STAT_CONFG (0x1 << 1) /**< \brief (UDP_GLB_STAT) Configured */ -#define UDP_GLB_STAT_ESR (0x1 << 2) /**< \brief (UDP_GLB_STAT) Enable Send Resume */ -#define UDP_GLB_STAT_RSMINPR (0x1 << 3) /**< \brief (UDP_GLB_STAT) */ -#define UDP_GLB_STAT_RMWUPE (0x1 << 4) /**< \brief (UDP_GLB_STAT) Remote Wake Up Enable */ -/* -------- UDP_FADDR : (UDP Offset: 0x008) Function Address Register -------- */ -#define UDP_FADDR_FADD (0x7f << 0) /**< \brief (UDP_FADDR) Function Address Value */ -#define UDP_FADDR_FEN (0x1 << 8) /**< \brief (UDP_FADDR) Function Enable */ -/* -------- UDP_IER : (UDP Offset: 0x010) Interrupt Enable Register -------- */ -#define UDP_IER_EP0INT (0x1 << 0) /**< \brief (UDP_IER) Enable Endpoint 0 Interrupt */ -#define UDP_IER_EP1INT (0x1 << 1) /**< \brief (UDP_IER) Enable Endpoint 1 Interrupt */ -#define UDP_IER_EP2INT (0x1 << 2) /**< \brief (UDP_IER) Enable Endpoint 2Interrupt */ -#define UDP_IER_EP3INT (0x1 << 3) /**< \brief (UDP_IER) Enable Endpoint 3 Interrupt */ -#define UDP_IER_EP4INT (0x1 << 4) /**< \brief (UDP_IER) Enable Endpoint 4 Interrupt */ -#define UDP_IER_EP5INT (0x1 << 5) /**< \brief (UDP_IER) Enable Endpoint 5 Interrupt */ -#define UDP_IER_EP6INT (0x1 << 6) /**< \brief (UDP_IER) Enable Endpoint 6 Interrupt */ -#define UDP_IER_EP7INT (0x1 << 7) /**< \brief (UDP_IER) Enable Endpoint 7 Interrupt */ -#define UDP_IER_RXSUSP (0x1 << 8) /**< \brief (UDP_IER) Enable UDP Suspend Interrupt */ -#define UDP_IER_RXRSM (0x1 << 9) /**< \brief (UDP_IER) Enable UDP Resume Interrupt */ -#define UDP_IER_EXTRSM (0x1 << 10) /**< \brief (UDP_IER) */ -#define UDP_IER_SOFINT (0x1 << 11) /**< \brief (UDP_IER) Enable Start Of Frame Interrupt */ -#define UDP_IER_WAKEUP (0x1 << 13) /**< \brief (UDP_IER) Enable UDP bus Wakeup Interrupt */ -/* -------- UDP_IDR : (UDP Offset: 0x014) Interrupt Disable Register -------- */ -#define UDP_IDR_EP0INT (0x1 << 0) /**< \brief (UDP_IDR) Disable Endpoint 0 Interrupt */ -#define UDP_IDR_EP1INT (0x1 << 1) /**< \brief (UDP_IDR) Disable Endpoint 1 Interrupt */ -#define UDP_IDR_EP2INT (0x1 << 2) /**< \brief (UDP_IDR) Disable Endpoint 2 Interrupt */ -#define UDP_IDR_EP3INT (0x1 << 3) /**< \brief (UDP_IDR) Disable Endpoint 3 Interrupt */ -#define UDP_IDR_EP4INT (0x1 << 4) /**< \brief (UDP_IDR) Disable Endpoint 4 Interrupt */ -#define UDP_IDR_EP5INT (0x1 << 5) /**< \brief (UDP_IDR) Disable Endpoint 5 Interrupt */ -#define UDP_IDR_EP6INT (0x1 << 6) /**< \brief (UDP_IDR) Disable Endpoint 6 Interrupt */ -#define UDP_IDR_EP7INT (0x1 << 7) /**< \brief (UDP_IDR) Disable Endpoint 7 Interrupt */ -#define UDP_IDR_RXSUSP (0x1 << 8) /**< \brief (UDP_IDR) Disable UDP Suspend Interrupt */ -#define UDP_IDR_RXRSM (0x1 << 9) /**< \brief (UDP_IDR) Disable UDP Resume Interrupt */ -#define UDP_IDR_EXTRSM (0x1 << 10) /**< \brief (UDP_IDR) */ -#define UDP_IDR_SOFINT (0x1 << 11) /**< \brief (UDP_IDR) Disable Start Of Frame Interrupt */ -#define UDP_IDR_WAKEUP (0x1 << 13) /**< \brief (UDP_IDR) Disable USB Bus Interrupt */ -/* -------- UDP_IMR : (UDP Offset: 0x018) Interrupt Mask Register -------- */ -#define UDP_IMR_EP0INT (0x1 << 0) /**< \brief (UDP_IMR) Mask Endpoint 0 Interrupt */ -#define UDP_IMR_EP1INT (0x1 << 1) /**< \brief (UDP_IMR) Mask Endpoint 1 Interrupt */ -#define UDP_IMR_EP2INT (0x1 << 2) /**< \brief (UDP_IMR) Mask Endpoint 2 Interrupt */ -#define UDP_IMR_EP3INT (0x1 << 3) /**< \brief (UDP_IMR) Mask Endpoint 3 Interrupt */ -#define UDP_IMR_EP4INT (0x1 << 4) /**< \brief (UDP_IMR) Mask Endpoint 4 Interrupt */ -#define UDP_IMR_EP5INT (0x1 << 5) /**< \brief (UDP_IMR) Mask Endpoint 5 Interrupt */ -#define UDP_IMR_EP6INT (0x1 << 6) /**< \brief (UDP_IMR) Mask Endpoint 6 Interrupt */ -#define UDP_IMR_EP7INT (0x1 << 7) /**< \brief (UDP_IMR) Mask Endpoint 7 Interrupt */ -#define UDP_IMR_RXSUSP (0x1 << 8) /**< \brief (UDP_IMR) Mask UDP Suspend Interrupt */ -#define UDP_IMR_RXRSM (0x1 << 9) /**< \brief (UDP_IMR) Mask UDP Resume Interrupt. */ -#define UDP_IMR_EXTRSM (0x1 << 10) /**< \brief (UDP_IMR) */ -#define UDP_IMR_SOFINT (0x1 << 11) /**< \brief (UDP_IMR) Mask Start Of Frame Interrupt */ -#define UDP_IMR_BIT12 (0x1 << 12) /**< \brief (UDP_IMR) UDP_IMR Bit 12 */ -#define UDP_IMR_WAKEUP (0x1 << 13) /**< \brief (UDP_IMR) USB Bus WAKEUP Interrupt */ -/* -------- UDP_ISR : (UDP Offset: 0x01C) Interrupt Status Register -------- */ -#define UDP_ISR_EP0INT (0x1 << 0) /**< \brief (UDP_ISR) Endpoint 0 Interrupt Status */ -#define UDP_ISR_EP1INT (0x1 << 1) /**< \brief (UDP_ISR) Endpoint 1 Interrupt Status */ -#define UDP_ISR_EP2INT (0x1 << 2) /**< \brief (UDP_ISR) Endpoint 2 Interrupt Status */ -#define UDP_ISR_EP3INT (0x1 << 3) /**< \brief (UDP_ISR) Endpoint 3 Interrupt Status */ -#define UDP_ISR_EP4INT (0x1 << 4) /**< \brief (UDP_ISR) Endpoint 4 Interrupt Status */ -#define UDP_ISR_EP5INT (0x1 << 5) /**< \brief (UDP_ISR) Endpoint 5 Interrupt Status */ -#define UDP_ISR_EP6INT (0x1 << 6) /**< \brief (UDP_ISR) Endpoint 6 Interrupt Status */ -#define UDP_ISR_EP7INT (0x1 << 7) /**< \brief (UDP_ISR) Endpoint 7Interrupt Status */ -#define UDP_ISR_RXSUSP (0x1 << 8) /**< \brief (UDP_ISR) UDP Suspend Interrupt Status */ -#define UDP_ISR_RXRSM (0x1 << 9) /**< \brief (UDP_ISR) UDP Resume Interrupt Status */ -#define UDP_ISR_EXTRSM (0x1 << 10) /**< \brief (UDP_ISR) */ -#define UDP_ISR_SOFINT (0x1 << 11) /**< \brief (UDP_ISR) Start of Frame Interrupt Status */ -#define UDP_ISR_ENDBUSRES (0x1 << 12) /**< \brief (UDP_ISR) End of BUS Reset Interrupt Status */ -#define UDP_ISR_WAKEUP (0x1 << 13) /**< \brief (UDP_ISR) UDP Resume Interrupt Status */ -/* -------- UDP_ICR : (UDP Offset: 0x020) Interrupt Clear Register -------- */ -#define UDP_ICR_RXSUSP (0x1 << 8) /**< \brief (UDP_ICR) Clear UDP Suspend Interrupt */ -#define UDP_ICR_RXRSM (0x1 << 9) /**< \brief (UDP_ICR) Clear UDP Resume Interrupt */ -#define UDP_ICR_EXTRSM (0x1 << 10) /**< \brief (UDP_ICR) */ -#define UDP_ICR_SOFINT (0x1 << 11) /**< \brief (UDP_ICR) Clear Start Of Frame Interrupt */ -#define UDP_ICR_ENDBUSRES (0x1 << 12) /**< \brief (UDP_ICR) Clear End of Bus Reset Interrupt */ -#define UDP_ICR_WAKEUP (0x1 << 13) /**< \brief (UDP_ICR) Clear Wakeup Interrupt */ -/* -------- UDP_RST_EP : (UDP Offset: 0x028) Reset Endpoint Register -------- */ -#define UDP_RST_EP_EP0 (0x1 << 0) /**< \brief (UDP_RST_EP) Reset Endpoint 0 */ -#define UDP_RST_EP_EP1 (0x1 << 1) /**< \brief (UDP_RST_EP) Reset Endpoint 1 */ -#define UDP_RST_EP_EP2 (0x1 << 2) /**< \brief (UDP_RST_EP) Reset Endpoint 2 */ -#define UDP_RST_EP_EP3 (0x1 << 3) /**< \brief (UDP_RST_EP) Reset Endpoint 3 */ -#define UDP_RST_EP_EP4 (0x1 << 4) /**< \brief (UDP_RST_EP) Reset Endpoint 4 */ -#define UDP_RST_EP_EP5 (0x1 << 5) /**< \brief (UDP_RST_EP) Reset Endpoint 5 */ -#define UDP_RST_EP_EP6 (0x1 << 6) /**< \brief (UDP_RST_EP) Reset Endpoint 6 */ -#define UDP_RST_EP_EP7 (0x1 << 7) /**< \brief (UDP_RST_EP) Reset Endpoint 7 */ -/* -------- UDP_CSR[8] : (UDP Offset: 0x2C) Endpoint Control and Status Register (ept_num = 0) -------- */ -#define UDP_CSR_TXCOMP (0x1 << 0) /**< \brief (UDP_CSR[8]) Generates an IN Packet with Data Previously Written in the DPR */ -#define UDP_CSR_RX_DATA_BK0 (0x1 << 1) /**< \brief (UDP_CSR[8]) Receive Data Bank 0 */ -#define UDP_CSR_RXSETUP (0x1 << 2) /**< \brief (UDP_CSR[8]) Received Setup */ -#define UDP_CSR_STALLSENTISOERROR (0x1 << 3) /**< \brief (UDP_CSR[8]) */ -#define UDP_CSR_TXPKTRDY (0x1 << 4) /**< \brief (UDP_CSR[8]) Transmit Packet Ready */ -#define UDP_CSR_FORCESTALL (0x1 << 5) /**< \brief (UDP_CSR[8]) Force Stall (used by Control, Bulk and Isochronous Endpoints) */ -#define UDP_CSR_RX_DATA_BK1 (0x1 << 6) /**< \brief (UDP_CSR[8]) Receive Data Bank 1 (only used by endpoints with ping-pong attributes) */ -#define UDP_CSR_DIR (0x1 << 7) /**< \brief (UDP_CSR[8]) Transfer Direction (only available for control endpoints) */ -#define UDP_CSR_EPTYPE (0x7 << 8) /**< \brief (UDP_CSR[8]) Endpoint Type */ -#define UDP_CSR_EPTYPE_CTRL (0x0 << 8) /**< \brief (UDP_CSR[8]) Control */ -#define UDP_CSR_EPTYPE_ISO_OUT (0x1 << 8) /**< \brief (UDP_CSR[8]) Isochronous OUT */ -#define UDP_CSR_EPTYPE_BULK_OUT (0x2 << 8) /**< \brief (UDP_CSR[8]) Bulk OUT */ -#define UDP_CSR_EPTYPE_INT_OUT (0x3 << 8) /**< \brief (UDP_CSR[8]) Interrupt OUT */ -#define UDP_CSR_EPTYPE_ISO_IN (0x5 << 8) /**< \brief (UDP_CSR[8]) Isochronous IN */ -#define UDP_CSR_EPTYPE_BULK_IN (0x6 << 8) /**< \brief (UDP_CSR[8]) Bulk IN */ -#define UDP_CSR_EPTYPE_INT_IN (0x7 << 8) /**< \brief (UDP_CSR[8]) Interrupt IN */ -#define UDP_CSR_DTGLE (0x1 << 11) /**< \brief (UDP_CSR[8]) Data Toggle */ -#define UDP_CSR_EPEDS (0x1 << 15) /**< \brief (UDP_CSR[8]) Endpoint Enable Disable */ -#define UDP_CSR_RXBYTECNT (0x7ff << 16) /**< \brief (UDP_CSR[8]) Number of Bytes Available in the FIFO */ -/* -------- UDP_FDR[8] : (UDP Offset: 0x4C) Endpoint FIFO Data Register (ept_num = 0) -------- */ -#define UDP_FDR_FIFO_DATA (0xff << 0) /**< \brief (UDP_FDR[8]) FIFO Data Value */ -/* -------- UDP_TXVC : (UDP Offset: 0x074) Transceiver Control Register -------- */ -#define UDP_TXVC_TXVDIS (0x1 << 8) /**< \brief (UDP_TXVC) Transceiver Disable */ -#define UDP_TXVC_PUON (0x1 << 9) /**< \brief (UDP_TXVC) Pullup On */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Universal Synchronous Asynchronous Receiver Transmitter */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_USART Universal Synchronous Asynchronous Receiver Transmitter */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Usart hardware registers */ -typedef struct { - WoReg US_CR; /**< \brief (Usart Offset: 0x0000) Control Register */ - RwReg US_MR; /**< \brief (Usart Offset: 0x0004) Mode Register */ - WoReg US_IER; /**< \brief (Usart Offset: 0x0008) Interrupt Enable Register */ - WoReg US_IDR; /**< \brief (Usart Offset: 0x000C) Interrupt Disable Register */ - RoReg US_IMR; /**< \brief (Usart Offset: 0x0010) Interrupt Mask Register */ - RoReg US_CSR; /**< \brief (Usart Offset: 0x0014) Channel Status Register */ - RoReg US_RHR; /**< \brief (Usart Offset: 0x0018) Receiver Holding Register */ - WoReg US_THR; /**< \brief (Usart Offset: 0x001C) Transmitter Holding Register */ - RwReg US_BRGR; /**< \brief (Usart Offset: 0x0020) Baud Rate Generator Register */ - RwReg US_RTOR; /**< \brief (Usart Offset: 0x0024) Receiver Time-out Register */ - RwReg US_TTGR; /**< \brief (Usart Offset: 0x0028) Transmitter Timeguard Register */ - RwReg Reserved1[5]; - RwReg US_FIDI; /**< \brief (Usart Offset: 0x0040) FI DI Ratio Register */ - RoReg US_NER; /**< \brief (Usart Offset: 0x0044) Number of Errors Register */ - RwReg Reserved2[1]; - RwReg US_IF; /**< \brief (Usart Offset: 0x004C) IrDA Filter Register */ - RwReg US_MAN; /**< \brief (Usart Offset: 0x0050) Manchester Encoder Decoder Register */ - RwReg Reserved3[36]; - RwReg US_WPMR; /**< \brief (Usart Offset: 0xE4) Write Protect Mode Register */ - RoReg US_WPSR; /**< \brief (Usart Offset: 0xE8) Write Protect Status Register */ - RwReg Reserved4[4]; - RoReg US_VERSION; /**< \brief (Usart Offset: 0xFC) Version Register */ - RwReg US_RPR; /**< \brief (Usart Offset: 0x100) Receive Pointer Register */ - RwReg US_RCR; /**< \brief (Usart Offset: 0x104) Receive Counter Register */ - RwReg US_TPR; /**< \brief (Usart Offset: 0x108) Transmit Pointer Register */ - RwReg US_TCR; /**< \brief (Usart Offset: 0x10C) Transmit Counter Register */ - RwReg US_RNPR; /**< \brief (Usart Offset: 0x110) Receive Next Pointer Register */ - RwReg US_RNCR; /**< \brief (Usart Offset: 0x114) Receive Next Counter Register */ - RwReg US_TNPR; /**< \brief (Usart Offset: 0x118) Transmit Next Pointer Register */ - RwReg US_TNCR; /**< \brief (Usart Offset: 0x11C) Transmit Next Counter Register */ - WoReg US_PTCR; /**< \brief (Usart Offset: 0x120) Transfer Control Register */ - RoReg US_PTSR; /**< \brief (Usart Offset: 0x124) Transfer Status Register */ -} Usart; -#endif /* __ASSEMBLY__ */ -/* -------- US_CR : (USART Offset: 0x0000) Control Register -------- */ -#define US_CR_RSTRX (0x1 << 2) /**< \brief (US_CR) Reset Receiver */ -#define US_CR_RSTTX (0x1 << 3) /**< \brief (US_CR) Reset Transmitter */ -#define US_CR_RXEN (0x1 << 4) /**< \brief (US_CR) Receiver Enable */ -#define US_CR_RXDIS (0x1 << 5) /**< \brief (US_CR) Receiver Disable */ -#define US_CR_TXEN (0x1 << 6) /**< \brief (US_CR) Transmitter Enable */ -#define US_CR_TXDIS (0x1 << 7) /**< \brief (US_CR) Transmitter Disable */ -#define US_CR_RSTSTA (0x1 << 8) /**< \brief (US_CR) Reset Status Bits */ -#define US_CR_STTBRK (0x1 << 9) /**< \brief (US_CR) Start Break */ -#define US_CR_STPBRK (0x1 << 10) /**< \brief (US_CR) Stop Break */ -#define US_CR_STTTO (0x1 << 11) /**< \brief (US_CR) Start Time-out */ -#define US_CR_SENDA (0x1 << 12) /**< \brief (US_CR) Send Address */ -#define US_CR_RSTIT (0x1 << 13) /**< \brief (US_CR) Reset Iterations */ -#define US_CR_RSTNACK (0x1 << 14) /**< \brief (US_CR) Reset Non Acknowledge */ -#define US_CR_RETTO (0x1 << 15) /**< \brief (US_CR) Rearm Time-out */ -#define US_CR_DTREN (0x1 << 16) /**< \brief (US_CR) Data Terminal Ready Enable */ -#define US_CR_DTRDIS (0x1 << 17) /**< \brief (US_CR) Data Terminal Ready Disable */ -#define US_CR_RTSEN__FCS (0x1 << 18) /**< \brief (US_CR) Request to Send Enable/Force SPI Chip Select */ -#define US_CR_RTSDIS__RCS (0x1 << 19) /**< \brief (US_CR) Request to Send Disable/Release SPI Chip Select */ -/* -------- US_MR : (USART Offset: 0x0004) Mode Register -------- */ -#define US_MR_USART_MODE (0xf << 0) /**< \brief (US_MR) */ -#define US_MR_USART_MODE_NORMAL (0x0) /**< (USART) Normal*/ -#define US_MR_USART_MODE_RS485 (0x1) /**< (USART) RS485*/ -#define US_MR_USART_MODE_HWHSH (0x2) /**< (USART) Hardware Handshaking*/ -#define US_MR_USART_MODE_ISO7816_0 (0x4) /**< (USART) ISO7816 protocol: T = 0*/ -#define US_MR_USART_MODE_ISO7816_1 (0x6) /**< (USART) ISO7816 protocol: T = 1*/ -#define US_MR_USART_MODE_IRDA (0x8) /**< (USART) IrDA*/ -#define US_MR_USART_MODE_SPIM (0xE) /**< (USART) SPI Master*/ -#define US_MR_USART_MODE_SPIS (0xF) /**< (USART) SPI Slave*/ -#define US_MR_USCLKS (0x3 << 4) /**< \brief (US_MR) Clock Selection */ -#define US_MR_USCLKS_CLOCK (0x0 << 4) /**< (USART) MCK*/ -#define US_MR_USCLKS_FDIV1 (0x1 << 4) /**< (USART) MCK/DIV(DIV=8)*/ -#define US_MR_USCLKS_SLOW (0x2 << 4) /**< (USART) Reserved*/ -#define US_MR_USCLKS_EXT (0x3 << 4) /**< (USART) SCK*/ -#define US_MR_CHRL (0x3 << 6) /**< \brief (US_MR) Character Length. */ -#define US_MR_CHRL_5_BITS (0x0 << 6) /**< (USART) Character Length: 5 bits*/ -#define US_MR_CHRL_6_BITS (0x1 << 6) /**< (USART) Character Length: 6 bits*/ -#define US_MR_CHRL_7_BITS (0x2 << 6) /**< (USART) Character Length: 7 bits*/ -#define US_MR_CHRL_8_BITS (0x3 << 6) /**< (USART) Character Length: 8 bits*/ -#define US_MR_SYNC__CPHA (0x1 << 8) /**< \brief (US_MR) Synchronous Mode Select or SPI Clock Phase */ -#define US_MR_PAR (0x7 << 9) /**< \brief (US_MR) Parity Type */ -#define US_MR_PAR_EVEN (0x0 << 9) /**< (USART) Even Parity*/ -#define US_MR_PAR_ODD (0x1 << 9) /**< (USART) Odd Parity*/ -#define US_MR_PAR_SPACE (0x2 << 9) /**< (USART) Parity forced to 0 (Space)*/ -#define US_MR_PAR_MARK (0x3 << 9) /**< (USART) Parity forced to 1 (Mark)*/ -#define US_MR_PAR_NONE (0x4 << 9) /**< (USART) No Parity*/ -#define US_MR_PAR_MULTI_DROP (0x6 << 9) /**< (USART) Multi-drop mode*/ -#define US_MR_NBSTOP (0x3 << 12) /**< \brief (US_MR) Number of Stop Bits */ -#define US_MR_NBSTOP_1_BIT (0x0 << 12) /**< (USART) 1 stop bit*/ -#define US_MR_NBSTOP_15_BIT (0x1 << 12) /**< (USART) Asynchronous (SYNC=0) 2 stop bits Synchronous (SYNC=1) 2 stop bits*/ -#define US_MR_NBSTOP_2_BIT (0x2 << 12) /**< (USART) 2 stop bits*/ -#define US_MR_CHMODE (0x3 << 14) /**< \brief (US_MR) Channel Mode */ -#define US_MR_CHMODE_NORMAL (0x0 << 14) /**< (USART) Normal Mode: The USART channel operates as an RX/TX USART.*/ -#define US_MR_CHMODE_AUTO (0x1 << 14) /**< (USART) Automatic Echo: Receiver Data Input is connected to the TXD pin.*/ -#define US_MR_CHMODE_LOCAL (0x2 << 14) /**< (USART) Local Loopback: Transmitter Output Signal is connected to Receiver Input Signal.*/ -#define US_MR_CHMODE_REMOTE (0x3 << 14) /**< (USART) Remote Loopback: RXD pin is internally connected to TXD pin.*/ -#define US_MR_MSBF__CPOL (0x1 << 16) /**< \brief (US_MR) Bit Order or SPI Clock Polarity */ -#define US_MR_MODE9 (0x1 << 17) /**< \brief (US_MR) 9-bit Character Length */ -#define US_MR_CLKO (0x1 << 18) /**< \brief (US_MR) Clock Output Select */ -#define US_MR_OVER (0x1 << 19) /**< \brief (US_MR) Oversampling Mode */ -#define US_MR_INACK (0x1 << 20) /**< \brief (US_MR) Inhibit Non Acknowledge */ -#define US_MR_DSNACK (0x1 << 21) /**< \brief (US_MR) Disable Successive NACK */ -#define US_MR_VAR_SYNC (0x1 << 22) /**< \brief (US_MR) Variable Synchronization of Command/Data Sync Start Frame Delimiter */ -#define US_MR_INVDATA (0x1 << 23) /**< \brief (US_MR) INverted Data */ -#define US_MR_MAX_ITERATION (0x7 << 24) /**< \brief (US_MR) */ -#define US_MR_FILTER (0x1 << 28) /**< \brief (US_MR) Infrared Receive Line Filter */ -#define US_MR_MAN (0x1 << 29) /**< \brief (US_MR) Manchester Encoder/Decoder Enable */ -#define US_MR_MODSYNC_ (0x1 << 30) /**< \brief (US_MR) */ -#define US_MR_ONEBIT (0x1 << 31) /**< \brief (US_MR) Start Frame Delimiter Selector */ -/* -------- US_IER : (USART Offset: 0x0008) Interrupt Enable Register -------- */ -#define US_IER_RXRDY (0x1 << 0) /**< \brief (US_IER) RXRDY Interrupt Enable */ -#define US_IER_TXRDY (0x1 << 1) /**< \brief (US_IER) TXRDY Interrupt Enable */ -#define US_IER_RXBRK (0x1 << 2) /**< \brief (US_IER) Receiver Break Interrupt Enable */ -#define US_IER_ENDRX (0x1 << 3) /**< \brief (US_IER) End of Receive Transfer Interrupt Enable */ -#define US_IER_ENDTX (0x1 << 4) /**< \brief (US_IER) End of Transmit Interrupt Enable */ -#define US_IER_OVRE (0x1 << 5) /**< \brief (US_IER) Overrun Error Interrupt Enable */ -#define US_IER_FRAME (0x1 << 6) /**< \brief (US_IER) Framing Error Interrupt Enable */ -#define US_IER_PARE (0x1 << 7) /**< \brief (US_IER) Parity Error Interrupt Enable */ -#define US_IER_TIMEOUT (0x1 << 8) /**< \brief (US_IER) Time-out Interrupt Enable */ -#define US_IER_TXEMPTY (0x1 << 9) /**< \brief (US_IER) TXEMPTY Interrupt Enable */ -#define US_IER_ITER__UNRE (0x1 << 10) /**< \brief (US_IER) Iteration or SPI Underrun Error Interrupt Enable */ -#define US_IER_TXBUFE (0x1 << 11) /**< \brief (US_IER) Buffer Empty Interrupt Enable */ -#define US_IER_RXBUFF (0x1 << 12) /**< \brief (US_IER) Buffer Full Interrupt Enable */ -#define US_IER_NACK (0x1 << 13) /**< \brief (US_IER) Non Acknowledge Interrupt Enable */ -#define US_IER_RIIC (0x1 << 16) /**< \brief (US_IER) Ring Indicator Input Change Enable */ -#define US_IER_DSRIC (0x1 << 17) /**< \brief (US_IER) Data Set Ready Input Change Enable */ -#define US_IER_DCDIC (0x1 << 18) /**< \brief (US_IER) Data Carrier Detect Input Change Interrupt Enable */ -#define US_IER_CTSIC (0x1 << 19) /**< \brief (US_IER) Clear to Send Input Change Interrupt Enable */ -#define US_IER_MANE (0x1 << 24) /**< \brief (US_IER) Manchester Error Interrupt Enable */ -/* -------- US_IDR : (USART Offset: 0x000C) Interrupt Disable Register -------- */ -#define US_IDR_RXRDY (0x1 << 0) /**< \brief (US_IDR) RXRDY Interrupt Disable */ -#define US_IDR_TXRDY (0x1 << 1) /**< \brief (US_IDR) TXRDY Interrupt Disable */ -#define US_IDR_RXBRK (0x1 << 2) /**< \brief (US_IDR) Receiver Break Interrupt Disable */ -#define US_IDR_ENDRX (0x1 << 3) /**< \brief (US_IDR) End of Receive Transfer Interrupt Disable */ -#define US_IDR_ENDTX (0x1 << 4) /**< \brief (US_IDR) End of Transmit Interrupt Disable */ -#define US_IDR_OVRE (0x1 << 5) /**< \brief (US_IDR) Overrun Error Interrupt Disable */ -#define US_IDR_FRAME (0x1 << 6) /**< \brief (US_IDR) Framing Error Interrupt Disable */ -#define US_IDR_PARE (0x1 << 7) /**< \brief (US_IDR) Parity Error Interrupt Disable */ -#define US_IDR_TIMEOUT (0x1 << 8) /**< \brief (US_IDR) Time-out Interrupt Disable */ -#define US_IDR_TXEMPTY (0x1 << 9) /**< \brief (US_IDR) TXEMPTY Interrupt Disable */ -#define US_IDR_ITER__UNRE (0x1 << 10) /**< \brief (US_IDR) Iteration or SPI Underrun Error Interrupt Enable */ -#define US_IDR_TXBUFE (0x1 << 11) /**< \brief (US_IDR) Buffer Empty Interrupt Disable */ -#define US_IDR_RXBUFF (0x1 << 12) /**< \brief (US_IDR) Buffer Full Interrupt Disable */ -#define US_IDR_NACK (0x1 << 13) /**< \brief (US_IDR) Non Acknowledge Interrupt Disable */ -#define US_IDR_RIIC (0x1 << 16) /**< \brief (US_IDR) Ring Indicator Input Change Disable */ -#define US_IDR_DSRIC (0x1 << 17) /**< \brief (US_IDR) Data Set Ready Input Change Disable */ -#define US_IDR_DCDIC (0x1 << 18) /**< \brief (US_IDR) Data Carrier Detect Input Change Interrupt Disable */ -#define US_IDR_CTSIC (0x1 << 19) /**< \brief (US_IDR) Clear to Send Input Change Interrupt Disable */ -#define US_IDR_MANE (0x1 << 24) /**< \brief (US_IDR) Manchester Error Interrupt Disable */ -/* -------- US_IMR : (USART Offset: 0x0010) Interrupt Mask Register -------- */ -#define US_IMR_RXRDY (0x1 << 0) /**< \brief (US_IMR) RXRDY Interrupt Mask */ -#define US_IMR_TXRDY (0x1 << 1) /**< \brief (US_IMR) TXRDY Interrupt Mask */ -#define US_IMR_RXBRK (0x1 << 2) /**< \brief (US_IMR) Receiver Break Interrupt Mask */ -#define US_IMR_ENDRX (0x1 << 3) /**< \brief (US_IMR) End of Receive Transfer Interrupt Mask */ -#define US_IMR_ENDTX (0x1 << 4) /**< \brief (US_IMR) End of Transmit Interrupt Mask */ -#define US_IMR_OVRE (0x1 << 5) /**< \brief (US_IMR) Overrun Error Interrupt Mask */ -#define US_IMR_FRAME (0x1 << 6) /**< \brief (US_IMR) Framing Error Interrupt Mask */ -#define US_IMR_PARE (0x1 << 7) /**< \brief (US_IMR) Parity Error Interrupt Mask */ -#define US_IMR_TIMEOUT (0x1 << 8) /**< \brief (US_IMR) Time-out Interrupt Mask */ -#define US_IMR_TXEMPTY (0x1 << 9) /**< \brief (US_IMR) TXEMPTY Interrupt Mask */ -#define US_IMR_ITER__UNRE (0x1 << 10) /**< \brief (US_IMR) Iteration or SPI Underrun Error Interrupt Enable */ -#define US_IMR_TXBUFE (0x1 << 11) /**< \brief (US_IMR) Buffer Empty Interrupt Mask */ -#define US_IMR_RXBUFF (0x1 << 12) /**< \brief (US_IMR) Buffer Full Interrupt Mask */ -#define US_IMR_NACK (0x1 << 13) /**< \brief (US_IMR) Non Acknowledge Interrupt Mask */ -#define US_IMR_RIIC (0x1 << 16) /**< \brief (US_IMR) Ring Indicator Input Change Mask */ -#define US_IMR_DSRIC (0x1 << 17) /**< \brief (US_IMR) Data Set Ready Input Change Mask */ -#define US_IMR_DCDIC (0x1 << 18) /**< \brief (US_IMR) Data Carrier Detect Input Change Interrupt Mask */ -#define US_IMR_CTSIC (0x1 << 19) /**< \brief (US_IMR) Clear to Send Input Change Interrupt Mask */ -#define US_IMR_MANE (0x1 << 24) /**< \brief (US_IMR) Manchester Error Interrupt Mask */ -/* -------- US_CSR : (USART Offset: 0x0014) Channel Status Register -------- */ -#define US_CSR_RXRDY (0x1 << 0) /**< \brief (US_CSR) Receiver Ready */ -#define US_CSR_TXRDY (0x1 << 1) /**< \brief (US_CSR) Transmitter Ready */ -#define US_CSR_RXBRK (0x1 << 2) /**< \brief (US_CSR) Break Received/End of Break */ -#define US_CSR_ENDRX (0x1 << 3) /**< \brief (US_CSR) End of Receiver Transfer */ -#define US_CSR_ENDTX (0x1 << 4) /**< \brief (US_CSR) End of Transmitter Transfer */ -#define US_CSR_OVRE (0x1 << 5) /**< \brief (US_CSR) Overrun Error */ -#define US_CSR_FRAME (0x1 << 6) /**< \brief (US_CSR) Framing Error */ -#define US_CSR_PARE (0x1 << 7) /**< \brief (US_CSR) Parity Error */ -#define US_CSR_TIMEOUT (0x1 << 8) /**< \brief (US_CSR) Receiver Time-out */ -#define US_CSR_TXEMPTY (0x1 << 9) /**< \brief (US_CSR) Transmitter Empty */ -#define US_CSR_ITER__UNRE (0x1 << 10) /**< \brief (US_CSR) Max number of Repetitions Reached or SPI Underrun Error */ -#define US_CSR_TXBUFE (0x1 << 11) /**< \brief (US_CSR) Transmission Buffer Empty */ -#define US_CSR_RXBUFF (0x1 << 12) /**< \brief (US_CSR) Reception Buffer Full */ -#define US_CSR_NACK (0x1 << 13) /**< \brief (US_CSR) */ -#define US_CSR_RIIC (0x1 << 16) /**< \brief (US_CSR) Ring Indicator Input Change Flag */ -#define US_CSR_DSRIC (0x1 << 17) /**< \brief (US_CSR) Data Set Ready Input Change Flag */ -#define US_CSR_DCDIC (0x1 << 18) /**< \brief (US_CSR) Data Carrier Detect Input Change Flag */ -#define US_CSR_CTSIC (0x1 << 19) /**< \brief (US_CSR) Clear to Send Input Change Flag */ -#define US_CSR_RI (0x1 << 20) /**< \brief (US_CSR) Image of RI Input */ -#define US_CSR_DSR (0x1 << 21) /**< \brief (US_CSR) Image of DSR Input */ -#define US_CSR_DCD (0x1 << 22) /**< \brief (US_CSR) Image of DCD Input */ -#define US_CSR_CTS (0x1 << 23) /**< \brief (US_CSR) Image of CTS Input */ -#define US_CSR_MANERR (0x1 << 24) /**< \brief (US_CSR) Manchester Error */ -/* -------- US_RHR : (USART Offset: 0x0018) Receiver Holding Register -------- */ -#define US_RHR_RXCHR (0x1ff << 0) /**< \brief (US_RHR) Received Character */ -#define US_RHR_RXSYNH (0x1 << 15) /**< \brief (US_RHR) Received Sync */ -/* -------- US_THR : (USART Offset: 0x001C) Transmitter Holding Register -------- */ -#define US_THR_TXCHR (0x1ff << 0) /**< \brief (US_THR) Character to be Transmitted */ -#define US_THR_TXSYNH (0x1 << 15) /**< \brief (US_THR) Sync Field to be transmitted */ -/* -------- US_BRGR : (USART Offset: 0x0020) Baud Rate Generator Register -------- */ -#define US_BRGR_CD (0xffff << 0) /**< \brief (US_BRGR) Clock Divider */ -#define US_BRGR_FP (0x7 << 16) /**< \brief (US_BRGR) Fractional Part */ -/* -------- US_RTOR : (USART Offset: 0x0024) Receiver Time-out Register -------- */ -#define US_RTOR_TO (0xffff << 0) /**< \brief (US_RTOR) Time-out Value */ -/* -------- US_TTGR : (USART Offset: 0x0028) Transmitter Timeguard Register -------- */ -#define US_TTGR_TG (0xff << 0) /**< \brief (US_TTGR) Timeguard Value */ -/* -------- US_FIDI : (USART Offset: 0x0040) FI DI Ratio Register -------- */ -#define US_FIDI_FI_DI_RATIO (0x7ff << 0) /**< \brief (US_FIDI) FI Over DI Ratio Value */ -/* -------- US_NER : (USART Offset: 0x0044) Number of Errors Register -------- */ -#define US_NER_NB_ERRORS (0xff << 0) /**< \brief (US_NER) Number of Errors */ -/* -------- US_IF : (USART Offset: 0x004C) IrDA Filter Register -------- */ -#define US_IF_IRDA_FILTER (0xff << 0) /**< \brief (US_IF) IrDA Filter */ -/* -------- US_MAN : (USART Offset: 0x0050) Manchester Encoder Decoder Register -------- */ -#define US_MAN_TX_PL (0xf << 0) /**< \brief (US_MAN) Transmitter Preamble Length */ -#define US_MAN_TX_PP (0x3 << 8) /**< \brief (US_MAN) Transmitter Preamble Pattern */ -#define US_MAN_TX_MPOL (0x1 << 12) /**< \brief (US_MAN) Transmitter Manchester Polarity */ -#define US_MAN_RX_PL (0xf << 16) /**< \brief (US_MAN) Receiver Preamble Length */ -#define US_MAN_RX_PP (0x3 << 24) /**< \brief (US_MAN) Receiver Preamble Pattern detected */ -#define US_MAN_RX_MPOL (0x1 << 28) /**< \brief (US_MAN) Receiver Manchester Polarity */ -#define US_MAN_STUCKTO1 (0x1 << 29) /**< \brief (US_MAN) */ -#define US_MAN_DRIFT (0x1 << 30) /**< \brief (US_MAN) Drift compensation */ -/* -------- US_WPMR : (USART Offset: 0xE4) Write Protect Mode Register -------- */ -#define US_WPMR_WPEN (0x1 << 0) /**< \brief (US_WPMR) Write Protect Enable */ -#define US_WPMR_WPKEY (0xffffff << 8) /**< \brief (US_WPMR) Write Protect KEY */ -/* -------- US_WPSR : (USART Offset: 0xE8) Write Protect Status Register -------- */ -#define US_WPSR_WPVS (0x1 << 0) /**< \brief (US_WPSR) Write Protect Violation Status */ -#define US_WPSR_WPVSRC (0xffff << 8) /**< \brief (US_WPSR) Write Protect Violation Source */ -/* -------- US_VERSION : (USART Offset: 0xFC) Version Register -------- */ -#define US_VERSION_VERSION (0xfff << 0) /**< \brief (US_VERSION) */ -#define US_VERSION_MFN (0x7 << 16) /**< \brief (US_VERSION) */ -/* -------- US_RPR : (USART Offset: 0x100) Receive Pointer Register -------- */ -#define US_RPR_RXPTR (0xffffffff << 0) /**< \brief (US_RPR) Receive Pointer Register */ -/* -------- US_RCR : (USART Offset: 0x104) Receive Counter Register -------- */ -#define US_RCR_RXCTR (0xffff << 0) /**< \brief (US_RCR) Receive Counter Register */ -/* -------- US_TPR : (USART Offset: 0x108) Transmit Pointer Register -------- */ -#define US_TPR_TXPTR (0xffffffff << 0) /**< \brief (US_TPR) Transmit Counter Register */ -/* -------- US_TCR : (USART Offset: 0x10C) Transmit Counter Register -------- */ -#define US_TCR_TXCTR (0xffff << 0) /**< \brief (US_TCR) Transmit Counter Register */ -/* -------- US_RNPR : (USART Offset: 0x110) Receive Next Pointer Register -------- */ -#define US_RNPR_RXNPTR (0xffffffff << 0) /**< \brief (US_RNPR) Receive Next Pointer */ -/* -------- US_RNCR : (USART Offset: 0x114) Receive Next Counter Register -------- */ -#define US_RNCR_RXNCTR (0xffff << 0) /**< \brief (US_RNCR) Receive Next Counter */ -/* -------- US_TNPR : (USART Offset: 0x118) Transmit Next Pointer Register -------- */ -#define US_TNPR_TXNPTR (0xffffffff << 0) /**< \brief (US_TNPR) Transmit Next Pointer */ -/* -------- US_TNCR : (USART Offset: 0x11C) Transmit Next Counter Register -------- */ -#define US_TNCR_TXNCTR (0xffff << 0) /**< \brief (US_TNCR) Transmit Counter Next */ -/* -------- US_PTCR : (USART Offset: 0x120) Transfer Control Register -------- */ -#define US_PTCR_RXTEN (0x1 << 0) /**< \brief (US_PTCR) Receiver Transfer Enable */ -#define US_PTCR_RXTDIS (0x1 << 1) /**< \brief (US_PTCR) Receiver Transfer Disable */ -#define US_PTCR_TXTEN (0x1 << 8) /**< \brief (US_PTCR) Transmitter Transfer Enable */ -#define US_PTCR_TXTDIS (0x1 << 9) /**< \brief (US_PTCR) Transmitter Transfer Disable */ -/* -------- US_PTSR : (USART Offset: 0x124) Transfer Status Register -------- */ -#define US_PTSR_RXTEN (0x1 << 0) /**< \brief (US_PTSR) Receiver Transfer Enable */ -#define US_PTSR_TXTEN (0x1 << 8) /**< \brief (US_PTSR) Transmitter Transfer Enable */ - -/*@}*/ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Watchdog Timer */ -/* ============================================================================= */ -/** \addtogroup AT91SAM3S_WDT Watchdog Timer */ -/*@{*/ - -#ifndef __ASSEMBLY__ -/** \brief Wdt hardware registers */ -typedef struct { - WoReg WDT_CR; /**< \brief (Wdt Offset: 0x00) Control Register */ - RwReg WDT_MR; /**< \brief (Wdt Offset: 0x04) Mode Register */ - RoReg WDT_SR; /**< \brief (Wdt Offset: 0x08) Status Register */ -} Wdt; -#endif /* __ASSEMBLY__ */ -/* -------- WDT_CR : (WDT Offset: 0x00) Control Register -------- */ -#define WDT_CR_WDRSTT (0x1 << 0) /**< \brief (WDT_CR) Watchdog Restart */ -#define WDT_CR_KEY (0xff << 24) /**< \brief (WDT_CR) Password */ -/* -------- WDT_MR : (WDT Offset: 0x04) Mode Register -------- */ -#define WDT_MR_WDV (0xfff << 0) /**< \brief (WDT_MR) Watchdog Counter Value */ -#define WDT_MR_WDFIEN (0x1 << 12) /**< \brief (WDT_MR) Watchdog Fault Interrupt Enable */ -#define WDT_MR_WDRSTEN (0x1 << 13) /**< \brief (WDT_MR) Watchdog Reset Enable */ -#define WDT_MR_WDRPROC (0x1 << 14) /**< \brief (WDT_MR) Watchdog Reset Processor */ -#define WDT_MR_WDDIS (0x1 << 15) /**< \brief (WDT_MR) Watchdog Disable */ -#define WDT_MR_WDD (0xfff << 16) /**< \brief (WDT_MR) Watchdog Delta Value */ -#define WDT_MR_WDDBGHLT (0x1 << 28) /**< \brief (WDT_MR) Watchdog Debug Halt */ -#define WDT_MR_WDIDLEHLT (0x1 << 29) /**< \brief (WDT_MR) Watchdog Idle Halt */ -/* -------- WDT_SR : (WDT Offset: 0x08) Status Register -------- */ -#define WDT_SR_WDUNF (0x1 << 0) /**< \brief (WDT_SR) Watchdog Underflow */ -#define WDT_SR_WDERR (0x1 << 1) /**< \brief (WDT_SR) Watchdog Error */ - -/*@}*/ - -/*@}*/ - -/* ***************************************************************************** */ -/* REGISTER ACCESS DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_reg Registers Access Definitions */ -/*@{*/ - -/* ========== Register definition for HSMCI peripheral ========== */ -#define REG_HSMCI_CR REG_ACCESS(WoReg, 0x40000000U) /**< \brief (HSMCI) Control Register */ -#define REG_HSMCI_MR REG_ACCESS(RwReg, 0x40000004U) /**< \brief (HSMCI) Mode Register */ -#define REG_HSMCI_DTOR REG_ACCESS(RwReg, 0x40000008U) /**< \brief (HSMCI) Data Timeout Register */ -#define REG_HSMCI_SDCR REG_ACCESS(RwReg, 0x4000000CU) /**< \brief (HSMCI) SD/SDIO Card Register */ -#define REG_HSMCI_ARGR REG_ACCESS(RwReg, 0x40000010U) /**< \brief (HSMCI) Argument Register */ -#define REG_HSMCI_CMDR REG_ACCESS(WoReg, 0x40000014U) /**< \brief (HSMCI) Command Register */ -#define REG_HSMCI_BLKR REG_ACCESS(RwReg, 0x40000018U) /**< \brief (HSMCI) Block Register */ -#define REG_HSMCI_CSTOR REG_ACCESS(RwReg, 0x4000001CU) /**< \brief (HSMCI) Completion Signal Timeout Register */ -#define REG_HSMCI_RSPR REG_ACCESS(RoReg, 0x40000020U) /**< \brief (HSMCI) Response Register */ -#define REG_HSMCI_RDR REG_ACCESS(RoReg, 0x40000030U) /**< \brief (HSMCI) Receive Data Register */ -#define REG_HSMCI_TDR REG_ACCESS(WoReg, 0x40000034U) /**< \brief (HSMCI) Transmit Data Register */ -#define REG_HSMCI_SR REG_ACCESS(RoReg, 0x40000040U) /**< \brief (HSMCI) Status Register */ -#define REG_HSMCI_IER REG_ACCESS(WoReg, 0x40000044U) /**< \brief (HSMCI) Interrupt Enable Register */ -#define REG_HSMCI_IDR REG_ACCESS(WoReg, 0x40000048U) /**< \brief (HSMCI) Interrupt Disable Register */ -#define REG_HSMCI_IMR REG_ACCESS(RoReg, 0x4000004CU) /**< \brief (HSMCI) Interrupt Mask Register */ -#define REG_HSMCI_CFG REG_ACCESS(RwReg, 0x40000054U) /**< \brief (HSMCI) Configuration Register */ -#define REG_HSMCI_WPMR REG_ACCESS(RwReg, 0x400000E4U) /**< \brief (HSMCI) Write Protection Mode Register */ -#define REG_HSMCI_WPSR REG_ACCESS(RoReg, 0x400000E8U) /**< \brief (HSMCI) Write Protection Status Register */ -#define REG_HSMCI_RPR REG_ACCESS(RwReg, 0x40000100U) /**< \brief (HSMCI) Receive Pointer Register */ -#define REG_HSMCI_RCR REG_ACCESS(RwReg, 0x40000104U) /**< \brief (HSMCI) Receive Counter Register */ -#define REG_HSMCI_TPR REG_ACCESS(RwReg, 0x40000108U) /**< \brief (HSMCI) Transmit Pointer Register */ -#define REG_HSMCI_TCR REG_ACCESS(RwReg, 0x4000010CU) /**< \brief (HSMCI) Transmit Counter Register */ -#define REG_HSMCI_RNPR REG_ACCESS(RwReg, 0x40000110U) /**< \brief (HSMCI) Receive Next Pointer Register */ -#define REG_HSMCI_RNCR REG_ACCESS(RwReg, 0x40000114U) /**< \brief (HSMCI) Receive Next Counter Register */ -#define REG_HSMCI_TNPR REG_ACCESS(RwReg, 0x40000118U) /**< \brief (HSMCI) Transmit Next Pointer Register */ -#define REG_HSMCI_TNCR REG_ACCESS(RwReg, 0x4000011CU) /**< \brief (HSMCI) Transmit Next Counter Register */ -#define REG_HSMCI_PTCR REG_ACCESS(WoReg, 0x40000120U) /**< \brief (HSMCI) Transfer Control Register */ -#define REG_HSMCI_PTSR REG_ACCESS(RoReg, 0x40000124U) /**< \brief (HSMCI) Transfer Status Register */ -/* ========== Register definition for SSC peripheral ========== */ -#define REG_SSC_CR REG_ACCESS(WoReg, 0x40004000U) /**< \brief (SSC) Control Register */ -#define REG_SSC_CMR REG_ACCESS(RwReg, 0x40004004U) /**< \brief (SSC) Clock Mode Register */ -#define REG_SSC_RCMR REG_ACCESS(RwReg, 0x40004010U) /**< \brief (SSC) Receive Clock Mode Register */ -#define REG_SSC_RFMR REG_ACCESS(RwReg, 0x40004014U) /**< \brief (SSC) Receive Frame Mode Register */ -#define REG_SSC_TCMR REG_ACCESS(RwReg, 0x40004018U) /**< \brief (SSC) Transmit Clock Mode Register */ -#define REG_SSC_TFMR REG_ACCESS(RwReg, 0x4000401CU) /**< \brief (SSC) Transmit Frame Mode Register */ -#define REG_SSC_RHR REG_ACCESS(RoReg, 0x40004020U) /**< \brief (SSC) Receive Holding Register */ -#define REG_SSC_THR REG_ACCESS(WoReg, 0x40004024U) /**< \brief (SSC) Transmit Holding Register */ -#define REG_SSC_RSHR REG_ACCESS(RoReg, 0x40004030U) /**< \brief (SSC) Receive Sync. Holding Register */ -#define REG_SSC_TSHR REG_ACCESS(RwReg, 0x40004034U) /**< \brief (SSC) Transmit Sync. Holding Register */ -#define REG_SSC_RC0R REG_ACCESS(RwReg, 0x40004038U) /**< \brief (SSC) Receive Compare 0 Register */ -#define REG_SSC_RC1R REG_ACCESS(RwReg, 0x4000403CU) /**< \brief (SSC) Receive Compare 1 Register */ -#define REG_SSC_SR REG_ACCESS(RoReg, 0x40004040U) /**< \brief (SSC) Status Register */ -#define REG_SSC_IER REG_ACCESS(WoReg, 0x40004044U) /**< \brief (SSC) Interrupt Enable Register */ -#define REG_SSC_IDR REG_ACCESS(WoReg, 0x40004048U) /**< \brief (SSC) Interrupt Disable Register */ -#define REG_SSC_IMR REG_ACCESS(RoReg, 0x4000404CU) /**< \brief (SSC) Interrupt Mask Register */ -#define REG_SSC_WPMR REG_ACCESS(RwReg, 0x400040E4U) /**< \brief (SSC) Write Protect Mode Register */ -#define REG_SSC_WPSR REG_ACCESS(RoReg, 0x400040E8U) /**< \brief (SSC) Write Protect Status Register */ -#define REG_SSC_RPR REG_ACCESS(RwReg, 0x40004100U) /**< \brief (SSC) Receive Pointer Register */ -#define REG_SSC_RCR REG_ACCESS(RwReg, 0x40004104U) /**< \brief (SSC) Receive Counter Register */ -#define REG_SSC_TPR REG_ACCESS(RwReg, 0x40004108U) /**< \brief (SSC) Transmit Pointer Register */ -#define REG_SSC_TCR REG_ACCESS(RwReg, 0x4000410CU) /**< \brief (SSC) Transmit Counter Register */ -#define REG_SSC_RNPR REG_ACCESS(RwReg, 0x40004110U) /**< \brief (SSC) Receive Next Pointer Register */ -#define REG_SSC_RNCR REG_ACCESS(RwReg, 0x40004114U) /**< \brief (SSC) Receive Next Counter Register */ -#define REG_SSC_TNPR REG_ACCESS(RwReg, 0x40004118U) /**< \brief (SSC) Transmit Next Pointer Register */ -#define REG_SSC_TNCR REG_ACCESS(RwReg, 0x4000411CU) /**< \brief (SSC) Transmit Next Counter Register */ -#define REG_SSC_PTCR REG_ACCESS(WoReg, 0x40004120U) /**< \brief (SSC) Transfer Control Register */ -#define REG_SSC_PTSR REG_ACCESS(RoReg, 0x40004124U) /**< \brief (SSC) Transfer Status Register */ -/* ========== Register definition for SPI peripheral ========== */ -#define REG_SPI_CR REG_ACCESS(WoReg, 0x40008000U) /**< \brief (SPI) Control Register */ -#define REG_SPI_MR REG_ACCESS(RwReg, 0x40008004U) /**< \brief (SPI) Mode Register */ -#define REG_SPI_RDR REG_ACCESS(RoReg, 0x40008008U) /**< \brief (SPI) Receive Data Register */ -#define REG_SPI_TDR REG_ACCESS(WoReg, 0x4000800CU) /**< \brief (SPI) Transmit Data Register */ -#define REG_SPI_SR REG_ACCESS(RoReg, 0x40008010U) /**< \brief (SPI) Status Register */ -#define REG_SPI_IER REG_ACCESS(WoReg, 0x40008014U) /**< \brief (SPI) Interrupt Enable Register */ -#define REG_SPI_IDR REG_ACCESS(WoReg, 0x40008018U) /**< \brief (SPI) Interrupt Disable Register */ -#define REG_SPI_IMR REG_ACCESS(RoReg, 0x4000801CU) /**< \brief (SPI) Interrupt Mask Register */ -#define REG_SPI_CSR REG_ACCESS(RwReg, 0x40008030U) /**< \brief (SPI) Chip Select Register */ -#define REG_SPI_WPMR REG_ACCESS(RwReg, 0x400080E4U) /**< \brief (SPI) Write Protection Control Register */ -#define REG_SPI_WPSR REG_ACCESS(RoReg, 0x400080E8U) /**< \brief (SPI) Write Protection Status Register */ -#define REG_SPI_RPR REG_ACCESS(RwReg, 0x40008100U) /**< \brief (SPI) Receive Pointer Register */ -#define REG_SPI_RCR REG_ACCESS(RwReg, 0x40008104U) /**< \brief (SPI) Receive Counter Register */ -#define REG_SPI_TPR REG_ACCESS(RwReg, 0x40008108U) /**< \brief (SPI) Transmit Pointer Register */ -#define REG_SPI_TCR REG_ACCESS(RwReg, 0x4000810CU) /**< \brief (SPI) Transmit Counter Register */ -#define REG_SPI_RNPR REG_ACCESS(RwReg, 0x40008110U) /**< \brief (SPI) Receive Next Pointer Register */ -#define REG_SPI_RNCR REG_ACCESS(RwReg, 0x40008114U) /**< \brief (SPI) Receive Next Counter Register */ -#define REG_SPI_TNPR REG_ACCESS(RwReg, 0x40008118U) /**< \brief (SPI) Transmit Next Pointer Register */ -#define REG_SPI_TNCR REG_ACCESS(RwReg, 0x4000811CU) /**< \brief (SPI) Transmit Next Counter Register */ -#define REG_SPI_PTCR REG_ACCESS(WoReg, 0x40008120U) /**< \brief (SPI) Transfer Control Register */ -#define REG_SPI_PTSR REG_ACCESS(RoReg, 0x40008124U) /**< \brief (SPI) Transfer Status Register */ -/* ========== Register definition for TC0 peripheral ========== */ -#define REG_TC0_CCR0 REG_ACCESS(WoReg, 0x40010000U) /**< \brief (TC0) Channel Control Register (channel = 0) */ -#define REG_TC0_CMR0 REG_ACCESS(RwReg, 0x40010004U) /**< \brief (TC0) Channel Mode Register (channel = 0) */ -#define REG_TC0_CV0 REG_ACCESS(RoReg, 0x40010010U) /**< \brief (TC0) Counter Value (channel = 0) */ -#define REG_TC0_RA0 REG_ACCESS(RwReg, 0x40010014U) /**< \brief (TC0) Register A (channel = 0) */ -#define REG_TC0_RB0 REG_ACCESS(RwReg, 0x40010018U) /**< \brief (TC0) Register B (channel = 0) */ -#define REG_TC0_RC0 REG_ACCESS(RwReg, 0x4001001CU) /**< \brief (TC0) Register C (channel = 0) */ -#define REG_TC0_SR0 REG_ACCESS(RoReg, 0x40010020U) /**< \brief (TC0) Status Register (channel = 0) */ -#define REG_TC0_IER0 REG_ACCESS(WoReg, 0x40010024U) /**< \brief (TC0) Interrupt Enable Register (channel = 0) */ -#define REG_TC0_IDR0 REG_ACCESS(WoReg, 0x40010028U) /**< \brief (TC0) Interrupt Disable Register (channel = 0) */ -#define REG_TC0_IMR0 REG_ACCESS(RoReg, 0x4001002CU) /**< \brief (TC0) Interrupt Mask Register (channel = 0) */ -#define REG_TC0_CCR1 REG_ACCESS(WoReg, 0x40010040U) /**< \brief (TC0) Channel Control Register (channel = 1) */ -#define REG_TC0_CMR1 REG_ACCESS(RwReg, 0x40010044U) /**< \brief (TC0) Channel Mode Register (channel = 1) */ -#define REG_TC0_CV1 REG_ACCESS(RoReg, 0x40010050U) /**< \brief (TC0) Counter Value (channel = 1) */ -#define REG_TC0_RA1 REG_ACCESS(RwReg, 0x40010054U) /**< \brief (TC0) Register A (channel = 1) */ -#define REG_TC0_RB1 REG_ACCESS(RwReg, 0x40010058U) /**< \brief (TC0) Register B (channel = 1) */ -#define REG_TC0_RC1 REG_ACCESS(RwReg, 0x4001005CU) /**< \brief (TC0) Register C (channel = 1) */ -#define REG_TC0_SR1 REG_ACCESS(RoReg, 0x40010060U) /**< \brief (TC0) Status Register (channel = 1) */ -#define REG_TC0_IER1 REG_ACCESS(WoReg, 0x40010064U) /**< \brief (TC0) Interrupt Enable Register (channel = 1) */ -#define REG_TC0_IDR1 REG_ACCESS(WoReg, 0x40010068U) /**< \brief (TC0) Interrupt Disable Register (channel = 1) */ -#define REG_TC0_IMR1 REG_ACCESS(RoReg, 0x4001006CU) /**< \brief (TC0) Interrupt Mask Register (channel = 1) */ -#define REG_TC0_CCR2 REG_ACCESS(WoReg, 0x40010080U) /**< \brief (TC0) Channel Control Register (channel = 2) */ -#define REG_TC0_CMR2 REG_ACCESS(RwReg, 0x40010084U) /**< \brief (TC0) Channel Mode Register (channel = 2) */ -#define REG_TC0_CV2 REG_ACCESS(RoReg, 0x40010090U) /**< \brief (TC0) Counter Value (channel = 2) */ -#define REG_TC0_RA2 REG_ACCESS(RwReg, 0x40010094U) /**< \brief (TC0) Register A (channel = 2) */ -#define REG_TC0_RB2 REG_ACCESS(RwReg, 0x40010098U) /**< \brief (TC0) Register B (channel = 2) */ -#define REG_TC0_RC2 REG_ACCESS(RwReg, 0x4001009CU) /**< \brief (TC0) Register C (channel = 2) */ -#define REG_TC0_SR2 REG_ACCESS(RoReg, 0x400100A0U) /**< \brief (TC0) Status Register (channel = 2) */ -#define REG_TC0_IER2 REG_ACCESS(WoReg, 0x400100A4U) /**< \brief (TC0) Interrupt Enable Register (channel = 2) */ -#define REG_TC0_IDR2 REG_ACCESS(WoReg, 0x400100A8U) /**< \brief (TC0) Interrupt Disable Register (channel = 2) */ -#define REG_TC0_IMR2 REG_ACCESS(RoReg, 0x400100ACU) /**< \brief (TC0) Interrupt Mask Register (channel = 2) */ -#define REG_TC0_BCR REG_ACCESS(WoReg, 0x400100C0U) /**< \brief (TC0) Block Control Register */ -#define REG_TC0_BMR REG_ACCESS(RwReg, 0x400100C4U) /**< \brief (TC0) Block Mode Register */ -#define REG_TC0_QIER REG_ACCESS(WoReg, 0x400100C8U) /**< \brief (TC0) QDEC Interrupt Enable Register */ -#define REG_TC0_QIDR REG_ACCESS(WoReg, 0x400100CCU) /**< \brief (TC0) QDEC Interrupt Disable Register */ -#define REG_TC0_QIMR REG_ACCESS(RoReg, 0x400100D0U) /**< \brief (TC0) QDEC Interrupt Mask Register */ -#define REG_TC0_QISR REG_ACCESS(RoReg, 0x400100D4U) /**< \brief (TC0) QDEC Interrupt Status Register */ -#define REG_TC0_FMR REG_ACCESS(RwReg, 0x400100D8U) /**< \brief (TC0) Fault Mode Register */ -#define REG_TC0_WPMR REG_ACCESS(RwReg, 0x400100E4U) /**< \brief (TC0) Write Protect Mode Register */ -#define REG_TC0_VER REG_ACCESS(RoReg, 0x400100FCU) /**< \brief (TC0) Version Register */ -/* ========== Register definition for TC1 peripheral ========== */ -#define REG_TC1_CCR0 REG_ACCESS(WoReg, 0x40014000U) /**< \brief (TC1) Channel Control Register (channel = 0) */ -#define REG_TC1_CMR0 REG_ACCESS(RwReg, 0x40014004U) /**< \brief (TC1) Channel Mode Register (channel = 0) */ -#define REG_TC1_CV0 REG_ACCESS(RoReg, 0x40014010U) /**< \brief (TC1) Counter Value (channel = 0) */ -#define REG_TC1_RA0 REG_ACCESS(RwReg, 0x40014014U) /**< \brief (TC1) Register A (channel = 0) */ -#define REG_TC1_RB0 REG_ACCESS(RwReg, 0x40014018U) /**< \brief (TC1) Register B (channel = 0) */ -#define REG_TC1_RC0 REG_ACCESS(RwReg, 0x4001401CU) /**< \brief (TC1) Register C (channel = 0) */ -#define REG_TC1_SR0 REG_ACCESS(RoReg, 0x40014020U) /**< \brief (TC1) Status Register (channel = 0) */ -#define REG_TC1_IER0 REG_ACCESS(WoReg, 0x40014024U) /**< \brief (TC1) Interrupt Enable Register (channel = 0) */ -#define REG_TC1_IDR0 REG_ACCESS(WoReg, 0x40014028U) /**< \brief (TC1) Interrupt Disable Register (channel = 0) */ -#define REG_TC1_IMR0 REG_ACCESS(RoReg, 0x4001402CU) /**< \brief (TC1) Interrupt Mask Register (channel = 0) */ -#define REG_TC1_CCR1 REG_ACCESS(WoReg, 0x40014040U) /**< \brief (TC1) Channel Control Register (channel = 1) */ -#define REG_TC1_CMR1 REG_ACCESS(RwReg, 0x40014044U) /**< \brief (TC1) Channel Mode Register (channel = 1) */ -#define REG_TC1_CV1 REG_ACCESS(RoReg, 0x40014050U) /**< \brief (TC1) Counter Value (channel = 1) */ -#define REG_TC1_RA1 REG_ACCESS(RwReg, 0x40014054U) /**< \brief (TC1) Register A (channel = 1) */ -#define REG_TC1_RB1 REG_ACCESS(RwReg, 0x40014058U) /**< \brief (TC1) Register B (channel = 1) */ -#define REG_TC1_RC1 REG_ACCESS(RwReg, 0x4001405CU) /**< \brief (TC1) Register C (channel = 1) */ -#define REG_TC1_SR1 REG_ACCESS(RoReg, 0x40014060U) /**< \brief (TC1) Status Register (channel = 1) */ -#define REG_TC1_IER1 REG_ACCESS(WoReg, 0x40014064U) /**< \brief (TC1) Interrupt Enable Register (channel = 1) */ -#define REG_TC1_IDR1 REG_ACCESS(WoReg, 0x40014068U) /**< \brief (TC1) Interrupt Disable Register (channel = 1) */ -#define REG_TC1_IMR1 REG_ACCESS(RoReg, 0x4001406CU) /**< \brief (TC1) Interrupt Mask Register (channel = 1) */ -#define REG_TC1_CCR2 REG_ACCESS(WoReg, 0x40014080U) /**< \brief (TC1) Channel Control Register (channel = 2) */ -#define REG_TC1_CMR2 REG_ACCESS(RwReg, 0x40014084U) /**< \brief (TC1) Channel Mode Register (channel = 2) */ -#define REG_TC1_CV2 REG_ACCESS(RoReg, 0x40014090U) /**< \brief (TC1) Counter Value (channel = 2) */ -#define REG_TC1_RA2 REG_ACCESS(RwReg, 0x40014094U) /**< \brief (TC1) Register A (channel = 2) */ -#define REG_TC1_RB2 REG_ACCESS(RwReg, 0x40014098U) /**< \brief (TC1) Register B (channel = 2) */ -#define REG_TC1_RC2 REG_ACCESS(RwReg, 0x4001409CU) /**< \brief (TC1) Register C (channel = 2) */ -#define REG_TC1_SR2 REG_ACCESS(RoReg, 0x400140A0U) /**< \brief (TC1) Status Register (channel = 2) */ -#define REG_TC1_IER2 REG_ACCESS(WoReg, 0x400140A4U) /**< \brief (TC1) Interrupt Enable Register (channel = 2) */ -#define REG_TC1_IDR2 REG_ACCESS(WoReg, 0x400140A8U) /**< \brief (TC1) Interrupt Disable Register (channel = 2) */ -#define REG_TC1_IMR2 REG_ACCESS(RoReg, 0x400140ACU) /**< \brief (TC1) Interrupt Mask Register (channel = 2) */ -#define REG_TC1_BCR REG_ACCESS(WoReg, 0x400140C0U) /**< \brief (TC1) Block Control Register */ -#define REG_TC1_BMR REG_ACCESS(RwReg, 0x400140C4U) /**< \brief (TC1) Block Mode Register */ -#define REG_TC1_QIER REG_ACCESS(WoReg, 0x400140C8U) /**< \brief (TC1) QDEC Interrupt Enable Register */ -#define REG_TC1_QIDR REG_ACCESS(WoReg, 0x400140CCU) /**< \brief (TC1) QDEC Interrupt Disable Register */ -#define REG_TC1_QIMR REG_ACCESS(RoReg, 0x400140D0U) /**< \brief (TC1) QDEC Interrupt Mask Register */ -#define REG_TC1_QISR REG_ACCESS(RoReg, 0x400140D4U) /**< \brief (TC1) QDEC Interrupt Status Register */ -#define REG_TC1_FMR REG_ACCESS(RwReg, 0x400140D8U) /**< \brief (TC1) Fault Mode Register */ -#define REG_TC1_WPMR REG_ACCESS(RwReg, 0x400140E4U) /**< \brief (TC1) Write Protect Mode Register */ -#define REG_TC1_VER REG_ACCESS(RoReg, 0x400140FCU) /**< \brief (TC1) Version Register */ -/* ========== Register definition for TWI0 peripheral ========== */ -#define REG_TWI0_CR REG_ACCESS(WoReg, 0x40018000U) /**< \brief (TWI0) Control Register */ -#define REG_TWI0_MMR REG_ACCESS(RwReg, 0x40018004U) /**< \brief (TWI0) Master Mode Register */ -#define REG_TWI0_SMR REG_ACCESS(RwReg, 0x40018008U) /**< \brief (TWI0) Slave Mode Register */ -#define REG_TWI0_IADR REG_ACCESS(RwReg, 0x4001800CU) /**< \brief (TWI0) Internal Address Register */ -#define REG_TWI0_CWGR REG_ACCESS(RwReg, 0x40018010U) /**< \brief (TWI0) Clock Waveform Generator Register */ -#define REG_TWI0_SR REG_ACCESS(RoReg, 0x40018020U) /**< \brief (TWI0) Status Register */ -#define REG_TWI0_IER REG_ACCESS(WoReg, 0x40018024U) /**< \brief (TWI0) Interrupt Enable Register */ -#define REG_TWI0_IDR REG_ACCESS(WoReg, 0x40018028U) /**< \brief (TWI0) Interrupt Disable Register */ -#define REG_TWI0_IMR REG_ACCESS(RoReg, 0x4001802CU) /**< \brief (TWI0) Interrupt Mask Register */ -#define REG_TWI0_RHR REG_ACCESS(RoReg, 0x40018030U) /**< \brief (TWI0) Receive Holding Register */ -#define REG_TWI0_THR REG_ACCESS(WoReg, 0x40018034U) /**< \brief (TWI0) Transmit Holding Register */ -#define REG_TWI0_RPR REG_ACCESS(RwReg, 0x40018100U) /**< \brief (TWI0) Receive Pointer Register */ -#define REG_TWI0_RCR REG_ACCESS(RwReg, 0x40018104U) /**< \brief (TWI0) Receive Counter Register */ -#define REG_TWI0_TPR REG_ACCESS(RwReg, 0x40018108U) /**< \brief (TWI0) Transmit Pointer Register */ -#define REG_TWI0_TCR REG_ACCESS(RwReg, 0x4001810CU) /**< \brief (TWI0) Transmit Counter Register */ -#define REG_TWI0_RNPR REG_ACCESS(RwReg, 0x40018110U) /**< \brief (TWI0) Receive Next Pointer Register */ -#define REG_TWI0_RNCR REG_ACCESS(RwReg, 0x40018114U) /**< \brief (TWI0) Receive Next Counter Register */ -#define REG_TWI0_TNPR REG_ACCESS(RwReg, 0x40018118U) /**< \brief (TWI0) Transmit Next Pointer Register */ -#define REG_TWI0_TNCR REG_ACCESS(RwReg, 0x4001811CU) /**< \brief (TWI0) Transmit Next Counter Register */ -#define REG_TWI0_PTCR REG_ACCESS(WoReg, 0x40018120U) /**< \brief (TWI0) Transfer Control Register */ -#define REG_TWI0_PTSR REG_ACCESS(RoReg, 0x40018124U) /**< \brief (TWI0) Transfer Status Register */ -/* ========== Register definition for TWI1 peripheral ========== */ -#define REG_TWI1_CR REG_ACCESS(WoReg, 0x4001C000U) /**< \brief (TWI1) Control Register */ -#define REG_TWI1_MMR REG_ACCESS(RwReg, 0x4001C004U) /**< \brief (TWI1) Master Mode Register */ -#define REG_TWI1_SMR REG_ACCESS(RwReg, 0x4001C008U) /**< \brief (TWI1) Slave Mode Register */ -#define REG_TWI1_IADR REG_ACCESS(RwReg, 0x4001C00CU) /**< \brief (TWI1) Internal Address Register */ -#define REG_TWI1_CWGR REG_ACCESS(RwReg, 0x4001C010U) /**< \brief (TWI1) Clock Waveform Generator Register */ -#define REG_TWI1_SR REG_ACCESS(RoReg, 0x4001C020U) /**< \brief (TWI1) Status Register */ -#define REG_TWI1_IER REG_ACCESS(WoReg, 0x4001C024U) /**< \brief (TWI1) Interrupt Enable Register */ -#define REG_TWI1_IDR REG_ACCESS(WoReg, 0x4001C028U) /**< \brief (TWI1) Interrupt Disable Register */ -#define REG_TWI1_IMR REG_ACCESS(RoReg, 0x4001C02CU) /**< \brief (TWI1) Interrupt Mask Register */ -#define REG_TWI1_RHR REG_ACCESS(RoReg, 0x4001C030U) /**< \brief (TWI1) Receive Holding Register */ -#define REG_TWI1_THR REG_ACCESS(WoReg, 0x4001C034U) /**< \brief (TWI1) Transmit Holding Register */ -#define REG_TWI1_RPR REG_ACCESS(RwReg, 0x4001C100U) /**< \brief (TWI1) Receive Pointer Register */ -#define REG_TWI1_RCR REG_ACCESS(RwReg, 0x4001C104U) /**< \brief (TWI1) Receive Counter Register */ -#define REG_TWI1_TPR REG_ACCESS(RwReg, 0x4001C108U) /**< \brief (TWI1) Transmit Pointer Register */ -#define REG_TWI1_TCR REG_ACCESS(RwReg, 0x4001C10CU) /**< \brief (TWI1) Transmit Counter Register */ -#define REG_TWI1_RNPR REG_ACCESS(RwReg, 0x4001C110U) /**< \brief (TWI1) Receive Next Pointer Register */ -#define REG_TWI1_RNCR REG_ACCESS(RwReg, 0x4001C114U) /**< \brief (TWI1) Receive Next Counter Register */ -#define REG_TWI1_TNPR REG_ACCESS(RwReg, 0x4001C118U) /**< \brief (TWI1) Transmit Next Pointer Register */ -#define REG_TWI1_TNCR REG_ACCESS(RwReg, 0x4001C11CU) /**< \brief (TWI1) Transmit Next Counter Register */ -#define REG_TWI1_PTCR REG_ACCESS(WoReg, 0x4001C120U) /**< \brief (TWI1) Transfer Control Register */ -#define REG_TWI1_PTSR REG_ACCESS(RoReg, 0x4001C124U) /**< \brief (TWI1) Transfer Status Register */ -/* ========== Register definition for PWM peripheral ========== */ -#define REG_PWM_CLK REG_ACCESS(RwReg, 0x40020000U) /**< \brief (PWM) PWM Clock Register */ -#define REG_PWM_ENA REG_ACCESS(WoReg, 0x40020004U) /**< \brief (PWM) PWM Enable Register */ -#define REG_PWM_DIS REG_ACCESS(WoReg, 0x40020008U) /**< \brief (PWM) PWM Disable Register */ -#define REG_PWM_SR REG_ACCESS(RoReg, 0x4002000CU) /**< \brief (PWM) PWM Status Register */ -#define REG_PWM_IER1 REG_ACCESS(WoReg, 0x40020010U) /**< \brief (PWM) PWM Interrupt Enable Register 1 */ -#define REG_PWM_IDR1 REG_ACCESS(WoReg, 0x40020014U) /**< \brief (PWM) PWM Interrupt Disable Register 1 */ -#define REG_PWM_IMR1 REG_ACCESS(RoReg, 0x40020018U) /**< \brief (PWM) PWM Interrupt Mask Register 1 */ -#define REG_PWM_ISR1 REG_ACCESS(RoReg, 0x4002001CU) /**< \brief (PWM) PWM Interrupt Status Register 1 */ -#define REG_PWM_SCM REG_ACCESS(RwReg, 0x40020020U) /**< \brief (PWM) PWM Sync Channels Mode Register */ -#define REG_PWM_SCUC REG_ACCESS(RwReg, 0x40020028U) /**< \brief (PWM) PWM Sync Channels Update Control Register */ -#define REG_PWM_SCUP REG_ACCESS(RwReg, 0x4002002CU) /**< \brief (PWM) PWM Sync Channels Update Period Register */ -#define REG_PWM_SCUPUPD REG_ACCESS(WoReg, 0x40020030U) /**< \brief (PWM) PWM Sync Channels Update Period Update Register */ -#define REG_PWM_IER2 REG_ACCESS(WoReg, 0x40020034U) /**< \brief (PWM) PWM Interrupt Enable Register 2 */ -#define REG_PWM_IDR2 REG_ACCESS(WoReg, 0x40020038U) /**< \brief (PWM) PWM Interrupt Disable Register 2 */ -#define REG_PWM_IMR2 REG_ACCESS(RoReg, 0x4002003CU) /**< \brief (PWM) PWM Interrupt Mask Register 2 */ -#define REG_PWM_ISR2 REG_ACCESS(RoReg, 0x40020040U) /**< \brief (PWM) PWM Interrupt Status Register 2 */ -#define REG_PWM_OOV REG_ACCESS(RwReg, 0x40020044U) /**< \brief (PWM) PWM Output Override Value Register */ -#define REG_PWM_OS REG_ACCESS(RwReg, 0x40020048U) /**< \brief (PWM) PWM Output Selection Register */ -#define REG_PWM_OSS REG_ACCESS(WoReg, 0x4002004CU) /**< \brief (PWM) PWM Output Selection Set Register */ -#define REG_PWM_OSC REG_ACCESS(WoReg, 0x40020050U) /**< \brief (PWM) PWM Output Selection Clear Register */ -#define REG_PWM_OSSUPD REG_ACCESS(WoReg, 0x40020054U) /**< \brief (PWM) PWM Output Selection Set Update Register */ -#define REG_PWM_OSCUPD REG_ACCESS(WoReg, 0x40020058U) /**< \brief (PWM) PWM Output Selection Clear Update Register */ -#define REG_PWM_FMR REG_ACCESS(RwReg, 0x4002005CU) /**< \brief (PWM) PWM Fault Mode Register */ -#define REG_PWM_FSR REG_ACCESS(RoReg, 0x40020060U) /**< \brief (PWM) PWM Fault Status Register */ -#define REG_PWM_FCR REG_ACCESS(WoReg, 0x40020064U) /**< \brief (PWM) PWM Fault Clear Register */ -#define REG_PWM_FPV REG_ACCESS(RwReg, 0x40020068U) /**< \brief (PWM) PWM Fault Protection Value Register */ -#define REG_PWM_FPE REG_ACCESS(RwReg, 0x4002006CU) /**< \brief (PWM) PWM Fault Protection Enable Register */ -#define REG_PWM_ELxMR REG_ACCESS(RwReg, 0x4002007CU) /**< \brief (PWM) PWM Event Line 0 Mode Register */ -#define REG_PWM_SMMR REG_ACCESS(RwReg, 0x400200B0U) /**< \brief (PWM) PWM Stepper Motor Mode Register */ -#define REG_PWM_WPCR REG_ACCESS(WoReg, 0x400200E4U) /**< \brief (PWM) PWM Write Protect Control Register */ -#define REG_PWM_WPSR REG_ACCESS(RoReg, 0x400200E8U) /**< \brief (PWM) PWM Write Protect Status Register */ -#define REG_PWM_RPR REG_ACCESS(RwReg, 0x40020100U) /**< \brief (PWM) Receive Pointer Register */ -#define REG_PWM_RCR REG_ACCESS(RwReg, 0x40020104U) /**< \brief (PWM) Receive Counter Register */ -#define REG_PWM_TPR REG_ACCESS(RwReg, 0x40020108U) /**< \brief (PWM) Transmit Pointer Register */ -#define REG_PWM_TCR REG_ACCESS(RwReg, 0x4002010CU) /**< \brief (PWM) Transmit Counter Register */ -#define REG_PWM_RNPR REG_ACCESS(RwReg, 0x40020110U) /**< \brief (PWM) Receive Next Pointer Register */ -#define REG_PWM_RNCR REG_ACCESS(RwReg, 0x40020114U) /**< \brief (PWM) Receive Next Counter Register */ -#define REG_PWM_TNPR REG_ACCESS(RwReg, 0x40020118U) /**< \brief (PWM) Transmit Next Pointer Register */ -#define REG_PWM_TNCR REG_ACCESS(RwReg, 0x4002011CU) /**< \brief (PWM) Transmit Next Counter Register */ -#define REG_PWM_PTCR REG_ACCESS(WoReg, 0x40020120U) /**< \brief (PWM) Transfer Control Register */ -#define REG_PWM_PTSR REG_ACCESS(RoReg, 0x40020124U) /**< \brief (PWM) Transfer Status Register */ -#define REG_PWM_CMP0V REG_ACCESS(RwReg, 0x40020130U) /**< \brief (PWM) PWM Comparison 0 Value Register */ -#define REG_PWM_CMP0VUPD REG_ACCESS(WoReg, 0x40020134U) /**< \brief (PWM) PWM Comparison 0 Value Update Register */ -#define REG_PWM_CMP0M REG_ACCESS(RwReg, 0x40020138U) /**< \brief (PWM) PWM Comparison 0 Mode Register */ -#define REG_PWM_CMP0MUPD REG_ACCESS(WoReg, 0x4002013CU) /**< \brief (PWM) PWM Comparison 0 Mode Update Register */ -#define REG_PWM_CMP1V REG_ACCESS(RwReg, 0x40020140U) /**< \brief (PWM) PWM Comparison 1 Value Register */ -#define REG_PWM_CMP1VUPD REG_ACCESS(WoReg, 0x40020144U) /**< \brief (PWM) PWM Comparison 1 Value Update Register */ -#define REG_PWM_CMP1M REG_ACCESS(RwReg, 0x40020148U) /**< \brief (PWM) PWM Comparison 1 Mode Register */ -#define REG_PWM_CMP1MUPD REG_ACCESS(WoReg, 0x4002014CU) /**< \brief (PWM) PWM Comparison 1 Mode Update Register */ -#define REG_PWM_CMP2V REG_ACCESS(RwReg, 0x40020150U) /**< \brief (PWM) PWM Comparison 2 Value Register */ -#define REG_PWM_CMP2VUPD REG_ACCESS(WoReg, 0x40020154U) /**< \brief (PWM) PWM Comparison 2 Value Update Register */ -#define REG_PWM_CMP2M REG_ACCESS(RwReg, 0x40020158U) /**< \brief (PWM) PWM Comparison 2 Mode Register */ -#define REG_PWM_CMP2MUPD REG_ACCESS(WoReg, 0x4002015CU) /**< \brief (PWM) PWM Comparison 2 Mode Update Register */ -#define REG_PWM_CMP3V REG_ACCESS(RwReg, 0x40020160U) /**< \brief (PWM) PWM Comparison 3 Value Register */ -#define REG_PWM_CMP3VUPD REG_ACCESS(WoReg, 0x40020164U) /**< \brief (PWM) PWM Comparison 3 Value Update Register */ -#define REG_PWM_CMP3M REG_ACCESS(RwReg, 0x40020168U) /**< \brief (PWM) PWM Comparison 3 Mode Register */ -#define REG_PWM_CMP3MUPD REG_ACCESS(WoReg, 0x4002016CU) /**< \brief (PWM) PWM Comparison 3 Mode Update Register */ -#define REG_PWM_CMP4V REG_ACCESS(RwReg, 0x40020170U) /**< \brief (PWM) PWM Comparison 4 Value Register */ -#define REG_PWM_CMP4VUPD REG_ACCESS(WoReg, 0x40020174U) /**< \brief (PWM) PWM Comparison 4 Value Update Register */ -#define REG_PWM_CMP4M REG_ACCESS(RwReg, 0x40020178U) /**< \brief (PWM) PWM Comparison 4 Mode Register */ -#define REG_PWM_CMP4MUPD REG_ACCESS(WoReg, 0x4002017CU) /**< \brief (PWM) PWM Comparison 4 Mode Update Register */ -#define REG_PWM_CMP5V REG_ACCESS(RwReg, 0x40020180U) /**< \brief (PWM) PWM Comparison 5 Value Register */ -#define REG_PWM_CMP5VUPD REG_ACCESS(WoReg, 0x40020184U) /**< \brief (PWM) PWM Comparison 5 Value Update Register */ -#define REG_PWM_CMP5M REG_ACCESS(RwReg, 0x40020188U) /**< \brief (PWM) PWM Comparison 5 Mode Register */ -#define REG_PWM_CMP5MUPD REG_ACCESS(WoReg, 0x4002018CU) /**< \brief (PWM) PWM Comparison 5 Mode Update Register */ -#define REG_PWM_CMP6V REG_ACCESS(RwReg, 0x40020190U) /**< \brief (PWM) PWM Comparison 6 Value Register */ -#define REG_PWM_CMP6VUPD REG_ACCESS(WoReg, 0x40020194U) /**< \brief (PWM) PWM Comparison 6 Value Update Register */ -#define REG_PWM_CMP6M REG_ACCESS(RwReg, 0x40020198U) /**< \brief (PWM) PWM Comparison 6 Mode Register */ -#define REG_PWM_CMP6MUPD REG_ACCESS(WoReg, 0x4002019CU) /**< \brief (PWM) PWM Comparison 6 Mode Update Register */ -#define REG_PWM_CMP7V REG_ACCESS(RwReg, 0x400201A0U) /**< \brief (PWM) PWM Comparison 7 Value Register */ -#define REG_PWM_CMP7VUPD REG_ACCESS(WoReg, 0x400201A4U) /**< \brief (PWM) PWM Comparison 7 Value Update Register */ -#define REG_PWM_CMP7M REG_ACCESS(RwReg, 0x400201A8U) /**< \brief (PWM) PWM Comparison 7 Mode Register */ -#define REG_PWM_CMP7MUPD REG_ACCESS(WoReg, 0x400201ACU) /**< \brief (PWM) PWM Comparison 7 Mode Update Register */ -#define REG_PWM_CMR0 REG_ACCESS(RwReg, 0x40020200U) /**< \brief (PWM) PWM Channel Mode Register (ch_num = 0) */ -#define REG_PWM_CDTY0 REG_ACCESS(RwReg, 0x40020204U) /**< \brief (PWM) PWM Channel Duty Cycle Register (ch_num = 0) */ -#define REG_PWM_CDTYUPD0 REG_ACCESS(WoReg, 0x40020208U) /**< \brief (PWM) PWM Channel Duty Cycle Update Register (ch_num = 0) */ -#define REG_PWM_CPRD0 REG_ACCESS(RwReg, 0x4002020CU) /**< \brief (PWM) PWM Channel Period Register (ch_num = 0) */ -#define REG_PWM_CPRDUPD0 REG_ACCESS(WoReg, 0x40020210U) /**< \brief (PWM) PWM Channel Period Update Register (ch_num = 0) */ -#define REG_PWM_CCNT0 REG_ACCESS(RoReg, 0x40020214U) /**< \brief (PWM) PWM Channel Counter Register (ch_num = 0) */ -#define REG_PWM_DT0 REG_ACCESS(RwReg, 0x40020218U) /**< \brief (PWM) PWM Channel Dead Time Register (ch_num = 0) */ -#define REG_PWM_DTUPD0 REG_ACCESS(WoReg, 0x4002021CU) /**< \brief (PWM) PWM Channel Dead Time Update Register (ch_num = 0) */ -#define REG_PWM_CMR1 REG_ACCESS(RwReg, 0x40020220U) /**< \brief (PWM) PWM Channel Mode Register (ch_num = 1) */ -#define REG_PWM_CDTY1 REG_ACCESS(RwReg, 0x40020224U) /**< \brief (PWM) PWM Channel Duty Cycle Register (ch_num = 1) */ -#define REG_PWM_CDTYUPD1 REG_ACCESS(WoReg, 0x40020228U) /**< \brief (PWM) PWM Channel Duty Cycle Update Register (ch_num = 1) */ -#define REG_PWM_CPRD1 REG_ACCESS(RwReg, 0x4002022CU) /**< \brief (PWM) PWM Channel Period Register (ch_num = 1) */ -#define REG_PWM_CPRDUPD1 REG_ACCESS(WoReg, 0x40020230U) /**< \brief (PWM) PWM Channel Period Update Register (ch_num = 1) */ -#define REG_PWM_CCNT1 REG_ACCESS(RoReg, 0x40020234U) /**< \brief (PWM) PWM Channel Counter Register (ch_num = 1) */ -#define REG_PWM_DT1 REG_ACCESS(RwReg, 0x40020238U) /**< \brief (PWM) PWM Channel Dead Time Register (ch_num = 1) */ -#define REG_PWM_DTUPD1 REG_ACCESS(WoReg, 0x4002023CU) /**< \brief (PWM) PWM Channel Dead Time Update Register (ch_num = 1) */ -#define REG_PWM_CMR2 REG_ACCESS(RwReg, 0x40020240U) /**< \brief (PWM) PWM Channel Mode Register (ch_num = 2) */ -#define REG_PWM_CDTY2 REG_ACCESS(RwReg, 0x40020244U) /**< \brief (PWM) PWM Channel Duty Cycle Register (ch_num = 2) */ -#define REG_PWM_CDTYUPD2 REG_ACCESS(WoReg, 0x40020248U) /**< \brief (PWM) PWM Channel Duty Cycle Update Register (ch_num = 2) */ -#define REG_PWM_CPRD2 REG_ACCESS(RwReg, 0x4002024CU) /**< \brief (PWM) PWM Channel Period Register (ch_num = 2) */ -#define REG_PWM_CPRDUPD2 REG_ACCESS(WoReg, 0x40020250U) /**< \brief (PWM) PWM Channel Period Update Register (ch_num = 2) */ -#define REG_PWM_CCNT2 REG_ACCESS(RoReg, 0x40020254U) /**< \brief (PWM) PWM Channel Counter Register (ch_num = 2) */ -#define REG_PWM_DT2 REG_ACCESS(RwReg, 0x40020258U) /**< \brief (PWM) PWM Channel Dead Time Register (ch_num = 2) */ -#define REG_PWM_DTUPD2 REG_ACCESS(WoReg, 0x4002025CU) /**< \brief (PWM) PWM Channel Dead Time Update Register (ch_num = 2) */ -#define REG_PWM_CMR3 REG_ACCESS(RwReg, 0x40020260U) /**< \brief (PWM) PWM Channel Mode Register (ch_num = 3) */ -#define REG_PWM_CDTY3 REG_ACCESS(RwReg, 0x40020264U) /**< \brief (PWM) PWM Channel Duty Cycle Register (ch_num = 3) */ -#define REG_PWM_CDTYUPD3 REG_ACCESS(WoReg, 0x40020268U) /**< \brief (PWM) PWM Channel Duty Cycle Update Register (ch_num = 3) */ -#define REG_PWM_CPRD3 REG_ACCESS(RwReg, 0x4002026CU) /**< \brief (PWM) PWM Channel Period Register (ch_num = 3) */ -#define REG_PWM_CPRDUPD3 REG_ACCESS(WoReg, 0x40020270U) /**< \brief (PWM) PWM Channel Period Update Register (ch_num = 3) */ -#define REG_PWM_CCNT3 REG_ACCESS(RoReg, 0x40020274U) /**< \brief (PWM) PWM Channel Counter Register (ch_num = 3) */ -#define REG_PWM_DT3 REG_ACCESS(RwReg, 0x40020278U) /**< \brief (PWM) PWM Channel Dead Time Register (ch_num = 3) */ -#define REG_PWM_DTUPD3 REG_ACCESS(WoReg, 0x4002027CU) /**< \brief (PWM) PWM Channel Dead Time Update Register (ch_num = 3) */ -/* ========== Register definition for USART0 peripheral ========== */ -#define REG_USART0_CR REG_ACCESS(WoReg, 0x40024000U) /**< \brief (USART0) Control Register */ -#define REG_USART0_MR REG_ACCESS(RwReg, 0x40024004U) /**< \brief (USART0) Mode Register */ -#define REG_USART0_IER REG_ACCESS(WoReg, 0x40024008U) /**< \brief (USART0) Interrupt Enable Register */ -#define REG_USART0_IDR REG_ACCESS(WoReg, 0x4002400CU) /**< \brief (USART0) Interrupt Disable Register */ -#define REG_USART0_IMR REG_ACCESS(RoReg, 0x40024010U) /**< \brief (USART0) Interrupt Mask Register */ -#define REG_USART0_CSR REG_ACCESS(RoReg, 0x40024014U) /**< \brief (USART0) Channel Status Register */ -#define REG_USART0_RHR REG_ACCESS(RoReg, 0x40024018U) /**< \brief (USART0) Receiver Holding Register */ -#define REG_USART0_THR REG_ACCESS(WoReg, 0x4002401CU) /**< \brief (USART0) Transmitter Holding Register */ -#define REG_USART0_BRGR REG_ACCESS(RwReg, 0x40024020U) /**< \brief (USART0) Baud Rate Generator Register */ -#define REG_USART0_RTOR REG_ACCESS(RwReg, 0x40024024U) /**< \brief (USART0) Receiver Time-out Register */ -#define REG_USART0_TTGR REG_ACCESS(RwReg, 0x40024028U) /**< \brief (USART0) Transmitter Timeguard Register */ -#define REG_USART0_FIDI REG_ACCESS(RwReg, 0x40024040U) /**< \brief (USART0) FI DI Ratio Register */ -#define REG_USART0_NER REG_ACCESS(RoReg, 0x40024044U) /**< \brief (USART0) Number of Errors Register */ -#define REG_USART0_IF REG_ACCESS(RwReg, 0x4002404CU) /**< \brief (USART0) IrDA Filter Register */ -#define REG_USART0_MAN REG_ACCESS(RwReg, 0x40024050U) /**< \brief (USART0) Manchester Encoder Decoder Register */ -#define REG_USART0_WPMR REG_ACCESS(RwReg, 0x400240E4U) /**< \brief (USART0) Write Protect Mode Register */ -#define REG_USART0_WPSR REG_ACCESS(RoReg, 0x400240E8U) /**< \brief (USART0) Write Protect Status Register */ -#define REG_USART0_VERSION REG_ACCESS(RoReg, 0x400240FCU) /**< \brief (USART0) Version Register */ -#define REG_USART0_RPR REG_ACCESS(RwReg, 0x40024100U) /**< \brief (USART0) Receive Pointer Register */ -#define REG_USART0_RCR REG_ACCESS(RwReg, 0x40024104U) /**< \brief (USART0) Receive Counter Register */ -#define REG_USART0_TPR REG_ACCESS(RwReg, 0x40024108U) /**< \brief (USART0) Transmit Pointer Register */ -#define REG_USART0_TCR REG_ACCESS(RwReg, 0x4002410CU) /**< \brief (USART0) Transmit Counter Register */ -#define REG_USART0_RNPR REG_ACCESS(RwReg, 0x40024110U) /**< \brief (USART0) Receive Next Pointer Register */ -#define REG_USART0_RNCR REG_ACCESS(RwReg, 0x40024114U) /**< \brief (USART0) Receive Next Counter Register */ -#define REG_USART0_TNPR REG_ACCESS(RwReg, 0x40024118U) /**< \brief (USART0) Transmit Next Pointer Register */ -#define REG_USART0_TNCR REG_ACCESS(RwReg, 0x4002411CU) /**< \brief (USART0) Transmit Next Counter Register */ -#define REG_USART0_PTCR REG_ACCESS(WoReg, 0x40024120U) /**< \brief (USART0) Transfer Control Register */ -#define REG_USART0_PTSR REG_ACCESS(RoReg, 0x40024124U) /**< \brief (USART0) Transfer Status Register */ -/* ========== Register definition for USART1 peripheral ========== */ -#define REG_USART1_CR REG_ACCESS(WoReg, 0x40028000U) /**< \brief (USART1) Control Register */ -#define REG_USART1_MR REG_ACCESS(RwReg, 0x40028004U) /**< \brief (USART1) Mode Register */ -#define REG_USART1_IER REG_ACCESS(WoReg, 0x40028008U) /**< \brief (USART1) Interrupt Enable Register */ -#define REG_USART1_IDR REG_ACCESS(WoReg, 0x4002800CU) /**< \brief (USART1) Interrupt Disable Register */ -#define REG_USART1_IMR REG_ACCESS(RoReg, 0x40028010U) /**< \brief (USART1) Interrupt Mask Register */ -#define REG_USART1_CSR REG_ACCESS(RoReg, 0x40028014U) /**< \brief (USART1) Channel Status Register */ -#define REG_USART1_RHR REG_ACCESS(RoReg, 0x40028018U) /**< \brief (USART1) Receiver Holding Register */ -#define REG_USART1_THR REG_ACCESS(WoReg, 0x4002801CU) /**< \brief (USART1) Transmitter Holding Register */ -#define REG_USART1_BRGR REG_ACCESS(RwReg, 0x40028020U) /**< \brief (USART1) Baud Rate Generator Register */ -#define REG_USART1_RTOR REG_ACCESS(RwReg, 0x40028024U) /**< \brief (USART1) Receiver Time-out Register */ -#define REG_USART1_TTGR REG_ACCESS(RwReg, 0x40028028U) /**< \brief (USART1) Transmitter Timeguard Register */ -#define REG_USART1_FIDI REG_ACCESS(RwReg, 0x40028040U) /**< \brief (USART1) FI DI Ratio Register */ -#define REG_USART1_NER REG_ACCESS(RoReg, 0x40028044U) /**< \brief (USART1) Number of Errors Register */ -#define REG_USART1_IF REG_ACCESS(RwReg, 0x4002804CU) /**< \brief (USART1) IrDA Filter Register */ -#define REG_USART1_MAN REG_ACCESS(RwReg, 0x40028050U) /**< \brief (USART1) Manchester Encoder Decoder Register */ -#define REG_USART1_WPMR REG_ACCESS(RwReg, 0x400280E4U) /**< \brief (USART1) Write Protect Mode Register */ -#define REG_USART1_WPSR REG_ACCESS(RoReg, 0x400280E8U) /**< \brief (USART1) Write Protect Status Register */ -#define REG_USART1_VERSION REG_ACCESS(RoReg, 0x400280FCU) /**< \brief (USART1) Version Register */ -#define REG_USART1_RPR REG_ACCESS(RwReg, 0x40028100U) /**< \brief (USART1) Receive Pointer Register */ -#define REG_USART1_RCR REG_ACCESS(RwReg, 0x40028104U) /**< \brief (USART1) Receive Counter Register */ -#define REG_USART1_TPR REG_ACCESS(RwReg, 0x40028108U) /**< \brief (USART1) Transmit Pointer Register */ -#define REG_USART1_TCR REG_ACCESS(RwReg, 0x4002810CU) /**< \brief (USART1) Transmit Counter Register */ -#define REG_USART1_RNPR REG_ACCESS(RwReg, 0x40028110U) /**< \brief (USART1) Receive Next Pointer Register */ -#define REG_USART1_RNCR REG_ACCESS(RwReg, 0x40028114U) /**< \brief (USART1) Receive Next Counter Register */ -#define REG_USART1_TNPR REG_ACCESS(RwReg, 0x40028118U) /**< \brief (USART1) Transmit Next Pointer Register */ -#define REG_USART1_TNCR REG_ACCESS(RwReg, 0x4002811CU) /**< \brief (USART1) Transmit Next Counter Register */ -#define REG_USART1_PTCR REG_ACCESS(WoReg, 0x40028120U) /**< \brief (USART1) Transfer Control Register */ -#define REG_USART1_PTSR REG_ACCESS(RoReg, 0x40028124U) /**< \brief (USART1) Transfer Status Register */ -/* ========== Register definition for UDP peripheral ========== */ -#define REG_UDP_FRM_NUM REG_ACCESS(RoReg, 0x40034000U) /**< \brief (UDP) Frame Number Register */ -#define REG_UDP_GLB_STAT REG_ACCESS(RwReg, 0x40034004U) /**< \brief (UDP) Global State Register */ -#define REG_UDP_FADDR REG_ACCESS(RwReg, 0x40034008U) /**< \brief (UDP) Function Address Register */ -#define REG_UDP_IER REG_ACCESS(WoReg, 0x40034010U) /**< \brief (UDP) Interrupt Enable Register */ -#define REG_UDP_IDR REG_ACCESS(WoReg, 0x40034014U) /**< \brief (UDP) Interrupt Disable Register */ -#define REG_UDP_IMR REG_ACCESS(RoReg, 0x40034018U) /**< \brief (UDP) Interrupt Mask Register */ -#define REG_UDP_ISR REG_ACCESS(RoReg, 0x4003401CU) /**< \brief (UDP) Interrupt Status Register */ -#define REG_UDP_ICR REG_ACCESS(WoReg, 0x40034020U) /**< \brief (UDP) Interrupt Clear Register */ -#define REG_UDP_RST_EP REG_ACCESS(RwReg, 0x40034028U) /**< \brief (UDP) Reset Endpoint Register */ -#define REG_UDP_CSR REG_ACCESS(RwReg, 0x4003402CU) /**< \brief (UDP) Endpoint Control and Status Register (ept_num = 0) */ -#define REG_UDP_FDR REG_ACCESS(RwReg, 0x4003404CU) /**< \brief (UDP) Endpoint FIFO Data Register (ept_num = 0) */ -#define REG_UDP_TXVC REG_ACCESS(RwReg, 0x40034074U) /**< \brief (UDP) Transceiver Control Register */ -/* ========== Register definition for ADC peripheral ========== */ -#define REG_ADC_CR REG_ACCESS(WoReg, 0x40038000U) /**< \brief (ADC) Control Register */ -#define REG_ADC_MR REG_ACCESS(RwReg, 0x40038004U) /**< \brief (ADC) Mode Register */ -#define REG_ADC_SEQ1R REG_ACCESS(RwReg, 0x40038008U) /**< \brief (ADC) Channel Sequence 1Register */ -#define REG_ADC_SEQ2R REG_ACCESS(RwReg, 0x4003800CU) /**< \brief (ADC) Channel Sequence 2 Register */ -#define REG_ADC_CHER REG_ACCESS(WoReg, 0x40038010U) /**< \brief (ADC) Channel Enable Register */ -#define REG_ADC_CHDR REG_ACCESS(WoReg, 0x40038014U) /**< \brief (ADC) Channel Disable Register */ -#define REG_ADC_CHSR REG_ACCESS(RoReg, 0x40038018U) /**< \brief (ADC) Channel Status Register */ -#define REG_ADC_LCDR REG_ACCESS(RoReg, 0x40038020U) /**< \brief (ADC) Last Converted Data Register */ -#define REG_ADC_IER REG_ACCESS(WoReg, 0x40038024U) /**< \brief (ADC) Interrupt Enable Register */ -#define REG_ADC_IDR REG_ACCESS(WoReg, 0x40038028U) /**< \brief (ADC) Interrupt Disable Register */ -#define REG_ADC_IMR REG_ACCESS(RoReg, 0x4003802CU) /**< \brief (ADC) Interrupt Mask Register */ -#define REG_ADC_ISR REG_ACCESS(RoReg, 0x40038030U) /**< \brief (ADC) Interrupt Status Register */ -#define REG_ADC_OVER REG_ACCESS(RoReg, 0x4003803CU) /**< \brief (ADC) Overrun Status Register */ -#define REG_ADC_EMR REG_ACCESS(RwReg, 0x40038040U) /**< \brief (ADC) Extended Mode Register */ -#define REG_ADC_CWR REG_ACCESS(RwReg, 0x40038044U) /**< \brief (ADC) Compare Window Register */ -#define REG_ADC_CGR REG_ACCESS(RwReg, 0x40038048U) /**< \brief (ADC) Channel Gain Register */ -#define REG_ADC_COR REG_ACCESS(RwReg, 0x4003804CU) /**< \brief (ADC) Channel Offset Register */ -#define REG_ADC_CDR0 REG_ACCESS(RoReg, 0x40038050U) /**< \brief (ADC) Channel Data Register 0 */ -#define REG_ADC_CDR1 REG_ACCESS(RoReg, 0x40038054U) /**< \brief (ADC) Channel Data Register 1 */ -#define REG_ADC_CDR2 REG_ACCESS(RoReg, 0x40038058U) /**< \brief (ADC) Channel Data Register 2 */ -#define REG_ADC_CDR3 REG_ACCESS(RoReg, 0x4003805CU) /**< \brief (ADC) Channel Data Register 3 */ -#define REG_ADC_CDR4 REG_ACCESS(RoReg, 0x40038060U) /**< \brief (ADC) Channel Data Register 4 */ -#define REG_ADC_CDR5 REG_ACCESS(RoReg, 0x40038064U) /**< \brief (ADC) Channel Data Register 5 */ -#define REG_ADC_CDR6 REG_ACCESS(RoReg, 0x40038068U) /**< \brief (ADC) Channel Data Register 6 */ -#define REG_ADC_CDR15 REG_ACCESS(RoReg, 0x4003806CU) /**< \brief (ADC) Channel Data Register 15 */ -#define REG_ADC_ACR REG_ACCESS(RwReg, 0x40038094U) /**< \brief (ADC) Analog Control Register */ -#define REG_ADC_WPMR REG_ACCESS(RwReg, 0x400380E4U) /**< \brief (ADC) Write Protect Mode Register */ -#define REG_ADC_WPSR REG_ACCESS(RoReg, 0x400380E8U) /**< \brief (ADC) Write Protect Status Register */ -#define REG_ADC_RPR REG_ACCESS(RwReg, 0x40038100U) /**< \brief (ADC) Receive Pointer Register */ -#define REG_ADC_RCR REG_ACCESS(RwReg, 0x40038104U) /**< \brief (ADC) Receive Counter Register */ -#define REG_ADC_TPR REG_ACCESS(RwReg, 0x40038108U) /**< \brief (ADC) Transmit Pointer Register */ -#define REG_ADC_TCR REG_ACCESS(RwReg, 0x4003810CU) /**< \brief (ADC) Transmit Counter Register */ -#define REG_ADC_RNPR REG_ACCESS(RwReg, 0x40038110U) /**< \brief (ADC) Receive Next Pointer Register */ -#define REG_ADC_RNCR REG_ACCESS(RwReg, 0x40038114U) /**< \brief (ADC) Receive Next Counter Register */ -#define REG_ADC_TNPR REG_ACCESS(RwReg, 0x40038118U) /**< \brief (ADC) Transmit Next Pointer Register */ -#define REG_ADC_TNCR REG_ACCESS(RwReg, 0x4003811CU) /**< \brief (ADC) Transmit Next Counter Register */ -#define REG_ADC_PTCR REG_ACCESS(WoReg, 0x40038120U) /**< \brief (ADC) Transfer Control Register */ -#define REG_ADC_PTSR REG_ACCESS(RoReg, 0x40038124U) /**< \brief (ADC) Transfer Status Register */ -/* ========== Register definition for DACC peripheral ========== */ -#define REG_DACC_CR REG_ACCESS(WoReg, 0x4003C000U) /**< \brief (DACC) Control Register */ -#define REG_DACC_MR REG_ACCESS(RwReg, 0x4003C004U) /**< \brief (DACC) Mode Register */ -#define REG_DACC_CHER REG_ACCESS(WoReg, 0x4003C010U) /**< \brief (DACC) Channel Enable Register */ -#define REG_DACC_CHDR REG_ACCESS(WoReg, 0x4003C014U) /**< \brief (DACC) Channel Disable Register */ -#define REG_DACC_CHSR REG_ACCESS(RoReg, 0x4003C018U) /**< \brief (DACC) Channel Status Register */ -#define REG_DACC_CDR REG_ACCESS(WoReg, 0x4003C020U) /**< \brief (DACC) Conversion Data Register */ -#define REG_DACC_IER REG_ACCESS(WoReg, 0x4003C024U) /**< \brief (DACC) Interrupt Enable Register */ -#define REG_DACC_IDR REG_ACCESS(WoReg, 0x4003C028U) /**< \brief (DACC) Interrupt Disable Register */ -#define REG_DACC_IMR REG_ACCESS(RoReg, 0x4003C02CU) /**< \brief (DACC) Interrupt Mask Register */ -#define REG_DACC_ISR REG_ACCESS(RoReg, 0x4003C030U) /**< \brief (DACC) Interrupt Status Register */ -#define REG_DACC_ACR REG_ACCESS(RwReg, 0x4003C094U) /**< \brief (DACC) Analog Current Register */ -#define REG_DACC_WPMR REG_ACCESS(RwReg, 0x4003C0E4U) /**< \brief (DACC) Write Protect Mode register */ -#define REG_DACC_WPSR REG_ACCESS(RoReg, 0x4003C0E8U) /**< \brief (DACC) Write Protect Status register */ -#define REG_DACC_RPR REG_ACCESS(RwReg, 0x4003C100U) /**< \brief (DACC) Receive Pointer Register */ -#define REG_DACC_RCR REG_ACCESS(RwReg, 0x4003C104U) /**< \brief (DACC) Receive Counter Register */ -#define REG_DACC_TPR REG_ACCESS(RwReg, 0x4003C108U) /**< \brief (DACC) Transmit Pointer Register */ -#define REG_DACC_TCR REG_ACCESS(RwReg, 0x4003C10CU) /**< \brief (DACC) Transmit Counter Register */ -#define REG_DACC_RNPR REG_ACCESS(RwReg, 0x4003C110U) /**< \brief (DACC) Receive Next Pointer Register */ -#define REG_DACC_RNCR REG_ACCESS(RwReg, 0x4003C114U) /**< \brief (DACC) Receive Next Counter Register */ -#define REG_DACC_TNPR REG_ACCESS(RwReg, 0x4003C118U) /**< \brief (DACC) Transmit Next Pointer Register */ -#define REG_DACC_TNCR REG_ACCESS(RwReg, 0x4003C11CU) /**< \brief (DACC) Transmit Next Counter Register */ -#define REG_DACC_PTCR REG_ACCESS(WoReg, 0x4003C120U) /**< \brief (DACC) Transfer Control Register */ -#define REG_DACC_PTSR REG_ACCESS(RoReg, 0x4003C124U) /**< \brief (DACC) Transfer Status Register */ -/* ========== Register definition for ACC peripheral ========== */ -#define REG_ACC_CR REG_ACCESS(WoReg, 0x40040000U) /**< \brief (ACC) Control Register */ -#define REG_ACC_MR REG_ACCESS(RwReg, 0x40040004U) /**< \brief (ACC) Mode Register */ -#define REG_ACC_IER REG_ACCESS(WoReg, 0x40040024U) /**< \brief (ACC) Interrupt Enable Register */ -#define REG_ACC_IDR REG_ACCESS(WoReg, 0x40040028U) /**< \brief (ACC) Interrupt Disable Register */ -#define REG_ACC_IMR REG_ACCESS(RoReg, 0x4004002CU) /**< \brief (ACC) Interrupt Mask Register */ -#define REG_ACC_ISR REG_ACCESS(RoReg, 0x40040030U) /**< \brief (ACC) Interrupt Status Register */ -#define REG_ACC_ACR REG_ACCESS(RwReg, 0x40040094U) /**< \brief (ACC) Analog Control Register */ -#define REG_ACC_WPMR REG_ACCESS(RwReg, 0x400400E4U) /**< \brief (ACC) Write Protect Mode Register */ -#define REG_ACC_WPSR REG_ACCESS(RoReg, 0x400400E8U) /**< \brief (ACC) Write Protect Status Register */ -/* ========== Register definition for CRCCU peripheral ========== */ -#define REG_CRCCU_DSCR REG_ACCESS(RwReg, 0x40044000U) /**< \brief (CRCCU) CRCCU Descriptor Base Register */ -#define REG_CRCCU_DMA_EN REG_ACCESS(WoReg, 0x40044008U) /**< \brief (CRCCU) CRCCU DMA Enable Register */ -#define REG_CRCCU_DMA_DIS REG_ACCESS(WoReg, 0x4004400CU) /**< \brief (CRCCU) CRCCU DMA Disable Register */ -#define REG_CRCCU_DMA_SR REG_ACCESS(RoReg, 0x40044010U) /**< \brief (CRCCU) CRCCU DMA Status Register */ -#define REG_CRCCU_DMA_IER REG_ACCESS(WoReg, 0x40044014U) /**< \brief (CRCCU) CRCCU DMA Interrupt Enable Register */ -#define REG_CRCCU_DMA_IDR REG_ACCESS(WoReg, 0x40044018U) /**< \brief (CRCCU) CRCCU DMA Interrupt Disable Register */ -#define REG_CRCCU_DMA_IMR REG_ACCESS(RoReg, 0x4004401CU) /**< \brief (CRCCU) CRCCU DMA Interrupt Mask Register */ -#define REG_CRCCU_DMA_ISR REG_ACCESS(RoReg, 0x40044020U) /**< \brief (CRCCU) CRCCU DMA Interrupt Status Register */ -#define REG_CRCCU_CR REG_ACCESS(WoReg, 0x40044034U) /**< \brief (CRCCU) CRCCU Control Register */ -#define REG_CRCCU_MR REG_ACCESS(RwReg, 0x40044038U) /**< \brief (CRCCU) CRCCU Mode Register */ -#define REG_CRCCU_SR REG_ACCESS(RoReg, 0x4004403CU) /**< \brief (CRCCU) CRCCU Status Register */ -#define REG_CRCCU_IER REG_ACCESS(WoReg, 0x40044040U) /**< \brief (CRCCU) CRCCU Interrupt Enable Register */ -#define REG_CRCCU_IDR REG_ACCESS(WoReg, 0x40044044U) /**< \brief (CRCCU) CRCCU Interrupt Disable Register */ -#define REG_CRCCU_IMR REG_ACCESS(RoReg, 0x40044048U) /**< \brief (CRCCU) CRCCU Interrupt Mask Register */ -#define REG_CRCCU_ISR REG_ACCESS(RoReg, 0x4004404CU) /**< \brief (CRCCU) CRCCU Interrupt Status Register */ -/* ========== Register definition for SMC peripheral ========== */ -#define REG_SMC_SETUP0 REG_ACCESS(RwReg, 0x400E0000U) /**< \brief (SMC) SMC Setup Register (CS_number = 0) */ -#define REG_SMC_PULSE0 REG_ACCESS(RwReg, 0x400E0004U) /**< \brief (SMC) SMC Pulse Register (CS_number = 0) */ -#define REG_SMC_CYCLE0 REG_ACCESS(RwReg, 0x400E0008U) /**< \brief (SMC) SMC Cycle Register (CS_number = 0) */ -#define REG_SMC_MODE0 REG_ACCESS(RwReg, 0x400E000CU) /**< \brief (SMC) SMC Mode Register (CS_number = 0) */ -#define REG_SMC_SETUP1 REG_ACCESS(RwReg, 0x400E0010U) /**< \brief (SMC) SMC Setup Register (CS_number = 1) */ -#define REG_SMC_PULSE1 REG_ACCESS(RwReg, 0x400E0014U) /**< \brief (SMC) SMC Pulse Register (CS_number = 1) */ -#define REG_SMC_CYCLE1 REG_ACCESS(RwReg, 0x400E0018U) /**< \brief (SMC) SMC Cycle Register (CS_number = 1) */ -#define REG_SMC_MODE1 REG_ACCESS(RwReg, 0x400E001CU) /**< \brief (SMC) SMC Mode Register (CS_number = 1) */ -#define REG_SMC_SETUP2 REG_ACCESS(RwReg, 0x400E0020U) /**< \brief (SMC) SMC Setup Register (CS_number = 2) */ -#define REG_SMC_PULSE2 REG_ACCESS(RwReg, 0x400E0024U) /**< \brief (SMC) SMC Pulse Register (CS_number = 2) */ -#define REG_SMC_CYCLE2 REG_ACCESS(RwReg, 0x400E0028U) /**< \brief (SMC) SMC Cycle Register (CS_number = 2) */ -#define REG_SMC_MODE2 REG_ACCESS(RwReg, 0x400E002CU) /**< \brief (SMC) SMC Mode Register (CS_number = 2) */ -#define REG_SMC_SETUP3 REG_ACCESS(RwReg, 0x400E0030U) /**< \brief (SMC) SMC Setup Register (CS_number = 3) */ -#define REG_SMC_PULSE3 REG_ACCESS(RwReg, 0x400E0034U) /**< \brief (SMC) SMC Pulse Register (CS_number = 3) */ -#define REG_SMC_CYCLE3 REG_ACCESS(RwReg, 0x400E0038U) /**< \brief (SMC) SMC Cycle Register (CS_number = 3) */ -#define REG_SMC_MODE3 REG_ACCESS(RwReg, 0x400E003CU) /**< \brief (SMC) SMC Mode Register (CS_number = 3) */ -#define REG_SMC_SETUP4 REG_ACCESS(RwReg, 0x400E0040U) /**< \brief (SMC) SMC Setup Register (CS_number = 4) */ -#define REG_SMC_PULSE4 REG_ACCESS(RwReg, 0x400E0044U) /**< \brief (SMC) SMC Pulse Register (CS_number = 4) */ -#define REG_SMC_CYCLE4 REG_ACCESS(RwReg, 0x400E0048U) /**< \brief (SMC) SMC Cycle Register (CS_number = 4) */ -#define REG_SMC_MODE4 REG_ACCESS(RwReg, 0x400E004CU) /**< \brief (SMC) SMC Mode Register (CS_number = 4) */ -#define REG_SMC_OCMS REG_ACCESS(RwReg, 0x400E0080U) /**< \brief (SMC) SMC OCMS MODE Register */ -#define REG_SMC_KEY1 REG_ACCESS(WoReg, 0x400E0084U) /**< \brief (SMC) SMC OCMS KEY1 Register */ -#define REG_SMC_KEY2 REG_ACCESS(WoReg, 0x400E0088U) /**< \brief (SMC) SMC OCMS KEY2 Register */ -#define REG_SMC_WPMR REG_ACCESS(RwReg, 0x400E00E4U) /**< \brief (SMC) SMC Write Protect Mode Register */ -#define REG_SMC_WPSR REG_ACCESS(RoReg, 0x400E00E8U) /**< \brief (SMC) SMC Write Protect Status Register */ -/* ========== Register definition for MATRIX peripheral ========== */ -#define REG_MATRIX_MCFG REG_ACCESS(RwReg, 0x400E0200U) /**< \brief (MATRIX) Master Configuration Register */ -#define REG_MATRIX_SCFG REG_ACCESS(RwReg, 0x400E0240U) /**< \brief (MATRIX) Slave Configuration Register */ -#define REG_MATRIX_PRAS0 REG_ACCESS(RwReg, 0x400E0280U) /**< \brief (MATRIX) Priority Register A for Slave 0 */ -#define REG_MATRIX_PRAS1 REG_ACCESS(RwReg, 0x400E0288U) /**< \brief (MATRIX) Priority Register A for Slave 1 */ -#define REG_MATRIX_PRAS2 REG_ACCESS(RwReg, 0x400E0290U) /**< \brief (MATRIX) Priority Register A for Slave 2 */ -#define REG_MATRIX_PRAS3 REG_ACCESS(RwReg, 0x400E0298U) /**< \brief (MATRIX) Priority Register A for Slave 3 */ -#define REG_MATRIX_PRAS4 REG_ACCESS(RwReg, 0x400E02A0U) /**< \brief (MATRIX) Priority Register A for Slave 4 */ -#define REG_MATRIX_SYSIO REG_ACCESS(RwReg, 0x400E0314U) /**< \brief (MATRIX) System IO Configuration register */ -#define REG_MATRIX_SMCNFCS REG_ACCESS(RwReg, 0x400E031CU) /**< \brief (MATRIX) SMC Chip Select NAND Flash Assignment Register */ -#define REG_MATRIX_WPMR REG_ACCESS(RwReg, 0x400E03E4U) /**< \brief (MATRIX) Write Protect Mode Register */ -#define REG_MATRIX_WPSR REG_ACCESS(RoReg, 0x400E03E8U) /**< \brief (MATRIX) Write Protect Status Register */ -/* ========== Register definition for PMC peripheral ========== */ -#define REG_PMC_SCER REG_ACCESS(WoReg, 0x400E0400U) /**< \brief (PMC) System Clock Enable Register */ -#define REG_PMC_SCDR REG_ACCESS(WoReg, 0x400E0404U) /**< \brief (PMC) System Clock Disable Register */ -#define REG_PMC_SCSR REG_ACCESS(RoReg, 0x400E0408U) /**< \brief (PMC) System Clock Status Register */ -#define REG_PMC_PCER0 REG_ACCESS(WoReg, 0x400E0410U) /**< \brief (PMC) Peripheral Clock Enable Register 0 */ -#define REG_PMC_PCDR0 REG_ACCESS(WoReg, 0x400E0414U) /**< \brief (PMC) Peripheral Clock Disable Register 0 */ -#define REG_PMC_PCSR0 REG_ACCESS(RoReg, 0x400E0418U) /**< \brief (PMC) Peripheral Clock Status Register 0 */ -#define REG_PMC_MOR REG_ACCESS(RwReg, 0x400E0420U) /**< \brief (PMC) Main Oscillator Register */ -#define REG_PMC_MCFR REG_ACCESS(RoReg, 0x400E0424U) /**< \brief (PMC) Main Clock Frequency Register */ -#define REG_PMC_PLLAR REG_ACCESS(RwReg, 0x400E0428U) /**< \brief (PMC) PLLA Register */ -#define REG_PMC_PLLBR REG_ACCESS(RwReg, 0x400E042CU) /**< \brief (PMC) PLLB Register */ -#define REG_PMC_MCKR REG_ACCESS(RwReg, 0x400E0430U) /**< \brief (PMC) Master Clock Register */ -#define REG_PMC_USB REG_ACCESS(RwReg, 0x400E0438U) /**< \brief (PMC) USB Clock Register */ -#define REG_PMC_PCK REG_ACCESS(RwReg, 0x400E0440U) /**< \brief (PMC) Programmable Clock 0 Register */ -#define REG_PMC_IER REG_ACCESS(WoReg, 0x400E0460U) /**< \brief (PMC) Interrupt Enable Register */ -#define REG_PMC_IDR REG_ACCESS(WoReg, 0x400E0464U) /**< \brief (PMC) Interrupt Disable Register */ -#define REG_PMC_SR REG_ACCESS(RoReg, 0x400E0468U) /**< \brief (PMC) Status Register */ -#define REG_PMC_IMR REG_ACCESS(RoReg, 0x400E046CU) /**< \brief (PMC) Interrupt Mask Register */ -#define REG_PMC_FSMR REG_ACCESS(RwReg, 0x400E0470U) /**< \brief (PMC) Fast Startup Mode Register */ -#define REG_PMC_FSPR REG_ACCESS(RwReg, 0x400E0474U) /**< \brief (PMC) Fast Startup Polarity Register */ -#define REG_PMC_FOCR REG_ACCESS(WoReg, 0x400E0478U) /**< \brief (PMC) Fault Output Clear Register */ -#define REG_PMC_WPMR REG_ACCESS(RwReg, 0x400E04E4U) /**< \brief (PMC) Write Protect Mode Register */ -#define REG_PMC_WPSR REG_ACCESS(RoReg, 0x400E04E8U) /**< \brief (PMC) Write Protect Status Register */ -#define REG_PMC_PCER1 REG_ACCESS(WoReg, 0x400E0500U) /**< \brief (PMC) Peripheral Clock Enable Register 1 */ -#define REG_PMC_PCDR1 REG_ACCESS(WoReg, 0x400E0504U) /**< \brief (PMC) Peripheral Clock Disable Register 1 */ -#define REG_PMC_PCSR1 REG_ACCESS(RoReg, 0x400E0508U) /**< \brief (PMC) Peripheral Clock Status Register 1 */ -#define REG_PMC_OCR REG_ACCESS(RwReg, 0x400E0510U) /**< \brief (PMC) Oscillator Calibration Register */ -/* ========== Register definition for UART0 peripheral ========== */ -#define REG_UART0_CR REG_ACCESS(WoReg, 0x400E0600U) /**< \brief (UART0) Control Register */ -#define REG_UART0_MR REG_ACCESS(RwReg, 0x400E0604U) /**< \brief (UART0) Mode Register */ -#define REG_UART0_IER REG_ACCESS(WoReg, 0x400E0608U) /**< \brief (UART0) Interrupt Enable Register */ -#define REG_UART0_IDR REG_ACCESS(WoReg, 0x400E060CU) /**< \brief (UART0) Interrupt Disable Register */ -#define REG_UART0_IMR REG_ACCESS(RoReg, 0x400E0610U) /**< \brief (UART0) Interrupt Mask Register */ -#define REG_UART0_SR REG_ACCESS(RoReg, 0x400E0614U) /**< \brief (UART0) Status Register */ -#define REG_UART0_RHR REG_ACCESS(RoReg, 0x400E0618U) /**< \brief (UART0) Receive Holding Register */ -#define REG_UART0_THR REG_ACCESS(WoReg, 0x400E061CU) /**< \brief (UART0) Transmit Holding Register */ -#define REG_UART0_BRGR REG_ACCESS(RwReg, 0x400E0620U) /**< \brief (UART0) Baud Rate Generator Register */ -#define REG_UART0_RPR REG_ACCESS(RwReg, 0x400E0700U) /**< \brief (UART0) Receive Pointer Register */ -#define REG_UART0_RCR REG_ACCESS(RwReg, 0x400E0704U) /**< \brief (UART0) Receive Counter Register */ -#define REG_UART0_TPR REG_ACCESS(RwReg, 0x400E0708U) /**< \brief (UART0) Transmit Pointer Register */ -#define REG_UART0_TCR REG_ACCESS(RwReg, 0x400E070CU) /**< \brief (UART0) Transmit Counter Register */ -#define REG_UART0_RNPR REG_ACCESS(RwReg, 0x400E0710U) /**< \brief (UART0) Receive Next Pointer Register */ -#define REG_UART0_RNCR REG_ACCESS(RwReg, 0x400E0714U) /**< \brief (UART0) Receive Next Counter Register */ -#define REG_UART0_TNPR REG_ACCESS(RwReg, 0x400E0718U) /**< \brief (UART0) Transmit Next Pointer Register */ -#define REG_UART0_TNCR REG_ACCESS(RwReg, 0x400E071CU) /**< \brief (UART0) Transmit Next Counter Register */ -#define REG_UART0_PTCR REG_ACCESS(WoReg, 0x400E0720U) /**< \brief (UART0) Transfer Control Register */ -#define REG_UART0_PTSR REG_ACCESS(RoReg, 0x400E0724U) /**< \brief (UART0) Transfer Status Register */ -/* ========== Register definition for CHIPID peripheral ========== */ -#define REG_CHIPID_CIDR REG_ACCESS(RoReg, 0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ -#define REG_CHIPID_EXID REG_ACCESS(RoReg, 0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ -/* ========== Register definition for UART1 peripheral ========== */ -#define REG_UART1_CR REG_ACCESS(WoReg, 0x400E0800U) /**< \brief (UART1) Control Register */ -#define REG_UART1_MR REG_ACCESS(RwReg, 0x400E0804U) /**< \brief (UART1) Mode Register */ -#define REG_UART1_IER REG_ACCESS(WoReg, 0x400E0808U) /**< \brief (UART1) Interrupt Enable Register */ -#define REG_UART1_IDR REG_ACCESS(WoReg, 0x400E080CU) /**< \brief (UART1) Interrupt Disable Register */ -#define REG_UART1_IMR REG_ACCESS(RoReg, 0x400E0810U) /**< \brief (UART1) Interrupt Mask Register */ -#define REG_UART1_SR REG_ACCESS(RoReg, 0x400E0814U) /**< \brief (UART1) Status Register */ -#define REG_UART1_RHR REG_ACCESS(RoReg, 0x400E0818U) /**< \brief (UART1) Receive Holding Register */ -#define REG_UART1_THR REG_ACCESS(WoReg, 0x400E081CU) /**< \brief (UART1) Transmit Holding Register */ -#define REG_UART1_BRGR REG_ACCESS(RwReg, 0x400E0820U) /**< \brief (UART1) Baud Rate Generator Register */ -#define REG_UART1_RPR REG_ACCESS(RwReg, 0x400E0900U) /**< \brief (UART1) Receive Pointer Register */ -#define REG_UART1_RCR REG_ACCESS(RwReg, 0x400E0904U) /**< \brief (UART1) Receive Counter Register */ -#define REG_UART1_TPR REG_ACCESS(RwReg, 0x400E0908U) /**< \brief (UART1) Transmit Pointer Register */ -#define REG_UART1_TCR REG_ACCESS(RwReg, 0x400E090CU) /**< \brief (UART1) Transmit Counter Register */ -#define REG_UART1_RNPR REG_ACCESS(RwReg, 0x400E0910U) /**< \brief (UART1) Receive Next Pointer Register */ -#define REG_UART1_RNCR REG_ACCESS(RwReg, 0x400E0914U) /**< \brief (UART1) Receive Next Counter Register */ -#define REG_UART1_TNPR REG_ACCESS(RwReg, 0x400E0918U) /**< \brief (UART1) Transmit Next Pointer Register */ -#define REG_UART1_TNCR REG_ACCESS(RwReg, 0x400E091CU) /**< \brief (UART1) Transmit Next Counter Register */ -#define REG_UART1_PTCR REG_ACCESS(WoReg, 0x400E0920U) /**< \brief (UART1) Transfer Control Register */ -#define REG_UART1_PTSR REG_ACCESS(RoReg, 0x400E0924U) /**< \brief (UART1) Transfer Status Register */ -/* ========== Register definition for EFC peripheral ========== */ -#define REG_EFC_FMR REG_ACCESS(RwReg, 0x400E0A00U) /**< \brief (EFC) EEFC Flash Mode Register */ -#define REG_EFC_FCR REG_ACCESS(WoReg, 0x400E0A04U) /**< \brief (EFC) EEFC Flash Command Register */ -#define REG_EFC_FSR REG_ACCESS(RoReg, 0x400E0A08U) /**< \brief (EFC) EEFC Flash Status Register */ -#define REG_EFC_FRR REG_ACCESS(RoReg, 0x400E0A0CU) /**< \brief (EFC) EEFC Flash Result Register */ -/* ========== Register definition for PIOA peripheral ========== */ -#define REG_PIOA_PER REG_ACCESS(WoReg, 0x400E0E00U) /**< \brief (PIOA) PIO Enable Register */ -#define REG_PIOA_PDR REG_ACCESS(WoReg, 0x400E0E04U) /**< \brief (PIOA) PIO Disable Register */ -#define REG_PIOA_PSR REG_ACCESS(RoReg, 0x400E0E08U) /**< \brief (PIOA) PIO Status Register */ -#define REG_PIOA_OER REG_ACCESS(WoReg, 0x400E0E10U) /**< \brief (PIOA) Output Enable Register */ -#define REG_PIOA_ODR REG_ACCESS(WoReg, 0x400E0E14U) /**< \brief (PIOA) Output Disable Register */ -#define REG_PIOA_OSR REG_ACCESS(RoReg, 0x400E0E18U) /**< \brief (PIOA) Output Status Register */ -#define REG_PIOA_IFER REG_ACCESS(WoReg, 0x400E0E20U) /**< \brief (PIOA) Glitch Input Filter Enable Register */ -#define REG_PIOA_IFDR REG_ACCESS(WoReg, 0x400E0E24U) /**< \brief (PIOA) Glitch Input Filter Disable Register */ -#define REG_PIOA_IFSR REG_ACCESS(RoReg, 0x400E0E28U) /**< \brief (PIOA) Glitch Input Filter Status Register */ -#define REG_PIOA_SODR REG_ACCESS(WoReg, 0x400E0E30U) /**< \brief (PIOA) Set Output Data Register */ -#define REG_PIOA_CODR REG_ACCESS(WoReg, 0x400E0E34U) /**< \brief (PIOA) Clear Output Data Register */ -#define REG_PIOA_ODSR REG_ACCESS(RwReg, 0x400E0E38U) /**< \brief (PIOA) Output Data Status Register */ -#define REG_PIOA_PDSR REG_ACCESS(RoReg, 0x400E0E3CU) /**< \brief (PIOA) Pin Data Status Register */ -#define REG_PIOA_IER REG_ACCESS(WoReg, 0x400E0E40U) /**< \brief (PIOA) Interrupt Enable Register */ -#define REG_PIOA_IDR REG_ACCESS(WoReg, 0x400E0E44U) /**< \brief (PIOA) Interrupt Disable Register */ -#define REG_PIOA_IMR REG_ACCESS(RoReg, 0x400E0E48U) /**< \brief (PIOA) Interrupt Mask Register */ -#define REG_PIOA_ISR REG_ACCESS(RoReg, 0x400E0E4CU) /**< \brief (PIOA) Interrupt Status Register */ -#define REG_PIOA_MDER REG_ACCESS(WoReg, 0x400E0E50U) /**< \brief (PIOA) Multi-driver Enable Register */ -#define REG_PIOA_MDDR REG_ACCESS(WoReg, 0x400E0E54U) /**< \brief (PIOA) Multi-driver Disable Register */ -#define REG_PIOA_MDSR REG_ACCESS(RoReg, 0x400E0E58U) /**< \brief (PIOA) Multi-driver Status Register */ -#define REG_PIOA_PUDR REG_ACCESS(WoReg, 0x400E0E60U) /**< \brief (PIOA) Pull-up Disable Register */ -#define REG_PIOA_PUER REG_ACCESS(WoReg, 0x400E0E64U) /**< \brief (PIOA) Pull-up Enable Register */ -#define REG_PIOA_PUSR REG_ACCESS(RoReg, 0x400E0E68U) /**< \brief (PIOA) Pad Pull-up Status Register */ -#define REG_PIOA_ABCDSR REG_ACCESS(RwReg, 0x400E0E70U) /**< \brief (PIOA) Peripheral Select Register */ -#define REG_PIOA_SCIFSR REG_ACCESS(WoReg, 0x400E0E80U) /**< \brief (PIOA) System Clock Glitch Input Filter Select Register */ -#define REG_PIOA_DIFSR REG_ACCESS(WoReg, 0x400E0E84U) /**< \brief (PIOA) Debouncing Input Filter Select Register */ -#define REG_PIOA_IFDGSR REG_ACCESS(RoReg, 0x400E0E88U) /**< \brief (PIOA) Glitch or Debouncing Input Filter Clock Selection Status Register */ -#define REG_PIOA_SCDR REG_ACCESS(RwReg, 0x400E0E8CU) /**< \brief (PIOA) Slow Clock Divider Debouncing Register */ -#define REG_PIOA_PPDDR REG_ACCESS(WoReg, 0x400E0E90U) /**< \brief (PIOA) Pad Pull-down Disable Register */ -#define REG_PIOA_PPDER REG_ACCESS(WoReg, 0x400E0E94U) /**< \brief (PIOA) Pad Pull-down Enable Register */ -#define REG_PIOA_PPDSR REG_ACCESS(RoReg, 0x400E0E98U) /**< \brief (PIOA) Pad Pull-down Status Register */ -#define REG_PIOA_OWER REG_ACCESS(WoReg, 0x400E0EA0U) /**< \brief (PIOA) Output Write Enable */ -#define REG_PIOA_OWDR REG_ACCESS(WoReg, 0x400E0EA4U) /**< \brief (PIOA) Output Write Disable */ -#define REG_PIOA_OWSR REG_ACCESS(RoReg, 0x400E0EA8U) /**< \brief (PIOA) Output Write Status Register */ -#define REG_PIOA_AIMER REG_ACCESS(WoReg, 0x400E0EB0U) /**< \brief (PIOA) Additional Interrupt Modes Enable Register */ -#define REG_PIOA_AIMDR REG_ACCESS(WoReg, 0x400E0EB4U) /**< \brief (PIOA) Additional Interrupt Modes Disables Register */ -#define REG_PIOA_AIMMR REG_ACCESS(RoReg, 0x400E0EB8U) /**< \brief (PIOA) Additional Interrupt Modes Mask Register */ -#define REG_PIOA_ESR REG_ACCESS(WoReg, 0x400E0EC0U) /**< \brief (PIOA) Edge Select Register */ -#define REG_PIOA_LSR REG_ACCESS(WoReg, 0x400E0EC4U) /**< \brief (PIOA) Level Select Register */ -#define REG_PIOA_ELSR REG_ACCESS(RoReg, 0x400E0EC8U) /**< \brief (PIOA) Edge/Level Status Register */ -#define REG_PIOA_FELLSR REG_ACCESS(WoReg, 0x400E0ED0U) /**< \brief (PIOA) Falling Edge/Low Level Select Register */ -#define REG_PIOA_REHLSR REG_ACCESS(WoReg, 0x400E0ED4U) /**< \brief (PIOA) Rising Edge/ High Level Select Register */ -#define REG_PIOA_FRLHSR REG_ACCESS(RoReg, 0x400E0ED8U) /**< \brief (PIOA) Fall/Rise - Low/High Status Register */ -#define REG_PIOA_LOCKSR REG_ACCESS(RoReg, 0x400E0EE0U) /**< \brief (PIOA) Lock Status */ -#define REG_PIOA_WPMR REG_ACCESS(RwReg, 0x400E0EE4U) /**< \brief (PIOA) Write Protect Mode Register */ -#define REG_PIOA_WPSR REG_ACCESS(RoReg, 0x400E0EE8U) /**< \brief (PIOA) Write Protect Status Register */ -#define REG_PIOA_SCHMITT REG_ACCESS(RwReg, 0x400E0F00U) /**< \brief (PIOA) Schmitt Trigger Register */ -#define REG_PIOA_PCMR REG_ACCESS(RwReg, 0x400E0F50U) /**< \brief (PIOA) Parallel Capture Mode Register */ -#define REG_PIOA_PCIER REG_ACCESS(WoReg, 0x400E0F54U) /**< \brief (PIOA) Parallel Capture Interrupt Enable Register */ -#define REG_PIOA_PCIDR REG_ACCESS(WoReg, 0x400E0F58U) /**< \brief (PIOA) Parallel Capture Interrupt Disable Register */ -#define REG_PIOA_PCIMR REG_ACCESS(RoReg, 0x400E0F5CU) /**< \brief (PIOA) Parallel Capture Interrupt Mask Register */ -#define REG_PIOA_PCISR REG_ACCESS(RoReg, 0x400E0F60U) /**< \brief (PIOA) Parallel Capture Interrupt Status Register */ -#define REG_PIOA_PCRHR REG_ACCESS(RoReg, 0x400E0F64U) /**< \brief (PIOA) Parallel Capture Reception Holding Register */ -/* ========== Register definition for PIOB peripheral ========== */ -#define REG_PIOB_PER REG_ACCESS(WoReg, 0x400E1000U) /**< \brief (PIOB) PIO Enable Register */ -#define REG_PIOB_PDR REG_ACCESS(WoReg, 0x400E1004U) /**< \brief (PIOB) PIO Disable Register */ -#define REG_PIOB_PSR REG_ACCESS(RoReg, 0x400E1008U) /**< \brief (PIOB) PIO Status Register */ -#define REG_PIOB_OER REG_ACCESS(WoReg, 0x400E1010U) /**< \brief (PIOB) Output Enable Register */ -#define REG_PIOB_ODR REG_ACCESS(WoReg, 0x400E1014U) /**< \brief (PIOB) Output Disable Register */ -#define REG_PIOB_OSR REG_ACCESS(RoReg, 0x400E1018U) /**< \brief (PIOB) Output Status Register */ -#define REG_PIOB_IFER REG_ACCESS(WoReg, 0x400E1020U) /**< \brief (PIOB) Glitch Input Filter Enable Register */ -#define REG_PIOB_IFDR REG_ACCESS(WoReg, 0x400E1024U) /**< \brief (PIOB) Glitch Input Filter Disable Register */ -#define REG_PIOB_IFSR REG_ACCESS(RoReg, 0x400E1028U) /**< \brief (PIOB) Glitch Input Filter Status Register */ -#define REG_PIOB_SODR REG_ACCESS(WoReg, 0x400E1030U) /**< \brief (PIOB) Set Output Data Register */ -#define REG_PIOB_CODR REG_ACCESS(WoReg, 0x400E1034U) /**< \brief (PIOB) Clear Output Data Register */ -#define REG_PIOB_ODSR REG_ACCESS(RwReg, 0x400E1038U) /**< \brief (PIOB) Output Data Status Register */ -#define REG_PIOB_PDSR REG_ACCESS(RoReg, 0x400E103CU) /**< \brief (PIOB) Pin Data Status Register */ -#define REG_PIOB_IER REG_ACCESS(WoReg, 0x400E1040U) /**< \brief (PIOB) Interrupt Enable Register */ -#define REG_PIOB_IDR REG_ACCESS(WoReg, 0x400E1044U) /**< \brief (PIOB) Interrupt Disable Register */ -#define REG_PIOB_IMR REG_ACCESS(RoReg, 0x400E1048U) /**< \brief (PIOB) Interrupt Mask Register */ -#define REG_PIOB_ISR REG_ACCESS(RoReg, 0x400E104CU) /**< \brief (PIOB) Interrupt Status Register */ -#define REG_PIOB_MDER REG_ACCESS(WoReg, 0x400E1050U) /**< \brief (PIOB) Multi-driver Enable Register */ -#define REG_PIOB_MDDR REG_ACCESS(WoReg, 0x400E1054U) /**< \brief (PIOB) Multi-driver Disable Register */ -#define REG_PIOB_MDSR REG_ACCESS(RoReg, 0x400E1058U) /**< \brief (PIOB) Multi-driver Status Register */ -#define REG_PIOB_PUDR REG_ACCESS(WoReg, 0x400E1060U) /**< \brief (PIOB) Pull-up Disable Register */ -#define REG_PIOB_PUER REG_ACCESS(WoReg, 0x400E1064U) /**< \brief (PIOB) Pull-up Enable Register */ -#define REG_PIOB_PUSR REG_ACCESS(RoReg, 0x400E1068U) /**< \brief (PIOB) Pad Pull-up Status Register */ -#define REG_PIOB_ABCDSR REG_ACCESS(RwReg, 0x400E1070U) /**< \brief (PIOB) Peripheral Select Register */ -#define REG_PIOB_SCIFSR REG_ACCESS(WoReg, 0x400E1080U) /**< \brief (PIOB) System Clock Glitch Input Filter Select Register */ -#define REG_PIOB_DIFSR REG_ACCESS(WoReg, 0x400E1084U) /**< \brief (PIOB) Debouncing Input Filter Select Register */ -#define REG_PIOB_IFDGSR REG_ACCESS(RoReg, 0x400E1088U) /**< \brief (PIOB) Glitch or Debouncing Input Filter Clock Selection Status Register */ -#define REG_PIOB_SCDR REG_ACCESS(RwReg, 0x400E108CU) /**< \brief (PIOB) Slow Clock Divider Debouncing Register */ -#define REG_PIOB_PPDDR REG_ACCESS(WoReg, 0x400E1090U) /**< \brief (PIOB) Pad Pull-down Disable Register */ -#define REG_PIOB_PPDER REG_ACCESS(WoReg, 0x400E1094U) /**< \brief (PIOB) Pad Pull-down Enable Register */ -#define REG_PIOB_PPDSR REG_ACCESS(RoReg, 0x400E1098U) /**< \brief (PIOB) Pad Pull-down Status Register */ -#define REG_PIOB_OWER REG_ACCESS(WoReg, 0x400E10A0U) /**< \brief (PIOB) Output Write Enable */ -#define REG_PIOB_OWDR REG_ACCESS(WoReg, 0x400E10A4U) /**< \brief (PIOB) Output Write Disable */ -#define REG_PIOB_OWSR REG_ACCESS(RoReg, 0x400E10A8U) /**< \brief (PIOB) Output Write Status Register */ -#define REG_PIOB_AIMER REG_ACCESS(WoReg, 0x400E10B0U) /**< \brief (PIOB) Additional Interrupt Modes Enable Register */ -#define REG_PIOB_AIMDR REG_ACCESS(WoReg, 0x400E10B4U) /**< \brief (PIOB) Additional Interrupt Modes Disables Register */ -#define REG_PIOB_AIMMR REG_ACCESS(RoReg, 0x400E10B8U) /**< \brief (PIOB) Additional Interrupt Modes Mask Register */ -#define REG_PIOB_ESR REG_ACCESS(WoReg, 0x400E10C0U) /**< \brief (PIOB) Edge Select Register */ -#define REG_PIOB_LSR REG_ACCESS(WoReg, 0x400E10C4U) /**< \brief (PIOB) Level Select Register */ -#define REG_PIOB_ELSR REG_ACCESS(RoReg, 0x400E10C8U) /**< \brief (PIOB) Edge/Level Status Register */ -#define REG_PIOB_FELLSR REG_ACCESS(WoReg, 0x400E10D0U) /**< \brief (PIOB) Falling Edge/Low Level Select Register */ -#define REG_PIOB_REHLSR REG_ACCESS(WoReg, 0x400E10D4U) /**< \brief (PIOB) Rising Edge/ High Level Select Register */ -#define REG_PIOB_FRLHSR REG_ACCESS(RoReg, 0x400E10D8U) /**< \brief (PIOB) Fall/Rise - Low/High Status Register */ -#define REG_PIOB_LOCKSR REG_ACCESS(RoReg, 0x400E10E0U) /**< \brief (PIOB) Lock Status */ -#define REG_PIOB_WPMR REG_ACCESS(RwReg, 0x400E10E4U) /**< \brief (PIOB) Write Protect Mode Register */ -#define REG_PIOB_WPSR REG_ACCESS(RoReg, 0x400E10E8U) /**< \brief (PIOB) Write Protect Status Register */ -#define REG_PIOB_SCHMITT REG_ACCESS(RwReg, 0x400E1100U) /**< \brief (PIOB) Schmitt Trigger Register */ -#define REG_PIOB_PCMR REG_ACCESS(RwReg, 0x400E1150U) /**< \brief (PIOB) Parallel Capture Mode Register */ -#define REG_PIOB_PCIER REG_ACCESS(WoReg, 0x400E1154U) /**< \brief (PIOB) Parallel Capture Interrupt Enable Register */ -#define REG_PIOB_PCIDR REG_ACCESS(WoReg, 0x400E1158U) /**< \brief (PIOB) Parallel Capture Interrupt Disable Register */ -#define REG_PIOB_PCIMR REG_ACCESS(RoReg, 0x400E115CU) /**< \brief (PIOB) Parallel Capture Interrupt Mask Register */ -#define REG_PIOB_PCISR REG_ACCESS(RoReg, 0x400E1160U) /**< \brief (PIOB) Parallel Capture Interrupt Status Register */ -#define REG_PIOB_PCRHR REG_ACCESS(RoReg, 0x400E1164U) /**< \brief (PIOB) Parallel Capture Reception Holding Register */ -/* ========== Register definition for PIOC peripheral ========== */ -#define REG_PIOC_PER REG_ACCESS(WoReg, 0x400E1200U) /**< \brief (PIOC) PIO Enable Register */ -#define REG_PIOC_PDR REG_ACCESS(WoReg, 0x400E1204U) /**< \brief (PIOC) PIO Disable Register */ -#define REG_PIOC_PSR REG_ACCESS(RoReg, 0x400E1208U) /**< \brief (PIOC) PIO Status Register */ -#define REG_PIOC_OER REG_ACCESS(WoReg, 0x400E1210U) /**< \brief (PIOC) Output Enable Register */ -#define REG_PIOC_ODR REG_ACCESS(WoReg, 0x400E1214U) /**< \brief (PIOC) Output Disable Register */ -#define REG_PIOC_OSR REG_ACCESS(RoReg, 0x400E1218U) /**< \brief (PIOC) Output Status Register */ -#define REG_PIOC_IFER REG_ACCESS(WoReg, 0x400E1220U) /**< \brief (PIOC) Glitch Input Filter Enable Register */ -#define REG_PIOC_IFDR REG_ACCESS(WoReg, 0x400E1224U) /**< \brief (PIOC) Glitch Input Filter Disable Register */ -#define REG_PIOC_IFSR REG_ACCESS(RoReg, 0x400E1228U) /**< \brief (PIOC) Glitch Input Filter Status Register */ -#define REG_PIOC_SODR REG_ACCESS(WoReg, 0x400E1230U) /**< \brief (PIOC) Set Output Data Register */ -#define REG_PIOC_CODR REG_ACCESS(WoReg, 0x400E1234U) /**< \brief (PIOC) Clear Output Data Register */ -#define REG_PIOC_ODSR REG_ACCESS(RwReg, 0x400E1238U) /**< \brief (PIOC) Output Data Status Register */ -#define REG_PIOC_PDSR REG_ACCESS(RoReg, 0x400E123CU) /**< \brief (PIOC) Pin Data Status Register */ -#define REG_PIOC_IER REG_ACCESS(WoReg, 0x400E1240U) /**< \brief (PIOC) Interrupt Enable Register */ -#define REG_PIOC_IDR REG_ACCESS(WoReg, 0x400E1244U) /**< \brief (PIOC) Interrupt Disable Register */ -#define REG_PIOC_IMR REG_ACCESS(RoReg, 0x400E1248U) /**< \brief (PIOC) Interrupt Mask Register */ -#define REG_PIOC_ISR REG_ACCESS(RoReg, 0x400E124CU) /**< \brief (PIOC) Interrupt Status Register */ -#define REG_PIOC_MDER REG_ACCESS(WoReg, 0x400E1250U) /**< \brief (PIOC) Multi-driver Enable Register */ -#define REG_PIOC_MDDR REG_ACCESS(WoReg, 0x400E1254U) /**< \brief (PIOC) Multi-driver Disable Register */ -#define REG_PIOC_MDSR REG_ACCESS(RoReg, 0x400E1258U) /**< \brief (PIOC) Multi-driver Status Register */ -#define REG_PIOC_PUDR REG_ACCESS(WoReg, 0x400E1260U) /**< \brief (PIOC) Pull-up Disable Register */ -#define REG_PIOC_PUER REG_ACCESS(WoReg, 0x400E1264U) /**< \brief (PIOC) Pull-up Enable Register */ -#define REG_PIOC_PUSR REG_ACCESS(RoReg, 0x400E1268U) /**< \brief (PIOC) Pad Pull-up Status Register */ -#define REG_PIOC_ABCDSR REG_ACCESS(RwReg, 0x400E1270U) /**< \brief (PIOC) Peripheral Select Register */ -#define REG_PIOC_SCIFSR REG_ACCESS(WoReg, 0x400E1280U) /**< \brief (PIOC) System Clock Glitch Input Filter Select Register */ -#define REG_PIOC_DIFSR REG_ACCESS(WoReg, 0x400E1284U) /**< \brief (PIOC) Debouncing Input Filter Select Register */ -#define REG_PIOC_IFDGSR REG_ACCESS(RoReg, 0x400E1288U) /**< \brief (PIOC) Glitch or Debouncing Input Filter Clock Selection Status Register */ -#define REG_PIOC_SCDR REG_ACCESS(RwReg, 0x400E128CU) /**< \brief (PIOC) Slow Clock Divider Debouncing Register */ -#define REG_PIOC_PPDDR REG_ACCESS(WoReg, 0x400E1290U) /**< \brief (PIOC) Pad Pull-down Disable Register */ -#define REG_PIOC_PPDER REG_ACCESS(WoReg, 0x400E1294U) /**< \brief (PIOC) Pad Pull-down Enable Register */ -#define REG_PIOC_PPDSR REG_ACCESS(RoReg, 0x400E1298U) /**< \brief (PIOC) Pad Pull-down Status Register */ -#define REG_PIOC_OWER REG_ACCESS(WoReg, 0x400E12A0U) /**< \brief (PIOC) Output Write Enable */ -#define REG_PIOC_OWDR REG_ACCESS(WoReg, 0x400E12A4U) /**< \brief (PIOC) Output Write Disable */ -#define REG_PIOC_OWSR REG_ACCESS(RoReg, 0x400E12A8U) /**< \brief (PIOC) Output Write Status Register */ -#define REG_PIOC_AIMER REG_ACCESS(WoReg, 0x400E12B0U) /**< \brief (PIOC) Additional Interrupt Modes Enable Register */ -#define REG_PIOC_AIMDR REG_ACCESS(WoReg, 0x400E12B4U) /**< \brief (PIOC) Additional Interrupt Modes Disables Register */ -#define REG_PIOC_AIMMR REG_ACCESS(RoReg, 0x400E12B8U) /**< \brief (PIOC) Additional Interrupt Modes Mask Register */ -#define REG_PIOC_ESR REG_ACCESS(WoReg, 0x400E12C0U) /**< \brief (PIOC) Edge Select Register */ -#define REG_PIOC_LSR REG_ACCESS(WoReg, 0x400E12C4U) /**< \brief (PIOC) Level Select Register */ -#define REG_PIOC_ELSR REG_ACCESS(RoReg, 0x400E12C8U) /**< \brief (PIOC) Edge/Level Status Register */ -#define REG_PIOC_FELLSR REG_ACCESS(WoReg, 0x400E12D0U) /**< \brief (PIOC) Falling Edge/Low Level Select Register */ -#define REG_PIOC_REHLSR REG_ACCESS(WoReg, 0x400E12D4U) /**< \brief (PIOC) Rising Edge/ High Level Select Register */ -#define REG_PIOC_FRLHSR REG_ACCESS(RoReg, 0x400E12D8U) /**< \brief (PIOC) Fall/Rise - Low/High Status Register */ -#define REG_PIOC_LOCKSR REG_ACCESS(RoReg, 0x400E12E0U) /**< \brief (PIOC) Lock Status */ -#define REG_PIOC_WPMR REG_ACCESS(RwReg, 0x400E12E4U) /**< \brief (PIOC) Write Protect Mode Register */ -#define REG_PIOC_WPSR REG_ACCESS(RoReg, 0x400E12E8U) /**< \brief (PIOC) Write Protect Status Register */ -#define REG_PIOC_SCHMITT REG_ACCESS(RwReg, 0x400E1300U) /**< \brief (PIOC) Schmitt Trigger Register */ -#define REG_PIOC_PCMR REG_ACCESS(RwReg, 0x400E1350U) /**< \brief (PIOC) Parallel Capture Mode Register */ -#define REG_PIOC_PCIER REG_ACCESS(WoReg, 0x400E1354U) /**< \brief (PIOC) Parallel Capture Interrupt Enable Register */ -#define REG_PIOC_PCIDR REG_ACCESS(WoReg, 0x400E1358U) /**< \brief (PIOC) Parallel Capture Interrupt Disable Register */ -#define REG_PIOC_PCIMR REG_ACCESS(RoReg, 0x400E135CU) /**< \brief (PIOC) Parallel Capture Interrupt Mask Register */ -#define REG_PIOC_PCISR REG_ACCESS(RoReg, 0x400E1360U) /**< \brief (PIOC) Parallel Capture Interrupt Status Register */ -#define REG_PIOC_PCRHR REG_ACCESS(RoReg, 0x400E1364U) /**< \brief (PIOC) Parallel Capture Reception Holding Register */ -/* ========== Register definition for RSTC peripheral ========== */ -#define REG_RSTC_CR REG_ACCESS(WoReg, 0x400E1400U) /**< \brief (RSTC) Control Register */ -#define REG_RSTC_SR REG_ACCESS(RoReg, 0x400E1404U) /**< \brief (RSTC) Status Register */ -#define REG_RSTC_MR REG_ACCESS(RwReg, 0x400E1408U) /**< \brief (RSTC) Mode Register */ -/* ========== Register definition for SUPC peripheral ========== */ -#define REG_SUPC_CR REG_ACCESS(WoReg, 0x400E1410U) /**< \brief (SUPC) Supply Controller Control Register */ -#define REG_SUPC_SMMR REG_ACCESS(RwReg, 0x400E1414U) /**< \brief (SUPC) Supply Controller Supply Monitor Mode Register */ -#define REG_SUPC_MR REG_ACCESS(RwReg, 0x400E1418U) /**< \brief (SUPC) Supply Controller Mode Register */ -#define REG_SUPC_WUMR REG_ACCESS(RwReg, 0x400E141CU) /**< \brief (SUPC) Supply Controller Wake Up Mode Register */ -#define REG_SUPC_WUIR REG_ACCESS(RwReg, 0x400E1420U) /**< \brief (SUPC) Supply Controller Wake Up Inputs Register */ -#define REG_SUPC_SR REG_ACCESS(RoReg, 0x400E1424U) /**< \brief (SUPC) Supply Controller Status Register */ -/* ========== Register definition for RTT peripheral ========== */ -#define REG_RTT_MR REG_ACCESS(RwReg, 0x400E1430U) /**< \brief (RTT) Mode Register */ -#define REG_RTT_AR REG_ACCESS(RwReg, 0x400E1434U) /**< \brief (RTT) Alarm Register */ -#define REG_RTT_VR REG_ACCESS(RoReg, 0x400E1438U) /**< \brief (RTT) Value Register */ -#define REG_RTT_SR REG_ACCESS(RoReg, 0x400E143CU) /**< \brief (RTT) Status Register */ -/* ========== Register definition for WDT peripheral ========== */ -#define REG_WDT_CR REG_ACCESS(WoReg, 0x400E1450U) /**< \brief (WDT) Control Register */ -#define REG_WDT_MR REG_ACCESS(RwReg, 0x400E1454U) /**< \brief (WDT) Mode Register */ -#define REG_WDT_SR REG_ACCESS(RoReg, 0x400E1458U) /**< \brief (WDT) Status Register */ -/* ========== Register definition for RTC peripheral ========== */ -#define REG_RTC_CR REG_ACCESS(RwReg, 0x400E1460U) /**< \brief (RTC) Control Register */ -#define REG_RTC_MR REG_ACCESS(RwReg, 0x400E1464U) /**< \brief (RTC) Mode Register */ -#define REG_RTC_TIMR REG_ACCESS(RwReg, 0x400E1468U) /**< \brief (RTC) Time Register */ -#define REG_RTC_CALR REG_ACCESS(RwReg, 0x400E146CU) /**< \brief (RTC) Calendar Register */ -#define REG_RTC_TIMALR REG_ACCESS(RwReg, 0x400E1470U) /**< \brief (RTC) Time Alarm Register */ -#define REG_RTC_CALALR REG_ACCESS(RwReg, 0x400E1474U) /**< \brief (RTC) Calendar Alarm Register */ -#define REG_RTC_SR REG_ACCESS(RoReg, 0x400E1478U) /**< \brief (RTC) Status Register */ -#define REG_RTC_SCCR REG_ACCESS(WoReg, 0x400E147CU) /**< \brief (RTC) Status Clear Command Register */ -#define REG_RTC_IER REG_ACCESS(WoReg, 0x400E1480U) /**< \brief (RTC) Interrupt Enable Register */ -#define REG_RTC_IDR REG_ACCESS(WoReg, 0x400E1484U) /**< \brief (RTC) Interrupt Disable Register */ -#define REG_RTC_IMR REG_ACCESS(RoReg, 0x400E1488U) /**< \brief (RTC) Interrupt Mask Register */ -#define REG_RTC_VER REG_ACCESS(RoReg, 0x400E148CU) /**< \brief (RTC) Valid Entry Register */ -/* ========== Register definition for GPBR peripheral ========== */ -#define REG_GPBR_GPBR0 REG_ACCESS(RwReg, 0x400E1490U) /**< \brief (GPBR) General Purpose Backup Register 0 */ -#define REG_GPBR_GPBR1 REG_ACCESS(RwReg, 0x400E1494U) /**< \brief (GPBR) General Purpose Backup Register 1 */ -#define REG_GPBR_GPBR2 REG_ACCESS(RwReg, 0x400E1498U) /**< \brief (GPBR) General Purpose Backup Register 2 */ -#define REG_GPBR_GPBR3 REG_ACCESS(RwReg, 0x400E149CU) /**< \brief (GPBR) General Purpose Backup Register 3 */ -/*@}*/ - -/* ***************************************************************************** */ -/* PERIPHERAL ID DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_id Peripheral Ids Definitions */ -/*@{*/ - -#define ID_SUPC ( 0) /**< \brief Supply Controller (SUPC) */ -#define ID_RSTC ( 1) /**< \brief Reset Controller (RSTC) */ -#define ID_RTC ( 2) /**< \brief Real Time Clock (RTC) */ -#define ID_RTT ( 3) /**< \brief Real Time Timer (RTT) */ -#define ID_WDT ( 4) /**< \brief Watchdog Timer (WDT) */ -#define ID_PMC ( 5) /**< \brief Power Management Controller (PMC) */ -#define ID_EFC ( 6) /**< \brief Enhanced Flash Controller (EFC) */ -#define ID_UART0 ( 8) /**< \brief UART 0 (UART0) */ -#define ID_UART1 ( 9) /**< \brief UART 1 (UART1) */ -#define ID_SMC (10) /**< \brief Static Memory Controller (SMC) */ -#define ID_PIOA (11) /**< \brief Parallel I/O Controller A (PIOA) */ -#define ID_PIOB (12) /**< \brief Parallel I/O Controller B (PIOB) */ -#define ID_PIOC (13) /**< \brief Parallel I/O Controller C (PIOC) */ -#define ID_USART0 (14) /**< \brief USART 0 (USART0) */ -#define ID_USART1 (15) /**< \brief USART 1 (USART1) */ -#define ID_HSMCI (18) /**< \brief Multimedia Card Interface (HSMCI) */ -#define ID_TWI0 (19) /**< \brief Two Wire Interface 0 (TWI0) */ -#define ID_TWI1 (20) /**< \brief Two Wire Interface 1 (TWI1) */ -#define ID_SPI (21) /**< \brief Serial Peripheral Interface (SPI) */ -#define ID_SSC (22) /**< \brief Synchronous Serial Controler (SSC) */ -#define ID_TC0 (23) /**< \brief Timer/Counter 0 (TC0) */ -#define ID_TC1 (24) /**< \brief Timer/Counter 1 (TC1) */ -#define ID_TC2 (25) /**< \brief Timer/Counter 2 (TC2) */ -#define ID_TC3 (26) /**< \brief Timer/Counter 3 (TC3) */ -#define ID_TC4 (27) /**< \brief Timer/Counter 4 (TC4) */ -#define ID_TC5 (28) /**< \brief Timer/Counter 5 (TC5) */ -#define ID_ADC (29) /**< \brief Analog To Digital Converter (ADC) */ -#define ID_DACC (30) /**< \brief Digital To Analog Converter (DACC) */ -#define ID_PWM (31) /**< \brief Pulse Width Modulation (PWM) */ -#define ID_CRCCU (32) /**< \brief CRC Calculation Unit (CRCCU) */ -#define ID_ACC (33) /**< \brief Analog Comparator (ACC) */ -#define ID_UDP (34) /**< \brief USB Device Port (UDP) */ -/*@}*/ - -/* ***************************************************************************** */ -/* BASE ADDRESS DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_base Peripheral Base Address Definitions */ -/*@{*/ - -#define HSMCI CAST(Hsmci , 0x40000000U) /**< \brief (HSMCI ) Base Address */ -#define PDC_HSMCI CAST(Pdc , 0x40000100U) /**< \brief (PDC_HSMCI ) Base Address */ -#define SSC CAST(Ssc , 0x40004000U) /**< \brief (SSC ) Base Address */ -#define PDC_SSC CAST(Pdc , 0x40004100U) /**< \brief (PDC_SSC ) Base Address */ -#define SPI CAST(Spi , 0x40008000U) /**< \brief (SPI ) Base Address */ -#define PDC_SPI CAST(Pdc , 0x40008100U) /**< \brief (PDC_SPI ) Base Address */ -#define TC0 CAST(Tc , 0x40010000U) /**< \brief (TC0 ) Base Address */ -#define TC1 CAST(Tc , 0x40014000U) /**< \brief (TC1 ) Base Address */ -#define TWI0 CAST(Twi , 0x40018000U) /**< \brief (TWI0 ) Base Address */ -#define PDC_TWI0 CAST(Pdc , 0x40018100U) /**< \brief (PDC_TWI0 ) Base Address */ -#define TWI1 CAST(Twi , 0x4001C000U) /**< \brief (TWI1 ) Base Address */ -#define PDC_TWI1 CAST(Pdc , 0x4001C100U) /**< \brief (PDC_TWI1 ) Base Address */ -#define PWM CAST(Pwm , 0x40020000U) /**< \brief (PWM ) Base Address */ -#define PDC_PWM CAST(Pdc , 0x40020100U) /**< \brief (PDC_PWM ) Base Address */ -#define USART0 CAST(Usart , 0x40024000U) /**< \brief (USART0 ) Base Address */ -#define PDC_USART0 CAST(Pdc , 0x40024100U) /**< \brief (PDC_USART0) Base Address */ -#define USART1 CAST(Usart , 0x40028000U) /**< \brief (USART1 ) Base Address */ -#define PDC_USART1 CAST(Pdc , 0x40028100U) /**< \brief (PDC_USART1) Base Address */ -#define UDP CAST(Udp , 0x40034000U) /**< \brief (UDP ) Base Address */ -#define ADC CAST(Adc , 0x40038000U) /**< \brief (ADC ) Base Address */ -#define PDC_ADC CAST(Pdc , 0x40038100U) /**< \brief (PDC_ADC ) Base Address */ -#define DACC CAST(Dacc , 0x4003C000U) /**< \brief (DACC ) Base Address */ -#define PDC_DACC CAST(Pdc , 0x4003C100U) /**< \brief (PDC_DACC ) Base Address */ -#define ACC CAST(Acc , 0x40040000U) /**< \brief (ACC ) Base Address */ -#define CRCCU CAST(Crccu , 0x40044000U) /**< \brief (CRCCU ) Base Address */ -#define SMC CAST(Smc , 0x400E0000U) /**< \brief (SMC ) Base Address */ -#define MATRIX CAST(Matrix , 0x400E0200U) /**< \brief (MATRIX ) Base Address */ -#define PMC CAST(Pmc , 0x400E0400U) /**< \brief (PMC ) Base Address */ -#define UART0 CAST(Uart , 0x400E0600U) /**< \brief (UART0 ) Base Address */ -#define PDC_UART0 CAST(Pdc , 0x400E0700U) /**< \brief (PDC_UART0 ) Base Address */ -#define CHIPID CAST(Chipid , 0x400E0740U) /**< \brief (CHIPID ) Base Address */ -#define UART1 CAST(Uart , 0x400E0800U) /**< \brief (UART1 ) Base Address */ -#define PDC_UART1 CAST(Pdc , 0x400E0900U) /**< \brief (PDC_UART1 ) Base Address */ -#define EFC CAST(Efc , 0x400E0A00U) /**< \brief (EFC ) Base Address */ -#define PIOA CAST(Pio , 0x400E0E00U) /**< \brief (PIOA ) Base Address */ -#define PIOB CAST(Pio , 0x400E1000U) /**< \brief (PIOB ) Base Address */ -#define PIOC CAST(Pio , 0x400E1200U) /**< \brief (PIOC ) Base Address */ -#define RSTC CAST(Rstc , 0x400E1400U) /**< \brief (RSTC ) Base Address */ -#define SUPC CAST(Supc , 0x400E1410U) /**< \brief (SUPC ) Base Address */ -#define RTT CAST(Rtt , 0x400E1430U) /**< \brief (RTT ) Base Address */ -#define WDT CAST(Wdt , 0x400E1450U) /**< \brief (WDT ) Base Address */ -#define RTC CAST(Rtc , 0x400E1460U) /**< \brief (RTC ) Base Address */ -#define GPBR CAST(Gpbr , 0x400E1490U) /**< \brief (GPBR ) Base Address */ -/*@}*/ - -/* ***************************************************************************** */ -/* PIO DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ -/** \addtogroup AT91SAM3S_pio Peripheral Pio Definitions */ -/*@{*/ - -#define PIO_PA0 (1 << 0) /**< \brief Pin Controlled by PA0 */ -#define PIO_PA1 (1 << 1) /**< \brief Pin Controlled by PA1 */ -#define PIO_PA2 (1 << 2) /**< \brief Pin Controlled by PA2 */ -#define PIO_PA3 (1 << 3) /**< \brief Pin Controlled by PA3 */ -#define PIO_PA4 (1 << 4) /**< \brief Pin Controlled by PA4 */ -#define PIO_PA5 (1 << 5) /**< \brief Pin Controlled by PA5 */ -#define PIO_PA6 (1 << 6) /**< \brief Pin Controlled by PA6 */ -#define PIO_PA7 (1 << 7) /**< \brief Pin Controlled by PA7 */ -#define PIO_PA8 (1 << 8) /**< \brief Pin Controlled by PA8 */ -#define PIO_PA9 (1 << 9) /**< \brief Pin Controlled by PA9 */ -#define PIO_PA10 (1 << 10) /**< \brief Pin Controlled by PA10 */ -#define PIO_PA11 (1 << 11) /**< \brief Pin Controlled by PA11 */ -#define PIO_PA12 (1 << 12) /**< \brief Pin Controlled by PA12 */ -#define PIO_PA13 (1 << 13) /**< \brief Pin Controlled by PA13 */ -#define PIO_PA14 (1 << 14) /**< \brief Pin Controlled by PA14 */ -#define PIO_PA15 (1 << 15) /**< \brief Pin Controlled by PA15 */ -#define PIO_PA16 (1 << 16) /**< \brief Pin Controlled by PA16 */ -#define PIO_PA17 (1 << 17) /**< \brief Pin Controlled by PA17 */ -#define PIO_PA18 (1 << 18) /**< \brief Pin Controlled by PA18 */ -#define PIO_PA19 (1 << 19) /**< \brief Pin Controlled by PA19 */ -#define PIO_PA20 (1 << 20) /**< \brief Pin Controlled by PA20 */ -#define PIO_PA21 (1 << 21) /**< \brief Pin Controlled by PA21 */ -#define PIO_PA22 (1 << 22) /**< \brief Pin Controlled by PA22 */ -#define PIO_PA23 (1 << 23) /**< \brief Pin Controlled by PA23 */ -#define PIO_PA24 (1 << 24) /**< \brief Pin Controlled by PA24 */ -#define PIO_PA25 (1 << 25) /**< \brief Pin Controlled by PA25 */ -#define PIO_PA26 (1 << 26) /**< \brief Pin Controlled by PA26 */ -#define PIO_PA27 (1 << 27) /**< \brief Pin Controlled by PA27 */ -#define PIO_PA28 (1 << 28) /**< \brief Pin Controlled by PA28 */ -#define PIO_PA29 (1 << 29) /**< \brief Pin Controlled by PA29 */ -#define PIO_PA30 (1 << 30) /**< \brief Pin Controlled by PA30 */ -#define PIO_PA31 (1 << 31) /**< \brief Pin Controlled by PA31 */ -#define PIO_PB0 (1 << 0) /**< \brief Pin Controlled by PB0 */ -#define PIO_PB1 (1 << 1) /**< \brief Pin Controlled by PB1 */ -#define PIO_PB2 (1 << 2) /**< \brief Pin Controlled by PB2 */ -#define PIO_PB3 (1 << 3) /**< \brief Pin Controlled by PB3 */ -#define PIO_PB4 (1 << 4) /**< \brief Pin Controlled by PB4 */ -#define PIO_PB5 (1 << 5) /**< \brief Pin Controlled by PB5 */ -#define PIO_PB6 (1 << 6) /**< \brief Pin Controlled by PB6 */ -#define PIO_PB7 (1 << 7) /**< \brief Pin Controlled by PB7 */ -#define PIO_PB8 (1 << 8) /**< \brief Pin Controlled by PB8 */ -#define PIO_PB9 (1 << 9) /**< \brief Pin Controlled by PB9 */ -#define PIO_PB10 (1 << 10) /**< \brief Pin Controlled by PB10 */ -#define PIO_PB11 (1 << 11) /**< \brief Pin Controlled by PB11 */ -#define PIO_PB12 (1 << 12) /**< \brief Pin Controlled by PB12 */ -#define PIO_PB13 (1 << 13) /**< \brief Pin Controlled by PB13 */ -#define PIO_PB14 (1 << 14) /**< \brief Pin Controlled by PB14 */ -#define PIO_PC0 (1 << 0) /**< \brief Pin Controlled by PC0 */ -#define PIO_PC1 (1 << 1) /**< \brief Pin Controlled by PC1 */ -#define PIO_PC2 (1 << 2) /**< \brief Pin Controlled by PC2 */ -#define PIO_PC3 (1 << 3) /**< \brief Pin Controlled by PC3 */ -#define PIO_PC4 (1 << 4) /**< \brief Pin Controlled by PC4 */ -#define PIO_PC5 (1 << 5) /**< \brief Pin Controlled by PC5 */ -#define PIO_PC6 (1 << 6) /**< \brief Pin Controlled by PC6 */ -#define PIO_PC7 (1 << 7) /**< \brief Pin Controlled by PC7 */ -#define PIO_PC8 (1 << 8) /**< \brief Pin Controlled by PC8 */ -#define PIO_PC9 (1 << 9) /**< \brief Pin Controlled by PC9 */ -#define PIO_PC10 (1 << 10) /**< \brief Pin Controlled by PC10 */ -#define PIO_PC11 (1 << 11) /**< \brief Pin Controlled by PC11 */ -#define PIO_PC12 (1 << 12) /**< \brief Pin Controlled by PC12 */ -#define PIO_PC13 (1 << 13) /**< \brief Pin Controlled by PC13 */ -#define PIO_PC14 (1 << 14) /**< \brief Pin Controlled by PC14 */ -#define PIO_PC15 (1 << 15) /**< \brief Pin Controlled by PC15 */ -#define PIO_PC16 (1 << 16) /**< \brief Pin Controlled by PC16 */ -#define PIO_PC17 (1 << 17) /**< \brief Pin Controlled by PC17 */ -#define PIO_PC18 (1 << 18) /**< \brief Pin Controlled by PC18 */ -#define PIO_PC19 (1 << 19) /**< \brief Pin Controlled by PC19 */ -#define PIO_PC20 (1 << 20) /**< \brief Pin Controlled by PC20 */ -#define PIO_PC21 (1 << 21) /**< \brief Pin Controlled by PC21 */ -#define PIO_PC22 (1 << 22) /**< \brief Pin Controlled by PC22 */ -#define PIO_PC23 (1 << 23) /**< \brief Pin Controlled by PC23 */ -#define PIO_PC24 (1 << 24) /**< \brief Pin Controlled by PC24 */ -#define PIO_PC25 (1 << 25) /**< \brief Pin Controlled by PC25 */ -#define PIO_PC26 (1 << 26) /**< \brief Pin Controlled by PC26 */ -#define PIO_PC27 (1 << 27) /**< \brief Pin Controlled by PC27 */ -#define PIO_PC28 (1 << 28) /**< \brief Pin Controlled by PC28 */ -#define PIO_PC29 (1 << 29) /**< \brief Pin Controlled by PC29 */ -#define PIO_PC30 (1 << 30) /**< \brief Pin Controlled by PC30 */ -#define PIO_PC31 (1 << 31) /**< \brief Pin Controlled by PC31 */ -/* ========== Pio definition for HSMCI peripheral ========== */ -#define PIO_PA28C_MCCDA (1 << 28) /**< \brief Hsmci signal: MCCDA */ -#define PIO_PA29C_MCCK (1 << 29) /**< \brief Hsmci signal: MCCK */ -#define PIO_PA30C_MCDA0 (1 << 30) /**< \brief Hsmci signal: MCDA0 */ -#define PIO_PA31C_MCDA1 (1 << 31) /**< \brief Hsmci signal: MCDA1 */ -#define PIO_PA26C_MCDA2 (1 << 26) /**< \brief Hsmci signal: MCDA2 */ -#define PIO_PA27C_MCDA3 (1 << 27) /**< \brief Hsmci signal: MCDA3 */ -/* ========== Pio definition for SSC peripheral ========== */ -#define PIO_PA18A_RD (1 << 18) /**< \brief Ssc signal: RD */ -#define PIO_PA20A_RF (1 << 20) /**< \brief Ssc signal: RF */ -#define PIO_PA19A_RK (1 << 19) /**< \brief Ssc signal: RK */ -#define PIO_PA17A_TD (1 << 17) /**< \brief Ssc signal: TD */ -#define PIO_PA15A_TF (1 << 15) /**< \brief Ssc signal: TF */ -#define PIO_PA16A_TK (1 << 16) /**< \brief Ssc signal: TK */ -/* ========== Pio definition for SPI peripheral ========== */ -#define PIO_PA12A_MISO (1 << 12) /**< \brief Spi signal: MISO */ -#define PIO_PA13A_MOSI (1 << 13) /**< \brief Spi signal: MOSI */ -#define PIO_PA11A_NPCS0 (1 << 11) /**< \brief Spi signal: NPCS0 */ -#define PIO_PA31A_NPCS1 (1 << 31) /**< \brief Spi signal: NPCS1 */ -#define PIO_PA9B_NPCS1 (1 << 9) /**< \brief Spi signal: NPCS1 */ -#define PIO_PB14A_NPCS1 (1 << 14) /**< \brief Spi signal: NPCS1 */ -#define PIO_PC4B_NPCS1 (1 << 4) /**< \brief Spi signal: NPCS1 */ -#define PIO_PA10B_NPCS2 (1 << 10) /**< \brief Spi signal: NPCS2 */ -#define PIO_PA30B_NPCS2 (1 << 30) /**< \brief Spi signal: NPCS2 */ -#define PIO_PB2B_NPCS2 (1 << 2) /**< \brief Spi signal: NPCS2 */ -#define PIO_PA22B_NPCS3 (1 << 22) /**< \brief Spi signal: NPCS3 */ -#define PIO_PA3B_NPCS3 (1 << 3) /**< \brief Spi signal: NPCS3 */ -#define PIO_PA5B_NPCS3 (1 << 5) /**< \brief Spi signal: NPCS3 */ -#define PIO_PA14A_SPCK (1 << 14) /**< \brief Spi signal: SPCK */ -/* ========== Pio definition for TC0 peripheral ========== */ -#define PIO_PA4B_TCLK0 (1 << 4) /**< \brief Tc0 signal: TCLK0 */ -#define PIO_PA28B_TCLK1 (1 << 28) /**< \brief Tc0 signal: TCLK1 */ -#define PIO_PA29B_TCLK2 (1 << 29) /**< \brief Tc0 signal: TCLK2 */ -#define PIO_PA0B_TIOA0 (1 << 0) /**< \brief Tc0 signal: TIOA0 */ -#define PIO_PA15B_TIOA1 (1 << 15) /**< \brief Tc0 signal: TIOA1 */ -#define PIO_PA26B_TIOA2 (1 << 26) /**< \brief Tc0 signal: TIOA2 */ -#define PIO_PA1B_TIOB0 (1 << 1) /**< \brief Tc0 signal: TIOB0 */ -#define PIO_PA16B_TIOB1 (1 << 16) /**< \brief Tc0 signal: TIOB1 */ -#define PIO_PA27B_TIOB2 (1 << 27) /**< \brief Tc0 signal: TIOB2 */ -/* ========== Pio definition for TC1 peripheral ========== */ -#define PIO_PC25B_TCLK3 (1 << 25) /**< \brief Tc1 signal: TCLK3 */ -#define PIO_PC28B_TCLK4 (1 << 28) /**< \brief Tc1 signal: TCLK4 */ -#define PIO_PC31B_TCLK5 (1 << 31) /**< \brief Tc1 signal: TCLK5 */ -#define PIO_PC23B_TIOA3 (1 << 23) /**< \brief Tc1 signal: TIOA3 */ -#define PIO_PC26B_TIOA4 (1 << 26) /**< \brief Tc1 signal: TIOA4 */ -#define PIO_PC29B_TIOA5 (1 << 29) /**< \brief Tc1 signal: TIOA5 */ -#define PIO_PC24B_TIOB3 (1 << 24) /**< \brief Tc1 signal: TIOB3 */ -#define PIO_PC27B_TIOB4 (1 << 27) /**< \brief Tc1 signal: TIOB4 */ -#define PIO_PC30B_TIOB5 (1 << 30) /**< \brief Tc1 signal: TIOB5 */ -/* ========== Pio definition for TWI0 peripheral ========== */ -#define PIO_PA4A_TWCK0 (1 << 4) /**< \brief Twi0 signal: TWCK0 */ -#define PIO_PA3A_TWD0 (1 << 3) /**< \brief Twi0 signal: TWD0 */ -/* ========== Pio definition for TWI1 peripheral ========== */ -#define PIO_PB5A_TWCK1 (1 << 5) /**< \brief Twi1 signal: TWCK1 */ -#define PIO_PB4A_TWD1 (1 << 4) /**< \brief Twi1 signal: TWD1 */ -/* ========== Pio definition for PWM peripheral ========== */ -#define PIO_PA9C_PWMFI0 (1 << 9) /**< \brief Pwm signal: PWMFI0 */ -#define PIO_PA0A_PWMH0 (1 << 0) /**< \brief Pwm signal: PWMH0 */ -#define PIO_PA11B_PWMH0 (1 << 11) /**< \brief Pwm signal: PWMH0 */ -#define PIO_PA23B_PWMH0 (1 << 23) /**< \brief Pwm signal: PWMH0 */ -#define PIO_PB0A_PWMH0 (1 << 0) /**< \brief Pwm signal: PWMH0 */ -#define PIO_PC18B_PWMH0 (1 << 18) /**< \brief Pwm signal: PWMH0 */ -#define PIO_PA1A_PWMH1 (1 << 1) /**< \brief Pwm signal: PWMH1 */ -#define PIO_PA12B_PWMH1 (1 << 12) /**< \brief Pwm signal: PWMH1 */ -#define PIO_PA24B_PWMH1 (1 << 24) /**< \brief Pwm signal: PWMH1 */ -#define PIO_PB1A_PWMH1 (1 << 1) /**< \brief Pwm signal: PWMH1 */ -#define PIO_PC19B_PWMH1 (1 << 19) /**< \brief Pwm signal: PWMH1 */ -#define PIO_PA13B_PWMH2 (1 << 13) /**< \brief Pwm signal: PWMH2 */ -#define PIO_PA2A_PWMH2 (1 << 2) /**< \brief Pwm signal: PWMH2 */ -#define PIO_PA25B_PWMH2 (1 << 25) /**< \brief Pwm signal: PWMH2 */ -#define PIO_PB4B_PWMH2 (1 << 4) /**< \brief Pwm signal: PWMH2 */ -#define PIO_PC20B_PWMH2 (1 << 20) /**< \brief Pwm signal: PWMH2 */ -#define PIO_PA14B_PWMH3 (1 << 14) /**< \brief Pwm signal: PWMH3 */ -#define PIO_PA17C_PWMH3 (1 << 17) /**< \brief Pwm signal: PWMH3 */ -#define PIO_PA7B_PWMH3 (1 << 7) /**< \brief Pwm signal: PWMH3 */ -#define PIO_PB14B_PWMH3 (1 << 14) /**< \brief Pwm signal: PWMH3 */ -#define PIO_PC21B_PWMH3 (1 << 21) /**< \brief Pwm signal: PWMH3 */ -#define PIO_PA19B_PWML0 (1 << 19) /**< \brief Pwm signal: PWML0 */ -#define PIO_PB5B_PWML0 (1 << 5) /**< \brief Pwm signal: PWML0 */ -#define PIO_PC0B_PWML0 (1 << 0) /**< \brief Pwm signal: PWML0 */ -#define PIO_PC13B_PWML0 (1 << 13) /**< \brief Pwm signal: PWML0 */ -#define PIO_PA20B_PWML1 (1 << 20) /**< \brief Pwm signal: PWML1 */ -#define PIO_PB12A_PWML1 (1 << 12) /**< \brief Pwm signal: PWML1 */ -#define PIO_PC1B_PWML1 (1 << 1) /**< \brief Pwm signal: PWML1 */ -#define PIO_PC15B_PWML1 (1 << 15) /**< \brief Pwm signal: PWML1 */ -#define PIO_PA16C_PWML2 (1 << 16) /**< \brief Pwm signal: PWML2 */ -#define PIO_PA30A_PWML2 (1 << 30) /**< \brief Pwm signal: PWML2 */ -#define PIO_PB13A_PWML2 (1 << 13) /**< \brief Pwm signal: PWML2 */ -#define PIO_PC2B_PWML2 (1 << 2) /**< \brief Pwm signal: PWML2 */ -#define PIO_PA15C_PWML3 (1 << 15) /**< \brief Pwm signal: PWML3 */ -#define PIO_PC22B_PWML3 (1 << 22) /**< \brief Pwm signal: PWML3 */ -#define PIO_PC3B_PWML3 (1 << 3) /**< \brief Pwm signal: PWML3 */ -/* ========== Pio definition for USART0 peripheral ========== */ -#define PIO_PA8A_CTS0 (1 << 8) /**< \brief Usart0 signal: CTS0 */ -#define PIO_PA7A_RTS0 (1 << 7) /**< \brief Usart0 signal: RTS0 */ -#define PIO_PA5A_RXD0 (1 << 5) /**< \brief Usart0 signal: RXD0 */ -#define PIO_PA2B_SCK0 (1 << 2) /**< \brief Usart0 signal: SCK0 */ -#define PIO_PA6A_TXD0 (1 << 6) /**< \brief Usart0 signal: TXD0 */ -/* ========== Pio definition for USART1 peripheral ========== */ -#define PIO_PA25A_CTS1 (1 << 25) /**< \brief Usart1 signal: CTS1 */ -#define PIO_PA26A_DCD1 (1 << 26) /**< \brief Usart1 signal: DCD1 */ -#define PIO_PA28A_DSR1 (1 << 28) /**< \brief Usart1 signal: DSR1 */ -#define PIO_PA27A_DTR1 (1 << 27) /**< \brief Usart1 signal: DTR1 */ -#define PIO_PA29A_RI1 (1 << 29) /**< \brief Usart1 signal: RI1 */ -#define PIO_PA24A_RTS1 (1 << 24) /**< \brief Usart1 signal: RTS1 */ -#define PIO_PA21A_RXD1 (1 << 21) /**< \brief Usart1 signal: RXD1 */ -#define PIO_PA23A_SCK1 (1 << 23) /**< \brief Usart1 signal: SCK1 */ -#define PIO_PA22A_TXD1 (1 << 22) /**< \brief Usart1 signal: TXD1 */ -/* ========== Pio definition for ADC peripheral ========== */ -#define PIO_PA17X1_AD0 (1 << 17) /**< \brief Adc signal: AD0 */ -#define PIO_PA18X1_AD1 (1 << 18) /**< \brief Adc signal: AD1 */ -#define PIO_PC13X1_AD10 (1 << 13) /**< \brief Adc signal: AD10 */ -#define PIO_PC15X1_AD11 (1 << 15) /**< \brief Adc signal: AD11 */ -#define PIO_PC12X1_AD12 (1 << 12) /**< \brief Adc signal: AD12 */ -#define PIO_PC29X1_AD13 (1 << 29) /**< \brief Adc signal: AD13 */ -#define PIO_PC30X1_AD14 (1 << 30) /**< \brief Adc signal: AD14 */ -#define PIO_PA19X1_AD2 (1 << 19) /**< \brief Adc signal: AD2 */ -#define PIO_PA20X1_AD3 (1 << 20) /**< \brief Adc signal: AD3 */ -#define PIO_PB0X1_AD4 (1 << 0) /**< \brief Adc signal: AD4 */ -#define PIO_PB1X1_AD5 (1 << 1) /**< \brief Adc signal: AD5 */ -#define PIO_PB2X1_AD6 (1 << 2) /**< \brief Adc signal: AD6 */ -#define PIO_PB3X1_AD7 (1 << 3) /**< \brief Adc signal: AD7 */ -#define PIO_PA21X1_AD8 (1 << 21) /**< \brief Adc signal: AD8 */ -#define PIO_PA22X1_AD9 (1 << 22) /**< \brief Adc signal: AD9 */ -#define PIO_PA8B_ADTRG (1 << 8) /**< \brief Adc signal: ADTRG */ -/* ========== Pio definition for DACC peripheral ========== */ -#define PIO_PB13X1_DAC0 (1 << 13) /**< \brief Dacc signal: DAC0 */ -#define PIO_PB14X1_DAC1 (1 << 14) /**< \brief Dacc signal: DAC1 */ -#define PIO_PA2C_DATRG (1 << 2) /**< \brief Dacc signal: DATRG */ -/* ========== Pio definition for PMC peripheral ========== */ -#define PIO_PA6B_PCK0 (1 << 6) /**< \brief Pmc signal: PCK0 */ -#define PIO_PB13B_PCK0 (1 << 13) /**< \brief Pmc signal: PCK0 */ -#define PIO_PA17B_PCK1 (1 << 17) /**< \brief Pmc signal: PCK1 */ -#define PIO_PA21B_PCK1 (1 << 21) /**< \brief Pmc signal: PCK1 */ -#define PIO_PA18B_PCK2 (1 << 18) /**< \brief Pmc signal: PCK2 */ -#define PIO_PA31B_PCK2 (1 << 31) /**< \brief Pmc signal: PCK2 */ -#define PIO_PB3B_PCK2 (1 << 3) /**< \brief Pmc signal: PCK2 */ -/* ========== Pio definition for UART0 peripheral ========== */ -#define PIO_PA9A_URXD0 (1 << 9) /**< \brief Uart0 signal: URXD0 */ -#define PIO_PA10A_UTXD0 (1 << 10) /**< \brief Uart0 signal: UTXD0 */ -/* ========== Pio definition for UART1 peripheral ========== */ -#define PIO_PB2A_URXD1 (1 << 2) /**< \brief Uart1 signal: URXD1 */ -#define PIO_PB3A_UTXD1 (1 << 3) /**< \brief Uart1 signal: UTXD1 */ -/* ========== Pio definition for PIOA peripheral ========== */ -#define PIO_PA24X1_PIODC0 (1 << 24) /**< \brief Pioa signal: PIODC0 */ -#define PIO_PA25X1_PIODC1 (1 << 25) /**< \brief Pioa signal: PIODC1 */ -#define PIO_PA26X1_PIODC2 (1 << 26) /**< \brief Pioa signal: PIODC2 */ -#define PIO_PA27X1_PIODC3 (1 << 27) /**< \brief Pioa signal: PIODC3 */ -#define PIO_PA28X1_PIODC4 (1 << 28) /**< \brief Pioa signal: PIODC4 */ -#define PIO_PA29X1_PIODC5 (1 << 29) /**< \brief Pioa signal: PIODC5 */ -#define PIO_PA30X1_PIODC6 (1 << 30) /**< \brief Pioa signal: PIODC6 */ -#define PIO_PA31X1_PIODC7 (1 << 31) /**< \brief Pioa signal: PIODC7 */ -#define PIO_PA23X1_PIODCCLK (1 << 23) /**< \brief Pioa signal: PIODCCLK */ -#define PIO_PA15X1_PIODCEN1 (1 << 15) /**< \brief Pioa signal: PIODCEN1 */ -#define PIO_PA16X1_PIODCEN2 (1 << 16) /**< \brief Pioa signal: PIODCEN2 */ -/*@}*/ - -/* ***************************************************************************** */ -/* MEMORY MAPPING DEFINITIONS FOR AT91SAM3S */ -/* ***************************************************************************** */ - -#define AT91C_IRAM (0x20000000) /**< Internal RAM base address */ -#define AT91C_IFLASH (0x00400000) /**< Internal Flash base address */ -#define AT91C_IROM (0x00800000) /**< Internal ROM base address */ -#define AT91C_IRAM (0x20000000) /**< Internal RAM base address */ -#define AT91C_EBI_CS0 (0x60000000) /**< EBI Chip Select 0 base address */ -#define AT91C_EBI_CS1 (0x61000000) /**< EBI Chip Select 1 base address */ -#define AT91C_EBI_CS2 (0x62000000) /**< EBI Chip Select 2 base address */ -#define AT91C_EBI_CS3 (0x63000000) /**< EBI Chip Select 3 base address */ - -#ifdef __cplusplus -} -#endif - -/*@}*/ - -#endif /* AT91SAM3S_H */ diff --git a/src/ersky9x/libraries/board/at91sam3s4/chip.h b/src/ersky9x/libraries/board/at91sam3s4/chip.h deleted file mode 100644 index d216db6d1..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/chip.h +++ /dev/null @@ -1,130 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// !Purpose -/// -/// Definition of AT91SAM3S4 characteristics and features -/// -/// !Usage -/// -# For ARM core feature, see "AT91SAM3S4 - ARM core features". -/// -# For IP features, see "AT91SAM3S4 - IP features". -/// -# For misc, see "AT91SAM3S4 - Misc". -//------------------------------------------------------------------------------ - -#ifndef CHIP_H -#define CHIP_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "AT91SAM3S4 - ARM core features" -/// This page lists several characteristics related to the ARM core -/// - -//ARM core features - -/// ARM core definition. -#define cortexm3 - -/// family definition. -#define at91sam3s - -//------------------------------------------------------------------------------ -/// \page "AT91SAM3S4 - IP features" -/// This page lists several characteristics related to the embedded IP -/// - -//IP FEATURES - -// EFC GPNVM number -#define CHIP_EFC_NUM_GPNVMS 3 - -/// Indicates chip has an Enhanced EFC. -#define CHIP_FLASH_EEFC - -// DMA channels number -#define CHIP_DMA_CHANNEL_NUM 4 - -// Indicate chip's MCI interface. -#define MCI2_INTERFACE - -// Indicate chip SSC has DMA interface. -#define CHIP_SSC_DMA - -// Indicate chip SPI has DMA interface. -#define CHIP_SPI_DMA - -/// Indicates chip has an UDP Full Speed. -#define CHIP_USB_UDP - -/// Indicates chip has an internal pull-up. -#define CHIP_USB_PULLUP_INTERNAL - -/// Number of USB endpoints -#define CHIP_USB_NUMENDPOINTS 8 - -/// Endpoints max paxcket size -#define CHIP_USB_ENDPOINTS_MAXPACKETSIZE(i) \ - ((i == 0) ? 64 : \ - ((i == 1) ? 64 : \ - ((i == 2) ? 64 : \ - ((i == 3) ? 64 : \ - ((i == 4) ? 512 : \ - ((i == 5) ? 512 : \ - ((i == 6) ? 64 : \ - ((i == 7) ? 64 : 0 )))))))) - -/// Endpoints Number of Bank -#define CHIP_USB_ENDPOINTS_BANKS(i) \ - ((i == 0) ? 1 : \ - ((i == 1) ? 2 : \ - ((i == 2) ? 2 : \ - ((i == 3) ? 1 : \ - ((i == 4) ? 2 : \ - ((i == 5) ? 2 : \ - ((i == 6) ? 2 : \ - ((i == 7) ? 2 : 0 )))))))) - -//------------------------------------------------------------------------------ -/// \page "AT91SAM3S4 - Misc " -/// This page lists misc features -/// - -//Misc - -#endif //#ifndef CHIP_H - diff --git a/src/ersky9x/libraries/board/at91sam3s4/flash.icf b/src/ersky9x/libraries/board/at91sam3s4/flash.icf deleted file mode 100644 index 942ad9b0d..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/flash.icf +++ /dev/null @@ -1,30 +0,0 @@ -/*###ICF### Section handled by ICF editor, don't touch! ****/ -/*-Editor annotation file-*/ -/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ -/*-Vector table start*/ -define symbol __ICFEDIT_vector_start__ = 0x000400000; /*Add for CMSIS*/ -/*-Memory Regions-*/ -define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; -define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF; -define symbol __ICFEDIT_region_ROM_start__ = 0x00400000; -define symbol __ICFEDIT_region_ROM_end__ = 0x0043FFFF; -/*-Sizes-*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; -define symbol __ICFEDIT_size_heap__ = 0x200; - -export symbol __ICFEDIT_vector_start__; /*Add for CMSIS*/ -/**** End of ICF editor section. ###ICF###*/ - -define memory mem with size = 4G; -define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; -define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; - -define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; -define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; - -initialize by copy { readwrite }; -do not initialize { section .noinit }; - -place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors }; /*Add for CMSIS*/ -place in ROM_region { readonly }; -place in RAM_region { readwrite,,block CSTACK, block HEAP }; diff --git a/src/ersky9x/libraries/board/at91sam3s4/flash.lds b/src/ersky9x/libraries/board/at91sam3s4/flash.lds deleted file mode 100644 index bb3aa2fce..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/flash.lds +++ /dev/null @@ -1,81 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------------ - * Linker script for running in internal FLASH on the AT91SAM3S4 - *----------------------------------------------------------------------------*/ - -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(ResetException) - -/* Memory Spaces Definitions */ -MEMORY -{ - sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0000C000 /* sram, 48K */ - flash (W!RX) : ORIGIN = 0x00400000, LENGTH = 0x00040000 /* Flash, 256K */ -} - -SECTIONS -{ - .fixed : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) - *(.text*) - *(.rodata*) - *(.glue_7) - *(.glue_7t) - . = ALIGN(4); - _efixed = .; /* End of text section */ - } >flash - - .relocate : AT (_efixed) - { - . = ALIGN(4); - _srelocate = .; - *(.ramfunc); - *(.data); - . = ALIGN(4); - _erelocate = .; - } >sram - - .bss (NOLOAD) : { - . = ALIGN(4); - _szero = .; - *(.bss) - . = ALIGN(4); - _ezero = .; - } >sram - - /* Stack in the end of SRAM */ - _estack = 0x2000BFFC; -} -end = .; diff --git a/src/ersky9x/libraries/board/at91sam3s4/sram.icf b/src/ersky9x/libraries/board/at91sam3s4/sram.icf deleted file mode 100644 index 894f96bf0..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/sram.icf +++ /dev/null @@ -1,27 +0,0 @@ -/*###ICF### Section handled by ICF editor, don't touch! ****/ -/*-Editor annotation file-*/ -/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ -/*-Vector table start*/ -define symbol __ICFEDIT_vector_start__ = 0x20000000; -/*-Memory Regions-*/ -define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; -define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF; -/*-Sizes-*/ -define symbol __ICFEDIT_size_cstack__ = 0x900; -define symbol __ICFEDIT_size_heap__ = 0x200; -/*-Exports-*/ -export symbol __ICFEDIT_vector_start__; -/**** End of ICF editor section. ###ICF###*/ - -define memory mem with size = 4G; -define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; - -/* define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { }; */ -define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; -define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; - -initialize by copy { readwrite }; -do not initialize { section .noinit }; - -place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors }; -place in RAM_region { readonly, readwrite, block CSTACK, block HEAP }; diff --git a/src/ersky9x/libraries/board/at91sam3s4/sram.lds b/src/ersky9x/libraries/board/at91sam3s4/sram.lds deleted file mode 100644 index 6b3f54abd..000000000 --- a/src/ersky9x/libraries/board/at91sam3s4/sram.lds +++ /dev/null @@ -1,81 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------------ - * Linker script for running in internal SRAM on the AT91SAM3S4 - *----------------------------------------------------------------------------*/ - -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(ResetException) - -/* Memory Spaces Definitions */ -MEMORY -{ - sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0000C000 /* sram, 48K */ -} - -SECTIONS -{ - .fixed : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) - *(.text*) - *(.ramfunc) - *(.rodata*) - *(.glue_7) - *(.glue_7t) - . = ALIGN(4); - _efixed = .; /* End of text section */ - } > sram - - .relocate : AT (_efixed) - { - . = ALIGN(4); - _srelocate = .; - *(.data) - . = ALIGN(4); - _erelocate = .; - } >sram - - .bss (NOLOAD) : { - . = ALIGN(4); - _szero = .; - *(.bss) - . = ALIGN(4); - _ezero = .; - } >sram - - /* Stack in the end of SRAM */ - _estack = 0x2000BFFC; - -} -end = .; diff --git a/src/ersky9x/libraries/board/board.h b/src/ersky9x/libraries/board/board.h deleted file mode 100644 index 85f4b1a24..000000000 --- a/src/ersky9x/libraries/board/board.h +++ /dev/null @@ -1,673 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/** - * \page sam3s_ek_board_desc "SAM3S-EK - Board Description" - * - * \section - * A file is dedicated to descibe the AT91SAM3S-EK board. - * - * \section Contents - * - The code for booting the board is provided by board_cstartup.S and - * board_lowlevel.c. - * - For using board PIOs, board characteristics (clock, etc.) and external - * components, see board.h. - * - For manipulating memories (remapping, SDRAM, etc.), see board_memories.h. - * - * To get more software details and the full list of parameters related to the - * SAM3S-EK board configuration, please have a look at the source file: \n - * \ref board.h\n - * - * This file can be used as a template and modified to fit a custom board, with - * specific PIOs usage or memory connections. - **/ -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// \file board.h -/// -/// \par Purpose -/// -/// Definition of AT91SAM3S-EK characteristics, AT91SAM3S-dependant PIOs and -/// external components interfacing. -/// -/// \par Usage -/// -# For operating frequency information, see "SAM3S-EK - Operating frequencies". -/// -# For using portable PIO definitions, see "SAM3S-EK - PIO definitions". -/// -# Several USB definitions are included here (see "SAM3S-EK - USB device"). -//------------------------------------------------------------------------------ - -#ifndef BOARD_H -#define BOARD_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */ -#include -#include - -#if defined(at91sam3s4) - #include "at91sam3s4/chip.h" - #include "at91sam3s4/AT91SAM3S4.h" -#else - #error Board does not support the specified chip. -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par -/// This page lists several definition related to the board description. -/// -/// Definitions -/// - BOARD_NAME - -/// Name of the board. -#define BOARD_NAME "AT91SAM3S-EK" -/// Board definition. -#define at91sam3sek -/// Family definition (already defined). -#define at91sam3s -/// Core definition -#define cortexm3 - -//#define BOARD_REV_A -#define BOARD_REV_B - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_opfreq "SAM3S-EK - Operating frequencies" -/// This page lists several definition related to the board operating frequency -/// (when using the initialization done by board_lowlevel.c). -/// -/// !Definitions -/// - BOARD_MAINOSC -/// - BOARD_MCK - -/// Frequency of the board main oscillator. -#define BOARD_MAINOSC 12000000 - -/// Master clock frequency (when using board_lowlevel.c). -//#define BOARD_MCK 48000000 -//#define BOARD_MCK 64000000 - -//------------------------------------------------------------------------------ -// ADC -//------------------------------------------------------------------------------ - -/// Startup time max, return from Idle mode (in µs) -#define ADC_STARTUP_TIME_MAX 15 -/// Track and hold Acquisition Time min (in ns) -#define ADC_TRACK_HOLD_TIME_MIN 1200 - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USB attributes configuration descriptor (bus or self powered, remote wakeup) -//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP -#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_piodef "SAM3S-EK - PIO definitions" -/// This pages lists all the pio definitions contained in board.h. The constants -/// are named using the following convention: PIN_* for a constant which defines -/// a single Pin instance (but may include several PIOs sharing the same -/// controller), and PINS_* for a list of Pin instances. -/// -/// !ADC -/// - PIN_ADC0_AD0 -/// - PIN_ADC0_AD1 -/// - PIN_ADC0_AD2 -/// - PIN_ADC0_AD3 -/// - PIN_ADC0_AD4 -/// - PIN_ADC0_AD5 -/// - PIN_ADC0_AD6 -/// - PIN_ADC0_AD7 -/// - PINS_ADC0 -/// -/// !UART -/// - PINS_UART -/// -/// !EBI -/// - PIN_EBI_DATA_BUS -/// - PIN_EBI_NCS0 -/// - PIN_EBI_NRD -/// - PIN_EBI_NWE -/// - PIN_EBI_ADDR_BUS -/// - PIN_EBI_PSRAM_NBS -/// - PIN_EBI_A1 -/// - PIN_EBI_LCD_RS -/// -/// !LEDs -/// - PIN_LED_0 -/// - PIN_LED_1 -/// - PIN_LED_2 -/// - PINS_LEDS -/// -/// !MCI -/// - PINS_MCI -/// -/// !Push buttons -/// - PIN_PUSHBUTTON_1 -/// - PIN_PUSHBUTTON_2 -/// - PINS_PUSHBUTTONS -/// - PUSHBUTTON_BP1 -/// - PUSHBUTTON_BP2 -/// -/// !PWMC -/// - PIN_PWMC_PWMH0 -/// - PIN_PWMC_PWML0 -/// - PIN_PWMC_PWMH1 -/// - PIN_PWMC_PWML1 -/// - PIN_PWMC_PWMH2 -/// - PIN_PWMC_PWML2 -/// - PIN_PWMC_PWMH3 -/// - PIN_PWMC_PWML3 -/// - PIN_PWM_LED0 -/// - PIN_PWM_LED1 -/// - PIN_PWM_LED2 -/// - CHANNEL_PWM_LED0 -/// - CHANNEL_PWM_LED1 -/// - CHANNEL_PWM_LED2 -/// -/// !SPI -/// - PIN_SPI_MISO -/// - PIN_SPI_MOSI -/// - PIN_SPI_SPCK -/// - PINS_SPI -/// - PIN_SPI_NPCS0_PA11 -/// -/// ! SSC -/// - PIN_SSC_TD -/// - PIN_SSC_TK -/// - PIN_SSC_TF -/// - PINS_SSC_CODEC -/// -/// ! PCK0 -/// - PIN_PCK0 -/// -/// !TWI -/// - PIN_TWI_TWD0 -/// - PIN_TWI_TWCK0 -/// - PINS_TWI -/// -/// !USART0 -/// - PIN_USART0_RXD -/// - PIN_USART0_TXD -/// - PIN_USART0_CTS -/// - PIN_USART0_RTS -/// - PIN_USART0_SCK -/// -/// !USB -/// - PIN_USB_PULLUP -/// - -/// ADC_AD0 pin definition. -#define PIN_ADC0_AD0 {1 << 21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD1 pin definition. -#define PIN_ADC0_AD1 {1 << 30, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD2 pin definition. -#define PIN_ADC0_AD2 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD3 pin definition. -#define PIN_ADC0_AD3 {1 << 4, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD4 pin definition. -#define PIN_ADC0_AD4 {1 << 15, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD5 pin definition. -#define PIN_ADC0_AD5 {1 << 16, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD6 pin definition. -#define PIN_ADC0_AD6 {1 << 17, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD7 pin definition. -#define PIN_ADC0_AD7 {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} - -/// Pins ADC -#define PINS_ADC PIN_ADC0_AD0, PIN_ADC0_AD1, PIN_ADC0_AD2, PIN_ADC0_AD3, PIN_ADC0_AD4, PIN_ADC0_AD5, PIN_ADC0_AD6, PIN_ADC0_AD7 - -/** UART pins (UTXD0 and URXD0) definitions, PA9,10. */ -#define PINS_UART {0x00000600, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} - -/// EBI -#define PIN_EBI_DATA_BUS {0xFF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NRD {1 << 11, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NWE {1 << 8, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -#define PIN_EBI_NCS0 {1 << 20, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_PSRAM_ADDR_BUS {0x3f00fff, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_PSRAM_NBS {1 << 7, PIOB, ID_PIOB, PIO_PERIPH_B, PIO_PULLUP}, \ - {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_A1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -#define PIN_EBI_NCS1 {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD CS pin */ -#define PIN_EBI_LCD_RS {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD RS pin */ - -#ifdef BOARD_REV_A -/** LED #0 pin definition. */ -#define PIN_LED_0 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #1 pin definition. */ -#define PIN_LED_1 {1 << 21, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #2 pin definition. */ -#define PIN_LED_2 {1 << 22, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -#endif -#ifdef BOARD_REV_B -/** LED #0 pin definition. */ -#define PIN_LED_0 {1 << 19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #1 pin definition. */ -#define PIN_LED_1 {1 << 20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #2 pin definition. */ -#define PIN_LED_2 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -#endif - -/** List of all LEDs definitions. */ -#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2 - -#if 0 -// TODO check BSS -/// MCI pins definition. -#define PINS_MCI {0x1f8, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_PULLUP}, \ - {1 << 3, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} - -/// MCI pin Card Detect -#define PIN_MCI_CD \ - {AT91C_PIO_PA25, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP} -#endif - -/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */ -#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} -/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */ -#define PIN_PUSHBUTTON_2 {1 << 12, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} -/** List of all push button definitions. */ -#define PINS_PUSHBUTTONS PIN_PUSHBUTTON_1, PIN_PUSHBUTTON_2 - -/** Push button #1 index. */ -#define PUSHBUTTON_BP1 0 -/** Push button #2 index. */ -#define PUSHBUTTON_BP2 1 - -/// Simulated joystick LEFT index. -#define JOYSTICK_LEFT 0 -/// Simulated joystick RIGHT index. -#define JOYSTICK_RIGHT 1 - -/** PWMC PWM0 pin definition. */ -#define PIN_PWMC_PWMH0 {1 << 18, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML0 {1 << 19, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} -/** PWMC PWM1 pin definition. */ -#define PIN_PWMC_PWMH1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML1 {1 << 20, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} -/** PWMC PWM2 pin definition. */ -#define PIN_PWMC_PWMH2 {1 << 20, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML2 {1 << 16, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} -/** PWMC PWM3 pin definition. */ -#define PIN_PWMC_PWMH3 {1 << 21, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML3 {1 << 15, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} -/** PWM pin definition for LED0 */ -#define PIN_PWM_LED0 PIN_PWMC_PWMH0, PIN_PWMC_PWML0 -/** PWM pin definition for LED1 */ -#define PIN_PWM_LED1 PIN_PWMC_PWMH2, PIN_PWMC_PWML2 -/** PWM pin definition for LED2 */ -#define PIN_PWM_LED2 PIN_PWMC_PWMH3, PIN_PWMC_PWML3 -/** PWM channel for LED0 */ -#define CHANNEL_PWM_LED0 0 -/** PWM channel for LED1 */ -#define CHANNEL_PWM_LED1 2 -/** PWM channel for LED2 */ -#define CHANNEL_PWM_LED2 3 - -/** SPI MISO pin definition. */ -#define PIN_SPI_MISO {1 << 12, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI MOSI pin definition. */ -#define PIN_SPI_MOSI {1 << 13, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI SPCK pin definition. */ -#define PIN_SPI_SPCK {1 << 14, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI chip select pin definition. */ -#define PIN_SPI_NPCS0_PA11 {1 << 11, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** List of SPI pin definitions (MISO, MOSI & SPCK). */ -#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK - -/// SSC pins definition. -#define PIN_SSC_TD {0x1 << 26, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_SSC_TK {0x1 << 28, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_SSC_TF {0x1 << 30, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_SSC_CODEC PIN_SSC_TD, PIN_SSC_TK, PIN_SSC_TF - -/// PCK0 -#define PIN_PCK0 {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} - -/// TWI pins definition. -#define TWI_V3XX -#define PIN_TWI_TWD0 {0x1 << 9, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_TWI_TWCK0 {0x1 << 10, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_TWI0 PIN_TWI_TWD0, PIN_TWI_TWCK0 -#define PIN_TWI_TWD1 {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_TWI_TWCK1 {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_TWI1 PIN_TWI_TWD1, PIN_TWI_TWCK1 - -/// USART0 -#define PIN_USART0_RXD {0x1 << 19, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_TXD {0x1 << 18, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_CTS {0x1 << 8, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_RTS {0x1 << 7, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_SCK {0x1 << 17, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} - -/// USART1 -#define PIN_USART1_RXD {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_TXD {0x1 << 22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_CTS {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} - - - -/// USB VBus monitoring pin definition. -#ifdef BOARD_REV_A -#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -#endif -#ifdef BOARD_REV_B -#define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -#endif - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_extcomp "SAM3S-EK - External components" -/// This page lists the definitions related to external on-board components -/// located in the board.h file for the AT91SAM3S-EK. -/// -/// !AT45 Dataflash Card -/// - BOARD_AT45_A_SPI_BASE -/// - BOARD_AT45_A_SPI_ID -/// - BOARD_AT45_A_SPI_PINS -/// - BOARD_AT45_A_SPI -/// - BOARD_AT45_A_NPCS -/// - BOARD_AT45_A_NPCS_PIN -/// -/// !AT45 Dataflash (serial onboard DataFlash) -/// - BOARD_AT45_B_SPI_BASE -/// - BOARD_AT45_B_SPI_ID -/// - BOARD_AT45_B_SPI_PINS -/// - BOARD_AT45_B_SPI -/// - BOARD_AT45_B_NPCS -/// - BOARD_AT45_B_NPCS_PIN -/// -/// !AT26 Serial Flash -/// - BOARD_AT26_A_SPI_BASE -/// - BOARD_AT26_A_SPI_ID -/// - BOARD_AT26_A_SPI_PINS -/// - BOARD_AT26_A_SPI -/// - BOARD_AT26_A_NPCS -/// - BOARD_AT26_A_NPCS_PIN -/// -/// !SD Card -/// - MCI2_INTERFACE -/// - BOARD_SD_MCI_BASE -/// - BOARD_SD_MCI_ID -/// - BOARD_SD_PINS -/// - BOARD_SD_SLOT -/// -/// !PSRAM -/// - BOARD_PSRAM_PINS -/// -/// !LCD -/// - BOARD_LCD_ILI9325 -/// - BOARD_LCD_PINS -/// - BOARD_BACKLIGHT_PIN -/// - BOARD_LCD_BASE -/// - BOARD_LCD_RS -/// - BOARD_LCD_WIDTH -/// - BOARD_LCD_HEIGHT -/// -/// !TouchScreen -/// - BOARD_TSC_ADS7843 -/// - PIN_TCS_IRQ -/// - PIN_TCS_BUSY -/// - BOARD_TSC_SPI_BASE -/// - BOARD_TSC_SPI_ID -/// - BOARD_TSC_SPI_PINS -/// - BOARD_TSC_NPCS -/// - BOARD_TSC_NPCS_PIN -/// -/// Base address of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_BASE SPI0 -///// Identifier of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_ID ID_SPI0 -///// Pins of the SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_PINS PINS_SPI0 -///// Dataflahs SPI number. -//#define BOARD_AT45_A_SPI 0 -///// Chip select connected to the dataflash. -//#define BOARD_AT45_A_NPCS 3 -///// Chip select pin connected to the dataflash. -//#define BOARD_AT45_A_NPCS_PIN PIN_SPI0_NPCS3 - -/// Base address of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_BASE SPI1 -///// Identifier of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_ID ID_SPI1 -///// Pins of the SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_PINS PINS_SPI1 -///// Dataflahs SPI number. -//#define BOARD_AT45_B_SPI 1 -///// Chip select connected to the dataflash. -//#define BOARD_AT45_B_NPCS 3 -///// Chip select pin connected to the dataflash. -//#define BOARD_AT45_B_NPCS_PIN PIN_SPI1_NPCS3 - -/// Base address of SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_BASE SPI0 -///// Identifier of SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_ID ID_SPI0 -///// Pins of the SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_PINS PINS_SPI0 -///// Serialflash SPI number. -//#define BOARD_AT26_A_SPI 0 -///// Chip select connected to the serialflash. -//#define BOARD_AT26_A_NPCS 3 -///// Chip select pin connected to the serialflash. -//#define BOARD_AT26_A_NPCS_PIN PIN_SPI0_NPCS3 - -/// ISO7816 -/// - PIN_SMARTCARD_CONNECT -/// - PIN_ISO7816_RSTMC -/// - PINS_ISO7816 - -/// Smartcard detection pin -//#define PIN_SMARTCARD_CONNECT {1 << 5, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// PIN used for reset the smartcard -//#define PIN_ISO7816_RSTMC {1 << 7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} -/// Pins used for connect the smartcard -//#define PINS_ISO7816 PIN_USART0_TXD, PIN_USART0_SCK, PIN_ISO7816_RSTMC - -/// Dma channel number -#define BOARD_MCI_DMA_CHANNEL 0 -/// MCI0 DMA hardware handshaking ID -#define DMA_HW_SRC_REQ_ID_MCI0 AT91C_HDMA_SRC_PER_0 -#define DMA_HW_DEST_REQ_ID_MCI0 AT91C_HDMA_DST_PER_0 -/// MCI1 DMA hardware handshaking ID -#define DMA_HW_SRC_REQ_ID_MCI1 AT91C_HDMA_SRC_PER_13 -#define DMA_HW_DEST_REQ_ID_MCI1 AT91C_HDMA_DST_PER_13 -/// SD DMA hardware handshaking ID -#define BOARD_SD_DMA_HW_SRC_REQ_ID DMA_HW_SRC_REQ_ID_MCI0 -#define BOARD_SD_DMA_HW_DEST_REQ_ID DMA_HW_DEST_REQ_ID_MCI0 - - -/// HS MCI interface -#define MCI2_INTERFACE -/// Base address of the MCI peripheral connected to the SD card. -#define BOARD_SD_MCI_BASE MCI0//MCI - -#if 0 -// TODO check BSS -///// Peripheral identifier of the MCI connected to the SD card. -#define BOARD_SD_MCI_ID ID_MCI0 //ID_MCI -#endif - -///// MCI pins that shall be configured to access the SD card. -#define BOARD_SD_PINS PINS_MCI -///// MCI slot to which the SD card is connected to. -#define BOARD_SD_SLOT MCI_SD_SLOTA -///// MCI Card Detect pin. -#define BOARD_SD_PIN_CD PIN_MCI_CD - -/*#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \ - PIN_EBI_PSRAM_ADDR_BUS, PIN_EBI_PSRAM_NBS, PIN_EBI_A1 */ - -/** Indicates board has an ILI9325 external component to manage LCD. */ -#define BOARD_LCD_ILI9325 - -/** LCD pins definition. */ -#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, \ - PIN_EBI_NCS1, PIN_EBI_LCD_RS -/** Backlight pin definition. */ -#define BOARD_BACKLIGHT_PIN {1 << 13, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT} -/** Define ILI9325 base address. */ -#define BOARD_LCD_BASE 0x61000000 -/** Define ILI9325 register select signal. */ -#define BOARD_LCD_RS (1 << 1) -/** Display width in pixels. */ -#define BOARD_LCD_WIDTH 240 -/** Display height in pixels. */ -#define BOARD_LCD_HEIGHT 320 - -/** Indicates board has an ADS7843 external component to manage Touch Screen */ -#define BOARD_TSC_ADS7843 - -#ifdef BOARD_REV_A -/** Touchscreen controller IRQ pin definition. */ -#define PIN_TCS_IRQ {PIO_PA4, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE} -#define PIN_TCS_IRQ_WUP_ID (1 << 3) -/** Touchscreen controller Busy pin definition. */ -#define PIN_TCS_BUSY {PIO_PA5, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP} -#endif -#ifdef BOARD_REV_B -/** Touchscreen controller IRQ pin definition. */ -#define PIN_TCS_IRQ {PIO_PA16, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE} -#define PIN_TCS_IRQ_WUP_ID (1 << 15) -/** Touchscreen controller Busy pin definition. */ -#define PIN_TCS_BUSY {PIO_PA17, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP} -#endif - -/** Base address of SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_BASE SPI -/** Identifier of SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_ID ID_SPI -/** Pins of the SPI peripheral connected to the touchscreen controller. */ -#define BOARD_TSC_SPI_PINS PINS_SPI -/** Chip select connected to the touchscreen controller. */ -#define BOARD_TSC_NPCS 0 -/** Chip select pin connected to the touchscreen controller. */ -#define BOARD_TSC_NPCS_PIN PIN_SPI_NPCS0_PA11 - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_mem "SAM3S-EK - Memories" -/// This page lists definitions related to internal & external on-board memories. -/// -/// !Embedded Flash -/// - BOARD_FLASH_EFC - -/// Internal SRAM address -#define AT91C_ISRAM AT91C_IRAM -#define AT91C_ISRAM_SIZE 0x00008000 - -#define AT91C_IFLASH_SIZE (0x40000) -#define AT91C_IFLASH_PAGE_SIZE (256) // Internal FLASH 0 Page Size: 256 bytes -#define AT91C_IFLASH_NB_OF_PAGES (1024) // Internal FLASH 0 Number of Pages: 512 -#define AT91C_IFLASH_LOCK_REGION_SIZE (16384) // Internal FLASH 0 Lock Region Size: 16 Kbytes -#define AT91C_IFLASH_NB_OF_LOCK_BITS (16) // Internal FLASH 0 Number of Lock Bits: 16 - -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// \section sam3s_ek_extcomp "SAM3S-EK - External components" -/// This page lists the definitions related to external on-board components -/// located in the board.h file for the SAM3S-EK. -/// -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_chipdef "SAM3S-EK - Individual chip definition" -/// This page lists the definitions related to different chip's definition -/// located in the board.h file for the SAM3S-EK. - -/// DBGU -#define BOARD_DBGU_ID ID_DBGU - -/// Rtc -#define BOARD_RTC_ID ID_RTC - -/// Twi eeprom -#define BOARD_ID_TWI_EEPROM ID_TWI1 -#define BOARD_BASE_TWI_EEPROM TWI1 -#define BOARD_PINS_TWI_EEPROM PINS_TWI1 - -/// USART -#define BOARD_PIN_USART_RXD PIN_USART1_RXD -#define BOARD_PIN_USART_TXD PIN_USART1_TXD -#define BOARD_PIN_USART_CTS PIN_USART1_CTS -#define BOARD_PIN_USART_RTS PIN_USART1_RTS -#define BOARD_PIN_USART_EN PIN_USART1_EN -#define BOARD_USART_BASE USART1 -#define BOARD_ID_USART ID_USART1 - -//------------------------------------------------------------------------------ - - -#define PIN_EBI_NANDOE {1 << 9, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDWE {1 << 10, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDCLE {1 << 17, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDALE {1 << 16, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDIO {0x000000FF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -/// Nandflash chip enable pin definition. -#define BOARD_NF_CE_PIN {1 << 14, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/// Nandflash ready/busy pin definition. -#define BOARD_NF_RB_PIN {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP} - -/// Nandflash controller peripheral pins definition. -#define PINS_NANDFLASH PIN_EBI_NANDIO, BOARD_NF_CE_PIN, BOARD_NF_RB_PIN, PIN_EBI_NANDOE, \ - PIN_EBI_NANDWE, PIN_EBI_NANDCLE, PIN_EBI_NANDALE - -/// Address for transferring command bytes to the nandflash. -#define BOARD_NF_COMMAND_ADDR 0x60400000 -/// Address for transferring address bytes to the nandflash. -#define BOARD_NF_ADDRESS_ADDR 0x60200000 -/// Address for transferring data bytes to the nandflash. -#define BOARD_NF_DATA_ADDR 0x60000000 - -#endif //#ifndef BOARD_H - diff --git a/src/ersky9x/libraries/board/board_cstartup_iar.c b/src/ersky9x/libraries/board/board_cstartup_iar.c deleted file mode 100644 index 55c01978f..000000000 --- a/src/ersky9x/libraries/board/board_cstartup_iar.c +++ /dev/null @@ -1,143 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------------ - * Headers - *------------------------------------------------------------------------------*/ - -#include "board.h" -#include - -#include "exceptions.h" -#include "board_lowlevel.h" - -/*------------------------------------------------------------------------------ - * Types - *------------------------------------------------------------------------------*/ -typedef union { IntFunc __fun; void * __ptr; } IntVector; - -/*------------------------------------------------------------------------------ - * ProtoTypes - *------------------------------------------------------------------------------*/ -extern void __iar_program_start( void ); - -int __low_level_init( void ); - -/*------------------------------------------------------------------------------ - * Variables - *------------------------------------------------------------------------------*/ -extern unsigned int __ICFEDIT_vector_start__; - - -/*------------------------------------------------------------------------------ - * Exception Table - *------------------------------------------------------------------------------*/ -#pragma language=extended -#pragma segment="CSTACK" - -/* The name "__vector_table" has special meaning for C-SPY: */ -/* it is where the SP start value is found, and the NVIC vector */ -/* table register (VTOR) is initialized to this address if != 0. */ - -#pragma section = ".vectors" -#pragma location = ".vectors" -const IntVector __vector_table[] = -{ - { .__ptr = __sfe( "CSTACK" ) }, - __iar_program_start, - - NMI_Handler, - HardFault_Handler, - MemManage_Handler, - BusFault_Handler, - UsageFault_Handler, - 0, 0, 0, 0, /* Reserved */ - SVC_Handler, - DebugMon_Handler, - 0, /* Reserved */ - PendSV_Handler, - SysTick_Handler, - - /* Configurable interrupts */ - SUPC_IrqHandler, /* 0 SUPPLY CONTROLLER */ - RSTC_IrqHandler, /* 1 RESET CONTROLLER */ - RTC_IrqHandler, /* 2 REAL TIME CLOCK */ - RTT_IrqHandler, /* 3 REAL TIME TIMER */ - WDT_IrqHandler, /* 4 WATCHDOG TIMER */ - PMC_IrqHandler, /* 5 PMC */ - EEFC_IrqHandler, /* 6 EEFC */ - IrqHandlerNotUsed, /* 7 Reserved */ - UART0_IrqHandler, /* 8 UART0 */ - UART1_IrqHandler, /* 9 UART1 */ - SMC_IrqHandler, /* 10 SMC */ - PIOA_IrqHandler, /* 11 Parallel IO Controller A */ - PIOB_IrqHandler, /* 12 Parallel IO Controller B */ - PIOC_IrqHandler, /* 13 Parallel IO Controller C */ - USART0_IrqHandler, /* 14 USART 0 */ - USART1_IrqHandler, /* 15 USART 1 */ - IrqHandlerNotUsed, /* 16 Reserved */ - IrqHandlerNotUsed, /* 17 Reserved */ - MCI_IrqHandler, /* 18 MCI */ - TWI0_IrqHandler, /* 19 TWI 0 */ - TWI1_IrqHandler, /* 20 TWI 1 */ - SPI_IrqHandler, /* 21 SPI */ - SSC_IrqHandler, /* 22 SSC */ - TC0_IrqHandler, /* 23 Timer Counter 0 */ - TC1_IrqHandler, /* 24 Timer Counter 1 */ - TC2_IrqHandler, /* 25 Timer Counter 2 */ - TC3_IrqHandler, /* 26 Timer Counter 3 */ - TC4_IrqHandler, /* 27 Timer Counter 4 */ - TC5_IrqHandler, /* 28 Timer Counter 5 */ - ADC_IrqHandler, /* 29 ADC controller */ - DAC_IrqHandler, /* 30 DAC controller */ - PWM_IrqHandler, /* 31 PWM */ - CRCCU_IrqHandler, /* 32 CRC Calculation Unit */ - ACC_IrqHandler, /* 33 Analog Comparator */ - USBD_IrqHandler, /* 34 USB Device Port */ - IrqHandlerNotUsed /* 35 not used */ -}; - -/*------------------------------------------------------------------------------ - * Exception Table - *------------------------------------------------------------------------------*/ - -/**------------------------------------------------------------------------------ - * This is the code that gets called on processor reset. To initialize the - * device. - *------------------------------------------------------------------------------*/ -int __low_level_init( void ) -{ - unsigned int * src = __section_begin(".vectors"); - - LowLevelInit(); - - SCB->VTOR = ((unsigned int)(src)) | (0x0 << 7); - - return 1; /* if return 0, the data sections will not be initialized. */ -} diff --git a/src/ersky9x/libraries/board/board_lowlevel.c b/src/ersky9x/libraries/board/board_lowlevel.c deleted file mode 100644 index c3e70538e..000000000 --- a/src/ersky9x/libraries/board/board_lowlevel.c +++ /dev/null @@ -1,195 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * - * Provides the low-level initialization function that gets called on chip startup. - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "board.h" -#include "board_memories.h" -#include "board_lowlevel.h" -#include - -/*---------------------------------------------------------------------------- - * Local definitions - *----------------------------------------------------------------------------*/ -/** Define clock timeout */ -#define CLOCK_TIMEOUT 5000 -/** Bit 29 must always be set to 1 when programming the CKGR_PLLAR register.*/ -#define PMC_PLLA_SET_BIT29 (0x1 << 29) -/** Specifies the number of Slow Clock cycles x8 before the LOCKA bit is set in PMC_SR after CKGR_PLLAR is written.*/ -#define PMC_PLLA_COUNT (0xBF << 8) -/** The PLLA Clock frequency is the PLLA input frequency multiplied by 8*/ -#define PMC_PLLA_MULTIPIER (0x07 << 16) -/** PLLA Divider is bypassed.*/ -#define PMC_PLLA_DIV (0x01) - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ -static void BOARD_ConfigurePmc(void) -{ -/* TODO: configurate PLL in new way */ -#if 0 - uint32_t timeout = 0; - /** 1: Checking the Main Oscillator Frequency (Optional) and Initialize main oscillator */ - /** 1.1 Initialize main oscillator */ - // TODO: - - /** 2. Setting PLL and Divider*/ - /** 2.1 Initialize PLLA*/ - PMC->CKGR_PLLAR = ( PMC_PLLA_SET_BIT29 | - PMC_PLLA_MULTIPIER | - PMC_PLLA_COUNT | - PMC_PLLA_DIV - ); - timeout = 0; - /** 2.2 Wait for the LOCKA bit to be set by polling the status register.*/ - while (!(PMC->PMC_SR & PMC_SR_LOCKA) && (timeout++ < CLOCK_TIMEOUT)); - /** 2.3 wait for the MCKRDY bit to be set by polling the status register*/ - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); - - /** 3. Selection of Master Clock and Processor Clock*/ - PMC->PMC_MCKR |= PMC_MCKR_PRES_CLK_2; - - /** 3.1 wait for the MCKRDY bit to be set by polling the status register*/ - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); - - /** 3.2 PLLA Clock is selected */ - PMC->PMC_MCKR = PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK; - - /** 3.3 wait for the MCKRDY bit to be set by polling the status register*/ - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); -#endif - -#if 1 // old as sam3u -#define AT91C_CKGR_MUL_SHIFT 16 -#define AT91C_CKGR_OUT_SHIFT 14 -#define AT91C_CKGR_PLLCOUNT_SHIFT 8 -#define AT91C_CKGR_DIV_SHIFT 0 - -// Settings at 48/48MHz -#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST & (0x8 << 8)) -#define BOARD_PLLR ((1 << 29) | (0x7 << AT91C_CKGR_MUL_SHIFT) \ - | (0x0 << AT91C_CKGR_OUT_SHIFT) |(0x1 << AT91C_CKGR_PLLCOUNT_SHIFT) \ - | (0x1 << AT91C_CKGR_DIV_SHIFT)) -#define BOARD_MCKR ( PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK) - -// Define clock timeout -#undef CLOCK_TIMEOUT -#define CLOCK_TIMEOUT 0xFFFFFFFF - - uint32_t timeout = 0; - - /* Enable NRST reset - ************************************/ - //AT91C_BASE_RSTC->RSTC_RMR |= AT91C_RSTC_URSTEN; - - /* Select external slow clock - ****************************/ - - - if ((SUPC->SUPC_SR & SUPC_SR_OSCSEL) != SUPC_SR_OSCSEL_CRYST) { - SUPC->SUPC_CR = SUPC_CR_XTALSEL_CRYSTAL_SEL | ((uint32_t)0xA5 << 24); - timeout = 0; - while (!(SUPC->SUPC_SR & SUPC_SR_OSCSEL_CRYST) ); - } - - - /* Initialize main oscillator - ****************************/ - if(!(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL)) - { - - PMC->CKGR_MOR = (0x37 << 16) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MOSCXTS) && (timeout++ < CLOCK_TIMEOUT)); - - } - - /* Switch to 3-20MHz Xtal oscillator */ - PMC->CKGR_MOR = (0x37 << 16) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MOSCSELS) && (timeout++ < CLOCK_TIMEOUT)); - PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS) | PMC_MCKR_CSS_MAIN_CLK; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); - - /* Initialize PLLA */ - PMC->CKGR_PLLAR = BOARD_PLLR; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_LOCKA) && (timeout++ < CLOCK_TIMEOUT)); - - /* Initialize UTMI for USB usage, can be disabled if not using USB for the sake of saving power*/ - //AT91C_BASE_CKGR->CKGR_UCKR |= (AT91C_CKGR_UPLLCOUNT & (3 << 20)) | AT91C_CKGR_UPLLEN; - //timeout = 0; - //while (!(PMC->PMC_SR & AT91C_PMC_LOCKU) && (timeout++ < CLOCK_TIMEOUT)); - - /* Switch to fast clock - **********************/ - PMC->PMC_MCKR = (BOARD_MCKR & ~PMC_MCKR_CSS) | PMC_MCKR_CSS_MAIN_CLK; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); - - PMC->PMC_MCKR = BOARD_MCKR; - timeout = 0; - while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT)); - -#endif -} - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/** - * \brief Performs the low-level initialization of the chip. This includes EFC, - * master clock and watchdog configuration. - */ -/*----------------------------------------------------------------------------*/ -void LowLevelInit (void) -{ - /** Set 2 WS for Embedded Flash Access */ - EFC->EEFC_FMR = (1 << 8); - - /** Configure PMC */ - BOARD_ConfigurePmc(); -} diff --git a/src/ersky9x/libraries/board/board_lowlevel.h b/src/ersky9x/libraries/board/board_lowlevel.h deleted file mode 100644 index 665449b1d..000000000 --- a/src/ersky9x/libraries/board/board_lowlevel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Collection of methods for lowlevel. -/// -//------------------------------------------------------------------------------ - -#ifndef BOARD_LOWLEVEL_H -#define BOARD_LOWLEVEL_H - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -extern void LowLevelInit(void); -extern void OptimizeCpuSpeed(void); - -#endif // BOARD_LOWLEVEL_H - diff --git a/src/ersky9x/libraries/board/board_memories.c b/src/ersky9x/libraries/board/board_memories.c deleted file mode 100644 index 5a7bfe915..000000000 --- a/src/ersky9x/libraries/board/board_memories.c +++ /dev/null @@ -1,96 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: Memories implementation -*/ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include -#include "board_memories.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - - -/** - * \brief Configures the EBI for NandFlash access. - * - */ -extern void BOARD_ConfigureNandFlash( void ) -{ - // Open EBI clock - PMC->PMC_PCER0 = (1<< ID_SMC); - // NCS0 is assigned to a NAND Flash (NANDOE and NANWE used for NCS0) - MATRIX->CCFG_SMCNFCS = CCFG_SMCNFCS_SMC_NFCS0; - -#if 0 - SMC->SMC_CS_NUMBER[0].SMC_SETUP = 0 - | ((0 << 0) & SMC_SETUP0_NWE_SETUP) - | ((1 << 8) & SMC_SETUP0_NCS_WR_SETUP) - | ((0 << 16) & SMC_SETUP0_NRD_SETUP) - | ((1 << 24) & SMC_SETUP0_NCS_RD_SETUP); - - SMC->SMC_CS_NUMBER[0].SMC_PULSE = 0 - | ((2 << 0) & SMC_PULSE0_NWE_PULSE) - | ((3 << 8) & SMC_PULSE0_NCS_WR_PULSE) - | ((4 << 16) & SMC_PULSE0_NRD_PULSE) - | ((4 << 24) & SMC_PULSE0_NCS_RD_PULSE); - - SMC->SMC_CS_NUMBER[0].SMC_CYCLE = 0 - | ((4 << 0) & SMC_CYCLE0_NWE_CYCLE) - | ((7 << 16) & SMC_CYCLE0_NRD_CYCLE); - - SMC->SMC_CS_NUMBER[0].SMC_MODE = SMC_MODE0_READ_MODE | SMC_MODE0_WRITE_MODE; -#else - SMC->SMC_CS_NUMBER[0].SMC_SETUP = 0 - | ((0 << 0) & SMC_SETUP0_NWE_SETUP) - | ((0 << 8) & SMC_SETUP0_NCS_WR_SETUP) - | ((0 << 16) & SMC_SETUP0_NRD_SETUP) - | ((0 << 24) & SMC_SETUP0_NCS_RD_SETUP); - - SMC->SMC_CS_NUMBER[0].SMC_PULSE = 0 - | ((2 << 0) & SMC_PULSE0_NWE_PULSE) - | ((2 << 8) & SMC_PULSE0_NCS_WR_PULSE) - | ((2 << 16) & SMC_PULSE0_NRD_PULSE) - | ((2 << 24) & SMC_PULSE0_NCS_RD_PULSE); - - SMC->SMC_CS_NUMBER[0].SMC_CYCLE = 0 - | ((3 << 0) & SMC_CYCLE0_NWE_CYCLE) - | ((3 << 16) & SMC_CYCLE0_NRD_CYCLE); - - SMC->SMC_CS_NUMBER[0].SMC_MODE = SMC_MODE1_READ_MODE | SMC_MODE1_WRITE_MODE; -#endif - - - -} - diff --git a/src/ersky9x/libraries/board/board_memories.h b/src/ersky9x/libraries/board/board_memories.h deleted file mode 100644 index b872b34bf..000000000 --- a/src/ersky9x/libraries/board/board_memories.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// !Purpose -/// -/// -/// !Usage -/// -//------------------------------------------------------------------------------ - -#ifndef BOARD_MEMORIES_H -#define BOARD_MEMORIES_H - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void BOARD_ConfigureNandFlash( void ) ; - -#endif //#ifndef BOARD_MEMORIES_H - diff --git a/src/ersky9x/libraries/board/exceptions.c b/src/ersky9x/libraries/board/exceptions.c deleted file mode 100644 index 9be59fc35..000000000 --- a/src/ersky9x/libraries/board/exceptions.c +++ /dev/null @@ -1,385 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * This file contains the default exception handlers. - * - * \note - * The exception handler has weak aliases. - * As they are weak aliases, any function with the same name will override - * this definition. - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "exceptions.h" -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Default interrupt handler for not used irq. - */ -void IrqHandlerNotUsed(void) -{ - while(1); -} - -/** - * \brief Default NMI interrupt handler. - */ -WEAK void NMI_Handler(void) -{ - while(1); -} - -/** - * \brief Default HardFault interrupt handler. - */ -WEAK void HardFault_Handler(void) -{ - while(1); -} - -/** - * \brief Default MemManage interrupt handler. - */ -WEAK void MemManage_Handler(void) -{ - while(1); -} - -/** - * \brief Default BusFault interrupt handler. - */ -WEAK void BusFault_Handler(void) -{ - while(1); -} - -/** - * \brief Default UsageFault interrupt handler. - */ -WEAK void UsageFault_Handler(void) -{ - while(1); -} - -/** - * \brief Default SVC interrupt handler. - */ -WEAK void SVC_Handler(void) -{ - while(1); -} - -/** - * \brief Default DebugMon interrupt handler. - */ -WEAK void DebugMon_Handler(void) -{ - while(1); -} - -/** - * \brief Default PendSV interrupt handler. - */ -WEAK void PendSV_Handler(void) -{ - while(1); -} - -/** - * \brief Default SysTick interrupt handler. - */ -WEAK void SysTick_Handler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for Supply Controller. - */ -WEAK void SUPC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for Reset Controller. - */ -WEAK void RSTC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for Real Time Clock. - */ -WEAK void RTC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for Real Time Timer. - */ -WEAK void RTT_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for Watchdog Timer. - */ -WEAK void WDT_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for PMC. - */ -WEAK void PMC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for EEFC. - */ -WEAK void EEFC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for UART0. - */ -WEAK void UART0_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for UART1. - */ -WEAK void UART1_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for SMC. - */ -WEAK void SMC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for PIOA Controller. - */ -WEAK void PIOA_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for PIOB Controller. - */ -WEAK void PIOB_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for PIOC Controller. - */ -WEAK void PIOC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for USART0. - */ -WEAK void USART0_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for USART1. - */ -WEAK void USART1_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for MCI. - */ -WEAK void MCI_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for TWI0. - */ -WEAK void TWI0_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for TWI1. - */ -WEAK void TWI1_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for SPI. - */ -WEAK void SPI_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for SSC. - */ -WEAK void SSC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for TC0. - */ -WEAK void TC0_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for TC1. - */ -WEAK void TC1_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default interrupt handler for TC2. - */ -WEAK void TC2_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for TC3. - */ -WEAK void TC3_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for TC4. - */ -WEAK void TC4_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for TC5. - */ -WEAK void TC5_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for ADC. - */ -WEAK void ADC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for DAC. - */ -WEAK void DAC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for PWM. - */ -WEAK void PWM_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for CRCCU. - */ -WEAK void CRCCU_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for ACC. - */ -WEAK void ACC_IrqHandler(void) -{ - while(1); -} - -/** - * \brief Default SUPC interrupt handler for USBD. - */ -WEAK void USBD_IrqHandler(void) -{ - while(1); -} diff --git a/src/ersky9x/libraries/board/exceptions.h b/src/ersky9x/libraries/board/exceptions.h deleted file mode 100644 index d1e95bc37..000000000 --- a/src/ersky9x/libraries/board/exceptions.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * Interface for default exception handlers. - */ - -#ifndef EXCEPTIONS_H -#define EXCEPTIONS_H - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/* Function prototype for exception table items (interrupt handler). */ -typedef void( *IntFunc )( void ); - -/* Define WEAK attribute */ -#if defined ( __CC_ARM ) - #define WEAK __attribute__ ((weak)) -#elif defined ( __ICCARM__ ) - #define WEAK __weak -#elif defined ( __GNUC__ ) - #define WEAK __attribute__ ((weak)) -#endif - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void IrqHandlerNotUsed(void); - -extern WEAK void NMI_Handler( void ); -extern WEAK void HardFault_Handler( void ); -extern WEAK void MemManage_Handler( void ); -extern WEAK void BusFault_Handler( void ); -extern WEAK void UsageFault_Handler( void ); -extern WEAK void SVC_Handler( void ); -extern WEAK void DebugMon_Handler( void ); -extern WEAK void PendSV_Handler( void ); -extern WEAK void SysTick_Handler( void ); - -extern WEAK void SUPC_IrqHandler(void); -extern WEAK void RSTC_IrqHandler(void); -extern WEAK void RTC_IrqHandler(void); -extern WEAK void RTT_IrqHandler(void); -extern WEAK void WDT_IrqHandler(void); -extern WEAK void PMC_IrqHandler(void); -extern WEAK void EEFC_IrqHandler(void); -extern WEAK void UART0_IrqHandler(void); -extern WEAK void UART1_IrqHandler(void); -extern WEAK void SMC_IrqHandler(void); -extern WEAK void PIOA_IrqHandler(void); -extern WEAK void PIOB_IrqHandler(void); -extern WEAK void PIOC_IrqHandler(void); -extern WEAK void USART0_IrqHandler(void); -extern WEAK void USART1_IrqHandler(void); -extern WEAK void MCI_IrqHandler(void); -extern WEAK void TWI0_IrqHandler(void); -extern WEAK void TWI1_IrqHandler(void); -extern WEAK void SPI_IrqHandler(void); -extern WEAK void SSC_IrqHandler(void); -extern WEAK void TC0_IrqHandler(void); -extern WEAK void TC1_IrqHandler(void); -extern WEAK void TC2_IrqHandler(void); -extern WEAK void TC3_IrqHandler(void); -extern WEAK void TC4_IrqHandler(void); -extern WEAK void TC5_IrqHandler(void); -extern WEAK void ADC_IrqHandler(void); -extern WEAK void DAC_IrqHandler(void); -extern WEAK void PWM_IrqHandler(void); -extern WEAK void CRCCU_IrqHandler(void); -extern WEAK void ACC_IrqHandler(void); -extern WEAK void USBD_IrqHandler(void); - -#endif /* #ifndef EXCEPTIONS_H */ diff --git a/src/ersky9x/libraries/cmsis/core_cm3.c b/src/ersky9x/libraries/cmsis/core_cm3.c deleted file mode 100644 index 96b03c514..000000000 --- a/src/ersky9x/libraries/cmsis/core_cm3.c +++ /dev/null @@ -1,804 +0,0 @@ -/****************************************************************************** - * @file: core_cm3.c - * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File - * @version: V1.10 - * @date: 24. Feb. 2009 - *---------------------------------------------------------------------------- - * - * Copyright (C) 2009 ARM Limited. All rights reserved. - * - * ARM Limited (ARM) is supplying this software for use with Cortex-Mx - * processor based microcontrollers. This file can be freely distributed - * within development tools that are supporting such ARM based processors. - * - * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED - * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. - * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. - * - ******************************************************************************/ - - - -#include - -/* define compiler specific symbols */ -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for armcc */ - #define __INLINE __inline /*!< inline keyword for armcc */ - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for iarcc */ - #define __INLINE inline /*!< inline keyword for iarcc. Only avaiable in High optimization mode! */ - #define __nop __no_operation /*!< no operation intrinsic in iarcc */ - -#elif defined ( __GNUC__ ) - #define __ASM asm /*!< asm keyword for gcc */ - #define __INLINE inline /*!< inline keyword for gcc */ -#endif - - - -#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -__ASM uint32_t __get_PSP(void) -{ - mrs r0, psp - bx lr -} - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -__ASM void __set_PSP(uint32_t topOfProcStack) -{ - msr psp, r0 - bx lr -} - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -__ASM uint32_t __get_MSP(void) -{ - mrs r0, msp - bx lr -} - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -__ASM void __set_MSP(uint32_t mainStackPointer) -{ - msr msp, r0 - bx lr -} - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -__ASM uint32_t __REV16(uint16_t value) -{ - rev16 r0, r0 - bx lr -} - -/** - * @brief Reverse byte order in signed short value with sign extension to integer - * - * @param int16_t value to reverse - * @return int32_t reversed value - * - * Reverse byte order in signed short value with sign extension to integer - */ -__ASM int32_t __REVSH(int16_t value) -{ - revsh r0, r0 - bx lr -} - - -#if (__ARMCC_VERSION < 400000) - -/** - * @brief Remove the exclusive lock created by ldrex - * - * @param none - * @return none - * - * Removes the exclusive lock which is created by ldrex. - */ -__ASM void __CLREX(void) -{ - clrex -} - -/** - * @brief Return the Base Priority value - * - * @param none - * @return uint32_t BasePriority - * - * Return the content of the base priority register - */ -__ASM uint32_t __get_BASEPRI(void) -{ - mrs r0, basepri - bx lr -} - -/** - * @brief Set the Base Priority value - * - * @param uint32_t BasePriority - * @return none - * - * Set the base priority register - */ -__ASM void __set_BASEPRI(uint32_t basePri) -{ - msr basepri, r0 - bx lr -} - -/** - * @brief Return the Priority Mask value - * - * @param none - * @return uint32_t PriMask - * - * Return the state of the priority mask bit from the priority mask - * register - */ -__ASM uint32_t __get_PRIMASK(void) -{ - mrs r0, primask - bx lr -} - -/** - * @brief Set the Priority Mask value - * - * @param uint32_t PriMask - * @return none - * - * Set the priority mask bit in the priority mask register - */ -__ASM void __set_PRIMASK(uint32_t priMask) -{ - msr primask, r0 - bx lr -} - -/** - * @brief Return the Fault Mask value - * - * @param none - * @return uint32_t FaultMask - * - * Return the content of the fault mask register - */ -__ASM uint32_t __get_FAULTMASK(void) -{ - mrs r0, faultmask - bx lr -} - -/** - * @brief Set the Fault Mask value - * - * @param uint32_t faultMask value - * @return none - * - * Set the fault mask register - */ -__ASM void __set_FAULTMASK(uint32_t faultMask) -{ - msr faultmask, r0 - bx lr -} - -/** - * @brief Return the Control Register value - * - * @param none - * @return uint32_t Control value - * - * Return the content of the control register - */ -__ASM uint32_t __get_CONTROL(void) -{ - mrs r0, control - bx lr -} - -/** - * @brief Set the Control Register value - * - * @param uint32_t Control value - * @return none - * - * Set the control register - */ -__ASM void __set_CONTROL(uint32_t control) -{ - msr control, r0 - bx lr -} - -#endif /* __ARMCC_VERSION */ - - -#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/ -#pragma diag_suppress=Pe940 - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -uint32_t __get_PSP(void) -{ - __ASM("mrs r0, psp"); - __ASM("bx lr"); -} - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -void __set_PSP(uint32_t topOfProcStack) -{ - __ASM("msr psp, r0"); - __ASM("bx lr"); -} - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -uint32_t __get_MSP(void) -{ - __ASM("mrs r0, msp"); - __ASM("bx lr"); -} - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -void __set_MSP(uint32_t topOfMainStack) -{ - __ASM("msr msp, r0"); - __ASM("bx lr"); -} - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -uint32_t __REV16(uint16_t value) -{ - __ASM("rev16 r0, r0"); - __ASM("bx lr"); -} - -/** - * @brief Reverse bit order of value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse bit order of value - */ -uint32_t __RBIT(uint32_t value) -{ - __ASM("rbit r0, r0"); - __ASM("bx lr"); -} - -/** - * @brief LDR Exclusive - * - * @param uint8_t* address - * @return uint8_t value of (*address) - * - * Exclusive LDR command - */ -uint8_t __LDREXB(uint8_t *addr) -{ - __ASM("ldrexb r0, [r0]"); - __ASM("bx lr"); -} - -/** - * @brief LDR Exclusive - * - * @param uint16_t* address - * @return uint16_t value of (*address) - * - * Exclusive LDR command - */ -uint16_t __LDREXH(uint16_t *addr) -{ - __ASM("ldrexh r0, [r0]"); - __ASM("bx lr"); -} - -/** - * @brief LDR Exclusive - * - * @param uint32_t* address - * @return uint32_t value of (*address) - * - * Exclusive LDR command - */ -uint32_t __LDREXW(uint32_t *addr) -{ - __ASM("ldrex r0, [r0]"); - __ASM("bx lr"); -} - -/** - * @brief STR Exclusive - * - * @param uint8_t *address - * @param uint8_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXB(uint8_t value, uint8_t *addr) -{ - __ASM("strexb r0, r0, [r1]"); - __ASM("bx lr"); -} - -/** - * @brief STR Exclusive - * - * @param uint16_t *address - * @param uint16_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXH(uint16_t value, uint16_t *addr) -{ - __ASM("strexh r0, r0, [r1]"); - __ASM("bx lr"); -} - -/** - * @brief STR Exclusive - * - * @param uint32_t *address - * @param uint32_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXW(uint32_t value, uint32_t *addr) -{ - __ASM("strex r0, r0, [r1]"); - __ASM("bx lr"); -} - -#pragma diag_default=Pe940 - - -#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -uint32_t __get_PSP(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, psp" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -void __set_PSP(uint32_t topOfProcStack) -{ - __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) ); -} - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -uint32_t __get_MSP(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, msp" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -void __set_MSP(uint32_t topOfMainStack) -{ - __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) ); -} - -/** - * @brief Return the Base Priority value - * - * @param none - * @return uint32_t BasePriority - * - * Return the content of the base priority register - */ -uint32_t __get_BASEPRI(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Base Priority value - * - * @param uint32_t BasePriority - * @return none - * - * Set the base priority register - */ -void __set_BASEPRI(uint32_t value) -{ - __ASM volatile ("MSR basepri, %0" : : "r" (value) ); -} - -/** - * @brief Return the Priority Mask value - * - * @param none - * @return uint32_t PriMask - * - * Return the state of the priority mask bit from the priority mask - * register - */ -uint32_t __get_PRIMASK(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, primask" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Priority Mask value - * - * @param uint32_t PriMask - * @return none - * - * Set the priority mask bit in the priority mask register - */ -void __set_PRIMASK(uint32_t priMask) -{ - __ASM volatile ("MSR primask, %0" : : "r" (priMask) ); -} - -/** - * @brief Return the Fault Mask value - * - * @param none - * @return uint32_t FaultMask - * - * Return the content of the fault mask register - */ -uint32_t __get_FAULTMASK(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Fault Mask value - * - * @param uint32_t faultMask value - * @return none - * - * Set the fault mask register - */ -void __set_FAULTMASK(uint32_t faultMask) -{ - __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) ); -} - -/** - * @brief Reverse byte order in integer value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in integer value - */ -uint32_t __REV(uint32_t value) -{ - uint32_t result=0; - - __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) ); - return(result); -} - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -uint32_t __REV16(uint16_t value) -{ - uint32_t result=0; - - __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) ); - return(result); -} - -/** - * @brief Reverse byte order in signed short value with sign extension to integer - * - * @param int32_t value to reverse - * @return int32_t reversed value - * - * Reverse byte order in signed short value with sign extension to integer - */ -int32_t __REVSH(int16_t value) -{ - uint32_t result=0; - - __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) ); - return(result); -} - -/** - * @brief Reverse bit order of value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse bit order of value - */ -uint32_t __RBIT(uint32_t value) -{ - uint32_t result=0; - - __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); - return(result); -} - -/** - * @brief LDR Exclusive - * - * @param uint8_t* address - * @return uint8_t value of (*address) - * - * Exclusive LDR command - */ -uint8_t __LDREXB(uint8_t *addr) -{ - uint8_t result=0; - - __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) ); - return(result); -} - -/** - * @brief LDR Exclusive - * - * @param uint16_t* address - * @return uint16_t value of (*address) - * - * Exclusive LDR command - */ -uint16_t __LDREXH(uint16_t *addr) -{ - uint16_t result=0; - - __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) ); - return(result); -} - -/** - * @brief LDR Exclusive - * - * @param uint32_t* address - * @return uint32_t value of (*address) - * - * Exclusive LDR command - */ -uint32_t __LDREXW(uint32_t *addr) -{ - uint32_t result=0; - - __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) ); - return(result); -} - -/** - * @brief STR Exclusive - * - * @param uint8_t *address - * @param uint8_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXB(uint8_t value, uint8_t *addr) -{ - uint32_t result=0; - - __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); - return(result); -} - -/** - * @brief STR Exclusive - * - * @param uint16_t *address - * @param uint16_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXH(uint16_t value, uint16_t *addr) -{ - uint32_t result=0; - - __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); - return(result); -} - -/** - * @brief STR Exclusive - * - * @param uint32_t *address - * @param uint32_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -uint32_t __STREXW(uint32_t value, uint32_t *addr) -{ - uint32_t result=0; - - __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); - return(result); -} - -/** - * @brief Return the Control Register value - * - * @param none - * @return uint32_t Control value - * - * Return the content of the control register - */ -uint32_t __get_CONTROL(void) -{ - uint32_t result=0; - - __ASM volatile ("MRS %0, control" : "=r" (result) ); - return(result); -} - -/** - * @brief Set the Control Register value - * - * @param uint32_t Control value - * @return none - * - * Set the control register - */ -void __set_CONTROL(uint32_t control) -{ - __ASM volatile ("MSR control, %0" : : "r" (control) ); -} - -#endif - - - - - - - - - - - - - - - - - diff --git a/src/ersky9x/libraries/cmsis/core_cm3.h b/src/ersky9x/libraries/cmsis/core_cm3.h deleted file mode 100644 index 9f83c1c0a..000000000 --- a/src/ersky9x/libraries/cmsis/core_cm3.h +++ /dev/null @@ -1,1265 +0,0 @@ -/****************************************************************************** - * @file: core_cm3.h - * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Header File - * @version: V1.10 - * @date: 24. Feb. 2009 - *---------------------------------------------------------------------------- - * - * Copyright (C) 2009 ARM Limited. All rights reserved. - * - * ARM Limited (ARM) is supplying this software for use with Cortex-Mx - * processor based microcontrollers. This file can be freely distributed - * within development tools that are supporting such ARM based processors. - * - * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED - * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. - * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. - * - ******************************************************************************/ - - - - -#ifndef __CM3_CORE_H__ -#define __CM3_CORE_H__ - - -#define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */ -#define __CM3_CMSIS_VERSION_SUB (0x10) /*!< [15:0] CMSIS HAL sub version */ -#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x03) /*!< Cortex core */ - -/** - * Lint configuration \n - * ----------------------- \n - * - * The following Lint messages will be suppressed and not shown: \n - * \n - * --- Error 10: --- \n - * register uint32_t __regBasePri __asm("basepri"); \n - * Error 10: Expecting ';' \n - * \n - * --- Error 530: --- \n - * return(__regBasePri); \n - * Warning 530: Symbol '__regBasePri' (line 264) not initialized \n - * \n - * --- Error 550: --- \n - * __regBasePri = (basePri & 0x1ff); \n - * } \n - * Warning 550: Symbol '__regBasePri' (line 271) not accessed \n - * \n - * --- Error 754: --- \n - * uint32_t RESERVED0[24]; \n - * Info 754: local structure member '' (line 109, file ./cm3_core.h) not referenced \n - * \n - * --- Error 750: --- \n - * #define __CM3_CORE_H__ \n - * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced \n - * \n - * --- Error 528: --- \n - * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n - * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced \n - * \n - * --- Error 751: --- \n - * } InterruptType_Type; \n - * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced \n - * \n - * \n - * Note: To re-enable a Message, insert a space before 'lint' * \n - * - */ - -/*lint -save */ -/*lint -e10 */ -/*lint -e530 */ -/*lint -e550 */ -/*lint -e754 */ -/*lint -e750 */ -/*lint -e528 */ -/*lint -e751 */ - - -#include /* Include standard types */ - -#if defined (__ICCARM__) - #include /* IAR Intrinsics */ -#endif - - -#ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */ -#endif - - - - -/** - * IO definitions - * - * define access restrictions to peripheral registers - */ - -#define __I volatile const /*!< defines 'read only' permissions */ -#define __O volatile /*!< defines 'write only' permissions */ -#define __IO volatile /*!< defines 'read / write' permissions */ - - - -/******************************************************************************* - * Register Abstraction - ******************************************************************************/ - - -/* System Reset */ -#define NVIC_VECTRESET 0 /*!< Vector Reset Bit */ -#define NVIC_SYSRESETREQ 2 /*!< System Reset Request */ -#define NVIC_AIRCR_VECTKEY (0x5FA << 16) /*!< AIRCR Key for write access */ -#define NVIC_AIRCR_ENDIANESS 15 /*!< Endianess */ - -/* Core Debug */ -#define CoreDebug_DEMCR_TRCENA (1 << 24) /*!< DEMCR TRCENA enable */ -#define ITM_TCR_ITMENA 1 /*!< ITM enable */ - - - - -/* memory mapping struct for Nested Vectored Interrupt Controller (NVIC) */ -typedef struct -{ - __IO uint32_t ISER[8]; /*!< Interrupt Set Enable Register */ - uint32_t RESERVED0[24]; - __IO uint32_t ICER[8]; /*!< Interrupt Clear Enable Register */ - uint32_t RSERVED1[24]; - __IO uint32_t ISPR[8]; /*!< Interrupt Set Pending Register */ - uint32_t RESERVED2[24]; - __IO uint32_t ICPR[8]; /*!< Interrupt Clear Pending Register */ - uint32_t RESERVED3[24]; - __IO uint32_t IABR[8]; /*!< Interrupt Active bit Register */ - uint32_t RESERVED4[56]; - __IO uint8_t IP[240]; /*!< Interrupt Priority Register, 8Bit wide */ - uint32_t RESERVED5[644]; - __O uint32_t STIR; /*!< Software Trigger Interrupt Register */ -} NVIC_Type; - - -/* memory mapping struct for System Control Block */ -typedef struct -{ - __I uint32_t CPUID; /*!< CPU ID Base Register */ - __IO uint32_t ICSR; /*!< Interrupt Control State Register */ - __IO uint32_t VTOR; /*!< Vector Table Offset Register */ - __IO uint32_t AIRCR; /*!< Application Interrupt / Reset Control Register */ - __IO uint32_t SCR; /*!< System Control Register */ - __IO uint32_t CCR; /*!< Configuration Control Register */ - __IO uint8_t SHP[12]; /*!< System Handlers Priority Registers (4-7, 8-11, 12-15) */ - __IO uint32_t SHCSR; /*!< System Handler Control and State Register */ - __IO uint32_t CFSR; /*!< Configurable Fault Status Register */ - __IO uint32_t HFSR; /*!< Hard Fault Status Register */ - __IO uint32_t DFSR; /*!< Debug Fault Status Register */ - __IO uint32_t MMFAR; /*!< Mem Manage Address Register */ - __IO uint32_t BFAR; /*!< Bus Fault Address Register */ - __IO uint32_t AFSR; /*!< Auxiliary Fault Status Register */ - __I uint32_t PFR[2]; /*!< Processor Feature Register */ - __I uint32_t DFR; /*!< Debug Feature Register */ - __I uint32_t ADR; /*!< Auxiliary Feature Register */ - __I uint32_t MMFR[4]; /*!< Memory Model Feature Register */ - __I uint32_t ISAR[5]; /*!< ISA Feature Register */ -} SCB_Type; - - -/* memory mapping struct for SysTick */ -typedef struct -{ - __IO uint32_t CTRL; /*!< SysTick Control and Status Register */ - __IO uint32_t LOAD; /*!< SysTick Reload Value Register */ - __IO uint32_t VAL; /*!< SysTick Current Value Register */ - __I uint32_t CALIB; /*!< SysTick Calibration Register */ -} SysTick_Type; - - -/* memory mapping structur for ITM */ -typedef struct -{ - __O union - { - __O uint8_t u8; /*!< ITM Stimulus Port 8-bit */ - __O uint16_t u16; /*!< ITM Stimulus Port 16-bit */ - __O uint32_t u32; /*!< ITM Stimulus Port 32-bit */ - } PORT [32]; /*!< ITM Stimulus Port Registers */ - uint32_t RESERVED0[864]; - __IO uint32_t TER; /*!< ITM Trace Enable Register */ - uint32_t RESERVED1[15]; - __IO uint32_t TPR; /*!< ITM Trace Privilege Register */ - uint32_t RESERVED2[15]; - __IO uint32_t TCR; /*!< ITM Trace Control Register */ - uint32_t RESERVED3[29]; - __IO uint32_t IWR; /*!< ITM Integration Write Register */ - __IO uint32_t IRR; /*!< ITM Integration Read Register */ - __IO uint32_t IMCR; /*!< ITM Integration Mode Control Register */ - uint32_t RESERVED4[43]; - __IO uint32_t LAR; /*!< ITM Lock Access Register */ - __IO uint32_t LSR; /*!< ITM Lock Status Register */ - uint32_t RESERVED5[6]; - __I uint32_t PID4; /*!< ITM Product ID Registers */ - __I uint32_t PID5; - __I uint32_t PID6; - __I uint32_t PID7; - __I uint32_t PID0; - __I uint32_t PID1; - __I uint32_t PID2; - __I uint32_t PID3; - __I uint32_t CID0; - __I uint32_t CID1; - __I uint32_t CID2; - __I uint32_t CID3; -} ITM_Type; - - -/* memory mapped struct for Interrupt Type */ -typedef struct -{ - uint32_t RESERVED0; - __I uint32_t ICTR; /*!< Interrupt Control Type Register */ -#if ((defined __CM3_REV) && (__CM3_REV >= 0x200)) - __IO uint32_t ACTLR; /*!< Auxiliary Control Register */ -#else - uint32_t RESERVED1; -#endif -} InterruptType_Type; - - -/* Memory Protection Unit */ -#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1) -typedef struct -{ - __I uint32_t TYPE; /*!< MPU Type Register */ - __IO uint32_t CTRL; /*!< MPU Control Register */ - __IO uint32_t RNR; /*!< MPU Region RNRber Register */ - __IO uint32_t RBAR; /*!< MPU Region Base Address Register */ - __IO uint32_t RASR; /*!< MPU Region Attribute and Size Register */ - __IO uint32_t RBAR_A1; /*!< MPU Alias 1 Region Base Address Register */ - __IO uint32_t RASR_A1; /*!< MPU Alias 1 Region Attribute and Size Register */ - __IO uint32_t RBAR_A2; /*!< MPU Alias 2 Region Base Address Register */ - __IO uint32_t RASR_A2; /*!< MPU Alias 2 Region Attribute and Size Register */ - __IO uint32_t RBAR_A3; /*!< MPU Alias 3 Region Base Address Register */ - __IO uint32_t RASR_A3; /*!< MPU Alias 3 Region Attribute and Size Register */ -} MPU_Type; -#endif - - -/* Core Debug Register */ -typedef struct -{ - __IO uint32_t DHCSR; /*!< Debug Halting Control and Status Register */ - __O uint32_t DCRSR; /*!< Debug Core Register Selector Register */ - __IO uint32_t DCRDR; /*!< Debug Core Register Data Register */ - __IO uint32_t DEMCR; /*!< Debug Exception and Monitor Control Register */ -} CoreDebug_Type; - - -/* Memory mapping of Cortex-M3 Hardware */ -#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */ -#define ITM_BASE (0xE0000000) /*!< ITM Base Address */ -#define CoreDebug_BASE (0xE000EDF0) /*!< Core Debug Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */ - -#define InterruptType ((InterruptType_Type *) SCS_BASE) /*!< Interrupt Type Register */ -#define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */ -#define ITM ((ITM_Type *) ITM_BASE) /*!< ITM configuration struct */ -#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ - -#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1) - #define MPU_BASE (SCS_BASE + 0x0D90) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type*) MPU_BASE) /*!< Memory Protection Unit */ -#endif - - - -/******************************************************************************* - * Hardware Abstraction Layer - ******************************************************************************/ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */ - #define __NOP __no_operation /*!< no operation intrinsic in IAR Compiler */ - -#elif defined ( __GNUC__ ) - #define __ASM asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - -#endif - - -/* ################### Compiler specific Intrinsics ########################### */ - -#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ -/* ARM armcc specific functions */ - -#define __enable_fault_irq __enable_fiq -#define __disable_fault_irq __disable_fiq - -#define __NOP __nop -#define __WFI __wfi -#define __WFE __wfe -#define __SEV __sev -#define __ISB() __isb(0) -#define __DSB() __dsb(0) -#define __DMB() __dmb(0) -#define __REV __rev -#define __RBIT __rbit -#define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr)) -#define __LDREXH(ptr) ((unsigned short) __ldrex(ptr)) -#define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr)) -#define __STREXB(value, ptr) __strex(value, ptr) -#define __STREXH(value, ptr) __strex(value, ptr) -#define __STREXW(value, ptr) __strex(value, ptr) - - - /* intrinsic unsigned long long __ldrexd(volatile void *ptr) */ - /* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */ - /* intrinsic void __enable_irq(); */ - /* intrinsic void __disable_irq(); */ - - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -extern uint32_t __get_PSP(void); - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -extern void __set_PSP(uint32_t topOfProcStack); - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -extern uint32_t __get_MSP(void); - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -extern void __set_MSP(uint32_t topOfMainStack); - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -extern uint32_t __REV16(uint16_t value); - -/* - * @brief Reverse byte order in signed short value with sign extension to integer - * - * @param int16_t value to reverse - * @return int32_t reversed value - * - * Reverse byte order in signed short value with sign extension to integer - */ -extern int32_t __REVSH(int16_t value); - - -#if (__ARMCC_VERSION < 400000) - -/** - * @brief Remove the exclusive lock created by ldrex - * - * @param none - * @return none - * - * Removes the exclusive lock which is created by ldrex. - */ -extern void __CLREX(void); - -/** - * @brief Return the Base Priority value - * - * @param none - * @return uint32_t BasePriority - * - * Return the content of the base priority register - */ -extern uint32_t __get_BASEPRI(void); - -/** - * @brief Set the Base Priority value - * - * @param uint32_t BasePriority - * @return none - * - * Set the base priority register - */ -extern void __set_BASEPRI(uint32_t basePri); - -/** - * @brief Return the Priority Mask value - * - * @param none - * @return uint32_t PriMask - * - * Return the state of the priority mask bit from the priority mask - * register - */ -extern uint32_t __get_PRIMASK(void); - -/** - * @brief Set the Priority Mask value - * - * @param uint32_t PriMask - * @return none - * - * Set the priority mask bit in the priority mask register - */ -extern void __set_PRIMASK(uint32_t priMask); - -/** - * @brief Return the Fault Mask value - * - * @param none - * @return uint32_t FaultMask - * - * Return the content of the fault mask register - */ -extern uint32_t __get_FAULTMASK(void); - -/** - * @brief Set the Fault Mask value - * - * @param uint32_t faultMask value - * @return none - * - * Set the fault mask register - */ -extern void __set_FAULTMASK(uint32_t faultMask); - -/** - * @brief Return the Control Register value - * - * @param none - * @return uint32_t Control value - * - * Return the content of the control register - */ -extern uint32_t __get_CONTROL(void); - -/** - * @brief Set the Control Register value - * - * @param uint32_t Control value - * @return none - * - * Set the control register - */ -extern void __set_CONTROL(uint32_t control); - -#else /* (__ARMCC_VERSION >= 400000) */ - - -/** - * @brief Remove the exclusive lock created by ldrex - * - * @param none - * @return none - * - * Removes the exclusive lock which is created by ldrex. - */ -#define __CLREX __clrex - -/** - * @brief Return the Base Priority value - * - * @param none - * @return uint32_t BasePriority - * - * Return the content of the base priority register - */ -static __INLINE uint32_t __get_BASEPRI(void) -{ - register uint32_t __regBasePri __ASM("basepri"); - return(__regBasePri); -} - -/** - * @brief Set the Base Priority value - * - * @param uint32_t BasePriority - * @return none - * - * Set the base priority register - */ -static __INLINE void __set_BASEPRI(uint32_t basePri) -{ - register uint32_t __regBasePri __ASM("basepri"); - __regBasePri = (basePri & 0x1ff); -} - -/** - * @brief Return the Priority Mask value - * - * @param none - * @return uint32_t PriMask - * - * Return the state of the priority mask bit from the priority mask - * register - */ -static __INLINE uint32_t __get_PRIMASK(void) -{ - register uint32_t __regPriMask __ASM("primask"); - return(__regPriMask); -} - -/** - * @brief Set the Priority Mask value - * - * @param uint32_t PriMask - * @return none - * - * Set the priority mask bit in the priority mask register - */ -static __INLINE void __set_PRIMASK(uint32_t priMask) -{ - register uint32_t __regPriMask __ASM("primask"); - __regPriMask = (priMask); -} - -/** - * @brief Return the Fault Mask value - * - * @param none - * @return uint32_t FaultMask - * - * Return the content of the fault mask register - */ -static __INLINE uint32_t __get_FAULTMASK(void) -{ - register uint32_t __regFaultMask __ASM("faultmask"); - return(__regFaultMask); -} - -/** - * @brief Set the Fault Mask value - * - * @param uint32_t faultMask value - * @return none - * - * Set the fault mask register - */ -static __INLINE void __set_FAULTMASK(uint32_t faultMask) -{ - register uint32_t __regFaultMask __ASM("faultmask"); - __regFaultMask = (faultMask & 1); -} - -/** - * @brief Return the Control Register value - * - * @param none - * @return uint32_t Control value - * - * Return the content of the control register - */ -static __INLINE uint32_t __get_CONTROL(void) -{ - register uint32_t __regControl __ASM("control"); - return(__regControl); -} - -/** - * @brief Set the Control Register value - * - * @param uint32_t Control value - * @return none - * - * Set the control register - */ -static __INLINE void __set_CONTROL(uint32_t control) -{ - register uint32_t __regControl __ASM("control"); - __regControl = control; -} - -#endif /* __ARMCC_VERSION */ - - - -#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/ -/* IAR iccarm specific functions */ - -#define __enable_irq __enable_interrupt /*!< global Interrupt enable */ -#define __disable_irq __disable_interrupt /*!< global Interrupt disable */ - -static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); } -static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); } - -static __INLINE void __WFI() { __ASM ("wfi"); } -static __INLINE void __WFE() { __ASM ("wfe"); } -static __INLINE void __SEV() { __ASM ("sev"); } -static __INLINE void __CLREX() { __ASM ("clrex"); } - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -extern uint32_t __get_PSP(void); - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -extern void __set_PSP(uint32_t topOfProcStack); - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -extern uint32_t __get_MSP(void); - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -extern void __set_MSP(uint32_t topOfMainStack); - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -extern uint32_t __REV16(uint16_t value); - -/** - * @brief Reverse bit order of value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse bit order of value - */ -extern uint32_t __RBIT(uint32_t value); - -/** - * @brief LDR Exclusive - * - * @param uint8_t* address - * @return uint8_t value of (*address) - * - * Exclusive LDR command - */ -extern uint8_t __LDREXB(uint8_t *addr); - -/** - * @brief LDR Exclusive - * - * @param uint16_t* address - * @return uint16_t value of (*address) - * - * Exclusive LDR command - */ -extern uint16_t __LDREXH(uint16_t *addr); - -/** - * @brief LDR Exclusive - * - * @param uint32_t* address - * @return uint32_t value of (*address) - * - * Exclusive LDR command - */ -extern uint32_t __LDREXW(uint32_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint8_t *address - * @param uint8_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXB(uint8_t value, uint8_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint16_t *address - * @param uint16_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXH(uint16_t value, uint16_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint32_t *address - * @param uint32_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXW(uint32_t value, uint32_t *addr); - - -/* intrinsic void __set_PRIMASK(); */ -/* intrinsic void __get_PRIMASK(); */ -/* intrinsic void __set_FAULTMASK(); */ -/* intrinsic void __get_FAULTMASK(); */ -/* intrinsic uint32_t __REV(uint32_t value); */ -/* intrinsic uint32_t __REVSH(uint32_t value); */ -/* intrinsic unsigned long __STREX(unsigned long, unsigned long); */ -/* intrinsic unsigned long __LDREX(unsigned long *); */ - - - -#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ -/* GNU gcc specific functions */ - -static __INLINE void __NOP() { __ASM volatile ("nop"); } -static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); } -static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); } - -static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); } -static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); } - -static __INLINE void __WFI() { __ASM volatile ("wfi"); } -static __INLINE void __WFE() { __ASM volatile ("wfe"); } -static __INLINE void __SEV() { __ASM volatile ("sev"); } -static __INLINE void __ISB(arg) { __ASM volatile ("isb"); } -static __INLINE void __DSB(arg) { __ASM volatile ("dsb"); } -static __INLINE void __DMB(arg) { __ASM volatile ("dmb"); } -static __INLINE void __CLREX() { __ASM volatile ("clrex"); } - - -/** - * @brief Return the Process Stack Pointer - * - * @param none - * @return uint32_t ProcessStackPointer - * - * Return the actual process stack pointer - */ -extern uint32_t __get_PSP(void); - -/** - * @brief Set the Process Stack Pointer - * - * @param uint32_t Process Stack Pointer - * @return none - * - * Assign the value ProcessStackPointer to the MSP - * (process stack pointer) Cortex processor register - */ -extern void __set_PSP(uint32_t topOfProcStack); - -/** - * @brief Return the Main Stack Pointer - * - * @param none - * @return uint32_t Main Stack Pointer - * - * Return the current value of the MSP (main stack pointer) - * Cortex processor register - */ -extern uint32_t __get_MSP(void); - -/** - * @brief Set the Main Stack Pointer - * - * @param uint32_t Main Stack Pointer - * @return none - * - * Assign the value mainStackPointer to the MSP - * (main stack pointer) Cortex processor register - */ -extern void __set_MSP(uint32_t topOfMainStack); - -/** - * @brief Return the Base Priority value - * - * @param none - * @return uint32_t BasePriority - * - * Return the content of the base priority register - */ -extern uint32_t __get_BASEPRI(void); - -/** - * @brief Set the Base Priority value - * - * @param uint32_t BasePriority - * @return none - * - * Set the base priority register - */ -extern void __set_BASEPRI(uint32_t basePri); - -/** - * @brief Return the Priority Mask value - * - * @param none - * @return uint32_t PriMask - * - * Return the state of the priority mask bit from the priority mask - * register - */ -extern uint32_t __get_PRIMASK(void); - -/** - * @brief Set the Priority Mask value - * - * @param uint32_t PriMask - * @return none - * - * Set the priority mask bit in the priority mask register - */ -extern void __set_PRIMASK(uint32_t priMask); - -/** - * @brief Return the Fault Mask value - * - * @param none - * @return uint32_t FaultMask - * - * Return the content of the fault mask register - */ -extern uint32_t __get_FAULTMASK(void); - -/** - * @brief Set the Fault Mask value - * - * @param uint32_t faultMask value - * @return none - * - * Set the fault mask register - */ -extern void __set_FAULTMASK(uint32_t faultMask); - -/** - * @brief Return the Control Register value -* -* @param none -* @return uint32_t Control value - * - * Return the content of the control register - */ -extern uint32_t __get_CONTROL(void); - -/** - * @brief Set the Control Register value - * - * @param uint32_t Control value - * @return none - * - * Set the control register - */ -extern void __set_CONTROL(uint32_t control); - -/** - * @brief Reverse byte order in integer value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in integer value - */ -extern uint32_t __REV(uint32_t value); - -/** - * @brief Reverse byte order in unsigned short value - * - * @param uint16_t value to reverse - * @return uint32_t reversed value - * - * Reverse byte order in unsigned short value - */ -extern uint32_t __REV16(uint16_t value); - -/* - * Reverse byte order in signed short value with sign extension to integer - * - * @param int16_t value to reverse - * @return int32_t reversed value - * - * @brief Reverse byte order in signed short value with sign extension to integer - */ -extern int32_t __REVSH(int16_t value); - -/** - * @brief Reverse bit order of value - * - * @param uint32_t value to reverse - * @return uint32_t reversed value - * - * Reverse bit order of value - */ -extern uint32_t __RBIT(uint32_t value); - -/** - * @brief LDR Exclusive - * - * @param uint8_t* address - * @return uint8_t value of (*address) - * - * Exclusive LDR command - */ -extern uint8_t __LDREXB(uint8_t *addr); - -/** - * @brief LDR Exclusive - * - * @param uint16_t* address - * @return uint16_t value of (*address) - * - * Exclusive LDR command - */ -extern uint16_t __LDREXH(uint16_t *addr); - -/** - * @brief LDR Exclusive - * - * @param uint32_t* address - * @return uint32_t value of (*address) - * - * Exclusive LDR command - */ -extern uint32_t __LDREXW(uint32_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint8_t *address - * @param uint8_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXB(uint8_t value, uint8_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint16_t *address - * @param uint16_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXH(uint16_t value, uint16_t *addr); - -/** - * @brief STR Exclusive - * - * @param uint32_t *address - * @param uint32_t value to store - * @return uint32_t successful / failed - * - * Exclusive STR command - */ -extern uint32_t __STREXW(uint32_t value, uint32_t *addr); - - -#endif - - - -/* ########################## NVIC functions #################################### */ - -/** - * @brief Set the Priority Grouping in NVIC Interrupt Controller - * - * @param uint32_t priority_grouping is priority grouping field - * @return - * - * Set the priority grouping field using the required unlock sequence. - * The parameter priority_grouping is assigned to the field - * SCB->AIRCR [10:8] PRIGROUP field. - */ -static __INLINE void NVIC_SetPriorityGrouping(uint32_t priority_grouping) -{ - uint32_t reg_value=0; - - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~((0xFFFFU << 16) | (0x0F << 8)); /* clear bits to change */ - reg_value = ((reg_value | NVIC_AIRCR_VECTKEY | (priority_grouping << 8))); /* Insert write key and priorty group */ - SCB->AIRCR = reg_value; -} - -/** - * @brief Enable Interrupt in NVIC Interrupt Controller - * - * @param IRQn_Type IRQn specifies the interrupt number - * @return none - * - * Enable a device specific interupt in the NVIC interrupt controller. - * The interrupt number cannot be a negative value. - */ -static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */ -} - -/** - * @brief Disable the interrupt line for external interrupt specified - * - * @param IRQn_Type IRQn is the positive number of the external interrupt - * @return none - * - * Disable a device specific interupt in the NVIC interrupt controller. - * The interrupt number cannot be a negative value. - */ -static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */ -} - -/** - * @brief Read the interrupt pending bit for a device specific interrupt source - * - * @param IRQn_Type IRQn is the number of the device specifc interrupt - * @return IRQn_Type Number of pending interrupt or zero - * - * Read the pending register in NVIC and return the number of the - * specified interrupt if its status is pending, otherwise it returns - * zero. The interrupt number cannot be a negative value. - */ -static __INLINE IRQn_Type NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((IRQn_Type) (NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))); /* Return Interrupt bit or 'zero' */ -} - -/** - * @brief Set the pending bit for an external interrupt - * - * @param IRQn_Type IRQn is the Number of the interrupt - * @return none - * - * Set the pending bit for the specified interrupt. - * The interrupt number cannot be a negative value. - */ -static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */ -} - -/** - * @brief Clear the pending bit for an external interrupt - * - * @param IRQn_Type IRQn is the Number of the interrupt - * @return none - * - * Clear the pending bit for the specified interrupt. - * The interrupt number cannot be a negative value. - */ -static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */ -} - -/** - * @brief Read the active bit for an external interrupt - * - * @param IRQn_Type IRQn is the Number of the interrupt - * @return IRQn_Type Number of pending interrupt or zero - * - * Read the active register in NVIC and returns the number of the - * specified interrupt if its status is active, otherwise it - * returns zero. The interrupt number cannot be a negative value. - */ -static __INLINE IRQn_Type NVIC_GetActive(IRQn_Type IRQn) -{ - return((IRQn_Type)(NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))); /* Return Interruptnumber or 'zero' */ -} - -/** - * @brief Set the priority for an interrupt - * - * @param IRQn_Type IRQn is the Number of the interrupt - * @param priority is the priority for the interrupt - * @return none - * - * Set the priority for the specified interrupt. The interrupt - * number can be positive to specify an external (device specific) - * interrupt, or negative to specify an internal (core) interrupt. \n - * - * Note: The priority cannot be set for every core interrupt. - */ -static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, int32_t priority) -{ - if(IRQn < 0) { - SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */ - else { - //NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */ - NVIC->IP[(uint32_t)(IRQn)] = (priority & 0xff); } /* set Priority for device specific Interrupts */ -} - -/** - * @brief Read the priority for an interrupt - * - * @param IRQn_Type IRQn is the Number of the interrupt - * @return priority is the priority for the interrupt - * - * Read the priority for the specified interrupt. The interrupt - * number can be positive to specify an external (device specific) - * interrupt, or negative to specify an internal (core) interrupt. - * - * The returned priority value is automatically aligned to the implemented - * priority bits of the microcontroller. - * - * Note: The priority cannot be set for every core interrupt. - */ -static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if(IRQn < 0) { - return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */ - else { - return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */ -} - - - -/* ################################## SysTick function ############################################ */ - -#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0) - -/* SysTick constants */ -#define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */ -#define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */ -#define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */ -#define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */ - -/** - * @brief Initialize and start the SysTick counter and its interrupt. - * - * @param uint32_t ticks is the number of ticks between two interrupts - * @return none - * - * Initialise the system tick timer and its interrupt and start the - * system tick timer / counter in free running mode to generate - * periodical interrupts. - */ -static __INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if (ticks > SYSTICK_MAXCOUNT) return (1); /* Reload value impossible */ - - SysTick->LOAD = (ticks & SYSTICK_MAXCOUNT) - 1; /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */ - SysTick->VAL = (0x00); /* Load the SysTick Counter Value */ - SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<AIRCR = (NVIC_AIRCR_VECTKEY | (SCB->AIRCR & (0x700)) | (1<DEMCR & CoreDebug_DEMCR_TRCENA) && - (ITM->TCR & ITM_TCR_ITMENA) && - (ITM->TER & (1UL << 0)) ) - { - while (ITM->PORT[0].u32 == 0); - ITM->PORT[0].u8 = (uint8_t) ch; - } - return (ch); -} - -#endif - -/*lint -restore */ diff --git a/src/ersky9x/libraries/components/ads7843/ads7843.c b/src/ersky9x/libraries/components/ads7843/ads7843.c deleted file mode 100644 index 62b545c61..000000000 --- a/src/ersky9x/libraries/components/ads7843/ads7843.c +++ /dev/null @@ -1,212 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of ADS7843 driver. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include - -#ifdef BOARD_TSC_ADS7843 - -#include -#include - -#include "ads7843.h" - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -#define ADS_CTRL_PD0 (1 << 0) /* PD0 */ -#define ADS_CTRL_PD1 (1 << 1) /* PD1 */ -#define ADS_CTRL_DFR (1 << 2) /* SER/DFR */ -#define ADS_CTRL_EIGHT_BITS_MOD (1 << 3) /* Mode */ -#define ADS_CTRL_START (1 << 7) /* Start Bit */ -#define ADS_CTRL_SWITCH_SHIFT 4 /* Address setting */ - -#if (BOARD_LCD_WIDTH == 240) -/* Get X position command */ -#define CMD_Y_POSITION ((1 << ADS_CTRL_SWITCH_SHIFT) | ADS_CTRL_START | ADS_CTRL_PD0 | ADS_CTRL_PD1) -/* Get Y position command */ -#define CMD_X_POSITION ((5 << ADS_CTRL_SWITCH_SHIFT) | ADS_CTRL_START | ADS_CTRL_PD0 | ADS_CTRL_PD1) -#else -/* Get X position command */ -#define CMD_X_POSITION ((1 << ADS_CTRL_SWITCH_SHIFT) | ADS_CTRL_START | ADS_CTRL_PD0 | ADS_CTRL_PD1) -/* Get Y position command */ -#define CMD_Y_POSITION ((5 << ADS_CTRL_SWITCH_SHIFT) | ADS_CTRL_START | ADS_CTRL_PD0 | ADS_CTRL_PD1) -#endif - -/* Enable penIRQ */ -#define CMD_ENABLE_PENIRQ ((1 << ADS_CTRL_SWITCH_SHIFT) | ADS_CTRL_START) - - -#define ADS7843_TIMEOUT 5000000 - -#define DELAY_BEFORE_SPCK (200 << 16) /* 2us min (tCSS) <=> 200/100 000 000 = 2us */ -#define DELAY_BETWEEN_CONS_COM (0xf << 24) /* 5us min (tCSH) <=> (32 * 15) / (100 000 000) = 5us */ - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -/** Pins used by SPI */ -static const Pin pinsSPI[] = {BOARD_TSC_SPI_PINS, BOARD_TSC_NPCS_PIN}; - -/** Touch screen BUSY pin */ -static const Pin pinBusy[] = {PIN_TCS_BUSY}; - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Generic function to send a command to the touchscreen controller. - * - * \param bCmd command to send - * - * \return command result - */ -static uint32_t SendCommand(unsigned char bCmd) -{ - uint32_t uResult = 0; - uint32_t uTimeout = 0; - - /* (volatile declaration needed for code optimisation by compiler) */ - volatile unsigned char bufferRX[3]; - volatile unsigned char bufferTX[3]; - - Pdc *pPdc = (Pdc *)SPI; - uint32_t dStatus; - - bufferRX[0] = 0; - bufferRX[1] = 0; - bufferRX[2] = 0; - - bufferTX[0] = bCmd; - bufferTX[1] = 0; - bufferTX[2] = 0; - - /* Send Command and data through the SPI */ - pPdc->PERIPH_PTCR = PERIPH_PTCR_RXTDIS; - pPdc->PERIPH_RPR = (uint32_t) bufferRX; - pPdc->PERIPH_RCR = 3; - - pPdc->PERIPH_PTCR = PERIPH_PTCR_TXTDIS; - pPdc->PERIPH_TPR = (uint32_t) bufferTX; - pPdc->PERIPH_TCR = 3; - - pPdc->PERIPH_PTCR = PERIPH_PTCR_RXTEN; - pPdc->PERIPH_PTCR = PERIPH_PTCR_TXTEN; - - do { - dStatus = REG_SPI_SR; - uTimeout++; - } - while ((( dStatus & SPI_SR_RXBUFF) != SPI_SR_RXBUFF) && (uTimeout < ADS7843_TIMEOUT)); - - pPdc->PERIPH_PTCR = PERIPH_PTCR_RXTDIS; - pPdc->PERIPH_PTCR = PERIPH_PTCR_TXTDIS; - - uResult = ((uint32_t)bufferRX[1] << 8) | (uint32_t)bufferRX[2]; - uResult = uResult >> 4; - - return uResult; -} - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Get position of the pen by ask the ADS controller (SPI). - * - * \param px_pos pointer to the horizontal position - * \param py_pos pointer to the vertical position - * - */ -void ADS7843_GetPosition(uint32_t *px_pos, uint32_t *py_pos) -{ - /* Get X position */ - *px_pos = SendCommand(CMD_X_POSITION); - /* Get Y position */ - *py_pos = SendCommand(CMD_Y_POSITION); - /* Switch to full power mode */ - SendCommand(CMD_ENABLE_PENIRQ); -} - -/** - * \brief Initialization of the SPI for communication with ADS7843 component. - */ -void ADS7843_Initialize(void) -{ - volatile uint32_t uDummy; - - /* Configure pins */ - PIO_Configure(pinsSPI, PIO_LISTSIZE(pinsSPI)); - - PIO_Configure(pinBusy, PIO_LISTSIZE(pinBusy)); - - SPI_Configure(BOARD_TSC_SPI_BASE, - BOARD_TSC_SPI_ID, - SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_PCS(BOARD_TSC_NPCS) /* Value of the SPI configuration register. */ - ); - - SPI_ConfigureNPCS(BOARD_TSC_SPI_BASE, BOARD_TSC_NPCS, - SPI_CSR_NCPHA | (SPI_CSR_DLYBS & DELAY_BEFORE_SPCK) | - (SPI_CSR_DLYBCT & DELAY_BETWEEN_CONS_COM) | (0xC8 << 8) ); - - SPI_Enable(BOARD_TSC_SPI_BASE); - - for (uDummy=0; uDummy<100000; uDummy++); - - uDummy = REG_SPI_SR; - uDummy = REG_SPI_RDR; - - SendCommand(CMD_ENABLE_PENIRQ); -} - -/** - * \brief Reset the ADS7843 - */ -void ADS7843_Reset(void) -{ - /* Disable SPI */ - SPI_Disable(BOARD_TSC_SPI_BASE); -} - -#endif /* #ifdef BOARD_TSC_ADS7843 */ diff --git a/src/ersky9x/libraries/components/ads7843/ads7843.h b/src/ersky9x/libraries/components/ads7843/ads7843.h deleted file mode 100644 index 393429312..000000000 --- a/src/ersky9x/libraries/components/ads7843/ads7843.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for ADS7843 driver. - */ - -#ifndef ADS7843_H -#define ADS7843_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include - -#ifdef BOARD_TSC_ADS7843 - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void ADS7843_Initialize(void); - -extern void ADS7843_Reset(void); - -extern void ADS7843_GetPosition(uint32_t *px_pos, uint32_t *py_pos); - -#endif /* #ifdef BOARD_TSC_ADS7843 */ -#endif /* #ifndef ADS7843_H */ diff --git a/src/ersky9x/libraries/components/wm8731/wm8731.c b/src/ersky9x/libraries/components/wm8731/wm8731.c deleted file mode 100644 index 17ed974e5..000000000 --- a/src/ersky9x/libraries/components/wm8731/wm8731.c +++ /dev/null @@ -1,140 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - -/** - * \file - * - * Implementation WM8731 driver. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include "wm8731.h" -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Read data from WM8731 Register. - * - * \param pTwid Pointer to twi driver structure - * \param device Twi slave address. - * \param regAddr Register address to read. - * \return value in the given register. - */ -uint16_t WM8731_Read(Twid *pTwid, - uint32_t device, - uint32_t regAddr) -{ - uint16_t bitsDataRegister; - uint8_t Tdata[2]={0,0}; - - TWID_Read(pTwid, device, regAddr, 0, Tdata, 2, 0); - bitsDataRegister = (Tdata[0] << 8) | Tdata[1]; - return bitsDataRegister; -} - -/** - * \brief Write data to WM8731 Register. - * - * \param pTwid Pointer to twi driver structure - * \param device Twi slave address. - * \param regAddr Register address to read. - * \param data Data to write - */ -void WM8731_Write(Twid *pTwid, - uint32_t device, - uint32_t regAddr, - uint16_t data) -{ - uint8_t tmpData[2]; - uint16_t tmp; - tmp = ((regAddr & 0x7f) << 9) | (data & 0x1ff); - - tmpData[0] = (tmp & 0xff00) >> 8; - tmpData[1] = tmp & 0xff; - TWID_Write(pTwid, device, regAddr, 0, tmpData, 2, 0); -} - -/** - * \brief Init WM8731 to DAC mode. - * - * \param pTwid Pointer to twi driver structure - * \param device Twi slave address. - * \return 0. - */ -uint8_t WM8731_DAC_Init(Twid *pTwid, - uint32_t device) -{ - /* reset */ - WM8731_Write(pTwid, device, WM8731_REG_RESET, 0); - - /* analogue audio path control */ - WM8731_Write(pTwid, device, WM8731_REG_ANALOGUE_PATH_CTRL, 0x12); - - /* digital audio path control*/ - WM8731_Write(pTwid, device, WM8731_REG_DIGITAL_PATH_CTRL, 0x00); - - /* power down control */ - WM8731_Write(pTwid, device, WM8731_REG_PWDOWN_CTRL, 0x7); - - /* Active control*/ - WM8731_Write(pTwid, device, WM8731_REG_ACTIVE_CTRL, 0x01); - - return 0; -} - -/** - * \brief Set WM8731 volume - * - * \param pTwid Pointer to twi driver structure - * \param device Twi slave address. - * \param register Register address - * \param value Register value, valid value is between 0x30 to 0x7f - * \return 0. - */ -uint8_t WM8731_VolumeSet(Twid *pTwid, - uint32_t device, - uint16_t value) -{ - uint16_t regValue; - - value &= WM8731_LHPVOL_BITS; - regValue = WM8731_LRHPBOTH_BIT | WM8731_LZCEN_BIT | value; - WM8731_Write(pTwid, device, WM8731_REG_LEFT_HPOUT, regValue); - regValue = WM8731_RZCEN_BIT | WM8731_RLHPBOTH_BIT | value; - WM8731_Write(pTwid, device, WM8731_REG_RIGHT_HPOUT, value); - return 0; -} - diff --git a/src/ersky9x/libraries/components/wm8731/wm8731.h b/src/ersky9x/libraries/components/wm8731/wm8731.h deleted file mode 100644 index 37e0e60b6..000000000 --- a/src/ersky9x/libraries/components/wm8731/wm8731.h +++ /dev/null @@ -1,195 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - -/** - * \file - * - * Implementation WM8731 driver. - * - */ - -#ifndef WM8731_H -#define WM8731_H - -#include "board.h" -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ -#define WM8731_CSB_STATE (0x0 << 0) - -/** Slave address */ -//#define WM8731_SLAVE_ADDRESS 0x1a | WM8731_CSB_STATE*/ -#define WM8731_SLAVE_ADDRESS 0x1b - - -/** Reset register*/ -#define WM8731_REG_RESET 0x0F - -/** Left Line in register*/ -#define WM8731_REG_LEFT_lINEIN 0x0 -/** Left line input volume control*/ -#define WM8731_LINVOL_BITS (0x1f << 0) -/** Left line input mute to ADC*/ -#define WM8731_LINMUTE_BIT (0x1 << 7) -/** Left to right channel line input volume and mute data load control*/ -#define WM8731_LRINBOTH_BIT (0x0 << 8) - -/** Right Line in register*/ -#define WM8731_REG_RIGHT_lINEIN 0x1 -/** Right line input volume control*/ -#define WM8731_RINVOL_BITS (0x1f << 0) -/** Right line input mute to ADC*/ -#define WM8731_RINMUTE_BIT (0x1 << 7) -/** Right to right channel line input volume and mute data load control*/ -#define WM8731_RLINBOTH_BIT (0x0 << 8) - -/** Left Headphone out register*/ -#define WM8731_REG_LEFT_HPOUT 0x2 -/** Left chnnel headphone output volume control*/ -#define WM8731_LHPVOL_BITS (0x7f << 0) -/** Left channel zero cross detect enable*/ -#define WM8731_LZCEN_BIT (0x1 << 7) -/** Left to right channel headphone volume, mute and zero cross data load control*/ -#define WM8731_LRHPBOTH_BIT (0x1 << 8) - -/** Right Headphone out register*/ -#define WM8731_REG_RIGHT_HPOUT 0x3 -/** Right chnnel headphone output volume control*/ -#define WM8731_RHPVOL_BITS (0x7f << 0) -/** Right channel zero cross detect enable*/ -#define WM8731_RZCEN_BIT (0x1 << 7) -/** Right to right channel headphone volume, mute and zero cross data load control*/ -#define WM8731_RLHPBOTH_BIT (0x1 << 8) - -/** Analogue audio path control register*/ -#define WM8731_REG_ANALOGUE_PATH_CTRL 0x4 - -/** Digital audio path control register*/ -#define WM8731_REG_DIGITAL_PATH_CTRL 0x5 - -/** Power down control register*/ -#define WM8731_REG_PWDOWN_CTRL 0x6 -/** LineIn power down*/ -#define WM8731_LINEINPD_BIT (0x1 << 0) -#define WM8731_ENABLE_LINEINPD (0x1 << 0) -#define WM8731_DISABLE_LINEINPD (0x0 << 0) -/** Mic power down*/ -#define WM8731_MICPD_BIT (0x1 << 1) -#define WM8731_ENABLE_MICPD (0x1 << 1) -#define WM8731_DISABLE_MICPD (0x0 << 1) -/** ADC power down*/ -#define WM8731_ADCPD_BIT (0x1 << 2) -#define WM8731_ENABLE_ADCPD (0x1 << 2) -#define WM8731_DISABLE_ADCPD (0x0 << 2) -/** DAC power down*/ -#define WM8731_DACPD_BIT (0x1 << 3) -#define WM8731_ENABLE_DACPD (0x1 << 3) -#define WM8731_DISABLE_DACPD (0x0 << 3) -/** OUT power down*/ -#define WM8731_OUTPD_BIT (0x1 << 4) -#define WM8731_ENABLE_OUTPD (0x1 << 4) -#define WM8731_DISABLE_OUTPD (0x0 << 4) -/** OSC power down*/ -#define WM8731_OSCBIT (0x1 << 5) -#define WM8731_ENABLE_OSCPD (0x1 << 5) -#define WM8731_DISABLE_OSCPD (0x0 << 5) -/** CLKOUT powerdown*/ -#define WM8731_CLKOUTPD_BIT (0x1 << 6) -#define WM8731_ENABLE_CLKOUTPD (0x1 << 6) -#define WM8731_DISABLE_CLKOUTPD (0x0 << 6) -/** Power off device*/ -#define WM8731_POWEROFF_BIT (0x1 << 7) -#define WM8731_DEV_POWER_OFF (0x1 << 7) -#define WM8731_DEV_POWER_ON (0x0 << 7) - -/** Interface format register*/ -#define WM8731_REG_DA_INTERFACE_FORMAT 0x7 -/** Format*/ -#define WM8731_FORMAT_BITS (0x3 << 0) -#define WM8731_FORMAT_MSB_LEFT_JUSTIFIED (0x0 << 0) -#define WM8731_FORMAT_MSB_RIGHT_JUSTIFIED (0x1 << 0) -#define WM8731_FORMAT_I2S (0x2 << 0) -#define WM8731_FORMAT_DSP (0x3 << 0) -/** Input audio data bit length select*/ -#define WM8731_IWL_BITS (0x3 << 2) -#define WM8731_IWL_16_BIT (0x0 << 2) -#define WM8731_IWL_20_BIT (0x1 << 2) -#define WM8731_IWL_24_BIT (0x2 << 2) -#define WM8731_IWL_32_BIT (0x3 << 2) -/** DACLRC phase control*/ -#define WM8731_IRP_BITS (0x1 << 4) -/** DAC Left right clock swap*/ -#define WM8731_IRSWAP_BIT (0x1 << 5) -/** Master slave mode control*/ -#define WM8731_MS_BIT (0x1 << 6) -#define WM8731_ENABLE_MASTER_MODE (0x1 << 6) -#define WM8731_ENABLE_SLAVE_MODE (0x0 << 6) -/** Bit clock invert*/ -#define WM8731_BCLKINV_BIT (0x1 << 7) - -/** Sampling control*/ -#define WM8731_REG_SAMPLECTRL 0x8 -/** Mode select, usb mode, normal mode*/ -#define WM8731_USBNORMAL_BIT (0x1 << 0) -#define WM8731_NORMAL_MODE (0x1 << 0) -#define WM8731_USB_MODE (0x1 << 1) -/** Base over-sampling rate*/ -#define WM8731_BOSR_BIT (0x1 << 1) -#define WM8731_USB_250FS (0x0 << 1) -#define WM8731_USB_272FS (0x1 << 1) -#define WM8731_NORMAL_256FS (0x0 << 1) -#define WM8731_NORMAL_128_192_384_FS (0x1 << 1) -/** Sample rate control*/ -#define WM8731_SR_BITS (0xf << 2) -#define WM8731_CLKIDIV2_BIT (0x1 << 6) -#define WM8731_CLKODIV2_BIT (0x1 << 7) - -/** Active control register*/ -#define WM8731_REG_ACTIVE_CTRL 0x9 -/** Activate interface*/ -#define WM8731_ACTIVE_BIT (0x1 << 0) -#define WM8731_ACTIVE_INTERFACE_ACTIVE (0x1 << 1) -#define WM8731_ACTIVE_INTERFACE_INACTIVE (0x0 << 1) - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern uint16_t WM8731_Read(Twid *pTwid, uint32_t device, uint32_t regAddr); -extern void WM8731_Write(Twid *pTwid, uint32_t device, uint32_t regAddr, uint16_t data); -extern uint8_t WM8731_DAC_Init(Twid *pTwid, uint32_t device); -extern uint8_t WM8731_VolumeSet(Twid *pTwid, uint32_t device, uint16_t value); - -#endif // WM8731_H - - diff --git a/src/ersky9x/libraries/drivers/acc/acc.c b/src/ersky9x/libraries/drivers/acc/acc.c deleted file mode 100644 index 5edb3dfe5..000000000 --- a/src/ersky9x/libraries/drivers/acc/acc.c +++ /dev/null @@ -1,164 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup adc_module Working with ACC - * The ACC driver provides the interface to configure and use the ACC peripheral.\n - * - * It converts the analog input to digital format. The converted result could be 12bit - * or 10bit. The ACC supports up to 16 analog lines. - * - * To Enable a ACC conversion,the user has to follow these few steps: - *
    - *
  • Select an appropriate reference voltage on ADVREF
  • - *
  • Configure the ACC according to its requirements and special needs,which could be - broken down into several parts: - * -# Select the resolution by setting or clearing ACC_MR_LOWRES bit in ACC_MR (Mode Register) - * -# Set ACC clock by setting ACC_MR_PRESCAL bits in ACC_MR, the clock is caculated with - ACCClock = MCK / ( (PRESCAL+1) * 2 ) - * -# Set Startup Time,Tracking Clock cycles and Transfer Clock respeticively in ACC_MR. -
  • - *
  • Start conversion by setting ACC_CR_START in ACC_CR.
  • - *
- * - * For more accurate information, please look at the ACC section of the - * Datasheet. - * - * Related files :\n - * \ref adc.c\n - * \ref adc.h\n -*/ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include -#include - - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initialize the ACC controller - * \param pAcc Pointer to an Acc instance. - * \param idAcc ACC identifier - * \param selplus input connected to inp, 0~7 - * \param selminus input connected to inm,0~7 - * \param ac_en Analog comprator enabled/disabled,use pattern - * \param edge CF flag triggering mode,use pattern - * \param invert INVert comparator output,use pattern defined in the device header - file -*/ -void ACC_Configure(Acc *pAcc, - uint8_t idAcc, - uint8_t selplus, - uint8_t selminus, - uint16_t ac_en, - uint16_t edge, - uint16_t invert) -{ - - /* Enable peripheral clock*/ - PMC->PMC_PCER1 = 1 << (idAcc-32); - - /* Reset the controller */ - pAcc->ACC_CR |= ACC_CR_SWRST; - - /* Write to the MR register */ - ACC_CfgModeReg( pAcc, - ( selplus & ACC_MR_SELPLUS) - | (( selminus<<4) & ACC_MR_SELMINUS) - | ( ac_en & ACC_MR_ACEN) - | ( edge & ACC_MR_EDGETYP) - | ( invert & ACC_MR_INV) ); - //pAcc->ACC_MR |= (ACC_MR_SELFS_OUTPUT|ACC_MR_FE_EN); - - pAcc->ACC_ACR = 0x7; - - while(pAcc->ACC_ISR & (uint32_t)ACC_ISR_MASK); -} - - -/** - * Return the Channel Converted Data - * \param pAdc Pointer to an Adc instance. - * \param channel channel to get converted value - * \return Channel converted data of the specified channel - */ -void ACC_SetComparisionPair(Acc *pAcc, uint8_t selplus,uint8_t selminus) -{ - - uint32_t temp; - - ASSERT(selplus < 8 && selminus < 8,"The assigned channel number is invalid!"); - - temp = pAcc->ACC_MR; - - pAcc->ACC_MR = temp & (~ACC_MR_SELMINUS)&(~ACC_MR_SELPLUS); - - pAcc->ACC_MR |= ((selplus & ACC_MR_SELPLUS)|((selminus<<4) & ACC_MR_SELMINUS)); - -} -/** - * Return Comparison Result - * \param pAcc Pointer to an Acc instance. - * \param status value of ACC_ISR - */ -uint8_t ACC_GetComparisionResult(Acc *pAcc,uint32_t status) -{ - uint32_t temp = pAcc->ACC_MR; - if( (temp & ACC_MR_INV)== ACC_MR_INV) - { - - if( status & ACC_ISR_SCO) - { - return 0; /* inn>inp*/ - } - else return 1;/* inp>inn*/ - - } - else - { - - if( status & ACC_ISR_SCO) - { - return 1; /* inp>inn*/ - } - else return 0;/* inn>inp*/ - } - -} - - - - - diff --git a/src/ersky9x/libraries/drivers/acc/acc.h b/src/ersky9x/libraries/drivers/acc/acc.h deleted file mode 100644 index 3d6cf945a..000000000 --- a/src/ersky9x/libraries/drivers/acc/acc.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \unit - * - * !Purpose - * - * Interface for configuration the Analog-to-Digital Converter (ACC) peripheral. - * - * !Usage - * - * -# Configurate the pins for ACC - * -# Initialize the ACC with ACC_Initialize(). - * -# Select the active channel using ACC_EnableChannel() - * -# Start the conversion with ACC_StartConversion() - * -# Wait the end of the conversion by polling status with ACC_GetStatus() - * -# Finally, get the converted data using ACC_GetConvertedData() - * -*/ -#ifndef ACC_H -#define ACC_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------------ - * Definitions - *------------------------------------------------------------------------------*/ -#define ACC_SELPLUS_AD12B0 0 -#define ACC_SELPLUS_AD12B1 1 -#define ACC_SELPLUS_AD12B2 2 -#define ACC_SELPLUS_AD12B3 3 -#define ACC_SELPLUS_AD12B4 4 -#define ACC_SELPLUS_AD12B5 5 -#define ACC_SELPLUS_AD12B6 6 -#define ACC_SELPLUS_AD12B7 7 -#define ACC_SELMINUS_TS 0 -#define ACC_SELMINUS_ADVREF 1 -#define ACC_SELMINUS_DAC0 2 -#define ACC_SELMINUS_DAC1 3 -#define ACC_SELMINUS_AD12B0 4 -#define ACC_SELMINUS_AD12B1 5 -#define ACC_SELMINUS_AD12B2 6 -#define ACC_SELMINUS_AD12B3 7 - - -/*------------------------------------------------------------------------------ - * Macros function of register access - *------------------------------------------------------------------------------*/ -#define ACC_CfgModeReg(pAcc, mode) { \ - (pAcc)->ACC_MR = (mode);\ - } - -#define ACC_GetModeReg(pAcc) ((pAcc)->ACC_MR) - -#define ACC_StartConversion(pAcc) ((pAcc)->ACC_CR = ACC_CR_START) - -#define ACC_SoftReset(pAcc) ((pAcc)->ACC_CR = ACC_CR_SWRST) - -#define ACC_EnableChannel(pAcc, channel) {\ - ASSERT(channel < 16, "ACC Channel not exist");\ - (pAcc)->ACC_CHER = (1 << (channel));\ - } - -#define ACC_DisableChannel (pAcc, channel) {\ - ASSERT((channel) < 16, "ACC Channel not exist");\ - (pAcc)->ACC_CHDR = (1 << (channel));\ - } - -#define ACC_EnableIt(pAcc, mode) {\ - ASSERT(((mode)&0xFFF00000)== 0, "ACC bad interrupt IER");\ - (pAcc)->ACC_IER = (mode);\ - } - -#define ACC_DisableIt(pAcc, mode) {\ - ASSERT(((mode)&0xFFF00000)== 0, "ACC bad interrupt IDR");\ - (pAcc)->ACC_IDR = (mode);\ - } - -#define ACC_EnableDataReadyIt(pAcc) ((pAcc)->ACC_IER = AT91C_ACC_DRDY) - -#define ACC_GetStatus(pAcc) ((pAcc)->ACC_ISR) - -#define ACC_GetChannelStatus(pAcc) ((pAcc)->ACC_CHSR) - -#define ACC_GetInterruptMaskStatus(pAcc) ((pAcc)->ACC_IMR) - -#define ACC_GetLastConvertedData(pAcc) ((pAcc)->ACC_LCDR) - -#define ACC_CfgAnalogCtrlReg(pAcc,mode) {\ - ASSERT(((mode) & 0xFFFCFF3C)==0, "ACC bad analog control config");\ - (pAcc)->ACC_ACR = (mode);\ - } - -#define ACC_CfgExtModeReg(pAcc, extmode) {\ - ASSERT(((extmode) & 0xFF00FFFE)==0, "ACC bad extended mode config");\ - (pAcc)->ACC_EMR = (extmode);\ - } - -#define ACC_GetAnalogCtrlReg(pAcc) ((pAcc)->ACC_ACR) - -/*------------------------------------------------------------------------------ - * Exported functions - *------------------------------------------------------------------------------*/ -void ACC_Configure(Acc *pAcc, - uint8_t idAcc, - uint8_t selplus, - uint8_t selminus, - uint16_t ac_en, - uint16_t edge, - uint16_t invert); - -extern uint8_t ACC_GetComparisionResult(Acc *pAcc,uint32_t status); - -#endif //#ifndef ACC_H diff --git a/src/ersky9x/libraries/drivers/adc/adc.c b/src/ersky9x/libraries/drivers/adc/adc.c deleted file mode 100644 index a2e2e3375..000000000 --- a/src/ersky9x/libraries/drivers/adc/adc.c +++ /dev/null @@ -1,231 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup adc_module Working with ADC - * The ADC driver provides the interface to configure and use the ADC peripheral. - * \n - * - * It converts the analog input to digital format. The converted result could be - * 12bit or 10bit. The ADC supports up to 16 analog lines. - * - * To Enable a ADC conversion,the user has to follow these few steps: - *
    - *
  • Select an appropriate reference voltage on ADVREF
  • - *
  • Configure the ADC according to its requirements and special needs,which - * could be broken down into several parts: - * -# Select the resolution by setting or clearing ADC_MR_LOWRES bit in - * ADC_MR (Mode Register) - * -# Set ADC clock by setting ADC_MR_PRESCAL bits in ADC_MR, the clock is - * calculated with ADCClock = MCK / ( (PRESCAL+1) * 2 ) - * -# Set Startup Time,Tracking Clock cycles and Transfer Clock respectively - * in ADC_MR. -
  • - *
  • Start conversion by setting ADC_CR_START in ADC_CR.
  • - *
- * - * For more accurate information, please look at the ADC section of the - * Datasheet. - * - * Related files :\n - * \ref adc.c\n - * \ref adc.h\n -*/ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initialize the ADC controller - * \param pAdc Pointer to an Adc instance. - * \param trgEn trigger mode, software or Hardware - * \param trgSel hardware trigger selection - * \param sleepMode sleep mode selection - * \param resolution resolution selection 10 bits or 12 bits - * \param mckClock value of MCK in Hz - * \param adcClock value of the ADC clock in Hz - * \param startupTime value of the start up time (in ADCClock) (see datasheet) - * \param trackingt Tracking Time (in ADCClock cycle) -*/ -void ADC_Initialize(Adc *pAdc, uint8_t idAdc, uint8_t trgEn, uint8_t trgSel, - uint8_t sleepMode, uint8_t resolution, uint32_t mckClock, - uint32_t adcClock, uint32_t startup, uint32_t tracking) { - uint32_t prescal; - prescal = (mckClock / (2*adcClock)) - 1; - - ASSERT( (prescal<0x3F), "ADC Bad PRESCAL\n\r"); - - TRACE_DEBUG("adcClock:%lu MasterClock:%lu\n\r", (mckClock/((prescal+1)*2)), - mckClock); - - if( adcClock != (mckClock/((prescal+1)*2)) ) { - TRACE_WARNING("User and calculated adcClocks are different : " - "user=%lu calc=%lu\n\r", - adcClock, (mckClock/((prescal+1)*2))); - } - - /* Enable peripheral clock*/ - PMC->PMC_PCER0 = 1 << idAdc; - - /* Reset the controller */ - ADC_SoftReset(pAdc); - - /* Write to the MR register */ - ADC_CfgModeReg( pAdc, - ( trgEn & ADC_MR_TRGEN) - | ( trgSel & ADC_MR_TRGSEL) - | ( resolution & ADC_MR_LOWRES) - | ( sleepMode & ADC_MR_SLEEP) - | ( (prescal<<8) & ADC_MR_PRESCAL) - | ( (startup<<16) & ADC_MR_STARTUP) - | ( (tracking<<24) & ADC_MR_TRACKTIM) ); -} - -/** - * Return the Channel Converted Data - * \param pAdc Pointer to an Adc instance. - * \param channel channel to get converted value - */ -uint32_t ADC_GetConvertedData(Adc *pAdc, uint32_t channel) { - uint32_t data=0; - - if (15 >= channel) { - data = *((RoReg *)((uint32_t)&(pAdc->ADC_CDR0)+ channel*4)); - } - return data; -} -/** - * Set compare channel - * \param pAdc Pointer to an Adc instance. - * \param channel channel number to be set,16 for all channels - */ -void ADC_SetCompareChannel(Adc *pAdc, uint8_t channel) { - ASSERT(channel<=16, "Invalid channel number"); - if (channel < 16) { - pAdc->ADC_EMR &= ~(ADC_EMR_CMPALL); - pAdc->ADC_EMR &= ~(ADC_EMR_CMPSEL); - pAdc->ADC_EMR |= (channel << 4); - } else { - pAdc->ADC_EMR |= ADC_EMR_CMPALL; - } -} -/** - * Set compare mode - * \param pAdc Pointer to an Adc instance. - * \param mode compare mode - */ -void ADC_SetCompareMode(Adc *pAdc, uint8_t mode) { - pAdc->ADC_EMR &= ~(ADC_EMR_CMPMODE); - pAdc->ADC_EMR |= mode; -} -/** - * Set comparsion window,one thereshold each time - * \param pAdc Pointer to an Adc instance. - * \param hi_lo Comparison Window - */ -void ADC_SetComparisonWindow(Adc *pAdc, uint32_t hi_lo) { - pAdc->ADC_CWR = hi_lo; -} - -/**---------------------------------------------------------------------------- -* Test if ADC Interrupt is Masked -* \param pAdc Pointer to an Adc instance. -* \param flag flag to be tested -* \return 1 if interrupt is masked, otherwise 0 -*/ -uint32_t ADC_IsInterruptMasked(Adc *pAdc, uint32_t flag) { - return (ADC_GetInterruptMaskStatus(pAdc) & flag); -} - -/**---------------------------------------------------------------------------- -* Test if ADC Status is Set -* \param pAdc Pointer to an Adc instance. -* \param flag flag to be tested -* \return 1 if the staus is set; 0 otherwise -*/ -uint32_t ADC_IsStatusSet(Adc *pAdc, uint32_t flag) { - return (ADC_GetStatus(pAdc) & flag); -} - -/**---------------------------------------------------------------------------- -* Test if ADC channel interrupt Status is Set -* \param adc_sr Value of SR register -* \param channel Channel to be tested -* \return 1 if interrupt status is set, otherwise 0 -*/ -uint8_t ADC_IsChannelInterruptStatusSet(uint32_t adc_sr, uint32_t channel) { - uint8_t status; - - if((adc_sr & (1<ADC_RCR == 0) && (pADC->ADC_RNCR == 0)) { - - pADC->ADC_RPR = (uint32_t) pBuffer; - pADC->ADC_RCR = size; - pADC->ADC_PTCR = ADC_PTCR_RXTEN; - - return 1; - } - /* Check if the second PDC bank is free*/ - else if (pADC->ADC_RNCR == 0) { - - pADC->ADC_RNPR = (uint32_t) pBuffer; - pADC->ADC_RNCR = size; - - return 1; - } else { - - return 0; - } - -} - diff --git a/src/ersky9x/libraries/drivers/adc/adc.h b/src/ersky9x/libraries/drivers/adc/adc.h deleted file mode 100644 index 98acf5257..000000000 --- a/src/ersky9x/libraries/drivers/adc/adc.h +++ /dev/null @@ -1,158 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \unit - * - * !Purpose - * - * Interface for configuration the Analog-to-Digital Converter (ADC) peripheral. - * - * !Usage - * - * -# Configurate the pins for ADC - * -# Initialize the ADC with ADC_Initialize(). - * -# Select the active channel using ADC_EnableChannel() - * -# Start the conversion with ADC_StartConversion() - * -# Wait the end of the conversion by polling status with ADC_GetStatus() - * -# Finally, get the converted data using ADC_GetConvertedData() - * -*/ -#ifndef ADC_H -#define ADC_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------------ - * Definitions - *------------------------------------------------------------------------------*/ -#define ADC_CHANNEL_0 0 -#define ADC_CHANNEL_1 1 -#define ADC_CHANNEL_2 2 -#define ADC_CHANNEL_3 3 -#define ADC_CHANNEL_4 4 -#define ADC_CHANNEL_5 5 -#define ADC_CHANNEL_6 6 -#define ADC_CHANNEL_7 7 -#define ADC_CHANNEL_8 8 -#define ADC_CHANNEL_9 9 -#define ADC_CHANNEL_10 10 -#define ADC_CHANNEL_11 11 -#define ADC_CHANNEL_12 12 -#define ADC_CHANNEL_13 13 -#define ADC_CHANNEL_14 14 -#define ADC_CHANNEL_15 15 - -/*------------------------------------------------------------------------------ - * Macros function of register access - *------------------------------------------------------------------------------*/ -#define ADC_CfgModeReg(pAdc, mode) { \ - ASSERT(((mode)&0xF00000C0)== 0, "ADC Bad configuration ADC MR");\ - (pAdc)->ADC_MR = (mode);\ - } - -#define ADC_GetModeReg(pAdc) ((pAdc)->ADC_MR) - -#define ADC_StartConversion(pAdc) ((pAdc)->ADC_CR = ADC_CR_START) - -#define ADC_SoftReset(pAdc) ((pAdc)->ADC_CR = ADC_CR_SWRST) - -#define ADC_EnableChannel(pAdc, channel) {\ - ASSERT(channel < 16, "ADC Channel not exist");\ - (pAdc)->ADC_CHER = (1 << (channel));\ - } - -#define ADC_DisableChannel (pAdc, channel) {\ - ASSERT((channel) < 16, "ADC Channel not exist");\ - (pAdc)->ADC_CHDR = (1 << (channel));\ - } - -#define ADC_EnableIt(pAdc, mode) {\ - (pAdc)->ADC_IER = (mode);\ - } - -#define ADC_DisableIt(pAdc, mode) {\ - (pAdc)->ADC_IDR = (mode);\ - } - -#define ADC_EnbaleTS(pAdc,mode) {\ - (pAdc)->ADC_ACR |= mode;\ - } - -#define ADC_EnableDataReadyIt(pAdc) ((pAdc)->ADC_IER = AT91C_ADC_DRDY) - -#define ADC_GetStatus(pAdc) ((pAdc)->ADC_ISR) - -#define ADC_GetCompareMode(pAdc) (((pAdc)->ADC_EMR)& (ADC_EMR_CMPMODE)) - -#define ADC_GetChannelStatus(pAdc) ((pAdc)->ADC_CHSR) - -#define ADC_GetInterruptMaskStatus(pAdc) ((pAdc)->ADC_IMR) - -#define ADC_GetLastConvertedData(pAdc) ((pAdc)->ADC_LCDR) - -#define ADC_CfgAnalogCtrlReg(pAdc,mode) {\ - ASSERT(((mode) & 0xFFFCFF3C)==0, "ADC bad analog control config");\ - (pAdc)->ADC_ACR = (mode);\ - } - -#define ADC_CfgExtModeReg(pAdc, extmode) {\ - ASSERT(((extmode) & 0xFF00FFFE)==0, "ADC bad extended mode config");\ - (pAdc)->ADC_EMR = (extmode);\ - } - -#define ADC_GetAnalogCtrlReg(pAdc) ((pAdc)->ADC_ACR) - -/*------------------------------------------------------------------------------ - * Exported functions - *------------------------------------------------------------------------------*/ -extern void ADC_Initialize (Adc *pAdc, - uint8_t idAdc, - uint8_t trgEn, - uint8_t trgSel, - uint8_t sleepMode, - uint8_t resolution, - uint32_t mckClock, - uint32_t adcClock, - uint32_t startupTime, - uint32_t sampleAndHoldTime); -extern uint32_t ADC_GetConvertedData(Adc *pAdc, uint32_t channel); -extern void ADC_SetCompareChannel(Adc *pAdc, uint8_t channel); -extern void ADC_SetCompareMode(Adc *pAdc, uint8_t mode); -extern void ADC_SetComparisonWindow(Adc *pAdc, uint32_t hi_lo); -extern uint32_t ADC_IsInterruptMasked(Adc *pAdc, uint32_t flag); -extern uint32_t ADC_IsStatusSet(Adc *pAdc, uint32_t flag); -extern uint8_t ADC_IsChannelInterruptStatusSet(uint32_t adc_sr, - uint32_t channel); -extern int8_t ADC_ReadBuffer(Adc *pADC,int16_t *pBuffer,int32_t size); - -#endif //#ifndef ADC_H diff --git a/src/ersky9x/libraries/drivers/async/async.c b/src/ersky9x/libraries/drivers/async/async.c deleted file mode 100644 index 3d26fef98..000000000 --- a/src/ersky9x/libraries/drivers/async/async.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Provide a routine for asynchronos transfer. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include -#include "async.h" - -/*---------------------------------------------------------------------------- - * Global functions - *----------------------------------------------------------------------------*/ - /** - * \brief Returns 1 if the given transfer has ended; otherwise returns 0. - * \param pAsync Pointer to an Async instance. - */ -uint8_t ASYNC_IsFinished(Async *pAsync) -{ - return (pAsync->status != ASYNC_STATUS_PENDING); -} - diff --git a/src/ersky9x/libraries/drivers/async/async.h b/src/ersky9x/libraries/drivers/async/async.h deleted file mode 100644 index d0bbec00e..000000000 --- a/src/ersky9x/libraries/drivers/async/async.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - /** - * \file - * - * Provide a routine for asynchronos transfer. - * - */ - -#ifndef ASYNC_H -#define ASYNC_H - - -/*---------------------------------------------------------------------------- - * Definition - *----------------------------------------------------------------------------*/ -/** Transfer is still pending.*/ -#define ASYNC_STATUS_PENDING 0xFF - -/*---------------------------------------------------------------------------- - * Type - *----------------------------------------------------------------------------*/ -/** Asynchronous transfer descriptor. */ -typedef struct _Async { - - /** Asynchronous transfer status.*/ - volatile uint8_t status; - /** Callback function to invoke when transfer completes or fails.*/ - void *callback; - /** Driver storage area; do not use.*/ - uint32_t pStorage[4]; -} Async; - -/*---------------------------------------------------------------------------- - * Global functions - *----------------------------------------------------------------------------*/ -extern uint8_t ASYNC_IsFinished(Async *pAsync); - -#endif //#ifndef ASYNC_H - diff --git a/src/ersky9x/libraries/drivers/crccu/crccu.c b/src/ersky9x/libraries/drivers/crccu/crccu.c deleted file mode 100644 index c57b6e967..000000000 --- a/src/ersky9x/libraries/drivers/crccu/crccu.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup crccu_module Working with CRCCU - * The CRCCU driver provides the interface to configure and use the CRCCU - * peripheral. - * - * It performs a CRC computation on a Memory Area. CRC computation is performed - * from the LSB to MSB bit. Three different polynomials are available: - * CCIT802.3, CASTAGNOLI and CCIT16. - * - * To computes CRC of a buffer, the user has to follow these few steps: - *
    - *
  • Reset initial CRC by setting RESET bit in CRCCU_CRC_CR,
  • - *
  • Configure CRC descriptor and working mode,
  • - *
  • Start to compute CRC by setting DMAEN in CRCCU_DMA_EN,
  • - *
  • Get CRC value in CRCCU_CRC_SR.
  • - *
- * - * For more accurate information, please look at the CRCCU section of the - * Datasheet. - * - * Related files :\n - * \ref crccu.c\n - * \ref crccu.h.\n -*/ -/*@{*/ -/*@}*/ - -/** - * \file - * - * Implementation of Cyclic Redundancy Check Calculation Unit (CRCCU). - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "crccu.h" -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ -#define CRCCU_TIMEOUT 0xFFFFFFFF - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ -/** - * \brief Reset initial CRC to 0xFFFFFFFF. - */ -void CRCCU_ResetCrcValue(void) -{ - Crccu *pCrccu = CRCCU; - - pCrccu->CRCCU_CR = CRCCU_CR_RESET; -} - -/** - * \brief Configure the CRCCU. - * - * \param dscrAddr CRC decscriptor address. - * \param mode CRC work mode - */ -void CRCCU_Configure(uint32_t dscrAddr, uint32_t mode) -{ - Crccu *pCrccu = CRCCU; - - pCrccu->CRCCU_DSCR = dscrAddr; - pCrccu->CRCCU_MR = mode; -} - -/** - * \brief Start to compute the CRC of a buffer. - * - * \return The CRC of the buffer. - */ -uint32_t CRCCU_ComputeCrc(void) -{ - Crccu *pCrccu = CRCCU; - uint32_t timeout = 0; - - pCrccu->CRCCU_DMA_EN = CRCCU_DMA_EN_DMAEN; - while (((pCrccu->CRCCU_DMA_SR & CRCCU_DMA_SR_DMASR) == CRCCU_DMA_SR_DMASR) - && (timeout++ < CRCCU_TIMEOUT)); - - return (pCrccu->CRCCU_SR); -} - -/** - * \brief Compare the CRC of a buffer is match to reference CRC. - * - * \return if 0 CRC is match, else dismatch. - */ -uint32_t CRCCU_CompareCrc(void) -{ - Crccu *pCrccu = CRCCU; - - if ((pCrccu->CRCCU_ISR & CRCCU_ISR_ERRISR) == CRCCU_ISR_ERRISR) { - return 1; - } else { - return 0; - } -} diff --git a/src/ersky9x/libraries/drivers/crccu/crccu.h b/src/ersky9x/libraries/drivers/crccu/crccu.h deleted file mode 100644 index f864cf3c7..000000000 --- a/src/ersky9x/libraries/drivers/crccu/crccu.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for Cyclic Redundancy Check Calculation Unit (CRCCU). - */ - -#ifndef CRCCU_H -#define CRCCU_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -typedef struct { - unsigned int TR_ADDR; - unsigned int TR_CTRL; - unsigned int reserved[2]; - unsigned int TR_CRC; -} CrcDscr; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ -void CRCCU_ResetCrcValue(void); -void CRCCU_Configure(uint32_t dscrAddr, uint32_t mode); -uint32_t CRCCU_ComputeCrc(void); -uint32_t CRCCU_CompareCrc(void); - -#endif /* #ifndef CRCCU_H */ - diff --git a/src/ersky9x/libraries/drivers/dacc/dacc.c b/src/ersky9x/libraries/drivers/dacc/dacc.c deleted file mode 100644 index bd9ce8199..000000000 --- a/src/ersky9x/libraries/drivers/dacc/dacc.c +++ /dev/null @@ -1,172 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup dacc_module Working with DACC - * The DACC driver provides the interface to configure and use the DACC peripheral.\n - * - * The DACC(Digital-to-Analog Converter Controller) converts digital code to analog output. - * The data to be converted are sent in a common register for all channels. It offers up to 2 - * analog outputs.The output voltage ranges from (1/6)ADVREF to (5/6)ADVREF. - * - * To Enable a DACC conversion,the user has to follow these few steps: - *
    - *
  • Select an appropriate reference voltage on ADVREF
  • - *
  • Configure the DACC according to its requirements and special needs,which could be - broken down into several parts: - * -# Enable DACC in free running mode by clearing TRGEN in DACC_MR; - * -# Configure Startup Time and Refresh Period through setting STARTUP and REFRESH fields - * in DACC_MR; The refresh mechanism is used to protect the output analog value from - * decreasing. - * -# Enable channels and write digital code to DACC_CDR,in free running mode, the conversion - * is started right after at least one channel is enabled and data is written . -
  • - *
- * - * For more accurate information, please look at the DACC section of the - * Datasheet. - * - * Related files :\n - * \ref DACC.c\n - * \ref DACC.h\n -*/ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include -#include - - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initialize the DACC controller - * \param pDACC Pointer to an DACC instance. - * \param idDACC identifier of DAC peripheral - * \param trgEn trigger mode, free running mode or external Hardware trigger - * \param word transfer size,word or half word - * \param trgSel hardware trigger selection - * \param sleepMode sleep mode selection - * \param mck value of MCK in Hz - * \param refresh refresh period - * \param user_sel user channel selection ,0 or 1 - * \param startup value of the start up time (in DACCClock) (see datasheet) -*/ -void DACC_Initialize (Dacc *pDACC, - uint8_t idDACC, - uint8_t trgEn, - uint8_t trgSel, - uint8_t word, - uint8_t sleepMode, - uint32_t mck, - uint8_t refresh,/*refresh period*/ - uint8_t user_sel,/*user channel selection*/ - uint32_t startup - ) -{ - ASSERT(1024*refresh*1000/(mck/2)<20,"Refresh preriod is too big!"); - - - /* Enable peripheral clock*/ - PMC->PMC_PCER0 = 1 << idDACC; - - /* Reset the controller */ - DACC_SoftReset(pDACC); - - /* Write to the MR register */ - DACC_CfgModeReg( pDACC, - ( trgEn & DACC_MR_TRGEN) - | ( trgSel & DACC_MR_TRGSEL) - | ( word & DACC_MR_WORD) - | ( sleepMode & DACC_MR_SLEEP) - | ( (refresh<<8) & DACC_MR_REFRESH) - | ( (user_sel<<16)& DACC_MR_USER_SEL) - | ( (startup<<24) & DACC_MR_STARTUP)); -} - - -/** - * Set the Conversion Data - * \param pDACC Pointer to an Dacc instance. - * \param channel channel to get converted value - * \return Channel converted data of the specified channel - */ -void DACC_SetConversionData(Dacc *pDACC, uint32_t data) -{ - uint32_t mr = pDACC->DACC_MR; - - if(mr & DACC_MR_WORD) - { - pDACC->DACC_CDR = data; - } - else - { - pDACC->DACC_CDR = (data&0xFFFF); - } -} - - -/** - * \brief Write converted data through PDC channel - * \param pDACC the pointer of DACC peripheral - * \param pBuffer the destination buffer - * \param size the size of the buffer -*/ -int8_t DACC_WriteBuffer(Dacc *pDACC,int16_t *pBuffer,int32_t size) -{ - - /* Check if the first PDC bank is free*/ - if ((pDACC->DACC_TCR == 0) && (pDACC->DACC_TNCR == 0)) { - - pDACC->DACC_TPR = (uint32_t) pBuffer; - pDACC->DACC_TCR = size; - pDACC->DACC_PTCR = DACC_PTCR_RXTEN; - - return 1; - } - /* Check if the second PDC bank is free*/ - else if (pDACC->DACC_TNCR == 0) { - - pDACC->DACC_TNPR = (uint32_t) pBuffer; - pDACC->DACC_TNCR = size; - - return 1; - } - else { - - return 0; - } - -} - - diff --git a/src/ersky9x/libraries/drivers/dacc/dacc.h b/src/ersky9x/libraries/drivers/dacc/dacc.h deleted file mode 100644 index 9282efcb0..000000000 --- a/src/ersky9x/libraries/drivers/dacc/dacc.h +++ /dev/null @@ -1,133 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \unit - * - * !Purpose - * - * Interface for configuration the Analog-to-Digital Converter (DACC) peripheral. - * - * !Usage - * - * -# Configurate the pins for DACC - * -# Initialize the DACC with DACC_Initialize(). - * -# Select the active channel using DACC_EnableChannel() - * -# Start the conversion with DACC_StartConversion() - * -# Wait the end of the conversion by polling status with DACC_GetStatus() - * -# Finally, get the converted data using DACC_GetConvertedData() - * -*/ -#ifndef DACC_H -#define DACC_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------------ - * Definitions - *------------------------------------------------------------------------------*/ -#define DACC_CHANNEL_0 0 -#define DACC_CHANNEL_1 1 - - -/*------------------------------------------------------------------------------ - * Macros function of register access - *------------------------------------------------------------------------------*/ -#define DACC_CfgModeReg(pDACC, mode) { \ - (pDACC)->DACC_MR = (mode);\ - } - -#define DACC_GetModeReg(pDACC) ((pDACC)->DACC_MR) - -#define DACC_StartConversion(pDACC) ((pDACC)->DACC_CR = DACC_CR_START) - -#define DACC_SoftReset(pDACC) ((pDACC)->DACC_CR = DACC_CR_SWRST) - -#define DACC_EnableChannel(pDACC, channel) {\ - (pDACC)->DACC_CHER = (1 << (channel));\ - } - -#define DACC_DisableChannel (pDACC, channel) {\ - (pDACC)->DACC_CHDR = (1 << (channel));\ - } - -#define DACC_EnableIt(pDACC, mode) {\ - ASSERT(((mode)&0xFFF00000)== 0, "DACC bad interrupt IER");\ - (pDACC)->DACC_IER = (mode);\ - } - -#define DACC_DisableIt(pDACC, mode) {\ - ASSERT(((mode)&0xFFF00000)== 0, "DACC bad interrupt IDR");\ - (pDACC)->DACC_IDR = (mode);\ - } - -#define DACC_EnableDataReadyIt(pDACC) ((pDACC)->DACC_IER = AT91C_DACC_DRDY) - -#define DACC_GetStatus(pDACC) ((pDACC)->DACC_ISR) - -#define DACC_GetChannelStatus(pDACC) ((pDACC)->DACC_CHSR) - -#define DACC_GetInterruptMaskStatus(pDACC) ((pDACC)->DACC_IMR) - -#define DACC_GetLastConvertedData(pDACC) ((pDACC)->DACC_LCDR) - -#define DACC_CfgAnalogCtrlReg(pDACC,mode) {\ - ASSERT(((mode) & 0xFFFCFF3C)==0, "DACC bad analog control config");\ - (pDACC)->DACC_ACR = (mode);\ - } - -#define DACC_CfgExtModeReg(pDACC, extmode) {\ - ASSERT(((extmode) & 0xFF00FFFE)==0, "DACC bad extended mode config");\ - (pDACC)->DACC_EMR = (extmode);\ - } - -#define DACC_GetAnalogCtrlReg(pDACC) ((pDACC)->DACC_ACR) - -/*------------------------------------------------------------------------------ - * Exported functions - *------------------------------------------------------------------------------*/ -extern void DACC_Initialize (Dacc *pDACC, - uint8_t idDACC, - uint8_t trgEn, - uint8_t trgSel, - uint8_t word, - uint8_t sleepMode, - uint32_t mck, - uint8_t refresh,/*refresh period*/ - uint8_t user_sel,/*user channel selection*/ - uint32_t startup - ); - - -extern void DACC_SetConversionData(Dacc *pDACC, uint32_t data); - -#endif //#ifndef DACC_H diff --git a/src/ersky9x/libraries/drivers/efc/efc.c b/src/ersky9x/libraries/drivers/efc/efc.c deleted file mode 100644 index 8610f097d..000000000 --- a/src/ersky9x/libraries/drivers/efc/efc.c +++ /dev/null @@ -1,286 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup efc_module Working with Enhanced Embedded Flash - * The EEFC driver provides the interface to configure and use the EEFC - * peripheral. - * - * The user needs to set the number of wait states depending on the frequency used.\n - * Configure number of cycles for flash read/write operations in the FWS field of EEFC_FMR. - * - * It offers a function to send flash command to EEFC and waits for the - * flash to be ready. - * - * To send flash command, the user could do in either of following way: - *
    - *
  • Write a correct key, command and argument in EEFC_FCR.
  • - *
  • Or, Use IAP (In Application Programming) function which is executed from - * ROM directly, this allows flash programming to be done by code running in flash.
  • - *
  • Once the command is achieved, it can be detected even by polling EEFC_FSR or interrupt. - *
- * - * The command argument could be a page number,GPNVM number or nothing, it depends on - * the command itself. Some useful functions in this driver could help user tranlate physical - * flash address into a page number and vice verse. - * - * For more accurate information, please look at the EEFC section of the - * Datasheet. - * - * Related files :\n - * \ref efc.c\n - * \ref efc.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of Emhance embedded Flash (EEFC) controller. - * - */ - - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include -#include "efc.h" -#include -#include - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Enables the flash ready interrupt source on the EEFC peripheral. - * - * \param efc Pointer to a Efc instance - */ -void EFC_EnableFrdyIt(Efc *efc) -{ - efc->EEFC_FMR |= EEFC_FMR_FRDY; -} - -/** - * \brief Disables the flash ready interrupt source on the EEFC peripheral. - * - * \param efc Pointer to a Efc instance - */ - -void EFC_DisableFrdyIt(Efc *efc) -{ - efc->EEFC_FMR &= ~EEFC_FMR_FRDY; -} - - -/** - * \brief Set read/write wait state on the EEFC perpherial. - * - * \param efc Pointer to a Efc instance - * \param cycles the number of wait states in cycle. - */ - -void EFC_SetWaitState(Efc *efc, uint8_t cycles) -{ - uint32_t value; - value = efc->EEFC_FMR; - value &= ~EEFC_FMR_FWS; - value |= cycles << 8; - efc->EEFC_FMR = value; -} - -/** - * \brief Returns the current status of the EEFC. - * - * \note Keep in mind that this function clears the value of some status bits (LOCKE, PROGE). - * - * \param efc Pointer to a Efc instance - */ -uint32_t EFC_GetStatus(Efc *efc) -{ - return efc->EEFC_FSR; -} - -/** - * \brief Returns the result of the last executed command. - * - * \param efc Pointer to a Efc instance - */ -uint32_t EFC_GetResult(Efc *efc) { - - return efc->EEFC_FRR; -} - -/** - * \brief Translates the given address page and offset values. - * \note The resulting values are stored in the provided variables if they are not null. - * - * \param efc Pointer to a Efc instance - * \param address Address to translate. - * \param pPage First page accessed. - * \param pOffset Byte offset in first page. - */ -void EFC_TranslateAddress( - Efc **efc, - uint32_t address, - unsigned short *pPage, - unsigned short *pOffset) -{ - Efc *pEfc; - unsigned short page; - unsigned short offset; - - SANITY_CHECK(address >= AT91C_IFLASH); - SANITY_CHECK(address <= (AT91C_IFLASH + AT91C_IFLASH_SIZE)); - - pEfc = EFC; - page = (address - AT91C_IFLASH) / AT91C_IFLASH_PAGE_SIZE; - offset = (address - AT91C_IFLASH) % AT91C_IFLASH_PAGE_SIZE; - - TRACE_DEBUG("Translated 0x%08X to page=%d and offset=%d\n\r", address, page, offset); - // Store values - if (pEfc) { - *efc = pEfc; - } - if (pPage) { - *pPage = page; - } - if (pOffset) { - *pOffset = offset; - } -} - -/** - * \brief Computes the address of a flash access given the page and offset. - * - * \param efc Pointer to a Efc instance - * \param page Page number. - * \param offset Byte offset inside page. - * \param pAddress Computed address (optional). - */ -void EFC_ComputeAddress( - Efc *efc, - unsigned short page, - unsigned short offset, - uint32_t *pAddress) -{ - uint32_t address; - SANITY_CHECK(efc); - SANITY_CHECK(page <= AT91C_IFLASH_NB_OF_PAGES); - SANITY_CHECK(offset < AT91C_IFLASH_PAGE_SIZE); - // Compute address - address = AT91C_IFLASH + page * AT91C_IFLASH_PAGE_SIZE + offset; - // Store result - if (pAddress) { - *pAddress = address; - } -} - -/** - * \brief Starts the executing the given command on the EEFC and returns as soon as the command is started. - * - * \note It does NOT set the FMCN field automatically. - * \param efc Pointer to a Efc instance - * \param command Command to execute. - * \param argument Command argument (should be 0 if not used). - */ -void EFC_StartCommand(Efc *efc, uint8_t command, unsigned short argument) -{ - // Check command & argument - switch (command) { - - case EFC_FCMD_WP: - case EFC_FCMD_WPL: - case EFC_FCMD_EWP: - case EFC_FCMD_EWPL: - case EFC_FCMD_SLB: - case EFC_FCMD_CLB: - ASSERT(argument < AT91C_IFLASH_NB_OF_PAGES, - "-F- Embedded flash has only %d pages\n\r", - AT91C_IFLASH_NB_OF_PAGES); - break; - - case EFC_FCMD_SFB: - case EFC_FCMD_CFB: - ASSERT(argument < 2, "-F- Embedded flash has only %d GPNVMs\n\r", 2); - break; - - case EFC_FCMD_GETD: - case EFC_FCMD_EA: - case EFC_FCMD_GLB: - case EFC_FCMD_GFB: - case EFC_FCMD_STUI: - ASSERT(argument == 0, "-F- Argument is meaningless for the given command.\n\r"); - break; - - default: ASSERT(0, "-F- Unknown command %d\n\r", command); - } - - // Start command Embedded flash - ASSERT((efc->EEFC_FSR & EEFC_FMR_FRDY) == EEFC_FMR_FRDY, "-F- EEFC is not ready\n\r"); - efc->EEFC_FCR = (0x5A << 24) | (argument << 8) | command; -} - -/** - * \brief Performs the given command and wait until its completion (or an error). - * - * \param efc Pointer to a Efc instance - * \param command Command to perform. - * \param argument Optional command argument. - * \return 0 if successful, otherwise returns an error code. - */ - -uint8_t EFC_PerformCommand(Efc *efc, uint8_t command, unsigned short argument) -{ - -#if defined(flash) || defined(USE_IAP_FEATURE) - // Pointer on IAP function in ROM - static uint32_t (*IAP_PerformCommand)(uint32_t, uint32_t); - IAP_PerformCommand = (uint32_t (*)(uint32_t, uint32_t)) *((uint32_t *) CHIP_FLASH_IAP_ADDRESS); - IAP_PerformCommand(0, (0x5A << 24) | (argument << 8) | command); - return (efc->EEFC_FSR & (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE)); - -#else - uint32_t status; - efc->EEFC_FCR = (0x5A << 24) | (argument << 8) | command; - do { - - status = efc->EEFC_FSR; - } - while ((status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY); - - return (status & (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE)); -#endif -} - - diff --git a/src/ersky9x/libraries/drivers/efc/efc.h b/src/ersky9x/libraries/drivers/efc/efc.h deleted file mode 100644 index 153f5401d..000000000 --- a/src/ersky9x/libraries/drivers/efc/efc.h +++ /dev/null @@ -1,112 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * - * Interface for configuration the Enhanced Embedded Flash Controller (EEFC) peripheral. - * - * \par Usage - * - * -# Enable/disable %flash ready interrupt sources using EFC_EnableFrdyIt() - * and EFC_DisableFrdyIt(). - * -# Translates the given address into which EEFC, page and offset values - * for difference density %flash memory using EFC_TranslateAddress(). - * -# Computes the address of a %flash access given the EFC, page and offset - * for difference density %flash memory using EFC_ComputeAddress(). - * -# Start the executing command with EFC_StartCommand() - * -# Retrieve the current status of the EFC using EFC_GetStatus(). - * -# Retrieve the result of the last executed command with EFC_GetResult(). - */ - -#ifndef EFC_H -#define EFC_H - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ -/* EFC command */ -#define EFC_FCMD_GETD 0x00 -#define EFC_FCMD_WP 0x01 -#define EFC_FCMD_WPL 0x02 -#define EFC_FCMD_EWP 0x03 -#define EFC_FCMD_EWPL 0x04 -#define EFC_FCMD_EA 0x05 -#define EFC_FCMD_SLB 0x08 -#define EFC_FCMD_CLB 0x09 -#define EFC_FCMD_GLB 0x0A -#define EFC_FCMD_SFB 0x0B -#define EFC_FCMD_CFB 0x0C -#define EFC_FCMD_GFB 0x0D -#define EFC_FCMD_STUI 0x0E -#define EFC_FCMD_SPUI 0x0F - -/* The IAP function entry addreass */ -#define CHIP_FLASH_IAP_ADDRESS (0x00800008) - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void EFC_EnableFrdyIt(Efc *efc); - -extern void EFC_DisableFrdyIt(Efc *efc); - -extern void EFC_SetWaitState(Efc *efc, uint8_t cycles); - -extern void EFC_TranslateAddress( - Efc **pEfc, - uint32_t address, - unsigned short *pPage, - unsigned short *pOffset); - -extern void EFC_ComputeAddress( - Efc *efc, - unsigned short page, - unsigned short offset, - uint32_t *pAddress); - -extern void EFC_StartCommand( - Efc *efc, - uint8_t command, - unsigned short argument); - -extern uint8_t EFC_PerformCommand( - Efc *efc, - uint8_t command, - unsigned short argument); - -extern uint32_t EFC_GetStatus(Efc *efc); - -extern uint32_t EFC_GetResult(Efc *efc); - -#endif //#ifndef EFC_H - diff --git a/src/ersky9x/libraries/drivers/flash/flashd.c b/src/ersky9x/libraries/drivers/flash/flashd.c deleted file mode 100644 index 27a7e1f58..000000000 --- a/src/ersky9x/libraries/drivers/flash/flashd.c +++ /dev/null @@ -1,494 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup flashd_module Flash Memory Interface - * The flash driver manages the programming, erasing, locking and unlocking sequences - * with dedicated commands. - * - * To implement flash programing operation, the user has to follow these few steps : - *
    - *
  • Configue flash wait states to initializes the flash.
  • - *
  • Checks whether a region to be programmed is locked.
  • - *
  • Unlocks the user region to be programmed if the region have locked before.
  • - *
  • Erases the user page before program (optional).
  • - *
  • Writes the user page from the page buffer.
  • - *
  • Locks the region of programmed area if any.
  • - *
- * - * Writing 8-bit and 16-bit data is not allowed and may lead to unpredictable data corruption. - * A check of this validity and padding for 32-bit alignment should be done in write algorithm. - - * Lock/unlock range associated with the user address range is automatically translated. - * - * This security bit can be enabled through the command "Set General Purpose NVM Bit 0". - * - * A 128-bit factory programmed unique ID could be read to serve several purposes. - * - * The driver accesses the flash memory by calling the lowlevel module provided in \ref efc_module. - * For more accurate information, please look at the EEFC section of the Datasheet. - * - * Related files :\n - * \ref flashd.c\n - * \ref flashd.h.\n - * \ref efc.c\n - * \ref efc.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * The flash driver provides the unified interface for flash program operations. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include "flashd.h" -#include - -#include -#include -#include -#include - -#include - - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Computes the lock range associated with the given address range. - * - * \param start Start address of lock range. - * \param end End address of lock range. - * \param pActualStart Actual start address of lock range. - * \param pActualEnd Actual end address of lock range. - */ -static void ComputeLockRange( - uint32_t start, - uint32_t end, - uint32_t *pActualStart, - uint32_t *pActualEnd) -{ - Efc *pStartEfc, *pEndEfc; - uint16_t startPage, endPage; - uint16_t numPagesInRegion; - uint16_t actualStartPage, actualEndPage; - - // Convert start and end address in page numbers - EFC_TranslateAddress(&pStartEfc, start, &startPage, 0); - EFC_TranslateAddress(&pEndEfc, end, &endPage, 0); - - // Find out the first page of the first region to lock - numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE; - actualStartPage = startPage - (startPage % numPagesInRegion); - actualEndPage = endPage; - if ((endPage % numPagesInRegion) != 0) { - - actualEndPage += numPagesInRegion - (endPage % numPagesInRegion); - } - // Store actual page numbers - EFC_ComputeAddress(pStartEfc, actualStartPage, 0, pActualStart); - EFC_ComputeAddress(pEndEfc, actualEndPage, 0, pActualEnd); - TRACE_DEBUG("Actual lock range is 0x%06X - 0x%06X\n\r", *pActualStart, *pActualEnd); -} - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initializes the flash driver. - * - * \param mck Master clock frequency in Hz. - */ - -void FLASHD_Initialize(uint32_t mck) -{ - EFC_DisableFrdyIt(EFC); - if ((mck/1000000) >= 64) { - EFC_SetWaitState(EFC, 2); - } - else if ((mck/1000000) >= 50) { - EFC_SetWaitState(EFC, 1); - } - else { - EFC_SetWaitState(EFC, 0); - } -} - -/** - * \brief Erases the entire flash. - * - * \param address Flash start address. - * \return 0 if successful; otherwise returns an error code. - */ -uint8_t FLASHD_Erase(uint32_t address) -{ - Efc *pEfc; - uint16_t page; - uint16_t offset; - uint8_t error; - SANITY_CHECK((address >=AT91C_IFLASH) || (address <= (AT91C_IFLASH + AT91C_IFLASH_SIZE))); - // Translate write address - EFC_TranslateAddress(&pEfc, address, &page, &offset); - error = EFC_PerformCommand(pEfc, EFC_FCMD_EA, 0); - return error; -} - - -static uint8_t pPageBuffer[AT91C_IFLASH_PAGE_SIZE]; -/** - * \brief Writes a data buffer in the internal flash - * - * \note This function works in polling mode, and thus only returns when the - * data has been effectively written. - * \param address Write address. - * \param pBuffer Data buffer. - * \param size Size of data buffer in bytes. - * \return 0 if successful, otherwise returns an error code. - */ -uint8_t FLASHD_Write( - uint32_t address, - const void *pBuffer, - uint32_t size) -{ - Efc *pEfc; - uint16_t page; - uint16_t offset; - uint32_t writeSize; - uint32_t pageAddress; - uint16_t padding; - uint8_t error; - - uint32_t sizeTmp; - uint32_t *pAlignedDestination; - uint32_t *pAlignedSource; - - SANITY_CHECK(pBuffer); - SANITY_CHECK(address >=AT91C_IFLASH); - SANITY_CHECK((address + size) <= (AT91C_IFLASH + AT91C_IFLASH_SIZE)); - // Translate write address - EFC_TranslateAddress(&pEfc, address, &page, &offset); - - // Write all pages - while (size > 0) { - - // Copy data in temporary buffer to avoid alignment problems - writeSize = min(AT91C_IFLASH_PAGE_SIZE - offset, size); - EFC_ComputeAddress(pEfc, page, 0, &pageAddress); - padding = AT91C_IFLASH_PAGE_SIZE - offset - writeSize; - - // Pre-buffer data - memcpy(pPageBuffer, (void *) pageAddress, offset); - - // Buffer data - memcpy(pPageBuffer + offset, pBuffer, writeSize); - - // Post-buffer data - memcpy(pPageBuffer + offset + writeSize, (void *) (pageAddress + offset + writeSize), padding); - - // Write page - // Writing 8-bit and 16-bit data is not allowed - // and may lead to unpredictable data corruption - pAlignedDestination = (uint32_t*)pageAddress; - pAlignedSource = (uint32_t*)pPageBuffer; - sizeTmp = AT91C_IFLASH_PAGE_SIZE; - while (sizeTmp >= 4) { - - *pAlignedDestination++ = *pAlignedSource++; - sizeTmp -= 4; - } - - // Send writing command - error = EFC_PerformCommand(pEfc, EFC_FCMD_EWP, page); - if (error) { - - return error; - } - - // Progression - address += AT91C_IFLASH_PAGE_SIZE; - pBuffer = (void *) ((uint32_t) pBuffer + writeSize); - size -= writeSize; - page++; - offset = 0; - } - - return 0; -} -/** - * \brief Locks all the regions in the given address range. The actual lock range is - * reported through two output parameters. - * \param address Start address of lock range. - * \param end End address of lock range. - * \param pActualStart Start address of the actual lock range (optional). - * \param pActualEnd End address of the actual lock range (optional). - * \return 0 if successful, otherwise returns an error code. - */ -uint8_t FLASHD_Lock( - uint32_t start, - uint32_t end, - uint32_t *pActualStart, - uint32_t *pActualEnd) -{ - Efc *pEfc; - uint32_t actualStart, actualEnd; - uint16_t startPage, endPage; - uint8_t error; - uint16_t numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE; - - // Compute actual lock range and store it - ComputeLockRange(start, end, &actualStart, &actualEnd); - if (pActualStart) { - - *pActualStart = actualStart; - } - if (pActualEnd) { - - *pActualEnd = actualEnd; - } - - // Compute page numbers - EFC_TranslateAddress(&pEfc, actualStart, &startPage, 0); - EFC_TranslateAddress(0, actualEnd, &endPage, 0); - - // Lock all pages - while (startPage < endPage) { - - error = EFC_PerformCommand(pEfc, EFC_FCMD_SLB, startPage); - if (error) { - - return error; - } - startPage += numPagesInRegion; - } - - return 0; -} - -/** - * \brief Unlocks all the regions in the given address range. The actual unlock range is - * reported through two output parameters. - * \param address Start address of unlock range. - * \param end End address of unlock range. - * \param pActualStart Start address of the actual unlock range (optional). - * \param pActualEnd End address of the actual unlock range (optional). - * \return 0 if successful, otherwise returns an error code. - */ -uint8_t FLASHD_Unlock( - uint32_t start, - uint32_t end, - uint32_t *pActualStart, - uint32_t *pActualEnd) -{ - Efc *pEfc; - uint32_t actualStart, actualEnd; - uint16_t startPage, endPage; - uint8_t error; - uint16_t numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE; - - // Compute actual unlock range and store it - ComputeLockRange(start, end, &actualStart, &actualEnd); - if (pActualStart) { - - *pActualStart = actualStart; - } - if (pActualEnd) { - - *pActualEnd = actualEnd; - } - - // Compute page numbers - EFC_TranslateAddress(&pEfc, actualStart, &startPage, 0); - EFC_TranslateAddress(0, actualEnd, &endPage, 0); - - // Unlock all pages - while (startPage < endPage) { - - error = EFC_PerformCommand(pEfc, EFC_FCMD_CLB, startPage); - if (error) { - - return error; - } - startPage += numPagesInRegion; - } - return 0; -} - -/** - * \brief Returns the number of locked regions inside the given address range. - * - * \param address Start address of range - * \param end End address of range. - */ -uint8_t FLASHD_IsLocked(uint32_t start, uint32_t end) -{ - Efc *pEfc; - uint16_t startPage, endPage; - uint8_t startRegion, endRegion; - uint32_t numPagesInRegion; - uint32_t status; - uint8_t error; - uint32_t numLockedRegions = 0; - - SANITY_CHECK(end >= start); - SANITY_CHECK((start >=AT91C_IFLASH) && (end <= AT91C_IFLASH + AT91C_IFLASH_SIZE)); - - // Compute page numbers - EFC_TranslateAddress(&pEfc, start, &startPage, 0); - EFC_TranslateAddress(0, end, &endPage, 0); - - // Compute region numbers - numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE; - startRegion = startPage / numPagesInRegion; - endRegion = endPage / numPagesInRegion; - if ((endPage % numPagesInRegion) != 0) { - - endRegion++; - } - - // Retrieve lock status - error = EFC_PerformCommand(pEfc, EFC_FCMD_GLB, 0); - ASSERT(!error, "-F- Error while trying to fetch lock bits status (0x%02X)\n\r", error); - status = EFC_GetResult(pEfc); - - // Check status of each involved region - while (startRegion < endRegion) { - - if ((status & (1 << startRegion)) != 0) { - - numLockedRegions++; - } - startRegion++; - } - - return numLockedRegions; -} - -/** - * \brief Check if the given GPNVM bit is set or not. - * - * \param gpnvm GPNVM bit index. - * \returns 1 if the given GPNVM bit is currently set; otherwise returns 0. - */ -uint8_t FLASHD_IsGPNVMSet(uint8_t gpnvm) -{ - uint8_t error; - uint32_t status; - - SANITY_CHECK(gpnvm < 2); - - // Get GPNVMs status - error = EFC_PerformCommand(EFC, EFC_FCMD_GFB, 0); - ASSERT(!error, "-F- Error while trying to fetch GPNVMs status (0x%02X)\n\r", error); - status = EFC_GetResult(EFC); - - // Check if GPNVM is set - if ((status & (1 << gpnvm)) != 0) { - return 1; - } - else { - return 0; - } -} -/** - * \brief Sets the selected GPNVM bit. - * - * \param gpnvm GPNVM bit index. - * \returns 0 if successful; otherwise returns an error code. - */ -uint8_t FLASHD_SetGPNVM(uint8_t gpnvm) -{ - SANITY_CHECK(gpnvm < 2); - - if (!FLASHD_IsGPNVMSet(gpnvm)) { - - return EFC_PerformCommand(EFC, EFC_FCMD_SFB, gpnvm); - } - else { - - return 0; - } -} - -/** - * \brief Clears the selected GPNVM bit. - * - * \param gpnvm GPNVM bit index. - * \returns 0 if successful; otherwise returns an error code. - */ -uint8_t FLASHD_ClearGPNVM(uint8_t gpnvm) -{ - SANITY_CHECK(gpnvm < 2); - - if (FLASHD_IsGPNVMSet(gpnvm)) { - - return EFC_PerformCommand(EFC, EFC_FCMD_CFB, gpnvm); - } - else { - - return 0; - } -} -/** - * \brief Read the unique ID. - * - * \param uniqueID pointer on a 4bytes char containing the unique ID value. - * \returns 0 if successful; otherwise returns an error code. - */ -uint8_t FLASHD_ReadUniqueID (uint32_t * uniqueID) -{ - uint8_t error; - SANITY_CHECK(uniqueID != NULL); - - uniqueID[0] = 0; - uniqueID[1] = 0; - uniqueID[2] = 0; - uniqueID[3] = 0; - - EFC_StartCommand(EFC, EFC_FCMD_STUI, 0); - - uniqueID[0] = *(uint32_t *)AT91C_IFLASH; - uniqueID[1] = *(uint32_t *)(AT91C_IFLASH + 4); - uniqueID[2] = *(uint32_t *)(AT91C_IFLASH + 8); - uniqueID[3] = *(uint32_t *)(AT91C_IFLASH + 12); - - error = EFC_PerformCommand(EFC, EFC_FCMD_SPUI, 0); - if (error) return error; - - return 0; -} diff --git a/src/ersky9x/libraries/drivers/flash/flashd.h b/src/ersky9x/libraries/drivers/flash/flashd.h deleted file mode 100644 index ab7924235..000000000 --- a/src/ersky9x/libraries/drivers/flash/flashd.h +++ /dev/null @@ -1,84 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- -*/ - -/** - * \file - * - * The flash driver provides the unified interface for flash program operations. - * - */ - -#ifndef FLASHD_H -#define FLASHD_H - -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void FLASHD_Initialize(uint32_t mck); - -extern uint8_t FLASHD_Erase(uint32_t address); - -extern uint8_t FLASHD_Write( - uint32_t address, - const void *pBuffer, - uint32_t size); - -extern uint8_t FLASHD_Lock( - uint32_t start, - uint32_t end, - uint32_t *pActualStart, - uint32_t *pActualEnd); - -extern uint8_t FLASHD_Unlock( - uint32_t start, - uint32_t end, - uint32_t *pActualStart, - uint32_t *pActualEnd); - -extern uint8_t FLASHD_IsLocked( - uint32_t start, - uint32_t end); - -extern uint8_t FLASHD_SetGPNVM(uint8_t gpnvm); - -extern uint8_t FLASHD_ClearGPNVM(uint8_t gpnvm); - -extern uint8_t FLASHD_IsGPNVMSet(uint8_t gpnvm); - -#define FLASHD_IsSecurityBitSet() FLASHD_IsGPNVMSet(0) - -#define FLASHD_SetSecurityBit() FLASHD_SetGPNVM(0) - -extern uint8_t FLASHD_ReadUniqueID(uint32_t * uniqueID); - -#endif //#ifndef FLASHD_H - diff --git a/src/ersky9x/libraries/drivers/lcd/color.h b/src/ersky9x/libraries/drivers/lcd/color.h deleted file mode 100644 index 8bae812bf..000000000 --- a/src/ersky9x/libraries/drivers/lcd/color.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef COLOR_H -#define COLOR_H - -/** - * \file - * - * RGB 24-bits color table definition. - * - */ - -/* - * RGB 24 Bpp - * RGB 888 - * R7R6R5R4 R3R2R1R0 G7G6G5G4 G3G2G1G0 B7B6B5B4 B3B2B1B0 - */ -#define COLOR_BLACK 0x000000 -#define COLOR_WHITE 0xFFFFFF - -#define COLOR_BLUE 0x0000FF -#define COLOR_GREEN 0x00FF00 -#define COLOR_RED 0xFF0000 - -#define COLOR_NAVY 0x000080 -#define COLOR_DARKBLUE 0x00008B -#define COLOR_DARKGREEN 0x006400 -#define COLOR_DARKCYAN 0x008B8B -#define COLOR_CYAN 0x00FFFF -#define COLOR_TURQUOISE 0x40E0D0 -#define COLOR_INDIGO 0x4B0082 -#define COLOR_DARKRED 0x800000 -#define COLOR_OLIVE 0x808000 -#define COLOR_GRAY 0x808080 -#define COLOR_SKYBLUE 0x87CEEB -#define COLOR_BLUEVIOLET 0x8A2BE2 -#define COLOR_LIGHTGREEN 0x90EE90 -#define COLOR_DARKVIOLET 0x9400D3 -#define COLOR_YELLOWGREEN 0x9ACD32 -#define COLOR_BROWN 0xA52A2A -#define COLOR_DARKGRAY 0xA9A9A9 -#define COLOR_SIENNA 0xA0522D -#define COLOR_LIGHTBLUE 0xADD8E6 -#define COLOR_GREENYELLOW 0xADFF2F -#define COLOR_SILVER 0xC0C0C0 -#define COLOR_LIGHTGREY 0xD3D3D3 -#define COLOR_LIGHTCYAN 0xE0FFFF -#define COLOR_VIOLET 0xEE82EE -#define COLOR_AZUR 0xF0FFFF -#define COLOR_BEIGE 0xF5F5DC -#define COLOR_MAGENTA 0xFF00FF -#define COLOR_TOMATO 0xFF6347 -#define COLOR_GOLD 0xFFD700 -#define COLOR_ORANGE 0xFFA500 -#define COLOR_SNOW 0xFFFAFA -#define COLOR_YELLOW 0xFFFF00 - -#endif /* #define COLOR_H */ diff --git a/src/ersky9x/libraries/drivers/lcd/draw.c b/src/ersky9x/libraries/drivers/lcd/draw.c deleted file mode 100644 index af9ed2762..000000000 --- a/src/ersky9x/libraries/drivers/lcd/draw.c +++ /dev/null @@ -1,333 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of draw function on LCD, Include draw text, image - * and basic shapes (line, rectangle, circle). - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include - -#include "draw.h" -#include "font.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Fills the given LCD buffer with a particular color. - * - * \param color Fill color. - */ -void LCDD_Fill(uint32_t color) -{ - uint32_t i; - - LCD_SetCursor(0, 0); - LCD_WriteRAM_Prepare(); - for (i = 0; i < (BOARD_LCD_WIDTH * BOARD_LCD_HEIGHT); i++) { - - LCD_WriteRAM(color); - } -} - -/** - * \brief Draw a pixel on LCD of given color. - * - * \param x X-coordinate of pixel. - * \param y Y-coordinate of pixel. - * \param color Pixel color. - */ -void LCDD_DrawPixel( - uint32_t x, - uint32_t y, - uint32_t color) -{ - LCD_SetCursor(x, y); - LCD_WriteRAM_Prepare(); - LCD_WriteRAM(color); -} - -/** - * \brief Read a pixel from LCD. - * - * \param x X-coordinate of pixel. - * \param y Y-coordinate of pixel. - * - * \return color Readed pixel color. - */ -uint32_t LCDD_ReadPixel( - uint32_t x, - uint32_t y) -{ - uint32_t color; - - LCD_SetCursor(x, y); - LCD_ReadRAM_Prepare(); - color = LCD_ReadRAM(); - - return color; -} - -/* - * \brief Draw a line on LCD, horizontal and vertical line are supported. - * - * \param x X-coordinate of line start. - * \param y Y-coordinate of line start. - * \param length line length. - * \param direction line direction: 0 - horizontal, 1 - vertical. - * \param color Pixel color. - */ -void LCDD_DrawLine( - uint32_t x, - uint32_t y, - uint32_t length, - uint32_t direction, - uint32_t color) -{ - uint32_t i = 0; - - LCD_SetCursor(x, y); - - if(direction == DIRECTION_HLINE) { - LCD_WriteRAM_Prepare(); - for(i = 0; i < length; i++) { - LCD_WriteRAM(color); - } - } - else { - for(i = 0; i < length; i++) { - LCD_WriteRAM_Prepare(); - LCD_WriteRAM(color); - y++; - LCD_SetCursor(x, y); - } - } -} - -/* - * \brief Draws a rectangle on LCD, at the given coordinates. - * - * \param x X-coordinate of upper-left rectangle corner. - * \param y Y-coordinate of upper-left rectangle corner. - * \param width Rectangle width in pixels. - * \param height Rectangle height in pixels. - * \param color Rectangle color. - */ -void LCDD_DrawRectangle( - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height, - uint32_t color) -{ - LCDD_DrawLine(x, y, width, DIRECTION_HLINE, color); - LCDD_DrawLine(x, (y + height), width, DIRECTION_HLINE, color); - - LCDD_DrawLine(x, y, height, DIRECTION_VLINE, color); - LCDD_DrawLine((x + width), y, height, DIRECTION_VLINE, color); -} - -/* - * \brief Draws a rectangle with fill inside on LCD, at the given coordinates. - * - * \param x X-coordinate of upper-left rectangle corner. - * \param y Y-coordinate of upper-left rectangle corner. - * \param width Rectangle width in pixels. - * \param height Rectangle height in pixels. - * \param color Rectangle color. - */ -void LCDD_DrawRectangleWithFill( - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height, - uint32_t color) -{ - uint32_t i; - - for (i = 0; i < height; i++) { - LCDD_DrawLine(x, y+i, width, DIRECTION_HLINE, color); - } -} - -/** - * \brief Draws a circle on LCD, at the given coordinates. - * - * \param x X-coordinate of circle center. - * \param y Y-coordinate of circle center. - * \param r circle radius. - * \param color circle color. - */ -void LCDD_DrawCircle( - uint32_t x, - uint32_t y, - uint32_t r, - uint32_t color) -{ - signed int d; /* Decision Variable */ - uint32_t curX; /* Current X Value */ - uint32_t curY; /* Current Y Value */ - - d = 3 - (r << 1); - curX = 0; - curY = r; - - while (curX <= curY) - { - LCDD_DrawPixel(x + curX, y + curY, color); - LCDD_DrawPixel(x + curX, y - curY, color); - LCDD_DrawPixel(x - curX, y + curY, color); - LCDD_DrawPixel(x - curX, y - curY, color); - LCDD_DrawPixel(x + curY, y + curX, color); - LCDD_DrawPixel(x + curY, y - curX, color); - LCDD_DrawPixel(x - curY, y + curX, color); - LCDD_DrawPixel(x - curY, y - curX, color); - - if (d < 0) { - d += (curX << 2) + 6; - } - else { - d += ((curX - curY) << 2) + 10; - curY--; - } - curX++; - } -} - -/** - * \brief Draws a string inside a LCD buffer, at the given coordinates. Line breaks - * will be honored. - * - * \param x X-coordinate of string top-left corner. - * \param y Y-coordinate of string top-left corner. - * \param pString String to display. - * \param color String color. - */ -void LCDD_DrawString( - uint32_t x, - uint32_t y, - const uint8_t *pString, - uint32_t color) -{ - unsigned xorg = x; - - while (*pString != 0) { - if (*pString == '\n') { - - y += gFont.height + 2; - x = xorg; - } - else { - - LCDD_DrawChar(x, y, *pString, color); - x += gFont.width + 2; - } - pString++; - } -} - -/** - * \brief Returns the width & height in pixels that a string will occupy on the screen - * if drawn using LCDD_DrawString. - * - * \param pString String. - * \param pWidth Pointer for storing the string width (optional). - * \param pHeight Pointer for storing the string height (optional). - * - * \return String width in pixels. - */ -void LCDD_GetStringSize( - const uint8_t *pString, - uint32_t *pWidth, - uint32_t *pHeight) -{ - uint32_t width = 0; - uint32_t height = gFont.height; - - while (*pString != 0) { - - if (*pString == '\n') { - - height += gFont.height + 2; - } - else { - - width += gFont.width + 2; - } - pString++; - } - - if (width > 0) width -= 2; - - if (pWidth) *pWidth = width; - if (pHeight) *pHeight = height; -} - -/* - * \brief Draw a raw image at given position on LCD. - * - * \param x X-coordinate of image start. - * \param y Y-coordinate of image start. - * \param pImage Image buffer. - * \param width Image width. - * \param height Image height. - */ -void LCDD_DrawImage( - uint32_t x, - uint32_t y, - const uint8_t *pImage, - uint32_t width, - uint32_t height) -{ - uint32_t row, col; - - for(row = y; row < (y + height); row++) { - LCD_SetCursor(x, row); - LCD_WriteRAM_Prepare(); - for(col = x; col < (x + width); col++) { - LCD_D() = *pImage++; - LCD_D() = *pImage++; - LCD_D() = *pImage++; - } - } -} - diff --git a/src/ersky9x/libraries/drivers/lcd/draw.h b/src/ersky9x/libraries/drivers/lcd/draw.h deleted file mode 100644 index ad726bb23..000000000 --- a/src/ersky9x/libraries/drivers/lcd/draw.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - /** - * \file - * - * Interface for draw function on LCD. - * - */ - -#ifndef DRAW_H -#define DRAW_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** Horizontal direction line definition */ -#define DIRECTION_HLINE 0 -/** Vertical direction line definition */ -#define DIRECTION_VLINE 1 - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ -extern void LCDD_Fill(uint32_t color); - -extern void LCDD_DrawPixel( - uint32_t x, - uint32_t y, - uint32_t c); - -extern uint32_t LCDD_ReadPixel( - uint32_t x, - uint32_t y); - -extern void LCDD_DrawLine( - uint32_t x, - uint32_t y, - uint32_t length, - uint32_t direction, - uint32_t color); - -extern void LCDD_DrawRectangle( - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height, - uint32_t color); - -extern void LCDD_DrawRectangleWithFill( - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height, - uint32_t color); - -extern void LCDD_DrawCircle( - uint32_t x, - uint32_t y, - uint32_t r, - uint32_t color); - -extern void LCDD_DrawString( - uint32_t x, - uint32_t y, - const uint8_t *pString, - uint32_t color); - -extern void LCDD_GetStringSize( - const uint8_t *pString, - uint32_t *pWidth, - uint32_t *pHeight); - -extern void LCDD_DrawImage( - uint32_t x, - uint32_t y, - const uint8_t *pImage, - uint32_t width, - uint32_t height); - -#endif /* #ifndef DRAW_H */ diff --git a/src/ersky9x/libraries/drivers/lcd/font.c b/src/ersky9x/libraries/drivers/lcd/font.c deleted file mode 100644 index 996eeb2ac..000000000 --- a/src/ersky9x/libraries/drivers/lcd/font.c +++ /dev/null @@ -1,95 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of draw font on LCD. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "color.h" -#include "font.h" -#include "draw.h" -#include "font10x14.h" -#include - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -/** Global variable describing the font being instancied. */ -const Font gFont = {10, 14}; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Draws an ASCII character on LCD. - * - * \param x X-coordinate of character upper-left corner. - * \param y Y-coordinate of character upper-left corner. - * \param c Character to output. - * \param color Character color. -*/ -void LCDD_DrawChar( - uint32_t x, - uint32_t y, - uint8_t c, - uint32_t color) -{ - uint32_t row, col; - - SANITY_CHECK((c >= 0x20) && (c <= 0x7F)); - - for (col = 0; col < 10; col++) { - - for (row = 0; row < 8; row++) { - - if ((pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1) { - - LCDD_DrawPixel(x+col, y+row, color); - } - } - for (row = 0; row < 6; row++) { - - if ((pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1) { - - LCDD_DrawPixel(x+col, y+row+8, color); - } - } - } -} - diff --git a/src/ersky9x/libraries/drivers/lcd/font.h b/src/ersky9x/libraries/drivers/lcd/font.h deleted file mode 100644 index 446d31cec..000000000 --- a/src/ersky9x/libraries/drivers/lcd/font.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for draw font on LCD. - * - */ - -/** - * - * \section Purpose - * - * The font.h files declares a font structure and a LCDD_DrawChar function - * that must be implemented by a font definition file to be used with the - * LCDD_DrawString method of draw.h. - * - * The font10x14.c implements the necessary variable and function for a 10x14 - * font. - * - * \section Usage - * - * -# Declare a gFont global variable with the necessary Font information. - * -# Implement an LCDD_DrawChar function which displays the specified - * character on the LCD. - * -# Use the LCDD_DrawString method defined in draw.h to display a complete - * string. - */ - -#ifndef FONT_H -#define FONT_H - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - - -/** Describes the font (width, height, supported characters, etc.) used by - * the LCD driver draw API. - */ -typedef struct _Font { - /* Font width in pixels. */ - uint8_t width; - /* Font height in pixels. */ - uint8_t height; -} Font; - -/*---------------------------------------------------------------------------- - * Variables - *----------------------------------------------------------------------------*/ - -/** Global variable describing the font being instancied. */ -extern const Font gFont; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void LCDD_DrawChar( - uint32_t x, - uint32_t y, - uint8_t c, - uint32_t color); - -#endif /* #ifndef FONT_H */ diff --git a/src/ersky9x/libraries/drivers/lcd/font10x14.h b/src/ersky9x/libraries/drivers/lcd/font10x14.h deleted file mode 100644 index 1685b7969..000000000 --- a/src/ersky9x/libraries/drivers/lcd/font10x14.h +++ /dev/null @@ -1,236 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - /** - * \file - * - * Font 10x14 table definition. - * - */ - -#ifndef LCD_FONT_10x14_H -#define LCD_FONT_10x14_H - -/** Char set of font 10x14 */ -const uint8_t pCharset10x14[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xCC, - 0xFF, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0xC0, 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, - 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0x60, 0x1E, 0x70, 0x3F, 0x30, 0x33, 0x30, 0xFF, 0xFC, - 0xFF, 0xFC, 0x33, 0x30, 0x33, 0xF0, 0x39, 0xE0, 0x18, 0xC0, - 0x60, 0x00, 0xF0, 0x0C, 0xF0, 0x3C, 0x60, 0xF0, 0x03, 0xC0, - 0x0F, 0x00, 0x3C, 0x18, 0xF0, 0x3C, 0xC0, 0x3C, 0x00, 0x18, - 0x3C, 0xF0, 0x7F, 0xF8, 0xC3, 0x1C, 0xC7, 0x8C, 0xCF, 0xCC, - 0xDC, 0xEC, 0x78, 0x78, 0x30, 0x30, 0x00, 0xFC, 0x00, 0xCC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0xEC, 0x00, - 0xF8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x3F, 0xF0, 0x78, 0x78, - 0x60, 0x18, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0x60, 0x18, - 0x78, 0x78, 0x3F, 0xF0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0x60, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x3F, 0xF8, - 0x3F, 0xF8, 0x03, 0x80, 0x07, 0xC0, 0x0E, 0xE0, 0x0C, 0x60, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x3F, 0xF0, - 0x3F, 0xF0, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x00, 0x44, 0x00, 0xEC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x00, 0x18, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0, - 0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0xC0, 0x00, 0x00, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0xFC, 0xC1, 0xCC, 0xC3, 0x8C, - 0xC7, 0x0C, 0xCE, 0x0C, 0xFC, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x70, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x0C, 0x70, 0x1C, 0xE0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, - 0xC1, 0xCC, 0xC3, 0x8C, 0xE7, 0x0C, 0x7E, 0x0C, 0x3C, 0x0C, - 0x30, 0x30, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x03, 0xC0, 0x07, 0xC0, 0x0E, 0xC0, 0x1C, 0xC0, 0x38, 0xC0, - 0x70, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xC0, 0x00, 0xC0, - 0xFC, 0x30, 0xFC, 0x38, 0xCC, 0x1C, 0xCC, 0x0C, 0xCC, 0x0C, - 0xCC, 0x0C, 0xCC, 0x0C, 0xCE, 0x1C, 0xC7, 0xF8, 0xC3, 0xF0, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE3, 0x1C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x9C, 0x71, 0xF8, 0x30, 0xF0, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC3, 0xFC, - 0xC7, 0xFC, 0xCE, 0x00, 0xDC, 0x00, 0xF8, 0x00, 0xF0, 0x00, - 0x3C, 0xF0, 0x7F, 0xF8, 0xE7, 0x9C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x3C, 0x00, 0x7E, 0x00, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x1C, - 0xC3, 0x38, 0xC3, 0x70, 0xE7, 0xE0, 0x7F, 0xC0, 0x3F, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x60, 0x3C, 0xF0, - 0x3C, 0xF0, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x44, 0x3C, 0xEC, - 0x3C, 0xF8, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, - 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0x00, 0x00, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x00, 0x00, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x38, 0x70, - 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC1, 0xEC, - 0xC3, 0xEC, 0xC3, 0x00, 0xE6, 0x00, 0x7E, 0x00, 0x3C, 0x00, - 0x30, 0xF0, 0x71, 0xF8, 0xE3, 0x9C, 0xC3, 0x0C, 0xC3, 0xFC, - 0xC3, 0xFC, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0x3F, 0xFC, 0x7F, 0xFC, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xC0, 0x7F, 0xFC, 0x3F, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x30, 0x30, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, - 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x73, 0xF8, 0x33, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x38, 0xC0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xFC, 0xFF, 0xFC, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, - 0x1C, 0xE0, 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x70, 0x00, 0x38, 0x00, 0x1F, 0x00, - 0x1F, 0x00, 0x38, 0x00, 0x70, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, - 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0xFF, 0xFC, 0xFF, 0xFC, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, - 0xC3, 0x00, 0xC3, 0x00, 0xE7, 0x00, 0x7E, 0x00, 0x3C, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0xCC, - 0xC0, 0xEC, 0xC0, 0x7C, 0xE0, 0x38, 0x7F, 0xFC, 0x3F, 0xEC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x80, 0xC3, 0x80, - 0xC3, 0xC0, 0xC3, 0xC0, 0xE7, 0x70, 0x7E, 0x3C, 0x3C, 0x1C, - 0x3C, 0x18, 0x7E, 0x1C, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x9C, 0xE1, 0xF8, 0x60, 0xF0, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFC, - 0xFF, 0xFC, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, - 0xFF, 0xC0, 0xFF, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, - 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0xFF, 0xE0, 0xFF, 0xC0, - 0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0xF8, - 0x00, 0xF8, 0x00, 0x3C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, - 0xF0, 0x3C, 0xF8, 0x7C, 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, - 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, 0xF8, 0x7C, 0xF0, 0x3C, - 0xFC, 0x00, 0xFE, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xFC, - 0x01, 0xFC, 0x03, 0x80, 0x07, 0x00, 0xFE, 0x00, 0xFC, 0x00, - 0xC0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, 0xC1, 0xCC, 0xC3, 0x8C, - 0xC7, 0x0C, 0xCE, 0x0C, 0xDC, 0x0C, 0xF8, 0x0C, 0xF0, 0x0C, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x00, - 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, 0x00, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, - 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x06, 0x78, 0x0E, 0xFC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xCC, 0x07, 0xFC, 0x03, 0xF8, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, - 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x9C, 0x01, 0xF8, 0x00, 0xF0, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, - 0x00, 0xF0, 0x01, 0xF8, 0x03, 0x9C, 0x03, 0x0C, 0x03, 0x0C, - 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, 0xFF, 0xFC, 0xFF, 0xFC, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0xDC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xDC, 0x07, 0xD8, 0x03, 0x90, - 0x00, 0x00, 0x03, 0x00, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x00, - 0xE3, 0x00, 0x70, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xDC, 0x0F, 0xF8, 0x07, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x80, 0x01, 0xFC, 0x00, 0xFC, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFC, - 0x1B, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x1C, 0xCF, 0xF8, 0xCF, 0xF0, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xE0, 0x01, 0xE0, - 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0xFC, 0x0F, 0xFC, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xC0, - 0x03, 0xC0, 0x07, 0x00, 0x0E, 0x00, 0x0F, 0xFC, 0x0F, 0xFC, - 0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x00, 0x07, 0x00, 0x0E, 0x00, - 0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0xFC, 0x03, 0xFC, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0xF8, 0x03, 0xF0, - 0x0F, 0xFC, 0x0F, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, - 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xFC, 0x0F, 0xFC, - 0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, - 0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x00, - 0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xFC, 0x0E, 0x78, 0x06, 0x30, - 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0xFF, 0xF0, 0xFF, 0xF8, - 0x0C, 0x1C, 0x0C, 0x1C, 0x0C, 0x38, 0x0C, 0x30, 0x00, 0x00, - 0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0, - 0x0F, 0xC0, 0x0F, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, - 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x0F, 0xE0, 0x0F, 0xC0, - 0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0xF8, - 0x00, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0, - 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0xF0, 0x01, 0xE0, - 0x01, 0xE0, 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, - 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x0C, 0x03, 0x9C, 0x01, 0xF8, - 0x01, 0xF0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x0C, 0x00, - 0x0C, 0x0C, 0x0C, 0x1C, 0x0C, 0x3C, 0x0C, 0x7C, 0x0C, 0xEC, - 0x0D, 0xCC, 0x0F, 0x8C, 0x0F, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, - 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x3F, 0xF0, 0x7C, 0xF8, - 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, - 0x03, 0x0C, 0x03, 0x0C, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x0C, - 0xC3, 0x0C, 0xC0, 0x0C, 0xE0, 0x0C, 0x70, 0x0C, 0x30, 0x0C, - 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, - 0x7C, 0xF8, 0x3F, 0xF0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC -}; - -#endif /* #ifdef _LCD_FONT_10x14_h */ diff --git a/src/ersky9x/libraries/drivers/lcd/lcdd.c b/src/ersky9x/libraries/drivers/lcd/lcdd.c deleted file mode 100644 index 6d85f41f6..000000000 --- a/src/ersky9x/libraries/drivers/lcd/lcdd.c +++ /dev/null @@ -1,149 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of LCD driver, Include LCD initialization, - * LCD on/off and LCD backlight control. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "lcdd.h" -#include -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initializes the LCD controller. - * Configure SMC to access LCD controller at 64MHz MCK. - */ -void LCDD_Initialize(void) -{ - const Pin pPins[] = {BOARD_LCD_PINS}; - Smc *pSmc = SMC; - - /* Enable pins */ - PIO_Configure(pPins, PIO_LISTSIZE(pPins)); - - /* Enable peripheral clock */ - PMC_EnablePeripheral(ID_SMC); - - /* EBI SMC Configuration */ - pSmc->SMC_CS_NUMBER[1].SMC_SETUP = 0 - | ((2 << 0) & SMC_SETUP1_NWE_SETUP) - | ((2 << 8) & SMC_SETUP1_NCS_WR_SETUP) - | ((2 << 16) & SMC_SETUP1_NRD_SETUP) - | ((2 << 24) & SMC_SETUP1_NCS_RD_SETUP) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_PULSE = 0 - | ((4 << 0) & SMC_PULSE1_NWE_PULSE) - | ((4 << 8) & SMC_PULSE1_NCS_WR_PULSE) - | ((10 << 16) & SMC_PULSE1_NRD_PULSE) - | ((10 << 24) & SMC_PULSE1_NCS_RD_PULSE) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = 0 - | ((10 << 0) & SMC_CYCLE1_NWE_CYCLE) - | ((22 << 16) & SMC_CYCLE1_NRD_CYCLE) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_MODE = 0 - | (SMC_MODE1_READ_MODE) - | (SMC_MODE1_WRITE_MODE) - | (0) /* Set 8 bit width. TODO: replace with definition in device header file */ - ; - - /* Initialize LCD controller */ - LCD_Initialize(); - - /* Set LCD backlight */ - LCDD_SetBacklight(2); -} - -/** - * \brief Turn on the LCD. - */ -void LCDD_On(void) -{ - LCD_On(); -} - -/** - * \brief Turn off the LCD. - */ -void LCDD_Off(void) -{ - LCD_Off(); -} - -/** - * \brief Set the backlight of the LCD. - * - * \param level Backlight brightness level [1..16], 1 means maximum brightness. - */ -void LCDD_SetBacklight (uint32_t level) -{ - uint32_t i; - const Pin pPins[] = {BOARD_BACKLIGHT_PIN}; - - /* Ensure valid level */ - level = (level < 1) ? 1 : level; - level = (level > 16) ? 16 : level; - - /* Enable pins */ - PIO_Configure(pPins, PIO_LISTSIZE(pPins)); - - /* Switch off backlight */ - PIO_Clear(pPins); - i = 600 * (BOARD_MCK / 1000000); /* wait for at least 500us */ - while(i--); - - /* Set new backlight level */ - for (i = 0; i < level; i++) { - PIO_Clear(pPins); - PIO_Clear(pPins); - PIO_Clear(pPins); - - PIO_Set(pPins); - PIO_Set(pPins); - PIO_Set(pPins); - } -} diff --git a/src/ersky9x/libraries/drivers/lcd/lcdd.h b/src/ersky9x/libraries/drivers/lcd/lcdd.h deleted file mode 100644 index af29f5824..000000000 --- a/src/ersky9x/libraries/drivers/lcd/lcdd.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for LCD driver. - * - */ - -#ifndef LCDD_H -#define LCDD_H - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void LCDD_Initialize(void); - -extern void LCDD_On(void); - -extern void LCDD_Off(void); - -extern void LCDD_SetBacklight (uint32_t step); - -#endif /* #ifndef LCDD_H */ diff --git a/src/ersky9x/libraries/drivers/pio/pio.c b/src/ersky9x/libraries/drivers/pio/pio.c deleted file mode 100644 index bebfa0f6b..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio.c +++ /dev/null @@ -1,464 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// \file - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "pio.h" -#include -#include - -//------------------------------------------------------------------------------ -// Local Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) of a PIO controller as being controlled by -/// peripheral A. Optionally, the corresponding internal pull-up(s) can be -/// enabled. -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask of one or more pin(s) to configure. -/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be -/// configured. -//------------------------------------------------------------------------------ -static void PIO_SetPeripheralA( - Pio *pio, - unsigned int mask, - unsigned char enablePullUp) -{ - unsigned int abcdsr; - // Disable interrupts on the pin(s) - pio->PIO_IDR = mask; - - // Enable the pull-up(s) if necessary - if (enablePullUp) { - pio->PIO_PUER = mask; - } - else { - - pio->PIO_PUDR = mask; - } - - abcdsr = pio->PIO_ABCDSR[0]; - pio->PIO_ABCDSR[0] &= (~mask & abcdsr); - abcdsr = pio->PIO_ABCDSR[1]; - pio->PIO_ABCDSR[1] &= (~mask & abcdsr); - pio->PIO_PDR = mask; -} - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) of a PIO controller as being controlled by -/// peripheral B. Optionally, the corresponding internal pull-up(s) can be -/// enabled. -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask of one or more pin(s) to configure. -/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be -/// configured. -//------------------------------------------------------------------------------ -static void PIO_SetPeripheralB( - Pio *pio, - unsigned int mask, - unsigned char enablePullUp) -{ - unsigned int abcdsr; - // Disable interrupts on the pin(s) - pio->PIO_IDR = mask; - - // Enable the pull-up(s) if necessary - if (enablePullUp) { - - pio->PIO_PUER = mask; - } - else { - - pio->PIO_PUDR = mask; - } - - abcdsr = pio->PIO_ABCDSR[0]; - pio->PIO_ABCDSR[0] = (mask | abcdsr); - abcdsr = pio->PIO_ABCDSR[1]; - pio->PIO_ABCDSR[1] &= (~mask & abcdsr); - - pio->PIO_PDR = mask; -} - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) of a PIO controller as being controlled by -/// peripheral C. Optionally, the corresponding internal pull-up(s) can be -/// enabled. -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask of one or more pin(s) to configure. -/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be -/// configured. -//------------------------------------------------------------------------------ -static void PIO_SetPeripheralC( - Pio *pio, - unsigned int mask, - unsigned char enablePullUp) -{ - unsigned int abcdsr; - // Disable interrupts on the pin(s) - pio->PIO_IDR = mask; - - // Enable the pull-up(s) if necessary - if (enablePullUp) { - - pio->PIO_PUER = mask; - } - else { - - pio->PIO_PUDR = mask; - } - - abcdsr = pio->PIO_ABCDSR[0]; - pio->PIO_ABCDSR[0] &= (~mask & abcdsr); - abcdsr = pio->PIO_ABCDSR[1]; - pio->PIO_ABCDSR[1] = (mask | abcdsr); - - pio->PIO_PDR = mask; -} - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) of a PIO controller as being controlled by -/// peripheral D. Optionally, the corresponding internal pull-up(s) can be -/// enabled. -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask of one or more pin(s) to configure. -/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be -/// configured. -//------------------------------------------------------------------------------ -static void PIO_SetPeripheralD( - Pio *pio, - unsigned int mask, - unsigned char enablePullUp) -{ - unsigned int abcdsr; - // Disable interrupts on the pin(s) - pio->PIO_IDR = mask; - - // Enable the pull-up(s) if necessary - if (enablePullUp) { - - pio->PIO_PUER = mask; - } - else { - - pio->PIO_PUDR = mask; - } - - abcdsr = pio->PIO_ABCDSR[0]; - pio->PIO_ABCDSR[0] = (mask | abcdsr); - abcdsr = pio->PIO_ABCDSR[1]; - pio->PIO_ABCDSR[1] = (mask | abcdsr); - - pio->PIO_PDR = mask; -} - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) or a PIO controller as inputs. Optionally, -/// the corresponding internal pull-up(s) and glitch filter(s) can be -/// enabled. -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask indicating which pin(s) to configure as input(s). -/// \param enablePullUp Indicates if the internal pull-up(s) must be enabled. -/// \param enableFilter Indicates if the glitch filter(s) must be enabled. -//------------------------------------------------------------------------------ -static void PIO_SetInput( - Pio *pio, - unsigned int mask, - unsigned char attribute) -{ - // Disable interrupts - pio->PIO_IDR = mask; - - // Enable pull-up(s) if necessary - if (attribute & PIO_PULLUP) - pio->PIO_PUER = mask; - else - pio->PIO_PUDR = mask; - - // Enable de-glitch(s) if necessary - if (attribute & PIO_DEGLITCH) - pio->PIO_IFER = mask; - else - pio->PIO_IFDR = mask; - - // Enable de-bounce if necessary - if (attribute & PIO_DEBOUNCE) { - pio->PIO_DIFSR = mask; - } - - // Configure pin as input - pio->PIO_ODR = mask; - pio->PIO_PER = mask; -} - -//------------------------------------------------------------------------------ -/// Configures one or more pin(s) of a PIO controller as outputs, with the -/// given default value. Optionally, the multi-drive feature can be enabled -/// on the pin(s). -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask indicating which pin(s) to configure. -/// \param defaultValue Default level on the pin(s). -/// \param enableMultiDrive Indicates if the pin(s) shall be configured as -/// open-drain. -/// \param enablePullUp Indicates if the pin shall have its pull-up activated. -//------------------------------------------------------------------------------ -static void PIO_SetOutput( - Pio *pio, - unsigned int mask, - unsigned char defaultValue, - unsigned char enableMultiDrive, - unsigned char enablePullUp) -{ - // Disable interrupts - pio->PIO_IDR = mask; - - // Enable pull-up(s) if necessary - if (enablePullUp) { - - pio->PIO_PUER = mask; - } - else { - - pio->PIO_PUDR = mask; - } - - // Enable multi-drive if necessary - if (enableMultiDrive) { - - pio->PIO_MDER = mask; - } - else { - - pio->PIO_MDDR = mask; - } - - // Set default value - if (defaultValue) { - - pio->PIO_SODR = mask; - } - else { - - pio->PIO_CODR = mask; - } - - // Configure pin(s) as output(s) - pio->PIO_OER = mask; - pio->PIO_PER = mask; -} - -//------------------------------------------------------------------------------ -/// Configures interrupt mode for input Pins -/// \param pio Pointer to a PIO controller. -/// \param mask Bitmask indicating which pin(s) to configure. -/// \param additionnalItMode Enable Pio Additionnal It Mode. -/// \param edgeMode Enable the edge mode. -/// \param risingEdgeOrHighLevel Enable IT on rising edge or high level. -//------------------------------------------------------------------------------ -static void PIO_SetInterrupt( - Pio *pio, - unsigned int mask, - unsigned char additionnalItMode, - unsigned char edgeMode, - unsigned char risingEdgeOrHighLevel) -{ - /* Configure the Interrupt mode in the PIO controller */ - if (additionnalItMode) { - /* enable additional interrupt mode */ - pio->PIO_AIMER = mask; - - /* if bit field of selected pin is 1, set as Rising Edge/High level detection event */ - if (risingEdgeOrHighLevel) - pio->PIO_REHLSR = mask; - else - pio->PIO_FELLSR = mask; - - /* if bit field of selected pin is 1, set as edge detection source */ - if (edgeMode) - pio->PIO_ESR = mask; - else - pio->PIO_LSR = mask; - } else { - /* disable additional interrupt mode */ - pio->PIO_AIMDR = mask; - } -} - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Configures a list of Pin instances, each of which can either hold a single -/// pin or a group of pins, depending on the mask value; all pins are configured -/// by this function. The size of the array must also be provided and is easily -/// computed using PIO_LISTSIZE whenever its length is not known in advance. -/// \param list Pointer to a list of Pin instances. -/// \param size Size of the Pin list (calculated using PIO_LISTSIZE). -/// \return 1 if the pins have been configured properly; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char PIO_Configure(const Pin *list, unsigned int size) -{ - // Configure pins - while (size > 0) { - - switch (list->type) { - - case PIO_PERIPH_A: - PIO_SetPeripheralA(list->pio, - list->mask, - (list->attribute & PIO_PULLUP) ? 1 : 0); - break; - - case PIO_PERIPH_B: - PIO_SetPeripheralB(list->pio, - list->mask, - (list->attribute & PIO_PULLUP) ? 1 : 0); - break; - - case PIO_PERIPH_C: - PIO_SetPeripheralC(list->pio, - list->mask, - (list->attribute & PIO_PULLUP) ? 1 : 0); - break; - - case PIO_PERIPH_D: - PIO_SetPeripheralD(list->pio, - list->mask, - (list->attribute & PIO_PULLUP) ? 1 : 0); - break; - case PIO_INPUT: - PMC_EnablePeripheral(list->id); - PIO_SetInput(list->pio, - list->mask, - list->attribute); - PIO_SetInterrupt(list->pio, - list->mask, - (list->attribute & PIO_IT_AIME) ? 1 : 0, - (list->attribute & PIO_IT_EDGE) ? 1 : 0, - (list->attribute & PIO_IT_RE_OR_HL) ? 1 : 0); - break; - - case PIO_OUTPUT_0: - case PIO_OUTPUT_1: - PIO_SetOutput(list->pio, - list->mask, - (list->type == PIO_OUTPUT_1), - (list->attribute & PIO_OPENDRAIN) ? 1 : 0, - (list->attribute & PIO_PULLUP) ? 1 : 0); - break; - - default: return 0; - } - - list++; - size--; - } - - return 1; -} - -//------------------------------------------------------------------------------ -/// Sets a high output level on all the PIOs defined in the given Pin instance. -/// This has no immediate effects on PIOs that are not output, but the PIO -/// controller will memorize the value they are changed to outputs. -/// \param pin Pointer to a Pin instance describing one or more pins. -//------------------------------------------------------------------------------ -void PIO_Set(const Pin *pin) -{ - pin->pio->PIO_SODR = pin->mask; -} - -//------------------------------------------------------------------------------ -/// Sets a low output level on all the PIOs defined in the given Pin instance. -/// This has no immediate effects on PIOs that are not output, but the PIO -/// controller will memorize the value they are changed to outputs. -/// \param pin Pointer to a Pin instance describing one or more pins. -//------------------------------------------------------------------------------ -void PIO_Clear(const Pin *pin) -{ - pin->pio->PIO_CODR = pin->mask; -} - -//------------------------------------------------------------------------------ -/// Returns 1 if one or more PIO of the given Pin instance currently have a high -/// level; otherwise returns 0. This method returns the actual value that is -/// being read on the pin. To return the supposed output value of a pin, use -/// PIO_GetOutputDataStatus() instead. -/// \param pin Pointer to a Pin instance describing one or more pins. -/// \return 1 if the Pin instance contains at least one PIO that currently has -/// a high level; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char PIO_Get(const Pin *pin) -{ - unsigned int reg; - if ((pin->type == PIO_OUTPUT_0) || (pin->type == PIO_OUTPUT_1)) { - - reg = pin->pio->PIO_ODSR; - } - else { - - reg = pin->pio->PIO_PDSR; - } - - if ((reg & pin->mask) == 0) { - - return 0; - } - else { - - return 1; - } -} - - -//------------------------------------------------------------------------------ -/// Returns 1 if one or more PIO of the given Pin are configured to output a -/// high level (even if they are not output). -/// To get the actual value of the pin, use PIO_Get() instead. -/// \param pin Pointer to a Pin instance describing one or more pins. -/// \return 1 if the Pin instance contains at least one PIO that is configured -/// to output a high level; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char PIO_GetOutputDataStatus(const Pin *pin) -{ - if ((pin->pio->PIO_ODSR & pin->mask) == 0) { - - return 0; - } - else { - - return 1; - } -} diff --git a/src/ersky9x/libraries/drivers/pio/pio.h b/src/ersky9x/libraries/drivers/pio/pio.h deleted file mode 100644 index 531b6825b..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio.h +++ /dev/null @@ -1,215 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \file -/// -/// \par Purpose -/// -/// This file provides a basic API for PIO configuration and usage of -/// user-controlled pins. Please refer to the board.h file for a list of -/// available pin definitions. -/// -/// \par Usage -/// -/// -# Define a constant pin description array such as the following one, using -/// the existing definitions provided by the board.h file if possible: -/// \code -/// const Pin pPins[] = {PIN_USART0_TXD, PIN_USART0_RXD}; -/// \endcode -/// Alternatively, it is possible to add new pins by provided the full Pin -/// structure: -/// \code -/// // Pin instance to configure PA10 & PA11 as inputs with the internal -/// // pull-up enabled. -/// const Pin pPins = { -/// (1 << 10) | (1 << 11), -/// REG_PIOA, -/// ID_PIOA, -/// PIO_INPUT, -/// PIO_PULLUP -/// }; -/// \endcode -/// -# Configure a pin array by calling PIO_Configure() with a pointer to the -/// array and its size (which is computed using the PIO_LISTSIZE macro). -/// -# Change and get the value of a user-controlled pin using the PIO_Set, -/// PIO_Clear and PIO_Get methods. -/// -# Get the level being currently output by a user-controlled pin configured -/// as an output using PIO_GetOutputDataStatus(). -//------------------------------------------------------------------------------ - -#ifndef PIO_H -#define PIO_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Global Definitions -//------------------------------------------------------------------------------ - -/// The pin is controlled by the associated signal of peripheral A. -#define PIO_PERIPH_A 0 -/// The pin is controlled by the associated signal of peripheral B. -#define PIO_PERIPH_B 1 -/// The pin is controlled by the associated signal of peripheral C. -#define PIO_PERIPH_C 2 -/// The pin is controlled by the associated signal of peripheral D. -#define PIO_PERIPH_D 3 -/// The pin is an input. -#define PIO_INPUT 4 -/// The pin is an output and has a default level of 0. -#define PIO_OUTPUT_0 5 -/// The pin is an output and has a default level of 1. -#define PIO_OUTPUT_1 6 - -/// Default pin configuration (no attribute). -#define PIO_DEFAULT (0 << 0) -/// The internal pin pull-up is active. -#define PIO_PULLUP (1 << 0) -/// The internal glitch filter is active. -#define PIO_DEGLITCH (1 << 1) -/// The pin is open-drain. -#define PIO_OPENDRAIN (1 << 2) - -/// The internal debouncing filter is active. -#define PIO_DEBOUNCE (1 << 3) - -/// Enable additional interrupt modes. -#define PIO_IT_AIME (1 << 4) - -/// Interrupt High Level/Rising Edge detection is active. -#define PIO_IT_RE_OR_HL (1 << 5) -/// Interrupt Edge detection is active. -#define PIO_IT_EDGE (1 << 6) - -/// Low level interrupt is active -#define PIO_IT_LOW_LEVEL (0 | 0 | PIO_IT_AIME) -/// High level interrupt is active -#define PIO_IT_HIGH_LEVEL (PIO_IT_RE_OR_HL | 0 | PIO_IT_AIME) -/// Falling edge interrupt is active -#define PIO_IT_FALL_EDGE (0 | PIO_IT_EDGE | PIO_IT_AIME) -/// Rising edge interrupt is active -#define PIO_IT_RISE_EDGE (PIO_IT_RE_OR_HL | PIO_IT_EDGE | PIO_IT_AIME) - -//------------------------------------------------------------------------------ -// Global Macros -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Calculates the size of an array of Pin instances. The array must be defined -/// locally (i.e. not a pointer), otherwise the computation will not be correct. -/// \param pPins Local array of Pin instances. -/// \return Number of elements in array. -//------------------------------------------------------------------------------ -#define PIO_LISTSIZE(pPins) (sizeof(pPins) / sizeof(Pin)) - -//------------------------------------------------------------------------------ -// Global Types -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// Describes the type and attribute of one PIO pin or a group of similar pins. -/// The #type# field can have the following values: -/// - PIO_PERIPH_A -/// - PIO_PERIPH_B -/// - PIO_OUTPUT_0 -/// - PIO_OUTPUT_1 -/// - PIO_INPUT -/// -/// The #attribute# field is a bitmask that can either be set to PIO_DEFAULt, -/// or combine (using bitwise OR '|') any number of the following constants: -/// - PIO_PULLUP -/// - PIO_DEGLITCH -/// - PIO_DEBOUNCE -/// - PIO_OPENDRAIN -/// - PIO_IT_LOW_LEVEL -/// - PIO_IT_HIGH_LEVEL -/// - PIO_IT_FALL_EDGE -/// - PIO_IT_RISE_EDGE -//------------------------------------------------------------------------------ -typedef struct { - - /// Bitmask indicating which pin(s) to configure. - unsigned int mask; - /// Pointer to the PIO controller which has the pin(s). - Pio *pio; - /// Peripheral ID of the PIO controller which has the pin(s). - unsigned char id; - /// Pin type. - unsigned char type; - /// Pin attribute. - unsigned char attribute; -} Pin; - -//------------------------------------------------------------------------------ -// Global Access Macros -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// Configures Glitch or Debouncing filter for input -/// \param pin Pointer to a Pin instance describing one or more pins. -/// \param cuttoff Cutt off frequency for debounce filter -//------------------------------------------------------------------------------ -static inline void PIO_SetDebounceFilter( - const Pin *pin, - unsigned int cuttoff) - { - Pio *pio = pin->pio; - - pio->PIO_DIFSR = pin->mask;//set Debouncing, 0 bit field no effect - pio->PIO_SCDR = ((32678/(2*(cuttoff))) - 1) & 0x3FFF;//the lowest 14 bits work -} - - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -extern unsigned char PIO_Configure(const Pin *list, unsigned int size); - -extern void PIO_Set(const Pin *pin); - -extern void PIO_Clear(const Pin *pin); - -extern unsigned char PIO_Get(const Pin *pin); - -//extern unsigned int PIO_GetISR(const Pin *pin); - -extern unsigned char PIO_GetOutputDataStatus(const Pin *pin); - -extern void PIO_EnableDebounce(const Pin *pin, unsigned int clkDiv); - -#endif //#ifndef PIO_H - diff --git a/src/ersky9x/libraries/drivers/pio/pio_it.c b/src/ersky9x/libraries/drivers/pio/pio_it.c deleted file mode 100644 index 760d78a4a..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio_it.c +++ /dev/null @@ -1,411 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// \file - -/// Disable traces for this file -#undef TRACE_LEVEL -#define TRACE_LEVEL 0 - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "pio_it.h" -#include "pio.h" -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Local definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Local types -//------------------------------------------------------------------------------ -/* Define WEAK attribute */ -#if defined ( __CC_ARM ) - #define WEAK __attribute__ ((weak)) -#elif defined ( __ICCARM__ ) - #define WEAK __weak -#elif defined ( __GNUC__ ) - #define WEAK __attribute__ ((weak)) -#endif - - -//------------------------------------------------------------------------------ -// Local variables -//------------------------------------------------------------------------------ -typedef void (*PioHandler) (unsigned char id); - -/* Default PIO handlers defined as weak functions which have to be redefined by - * the application */ -WEAK void PIOA_Irq0Handler(unsigned char id) {} -WEAK void PIOA_Irq1Handler(unsigned char id) {} -WEAK void PIOA_Irq2Handler(unsigned char id) {} -WEAK void PIOA_Irq3Handler(unsigned char id) {} -WEAK void PIOA_Irq4Handler(unsigned char id) {} -WEAK void PIOA_Irq5Handler(unsigned char id) {} -WEAK void PIOA_Irq6Handler(unsigned char id) {} -WEAK void PIOA_Irq7Handler(unsigned char id) {} -WEAK void PIOA_Irq8Handler(unsigned char id) {} -WEAK void PIOA_Irq9Handler(unsigned char id) {} -WEAK void PIOA_Irq10Handler(unsigned char id) {} -WEAK void PIOA_Irq11Handler(unsigned char id) {} -WEAK void PIOA_Irq12Handler(unsigned char id) {} -WEAK void PIOA_Irq13Handler(unsigned char id) {} -WEAK void PIOA_Irq14Handler(unsigned char id) {} -WEAK void PIOA_Irq15Handler(unsigned char id) {} -WEAK void PIOA_Irq16Handler(unsigned char id) {} -WEAK void PIOA_Irq17Handler(unsigned char id) {} -WEAK void PIOA_Irq18Handler(unsigned char id) {} -WEAK void PIOA_Irq19Handler(unsigned char id) {} -WEAK void PIOA_Irq20Handler(unsigned char id) {} -WEAK void PIOA_Irq21Handler(unsigned char id) {} -WEAK void PIOA_Irq22Handler(unsigned char id) {} -WEAK void PIOA_Irq23Handler(unsigned char id) {} -WEAK void PIOA_Irq24Handler(unsigned char id) {} -WEAK void PIOA_Irq25Handler(unsigned char id) {} -WEAK void PIOA_Irq26Handler(unsigned char id) {} -WEAK void PIOA_Irq27Handler(unsigned char id) {} -WEAK void PIOA_Irq28Handler(unsigned char id) {} -WEAK void PIOA_Irq29Handler(unsigned char id) {} -WEAK void PIOA_Irq30Handler(unsigned char id) {} -WEAK void PIOA_Irq31Handler(unsigned char id) {} - - -/** pioAHandlers records ISR routines for each PIO Id for PIO controller A */ -static const PioHandler pioAHandlers[32] = { - (PioHandler) PIOA_Irq0Handler, /**< PA0 IT Handler */ - (PioHandler) PIOA_Irq1Handler, /**< PA1 IT Handler */ - (PioHandler) PIOA_Irq2Handler, /**< PA2 IT Handler */ - (PioHandler) PIOA_Irq3Handler, /**< PA3 IT Handler */ - (PioHandler) PIOA_Irq4Handler, /**< PA4 IT Handler */ - (PioHandler) PIOA_Irq5Handler, /**< PA5 IT Handler */ - (PioHandler) PIOA_Irq6Handler, /**< PA6 IT Handler */ - (PioHandler) PIOA_Irq7Handler, /**< PA7 IT Handler */ - (PioHandler) PIOA_Irq8Handler, /**< PA8 IT Handler */ - (PioHandler) PIOA_Irq9Handler, /**< PA9 IT Handler */ - (PioHandler) PIOA_Irq10Handler, /**< PA10 IT Handler */ - (PioHandler) PIOA_Irq11Handler, /**< PA11 IT Handler */ - (PioHandler) PIOA_Irq12Handler, /**< PA12 IT Handler */ - (PioHandler) PIOA_Irq13Handler, /**< PA13 IT Handler */ - (PioHandler) PIOA_Irq14Handler, /**< PA14 IT Handler */ - (PioHandler) PIOA_Irq15Handler, /**< PA15 IT Handler */ - (PioHandler) PIOA_Irq16Handler, /**< PA16 IT Handler */ - (PioHandler) PIOA_Irq17Handler, /**< PA17 IT Handler */ - (PioHandler) PIOA_Irq18Handler, /**< PA18 IT Handler */ - (PioHandler) PIOA_Irq19Handler, /**< PA19 IT Handler */ - (PioHandler) PIOA_Irq20Handler, /**< PA20 IT Handler */ - (PioHandler) PIOA_Irq21Handler, /**< PA21 IT Handler */ - (PioHandler) PIOA_Irq22Handler, /**< PA22 IT Handler */ - (PioHandler) PIOA_Irq23Handler, /**< PA23 IT Handler */ - (PioHandler) PIOA_Irq24Handler, /**< PA24 IT Handler */ - (PioHandler) PIOA_Irq25Handler, /**< PA25 IT Handler */ - (PioHandler) PIOA_Irq26Handler, /**< PA26 IT Handler */ - (PioHandler) PIOA_Irq27Handler, /**< PA27 IT Handler */ - (PioHandler) PIOA_Irq28Handler, /**< PA28 IT Handler */ - (PioHandler) PIOA_Irq29Handler, /**< PA29 IT Handler */ - (PioHandler) PIOA_Irq30Handler, /**< PA30 IT Handler */ - (PioHandler) PIOA_Irq31Handler /**< PA31 IT Handler */ -}; - -/* Default PIO handlers defined as weak functions which have to be redefined by - * the application */ -WEAK void PIOB_Irq0Handler(unsigned char id) {} -WEAK void PIOB_Irq1Handler(unsigned char id) {} -WEAK void PIOB_Irq2Handler(unsigned char id) {} -WEAK void PIOB_Irq3Handler(unsigned char id) {} -WEAK void PIOB_Irq4Handler(unsigned char id) {} -WEAK void PIOB_Irq5Handler(unsigned char id) {} -WEAK void PIOB_Irq6Handler(unsigned char id) {} -WEAK void PIOB_Irq7Handler(unsigned char id) {} -WEAK void PIOB_Irq8Handler(unsigned char id) {} -WEAK void PIOB_Irq9Handler(unsigned char id) {} -WEAK void PIOB_Irq10Handler(unsigned char id) {} -WEAK void PIOB_Irq11Handler(unsigned char id) {} -WEAK void PIOB_Irq12Handler(unsigned char id) {} -WEAK void PIOB_Irq13Handler(unsigned char id) {} -WEAK void PIOB_Irq14Handler(unsigned char id) {} -WEAK void PIOB_Irq15Handler(unsigned char id) {} -WEAK void PIOB_Irq16Handler(unsigned char id) {} -WEAK void PIOB_Irq17Handler(unsigned char id) {} -WEAK void PIOB_Irq18Handler(unsigned char id) {} -WEAK void PIOB_Irq19Handler(unsigned char id) {} -WEAK void PIOB_Irq20Handler(unsigned char id) {} -WEAK void PIOB_Irq21Handler(unsigned char id) {} -WEAK void PIOB_Irq22Handler(unsigned char id) {} -WEAK void PIOB_Irq23Handler(unsigned char id) {} -WEAK void PIOB_Irq24Handler(unsigned char id) {} -WEAK void PIOB_Irq25Handler(unsigned char id) {} -WEAK void PIOB_Irq26Handler(unsigned char id) {} -WEAK void PIOB_Irq27Handler(unsigned char id) {} -WEAK void PIOB_Irq28Handler(unsigned char id) {} -WEAK void PIOB_Irq29Handler(unsigned char id) {} -WEAK void PIOB_Irq30Handler(unsigned char id) {} -WEAK void PIOB_Irq31Handler(unsigned char id) {} - - -/** PIOBHandlers records ISR routines for each PIO Id for PIO controller A */ -static const PioHandler pioBHandlers[32] = { - (PioHandler) PIOB_Irq0Handler, /**< PB0 IT Handler */ - (PioHandler) PIOB_Irq1Handler, /**< PB1 IT Handler */ - (PioHandler) PIOB_Irq2Handler, /**< PB2 IT Handler */ - (PioHandler) PIOB_Irq3Handler, /**< PB3 IT Handler */ - (PioHandler) PIOB_Irq4Handler, /**< PB4 IT Handler */ - (PioHandler) PIOB_Irq5Handler, /**< PB5 IT Handler */ - (PioHandler) PIOB_Irq6Handler, /**< PB6 IT Handler */ - (PioHandler) PIOB_Irq7Handler, /**< PB7 IT Handler */ - (PioHandler) PIOB_Irq8Handler, /**< PB8 IT Handler */ - (PioHandler) PIOB_Irq9Handler, /**< PB9 IT Handler */ - (PioHandler) PIOB_Irq10Handler, /**< PB10 IT Handler */ - (PioHandler) PIOB_Irq11Handler, /**< PB11 IT Handler */ - (PioHandler) PIOB_Irq12Handler, /**< PB12 IT Handler */ - (PioHandler) PIOB_Irq13Handler, /**< PB13 IT Handler */ - (PioHandler) PIOB_Irq14Handler, /**< PB14 IT Handler */ - (PioHandler) PIOB_Irq15Handler, /**< PB15 IT Handler */ - (PioHandler) PIOB_Irq16Handler, /**< PB16 IT Handler */ - (PioHandler) PIOB_Irq17Handler, /**< PB17 IT Handler */ - (PioHandler) PIOB_Irq18Handler, /**< PB18 IT Handler */ - (PioHandler) PIOB_Irq19Handler, /**< PB19 IT Handler */ - (PioHandler) PIOB_Irq20Handler, /**< PB20 IT Handler */ - (PioHandler) PIOB_Irq21Handler, /**< PB21 IT Handler */ - (PioHandler) PIOB_Irq22Handler, /**< PB22 IT Handler */ - (PioHandler) PIOB_Irq23Handler, /**< PB23 IT Handler */ - (PioHandler) PIOB_Irq24Handler, /**< PB24 IT Handler */ - (PioHandler) PIOB_Irq25Handler, /**< PB25 IT Handler */ - (PioHandler) PIOB_Irq26Handler, /**< PB26 IT Handler */ - (PioHandler) PIOB_Irq27Handler, /**< PB27 IT Handler */ - (PioHandler) PIOB_Irq28Handler, /**< PB28 IT Handler */ - (PioHandler) PIOB_Irq29Handler, /**< PB29 IT Handler */ - (PioHandler) PIOB_Irq30Handler, /**< PB30 IT Handler */ - (PioHandler) PIOB_Irq31Handler /**< PB31 IT Handler */ -}; - -/* Default PIO handlers defined as weak functions which have to be redefined by - * the application */ -WEAK void PIOC_Irq0Handler(unsigned char id) {} -WEAK void PIOC_Irq1Handler(unsigned char id) {} -WEAK void PIOC_Irq2Handler(unsigned char id) {} -WEAK void PIOC_Irq3Handler(unsigned char id) {} -WEAK void PIOC_Irq4Handler(unsigned char id) {} -WEAK void PIOC_Irq5Handler(unsigned char id) {} -WEAK void PIOC_Irq6Handler(unsigned char id) {} -WEAK void PIOC_Irq7Handler(unsigned char id) {} -WEAK void PIOC_Irq8Handler(unsigned char id) {} -WEAK void PIOC_Irq9Handler(unsigned char id) {} -WEAK void PIOC_Irq10Handler(unsigned char id) {} -WEAK void PIOC_Irq11Handler(unsigned char id) {} -WEAK void PIOC_Irq12Handler(unsigned char id) {} -WEAK void PIOC_Irq13Handler(unsigned char id) {} -WEAK void PIOC_Irq14Handler(unsigned char id) {} -WEAK void PIOC_Irq15Handler(unsigned char id) {} -WEAK void PIOC_Irq16Handler(unsigned char id) {} -WEAK void PIOC_Irq17Handler(unsigned char id) {} -WEAK void PIOC_Irq18Handler(unsigned char id) {} -WEAK void PIOC_Irq19Handler(unsigned char id) {} -WEAK void PIOC_Irq20Handler(unsigned char id) {} -WEAK void PIOC_Irq21Handler(unsigned char id) {} -WEAK void PIOC_Irq22Handler(unsigned char id) {} -WEAK void PIOC_Irq23Handler(unsigned char id) {} -WEAK void PIOC_Irq24Handler(unsigned char id) {} -WEAK void PIOC_Irq25Handler(unsigned char id) {} -WEAK void PIOC_Irq26Handler(unsigned char id) {} -WEAK void PIOC_Irq27Handler(unsigned char id) {} -WEAK void PIOC_Irq28Handler(unsigned char id) {} -WEAK void PIOC_Irq29Handler(unsigned char id) {} -WEAK void PIOC_Irq30Handler(unsigned char id) {} -WEAK void PIOC_Irq31Handler(unsigned char id) {} - - -/** PIOCHandlers records ISR routines for each PIO Id for PIO controller A */ -static const PioHandler pioCHandlers[32] = { - (PioHandler) PIOC_Irq0Handler, /**< PC0 IT Handler */ - (PioHandler) PIOC_Irq1Handler, /**< PC1 IT Handler */ - (PioHandler) PIOC_Irq2Handler, /**< PC2 IT Handler */ - (PioHandler) PIOC_Irq3Handler, /**< PC3 IT Handler */ - (PioHandler) PIOC_Irq4Handler, /**< PC4 IT Handler */ - (PioHandler) PIOC_Irq5Handler, /**< PC5 IT Handler */ - (PioHandler) PIOC_Irq6Handler, /**< PC6 IT Handler */ - (PioHandler) PIOC_Irq7Handler, /**< PC7 IT Handler */ - (PioHandler) PIOC_Irq8Handler, /**< PC8 IT Handler */ - (PioHandler) PIOC_Irq9Handler, /**< PC9 IT Handler */ - (PioHandler) PIOC_Irq10Handler, /**< PC10 IT Handler */ - (PioHandler) PIOC_Irq11Handler, /**< PC11 IT Handler */ - (PioHandler) PIOC_Irq12Handler, /**< PC12 IT Handler */ - (PioHandler) PIOC_Irq13Handler, /**< PC13 IT Handler */ - (PioHandler) PIOC_Irq14Handler, /**< PC14 IT Handler */ - (PioHandler) PIOC_Irq15Handler, /**< PC15 IT Handler */ - (PioHandler) PIOC_Irq16Handler, /**< PC16 IT Handler */ - (PioHandler) PIOC_Irq17Handler, /**< PC17 IT Handler */ - (PioHandler) PIOC_Irq18Handler, /**< PC18 IT Handler */ - (PioHandler) PIOC_Irq19Handler, /**< PC19 IT Handler */ - (PioHandler) PIOC_Irq20Handler, /**< PC20 IT Handler */ - (PioHandler) PIOC_Irq21Handler, /**< PC21 IT Handler */ - (PioHandler) PIOC_Irq22Handler, /**< PC22 IT Handler */ - (PioHandler) PIOC_Irq23Handler, /**< PC23 IT Handler */ - (PioHandler) PIOC_Irq24Handler, /**< PC24 IT Handler */ - (PioHandler) PIOC_Irq25Handler, /**< PC25 IT Handler */ - (PioHandler) PIOC_Irq26Handler, /**< PC26 IT Handler */ - (PioHandler) PIOC_Irq27Handler, /**< PC27 IT Handler */ - (PioHandler) PIOC_Irq28Handler, /**< PC28 IT Handler */ - (PioHandler) PIOC_Irq29Handler, /**< PC29 IT Handler */ - (PioHandler) PIOC_Irq30Handler, /**< PC30 IT Handler */ - (PioHandler) PIOC_Irq31Handler /**< PC31 IT Handler */ -}; - -//------------------------------------------------------------------------------ -/// \brief Generic PIO Handler. -/// The NVIC branches to the PIOx_IrqHandler() registered in exeption.c -/// PIOx_IrqHandler() invokes PIO_IrqHandler which scans which id has triggered -/// an interrupt and call the corresponding routine for the Id (<=> for the pin) -/// \param pPio PIO controller base address. -/// \param pPioHandlers Constant table which contains IT routines for each PIO Id -//------------------------------------------------------------------------------ -static void PIO_IrqHandler(Pio *pPio, const PioHandler *pPioHandlers) -{ - unsigned int status, id; - - status = pPio->PIO_ISR; - status &= pPio->PIO_IMR; - - for (id = 0; id < 32; ++id) { - if (status & (1 << id)) { - pPioHandlers[id](id); - } - } - -} - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller A interrupt handler -/// Redefined PIOA interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -void PIOA_IrqHandler(void) -{ - PIO_IrqHandler(PIOA, pioAHandlers); -} - -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller B interrupt handler -/// Redefined PIOB interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -void PIOB_IrqHandler(void) -{ - PIO_IrqHandler(PIOB, pioBHandlers); -} - -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller C interrupt handler -/// Redefined PIOC interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -void PIOC_IrqHandler(void) -{ - PIO_IrqHandler(PIOC, pioCHandlers); -} - -//------------------------------------------------------------------------------ -/// Enables the given interrupt source. The status -/// register of the corresponding PIO controller is cleared prior to enabling -/// the interrupt. -/// \param pPin Interrupt source to enable. -//------------------------------------------------------------------------------ -void PIO_EnableIt(const Pin *pPin) -{ - Pio* pio = pPin->pio; - TRACE_DEBUG("PIO_EnableIt()\n\r"); - -// SANITY_CHECK(pPin); - - /* Enable the interrupt in the PIO controller */ - pio->PIO_ISR; - pio->PIO_IER = pPin->mask; - - -} - -//------------------------------------------------------------------------------ -/// Disables a given interrupt source, with no added side effects. -/// \param pPin Interrupt source to disable. -//------------------------------------------------------------------------------ -void PIO_DisableIt(const Pin *pPin) -{ - Pio* pio = pPin->pio; - SANITY_CHECK(pPin); - - TRACE_DEBUG("PIO_DisableIt()\n\r"); - - /* Disable the interrupt in the PIO controller */ - pio->PIO_IDR = pPin->mask; -} - -//------------------------------------------------------------------------------ -/// \brief Initializes the PIO interrupt management logic -/// The desired priority of PIO interrupts must be provided. -/// Calling this function multiple times result in the reset of currently -/// configured interrupts. -/// \param priority PIO controller interrupts priority. -//------------------------------------------------------------------------------ -void PIO_InitializeInterrupts(unsigned int priority) -{ - TRACE_DEBUG("PIO_Initialize()\n\r"); - - // Configure PIO interrupt sources - TRACE_DEBUG("PIO_Initialize: Configuring PIOA\n\r"); - PIOA->PIO_ISR; - PIOA->PIO_IDR = 0xFFFFFFFF; - NVIC_DisableIRQ(PIOA_IRQn); - NVIC_ClearPendingIRQ(PIOA_IRQn); - NVIC_SetPriority(PIOA_IRQn, priority); - NVIC_EnableIRQ(PIOA_IRQn); - - TRACE_DEBUG("PIO_Initialize: Configuring PIOB\n\r"); - PIOB->PIO_ISR; - PIOB->PIO_IDR = 0xFFFFFFFF; - NVIC_DisableIRQ(PIOB_IRQn); - NVIC_ClearPendingIRQ(PIOB_IRQn); - NVIC_SetPriority(PIOB_IRQn, priority); - NVIC_EnableIRQ(PIOB_IRQn); - - TRACE_DEBUG("PIO_Initialize: Configuring PIOC\n\r"); - PIOC->PIO_ISR; - PIOC->PIO_IDR = 0xFFFFFFFF; - NVIC_DisableIRQ(PIOC_IRQn); - NVIC_ClearPendingIRQ(PIOC_IRQn); - NVIC_SetPriority(PIOC_IRQn, priority); - NVIC_EnableIRQ(PIOC_IRQn); -} diff --git a/src/ersky9x/libraries/drivers/pio/pio_it.h b/src/ersky9x/libraries/drivers/pio/pio_it.h deleted file mode 100644 index 15c0d5fc7..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio_it.h +++ /dev/null @@ -1,153 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \file -/// -/// \par Purpose -/// -/// Configuration and handling of interrupts on PIO status changes. The API -/// provided here have several advantages over the traditional PIO interrupt -/// configuration approach: -/// - It is highly portable -/// - It automatically demultiplexes interrupts when multiples pins have been -/// configured on a single PIO controller -/// - It allows a group of pins to share the same interrupt -/// -/// However, it also has several minor drawbacks that may prevent from using it -/// in particular applications: -/// - It enables the clocks of all PIO controllers -/// - PIO controllers all share the same interrupt handler, which does the -/// demultiplexing and can be slower than direct configuration -/// - It reserves space for a fixed number of interrupts, which can be -/// increased by modifying the appropriate constant in pio_it.c. -/// -/// \par Usage -/// -/// -# Initialize the PIO interrupt mechanism using PIO_InitializeInterrupts() -/// with the desired priority (0 ... 7). -/// -# Configure a status change interrupt on one or more pin(s) with -/// PIO_ConfigureIt(). -/// -# Enable & disable interrupts on pins using PIO_EnableIt() and -/// PIO_DisableIt(). -//------------------------------------------------------------------------------ - -#ifndef PIO_IT_H -#define PIO_IT_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "pio.h" - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// \file - -/// Disable traces for this file -#undef TRACE_LEVEL -#define TRACE_LEVEL 0 - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "pio_it.h" -#include "pio.h" - -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller A interrupt handler -/// Redefined PIOA interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -extern void PIOA_IrqHandler(void); -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller B interrupt handler -/// Redefined PIOB interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -extern void PIOB_IrqHandler(void); -//------------------------------------------------------------------------------ -/// \brief Parallel IO Controller C interrupt handler -/// Redefined PIOC interrupt handler for NVIC interrupt table. -//------------------------------------------------------------------------------ -extern void PIOC_IrqHandler(void); -//------------------------------------------------------------------------------ -/// Configures and enables the given interrupt source. The status -/// register of the corresponding PIO controller is cleared prior to enabling -/// the interrupt. -/// \param pPin Interrupt source to enable. -//------------------------------------------------------------------------------ -extern void PIO_EnableIt(const Pin *pPin); -//------------------------------------------------------------------------------ -/// Disables a given interrupt source, with no added side effects. -/// \param pPin Interrupt source to disable. -//------------------------------------------------------------------------------ -extern void PIO_DisableIt(const Pin *pPin); -//------------------------------------------------------------------------------ -/// \brief Initializes the PIO interrupt management logic -/// The desired priority of PIO interrupts must be provided. -/// Calling this function multiple times result in the reset of currently -/// configured interrupts. -/// \param priority PIO controller interrupts priority. -//------------------------------------------------------------------------------ -extern void PIO_InitializeInterrupts(unsigned int priority); - -#endif //#ifndef PIO_IT_H - diff --git a/src/ersky9x/libraries/drivers/pio/pio_keypad.c b/src/ersky9x/libraries/drivers/pio/pio_keypad.c deleted file mode 100644 index e617289ea..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio_keypad.c +++ /dev/null @@ -1,147 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "pio.h" -#include "pio_keypad.h" - - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Configures keypad controller -/// \param pPIO Pointer to a PIO instance -/// \param config Configuration data for given pin,see head file for detail -//------------------------------------------------------------------------------ -void PIO_KeyPadConfig(AT91S_PIO *pPIO, KeyPadConfig *config) -{ - //enable/disable keypad controller - pPIO->PIO_KER = config->enable; - - //if enable, set keypad matrix and debouncing - if(config->enable == TRUE) { - //set key matrix - pPIO->PIO_KRCR = (config->row | config->col<<8) ; - - //set debouncing - pPIO->PIO_KDR = config->debouncing; - - } -} - - -//------------------------------------------------------------------------------ -/// Get Key Press/Release status -/// \param pPIO Pointer to a PIO instance -/// \param event Pointer to a instance of KeyEvent for storing keypad status -//------------------------------------------------------------------------------ -void PIO_GetKeyStatus(AT91S_PIO *pPIO, KeyEvent *event) -{ - int i,j; - - //get key press event - event->kdEvent.press = (pPIO->KSR&0x1)?TRUE:FALSE; - event->kdEvent.keyPressNum = (pPIO->KSR>>8)&0x3; - j=event->kdEvent.keyPressNum+1; - for(i=0; ikdEvent.preKeyMatrix[i].row = ((pPIO->KKPR) >> (8*i)) & 0x7; - event->kdEvent.preKeyMatrix[i].col = ((pPIO->KKPR) >> (8*i+4)) & 0x7; - } - - //get key release event - event->kuEvent.release = ((pPIO->KSR>>1) & 0x1)?TRUE:FALSE; - event->kuEvent.keyRelNum = (pPIO->KSR>>16)&0x3; - j=event->kdEvent.keyPressNum+1; - for(i=0;ikuEvent.relKeyMatrix[i].row = ((pPIO->KKRR) >> (8*i)) & 0x7; - event->kuEvent.relKeyMatrix[i].col = ((pPIO->KKRR) >> (8*i+4)) & 0x7; - } - -} - - -//------------------------------------------------------------------------------ -/// Enable keypad interrupt as Key Press Interrupt or Key Release Interrupt or both -/// \param pPIO Pointer to a PIO instance -/// \param mode Select key interrupt mode to enable, -/// 0x1 Key Press Interrupt -/// 0x2 Key Release Interrupt -/// 0x3 both of two type -//------------------------------------------------------------------------------ -void PIO_KeypadEnableIt(AT91S_PIO *pPIO, unsigned int mode) -{ - switch(mode){ - case 1:PIO_KeyPadEnableKPIt(pPIO); - break; - - case 2:PIO_KeyPadEnableKRIt(pPIO); - break; - - case 3:PIO_KeyPadEnableKPIt(pPIO); - PIO_KeyPadEnableKRIt(pPIO); - break; - - default:break; - } - -} - -//------------------------------------------------------------------------------ -/// Disable Key Press Interrupt or Key Release Interrupt or both of them -/// \param pPIO Pointer to a PIO instance -/// \param mode Select key interrupt mode to disable, -/// 0x1 Key Press Interrupt -/// 0x2 Key Release Interrupt -/// 0x3 both of two type -//------------------------------------------------------------------------------ -void PIO_KeypadDisableIt(AT91S_PIO *pPIO, unsigned int mode) -{ - switch(mode){ - case 1:PIO_KeyPadDisableKPIt(pPIO); - break; - - case 2:PIO_KeyPadDisableKRIt(pPIO); - break; - - case 3:PIO_KeyPadDisableKPIt(pPIO); - PIO_KeyPadDisableKRIt(pPIO); - break; - - default:break; - } - -} - - diff --git a/src/ersky9x/libraries/drivers/pio/pio_keypad.h b/src/ersky9x/libraries/drivers/pio/pio_keypad.h deleted file mode 100644 index 166f06680..000000000 --- a/src/ersky9x/libraries/drivers/pio/pio_keypad.h +++ /dev/null @@ -1,153 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef PIO_KEYPAD_H -#define PIO_KEYPAD_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Global Definitions -//------------------------------------------------------------------------------ - - - - -//------------------------------------------------------------------------------ -// Global Macros -//------------------------------------------------------------------------------ -//enable keypad press interrupt -#define PIO_KeyPadEnableKPIt(pPIO) ((pPIO)->KIER = 1<<0) - -//enable keypad release interrupt -#define PIO_KeyPadEnableKRIt(pPIO) ((pPIO)->KIER = 1<<1) - -//disable keypad press interrupt -#define PIO_KeyPadDisableKPIt(pPIO) ((pPIO)->KIDR = 1<<0) - -//disable keypad release interrupt -#define PIO_KeyPadDisableKRIt(pPIO) ((pPIO)->KIDR = 1<<1) - -//enable keypad controller interrupt -#define PIO_KeyPadEnableIt(pPIO, mode) {switch(mode):\ - case 1:PIO_KeyPadEnableKPIt(pPIO);break;\ - case 2:PIO_KeyPadEnableKRIt(pPIO);break;\ - case 3:PIO_KeyPadEnableKPIt(pPIO);\ - PIO_KeyPadEnableKRIt(pPIO);break;\ - default:break;\ - } - -//disable keypad controller interrupt -#define PIO_KeyPadDisableIt(pPIO, mode) {switch(mode):\ - case 1:PIO_KeyPadDisableKPIt(pPIO);break;\ - case 2:PIO_KeyPadDisableKRIt(pPIO);break;\ - case 3:PIO_KeyPadDisableKPIt(pPIO);\ - PIO_KeyPadDisableKRIt(pPIO);break;\ - default:break;\ - } - -//get keypad controller interrupt mask -#define PIO_KeyPadGetItMask(pPIO) ((pPIO)->PIO_KIMR) - - -//------------------------------------------------------------------------------ -/// Calculates the size of an array of Pin instances. The array must be defined -/// locally (i.e. not a pointer), otherwise the computation will not be correct. -/// \param pPins Local array of Pin instances. -/// \return Number of elements in array. -//------------------------------------------------------------------------------ -#define PIO_LISTSIZE(pPins) (sizeof(pPins) / sizeof(Pin)) - -//------------------------------------------------------------------------------ -// Global Types -//------------------------------------------------------------------------------ -typedef enum { - FALSE, - TRUE -} bool; - -typedef struct _KeyPadConfig { - bool enable;//keypad controller enable or disable - unsigned char col:3;//config column size - unsigned char row:3;//config row size - unsigned int debouncing;//config debouncing -} KeyPadConfig; - - -typedef struct _KeyColRow { - unsigned char row:3; - unsigned char col:3; -} KeyColRow; - - -typedef struct _KeyDownEvent { - bool press;//at least 1 pressed key detected, or 0 - unsigned char keyPressNum;//simultaneously pressed key number - KeyColRow preKeyMatrix[4];//pressed key matrix -} KeyDownEvent; - - - -typedef struct _KeyUpEvent { - bool release;//at least 1 released key detected, or 0 - unsigned char keyRelNum;//simultaneously released key number - KeyColRow relKeyMatrix[4];//released key matrix -} KeyUpEvent; - - - -typedef struct _KeyEvent { - KeyDownEvent kdEvent; - KeyUpEvent kuEvent; -} KeyEvent; - -//------------------------------------------------------------------------------ -// Global Access Macros -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -void PIO_KeyPadConfig(AT91S_PIO *pPIO, KeyPadConfig *config); - -void PIO_GetKeyStatus(AT91S_PIO *pPIO, KeyEvent *event); - -void PIO_KeypadEnableIt(AT91S_PIO *pio, unsigned int mode); - -void PIO_KeypadDisableIt(AT91S_PIO *pio, unsigned int mode); - - -#endif //#ifndef PIO_KEYPAD_H - diff --git a/src/ersky9x/libraries/drivers/pmc/pmc.c b/src/ersky9x/libraries/drivers/pmc/pmc.c deleted file mode 100644 index 4c3d58a11..000000000 --- a/src/ersky9x/libraries/drivers/pmc/pmc.c +++ /dev/null @@ -1,143 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "pmc.h" -#include -#include - -//------------------------------------------------------------------------------ -// Local definitions -//------------------------------------------------------------------------------ -#define MASK_STATUS0 0xFFFFFFFC -#define MASK_STATUS1 0xFFFFFFFF - - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Enables the clock of a peripheral. The peripheral ID is used - * to identify which peripheral is targetted. - * \note The ID must NOT be shifted (i.e. 1 << ID_xxx). - * \param id Peripheral ID (ID_xxx). - */ -void PMC_EnablePeripheral(unsigned int id) -{ - SANITY_CHECK(id < 35); - if (id < 32) { - if ((PMC->PMC_PCSR0 & (1 << id)) == (1 << id)) { - - TRACE_DEBUG("PMC_EnablePeripheral: clock of peripheral" " %u is already enabled\n\r", id); - } - else { - PMC->PMC_PCER0 = 1 << id; - } - } - else { - id -= 32; - if ((PMC->PMC_PCSR1 & (1 << id)) == (1 << id)) { - - TRACE_DEBUG("PMC_EnablePeripheral: clock of peripheral" " %u is already enabled\n\r", id + 32); - } - else { - PMC->PMC_PCER1 = 1 << id; - } - } -} - -/** - * \brief Disables the clock of a peripheral. The peripheral ID is used - * to identify which peripheral is targetted. - * \note The ID must NOT be shifted (i.e. 1 << ID_xxx). - * \param id Peripheral ID (ID_xxx). - */ -void PMC_DisablePeripheral(unsigned int id) -{ - SANITY_CHECK(id < 35); - if (id < 32) { - if ((PMC->PMC_PCSR0 & (1 << id)) != (1 << id)) { - TRACE_DEBUG("PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", id); - } - else { - PMC->PMC_PCDR0 = 1 << id; - } - } - else { - id -= 32; - if ((PMC->PMC_PCSR1 & (1 << id)) != (1 << id)) { - TRACE_DEBUG("PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", id + 32); - } - else { - PMC->PMC_PCDR1 = 1 << id; - } - } -} - -/** - * \brief Enable all the periph clock via PMC - */ -void PMC_EnableAllPeripherals(void) -{ - PMC->PMC_PCER0 = MASK_STATUS0; - while( (PMC->PMC_PCSR0 & MASK_STATUS0) != MASK_STATUS0); - PMC->PMC_PCER1 = MASK_STATUS1; - while( (PMC->PMC_PCSR1 & MASK_STATUS1) != MASK_STATUS1); - TRACE_DEBUG("Enable all periph clocks\n\r"); -} -/** - * \brief Disable all the periph clock via PMC - */ -void PMC_DisableAllPeripherals(void) -{ - PMC->PMC_PCDR0 = MASK_STATUS0; - while((PMC->PMC_PCSR0 & MASK_STATUS0) != 0); - PMC->PMC_PCDR1 = MASK_STATUS1; - while((PMC->PMC_PCSR1 & MASK_STATUS1) != 0); - TRACE_DEBUG("Disable all periph clocks\n\r"); -} - -/** - * \brief Get Periph Status for the given peripheral ID. - * \param id Peripheral ID (ID_xxx). - */ -unsigned int PMC_IsPeriphEnabled(unsigned int id) -{ - SANITY_CHECK(id < 35); - if (id < 32) { - return (PMC->PMC_PCSR0 & (1 << id)); - } - else { - return (PMC->PMC_PCSR1 & (1 << (id - 32))); - } -} diff --git a/src/ersky9x/libraries/drivers/pmc/pmc.h b/src/ersky9x/libraries/drivers/pmc/pmc.h deleted file mode 100644 index a53b36561..000000000 --- a/src/ersky9x/libraries/drivers/pmc/pmc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef PMC_H -#define PMC_H - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -#if defined(at91sam7l64) || defined(at91sam7l128) -extern void PMC_SetFastWakeUpInputs(unsigned int inputs); -extern void PMC_DisableMainOscillator(void); -extern -#ifdef __ICCARM__ -__ramfunc -#endif //__ICCARM__ -void PMC_DisableMainOscillatorForWaitMode(void); -#endif // at91sam7l64 at91sam7l128 - -extern void PMC_DisableProcessorClock(void); -extern void PMC_EnablePeripheral(unsigned int id); -extern void PMC_DisablePeripheral(unsigned int id); -extern void PMC_CPUInIdleMode(void); - - -extern void PMC_EnableAllPeripherals(void); - -extern void PMC_DisableAllPeripherals(void); - -extern unsigned int PMC_IsAllPeriphEnabled(void); - -extern unsigned int PMC_IsPeriphEnabled(unsigned int id); - -#endif //#ifndef PMC_H - diff --git a/src/ersky9x/libraries/drivers/pwmc/pwmc.c b/src/ersky9x/libraries/drivers/pwmc/pwmc.c deleted file mode 100644 index 00062922a..000000000 --- a/src/ersky9x/libraries/drivers/pwmc/pwmc.c +++ /dev/null @@ -1,648 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup pwm_module Working with PWM - * The PWM driver provides the interface to configure and use the PWM - * peripheral. - * - * The PWM macrocell controls square output waveforms of 4 channels. - * Characteristics of output waveforms such as period, duty-cycle, - * dead-time can be configured.\n - * Some of PWM channels can be linked together as synchronous channel and - * duty-cycle of synchronous channels can be updated by PDC automaticly. - * - * Before enabling the channels, they must have been configured first. - * The main settings include: - *
    - *
  • Configuration of the clock generator.
  • - *
  • Selection of the clock for each channel.
  • - *
  • Configuration of output waveform characteristics, such as period, duty-cycle etc.
  • - *
  • Configuration for synchronous channels if needed.
  • - * - Selection of the synchronous channels. - * - Selection of the moment when the WRDY flag and the corresponding PDC - * transfer request are set (PTRM and PTRCS in the PWM_SCM register). - * - Configuration of the update mode (UPDM in the PWM_SCM register). - * - Configuration of the update period (UPR in the PWM_SCUP register). - *
- * - * After the channels is enabled, the user must use respective update registers - * to change the wave characteristics to prevent unexpected output waveform. - * i.e. PWM_CDTYUPDx register should be used if user want to change duty-cycle - * when the channel is enabled. - * - * For more accurate information, please look at the PWM section of the - * Datasheet. - * - * Related files :\n - * \ref pwmc.c\n - * \ref pwmc.h.\n - */ -/*@{*/ -/*@}*/ - -/** - * \file - * - * Implementation of the Pulse Width Modulation Controller (PWM) peripheral. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */ -#include - -#include "pwmc.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Finds a prescaler/divisor couple to generate the desired frequency - * from MCK. - * - * Returns the value to enter in PWM_CLK or 0 if the configuration cannot be - * met. - * - * \param frequency Desired frequency in Hz. - * \param mck Master clock frequency in Hz. - */ -static uint16_t FindClockConfiguration( - uint32_t frequency, - uint32_t mck) -{ - uint32_t divisors[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}; - uint8_t divisor = 0; - uint32_t prescaler; - - SANITY_CHECK(frequency < mck); - - /* Find prescaler and divisor values */ - prescaler = (mck / divisors[divisor]) / frequency; - while ((prescaler > 255) && (divisor < 11)) { - - divisor++; - prescaler = (mck / divisors[divisor]) / frequency; - } - - /* Return result */ - if (divisor < 11) { - - TRACE_DEBUG("Found divisor=%u and prescaler=%u for freq=%uHz\n\r", - divisors[divisor], prescaler, frequency); - return prescaler | (divisor << 8); - } - else { - - return 0; - } -} - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Configures PWM a channel with the given parameters, basic configure function. - * - * The PWM controller must have been clocked in the PMC prior to calling this - * function. - * Beware: this function disables the channel. It waits until disable is effective. - * - * \param channel Channel number. - * \param prescaler Channel prescaler. - * \param alignment Channel alignment. - * \param polarity Channel polarity. - */ -void PWMC_ConfigureChannel( - uint8_t channel, - uint32_t prescaler, - uint32_t alignment, - uint32_t polarity) -{ - SANITY_CHECK(prescaler < PWM_CMR0_CPRE_MCKB); - SANITY_CHECK((alignment & ~PWM_CMR0_CALG) == 0); - SANITY_CHECK((polarity & ~PWM_CMR0_CPOL) == 0); - - /* Disable channel (effective at the end of the current period) */ - if ((PWM->PWM_SR & (1 << channel)) != 0) { - PWM->PWM_DIS = 1 << channel; - while ((PWM->PWM_SR & (1 << channel)) != 0); - } - - /* Configure channel */ - PWM->PWM_CH_NUM[channel].PWM_CMR = prescaler | alignment | polarity; -} - -/** - * \brief Configures PWM a channel with the given parameters, extend configure function. - * - * The PWM controller must have been clocked in the PMC prior to calling this - * function. - * Beware: this function disables the channel. It waits until disable is effective. - * - * \param channel Channel number. - * \param prescaler Channel prescaler. - * \param alignment Channel alignment. - * \param polarity Channel polarity. - * \param countEventSelect Channel counter event selection. - * \param DTEnable Channel dead time generator enable. - * \param DTHInverte Channel Dead-Time PWMHx output Inverted. - * \param DTLInverte Channel Dead-Time PWMHx output Inverted. - */ -void PWMC_ConfigureChannelExt( - uint8_t channel, - uint32_t prescaler, - uint32_t alignment, - uint32_t polarity, - uint32_t countEventSelect, - uint32_t DTEnable, - uint32_t DTHInverte, - uint32_t DTLInverte) -{ - SANITY_CHECK(prescaler < PWM_CMR0_CPRE_MCKB); - SANITY_CHECK((alignment & ~PWM_CMR0_CALG) == 0); - SANITY_CHECK((polarity & ~PWM_CMR0_CPOL) == 0); - SANITY_CHECK((countEventSelect & ~PWM_CMR0_CES) == 0); - SANITY_CHECK((DTEnable & ~PWM_CMR0_DTE) == 0); - SANITY_CHECK((DTHInverte & ~PWM_CMR0_DTHI) == 0); - SANITY_CHECK((DTLInverte & ~PWM_CMR0_DTLI) == 0); - - /* Disable channel (effective at the end of the current period) */ - if ((PWM->PWM_SR & (1 << channel)) != 0) { - PWM->PWM_DIS = 1 << channel; - while ((PWM->PWM_SR & (1 << channel)) != 0); - } - - /* Configure channel */ - PWM->PWM_CH_NUM[channel].PWM_CMR = prescaler | alignment | polarity | - countEventSelect | DTEnable | DTHInverte | DTLInverte; -} - -/** - * \brief Configures PWM clocks A & B to run at the given frequencies. - * - * This function finds the best MCK divisor and prescaler values automatically. - * - * \param clka Desired clock A frequency (0 if not used). - * \param clkb Desired clock B frequency (0 if not used). - * \param mck Master clock frequency. - */ -void PWMC_ConfigureClocks(uint32_t clka, uint32_t clkb, uint32_t mck) -{ - uint32_t mode = 0; - uint32_t result; - - /* Clock A */ - if (clka != 0) { - - result = FindClockConfiguration(clka, mck); - ASSERT(result != 0, "-F- Could not generate the desired PWM frequency (%uHz)\n\r", (unsigned int)clka); - mode |= result; - } - - /* Clock B */ - if (clkb != 0) { - - result = FindClockConfiguration(clkb, mck); - ASSERT(result != 0, "-F- Could not generate the desired PWM frequency (%uHz)\n\r", (unsigned int)clkb); - mode |= (result << 16); - } - - /* Configure clocks */ - TRACE_DEBUG("Setting PWM_CLK = 0x%08X\n\r", mode); - PWM->PWM_CLK = mode; -} - -/** - * \brief Sets the period value used by a PWM channel. - * - * This function writes directly to the CPRD register if the channel is disabled; - * otherwise, it uses the update register CPRDUPD. - * - * \param channel Channel number. - * \param period Period value. - */ -void PWMC_SetPeriod(uint8_t channel, uint16_t period) -{ - /* If channel is disabled, write to CPRD */ - if ((PWM->PWM_SR & (1 << channel)) == 0) { - - PWM->PWM_CH_NUM[channel].PWM_CPRD = period; - } - /* Otherwise use update register */ - else { - - PWM->PWM_CH_NUM[channel].PWM_CPRDUPD = period; - } -} - -/** - * \brief Sets the duty cycle used by a PWM channel. - * This function writes directly to the CDTY register if the channel is disabled; - * otherwise it uses the update register CDTYUPD. - * Note that the duty cycle must always be inferior or equal to the channel - * period. - * - * \param channel Channel number. - * \param duty Duty cycle value. - */ -void PWMC_SetDutyCycle(uint8_t channel, uint16_t duty) -{ - SANITY_CHECK(duty <= PWM->PWM_CH_NUM[channel].PWM_CPRD); - - /* If channel is disabled, write to CDTY */ - if ((PWM->PWM_SR & (1 << channel)) == 0) { - - PWM->PWM_CH_NUM[channel].PWM_CDTY = duty; - } - /* Otherwise use update register */ - else { - - PWM->PWM_CH_NUM[channel].PWM_CDTYUPD = duty; - } -} - -/** - * \brief Sets the dead time used by a PWM channel. - * This function writes directly to the DT register if the channel is disabled; - * otherwise it uses the update register DTUPD. - * Note that the dead time must always be inferior or equal to the channel - * period. - * - * \param channel Channel number. - * \param timeH Dead time value for PWMHx output. - * \param timeL Dead time value for PWMLx output. - */ -void PWMC_SetDeadTime(uint8_t channel, uint16_t timeH, uint16_t timeL) -{ - SANITY_CHECK(timeH <= PWM->PWM_CH_NUM[channel].PWM_CPRD); - SANITY_CHECK(timeL <= PWM->PWM_CH_NUM[channel].PWM_CPRD); - - /* If channel is disabled, write to DT */ - if ((PWM->PWM_SR & (1 << channel)) == 0) { - - PWM->PWM_CH_NUM[channel].PWM_DT = timeH | (timeL << 16); - } - /* Otherwise use update register */ - else { - PWM->PWM_CH_NUM[channel].PWM_DTUPD = timeH | (timeL << 16); - } -} - -/** - * \brief Configures Syncronous channel with the given parameters. - * Beware: At this time, the channels should be disabled. - * - * \param channels Bitwise OR of Syncronous channels. - * \param updateMode Syncronous channel update mode. - * \param requestMode PDC transfer request mode. - * \param requestComparisonSelect PDC transfer request comparison selection. - */ -void PWMC_ConfigureSyncChannel( - uint32_t channels, - uint32_t updateMode, - uint32_t requestMode, - uint32_t requestComparisonSelect) -{ - PWM->PWM_SCM = channels | updateMode | requestMode - | requestComparisonSelect; -} - -/** - * \brief Sets the update period of the synchronous channels. - * This function writes directly to the SCUP register if the channel #0 is disabled; - * otherwise it uses the update register SCUPUPD. - * - * \param period update period. - */ -void PWMC_SetSyncChannelUpdatePeriod(uint8_t period) -{ - /* If channel is disabled, write to SCUP */ - if ((PWM->PWM_SR & (1 << 0)) == 0) { - - PWM->PWM_SCUP = period; - } - /* Otherwise use update register */ - else { - - PWM->PWM_SCUPUPD = period; - } -} - -/** - * \brief Sets synchronous channels update unlock. - * - * Note: If the UPDM field is set to 0, writing the UPDULOCK bit to 1 - * triggers the update of the period value, the duty-cycle and - * the dead-time values of synchronous channels at the beginning - * of the next PWM period. If the field UPDM is set to 1 or 2, - * writing the UPDULOCK bit to 1 triggers only the update of - * the period value and of the dead-time values of synchronous channels. - * This bit is automatically reset when the update is done. - */ -void PWMC_SetSyncChannelUpdateUnlock(void) -{ - PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; -} - -/** - * \brief Enables the given PWM channel. - * - * This does NOT enable the corresponding pin;this must be done in the user code. - * - * \param channel Channel number. - */ -void PWMC_EnableChannel(uint8_t channel) -{ - PWM->PWM_ENA = 1 << channel; -} - -/** - * \brief Disables the given PWM channel. - * - * Beware, channel will be effectively disabled at the end of the current period. - * Application can check channel is disabled using the following wait loop: - * while ((PWM->PWM_SR & (1 << channel)) != 0); - * - * \param channel Channel number. - */ -void PWMC_DisableChannel(uint8_t channel) -{ - PWM->PWM_DIS = 1 << channel; -} - -/** - * \brief Enables the period interrupt for the given PWM channel. - * - * \param channel Channel number. - */ -void PWMC_EnableChannelIt(uint8_t channel) -{ - PWM->PWM_IER1 = 1 << channel; -} - -/** - * \brief Disables the period interrupt for the given PWM channel. - * - * \param channel Channel number. - */ -void PWMC_DisableChannelIt(uint8_t channel) -{ - PWM->PWM_IDR1 = 1 << channel; -} - -/** - * \brief Enables the selected interrupts sources on a PWMC peripheral. - * - * \param sources1 Bitwise OR of selected interrupt sources of PWM_IER1. - * \param sources2 Bitwise OR of selected interrupt sources of PWM_IER2. - */ -void PWMC_EnableIt(uint32_t sources1, uint32_t sources2) -{ - PWM->PWM_IER1 = sources1; - PWM->PWM_IER2 = sources2; -} - -/** - * \brief Disables the selected interrupts sources on a PWMC peripheral. - * - * \param sources1 Bitwise OR of selected interrupt sources of PWM_IDR1. - * \param sources2 Bitwise OR of selected interrupt sources of PWM_IDR2. - */ -void PWMC_DisableIt(uint32_t sources1, uint32_t sources2) -{ - PWM->PWM_IDR1 = sources1; - PWM->PWM_IDR2 = sources2; -} - -/** - * \brief Sends the contents of buffer through a PWMC peripheral, using the PDC to - * take care of the transfer. - * - * Note: Duty cycle of syncronous channels can update by PDC - * when the field UPDM (Update Mode) in the PWM_SCM register is set to 2. - * - * \param pwmc Pointer to an Pwm instance. - * \param buffer Data buffer to send. - * \param length Length of the data buffer. - */ -uint8_t PWMC_WriteBuffer(Pwm *pwmc, - void *buffer, - uint32_t length) -{ - /* Check if first bank is free */ - if (pwmc->PWM_TCR == 0) { - - pwmc->PWM_TPR = (uint32_t) buffer; - pwmc->PWM_TCR = length; - pwmc->PWM_PTCR = PERIPH_PTCR_TXTEN; - return 1; - } - /* Check if second bank is free */ - else if (pwmc->PWM_TNCR == 0) { - - pwmc->PWM_TNPR = (uint32_t) buffer; - pwmc->PWM_TNCR = length; - return 1; - } - - /* No free banks */ - return 0; -} - -/** - * \brief Set PWM output override value. - * - * \param value Bitwise OR of output override value. - */ -void PWMC_SetOverrideValue(uint32_t value) -{ - PWM->PWM_OOV = value; -} - -/** - * \brief Enalbe override output. - * - * \param value Bitwise OR of output selection. - * \param sync 0: enable the output asyncronously, 1: enable it syncronously - */ -void PWMC_EnableOverrideOutput(uint32_t value, uint32_t sync) -{ - if (sync) { - - PWM->PWM_OSSUPD = value; - } else { - - PWM->PWM_OSS = value; - } -} - -/** - * \brief Disalbe override output. - * - * \param value Bitwise OR of output selection. - * \param sync 0: enable the output asyncronously, 1: enable it syncronously - */ -void PWMC_DisableOverrideOutput(uint32_t value, uint32_t sync) -{ - if (sync) { - - PWM->PWM_OSCUPD = value; - } else { - - PWM->PWM_OSC = value; - } -} - -/** - * \brief Set PWM fault mode. - * - * \param mode Bitwise OR of fault mode. - */ -void PWMC_SetFaultMode(uint32_t mode) -{ - PWM->PWM_FMR = mode; -} - -/** - * \brief PWM fault clear. - * - * \param fault Bitwise OR of fault to clear. - */ -void PWMC_FaultClear(uint32_t fault) -{ - PWM->PWM_FCR = fault; -} - -/** - * \brief Set PWM fault protection value. - * - * \param value Bitwise OR of fault protection value. - */ -void PWMC_SetFaultProtectionValue(uint32_t value) -{ - PWM->PWM_FPV = value; -} - -/** - * \brief Enable PWM fault protection. - * - * \param value Bitwise OR of FPEx[y]. - */ -void PWMC_EnableFaultProtection(uint32_t value) -{ - PWM->PWM_FPE = value; -} - -/** - * \brief Configure comparison unit. - * - * \param x comparison x index - * \param value comparison x value. - * \param mode comparison x mode - */ -void PWMC_ConfigureComparisonUnit(uint32_t x, uint32_t value, uint32_t mode) -{ - /* If channel is disabled, write to CMPxM & CMPxV */ - if ((PWM->PWM_SR & (1 << 0)) == 0) { - if (x == 0) { - PWM->PWM_CMP0M = mode; - PWM->PWM_CMP0V = value; - } else if (x == 1) { - PWM->PWM_CMP1M = mode; - PWM->PWM_CMP1V = value; - } else if (x == 2) { - PWM->PWM_CMP2M = mode; - PWM->PWM_CMP2V = value; - } else if (x == 3) { - PWM->PWM_CMP3M = mode; - PWM->PWM_CMP3V = value; - } else if (x == 4) { - PWM->PWM_CMP4M = mode; - PWM->PWM_CMP4V = value; - } else if (x == 5) { - PWM->PWM_CMP5M = mode; - PWM->PWM_CMP5V = value; - } else if (x == 6) { - PWM->PWM_CMP6M = mode; - PWM->PWM_CMP6V = value; - } else if (x == 7) { - PWM->PWM_CMP7M = mode; - PWM->PWM_CMP7V = value; - } - } - /* Otherwise use update register */ - else { - if (x == 0) { - PWM->PWM_CMP0MUPD = mode; - PWM->PWM_CMP0VUPD = value; - } else if (x == 1) { - PWM->PWM_CMP1MUPD = mode; - PWM->PWM_CMP1VUPD = value; - } else if (x == 2) { - PWM->PWM_CMP2MUPD = mode; - PWM->PWM_CMP2VUPD = value; - } else if (x == 3) { - PWM->PWM_CMP3MUPD = mode; - PWM->PWM_CMP3VUPD = value; - } else if (x == 4) { - PWM->PWM_CMP4MUPD = mode; - PWM->PWM_CMP4VUPD = value; - } else if (x == 5) { - PWM->PWM_CMP5MUPD = mode; - PWM->PWM_CMP5VUPD = value; - } else if (x == 6) { - PWM->PWM_CMP6MUPD = mode; - PWM->PWM_CMP6VUPD = value; - } else if (x == 7) { - PWM->PWM_CMP7MUPD = mode; - PWM->PWM_CMP7VUPD = value; - } - } -} - -/** - * \brief Configure event line mode. - * - * \param x Line x - * \param mode Bitwise OR of line mode selection - */ -void PWMC_ConfigureEventLineMode(uint32_t x, uint32_t mode) -{ - SANITY_CHECK(x < 2); - - PWM->PWM_ELxMR[x] = mode; -} diff --git a/src/ersky9x/libraries/drivers/pwmc/pwmc.h b/src/ersky9x/libraries/drivers/pwmc/pwmc.h deleted file mode 100644 index de4388899..000000000 --- a/src/ersky9x/libraries/drivers/pwmc/pwmc.h +++ /dev/null @@ -1,159 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * - * Interface for configuration the Pulse Width Modulation Controller (PWM) peripheral. - * - * \par Usage - * - * -# Configures PWM clocks A & B to run at the given frequencies using - * \ref PWMC_ConfigureClocks(). - * -# Configure PWMC channel using \ref PWMC_ConfigureChannel(), \ref PWMC_ConfigureChannelExt() - * \ref PWMC_SetPeriod(), \ref PWMC_SetDutyCycle() and \ref PWMC_SetDeadTime(). - * -# Enable & disable channel using \ref PWMC_EnableChannel() and - * \ref PWMC_DisableChannel(). - * -# Enable & disable the period interrupt for the given PWM channel using - * \ref PWMC_EnableChannelIt() and \ref PWMC_DisableChannelIt(). - * -# Enable & disable the selected interrupts sources on a PWMC peripheral - * using \ref PWMC_EnableIt() and \ref PWMC_DisableIt(). - * -# Control syncronous channel using \ref PWMC_ConfigureSyncChannel(), - * \ref PWMC_SetSyncChannelUpdatePeriod() and \ref PWMC_SetSyncChannelUpdateUnlock(). - * -# Control PWM override output using \ref PWMC_SetOverrideValue(), - * \ref PWMC_EnableOverrideOutput() and \ref PWMC_DisableOverrideOutput(). - * -# \ref Send data through the transmitter using \ref PWMC_WriteBuffer(). - * - */ - -#ifndef PWMC_H -#define PWMC_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/* PWM sub-bit field definition. begin */ -/* TODO: remove them when AT91SAM3S4.h have the definitions. */ -// PWM_CMRx -#define PWM_CMR0_CPRE_MCKA (0xB) // (PWMC_CH) -#define PWM_CMR0_CPRE_MCKB (0xC) // (PWMC_CH) -#define PWM_CMR1_CPRE_MCKA (0xB) // (PWMC_CH) -#define PWM_CMR2_CPRE_MCKA (0xB) // (PWMC_CH) -// PWM_SCM -#define PWM_SCM_UPDM_MODE0 (0x0 << 16) // (PWMC) Manual write of data and manual trigger of the update -#define PWM_SCM_UPDM_MODE1 (0x1 << 16) // (PWMC) Manual write of data and automatic trigger of the update -#define PWM_SCM_UPDM_MODE2 (0x2 << 16) // (PWMC) Automatic write of data and automatic trigger of the update -/* end */ - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void PWMC_ConfigureChannel( - uint8_t channel, - uint32_t prescaler, - uint32_t alignment, - uint32_t polarity); - -extern void PWMC_ConfigureChannelExt( - uint8_t channel, - uint32_t prescaler, - uint32_t alignment, - uint32_t polarity, - uint32_t countEventSelect, - uint32_t DTEnable, - uint32_t DTHInverte, - uint32_t DTLInverte); - -extern void PWMC_ConfigureClocks - (uint32_t clka, - uint32_t clkb, - uint32_t mck); - -extern void PWMC_SetPeriod(uint8_t channel, uint16_t period); - -extern void PWMC_SetDutyCycle(uint8_t channel, uint16_t duty); - -extern void PWMC_SetDeadTime(uint8_t channel, uint16_t timeH, uint16_t timeL); - -extern void PWMC_ConfigureSyncChannel( - uint32_t channels, - uint32_t updateMode, - uint32_t requestMode, - uint32_t requestComparisonSelect); - -extern void PWMC_SetSyncChannelUpdatePeriod(uint8_t period); - -extern void PWMC_SetSyncChannelUpdateUnlock(void); - -extern void PWMC_EnableChannel(uint8_t channel); - -extern void PWMC_DisableChannel(uint8_t channel); - -extern void PWMC_EnableChannelIt(uint8_t channel); - -extern void PWMC_DisableChannelIt(uint8_t channel); - -extern void PWMC_EnableIt(uint32_t sources1, uint32_t sources2); - -extern void PWMC_DisableIt(uint32_t sources1, uint32_t sources2); - -extern uint8_t PWMC_WriteBuffer(Pwm *pwmc, - void *buffer, - uint32_t length); - -extern void PWMC_SetOverrideValue(uint32_t value); - -extern void PWMC_EnableOverrideOutput(uint32_t value, uint32_t sync); - -extern void PWMC_DisableOverrideOutput(uint32_t value, uint32_t sync); - -extern void PWMC_SetFaultMode(uint32_t mode); - -extern void PWMC_FaultClear(uint32_t fault); - -extern void PWMC_SetFaultProtectionValue(uint32_t value); - -extern void PWMC_EnableFaultProtection(uint32_t value); - -extern void PWMC_ConfigureComparisonUnit(uint32_t x, uint32_t value, uint32_t mode); - -extern void PWMC_ConfigureEventLineMode(uint32_t x, uint32_t mode); - -#endif /* #ifndef PWMC_H */ - diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchGnuCfg3SRevB.a b/src/ersky9x/libraries/drivers/qtouch/libQTouchGnuCfg3SRevB.a deleted file mode 100644 index 56bb0b36a70d4772947c17e60f92919a113e1494..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53640 zcmd_T3w%|@xjsB=ubpJ&Lhe8af$Utk$R#8pASgmeAV2~V2r43)gd~tiNJ0`c*s4)c z@lub7wJ6$JZLO`g)p$9z)k3Xpt+g$PRw=ekt@T*xY2!V$w*5cPtatWWdk3xkpYQwq zdcJRxwVrw3dFP$Wnl)?o%sXr4Eokg+YF(HxD-`KUO6Sa*TQ+~r{JEh}u@3T|L!r5| z5ujZ|f>LUtQg-{lc9bqrD*C8?N~z5UPkh|`C8b6l+k5L#jXhiIdpdfe$gM6dTxu5Yocj9O6{{D! zC!QqfpRp)JS8y6koBznpzt>I$GML#+Z|qo*pC6+{zl<(Sb@(9Xqy#tBwBd z&fd;$NVc~%w{-Wg>I=PW=w5Er!U5qVu6tmM;S0j|(T8=+A4mWDez_+VK*JBqHUEwx%Sp zNE2dE1?Vd!RSC}Z$VEw%5BV7jP*rLdlm_&L4O%(ySZTIWjWL=NaSB+mY$JAv5sFSl zSio{RgWwF2Gk+C1ftZ`fc^ZO&Q|dJ*?j>jq1Y=HSjg|L`lTb*sbHMp3&bIRq&Ozr1 zoMW6H;T-E6#yQS8hO^`R9_M)HEGS5DHsPG;Y{NOpS&w8!IZZexJA1%Mac;*s)%gm} zY0d!7>CO{4XE+N`v`l9i&ZC{RIFE78#d)mLigT9pG)geexf1?t=SG~zJNt3Yaqhu+ zg7X>ZpXltvIakI05c#*K2i{@H8g~@{vf|509-9*8z4J8fso(el7~k11r8l>%BBE3?ktq z23)4|M!n_C%oPEu3lvxhnN0OcAp;46VB1#vkb#62=I(%ycESxT+E0WGCOpK@BSOX` z{GM@tA!KYq9dmqCNVNPcru1@PBQi0{N)G-Bh+B6dq*AP5M73UUJAd94bZ0_)>Oq{W z!}<=fYSYdk^_;%*av_m+H=`Y~J`aB>=}$qY^}NMaw-mHWx4uh>zgSiUNw{7d>v1sa zX$ce`)_3)V;AKojZCW2_**i&7$oiWOe;#z^5z@9Uk+lxW->3Y!mKH#`8p8269Hl5z z+97zXjgZ6bg8YnbQ`UJ}@)S^G#xS&A(_{L;uo|>KM+uwxu2w3A0>2bDmq?u!pJ7F86BnK%x@nYuoY!)#F(ZIM9C+i%Sfqbak ze^A|OMzma!+)>QmY~EIea|t8OW#cuR6kfFzI$bwbBAf0kaHV;N{)&`?<++rza-SnC z8uAo`4kPa|le7XW)D8W?N+BjdDp=(bx%V>vD}CuG_KX2_1Tg~EUz0~cyRJ!at)^2p zV)(NKBdQR_%Pl<{n>w3YdOCM>H??%{+-N+ZEz_rm+S__tHg0O`*jQ9F3!~&&Tbi0? zHFj^C+0oh2GP9*|Q`@YvqS-~Ivk)Bqj|^|?Xlmcl+=2!h9=tUnQyAMekr}qF!pR7S zOi|e!cq%q7K55eAMH32E+6n6$0!cpEmjjj^A6jJhhU}zJ@vPju{MoZ76x_40xO8sG z!nMouXV~$*c0$p>M*E_t?WFaAvA($93|N^H^GgeJ3X5~|3Z_jNpI2BgE0E}uxH({j z%1${SotT%qZ(CNV;*_ncAeumS*CPq1C#;;)XAQ+!!Q(#&{#d=z^~``hWZU^eb|9nD zn$xiT&g});=X7;F;Z}u0oUt`ytL@_lV~+Qw_kDIa=3vI+mj^Oy>>2wG1PjOaT~T4Z zq(b8cr|k?3{nbt%I+!wj`>4aCY8tBcEo-Xi9|#PLAGoa|{^jXAD~E#i^zFgH#;W|P z*qVLI`Ulj2mySt~*!4(BjmppNDz3JwGWupeXw5!05S*UTWgWE&GP-6g5A3eoZT0WZ z{z=yUfv58x`s_lGhnFB|SJuFQF9z$xom`uY*8 zCadqnW%HNQ_!DYUA5n!lUGX&u)j3_kg1Rnic4l7Pc9u46du+|~U3w?$IU*G&Qn59whg2ZD|J(+~ z@AAblaXIw-2b`s>PbVjhQduSdScan_IrRqXs=$@@u3$u1@5h7$*Z}E|n$&p_!M=%|KZqLNOw?apR>WM=D3oKw zbkqVcky7+L)DEzHGgYjHB{$6gYf~?yUx&NE^y^UKi=^=9~ zGPQ;YDolT2(nvA1yM&_m`AGP$f^?>1@ zm_odWO6}d*)l%QMwWq$Tv!|Z1RBzih%sh1=GIG(P+B-Y8g!E}gM^D?9j+W*Sf8u(% zY1+} z)=3Md-a1;kQ4MBxO=p48QG(_+wfyY5b@g+KMM3EtRk?ie>8CG+u42zy;(1Herk$8^ zWEF?2&aHe;#;0Vi$35Be&hxzU)edB)WUf^2$hp4AJ4IJc55{IK_3e#4dXBMOD$95A z)Uwmh2vvsk5KndYc3_rIMbx?}WT{ukQm>GurQ!UQ&i1@zZvCHFkyp@Cub`z~K}+Ye zzB*bkL)?uy-+Ip5k~8w2M_cXg4Mn8lZ^DRU8lLG>T=b1bo0NY(6)~dj1n<(Z)f;u3 zXvSqQbyMOMy`)T?zPf&KO~`KG$ilsBWzp#$jAy}3-(_l|s`v0s^oitA`@^Ljtj2s>!sJ?LGk65nMj_4#M} z{AH1=3wrsW#}_`==ReupCtf4cy{&GR$jFEx19;KT-`>t}dokT4qt}{r zH1~OjCy7$aDl1P3O|6rk$)RQVb-WV4jzguz#q+k$o;iE|Nzzd+F2e;!iw{a7&x7)>5s3X1 z?W$-~PY=8;n|5reZ``!0yX68^)ZNl9oVJe5oqoE#t)s=IsiG*dv^t*QkEp+hP}8fK zPBJ1e@}UwDG_pgE2>z)1Nej7U+>8kdDT2#r$D*4rylcm%4oIL*yjp1NZtU0+$ub;Q z2kKQ7HFa*=h9QC~TD*2uQDbj!ciW~Ny@>TMxbcw1h*n`-r=1yj2`M8xrSia_9LBra zMawaaZVC>Ln*DPAak&{I&VY=G1F!z!^kW~xco#;={S5&ecpGQr_zOr+Jxjoc7-Du| zuv-8cfJtgMU#A029C+20$lRkohVfP-%&)I~no_(Us1LKtVSVSp&p0Ma3$U2tuNzZd z{)qDHyB+#c!J|I%P5v%`->{jt=$i^2^rrKI3|! z?*T&qjlLuZ`SbT_=xabY^^F!e<}WWwUm+^@OMc*pT6QKeWOvi zX+{a;jCV$qzCX@%?+5DRGOj7_k|=$XQOU~@Zk*9q9;NRc=$i*2>SLc`^l>4~#G#H3 z=qsm3oC&Lo(l-OM1znJ#z6m&tz829}Eb+eqeN%WtilaUrT_R`rFQC%Uq{EIfbUWd( z-J~@A56G2hpL;TLY-5lMyJAcVU1I{lHC`evQ`qgovdAGsECh!SQI-Q))@{YFZ(V^> zTnaSK=QS*ietuBB`42Q7pYw+@ztOZmXAJk}fHZUGIa~Lfe%e>jVB07~Wcu;CY%{`9 z{C5Q96Qkr4wR}TZJ~8a0$A)yI{!v<Q9ecQ6KP+CmAYir>%-GtSmMgP~a7v09(U;hpX|Ti>aEns=J#Y<;Kr zX|Bn6&Q>9hfX~KL{bV3p37=W%xSmUa#<88QF$9qG**GZAXHq(@=Qg4F{7X}B{o~U> z<0#JsO5;d>9S7qN;Ydeq9u%59#y=cIzYN+q#(&)qK+=E0!B)$I@v-y}b_{3#&APt| z2g5_4DN>Fj9qpwgN}m0nag1Lp@`doHLj(IC;~35*KC<|XNypXS6BW)yelLHx-@G-V zCRNz03Y+!BP<`}oNBNm+W{V<+z5anwLoY~}Bu;GD#hT;`>G8OSNdeoAi+q-o&Lie4*gOFprP$|@Un0nHE9pwXT0zbulfOx@ zO|V1oQ-YTZUL*K9!7m8jC-^NvPLfmaQ-aS39uoY8Anzy2y(0Jr!FL4%Xs--+1d|0b z1+xWtA5m_yAjcP^O9kf%E)?W_#qerD-dCj06x=9ClNs_`1v>P#ur@OwlI7k(i4V6*DNLTldDBJU-iDfxXN`$`Gi75XciAWDB zH6Kw`V6H3xBmH@#F}UKmfc20=oUc@f2t7I;XdMqURO;)ZL5?4p@4pdIc#a>5`uPV;5;{jvKli|=l^*4$3(|&+w0_-sIh1A_W_20m@a82+N* zuLbpU4Sd{&DiG&kDrsDQ1nK$-5s_~+d7V$)9+B=m(i9@v(w=}0X~aj>YSj8b=yna% zdZAC>7r+qZQ0_uOoeuQRAPv;%A(C$Yz*!~pLVjoL+UJ*?*sgtUsWHO;1a|GrG^P!i z7E7FqT>ewLcF&YOXiV8-{I>3~ktXYLktXYo-|9VngvECPO}P_16K_06!e%W|JR`=TUTj*m4)_F2XZf1EMH&-Sw8%F=3Gb_2L}=;|SkTXek#t@nWz zCy-`ohIns_bMn`tj3)fJ(_gluA@jW=Gzbn2IHVX z_ZF5j7mS!w8L-gR5yjeQX(TI!AlEAAu^u+-fNz_Tyzi{Qah*CnmEM3RpS z8HoE1g%1d6$8o?2OI=qu7{_)GOI??YiF<(LFNBPZ`!t1*3K^%g$u%r>{{vF-7P|tg z4=4AovCgf4KLLw07g3u^wAhze|DgpIkOP;LMc&se>oJkNkFuj)Blmvoy`0{!YcFm` zWqo581=xL9-_%~_*m_V4Ft^qKy$Rk)cXveip&10vw*gfpKYlW-|hcm;X8Po=Il zb_6P|nf~+AX&S$fG>c)oQUo=(4eSjjPZr@kd*!+pJ z^71C+<>lo^*reWISsA%`D;LgMv|(XMggxkQl$ALnzrcQ8U0z~;>C#^Nx2kBP9ba8? zioI>UU9kDw9W!U;U$tw)Rd&+-ThF!E+-M(EMRs|S3)S{BYC+AcS@u(x6yd30!3ee{ zb_MJ-8#Xi~G*ma-*6_=QYa5adNUAMGn`*sIb_+3fytnAr%hfS_Y$o@YY``-vK*2LgMp!3Z5fIfR_$<}=I2q~ zuK(bQzgwYEgOl9UmE)%V_GqRKIi{5Sre#0=rb?k~(t%x7$ZryJ_2r|9)k!NdS`!=U zT5B5iwqDn8r1d8a#$K~LF1frR{!TukM>sw@{q~#gqtq1(0r>nkj-8XSy<`Vr9D9!{ zpPeW9K^$W3$7s>!d>pyZ8KdK@g-<)i>Ba&3P6`gWUJB|C*PA{)4=jBq3I8GCG#nIM#Rrj@NOpYd#;yGMvbTgn1%8QQ32C z5t_L*mYZ6A1}@qr;a{*KiBv3`PyJg~^`xDDF7zX8>cX~DnEdR<1gx0^^;z?bG{mDV zjZB8ZbZ(>#mfxhz%)v&OmNap0)hk1fXE8*JAe|LslHxN73Mc8#6T9(s2ksS)@pXV0 z=;)?F3p~%@$c^Vtkw#nmF;#6s6gK@c*DPwD)o)P9y~ePmR3q&g|Cbw-_-o3u>~O0$ ziq><;ek+ZCW6O^5xMO*c>hWPi;#rv4s|Q7Q!5IMc^&0K>0uCG@3&M}6c|j{16W`1L&xeWo`> zkd`CzspHqT(Wei;&cgb3!SC0{ZPxzY-Q=%7N?$wl6@$n8aV^v2?^gJ!&$x}KjCF

P4k) zqDPzwdjzy!-~D6V`lmkpdJXIQDf}i5yy_Rw$9gf&g#8!{zrKf|F9aU-VOk=rZxDVH z2VND6NXzLFXTmrH@#}jY`gqN$58kjo&Py?l$?nG? z{z1>|g>cYrpb%)TIoH`|N70p_DbGHSb^|Mb#<88SuVFa*Fxmywn?NALIXX3t^aX|h zl9qLK_i3)jOYY*j|MBkn!vpC^GV1eXZEhM1((YC+m_1<>r)OL&LiPQhJ*oTj4w+XTNX z$c@nCKS@M$|DoVBMCjG?*x(-%{wqY(?^_Z+8eIV8CJL4kq3=w=Cc!Sjy@GcVbCmkB z&;vwt&M&fFQ0}*gC})zS3zb?PQM4TIamJrV#1t6s;Xoc}B09ze#C-IX!~*>OB|?5V z5$R+y9y$Z97wPf7B0ZIebQcI+PLytdeBOIR_AEpO5jhJ-IV7c#&j!+10@KKG80iW@ z-j}3T3G%)qy(TW9eU8wm0?lV1!E|)}0z;(nSkUzg)b)${o2od#}#NuRoZ%`gk)}pWt7S zNDMC>M7%F2De?t5Ty5~Z=_c7D(H=d5@0&@LiGTf;AFMUF@8WUaU4s>eFp0~bksxFm zZjnqwpl1~^ywb*9OwiX8w<}!GV!vbkH%{?5q8%0u___nz!72R8n%NM<`T=iz`sd)imd{50a;PP!K2Y_*W_XpmF zLO<6Ja9i_jC_mR^P&sUKB;s#mfO2>*{>IRlYloL_L)i<6{W%iln@PA18OK2&-b|v` zB%yZ=b9%Fo<#F94ZwXM7elv;IdotqbbaGV!?TYbclH(8vSdI-UQLispwgoAr`jKtA z`w)`!1F)=swFxxul~GuCNVb^sGjJqhIl!exZ8biQ_EOpn6}UJx^$XxwnOa5Kx1dw} z*4b%ar1CKq6AJ99O}m_dhFqS;KHkcb(DJl7RFkbqd(XEnO}mhEj?fQWn$Aa%H9;ry zB!bc(A)Tx9`X1?9NatIuD857}pdJV7-*PF!eTi8UviEW85x99! zG&IZ0@g|GOMfQe}Jvro_i|v%6;)(f%3#U%D3ySP>Lv}&PJ}Z=OPbsp`D#|aj^NOaQ zHgnd@yuAErShUD1vs2dNZ5gv>&YC@I)oC*)uKd*W0733unzdZDC3I zghh*H6&J6awP-@w!u%5Zr|Q)$E9abZ;li?+d3Hz0zOdSk$GOPPFT(3I?99-YzEM1J zq)c67ZlGZUc1WPTx5sv3ZjK;iqAXEUK+9&_MV-aH)~d_ov``J;tj}$ zeeb0U?3Wa=$o_*`zk0*z1*^^}w=>q;qlyBlxSVR{ABI-%sowiQMqf;oH9g^wg?BUD zP@Oqj07>Y<<9DhR>U?;ZWz;$+%T~rx50k5zlnJFyE}U(YAUYbp{j`uKON3GIJRL* zLrOzuP3j%L8eVcRr!Vo=gxg~GXS}28=N?uEnwPh%Xsg~_6Nj9s2gWvhA7^zy9XJR~ zX^6e`Nnmb6P0s#-*u8wCgf%1PXkdnY$exjOz%H~3&#B37W$NQwr_IlaMPT@(`%Nj%IQ*tiF*=m3RRuoI=vNjVkO--t~T|) z?Dful*|k4@Fmn*NJ{{{Zv4?&$ob|oc@2I*N!M{kJb2eK>eq@>lC7TKTt?C$1ko^!Jp4Hv)FdZHcv6HLHOkw-k|qR4&F@Y$uZ0-KO-|axx5TVDlr|1gQ1zg z1>}=}%S2x6LrGX8!ursMq;d{8E;W2UYACz5*~xj(xo^UHHFH1eDW^8>w!r>;)OhNB zDt}yU0wj`f#N1|0%RXFKbH%XLAG=?j6gCq^f%Df9{3K*nR+OtW@1C(sS_JgzK~qQ)|K0kGn*Kk zoeO?$!-KD>Tb=6onzV*-4LmX)c;fY;|M2RDb-}Wmx=2FV{cBhpBO1qN;gaOSCCObk zSl0!vwXX^8j=4Jas<zOB7y@aaNP zOFvDuARjW{)u9_J(6fJoPYAV+;0kWkQaDjC0i7n+zLJRg7mwOgPMj-z;zI4;Q%R~+=HNil;CS6#N3|z%em?Bcqqen2yrfjN z5l2o?D6Hn}Xg5~sW)@@XiPokTud83VbTMA!P*QJp?=M+>`cl=~vaKs@Zchz*%k;?1 zjF8hWgI%?FeSO6lYoT`K($kl%TVB6(edW@nOO`HC)n}}#t*=_WwtmCXwX5q_Ev~Ea zy_zDt`X`lYXChxsSpQyx~MSI$nbUWc+pyyqdj%!M7$*g}uj*_tK9kGi66rt0~2 z2rLqsZ3(8P&F*b%y6tMm`(u?3aJR^FD@5e_UT%`z9-ThlFn`DqOM??S_wBFAS&PZr(Ui0k^8fm21vev36B7_$jBUcpl3zKE1`u`_Z5kIP7`8Ia{8!s8^d3$tw;WaPLefXW*(eGkkvXsjtuk`ocI@>f_ zMEb6eVZ5AR@ayZNKB+&hL>PVdMCrQ)iTT@t(RWvrzTKDyHT8$7w6MN!N9lV8`a<9t zXY_HTNIhM(njOv8kKTaUWv~iij?%qsy ztvnkXmWB1gdSY4q`gV_T+Zx!~QO}8-pU*Wp+*Us452gNS+MhFq`*T2=x%1p7S(A%Q zKVGj=tqdmz2?dknN#l7Wq;-RU7BIWaZS(fxMoLvp5vY2xf89? zd7&&XTbAcWuF2t|_#F2JbIzXm>qi;5=C;xo&g*(k6umWyz95Q@S~D{v6L;Z^Lz<%5 zv&-hGZG@Bm$!IugtQtvf^}qB8Baw*ljN4y^*UnIEw)X&Vv|t_)M8w(|!g;Syj?V?+ zQbG3Dq|Xv$zf8JGkT)FZ3k5F`yk78T!7mCvAUG)aN5Q`cI=Cp*H&#%u^?U)znO>!?ybV-E6Pdh zy^GNIW8wc%Q14kJpY;m8yq76oOT^8#j)=aQZw%*}S-t#u!|6 z3w^EN4T84_-X?gLAfLO`^9{iP!6yZOD9Gm@1x6?*#u#@IAo~1o_jM@nZ#( z1!)gLezxF5!O4PVjhMf;DYsBi-w&Yq+nW5ff@cbzC%8%Qd_lc-4EYO$zDV#|!5aiW zE69BV)PJYomjv$<N_kX_j7x@{DIP)2e$X!Q~3xxmtn;PC`Bkxlf z$-b{rB;d~S*67&5bJdRvgz^;%v+gIP_kE44tcPG|lvomW-K2pa% zDG@D*H|;b}D|RmW#juzs83-?@&h&ERuCEsPCAf&I^!GJ%dkykRVS^FwmNiJoxLWaG z!S!bW40?2rV7?J@2RTjbtIan;mO|VfOOE+Q$b1sPn7{Lm4aR+&loO*@xSTjnDtZg9 z2?*nY>pMWpZg3Y|KgGPnZGxZ`7l(5|?-{f8&Mhpsa`QVrTd@~H@xO+j3$^cqNSMxm z9omnD+61mgVxcyUxiFutAdz$tVV5jV$fwp@0$N-6vlYLCtS(Ega<~B%i^HD-#Ge6SZieFnKVc>nd7rIV z#AF@|6oZRQB>a`3-e)WRL@nNDE1qTjdY`RWO=0h|6&)nK&sNMPc~mrGGo1dm%*z2i z+OeFKP&KLo>a8nq!sI+pa9j;dz8aabE@z&s+7zZ@?IMwjBNYqRSL={wt88PFUx1YI$@SGxV)M1vnQmXbct$ zza|>Tkh&SUz7NP(7L3*z>(OD)fHzua&ZXZ59YUsd=+HE1$(zYSU7+b% zq&dR3F4Qy!;d#1t`!szS={s0apVHUpebNV5^h@*w4#7M2elV>|wS3+`7}l@-TuRC3 zrKGd=TKuw3!KXnNa=KyC)$mQe2`3t6Ox_RAmGDgARcuH2?Tqw9!2ys3590(kl~;=O za2pf+q4fY2{+q2 z;7H!e3KT5YeEk`o7mI67?uN%1eUP)xWEW;xGk#4tn|*|3&E%Y!{RiE4 zEh~{7182QNQPE~*;&j@k%ht)Fi>Z2z&YY{e=o)hBd>r*QR0s5W*1wengZYq06RYxL zKKp@MLp7jUF1M__sdiszZi&4kWG9B~ouN64Dwo@d)vy4y!XNhdqq6cR<`=B0!8pL< zek;bZ?4+VVz{firV~rg@sSm$#Jh``FAdy&P?H7`@3f|7n z{oslZvWDjr=YG)tmmpUBztJD_k~MwQp}_R=p&KtNA4~;r)MX)@FTBhF@2bnz{dRZF z&BHN+_w3B-8$Vc=bxz-vE90jpzZtRuN6UsM7RL{k4X1_ZyA9tLfd#-|@VUC2LgcZ0 z$Wh$2$sL=IF5OwZ`i&o0zdpL7W^GnhS6!cV>al^ku8hZ~R`p=-YER8=eLXeVT{XWQ zI~0tIITR{zkV{q2)K&4@ln<^M+6I{iDuPFXn*WuqlYh(gbTu^hvd#EjheA$EF56Vy zxU+6&`pzqc`jc7n`?G&Da5nNDdvHQu+2H!qtv5r#xx<-iF7mdoBJsJitLrwNv*g%7 z&(gYe`9~O|Ze3+g(qLV6%F()wKRIsO#|FMrQMWGhB?+528MYTohn$$i!Mct8)A8Mv zQ|s0(hn9??{uF#@YIfZ^?y7BE`t;FLYbJF4*C2DgNay^#Bd6B<=ift@mFl)H1ICZ*p$eA8U-xw)_so7sr8ao=nSS7q*t>|W%Q{+?o~!pO}Hk<2AaCi z{(|=54BqDtN3jgxAsC+PrN?tv&ZK6GD1S%Z;;c5Z+f@F3nW*2hFgr1nKa%A!G{ylU;8qpvv`n zNv-1q;`uJuOLd(|bsjuJx`xgsyrsQ$e9@a*4o>@N$E&VKifRM1=7xqd&r3Q3hwo!Q z940-bS?3Xc=6W}Wb90`T8_s2G*NU?%c%~53) zINY?MOWYE{LP2xSvDMSDaK<&j^8gOcjy{aTxCVGm#OI(o0S9a3dK^hOCgM1e`&aS- zdlhZ+;`>m6fA6^aetr>R^}@2mH7ePH?;M*i6?;3oBevA*Zx`q`hI*}0?tHk&H5x)gb z{706v++Hi%)q=^AwYy6TEZ*w@Ekb;LrxWETLS+JjrXD=6>>b zGX4(6giDHUdvjZe_cKqID55YU-+mBL<>4zz?#OKFPcDT`wTuazTYfhqs%J+RzYx{a z(rms{G~(?I^0g@WZaUkuB+C`sa2@Ja<-2pGZq@&CJFBR!zLBvDRHQ!(;&qUo z=*YXk3ybQc{&yH|jmIO34=OxFwJQ@e;66o_$^(OP<{=p^XC8J_Aj2oCUoHgNI3wqd zVhq={{oz`#aYk+-7{<@ApF)P?3FA!IDPUlkE$nVAP^upf{}4Esi_!yG=IeAECJwx+ z5Ro`tXPog?gW=bgI@R6h7Xly4eqntaQ!$RoQVte|%@ZDMEl1=K&aZDC^ksn;5+M3IUta_C6@q6R<>-2F`1SEqj;Y{cGI*S8CStOw(azPrHi%UusSGcuyA zk^4OS{&X9VF7<_QB;%kQ>F?t3>$?~F{39%*@7s{`>uZI+ec**~uslZJi||vQaSKxL zEf+%ojlLuB`}L`l+;5SDz~_%EqwjV2{raAQzBf+L{$7QgUtcZtp>c=6&%|N$y$`=% z-#3uhr@=GMgmI$TukTLW2&}IV4wx^5^(7*Li37HpmZ4NRJ>pClmy-PY?uEW$$b@jP zeVP1mG-~32tP>Y{_`Nw{wzeGGE7CJ?mo5`C9beHu#(sYoCX{7E>N z)l?iTE7)OoeLiTT1YDmtEJKfW`-VIb*m#2c&%!38kOJo-H!{c=^HY z_C*1dvH*JKg)`{C!qlIr>opt=IXq|M%0$YiYWe&dDA5jtj5m+;A8e`J9b6otz3clofj=aQ*%1%lg|m` zD1S8$>SG_9j{2khk8uqDnjwIsAHzX;9!&oSQS@QZ#!>#bA%LXC{?8lm!tyU_fK}Mc zj}XdObHqr!XXID*MvTKoj<)b?#{at{dY%Bmj1w_32hTs2^^fHJBm9WpFZeJTzPIXr znv%a-qds(@_t?14eA-_mp*jNSH`r#0+V&8bM;a&gH{thofL|hV9NSQy*Pd7_sBOVO zZxXsquuG8Fp7NInUN3mF;1>nIBKUQ|hXi@;8ULW*vw}wj`D|o(78(bUQ+vb`!E(XX zg69cx*_(2F11*s=A;f)xUl!E1h~R%;=vM_fGe-Hp2_^+xdb}W~?ifB_aJk@Ff|~^| z5Zonrjo^($bbZ>k5V(&tZp|-BI2S^xpZm(me_H4l1%FLM*T#uL;%h|6{aM1b4I*f+ z?ov-8?nT-VrU+&e!JkBg+zg@T5%K(7Ah=BUYl)CMOK5HHg7{rRb3K&$^mi73w+nr* zp#IJR_y>i4R`8dCuL-^-=-{zKeWL|ouA=E#f(ry!2=a5)l;1?e;AOMm`9$QqN5U@= z`U;^rPGI=$f?pK={X#z|^y5N*Pv~cbJ}mUhLjP9iKMMV((0>!u-%~((X)#DQ53_WF z#YFJu3sw+Ojw-?P1UCul?G7#d+g+Vc zlp88Eji|c(ON3rdL_P2sO8NCf)JL<>twhud9qSLxL?e>Wh@S!)X^q100zr;jNux*_ zPa~q<7YpiiL9Y~gqhN#J7QwB87ZH(9-H!u5LmK(qBe+lScES6I$oDq|9~I*cfo+P8=Aq8KUy$HFeFH`7>3UlJVkJ!;8H>T9RtYG zY=-jMb{*Ix^cF#Fs|$X&(3c6)jEwR0^8|RK(6lQff4|^eg7*l1UGPD{ZwWpwsGmQG z|0AJ)CitA-QNdpc>gN>XUl*G522B62g0Q#HbgbYg!8E~;V4>i2L1Rl#Qy}WA5TwZu z=`#d33N{FC5v0i;<@mA|qJI7XX(>cnKmUOGz6I+07Pw!+zaXfef8Y-Y{g~hrg3k&b z64cK{$R86L-O>qdqV@fX`y#|}wDYM%wDV#j;?oiJeF$`fP7>7d!N;wvO-{w=@_%mQ?SEfWT%^IbV+_9I|5Y3Bu)H>p zPL_{Wz(#mp0>(t1`Lt&Np6Z!U(?%H2YrpmON7;CL2GwG$t!<<;J+o?#(fu~wQ0@Ej z1VhLAEvJsOEm$c?@d<|{gM0y$dzbf z;ZB?H@aHc0t&BWRt!rbQ@0ZXv)_;ye!_*BWXmN0D@rzS8+{;gnatSfM{*pIQdGd9*Va)ga_GI_zcb4WQc--9Z=)M_`tv$1ApNE_?tfc8CB zF#_Wnk%DDEYW)g?!v%EZd<{9UoV^GLIFG__J70i5=-h{MjPnO@Vx4z!j#IJxY?yt( z`T{j!^aV}dxBe3uarpfy<-CKl<@_Dzfa7RQ={N_S9GqjE$vDS4{PI+sa|+ImvkT{V zhx<$toHaNnI($wgIea>ea?V9!$nl$HboYS3e;GE&GU(a;dn~!$5 zFKUdl6z8!{EzVia#mLk+XB+(4P9M(Wohxw8ac;nQfQBSQy|FE$%~{EPGjCHWWK!A*-BhcrB-y z&A~YfHEBD4M1-L8dj!Tf{CyJZ@Ye`xwH^`d+Q7R|g02t&uxsZ7CgDLQu|xZ53;qJC z3wG_FLQvSQorE^u6uWlXEo&NT;+gD4fkj}&pM*5DjX8*f6-*E|=I~Q5_XW_#T$AMq z91Fn4oSO6t$P(FU{|=OxiNtjfzEk}?PCVciTl{e&VGLQN`jVGXl|TeYdogY_3ptVv_;tq=A> zkVDqA?Ii!oo2rx~-n6Hz57`=)l4Rvre`9lM1__h(Pci%jonAQ@SKzn@8q#!nKVuSi zft99H{5i=-Na{omF_EW9TFlR3X5meeI+5p?NDxQb9Zd5GvrqssmFCLU^SUPXILHAL zw?2=P`x~VKzNyHRn}g3W$wnM*4)&4kC8=|8D|2u)Nu7h+n1csM>KyE64tP_f&B4jK zojG^~zSNb>!5tbgYtXx7>> z>sS%}S`)`-*w{%cYRhIlxI-Z8-20$*^bKqPfgtl>)vBzwAZ%s0QXEKJ1o|&b{&$R? zuI1R)$NhqIW{_dyj^SjD4l>)>y?BR-m8Jdet`dH3Pv0f@4vqC)N`BYUncy?wKXLpC z0+~7+Pw3q9tvlo9vNQ)YJ%&FttV31>;2nhJJjpB{)@8HK98*Ba7j@`Vc*jg($p3_{lft|PY2d!}q$~EQ}%;s@Tw}GCZ3-w1$(|Ug#?=|bs zZd~22-_riW2!p}Re*&y2mQDr?-N0W3?`-76EvUQEz=jsLUR^qm^j{cxvQ}3Hddwpz zu{Ble;)fK+{hpWoBv*GLZ|F8?mEJ9v#_(1T({U}+6Io~18i9by<=l~V(M4JSvMRJ3 zC#(H;WLtSXs92vRJe2>?#LZP9W-nO&C^(jt|0J`~s#}elREWdeV5R0*YCRMN)Q`aW zx3Yil?y3JDeo5$WD7*U_y&1Gwzc6H{7TFhsU?Oj)7uj7!c52AJpvX=L71%usCg&9t zl+41I9t~a$>Yul)(1wn-3Fj1I+os39L)eQV*?$jMFi#Ino@gg7m^Hm))-pSOJq+#h zPn%Z87x`sv4p=@VmpfL**D>SaslCauW;af{A~)}}nR$EG*gHd0X3fkm&dD#%!@$fF zd&0KtvLe1q@Z`|+l1Y2*{I~3rouY;Ij2rEBA$vy1Ublefv>QLyYCnHTul-94?;~7b zPbw-|WXCVyzJS~XyDr>NyV6djv3##xvi>3%$-|%?hWObbdo#`pa4xp9s_nD|b|=oE z5_|l5yJfRIK2)4{ZXns0pL+t?=itjw;OUUlcPxaCf@)fYJay+FoJtEBUd z%BIdY>Y6gPTU`qybVSFGllZaA<9zWehsy1daZ?|;zA9L?_@TO-Uk=!VbrXL%(4=l3 z$b3hwb`Gm)?;VaAWC+S(!%F|d9Pr;eq(Vu9m8yB^zJcJ8XO9Q%+XpIh_6;!Z>Nhqf z?_HLZZ&j5IXQ_La#lD$u_rvdn#l9Jcx2lrz%ZA4xJiaETsu&j1 zkSLC;e)_oWoHPE${=0@_`!g=X8|$u)sB{oayRT;FO6Ko3J1?tRzw^SH%;6~w`<6XC z92^|no$|pA?^*+&sVKN6t1`Uhf;<$iF(hpXS|Uw2j2*umTnF8@#!2CC8r z$3YGuZ}kuCA9(h_%~iXqo;`3?)#t08K9CI` zaLvHJWoOl>arW^a!`A%D0ek46-9J5eX!SegwH5FEqi^)!>i2G~JD# zFZHNfaeZT_-F%>=YP+NIPlNUNd|0qEO{Q2reeB`6ps%*7cMrUKu--Xx*SiPn_7B`w zk$5!b-SWCS2I2+-!dY-208UN+v=wQ?Q;P9ru0ZUe0$8uBkOkVV3Jzvq$4Sls8}D?? zTN%_k_h;Qv5j=+4EiOP<>|o`%y%n)9ljiP}AaGUxn3|F*u%aX*CV6RVw|c>w3&>W=8A`K)sOCeXxKSu9Z$BKmh2m_2ku5Lv8x6) z`58MahoEsgTE$z51A8m(J&;kA^1=0QxxW1acOI`)dIwCzy~+6-zs-G?NgT)_ONH+{ zT{*t6avhd+gLP$KmwkEgvY7r@-&(Yc5tAdsGkx(JbbRLq3lrGPgK;5vco@fF){^AV z4c4`RYwX>@t7EQ;y)tf>6CuN~(urjJWod>Ue_5y>(UjQuv#2nfPbJ&9Y4G3!VTL3+ znpNj#O$3406zUISa42uNn@5cZH6l1joT`J*G(kjP7Rohwu|LxiTuVvg+!$*NNpx9j zIb>l~BF}_!?d3XU*y$m(ipV}o#OxE(alni|EDjG9G5bVbzNq@}WuGG))ZqVP*{8m! z4GRBnX1~GBKC2<@NMPp#p+S2iswQ8v)(|#m??ys{_J%LdT#)B!R>Vc*rINRZvVo)C zLV&Pin?k|_2IDQ4;UIW?kr8u5WVZ>_vcb6*G@SA&U{&Bi6RiTQbiFK;o5i(+Yh5nR z+HoDF7zZvqp-g-02yXORW^KLZ))HE^w~o-Qy=w^Tpza+iA-;9i&e902<9AI>RD z9@57!eS!&SO&IlQjYbu8d5IB@F_+&JO;jteRqbm{6g0l0qR+Zi$h z`L}f3HN%XnL)WYYxN&M3=WCi5E$v0Ru71RDfHf*+^v#FpyK zZ5N60D4dcFi)QiY{1^$f)`r=`lp%l9;>gwm#SFBiP_7Xr) zZ>fnkqu0u)2Ssb?ZtTTImgQ&T)wbA0(cIF}xvi~3^K`CIn4Zq|9ldRx9pQqM6nowh z&s*wwXOGy|VJe|yjwdzO^PcQ^=Xu`wD!fzT1Pw6yCeStE?q=|BGIIALm_p!!M(k=} zrIqSRGdV2vN>}QYuGA}C>FjV0OUv9#8lf_*$SYr|SH4oOe5LcfYC6H*99#!6K0Co~ zknmm`6e!}(*A;-TkG8e9*LUvdb?;iaXA zi1b@Jn(Hs>>}c`55Z7%M-YpWYjFK{S`s(_{HFfpN)~-II*1R+L1d_A8DxO_JBfB=X zFMm^$4oJ7(9#6ujE4+^j72vT!F#mIO{#*LGkae_k-MULk>rb=+NjDGdHtRNZ6jh%Q zrgTwVAd@Q7Nl}YGM`6G3JFDSFqIdFy>#4p}dHyn=f6hPam^(VVx7C}iG-g+iyOGDt zSGjeIS3rl`3ty#eZfNGeMCaeF@1B3Ui^}wqCRKO0o~JUpHR`Q6kmhTA*RI@IKBzS)jsw)jQt6!e-xiLWWl_KN8}8zOFdT_ZidD06-Olg+*8wE}$= z=GNmn_;yV;cJ#J+`uU0Bi0&iulg7B{d?mYi{^XzWBm z`obu86PAoIJh6zY7SXwQG9TM{dtx7TUwoWI#K=wyHn(irv8De1@9*YLkWnN-2Bfl6 z-3us#cbo}?pFcF{_|wPuNw0zohwsLjFb@6onzRJWn+aPijK3#?#uADC@yZ_^?yoQr z0+b_jw4E}}=&J_9uMZ{`svJD(WAga*pyw|5)0J_Mly+|< zPamR$_3=lPUtc={8^ANpGB62%Rw~d7=+)i?~l+I z{#7D!0QE8szrKUMdQKNPwu3k*^XqF(2GiFLO#W;L`SlG#Uok|Pzf2q^e|q5;bSw_K zR%E`}_3E?HHz`VA>KyO7je(@m$DiWNpK;GZpZ=vT45RP#D1B3*uOBkZAKQb`*A%7i zsWhdyxNn?Et3FEKz0emzp{Oq#htWsd3loPr7L9dnPwA&KVVrmH*Wc6F+`{^&z8oAz z-&Ili{sevN5pJB(cX^b)L(sPzLe$6E8>8>mD1B9^j9Q}%X!LzHN?+Cj*g_(l`a(F2 zzORVBV({p0fxeEYeuz2;L{1Cg6bzksPuq7OXS?QtTC@mqCEDknsEZDliE?3AA5w~M zdo<2?iN5Bm+NZj<(Nn-L!ohN&3F&L$*Y_c8h-jN@oX=}m8vT6kX-oOYQ0CV!P1>I` z(*7KfX6`)qN%piwrXMd;j$*foQWiqplCVmD3uJnU`rXXoV9=Dutu2l{sOPw+Ei%1P zTHdq;*z$P7@bMk(k@6|wcfdCwJP;MiJ#CTlsaikpU)S-&vMJjXq5k@91-ymx<&Q8gkS1aeOupLg`f3JnN5TlY+1 z64KdPpT}WO<2gHGg@^UaJKb|wVDkw0Y?U8H7evv8s>8=&?ee*69O=t(usV2f51e_9 zmV@S=yL%)I-391T`mKVL4QV=6?~8?3JL(&ByAV27%>oc+aN7@F_cmP^mpu2iK7Mch|{9>;vt;iEst3|v6LjOSUCxV9sUljbc;2VPP3;s=zV;Ghr zUNA*)v>@9W!}A2E2+kDLdpHn2U+6`GdJhNqHA2%emU_+-JXero5AxdtI|X+LeoF8% zL7MDQp0>2ay@GtElm3F>mj&+=)O$G)uJ>{PpA!CI!50Pfo(+WmPUtrT-xIWPPcof& z!4$#Kg5w4A1g8kj6f6@g7vygi>eG8PfO@YKQ16Wbep$jF7W}^8tAay7#-a`mFSLn$S&bR7vZ$*h9t^O##P{L_QM|zdev{oj) zQE0u#5cF1|cS!g}Lhlm#8lkl%Ipp^VeXrm*iRgqM5~S%M(>W;N&j|fWi}`Vxt#2kbx4bhgkmfhKi6_mSY^MCA7e5`IYN7li(;U}7xfkgp8l1emu9jwepW zk{c1>vxF`ax?HeE__acxC)g(Z4xx7neTmT53f>}km*CfllQAY2`U#-$wAuG4(>D=6O* z#>bBZ{+{BV%#}pwuO%XX93OM9*qD!BWAwf=dNg2(A&-;|;`X7P?hX*C+To|G+EA$MwHj@CLz~1n&~ONAM9r zJ?=ofr-go2@Q9!uZy;QcH-N7Q|4qSn1!<_x^c}%eLDMb^gx2E>$mzYJKt0X?>h_B3 zqQC0`Tt#`H9$x?(g>Dh-73>q#;|IuHC-hB%`nyNq-y!rD1s@Q6Sn&ITKN9@8;1R)B z1YZ;Uli*u|+#SGnMC)Rrepdl7Rp^jlq2P2uz1I_Rdaox?@AU+(kZ?VY0KHCVZO;u_ z@AU+7D-P4+_5iliO9ZbJ)O$U_=T-rR^FtZLFA3_s*q~|u&vyMC!6yZOD9F744F9Fz zZv}rZ$o&8e9~RW_JOFLmExej8@MOV-g4}Y(@D+lq1lI|! z7pxa-57<) zM}hx>&_@La1z#0BF8F6bZYrU^4+Ql%3v>)R9P*O{^>_>PSfRP$h~fEydfWwCkF$XD zgqcX&|$3xeF%5eQ-aU+~X@ZwqpZ2gBn8@o^zdrwejV1;Zx^a?1zl zd4h`sD+Rd)gyDJ|20T}2JstzyDm3?TQ4Yh3|Es;w`nihxvz+l!Uj3YgKDvM{&l{ja z8qa|wL3DY#Kh6}?&t)+6a~T*SAN@w5;8Y@>dou)!iAc9hQ0D{bFCYypCx&GF0Q^7A C66u%# diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.a b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.a deleted file mode 100644 index 0cefacc4ae7cbcd08b2ef0f5d25201167429ea96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25168 zcmeHv4Rll2mF~G$lJ#R@#7`4LTypIgA_y4SfCDXUWEq6bIA9zmWD>WsYzu7SA6XLA zp0=+t<;SGygq5M0(4=jc>2%Vrwjmm5leDa;ZQ3*)R-bIcdQ+44qFIwEKklpwhETzD z;`i-ye|&XOR&3JOH#3W)b+ykvd!K#w`MLL=z0WzfbZs!w*70%2aw#`dR;^l7wPMZc z>J^gY;UxXPBvn_fQZlqS7-I_rXO_-FUU`ibP|9aHO}5 zZI6Wd0@04n?J?HX*&2w(g0WrE!1k`-jwtJk1=@m0jRa$%Ks3}7?d;jX6MK8MckT$Z z2V+4(Lp{OPu2A67&;ViEJG)|`2xaVQ4YoZ>NjpL@p1n5`Xb*MCnL2wqQHP=#6l-BB7`vlT?y(%9SFyazdax7=1Jl?TH%DM-`mQP~xis zfyVmHHT;jYcc9+AyLwO!Myj`U1bccyU5f5KySkOiL>aYUC>m98rYeX=jPRyY322PA zK%_T@28ecbwxfAuRz>8EH5d(1vXUMQcLJmQYALHQ^!0ax9G9e( zYpRrJi{o?a8~lPG;MS0Xz}##SW2|u|Pq(aO5+ZIkkEj*Vj%X|r3$`LQ&@Dp+Z|m*u zMjNn-&S0b>66@~8@M9IN(I~5kh5C`+9%|jSBd|RZ><+PtNT@3}p{D8nieM}j>1^E< z3n33N$oWVfa_#8s+1@Ls=cLHm=l<*KVP=;m?gbe)EfaAGtbjEDKBnPT_6Xu?FoCmG zMF36A&cZsJBt?NQ(b8<}(^{PP3%TrdTAGbLsl|ytgB=AP)6#70>xlR3@Na8z;-AUO z*V8HgR;`jY_5hK>u6dE~Mk(4tfDQ z2K*r6#5Rjr*$)sI(&49o-vfL;uGtt5|3r)kG{z`DwZ$iJd4LoBUBsP;tMX@IAbt^P z4=ePAz=85HMf_eGs0dUhmEQ<_0P(kR5xougdc;>MIBWYz^Uk)`=4kKsSQsyYK&7V{ zPtxAL&fcCK&3*C%B^unddsVX>r$9j`G9^-dCY0QgElz zO}IMe?p?#maXV9bU{wyGvQkN|&P`sy%G(vny}1mOX-@G(vZ)NEZ-x#EGQ^$*tg)^Dw;3`om*rK#T?p-+XI*U@{bd2{Q| zW@*{7p5DN&o=9(3mmKfx>FVqW$?;fgFet~OZ5^TZU7+j$9_nfD4EB7it1}ksBF?t( zu8-CBMlf)f-M>OwMoHU|w5gZNX{U)`8=vDzWze%R(z}D|=0`h5o2h*t7>LF~-O=Xt z-L0Ya_E5XDtvB*$YpAEKLqaPDs+xn5?&kVUwax1qAgWfLF8X(MbyakfNz3Y|S^0_z z)cPhe;qA}6{^oL{R6g~MbfVI&y}?L(^JIVj!9?Cv#d1{p;1b#+ox4MkD6i88>~Hig z4Xyyqw4_+auI^T8+2(Gx`h?lf7Mjy;|HSX!o#-z4*Th5}>)+?QdKR!$7&He@p0D(R z_NwayD>tVl&evY@Hs{+5KG#Xt3Co-0Xx7OADr=1(L3Tv(8#Fv(|9 zy2W*po(0P;WNKLXs{2d*`?5nW%jF?qV?SF`kZLN~7#>MjmI$Ll*~ak1rmBN`=0BP6 z4Au>~itFO0^v_q<#i{hVp`W|6Ba7;Uezv$Eb<`)0LEEs9w%-9AP*SD?Z^%@91H1br zzb#$r_j0|hwYE!wEpUA(OSO!zzkHT0XDL?BmcKpBN(=p_^u~F6vT;v+iFxt0v-A9O z(i0nJXDg-RyXN}}Q@^l{B%0#w;xEt2$ZcFXogg-r}-O^zX(sfnZ|dXNsINFk`R^R?%v*nQazZfz4{O+3Yrl zt-~0dhEOcb6Xpva0t@UaCZO6(6wQK7bO>l(=D16q!xy4(n(r3g z&e$Tr1wg74`bQ`obiV={34(7Y(eIFL9q~@azN)03ru2D?T_jk_SeDX}U&1Y32u;Yg z5tlLc5Wx@2^L?VXD)c86_$)z`^Id|V{|wLpPfwa4I)ZE%u}rpAL^L$b%S8!=38p47>ChWmbl6U{tmm)}dmDd8O498PZtM z^Zg^QXf6+7mAI%aR1w67;im;ODG&Mh9@n^(_6A;!i^}Eg4M_5?=oC@qtyTB{csPZI zYETg!tVdk0dNJ-}YAR)gi;$W7dG1x*ImX2kz4t|32jJS>=>D0~y2KyBk1^Spx11TboEcO0 z){;L89*7(#gzO*r;I4=dF5&;ZGXu}B_=$o#0iFO$9qaJgy@I)Z$R`YwM?m0Ku-97T zZLvS+W|GN2BRx?+-(QpUNWyqhe4qvY!hF9YxH0H0NhU=1Z%4x$;_z(<9q|rZttDkb z%*KQilZG}x+N&szWlyk0tNcs3oh|v3ciYm!U0?8))Yg~0k$B9P9V1B_>h1kQz8PbF zSoTSA%fOt0kNV8RLYa77xHO~oU(Y=`aN(TCFQ(Zd;+EWxj9^tz6cXFyDEspOujb?30YvxWXrEj?Cw0^DSK*{I9 zUBJ0t_Rb>-t~)sImph2_W$&!oBQ3Le3IqP-4&?p4^^#B|TrYZe(?zHA)smOJH5Z)% z@x`H^P&Oz1Vc#sSmxbiIWT{p~DoK&03T3R~@bGQ^-3z`~bG7#B%qPxGY;<+Ff{h)G z!9yK~f~k&F@RHJw)Rq+J{WDeHgx-Fje6aQ5Jy2|07yv5~7cn`Uj!aCKwLtkixI~*G z>jU^AB*@9p4|6xJ9}L3j=r=jXk>^S^@I_emnfIFxkS9XX7jsrF8*|}5gk66dM1k@%)+JJXsT>49qTK=UM{?fe;P6Dq_I zjJEUB5OjoBDwnYws6P8j?lj2dA*>P?hM-m#;*)@@0YjY!qfJbFNnHUdAI-IO$?OV* zuTx~`fzbwA4TFc;0oBg2nT+!4z(;AuV3fC4Cy)C@kb&xHly?|>Q_+un0IGiKeVk9; zdGIwDl>=Un3nVS9gi@+J+)_M{JfqFI4t)9a+X-I1ydm(lAdT8j?P`)2!=>+!^WanI zAZcL_VtRQQ@VSvj^3-uk@|IVwmW@s2U$Z&ayob$Mb#Il-`u_Vok|+~FvpHvw=F_%0 zX}+%P_K5WI%}Tl3JEp$hgKJ~>)3+t<=crNW)J_6M*cJ}uHW$#+4=HrYM|iV>6ENYa z)0TtVxt%(hRKWYMQMFkMZzhQ$}jq()LrcHlUXv2AZu~zt9_lC%o@z;T zz|3lSE9?2mn^~L7E}X*un^~vl4#b?E+dJ;FTQf7QAFq9?<-v|>dqHMqfu}ar@@5tf zJv+)KiWz@99G-~E6VJ2jk{%p%fP!k(n>X z**CXjrLgs{utJ~NAD?l_S@cQZ1%G9E;eTg~lh7#nR@U{S=By{~98WsY*U5&9Hrws# zQ;Pmnx*WHhIhkTT=1!gFGJbW& zeEQDx?vksC%@-fCy#z{e>NQTedgkwamxoCzTHsjW_$lYJSwDEi!$1uqoU z72Ys@3Xfrb!4nqhLzmo#vuZzaPVXzn9l%^gMP7nxAUe$xr)pO(RWkz89Ku)R-fQ1y z+iyKkFl0Gse$4a**qSv(jizUWqHA7ZhNr=E zTFs<`M%(at2>&VxGlX*BG>20|9oko2$5qn^l5I$QAoI|U2=$p7&~!Z9i+{2WRMKe} z68d_nWvRB8N;C4Q>FXd%%|iu{?WLbLQyK-DYwK+my-lU2lU}X3pj#M#hxf9nBA}}I zh>>in)qtdz+6E*~p2#Yv0I=U(wSlTD^V>kxtEO%PHP1x>Ivc2rT4LHZ(0`7-?jJ=( z$R26OC8A~NS@Ea1$`t&QfOn&MLkivnNI}9ywiM;HfUffI1%4LS5?mzj5FoZ>D1BsS zUqhTu#gG|E^lt*Hf%eWHQxQN~r{hjmEzQn;jChF-|AiJOekc1C@U2>!o&A#*CwdWI z2ivWs+4)`)6*a-yx1ug%Y6A43bul%VU`;ImKDl4r&f8{^K9^O4zDUbsXZLAwD*raN z2{`$dtWD#k{KdRI^mNKU7wxIaivTay;hzRxqQmzBmvlJoD=*jK zPXSkhiOuKb>FKohy+X%Nduh~QLeHE8zD`Fc{q#8Pxlsezvj0bilP&vO15SJ4)j<5S z=|)!q@t5gvqOS!`S?Hp@@O8kKLm#?jXQMwKR`^x=cHk#~v;z`d+Y5s(kXjQM$GgT)85bN7X=6rBXcvP^oG``~US~we(!At2Fi2$Sc%2=dt8tU9`RW zhI4kgN9yvOm{X6zaZgr`*qmct?|*JU^>`?QMm?maCf{&+?T@jiUK_x-JRr9`Ah$dq zQ}lqiu&IvWP#=<9EBv}&2y(Y(E z$7og7#r`JiWvXl&WPdpQ_gSwC6z}6c$B51EU0~#JVvqlz&rY-wBh3XZup$nxgfC+f z9pQ<3R~fXY^>cw?zrKASSvJcjq~!JX@Cm1%cC#nhz5ze)<;{DJ zS^S$btgxB4Y=M8dAFUU+jlXU`k~Og-)Nk0eUtjWbFLnrzh!Rp=N5`4t&g+j|FV5b} z1ow=T=)N;$cGsnB@CJ>(z7Ni`P1V;e% zydP&L_N*@%du9DQDcd+^;D>PBP|kH^$TvRR$lH!|?3>TNJklSZKj<49qdJI;ydq=g zCZOF9;7<{Up>0YihX$@e-=m|lo;%VqY*X}YTyGw;@tO+d-N;LQkF&^O(tD!59(yaq zkxBiNr8b|Kk|j*kCD97^U3uUIv^Pqyj8F@Ci>Wp1&dEGNdF{D*x|U$>S5tB;?^$mf zbMbN~%fx1J(w6s~$Y!IT(2r<4fw!I4dh`sXINWBXEJ5S+K{7LZb+^pPoF4w$Q2t!-MxxO$GR+8Q@9;PE# z-?n7i=IrGFk;{Y=XgV_Aw+*oIg3HBTiRs9lw2x)GT{}}E`uL#|-VP|7%f5Yjvdd9- zHIU8p9=<^jF9VA3GT`)@j{b1(X@UF%T-IHREDV;Ll{HtDwMdb*5dBD-Sw7&o7d$hW z!zTOJs_*0<4`BpJ@9I*0CR>BmV>WX@3mpSjyNh073fJEoNP}k_%{^#yM#l|0^}wB)qoBw>P--G>IfqL!$e2< z!uKiZ>oEj8c`{# z7n+s_7yga@Y4Qm@!5cwgQUI#N{T*uRx2eB*BdIAeEI06xzcyb$H|6-9IUiL{3B27A z&&Q`%PtB5#Pf~>es`9E4r#!qL0jbsSJ>tCYm9!N2s9i}% zwdyoRjPlapt5fpmfl;0t14Wg`#}b(H$y*J+smP1#`O;O&PI(a2Jc@HCw+dr)8^BeHx z>))MVu&Ydf9(3w+xB=<@P}51j7%uf*MwF%SV1mdS!XBik`H1*7_~?B}@+4doxIF&# zqexW#^wH$`s`vWN*Q)AjWpmv7?{#}kR!rOLRzjNp7hUIBgZ45(eVT*N`6@494LY`6 z!9M{=SEGXW0#f_ZMc+XBJfK;*2!9fBHPHF2BPs$&-$eR59Zql2Zvn5+(yT0@#fjg+ zegwQ(OS7^!v^de7{H)%$wKOYBBd*8)8Tc_BeO!xE{vxiAo_-y45$z!dt1eFbE;b9a zhjjFLTAb*!dHE9BPt8wruyP$)vXJz>CK0sbQRnsCv1vtI%KGhFoTBf>8M zQXoLu~zU(L(4;&q|_Cd)-BTB($;i&fWN|8^cDVu0ZduSnjvp z_)`27+}9-I|2<38MEr(WWhcq3Xt4I8)2~Wfiox=W%&;=g2lj4Q9?>7IGkzXWU9`X=*Z==7?EMk;iz)-| z)+))ZRgzn)BvV`^!94NA=Z}^63%+7~M)(r@%Q^ls?mH%b>jd^?{z#lNP@D0Z=JeH< z2;qBAPK7(Jac7R3pS65tVpDbh1om_O4By~kWmSC>8*lIbUEfn#bJCf4-D%2LO$`@+ zVp@Uk^1P^gm&c-fmq#2wz=DF%*I(iaXOvZf@Cl3G=ASETxiN9g=9%YDTywN|{6juA zCLr#VTuMAs>?&r7R^RNz9$&#(s?Se(eaz7C==h*u1C`cn=&L_XC2Vow@aC%%*z3ub z2q}ui6SUsawBQl!;1Ew!dUn`}SW`(oyMB)F^C`3W*QdR#X~8pzgNZNrgwaRldrRtV znRCl7WH)0S!@<{IY)@ycUTTBA7WaVHj+e1LaQ)!5r?VDDD>dK0=49VT9ln3f=6ccR zJiFg#IlK8veA^2DUVo9_k>2Jn^dHCWO-p*ncNrA6&E$XF?<~s{pBg_^$;NAhgNeTx zcd~ebq`f}x)r9Zr#HTl3@iso4HOFn4q!3?x`>^-&4(Wi;H0ry0r15}H9K}k2!=CnD zUJ*XvGmm;NSB3AJ|7wDvG~eZCT%Y%Q7mF#{jrr%p^?qoxTS)J=eJ|ngZ^1rO+mh^P zrT?h19`W)e%S>^ko*hh>(=T7L&J;%LZ3h#qjI^QBy^H4#Ul@Avon*i^di0&-mV=2W ze1&7ycf8wPO<2>yJISUe6R+S4Qo=jlEf?a82Yz8KIAim(%)9u)5~KaI>4Vs@DxjAz z?JK=Fw59k7v=DuR=|8~n+qgBIoVUkkMv6Bh@|5#K$KLS<#L?&8@iv~1v$9J6Lwv;G zT&Ms15b3pNJsZP13H<)+gcq}WC5({N(d=G^Gp1PGFk^M&UHlk5ikxJuu1Ua$VDt ztJ>-i$!)uuBCL08g2p_e=sZ`E4I6qoI+v4BCD1%Rudg3;u0Nb4T>ojVRiGKQKz++) z!H3OdAz?cD>f3_s+Pr6D@x3Q58=DgU5Wau1oyZ4IKB7W6+Q=7E2q&snNnfX=*D2|( z3cg*zBLvH2TULah_$A=vga4tDeo^6TLHmn7~;Mk^gpsp`q|NEe7s1C zpB;J_1NCjbfM#M`2Zcy{Q}w5(Q3=Y6>hb_}Z}6vo8w_4vS%pafMt}NmQ1PeqiYR>O z8g37(x#?_dzEFuoY9m#IdWKfzMU(STjen}M>i;G_(oqd6-&!OPpBg-PzR_4UhI%CE zRnmXoiT4@k1dZ};=KD^(&)-8Hec!1OG-EL8=fS;5{X|`&K4bFf=LO$X>N}*9hbRyE zqkeDe7l*Pm{peXqf#eze%fz&fQ*-}z0=4Us)`8E3flK|%pB;cCFNRA$p2?rC Z_7_N6*n^l}UOV_&kVf+88BT%Z{a;Fhr>Fn` diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.txt b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.txt deleted file mode 100644 index 1da507468..000000000 --- a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta1.txt +++ /dev/null @@ -1,6 +0,0 @@ -QTouch library for AT91SAM3S-EK board version A. -Modified board. - -Burst pulses 5 CPU cycles wide. - -Slider on pins PA0, PA1, PA2, PA3, PA4, PA5 diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.a b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.a deleted file mode 100644 index 052f0090c7261bc353e64440b911e5f927b819be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18058 zcmeHP3vg4{nLhVQwyq!84j~kXLoZ;6N#ci$F(#pjEMZ3mg9$h!O`J-yEh7`#k|mkS zQ>GCK59iG!o5#|WBs1*{$UW(ribVu+7GKxV!A~N@oN~6NTnqg9**-ZurONp7TG>f1dZ;|3Bx*GZuM*t-hPH%j9&hR?J^mWi79&tdQk$&eA_+ zxw5KS&EU>vj7?!o{QmgDRW~zc3^TVgR`M@ng_ho6DC`OZ{jID$=!p!*4feG z3WYu4-jJ)k)3YYTdcv+&52!&;*y{>;yF(q_YdF#0-QKar)#eF%2=#V*S~|V1d%b;x zwRd!ey+O*@+2U!vmq=^8VV>O|bhUXql}sJo9SRXTUEl2p`&_(IB;MuqgnEPClzt7T z8u){}T0w6})k#%Saw?4?y$ZqAgP+nStVJ@r1lYR_UHV2QbR7l`?PPd1l>$N@W_#?(F+&8|nl>z~oavV8v_{W9+#+ zPS2=hG7`mXDsf9gzEC(A_Ou|?*QLZN-sQcpM>>}cr?dy$6(lzgNQxz==axBC@(8bzsn`cvNy zGdrDJ0Jel6A_y##H6Y%c!Y%A>q%|->vPDA>n^+bL=y1{$0$!S;N$h*6G|A_%hk#QV z3P|h;Es5B~Ca@O~M^ZG2y_8B5KcD>^_=;2`B=!s7ck1w8rO98x>!;@rf&Y+B{+%@W zE7=L)Z|nF}o*q8~{9PUY&%j4?xH*+(Y$ABs2K*`mK0}9J0r?UgPWf-q;ly96!-;>F z4kvz#4kvyHcmZNF!W9_b?*re2G>KioEbKufHtO(gz{`M7N0^B5e1!x7G)E}^FM)p> zp#nJZ-$XhWX-)qJz#m4SF(&>;NaK&s3BvPeq5-H(Dt|igKBPwwh;IeH4C(7soVDKA zytcKaIpl8-2e5>?tmVyEgZw=m{_Zu+J<5U*^7O8o->jtRm2YL?jxMju-|p)4U~Q-6 z*VPr`#2{9BZwM5;Y4j3Rr@eg(SrJ}GqPym&F|1aVT$N6qr;-<>ljpOdHkFfJfE9vV z{lfGNKsni3t|hbrtrg0$tS-*FC0$vwFZ}}j|LlXvSbfb(xn}vQdf8Ftxc++C;qMA` zbb5pG>iMOW<)sy+^Q~3om1TF#tB~9MK^e>K#Z5Z7WU=fCFSLd{UGqYfgoUu8Q{1$& z#!>5Ps9jy#@GZ`8)if=%&Reyzc6E)twyCDVC71Z+3!mxU?*^I|(>J5Jv1M(uTvFog zZtL)Lf2*@29Pac2Zw>T*%i#}VN|h{|CzlYZ9i-*{Zc4V1ans7}7I`L0T@m!Jp_($Jvz9QncYBGU2<*2lC=_qf~Cr1v}8_7QZLh);v0TmrUhFH7u=aUtU97 zuw$J!7~*aElH-lhrOD+Y8%7TMdb?WWl13la>cC!e9h;q8ULFyOEyKli$xlB|b`}0{ zpggk4{^@Yi$z})}%%1(n12%A8tKQ3slFN#@tjuNG3XcvHM>ay%y1!sAmk%Tx%(6Q$ zNtSyuWOvUWka{5?$Z~*mGkL^aupi&c6A1?^`XCXD_9r&lq%#|ZrIA^??=Bo3$he*z z7G^CCB$rn_c>lB~2Ff=$`wON-2M!cx96nG@xA!l^9Q;1l1zi8k2TGrL5X8<3g zA}S;9!=AjoMBao>AxI_04c(ofequZ1l70$cEaFhFQtcL$*5e3^p^G zh|0FY`srs6F?nI+rQOLTS4O53&9djjekBbLI2J#dh}wiXEN-#<(pKqs0GO>%Jd-K* z+fNQZo7l+qA3yT|dktO6A-*TsFgucQsx~v(XgO7vc_tvlEy6)&?Fsah_p$hYF;m&!rf?gV_jErLa~m?X25 zA!SMyNs_XpY$?Z*E9J?$jARei)$a}4!W4ZSS7_UAjYE~ zZea?@Rw4bSP0)@s*9(J%>$Qwe@1&Gg#RjR#lQxo8t`q(!*O@gwow82n2-5aEd81`h z=H`qo=6=(Ix;n#<;`(zgUO(AoslMJK+`;?$H)@~ctNP);Tx?&HU3X4j!_egQh5=eb zgYEHpS~{3egruXQw7iOCq&`M0GuyH(OPnA~5vB^$gsUI|pM?n%kPt<)Ac@&RCek^R z6}vV2n~E)(14*(8r(@u$jl^GsnE1<8yoqASbrO9lW7||bM))@r8fs-Tpm zGD+^KF$7VxQa6?NCgMTZ;8ag^8HWNqQI#}(k3hho+VYB&@y>t>Bwvf zI%ppn{m&>SY9`rUc6$%Y2!$8QOF%YOyf&>2q+FC=;w4^mTCno%!fp=hJv4(AfTDB3bz>e_W^h6}jN< zIvm^5DKOy!K>DL8ic-I$I{YU{f2hOvrqcYg!3GWZZw>hG4fqGZX^p5xn27fN2V$DX z)CYve5fjimMEgHUHLcQ1?^}dpF3;_gogJTPwyR0R85+wwwKBcGtgxeTdP{yu2B4c{Adi z{f#fbmGI>?duX*~9YK}UN<}>U=*b3$1lf#lv@;H4?Prt9WjR9$k9Bp1w)v_?j@PDoHtqmFC~5r!w#H3tUm5;Z29K!o4C8F4mz&L63C`qqmW zq~jFB@1t+MNSz{>NBu~Q5BG=Aw-_?+9P+t17kL|B*g`Cr<47gF> z+d6&PdkfMz^*ern`pVIG8g~pcZC`L8eMbMv2D!2NZ!KiOO2I}TD}a$cZKz3K7(qWC zZ$VDugO!5&k<#mX7f3N^q)(ftq_51X-7-QWvAe>Q}8u)3S2IJ z>WvF|xJ!o%Ai<76*dOHE#yCTaH*VU+W^xcwWiRW8xbiCo7=9`!$#`DFQ zj&1I{)O3a89ryQ^WFt&-FLU4HzAYik!V{*aB1?oHuWE(i{)h+a# z>^5&-?QX(za!XUoB=-l2pTGE1^Q0qePQLF@!aPVNvuA|o#b?;_tgP{4)?5`6pHEt5 zA8Bp8HZggyXoS7Sb8|hD++Bq~8Tiif1(Ev-7X*?6Vp+yvQ<>?oxlA}LT)QA3Z2$e* zn{B42P1{-NZ)17BM&Hd2_H_OTgGS-Vy24Ke*z@;E>=_YHrNje=*c{<$b}gIpv$|b% z@1aj#J7!t~ z9Xok17fj5vjnc;Fv)rJ|NZ&hqUeU&^P10t|mdyT)2h9(e9>&>WO

    n?fGh$>j(l z3|+F}McC4p!jGYEJNa@A6eFyl81{{uV)$Zh6vHs}QLGu1x_Xbt@95R#(~`7@4%I2x ziPQ)JnwQ#tC;QXrcRT_kVISy5F!~+TzD`nR0P0V&Gc?!(2Mb4v=K%Q~B**jR~(3x-8_YQXxw)5|BidLH=(a? zMOcp@Vx(xi2xJ5SBh!TV8ieZ*h~J7>1G-mB1}2I(K*y zNS#K2z8|F0Gzat8%fMex(X!Zp0pAP!fR4{MoK)O|nMU=|^C`cqO>UI;Ch#I1egt^2 z4u2o`4LbZ7@Nyj<2d;q$mOhoI=hHdFVx2sdug4|rg#w-Yh^Yp=Scgvpe~}I+`3B%b zqCodl=?<|K+MI%szq3?mR896UR2d zQ|g;8+%DV`ohuC07Yesu$?scYK?jfz`M|CR>hf{-^3epWzM?yMyE5x?PAz4PCv91- zggKgZO3FAMncFAe&Srh#0h?INhD7;9M4A>In3|9Zgt-%9;@rxZdG4y1G?&E>M+@+L zIV$6MJo?dyP_(v>ZgtuPUnIL&JUlNkQO+LOov^u)D*rpXFch3Fj%>GEhJuAJCTuum z%8uCMxKkIfP4@)`2MYEnwOZ>;);}1j3A`~<+-I|xkH~UXLSmhPe;C0JHQ-_XY~Xlg zv)w#w=JcI`y(9QhNPJJU*=dWgVq5%`=)yW*AC22fBd`*WFgZGKBGPYPF}zCEydz>O z+z}|o{nBbSD6y?&F?Q`g)-~WfOemf^?5Zt{ZKGaNxPRMkpLD32_t%L?&$Mj`lN_D4 z!ESzMXF%Y+nK800fw@xrNlYsKI2I}V%|P~<%7RRlRKml(DlYN2PMwA{{mTD>5`HsZ-LQ(LTk_Q%AK+_`(QA?7}LA3mq zk6T{ph-|QnLy;-Iz}?3bUH^7$a(!~i6Oko>mm+NL?_ydX?y^hoC?$_-#pOWM&^CQX zAa}%vKJuZDY?eJol<`#b2}N?9N%1IOQ)bub6K}{Vn>g^9O}2hkzzU|ZfdHAA<2nl? z8%6`NN7C-N!q_LDjqc?ZBfijcMLMF=fNa{DJo83j6>gs*&HV_NJX|lFi1Fx^HKmBj zmQJ19Z4uU|-EF5{~{HQt@1*DgP40#BWk#>T}8;CO-0SRq^Lk{th)BB>pV;94h{w z6eC{&>PB?(Jw#dYIdG!SeGL)LKKU5pG{twI`jU?zlHt za1D5W0vSt=_q{5pl{J=}tSLjR=`)_?Qn^m85;{4W^O|l_(~J&XObG+j1LtF^(qDia z^()npk1=9ur%~T7$T>kbf>B>Wrw`ML!&v$xFjp9r0XOQq6LMPp^k=We`uQN&d;$7i z*Xbj@1Y^~Y?&wk(MljZ|0QV8J`r)F@Nz%T_A3f^7FjWr%?A)p_RHpr3RPUE4` zNnaR2KfaHkGf>5I;C@iFe8hYfaw`y%KDw_#!1eK8nFmA4Pt0|9Z_o1|3#^qD>S6L1 zpAD~9CU0tw%R)6D_a2wwC*exf)1LbNpmW}F?>8vTZzZLF{c}pSu*;tCWl#8P>Iv7} zfEP{u-PBAZ$Nb&YU;Nb+y{YLi9=pSyo|R+xT=BJ0V?~gV5$F?3YbF7$??$`hSAu&Rco7o%^{ZN0Gc|T9CObj@9U-}~+VMZpZw6NY diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.txt b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.txt deleted file mode 100644 index 4ba75e960..000000000 --- a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevABeta2.txt +++ /dev/null @@ -1,10 +0,0 @@ -QTouch library for AT91SAM3S-EK board version A. -Modified board. - -Burst pulses 5 CPU cycles wide. - -A Valid key on pins PC22 and PC23 -A UP key on pins PC24 and PC25 -A Down key on pins PC26 and PC27 -A Left key on pins PC28 and PC29 -A right key on pins PC30 and PC31 diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.a b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.a deleted file mode 100644 index c434ea543c23cfff5a108a99693fb39b5f6aee7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25190 zcmeHv3wTt=m1f=BEp@9UL?aYOk~{cH$XLQ4B=ImL&brltwpx}!mKoc@%5=A+h8EVN zrEU>vl3BMf7~yzgAa*{3?F~4Y?2dyyxCauySd^z@51UU9^JOAD>&~t>JmmQzSa2F9 zi}pWtAG&>M4-!uD?d-?t?{?LxbL!No$Gx}Csj6Fer@y;7_#bRbq-3b5T)yg#<;$0s zS4vVjC+YtsX~ohNN(P^eF*c7e(}I~@H+_pS<8|u_#wsBv)m4XbuD+Ujy2BA~sJpY7 zZR`$odBefhjS<$?+T;yK{E?opcVnA>QJEeznWU1OQ?3-rl@q+}{_rE-a7WmHKBC}Uh7w=y z_11gVRmp$!U(NqmOAt-a+0%g_I7th&=%pg))uss%&LgIn!Lr|))Qb<6wieccsAY)O3QPCt|w#;mQ+fB>VQHb zf#wKXVi>sB8n??T)N$^!MLK($mCo{ZManvt7*f1V{&0Yjm2`io6&U4LN?EpQRqDHA z*{TZV_VC#rT~p^41OYdR3<4`*Qy61)vw3>jGA1EX!t#k)77m6Z-4TBiVtws$sNl_= z?d@m+R@Un8F6)l8cVZy2vZipDl|=%*NN))=^=$HP?Dn?@SXp8F3NFH)+YVFwADW@l;$l53W>+4}==O*s}*@{cVC9rf>hwupvx3Gs1SHT3% zCKW+wVi_!?!%0#Y_(Cns%D$?_i9eIeUah5B*&Z!U^jYix@Q9XXW#2`-SBD?e;>16j zm#?Q&{`FcVt?W(UjXL}%N%`mS{CfHb=uhhS$CCKxvNOO>>*xmz_<7(T>FECod_sqt zwK!urpxF%gXAF3u0e9-~Imln9!%5y>>TsfW8SuZ>;lw{xSH_6{X#@Rlf!mR8#x)1y z;}Gzjh!fi!W?^q4GN8kc1HT=30j?a3hu;t*fW{c*r?&Vqu5#c+zk+xc;;Q^P7>Iv^ zv<(XVR^UMSm?C~B4O9S?N#)lA??e1UTtsgMz6SAS3eK88-?+KCsWIHSF%rTn!CO(@ zhzDtBS8Hd-rp7M$ffDxjY+2DL$LW#L%p$Gr0dMCE6UY~ zT3|(`{F+f-Ho8}o{0>4@{;hYywO>MpH^cS3m;OJS5@6^tPgR3dwf26GRK2A7_S>cE z&h}7iTcBHdV0qcH^0LaZmk}1m zTZF>(4OP`^ymf0HSX1{!PViQ(UsbX6{)ROVxV+NhPHFl#M&K)<#?|zSYFyW}xlvlY zxTDkC)6w18)+WbWJK9=10&+ak#gw!WNozZ~oEDl5HuH&|R0KWiyE`{gwcKdJa3eMC{e9s`pgr8UroAc9 z(h_Kq9_;LXq$$wR9F)+&-pWRQcYC8}ZFS@7I*6*4=Zx;2wzjfhk+j$|!^)SHq1M-t z2`_%$>(`eXrSkc2cPlF0)ambTX`JfnKbpwvs#ub0pI$;sck7lwcbM1dQ}#D{mj;)Y zCRtJ>*wfx5Ene5o*vcbjH@npwFL6)){>o&#<6mNvHLQ2L>*JFM3x$5O|LExoCuqm) zM_92rE^)pV$A_G68~E%;?MFCoD5FLQP1czuUnp0Sy3!z=;EoUY5}3m?YJi`a;{7~1rH({et-Nl2R|d4Oo-FOF znlKBcU6n_R+Evt zWzBX>W#e;=s%-l<({}M2LPNIsr$758pRb5%^1MRCWMw9@b9J(5UR0HB-3H0BOiYYu zt|D5lUnb>Gk_o$;%gmUWOnn>Be9D!bw=I2p+T-ROrU6agS&D2-+Gf%Qdf7DhtIE!z z_I+GpR4$EHPJ+I~TMvB=`gVrdB2tBU)Wq zR=$FzY40MIZnNB*A!l_R)Kg$^0 zAZ#9xN`?M;N(bGog!L4HZ!^(vmhBwz7RLUQlKvj0=QDPe!a~Lpl#cuoZt+ZLLUxU~ zn6ZZ_{G2@3Cwh}Y-=l=jQ;2e2p%C<+BecQa6Q>XzLH3JSB-<$>8k*+hqJ+W()X+?q zncIUjDK{Y*Hx8el!`x%I1^9$LokH{zNQ|LfF^n05j$mO7Wm6k5lx+m+-&6n<OYcQCp}Yh!4Y012idzRD4frTuOTbhkK2e%i9}ql6OI;h$`<+g%1ITU!bAt zR74kg5Z9}oi~E?`i<(AFC;g4`iov%U=|(Wh3+m)iUlF8|*E>ylZ|UUGJxGvB-f{5N z$>gMeqkef1qSjY-0_Ui|FK${Y;Qbzir^Fk;zH_M*WWKqg@U+RGdG(O4_d}~}OINI1CUaif-?my-O!K$plIH(T{cUt#?ZnlBDu{S`-pgB1 z{xbnzpM)p-+vsT<03DBT1uQIxSc!^)t_={RneY^DGSD9dUa#Zdp~ZRN^W=8_cChQ~76XcFVpBIG>vtcb&*Mx%(A&Zn7U| zC3%E2AJ4L6uZ`-gG5Crq6(5elSA@*m$8(3`$}ujX=shp$5&+lkYS+)SRww=pK8&fx zyy3{W;mDYdla_o@@IE9tAY|Xjr*}hqdI^7eM@IBWdW`@NKw1q8Iy0Pt*)!l0hRG8k zaO>A;$#(iO_Lnfpg1>Q3>~WGI|GGv&L#+=?{wc_08@3g3CNC6p5FGbF-@d<N9gfGqozA&mcjl7>`^}tpUywLoch0Ha>&xLO4EVkv z^8UecPRJH6XJ1)+HY@9x<8^1%*(`zhqR>w$nj8O|YYx{djpW*8sTM^lNs*-rMXc=U z;hWrB=KY}R*$E14SLdot&=ufZN1$@YtR>06-?@%=yvX|6>6i8zI@pJ}cnQbP&mDLWi}#_dV8 zH@cA<*W3`>xY~ zll`dzJ+_`u5rl;AGvF@*CtW{6nK|^doBpz8@@64#la$j!L$!R6A|ToJ+ZT zOSfaqxLGX8-HSNa*R7|w|Tc|x463~{z2mKd~y6o=A7r&C+63uf4@3WSfBIU z2Z`@Cr;qhaD$lEmopNte`j> zaIr=25B&wW?f}R5i6_?GmY6$8d}mLw1(ojfc>3Q}B^F3l{=dZ`mVJDZ75+`aY|nOo z!@bk}sHf6x3(aw7#^<_ET1+Rtde6NfFT zqv_wjALV8~%@(nVA4anduE!X#J!5~__HF1C+PLn)M8%+G{705YgRo7l1@SlB-m~xi zm2hH<{q-a5=v^k^bJAcs49o@8xe?S$Fm!>uaFiIh1iu$naj?dFjWT>->o=Yd#vDbxyKv zNEGh>ZzO#}$b8rR63WZGY`gr=33llAvo;$zGVcM$2Z;;&q0gZ)_nYTTv&|zPB;to| zPZY2WjQIGW%<*?^1&PeJK1dwjzc6t#b4*;ZnTAOsTJjLpYtO077i`}?T21!@o4*=u zMI-%%gjo_6K6>Hdzh{ftaGsmS{G%8C;g$67e>phso`PDo_?DrYJvq-eB#NDNO>&s! zGd)9hf;_(XSZl(V!=`K z<5Bbe;6qLOgL%HWhp>0yDS8hR*t4^p_MB`dM|6KQhn%k6y-1gj<|(f1l5H8=t&dxF zqz|O+G(TbbI_%J@?2zdlf z`u6|>NrQUyiE2MlIRq3M?I*IcRd-)5kCdEW&eA5Tcv>V~*H`Be@EU=O@z?^L8- zk6W>Pg<>FG+unI7m+Pe2J4Mt&Gq!jB-`M~D1ytoLxLRN2J# zpgdYHQ^5oaY##8bJ?t60ZKmkCYz62Gv^*K?E-g;w-^A7eCqI%58SFs=z5)1Q9lcqL zQ~o^O9(p?E&qaHx^16ZN>F}=tcj)kKz$G0{d(De=__u(oU}6QlJUyNE!+t9wnqkOw0`>6NGDzzb3~u9{jENN_;RUooJ%>$L<^|8 z174VBWBp{KcF;-1A~<#>6J!&cZNdpA^)wNWV?VNTxG2;aMwE_u@wHOJF8T7Q?fJ>p zKQ_s$YpeRRHx=rVt6>v9GV_&KgLrW9WZHzUbKz8~%e-_5K%cG_iqf?e;))K}tR3C~mXw-9SYVuVF+Ws8A6m0Dr7%eei*5Cz8>B8bf0*ukSMR`e7#i@q9BBrv@0}O6D<_u`RmDQf8KR@tQ>pB zLr0W+=D+RR*q0Xf_m=ZA$ksgK`u$kwsGTHB;<(dfE47VQChY7x2`5u!TOs>%@qb7- z?VvcHblFC%Zs$BBM;7+|_q#HP<}lLi&?0(d(qrp&O_)SmXwqXZg7&nwE->uj&*&R0 zn&T3NO%gHFWcR&-IxRPk#UU$-0)l z=$-GxK8zi3EgFp$_OAz($vREqEI`!+)#sM@VOQ=*YXR{W_xEv1@oll#psaFwShZTz=wmUg8cWl*}3uOKur5m(&bdOW4Fn z)Qq7wekL@&pMV)^vN-h{xM^LFBYFvd#6VLA0HHIts5y;Y&##!(V;S}Z3d$qK2G zn>dByvAEoVRO*1sGHTYSBB=iue<1-o3MIWAZK-kgvJ&USkE2Ml%hKOW%3U}5uu|II zgot+CiGM1UO{`>tR$j5@w~+6nY~0pUFHpuU&f1i-iz}TTh}L4=mkBps~gm!PjLn97D+aaMC8rb_? zkBrKCZc9LnMbWzb4unBimOlM>so@992=5bdFvYMn4On9RVEgxNn74`BFjNP zp&!w90&hE~<-iF_v6YyWx(LOTLvkNIeMR%P$fFJaCF}%~qOs83beA~A*d?b_ammi? z1q^92R|$gY`e0;}RL)0p)ui(f*SW8Nmf=-ci3pduUD!Y;7P!r=+fy(TUG;K{xLo@- z^LEqY+8GPG;v2$V+v}Cv!sVK`2_a~UIM){j!ZO4~7!EU$t8ZJfYm@esfXHRSu`?5y z*K7l9u;6mBCt@aYr)*={X4lS{h%SE6gtr3<=dwRLGug$cy9#74eS)8_oRksd@y`(}CxzYXWlDFojuN=W_;!rw=jiSV}+BHtB+Ht1^=WIPX{4TYBw z4mo8Mq8t~6l5#etkTLQH5KewZl1IJ=I>+^6gtkSDy^E0aazG~=oPL!QqCP7TQa-Ym zZ7_RxQ3wayvkLw_g?@!_$eD+{#J>`u&4PMU2st$rBL4=Wqx>L+;M+>+rHnnU;NK%0 z1Llx|4-$@iza$*_%&05T$=4ymnMpnlajERv5N~JPry(wseG}9k~e94@TDyIN%cf?ci>D5!Sq~eoQ zVF*=u#yw9|ZjDOR@!g5IDx1U%pyO6k!~h=PyziCtC`u>lb0)tODS&``05n8J}~yj`#O1e4Rc7P-$&qEuNS1mjq;p$rht`?7xlfL zN?twqXbc&_DDO#~yaI(emAvPtDes?j@*FyO8xY6sA5!%>4Zc+UyBQ1_Digv*=+ynV zvFQF#(@DPwF8%#>91kXlyb87=Ma@UVIQZy&N%ACI1Y92f8d7&y{uGk-jiXQe0@(5u zE2e$sYEV{8TjOz%=KoIDcvhjkOi-WZAav%+iLeSC+oIsKr;V<91@A;i?MoMZ6X`L8 zX5}J$58^7&nXSDlf{^yi{bwCcZ_$^4muYDh7SrOyZ{zEqjar(8y`#m6p2g4a9n{h+ zERMJy|DV7Q>FDEHobqRLef0Fppo`i-wCLi*Z)bBrdq_vm*WyIa;pIzcKN&214pywg zE0XwgdHH&}6ZAWE{Ba1<;~vnRI(kEryqmZ@J>3ubcXj+EPmgZ~{lDnwVVyjB{%+Ud zH0P;EDrVfs6sIvk^jzRebU1zU z=vL@U&q|`tc+EwABs8;@)-CwT8^dO%Hg9K7B>B^Ce3>N7__y%%KKtZPw<%nPkNog; zj^t$rzJXF+|G=7sZaqT#B+)0Ha?=(+k|k}WudwW+cjp&ctebQb~EO7l>A6L4X{HOTf-k)K=sWRYhtdQJTA-S`F+1}rGeJf!e%$j&R%QRsz)t&u`X(_(b^Q!Wlo;2kvKd z<`;ynUWYw2p{x*uj-V#$>u9}54hNvfOwW^eKuin zQX6bbE9rA);6==LL_V8HW3)>1!%JE0hp593FInxcy0T6_?n*nk?n3mzrS5I+Y_~1` zpgYrj*q!c9ix0TYgTfv(xu0}r6;0$FA3t8f#;b&#vG0s$v1p8>y`6t7=K6T@tLrW} z>z_@Sqt=N*AzJ#`Vdwcx(hiqt)b;V+`W-HD6srKXjJWgs($Ef%zonh5LZA7V-MIwAtc_hwY4+ z~1oRT7e1&HR?#p`$EkxgB`aj_K zUDOgE%-`xVBgHu(@|4p9hb}t3;^_X1&id0)R#f4Bh>sYY>vW$UAicJ(VPjY$fzN-n z@M>b4gb^}yAhC^^_{xSED;q~opLl7;emIree_{wYp9#Bl-r_Zp9-yI)R-zR7j+m%di^LjpT`iP@_P z`ud|czt)cvnF^F3obEaV&Dm6-`JLi_rv0CJ<-lo=Ci$~w`n{)X%Dv7t4hg!bK=u!v z$>eJhJA{qgVg9z_gNC1w>zy?-AGBU?njdTOaWa#)2PW8Du6<^5RXd$@C%djH8*3eF zp)rprI_D~~VL#8L4~t2t0yKwD>E{QX>kkJB*MElV6lg{bsExQR_^-JvB+Nu#eOr)C zoAUfCzW>B!V>99(!|zXa6Zzj!eU=F)8~I@};XrjN>8q9W8YR6+!8a;+H-$yA9V@~| z{2FlbzrUrVpH=vLXn&GRHXQLs5fa}oDHO5i78iwQmGFWRl3zYkVmJnmdkq~*_9w|% zL}8I^Z;H3UpF=qK9zaNPT9h!Ng#S?q2M|)eCkdY~+n3@3*{&qNJNL8Gx3lPnc7Z7F zKnFWAD85;AI+h-|gPi-=G3H_2aR)UX3sc|ELjNPnl#d;K#>b1K_}HO`5vXrd0h)<% z9TXz*P1lzmM=cDUgb+a2nHvwtiq%OMqfJZ%igV5MBzi%a9dc-9o0L&)I@|8 zxTuX(5yVIOsDLKtumb;7XWqUDiH~$tLFKy>3B;$uB0S${tQx_C1iec7?>+H81D!&n zyzBYi6Yuj+kVoHpst3&oM*SAyUZi%RE>WK`sr0)OeAB7#Hk~{~Ii!;JG>CNyT^|_r zi|gd6{g+DK1o+nL1u1c(yw&iztM#R45%m8TWCWwUT{?NW3UexX`@uJz`hKL7 zN6$(El4tZS{{eifIW_rjGtdlOk`tA+W8hN%@@EG^k{7|HAJ61VSNjVj4Ynetm*)eY O4{0Qip5X)}@BacpN!1Pj diff --git a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.txt b/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.txt deleted file mode 100644 index e5a666bb9..000000000 --- a/src/ersky9x/libraries/drivers/qtouch/libQTouchIarCfg3SRevB.txt +++ /dev/null @@ -1,11 +0,0 @@ -QTouch library for AT91SAM3S-EK board version B. - -Burst pulses 5 CPU cycles wide. - -Slider on pins PA0, PA1, PA2, PA3, PA4, PA5 - -A Valid key on pins PC22 and PC23 -A UP key on pins PC24 and PC25 -A Down key on pins PC26 and PC27 -A Left key on pins PC28 and PC29 -A right key on pins PC30 and PC31 diff --git a/src/ersky9x/libraries/drivers/rtc/rtc.c b/src/ersky9x/libraries/drivers/rtc/rtc.c deleted file mode 100644 index d0d04959b..000000000 --- a/src/ersky9x/libraries/drivers/rtc/rtc.c +++ /dev/null @@ -1,467 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup rtc_module Working with RTC - * The RTC driver provides the interface to configure and use the RTC - * peripheral. - * - * It manages date, time, and alarms.\n - * This timer is clocked by the 32kHz system clock, and is not impacted by - * power management settings (PMC). To be accurate, it is better to use an - * external 32kHz crystal instead of the internal 32kHz RC.\n - * - * It uses BCD format, and time can be set in AM/PM or 24h mode through a - * configuration bit in the mode register.\n - * - * To update date or time, the user has to follow these few steps : - *
      - *
    • Set UPDTIM and/or UPDCAL bit(s) in RTC_CR,
    • - *
    • Polling or IRQ on the ACKUPD bit of RTC_CR,
    • - *
    • Clear ACKUPD bit in RTC_SCCR,
    • - *
    • Update Time and/or Calendar values in RTC_TIMR/RTC_CALR (BCD format),
    • - *
    • Clear UPDTIM and/or UPDCAL bit in RTC_CR.
    • - *
    - * An alarm can be set to happen on month, date, hours, minutes or seconds, - * by setting the proper "Enable" bit of each of these fields in the Time and - * Calendar registers. - * This allows a large number of configurations to be available for the user. - * Alarm occurence can be detected even by polling or interrupt. - * - * A check of the validity of the date and time format and values written by the user is automatically done. - * Errors are reported through the Valid Entry Register. - * - * For more accurate information, please look at the RTC section of the - * Datasheet. - * - * Related files :\n - * \ref rtc.c\n - * \ref rtc.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of Real Time Clock (RTC) controller. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */ -#include - -#include "rtc.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Sets the RTC in either 12 or 24 hour mode. - * - * \param mode Hour mode. - */ -void RTC_SetHourMode(uint32_t mode) -{ - SANITY_CHECK((mode & 0xFFFFFFFE) == 0); - - TRACE_DEBUG("RTC_SetHourMode()\n\r"); - - RTC->RTC_MR = mode; -} - -/** - * \brief Gets the RTC mode. - * - * \return Hour mode. - */ -uint32_t RTC_GetHourMode( void ) -{ - uint32_t hmode; - - TRACE_DEBUG("RTC_SetHourMode()\n\r"); - - hmode = RTC->RTC_MR; - hmode &= 0xFFFFFFFE; - - return hmode; -} - -/** - * \brief Enables the selected interrupt sources of the RTC. - * - * \param sources Interrupt sources to enable. - */ -void RTC_EnableIt(uint32_t sources) -{ - SANITY_CHECK((sources & ~0x1F) == 0); - - TRACE_DEBUG("RTC_EnableIt()\n\r"); - - RTC->RTC_IER = sources; -} - -/** -* \brief Disables the selected interrupt sources of the RTC. -* -* \param sources Interrupt sources to disable. -*/ -void RTC_DisableIt(uint32_t sources) -{ - SANITY_CHECK((sources & ~0x1F) == 0); - - TRACE_DEBUG("RTC_DisableIt()\n\r"); - - RTC->RTC_IDR = sources; -} - -/** - * \brief Sets the current time in the RTC. - * - * \param hour Current hour in 12 or 24 hour mode. - * \param minute Current minute. - * \param second Current second. - * \return 0 sucess, 1 fail to set - */ -int RTC_SetTime(uint8_t hour, uint8_t minute, uint8_t second) -{ - uint32_t time=0; - uint8_t hour_bcd; - uint8_t min_bcd; - uint8_t sec_bcd; - - TRACE_DEBUG("RTC_SetTime(%02d:%02d:%02d)\n\r", hour, minute, second); - - /* if 12-hour mode, set AMPM bit */ - if ((RTC->RTC_MR & RTC_MR_HRMOD) == RTC_MR_HRMOD) { - - if (hour > 12) { - - hour -= 12; - time |= RTC_TIMR_AMPM; - } - } - hour_bcd = (hour%10) | ((hour/10)<<4); - min_bcd = (minute%10) | ((minute/10)<<4); - sec_bcd = (second%10) | ((second/10)<<4); - - /* value overflow */ - if((hour_bcd & (uint8_t)(~RTC_HOUR_BIT_LEN_MASK)) | - (min_bcd & (uint8_t)(~RTC_MIN_BIT_LEN_MASK)) | - (sec_bcd & (uint8_t)(~RTC_SEC_BIT_LEN_MASK))) - return 1; - - time = sec_bcd | (min_bcd << 8) | (hour_bcd<<16); - - /* Set time */ - while ((RTC->RTC_SR & RTC_SR_SEC) != RTC_SR_SEC); /* wait from previous set */ - RTC->RTC_CR |= RTC_CR_UPDTIM; - while ((RTC->RTC_SR & RTC_SR_ACKUPD) != RTC_SR_ACKUPD); - RTC->RTC_SCCR = RTC_SCCR_ACKCLR; - RTC->RTC_TIMR = time; - RTC->RTC_CR &= ~RTC_CR_UPDTIM; - RTC->RTC_SCCR |= RTC_SCCR_SECCLR; /* clear SECENV in SCCR */ - - return (int)(RTC->RTC_VER & RTC_VER_NVTIM); -} - -/** - * \brief Retrieves the current time as stored in the RTC in several variables. - * - * \param pHour If not null, current hour is stored in this variable. - * \param pMinute If not null, current minute is stored in this variable. - * \param pSecond If not null, current second is stored in this variable. - */ -void RTC_GetTime( - uint8_t *pHour, - uint8_t *pMinute, - uint8_t *pSecond) -{ - uint32_t time; - - TRACE_DEBUG("RTC_GetTime()\n\r"); - - /* Get current RTC time */ - time = RTC->RTC_TIMR; - while (time != RTC->RTC_TIMR) { - - time = RTC->RTC_TIMR; - } - - /* Hour */ - if (pHour) { - - *pHour = ((time & 0x00300000) >> 20) * 10 - + ((time & 0x000F0000) >> 16); - if ((time & RTC_TIMR_AMPM) == RTC_TIMR_AMPM) { - - *pHour += 12; - } - } - - /* Minute */ - if (pMinute) { - - *pMinute = ((time & 0x00007000) >> 12) * 10 - + ((time & 0x00000F00) >> 8); - } - - /* Second */ - if (pSecond) { - - *pSecond = ((time & 0x00000070) >> 4) * 10 - + (time & 0x0000000F); - } -} - -/** - * \brief Sets a time alarm on the RTC. - * The match is performed only on the provided variables; - * Setting all pointers to 0 disables the time alarm. - * - * \note In AM/PM mode, the hour value must have bit #7 set for PM, cleared for - * AM (as expected in the time registers). - * - * \param pHour If not null, the time alarm will hour-match this value. - * \param pMinute If not null, the time alarm will minute-match this value. - * \param pSecond If not null, the time alarm will second-match this value. - * \return 0 success, 1 fail to set - */ -int RTC_SetTimeAlarm( - uint8_t *pHour, - uint8_t *pMinute, - uint8_t *pSecond) -{ - uint32_t alarm = 0; - - TRACE_DEBUG("RTC_SetTimeAlarm()\n\r"); - - /* Hour */ - if (pHour) { - - alarm |= RTC_TIMALR_HOUREN | ((*pHour / 10) << 20) | ((*pHour % 10) << 16); - } - - /* Minute */ - if (pMinute) { - - alarm |= RTC_TIMALR_MINEN | ((*pMinute / 10) << 12) | ((*pMinute % 10) << 8); - } - - /* Second */ - if (pSecond) { - - alarm |= RTC_TIMALR_SECEN | ((*pSecond / 10) << 4) | (*pSecond % 10); - } - - RTC->RTC_TIMALR = alarm; - - return (int)(RTC->RTC_VER & RTC_VER_NVTIMALR); -} - -/** - * \brief Retrieves the current year, month and day from the RTC. - * Month, day and week values are numbered starting at 1. - * - * \param pYear Current year (optional). - * \param pMonth Current month (optional). - * \param pDay Current day (optional). - * \param pWeek Current day in current week (optional). - */ -void RTC_GetDate( - unsigned short *pYear, - uint8_t *pMonth, - uint8_t *pDay, - uint8_t *pWeek) -{ - uint32_t date; - - /* Get current date (multiple reads are necessary to insure a stable value) */ - do { - - date = RTC->RTC_CALR; - } - while (date != RTC->RTC_CALR); - - /* Retrieve year */ - if (pYear) { - - *pYear = (((date >> 4) & 0x7) * 1000) - + ((date & 0xF) * 100) - + (((date >> 12) & 0xF) * 10) - + ((date >> 8) & 0xF); - } - - /* Retrieve month */ - if (pMonth) { - - *pMonth = (((date >> 20) & 1) * 10) + ((date >> 16) & 0xF); - } - - /* Retrieve day */ - if (pDay) { - - *pDay = (((date >> 28) & 0x3) * 10) + ((date >> 24) & 0xF); - } - - /* Retrieve week */ - if (pWeek) { - - *pWeek = ((date >> 21) & 0x7); - } -} - -/** - * \brief Sets the current year, month and day in the RTC. - * Month, day and week values must be numbered starting from 1. - * - * \param year Current year. - * \param month Current month. - * \param day Current day. - * \param week Day number in current week. - * \return 0 success, 1 fail to set - */ -int RTC_SetDate( - unsigned short year, - uint8_t month, - uint8_t day, - uint8_t week) -{ - uint32_t date; - uint8_t cent_bcd; - uint8_t year_bcd; - uint8_t month_bcd; - uint8_t day_bcd; - uint8_t week_bcd; - - cent_bcd = ((year/100)%10) | ((year/1000)<<4); - year_bcd = (year%10) | (((year/10)%10)<<4); - month_bcd = ((month%10) | (month/10)<<4); - day_bcd = ((day%10) | (day/10)<<4); - week_bcd = ((week%10) | (week/10)<<4); - - /* value over flow */ - if((cent_bcd & (uint8_t)(~RTC_CENT_BIT_LEN_MASK)) | - (year_bcd & (uint8_t)(~RTC_YEAR_BIT_LEN_MASK)) | - (month_bcd & (uint8_t)(~RTC_MONTH_BIT_LEN_MASK)) | - (week_bcd & (uint8_t)(~RTC_WEEK_BIT_LEN_MASK)) | - (day_bcd & (uint8_t)(~RTC_DATE_BIT_LEN_MASK))) - return 1; - - - /* Convert values to date register value */ - date = cent_bcd | - (year_bcd << 8) | - (month_bcd << 16) | - (week_bcd << 21) | - (day_bcd << 24); - - - /* Update calendar register */ - while ((RTC->RTC_SR & RTC_SR_SEC) != RTC_SR_SEC); /* wait from previous set */ - RTC->RTC_CR |= RTC_CR_UPDCAL; - while ((RTC->RTC_SR & RTC_SR_ACKUPD) != RTC_SR_ACKUPD); - RTC->RTC_SCCR = RTC_SCCR_ACKCLR; - RTC->RTC_CALR = date; - RTC->RTC_CR &= ~RTC_CR_UPDCAL; - RTC->RTC_SCCR |= RTC_SCCR_SECCLR; /* clear SECENV in SCCR */ - - return (int)(RTC->RTC_VER & RTC_VER_NVCAL); -} - -/** - * \brief Sets a date alarm in the RTC. - * The alarm will match only the provided values; - * Passing a null-pointer disables the corresponding field match. - * - * \param pMonth If not null, the RTC alarm will month-match this value. - * \param pDay If not null, the RTC alarm will day-match this value. - * \return 0 success, 1 fail to set - */ -int RTC_SetDateAlarm(uint8_t *pMonth, uint8_t *pDay) -{ - uint32_t alarm; - - alarm = ((pMonth) || (pDay)) ? (0) : (0x01010000); - - TRACE_DEBUG("RTC_SetDateAlarm()\n\r"); - - /* Compute alarm field value */ - if (pMonth) { - - alarm |= RTC_CALALR_MTHEN | ((*pMonth / 10) << 20) | ((*pMonth % 10) << 16); - } - if (pDay) { - - alarm |= RTC_CALALR_DATEEN | ((*pDay / 10) << 28) | ((*pDay % 10) << 24); - } - - /* Set alarm */ - RTC->RTC_CALALR = alarm; - - return (int)(RTC->RTC_VER & RTC_VER_NVCALALR); -} - -/** - * \brief Clear flag bits of status clear command register in the RTC. - * - * \param mask Bits mask of cleared events - */ -void RTC_ClearSCCR(uint32_t mask) -{ - /* Clear all flag bits in status clear command register */ - mask &= RTC_SCCR_ACKCLR | RTC_SCCR_ALRCLR | RTC_SCCR_SECCLR | \ - RTC_SCCR_TIMCLR | RTC_SCCR_CALCLR; - - RTC->RTC_SCCR = mask; -} - -/** - * \brief Get flag bits of status register in the RTC. - * - * \param mask Bits mask of Status Register - * \return Status register & mask - */ -uint32_t RTC_GetSR(uint32_t mask) -{ - uint32_t event; - - event = RTC->RTC_SR; - - return (event & mask); -} - diff --git a/src/ersky9x/libraries/drivers/rtc/rtc.h b/src/ersky9x/libraries/drivers/rtc/rtc.h deleted file mode 100644 index 2164ae24e..000000000 --- a/src/ersky9x/libraries/drivers/rtc/rtc.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for Real Time Clock (RTC) controller. - * - */ - -#ifndef RTC_H -#define RTC_H - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -#define RTC_HOUR_BIT_LEN_MASK 0x3F -#define RTC_MIN_BIT_LEN_MASK 0x7F -#define RTC_SEC_BIT_LEN_MASK 0x7F -#define RTC_CENT_BIT_LEN_MASK 0x7F -#define RTC_YEAR_BIT_LEN_MASK 0xFF -#define RTC_MONTH_BIT_LEN_MASK 0x1F -#define RTC_DATE_BIT_LEN_MASK 0x3F -#define RTC_WEEK_BIT_LEN_MASK 0x07 - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void RTC_SetHourMode(uint32_t mode); - -extern uint32_t RTC_GetHourMode( void ) ; - -extern void RTC_EnableIt(uint32_t sources); - -extern void RTC_DisableIt(uint32_t sources); - -extern int RTC_SetTime( - uint8_t hour, - uint8_t minute, - uint8_t second); - -extern void RTC_GetTime( - uint8_t *pHour, - uint8_t *pMinute, - uint8_t *pSecond); - -extern int RTC_SetTimeAlarm( - uint8_t *pHour, - uint8_t *pMinute, - uint8_t *pSecond); - -extern void RTC_GetDate( - unsigned short *pYear, - uint8_t *pMonth, - uint8_t *pDay, - uint8_t *pWeek); - -extern int RTC_SetDate( - unsigned short year, - uint8_t month, - uint8_t day, - uint8_t week); - -extern int RTC_SetDateAlarm(uint8_t *pMonth, uint8_t *pDay); - -extern void RTC_ClearSCCR(uint32_t mask); - -extern uint32_t RTC_GetSR(uint32_t mask); - -#endif /* #ifndef RTC_H */ - diff --git a/src/ersky9x/libraries/drivers/rtt/rtt.c b/src/ersky9x/libraries/drivers/rtt/rtt.c deleted file mode 100644 index 9285beee3..000000000 --- a/src/ersky9x/libraries/drivers/rtt/rtt.c +++ /dev/null @@ -1,136 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup rtt_module Working with RTT - * The RTT driver provides the interface to configure and use the RTT - * peripheral. - * - * The Real-time Timer is used to count elapsed seconds.\n - * This timer is clocked by the 32kHz system clock divided by a programmable - * 16-bit balue. To be accurate, it is better to use an - * external 32kHz crystal instead of the internal 32kHz RC.\n - * - * To count elapsed seconds, the user could follow these few steps: - *
      - *
    • Programming PTPRES in RTT_MR to feeding the timer with a 1Hz signal.
    • - *
    • Writing the bit RTTRST in RTT_MR to restart the timer with new settings.
    • - *
    - * - * An alarm can be set to happen on second by setting alarm value in RTT_AR. - * Alarm occurence can be detected by polling or interrupt. - * - * For more accurate information, please look at the RTT section of the - * Datasheet. - * - * Related files :\n - * \ref rtt.c\n - * \ref rtt.h.\n - */ -/*@{*/ -/*@}*/ - -/** - * \file - * - * Implementation of Real Time Timer (RTT) controller. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */ -#include - -#include "rtt.h" -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Changes the prescaler value of the given RTT and restarts it. - * - * \note This function disables RTT interrupt sources. - * - * \param rtt Pointer to a Rtt instance. - * \param prescaler Prescaler value for the RTT. - */ -void RTT_SetPrescaler(Rtt *rtt, uint16_t prescaler) -{ - rtt->RTT_MR = (prescaler | RTT_MR_RTTRST); -} - -/** - * \brief Returns the current value of the RTT timer value. - * - * \param rtt Pointer to a Rtt instance. - */ -uint32_t RTT_GetTime(Rtt *rtt) -{ - return rtt->RTT_VR; -} - -/** - * \brief Enables the specified RTT interrupt sources. - * - * \param rtt Pointer to a Rtt instance. - * \param sources Bitmask of interrupts to enable. - */ -void RTT_EnableIT(Rtt *rtt, uint32_t sources) -{ - ASSERT((sources & 0x0004FFFF) == 0, - "RTT_EnableIT: Wrong sources value.\n\r"); - rtt->RTT_MR |= sources; -} - -/** - * \brief Returns the status register value of the given RTT. - * - * \param rtt Pointer to an Rtt instance. - */ -uint32_t RTT_GetStatus(Rtt *rtt) -{ - return rtt->RTT_SR; -} - -/** - * \brief Configures the RTT to generate an alarm at the given time. - * - * \param pRtt Pointer to an Rtt instance. - * \param time Alarm time. - */ -void RTT_SetAlarm(Rtt *pRtt, uint32_t time) -{ - SANITY_CHECK(time > 0); - - pRtt->RTT_AR = time - 1; -} diff --git a/src/ersky9x/libraries/drivers/rtt/rtt.h b/src/ersky9x/libraries/drivers/rtt/rtt.h deleted file mode 100644 index 749aa4db1..000000000 --- a/src/ersky9x/libraries/drivers/rtt/rtt.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * - * Interface for Real Time Timer (RTT) controller. - * - * \par Usage - * - * -# Changes the prescaler value of the given RTT and restarts it - * using \ref RTT_SetPrescaler(). - * -# Get current value of the RTT using \ref RTT_GetTime(). - * -# Enables the specified RTT interrupt using \ref RTT_EnableIT(). - * -# Get the status register value of the given RTT using \ref RTT_GetStatus(). - * -# Configures the RTT to generate an alarm at the given time - * using \ref RTT_SetAlarm(). - */ - -#ifndef RTT_H -#define RTT_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -#ifndef AT91C_BASE_RTTC - #define AT91C_BASE_RTTC RTT -#endif - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void RTT_SetPrescaler(Rtt *rtt, uint16_t prescaler); - -extern uint32_t RTT_GetTime(Rtt *rtt); - -extern void RTT_EnableIT(Rtt *rtt, uint32_t sources); - -extern uint32_t RTT_GetStatus(Rtt *rtt); - -extern void RTT_SetAlarm(Rtt *pRtt, uint32_t time); - -#endif /* #ifndef RTT_H */ - diff --git a/src/ersky9x/libraries/drivers/spi-flash/at45d.c b/src/ersky9x/libraries/drivers/spi-flash/at45d.c deleted file mode 100644 index 72fffb031..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/at45d.c +++ /dev/null @@ -1,253 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup at45d_module AT45 driver. - * The AT45 Dataflash driver is based on the corresponding AT45 driver. - * A AT45 instance has to be initialized using the Dataflash levle function - * AT45_Configure(). AT45 Dataflash can be automatically detected using - * the AT45_FindDevice() function. Then AT45 dataflash operations such as - * read, write and erase DF can be launched using AT45_SendCommand function - * with corresponding AT45 command set. - * - * \usage - *
      - *
    • Reads data from the At45 at the specified address using AT45D_Read().
    • - *
    • Writes data on the At45 at the specified address using AT45D_Write().
    • - *
    • Erases a page of data at the given address using AT45D_Erase().
    • - *
    • Poll until the At45 has completed of corresponding operations using - * AT45D_WaitReady().
    • - *
    • Retrieves and returns the At45 current using AT45D_GetStatus().
    • - *
    - * Related files :\n - * \ref at45d.c\n - * \ref at45d.h.\n - */ - /*@{*/ - /*@}*/ - - -/** - * \file - * - * Implementation of At45 driver. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "spi_at45.h" -#include "at45d.h" -#include -#include - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Wait for transfer to finish calling the SPI driver ISR (interrupts are - * disabled). - * - * \param pAt45 Pointer to an AT45 driver instance. - */ -static void AT45D_Wait(At45 *pAt45) -{ - SANITY_CHECK(pAt45); - - /* Wait for transfer to finish*/ - while (AT45_IsBusy(pAt45)) { - - SPID_Handler(pAt45->pSpid); - } -} - -/*---------------------------------------------------------------------------- - * Global functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Waits for the At45 to be ready to accept new commands. - * - * \param pAt45 Pointer to an AT45 driver instance. - */ -void AT45D_WaitReady(At45 *pAt45) -{ - uint8_t ready = 0; - - SANITY_CHECK(pAt45); - /* Poll device until it is ready.*/ - while (!ready) { - ready = AT45_STATUS_READY(AT45D_GetStatus(pAt45)); - } -} - -/** - * \brief Retrieves and returns the At45 current status, or 0 if an error happened. - * - * \param pAt45 Pointer to an AT45 driver instance. - */ -uint8_t AT45D_GetStatus(At45 *pAt45) -{ - uint8_t error; - uint8_t status; - - SANITY_CHECK(pAt45); - - /* Issue a status register read command*/ - error = AT45_SendCommand(pAt45, AT45_STATUS_READ, 1, &status, 1, 0, 0, 0); - ASSERT(!error, "-F- AT45_GetStatus: Failed to issue command.\n\r"); - - /* Wait for command to terminate*/ - while (AT45_IsBusy(pAt45)) { - AT45D_Wait(pAt45); - } - return status; -} - -/** - * \brief Reads data from the At45 inside the provided buffer. Since a continuous - * read command is used, there is no restriction on the buffer size and read address. - * - * \param pAt45 Pointer to an AT45 driver instance. - * \param pBuffer Data buffer. - * \param size Number of bytes to read. - * \param address Address at which data shall be read. - */ -void AT45D_Read( - At45 *pAt45, - uint8_t *pBuffer, - uint32_t size, - uint32_t address) -{ - uint8_t error; - - SANITY_CHECK(pAt45); - SANITY_CHECK(pBuffer); - - /* Issue a continuous read array command.*/ - error = AT45_SendCommand(pAt45, AT45_CONTINUOUS_READ_LEG, 8, pBuffer, size, address, 0, 0); - ASSERT(!error, "-F- AT45_Read: Failed to issue command\n\r"); - - /* Wait for the read command to execute.*/ - while (AT45_IsBusy(pAt45)) { - - AT45D_Wait(pAt45); - } -} - -/** - * \brief Writes data on the At45 at the specified address. Only one page of - * data is written that way; if the address is not at the beginning of the - * page, the data is written starting from this address and wraps around to - * the beginning of the page. - * \param pAt45 Pointer to an AT45 driver instance. - * \param pBuffer Data buffer. - * \param size Number of bytes to write. - * \param address Destination address on the At45. - */ -void AT45D_Write( - At45 *pAt45, - uint8_t *pBuffer, - uint32_t size, - uint32_t address) -{ - uint8_t error; - - SANITY_CHECK(pAt45); - SANITY_CHECK(pBuffer); - SANITY_CHECK(size <= pAt45->pDesc->pageSize); - - /* Issue a page write through buffer 1 command. */ - error = AT45_SendCommand(pAt45, AT45_PAGE_WRITE_BUF1, 4, pBuffer, size, address, 0, 0); - ASSERT(!error, "-F- AT45_Write: Could not issue command.\n\r"); - - /* Wait until the command is sent. */ - while (AT45_IsBusy(pAt45)) { - - AT45D_Wait(pAt45); - } - - /* Wait until the At45 becomes ready again.*/ - AT45D_WaitReady(pAt45); -} - -/** - * \brief Erases a page of data at the given address in the At45. - * - * \param pAt45 Pointer to an AT45 driver instance. - * \param address Address of page to erase. - */ -void AT45D_Erase(At45 *pAt45, uint32_t address) -{ - uint8_t error; - - SANITY_CHECK(pAt45); - - /* Issue a page erase command. */ - error = AT45_SendCommand(pAt45, AT45_PAGE_ERASE, 4, 0, 0, address, 0, 0); - ASSERT(!error, "-F- AT45_Erase: Could not issue command.\n\r"); - - /* Wait for end of transfer. */ - while (AT45_IsBusy(pAt45)) { - - AT45D_Wait(pAt45); - } - - /* Poll until the At45 has completed the erase operation.*/ - AT45D_WaitReady(pAt45); -} - -/** - * \brief Configure power-of-2 binary page size in the At45. - * - * \param pAt45 Pointer to an AT45 driver instance. - */ -void AT45D_BinaryPage(At45 *pAt45) -{ - uint8_t error; - uint8_t opcode[3]= {AT45_BINARY_PAGE}; - SANITY_CHECK(pAt45); - - /* Issue a binary page command. */ - - error = AT45_SendCommand(pAt45, AT45_BINARY_PAGE_FIRST_OPCODE, 1, opcode, 3, 0, 0, 0); - - ASSERT(!error, "-F- AT45_Erase: Could not issue command.\n\r"); - - /* Wait for end of transfer.*/ - while (AT45_IsBusy(pAt45)) { - - AT45D_Wait(pAt45); - } - - /* Wait until the At45 becomes ready again.*/ - AT45D_WaitReady(pAt45); -} diff --git a/src/ersky9x/libraries/drivers/spi-flash/at45d.h b/src/ersky9x/libraries/drivers/spi-flash/at45d.h deleted file mode 100644 index 34eb957fc..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/at45d.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of At45 driver. - * - */ - - -#ifndef AT45D_H -#define AT45D_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "spi_at45.h" - -/*---------------------------------------------------------------------------- - * Global functions - *----------------------------------------------------------------------------*/ - -extern void AT45D_WaitReady(At45 *pAt45); - -extern uint8_t AT45D_GetStatus(At45 *pAt45); - -extern void AT45D_Read( - At45 *pAt45, - uint8_t *pBuffer, - uint32_t size, - uint32_t address); - -extern void AT45D_Write( - At45 *pAt45, - uint8_t *pBuffer, - uint32_t size, - uint32_t address); - -extern void AT45D_Erase(At45 *pAt45, uint32_t address); - -extern void AT45D_BinaryPage(At45 *pAt45); - -#endif //#ifndef AT45D_H - diff --git a/src/ersky9x/libraries/drivers/spi-flash/spi_at45.c b/src/ersky9x/libraries/drivers/spi-flash/spi_at45.c deleted file mode 100644 index 14f952ecd..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/spi_at45.c +++ /dev/null @@ -1,311 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup spi_at45_module SPI AT45 driver. - * The Dataflash driver is based on top of the corresponding Spi driver. - * A Dataflash structure instance has to be initialized using the DF_Init - * function. Then basic dataflash operations can be launched using macros such - * as DF_continuous_read. These macros invoke the DF_Command() function which - * invokes the DPI low driver using the SPI_SendCommand() function. - * Beware to compute the dataflash internal address, the dataflash sector - * description must be known (DataflashDesc). Dataflash can be automatically - * detected using the DF_Scan() function. - * - * \usage - *
      - *
    • Initializes an AT45 instance and configures SPI chip select pin - * using AT45_Configure().
    • - *
    • Detect DF and returns DF description corresponding to the device - * connected using AT45_FindDevice().This function shall be called by - * the application before AT45_SendCommand.
    • - *
    • Sends a command to the DF through the SPI using AT45_SendCommand(). - * The command is identified by its command code and the number of - * bytes to transfer.
    • - *
    • Example code for sending command to write a page to DF.
    • - * \code - * // Issue a page write through buffer 1 command - * error = AT45_SendCommand(pAt45, AT45_PAGE_WRITE_BUF1, 4, - * pBuffer, size, address, 0, 0); - * \endcode - *
    • Example code for sending command to read a page from DF. - * If data needs to be received, then a data buffer must be - * provided.
    • - * \code - * // Issue a continuous read array command - * error = AT45_SendCommand(pAt45, AT45_CONTINUOUS_READ_LEG, 8, - * pBuffer, size, address, 0, 0); - * \endcode - *
    • This function does not block; its optional callback will - * be invoked when the transfer completes.
    • - *
    • Check the AT45 driver is ready or not by polling AT45_IsBusy(). - *
    - * Related files :\n - * \ref spi_at45.c\n - * \ref spi_at45.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of SPI At45 driver. - * - */ - - - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "spi_at45.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Internal definitions - *----------------------------------------------------------------------------*/ - -/** Number of dataflash which can be recognized.*/ -#define NUMDATAFLASH (sizeof(at45Devices) / sizeof(At45Desc)) - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -/** indicate if the device is configured as binary page or not.*/ -static uint8_t configuredBinaryPage; - -/** At45 device descriptor structure. */ -static const At45Desc at45Devices[] = { - { 512, 1, 264, 9, 0x0C, "AT45DB011D"}, - { 1024, 1, 264, 9, 0x14, "AT45DB021D"}, - { 2048, 1, 264, 9, 0x1C, "AT45DB041D"}, - { 4096, 1, 264, 9, 0x24, "AT45DB081D"}, - { 4096, 1, 528, 10, 0x2C, "AT45DB161D"}, - { 8192, 1, 528, 10, 0x34, "AT45DB321D"}, - { 8192, 1, 1056, 11, 0x3C, "AT45DB642D"}, - {16384, 1, 1056, 11, 0x10, "AT45DB1282"}, - {16384, 1, 2112, 12, 0x18, "AT45DB2562"}, - {32768, 1, 2112, 12, 0x20, "AT45DB5122"} -}; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initializes an AT45 instance and configures SPI chip select register. - * - * \param pAt45 Pointer to the At45 instance to initialize. - * \param pSpid Pointer to the underlying SPI driver. - * \param spiCs Chip select value to connect to the At45. - * \return 0. - */ -uint8_t AT45_Configure(At45 *pAt45, Spid *pSpid, uint8_t spiCs) -{ - SpidCmd *pCommand; - - /* Sanity checks */ - ASSERT(pSpid, "AT45_Configure: pSpid is 0.\n\r"); - ASSERT(pAt45, "AT45_Configure: pAt45 is 0.\n\r"); - - /* Initialize the At45 instance */ - pAt45->pSpid = pSpid; - pAt45->pDesc = 0; - memset(pAt45->pCmdBuffer, 0, 8); - - /* Initialize the spidCmd structure*/ - pCommand = &(pAt45->command); - pCommand->pCmd = pAt45->pCmdBuffer; - pCommand->callback = 0; - pCommand->pArgument = 0; - pCommand->spiCs = spiCs; - - return 0; -} - -/** - * \brief Check if the At45 driver is in busy. - * - * \param pAt45 Pointer to the At45 instance to initialize. - * \return 1 if the At45 driver is not executing any command,otherwise it returns 0. - */ -uint8_t AT45_IsBusy(At45 *pAt45) -{ - return SPID_IsBusy(pAt45->pSpid); -} - -/** - * \brief Sends a command to the dataflash through the SPI. - * The command is identified by its command code and the number of bytes to transfer - * (1 + number of address bytes + number of dummy bytes).If data needs to be received, - * then a data buffer must be provided. - * \note This function does not block; its optional callback will be invoked when - * the transfer completes. - * \param pAt45 Pointer to the At45 instance to initialize. - * \param cmd Command code. - * \param cmdSize Size of command code + address bytes + dummy bytes. - * \param pData Data buffer. - * \param dataSize Number of data bytes to send/receive. - * \param address Address at which the command is performed if meaningful. - * \param callback Optional callback to invoke at end of transfer. - * \param pArgument Optional parameter to the callback function. - * \return 0. - */ -uint8_t AT45_SendCommand( - At45 *pAt45, - uint8_t cmd, - uint8_t cmdSize, - uint8_t *pData, - uint32_t dataSize, - uint32_t address, - SpidCallback callback, - void *pArgument) -{ - SpidCmd *pCommand; - const At45Desc *pDesc = pAt45->pDesc; - uint32_t dfAddress = 0; - - /* Sanity checks*/ - ASSERT(pAt45, "AT45_Command: pAt45 is 0.\n\r"); - ASSERT(pDesc || (cmd == AT45_STATUS_READ), - "AT45_Command: Device has no descriptor, only STATUS_READ command allowed\n\r"); - - /* Check if the SPI driver is available*/ - if (AT45_IsBusy(pAt45)) { - - return AT45_ERROR_LOCK; - } - - /* Compute command pattern*/ - pAt45->pCmdBuffer[0] = cmd; - - /* Add address bytes if necessary*/ - if (cmdSize > 1) { - - ASSERT(pDesc, "AT45_Command: No descriptor for dataflash.\n\r"); - if (!configuredBinaryPage) { - dfAddress = - ((address / (pDesc->pageSize)) << pDesc->pageOffset) - + (address % (pDesc->pageSize)); - } - else { - dfAddress = address; - } - /* Write address bytes*/ - if (pDesc->pageNumber >= 16384) { - - pAt45->pCmdBuffer[1] = ((dfAddress & 0x0F000000) >> 24); - pAt45->pCmdBuffer[2] = ((dfAddress & 0x00FF0000) >> 16); - pAt45->pCmdBuffer[3] = ((dfAddress & 0x0000FF00) >> 8); - pAt45->pCmdBuffer[4] = ((dfAddress & 0x000000FF) >> 0); - - if ((cmd != AT45_CONTINUOUS_READ) && (cmd != AT45_PAGE_READ)) { - - cmdSize++; - } - } - else { - - pAt45->pCmdBuffer[1] = ((dfAddress & 0x00FF0000) >> 16); - pAt45->pCmdBuffer[2] = ((dfAddress & 0x0000FF00) >> 8); - pAt45->pCmdBuffer[3] = ((dfAddress & 0x000000FF) >> 0); - } - } - - /* Update the SPI Transfer descriptors*/ - pCommand = &(pAt45->command); - pCommand->cmdSize = cmdSize; - pCommand->pData = pData; - pCommand->dataSize = dataSize; - pCommand->callback = callback; - pCommand->pArgument = pArgument; - - /* Send Command and data through the SPI*/ - if (SPID_SendCommand(pAt45->pSpid, pCommand)) { - - return AT45_ERROR_SPI; - } - - return 0; -} - -/** - * \brief returns the At45Desc structure corresponding to the device connected. - * It automatically initializes pAt45->pDesc field structure. - * \note This function shall be called by the application before AT45_SendCommand. - * \param pAt45 Pointer to the At45 instance to initialize. - * \param status Device status register value. - * \return 0 if successful; Otherwise, returns AT45_ERROR_LOCK if the At45 - * driver is in use or AT45_ERROR_SPI if there was an error with the SPI driver. - */ -const At45Desc * AT45_FindDevice(At45 *pAt45, uint8_t status) -{ - uint32_t i; - uint8_t id = AT45_STATUS_ID(status); - - /* Check if status is all one; in which case, it is assumed that no device is connected*/ - if (status == 0xFF) { - - return 0; - } - - /* Look in device array */ - i = 0; - pAt45->pDesc = 0; - while ((i < NUMDATAFLASH) && !(pAt45->pDesc)) { - - if (at45Devices[i].id == id) { - - pAt45->pDesc = &(at45Devices[i]); - } - i++; - } - configuredBinaryPage = AT45_STATUS_BINARY(status); - return pAt45->pDesc; -} - -/** - * \brief returns the pagesize corresponding to the device connected. - * \param pAt45 Pointer to the At45 instance to initialize. - * \param status Device status register value. - * \return page size. - */ -uint32_t AT45_PageSize(At45 *pAt45) -{ - uint32_t pagesize = pAt45->pDesc->pageSize; - if(((pAt45->pDesc->hasBinaryPage) == 0) || !configuredBinaryPage){ - return pagesize; - } - return ((pagesize >> 8) << 8); -} diff --git a/src/ersky9x/libraries/drivers/spi-flash/spi_at45.h b/src/ersky9x/libraries/drivers/spi-flash/spi_at45.h deleted file mode 100644 index 93ad91f89..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/spi_at45.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of SPI At45 driver. - * - */ - -#ifndef SPI_AT45_H -#define SPI_AT45_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include "spi_pdc.h" - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ -/** Returns 1 if the device is ready; otherwise 0.*/ -#define AT45_STATUS_READY(status) (status & 0x80) -/** Returns the device ID code.*/ -#define AT45_STATUS_ID(status) (status & 0x3c) -/** Returns 1 if the device is configured in binary page mode; otherwise 0.*/ -#define AT45_STATUS_BINARY(status) (status & 0x01) - -#define AT45_PageOffset(pAt45) ((pAt45)->pDesc->pageOffset) -#define AT45_PageNumber(pAt45) ((pAt45)->pDesc->pageNumber) - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** The dataflash driver is currently in use.*/ -#define AT45_ERROR_LOCK 1 -/** There was an error with the SPI driver.*/ -#define AT45_ERROR_SPI 2 - -/** AT45 dataflash SPI CSR settings given MCK and SPCK.*/ -#define AT45_CSR(mck, spck) (SPI_CSR_NCPHA | SPID_CSR_DLYBCT(mck, 250) | SPID_CSR_DLYBS(mck, 250) | SPID_CSR_SCBR(mck, spck)) - -/** Main memory page read command code. */ -#define AT45_PAGE_READ 0xD2 -/** Continous array read (legacy) command code.*/ -#define AT45_CONTINUOUS_READ_LEG 0xE8 -/** Continous array read (low frequency) command code.*/ -#define AT45_CONTINUOUS_READ_LF 0x03 -/** Continous array read command code.*/ -#define AT45_CONTINUOUS_READ 0x0B -/** Buffer 1 read (low frequency) command code.*/ -#define AT45_BUF1_READ_LF 0xD1 -/** Buffer 2 read (low frequency) command code.*/ -#define AT45_BUF2_READ_LF 0xD3 -/** Buffer 1 read (serial) command code.*/ -#define AT45_BUF1_READ_SER 0xD4 -/** Buffer 2 read (serial) command code.*/ -#define AT45_BUF2_READ_SER 0xD6 -/** Buffer 1 read (8-bit) command code.*/ -#define AT45_BUF1_READ_8B 0x54 -/** Buffer 2 read (8-bit) command code.*/ -#define AT45_BUF2_READ_8B 0x56 - -/** Buffer 1 write command code.*/ -#define AT45_BUF1_WRITE 0x84 -/** Buffer 2 write command code.*/ -#define AT45_BUF2_WRITE 0x87 -/** Buffer 1 to main memory page program with erase command code.*/ -#define AT45_BUF1_MEM_ERASE 0x83 -/** Buffer 2 to main memory page program with erase command code.*/ -#define AT45_BUF2_MEM_ERASE 0x86 -/** Buffer 1 to main memory page program without erase command code.*/ -#define AT45_BUF1_MEM_NOERASE 0x88 -/** Buffer 2 to main memory page program without erase command code.*/ -#define AT45_BUF2_MEM_NOERASE 0x89 -/** Page erase command code.*/ -#define AT45_PAGE_ERASE 0x81 -/** Block erase command code.*/ -#define AT45_BLOCK_ERASE 0x50 -/** Sector erase command code.*/ -#define AT45_SECTOR_ERASE 0x7C -/** Chip erase command code.*/ -#define AT45_CHIP_ERASE 0xC7, 0x94, 0x80, 0x9A -/** Main memory page program through buffer 1 command code.*/ -#define AT45_PAGE_WRITE_BUF1 0x82 -/** Main memory page program through buffer 2 command code.*/ -#define AT45_PAGE_WRITE_BUF2 0x85 - -/** Main memory page to buffer 1 transfer command code.*/ -#define AT45_PAGE_BUF1_TX 0x53 -/** Main memory page to buffer 2 transfer command code.*/ -#define AT45_PAGE_BUF2_TX 0x55 -/** Main memory page to buffer 1 compare command code.*/ -#define AT45_PAGE_BUF1_CMP 0x60 -/** Main memory page to buffer 2 compare command code.*/ -#define AT45_PAGE_BUF2_CMP 0x61 -/** Auto page rewrite through buffer 1 command code.*/ -#define AT45_AUTO_REWRITE_BUF1 0x58 -/** Auto page rewrite through buffer 2 command code.*/ -#define AT45_AUTO_REWRITE_BUF2 0x59 -/** Deep power-down command code.*/ -#define AT45_DEEP_PDOWN 0xB9 -/** Resume from deep power-down command code.*/ -#define AT45_RES_DEEP_PDOWN 0xAB -/** Status register read command code.*/ -#define AT45_STATUS_READ 0xD7 -/** Manufacturer and device ID read command code.*/ -#define AT45_ID_READ 0x9F - -/** Power-of-2 binary page size configuration command code.*/ -#define AT45_BINARY_PAGE_FIRST_OPCODE 0x3D -#define AT45_BINARY_PAGE 0x2A, 0x80, 0xA6 - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** Dataflash description. A constant array of DataflashDesc instance is defined - in at45.c. The DF_Scan() function returns the corresponding descriptor according - to the dataflash ID detected. This description (page_size, page_offset) is used - to compute the internal dataflash address by the DF_Command() function. */ -typedef struct { - /** dataflash page number. */ - uint32_t pageNumber; - // indicate if power-of-2 binary page supported.*/ - uint32_t hasBinaryPage; - /** dataflash page size.*/ - uint32_t pageSize; - /** page offset in command.*/ - uint32_t pageOffset; - /** Dataflash ID.*/ - uint8_t id; - /** Identifier.*/ - const char *name; -} At45Desc; - -/** Dataflash driver structure. It holds the current command being processed. - This structure is initialized by the DF_Init() command. - pDfDesc field can be initialized by the DF_Scan() function. - cmdBuffer is a private driver area used to compute the dataflash address to - be sent to the dataflash. Beware the PDC master must have access to this area.*/ -typedef struct _Dataflash { - /** Pointer to Spi Structure (SPI low level driver).*/ - Spid *pSpid; - /** Current SPI command sent to the SPI low level driver.*/ - SpidCmd command; - /** Pointer to the dataflash description.*/ - const At45Desc *pDesc; - /** Buffer to store the current command (opcode + dataflash address.*/ - uint8_t pCmdBuffer[8]; -} At45; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern uint8_t AT45_Configure(At45 *pAt45, Spid *pSpid, uint8_t spiCs); - -extern uint8_t AT45_IsBusy(At45 *pAt45); - -extern uint8_t AT45_SendCommand( - At45 *pAt45, - uint8_t cmd, - uint8_t cmdSize, - uint8_t *pData, - uint32_t dataSize, - uint32_t address, - SpidCallback callback, - void *pArgument); - -extern const At45Desc * AT45_FindDevice(At45 *pAt45, uint8_t status); - -extern uint32_t AT45_PageSize(At45 *pAt45); -#endif // #ifndef SPI_AT45_H - diff --git a/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.c b/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.c deleted file mode 100644 index 0d07efc7d..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.c +++ /dev/null @@ -1,275 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup spi_pdc_module SPI PDC driver - * The Spi driver is a low level spi driver which performs SPI device Initializes, - * spi transfer and receive. It can be used by upper SPI driver such as AT45 - * driver and AT26 driver. - * - * \usage - *
      - *
    • Initializes a SPI instance and the corresponding SPI hardware, - * Configure SPI in Master Mode using SPID_Configure().
    • - *
    • Configures the SPI characteristics (such as Clock Polarity, Phase, - * transfers delay and Baud Rate) for the device corresponding to the - * chip select using SPID_ConfigureCS().
    • - *
    • Starts a SPI master transfer using SPID_SendCommand(). - * The transfer is performed using the PDC channels.
    • - *
    • It enable the SPI clock.
    • - *
    • Set the corresponding peripheral chip select.
    • - *
    • Initialize the two SPI PDC buffers.
    • - *
    • Initialize SPI_TPR and SPI_TCR with SPI command data and size - * to send command data first.
    • - *
    • Initialize SPI_RPR and SPI_RCR with SPI command data and size - * as dummy value.
    • - *
    • Initialize SPI_TNPR and SPI_TNCR with rest of the data to be - * transfered.(if the data specified in cmd structure)
    • - *
    • Initialize SPI_RNPR and SPI_RNCR with rest of the data to be - * received.(if the data specified in cmd structure)
    • - *
    • Initialize the callback function if specified.
    • - *
    • Enable transmitter and receiver.
    • - *
    • Example for sending a command to the dataflash through the SPI.
    • - * \code - * /// Build command to be sent. - * ... - * // Send Command and data through the SPI - * if (SPID_SendCommand(pAt45->pSpid, pCommand)) { - * return AT45_ERROR_SPI; - * } - * \endcode - *
    • The SPI_Handler() must be called by the SPI Interrupt Service Routine - * with the corresponding Spi instance. It is invokes to check for pending - * interrupts.
    • - *
    • Example for initializing SPI interrupt handler in upper application.
    • - * \code - * AIC_ConfigureIT(AT91C_ID_SPI, 0, SPI_Handler); - * \endcode - *
    - * Related files :\n - * \ref spi_pdc.c\n - * \ref spi_pdc.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of SPI PDC driver. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "spi_pdc.h" -#include - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ - -/** Write PMC register*/ -#define WRITE_PMC(pPmc, regName, value) pPmc->regName = (value) - -/** Write SPI register*/ -#define WRITE_SPI(pSpi, regName, value) pSpi->regName = (value) - -/** Read SPI registers */ -#define READ_SPI(pSpi, regName) (pSpi->regName) - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Initializes the Spid structure and the corresponding SPI hardware. - * - * \param pSpid Pointer to a Spid instance. - * \param pSpiHw Associated SPI peripheral. - * \param spiId SPI peripheral identifier. - * \return 0. - */ -uint8_t SPID_Configure(Spid *pSpid, Spi *pSpiHw, uint8_t spiId) -{ - /* Initialize the SPI structure*/ - pSpid->pSpiHw = pSpiHw; - pSpid->spiId = spiId; - pSpid->semaphore = 1; - pSpid->pCurrentCommand = 0; - - /* Enable the SPI clock*/ - WRITE_PMC(PMC, PMC_PCER0, (1 << pSpid->spiId)); - - /* Execute a software reset of the SPI twice */ - WRITE_SPI(pSpiHw, SPI_CR, SPI_CR_SWRST); - WRITE_SPI(pSpiHw, SPI_CR, SPI_CR_SWRST); - - /* Configure SPI in Master Mode with No CS selected !!! */ - WRITE_SPI(pSpiHw, SPI_MR, SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_MR_PCS); - - /* Enable the SPI*/ - WRITE_SPI(pSpiHw, SPI_CR, SPI_CR_SPIEN); - - /* Enable the SPI clock*/ - WRITE_PMC(PMC, PMC_PCDR0, (1 << pSpid->spiId)); - - return 0; -} - -/** - * \brief Configures the parameters for the device corresponding to the cs. - * - * \param pSpid Pointer to a Spid instance. - * \param cs number corresponding to the SPI chip select. - * \param csr SPI_CSR value to setup. - */ -void SPID_ConfigureCS(Spid *pSpid, uint8_t cs, uint32_t csr) -{ - Spi *pSpiHw = pSpid->pSpiHw; - WRITE_SPI(pSpiHw, SPI_CSR[cs], csr); -} - -/** - * \brief Starts a SPI master transfer. This is a non blocking function. It will - * return as soon as the transfer is started. - * - * \param pSpid Pointer to a Spid instance. - * \param pCommand Pointer to the SPI command to execute. - * \return 0 if the transfer has been started successfully; otherwise returns - * SPID_ERROR_LOCK is the driver is in use, or SPID_ERROR if the command is not - * valid. - */ -uint8_t SPID_SendCommand(Spid *pSpid, SpidCmd *pCommand) -{ - Spi *pSpiHw = pSpid->pSpiHw; - uint32_t spiMr; - - /* Try to get the dataflash semaphore */ - if (pSpid->semaphore == 0) { - - return SPID_ERROR_LOCK; - } - pSpid->semaphore--; - - /* Enable the SPI clock */ - WRITE_PMC(PMC, PMC_PCER0, (1 << pSpid->spiId)); - - /* Disable transmitter and receiver*/ - WRITE_SPI(pSpiHw, SPI_PTCR, SPI_PTCR_RXTDIS | SPI_PTCR_TXTDIS); - - /* Write to the MR register*/ - spiMr = READ_SPI(pSpiHw, SPI_MR); - spiMr |= SPI_MR_PCS; - spiMr &= ~((1 << pCommand->spiCs) << 16); - WRITE_SPI(pSpiHw, SPI_MR, spiMr); - - /* Initialize the two SPI PDC buffer*/ - WRITE_SPI(pSpiHw, SPI_RPR, (int) pCommand->pCmd); - WRITE_SPI(pSpiHw, SPI_RCR, pCommand->cmdSize); - WRITE_SPI(pSpiHw, SPI_TPR, (int) pCommand->pCmd); - WRITE_SPI(pSpiHw, SPI_TCR, pCommand->cmdSize); - - WRITE_SPI(pSpiHw, SPI_RNPR, (int) pCommand->pData); - WRITE_SPI(pSpiHw, SPI_RNCR, pCommand->dataSize); - WRITE_SPI(pSpiHw, SPI_TNPR, (int) pCommand->pData); - WRITE_SPI(pSpiHw, SPI_TNCR, pCommand->dataSize); - - /* Initialize the callback*/ - pSpid->pCurrentCommand = pCommand; - - /* Enable transmitter and receiver*/ - WRITE_SPI(pSpiHw, SPI_PTCR, SPI_PTCR_RXTEN | SPI_PTCR_TXTEN); - - /* Enable buffer complete interrupt*/ - WRITE_SPI(pSpiHw, SPI_IER, SPI_IER_RXBUFF); - - return 0; -} - - -/** - * \brief The SPI_Handler must be called by the SPI Interrupt Service Routine with the - * corresponding Spi instance. - * - * \note The SPI_Handler will unlock the Spi semaphore and invoke the upper application - * callback. - * \param pSpid Pointer to a Spid instance. - */ -void SPID_Handler(Spid *pSpid) -{ - SpidCmd *pSpidCmd = pSpid->pCurrentCommand; - Spi *pSpiHw = pSpid->pSpiHw; - volatile uint32_t spiSr; - - /* Read the status register*/ - spiSr = READ_SPI(pSpiHw, SPI_SR); - if (spiSr & SPI_SR_RXBUFF) { - - /* Disable transmitter and receiver */ - WRITE_SPI(pSpiHw, SPI_PTCR, SPI_PTCR_RXTDIS | SPI_PTCR_TXTDIS); - - /* Disable the SPI clock*/ - WRITE_PMC(PMC, PMC_PCDR0, (1 << pSpid->spiId)); - - /* Disable buffer complete interrupt */ - WRITE_SPI(pSpiHw, SPI_IDR, SPI_IDR_RXBUFF); - - /* Release the dataflash semaphore*/ - pSpid->semaphore++; - - /* Invoke the callback associated with the current command*/ - if (pSpidCmd && pSpidCmd->callback) { - - pSpidCmd->callback(0, pSpidCmd->pArgument); - } - - /* Nothing must be done after. A new DF operation may have been started - in the callback function.*/ - } -} - -/** - * \brief Returns 1 if the SPI driver is currently busy executing a command; otherwise - * returns 0. - * \param pSpid Pointer to a Spid instance. - */ -uint8_t SPID_IsBusy(const Spid *pSpid) -{ - if (pSpid->semaphore == 0) { - - return 1; - } - else { - - return 0; - } -} diff --git a/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.h b/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.h deleted file mode 100644 index 7c2934fee..000000000 --- a/src/ersky9x/libraries/drivers/spi-flash/spi_pdc.h +++ /dev/null @@ -1,133 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of SPI PDC driver. - * - */ - -#ifndef SPI_PDC_H -#define SPI_PDC_H - - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** An unspecified error has occured.*/ -#define SPID_ERROR 1 - -/** SPI driver is currently in use.*/ -#define SPID_ERROR_LOCK 2 - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ - -/** Calculates the value of the SCBR field of the Chip Select Register given MCK and SPCK.*/ -#define SPID_CSR_SCBR(mck, spck) ((((mck) / (spck)) << 8) & SPI_CSR_SCBR) - -/** Calculates the value of the DLYBS field of the Chip Select Register given delay in ns and MCK.*/ -#define SPID_CSR_DLYBS(mck, delay) ((((((delay) * ((mck) / 1000000)) / 1000) + 1) << 16) & SPI_CSR_DLYBS) - -/** Calculates the value of the DLYBCT field of the Chip Select Register given delay in ns and MCK.*/ -#define SPID_CSR_DLYBCT(mck, delay) ((((((delay) / 32 * ((mck) / 1000000)) / 1000) + 1) << 24) & SPI_CSR_DLYBCT) - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** SPI transfer complete callback.*/ -typedef void (*SpidCallback )(uint8_t, void *); - -/** Spi Transfer Request prepared by the application upper layer. This structure - is sent to the SPI_SendCommand function to start the transfer. At the end of - the transfer, the callback is invoked by the interrupt handler.*/ -typedef struct _SpidCmd { - - /** Pointer to the command data.*/ - uint8_t *pCmd; - /** Command size in bytes.*/ - uint8_t cmdSize; - /** Pointer to the data to be sent.*/ - uint8_t *pData; - /** Data size in bytes.*/ - unsigned short dataSize; - /** SPI chip select.*/ - uint8_t spiCs; - /** Callback function invoked at the end of transfer.*/ - SpidCallback callback; - /** Callback arguments.*/ - void *pArgument; - -} SpidCmd; - -/** Constant structure associated with SPI port. This structure prevents - client applications to have access in the same time.*/ -typedef struct { - - /** Pointer to SPI Hardware registers*/ - Spi *pSpiHw; - /** SPI Id as defined in the product datasheet*/ - char spiId; - /** Current SpiCommand being processed*/ - SpidCmd *pCurrentCommand; - /** Mutual exclusion semaphore.*/ - volatile char semaphore; - -} Spid; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern uint8_t SPID_Configure( - Spid *pSpid, - Spi *pSpiHw, - uint8_t spiId); - -extern void SPID_ConfigureCS(Spid *pSpid, uint8_t cs, uint32_t csr); - -extern uint8_t SPID_SendCommand( - Spid *pSpid, - SpidCmd *pCommand); - -extern void SPID_Handler(Spid *pSpid); - -extern uint8_t SPID_IsBusy(const Spid *pSpid); - -#endif // #ifndef SPI_PDC_H - diff --git a/src/ersky9x/libraries/drivers/spi/spi.c b/src/ersky9x/libraries/drivers/spi/spi.c deleted file mode 100644 index dd02721be..000000000 --- a/src/ersky9x/libraries/drivers/spi/spi.c +++ /dev/null @@ -1,241 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup spi_module Working with SPI - * The SPI driver provides the interface to configure and use the SPI - * peripheral. - * - * The Serial Peripheral Interface (SPI) circuit is a synchronous serial - * data link that provides communication with external devices in Master - * or Slave Mode. - * - * To use the SPI, the user has to follow these few steps: - * -# Enable the SPI pins required by the application (see pio.h). - * -# Configure the SPI using the \ref SPI_Configure(). This enables the - * peripheral clock. The mode register is loaded with the given value. - * -# Configure all the necessary chip selects with \ref SPI_ConfigureNPCS(). - * -# Enable the SPI by calling \ref SPI_Enable(). - * -# Send/receive data using \ref SPI_Write() and \ref SPI_Read(). Note that \ref SPI_Read() - * must be called after \ref SPI_Write() to retrieve the last value read. - * -# Send/receive data using the PDC with the \ref SPI_WriteBuffer() and - * \ref SPI_ReadBuffer() functions. - * -# Disable the SPI by calling \ref SPI_Disable(). - * - * For more accurate information, please look at the SPI section of the - * Datasheet. - * - * Related files :\n - * \ref spi.c\n - * \ref spi.h.\n -*/ -/*@{*/ -/*@}*/ - -/** - * \file - * - * Implementation of Serial Peripheral Interface (SPI) controller. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "spi.h" -#include "pmc/pmc.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Enables a SPI peripheral. - * - * \param spi Pointer to an Spi instance. - */ -void SPI_Enable(Spi *spi) -{ - spi->SPI_CR = SPI_CR_SPIEN; -} - -/** - * \brief Disables a SPI peripheral. - * - * \param spi Pointer to an Spi instance. - */ -void SPI_Disable(Spi *spi) -{ - spi->SPI_CR = SPI_CR_SPIDIS; -} - -/** - * \brief Configures a SPI peripheral as specified. The configuration can be computed - * using several macros (see \ref spi_configuration_macros). - * - * \param spi Pointer to an Spi instance. - * \param id Peripheral ID of the SPI. - * \param configuration Value of the SPI configuration register. - */ -void SPI_Configure(Spi *spi, - uint32_t id, - uint32_t configuration) -{ - PMC_EnablePeripheral(ID_SPI); - spi->SPI_CR = SPI_CR_SPIDIS; - - /* Execute a software reset of the SPI twice */ - spi->SPI_CR = SPI_CR_SWRST; - spi->SPI_CR = SPI_CR_SWRST; - spi->SPI_MR = configuration; -} - -/** - * \brief Configures a chip select of a SPI peripheral. The chip select configuration - * is computed using several macros (see \ref spi_configuration_macros). - * - * \param spi Pointer to an Spi instance. - * \param npcs Chip select to configure (0, 1, 2 or 3). - * \param configuration Desired chip select configuration. - */ -void SPI_ConfigureNPCS(Spi *spi, - uint32_t npcs, - uint32_t configuration) -{ - spi->SPI_CSR[npcs] = configuration; -} - -/** - * \brief Sends data through a SPI peripheral. If the SPI is configured to use a fixed - * peripheral select, the npcs value is meaningless. Otherwise, it identifies - * the component which shall be addressed. - * - * \param spi Pointer to an Spi instance. - * \param npcs Chip select of the component to address (0, 1, 2 or 3). - * \param data Word of data to send. - */ -void SPI_Write(Spi *spi, uint32_t npcs, uint16_t data) -{ - /* Send data */ - while ((spi->SPI_SR & SPI_SR_TXEMPTY) == 0); - spi->SPI_TDR = data | SPI_PCS(npcs); - while ((spi->SPI_SR & SPI_SR_TDRE) == 0); -} - -/** - * \brief Sends the contents of buffer through a SPI peripheral, using the PDC to - * take care of the transfer. - * - * \param spi Pointer to an Spi instance. - * \param buffer Data buffer to send. - * \param length Length of the data buffer. - */ -uint8_t SPI_WriteBuffer(Spi *spi, - void *buffer, - uint32_t length) -{ - /* Check if first bank is free */ - if (spi->SPI_TCR == 0) { - - spi->SPI_TPR = (uint32_t) buffer; - spi->SPI_TCR = length; - spi->SPI_PTCR = PERIPH_PTCR_TXTEN; - return 1; - } - /* Check if second bank is free */ - else if (spi->SPI_TNCR == 0) { - - spi->SPI_TNPR = (uint32_t) buffer; - spi->SPI_TNCR = length; - return 1; - } - - /* No free banks */ - return 0; -} - -/** - * \brief Check if SPI transfer finish. - * - * \param spi Pointer to an Spi instance. - * - * \return Returns 1 if there is no pending write operation on the SPI; otherwise - * returns 0. - */ -uint8_t SPI_IsFinished(Spi *spi) -{ - return ((spi->SPI_SR & SPI_SR_TXEMPTY) != 0); -} - -/** - * \brief Reads and returns the last word of data received by a SPI peripheral. This - * method must be called after a successful SPI_Write call. - * - * \param spi Pointer to an Spi instance. - * - * \return readed data. - */ -uint16_t SPI_Read(Spi *spi) -{ - while ((spi->SPI_SR & SPI_SR_RDRF) == 0); - return spi->SPI_RDR & 0xFFFF; -} - -/** - * \brief Reads data from a SPI peripheral until the provided buffer is filled. This - * method does NOT need to be called after SPI_Write or SPI_WriteBuffer. - * - * \param spi Pointer to an Spi instance. - * \param buffer Data buffer to store incoming bytes. - * \param length Length in bytes of the data buffer. - */ -uint8_t SPI_ReadBuffer(Spi *spi, - void *buffer, - uint32_t length) -{ - /* Check if the first bank is free */ - if (spi->SPI_RCR == 0) { - - spi->SPI_RPR = (uint32_t) buffer; - spi->SPI_RCR = length; - spi->SPI_PTCR = PERIPH_PTCR_RXTEN; - return 1; - } - /* Check if second bank is free */ - else if (spi->SPI_RNCR == 0) { - - spi->SPI_RNPR = (uint32_t) buffer; - spi->SPI_RNCR = length; - return 1; - } - - /* No free bank */ - return 0; -} diff --git a/src/ersky9x/libraries/drivers/spi/spi.h b/src/ersky9x/libraries/drivers/spi/spi.h deleted file mode 100644 index 0921f2fe0..000000000 --- a/src/ersky9x/libraries/drivers/spi/spi.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for Serial Peripheral Interface (SPI) controller. - * - */ - -#ifndef SPI_H -#define SPI_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ - -/** - * \page spi_configuration_macros SPI configuration macros - * - * This page lists several macros which should be used when configuring a SPI - * peripheral. - * - * \par Macros: - * - \ref SPI_PCS - * - \ref SPI_SCBR - * - \ref SPI_DLYBS - * - \ref SPI_DLYBCT - */ - -/** Calculate the PCS field value given the chip select NPCS value */ -#define SPI_PCS(npcs) ((~(1 << npcs) & 0xF) << 16) - -/** Calculates the value of the CSR SCBR field given the baudrate and MCK. */ -#define SPI_SCBR(baudrate, masterClock) \ - ((uint32_t) (masterClock / baudrate) << 8) - -/** Calculates the value of the CSR DLYBS field given the desired delay (in ns) */ -#define SPI_DLYBS(delay, masterClock) \ - ((uint32_t) (((masterClock / 1000000) * delay) / 1000) << 16) - -/** Calculates the value of the CSR DLYBCT field given the desired delay (in ns) */ -#define SPI_DLYBCT(delay, masterClock) \ - ((uint32_t) (((masterClock / 1000000) * delay) / 32000) << 24) -/*------------------------------------------------------------------------------ */ - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void SPI_Enable(Spi *spi); -extern void SPI_Disable(Spi *spi); -extern void SPI_Configure(Spi *spi, - uint32_t id, - uint32_t configuration); -extern void SPI_ConfigureNPCS(Spi *spi, - uint32_t npcs, - uint32_t configuration); -extern void SPI_Write(Spi *spi, uint32_t npcs, uint16_t data); -extern uint8_t SPI_WriteBuffer(Spi *spi, - void *buffer, - uint32_t length); - -extern uint8_t SPI_IsFinished(Spi *pSpi); - -extern uint16_t SPI_Read(Spi *spi); -extern uint8_t SPI_ReadBuffer(Spi *spi, - void *buffer, - uint32_t length); - -#endif /* #ifndef SPI_H */ - diff --git a/src/ersky9x/libraries/drivers/ssc/ssc.c b/src/ersky9x/libraries/drivers/ssc/ssc.c deleted file mode 100644 index 7289226c4..000000000 --- a/src/ersky9x/libraries/drivers/ssc/ssc.c +++ /dev/null @@ -1,248 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup ssc module Working with SSC - * The SSC driver provides the interface to configure and use the SSC - * peripheral. - * - * !Usage - * - * -# Enable the SSC interface pins. - * -# Configure the SSC to operate at a specific frequency by calling - * SSC_Configure(). This function enables the peripheral clock of the SSC, - * but not its PIOs. - * -# Configure the transmitter and/or the receiver using the - * SSC_ConfigureTransmitter() and SSC_ConfigureEmitter() functions. - * -# Enable the PIOs or the transmitter and/or the received. - * -# Enable the transmitter and/or the receiver using SSC_EnableTransmitter() - * and SSC_EnableReceiver() - * -# Send data through the transmitter using SSC_Write() and SSC_WriteBuffer() - * -# Receive data from the receiver using SSC_Read() and SSC_ReadBuffer() - * -# Disable the transmitter and/or the receiver using SSC_DisableTransmitter() - * and SSC_DisableReceiver() - * - * For more accurate information, please look at the RTC section of the - * Datasheet. - * - * Related files :\n - * \ref ssc.c\n - * \ref ssc.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of Synchronous Serial (SSC) controller. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "ssc.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Configures a SSC peripheral.If the divided clock is not used, the master - * clock frequency can be set to 0. - * \note The emitter and transmitter are disabled by this function. - * \param bitRate bit rate. - * \param masterClock master clock. - */ -void SSC_Configure(uint32_t bitRate, uint32_t masterClock) -{ - /* Enable SSC peripheral clock */ - PMC->PMC_PCER0 = 1 << ID_SSC; - - /* Reset, disable receiver & transmitter */ - SSC->SSC_CR = SSC_CR_RXDIS | SSC_CR_TXDIS | SSC_CR_SWRST; - - SSC->SSC_PTCR = SSC_PTCR_RXTDIS | SSC_PTCR_TXTDIS; - /* Configure clock frequency */ - if (bitRate != 0) { - - SSC->SSC_CMR = masterClock / (2 * bitRate); - } - else { - - SSC->SSC_CMR = 0; - } -} - -/** - * \brief Configures the transmitter of a SSC peripheral. - * \param tcmr Transmit Clock Mode Register value. - * \param tfmr Transmit Frame Mode Register value. - */ -void SSC_ConfigureTransmitter(uint32_t tcmr, uint32_t tfmr) -{ - SSC->SSC_TCMR = tcmr; - SSC->SSC_TFMR = tfmr; -} - -/** - * \brief Configures the receiver of a SSC peripheral. - * \param rcmr Receive Clock Mode Register value. - * \param rfmr Receive Frame Mode Register value. - */ -void SSC_ConfigureReceiver(uint32_t rcmr, uint32_t rfmr) -{ - SSC->SSC_RCMR = rcmr; - SSC->SSC_RFMR = rfmr; -} - -/** - * \brief Enables the transmitter of a SSC peripheral. - */ -void SSC_EnableTransmitter(void) -{ - SSC->SSC_CR = SSC_CR_TXEN; -} - -/** - * \brief Disables the transmitter of a SSC peripheral. - */ -void SSC_DisableTransmitter(void) -{ - SSC->SSC_CR = SSC_CR_TXDIS; -} - -/** - * \brief Enables the receiver of a SSC peripheral. - */ -void SSC_EnableReceiver(void) -{ - SSC->SSC_CR = SSC_CR_RXEN; -} - -/** - * \brief Disables the receiver of a SSC peripheral. - */ -void SSC_DisableReceiver(void) -{ - SSC->SSC_CR = SSC_CR_RXDIS; -} - -/** - * \brief Enables one or more interrupt sources of a SSC peripheral. - * \param Bitwise OR of selected interrupt sources. - */ -void SSC_EnableInterrupts(uint32_t sources) -{ - SSC->SSC_IER = sources; -} - -/** - * \brief Disables one or more interrupt sources of a SSC peripheral. - * \param Bitwise OR of selected interrupt sources. - */ -void SSC_DisableInterrupts(uint32_t sources) -{ - SSC->SSC_IDR = sources; -} - -/** - * \brief Sends one data frame through a SSC peripheral. If another frame is currently - * being sent, this function waits for the previous transfer to complete. - * \param frame Data frame to send. - */ -void SSC_Write(uint32_t frame) -{ - while ((SSC->SSC_SR & SSC_SR_TXRDY) == 0); - SSC->SSC_THR = frame; -} - -/** - * \brief Waits until one frame is received on a SSC peripheral, and returns it. - */ -uint32_t SSC_Read(void) -{ - while ((SSC->SSC_SR & SSC_SR_RXRDY) == 0); - return SSC->SSC_RHR; -} - -/** - * \brief Sends the contents of a data buffer a SSC peripheral, using the PDC. - * \param buffer Data buffer to send. - * \param length Size of the data buffer. - * \return 1 if the buffer has been queued for transmission; otherwise returns 0. - */ -uint8_t SSC_WriteBuffer(void *buffer, uint32_t length) -{ - /* Check if first bank is free*/ - if (SSC->SSC_TCR == 0) { - - SSC->SSC_TPR = (uint32_t) buffer; - SSC->SSC_TCR = length; - SSC->SSC_PTCR = SSC_PTCR_TXTEN; - return 1; - } - /* Check if second bank is free*/ - else if (SSC->SSC_TNCR == 0) { - - SSC->SSC_TNPR = (uint32_t) buffer; - SSC->SSC_TNCR = length; - return 1; - } - return 0; -} - -/** - * \brief Reads data coming from a SSC peripheral receiver and stores it into the - * giving buffer with PDC. - * \param buffer ata buffer used for reception. - * \param length Size of the data buffer. - * \return 1 if the buffer has been queued for reception; otherwise returns 0. - */ -uint8_t SSC_ReadBuffer(void *buffer, uint32_t length) -{ - /* Check if the first bank is free*/ - if (SSC->SSC_RCR == 0) { - - SSC->SSC_RPR = (uint32_t) buffer; - SSC->SSC_RCR = length; - SSC->SSC_PTCR = SSC_PTCR_RXTEN; - return 1; - } - /* Check if second bank is free*/ - else if (SSC->SSC_RNCR == 0) { - SSC->SSC_RNPR = (uint32_t) buffer; - SSC->SSC_RNCR = length; - return 1; - } - return 0; -} \ No newline at end of file diff --git a/src/ersky9x/libraries/drivers/ssc/ssc.h b/src/ersky9x/libraries/drivers/ssc/ssc.h deleted file mode 100644 index 61c43c723..000000000 --- a/src/ersky9x/libraries/drivers/ssc/ssc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for Synchronous Serial (SSC) controller. - * - */ - -#ifndef SSC_H -#define SSC_H - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ -extern void SSC_Configure(uint32_t bitRate, uint32_t masterClock); -extern void SSC_ConfigureTransmitter(uint32_t tcmr, uint32_t tfmr); -extern void SSC_ConfigureReceiver(uint32_t rcmr, uint32_t rfmr); -extern void SSC_EnableTransmitter(void); -extern void SSC_DisableTransmitter(void); -extern void SSC_EnableReceiver(void); -extern void SSC_DisableReceiver(void); -extern void SSC_EnableInterrupts(uint32_t sources); -extern void SSC_DisableInterrupts(uint32_t sources); -extern void SSC_Write(uint32_t frame); -extern uint32_t SSC_Read(void); -extern uint8_t SSC_WriteBuffer(void *buffer, uint32_t length); -extern uint8_t SSC_ReadBuffer(void *buffer, uint32_t length); - -#endif //#ifndef SSC_H - diff --git a/src/ersky9x/libraries/drivers/tc/tc.c b/src/ersky9x/libraries/drivers/tc/tc.c deleted file mode 100644 index d288a3e0c..000000000 --- a/src/ersky9x/libraries/drivers/tc/tc.c +++ /dev/null @@ -1,148 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------------ - * Headers - *------------------------------------------------------------------------------*/ - -#include "tc.h" - -/*------------------------------------------------------------------------------ - * Global functions - *------------------------------------------------------------------------------*/ - -/**------------------------------------------------------------------------------ - * \brief Configures a Timer Counter Channel - * Configures a Timer Counter to operate in the given mode. Timer is stopped - * after configuration and must be restarted with TC_Start(). All the - * interrupts of the timer are also disabled. - * \param pTc Pointer to an AT91S_TC instance. - * \param channel Channel number. - * \param mode Operating mode (TC_CMR value). - *------------------------------------------------------------------------------*/ -void TC_Configure(Tc *pTc, unsigned char channel, unsigned int mode) -{ - TcChannel *pTcCh = &pTc->TC_CHANNEL[channel]; - - /* Disable TC clock */ - pTcCh->TC_CCR = TC_CCR0_CLKDIS; - - /* Disable interrupts */ - pTcCh->TC_IDR = 0xFFFFFFFF; - - /* Clear status register */ - pTcCh->TC_SR; - - /* Set mode */ - pTcCh->TC_CMR = mode; -} - -/**------------------------------------------------------------------------------ - * \brief Reset and Start the TC Channel - * Enables the timer clock and performs a software reset to start the counting. - * \param pTc Pointer to an AT91S_TC instance. - * \param channel Channel number. - *------------------------------------------------------------------------------*/ -void TC_Start(Tc *pTc, unsigned char channel) -{ - TcChannel *pTcCh = &pTc->TC_CHANNEL[channel]; - pTcCh->TC_CCR = TC_CCR0_CLKEN | TC_CCR0_SWTRG; -} - -/**------------------------------------------------------------------------------ - * \brief Stop TC Channel - * Disables the timer clock, stopping the counting. - * \param pTc Pointer to an AT91S_TC instance. - * \param channel Channel number. - *------------------------------------------------------------------------------*/ -void TC_Stop(Tc *pTc, unsigned char channel) -{ - TcChannel *pTcCh = &pTc->TC_CHANNEL[channel]; - pTcCh->TC_CCR = TC_CCR0_CLKDIS; -} - -/**------------------------------------------------------------------------------ - * \brief Find best MCK divisor - * Finds the best MCK divisor given the timer frequency and MCK. The result - * is guaranteed to satisfy the following equation: - * \pre - * (MCK / (DIV * 65536)) <= freq <= (MCK / DIV) - * \endpre - * with DIV being the highest possible value. - * \param freq Desired timer frequency. - * \param mck Master clock frequency. - * \param div Divisor value. - * \param tcclks TCCLKS field value for divisor. - * \return 1 if a proper divisor has been found; otherwise 0. - *------------------------------------------------------------------------------*/ -unsigned char TC_FindMckDivisor( - unsigned int freq, - unsigned int mck, - unsigned int *div, - unsigned int *tcclks) -{ - const unsigned int divisors[5] = {2, 8, 32, 128,BOARD_MCK / 32768}; - - unsigned int index = 0; - - /* Satisfy lower bound */ - while (freq < ((mck / divisors[index]) / 65536)) { - - index++; - - /* If no divisor can be found, return 0 */ - if (index == 5) { - - return 0; - } - } - - /* Try to maximize DIV while satisfying upper bound */ - while (index < 4) { - - if (freq > (mck / divisors[index + 1])) { - - break; - } - index++; - } - - /* Store results */ - if (div) { - - *div = divisors[index]; - } - if (tcclks) { - - *tcclks = index; - } - - return 1; -} - diff --git a/src/ersky9x/libraries/drivers/tc/tc.h b/src/ersky9x/libraries/drivers/tc/tc.h deleted file mode 100644 index 3cab62ced..000000000 --- a/src/ersky9x/libraries/drivers/tc/tc.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/**------------------------------------------------------------------------------ - * \unit - * - * Purpose - * - * API for configuring and using Timer Counter (TC) peripherals. - * - * Usage - * -# Optionally, use TC_FindMckDivisor() to let the program find the best - * TCCLKS field value automatically. - * -# Configure a Timer Counter in the desired mode using TC_Configure(). - * -# Start or stop the timer clock using TC_Start() and TC_Stop(). - *------------------------------------------------------------------------------*/ - -#ifndef TC_H -#define TC_H - -/*------------------------------------------------------------------------------ - * Headers - *------------------------------------------------------------------------------*/ - -#include - -/*------------------------------------------------------------------------------ - * Global functions - *------------------------------------------------------------------------------*/ - -extern void TC_Configure(Tc *pTc, unsigned char ch, unsigned int mode); - -extern void TC_Start(Tc *pTc, unsigned char ch); - -extern void TC_Stop(Tc *pTc, unsigned char ch); - -extern unsigned char TC_FindMckDivisor( - unsigned int freq, - unsigned int mck, - unsigned int *div, - unsigned int *tcclks); - -#endif /* #ifndef TC_H */ - diff --git a/src/ersky9x/libraries/drivers/tsd/tsd.h b/src/ersky9x/libraries/drivers/tsd/tsd.h deleted file mode 100644 index 09be7cafa..000000000 --- a/src/ersky9x/libraries/drivers/tsd/tsd.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for touchscreen driver which includes touchscreen calibration, - * retrieving measurements etc. - * - * \par Usage - * - * -# Call TSD_Initialize() whenever the touchscreen should start the - * calibration process (as it is done in the function). - * -# Declare a global TSD_PenPressed function anywhere in your code. This - * function will get called every time the pen is pressed on the screen. - * -# Declare a global TSD_PenMoved function, which will get called whenever - * the pen stays in contact with the screen but changes position. - * -# Declare a global TSD_PenReleased function, which will be invoked as the - * pen is lifted from the screen. - */ - -#ifndef TSD_H -#define TSD_H - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "tsd_com.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void TSD_Initialize(int8_t calEn); - -extern uint8_t TSD_Calibrate(void); - -extern void TSD_Reset(void); - -extern void TSD_TimerHandler(void); - -#endif /* #ifndef TSD_H */ diff --git a/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.c b/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.c deleted file mode 100644 index 1deca4ac0..000000000 --- a/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.c +++ /dev/null @@ -1,302 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of ADS7843 driver. - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include -#include - -#ifdef BOARD_TSC_ADS7843 - -#include "tsd.h" -#include "tsd_com.h" -#include -#include -#include -#include -#include -#include -#include "tsd/tsd_ads7843.h" - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** Delay for pushbutton debouncing (the time-base is 10 ms). */ -#define DEBOUNCE_TIME 6 /* 10 * 6 = 60 ms */ - -/** Color of calibration points. */ -#define POINTS_COLOR 0x0000FF - -/** Size in pixels of calibration points. */ -#define POINTS_SIZE 4 - -/** Maximum difference in pixels between the test point and the measured point. */ -#define POINTS_MAX_ERROR 5 - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** pen state */ -typedef enum { - STATE_PEN_RELEASED = 0, - STATE_PEN_PRESSED = 1, - STATE_PEN_DEBOUNCE = 2 -} e_pen_state; - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -/** Pins used by Interrupt Signal for Touch Screen Controller */ -static const Pin pinPenIRQ = PIN_TCS_IRQ; - -/** Global timestamp in milliseconds since start of application. */ -static volatile uint32_t timestamp = 0; - -/** last time when the pen is pressed on the touchscreen */ -static volatile uint32_t timePress = 0; - -/** last time when the pen is released */ -static volatile uint32_t timeRelease = 0; - -/** pen state */ -static volatile e_pen_state penState = STATE_PEN_RELEASED; - -/** Touch screen initiallized flag */ -static uint32_t tsInitFlag = 0; - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Timer handler for touch screen. Increments the timestamp counter. - * Determine the state "Pen Pressed" or "Pen Released". To change state, - * the penIRQ has to keep the same value during DEBOUNCE_TIME. - * - * \note External timer interrupt should call it per 10ms. - */ -extern void TSD_TimerHandler( void ) -{ - uint32_t data[2]; - static uint32_t point[2]; - - if (!tsInitFlag) return; - - timestamp++; - /* Get the current position of the pen if penIRQ has low value (pen pressed) */ - if (PIO_Get(&pinPenIRQ) == 0) { - /* Get the current position of the pressed pen */ - if(TSDCom_IsCalibrationOk()) { - TSD_GetRawMeasurement(data); - TSDCom_InterpolateMeasurement(data, point); - } - - /* call the callback function */ - if(penState == STATE_PEN_PRESSED) { - if(TSDCom_IsCalibrationOk()) { - TSD_PenMoved(point[0], point[1]); - } - } - } - - /* Determine the pen state */ - if (PIO_Get(&pinPenIRQ) == 0) { - - /* reinit the last time when release */ - timeRelease = timestamp; - if(penState == STATE_PEN_DEBOUNCE) { - if( (timestamp - timePress) > DEBOUNCE_TIME) { - /* pen is pressed during an enough time : the state change */ - penState = STATE_PEN_PRESSED; - /* call the callback function */ - if(TSDCom_IsCalibrationOk()) { - TSD_PenPressed(point[0], point[1]); - } - } - } - } - else { - /* reinit the last time when release */ - timePress = timestamp; - - if(penState == STATE_PEN_DEBOUNCE) { - if( (timestamp - timeRelease) > DEBOUNCE_TIME) { - /* pen is released during an enough time : the state change */ - penState = STATE_PEN_RELEASED; - /* call the callback function */ - if(TSDCom_IsCalibrationOk()) { - TSD_PenReleased(point[0], point[1]); - } - } - } - } -} - -/** - * \breif Interrupt handler for Touchscreen. - */ -static void ISR_PenIRQ(void) -{ - /* Check if the pen has been pressed */ - if (!PIO_Get(&pinPenIRQ)) { - if(penState == STATE_PEN_RELEASED) { - - timePress = timestamp; - penState = STATE_PEN_DEBOUNCE; - } - } - else { - if(penState == STATE_PEN_PRESSED) { - - timeRelease = timestamp; - penState = STATE_PEN_DEBOUNCE; - } - } -} - -/** - * \brief Configure PENIRQ for interrupt. - */ -static void ConfigurePenIRQ(void) -{ - /* Configure pios */ - PIO_Configure(&pinPenIRQ, PIO_LISTSIZE(pinPenIRQ)); - - /* Initialize interrupts */ - PIO_InitializeInterrupts(0); - PIO_ConfigureIt(&pinPenIRQ, (void (*)(const Pin *)) ISR_PenIRQ); - - /* Enable the interrupt */ - PIO_EnableIt(&pinPenIRQ); -} - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Reads and store a touchscreen measurement in the provided array. - * - * \param pData Array where the measurements will be stored - */ -extern void TSD_GetRawMeasurement(uint32_t *pData) -{ - /* Get the current position of the pressed pen */ - PIO_DisableIt(&pinPenIRQ); - ADS7843_GetPosition(&pData[0], &pData[1]); - PIO_EnableIt(&pinPenIRQ); -} - -/** - * \brief Wait pen pressed. - */ -extern void TSD_WaitPenPressed( void ) -{ - /* Wait for touch & end of conversion */ - while (penState != STATE_PEN_RELEASED); - /*while (penState != STATE_PEN_PRESSED); */ - while (penState != STATE_PEN_PRESSED) { - } -} - -/** - * \brief Wait pen released. - */ -extern void TSD_WaitPenReleased( void ) -{ - /* Wait for contact loss */ - while (penState != STATE_PEN_PRESSED); - while (penState != STATE_PEN_RELEASED); -} - -/** - * \brief Do calibration. - * - * \return 1 if calibration is Ok, 0 else. - */ -uint8_t TSD_Calibrate(void) -{ - uint8_t ret = 0; - - /* Calibration is done only once */ - if(TSDCom_IsCalibrationOk()) { - return 1; - } - - /* Do calibration */ - ret = TSDCom_Calibrate(); - - return ret; -} - -/** - * \brief Initializes the touchscreen driver and starts the calibration process. When - * finished, the touchscreen is operational. - * - * \note Important: the LCD driver must have been initialized prior to calling this - * function. - */ -extern void TSD_Initialize( int8_t calEn ) -{ - ADS7843_Initialize(); - ConfigurePenIRQ(); - - tsInitFlag = 1; - - /* Calibration */ - if(calEn) { - while (!TSD_Calibrate()); - } -} - -/** - * \brief Stop the Touchscreen, disable interrupt. - */ -void TSD_Reset(void) -{ - /* Disable SPI 0 */ - ADS7843_Reset(); - - /* Disable the interrupt */ - PIO_DisableIt(&pinPenIRQ); -} - -#endif /* #ifdef BOARD_TSC_ADS7843 */ diff --git a/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.h b/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.h deleted file mode 100644 index edd9e797e..000000000 --- a/src/ersky9x/libraries/drivers/tsd/tsd_ads7843.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _TSD_ADS7843_ -#define _TSD_ADS7843_ - -/*---------------------------------------------------------------------------- - * External functions - *----------------------------------------------------------------------------*/ -extern void TSD_PenPressed( uint32_t dwX, uint32_t dwY ) ; -extern void TSD_PenMoved( uint32_t dwX, uint32_t dwY ) ; -extern void TSD_PenReleased( uint32_t dwX, uint32_t dwY ) ; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ -extern void TSD_WaitPenPressed( void ) ; -extern void TSD_WaitPenReleased( void ) ; -extern void TSD_GetRawMeasurement( uint32_t *pData ) ; -extern void TSD_Initialize( int8_t calEn ) ; - - -#endif // _TSD_ADS7843_ \ No newline at end of file diff --git a/src/ersky9x/libraries/drivers/tsd/tsd_com.c b/src/ersky9x/libraries/drivers/tsd/tsd_com.c deleted file mode 100644 index ebc85ced1..000000000 --- a/src/ersky9x/libraries/drivers/tsd/tsd_com.c +++ /dev/null @@ -1,380 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of touchscreen driver device irrelevance code. - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include - -#include "tsd.h" -#include -#include -#include -#include -#include -#include -#include -#include "tsd/tsd_ads7843.h" - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** Size in pixels of calibration points. */ -#define POINTS_SIZE 4 -/** Maximum difference in pixels between the test point and the measured point. */ -#define POINTS_MAX_ERROR 8 - -/** Delay at the end of calibartion for result display */ -#define DELAY_RESULT_DISPLAY 4000000 - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** Point used during the touchscreen calibration process. */ -typedef struct _CalibrationPoint { - - /** Coordinate of point along the X-axis of the screen. */ - uint32_t x; - /** Coordinate of point along the Y-axis of the screen. */ - uint32_t y; - /** Calibration data of point. */ - uint32_t data[2]; - -} CalibrationPoint; - -/*---------------------------------------------------------------------------- - * Variables - *----------------------------------------------------------------------------*/ - -/** indicates if the touch screen has been calibrated. */ -/** If not, Callback functions are not called. */ -static volatile uint8_t bCalibrationOk = 1 ; //0; -/** Slope for interpoling touchscreen measurements along the X-axis. */ -static int32_t xSlope; -/** Slope for interpoling touchscreen measurements along the Y-axis. */ -static int32_t ySlope; - -/** Calibration points. */ -static CalibrationPoint calibrationPoints[] = { - - /* Top-left corner calibration point */ - { - BOARD_LCD_WIDTH / 10, - BOARD_LCD_HEIGHT / 10, - {0, 0} - }, - /* Top-right corner calibration point */ - { - BOARD_LCD_WIDTH - BOARD_LCD_WIDTH / 10, - BOARD_LCD_HEIGHT / 10, - {0, 0} - }, - /* Bottom-right corner calibration point */ - { - BOARD_LCD_WIDTH - BOARD_LCD_WIDTH / 10, - BOARD_LCD_HEIGHT - BOARD_LCD_HEIGHT / 10, - {0, 0} - }, - /* Bottom-left corner calibration point */ - { - BOARD_LCD_WIDTH / 10, - BOARD_LCD_HEIGHT - BOARD_LCD_HEIGHT / 10, - {0, 0} - } -}; - -/** Test point */ -static const CalibrationPoint testPoint = { - BOARD_LCD_WIDTH / 2, - BOARD_LCD_HEIGHT / 2, - {0, 0} -}; - -/*---------------------------------------------------------------------------- - * External functions - *----------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------- - * Local functions - *----------------------------------------------------------------------------*/ - -/* - * \brief Display a calibration point on the given buffer. - * - * \param pPoint Calibration point to display. - */ -static void DrawCalibrationPoint(const CalibrationPoint *pPoint) -{ - LCDD_DrawRectangleWithFill(pPoint->x - POINTS_SIZE / 2, - pPoint->y - POINTS_SIZE / 2, - POINTS_SIZE, - POINTS_SIZE, - COLOR_RED); -} - -/** - * \brief Clears a calibration point from the given buffer. - * - * \param pPoint Calibration point to clear. - */ -static void ClearCalibrationPoint(const CalibrationPoint *pPoint) -{ - LCDD_DrawRectangleWithFill(pPoint->x - POINTS_SIZE / 2, - pPoint->y - POINTS_SIZE / 2, - POINTS_SIZE, - POINTS_SIZE, - COLOR_WHITE); -} - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \breif Indicates if the calibration of the touch screen is Ok. - * - * \return 1 calibration Ok, 0 if not. - */ -uint8_t TSDCom_IsCalibrationOk(void) -{ - if (bCalibrationOk == 1) { - return 1; - } else { - return 0; - } -} - -/** - * \brief Interpolates the provided raw measurements using the previously calculated - * slope. The resulting x and y coordinates are stored in an array. - * - * \param pData Raw measurement data, as returned by TSD_GetRawMeasurement(). - * \param pPoint Array in which x and y will be stored. - */ -void TSDCom_InterpolateMeasurement(const uint32_t *pData, uint32_t *pPoint) -{ - pPoint[0] = calibrationPoints[0].x - - (((int32_t) calibrationPoints[0].data[0] - (int32_t) pData[0]) * 1024) - / xSlope; - - pPoint[1] = calibrationPoints[0].y - - (((int32_t) calibrationPoints[0].data[1] - (int32_t) pData[1]) * 1024) - / ySlope; - - if(pPoint[0] & 0x80000000) /* Is pPoint[0] negative ? */ - { - pPoint[0] = 0; - } - - if(pPoint[0] > BOARD_LCD_WIDTH) /* Is pPoint[0] bigger than the LCD width ? */ - { - pPoint[0] = BOARD_LCD_WIDTH; - } - - if(pPoint[1] & 0x80000000) /* Is pPoint[1] negative ? */ - { - pPoint[1] = 0; - } - - if(pPoint[1] > BOARD_LCD_HEIGHT) /* Is pPoint[1] bigger than the LCD width ? */ - { - pPoint[1] = BOARD_LCD_HEIGHT; - } -} - -/** - * \brief Performs the calibration process using the provided buffer to display - * information. - * - * \return True if calibration was successful; otherwise false. - */ -uint8_t TSDCom_Calibrate(void) -{ - volatile uint32_t i; /* to keep the tempo with gcc code optimisation */ - int32_t slope1, slope2; - CalibrationPoint measuredPoint; - uint8_t xOk, yOk; - int32_t xDiff, yDiff; - - /* Calibration setup */ - LCDD_Fill(COLOR_WHITE); - LCDD_DrawString(30, 50, (uint8_t *)"LCD calibration", COLOR_BLACK); - LCDD_DrawString(1, 140, (uint8_t *)"Touch the dots to\ncalibrate the screen", COLOR_DARKBLUE); - - /* Calibration points */ - for (i=0; i < 4; i++) { - - DrawCalibrationPoint(&calibrationPoints[i]); - - /* Wait for touch & end of conversion */ - TSD_WaitPenPressed(); - TSD_GetRawMeasurement(calibrationPoints[i].data); - ClearCalibrationPoint(&calibrationPoints[i]); - - /* Wait for contact loss */ - TSD_WaitPenReleased(); - } - - /** - * Calculate slopes using the calibration data - * Theory behind those calculations: - * - We suppose the touchscreen measurements are linear, so the following equations are true (simple - * linear regression) for any two 'a' and 'b' points of the screen: - * dx = (a.data[0] - b.data[0]) / (a.x - b.x) - * dy = (a.data[1] - b.data[1]) / (a.y - b.y) - * - * - We calculate dx and dy (called xslope and yslope here) using the calibration points. - * - * - We can then use dx and dy to infer the position of a point 'p' given the measurements performed - * by the touchscreen ('c' is any of the calibration points): - * dx = (p.data[0] - c.data[0]) / (p.x - c.x) - * dy = (p.data[1] - c.data[1]) / (p.y - c.y) - * Thus: - * p.x = c.x - (p.data[0] - c.data[0]) / dx - * p.y = c.y - (p.data[1] - c.data[1]) / dy - * - * - Since there are four calibration points, dx and dy can be calculated twice, so we average - * the two values. - */ - slope1 = ((int32_t) calibrationPoints[0].data[0]) - ((int32_t) calibrationPoints[1].data[0]); - slope1 *= 1024; - slope1 /= ((int32_t) calibrationPoints[0].x) - ((int32_t) calibrationPoints[1].x); - slope2 = ((int32_t) calibrationPoints[2].data[0]) - ((int32_t) calibrationPoints[3].data[0]); - slope2 *= 1024; - slope2 /= ((int32_t) calibrationPoints[2].x) - ((int32_t) calibrationPoints[3].x); - xSlope = (slope1 + slope2) / 2; - - slope1 = ((int32_t) calibrationPoints[0].data[1]) - ((int32_t) calibrationPoints[2].data[1]); - slope1 *= 1024; - slope1 /= ((int32_t) calibrationPoints[0].y) - ((int32_t) calibrationPoints[2].y); - slope2 = ((int32_t) calibrationPoints[1].data[1]) - ((int32_t) calibrationPoints[3].data[1]); - slope2 *= 1024; - slope2 /= ((int32_t) calibrationPoints[1].y) - ((int32_t) calibrationPoints[3].y); - ySlope = (slope1 + slope2) / 2; - - /* Test point */ - LCDD_Fill(0xFFFFFF); - LCDD_DrawString(30, 50, (uint8_t *)"LCD calibration", COLOR_BLACK); - LCDD_DrawString(1, 100, (uint8_t *)" Touch the point to\nvalidate calibration", COLOR_DARKBLUE); - DrawCalibrationPoint(&testPoint); - - /* Wait for touch & end of conversion */ - TSD_WaitPenPressed(); - - TSD_GetRawMeasurement(measuredPoint.data); - TSDCom_InterpolateMeasurement(measuredPoint.data, (uint32_t *) &measuredPoint); - DrawCalibrationPoint(&measuredPoint); - - /* Check resulting x and y */ - xDiff = (int32_t) measuredPoint.x - (int32_t) testPoint.x; - yDiff = (int32_t) measuredPoint.y - (int32_t) testPoint.y; - xOk = (xDiff >= -POINTS_MAX_ERROR) && (xDiff <= POINTS_MAX_ERROR); - yOk = (yDiff >= -POINTS_MAX_ERROR) && (yDiff <= POINTS_MAX_ERROR); - - /* Wait for contact loss */ - TSD_WaitPenReleased(); - - /* Check calibration result */ - if (xOk && yOk) { - - bCalibrationOk = 1; - LCDD_Fill(COLOR_WHITE); - LCDD_DrawString(30, 50, (uint8_t *)"LCD calibration", COLOR_BLACK); - LCDD_DrawString(80, 140, (uint8_t *)"Success !", COLOR_GREEN); - - } - else { - - bCalibrationOk = 0; - LCDD_Fill(COLOR_WHITE); - LCDD_DrawString(30, 50, (uint8_t *)"LCD calibration", COLOR_BLACK); - LCDD_DrawString(40, 140, (uint8_t *)"Error too big", COLOR_RED); - } - - /* Slight delay */ - for (i = 0; i < DELAY_RESULT_DISPLAY; i++); - - return (xOk && yOk); -} - -/** - * \brief Read calibrate data to buffer. - * - * \param pBuffer Data buffer. - * \param size Size of data buffer in bytes. - */ -void TSDCom_ReadCalibrateData(void *pBuffer, uint32_t size) -{ - uint8_t *pDest = (uint8_t *)pBuffer; - - SANITY_CHECK((sizeof(bCalibrationOk) + sizeof(xSlope) + - sizeof(ySlope) + sizeof(calibrationPoints[0].data)) < size); - - memcpy(pDest, (void const *)&bCalibrationOk, sizeof(bCalibrationOk)); - pDest += sizeof(bCalibrationOk); - memcpy(pDest, &xSlope, sizeof(xSlope)); - pDest += sizeof(xSlope); - memcpy(pDest, &ySlope, sizeof(ySlope)); - pDest += sizeof(ySlope); - memcpy(pDest, &calibrationPoints[0].data, sizeof(calibrationPoints[0].data)); - pDest += sizeof(calibrationPoints[0].data); -} - -/** - * \brief Restore calibrate data with buffer data. - * - * \param pBuffer Data buffer. - * \param size Size of data buffer in bytes. - */ -void TSDCom_RestoreCalibrateData(void *pBuffer, uint32_t size) -{ - uint8_t *pSrc = (uint8_t *)pBuffer; - - SANITY_CHECK((sizeof(bCalibrationOk) + sizeof(xSlope) + - sizeof(ySlope) + sizeof(calibrationPoints[0].data)) < size); - - memcpy((void *)&bCalibrationOk, pSrc, sizeof(bCalibrationOk)); - pSrc += sizeof(bCalibrationOk); - memcpy(&xSlope, pSrc, sizeof(xSlope)); - pSrc += sizeof(xSlope); - memcpy(&ySlope, pSrc, sizeof(ySlope)); - pSrc += sizeof(ySlope); - memcpy(&calibrationPoints[0].data, pSrc, sizeof(calibrationPoints[0].data)); - pSrc += sizeof(calibrationPoints[0].data); -} diff --git a/src/ersky9x/libraries/drivers/tsd/tsd_com.h b/src/ersky9x/libraries/drivers/tsd/tsd_com.h deleted file mode 100644 index df5ffc806..000000000 --- a/src/ersky9x/libraries/drivers/tsd/tsd_com.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for touchscreen driver device irrelevance code. - */ - -#ifndef TSD_COM_H -#define TSD_COM_H - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void TSDCom_InterpolateMeasurement( - const uint32_t *pData, - uint32_t *pPoint); - -uint8_t TSDCom_Calibrate(void); - -uint8_t TSDCom_IsCalibrationOk(void); - -void TSDCom_ReadCalibrateData(void *pBuffer, uint32_t size); -void TSDCom_RestoreCalibrateData(void *pBuffer, uint32_t size); - -#endif /* #ifndef TSD_COM_H */ diff --git a/src/ersky9x/libraries/drivers/twi/twi.c b/src/ersky9x/libraries/drivers/twi/twi.c deleted file mode 100644 index b69bc96a7..000000000 --- a/src/ersky9x/libraries/drivers/twi/twi.c +++ /dev/null @@ -1,377 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup twi_module Working with TWI - * The TWI driver provides the interface to configure and use the TWI - * peripheral. - * - * \usage - *
      - *
    • Configures a TWI peripheral to operate in master mode, at the given - * frequency (in Hz) using TWI_Configure().
    • - *
    • Sends a STOP condition on the TWI using TWI_Stop().
    • - *
    • Starts a read operation on the TWI bus with the specified slave using - * TWI_StartRead(). Data must then be read using TWI_ReadByte() whenever - * a byte is available (poll using TWI_ByteReceived()).
    • - *
    • Starts a write operation on the TWI to access the selected slave using - * TWI_StartWrite(). A byte of data must be provided to start the write; - * other bytes are written next.
    • - *
    • Sends a byte of data to one of the TWI slaves on the bus using TWI_WriteByte(). - * This function must be called once before TWI_StartWrite() with the first byte of data - * to send, then it shall be called repeatedly after that to send the remaining bytes.
    • - *
    • Check if a byte has been received and can be read on the given TWI - * peripheral using TWI_ByteReceived().< - * Check if a byte has been sent using TWI_ByteSent().
    • - *
    • Check if the current transmission is complete (the STOP has been sent) - * using TWI_TransferComplete().
    • - *
    • Enables & disable the selected interrupts sources on a TWI peripheral - * using TWI_EnableIt() and TWI_DisableIt().
    • - *
    • Get current status register of the given TWI peripheral using - * TWI_GetStatus(). Get current status register of the given TWI peripheral, but - * masking interrupt sources which are not currently enabled using - * TWI_GetMaskedStatus().
    • - *
    - * For more accurate information, please look at the TWI section of the - * Datasheet. - * - * Related files :\n - * \ref twi.c\n - * \ref twi.h.\n -*/ -/*@{*/ -/*@}*/ - - -/** - * \file - * - * Implementation of Two Wire Interface (TWI). - * - */ - - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include "twi.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Configures a TWI peripheral to operate in master mode, at the given - * frequency (in Hz). The duty cycle of the TWI clock is set to 50%. - * \param pTwi Pointer to an Twi instance. - * \param twck Desired TWI clock frequency. - * \param mck Master clock frequency. - */ -void TWI_ConfigureMaster(Twi *pTwi, uint32_t twck, uint32_t mck) -{ - uint32_t ckdiv = 0; - uint32_t cldiv; - uint8_t ok = 0; - - TRACE_DEBUG("TWI_ConfigureMaster()\n\r"); - SANITY_CHECK(pTwi); - - /* SVEN: TWI Slave Mode Enabled */ - pTwi->TWI_CR = TWI_CR_SVEN; - /* Reset the TWI*/ - pTwi->TWI_CR = TWI_CR_SWRST; - pTwi->TWI_RHR; - - /* TWI Slave Mode Disabled, TWI Master Mode Disabled. */ - pTwi->TWI_CR = TWI_CR_SVDIS; - pTwi->TWI_CR = TWI_CR_MSDIS; - - /* Set master mode */ - pTwi->TWI_CR = TWI_CR_MSEN; - - /* Configure clock */ - while (!ok) { - cldiv = ((mck / (2 * twck)) - 3) / power(2, ckdiv); - if (cldiv <= 255) { - ok = 1; - } - else { - ckdiv++; - } - } - ASSERT(ckdiv < 8, "-F- Cannot find valid TWI clock parameters\n\r"); - TRACE_DEBUG("Using CKDIV = %u and CLDIV/CHDIV = %u\n\r", ckdiv, cldiv); - pTwi->TWI_CWGR = 0; - pTwi->TWI_CWGR = (ckdiv << 16) | (cldiv << 8) | cldiv; -} - -/** - * \brief Configures a TWI peripheral to operate in slave mode. - * \param pTwi Pointer to an Twi instance. - * \param slaveAddress Slave address. - */ -void TWI_ConfigureSlave(Twi *pTwi, uint8_t slaveAddress) -{ - uint32_t i; - - /* TWI software reset */ - pTwi->TWI_CR = TWI_CR_SWRST; - pTwi->TWI_RHR; - - /* Wait at least 10 ms */ - for (i=0; i < 1000000; i++); - - /* TWI Slave Mode Disabled, TWI Master Mode Disabled*/ - pTwi->TWI_CR = TWI_CR_SVDIS | TWI_CR_MSDIS; - - /* Configure slave address. */ - pTwi->TWI_SMR = 0; - pTwi->TWI_SMR = (slaveAddress << 16) & TWI_SMR_SADR; - - /* SVEN: TWI Slave Mode Enabled */ - pTwi->TWI_CR = TWI_CR_SVEN; - - /* Wait at least 10 ms */ - for (i=0; i < 1000000; i++); - ASSERT( (pTwi->TWI_CR & TWI_CR_SVDIS)!= TWI_CR_SVDIS, "Can't configure TWI slave mode"); -} - -/** - * \brief Sends a STOP condition on the TWI. - * \param pTwi Pointer to an Twi instance. - */ -void TWI_Stop(Twi *pTwi) -{ - SANITY_CHECK(pTwi); - pTwi->TWI_CR = TWI_CR_STOP; -} - -/** - * \brief Starts a read operation on the TWI bus with the specified slave, it returns - * immediately. Data must then be read using TWI_ReadByte() whenever a byte is - * available (poll using TWI_ByteReceived()). - * \param pTwi Pointer to an Twi instance. - * \param address Slave address on the bus. - * \param iaddress Optional internal address bytes. - * \param isize Number of internal address bytes. - */ -void TWI_StartRead( - Twi *pTwi, - uint8_t address, - uint32_t iaddress, - uint8_t isize) -{ - SANITY_CHECK(pTwi); - SANITY_CHECK((address & 0x80) == 0); - SANITY_CHECK((iaddress & 0xFF000000) == 0); - SANITY_CHECK(isize < 4); - - /* Set slave address and number of internal address bytes. */ - pTwi->TWI_MMR = 0; - pTwi->TWI_MMR = (isize << 8) | TWI_MMR_MREAD | (address << 16); - - /* Set internal address bytes */ - pTwi->TWI_IADR = 0; - pTwi->TWI_IADR = iaddress; - - /* Send START condition */ - pTwi->TWI_CR = TWI_CR_START; -} - -/** - * \brief Reads a byte from the TWI bus. The read operation must have been started - * using TWI_StartRead() and a byte must be available (check with TWI_ByteReceived()). - * \param pTwi Pointer to an Twi instance. - * \return byte read. - */ -uint8_t TWI_ReadByte(Twi *pTwi) -{ - SANITY_CHECK(pTwi); - - return pTwi->TWI_RHR; -} - -/** - * \brief Sends a byte of data to one of the TWI slaves on the bus. - * \note This function must be called once before TWI_StartWrite() with - * the first byte of data to send, then it shall be called repeatedly - * after that to send the remaining bytes. - * \param pTwi Pointer to an Twi instance. - * \param byte Byte to send. - */ -void TWI_WriteByte(Twi *pTwi, uint8_t byte) -{ - SANITY_CHECK(pTwi); - - pTwi->TWI_THR = byte; -} - -/** - * \brief Starts a write operation on the TWI to access the selected slave, then - * returns immediately. A byte of data must be provided to start the write; - * other bytes are written next. - * after that to send the remaining bytes. - * \param pTwi Pointer to an Twi instance. - * \param address Address of slave to acccess on the bus. - * \param iaddress Optional slave internal address. - * \param isize Number of internal address bytes. - * \param byte First byte to send. - */ -void TWI_StartWrite( - Twi *pTwi, - uint8_t address, - uint32_t iaddress, - uint8_t isize, - uint8_t byte) -{ - SANITY_CHECK(pTwi); - SANITY_CHECK((address & 0x80) == 0); - SANITY_CHECK((iaddress & 0xFF000000) == 0); - SANITY_CHECK(isize < 4); - - /* Set slave address and number of internal address bytes. */ - pTwi->TWI_MMR = 0; - pTwi->TWI_MMR = (isize << 8) | (address << 16); - - /* Set internal address bytes. */ - pTwi->TWI_IADR = 0; - pTwi->TWI_IADR = iaddress; - - /* Write first byte to send.*/ - TWI_WriteByte(pTwi, byte); -} - -/** - * \brief Check if a byte have been receiced from TWI. - * \param pTwi Pointer to an Twi instance. - * \return 1 if a byte has been received and can be read on the given TWI - * peripheral; otherwise, returns 0. This function resets the status register. - */ -uint8_t TWI_ByteReceived(Twi *pTwi) -{ - return ((pTwi->TWI_SR & TWI_SR_RXRDY) == TWI_SR_RXRDY); -} - -/** - * \brief Check if a byte have been sent to TWI. - * \param pTwi Pointer to an Twi instance. - * \return 1 if a byte has been sent so another one can be stored for - * transmission; otherwise returns 0. This function clears the status register. - */ -uint8_t TWI_ByteSent(Twi *pTwi) -{ - return ((pTwi->TWI_SR & TWI_SR_TXRDY) == TWI_SR_TXRDY); -} - -/** - * \brief Check if current transmission is complet. - * \param pTwi Pointer to an Twi instance. - * \return 1 if the current transmission is complete (the STOP has been sent); - * otherwise returns 0. - */ -uint8_t TWI_TransferComplete(Twi *pTwi) -{ - return ((pTwi->TWI_SR & TWI_SR_TXCOMP) == TWI_SR_TXCOMP); -} - -/** - * \brief Enables the selected interrupts sources on a TWI peripheral. - * \param pTwi Pointer to an Twi instance. - * \param sources Bitwise OR of selected interrupt sources. - */ -void TWI_EnableIt(Twi *pTwi, uint32_t sources) -{ - SANITY_CHECK(pTwi); - SANITY_CHECK((sources & 0xFFFFF088) == 0); - - pTwi->TWI_IER = sources; -} - -/** - * \brief Disables the selected interrupts sources on a TWI peripheral. - * \param pTwi Pointer to an Twi instance. - * \param sources Bitwise OR of selected interrupt sources. - */ -void TWI_DisableIt(Twi *pTwi, uint32_t sources) -{ - SANITY_CHECK(pTwi); - SANITY_CHECK((sources & 0xFFFFF088) == 0); - - pTwi->TWI_IDR = sources; -} - -/** - * \brief Get the current status register of the given TWI peripheral. - * \note This resets the internal value of the status register, so further - * read may yield different values. - * \param pTwi Pointer to an Twi instance. - * \return TWI status register. - */ -uint32_t TWI_GetStatus(Twi *pTwi) -{ - SANITY_CHECK(pTwi); - - return pTwi->TWI_SR; -} - -/** - * \brief Returns the current status register of the given TWI peripheral, but - * masking interrupt sources which are not currently enabled. - * \note This resets the internal value of the status register, so further - * read may yield different values. - * \param pTwi Pointer to an Twi instance. - */ -uint32_t TWI_GetMaskedStatus(Twi *pTwi) -{ - uint32_t status; - - SANITY_CHECK(pTwi); - - status = pTwi->TWI_SR; - status &= pTwi->TWI_IMR; - - return status; -} - -/** - * \brief Sends a STOP condition. STOP Condition is sent just after completing - * the current byte transmission in master read mode. - * \param pTwi Pointer to an Twi instance. - */ -void TWI_SendSTOPCondition(Twi *pTwi) -{ - SANITY_CHECK(pTwi); - - pTwi->TWI_CR |= TWI_CR_STOP; -} - diff --git a/src/ersky9x/libraries/drivers/twi/twi.h b/src/ersky9x/libraries/drivers/twi/twi.h deleted file mode 100644 index 5e2848707..000000000 --- a/src/ersky9x/libraries/drivers/twi/twi.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface for configuration the Two Wire Interface (TWI) peripheral. - * - */ - -#ifndef TWI_H -#define TWI_H - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ -/* Returns 1 if the TXRDY bit (ready to transmit data) is set in the given status register value.*/ -#define TWI_STATUS_TXRDY(status) ((status & TWI_SR_TXRDY) == TWI_SR_TXRDY) - -/* Returns 1 if the RXRDY bit (ready to receive data) is set in the given status register value.*/ -#define TWI_STATUS_RXRDY(status) ((status & TWI_SR_RXRDY) == TWI_SR_RXRDY) - -/* Returns 1 if the TXCOMP bit (transfer complete) is set in the given status register value.*/ -#define TWI_STATUS_TXCOMP(status) ((status & TWI_SR_TXCOMP) == TWI_SR_TXCOMP) - -/*---------------------------------------------------------------------------- - * External function - *----------------------------------------------------------------------------*/ - -extern void TWI_ConfigureMaster(Twi *pTwi, uint32_t twck, uint32_t mck); - -extern void TWI_ConfigureSlave(Twi *pTwi, uint8_t slaveAddress); - -extern void TWI_Stop(Twi *pTwi); - -extern void TWI_StartRead( - Twi *pTwi, - uint8_t address, - uint32_t iaddress, - uint8_t isize); - -extern uint8_t TWI_ReadByte(Twi *pTwi); - -extern void TWI_WriteByte(Twi *pTwi, uint8_t byte); - -extern void TWI_StartWrite( - Twi *pTwi, - uint8_t address, - uint32_t iaddress, - uint8_t isize, - uint8_t byte); - -extern uint8_t TWI_ByteReceived(Twi *pTwi); - -extern uint8_t TWI_ByteSent(Twi *pTwi); - -extern uint8_t TWI_TransferComplete(Twi *pTwi); - -extern void TWI_EnableIt(Twi *pTwi, uint32_t sources); - -extern void TWI_DisableIt(Twi *pTwi, uint32_t sources); - -extern uint32_t TWI_GetStatus(Twi *pTwi); - -extern uint32_t TWI_GetMaskedStatus(Twi *pTwi); - -extern void TWI_SendSTOPCondition(Twi *pTwi); - -#endif //#ifndef TWI_H diff --git a/src/ersky9x/libraries/drivers/twi/twid.c b/src/ersky9x/libraries/drivers/twi/twid.c deleted file mode 100644 index 49751681e..000000000 --- a/src/ersky9x/libraries/drivers/twi/twid.c +++ /dev/null @@ -1,342 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - - - - - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "twid.h" -#include -#include -#include - -/*---------------------------------------------------------------------------- - * Definition - *----------------------------------------------------------------------------*/ -#define TWITIMEOUTMAX 50000 - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** TWI driver callback function.*/ -typedef void (*TwiCallback)(Async *); - -/** TWI asynchronous transfer descriptor.*/ -typedef struct _AsyncTwi { - - /** Asynchronous transfer status. */ - volatile uint8_t status; - // Callback function to invoke when transfer completes or fails.*/ - TwiCallback callback; - /** Pointer to the data buffer.*/ - uint8_t *pData; - /** Total number of bytes to transfer.*/ - uint32_t num; - /** Number of already transferred bytes.*/ - uint32_t transferred; - -} AsyncTwi; - -/*---------------------------------------------------------------------------- - * Global functions - *----------------------------------------------------------------------------*/ -/** - * \brief Initializes a TWI driver instance, using the given TWI peripheral. - * \note The peripheral must have been initialized properly before calling this function. - * \param pTwid Pointer to the Twid instance to initialize. - * \param pTwi Pointer to the TWI peripheral to use. - */ -void TWID_Initialize(Twid *pTwid, Twi *pTwi) -{ - TRACE_DEBUG("TWID_Initialize()\n\r"); - SANITY_CHECK(pTwid); - SANITY_CHECK(pTwi); - - /* Initialize driver. */ - pTwid->pTwi = pTwi; - pTwid->pTransfer = 0; -} - - -/** - * \brief Interrupt handler for a TWI peripheral. Manages asynchronous transfer - * occuring on the bus. This function MUST be called by the interrupt service - * routine of the TWI peripheral if asynchronous read/write are needed. - * \param pTwid Pointer to a Twid instance. - */ -void TWID_Handler(Twid *pTwid) -{ - uint8_t status; - AsyncTwi *pTransfer = (AsyncTwi *) pTwid->pTransfer; - Twi *pTwi = pTwid->pTwi; - - SANITY_CHECK(pTwid); - - /* Retrieve interrupt status */ - status = TWI_GetMaskedStatus(pTwi); - - /* Byte received */ - if (TWI_STATUS_RXRDY(status)) { - - pTransfer->pData[pTransfer->transferred] = TWI_ReadByte(pTwi); - pTransfer->transferred++; - - /* check for transfer finish */ - if (pTransfer->transferred == pTransfer->num) { - - TWI_DisableIt(pTwi, TWI_IDR_RXRDY); - TWI_EnableIt(pTwi, TWI_IER_TXCOMP); - } - /* Last byte? */ - else if (pTransfer->transferred == (pTransfer->num - 1)) { - - TWI_Stop(pTwi); - } - } - /* Byte sent*/ - else if (TWI_STATUS_TXRDY(status)) { - - /* Transfer finished ? */ - if (pTransfer->transferred == pTransfer->num) { - - TWI_DisableIt(pTwi, TWI_IDR_TXRDY); - TWI_EnableIt(pTwi, TWI_IER_TXCOMP); - TWI_SendSTOPCondition(pTwi); - } - /* Bytes remaining */ - else { - - TWI_WriteByte(pTwi, pTransfer->pData[pTransfer->transferred]); - pTransfer->transferred++; - } - } - /* Transfer complete*/ - else if (TWI_STATUS_TXCOMP(status)) { - - TWI_DisableIt(pTwi, TWI_IDR_TXCOMP); - pTransfer->status = 0; - if (pTransfer->callback) { - - pTransfer->callback((Async *) pTransfer); - } - pTwid->pTransfer = 0; - } -} - -/** - * \brief Asynchronously reads data from a slave on the TWI bus. An optional - * callback function is triggered when the transfer is complete. - * \param pTwid Pointer to a Twid instance. - * \param address TWI slave address. - * \param iaddress Optional slave internal address. - * \param isize Internal address size in bytes. - * \param pData Data buffer for storing received bytes. - * \param num Number of bytes to read. - * \param pAsync Asynchronous transfer descriptor. - * \return 0 if the transfer has been started; otherwise returns a TWI error code. - */ -uint8_t TWID_Read( - Twid *pTwid, - uint8_t address, - uint32_t iaddress, - uint8_t isize, - uint8_t *pData, - uint32_t num, - Async *pAsync) -{ - Twi *pTwi = pTwid->pTwi; - AsyncTwi *pTransfer = (AsyncTwi *) pTwid->pTransfer; - uint32_t timeout; - - SANITY_CHECK(pTwid); - SANITY_CHECK((address & 0x80) == 0); - SANITY_CHECK((iaddress & 0xFF000000) == 0); - SANITY_CHECK(isize < 4); - - /* Check that no transfer is already pending*/ - if (pTransfer) { - - TRACE_ERROR("TWID_Read: A transfer is already pending\n\r"); - return TWID_ERROR_BUSY; - } - - /* Set STOP signal if only one byte is sent*/ - if (num == 1) { - - TWI_Stop(pTwi); - } - - /* Asynchronous transfer*/ - if (pAsync) { - - /* Update the transfer descriptor */ - pTwid->pTransfer = pAsync; - pTransfer = (AsyncTwi *) pAsync; - pTransfer->status = ASYNC_STATUS_PENDING; - pTransfer->pData = pData; - pTransfer->num = num; - pTransfer->transferred = 0; - - /* Enable read interrupt and start the transfer */ - TWI_EnableIt(pTwi, TWI_IER_RXRDY); - TWI_StartRead(pTwi, address, iaddress, isize); - } - /* Synchronous transfer*/ - else { - - /* Start read*/ - TWI_StartRead(pTwi, address, iaddress, isize); - - /* Read all bytes, setting STOP before the last byte*/ - while (num > 0) { - - /* Last byte ?*/ - if (num == 1) { - - TWI_Stop(pTwi); - } - - /* Wait for byte then read and store it*/ - timeout = 0; - while( !TWI_ByteReceived(pTwi) && (++timeoutpTwi; - AsyncTwi *pTransfer = (AsyncTwi *) pTwid->pTransfer; - uint32_t timeout; - - SANITY_CHECK(pTwi); - SANITY_CHECK((address & 0x80) == 0); - SANITY_CHECK((iaddress & 0xFF000000) == 0); - SANITY_CHECK(isize < 4); - - /* Check that no transfer is already pending */ - if (pTransfer) { - - TRACE_ERROR("TWI_Write: A transfer is already pending\n\r"); - return TWID_ERROR_BUSY; - } - - /* Asynchronous transfer */ - if (pAsync) { - - /* Update the transfer descriptor */ - pTwid->pTransfer = pAsync; - pTransfer = (AsyncTwi *) pAsync; - pTransfer->status = ASYNC_STATUS_PENDING; - pTransfer->pData = pData; - pTransfer->num = num; - pTransfer->transferred = 1; - - /* Enable write interrupt and start the transfer */ - TWI_StartWrite(pTwi, address, iaddress, isize, *pData); - TWI_EnableIt(pTwi, TWI_IER_TXRDY); - } - /* Synchronous transfer*/ - else { - - // Start write - TWI_StartWrite(pTwi, address, iaddress, isize, *pData++); - num--; - - /* Send all bytes */ - while (num > 0) { - - /* Wait before sending the next byte */ - timeout = 0; - while( !TWI_ByteSent(pTwi) && (++timeout -#include - -/*---------------------------------------------------------------------------- - * Definition - *----------------------------------------------------------------------------*/ - -/** TWI driver is currently busy. */ -#define TWID_ERROR_BUSY 1 - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ - -/** TWI driver structure. Holds the internal state of the driver.*/ -typedef struct _Twid { - /** Pointer to the underlying TWI peripheral.*/ - Twi *pTwi; - /** Current asynchronous transfer being processed.*/ - Async *pTransfer; - -} Twid; - -/*---------------------------------------------------------------------------- - * Export functions - *----------------------------------------------------------------------------*/ -extern void TWID_Initialize(Twid *pTwid, Twi *pTwi); - -extern void TWID_Handler(Twid *pTwid); - -extern uint8_t TWID_Read( - Twid *pTwid, - uint8_t address, - uint32_t iaddress, - uint8_t isize, - uint8_t *pData, - uint32_t num, - Async *pAsync); - -extern uint8_t TWID_Write( - Twid *pTwid, - uint8_t address, - uint32_t iaddress, - uint8_t isize, - uint8_t *pData, - uint32_t num, - Async *pAsync); - -#endif //#ifndef TWID_H - diff --git a/src/ersky9x/libraries/drivers/usart/uart_console.c b/src/ersky9x/libraries/drivers/usart/uart_console.c deleted file mode 100644 index 0b7f017e5..000000000 --- a/src/ersky9x/libraries/drivers/usart/uart_console.c +++ /dev/null @@ -1,288 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implements UART console. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include "usart/uart_console.h" - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/** Console baudrate always using 115200. */ -#define CONSOLE_BAUDRATE 115200 -/** Usart Hw interface used by the console (UART0). */ -#define CONSOLE_USART UART0 -/** Usart Hw ID used by the console (UART0). */ -#define CONSOLE_ID ID_UART0 -/** Pins description corresponding to Rxd,Txd, (UART pins) */ -#define CONSOLE_PINS {PINS_UART} - -/*---------------------------------------------------------------------------- - * Variables - *----------------------------------------------------------------------------*/ - -/** Is Console Initialized. */ -static uint8_t isConsolInitialized = 0; - -/** - * \brief Configures an USART peripheral with the specified parameters. - * - * \param baudrate Baudrate at which the USART should operate (in Hz). - * \param masterClock Frequency of the system master clock (in Hz). - */ -static void UART_Configure( uint32_t baudrate, - uint32_t masterClock) -{ - const Pin pPins[] = CONSOLE_PINS; - Uart *pUart = CONSOLE_USART; - - /* Configure PIO */ - PIO_Configure(pPins, PIO_LISTSIZE(pPins)); - - /* Configure PMC */ - PMC->PMC_PCER0 = 1 << CONSOLE_ID; - - /* Reset and disable receiver & transmitter */ - pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX - | UART_CR_RXDIS | UART_CR_TXDIS; - - /* Configure mode */ - pUart->UART_MR = (0x4 << 9); /* TODO: Change with new symbols: AT91C_UART_CHRL_8_BITS | AT91C_UART_PAR_NONE */ - - /* Configure baudrate */ - /* Asynchronous, no oversampling */ - pUart->UART_BRGR = (masterClock / baudrate) / 16; - - /* Disable PDC channel */ - pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS; - - /* Enable receiver and transmitter */ - pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN; - - isConsolInitialized = 1; -} - -/** - * \brief Outputs a character on the UART line. - * - * \note This function is synchronous (i.e. uses polling). - * \param c Character to send. - */ -void UART_PutChar(uint8_t c) -{ - Uart *pUart = CONSOLE_USART; - - if (!isConsolInitialized) - UART_Configure(CONSOLE_BAUDRATE, BOARD_MCK); - - /* Wait for the transmitter to be ready */ - while ((pUart->UART_SR & UART_SR_TXEMPTY) == 0); - - /* Send character */ - pUart->UART_THR = c; - -} - -/** - * \brief Input a character from the UART line. - * - * \note This function is synchronous - * \return character received. - */ -uint8_t UART_GetChar(void) -{ - Uart *pUart = CONSOLE_USART; - - if (!isConsolInitialized) - UART_Configure(CONSOLE_BAUDRATE, BOARD_MCK); - - while((pUart->UART_SR & UART_SR_RXRDY) == 0); - return pUart->UART_RHR; -} - -/** - * \brief Check if there is Input from UART line. - * - * \return true if there is Input. - */ -bool UART_IsRxReady(void) -{ - Uart *pUart = CONSOLE_USART; - - if (!isConsolInitialized) - UART_Configure(CONSOLE_BAUDRATE, BOARD_MCK); - - return (pUart->UART_SR & UART_SR_RXRDY) > 0; -} - -/* \cond NOFPUT */ -#ifndef NOFPUT -#include -#include -/** - * \brief Implementation of fputc using the UART as the standard output. Required - * for printf(). - * - * \param c Character to write. - * \param pStream Output stream. - * - * \return The character written if successful, or -1 if the output stream is - * not stdout or stderr. - */ -int fputc ( int c, FILE * pStream ) -{ - if ((pStream == stdout) || (pStream == stderr)) { - UART_PutChar(c); - return c; - } - else { - - return EOF; - } -} - -/** - * \brief Implementation of fputs using the UART as the standard output. Required - * for printf(). Does NOT currently use the PDC. - * - * \param pStr String to write. - * \param pStream Output stream. - * - * \return Number of characters written if successful, or -1 if the output - * stream is not stdout or stderr. - */ -signed int fputs(const char *pStr, FILE *pStream) -{ - signed int num = 0; - - while (*pStr != 0) { - - if (fputc(*pStr, pStream) == -1) { - - return -1; - } - num++; - pStr++; - } - - return num; -} - -#undef putchar - -/** - * \brief Outputs a character on the UART. - * - * \param c Character to output. - * - * \return The character that was output. - */ -signed int putchar(signed int c) -{ - return fputc(c, stdout); -} - -/* The char which has been ungotten, or EOF. */ -static int _UngetChar = EOF; - -/** - * \brief Implementation of fputc using the UART as the standard output. Required - * for printf(). - * - * \param c Character to write. - * \param pStream Output stream. - * - * \return The character written if successful, or -1 if the output stream is - * not stdout or stderr. - */ -int fgetc (FILE * pStream ) -{ - int c; - - if (pStream == stdin) { - c = UART_GetChar(); - return c; - } - else { - - return EOF; - } -} - -#undef getchar -/** - * \brief Get a character from UART. - * - * \return The character received. - */ -signed int getchar(void) -{ - if (_UngetChar != EOF) - { - int res = _UngetChar; - _UngetChar = EOF; - return res; - } - else - { - return fgetc(stdin); - } -} - -#undef __ungetchar -/** - * \brief Unget a character from stdin. - * - * \return The unget character. - */ -signed int __ungetchar(int c) -{ - _UngetChar = c; - return c; -} - -#endif /* #ifndef NOFPUT */ -/* \endcond */ diff --git a/src/ersky9x/libraries/drivers/usart/uart_console.h b/src/ersky9x/libraries/drivers/usart/uart_console.h deleted file mode 100644 index d2e4ab983..000000000 --- a/src/ersky9x/libraries/drivers/usart/uart_console.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - -#ifndef UART_CONSOLE_H_ -#define UART_CONSOLE_H_ - -extern void UART_PutChar(uint8_t c); -extern uint8_t UART_GetChar(void); -extern bool UART_IsRxReady(void); - -#endif /* UART_CONSOLE_H_ */ diff --git a/src/ersky9x/libraries/drivers/usart/usart.c b/src/ersky9x/libraries/drivers/usart/usart.c deleted file mode 100644 index c8e23d1ed..000000000 --- a/src/ersky9x/libraries/drivers/usart/usart.c +++ /dev/null @@ -1,395 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** \addtogroup usart_module Working with USART - * The USART driver provides the interface to configure and use the USART peripheral.\n - * - * The USART supports several kinds of comminication modes such as full-duplex asynchronous/ - * synchronous serial commnunication,RS485 with driver control signal,ISO7816,SPI and Test modes. - * - * To start a USART transfer with \ref AT91SAM3S_PDC "PDC" support, the user could follow these steps: - *
      - *
    • Configure USART with expected mode and baudrate(see \ref USART_Configure), which could be done by: - * -# Resetting and disabling transmitter and receiver by setting US_CR(Control Register).
    • - * -# Conifguring the USART in a specific mode by setting USART_MODE bits in US_MR(Mode Register) - * -# Setting baudrate which is different from mode to mode. - - *
    • Enable transmitter or receiver respectively by set US_CR_TXEN or US_CR_RXEN in US_CR.
    • - *
    • Read from or write to the peripheral with \ref USART_ReadBuffer or \ref USART_WriteBuffer. - These operations could be done by polling or interruption.
    • - *
    • For polling, check the status bit US_CSR_ENDRX/US_CSR_RXBUFF (READ) or US_CSR_ENDTX/ - US_CSR_TXBUFE (WRITE).
    • - *
    • For interruption,"enable" the status bit through US_IER and - realize the hanler with USARTx_IrqHandler according to IRQ vector - table which is defined in board_cstartup_.c - To enable the interruption of USART,it should be configured with priority and enabled first through - NVIC .
    • - *
    - * - * For more accurate information, please look at the USART section of the - * Datasheet. - * - * Related files :\n - * \ref usart.c\n - * \ref usart.h\n -*/ - - - -/** - * \file - * - * Implementation of USART (Universal Synchronous Asynchronous Receiver Transmitter) - * controller. - * - */ -/*------------------------------------------------------------------------------ - * Headers - *------------------------------------------------------------------------------*/ -#include - -#include "usart.h" -#include -#include - -/*---------------------------------------------------------------------------- - * Local definitions - *----------------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------------------ - * Exported functions - *------------------------------------------------------------------------------*/ - -/** - * \brief Configures an USART peripheral with the specified parameters. - * - * - * \param usart Pointer to the USART peripheral to configure. - * \param mode Desired value for the USART mode register (see the datasheet). - * \param baudrate Baudrate at which the USART should operate (in Hz). - * \param masterClock Frequency of the system master clock (in Hz). - */ -void USART_Configure(Usart *usart, - uint32_t mode, - uint32_t baudrate, - uint32_t masterClock) -{ - /* Reset and disable receiver & transmitter*/ - usart->US_CR = US_CR_RSTRX | US_CR_RSTTX - | US_CR_RXDIS | US_CR_TXDIS; - - /* Configure mode*/ - usart->US_MR = mode; - - /* Configure baudrate*/ - /* Asynchronous, no oversampling*/ - if (((mode & US_MR_SYNC__CPHA) == 0) - && ((mode & US_MR_OVER) == 0)) { - - usart->US_BRGR = (masterClock / baudrate) / 16; - } - /* TODO other modes*/ -} -/** - * \brief Enables or disables the transmitter of an USART peripheral. - * - * - * \param usart Pointer to an USART peripheral - * \param enabled If true, the transmitter is enabled; otherwise it is - * disabled. - */ -void USART_SetTransmitterEnabled(Usart *usart, uint8_t enabled) -{ - if (enabled) { - - usart->US_CR = US_CR_TXEN; - } - else { - - usart->US_CR = US_CR_TXDIS; - } -} - -/** - * \brief Enables or disables the receiver of an USART peripheral - * - * - * \param usart Pointer to an USART peripheral - * \param enabled If true, the receiver is enabled; otherwise it is disabled. - */ -void USART_SetReceiverEnabled(Usart *usart, - uint8_t enabled) -{ - if (enabled) { - - usart->US_CR = US_CR_RXEN; - } - else { - - usart->US_CR = US_CR_RXDIS; - } -} - -/** - * \brief Sends one packet of data through the specified USART peripheral. This - * function operates synchronously, so it only returns when the data has been - * actually sent. - * - * - * \param usart Pointer to an USART peripheral. - * \param data Data to send including 9nth bit and sync field if necessary (in - * the same format as the US_THR register in the datasheet). - * \param timeOut Time out value (0 = no timeout). - */ -void USART_Write( - Usart *usart, - uint16_t data, - volatile uint32_t timeOut) -{ - if (timeOut == 0) { - - while ((usart->US_CSR & US_CSR_TXEMPTY) == 0); - } - else { - - while ((usart->US_CSR & US_CSR_TXEMPTY) == 0) { - - if (timeOut == 0) { - - TRACE_ERROR("USART_Write: Timed out.\n\r"); - return; - } - timeOut--; - } - } - - usart->US_THR = data; -} - -/** - * \brief Sends the contents of a data buffer through the specified USART peripheral. - * This function returns immediately (1 if the buffer has been queued, 0 - * otherwise); poll the ENDTX and TXBUFE bits of the USART status register - * to check for the transfer completion. - * - * \param usart Pointer to an USART peripheral. - * \param buffer Pointer to the data buffer to send. - * \param size Size of the data buffer (in bytes). - */ -uint8_t USART_WriteBuffer( - Usart *usart, - void *buffer, - uint32_t size) -{ - /* Check if the first PDC bank is free*/ - if ((usart->US_TCR == 0) && (usart->US_TNCR == 0)) { - - usart->US_TPR = (uint32_t) buffer; - usart->US_TCR = size; - usart->US_PTCR = US_PTCR_TXTEN; - - return 1; - } - /* Check if the second PDC bank is free*/ - else if (usart->US_TNCR == 0) { - - usart->US_TNPR = (uint32_t) buffer; - usart->US_TNCR = size; - - return 1; - } - else { - - return 0; - } -} - - -/** - * \brief Reads and return a packet of data on the specified USART peripheral. This - * function operates asynchronously, so it waits until some data has been - * received. - * - * \param usart Pointer to an USART peripheral. - * \param timeOut Time out value (0 -> no timeout). - */ -uint16_t USART_Read( - Usart *usart, - volatile uint32_t timeOut) -{ - if (timeOut == 0) { - - while ((usart->US_CSR & US_CSR_RXRDY) == 0); - } - else { - - while ((usart->US_CSR & US_CSR_RXRDY) == 0) { - - if (timeOut == 0) { - - TRACE_ERROR("USART_Read: Timed out.\n\r"); - return 0; - } - timeOut--; - } - } - - return usart->US_RHR; -} - -/** - * \brief Reads data from an USART peripheral, filling the provided buffer until it - * becomes full. This function returns immediately with 1 if the buffer has - * been queued for transmission; otherwise 0. - * - * \param usart Pointer to an USART peripheral. - * \param buffer Pointer to the buffer where the received data will be stored. - * \param size Size of the data buffer (in bytes). - */ -uint8_t USART_ReadBuffer(Usart *usart, - void *buffer, - uint32_t size) -{ - /* Check if the first PDC bank is free*/ - if ((usart->US_RCR == 0) && (usart->US_RNCR == 0)) { - - usart->US_RPR = (uint32_t) buffer; - usart->US_RCR = size; - usart->US_PTCR = US_PTCR_RXTEN; - - return 1; - } - /* Check if the second PDC bank is free*/ - else if (usart->US_RNCR == 0) { - - usart->US_RNPR = (uint32_t) buffer; - usart->US_RNCR = size; - - return 1; - } - else { - - return 0; - } -} - -/** - * \brief Returns 1 if some data has been received and can be read from an USART; - * otherwise returns 0. - * - * \param usart Pointer to an Usart instance. - */ -uint8_t USART_IsDataAvailable(Usart *usart) -{ - if ((usart->US_CSR & US_CSR_RXRDY) != 0) { - - return 1; - } - else { - - return 0; - } -} - -/** - * \brief Sets the filter value for the IRDA demodulator. - * - * \param pUsart Pointer to an Usart instance. - * \param filter Filter value. - */ -void USART_SetIrdaFilter(Usart *pUsart, uint8_t filter) -{ - SANITY_CHECK(pUsart); - - pUsart->US_IF = filter; -} - -/** - * \brief Sends one packet of data through the specified USART peripheral. This - * function operates synchronously, so it only returns when the data has been - * actually sent. - * - * \param usart Pointer to an USART peripheral. - * \param c Character to send - */ -void USART_PutChar( - Usart *usart, - uint8_t c) -{ - /* Wait for the transmitter to be ready*/ - while ((usart->US_CSR & US_CSR_TXEMPTY) == 0); - - /* Send character*/ - usart->US_THR = c; - - /* Wait for the transfer to complete*/ - while ((usart->US_CSR & US_CSR_TXEMPTY) == 0); -} - -/** - * \brief Return 1 if a character can be read in USART - */ -uint32_t USART_IsRxReady(Usart *usart) -{ - return (usart->US_CSR & US_CSR_RXRDY); -} -/** - * \brief Get present status - */ -uint32_t USART_GetStatus(Usart *usart) -{ - return usart->US_CSR; -} -/** - * \brief Enable interrupt - */ -void USART_EnableIt(Usart *usart,uint32_t mode) -{ - usart->US_IER = mode; -} -/** - * \brief Disable interrupt - */ -void USART_DisableIt(Usart *usart,uint32_t mode) -{ - usart->US_IDR = mode; -} -/** - * \brief Reads and returns a character from the USART. - * - * \note This function is synchronous (i.e. uses polling). - * \param usart Pointer to an USART peripheral. - * \return Character received. - */ -uint8_t USART_GetChar(Usart *usart) -{ - while ((usart->US_CSR & US_CSR_RXRDY) == 0); - return usart->US_RHR; -} diff --git a/src/ersky9x/libraries/drivers/usart/usart.h b/src/ersky9x/libraries/drivers/usart/usart.h deleted file mode 100644 index 3f10e59e8..000000000 --- a/src/ersky9x/libraries/drivers/usart/usart.h +++ /dev/null @@ -1,129 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * - * This module provides several definitions and methods for using an USART - * peripheral. - * - * \par Usage - * - * -# Enable the USART peripheral clock in the PMC. - * -# Enable the required USART PIOs (see pio.h). - * -# Configure the UART by calling USART_Configure. - * -# Enable the transmitter and/or the receiver of the USART using - * USART_SetTransmitterEnabled and USART_SetReceiverEnabled. - * -# Send data through the USART using the USART_Write and - * USART_WriteBuffer methods. - * -# Receive data from the USART using the USART_Read and - * USART_ReadBuffer functions; the availability of data can be polled - * with USART_IsDataAvailable. - * -# Disable the transmitter and/or the receiver of the USART with - * USART_SetTransmitterEnabled and USART_SetReceiverEnabled. - */ - -#ifndef USART_H -#define USART_H - -/*------------------------------------------------------------------------------ - * Headers - *------------------------------------------------------------------------------*/ - -#include - -/*------------------------------------------------------------------------------ - * Definitions - *------------------------------------------------------------------------------*/ - -/** \section USART_mode USART modes - * This section lists several common operating modes for an USART peripheral. - * - * \b Modes - * - USART_MODE_ASYNCHRONOUS - * - USART_MODE_IRDA - */ - -/** Basic asynchronous mode, i.e. 8 bits no parity.*/ -#define USART_MODE_ASYNCHRONOUS (AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE) - -/** IRDA mode*/ -#define USART_MODE_IRDA (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER) - - -/*------------------------------------------------------------------------------*/ -/* Exported functions*/ -/*------------------------------------------------------------------------------*/ - -extern void USART_Configure( - Usart *usart, - uint32_t mode, - uint32_t baudrate, - uint32_t masterClock); -extern uint32_t USART_GetStatus(Usart *usart); -extern void USART_EnableIt(Usart *usart,uint32_t mode); -extern void USART_DisableIt(Usart *usart,uint32_t mode); -extern void USART_SetTransmitterEnabled(Usart *usart, uint8_t enabled); - -extern void USART_SetReceiverEnabled(Usart *usart, uint8_t enabled); - -extern void USART_Write( - Usart *usart, - uint16_t data, - volatile uint32_t timeOut); - -extern uint8_t USART_WriteBuffer( - Usart *usart, - void *buffer, - uint32_t size); - -extern uint16_t USART_Read( - Usart *usart, - volatile uint32_t timeOut); - -extern uint8_t USART_ReadBuffer( - Usart *usart, - void *buffer, - uint32_t size); - -extern uint8_t USART_IsDataAvailable(Usart *usart); - -extern void USART_SetIrdaFilter(Usart *pUsart, uint8_t filter); - -extern void USART_PutChar(Usart *usart, uint8_t c); - -extern uint32_t USART_IsRxReady(Usart *usart); - -extern uint8_t USART_GetChar(Usart *usart); - - -#endif /*#ifndef USART_H*/ - diff --git a/src/ersky9x/libraries/drivers/utility/assert.h b/src/ersky9x/libraries/drivers/utility/assert.h deleted file mode 100644 index 5cccb6193..000000000 --- a/src/ersky9x/libraries/drivers/utility/assert.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Definition of the ASSERT() and SANITY_CHECK() macros, which are used for -/// runtime condition & parameter verifying. -/// -/// !Usage -/// -/// -# Use ASSERT() in your code to check the value of function parameters, -/// return values, etc. *Warning:* the ASSERT() condition must not have -/// any side-effect; otherwise, the program may not work properly -/// anymore when assertions are disabled. -/// -# Use SANITY_CHECK() to perform checks with a default error message -/// (outputs the file and line number where the error occured). This -/// reduces memory overhead caused by assertion error strings. -/// -# Initialize the dbgu to see failed assertions at run-time. -/// -# Assertions can be entirely disabled by defining the NOASSERT symbol -/// at compilation time. -//------------------------------------------------------------------------------ - -#ifndef ASSERT_H -#define ASSERT_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "trace.h" - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#if defined(NOASSERT) - #define ASSERT(...) - #define SANITY_CHECK(...) -#else - - #if (TRACE_LEVEL == 0) - /// Checks that the given condition is true, - /// otherwise stops the program execution. - /// \param condition Condition to verify. - #define ASSERT(condition, ...) { \ - if (!(condition)) { \ - while (1); \ - } \ - } - - /// Performs the same duty as the ASSERT() macro - /// \param condition Condition to verify. - #define SANITY_CHECK(condition) ASSERT(condition, ...) - - #else - /// Checks that the given condition is true, otherwise displays an error - /// message and stops the program execution. - /// \param condition Condition to verify. - #define ASSERT(condition, ...) { \ - if (!(condition)) { \ - printf("-F- ASSERT: "); \ - printf(__VA_ARGS__); \ - while (1); \ - } \ - } - #define SANITY_ERROR "Sanity check failed at %s:%d\n\r" - - /// Performs the same duty as the ASSERT() macro, except a default error - /// message is output if the condition is false. - /// \param condition Condition to verify. - #define SANITY_CHECK(condition) ASSERT(condition, SANITY_ERROR, __FILE__, __LINE__) - #endif -#endif - - - - - - - - - - -#endif //#ifndef ASSERT_H - diff --git a/src/ersky9x/libraries/drivers/utility/bitbanding.h b/src/ersky9x/libraries/drivers/utility/bitbanding.h deleted file mode 100644 index d709d6dc0..000000000 --- a/src/ersky9x/libraries/drivers/utility/bitbanding.h +++ /dev/null @@ -1,108 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef BITBANDING_H -#define BITBANDING_H - -//------------------------------------------------------------------------------ -/// \file bitbanding.h -/// Include Defines & macros for bit-banding. -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Header files -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Global Macros -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \def IS_BITBAND_SRAM_ADDR(x) -/// \brief Check if the address is in bit banding sram region. -/// \note The address should be in area of 0x2000000 ~ 0x200FFFFF -/// \param x The address to check. -//------------------------------------------------------------------------------ -#define IS_BITBAND_SRAM_ADDR(x) \ - ( ((uint32_t)(x)) >= 0x20000000 && \ - ((uint32_t)(x)) < (0x20000000+0x100000) ) - -//------------------------------------------------------------------------------ -/// \def IS_BITBAND_PERIPH_ADDR(x) -/// \brief Check if the address is in bit banding peripheral region -/// \note The address should be in area of 0x4000000 ~ 0x400FFFFF -/// \param x The address to check -//------------------------------------------------------------------------------ -#define IS_BITBAND_PERIPH_ADDR(x) \ - ( ((uint32_t)(x)) >= 0x40000000 && \ - ((uint32_t)(x)) < (0x40000000+0x100000) ) - -//------------------------------------------------------------------------------ -/// \def BITBAND_ALIAS_ADDRESS(addr, bit) -/// \brief Calculate bit band alias address. -/// -/// Calculate the bit band alias address and return a pointer address to word. -/// \param addr The byte address of bitbanding bit. -/// \param bit The bit position of bitbanding bit. -/// \callergraph -//------------------------------------------------------------------------------ -#define BITBAND_ALIAS_ADDRESS(addr, bit) \ - ((volatile uint32_t*)((((uint32_t)(addr) & 0xF0000000) + 0x02000000) \ - +((((uint32_t)(addr)&0xFFFFF)*32)\ - +( (uint32_t)(bit)*4)))) - -//------------------------------------------------------------------------------ -/// \def WRITE_BITBANDING(addr32, bit, val) -/// \brief Bit write through bit banding. -/// \param addr32 32-bit aligned byte address where the bit exists. -/// \param bit Bit position. -/// \param val The value that the bit is set to. -/// \callergraph -//------------------------------------------------------------------------------ -#define WRITE_BITBANDING(addr32, bit, val) do {\ - *BITBAND_ALIAS_ADDRESS(addr32,bit) = (val); \ - } while (0); - -//------------------------------------------------------------------------------ -/// \def TOGGLE_BITBANDING(addr32, bit) -/// \brief Toggle bit through bit banding -/// \param addr32 32-bit aligned byte address where the bit exists. -/// \param bit Bit position. -//------------------------------------------------------------------------------ -#define TOGGLE_BITBANDING(addr32, bit) do {\ - volatile uint32_t * p = \ - BITBAND_ALIAS_ADDRESS(addr32,bit); \ - if (*p) *p = 0; \ - else *p = 1; \ - }while(0); - -#endif //#ifndef BITBANDING_H - diff --git a/src/ersky9x/libraries/drivers/utility/bmp.c b/src/ersky9x/libraries/drivers/utility/bmp.c deleted file mode 100644 index 13ad4101d..000000000 --- a/src/ersky9x/libraries/drivers/utility/bmp.c +++ /dev/null @@ -1,322 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "bmp.h" -#include -#include - -#include - -//----------------------------------------------------------------------------- -// Define -//----------------------------------------------------------------------------- -/// BMP offset for header -#define IMAGE_OFFSET 0x100 - - -//------------------------------------------------------------------------------ -// Internal constants -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Describe the BMP palette -//------------------------------------------------------------------------------ -struct BMPPaletteEntry { - - /// Blue value - unsigned char b; - /// Green value - unsigned char g; - /// Red value - unsigned char r; - /// Filler character value - unsigned char filler; -}; - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Test if BMP is valid -/// \param file Buffer holding the file to examinate. -/// \return 1 if the header of a BMP file is valid; otherwise returns 0. -//------------------------------------------------------------------------------ -unsigned char BMP_IsValid(void *file) -{ - return ((struct BMPHeader *) file)->type == BMP_TYPE; -} - -//------------------------------------------------------------------------------ -/// Returns the size of a BMP image given at least its header (the file does -/// not have to be complete). -/// \param file Pointer to the buffer which holds the BMP file. -/// \return size of BMP image -//------------------------------------------------------------------------------ -unsigned int BMP_GetFileSize(void *file) -{ - return ((struct BMPHeader *) file)->fileSize; -} - -//----------------------------------------------------------------------------- -/// Write a BMP header -/// \param pAddressHeader Begin address of the BMP -/// \param bmpHSize BMP heigth size -/// \param bmpVSize BMP width size -/// \param bmpRgb Type of BMP (YUV or RGB) -/// \param nbByte_Pixels Number of byte per pixels -//----------------------------------------------------------------------------- -void WriteBMPheader(unsigned int* pAddressHeader, - unsigned int bmpHSize, - unsigned int bmpVSize, - unsigned char bmpRgb, - unsigned char nbByte_Pixels) -{ - unsigned int i; - unsigned int* fill; - struct BMPHeader *Header; - - fill = pAddressHeader; - for (i=0; itype = BMP_TYPE; - Header->fileSize = (bmpHSize * bmpVSize * nbByte_Pixels) + IMAGE_OFFSET; - Header->reserved1 = 0; - Header->reserved2 = 0; - Header->offset = IMAGE_OFFSET; - Header->headerSize = BITMAPINFOHEADER; - Header->width = bmpHSize; - Header->height = bmpVSize; - Header->planes = 1; - Header->bits = nbByte_Pixels * 8; - Header->compression = 0; - Header->imageSize = bmpHSize * bmpVSize * nbByte_Pixels; - Header->xresolution = 0; - Header->yresolution = 0; - Header->ncolours = 0; - Header->importantcolours = 0; -} - - -//------------------------------------------------------------------------------ -/// debug function, dislay BMP header -/// \param pAddressHeader Address of the BMP -//------------------------------------------------------------------------------ -void BMP_displayHeader(unsigned int* pAddressHeader) -{ - struct BMPHeader *header; - - header = (struct BMPHeader*) pAddressHeader; - - TRACE_INFO("BMP\n\r"); - TRACE_INFO("type 0x%X \n\r", header->type); - TRACE_INFO("fileSize %d \n\r", header->fileSize); - TRACE_INFO("reserved1 %d \n\r", header->reserved1); - TRACE_INFO("reserved2 %d \n\r", header->reserved2); - TRACE_INFO("offset %d \n\r", header->offset); - TRACE_INFO("headerSize %d \n\r", header->headerSize); - TRACE_INFO("width %d \n\r", header->width); - TRACE_INFO("height %d \n\r", header->height); - TRACE_INFO("planes %d \n\r", header->planes); - TRACE_INFO("bits %d \n\r", header->bits); - TRACE_INFO("compression %d \n\r", header->compression); - TRACE_INFO("imageSize %d \n\r", header->imageSize); - TRACE_INFO("xresolution %d \n\r", header->xresolution); - TRACE_INFO("yresolution %d \n\r", header->yresolution); - TRACE_INFO("ncolours %d \n\r", header->ncolours); - TRACE_INFO("importantcolours %d\n\r", header->importantcolours); -} - - -//------------------------------------------------------------------------------ -/// Loads a BMP image located at the given address, decodes it and stores the -/// resulting image inside the provided buffer. Image must have the specified -/// width & height. -/// If no buffer is provided, this function simply checks if it is able to -/// decode the image. -/// \param file Buffer which holds the BMP file. -/// \param buffer Buffer in which to store the decoded image. -/// \param width Buffer width in pixels. -/// \param height Buffer height in pixels. -/// \param bpp Number of bits per pixels that the buffer stores. -/// \return 0 if the image has been loaded; otherwise returns an error code. -//------------------------------------------------------------------------------ -unsigned char BMP_Decode( - void *file, - unsigned char *buffer, - unsigned int width, - unsigned int height, - unsigned char bpp) -{ - struct BMPHeader *header; - unsigned int i, j; - unsigned char r, g, b; - unsigned char *image; - - // Read header information - header = (struct BMPHeader *) file; - - // Verify that the file is valid - if (!BMP_IsValid(file)) { - - TRACE_ERROR("BMP_Decode: File type is not 'BM' (0x%04X).\n\r",header->type); - return 1; - } - - // Check that parameters match - if ((header->compression != 0) - || (header->width != width) - || (header->height != height)) { - - TRACE_ERROR("BMP_Decode: File format not supported\n\r"); - TRACE_ERROR(" -> .compression = %u\n\r", header->compression); - TRACE_ERROR(" -> .width = %u\n\r", header->width); - TRACE_ERROR(" -> .height = %u\n\r", header->height); - TRACE_ERROR(" -> .bits = %d\n\r", header->bits); - return 2; - } - - // Get image data - image = (unsigned char *) ((unsigned int) file + header->offset); - - // Check that the bpp resolution is supported - // Only a 24-bit output & 24- or 8-bit input are supported - if (bpp != 24) { - - TRACE_ERROR("BMP_Decode: Output resolution not supported\n\r"); - return 3; - } - else if (header->bits == 24) { - - // Decoding is ok - if (!buffer) return 0; - - // Get image data (swapping red & blue) - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - - r = image[((height - i - 1) * width + j) * 3 + 2]; - g = image[((height - i - 1) * width + j) * 3 + 1]; - b = image[((height - i - 1) * width + j) * 3]; - -#if defined(BOARD_LCD_RGB565) - // Interlacing - r = ((r << 1) & 0xF0) | ((g & 0x80) >> 4) | ((r & 0x80) >> 5); - g = (g << 1) & 0xF8; - b = b & 0xF8; - - buffer[(i * width + j) * 3] = b; - buffer[(i * width + j) * 3 + 1] = g; - buffer[(i * width + j) * 3 + 2] = r; - -#else - buffer[(i * width + j) * 3] = r; - buffer[(i * width + j) * 3 + 1] = g; - buffer[(i * width + j) * 3 + 2] = b; -#endif //#if defined(BOARD_LCD_RGB565) - } - } - } - else if (header->bits == 8) { - - // Decoding is ok - if (!buffer) return 0; - - // Retrieve palette - struct BMPPaletteEntry palette[256]; - memcpy(palette, - (unsigned char *) ((unsigned int) file + sizeof(struct BMPHeader)), - header->offset - sizeof(struct BMPHeader)); - - // Decode image (reversing row order) - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - - r = palette[image[(height - i - 1) * width + j]].r; - g = palette[image[(height - i - 1) * width + j]].g; - b = palette[image[(height - i - 1) * width + j]].b; - - buffer[(i * width + j) * 3] = r; - buffer[(i * width + j) * 3 + 1] = g; - buffer[(i * width + j) * 3 + 2] = b; - } - } - } - else { - - TRACE_ERROR("BMP_Decode: Input resolution not supported\n\r"); - TRACE_INFO("header->bits 0x%X \n\r", header->bits); - return 4; - } - - return 0; -} - -//------------------------------------------------------------------------------ -/// Convert RGB 565 to RGB 555 (RGB 555 is adapted to LCD) -/// \param fileSource Buffer which holds the RGB file -/// \param fileDestination Buffer in which to store the decoded image -/// \param width Buffer width in pixels. -/// \param height Buffer height in pixels. -/// \param bpp Number of bits per pixels that the buffer stores. -//------------------------------------------------------------------------------ -void RGB565toBGR555( - unsigned char *fileSource, - unsigned char *fileDestination, - unsigned int width, - unsigned int height, - unsigned char bpp) -{ - unsigned int i; - unsigned int j; - unsigned int row; - - for (i=0; i < height*(bpp/8); i++) { - row = (i*width*(bpp/8)); - for (j=0; j <= width*(bpp/8); j+=2) { - fileDestination[row+j] = ((fileSource[row+j+1]>>3)&0x1F) - | (fileSource[row+j]&0xE0); - fileDestination[row+j+1] = (fileSource[row+j+1]&0x03) - | ((fileSource[row+j]&0x1F)<<2); - } - } -} diff --git a/src/ersky9x/libraries/drivers/utility/bmp.h b/src/ersky9x/libraries/drivers/utility/bmp.h deleted file mode 100644 index 6adfac38c..000000000 --- a/src/ersky9x/libraries/drivers/utility/bmp.h +++ /dev/null @@ -1,130 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Utility for BMP -/// -//------------------------------------------------------------------------------ - -#ifndef BMP_H -#define BMP_H - -/// BMP magic number ('BM'). -#define BMP_TYPE 0x4D42 - -/// headerSize must be set to 40 -#define BITMAPINFOHEADER 40 - -//------------------------------------------------------------------------------ -// Exported types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -// BMP (Windows) Header Format -struct BMPHeader { - /// signature, must be 4D42 hex - unsigned short type; - /// size of BMP file in bytes (unreliable) - unsigned int fileSize; - /// reserved, must be zero - unsigned short reserved1; - /// reserved, must be zero - unsigned short reserved2; - /// offset to start of image data in bytes - unsigned int offset; - /// size of BITMAPINFOHEADER structure, must be 40 - unsigned int headerSize; - /// image width in pixels - unsigned int width; - /// image height in pixels - unsigned int height; - /// number of planes in the image, must be 1 - unsigned short planes; - /// number of bits per pixel (1, 4, 8, 16, 24, 32) - unsigned short bits; - /// compression type (0=none, 1=RLE-8, 2=RLE-4) - unsigned int compression; - /// size of image data in bytes (including padding) - unsigned int imageSize; - /// horizontal resolution in pixels per meter (unreliable) - unsigned int xresolution; - /// vertical resolution in pixels per meter (unreliable) - unsigned int yresolution; - /// number of colors in image, or zero - unsigned int ncolours; - /// number of important colors, or zero - unsigned int importantcolours; - -} __attribute__ ((packed)); // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char BMP_IsValid(void *file); - -extern unsigned int BMP_GetFileSize(void *file); - -extern unsigned char BMP_Decode( - void *file, - unsigned char *buffer, - unsigned int width, - unsigned int height, - unsigned char bpp); - -extern void WriteBMPheader(unsigned int* pAddressHeader, - unsigned int bmpHSize, - unsigned int bmpVSize, - unsigned char bmpRgb, - unsigned char nbByte_Pixels); - -extern void BMP_displayHeader(unsigned int* pAddressHeader); - -extern void RGB565toBGR555( - unsigned char *fileSource, - unsigned char *fileDestination, - unsigned int width, - unsigned int height, - unsigned char bpp); - - -#endif //#ifndef BMP_H - diff --git a/src/ersky9x/libraries/drivers/utility/clock.c b/src/ersky9x/libraries/drivers/utility/clock.c deleted file mode 100644 index 110e68eca..000000000 --- a/src/ersky9x/libraries/drivers/utility/clock.c +++ /dev/null @@ -1,259 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "clock.h" -#include -#include - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ -int currentConfig = 0; // 0 have to be the default configuration - -//------------------------------------------------------------------------------ -/// Describes a possible clock configuration (processor clock & master clock), -/// including the necessary register values. -//------------------------------------------------------------------------------ -struct ClockConfiguration { - - /// Processor clock frequency (in MHz). - unsigned short pck; - /// Master clock frequency (in MHz). - unsigned short mck; - /// CKGR_PLL reqister value. - unsigned int pllr; - /// PMC_MCKR register value. - unsigned int mckr; -}; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -// Clock configurations for the AT91SAM9263-EK -#if defined(at91sam9263) - -#define AT91C_CKGR_PLLR AT91C_CKGR_PLLAR -#define AT91C_PMC_LOCK AT91C_PMC_LOCKA - -static const struct ClockConfiguration clockConfigurations[] = { - // PCK = 200 MHz, MCK = 100 MHz - {200, 100, 0x206DBF09, 0x00000102}, - // PCK = 240 MHz, MCK = 120 MHz - {240, 120, 0x202BC003, 0x00000102}, - // PCK = 120 MHz, MCK = 120 MHz - {120, 120, 0x20156003, 0x00000002}, - // PCK = 96 MHz, MCK = 48 MHz - {96, 48, 0x2057400F, 0x00000102}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x2057400F, 0x00000006} -}; - -// Clock configurations for the AT91SAM9G20-EK -#elif defined(at91sam9g20) - -#define AT91C_CKGR_PLLR AT91C_CKGR_PLLAR -#define AT91C_PMC_LOCK AT91C_PMC_LOCKA - -static const struct ClockConfiguration clockConfigurations[] = { - - // PCK = 400 MHz, MCK = 133 MHz - {400, 133, 0x202A0101, 0x00001302}, - // PCK = 200 MHz, MCK = 100 MHz - {200, 100, 0x202A3F01, 0x0000010A}, - // PCK = 96 MHz, MCK = 48 MHz - {96, 48, 0x207C3F03, 0x0000010E}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x207C3F03, 0x00000012} -}; - -// Clock configurations for the AT91SAM9XE-EK, AT91SAM9261-EK -#elif defined(at91sam9xe128) || \ - defined(at91sam9xe256) || \ - defined(at91sam9xe512) || \ - defined(at91sam9261) - -#define AT91C_CKGR_PLLR AT91C_CKGR_PLLAR -#define AT91C_PMC_LOCK AT91C_PMC_LOCKA - -static const struct ClockConfiguration clockConfigurations[] = { - - // PCK = 200 MHz, MCK = 100 MHz - {200, 100, 0x208CBF0D, 0x00000102}, - // PCK = 100 MHz, MCK = 100 MHz - {100, 100, 0x20273F07, 0x00000002}, - // PCK = 96 MHz, MCK = 48 MHz - {96, 48, 0x20483F0E, 0x00000102}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x20483F0E, 0x00000006} -}; - -// Clock configurations for the AT91SAM9RL64-EK, AT91CAP9-DK, AT91CAP9-STK -#elif defined(at91sam9rl64) || \ - defined(at91cap9) - -#define AT91C_CKGR_PLLR AT91C_CKGR_PLLAR -#define AT91C_PMC_LOCK AT91C_PMC_LOCKA - -static const struct ClockConfiguration clockConfigurations[] = { - - // PCK = 200 MHz, MCK = 100 MHz - {200, 100, 0x2031BF03, 0x00000102}, - // PCK = 100 MHz, MCK = 100 MHz - {100, 100, 0x20183F03, 0x00000002}, - // PCK = 96 MHz, MCK = 48 MHz - {96, 48, 0x20073F01, 0x00000102}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x20073F01, 0x00000006} -}; - -// Clock configuration for the AT91SAM7X-EK, AT91SAM7S-EK, AT91SAM7SE-EK -#elif defined(at91sam7x128) || defined(at91sam7x256) || defined(at91sam7x512) \ - || defined(at91sam7xc128) || defined(at91sam7xc256) || defined(at91sam7xc512) \ - || defined(at91sam7s16) || defined(at91sam7s161) || defined(at91sam7s32) \ - || defined(at91sam7s321) || defined(at91sam7s64) || defined(at91sam7s128) \ - || defined(at91sam7s256) || defined(at91sam7s512) || defined(at91sam7se32) \ - || defined(at91sam7se256) || defined(at91sam7se512) - -static const struct ClockConfiguration clockConfigurations[] = { - - // PCK = 55 MHz, MCK = 55 MHz - {55, 55, 0x006A3F12, 0x00000007}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x00483F0E, 0x00000007}, -}; - -// Clock configuration for the AT91SAM7A3 -#elif defined(at91sam7a3) - -static const struct ClockConfiguration clockConfigurations[] = { - - // PCK = 60 MHz, MCK = 60 MHz - {60, 60, 0x000C3F02, 0x00000007}, - // PCK = 48 MHz, MCK = 48 MHz - {48, 48, 0x00483F0E, 0x00000007} -}; - -// No clock configuration -#else - #error No clock configuration for this board. -#endif - -/// Number of available clock configurations -#define NB_CLOCK_CONFIGURATION (sizeof(clockConfigurations)/sizeof(clockConfigurations[0])) - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Sets the specified clock configuration. -/// \param configuration Index of the configuration to set. -//------------------------------------------------------------------------------ -void CLOCK_SetConfig(unsigned char configuration) -{ - printf("Setting clock configuration #%d ... ", configuration); - currentConfig = configuration; - - // Switch to main oscillator in two operations - PMC->PMC_MCKR = (PMC->PMC_MCKR & ~AT91C_PMC_CSS) | AT91C_PMC_CSS_MAIN_CLK; - while ((PMC->PMC_SR & AT91C_PMC_MCKRDY) == 0); - - // Configure PLL - *AT91C_CKGR_PLLAR = clockConfigurations[configuration].pllr; - while ((PMC->PMC_SR & AT91C_PMC_LOCKA) == 0); - - // Configure master clock in two operations - PMC->PMC_MCKR = (clockConfigurations[configuration].mckr & ~AT91C_PMC_CSS) | AT91C_PMC_CSS_MAIN_CLK; - while ((PMC->PMC_SR & AT91C_PMC_MCKRDY) == 0); - PMC->PMC_MCKR = clockConfigurations[configuration].mckr; - while ((PMC->PMC_SR & AT91C_PMC_MCKRDY) == 0); - - // DBGU reconfiguration - DBGU_Configure(DBGU_STANDARD, 115200, clockConfigurations[configuration].mck*1000000); - printf("done.\n\r"); -} - -//------------------------------------------------------------------------------ -/// Display the user menu on the DBGU. -//------------------------------------------------------------------------------ -void CLOCK_DisplayMenu(void) -{ - unsigned int i; - - printf("\n\rMenu Clock configuration:\n\r"); - for (i = 0; i < NB_CLOCK_CONFIGURATION; i++) { - - printf(" %d: Set PCK = %3d MHz, MCK = %3d MHz %s\n\r", - i, - clockConfigurations[i].pck, - clockConfigurations[i].mck, - (currentConfig==i)?"(curr)":""); - } -} - -//------------------------------------------------------------------------------ -/// Get the current MCK -//------------------------------------------------------------------------------ -unsigned short CLOCK_GetCurrMCK(void) -{ - return clockConfigurations[currentConfig].mck; -} - -//------------------------------------------------------------------------------ -/// Get the current PCK -//------------------------------------------------------------------------------ -unsigned short CLOCK_GetCurrPCK(void) -{ - return clockConfigurations[currentConfig].pck; -} - -//------------------------------------------------------------------------------ -/// Change clock configuration. -//------------------------------------------------------------------------------ -void CLOCK_UserChangeConfig(void) -{ - unsigned char key = 0; - - while (1) - { - CLOCK_DisplayMenu(); - key = DBGU_GetChar(); - - if ((key >= '0') && (key <= ('0' + NB_CLOCK_CONFIGURATION - 1))) - { - CLOCK_SetConfig(key - '0'); - break; - } - } -} \ No newline at end of file diff --git a/src/ersky9x/libraries/drivers/utility/clock.h b/src/ersky9x/libraries/drivers/utility/clock.h deleted file mode 100644 index 976f8e967..000000000 --- a/src/ersky9x/libraries/drivers/utility/clock.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef CLOCK_H -#define CLOCK_H - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -extern void CLOCK_SetConfig(unsigned char configuration); - -extern void CLOCK_DisplayMenu(void); - -extern void CLOCK_UserChangeConfig(void); - -extern unsigned short CLOCK_GetCurrMCK(void); - -extern unsigned short CLOCK_GetCurrPCK(void); - -#endif //#ifndef FREQCONF_H diff --git a/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.c b/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.c deleted file mode 100644 index c81bae655..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.c +++ /dev/null @@ -1,316 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Function: Firmware encryption using hardware acceleration -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#include "aes_hardware.h" - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_HARD) -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Inline functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Converts an ASCII value to an hexadecimal one -/// \param ASCII string -/// \param Buffer to store integer value -/// \param Length of string -//------------------------------------------------------------------------------ -static inline void ASCII2Hex(const unsigned char * ascii, - unsigned char * binary, - unsigned int length) -{ - unsigned int i; - - for (i=0; i < length; i++) { - if (ascii[i*2] >= 'A') { - binary[i] = ascii[i*2] - 'A' + 10; - } - else { - binary[i] = ascii[i*2] - '0'; - } - binary[i] <<= 4; - if (ascii[i*2+1] >= 'A') { - binary[i] += ascii[i*2+1] - 'A' + 10; - } - else { - binary[i] += ascii[i*2+1] - '0'; - } - } -} - -//------------------------------------------------------------------------------ -// Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the AES peripheral -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -void aes_hard_init(void) -{ - unsigned char key[16]; - -#if defined(ENCRYPTION_CTR) || defined(ENCRYPTION_CBC) - unsigned char IV[16]; -#endif - - TRACE_DEBUG("AES/HARD: Initializing ...\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode -#if defined(ENCRYPTION_ECB) - //AES_Configure(AT91C_AES_CIPHER, AT91C_AES_SMOD_PDC, AT91C_AES_OPMOD_ECB); - - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_ECB; -#elif defined(ENCRYPTION_CBC) - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_CBC; -#elif defined(ENCRYPTION_CTR) - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_CTR; -#endif - - // Convert and load key - ASCII2Hex((unsigned char*)ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - AES_SetKey((unsigned int*)key); - - // Convert and load IV -#if defined(ENCRYPTION_CTR) || defined(ENCRYPTION_CBC) - ASCII2Hex((unsigned char*)ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - AES_SetVector((unsigned int*)IV); -#endif - - TRACE_DEBUG("AES/HARD: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES peripheral for CBC mode -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -#if defined(ENCRYPTION_CBC) -void aes_hard_init_CBC(void) -{ - unsigned char key[16]; - unsigned char IV[16]; - - TRACE_DEBUG("aes_hard_init_CBC\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_CBC; - - // Convert and load key - ASCII2Hex((unsigned char*)ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - AES_SetKey((unsigned int*)key); - - // Convert and load IV - ASCII2Hex((unsigned char*)ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - AES_SetVector((unsigned int*)IV); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES peripheral for CTR mode -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -void aes_hard_init_CTR(void) -{ - unsigned char key[16]; - unsigned char IV[16]; - - TRACE_DEBUG("aes_hard_init_CTR\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_CTR; - - // Convert and load key - ASCII2Hex((unsigned char*)ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - AES_SetKey((unsigned int*)key); - - // Convert and load IV - ASCII2Hex((unsigned char*)ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - AES_SetVector((unsigned int*)IV); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES peripheral for ECB mode -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -void aes_hard_init_ECB(void) -{ - unsigned char key[16]; - - TRACE_DEBUG("aes_hard_init_ECB\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode - //AES_Configure(AT91C_AES_CIPHER, AT91C_AES_SMOD_MANUAL, AT91C_AES_OPMOD_ECB); - AT91C_BASE_AES->AES_MR = AT91C_AES_SMOD_PDC | AT91C_AES_OPMOD_ECB; - - // Convert and load key - ASCII2Hex((unsigned char*)ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - AES_SetKey((unsigned int*)key); -} -#endif -#endif // ONLY_ONE_ENCRYPTION - -//------------------------------------------------------------------------------ -/// Cleans up the AES peripheral -//------------------------------------------------------------------------------ -void aes_hard_cleanup(void) -{ - TRACE_DEBUG("AES/HARD: Cleaning up ...\n\r"); - - AT91C_BASE_AES->AES_MR = 0; - -#ifdef AT91C_ID_AES - PMC_DisablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_DisablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_DisablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Close PDC - AT91C_BASE_PDC_AES->PDC_PTCR = AT91C_PDC_RXTDIS; - AT91C_BASE_PDC_AES->PDC_PTCR = AT91C_PDC_TXTDIS; - - // Reset all Counter register Next buffer first - AT91C_BASE_PDC_AES->PDC_TNPR = 0; - AT91C_BASE_PDC_AES->PDC_TNCR = 0; - AT91C_BASE_PDC_AES->PDC_RPR = 0; - AT91C_BASE_PDC_AES->PDC_RCR = 0; - AT91C_BASE_PDC_AES->PDC_TPR = 0; - AT91C_BASE_PDC_AES->PDC_TCR = 0; - AT91C_BASE_PDC_AES->PDC_RPR = 0; - AT91C_BASE_PDC_AES->PDC_RCR = 0; - - TRACE_DEBUG("AES/HARD: Cleanup done.\n\r"); -} - -//------------------------------------------------------------------------------ -/// Decrypts a variable-length cipher text -/// \param pCipherText text to decrypt -/// \param pPlainText to store plain text -/// \param length of cipher text (in bytes) -/// \return: 1 if ok, 0 if error -//------------------------------------------------------------------------------ -int aes_hard_decrypt(const unsigned char *pCipherText, - unsigned char *pPlainText, - unsigned int length) -{ - TRACE_DEBUG("aes_hard_decrypt\n\r"); - - // Check parameters - if ((pCipherText == NULL) || (pPlainText == NULL)) { - return 0; - } - - // Set source and destination buffers in PDC - AT91C_BASE_PDC_AES->PDC_TPR = (unsigned int) pCipherText; - AT91C_BASE_PDC_AES->PDC_RPR = (unsigned int) pPlainText; - - AT91C_BASE_PDC_AES->PDC_TCR = length >> 2; - AT91C_BASE_PDC_AES->PDC_RCR = length >> 2; - - // Start decryption and wait - AT91C_BASE_PDC_AES->PDC_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN; - while (((AES_GetStatus()) & AT91C_AES_ENDRX) == 0); - - return 1; -} - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_HARD) - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.h b/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.h deleted file mode 100644 index 693f09830..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/aes_hardware.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Firmware encryption using AES hardware acceleration -/// This code is based on the AES reference implementation published by Paulo -/// Barreto and Vincent Rijmen. -/// -/// !Usage -/// -/// -# aes_hard_init: Initialize AES hardware -/// -# aes_hard_init_CBC: for the CBC mode -/// -# aes_hard_init_CTR: for the CTR mode -/// -# aes_hard_init_ECB: for the ECB mode -/// -# aes_hard_cleanup: Cleans up AES -/// -# aes_hard_decrypt: Decrypts a variable-length cipher text -//------------------------------------------------------------------------------ - -#ifndef BOOTLOADER_AES_HARDWARE_H -#define BOOTLOADER_AES_HARDWARE_H - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ -#include "config.h" - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_HARD) - -//------------------------------------------------------------------------------ -// Check configuration -//------------------------------------------------------------------------------ -#if (ENCRYPTION_KEY_LENGTH != 16) - #error Hardware AES acceleration only supports 128 bits keys. -#endif - -#if (ENCRYPTION_BLOCK_LENGTH != 16) - #error Hardware AES acceleration only supports 128 bits blocks. -#endif - -#if !defined(ENCRYPTION_ECB) && \ - !defined(ENCRYPTION_CBC) && \ - !defined(ENCRYPTION_CTR) - #error Only ECB, CBC & CTR modes are supported. -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -#define ENCRYPTION_INIT aes_hard_init -#define ENCRYPTION_CLEANUP aes_hard_cleanup -#define ENCRYPTION_DECRYPT aes_hard_decrypt -#endif - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -extern void aes_hard_init(void); -#ifndef ONLY_ONE_ENCRYPTION -extern void aes_hard_init_CBC(void); -extern void aes_hard_init_CTR(void); -extern void aes_hard_init_ECB(void); -#endif -extern void aes_hard_cleanup(void); -extern int aes_hard_decrypt(const unsigned char *, unsigned char *, unsigned int); - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_HARD) -#endif // BOOTLOADER_AES_HARDWARE_H - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.c b/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.c deleted file mode 100644 index b3a5c0540..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.c +++ /dev/null @@ -1,801 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Firmware encryption using AES reference implementation -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ -#include "aes_reference.h" - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_REF) -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Global variables -//------------------------------------------------------------------------------ -#define word8 static unsigned char -#define word32 static unsigned int - -#include "boxes-ref.dat" - -static unsigned char shifts[3][2][4] = { - {{0,1,2,3}, {0,3,2,1}}, - {{0,1,2,3}, {0,5,4,3}}, - {{0,7,5,5}, {0,1,3,4}} -}; - -static unsigned char key[KC][4]; -static unsigned char expandedKey[ROUNDS+1][BC][4]; -static unsigned int T0[256], T1[256], T2[256], T3[256], TF[256]; - -#if defined(ENCRYPTION_CBC) || defined(ENCRYPTION_CTR) -static unsigned char IV[BC][4]; -#endif - -//------------------------------------------------------------------------------ -// Inline functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Multiply two elements of GF(2^m) needed for MixColumn and InvMixColumn -/// \param a first element -/// \param b second element -/// \return result of operation -//------------------------------------------------------------------------------ -static unsigned char mul(unsigned char a, unsigned char b) -{ - if (a && b) { - return Alogtable[(Logtable[a] + Logtable[b])%255]; - } - else { - return 0; - } -} - -//------------------------------------------------------------------------------ -/// Returns the minimum between two numbers -/// \param First number -/// \param Second number -/// \return Minimum between the two operands -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -static unsigned int min(unsigned int number1, unsigned int number2) -{ - if (number1 > number2) { - return number2; - } - else { - return number1; - } -} -#endif - -//------------------------------------------------------------------------------ -/// XOR text and round key together -/// \param Plain text -/// \param Round key -//------------------------------------------------------------------------------ -static inline void addRoundKey(unsigned char a[BC][4], const unsigned char rk[BC][4]) -{ - unsigned int i; - - for (i=0; i < BC; i++) { - ((int *) a)[i] ^= ((int *) rk)[i]; - } -} - -//------------------------------------------------------------------------------ -/// Performs the AES key schedule -/// \param Key to use -/// \param Buffer to store expanded key schedule -//------------------------------------------------------------------------------ -static inline void keySchedule(unsigned char k[KC][4], unsigned char W[ROUNDS+1][BC][4]) -{ - int t; - int rconpointer = 0; - unsigned int j; - unsigned char tk[KC][4]; - - for(j=0; j < KC; j++) { - ((int *) tk)[j] = ((int *) k)[j]; - } - - t = 0; - /* copy values into round key array */ - for(j=0; (j < KC) && (t < (ROUNDS+1)*BC); j++, t++) { - ((int *) W[t / BC])[t%BC] = ((int *) tk)[j]; - } - - while (t < (ROUNDS+1)*BC) { - - tk[0][0] ^= S[tk[KC-1][1]] ^ rcon[rconpointer++]; - tk[0][1] ^= S[tk[KC-1][2]]; - tk[0][2] ^= S[tk[KC-1][3]]; - tk[0][3] ^= S[tk[KC-1][0]]; - - if (KC != 8) { - for(j=1; j < KC; j++) { - ((int *) tk)[j] ^= ((int *) tk)[j-1]; - } - } - else { - for(j=1; j < KC/2; j++) { - ((int *) tk)[j] ^= ((int *) tk)[j-1]; - } - tk[KC/2][0] ^= S[tk[KC/2 - 1][0]]; - tk[KC/2][1] ^= S[tk[KC/2 - 1][1]]; - tk[KC/2][2] ^= S[tk[KC/2 - 1][2]]; - tk[KC/2][3] ^= S[tk[KC/2 - 1][3]]; - - for(j=KC/2+1; j < KC; j++) { - ((int *) tk)[j] ^= ((int *) tk)[j-1]; - } - } - - // copy values into round key array - for(j=0; (j < KC) && (t < (ROUNDS+1)*BC); j++, t++) { - ((int *) W[t/BC])[t%BC] = ((int *) tk)[j]; - } - } -} - -//------------------------------------------------------------------------------ -/// Performs the AES inverse key schedule -/// \param Key to use -/// \param Buffer to store expanded key schedule -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) || defined(ENCRYPTION_CBC) -static inline void invKeySchedule(unsigned char k[KC][4], - unsigned char W[ROUNDS+1][BC][4]) -{ - unsigned int r; - unsigned int j; - unsigned char tmp[4]; - - // Expand key normally - keySchedule(k, W); - - // Apply invMixColumns to all rounds except first and last one - for (r=1; r < ROUNDS; r++) { - for (j=0; j < BC; j++) { - tmp[0] = mul(0x0E, W[r][j][0]) ^ mul(0x0B, W[r][j][1]) ^ - mul(0x0D, W[r][j][2]) ^ mul(0x09, W[r][j][3]); - tmp[1] = mul(0x0E, W[r][j][1]) ^ mul(0x0B, W[r][j][2]) ^ - mul(0x0D, W[r][j][3]) ^ mul(0x09, W[r][j][0]); - tmp[2] = mul(0x0E, W[r][j][2]) ^ mul(0x0B, W[r][j][3]) ^ - mul(0x0D, W[r][j][0]) ^ mul(0x09, W[r][j][1]); - tmp[3] = mul(0x0E, W[r][j][3]) ^ mul(0x0B, W[r][j][0]) ^ - mul(0x0D, W[r][j][1]) ^ mul(0x09, W[r][j][2]); - W[r][j][0] = tmp[0]; - W[r][j][1] = tmp[1]; - W[r][j][2] = tmp[2]; - W[r][j][3] = tmp[3]; - } - } -} -#endif - -//------------------------------------------------------------------------------ -/// Perform the RotBytes operation needed by the AES cipher -/// \param input to rotate -/// \return Rotated word -//------------------------------------------------------------------------------ -static inline unsigned int rotBytes(unsigned int input) -{ - return ((input << 8) | (input >> 24)); -} - -//------------------------------------------------------------------------------ -/// Generates the lookup tables needed for encryption -/// \param Pointer to t0 -/// \param Pointer to t1 -/// \param Pointer to t2 -/// \param Pointer to t3 -/// \param Pointer to tf -/// \param Box -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -static inline void generateEncryptionLUTs(unsigned int * t0, - unsigned int * t1, - unsigned int * t2, - unsigned int * t3, - unsigned int * tf, - unsigned char box[256]) -{ - unsigned int a; - - for (a=0; a <= 255; a++) { - // Calc t0 - t0[a] = (mul(2, box[a])) | - (box[a] << 8) | - (box[a] << 16) | - (mul(3, box[a]) << 24); - - // Calc t1, t2, t3 - t1[a] = rotBytes(t0[a]); - t2[a] = rotBytes(t1[a]); - t3[a] = rotBytes(t2[a]); - - // Calc tf - tf[a] = box[a] | (box[a] << 8) | (box[a] << 16) | (box[a] << 24); - } -} -#endif - -//------------------------------------------------------------------------------ -/// Generates the lookup tables needed for decryption -/// \param Pointer to t0 -/// \param Pointer to t1 -/// \param Pointer to t2 -/// \param Pointer to t3 -/// \param Pointer to tf -/// \param Box -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) || defined(ENCRYPTION_CBC) -static inline void generateDecryptionLUTs(unsigned int * t0, - unsigned int * t1, - unsigned int * t2, - unsigned int * t3, - unsigned int * tf, - unsigned char box[256]) -{ - unsigned int a; - - for (a=0; a <= 255; a++) { - - // Calc t0 - t0[a] = (mul(0x0E, box[a])) | - (mul(0x09, box[a]) << 8) | - (mul(0x0D, box[a]) << 16) | - (mul(0x0B, box[a]) << 24); - - // Calc t1, t2, t3 - t1[a] = rotBytes(t0[a]); - t2[a] = rotBytes(t1[a]); - t3[a] = rotBytes(t2[a]); - - // Calc tf - tf[a] = box[a] | (box[a] << 8) | (box[a] << 16) | (box[a] << 24); - } -} -#endif - -//------------------------------------------------------------------------------ -/// Copies a block to a buffer -/// \param Block to copy -/// \param Buffer to store copy -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -static void copyBlock(unsigned char input[BC][4], unsigned char output[BC][4]) -{ - unsigned int j; - - for (j=0; j < BC; j++) { - ((int *) output)[j] = ((int *) input)[j]; - } -} -#endif - -//------------------------------------------------------------------------------ -/// Encrypts a block of plain text using precalculated LUTs -/// \param Block of plain text to encrypt -/// \param Expanded key -/// \param Pointer to t0 -/// \param Pointer to t1 -/// \param Pointer to t2 -/// \param Pointer to t3 -/// \param Pointer to tf -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -static inline void encrypt(unsigned char a[BC][4], - const unsigned char rk[ROUNDS+1][BC][4], - unsigned int * t0, - unsigned int * t1, - unsigned int * t2, - unsigned int * t3, - unsigned int * tf) -{ - unsigned char b[BC][4]; - unsigned int r; - unsigned int j; - - // First key addition - addRoundKey(a, rk[0]); - - // ROUNDS-1 ordinary rounds - for(r=1; r < ROUNDS; r++) { - for (j=0; j < BC; j++) { - - ((int *) b)[j] = t0[a[j][0]] ^ - t1[a[(j+shifts[SC][0][1])%BC][1]] ^ - t2[a[(j+shifts[SC][0][2])%BC][2]] ^ - t3[a[(j+shifts[SC][0][3])%BC][3]] ^ - ((int *) rk[r])[j]; - } - if ((++r) == ROUNDS) { - break; - } - for (j=0; j < BC; j++) { - ((int *) a)[j] = t0[b[j][0]] ^ - t1[b[(j+shifts[SC][0][1])%BC][1]] ^ - t2[b[(j+shifts[SC][0][2])%BC][2]] ^ - t3[b[(j+shifts[SC][0][3])%BC][3]] ^ - ((int *) rk[r])[j]; - } - } - - // Last round (no MixColumns) - for (j=0; j < BC; j++) { - ((int *) a)[j] = (t0f[b[j][0]]) ^ - (t1f[b[(j+shifts[SC][0][1])%BC][1]]) ^ - (t2f[b[(j+shifts[SC][0][2])%BC][2]]) ^ - (t3f[b[(j+shifts[SC][0][3])%BC][3]]) ^ - ((int *) rk[ROUNDS])[j]; - } -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a block of plain text using precalculated LUTs -/// \param Block of cipher text to decrypt -/// \param Expanded key -/// \param Pointer to t0 -/// \param Pointer to t1 -/// \param Pointer to t2 -/// \param Pointer to t3 -/// \param Pointer to tf -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) || defined(ENCRYPTION_CBC) -static inline void decrypt(unsigned char a[BC][4], - const unsigned char rk[ROUNDS+1][BC][4], - unsigned int * t0, - unsigned int * t1, - unsigned int * t2, - unsigned int * t3, - unsigned int * tf) -{ - unsigned char b[BC][4]; - unsigned int r; - unsigned int j; - - // First key addition - addRoundKey(a, rk[ROUNDS]); - - // ROUNDS-1 ordinary rounds - for(r=ROUNDS-1; r > 0; r--) { - for (j=0; j < BC; j++) { - ((int *) b)[j] = t0[a[j][0]] ^ - t1[a[(j+shifts[SC][1][1])%BC][1]] ^ - t2[a[(j+shifts[SC][1][2])%BC][2]] ^ - t3[a[(j+shifts[SC][1][3])%BC][3]] ^ - ((int *) rk[r])[j]; - } - if ((--r) == 0) { - break; - } - for (j=0; j < BC; j++) { - ((int *) a)[j] = t0[b[j][0]] ^ - t1[b[(j+shifts[SC][1][1])%BC][1]] ^ - t2[b[(j+shifts[SC][1][2])%BC][2]] ^ - t3[b[(j+shifts[SC][1][3])%BC][3]] ^ - ((int *) rk[r])[j]; - } - } - // Last round (no MixColumns) - for (j=0; j < BC; j++) { - ((int *) a)[j] = (t0f[b[j][0]]) ^ - (t1f[b[(j+shifts[SC][1][1])%BC][1]]) ^ - (t2f[b[(j+shifts[SC][1][2])%BC][2]]) ^ - (t3f[b[(j+shifts[SC][1][3])%BC][3]]) ^ - ((int *) rk[0])[j]; - } -} -#endif - -//------------------------------------------------------------------------------ -/// Converts an ASCII hexadecimal representation to a raw binary one -/// \param ASCII value -/// \param Buffer to store binary value -/// \param Size of value -//------------------------------------------------------------------------------ -static void ASCII2RawHex(const unsigned char * ascii, - unsigned char * binary, - unsigned int length) -{ - unsigned char * ptr; - unsigned int i; - - ptr = (unsigned char *) binary; - for (i=0; i < length; i++, ptr++, ascii++) { - if (*ascii >= 'A') { - *ptr = *ascii - 'A' + 10; - } - else { - *ptr = *ascii - '0'; - } - *ptr <<= 4; - ascii++; - if (*ascii >= 'A') { - *ptr += *ascii - 'A' + 10; - } - else { - *ptr += *ascii - '0'; - } - } -} - -//------------------------------------------------------------------------------ -/// Decrypts a cipher text using ECB mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text -/// \param Expanded key to use -/// \return 0 if successful, 0 otherwise -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -static unsigned int ecb_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length, - unsigned char expandedKey[ROUNDS+1][BC][4]) -{ - unsigned char block[BC][4]; - unsigned int i; - unsigned int l; - - // Check input parameters - if ((cipherText == NULL) || (plainText == NULL) || (expandedKey == NULL)) { - TRACE_DEBUG("AES/REF: NULL parameter(s).\n\r"); - return 0; - } - if (length%ENCRYPTION_BLOCK_LENGTH != 0) { - TRACE_DEBUG("AES/REF: Data length must be a multiple of the cipher block size.\n\r"); - return 0; - } - // ECB decryption - for (l=0; l < length;) { - // Copy cipher text block, decrypt it and copy result - for (i=0; i < ENCRYPTION_BLOCK_LENGTH; i++) { - ((char *) block)[i] = cipherText[l+i]; - } - decrypt(block, expandedKey, T0, T1, T2, T3, TF); - for (i=0; i < ENCRYPTION_BLOCK_LENGTH; i++) { - plainText[l+i] = ((char *) block)[i]; - } - l += ENCRYPTION_BLOCK_LENGTH; - } - - return 1; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a cipher text using CBC mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -/// \param Expanded key to use -/// \param Initialization vector to use -/// \return 1 if successful, 0 otherwise */ -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CBC) -static unsigned int cbc_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length, - const unsigned char expandedKey[ROUNDS+1][BC][4], - unsigned char IV[BC][4]) -{ - unsigned char block[BC][4]; - unsigned int i; - unsigned int l; - - // Check input parameters - if ((cipherText == NULL) || (plainText == NULL)) { - TRACE_DEBUG("AES/REF: NULL parameter(s).\n\r"); - return 0; - } - if (length%ENCRYPTION_BLOCK_LENGTH != 0) { - TRACE_DEBUG("AES/REF: Cipher text length must be a multiple of the cipher block length.\n\r"); - return 0; - } - // Decrypt data - for (l=0; l < length;) { - // Copy and decrypt a block of cipher text - for (i=0; i < BC; i++) { - ((int *) block)[i] = ((int *) &cipherText[l])[i]; - } - decrypt(block, expandedKey, T0, T1, T2, T3, TF); - // Xor decrypted text & IV, copy new IV - for (i=0; i < BC; i++) { - unsigned int tmp = ((int *) block)[i] ^ ((int *) IV)[i]; - ((int *) IV)[i] = ((int *) &cipherText[l])[i]; - ((int *) &plainText[l])[i] = tmp; - } - - // Loop progression - l += ENCRYPTION_BLOCK_LENGTH; - } - return 1; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a cipher text using CTR mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text -/// \param Expanded key to use -/// \param Initialization vector to use -/// \return 1 if successful, 0 otherwise -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -static unsigned int ctr_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length, - const unsigned char expandedKey[ROUNDS+1][BC][4], - unsigned char IV[BC][4]) -{ - unsigned char block[BC][4]; - unsigned int bytes; - unsigned int i; - unsigned int l; - int k; - - // Check input parameters - if ((cipherText == NULL) || (plainText == NULL)) { - return 0; - } - for (l=0; l < length;) { - // Copy counter and encrypt it - copyBlock(IV, block); - encrypt(block, expandedKey, T0, T1, T2, T3, TF); - - // XOR current plain text block with encrypted counter - bytes = min(length - l, ENCRYPTION_BLOCK_LENGTH); - - for (i=0; i < bytes; i++) { - plainText[l+i] = cipherText[l+i] ^ ((char *) block)[i]; - } - // Increment counter (big-endian) and number of encrypted bytes - for (k=ENCRYPTION_BLOCK_LENGTH-1; k >= 0; k--) { - if (++((char *) IV)[k] != 0) { - break; - } - } - l += bytes; - } - return 1; -} -#endif - -//------------------------------------------------------------------------------ -// Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the AES algorithm -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -void aes_ref_init(void) -{ - TRACE_DEBUG("AES/REF: Initializing ...\n\r"); - - ASCII2RawHex((unsigned char*)ENCRYPTION_KEY, (unsigned char*)key, ENCRYPTION_KEY_LENGTH); - -#if defined(ENCRYPTION_ECB) || defined(ENCRYPTION_CBC) - - // Initialize key schedule - invKeySchedule(key, expandedKey); - - // Generate lookup tables - generateDecryptionLUTs(T0, T1, T2, T3, TF, Si); - -#elif defined(ENCRYPTION_CTR) - - // Initialize key schedule - keySchedule(key, expandedKey); - - // Generate lookup tables - generateEncryptionLUTs(T0, T1, T2, T3, TF, S); -#endif - -#if defined(ENCRYPTION_CBC) || defined(ENCRYPTION_CTR) - // Initialize counter - ASCII2RawHex((unsigned char*)ENCRYPTION_IV, (unsigned char*)IV, ENCRYPTION_BLOCK_LENGTH); -#endif - - TRACE_DEBUG("AES/REF: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES algorithm mode CBC -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -#if defined(ENCRYPTION_CBC) -void aes_ref_init_CBC(void) -{ - TRACE_DEBUG("aes_ref_init_CBC\n\r"); - - ASCII2RawHex((unsigned char*)ENCRYPTION_KEY, (unsigned char*)key, ENCRYPTION_KEY_LENGTH); - - // Initialize key schedule - invKeySchedule(key, expandedKey); - - // Generate lookup tables - generateDecryptionLUTs(T0, T1, T2, T3, TF, Si); - - // Initialize counter - ASCII2RawHex((unsigned char*)ENCRYPTION_IV, (unsigned char*)IV, ENCRYPTION_BLOCK_LENGTH); - - TRACE_DEBUG("AES/REF: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES algorithm mode ECB -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -void aes_ref_init_ECB(void) -{ - TRACE_DEBUG("aes_ref_init_ECB\n\r"); - - ASCII2RawHex((unsigned char*)ENCRYPTION_KEY, (unsigned char*)key, ENCRYPTION_KEY_LENGTH); - - // Initialize key schedule - invKeySchedule(key, expandedKey); - - // Generate lookup tables - generateDecryptionLUTs(T0, T1, T2, T3, TF, Si); - - TRACE_DEBUG("AES/REF: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the AES algorithm mode CTR -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -void aes_ref_init_CTR(void) -{ - TRACE_DEBUG("aes_ref_init_CTR\n\r"); - - ASCII2RawHex((unsigned char*)ENCRYPTION_KEY, (unsigned char*)key, ENCRYPTION_KEY_LENGTH); - - // Initialize key schedule - keySchedule(key, expandedKey); - - // Generate lookup tables - generateEncryptionLUTs(T0, T1, T2, T3, TF, S); - - // Initialize counter - ASCII2RawHex((unsigned char*)ENCRYPTION_IV, (unsigned char*)IV, ENCRYPTION_BLOCK_LENGTH); - - TRACE_DEBUG("AES/REF: Initialization done.\n\r"); -} -#endif -#endif // ONLY_ONE_ENCRYPTION - -//------------------------------------------------------------------------------ -/// Cleanup the AES algorithm -//------------------------------------------------------------------------------ -void aes_ref_cleanup(void) -{ - TRACE_DEBUG("AES/REF: Cleaning up ...\n\r"); - TRACE_DEBUG("AES/REF: Cleanup done.\n\r"); -} - -//------------------------------------------------------------------------------ -/// Decrypt a cipher text of variable length -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -/// \return 1 if decryption was successful, 0 otherwise. -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -int aes_ref_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - TRACE_DEBUG("aes_ref_decrypt\n\r"); -#if defined(ENCRYPTION_ECB) - return ecb_decrypt(cipherText, plainText, length, expandedKey); -#elif defined(ENCRYPTION_CBC) - return cbc_decrypt(cipherText, plainText, length, expandedKey, IV);; -#elif defined(ENCRYPTION_CTR) - return ctr_decrypt(cipherText, plainText, length, expandedKey, IV); -#endif -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypt a cipher text of variable length, mode CBC -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -/// \return 1 if decryption was successful, 0 otherwise. -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -#if defined(ENCRYPTION_CBC) -int aes_ref_decrypt_CBC(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - TRACE_DEBUG("aes_ref_decrypt_CBC\n\r"); - return cbc_decrypt(cipherText, plainText, length, expandedKey, IV);; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypt a cipher text of variable length, mode ECB -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -/// \return 1 if decryption was successful, 0 otherwise. -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -int aes_ref_decrypt_ECB(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - TRACE_DEBUG("aes_ref_decrypt_ECB\n\r"); - return ecb_decrypt(cipherText, plainText, length, expandedKey); -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypt a cipher text of variable length, mode CTR -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -/// \return 1 if decryption was successful, 0 otherwise. -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -int aes_ref_decrypt_CTR(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - TRACE_DEBUG("aes_ref_decrypt_CTR\n\r"); - return ctr_decrypt(cipherText, plainText, length, expandedKey, IV); -} -#endif - -#endif // ONLY_ONE_ENCRYPTION - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_REF) - - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.h b/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.h deleted file mode 100644 index 8de7b751b..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/aes_reference.h +++ /dev/null @@ -1,132 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Firmware encryption using AES reference implementation -/// -/// !Usage -/// -/// -# aes_ref_init: Initialize AES hardware -/// -# aes_ref_init_CBC: for the CBC mode -/// -# aes_ref_init_ECB: for the CTR mode -/// -# aes_ref_init_CTR: for the ECB mode -/// -# aes_ref_cleanup: Cleans up AES -/// -# aes_ref_decrypt: Decrypts a variable-length cipher text -/// -# aes_ref_decrypt_CBC: for CBC mode -/// -# aes_ref_decrypt_ECB: for ECB mode -/// -# aes_ref_decrypt_CTR: for CTR mode -//------------------------------------------------------------------------------ - -#ifndef BOOTLOADER_AES_REFERENCE_H -#define BOOTLOADER_AES_REFERENCE_H - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ -#include "config.h" - - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_REF) - -//------------------------------------------------------------------------------ -// Check configuration -//------------------------------------------------------------------------------ - -// Supported modes -#if !defined(ENCRYPTION_ECB) && \ - !defined(ENCRYPTION_CBC) && \ - !defined(ENCRYPTION_CTR) - #error No other mode than ECB, CBC & CTR are supported. -#endif - -// Supported key length -#if (ENCRYPTION_KEY_LENGTH != 16) && \ - (ENCRYPTION_KEY_LENGTH != 24) && \ - (ENCRYPTION_KEY_LENGTH != 32) - #error Only key lengths of 128, 192 or 256 bits are supported. -#endif - -// Supported block length -#if (ENCRYPTION_BLOCK_LENGTH != 16) - #error Only block length of 128 bits is supported. -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#define BC (ENCRYPTION_BLOCK_LENGTH / 4) -#define SC ((BC - 4) >> 1) -#define KC (ENCRYPTION_KEY_LENGTH / 4) -#define t0f 0x000000FF & tf -#define t1f 0x0000FF00 & tf -#define t2f 0x00FF0000 & tf -#define t3f 0xFF000000 & tf - -#if (KC >= BC) - #define ROUNDS (KC + 6) -#else - #define ROUNDS (BC + 6) -#endif - -#ifdef ONLY_ONE_ENCRYPTION -#define ENCRYPTION_INIT aes_ref_init -#define ENCRYPTION_CLEANUP aes_ref_cleanup -#define ENCRYPTION_DECRYPT aes_ref_decrypt -#endif - -//------------------------------------------------------------------------------ -// Prototypes -//------------------------------------------------------------------------------ -extern void aes_ref_init(void); -extern void aes_ref_init_CBC(void); -extern void aes_ref_init_ECB(void); -extern void aes_ref_init_CTR(void); -extern void aes_ref_cleanup(void); -extern int aes_ref_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int aes_ref_decrypt_CBC(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int aes_ref_decrypt_ECB(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int aes_ref_decrypt_CTR(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_AES_REF) - -#endif // BOOTLOADER_AES_REFERENCE_H - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/encryption.h b/src/ersky9x/libraries/drivers/utility/encryption/encryption.h deleted file mode 100644 index d21a43ab1..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/encryption.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Firmware encryption -/// -/// !Usage -/// -/// This file must include the header of every encryption module implemented for -/// the bootloader. It is also responsible for defining mock functions if no -/// encryption module is selected, as well as checking that parameters are -/// correctly set. -// -/// An encryption module must define the following functions: -/// -# void encryption_init(void); -/// -# void encryption_cleanup(void); -/// -# int encryption_decrypt(const unsigned char *, unsigned char *, unsigned int) -//------------------------------------------------------------------------------ - -#ifndef BOOTLOADER_ENCRYPTION_H -#define BOOTLOADER_ENCRYPTION_H - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ -#include "config.h" - - -//------------------------------------------------------------------------------ -// Check configuration -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -#if !defined(ENCRYPTION_INIT) && !defined(USE_ENCRYPTION) - #define ENCRYPTION_INIT(); - #define ENCRYPTION_CLEANUP(); - #define ENCRYPTION_DECRYPT(...) 1 - -#elif !defined(ENCRYPTION_INIT) && defined(USE_ENCRYPTION) - #error USE_ENCRYPTION defined but no encryption method selected. - -#elif !defined(ENCRYPTION_AES_LTC) && \ - !defined(ENCRYPTION_AES_REF) && \ - !defined(ENCRYPTION_AES_HARD) && \ - !defined(ENCRYPTION_3DES_LTC) && \ - !defined(ENCRYPTION_3DES_HARD) - #error No algorithm selected. - -#elif !defined(ENCRYPTION_ECB) && \ - !defined(ENCRYPTION_CBC) && \ - !defined(ENCRYPTION_CTR) - #error No encryption mode selected. - -#elif !defined(ENCRYPTION_KEY) - #error No key defined. - -#elif !defined(ENCRYPTION_KEY_LENGTH) - #error No key length selected. - -#elif !defined(ENCRYPTION_IV) - #error No initialization vector defined. - -#elif !defined(ENCRYPTION_BLOCK_LENGTH) - #error No block length selected. - -#endif -#endif // ONLY_ONE_ENCRYPTION -#endif // BOOTLOADER_ENCRYPTION_H - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.c b/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.c deleted file mode 100644 index da9ac06a8..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.c +++ /dev/null @@ -1,445 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Function: Firmware encryption using libTomCrypt -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#include "libtomcrypt.h" -#include -#include -#include "config.h" - -#if defined(USE_ENCRYPTION) && (defined(ENCRYPTION_AES_LTC) || defined(ENCRYPTION_3DES_LTC)) -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Global variables -//------------------------------------------------------------------------------ - -#if defined(ENCRYPTION_ECB) - symmetric_ECB sECB; -#endif -#if defined(ENCRYPTION_CBC) - symmetric_CBC sCBC; -#endif -#if defined(ENCRYPTION_CTR) - symmetric_CTR sCTR; -#endif - -//------------------------------------------------------------------------------ -// Inline functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Converts an ASCII string to an hexadecimal value -/// \param ASCII string to convert -/// \param Buffer to store converted value -/// \param Length of buffer -//------------------------------------------------------------------------------ -static inline void ASCII2Hex(const char * ascii, unsigned char * binary, unsigned int length) -{ - unsigned int i; - - for (i=0; i < length; i++) { - if (ascii[i*2] >= 'A') { - binary[i] = ascii[i*2] - 'A' + 10; - } - else { - binary[i] = ascii[i*2] - '0'; - } - binary[i] <<= 4; - if (ascii[i*2+1] >= 'A') { - binary[i] += ascii[i*2+1] - 'A' + 10; - } - else { - binary[i] += ascii[i*2+1] - '0'; - } - } -} - -//------------------------------------------------------------------------------ -// Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the decryption process -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -void ltc_init(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - -#if defined(ENCRYPTION_CTR) || defined(ENCRYPTION_CBC) - unsigned char IV[ENCRYPTION_BLOCK_LENGTH]; -#endif - - TRACE_DEBUG("LTC: Initializing ...\n\r"); - - // Register cipher - register_cipher(&CIPHER_DESC); - cipherID = find_cipher(CIPHER_NAME); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - -#if defined(ENCRYPTION_CTR) || defined(ENCRYPTION_CBC) - // Load IV - ASCII2Hex(ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); -#endif - - // Start decryption mode -#if defined(ENCRYPTION_ECB) - ecb_start(cipherID, key, ENCRYPTION_KEY_LENGTH, 0, &sECB); -#elif defined(ENCRYPTION_CBC) - cbc_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, &sCBC); -#elif defined(ENCRYPTION_CTR) - ctr_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, CTR_COUNTER_BIG_ENDIAN, &sCTR); -#endif - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif // ONLY_ONE_ENCRYPTION - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for AES, mode CBC -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -#if defined(ENCRYPTION_CBC) -void ltc_init_AES_CBC(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - unsigned char IV[ENCRYPTION_BLOCK_LENGTH]; - - TRACE_DEBUG("LTC: Initializing CBC...\n\r"); - - // Register cipher - register_cipher(&rijndael_desc); - cipherID = find_cipher("rijndael"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Load IV - ASCII2Hex(ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - // Start decryption mode - cbc_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, &sCBC); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for AES, mode CTR -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -void ltc_init_AES_CTR(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - unsigned char IV[ENCRYPTION_BLOCK_LENGTH]; - - TRACE_DEBUG("LTC: Initializing CTR...\n\r"); - - // Register cipher - register_cipher(&rijndael_desc); - cipherID = find_cipher("rijndael"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Load IV - ASCII2Hex(ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - // Start decryption mode - ctr_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, CTR_COUNTER_BIG_ENDIAN, &sCTR); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for AES, mode ECB -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -void ltc_init_AES_ECB(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("LTC: Initializing ECB...\n\r"); - - // Register cipher - register_cipher(&rijndael_desc); - cipherID = find_cipher("rijndael"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Start decryption mode - ecb_start(cipherID, key, ENCRYPTION_KEY_LENGTH, 0, &sECB); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for 3DES, mode CBC -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CBC) -void ltc_init_3DES_CBC(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - unsigned char IV[ENCRYPTION_BLOCK_LENGTH]; - - TRACE_DEBUG("LTC: Initializing CBC...\n\r"); - - // Register cipher - register_cipher(&des3_desc); - cipherID = find_cipher("3des"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Load IV - ASCII2Hex(ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - // Start decryption mode - cbc_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, &sCBC); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for 3DES, mode CTR -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -void ltc_init_3DES_CTR(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - unsigned char IV[ENCRYPTION_BLOCK_LENGTH]; - - TRACE_DEBUG("LTC: Initializing CTR...\n\r"); - - // Register cipher - register_cipher(&des3_desc); - cipherID = find_cipher("3des"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Load IV - ASCII2Hex(ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - // Start decryption mode - ctr_start(cipherID, IV, key, ENCRYPTION_KEY_LENGTH, 0, CTR_COUNTER_BIG_ENDIAN, &sCTR); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the decryption process for 3DES, mode ECB -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -void ltc_init_3DES_ECB(void) -{ - int cipherID; - unsigned char key[ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("LTC: Initializing ECB...\n\r"); - - // Register cipher - register_cipher(&des3_desc); - cipherID = find_cipher("3des"); - - // Load key - ASCII2Hex(ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - // Start decryption mode - ecb_start(cipherID, key, ENCRYPTION_KEY_LENGTH, 0, &sECB); - - TRACE_DEBUG("LTC: Initialization done.\n\r"); -} -#endif -#endif // ONLY_ONE_ENCRYPTION - - -//------------------------------------------------------------------------------ -/// Terminates the decryption process -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -void ltc_cleanup(void) -{ - TRACE_DEBUG("LTC: Cleaning up ...\n\r"); - -#if defined(ENCRYPTION_ECB) - ecb_done(&sECB); -#elif defined(ENCRYPTION_CBC) - cbc_done(&sCBC); -#elif defined(ENCRYPTION_CTR) - ctr_done(&sCTR); -#endif - - TRACE_DEBUG("LTC: Cleanup done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Terminates the decryption process for mode CBC -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -#if defined(ENCRYPTION_CBC) -void ltc_cleanup_CBC(void) -{ - TRACE_DEBUG("LTC: Cleaning up CBC...\n\r"); - cbc_done(&sCBC); - TRACE_DEBUG("LTC: Cleanup done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Terminates the decryption process for mode CTR -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_CTR) -void ltc_cleanup_CTR(void) -{ - TRACE_DEBUG("LTC: Cleaning up CTR...\n\r"); - ctr_done(&sCTR); - TRACE_DEBUG("LTC: Cleanup done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Terminates the decryption process for mode ECB -//------------------------------------------------------------------------------ -#if defined(ENCRYPTION_ECB) -void ltc_cleanup_ECB(void) -{ - TRACE_DEBUG("LTC: Cleaning up ECB...\n\r"); - ecb_done(&sECB); - TRACE_DEBUG("LTC: Cleanup done.\n\r"); -} -#endif -#endif // ONLY_ONE_ENCRYPTION - -//------------------------------------------------------------------------------ -/// Decrypts a block of data -/// \param Data to decrypt -/// \param Buffer to store decrypted data -/// \param Length of data -/// \return 1 if successful, 0 otherwise. -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -int ltc_decrypt(const unsigned char * cipherText, unsigned char * plainText, unsigned int length) -{ -#if defined(ENCRYPTION_ECB) - if (ecb_decrypt(cipherText, plainText, length, &sECB) != CRYPT_OK) { -#elif defined(ENCRYPTION_CBC) - if (cbc_decrypt(cipherText, plainText, length, &sCBC) != CRYPT_OK) { -#elif defined(ENCRYPTION_CTR) - if (ctr_decrypt(cipherText, plainText, length, &sCTR) != CRYPT_OK) { -#endif - return 0; - } - else { - return 1; - } -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a block of data in CBC mode -/// \param Data to decrypt -/// \param Buffer to store decrypted data -/// \param Length of data -/// \return 1 if successful, 0 otherwise. -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -int ltc_decrypt_CBC(const unsigned char * cipherText, unsigned char * plainText, unsigned int length) -{ - if (cbc_decrypt(cipherText, plainText, length, &sCBC) != CRYPT_OK) { - return 0; - } - else { - return 1; - } -} - -//------------------------------------------------------------------------------ -/// Decrypts a block of data in CTR mode -/// \param Data to decrypt -/// \param Buffer to store decrypted data -/// \param Length of data -/// \return 1 if successful, 0 otherwise. -//------------------------------------------------------------------------------ -int ltc_decrypt_CTR(const unsigned char * cipherText, unsigned char * plainText, unsigned int length) -{ - if (ctr_decrypt(cipherText, plainText, length, &sCTR) != CRYPT_OK) { - return 0; - } - else { - return 1; - } -} - -//------------------------------------------------------------------------------ -/// Decrypts a block of data in ECB mode -/// \param Data to decrypt -/// \param Buffer to store decrypted data -/// \param Length of data -/// \return 1 if successful, 0 otherwise. -//------------------------------------------------------------------------------ -int ltc_decrypt_ECB(const unsigned char * cipherText, unsigned char * plainText, unsigned int length) -{ - if (ecb_decrypt(cipherText, plainText, length, &sECB) != CRYPT_OK) { - return 0; - } - else { - return 1; - } -} -#endif // ONLY_ONE_ENCRYPTION - -#endif // defined(USE_ENCRYPTION) && (defined(ENCRYPTION_AES_LTC) || defined(ENCRYPTION_3DES_LTC)) - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.h b/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.h deleted file mode 100644 index 4052075b7..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/libtomcrypt.h +++ /dev/null @@ -1,149 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Firmware encryption using libTomCrypt -/// -/// !Usage -/// -/// -# ltc_init: Initialize LibTomCrypt -/// -# ltc_init_AES_CBC -/// -# ltc_init_AES_CTR -/// -# ltc_init_AES_ECB -/// -# ltc_init_3DES_CBC -/// -# ltc_init_3DES_CTR -/// -# ltc_init_3DES_ECB -/// -# ltc_cleanup -/// -# ltc_cleanup_CBC -/// -# ltc_cleanup_CTR -/// -# ltc_cleanup_ECB -/// -# ltc_decrypt -/// -# ltc_decrypt_CBC -/// -# ltc_decrypt_CTR -/// -# ltc_decrypt_ECB -//------------------------------------------------------------------------------ - -#ifndef BOOTLOADER_LIBTOMCRYPT_H -#define BOOTLOADER_LIBTOMCRYPT_H - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#include "config.h" - -#if defined(USE_ENCRYPTION) && (defined(ENCRYPTION_AES_LTC) || defined(ENCRYPTION_3DES_LTC)) - -//------------------------------------------------------------------------------ -// Check configuration -//------------------------------------------------------------------------------ - -// Supported modes -#if !defined(ENCRYPTION_CTR) && \ - !defined(ENCRYPTION_CBC) && \ - !defined(ENCRYPTION_ECB) - #error No other mode than ECB, CBC & CTR are supported. -#endif - -// Supported key length -#if defined(ENCRYPTION_AES_LTC) - #if (ENCRYPTION_KEY_LENGTH != 16) && \ - (ENCRYPTION_KEY_LENGTH != 24) && \ - (ENCRYPTION_KEY_LENGTH != 32) - #error Only a key length of 128, 192 or 256 bits are supported with AES. - #endif -#elif defined(ENCRYPTION_3DES_LTC) - #if (ENCRYPTION_KEY_LENGTH != 16) && \ - (ENCRYPTION_KEY_LENGTH != 24) - #error Only a key length of 128 or 192 bits are supported with Triple-DES. - #endif -#endif - -// Supported block length -#if defined(ENCRYPTION_AES_LTC) - #if (ENCRYPTION_BLOCK_LENGTH != 16) - #error Only a block length of 128 bits is supported with AES. - #endif -#elif defined(ENCRYPTION_3DES_LTC) - #if (ENCRYPTION_BLOCK_LENGTH != 8) - #error Only a block length of 64 bits is supported with Triple-DES. - #endif -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -// Functions -#ifdef ONLY_ONE_ENCRYPTION -#define ENCRYPTION_INIT ltc_init -#define ENCRYPTION_CLEANUP ltc_cleanup -#define ENCRYPTION_DECRYPT ltc_decrypt - -#if defined(ENCRYPTION_AES_LTC) - #define CIPHER_NAME "rijndael" - #define CIPHER_DESC rijndael_desc -#elif defined(ENCRYPTION_3DES_LTC) - #define CIPHER_NAME "3des" - #define CIPHER_DESC des3_desc -#endif -#endif - -//------------------------------------------------------------------------------ -// Prototypes -//------------------------------------------------------------------------------ - -#ifdef ONLY_ONE_ENCRYPTION -extern void ltc_init(void); -#endif -extern void ltc_init_AES_CBC(void); -extern void ltc_init_AES_CTR(void); -extern void ltc_init_AES_ECB(void); -extern void ltc_init_3DES_CBC(void); -extern void ltc_init_3DES_CTR(void); -extern void ltc_init_3DES_ECB(void); - -extern void ltc_cleanup(void); -extern void ltc_cleanup_CBC(void); -extern void ltc_cleanup_CTR(void); -extern void ltc_cleanup_ECB(void); - -extern int ltc_decrypt(const unsigned char * cipherText, unsigned char * plainText, unsigned int length); -extern int ltc_decrypt_CBC(const unsigned char * cipherText, unsigned char * plainText, unsigned int length); -extern int ltc_decrypt_CTR(const unsigned char * cipherText, unsigned char * plainText, unsigned int length); -extern int ltc_decrypt_ECB(const unsigned char * cipherText, unsigned char * plainText, unsigned int length); - -#endif // defined(USE_ENCRYPTION) && (defined(ENCRYPTION_AES_LTC) || defined(ENCRYPTION_3DES_LTC)) -#endif // BOOTLOADER_AES_LIBTOMCRYPT_H - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.c b/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.c deleted file mode 100644 index 33703759a..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.c +++ /dev/null @@ -1,520 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Function: Firmware encryption using TDES hardware acceleration -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#include "tdes_hardware.h" - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_3DES_HARD) -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Global variables -//------------------------------------------------------------------------------ - -#ifdef ENCRYPTION_CTR - unsigned char CTR[ENCRYPTION_BLOCK_LENGTH]; -#endif - -//------------------------------------------------------------------------------ -// Inline functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Converts an ASCII value to an hexadecimal one -/// \param ASCII string -/// \param Buffer to store integer value -/// \param Length of string -//------------------------------------------------------------------------------ -static inline void ASCII2Hex(const unsigned char * ascii, unsigned char * binary, unsigned int length) -{ - unsigned int i; - - for (i=0; i < length; i++) { - if (ascii[i*2] >= 'A') { - binary[i] = ascii[i*2] - 'A' + 10; - } - else { - binary[i] = ascii[i*2] - '0'; - } - binary[i] <<= 4; - if (ascii[i*2+1] >= 'A') { - binary[i] += ascii[i*2+1] - 'A' + 10; - } - else { - binary[i] += ascii[i*2+1] - '0'; - } - } -} -//------------------------------------------------------------------------------ -// Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the TDES peripheral -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -void tdes_hard_init(void) -{ - unsigned char key[ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("TDES/HARD: Initializing ...\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES/TDES undefined -#endif - - // Load mode -#if (ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | TDES_MODE - | AT91C_TDES_TDESMOD | TDES_CIPHER; -#else - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | TDES_MODE | AT91C_TDES_KEYMOD - | AT91C_TDES_TDESMOD | TDES_CIPHER; -#endif - - // Convert and load key - ASCII2Hex((unsigned char*)ENCRYPTION_KEY, key, ENCRYPTION_KEY_LENGTH); - - AT91C_BASE_TDES->TDES_KEY1WxR[0] = ((int *) key)[0]; - AT91C_BASE_TDES->TDES_KEY1WxR[1] = ((int *) key)[1]; - AT91C_BASE_TDES->TDES_KEY2WxR[0] = ((int *) key)[2]; - AT91C_BASE_TDES->TDES_KEY2WxR[1] = ((int *) key)[3]; - -#if (ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_KEY3WxR[0] = ((int *) key)[4]; - AT91C_BASE_TDES->TDES_KEY3WxR[1] = ((int *) key)[5]; -#endif - -#if defined(ENCRYPTION_CBC) - unsigned char IV[8]; - ASCII2Hex((unsigned char*)ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - AT91C_BASE_TDES->TDES_IVxR[0] = ((int *) IV)[0]; - AT91C_BASE_TDES->TDES_IVxR[1] = ((int *) IV)[1]; - -#elif defined(ENCRYPTION_CTR) - // Convert IV - ASCII2Hex((unsigned char*)ENCRYPTION_IV, CTR, ENCRYPTION_BLOCK_LENGTH); -#endif - - TRACE_DEBUG("TDES/HARD: Initialization done.\n\r"); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the DES peripheral for CBC mode -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -void tdes_hard_init_CBC(void) -{ - unsigned char key[TDES_ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("tdes_hard_init_CBC\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_CBC - | AT91C_TDES_TDESMOD | 0; -#else - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_CBC | AT91C_TDES_KEYMOD - | AT91C_TDES_TDESMOD | 0; -#endif - - // Convert and load key - ASCII2Hex((unsigned char*)TDES_ENCRYPTION_KEY, key, TDES_ENCRYPTION_KEY_LENGTH); - - AT91C_BASE_TDES->TDES_KEY1WxR[0] = ((int *) key)[0]; - AT91C_BASE_TDES->TDES_KEY1WxR[1] = ((int *) key)[1]; - AT91C_BASE_TDES->TDES_KEY2WxR[0] = ((int *) key)[2]; - AT91C_BASE_TDES->TDES_KEY2WxR[1] = ((int *) key)[3]; - -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_KEY3WxR[0] = ((int *) key)[4]; - AT91C_BASE_TDES->TDES_KEY3WxR[1] = ((int *) key)[5]; -#endif - - unsigned char IV[8]; - ASCII2Hex((unsigned char*)ENCRYPTION_IV, IV, ENCRYPTION_BLOCK_LENGTH); - - AT91C_BASE_TDES->TDES_IVxR[0] = ((int *) IV)[0]; - AT91C_BASE_TDES->TDES_IVxR[1] = ((int *) IV)[1]; -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the DES peripheral for CTR mode -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -void tdes_hard_init_CTR(void) -{ - unsigned char key[TDES_ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("tdes_hard_init_CTR\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_ECB - | AT91C_TDES_TDESMOD | AT91C_TDES_CIPHER; -#else - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_ECB | AT91C_TDES_KEYMOD - | AT91C_TDES_TDESMOD | AT91C_TDES_CIPHER; -#endif - - // Convert and load key - ASCII2Hex((unsigned char*)TDES_ENCRYPTION_KEY, key, TDES_ENCRYPTION_KEY_LENGTH); - - AT91C_BASE_TDES->TDES_KEY1WxR[0] = ((int *) key)[0]; - AT91C_BASE_TDES->TDES_KEY1WxR[1] = ((int *) key)[1]; - AT91C_BASE_TDES->TDES_KEY2WxR[0] = ((int *) key)[2]; - AT91C_BASE_TDES->TDES_KEY2WxR[1] = ((int *) key)[3]; - -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_KEY3WxR[0] = ((int *) key)[4]; - AT91C_BASE_TDES->TDES_KEY3WxR[1] = ((int *) key)[5]; -#endif - - // Convert IV - ASCII2Hex((unsigned char*)ENCRYPTION_IV, CTR, ENCRYPTION_BLOCK_LENGTH); -} -#endif - -//------------------------------------------------------------------------------ -/// Initializes the DES peripheral for ECB mode -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -void tdes_hard_init_ECB(void) -{ - unsigned char key[TDES_ENCRYPTION_KEY_LENGTH]; - - TRACE_DEBUG("tdes_hard_init_ECB\n\r"); - - // Activate peripheral clock -#ifdef AT91C_ID_AES - PMC_EnablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_EnablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_EnablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - - // Load mode -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_ECB - | AT91C_TDES_TDESMOD | 0; -#else - AT91C_BASE_TDES->TDES_MR = AT91C_TDES_SMOD_MANUAL | AT91C_TDES_OPMOD_ECB | AT91C_TDES_KEYMOD - | AT91C_TDES_TDESMOD | 0; -#endif - - // Convert and load key - ASCII2Hex((unsigned char*)TDES_ENCRYPTION_KEY, key, TDES_ENCRYPTION_KEY_LENGTH); - - AT91C_BASE_TDES->TDES_KEY1WxR[0] = ((int *) key)[0]; - AT91C_BASE_TDES->TDES_KEY1WxR[1] = ((int *) key)[1]; - AT91C_BASE_TDES->TDES_KEY2WxR[0] = ((int *) key)[2]; - AT91C_BASE_TDES->TDES_KEY2WxR[1] = ((int *) key)[3]; - -#if (TDES_ENCRYPTION_KEY_LENGTH == 24) - AT91C_BASE_TDES->TDES_KEY3WxR[0] = ((int *) key)[4]; - AT91C_BASE_TDES->TDES_KEY3WxR[1] = ((int *) key)[5]; -#endif -} -#endif - -//------------------------------------------------------------------------------ -/// Cleans up the DES peripheral -//------------------------------------------------------------------------------ -void tdes_hard_cleanup(void) -{ - TRACE_DEBUG("TDES/HARD: Cleaning up ...\n\r"); - AT91C_BASE_TDES->TDES_MR = 0; -#ifdef AT91C_ID_AES - PMC_DisablePeripheral( AT91C_ID_AES ); -#elif AT91C_ID_AESTDES - PMC_DisablePeripheral( AT91C_ID_AESTDES ); -#elif AT91C_ID_TDES - PMC_DisablePeripheral( AT91C_ID_TDES ); -#else -#error AES undefined -#endif - TRACE_DEBUG("TDES/HARD: Cleanup done.\n\r"); -} - -//------------------------------------------------------------------------------ -/// Decrypts a variable-length cipher text -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -int tdes_hard_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - unsigned int l; - - TRACE_DEBUG("tdes_hard_decrypt\n\r"); - -#if defined(ENCRYPTION_ECB) || defined(ENCRYPTION_CBC) - for (l=0; l < length;) { - - // Load counter and encrypt it - AT91C_BASE_TDES->TDES_IDATAxR[0] = ((int *) &cipherText[l])[0]; - AT91C_BASE_TDES->TDES_IDATAxR[1] = ((int *) &cipherText[l])[1]; - - // Start processing - AT91C_BASE_TDES->TDES_CR = AT91C_TDES_START; - - while (!((AT91C_BASE_TDES->TDES_ISR) & AT91C_TDES_DATRDY)); - - ((int *) &plainText[l])[0] = AT91C_BASE_TDES->TDES_ODATAxR[0]; - ((int *) &plainText[l])[1] = AT91C_BASE_TDES->TDES_ODATAxR[1]; - - l += ENCRYPTION_BLOCK_LENGTH; - } - -#elif defined(ENCRYPTION_CTR) - unsigned int bytes; - unsigned char block[ENCRYPTION_BLOCK_LENGTH]; - unsigned int e; - unsigned int i; - int k; - - // Decrypt - for (e=0; e < length;) { - - // Load counter and encrypt it - AT91C_BASE_TDES->TDES_IDATAxR[0] = ((int *) CTR)[0]; - AT91C_BASE_TDES->TDES_IDATAxR[1] = ((int *) CTR)[1]; - - AT91C_BASE_TDES->TDES_CR = AT91C_TDES_START; - while (!(AT91C_BASE_TDES->TDES_ISR & AT91C_TDES_DATRDY)); - - ((int *) block)[0] = AT91C_BASE_TDES->TDES_ODATAxR[0]; - ((int *) block)[1] = AT91C_BASE_TDES->TDES_ODATAxR[1]; - - // XOR current plain text block with encrypted counter - if ((length-e) < ENCRYPTION_BLOCK_LENGTH) { - bytes = length - e; - } - else { - bytes = ENCRYPTION_BLOCK_LENGTH; - } - - for (i=0; i < bytes; i++) { - plainText[e+i] = cipherText[e+i] ^ ((char *) block)[i]; - } - - // Increment counter (big-endian) and number of encrypted bytes - for (k=ENCRYPTION_BLOCK_LENGTH-1; k >= 0; k--) { - if (++((char *) CTR)[k] != 0) { - break; - } - } - e += bytes; - } -#endif // ENCRYPTION_CTR - - return 1; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a variable-length cipher text for CBC mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -int tdes_hard_decrypt_CBC(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - unsigned int l; - - TRACE_DEBUG("tdes_hard_decrypt_CBC\n\r"); - - for (l=0; l < length;) { - // Load counter and encrypt it - AT91C_BASE_TDES->TDES_IDATAxR[0] = ((int *) &cipherText[l])[0]; - AT91C_BASE_TDES->TDES_IDATAxR[1] = ((int *) &cipherText[l])[1]; - - // Start processing - AT91C_BASE_TDES->TDES_CR = AT91C_TDES_START; - - while (!((AT91C_BASE_TDES->TDES_ISR) & AT91C_TDES_DATRDY)); - - ((int *) &plainText[l])[0] = AT91C_BASE_TDES->TDES_ODATAxR[0]; - ((int *) &plainText[l])[1] = AT91C_BASE_TDES->TDES_ODATAxR[1]; - - l += ENCRYPTION_BLOCK_LENGTH; - } - return 1; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a variable-length cipher text for CTR mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -int tdes_hard_decrypt_CTR(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - unsigned int bytes; - unsigned char block[ENCRYPTION_BLOCK_LENGTH]; - unsigned int e; - unsigned int i; - int k; - - TRACE_DEBUG("tdes_hard_decrypt_CTR\n\r"); - - // Decrypt - for (e=0; e < length;) { - - // Load counter and encrypt it - AT91C_BASE_TDES->TDES_IDATAxR[0] = ((int *) CTR)[0]; - AT91C_BASE_TDES->TDES_IDATAxR[1] = ((int *) CTR)[1]; - - AT91C_BASE_TDES->TDES_CR = AT91C_TDES_START; - while (!(AT91C_BASE_TDES->TDES_ISR & AT91C_TDES_DATRDY)); - - ((int *) block)[0] = AT91C_BASE_TDES->TDES_ODATAxR[0]; - ((int *) block)[1] = AT91C_BASE_TDES->TDES_ODATAxR[1]; - - // XOR current plain text block with encrypted counter - if ((length-e) < ENCRYPTION_BLOCK_LENGTH) { - bytes = length - e; - } - else { - bytes = ENCRYPTION_BLOCK_LENGTH; - } - - for (i=0; i < bytes; i++) { - plainText[e+i] = cipherText[e+i] ^ ((char *) block)[i]; - } - - // Increment counter (big-endian) and number of encrypted bytes - for (k=ENCRYPTION_BLOCK_LENGTH-1; k >= 0; k--) { - if (++((char *) CTR)[k] != 0) { - break; - } - } - e += bytes; - } - - return 1; -} -#endif - -//------------------------------------------------------------------------------ -/// Decrypts a variable-length cipher text for ECB mode -/// \param Cipher text to decrypt -/// \param Buffer to store plain text -/// \param Length of cipher text (in bytes) -//------------------------------------------------------------------------------ -#ifndef ONLY_ONE_ENCRYPTION -int tdes_hard_decrypt_ECB(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length) -{ - unsigned int l; - - TRACE_DEBUG("tdes_hard_decrypt_ECB\n\r"); - - for (l=0; l < length;) { - - // Load counter and encrypt it - AT91C_BASE_TDES->TDES_IDATAxR[0] = ((int *) &cipherText[l])[0]; - AT91C_BASE_TDES->TDES_IDATAxR[1] = ((int *) &cipherText[l])[1]; - - // Start processing - AT91C_BASE_TDES->TDES_CR = AT91C_TDES_START; - - while (!((AT91C_BASE_TDES->TDES_ISR) & AT91C_TDES_DATRDY)); - - ((int *) &plainText[l])[0] = AT91C_BASE_TDES->TDES_ODATAxR[0]; - ((int *) &plainText[l])[1] = AT91C_BASE_TDES->TDES_ODATAxR[1]; - - l += ENCRYPTION_BLOCK_LENGTH; - } - return 1; -} -#endif - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_3DES_HARD) - - - diff --git a/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.h b/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.h deleted file mode 100644 index 7d8631552..000000000 --- a/src/ersky9x/libraries/drivers/utility/encryption/tdes_hardware.h +++ /dev/null @@ -1,125 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Firmware encryption using TDES hardware acceleration -/// -/// !Usage -/// -/// -# tdes_hard_init: Initialize TDES hardware -/// -# tdes_hard_init_CBC: for the CBC mode -/// -# tdes_hard_init_ECB: for the CTR mode -/// -# tdes_hard_init_CTR: for the ECB mode -/// -# tdes_hard_cleanup: Cleans up DES -/// -# tdes_hard_decrypt: Decrypts a variable-length cipher text -/// -# tdes_hard_decrypt_CBC: for CBC mode -/// -# tdes_hard_decrypt_ECB: for ECB mode -/// -# tdes_hard_decrypt_CTR: for CTR mode -//------------------------------------------------------------------------------ -#ifndef BOOTLOADER_TDES_HARDWARE_H -#define BOOTLOADER_TDES_HARDWARE_H - -//------------------------------------------------------------------------------ -// Includes -//------------------------------------------------------------------------------ - -#include "config.h" - -#if defined(USE_ENCRYPTION) && defined(ENCRYPTION_3DES_HARD) - -//------------------------------------------------------------------------------ -// Check configuration -//------------------------------------------------------------------------------ - -#ifdef ONLY_ONE_ENCRYPTION -#if (ENCRYPTION_KEY_LENGTH != 16) && (ENCRYPTION_KEY_LENGTH != 24) - #error Triple-DES hardware acceleration only supports 128 and 192 bits keys. -#endif - -#if (ENCRYPTION_BLOCK_LENGTH != 8) - #error Triple-DES hardware acceleration only supports 64 bits blocks. -#endif - -#if !defined(ENCRYPTION_ECB) && \ - !defined(ENCRYPTION_CBC) && \ - !defined(ENCRYPTION_CTR) - #error Only ECB, CBC & CTR mode are supported. -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#define ENCRYPTION_INIT tdes_hard_init -#define ENCRYPTION_CLEANUP tdes_hard_cleanup -#define ENCRYPTION_DECRYPT tdes_hard_decrypt - -#if defined(ENCRYPTION_ECB) - #define TDES_MODE AT91C_TDES_OPMOD_ECB - #define TDES_CIPHER 0 -#elif defined(ENCRYPTION_CBC) - #define TDES_MODE AT91C_TDES_OPMOD_CBC - #define TDES_CIPHER 0 -#elif defined(ENCRYPTION_CTR) - #define TDES_MODE AT91C_TDES_OPMOD_ECB - #define TDES_CIPHER AT91C_TDES_CIPHER -#endif - -#endif // ONLY_ONE_ENCRYPTION - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -#ifdef ONLY_ONE_ENCRYPTION -extern void tdes_hard_init(void); -#endif -extern void tdes_hard_init_CBC(void); -extern void tdes_hard_init_CTR(void); -extern void tdes_hard_init_ECB(void); -extern void tdes_hard_cleanup(void); -extern int tdes_hard_decrypt(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int tdes_hard_decrypt_CBC(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int tdes_hard_decrypt_CTR(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); -extern int tdes_hard_decrypt_ECB(const unsigned char * cipherText, - unsigned char * plainText, - unsigned int length); - - -#endif // defined(USE_ENCRYPTION) && defined(ENCRYPTION_3DES_HARD) -#endif // BOOTLOADER_DES_HARDWARE_H - diff --git a/src/ersky9x/libraries/drivers/utility/hamming.c b/src/ersky9x/libraries/drivers/utility/hamming.c deleted file mode 100644 index b3c3220a0..000000000 --- a/src/ersky9x/libraries/drivers/utility/hamming.c +++ /dev/null @@ -1,335 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "hamming.h" -#include -#include - -//------------------------------------------------------------------------------ -// Internal function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Counts and return the number of bits set to '1' in the given byte. -/// \param byte Byte to count. -//------------------------------------------------------------------------------ -static unsigned char CountBitsInByte(unsigned char byte) -{ - unsigned char count = 0; - while (byte > 0) { - - if (byte & 1) { - - count++; - } - byte >>= 1; - } - - return count; -} - -//------------------------------------------------------------------------------ -/// Counts and return the number of bits set to '1' in the given hamming code. -/// \param code Hamming code. -//------------------------------------------------------------------------------ -static unsigned char CountBitsInCode256(unsigned char *code) -{ - return CountBitsInByte(code[0]) - + CountBitsInByte(code[1]) - + CountBitsInByte(code[2]); -} - -//------------------------------------------------------------------------------ -/// Calculates the 22-bit hamming code for a 256-bytes block of data. -/// \param data Data buffer to calculate code for. -/// \param code Pointer to a buffer where the code should be stored. -//------------------------------------------------------------------------------ -static void Compute256(const unsigned char *data, unsigned char *code) -{ - unsigned int i; - unsigned char columnSum = 0; - unsigned char evenLineCode = 0; - unsigned char oddLineCode = 0; - unsigned char evenColumnCode = 0; - unsigned char oddColumnCode = 0; - - // Xor all bytes together to get the column sum; - // At the same time, calculate the even and odd line codes - for (i=0; i < 256; i++) { - - columnSum ^= data[i]; - - // If the xor sum of the byte is 0, then this byte has no incidence on - // the computed code; so check if the sum is 1. - if ((CountBitsInByte(data[i]) & 1) == 1) { - - // Parity groups are formed by forcing a particular index bit to 0 - // (even) or 1 (odd). - // Example on one byte: - // - // bits (dec) 7 6 5 4 3 2 1 0 - // (bin) 111 110 101 100 011 010 001 000 - // '---'---'---'----------. - // | - // groups P4' ooooooooooooooo eeeeeeeeeeeeeee P4 | - // P2' ooooooo eeeeeee ooooooo eeeeeee P2 | - // P1' ooo eee ooo eee ooo eee ooo eee P1 | - // | - // We can see that: | - // - P4 -> bit 2 of index is 0 --------------------' - // - P4' -> bit 2 of index is 1. - // - P2 -> bit 1 of index if 0. - // - etc... - // We deduce that a bit position has an impact on all even Px if - // the log2(x)nth bit of its index is 0 - // ex: log2(4) = 2, bit2 of the index must be 0 (-> 0 1 2 3) - // and on all odd Px' if the log2(x)nth bit of its index is 1 - // ex: log2(2) = 1, bit1 of the index must be 1 (-> 0 1 4 5) - // - // As such, we calculate all the possible Px and Px' values at the - // same time in two variables, evenLineCode and oddLineCode, such as - // evenLineCode bits: P128 P64 P32 P16 P8 P4 P2 P1 - // oddLineCode bits: P128' P64' P32' P16' P8' P4' P2' P1' - // - evenLineCode ^= (255 - i); - oddLineCode ^= i; - } - } - - // At this point, we have the line parities, and the column sum. First, We - // must caculate the parity group values on the column sum. - for (i=0; i < 8; i++) { - - if (columnSum & 1) { - - evenColumnCode ^= (7 - i); - oddColumnCode ^= i; - } - columnSum >>= 1; - } - - // Now, we must interleave the parity values, to obtain the following layout: - // Code[0] = Line1 - // Code[1] = Line2 - // Code[2] = Column - // Line = Px' Px P(x-1)- P(x-1) ... - // Column = P4' P4 P2' P2 P1' P1 PadBit PadBit - code[0] = 0; - code[1] = 0; - code[2] = 0; - - for (i=0; i < 4; i++) { - - code[0] <<= 2; - code[1] <<= 2; - code[2] <<= 2; - - // Line 1 - if ((oddLineCode & 0x80) != 0) { - - code[0] |= 2; - } - if ((evenLineCode & 0x80) != 0) { - - code[0] |= 1; - } - - // Line 2 - if ((oddLineCode & 0x08) != 0) { - - code[1] |= 2; - } - if ((evenLineCode & 0x08) != 0) { - - code[1] |= 1; - } - - // Column - if ((oddColumnCode & 0x04) != 0) { - - code[2] |= 2; - } - if ((evenColumnCode & 0x04) != 0) { - - code[2] |= 1; - } - - oddLineCode <<= 1; - evenLineCode <<= 1; - oddColumnCode <<= 1; - evenColumnCode <<= 1; - } - - // Invert codes (linux compatibility) - code[0] = ~code[0]; - code[1] = ~code[1]; - code[2] = ~code[2]; - - TRACE_DEBUG("Computed code = %02X %02X %02X\n\r", - code[0], code[1], code[2]); -} - -//------------------------------------------------------------------------------ -/// Verifies and corrects a 256-bytes block of data using the given 22-bits -/// hamming code. -/// Returns 0 if there is no error, otherwise returns a HAMMING_ERROR code. -/// \param data Data buffer to check. -/// \param originalCode Hamming code to use for verifying the data. -//------------------------------------------------------------------------------ -static unsigned char Verify256( - unsigned char *data, - const unsigned char *originalCode) -{ - // Calculate new code - unsigned char computedCode[3]; - unsigned char correctionCode[3]; - Compute256(data, computedCode); - - // Xor both codes together - correctionCode[0] = computedCode[0] ^ originalCode[0]; - correctionCode[1] = computedCode[1] ^ originalCode[1]; - correctionCode[2] = computedCode[2] ^ originalCode[2]; - - TRACE_DEBUG("Correction code = %02X %02X %02X\n\r", - correctionCode[0], correctionCode[1], correctionCode[2]); - - // If all bytes are 0, there is no error - if ((correctionCode[0] == 0) - && (correctionCode[1] == 0) - && (correctionCode[2] == 0)) { - - return 0; - } - // If there is a single bit error, there are 11 bits set to 1 - if (CountBitsInCode256(correctionCode) == 11) { - - // Get byte and bit indexes - unsigned char byte = correctionCode[0] & 0x80; - byte |= (correctionCode[0] << 1) & 0x40; - byte |= (correctionCode[0] << 2) & 0x20; - byte |= (correctionCode[0] << 3) & 0x10; - - byte |= (correctionCode[1] >> 4) & 0x08; - byte |= (correctionCode[1] >> 3) & 0x04; - byte |= (correctionCode[1] >> 2) & 0x02; - byte |= (correctionCode[1] >> 1) & 0x01; - - unsigned char bit = (correctionCode[2] >> 5) & 0x04; - bit |= (correctionCode[2] >> 4) & 0x02; - bit |= (correctionCode[2] >> 3) & 0x01; - - // Correct bit - TRACE_DEBUG("Correcting byte #%d at bit %d\n\r", byte, bit); - data[byte] ^= (1 << bit); - - return Hamming_ERROR_SINGLEBIT; - } - // Check if ECC has been corrupted - if (CountBitsInCode256(correctionCode) == 1) { - - return Hamming_ERROR_ECC; - } - // Otherwise, this is a multi-bit error - else { - - return Hamming_ERROR_MULTIPLEBITS; - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Computes 3-bytes hamming codes for a data block whose size is multiple of -/// 256 bytes. Each 256 bytes block gets its own code. -/// \param data Data to compute code for. -/// \param size Data size in bytes. -/// \param code Codes buffer. -//------------------------------------------------------------------------------ -void Hamming_Compute256x( - const unsigned char *data, - unsigned int size, - unsigned char *code) -{ - TRACE_DEBUG("Hamming_Compute256x()\n\r"); - - while (size > 0) { - - Compute256(data, code); - data += 256; - code += 3; - size -= 256; - } -} - -//------------------------------------------------------------------------------ -/// Verifies 3-bytes hamming codes for a data block whose size is multiple of -/// 256 bytes. Each 256-bytes block is verified with its own code. -/// Returns 0 if the data is correct, Hamming_ERROR_SINGLEBIT if one or more -/// block(s) have had a single bit corrected, or either Hamming_ERROR_ECC -/// or Hamming_ERROR_MULTIPLEBITS. -/// \param data Data buffer to verify. -/// \param size Size of the data in bytes. -/// \param code Original codes. -//------------------------------------------------------------------------------ -unsigned char Hamming_Verify256x( - unsigned char *data, - unsigned int size, - const unsigned char *code) -{ - unsigned char error; - unsigned char result = 0; - - TRACE_DEBUG("Hamming_Verify256x()\n\r"); - - while (size > 0) { - - error = Verify256(data, code); - if (error == Hamming_ERROR_SINGLEBIT) { - - result = Hamming_ERROR_SINGLEBIT; - } - else if (error) { - - return error; - } - - data += 256; - code += 3; - size -= 256; - } - - return result; -} - diff --git a/src/ersky9x/libraries/drivers/utility/hamming.h b/src/ersky9x/libraries/drivers/utility/hamming.h deleted file mode 100644 index 3d5c55506..000000000 --- a/src/ersky9x/libraries/drivers/utility/hamming.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef HAMMING_H -#define HAMMING_H - -//------------------------------------------------------------------------------ -// Defines -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Hamming Code Errors" -/// These are the possible errors when trying to verify a block of data encoded -/// using a Hamming code: -/// -/// !Errors: -/// - Hamming_ERROR_SINGLEBIT -/// - Hamming_ERROR_ECC -/// - Hamming_ERROR_MULTIPLEBITS - -/// A single bit was incorrect but has been recovered. -#define Hamming_ERROR_SINGLEBIT 1 - -/// The original code has been corrupted. -#define Hamming_ERROR_ECC 2 - -/// Multiple bits are incorrect in the data and they cannot be corrected. -#define Hamming_ERROR_MULTIPLEBITS 3 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void Hamming_Compute256x( - const unsigned char *data, - unsigned int size, - unsigned char *code); - -extern unsigned char Hamming_Verify256x( - unsigned char *data, - unsigned int size, - const unsigned char *code); - -#endif //#ifndef HAMMING_H - diff --git a/src/ersky9x/libraries/drivers/utility/iap.c b/src/ersky9x/libraries/drivers/utility/iap.c deleted file mode 100644 index a17ae9ee0..000000000 --- a/src/ersky9x/libraries/drivers/utility/iap.c +++ /dev/null @@ -1,98 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: IAP implementation - - About: Purpose - IAP feature is avalaible on ATMEL chip with internal FLASH. This allows - the FLASH memory to be programmed even when the code is also running in - FLASH, without writing some SRAM relocated functions. - The IAP function entry point is written in the 3rd exception vector - (SWI at 0x300008), and is retrieved just by reading the value at this - address. - - ROM function algorithm : - // Send Command - AT91_BASE_MC->MC_FCR = FlashCmd - // Wait Flash is ready - while ((AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY) != AT91C_MC_FRDY) - return -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "iap.h" -#include -#include - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -/* - Function: IAP_PerformCmd - Perform a FLASH command through the IAP function. - - Returns: - 0 if the IAP function has executed correctly. - -1 if the IAP feature is not implemented in the ROM code. -*/ -unsigned long IAP_PerformCmd(unsigned long FlashCmd) -{ - // Pointer on IAP function in ROM - static void (*IAP_Function)(unsigned int) = 0; - - if (IAP_Function == 0) { - - IAP_Function = (void (*)(unsigned int)) (*((unsigned int *) IAP_FUNC_ADDR)); - TRACE_DEBUG("IAP_PerformCmd : IAP function address in ROM : 0x%08X\n\r", (unsigned int) IAP_Function); - - /* Check if IAP function is implemented (opcode in SWI != 'b' or 'ldr') */ - if ((((((unsigned long)IAP_Function >> 24) & 0xFF) == 0xEA) || - (((unsigned long)IAP_Function >> 24) & 0xFF) == 0xE5)) { - TRACE_ERROR("IAP_PerformCmd : no IAP function address found in ROM\n\r"); - IAP_Function = 0; - return -1; - } - } - - /* Perform FLASH command */ - IAP_Function(FlashCmd); - - return 0; -} - diff --git a/src/ersky9x/libraries/drivers/utility/iap.h b/src/ersky9x/libraries/drivers/utility/iap.h deleted file mode 100644 index bffd48792..000000000 --- a/src/ersky9x/libraries/drivers/utility/iap.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: IAP - - About: Purpose - Small function for using IAP feature. - - About: Usage - Perform a FLASH command using . - -*/ - -#ifndef IAP_H -#define IAP_H - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned long IAP_PerformCmd (unsigned long FlashCmd); - -#endif //#ifndef IAP_H - diff --git a/src/ersky9x/libraries/drivers/utility/led.c b/src/ersky9x/libraries/drivers/utility/led.c deleted file mode 100644 index 31455fc24..000000000 --- a/src/ersky9x/libraries/drivers/utility/led.c +++ /dev/null @@ -1,164 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// \file - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "led.h" -#include -#include - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ - -#ifdef PINS_LEDS -static const Pin pinsLeds[] = {PINS_LEDS}; -static const unsigned int numLeds = PIO_LISTSIZE(pinsLeds); -#endif - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Configures the pin associated with the given LED number. If the LED does -/// not exist on the board, the function does nothing. -/// \param led Number of the LED to configure. -/// \return 1 if the LED exists and has been configured; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char LED_Configure(unsigned int led) -{ -#ifdef PINS_LEDS - // Check that LED exists - if (led >= numLeds) { - - return 0; - } - - // Configure LED - return (PIO_Configure(&pinsLeds[led], 1)); -#else - return 0; -#endif -} - -//------------------------------------------------------------------------------ -/// Turns the given LED on if it exists; otherwise does nothing. -/// \param led Number of the LED to turn on. -/// \return 1 if the LED has been turned on; 0 otherwise. -//------------------------------------------------------------------------------ -unsigned char LED_Set(unsigned int led) -{ -#ifdef PINS_LEDS - // Check if LED exists - if (led >= numLeds) { - - return 0; - } - - // Turn LED on - if (pinsLeds[led].type == PIO_OUTPUT_0) { - - PIO_Set(&pinsLeds[led]); - } - else { - - PIO_Clear(&pinsLeds[led]); - } - - return 1; -#else - return 0; -#endif -} - -//------------------------------------------------------------------------------ -/// Turns a LED off. -/// \param led Number of the LED to turn off. -/// \param 1 if the LED has been turned off; 0 otherwise. -//------------------------------------------------------------------------------ -unsigned char LED_Clear(unsigned int led) -{ -#ifdef PINS_LEDS - // Check if LED exists - if (led >= numLeds) { - - return 0; - } - - // Turn LED off - if (pinsLeds[led].type == PIO_OUTPUT_0) { - - PIO_Clear(&pinsLeds[led]); - } - else { - - PIO_Set(&pinsLeds[led]); - } - - return 1; -#else - return 0; -#endif -} - -//------------------------------------------------------------------------------ -/// Toggles the current state of a LED. -/// \param led Number of the LED to toggle. -/// \return 1 if the LED has been toggled; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char LED_Toggle(unsigned int led) -{ -#ifdef PINS_LEDS - // Check if LED exists - if (led >= numLeds) { - - return 0; - } - - // Toggle LED - if (PIO_GetOutputDataStatus(&pinsLeds[led])) { - - PIO_Clear(&pinsLeds[led]); - } - else { - - PIO_Set(&pinsLeds[led]); - } - - return 1; -#else - return 0; -#endif -} - diff --git a/src/ersky9x/libraries/drivers/utility/led.h b/src/ersky9x/libraries/drivers/utility/led.h deleted file mode 100644 index cca94eb1f..000000000 --- a/src/ersky9x/libraries/drivers/utility/led.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \file -/// -/// \par Purpose -/// -/// Small set of functions for simple and portable LED usage. -/// -/// \par Usage -/// -/// -# Configure one or more LEDs using LED_Configure and -/// LED_ConfigureAll. -/// -# Set, clear and toggle LEDs using LED_Set, LED_Clear and -/// LED_Toggle. -/// -/// LEDs are numbered starting from 0; the number of LEDs depend on the -/// board being used. All the functions defined here will compile properly -/// regardless of whether the LED is defined or not; they will simply -/// return 0 when a LED which does not exist is given as an argument. -/// Also, these functions take into account how each LED is connected on to -/// board; thus, might change the level on the corresponding pin -/// to 0 or 1, but it will always light the LED on; same thing for the other -/// methods. -//------------------------------------------------------------------------------ - -#ifndef LED_H -#define LED_H - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -extern unsigned char LED_Configure(unsigned int led); - -extern unsigned char LED_Set(unsigned int led); - -extern unsigned char LED_Clear(unsigned int led); - -extern unsigned char LED_Toggle(unsigned int led); - -#endif //#ifndef LED_H - diff --git a/src/ersky9x/libraries/drivers/utility/math.c b/src/ersky9x/libraries/drivers/utility/math.c deleted file mode 100644 index 601238531..000000000 --- a/src/ersky9x/libraries/drivers/utility/math.c +++ /dev/null @@ -1,91 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "math.h" -#include "trace.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns the minimum value between two integers. -/// \param a First integer to compare. -/// \param b Second integer to compare. -//------------------------------------------------------------------------------ -unsigned int min(unsigned int a, unsigned int b) -{ - if (a < b) { - - return a; - } - else { - - return b; - } -} - -//------------------------------------------------------------------------------ -/// Returns the absolute value of an integer. -/// \param value Integer value. -//------------------------------------------------------------------------------ -// Do not call this function "abs", problem with gcc ! -unsigned int absv(signed int value) -{ - if (value < 0) { - - return -value; - } - else { - - return value; - } -} - -//------------------------------------------------------------------------------ -/// Computes and returns x power of y. -/// \param x Value. -/// \param y Power. -//------------------------------------------------------------------------------ -unsigned int power(unsigned int x, unsigned int y) -{ - unsigned int result = 1; - - while (y > 0) { - - result *= x; - y--; - } - return result; -} - diff --git a/src/ersky9x/libraries/drivers/utility/math.h b/src/ersky9x/libraries/drivers/utility/math.h deleted file mode 100644 index 7e1c486da..000000000 --- a/src/ersky9x/libraries/drivers/utility/math.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef MATH_H -#define MATH_H - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned int min(unsigned int a, unsigned int b); -extern unsigned int absv(signed int value); -extern unsigned int power(unsigned int x, unsigned int y); -#endif //#ifndef MATH_H - diff --git a/src/ersky9x/libraries/drivers/utility/rand.c b/src/ersky9x/libraries/drivers/utility/rand.c deleted file mode 100644 index 3774bbcdb..000000000 --- a/src/ersky9x/libraries/drivers/utility/rand.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "rand.h" - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -static unsigned long int next = 1; - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initialize the seed for rand generator. -/// \param seed rand initiation seed -//------------------------------------------------------------------------------ -void srand(unsigned int seed) -{ - next = seed; -} - -//------------------------------------------------------------------------------ -/// Return a random number, maxinum assumed to be 65536 -//------------------------------------------------------------------------------ - -int rand(void) -{ - next = next * 1103515245 + 12345; - return (unsigned int)(next/131072) % 65536; -} - diff --git a/src/ersky9x/libraries/drivers/utility/rand.h b/src/ersky9x/libraries/drivers/utility/rand.h deleted file mode 100644 index 072181bca..000000000 --- a/src/ersky9x/libraries/drivers/utility/rand.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Small function for gererating random number. -/// -//------------------------------------------------------------------------------ - -#ifndef RAND_H -#define RAND_H - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -extern void srand(unsigned int seed); -extern int rand(void); - -#endif //#ifndef RAND_H diff --git a/src/ersky9x/libraries/drivers/utility/retarget.c b/src/ersky9x/libraries/drivers/utility/retarget.c deleted file mode 100644 index 8f81ba6d3..000000000 --- a/src/ersky9x/libraries/drivers/utility/retarget.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// This file Configures the target-dependent low level functions for character I/O. -/// -/// !Contents -/// The code implement the lower-level functions as follows: -/// - fputc -/// - ferror -/// - _ttywrch -/// - _sys_exit -/// -/// -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include - -// Disable semihosting -#pragma import(__use_no_semihosting_swi) - -struct __FILE { int handle;} ; -FILE __stdout; -FILE __stderr; - -//------------------------------------------------------------------------------ -/// Outputs a character to a file. -//------------------------------------------------------------------------------ -int fputc(int ch, FILE *f) { - if ((f == stdout) || (f == stderr)) { - DBGU_PutChar(ch); - return ch; - } - else { - return EOF; - } -} - -//------------------------------------------------------------------------------ -/// Returns the error status accumulated during file I/O. -//------------------------------------------------------------------------------ -int ferror(FILE *f) { - return EOF; -} - - -void _ttywrch(int ch) { - DBGU_PutChar((unsigned char)ch); -} - - -void _sys_exit(int return_code) { - label: goto label; /* endless loop */ -} diff --git a/src/ersky9x/libraries/drivers/utility/stdio.c b/src/ersky9x/libraries/drivers/utility/stdio.c deleted file mode 100644 index c9b69762a..000000000 --- a/src/ersky9x/libraries/drivers/utility/stdio.c +++ /dev/null @@ -1,511 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Implementation of several stdio.h methods, such as printf(), sprintf() and -/// so on. This reduces the memory footprint of the binary when using those -/// methods, compared to the libc implementation. -/// -/// !Usage -/// -/// Adds stdio.c to the list of file to compile for the project. This will -/// automatically replace libc methods by the custom ones. -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Local Definitions -//------------------------------------------------------------------------------ - -// Maximum string size allowed (in bytes). -#define MAX_STRING_SIZE 100 - -//------------------------------------------------------------------------------ -// Global Variables -//------------------------------------------------------------------------------ - -// Required for proper compilation. -struct _reent r = {0, (FILE *) 0, (FILE *) 1, (FILE *) 0}; -struct _reent *_impure_ptr = &r; - -//------------------------------------------------------------------------------ -// Local Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Writes a character inside the given string. Returns 1. -// \param pStr Storage string. -// \param c Character to write. -//------------------------------------------------------------------------------ -signed int PutChar(char *pStr, char c) -{ - *pStr = c; - return 1; -} - -//------------------------------------------------------------------------------ -// Writes a string inside the given string. -// Returns the size of the written -// string. -// \param pStr Storage string. -// \param pSource Source string. -//------------------------------------------------------------------------------ -signed int PutString(char *pStr, const char *pSource) -{ - signed int num = 0; - - while (*pSource != 0) { - - *pStr++ = *pSource++; - num++; - } - - return num; -} - -//------------------------------------------------------------------------------ -// Writes an unsigned int inside the given string, using the provided fill & -// width parameters. -// Returns the size in characters of the written integer. -// \param pStr Storage string. -// \param fill Fill character. -// \param width Minimum integer width. -// \param value Integer value. -//------------------------------------------------------------------------------ -signed int PutUnsignedInt( - char *pStr, - char fill, - signed int width, - unsigned int value) -{ - signed int num = 0; - - // Take current digit into account when calculating width - width--; - - // Recursively write upper digits - if ((value / 10) > 0) { - - num = PutUnsignedInt(pStr, fill, width, value / 10); - pStr += num; - } - // Write filler characters - else { - - while (width > 0) { - - PutChar(pStr, fill); - pStr++; - num++; - width--; - } - } - - // Write lower digit - num += PutChar(pStr, (value % 10) + '0'); - - return num; -} - -//------------------------------------------------------------------------------ -// Writes a signed int inside the given string, using the provided fill & width -// parameters. -// Returns the size of the written integer. -// \param pStr Storage string. -// \param fill Fill character. -// \param width Minimum integer width. -// \param value Signed integer value. -//------------------------------------------------------------------------------ -signed int PutSignedInt( - char *pStr, - char fill, - signed int width, - signed int value) -{ - signed int num = 0; - unsigned int absolute; - - // Compute absolute value - if (value < 0) { - - absolute = -value; - } - else { - - absolute = value; - } - - // Take current digit into account when calculating width - width--; - - // Recursively write upper digits - if ((absolute / 10) > 0) { - - if (value < 0) { - - num = PutSignedInt(pStr, fill, width, -(absolute / 10)); - } - else { - - num = PutSignedInt(pStr, fill, width, absolute / 10); - } - pStr += num; - } - else { - - // Reserve space for sign - if (value < 0) { - - width--; - } - - // Write filler characters - while (width > 0) { - - PutChar(pStr, fill); - pStr++; - num++; - width--; - } - - // Write sign - if (value < 0) { - - num += PutChar(pStr, '-'); - pStr++; - } - } - - // Write lower digit - num += PutChar(pStr, (absolute % 10) + '0'); - - return num; -} - -//------------------------------------------------------------------------------ -// Writes an hexadecimal value into a string, using the given fill, width & -// capital parameters. -// Returns the number of char written. -// \param pStr Storage string. -// \param fill Fill character. -// \param width Minimum integer width. -// \param maj Indicates if the letters must be printed in lower- or upper-case. -// \param value Hexadecimal value. -//------------------------------------------------------------------------------ -signed int PutHexa( - char *pStr, - char fill, - signed int width, - unsigned char maj, - unsigned int value) -{ - signed int num = 0; - - // Decrement width - width--; - - // Recursively output upper digits - if ((value >> 4) > 0) { - - num += PutHexa(pStr, fill, width, maj, value >> 4); - pStr += num; - } - // Write filler chars - else { - - while (width > 0) { - - PutChar(pStr, fill); - pStr++; - num++; - width--; - } - } - - // Write current digit - if ((value & 0xF) < 10) { - - PutChar(pStr, (value & 0xF) + '0'); - } - else if (maj) { - - PutChar(pStr, (value & 0xF) - 10 + 'A'); - } - else { - - PutChar(pStr, (value & 0xF) - 10 + 'a'); - } - num++; - - return num; -} - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Stores the result of a formatted string into another string. Format -/// arguments are given in a va_list instance. -/// Return the number of characters written. -/// \param pStr Destination string. -/// \param length Length of Destination string. -/// \param pFormat Format string. -/// \param ap Argument list. -//------------------------------------------------------------------------------ -signed int vsnprintf(char *pStr, size_t length, const char *pFormat, va_list ap) -{ - char fill; - unsigned char width; - signed int num = 0; - signed int size = 0; - - // Clear the string - if (pStr) { - - *pStr = 0; - } - - // Phase string - while (*pFormat != 0 && size < length) { - - // Normal character - if (*pFormat != '%') { - - *pStr++ = *pFormat++; - size++; - } - // Escaped '%' - else if (*(pFormat+1) == '%') { - - *pStr++ = '%'; - pFormat += 2; - size++; - } - // Token delimiter - else { - - fill = ' '; - width = 0; - pFormat++; - - // Parse filler - if (*pFormat == '0') { - - fill = '0'; - pFormat++; - } - - // Parse width - while ((*pFormat >= '0') && (*pFormat <= '9')) { - - width = (width*10) + *pFormat-'0'; - pFormat++; - } - - // Check if there is enough space - if (size + width > length) { - - width = length - size; - } - - // Parse type - switch (*pFormat) { - case 'd': - case 'i': num = PutSignedInt(pStr, fill, width, va_arg(ap, signed int)); break; - case 'u': num = PutUnsignedInt(pStr, fill, width, va_arg(ap, unsigned int)); break; - case 'x': num = PutHexa(pStr, fill, width, 0, va_arg(ap, unsigned int)); break; - case 'X': num = PutHexa(pStr, fill, width, 1, va_arg(ap, unsigned int)); break; - case 's': num = PutString(pStr, va_arg(ap, char *)); break; - case 'c': num = PutChar(pStr, va_arg(ap, unsigned int)); break; - default: - return EOF; - } - - pFormat++; - pStr += num; - size += num; - } - } - - // NULL-terminated (final \0 is not counted) - if (size < length) { - - *pStr = 0; - } - else { - - *(--pStr) = 0; - size--; - } - - return size; -} - -//------------------------------------------------------------------------------ -/// Stores the result of a formatted string into another string. Format -/// arguments are given in a va_list instance. -/// Return the number of characters written. -/// \param pString Destination string. -/// \param length Length of Destination string. -/// \param pFormat Format string. -/// \param ... Other arguments -//------------------------------------------------------------------------------ -signed int snprintf(char *pString, size_t length, const char *pFormat, ...) -{ - va_list ap; - signed int rc; - - va_start(ap, pFormat); - rc = vsnprintf(pString, length, pFormat, ap); - va_end(ap); - - return rc; -} - -//------------------------------------------------------------------------------ -/// Stores the result of a formatted string into another string. Format -/// arguments are given in a va_list instance. -/// Return the number of characters written. -/// \param pString Destination string. -/// \param pFormat Format string. -/// \param ap Argument list. -//------------------------------------------------------------------------------ -signed int vsprintf(char *pString, const char *pFormat, va_list ap) -{ - return vsnprintf(pString, MAX_STRING_SIZE, pFormat, ap); -} - -//------------------------------------------------------------------------------ -/// Outputs a formatted string on the given stream. Format arguments are given -/// in a va_list instance. -/// \param pStream Output stream. -/// \param pFormat Format string -/// \param ap Argument list. -//------------------------------------------------------------------------------ -signed int vfprintf(FILE *pStream, const char *pFormat, va_list ap) -{ - char pStr[MAX_STRING_SIZE]; - char pError[] = "stdio.c: increase MAX_STRING_SIZE\n\r"; - - // Write formatted string in buffer - if (vsprintf(pStr, pFormat, ap) >= MAX_STRING_SIZE) { - - fputs(pError, stderr); - while (1); // Increase MAX_STRING_SIZE - } - - // Display string - return fputs(pStr, pStream); -} - -//------------------------------------------------------------------------------ -/// Outputs a formatted string on the DBGU stream. Format arguments are given -/// in a va_list instance. -/// \param pFormat Format string -/// \param ap Argument list. -//------------------------------------------------------------------------------ -signed int vprintf(const char *pFormat, va_list ap) -{ - return vfprintf(stdout, pFormat, ap); -} - -//------------------------------------------------------------------------------ -/// Outputs a formatted string on the given stream, using a variable number of -/// arguments. -/// \param pStream Output stream. -/// \param pFormat Format string. -//------------------------------------------------------------------------------ -signed int fprintf(FILE *pStream, const char *pFormat, ...) -{ - va_list ap; - signed int result; - - // Forward call to vfprintf - va_start(ap, pFormat); - result = vfprintf(pStream, pFormat, ap); - va_end(ap); - - return result; -} - -//------------------------------------------------------------------------------ -/// Outputs a formatted string on the DBGU stream, using a variable number of -/// arguments. -/// \param pFormat Format string. -//------------------------------------------------------------------------------ -signed int printf(const char *pFormat, ...) -{ - va_list ap; - signed int result; - - // Forward call to vprintf - va_start(ap, pFormat); - result = vprintf(pFormat, ap); - va_end(ap); - - return result; -} - -//------------------------------------------------------------------------------ -/// Writes a formatted string inside another string. -/// \param pStr Storage string. -/// \param pFormat Format string. -//------------------------------------------------------------------------------ -signed int sprintf(char *pStr, const char *pFormat, ...) -{ - va_list ap; - signed int result; - - // Forward call to vsprintf - va_start(ap, pFormat); - result = vsprintf(pStr, pFormat, ap); - va_end(ap); - - return result; -} - -//------------------------------------------------------------------------------ -/// Outputs a string on stdout. -/// \param pStr String to output. -//------------------------------------------------------------------------------ -signed int puts(const char *pStr) -{ - return fputs(pStr, stdout); -} diff --git a/src/ersky9x/libraries/drivers/utility/string.c b/src/ersky9x/libraries/drivers/utility/string.c deleted file mode 100644 index 6c2af0d51..000000000 --- a/src/ersky9x/libraries/drivers/utility/string.c +++ /dev/null @@ -1,239 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Implementation of several methods defined in string.h, for reducing the -/// memory footprint when using them (since the whole libc.o file gets included -/// even when using a single method). -/// -/// !Usage -/// -/// Add string.c to the list of files to compile for the project. This will -/// automatically replace standard libc methods by the custom ones. -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Copies data from a source buffer into a destination buffer. The two buffers -/// must NOT overlap. Returns the destination buffer. -/// \param pDestination Destination buffer. -/// \param pSource Source buffer. -/// \param num Number of bytes to copy. -//------------------------------------------------------------------------------ -void * memcpy(void *pDestination, const void *pSource, size_t num) -{ - unsigned char *pByteDestination; - unsigned char *pByteSource; - unsigned int *pAlignedSource = (unsigned int *) pSource; - unsigned int *pAlignedDestination = (unsigned int *) pDestination; - - // If num is more than 4 bytes, and both dest. and source are aligned, - // then copy dwords - if ((((unsigned int) pAlignedDestination & 0x3) == 0) - && (((unsigned int) pAlignedSource & 0x3) == 0) - && (num >= 4)) { - - while (num >= 4) { - - *pAlignedDestination++ = *pAlignedSource++; - num -= 4; - } - } - - // Copy remaining bytes - pByteDestination = (unsigned char *) pAlignedDestination; - pByteSource = (unsigned char *) pAlignedSource; - while (num--) { - - *pByteDestination++ = *pByteSource++; - } - - return pDestination; -} - -//------------------------------------------------------------------------------ -/// Fills a memory region with the given value. Returns a pointer to the -/// memory region. -/// \param pBuffer Pointer to the start of the memory region to fill -/// \param value Value to fill the region with -/// \param num Size to fill in bytes -//------------------------------------------------------------------------------ -void * memset(void *pBuffer, int value, size_t num) -{ - unsigned char *pByteDestination; - unsigned int *pAlignedDestination = (unsigned int *) pBuffer; - unsigned int alignedValue = (value << 24) | (value << 16) | (value << 8) | value; - - // Set words if possible - if ((((unsigned int) pAlignedDestination & 0x3) == 0) && (num >= 4)) { - while (num >= 4) { - *pAlignedDestination++ = alignedValue; - num -= 4; - } - } - // Set remaining bytes - pByteDestination = (unsigned char *) pAlignedDestination; - while (num--) { - *pByteDestination++ = value; - } - return pBuffer; -} - -//----------------------------------------------------------------------------- -/// Search a character in the given string. -/// Returns a pointer to the character location. -/// \param pString Pointer to the start of the string to search. -/// \param character The character to find. -//----------------------------------------------------------------------------- -char * strchr(const char *pString, int character) -{ - char * p = (char *)pString; - char c = character & 0xFF; - - while(*p != c) { - if (*p == 0) { - return 0; - } - p++; - } - return p; -} - -//----------------------------------------------------------------------------- -/// Return the length of a given string -/// \param pString Pointer to the start of the string. -//----------------------------------------------------------------------------- -size_t strlen(const char *pString) -{ - unsigned int length = 0; - - while(*pString++ != 0) { - length++; - } - return length; -} - - -//----------------------------------------------------------------------------- -/// Search a character backword from the end of given string. -/// Returns a pointer to the character location. -/// \param pString Pointer to the start of the string to search. -/// \param character The character to find. -//----------------------------------------------------------------------------- -char * strrchr(const char *pString, int character) -{ - char *p = 0; - - while(*pString != 0) { - if (*pString++ == character) { - p = (char*)pString; - } - } - return p; -} - -//----------------------------------------------------------------------------- -/// Copy from source string to destination string -/// Return a pointer to the destination string -/// \param pDestination Pointer to the destination string. -/// \param pSource Pointer to the source string. -//----------------------------------------------------------------------------- -char * strcpy(char *pDestination, const char *pSource) -{ - char *pSaveDest = pDestination; - - for(; (*pDestination = *pSource) != 0; ++pSource, ++pDestination); - return pSaveDest; -} - -//----------------------------------------------------------------------------- -/// Compare the first specified bytes of 2 given strings -/// Return 0 if equals -/// Return >0 if 1st string > 2nd string -/// Return <0 if 1st string < 2nd string -/// \param pString1 Pointer to the start of the 1st string. -/// \param pString2 Pointer to the start of the 2nd string. -/// \param count Number of bytes that should be compared. -//----------------------------------------------------------------------------- -int strncmp(const char *pString1, const char *pString2, size_t count) -{ - int r; - - while(count) { - r = *pString1 - *pString2; - if (r == 0) { - if (*pString1 == 0) { - break; - } - pString1++; - pString2++; - count--; - continue; - } - return r; - } - return 0; -} - -//----------------------------------------------------------------------------- -/// Copy the first number of bytes from source string to destination string -/// Return the pointer to the destination string. -/// \param pDestination Pointer to the start of destination string. -/// \param pSource Pointer to the start of the source string. -/// \param count Number of bytes that should be copied. -//----------------------------------------------------------------------------- -char * strncpy(char *pDestination, const char *pSource, size_t count) -{ - char *pSaveDest = pDestination; - - while (count) { - *pDestination = *pSource; - if (*pSource == 0) { - break; - } - pDestination++; - pSource++; - count--; - } - return pSaveDest; -} - diff --git a/src/ersky9x/libraries/drivers/utility/trace.c b/src/ersky9x/libraries/drivers/utility/trace.c deleted file mode 100644 index 9c0951aa0..000000000 --- a/src/ersky9x/libraries/drivers/utility/trace.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "trace.h" - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Trace level can be set at applet initialization -#if !defined(NOTRACE) && (DYN_TRACES == 1) - unsigned int traceLevel = TRACE_LEVEL; -#endif - diff --git a/src/ersky9x/libraries/drivers/utility/trace.h b/src/ersky9x/libraries/drivers/utility/trace.h deleted file mode 100644 index d56093102..000000000 --- a/src/ersky9x/libraries/drivers/utility/trace.h +++ /dev/null @@ -1,246 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \file -/// -/// \par Purpose -/// -/// Standard output methods for reporting debug information, warnings and -/// errors, which can be easily be turned on/off. -/// -/// \par Usage -/// -# Initialize the DBGU using TRACE_CONFIGURE() if you intend to eventually -/// disable ALL traces; otherwise use DBGU_Configure(). -/// -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR() -/// TRACE_FATAL() macros to output traces throughout the program. -/// -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2 -/// and Fatal 1. Disable a group of traces by changing the value of -/// TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL -/// are not generated. To generate no trace, use the reserved value 0. -/// -# Trace disabling can be static or dynamic. If dynamic disabling is selected -/// the trace level can be modified in runtime. If static disabling is selected -/// the disabled traces are not compiled. -/// -/// \par traceLevels Trace level description -/// -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program, -/// and which do not produce meaningful information otherwise. -/// -# TRACE_INFO (4): Informational trace about the program execution. Should -/// enable the user to see the execution flow. -/// -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case -/// it can be discarded safely; it may even be expected. -/// -# TRACE_ERROR (2): Indicates an error which may not stop the program execution, -/// but which indicates there is a problem with the code. -/// -# TRACE_FATAL (1): Indicates a major error which prevents the program from going -/// any further. - -//------------------------------------------------------------------------------ - -#ifndef TRACE_H -#define TRACE_H - -#include "debug.h" - -#if 0 -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include -#include - -//------------------------------------------------------------------------------ -// Global Definitions -//------------------------------------------------------------------------------ - -/// Softpack Version -#define SOFTPACK_VERSION "1.0beta1" - -#define TRACE_LEVEL_DEBUG 5 -#define TRACE_LEVEL_INFO 4 -#define TRACE_LEVEL_WARNING 3 -#define TRACE_LEVEL_ERROR 2 -#define TRACE_LEVEL_FATAL 1 -#define TRACE_LEVEL_NO_TRACE 0 - -// By default, all traces are output except the debug one. -#if !defined(TRACE_LEVEL) -#define TRACE_LEVEL TRACE_LEVEL_INFO -#endif - -// By default, trace level is static (not dynamic) -#if !defined(DYN_TRACES) -#define DYN_TRACES 0 -#endif - -#if defined(NOTRACE) -#error "Error: NOTRACE has to be not defined !" -#endif - -#undef NOTRACE -#if (DYN_TRACES==0) - #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE) - #define NOTRACE - #endif -#endif - - - -//------------------------------------------------------------------------------ -// Global Macros -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the DBGU -/// \param mode DBGU mode. -/// \param baudrate DBGU baudrate. -/// \param mck Master clock frequency. -//------------------------------------------------------------------------------ -#define TRACE_CONFIGURE(mode, baudrate, mck) { \ - const Pin pinsDbgu[] = {PINS_DBGU}; \ - PIO_Configure(pinsDbgu, PIO_LISTSIZE(pinsDbgu)); \ - DBGU_Configure(mode, baudrate, mck); \ - } - -//------------------------------------------------------------------------------ -/// Initializes the DBGU for ISP project -/// \param mode DBGU mode. -/// \param baudrate DBGU baudrate. -/// \param mck Master clock frequency. -//------------------------------------------------------------------------------ -#ifndef DYNTRACE -#define DYNTRACE 0 -#endif - -#if (TRACE_LEVEL==0) && (DYNTRACE==0) -#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) {} -#else -#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) { \ - const Pin pinsDbgu[] = {PINS_DBGU}; \ - PIO_Configure(pinsDbgu, PIO_LISTSIZE(pinsDbgu)); \ - DBGU_Configure(mode, baudrate, mck); \ - } -#endif - -//------------------------------------------------------------------------------ -/// Outputs a formatted string using if the log level is high -/// enough. Can be disabled by defining TRACE_LEVEL=0 during compilation. -/// \param format Formatted string to output. -/// \param ... Additional parameters depending on formatted string. -//------------------------------------------------------------------------------ -#if defined(NOTRACE) - -// Empty macro -#define TRACE_DEBUG(...) { } -#define TRACE_INFO(...) { } -#define TRACE_WARNING(...) { } -#define TRACE_ERROR(...) { } -#define TRACE_FATAL(...) { while(1); } - -#define TRACE_DEBUG_WP(...) { } -#define TRACE_INFO_WP(...) { } -#define TRACE_WARNING_WP(...) { } -#define TRACE_ERROR_WP(...) { } -#define TRACE_FATAL_WP(...) { while(1); } - -#elif (DYN_TRACES == 1) - -// Trace output depends on traceLevel value -#define TRACE_DEBUG(...) { if (traceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } } -#define TRACE_INFO(...) { if (traceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } } -#define TRACE_WARNING(...) { if (traceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } } -#define TRACE_ERROR(...) { if (traceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } } -#define TRACE_FATAL(...) { if (traceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while(1); } } - -#define TRACE_DEBUG_WP(...) { if (traceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } } -#define TRACE_INFO_WP(...) { if (traceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } } -#define TRACE_WARNING_WP(...) { if (traceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } } -#define TRACE_ERROR_WP(...) { if (traceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } } -#define TRACE_FATAL_WP(...) { if (traceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while(1); } } - -#else - -// Trace compilation depends on TRACE_LEVEL value -#if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG) -#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); } -#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); } -#else -#define TRACE_DEBUG(...) { } -#define TRACE_DEBUG_WP(...) { } -#endif - -#if (TRACE_LEVEL >= TRACE_LEVEL_INFO) -#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); } -#define TRACE_INFO_WP(...) { printf(__VA_ARGS__); } -#else -#define TRACE_INFO(...) { } -#define TRACE_INFO_WP(...) { } -#endif - -#if (TRACE_LEVEL >= TRACE_LEVEL_WARNING) -#define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); } -#define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); } -#else -#define TRACE_WARNING(...) { } -#define TRACE_WARNING_WP(...) { } -#endif - -#if (TRACE_LEVEL >= TRACE_LEVEL_ERROR) -#define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); } -#define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); } -#else -#define TRACE_ERROR(...) { } -#define TRACE_ERROR_WP(...) { } -#endif - -#if (TRACE_LEVEL >= TRACE_LEVEL_FATAL) -#define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while(1); } -#define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while(1); } -#else -#define TRACE_FATAL(...) { while(1); } -#define TRACE_FATAL_WP(...) { while(1); } -#endif - -#endif - - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ -// Depending on DYN_TRACES, traceLevel is a modifable runtime variable -// or a define -#if !defined(NOTRACE) && (DYN_TRACES == 1) - extern unsigned int traceLevel; -#endif - -#endif - -#endif //#ifndef TRACE_H - diff --git a/src/ersky9x/libraries/drivers/utility/util.c b/src/ersky9x/libraries/drivers/utility/util.c deleted file mode 100644 index 0fbbb1e72..000000000 --- a/src/ersky9x/libraries/drivers/utility/util.c +++ /dev/null @@ -1,223 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include -#include - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Print char if printable. If not print a point -/// \param c char to -//------------------------------------------------------------------------------ -static void PrintChar(unsigned char c) -{ - if( (/*c >= 0x00 &&*/ c <= 0x1F) || - (c >= 0xB0 && c <= 0xDF) ) { - - printf("."); - } - else { - - printf("%c", c); - } -} - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Displays the content of the given frame on the DBGU. -/// \param pBuffer Pointer to the frame to dump. -/// \param size Buffer size in bytes. -//------------------------------------------------------------------------------ -void UTIL_DbguDumpFrame(unsigned char *pFrame, unsigned int size) -{ - unsigned int i; - - for (i=0; i < size; i++) { - printf("%02X ", pFrame[i]); - } - - printf("\n\r"); -} - -//------------------------------------------------------------------------------ -/// Displays the content of the given buffer on the DBGU. -/// \param pBuffer Pointer to the buffer to dump. -/// \param size Buffer size in bytes. -/// \param address Start address to display -//------------------------------------------------------------------------------ -void UTIL_DbguDumpMemory( - unsigned char *pBuffer, - unsigned int size, - unsigned int address - ) -{ - unsigned int i, j; - unsigned int lastLineStart; - unsigned char* pTmp; - - for (i=0; i < (size / 16); i++) { - - printf("0x%08X: ", address + (i*16)); - pTmp = (unsigned char*)&pBuffer[i*16]; - for (j=0; j < 4; j++) { - printf("%02X%02X%02X%02X ", pTmp[0],pTmp[1],pTmp[2],pTmp[3]); - pTmp += 4; - } - - pTmp = (unsigned char*)&pBuffer[i*16]; - for (j=0; j < 16; j++) { - PrintChar(*pTmp++); - } - - printf("\n\r"); - } - - if( (size%16) != 0) { - lastLineStart = size - (size%16); - printf("0x%08X: ", address + lastLineStart); - - for (j= lastLineStart; j < lastLineStart+16; j++) { - - if( (j!=lastLineStart) && (j%4 == 0) ) { - printf(" "); - } - if(j= '0' && key <= '9' ) { - value = (value * 10) + (key - '0'); - nbNb++; - } - else if(key == 0x0D || key == ' ') { - if(nbNb == 0) { - printf("\n\rWrite a number and press ENTER or SPACE!\n\r"); - return 0; - } else { - printf("\n\r"); - *pValue = value; - return 1; - } - } else { - printf("\n\r'%c' not a number!\n\r", key); - return 0; - } - } -} - -//------------------------------------------------------------------------------ -/// Reads an integer and check the value -//------------------------------------------------------------------------------ -unsigned char UTIL_DbguGetIntegerMinMax( - unsigned int *pValue, - unsigned int min, - unsigned int max - ) -{ - unsigned int value = 0; - - if( UTIL_DbguGetInteger(&value) == 0) { - return 0; - } - - if(value < min || value > max) { - printf("\n\rThe number have to be between %d and %d\n\r", min, max); - return 0; - } - - printf("\n\r"); - *pValue = value; - return 1; -} - -//------------------------------------------------------------------------------ -/// Reads an hexadecimal number -//------------------------------------------------------------------------------ -unsigned char UTIL_DbguGetHexa32(unsigned int *pValue) -{ - unsigned char key; - unsigned int i = 0; - unsigned int value = 0; - for(i = 0; i < 8; i++) { - key = DBGU_GetChar(); - DBGU_PutChar(key); - if(key >= '0' && key <= '9' ) { - value = (value * 16) + (key - '0'); - } - else if(key >= 'A' && key <= 'F' ) { - value = (value * 16) + (key - 'A' + 10) ; - } - else if(key >= 'a' && key <= 'f' ) { - value = (value * 16) + (key - 'a' + 10) ; - } - else { - printf("\n\rIt is not a hexa character!\n\r"); - return 0; - } - } - - printf("\n\r"); - *pValue = value; - return 1; -} - diff --git a/src/ersky9x/libraries/drivers/utility/util.h b/src/ersky9x/libraries/drivers/utility/util.h deleted file mode 100644 index b0a184aec..000000000 --- a/src/ersky9x/libraries/drivers/utility/util.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef UTIL_H -#define UTIL_H - -//------------------------------------------------------------------------------ -// Global Functions -//------------------------------------------------------------------------------ - -extern void UTIL_DbguDumpFrame(unsigned char *pFrame, unsigned int size); - -extern void UTIL_DbguDumpMemory(unsigned char *pBuffer, unsigned int size, unsigned int address); - -extern unsigned char UTIL_DbguGetInteger(unsigned int *pValue); - -extern unsigned char UTIL_DbguGetIntegerMinMax(unsigned int *pValue, unsigned int min, unsigned int max); - -extern unsigned char UTIL_DbguGetHexa32(unsigned int *pValue); - -#endif //#ifndef UTIL_H - diff --git a/src/ersky9x/libraries/drivers/utility/utility.dir b/src/ersky9x/libraries/drivers/utility/utility.dir deleted file mode 100644 index b318e278d..000000000 --- a/src/ersky9x/libraries/drivers/utility/utility.dir +++ /dev/null @@ -1,50 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// The utility directory contains several very small APIs for performing -/// specific tasks, such as LED configuration, BMP header decoding, etc. -/// -/// !!!Contents -/// -/// Most modules contained here are very small and do not fit in any of the -/// other at91lib categories. They primarily provide helper functions -/// (e.g. for handling BMP and WAV files) and re-implementation of libc code for -/// reducing code size (math, stdio, string). -/// -/// Two important files are assert.h and trace.h. The first one provides macros -/// for run-time verifications of parameters & values. Trace.h enables the -/// programmer to add debug traces to APIs that can be easily turned on or off -/// depending on the debugging needs. -//------------------------------------------------------------------------------ - diff --git a/src/ersky9x/libraries/drivers/utility/video.c b/src/ersky9x/libraries/drivers/utility/video.c deleted file mode 100644 index d516a1bf7..000000000 --- a/src/ersky9x/libraries/drivers/utility/video.c +++ /dev/null @@ -1,130 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include "video.h" - -//----------------------------------------------------------------------------- -/// Conversion YCrCb to RGB:
    -/// R = 1.164(Yi – 16) + 1.596(Cr – 128)
    -/// G = 1.164(Yi – 16) – 0.813(Cr – 128) – 0.391(Cb – 128)
    -/// B = 1.164(Yi – 16) + 2.018(Cb – 128)
    -/// -/// Pixel i+1:
    -/// YCrCb to RGB:
    -/// R = 1.164(Yi+1 – 16) + 1.596(Cr – 128)
    -/// G = 1.164(Yi+1 – 16) – 0.813(Cr – 128) – 0.391(Cb – 128)
    -/// B = 1.164(Yi+1 – 16) + 2.018(Cb – 128) -/// \param ycc Source buffer (YCC) -/// \param rgb Destination buffer (RGB) -/// \param len Length of buffer -//----------------------------------------------------------------------------- -void VIDEO_Ycc2Rgb(unsigned char *ycc, unsigned short *rgb, unsigned int len) -{ - int r_calc_i; - int g_calc_i; - int b_calc_i; - int r_calc_i_incr; - int g_calc_i_incr; - int b_calc_i_incr; - int cr_i; - int y_i; - int cb_i; - int y_i_incr; - int val; - int val1; - int val2; - int val3; - int val4; - int val5; - int i; - - for(i=0; i 255) - r_calc_i = 255; - - if (g_calc_i < 0) - g_calc_i = 0; - else if (g_calc_i > 255) - g_calc_i = 255; - - if (b_calc_i < 0) - b_calc_i = 0; - else if (b_calc_i > 255) - b_calc_i = 255; - - if (r_calc_i_incr < 0) - r_calc_i_incr = 0; - else if (r_calc_i_incr > 255) - r_calc_i_incr = 255; - - if (g_calc_i_incr < 0) - g_calc_i_incr = 0; - else if (g_calc_i_incr > 255) - g_calc_i_incr = 255; - - if (b_calc_i_incr < 0) - b_calc_i_incr = 0; - else if (b_calc_i_incr > 255) - b_calc_i_incr = 255; - - *rgb++ = (((unsigned short )r_calc_i & 0xF8) >> 3) - | ((((unsigned short)g_calc_i & 0xF8) >> 3) << 5) - | ((((unsigned short)b_calc_i & 0xF8) >> 3) << 10); - - *rgb++ = (((unsigned short )r_calc_i_incr & 0xF8) >> 3) - | ((((unsigned short)g_calc_i_incr & 0xF8) >> 3) << 5) - | ((((unsigned short)b_calc_i_incr & 0xF8) >> 3) << 10); - } -} - diff --git a/src/ersky9x/libraries/drivers/utility/video.h b/src/ersky9x/libraries/drivers/utility/video.h deleted file mode 100644 index 28f4a18a2..000000000 --- a/src/ersky9x/libraries/drivers/utility/video.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Video structure, used for LCD and ISI. -/// Conversion Video from YCC to RGB -/// -//------------------------------------------------------------------------------ - -#ifndef _VIDEO_H -#define _VIDEO_H - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- -/// Type of video is YUV -#define YUV 0 -/// Type of video is RGB -#define RGB 1 - -//----------------------------------------------------------------------------- -/// Video structure -//----------------------------------------------------------------------------- -typedef struct _AT91S_VIDEO -{ - /// LCD Vertical Size - unsigned int lcd_vsize; - /// LCD Horizontal Size - unsigned int lcd_hsize; - /// LCD Number of Bit Per Pixel - unsigned int lcd_nbpp; - /// LCD Frame Buffer Address - unsigned int lcd_fb_addr; - /// Base address for the frame buffer descriptors list - unsigned int Isi_fbd_base; - /// Start of Line Delay - unsigned int Hblank; - /// Start of frame Delay - unsigned int Vblank; - /// Vertical size of the Image sensor [0..2047] - unsigned int codec_vsize; - /// Horizontal size of the Image sensor [0..2047] - unsigned int codec_hsize; - /// Base address for codec DMA - unsigned int codec_fb_addr; - /// Buffer index - unsigned int IsiPrevBuffIndex; - /// Type of video - unsigned char rgb_or_yuv; -}AT91S_VIDEO, *AT91PS_VIDEO; - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -extern void VIDEO_Ycc2Rgb(unsigned char *ycc, unsigned short *rgb, unsigned int len); - -#endif - diff --git a/src/ersky9x/libraries/drivers/utility/wav.c b/src/ersky9x/libraries/drivers/utility/wav.c deleted file mode 100644 index d52d11b27..000000000 --- a/src/ersky9x/libraries/drivers/utility/wav.c +++ /dev/null @@ -1,84 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "wav.h" -#include - -//------------------------------------------------------------------------------ -// Internal constants -//------------------------------------------------------------------------------ - -/// WAV letters "RIFF" -#define WAV_CHUNKID 0x46464952 -/// WAV letters "WAVE" -#define WAV_FORMAT 0x45564157 -/// WAV letters "fmt " -#define WAV_SUBCHUNKID 0x20746D66 - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns 1 if the header of a Wav file is valid; otherwise returns 0. -/// \param file Buffer holding the file to examinate. -//------------------------------------------------------------------------------ -unsigned char WAV_IsValid(const WavHeader *header) -{ - return ((header->chunkID == WAV_CHUNKID) - && (header->format == WAV_FORMAT) - && (header->subchunk1Size == 0x10)); -} - -//------------------------------------------------------------------------------ -/// Display the information of the WAV file (sample rate, stereo/mono and frame -/// size). -//------------------------------------------------------------------------------ -void WAV_DisplayInfo(const WavHeader *header) -{ - printf( "Wave file header information\n\r"); - printf( "--------------------------------\n\r"); - printf( " - Chunk ID = 0x%08X\n\r", header->chunkID); - printf( " - Chunk Size = %d\n\r", header->chunkSize); - printf( " - Format = 0x%08X\n\r", header->format); - printf( " - SubChunk ID = 0x%08X\n\r", header->subchunk1ID); - printf( " - Subchunk1 Size = %d\n\r", header->subchunk1Size); - printf( " - Audio Format = 0x%04X\n\r", header->audioFormat); - printf( " - Num. Channels = %d\n\r", header->numChannels); - printf( " - Sample Rate = %d\n\r", header->sampleRate); - printf( " - Byte Rate = %d\n\r", header->byteRate); - printf( " - Block Align = %d\n\r", header->blockAlign); - printf( " - Bits Per Sample = %d\n\r", header->bitsPerSample); - printf( " - Subchunk2 ID = 0x%08X\n\r", header->subchunk2ID); - printf( " - Subchunk2 Size = %d\n\r", header->subchunk2Size); -} \ No newline at end of file diff --git a/src/ersky9x/libraries/drivers/utility/wav.h b/src/ersky9x/libraries/drivers/utility/wav.h deleted file mode 100644 index 2af448c68..000000000 --- a/src/ersky9x/libraries/drivers/utility/wav.h +++ /dev/null @@ -1,82 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef WAV_H -#define WAV_H - -//------------------------------------------------------------------------------ -// Exported types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Standard WAV file header information. -//------------------------------------------------------------------------------ -typedef struct _WavHeader -{ - /// Contains the letters "RIFF" in ASCII form. - unsigned int chunkID; - /// Size of the rest of the chunk following this number. - unsigned int chunkSize; - /// Contains the letters "WAVE". - unsigned int format; - /// Contains the letters "fmt ". - unsigned int subchunk1ID; - /// 16 for PCM. This is the size of the rest of the Subchunk - /// which follows this number. - unsigned int subchunk1Size; - /// PCM = 1 (i.e. Linear quantization). Values other than 1 indicate some - /// form of compression. - unsigned short audioFormat; - /// Mono = 1, Stereo = 2, etc. - unsigned short numChannels; - /// 8000, 44100, etc. - unsigned int sampleRate; - /// SampleRate * NumChannels * BitsPerSample/8 - unsigned int byteRate; - /// NumChannels * BitsPerSample/8 - unsigned short blockAlign; - /// 8 bits = 8, 16 bits = 16, etc. - unsigned short bitsPerSample; - /// Contains the letters "data". - unsigned int subchunk2ID; - /// Number of bytes in the data. - unsigned int subchunk2Size; - -} WavHeader; - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char WAV_IsValid(const WavHeader *header); - -extern void WAV_DisplayInfo(const WavHeader *header); - -#endif //#ifndef WAV_H - diff --git a/src/ersky9x/libraries/drivers/wdt/wdt.c b/src/ersky9x/libraries/drivers/wdt/wdt.c deleted file mode 100644 index ff299d66f..000000000 --- a/src/ersky9x/libraries/drivers/wdt/wdt.c +++ /dev/null @@ -1,141 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of Watchdog Timer (WDT) controller. - * - */ - -/** \addtogroup wdt_module Working with WDT - * The WDT driver provides the interface to configure and use the WDT - * peripheral. - * - * The WDT can be used to prevent system lock-up if the software becomes - * trapped in a deadlock. It can generate a general reset or a processor - * reset only. It is clocked by slow clock divided by 128. - * - * The WDT is running at reset with 16 seconds watchdog period (slow clock at 32.768 kHz) - * and external reset generation enabled. The user must either disable it or - * reprogram it to meet the application requires. - * - * To use the WDT, the user could follow these few steps: - *
      - *
    • Enable watchdog with given mode using \ref WDT_Enable(). - *
    • Restart the watchdog using \ref WDT_Restart() within the watchdog period. - *
    - * - * For more accurate information, please look at the WDT section of the - * Datasheet. - * - * \note - * The Watchdog Mode Register (WDT_MR) can be written only once.\n - * - * Related files :\n - * \ref wdt.c\n - * \ref wdt.h.\n - */ -/*@{*/ -/*@}*/ - -/*--------------------------------------------------------------------------- - * Headers - *---------------------------------------------------------------------------*/ - -/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */ -#include - -#include -#include "wdt.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Enable watchdog with given mode. - * - * \note The Watchdog Mode Register (WDT_MR) can be written only once. - * Only a processor reset resets it. - * - * \param mode WDT mode to be set - */ -void WDT_Enable(uint32_t mode) -{ - Wdt *pWDT = WDT; - - pWDT->WDT_MR = mode; -} - -/** - * \brief Disable watchdog. - * - * \note The Watchdog Mode Register (WDT_MR) can be written only once. - * Only a processor reset resets it. - */ -void WDT_Disable(void) -{ - Wdt *pWDT = WDT; - - pWDT->WDT_MR = WDT_MR_WDDIS; -} - -/** - * \brief Watchdog restart. - */ -void WDT_Restart(void) -{ - Wdt *pWDT = WDT; - - pWDT->WDT_CR = 0xA5000001; -} - -/** - * \brief Watchdog get status. - */ -uint32_t WDT_GetStatus(void) -{ - Wdt *pWDT = WDT; - - return(pWDT->WDT_SR & 0x3); -} - -/** - * \brief Watchdog get period. - * - * \param ms desired watchdog period in millisecond. - */ -uint32_t WDT_GetPeriod(uint32_t ms) -{ - if ((ms < 4) || (ms > 16000)) { - return 0; - } - return((ms << 8) / 1000); -} diff --git a/src/ersky9x/libraries/drivers/wdt/wdt.h b/src/ersky9x/libraries/drivers/wdt/wdt.h deleted file mode 100644 index a07bf77e8..000000000 --- a/src/ersky9x/libraries/drivers/wdt/wdt.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * \par Purpose - * Interface for Watchdog Timer (WDT) controller. - * - * \par Usage - * -# Enable watchdog with given mode using \ref WDT_Enable(). - * -# Disable watchdog using \ref WDT_Disable() - * -# Restart the watchdog using \ref WDT_Restart(). - * -# Get watchdog status using \ref WDT_GetStatus(). - * -# Caculate watchdog period value using \ref WDT_GetPeriod(). - */ - -#ifndef WDT_H -#define WDT_H - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern void WDT_Enable(uint32_t mode); - -extern void WDT_Disable(void); - -extern void WDT_Restart(void); - -extern uint32_t WDT_GetStatus(void); - -extern uint32_t WDT_GetPeriod(uint32_t ms); - -#endif /* #ifndef WDT_H */ diff --git a/src/ersky9x/libraries/memories/.project b/src/ersky9x/libraries/memories/.project deleted file mode 100644 index 75999553f..000000000 --- a/src/ersky9x/libraries/memories/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - memories - - - - - - - - diff --git a/src/ersky9x/libraries/memories/Media.c b/src/ersky9x/libraries/memories/Media.c deleted file mode 100644 index f099b1750..000000000 --- a/src/ersky9x/libraries/memories/Media.c +++ /dev/null @@ -1,57 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "Media.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -/// Number of medias which are effectively used. -unsigned int numMedias = 0; - -//------------------------------------------------------------------------------ -//! \brief Handle interrupts on specified media -//! \param pMedia List of media -//! \param bNumMedia Number of media in list -//! \see S_media -//------------------------------------------------------------------------------ -void MED_HandleAll(Media *pMedia, unsigned char bNumMedia) -{ - // Check each media for interrupts to handle - unsigned int i; - for (i = 0; i < bNumMedia; i++) { - - MED_Handler(&(pMedia[i])); - } -} diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.c deleted file mode 100644 index 045b9f39d..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "sam-gui/common/sam_gui_bitmap_raw.h" -#include "sam-gui/common/sam_gui_errors.h" -#include -#include - -extern int BitmapRaw_Initialize( SGUIBitmapRaw* pbmpBitmap, uint32_t dwWidth, uint32_t dwHeight, uint32_t dwBPP ) -{ - // Check pointers - if ( pbmpBitmap == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( (dwWidth == 0) || (dwHeight == 0) || (dwBPP == 0) ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - memset( pbmpBitmap, 0, sizeof( SGUIBitmapRaw ) ) ; - pbmpBitmap->dwWidth=dwWidth ; - pbmpBitmap->dwHeight=dwHeight ; - pbmpBitmap->dwBPP=dwBPP ; - - return SAMGUI_E_OK ; -} - -extern int BitmapRaw_SetData( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucData, uint32_t dwDataLength ) -{ - // Check pointers - if ( (pbmpBitmap == NULL) || (pucData == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( dwDataLength == 0 ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - pbmpBitmap->pucData=pucData ; - pbmpBitmap->dwDataLength=dwDataLength ; - - return SAMGUI_E_OK ; -} - -extern int BitmapRaw_SetLUT( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucLUT, uint32_t dwLUTLength ) -{ - // Check pointers - if ( (pbmpBitmap == NULL) || (pucLUT == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( dwLUTLength == 0 ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - pbmpBitmap->pucData=pucLUT ; - pbmpBitmap->dwDataLength=dwLUTLength ; - - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.h deleted file mode 100644 index 7d95d6a3b..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_bitmap_raw.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _SAM_GUI_BITMAP_RAW_ -#define _SAM_GUI_BITMAP_RAW_ - -typedef struct _SGUIBitmapRaw -{ - uint32_t dwWidth ; - uint32_t dwHeight ; - uint32_t dwBPP ; - uint32_t dwLUTLength ; - uint8_t* pucLUT ; - uint32_t dwDataLength ; - uint8_t* pucData ; -} SGUIBitmapRaw ; - -extern int BitmapRaw_Initialize( SGUIBitmapRaw* pbmpBitmap, uint32_t dwWidth, uint32_t dwHeight, uint32_t dwBPP ) ; - -extern int BitmapRaw_SetData( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucData, uint32_t dwDataLength ) ; -extern int BitmapRaw_SetLUT( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucLUT, uint32_t dwLUTLength ) ; - -#endif // _SAM_GUI_BITMAP_RAW_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_color.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_color.c deleted file mode 100644 index e0617d525..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_color.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "sam-gui/common/sam_gui_color.h" -#include "sam-gui/common/sam_gui_errors.h" -#include - -extern int COLOR_GetGradientValue( SGUIColor* pclrBegin, SGUIColor* pclrEnd, - uint32_t dwNumber, uint32_t dwIndex, SGUIColor* pclrResult ) -{ - // Check pointers - if ( (pclrBegin == NULL) || (pclrEnd == NULL) || (pclrResult == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( dwNumber == 0 ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Process gradient - - return SAMGUI_E_OK ; -} - -extern int COLOR_RGB565( SGUIColor* pclrIn, SGUIColor* pclrResult ) -{ - // Check pointers - if ( (pclrIn == NULL) || (pclrResult == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - pclrResult->u.RGBA.ucR=pclrIn->u.RGBA.ucR&0x1f ; - pclrResult->u.RGBA.ucG=pclrIn->u.RGBA.ucG&0x3f ; - pclrResult->u.RGBA.ucB=pclrIn->u.RGBA.ucB&0x1f ; - pclrResult->u.RGBA.ucA=0x00 ; - - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_color.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_color.h deleted file mode 100644 index 5c0c6b6b4..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_color.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SAM_GUI_COLOR_ -#define _SAM_GUI_COLOR_ - -typedef struct _SGUIColor -{ - union _u - { - uint32_t dwRGBA ; - - struct _RGBA - { - uint8_t ucA ; - uint8_t ucB ; - uint8_t ucG ; - uint8_t ucR ; - } RGBA ; - } u ; -} SGUIColor ; - -//#define ucR u.RGBA.ucR -//#define ucG u.RGBA.ucG -//#define ucB u.RGBA.ucB -//#define ucA u.RGBA.ucA - -extern int COLOR_GetGradientValue( SGUIColor* pclrBegin, SGUIColor* pclrEnd, - uint32_t dwNumber, uint32_t dwIndex, SGUIColor* pclrResult ) ; - -extern int COLOR_RGB565( SGUIColor* pclrIn, SGUIColor* pclrResult ) ; - -//#define COLOR_FROM_RGB( r, g, b ) - -#endif // _SAM_GUI_COLOR_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.c deleted file mode 100644 index d35dbfe35..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "sam-gui/common/sam_gui_color.h" - diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.h deleted file mode 100644 index 66ea3397d..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_colors.h +++ /dev/null @@ -1,45 +0,0 @@ -#include "sam-gui/common/sam_gui_color.h" - -#define GUICLR_WHITE 0x00ffffff -#define GUICLR_BLACK 0x00000000 - -#define GUICLR_BLUE 0x0000FF -#define GUICLR_GREEN 0x00FF00 -#define GUICLR_RED 0xFF0000 - -#define GUICLR_NAVY 0x000080 -#define GUICLR_DARKBLUE 0x00008B -#define GUICLR_DARKGREEN 0x006400 -#define GUICLR_DARKCYAN 0x008B8B -#define GUICLR_CYAN 0x00FFFF -#define GUICLR_TURQUOISE 0x40E0D0 -#define GUICLR_INDIGO 0x4B0082 -#define GUICLR_DARKRED 0x800000 -#define GUICLR_OLIVE 0x808000 -#define GUICLR_GRAY 0x808080 -#define GUICLR_SKYBLUE 0x87CEEB -#define GUICLR_BLUEVIOLET 0x8A2BE2 -#define GUICLR_LIGHTGREEN 0x90EE90 -#define GUICLR_DARKVIOLET 0x9400D3 -#define GUICLR_YELLOWGREEN 0x9ACD32 -#define GUICLR_BROWN 0xA52A2A -#define GUICLR_DARKGRAY 0xA9A9A9 -#define GUICLR_SIENNA 0xA0522D -#define GUICLR_LIGHTBLUE 0xADD8E6 -#define GUICLR_GREENYELLOW 0xADFF2F -#define GUICLR_SILVER 0xC0C0C0 -#define GUICLR_LIGHTGREY 0xD3D3D3 -#define GUICLR_LIGHTCYAN 0xE0FFFF -#define GUICLR_VIOLET 0xEE82EE -#define GUICLR_AZUR 0xF0FFFF -#define GUICLR_BEIGE 0xF5F5DC -#define GUICLR_MAGENTA 0xFF00FF -#define GUICLR_TOMATO 0xFF6347 -#define GUICLR_GOLD 0xFFD700 -#define GUICLR_ORANGE 0xFFA500 -#define GUICLR_SNOW 0xFFFAFA -#define GUICLR_YELLOW 0xFFFF00 - -#define GUICLR( r, g, b ) ((uint32_t)((r<<16)|(g<<8)|b)) - -#define GUICLR_ATMEL_BLUE GUICLR( 6, 61, 232 ) diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_errors.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_errors.h deleted file mode 100644 index f8174c156..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_errors.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _SAM_GUI_ERRORS_ -#define _SAM_GUI_ERRORS_ - -#define SAMGUI_E_OK 0x0L - -#define SAMGUI_ERRORS_COMMON_BASE 0x1L -#define SAMGUI_ERRORS_PORTING_BASE 0x1000L -#define SAMGUI_ERRORS_DISP_BASE 0x2000L -#define SAMGUI_ERRORS_WGT_BASE 0x3000L -#define SAMGUI_ERRORS_WM_BASE 0x4000L - - -/* - * Common errors - */ -#define SAMGUI_E_BAD_POINTER SAMGUI_ERRORS_COMMON_BASE -#define SAMGUI_E_BAD_PARAMETER SAMGUI_ERRORS_COMMON_BASE+1 -#define SAMGUI_E_FILE_OPEN SAMGUI_ERRORS_COMMON_BASE+2 - -/* - * Porting layer errors - */ - -/* - * DISP layer errors - */ -#define SAMGUI_E_WRONG_COMPONENT SAMGUI_ERRORS_DISP_BASE - -/* - * WGT layer errors - */ -#define SAMGUI_E_TOO_MUCH_WIDGETS SAMGUI_ERRORS_WGT_BASE -#define SAMGUI_E_MSQUEUE SAMGUI_ERRORS_WGT_BASE+1 -#define SAMGUI_E_NO_SELECTED_WIDGET SAMGUI_ERRORS_WGT_BASE+2 -#define SAMGUI_E_NOT_ENOUGH_MEMORY SAMGUI_ERRORS_WGT_BASE+3 -#define SAMGUI_E_INVALID_WIDGET SAMGUI_ERRORS_WGT_BASE+4 - -/* - * WM layer errors - */ - -#endif // _SAM_GUI_ERRORS_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_font.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_font.c deleted file mode 100644 index 92edc948b..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_font.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "sam-gui/common/sam_gui_font.h" -#include "sam-gui/common/sam_gui_errors.h" -#include - -const SGUIFont g_Font10x14= -{ - .dwType=WGT_FONT_TYPE_BITMAP, - .dwWidth=10 , - .dwHeight=14 , - .pvData=(void*)aucFont10x14 -} ; \ No newline at end of file diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_font.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_font.h deleted file mode 100644 index 7b228abae..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_font.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _SAM_GUI_FONT_ -#define _SAM_GUI_FONT_ - -#include "sam-gui/common/sam_gui_font10x14.h" - -typedef enum _WGT_FontType -{ - WGT_FONT_TYPE_BITMAP, - WGT_FONT_TYPE_VECTOR, - WGT_FONT_TYPE_MAX -} WGT_FontType ; - -typedef struct _SGUIFont -{ - WGT_FontType dwType ; - uint32_t dwWidth ; // Font width in pixels. - uint32_t dwHeight ; // Font height in pixels. - void* pvData ; -} SGUIFont ; - -extern const SGUIFont g_Font10x14 ; - -#endif // _SAM_GUI_FONT_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.c deleted file mode 100644 index d9b0df8a4..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.c +++ /dev/null @@ -1,235 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - /** - * \file - * - * Font 10x14 table definition. - * - */ - -#include "sam-gui/common/sam_gui_font10x14.h" - -/** Char set of font 10x14 */ -const uint8_t aucFont10x14[]= -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xCC, - 0xFF, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0xC0, 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, - 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0x60, 0x1E, 0x70, 0x3F, 0x30, 0x33, 0x30, 0xFF, 0xFC, - 0xFF, 0xFC, 0x33, 0x30, 0x33, 0xF0, 0x39, 0xE0, 0x18, 0xC0, - 0x60, 0x00, 0xF0, 0x0C, 0xF0, 0x3C, 0x60, 0xF0, 0x03, 0xC0, - 0x0F, 0x00, 0x3C, 0x18, 0xF0, 0x3C, 0xC0, 0x3C, 0x00, 0x18, - 0x3C, 0xF0, 0x7F, 0xF8, 0xC3, 0x1C, 0xC7, 0x8C, 0xCF, 0xCC, - 0xDC, 0xEC, 0x78, 0x78, 0x30, 0x30, 0x00, 0xFC, 0x00, 0xCC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0xEC, 0x00, - 0xF8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x3F, 0xF0, 0x78, 0x78, - 0x60, 0x18, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0x60, 0x18, - 0x78, 0x78, 0x3F, 0xF0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0x60, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x3F, 0xF8, - 0x3F, 0xF8, 0x03, 0x80, 0x07, 0xC0, 0x0E, 0xE0, 0x0C, 0x60, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x3F, 0xF0, - 0x3F, 0xF0, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x00, 0x44, 0x00, 0xEC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x00, 0x18, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0, - 0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0xC0, 0x00, 0x00, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0xFC, 0xC1, 0xCC, 0xC3, 0x8C, - 0xC7, 0x0C, 0xCE, 0x0C, 0xFC, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x70, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x0C, 0x70, 0x1C, 0xE0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, - 0xC1, 0xCC, 0xC3, 0x8C, 0xE7, 0x0C, 0x7E, 0x0C, 0x3C, 0x0C, - 0x30, 0x30, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x03, 0xC0, 0x07, 0xC0, 0x0E, 0xC0, 0x1C, 0xC0, 0x38, 0xC0, - 0x70, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xC0, 0x00, 0xC0, - 0xFC, 0x30, 0xFC, 0x38, 0xCC, 0x1C, 0xCC, 0x0C, 0xCC, 0x0C, - 0xCC, 0x0C, 0xCC, 0x0C, 0xCE, 0x1C, 0xC7, 0xF8, 0xC3, 0xF0, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE3, 0x1C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x9C, 0x71, 0xF8, 0x30, 0xF0, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC3, 0xFC, - 0xC7, 0xFC, 0xCE, 0x00, 0xDC, 0x00, 0xF8, 0x00, 0xF0, 0x00, - 0x3C, 0xF0, 0x7F, 0xF8, 0xE7, 0x9C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x3C, 0x00, 0x7E, 0x00, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x1C, - 0xC3, 0x38, 0xC3, 0x70, 0xE7, 0xE0, 0x7F, 0xC0, 0x3F, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x60, 0x3C, 0xF0, - 0x3C, 0xF0, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x44, 0x3C, 0xEC, - 0x3C, 0xF8, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, - 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0x00, 0x00, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x00, 0x00, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x38, 0x70, - 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC1, 0xEC, - 0xC3, 0xEC, 0xC3, 0x00, 0xE6, 0x00, 0x7E, 0x00, 0x3C, 0x00, - 0x30, 0xF0, 0x71, 0xF8, 0xE3, 0x9C, 0xC3, 0x0C, 0xC3, 0xFC, - 0xC3, 0xFC, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0x3F, 0xFC, 0x7F, 0xFC, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xC0, 0x7F, 0xFC, 0x3F, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x30, 0x30, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, - 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x73, 0xF8, 0x33, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x38, 0xC0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xFC, 0xFF, 0xFC, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, - 0x1C, 0xE0, 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x70, 0x00, 0x38, 0x00, 0x1F, 0x00, - 0x1F, 0x00, 0x38, 0x00, 0x70, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, - 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0xFF, 0xFC, 0xFF, 0xFC, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, - 0xC3, 0x00, 0xC3, 0x00, 0xE7, 0x00, 0x7E, 0x00, 0x3C, 0x00, - 0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0xCC, - 0xC0, 0xEC, 0xC0, 0x7C, 0xE0, 0x38, 0x7F, 0xFC, 0x3F, 0xEC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x80, 0xC3, 0x80, - 0xC3, 0xC0, 0xC3, 0xC0, 0xE7, 0x70, 0x7E, 0x3C, 0x3C, 0x1C, - 0x3C, 0x18, 0x7E, 0x1C, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, - 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x9C, 0xE1, 0xF8, 0x60, 0xF0, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFC, - 0xFF, 0xFC, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, - 0xFF, 0xC0, 0xFF, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, - 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0xFF, 0xE0, 0xFF, 0xC0, - 0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0xF8, - 0x00, 0xF8, 0x00, 0x3C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, - 0xF0, 0x3C, 0xF8, 0x7C, 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, - 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, 0xF8, 0x7C, 0xF0, 0x3C, - 0xFC, 0x00, 0xFE, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xFC, - 0x01, 0xFC, 0x03, 0x80, 0x07, 0x00, 0xFE, 0x00, 0xFC, 0x00, - 0xC0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, 0xC1, 0xCC, 0xC3, 0x8C, - 0xC7, 0x0C, 0xCE, 0x0C, 0xDC, 0x0C, 0xF8, 0x0C, 0xF0, 0x0C, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, - 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, - 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x00, - 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, 0x00, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, - 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x06, 0x78, 0x0E, 0xFC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xCC, 0x07, 0xFC, 0x03, 0xF8, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, - 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x9C, 0x01, 0xF8, 0x00, 0xF0, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, - 0x00, 0xF0, 0x01, 0xF8, 0x03, 0x9C, 0x03, 0x0C, 0x03, 0x0C, - 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, 0xFF, 0xFC, 0xFF, 0xFC, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0xDC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xDC, 0x07, 0xD8, 0x03, 0x90, - 0x00, 0x00, 0x03, 0x00, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x00, - 0xE3, 0x00, 0x70, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xDC, 0x0F, 0xF8, 0x07, 0xF0, - 0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x03, 0x80, 0x01, 0xFC, 0x00, 0xFC, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFC, - 0x1B, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x1C, 0xCF, 0xF8, 0xCF, 0xF0, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xE0, 0x01, 0xE0, - 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC, - 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0xFC, 0x0F, 0xFC, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xC0, - 0x03, 0xC0, 0x07, 0x00, 0x0E, 0x00, 0x0F, 0xFC, 0x0F, 0xFC, - 0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x00, 0x07, 0x00, 0x0E, 0x00, - 0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0xFC, 0x03, 0xFC, - 0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0xF8, 0x03, 0xF0, - 0x0F, 0xFC, 0x0F, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, - 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, - 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xFC, 0x0F, 0xFC, - 0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, - 0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x00, - 0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC, - 0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xFC, 0x0E, 0x78, 0x06, 0x30, - 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0xFF, 0xF0, 0xFF, 0xF8, - 0x0C, 0x1C, 0x0C, 0x1C, 0x0C, 0x38, 0x0C, 0x30, 0x00, 0x00, - 0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C, - 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0, - 0x0F, 0xC0, 0x0F, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, - 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x0F, 0xE0, 0x0F, 0xC0, - 0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0xF8, - 0x00, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0, - 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0xF0, 0x01, 0xE0, - 0x01, 0xE0, 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, - 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x0C, 0x03, 0x9C, 0x01, 0xF8, - 0x01, 0xF0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x0C, 0x00, - 0x0C, 0x0C, 0x0C, 0x1C, 0x0C, 0x3C, 0x0C, 0x7C, 0x0C, 0xEC, - 0x0D, 0xCC, 0x0F, 0x8C, 0x0F, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, - 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x3F, 0xF0, 0x7C, 0xF8, - 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, - 0x03, 0x0C, 0x03, 0x0C, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x0C, - 0xC3, 0x0C, 0xC0, 0x0C, 0xE0, 0x0C, 0x70, 0x0C, 0x30, 0x0C, - 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, - 0x7C, 0xF8, 0x3F, 0xF0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, - 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, - 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC -} ; - diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.h deleted file mode 100644 index 56aee6416..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_font10x14.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - /** - * \file - * - * Font 10x14 table definition. - * - */ - -#ifndef _SAMGUI_FONT_10x14_ -#define _SAMGUI_FONT_10x14_ - -//! Char set of font 10x14 -extern const uint8_t aucFont10x14[] ; - - -#endif // _SAMGUI_FONT_10x14_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_point.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_point.c deleted file mode 100644 index 0044b0c38..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_point.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "sam-gui/common/sam_gui_point.h" -#include "sam-gui/common/sam_gui_errors.h" diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_point.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_point.h deleted file mode 100644 index 1efea63dc..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_point.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _SAM_GUI_POINT_ -#define _SAM_GUI_POINT_ - -typedef struct _SGUIPoint -{ - uint32_t dwX ; - uint32_t dwY ; -} SGUIPoint ; - -#endif // _SAM_GUI_POINT_ diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_size.c b/src/ersky9x/libraries/sam-gui/common/sam_gui_size.c deleted file mode 100644 index 0d0784e0f..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_size.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "sam-gui/common/sam_gui_size.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/common/sam_gui_point.h" diff --git a/src/ersky9x/libraries/sam-gui/common/sam_gui_size.h b/src/ersky9x/libraries/sam-gui/common/sam_gui_size.h deleted file mode 100644 index 20c5ad0ba..000000000 --- a/src/ersky9x/libraries/sam-gui/common/sam_gui_size.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _SAM_GUI_SIZE_ -#define _SAM_GUI_SIZE_ - -#include "common/sam_gui_point.h" - -typedef struct _SGUISize -{ - uint32_t dwWidth ; - uint32_t dwHeight ; -} SGUISize ; - -#endif // _SAM_GUI_SIZE_ diff --git a/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.c b/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.c deleted file mode 100644 index 76f8348db..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.c +++ /dev/null @@ -1,411 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// HX8347 driver -/// -/// !Usage -/// -/// Explanation on the usage of the code made available through the header file. -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include - -#include "disp/backends/HX8347/backend_HX8347.h" - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ -typedef volatile unsigned short REG16; - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -/// LCD index register address -#define HX8347_IR(baseAddr) (*((REG16 *)(baseAddr))) -/// LCD status register address -#define HX8347_SR(baseAddr) (*((REG16 *)(baseAddr))) -/// LCD data address -#define HX8347_D(baseAddr) (*((REG16 *)((unsigned int)(baseAddr) + BOARD_LCD_RS))) - -/// HX8347 ID code -#define HX8347_HIMAXID_CODE 0x47 - -/// HX8347 LCD Registers -#define HX8347_R00H 0x00 -#define HX8347_R01H 0x01 -#define HX8347_R02H 0x02 -#define HX8347_R03H 0x03 -#define HX8347_R04H 0x04 -#define HX8347_R05H 0x05 -#define HX8347_R06H 0x06 -#define HX8347_R07H 0x07 -#define HX8347_R08H 0x08 -#define HX8347_R09H 0x09 -#define HX8347_R0AH 0x0A -#define HX8347_R0CH 0x0C -#define HX8347_R0DH 0x0D -#define HX8347_R0EH 0x0E -#define HX8347_R0FH 0x0F -#define HX8347_R10H 0x10 -#define HX8347_R11H 0x11 -#define HX8347_R12H 0x12 -#define HX8347_R13H 0x13 -#define HX8347_R14H 0x14 -#define HX8347_R15H 0x15 -#define HX8347_R16H 0x16 -#define HX8347_R18H 0x18 -#define HX8347_R19H 0x19 -#define HX8347_R1AH 0x1A -#define HX8347_R1BH 0x1B -#define HX8347_R1CH 0x1C -#define HX8347_R1DH 0x1D -#define HX8347_R1EH 0x1E -#define HX8347_R1FH 0x1F -#define HX8347_R20H 0x20 -#define HX8347_R21H 0x21 -#define HX8347_R22H 0x22 -#define HX8347_R23H 0x23 -#define HX8347_R24H 0x24 -#define HX8347_R25H 0x25 -#define HX8347_R26H 0x26 -#define HX8347_R27H 0x27 -#define HX8347_R28H 0x28 -#define HX8347_R29H 0x29 -#define HX8347_R2AH 0x2A -#define HX8347_R2BH 0x2B -#define HX8347_R2CH 0x2C -#define HX8347_R2DH 0x2D -#define HX8347_R35H 0x35 -#define HX8347_R36H 0x36 -#define HX8347_R37H 0x37 -#define HX8347_R38H 0x38 -#define HX8347_R39H 0x39 -#define HX8347_R3AH 0x3A -#define HX8347_R3BH 0x3B -#define HX8347_R3CH 0x3C -#define HX8347_R3DH 0x3D -#define HX8347_R3EH 0x3E -#define HX8347_R40H 0x40 -#define HX8347_R41H 0x41 -#define HX8347_R42H 0x42 -#define HX8347_R43H 0x43 -#define HX8347_R44H 0x44 -#define HX8347_R45H 0x45 -#define HX8347_R46H 0x46 -#define HX8347_R47H 0x47 -#define HX8347_R48H 0x48 -#define HX8347_R49H 0x49 -#define HX8347_R4AH 0x4A -#define HX8347_R4BH 0x4B -#define HX8347_R4CH 0x4C -#define HX8347_R4DH 0x4D -#define HX8347_R4EH 0x4E -#define HX8347_R4FH 0x4F -#define HX8347_R50H 0x50 -#define HX8347_R51H 0x51 -#define HX8347_R64H 0x64 -#define HX8347_R65H 0x65 -#define HX8347_R66H 0x66 -#define HX8347_R67H 0x67 -#define HX8347_R70H 0x70 -#define HX8347_R72H 0x72 -#define HX8347_R90H 0x90 -#define HX8347_R91H 0x91 -#define HX8347_R93H 0x93 -#define HX8347_R94H 0x94 -#define HX8347_R95H 0x95 - -//------------------------------------------------------------------------------ -// External functions -//------------------------------------------------------------------------------ -// External delay 1 ms function -extern void DelayMS(unsigned int ms); -#define Delay(ms) DelayMS(ms) - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Write data to LCD Register. -/// \param pLcdBase LCD base address. -/// \param reg Register address. -/// \param data Data to be written. -//------------------------------------------------------------------------------ -static void _HX8347_WriteReg(void *pLcdBase, unsigned char reg, unsigned short data) -{ - HX8347_IR(pLcdBase) = reg; - HX8347_D(pLcdBase) = data; -} - -//------------------------------------------------------------------------------ -/// Read data from LCD Register. -/// \param pLcdBase LCD base address. -/// \param reg Register address. -/// \return data Data to be read. -//------------------------------------------------------------------------------ -static unsigned short _HX8347_ReadReg(void *pLcdBase, unsigned char reg) -{ - HX8347_IR(pLcdBase) = reg; - return HX8347_D(pLcdBase); -} - -//------------------------------------------------------------------------------ -/// Read LCD status Register. -/// \param pLcdBase LCD base address. -/// \param reg Register address. -/// \return data Status Data. -//------------------------------------------------------------------------------ -static unsigned short _HX8347_ReadStatus(void *pLcdBase) -{ - return HX8347_SR(pLcdBase); -} - -//------------------------------------------------------------------------------ -/// Prepare to write GRAM data. -/// \param pLcdBase LCD base address. -//------------------------------------------------------------------------------ -static void _HX8347_WriteRAM_Prepare(void *pLcdBase) -{ - HX8347_IR(pLcdBase) = HX8347_R22H; -} - -//------------------------------------------------------------------------------ -/// Write data to LCD GRAM. -/// \param pLcdBase LCD base address. -/// \param color 16-bits RGB color. -//------------------------------------------------------------------------------ -static void _HX8347_WriteRAM(void *pLcdBase, unsigned short color) -{ - // Write 16-bit GRAM Reg - HX8347_D(pLcdBase) = color; -} - -//------------------------------------------------------------------------------ -/// Prepare to read GRAM data. -/// \param pLcdBase LCD base address. -//------------------------------------------------------------------------------ -static void _HX8347_ReadRAM_Prepare(void *pLcdBase) -{ - HX8347_IR(pLcdBase) = HX8347_R22H; -} - -//------------------------------------------------------------------------------ -/// Read GRAM data. -/// \param pLcdBase LCD base address. -/// \return 16-bits RGB color. -//------------------------------------------------------------------------------ -static unsigned short _HX8347_ReadRAM(void *pLcdBase) -{ - // Read 16-bit GRAM Reg - return HX8347_D(pLcdBase); -} - -//------------------------------------------------------------------------------ -/// Initialize the LCD controller. -/// \param pLcdBase LCD base address. -//------------------------------------------------------------------------------ -static void _HX8347_Initialize(void *pLcdBase) -{ - unsigned short chipid; - - // Check HX8347 chipid - chipid = _HX8347_ReadReg(pLcdBase, HX8347_R67H); - if(chipid != HX8347_HIMAXID_CODE) { - - printf("Read HX8347 chip ID error, skip initialization.\r\n"); - return ; - } - - // Start internal OSC - _HX8347_WriteReg(pLcdBase, HX8347_R19H, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz - _HX8347_WriteReg(pLcdBase, HX8347_R93H, 0x0C); // RADJ=1100 - - // Power on flow - _HX8347_WriteReg(pLcdBase, HX8347_R44H, 0x4D); // VCM=100 1101 - _HX8347_WriteReg(pLcdBase, HX8347_R45H, 0x11); // VDV=1 0001 - _HX8347_WriteReg(pLcdBase, HX8347_R20H, 0x40); // BT=0100 - _HX8347_WriteReg(pLcdBase, HX8347_R1DH, 0x07); // VC1=111 - _HX8347_WriteReg(pLcdBase, HX8347_R1EH, 0x00); // VC3=000 - _HX8347_WriteReg(pLcdBase, HX8347_R1FH, 0x04); // VRH=0100 - - _HX8347_WriteReg(pLcdBase, HX8347_R1CH, 0x04); // AP=100 - _HX8347_WriteReg(pLcdBase, HX8347_R1BH, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 - Delay(50); - - _HX8347_WriteReg(pLcdBase, HX8347_R43H, 0x80); // Set VCOMG=1 - Delay(50); - - // Gamma for CMO 2.8 - _HX8347_WriteReg(pLcdBase, HX8347_R46H, 0x95); - _HX8347_WriteReg(pLcdBase, HX8347_R47H, 0x51); - _HX8347_WriteReg(pLcdBase, HX8347_R48H, 0x00); - _HX8347_WriteReg(pLcdBase, HX8347_R49H, 0x36); - _HX8347_WriteReg(pLcdBase, HX8347_R4AH, 0x11); - _HX8347_WriteReg(pLcdBase, HX8347_R4BH, 0x66); - _HX8347_WriteReg(pLcdBase, HX8347_R4CH, 0x14); - _HX8347_WriteReg(pLcdBase, HX8347_R4DH, 0x77); - _HX8347_WriteReg(pLcdBase, HX8347_R4EH, 0x13); - _HX8347_WriteReg(pLcdBase, HX8347_R4FH, 0x4C); - _HX8347_WriteReg(pLcdBase, HX8347_R50H, 0x46); - _HX8347_WriteReg(pLcdBase, HX8347_R51H, 0x46); - - //240x320 window setting - _HX8347_WriteReg(pLcdBase, HX8347_R02H, 0x00); // Column address start2 - _HX8347_WriteReg(pLcdBase, HX8347_R03H, 0x00); // Column address start1 - _HX8347_WriteReg(pLcdBase, HX8347_R04H, 0x00); // Column address end2 - _HX8347_WriteReg(pLcdBase, HX8347_R05H, 0xEF); // Column address end1 - _HX8347_WriteReg(pLcdBase, HX8347_R06H, 0x00); // Row address start2 - _HX8347_WriteReg(pLcdBase, HX8347_R07H, 0x00); // Row address start1 - _HX8347_WriteReg(pLcdBase, HX8347_R08H, 0x01); // Row address end2 - _HX8347_WriteReg(pLcdBase, HX8347_R09H, 0x3F); // Row address end1 - - // Display Setting - _HX8347_WriteReg(pLcdBase, HX8347_R01H, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 - _HX8347_WriteReg(pLcdBase, HX8347_R16H, 0xC8); // MY=1, MX=1, MV=0, BGR=1 - _HX8347_WriteReg(pLcdBase, HX8347_R23H, 0x95); // N_DC=1001 0101 - _HX8347_WriteReg(pLcdBase, HX8347_R24H, 0x95); // P_DC=1001 0101 - _HX8347_WriteReg(pLcdBase, HX8347_R25H, 0xFF); // I_DC=1111 1111 - _HX8347_WriteReg(pLcdBase, HX8347_R27H, 0x06); // N_BP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R28H, 0x06); // N_FP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R29H, 0x06); // P_BP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R2AH, 0x06); // P_FP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R2CH, 0x06); // I_BP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R2DH, 0x06); // I_FP=0000 0110 - _HX8347_WriteReg(pLcdBase, HX8347_R3AH, 0x01); // N_RTN=0000, N_NW=001 - _HX8347_WriteReg(pLcdBase, HX8347_R3BH, 0x01); // P_RTN=0000, P_NW=001 - _HX8347_WriteReg(pLcdBase, HX8347_R3CH, 0xF0); // I_RTN=1111, I_NW=000 - _HX8347_WriteReg(pLcdBase, HX8347_R3DH, 0x00); // DIV=00 - _HX8347_WriteReg(pLcdBase, HX8347_R3EH, 0x38); // SON=38h - _HX8347_WriteReg(pLcdBase, HX8347_R40H, 0x0F); // GDON=0Fh - _HX8347_WriteReg(pLcdBase, HX8347_R41H, 0xF0); // GDOF=F0h -} - -//------------------------------------------------------------------------------ -/// Turn on the LCD. -/// \param pLcdBase LCD base address. -//------------------------------------------------------------------------------ -static void _HX8347_On( void *pLcdBase ) -{ - // Display ON Setting - _HX8347_WriteReg(pLcdBase, HX8347_R90H, 0x7F); // SAP=0111 1111 - _HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x04); // GON=0, DTE=0, D=01 - Delay(100); - _HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x24); // GON=1, DTE=0, D=01 - _HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x2C); // GON=1, DTE=0, D=11 - Delay(100); - _HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x3C); // GON=1, DTE=1, D=11 -} - -//------------------------------------------------------------------------------ -/// Turn off the LCD. -/// \param pLcdBase LCD base address. -//------------------------------------------------------------------------------ -static void _HX8347_Off( void *pLcdBase ) -{ - _HX8347_WriteReg(pLcdBase, HX8347_R90H, 0x00); // SAP=0000 0000 - _HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x00); // GON=0, DTE=0, D=00 -} - -//------------------------------------------------------------------------------ -/// Set cursor of LCD srceen. -/// \param pLcdBase LCD base address. -/// \param x X-coordinate of upper-left corner on LCD. -/// \param y Y-coordinate of upper-left corner on LCD. -//------------------------------------------------------------------------------ -static void _HX8347_SetCursor(void *pLcdBase, unsigned short x, unsigned short y) -{ - unsigned char x1, x2, y1, y2; - - x1 = x & 0xff; - x2 = (x & 0xff00) >>8; - y1 = y & 0xff; - y2 = (y & 0xff00) >>8; - _HX8347_WriteReg(pLcdBase, HX8347_R02H, x2); // column high - _HX8347_WriteReg(pLcdBase, HX8347_R03H, x1); // column low - _HX8347_WriteReg(pLcdBase, HX8347_R06H, y2); // row high - _HX8347_WriteReg(pLcdBase, HX8347_R07H, y1); // row low -} - -//------------------------------------------------------------------------------ -/// Set the window size user can access. -/// \param pLcdBase LCD base address. -/// \param x_start X-coordinate of upper-left corner on LCD. -/// \param y_start Y-coordinate of upper-left corner on LCD. -/// \param x_end X-coordinate of bottom-right corner on LCD. -/// \param y_end Y-coordinate of bottom-right corner on LCD. -//------------------------------------------------------------------------------ -static void _HX8347_SetWindow(void *pLcdBase,unsigned short x_start, unsigned short y_start,unsigned short x_end, unsigned short y_end) -{ - unsigned char x1, x2, y1, y2; - - x1 = x_start & 0xff; - x2 = (x_start & 0xff00) >>8; - y1 = y_start & 0xff; - y2 = (y_start & 0xff00) >>8; - _HX8347_WriteReg(pLcdBase, 0x02, x2); // column high - _HX8347_WriteReg(pLcdBase, 0x03, x1); // column low - _HX8347_WriteReg(pLcdBase, 0x06, y2); // row high - _HX8347_WriteReg(pLcdBase, 0x07, y1); // row low - - x1 = x_end & 0xff; - x2 = (x_end & 0xff00) >>8; - y1 = y_end & 0xff; - y2 = (y_end & 0xff00) >>8; - _HX8347_WriteReg(pLcdBase, 0x04, x2); // column high - _HX8347_WriteReg(pLcdBase, 0x05, x1); // column low - _HX8347_WriteReg(pLcdBase, 0x08, y2); // row high - _HX8347_WriteReg(pLcdBase, 0x09, y1); // row low -} - -SDISPBackend sDISP_Backend_HX8347= -{ - .sData={ 0 }, - -// .Reset=_DBE_HX8347_Reset, -// .Initialize=_DBE_HX8347_Initialize, -// .GetPixel=_DBE_HX8347_GetPixel, -// .SetPixel=_DBE_HX8347_SetPixel, -// .DrawLine=_DBE_HX8347_DrawLine, -// .DrawCircle=_DBE_HX8347_DrawCircle, -// .DrawFilledCircle=_DBE_HX8347_DrawFilledCircle, -// .DrawRectangle=_DBE_HX8347_DrawRectangle, -// .DrawFilledRectangle=_DBE_HX8347_DrawFilledRectangle, -// .DrawBitmap=_DBE_HX8347_DrawBitmap, -// .IOCtl=_DBE_HX8347_IOCtl -} ; diff --git a/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.h b/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.h deleted file mode 100644 index 46ba01870..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/backends/HX8347/backend_HX8347.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definition of methods for HX8347 driver. -/// -/// !!!Usage -/// -/// -# LCD_WriteReg -/// -# LCD_ReadReg -/// -# LCD_ReadStatus -/// -# LCD_DumpReg -/// -# LCD_WriteRAM_Prepare -/// -# LCD_WriteRAM -/// -# LCD_ReadRAM_Prepare -/// -# LCD_ReadRAM -/// -# LCD_Initialize -/// -# LCD_SetCursor -/// -# LCD_On -/// -# LCD_Off -//------------------------------------------------------------------------------ - -#ifndef HX8347_H -#define HX8347_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include "disp/disp_backend.h" - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -/// Convert 24-bits color to 16-bits color -#define RGB24ToRGB16(color) (((color >> 8) & 0xF800) | \ - ((color >> 5) & 0x7E0) | \ - ((color >> 3) & 0x1F)) - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -//void LCD_WriteReg(void *pLcdBase, unsigned char reg, unsigned short data); -//unsigned short LCD_ReadReg(void *pLcdBase, unsigned char reg); -//unsigned short LCD_ReadStatus(void *pLcdBase); -//void LCD_DumpReg(void *pLcdBase, unsigned char startAddr, unsigned char endAddr); -//void LCD_WriteRAM_Prepare(void *pLcdBase); -//void LCD_WriteRAM(void *pLcdBase, unsigned short color); -//void LCD_ReadRAM_Prepare(void *pLcdBase); -//unsigned short LCD_ReadRAM(void *pLcdBase); -//void LCD_Initialize(void *pLcdBase); -//void LCD_SetCursor(void *pLcdBase, unsigned short x, unsigned short y); -//void LCD_On(void *pLcdBase); -//void LCD_Off(void *pLcdBase); -//void LCD_SetWindow(void *pLcdBase,unsigned short x_start, unsigned short y_start,unsigned short x_end, unsigned short y_end); - -extern SDISPBackend sDISP_Backend_HX8347 ; - -#endif //#ifndef HX8347_H diff --git a/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.c b/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.c deleted file mode 100644 index f5c8972ad..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.c +++ /dev/null @@ -1,1620 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Implementation of ILI9325 driver. - * - */ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include -#include - -#include "disp/backends/ILI9325/backend_ILI9325.h" -#include "porting/sam_gui_porting.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/common/sam_gui_font10x14.h" -#include "sam-gui/file/file_fs.h" -#include "drivers/utility/bmp.h" - -#include "drivers/pio/pio.h" -#include "drivers/pmc/pmc.h" -#include "drivers/utility/bmp.h" - -//#include "components/ILI9325/ili9325.h" - -/*---------------------------------------------------------------------------- - * Types - *----------------------------------------------------------------------------*/ -//------------------------------------------------------------------------------ -// Exported types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -// BMP (Windows) Header Format -struct _SBMPHeader -{ - uint16_t wType ; // signature, must be 4D42 hex - uint32_t dwFileSize ; // size of BMP file in bytes (unreliable) - uint16_t wReserved1 ; // reserved, must be zero - uint16_t wReserved2 ; // reserved, must be zero - uint32_t dwOffset ; // offset to start of image data in bytes - uint32_t dwHeaderSize ; // size of BITMAPINFOHEADER structure, must be 40 - uint32_t dwWidth ; // image width in pixels - uint32_t dwHeight ; // image height in pixels - uint16_t wPlanes ; // number of planes in the image, must be 1 - uint16_t wBits ; // number of bits per pixel (1, 4, 8, 16, 24, 32) - uint32_t dwCompression ; // compression type (0=none, 1=RLE-8, 2=RLE-4) - uint32_t dwImageSize ; // size of image data in bytes (including padding) - uint32_t dwHResolution ; // horizontal resolution in pixels per meter (unreliable) - uint32_t dwVResolution ; // vertical resolution in pixels per meter (unreliable) - uint32_t dwColours ; // number of colors in image, or zero - uint32_t dwImportantcolours ; // number of important colors, or zero -} __attribute__ ((packed)); // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -typedef struct _SBMPHeader SBMPHeader ; - -typedef volatile uint8_t vByte ; - -/*---------------------------------------------------------------------------- - * Macros - *----------------------------------------------------------------------------*/ - -/** LCD index register address */ -#define ILI9325_IR (*((vByte *)(BOARD_LCD_BASE))) -/** LCD status register address */ -#define ILI9325_SR (*((vByte *)(BOARD_LCD_BASE))) -/** LCD data address */ -#define ILI9325_D (*((vByte *)((uint32_t)(BOARD_LCD_BASE) + BOARD_LCD_RS))) - -#define ILI9325_WIDTH 240 -#define ILI9325_HEIGTH 320 - -//#define ILI9325_BGR_MODE -#define ILI9325_RGB_MODE - -/*---------------------------------------------------------------------------- - * Definitions - *----------------------------------------------------------------------------*/ - -/* ILI9325 ID code */ -#define ILI9325_DEVICE_CODE 0x9325 - -/* ILI9325 LCD Registers */ -#define ILI9325_R00H 0x00 /* Driver Code Read */ -#define ILI9325_R01H 0x01 /* Driver Output Control 1 */ -#define ILI9325_R02H 0x02 /* LCD Driving Control */ -#define ILI9325_R03H 0x03 /* Entry Mode */ -#define ILI9325_R04H 0x04 /* Resize Control */ -#define ILI9325_R07H 0x07 /* Display Control 1 */ -#define ILI9325_R08H 0x08 /* Display Control 2 */ -#define ILI9325_R09H 0x09 /* Display Control 3 */ -#define ILI9325_R0AH 0x0A /* Display Control 4 */ -#define ILI9325_R0CH 0x0C /* RGB Display Interface Control 1 */ -#define ILI9325_R0DH 0x0D /* Frame Maker Position */ -#define ILI9325_R0FH 0x0F /* RGB Display Interface Control 2 */ - -#define ILI9325_R10H 0x10 /* Power Control 1 */ -#define ILI9325_R11H 0x11 /* Power Control 2 */ -#define ILI9325_R12H 0x12 /* Power Control 3 */ -#define ILI9325_R13H 0x13 /* Power Control 4 */ - -#define ILI9325_R20H 0x20 /* Horizontal GRAM Address Set */ -#define ILI9325_R21H 0x21 /* Vertical GRAM Address Set */ -#define ILI9325_R22H 0x22 /* Write Data to GRAM */ -#define ILI9325_R29H 0x29 /* Power Control 7 */ -#define ILI9325_R2BH 0x2B /* Frame Rate and Color Control */ - -#define ILI9325_R30H 0x30 /* Gamma Control 1 */ -#define ILI9325_R31H 0x31 /* Gamma Control 2 */ -#define ILI9325_R32H 0x32 /* Gamma Control 3 */ -#define ILI9325_R35H 0x35 /* Gamma Control 4 */ -#define ILI9325_R36H 0x36 /* Gamma Control 5 */ -#define ILI9325_R37H 0x37 /* Gamma Control 6 */ -#define ILI9325_R38H 0x38 /* Gamma Control 7 */ -#define ILI9325_R39H 0x39 /* Gamma Control 8 */ -#define ILI9325_R3CH 0x3C /* Gamma Control 9 */ -#define ILI9325_R3DH 0x3D /* Gamma Control 10 */ - -#define ILI9325_R50H 0x50 /* Horizontal Address Start Position */ -#define ILI9325_R51H 0x51 /* Horizontal Address End Position */ -#define ILI9325_R52H 0x52 /* Vertical Address Start Position */ -#define ILI9325_R53H 0x53 /* Vertical Address End Position */ - -#define ILI9325_R60H 0x60 /* Driver Output Control 2 */ -#define ILI9325_R61H 0x61 /* Base Image Display Control */ -#define ILI9325_R6AH 0x6A /* Vertical Scroll Control */ - -#define ILI9325_R80H 0x80 /* Partial Image 1 Display Position */ -#define ILI9325_R81H 0x81 /* Partial Image 1 Area (Start Line) */ -#define ILI9325_R82H 0x82 /* Partial Image 1 Area (End Line) */ -#define ILI9325_R83H 0x83 /* Partial Image 2 Display Position */ -#define ILI9325_R84H 0x84 /* Partial Image 2 Area (Start Line) */ -#define ILI9325_R85H 0x85 /* Partial Image 2 Area (End Line) */ - -#define ILI9325_R90H 0x90 /* Panel Interface Control 1 */ -#define ILI9325_R92H 0x92 /* Panel Interface Control 2 */ -#define ILI9325_R95H 0x95 /* Panel Interface Control 4 */ - -#define ILI9325_RA1H 0xA1 /* OTP VCM Programming Control */ -#define ILI9325_RA2H 0xA2 /* OTP VCM Status and Enable */ -#define ILI9325_RA5H 0xA5 /* OTP Programming ID Key */ - -#define TS_INS_START_OSC 0x00 //data read at this instruction should be 0x0789 --> use for test connection -#define TS_INS_DRIV_OUT_CTRL 0x01 -#define TS_INS_DRIV_WAV_CTRL 0x02 -#define TS_INS_ENTRY_MOD 0x03 -#define TS_INS_RESIZE_CTRL 0x04 -#define TS_INS_DISP_CTRL1 0x07 -#define TS_INS_DISP_CTRL2 0x08 -#define TS_INS_DISP_CTRL3 0x09 -#define TS_INS_DISP_CTRL4 0x0A -#define TS_INS_RGB_DISP_IF_CTRL1 0x0C -#define TS_INS_FRM_MARKER_POS 0x0D -#define TS_INS_RGB_DISP_IF_CTRL2 0x0F -#define TS_INS_POW_CTRL1 0x10 -#define TS_INS_POW_CTRL2 0x11 -#define TS_INS_POW_CTRL3 0x12 -#define TS_INS_POW_CTRL4 0x13 -#define TS_INS_GRAM_HOR_AD 0x20 -#define TS_INS_GRAM_VER_AD 0x21 -#define TS_INS_RW_GRAM 0x22 -#define TS_INS_POW_CTRL7 0x29 -#define TS_INS_FRM_RATE_COL_CTRL 0x2B -#define TS_INS_GAMMA_CTRL1 0x30 -#define TS_INS_GAMMA_CTRL2 0x31 -#define TS_INS_GAMMA_CTRL3 0x32 -#define TS_INS_GAMMA_CTRL4 0x35 -#define TS_INS_GAMMA_CTRL5 0x36 -#define TS_INS_GAMMA_CTRL6 0x37 -#define TS_INS_GAMMA_CTRL7 0x38 -#define TS_INS_GAMMA_CTRL8 0x39 -#define TS_INS_GAMMA_CTRL9 0x3C -#define TS_INS_GAMMA_CTRL10 0x3D -#define TS_INS_HOR_START_AD 0x50 -#define TS_INS_HOR_END_AD 0x51 -#define TS_INS_VER_START_AD 0x52 -#define TS_INS_VER_END_AD 0x53 -#define TS_INS_GATE_SCAN_CTRL1 0x60 -#define TS_INS_GATE_SCAN_CTRL2 0x61 -#define TS_INS_GATE_SCAN_CTRL3 0x6A -#define TS_INS_PART_IMG1_DISP_POS 0x80 -#define TS_INS_PART_IMG1_START_AD 0x81 -#define TS_INS_PART_IMG1_END_AD 0x82 -#define TS_INS_PART_IMG2_DISP_POS 0x83 -#define TS_INS_PART_IMG2_START_AD 0x84 -#define TS_INS_PART_IMG2_END_AD 0x85 -#define TS_INS_PANEL_IF_CTRL1 0x90 -#define TS_INS_PANEL_IF_CTRL2 0x92 -#define TS_INS_PANEL_IF_CTRL3 0x93 -#define TS_INS_PANEL_IF_CTRL4 0x95 -#define TS_INS_PANEL_IF_CTRL5 0x97 -#define TS_INS_PANEL_IF_CTRL6 0x98 - -//touch screen LCD configuration -#define TS_ORN_PORTRAIT - -#ifdef TS_ORN_PORTRAIT -# define TS_SIZE_X 240 -# define TS_SIZE_Y 320 -# define TS_VAL_ENTRY_MOD 0x0030 -# define TS_INS_GRAM_ADX TS_INS_GRAM_HOR_AD -# define TS_INS_GRAM_ADY TS_INS_GRAM_VER_AD -# define TS_INS_START_ADX TS_INS_HOR_START_AD -# define TS_INS_END_ADX TS_INS_HOR_END_AD -# define TS_INS_START_ADY TS_INS_VER_START_AD -# define TS_INS_END_ADY TS_INS_VER_END_AD -#else -# define TS_SIZE_X 320 -# define TS_SIZE_Y 240 -# define TS_VAL_ENTRY_MOD 0x0028 -# define TS_INS_GRAM_ADX TS_INS_GRAM_VER_AD -# define TS_INS_GRAM_ADY TS_INS_GRAM_HOR_AD -# define TS_INS_START_ADX TS_INS_VER_START_AD -# define TS_INS_END_ADX TS_INS_VER_END_AD -# define TS_INS_START_ADY TS_INS_HOR_START_AD -# define TS_INS_END_ADY TS_INS_HOR_END_AD -#endif - -/*---------------------------------------------------------------------------- - * Statics - *----------------------------------------------------------------------------*/ - -// static buffer for file operations -static uint8_t _DBE_ILI9325_aucFileData[1024*2] ; - -static uint32_t _DBE_ILI9325_DrawBitmap( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) ; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -/** - * \brief Write data to LCD Register. - * - * \param reg Register address. - * \param data Data to be written. - */ -static void _DBE_ILI9325_WriteReg( uint8_t ucReg, uint16_t wData ) -{ - ILI9325_IR = 0 ; - ILI9325_IR = ucReg ; - ILI9325_D = (wData >> 8) & 0xFF ; - ILI9325_D = wData & 0xFF ; -} - -/** - * \brief Read data from LCD Register. - * - * \param reg Register address. - * - * \return Readed data. - */ -static uint16_t _DBE_ILI9325_ReadReg( uint8_t ucReg ) -{ - uint16_t wValue ; - - ILI9325_IR = 0 ; - ILI9325_IR = ucReg ; - - wValue = ILI9325_D ; - wValue = (wValue << 8) | ILI9325_D ; - - return wValue ; -} - -/** - * \brief Read LCD status Register. - * - * \return status data. - */ -static uint16_t _DBE_ILI9325_ReadStatus( void ) -{ - return ILI9325_SR ; -} - -/** - * \brief Prepare to access GRAM data. - */ -static inline void _DBE_ILI9325_RAMAccess_Prepare( void ) -{ - ILI9325_IR=0 ; - ILI9325_IR=ILI9325_R22H ; -} - -/** - * \brief Write data to LCD GRAM. - * - * \param color 24-bits RGB color. - */ -static void _DBE_ILI9325_WriteRAM( uint32_t dwColor ) -{ -#ifdef ILI9325_BGR_MODE - ILI9325_D = (dwColor & 0xff) ; - ILI9325_D = ((dwColor >> 8) & 0xff) ; - ILI9325_D = ((dwColor >> 16) & 0xff) ; -#endif // ILI9325_BGR_MODE - -#ifdef ILI9325_RGB_MODE - ILI9325_D = ((dwColor >> 16) & 0xff) ; - ILI9325_D = ((dwColor >> 8) & 0xff) ; - ILI9325_D = (dwColor & 0xff) ; -#endif // ILI9325_RGB_MODE -} - -/** - * \brief Read data to LCD GRAM. - * - * \note Because pixel data LCD GRAM is 18-bits, so convertion to RGB 24-bits - * will cause low color bit lose. - * - * \return color 24-bits RGB color. - */ -static uint32_t _DBE_ILI9325_ReadRAM( SGUIColor* pclrResult ) -{ - uint8_t ucValue ; - - ucValue=ILI9325_D ; // dummy read - ucValue=ILI9325_D ; // dummy read - ucValue=ILI9325_D ; // data upper byte - pclrResult->u.RGBA.ucR=ucValue & 0xf8 ; - pclrResult->u.RGBA.ucG=(ucValue & 0x07) << 13 ; - - ucValue=ILI9325_D ; // data lower byte - pclrResult->u.RGBA.ucG|=(ucValue & 0xe0) << 5 ; - pclrResult->u.RGBA.ucB=(ucValue & 0x1f) << 19 ; - - return SAMGUI_E_OK ; -} - -/** - * \brief Set cursor of LCD srceen. - * - * \param x X-coordinate of upper-left corner on LCD. - * \param y Y-coordinate of upper-left corner on LCD. - */ -static inline void _DBE_ILI9325_SetCursor( uint16_t wX, uint16_t wY ) -{ - _DBE_ILI9325_WriteReg( TS_INS_GRAM_HOR_AD, wX ) ; // column - _DBE_ILI9325_WriteReg( TS_INS_GRAM_VER_AD, wY ) ; // row -} - -/** - * \brief Turn on the LCD. - */ -static inline void _DBE_ILI9325_LCD_On( void ) -{ - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x133 ) ; -} - -/** - * \brief Turn off the LCD. - */ -static inline void _DBE_ILI9325_LCD_Off( void ) -{ - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x00 ) ; -} - -static uint32_t _DBE_ILI9325_Reset( void ) -{ - return SAMGUI_E_OK ; -} - -/** - * \brief Set the backlight of the LCD. - * - * \param level Backlight brightness level [1..16], 1 means maximum brightness. - */ -static void _DBE_ILI9325_SetBacklight( uint32_t dwLevel ) -{ - uint32_t i ; - const Pin pPins[]={ BOARD_BACKLIGHT_PIN } ; - - printf( "_DBE_ILI9325_SetBacklight - %u\r\n", dwLevel ) ; - - // Ensure valid level - if ( dwLevel < 1 ) - { - dwLevel=1 ; - } - else - { - if ( dwLevel > 16 ) - { - dwLevel=16 ; - } - } - - // Switch off backlight - PIO_Clear( pPins ) ; - vTaskDelay( 2/portTICK_RATE_MS ) ; - - // Set new backlight level - for ( i=17 ; i > dwLevel ; i-- ) - { - PIO_Clear( pPins ) ; - PIO_Clear( pPins ) ; - PIO_Clear( pPins ) ; - - PIO_Set( pPins ) ; - PIO_Set( pPins ) ; - PIO_Set( pPins ) ; - } -} - -static void _DBE_ILI9325_SetOrientation( uint32_t dwOrientation ) -{ -//DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT -//DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE -} - -static inline void _DBE_ILI9325_SetBGRMode( void ) -{ - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; /* set GRAM write direction and BGR=1. */ -} - -static inline void _DBE_ILI9325_SetRGBMode( void ) -{ - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xD030 ) ; /* set GRAM write direction and BGR=1. */ -} - -static void _DBE_ILI9325_SetWindow( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight ) -{ - /* Set Horizontal Address Start Position */ - _DBE_ILI9325_WriteReg( ILI9325_R50H, (uint16_t)dwX ) ; - - /* Set Horizontal Address End Position */ - _DBE_ILI9325_WriteReg( ILI9325_R51H, (uint16_t)dwX+dwWidth-1 ) ; - - /* Set Vertical Address Start Position */ - _DBE_ILI9325_WriteReg( ILI9325_R52H, (uint16_t)dwY ) ; - - /* Set Vertical Address End Position */ - _DBE_ILI9325_WriteReg( ILI9325_R53H, (uint16_t)dwY+dwHeight-1 ) ; -} - -/** - * \brief Initialize the LCD controller. - */ -static uint32_t _DBE_ILI9325_Initialize( void ) -{ - const Pin pPins[]={ BOARD_LCD_PINS, BOARD_BACKLIGHT_PIN } ; - Smc *pSmc=SMC ; - uint16_t wChipID ; - - // Enable pins - PIO_Configure( pPins, PIO_LISTSIZE( pPins ) ) ; - - // Enable peripheral clock - PMC_EnablePeripheral( ID_SMC ) ; - - // EBI SMC Configuration - pSmc->SMC_CS_NUMBER[1].SMC_SETUP = 0 - | ((2 << 0) & SMC_SETUP1_NWE_SETUP) - | ((2 << 8) & SMC_SETUP1_NCS_WR_SETUP) - | ((2 << 16) & SMC_SETUP1_NRD_SETUP) - | ((2 << 24) & SMC_SETUP1_NCS_RD_SETUP) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_PULSE = 0 - | ((4 << 0) & SMC_PULSE1_NWE_PULSE) - | ((4 << 8) & SMC_PULSE1_NCS_WR_PULSE) - | ((10 << 16) & SMC_PULSE1_NRD_PULSE) - | ((10 << 24) & SMC_PULSE1_NCS_RD_PULSE) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = 0 - | ((10 << 0) & SMC_CYCLE1_NWE_CYCLE) - | ((22 << 16) & SMC_CYCLE1_NRD_CYCLE) - ; - - pSmc->SMC_CS_NUMBER[1].SMC_MODE = 0 - | (SMC_MODE1_READ_MODE) - | (SMC_MODE1_WRITE_MODE) - | (0) /* Set 8 bit width. TODO: replace with definition in device header file */ - ; - - // Check ILI9325 chipid -// wChipID=_DBE_ILI9325_ReadReg( ILI9325_R00H ) ; -// if ( wChipID != ILI9325_DEVICE_CODE ) -// { -// printf( "Read ILI9325 chip ID (%x) error, skip initialization.\r\n", wChipID ) ; -// return SAMGUI_E_WRONG_COMPONENT ; -// } - - // Turn off LCD - _DBE_ILI9325_LCD_Off() ; - -#if 1 - // Start initial sequence - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL1, 0x0000 ) ; /* DSTB = LP = STB = 0 */ - _DBE_ILI9325_WriteReg( TS_INS_START_OSC, 0x0001 ) ; /* start internal OSC */ - _DBE_ILI9325_WriteReg( TS_INS_DRIV_OUT_CTRL, 0x0100 ) ; /* set SS and SM bit */ - _DBE_ILI9325_WriteReg( TS_INS_DRIV_WAV_CTRL, 0x0700 ) ; /* set 1 line inversion */ -#ifdef ILI9325_BGR_MODE -// _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; /* set GRAM write direction and BGR=1. */ - _DBE_ILI9325_SetBGRMode() ; -#endif // ILI9325_BGR_MODE -#ifdef ILI9325_RGB_MODE -// _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xD030 ) ; /* set GRAM write direction and BGR=1. */ - _DBE_ILI9325_SetRGBMode() ; - -#endif // ILI9325_RGB_MODE - _DBE_ILI9325_WriteReg( TS_INS_RESIZE_CTRL, 0x0000 ) ; /* Resize register */ -// wChipID=_DBE_ILI9325_ReadReg( TS_INS_DISP_CTRL1 ) ; -// printf( "TS_INS_DISP_CTRL1 %x\r\n", wChipID ) ; -// _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x0100 ) ; - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL2, 0x0207 ) ; /* set the back porch and front porch */ - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL3, 0x0000 ) ; /* set non-display area refresh cycle ISC[3:0] */ - _DBE_ILI9325_WriteReg(TS_INS_DISP_CTRL4, 0x0000); /* FMARK function */ - _DBE_ILI9325_WriteReg(TS_INS_RGB_DISP_IF_CTRL1, 0x0000); /* RGB interface setting */ - _DBE_ILI9325_WriteReg(TS_INS_FRM_MARKER_POS, 0x0000); /* Frame marker Position */ - _DBE_ILI9325_WriteReg(TS_INS_RGB_DISP_IF_CTRL2, 0x0000); /* RGB interface polarity */ - - /* Power on sequence */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL1, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL2, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL3, 0x0000); /* VREG1OUT voltage */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL4, 0x0000); /* VDV[4:0] for VCOM amplitude */ - - SAMGUI_TaskDelay( 200 ) ; /* Dis-charge capacitor power voltage */ - - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL1, 0x1290); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL2, 0x0227); /* DC1[2:0], DC0[2:0], VC[2:0] */ - - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL3, 0x001B); /* Internal reference voltage= Vci; */ - - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL4, 0x1100); /* Set VDV[4:0] for VCOM amplitude */ - _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL7, 0x0019); /* Set VCM[5:0] for VCOMH */ - _DBE_ILI9325_WriteReg(TS_INS_FRM_RATE_COL_CTRL, 0x000D); /* Set Frame Rate */ - - SAMGUI_TaskDelay( 50 ) ; - -// _DBE_ILI9325_WriteReg(TS_INS_GRAM_HOR_AD, 0x0000); /* GRAM horizontal Address */ -// _DBE_ILI9325_WriteReg(TS_INS_GRAM_VER_AD, 0x0000); /* GRAM Vertical Address */ - _DBE_ILI9325_SetCursor( 0, 0 ) ; - - // Adjust the Gamma Curve - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL1, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL2, 0x0204); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL3, 0x0200); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL4, 0x0007); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL5, 0x1404); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL6, 0x0705); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL7, 0x0305); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL8, 0x0707); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL9, 0x0701); - _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL10, 0x000e); - - // Set GRAM area (240x320) -// _DBE_ILI9325_WriteReg(TS_INS_HOR_START_AD, 0x0000); /* Horizontal GRAM Start Address */ -// _DBE_ILI9325_WriteReg(TS_INS_HOR_END_AD, 0x00ef); /* Horizontal GRAM End Address */ -// _DBE_ILI9325_WriteReg(TS_INS_VER_START_AD, 0x0000); /* Vertical GRAM Start Address */ -// _DBE_ILI9325_WriteReg(TS_INS_VER_END_AD, 0x013f); /* Vertical GRAM End Address */ - _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - - _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL1, 0xa700); - _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL2, 0x0001); - _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL3, 0x0000); - - // Partial Display Control - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_DISP_POS, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_START_AD, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_END_AD, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_DISP_POS, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_START_AD, 0x0000); - _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_END_AD, 0x0000); - - // Panel Control - _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL1, 0x0010); - _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL2, 0x0600); - _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL4, 0x0110); -#else - SAMGUI_TaskDelay( 100 ) ; - - _DBE_ILI9325_WriteReg( 0x00E5, 0x8000 ) ; //set the internal vcore voltage - _DBE_ILI9325_WriteReg( TS_INS_START_OSC, 0x0001 ) ; //start oscillator - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_DRIV_OUT_CTRL, 0x0100 ) ; //set SS, SM - _DBE_ILI9325_WriteReg( TS_INS_DRIV_WAV_CTRL, 0x0700 ) ; //set 1 line inversion - - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, TS_VAL_ENTRY_MOD ) ; //set GRAM write direction, BGR=0 - - _DBE_ILI9325_WriteReg( TS_INS_RESIZE_CTRL, 0x0000 ) ; //no resizing - - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL2, 0x0202 ) ; //front & back porch periods = 2 - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL3, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL4, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_RGB_DISP_IF_CTRL1, 0x0000 ) ; //select system interface - _DBE_ILI9325_WriteReg( TS_INS_FRM_MARKER_POS, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_RGB_DISP_IF_CTRL2, 0x0000 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL1, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL2, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL3, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL4, 0x0000 ) ; - SAMGUI_TaskDelay( 200 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL1, 0x17B0 ) ; - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL2, 0x0137 ) ; - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL3, 0x013C ) ; - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL4, 0x1400 ) ; - _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL7, 0x0007 ) ; - SAMGUI_TaskDelay( 50 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_GRAM_HOR_AD, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GRAM_VER_AD, 0x0000 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL1, 0x0007 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL2, 0x0504 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL3, 0x0703 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL4, 0x0002 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL5, 0x0707 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL6, 0x0406 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL7, 0x0006 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL8, 0x0404 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL9, 0x0700 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GAMMA_CTRL10, 0x0A08 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_HOR_START_AD, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_HOR_END_AD, 0x00EF ) ; - _DBE_ILI9325_WriteReg( TS_INS_VER_START_AD, 0x0000 ) ; - _DBE_ILI9325_WriteReg(TS_INS_VER_END_AD, 0x013F ) ; - _DBE_ILI9325_WriteReg( TS_INS_GATE_SCAN_CTRL1, 0x2700 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GATE_SCAN_CTRL2, 0x0001 ) ; - _DBE_ILI9325_WriteReg( TS_INS_GATE_SCAN_CTRL3, 0x0000 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG1_DISP_POS, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG1_START_AD,0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG1_END_AD, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG2_DISP_POS, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG2_START_AD, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PART_IMG2_END_AD, 0x0000 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_PANEL_IF_CTRL1, 0x0010 ) ; - _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL2, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PANEL_IF_CTRL3, 0x0003 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PANEL_IF_CTRL4, 0x0110 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PANEL_IF_CTRL5, 0x0000 ) ; - _DBE_ILI9325_WriteReg( TS_INS_PANEL_IF_CTRL6, 0x0000 ) ; - - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x0173 ) ; -#endif - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_Color666( uint32_t dwColor888 ) -{ - return ((dwColor888&0xfc)<<2)|((dwColor888&0xfc00)<<2)|((dwColor888&0xfc0000)<<2) ; -} - -static uint32_t _DBE_ILI9325_GetPixel( uint32_t dwX, uint32_t dwY, SGUIColor* pclrResult ) -{ - if ( pclrResult == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - _DBE_ILI9325_SetCursor( dwX, dwY ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; -// pclrResult->u.dwRGBA=_DBE_ILI9325_ReadRAM() ; - _DBE_ILI9325_ReadRAM( pclrResult ) ; - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawPixel( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn ) -{ - if ( dwX >= BOARD_LCD_WIDTH ) - { - dwX=BOARD_LCD_WIDTH-1 ; - } - - if ( dwY >= BOARD_LCD_HEIGHT ) - { - dwY=BOARD_LCD_HEIGHT-1 ; - } - - _DBE_ILI9325_SetCursor( dwX, dwY ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; -#ifdef ILI9325_RGB_MODE - ILI9325_D=((pclrIn->u.dwRGBA >> 16) & 0xff) ; - ILI9325_D=((pclrIn->u.dwRGBA >> 8) & 0xff) ; - ILI9325_D=(pclrIn->u.dwRGBA & 0xff) ; -#endif // ILI9325_RGB_MODE - -#ifdef ILI9325_BGR_MODE -// _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ; - ILI9325_D=(pclrIn->u.dwRGBA & 0xff) ; - ILI9325_D=((pclrIn->u.dwRGBA >> 8) & 0xff) ; - ILI9325_D=((pclrIn->u.dwRGBA >> 16) & 0xff) ; -#endif // ILI9325_BGR_MODE - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawLineBresenham( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn ) -{ - int dx, dy ; - int i ; - int xinc, yinc, cumul ; - int x, y ; - - x = dwX1 ; - y = dwY1 ; - dx = dwX2 - dwX1 ; - dy = dwY2 - dwY1 ; - - xinc = ( dx > 0 ) ? 1 : -1 ; - yinc = ( dy > 0 ) ? 1 : -1 ; - dx = ( dx > 0 ) ? dx : -dx ; - dy = ( dy > 0 ) ? dy : -dy ; - - _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ; - - if ( dx > dy ) - { - cumul = dx / 2 ; - for ( i = 1 ; i <= dx ; i++ ) - { - x += xinc ; - cumul += dy ; - - if ( cumul >= dx ) - { - cumul -= dx ; - y += yinc ; - } - _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ; - } - } - else - { - cumul = dy / 2 ; - for ( i = 1 ; i <= dy ; i++ ) - { - y += yinc ; - cumul += dx ; - - if ( cumul >= dy ) - { - cumul -= dy ; - x += xinc ; - } - - _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ; - } - } - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawLine( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn ) -{ - uint32_t dw=0 ; - - if ( dwX1 >= BOARD_LCD_WIDTH ) - { - dwX1=BOARD_LCD_WIDTH-1 ; - } - - if ( dwX2 >= BOARD_LCD_WIDTH ) - { - dwX2=BOARD_LCD_WIDTH-1 ; - } - - if ( dwY1 >= BOARD_LCD_HEIGHT ) - { - dwY1=BOARD_LCD_HEIGHT-1 ; - } - - if ( dwY2 >= BOARD_LCD_HEIGHT ) - { - dwY2=BOARD_LCD_HEIGHT-1 ; - } - - _DBE_ILI9325_SetCursor( dwX1, dwY1 ) ; - - // Horizontal line - if ( dwY1 == dwY2 ) - { - _DBE_ILI9325_RAMAccess_Prepare() ; - - if ( dwX1 > dwX2 ) - { - dw=dwX1 ; - dwX1=dwX2 ; - dwX2=dw ; - } - - for ( dw=dwX1 ; dw <= dwX2 ; dw++ ) - { - _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ; - } - } - else - { - // Vertical line - if ( dwX1 == dwX2 ) - { - if ( dwY1 > dwY2 ) - { - dw=dwY1 ; - dwY1=dwY2 ; - dwY2=dw ; - } - - for ( dw=dwY1 ; dw <= dwY2 ; dw++ ) - { - _DBE_ILI9325_RAMAccess_Prepare() ; - _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ; - _DBE_ILI9325_SetCursor( dwX1, dw ) ; - } - } - else // Bresenham - { - return _DBE_ILI9325_DrawLineBresenham( dwX1, dwY1, dwX2, dwY2, pclrIn ) ; - } - } - - return SAMGUI_E_OK ; -} - -#if 1 -static uint32_t _DBE_ILI9325_DrawCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder ) -{ - signed int d ; // Decision Variable - uint32_t dwCurX ; // Current X Value - uint32_t dwCurY ; // Current Y Value - - if ( pclrBorder == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - d = 3 - (dwRadius << 1) ; - dwCurX = 0 ; - dwCurY = dwRadius ; - - while ( dwCurX <= dwCurY ) - { - _DBE_ILI9325_DrawPixel( dwX + dwCurX, dwY + dwCurY, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX + dwCurX, dwY - dwCurY, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX - dwCurX, dwY + dwCurY, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX - dwCurX, dwY - dwCurY, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX + dwCurY, dwY + dwCurX, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX + dwCurY, dwY - dwCurX, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX - dwCurY, dwY + dwCurX, pclrBorder ) ; - _DBE_ILI9325_DrawPixel( dwX - dwCurY, dwY - dwCurX, pclrBorder ) ; - - if ( d < 0 ) - { - d += (dwCurX << 2) + 6 ; - } - else - { - d += ((dwCurX - dwCurY) << 2) + 10; - dwCurY-- ; - } - - dwCurX++ ; - } - - return SAMGUI_E_OK ; -} -#else -void plot4points( uint32_t dwX, uint32_t dwY, int iX, int iY, SGUIColor* pclrBorder ) -{ - _DBE_ILI9325_DrawPixel( dwX+iX, dwY+iY, pclrBorder ) ; - if ( iX != 0 ) _DBE_ILI9325_DrawPixel( dwX-iX, dwY+iY, pclrBorder ) ; - if ( iY != 0 ) _DBE_ILI9325_DrawPixel( dwX+iX, dwY-iY, pclrBorder ) ; - if ( iX != 0 && iY != 0 ) _DBE_ILI9325_DrawPixel( dwX-iX, dwY-iY, pclrBorder ) ; -} - -void _DBE_ILI9325_Plot8points( uint32_t dwX, uint32_t dwY, int x, int iY, SGUIColor* pclrBorder ) -{ - _DBE_ILI9325_Plot4points( dwX, dwY, iX, iY, pclrBorder ) ; - if ( iX != iY ) _DBE_ILI9325_Plot4points( dwX, dwY, iY, iX, pclrBorder ) ; -} - -static uint32_t _DBE_ILI9325_DrawCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder ) -{ - int iError=-dwRadius ; - int iX=dwRadius ; - int iY=0 ; - - while ( iX >= iY ) - { - plot8points( dwX, dwY, iX, iY, pclrBorder ) ; - - iError+=iY ; - ++iY ; - iError+=iY ; - - if ( iError >= 0 ) - { - --iX ; - iError-=iX ; - iError-=iX ; - } - } -} -#endif - -static uint32_t _DBE_ILI9325_DrawFilledCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder, SGUIColor* pclrInside ) -{ - signed int d ; // Decision Variable - uint32_t dwCurX ; // Current X Value - uint32_t dwCurY ; // Current Y Value - -// if ( pclrBorder == NULL ) -// { -// return SAMGUI_E_BAD_POINTER ; -// } - - d = 3 - (dwRadius << 1) ; - dwCurX = 0 ; - dwCurY = dwRadius ; - - while ( dwCurX <= dwCurY ) - { - _DBE_ILI9325_DrawLine( dwX-dwCurX, dwY-dwCurY, dwX+dwCurX, dwY-dwCurY, pclrInside ) ; - _DBE_ILI9325_DrawLine( dwX-dwCurX, dwY+dwCurY, dwX+dwCurX, dwY+dwCurY, pclrInside ) ; - _DBE_ILI9325_DrawLine( dwX-dwCurY, dwY-dwCurX, dwX+dwCurY, dwY-dwCurX, pclrInside ) ; - _DBE_ILI9325_DrawLine( dwX-dwCurY, dwY+dwCurX, dwX+dwCurY, dwY+dwCurX, pclrInside ) ; - - if ( d < 0 ) - { - d += (dwCurX << 2) + 6 ; - } - else - { - d += ((dwCurX - dwCurY) << 2) + 10; - dwCurY-- ; - } - - dwCurX++ ; - } - - if ( pclrBorder != NULL ) - { - _DBE_ILI9325_DrawCircle( dwX, dwY, dwRadius, pclrBorder ) ; - } - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame ) -{ - _DBE_ILI9325_DrawLine( dwX1, dwY1, dwX2, dwY1, pclrFrame ) ; - _DBE_ILI9325_DrawLine( dwX1, dwY2, dwX2, dwY2, pclrFrame ) ; - - _DBE_ILI9325_DrawLine( dwX1, dwY1, dwX1, dwY2, pclrFrame ) ; - _DBE_ILI9325_DrawLine( dwX2, dwY1, dwX2, dwY2, pclrFrame ) ; - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawFilledRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame, SGUIColor* pclrInside ) -{ - uint32_t dw ; - uint32_t dwLength ; - - // Check coordonates - if ( dwX1 > dwX2 ) - { - dw=dwX1 ; - dwX1=dwX2 ; - dwX2=dw ; - } - - if ( dwY1 > dwY2 ) - { - dw=dwY1 ; - dwY1=dwY2 ; - dwY2=dw ; - } - - _DBE_ILI9325_SetCursor( dwX1, dwY1 ) ; - _DBE_ILI9325_SetWindow( dwX1, dwY1, dwX2-dwX1+1, dwY2-dwY1+1 ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; - - dwLength=(dwX2-dwX1+1)*(dwY2-dwY1+1) ; - for ( dw=0 ; dw < dwLength ; dw++ ) - { -// _DBE_ILI9325_WriteRAM( pclrInside->u.dwRGBA ) ; -#ifdef ILI9325_BGR_MODE - ILI9325_D=(pclrInside->u.dwRGBA & 0xff) ; - ILI9325_D=((pclrInside->u.dwRGBA >> 8) & 0xff) ; - ILI9325_D=((pclrInside->u.dwRGBA >> 16) & 0xff) ; -#endif // ILI9325_BGR_MODE - -#ifdef ILI9325_RGB_MODE - ILI9325_D=((pclrInside->u.dwRGBA >> 16) & 0xff) ; - ILI9325_D=((pclrInside->u.dwRGBA >> 8) & 0xff) ; - ILI9325_D=(pclrInside->u.dwRGBA & 0xff) ; -#endif // ILI9325_RGB_MODE - } - - _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawBitmapBMP( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) -{ - uint32_t dwRow ; - uint32_t dwCol ; - uint32_t dwMinWidth ; - uint32_t dwMinHeight ; - SBMPHeader* pHeader ; -#ifdef ILI9325_RGB_MODE - uint8_t ucR ; - uint8_t ucG ; - uint8_t ucB ; -#endif // ILI9325_RGB_MODE - uint8_t* pucImage ; - uint8_t* pucLine ; - uint32_t dwScanLineBits ; - uint32_t dwScanLineBytes ; - SGUIColor clr={ .u.dwRGBA=0xff0000 } ; - - // Read header information - pHeader=(SBMPHeader*)pucData ; - -// printf( "_DBE_ILI9325_DrawBitmapBMP\n\r" ) ; - - dwScanLineBits=pHeader->dwWidth*pHeader->wBits ; - dwScanLineBytes=((dwScanLineBits+31)/32)*4 ; - - // Check that parameters match - if ( (pHeader->dwCompression != 0) || (pHeader->dwWidth != dwWidth) || (pHeader->dwHeight != dwHeight) ) - { - printf( "BMP_Decode: File format not supported\n\r" ) ; - printf( " -> .compression = %u\n\r", pHeader->dwCompression ) ; - printf( " -> .width = %u %u\n\r", pHeader->dwWidth, dwWidth ) ; - printf( " -> .height = %u %u\n\r", pHeader->dwHeight, dwHeight ) ; - printf( " -> .bits = %u\n\r", pHeader->wBits ) ; - printf( " -> .scanline_bits = %u\n\r", dwScanLineBits ) ; - printf( " -> .scanline_bytes = %u\n\r", dwScanLineBytes ) ; - - _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ; - clr.u.dwRGBA=0x000000 ; - _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ; - _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ; - - return 2 ; - } - - // Get image data - pucImage=pucData+pHeader->dwOffset ; - dwMinWidth=(dwWidth+dwX < ILI9325_WIDTH)?dwWidth:ILI9325_WIDTH ; - dwMinHeight=(dwHeight+dwY < ILI9325_HEIGTH)?dwHeight:ILI9325_HEIGTH ; - - if ( pHeader->wBits == 24 ) - { -// _DBE_ILI9325_WriteReg(ILI9325_R03H, _DBE_ILI9325_ReadReg( ILI9325_R03H )~(1<<12) ); /* set GRAM write direction and BGR=1. */ - _DBE_ILI9325_SetCursor( dwX, dwY ) ; - _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; - - // Send image data to ILI9325 (swapping red & blue) - for ( dwRow=0 ; dwRow < dwMinHeight ; dwRow++ ) - { - pucLine=pucImage+((dwHeight-dwRow-1)*dwScanLineBytes) ; -// printf( "_DBE_ILI9325_DrawBitmapBMP - Line %u/%u\n\r", dwRow, ((dwHeight-dwRow-1)*(dwWidth*3)) ) ; - - for ( dwCol=0 ; dwCol < dwMinWidth ; dwCol++ ) - { -#ifdef ILI9325_BGR_MODE - ILI9325_D=(*pucLine/*<<2*/)++ ; - ILI9325_D=(*pucLine/*<<2*/)++ ; - ILI9325_D=(*pucLine/*<<2*/)++ ; -#endif // ILI9325_BGR_MODE - -#ifdef ILI9325_RGB_MODE - ucB=*pucLine++ ; - ucG=*pucLine++ ; - ucR=*pucLine++ ; - ILI9325_D=ucR/*<<2*/ ; - ILI9325_D=ucG/*<<2*/ ; - ILI9325_D=ucB/*<<2*/ ; -#endif // ILI9325_RGB_MODE - } - } - - _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - -// _DBE_ILI9325_WriteReg(ILI9325_R03H, _DBE_ILI9325_ReadReg( ILI9325_R03H )|(1<<12) ); /* set GRAM write direction and BGR=1. */ - } - else - { - if ( pHeader->wBits == 8 ) - { -// // Retrieve palette -// struct BMPPaletteEntry palette[256]; -// memcpy(palette, -// (unsigned char *) ((unsigned int) file + sizeof(struct BMPHeader)), -// header->offset - sizeof(struct BMPHeader)); -// - // Decode image (reversing row order) - // Send image data to ILI9325 (swapping red & blue) - for ( dwRow=0 ; dwRow < dwMinHeight ; dwRow++ ) - { - _DBE_ILI9325_SetCursor( dwX, dwY+dwRow ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; - pucLine=pucImage+((dwHeight-dwRow-1)*dwWidth) ; -// printf( "_DBE_ILI9325_DrawBitmapBMP - Line %u/%u/%u\n\r", dwRow, dwMinWidth, ((dwHeight-dwRow-1)*dwWidth) ) ; - - for ( dwCol=0 ; dwCol < dwMinWidth ; dwCol++ ) - { - ILI9325_D=(*pucLine++)/*<<2*/ ; - ILI9325_D=(*pucLine++)/*<<2*/ ; - ILI9325_D=(*pucLine++)/*<<2*/ ; - } - } - } - else - { - printf( "BMP_Decode: Input resolution not supported\n\r" ) ; - printf( "header->bits 0x%X \n\r", pHeader->wBits ) ; - - - _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ; - clr.u.dwRGBA=0x000000 ; - _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ; - _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ; - - return 4 ; - } - } - - return SAMGUI_E_OK ; -} - -#if 0 -static uint32_t _DBE_ILI9325_DrawBitmapBMPFile( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) -{ - uint32_t dwLine ; - uint8_t* pucLine=_DBE_ILI9325_aucFileData ; - FIL fp ; - struct BMPHeader sHeader ; - uint32_t dwLineLength ; - uint32_t dwLength ; - uint32_t dwTemp ; -#ifdef ILI9325_RGB_MODE - uint8_t ucR ; - uint8_t ucG ; - uint8_t ucB ; -#endif // ILI9325_RGB_MODE - - // Read first 256 bytes to obtain header - if ( f_open( &fp, (const char*)pucData, FA_OPEN_EXISTING|FA_READ ) == FR_OK ) - { - if ( f_read( &fp, &sHeader, sizeof( sHeader ), &dwLength ) == FR_OK ) - { -// printf( "read %c%c\r\n", (char)(sHeader.type&0xff), (char)(sHeader.type>>8) ) ; -// printf( " -> .compression = %u\n\r", sHeader.compression ) ; -// printf( " -> .width = %u\n\r", sHeader.width ) ; -// printf( " -> .height = %u\n\r", sHeader.height ) ; -// printf( " -> .bits = %u\n\r", sHeader.bits ) ; - - dwLineLength=(((sHeader.width*sHeader.bits)+31)/32)*4 ; - - // if header is Windows BMP 24bpp, alloc line size bytes on HEAP - if ( (sHeader.bits == 24) ) - { - // Move file pointer to begin of BMP data - f_lseek( &fp, sHeader.offset ) ; -//_DBE_ILI9325_WriteReg( TS_INS_DRIV_OUT_CTRL, 0x0000 ) ; -//_DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; -#if 0 - dwTemp=_DBE_ILI9325_ReadReg( TS_INS_DISP_CTRL1 ) ; -// printf( "DISP_CTRL1 %x\r\n", dwTemp ) ; - dwTemp&=~0x0002 ; - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, dwTemp ) ; -#endif - - _DBE_ILI9325_SetCursor( dwX, dwY ) ; - _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ; - _DBE_ILI9325_RAMAccess_Prepare() ; - - // Read each bitmap line and write it on backend - for ( dwLine=0 ; dwLine < sHeader.height ; dwLine++ ) - { - if ( f_read( &fp, pucLine, dwLineLength, &dwLength ) == FR_OK ) - { -#if 1 -#ifdef ILI9325_RGB_MODE -// for ( dwLength=0 ; dwLength < dwLineLength ; dwLength+=3 ) -// { -// dwTemp=pucLine[dwLength] ; ; -// pucLine[dwLength]=pucLine[dwLength+2] ; -// pucLine[dwLength+2]=dwTemp ; ; -// } -#endif // ILI9325_RGB_MODE - - _DBE_ILI9325_DrawBitmap( dwX, dwY+sHeader.height-dwLine, sHeader.width, 1, pucLine ) ; -#else - for ( dwTemp=0 ; dwTemp < sHeader.width ; dwTemp++ ) - { -#ifdef ILI9325_BGR_MODE - ILI9325_D=(*pucLine/*<<2*/)++ ; - ILI9325_D=(*pucLine/*<<2*/)++ ; - ILI9325_D=(*pucLine/*<<2*/)++ ; -#endif // ILI9325_BGR_MODE - -#ifdef ILI9325_RGB_MODE - ucB=*pucLine++ ; - ucG=*pucLine++ ; - ucR=*pucLine++ ; - ILI9325_D=ucR/*<<2*/ ; - ILI9325_D=ucG/*<<2*/ ; - ILI9325_D=ucB/*<<2*/ ; -#endif // ILI9325_RGB_MODE - } -#endif - } - } - _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - -#if 0 - dwTemp=_DBE_ILI9325_ReadReg( TS_INS_DISP_CTRL1 ) ; -// printf( "DISP_CTRL1 %x\r\n", dwTemp ) ; - dwTemp|=0x0002 ; - _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, dwTemp ) ; -#endif -//_DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xd030 ) ; -//_DBE_ILI9325_WriteReg( TS_INS_DRIV_OUT_CTRL, 0x0100 ) ; - } - } - else - { - printf( "failed to read\r\n" ) ; - } - f_close( &fp ) ; - return SAMGUI_E_OK ; - } - else - { - SGUIColor clr={ .u.dwRGBA=0xff0000 } ; - - printf( "failed to open %s\r\n", (const char*)pucData ) ; - _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ; - clr.u.dwRGBA=0x000000 ; - _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ; - _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ; - } - - return SAMGUI_E_FILE_OPEN ; -} -#else -static uint32_t _DBE_ILI9325_DrawBitmapBMPFile( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) -{ -// uint32_t dwLine ; - uint32_t dwMin ; - FIL fp ; - struct BMPHeader sHeader ; - uint32_t dwLineLength ; - uint32_t dwLength ; - uint32_t dwTemp ; - uint32_t dwIndex ; - - // Read first 256 bytes to obtain header - if ( f_open( &fp, (const char*)pucData, FA_OPEN_EXISTING|FA_READ ) == FR_OK ) - { - if ( f_read( &fp, &sHeader, sizeof( sHeader ), &dwLength ) == FR_OK ) - { -// printf( "read %c%c\r\n", (char)(sHeader.type&0xff), (char)(sHeader.type>>8) ) ; -// printf( " -> .compression = %u\n\r", sHeader.compression ) ; -// printf( " -> .width = %u\n\r", sHeader.width ) ; -// printf( " -> .height = %u\n\r", sHeader.height ) ; -// printf( " -> .bits = %u\n\r", sHeader.bits ) ; - - dwLineLength=(((sHeader.width*sHeader.bits)+31)/32)*4 ; - - // if header is Windows BMP 24bpp, alloc line size bytes on HEAP - if ( (sHeader.bits == 24) ) - { - // Move file pointer to begin of BMP data - f_lseek( &fp, sHeader.offset ) ; - -// dwX2=dwX ; -// dwY+=sHeader.height ; - - // Set window -//#if defined ILI9325_RGB_MODE - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc010 ) ; /* set GRAM write direction and BGR=1. */ -//#endif // defined ILI9325_RGB_MODE -//#if defined ILI9325_BGR_MODE - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc010 ) ; /* set GRAM write direction and BGR=1. */ -//#endif // defined ILI9325_BGR_MODE - _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ; -// _DBE_ILI9325_SetCursor( dwX, dwY ) ; //+dwHeight-1 ) ; - _DBE_ILI9325_SetCursor( dwX, dwY+dwHeight-1 ) ; - - -//// dwX2=_DBE_ILI9325_ReadReg( ILI9325_R03H ) ; -////// dwX2|=(1<<5) ; // I/D1=1 -//// dwX2&=~(1<<3) ; // I/D1=0 -////// dwX2&=~(1<<3) ; // AM=0 -////// dwX2|=(1<<3) ; // AM=1 -//// _DBE_ILI9325_WriteReg( ILI9325_R03H, (uint16_t)dwX2 ) ; - - ILI9325_IR=0 ; - ILI9325_IR=TS_INS_RW_GRAM ; - - // Read buffer and write it on backend - dwIndex=0 ; - do - { - if ( f_read( &fp, _DBE_ILI9325_aucFileData, sizeof( _DBE_ILI9325_aucFileData ), &dwLength ) == FR_OK ) - { -// printf( "Read %u bytes\r\n", dwLength ) ; - // Get Min value from read length and buffer length -// dwMin=(dwLength < sizeof( _DBE_ILI9325_aucFileData ) )?dwLength:sizeof( _DBE_ILI9325_aucFileData ) ; - -#if defined ILI9325_RGB_MODE -// // Convert from BGR to RGB -// for ( dwLength=0 ; dwLength < dwMin ; dwLength+=3 ) -// { -// dwTemp=_DBE_ILI9325_aucFileData[dwLength] ; ; -// _DBE_ILI9325_aucFileData[dwLength]=_DBE_ILI9325_aucFileData[dwLength+2] ; -// _DBE_ILI9325_aucFileData[dwLength+2]=dwTemp ; -// } -#endif // defined ILI9325_RGB_MODE - -// printf( "writing %u bytes\r\n", dwMin ) ; - // Draw whole buffer data to backend - dwMin=dwWidth*3 ; - if ( dwLineLength != dwMin ) - { - for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++, dwIndex++ ) - { - if ( (dwIndex >= dwMin) && (dwIndex < dwLineLength) ) - { - } - else - { - if ( dwIndex == dwLineLength ) - { - dwIndex=0 ; - } - ILI9325_D=_DBE_ILI9325_aucFileData[dwTemp] ; - } - } - } - else - { - for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++ ) - { - ILI9325_D=_DBE_ILI9325_aucFileData[dwTemp] ; - } - } - } - } while ( dwLength == sizeof( _DBE_ILI9325_aucFileData ) ) ; - -#if defined ILI9325_RGB_MODE - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xd030 ) ; /* set GRAM write direction and BGR=1. */ -#endif // defined ILI9325_RGB_MODE -#if defined ILI9325_BGR_MODE - _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; /* set GRAM write direction and BGR=1. */ -#endif // defined ILI9325_BGR_MODE - // Restore whole window - _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - } - } - else - { - printf( "failed to read\r\n" ) ; - } - f_close( &fp ) ; - return SAMGUI_E_OK ; - } - else - { - SGUIColor clr={ .u.dwRGBA=0xff0000 } ; - - printf( "failed to open %s\r\n", (const char*)pucData ) ; - - _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ; - clr.u.dwRGBA=0x000000 ; - - _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ; - _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ; - - } - - return SAMGUI_E_FILE_OPEN ; -} -#endif - -static uint32_t _DBE_ILI9325_DrawBitmap( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) -{ - uint32_t dwCol ; -//#ifdef ILI9325_BGR_MODE -// uint8_t ucB ; -// uint8_t ucG ; -// uint8_t ucR ; -//#endif // ILI9325_BGR_MODE - - // Check if bitmap is Microsoft BMP - if ( (pucData[0] == 'B') && (pucData[1] == 'M') ) - { - return _DBE_ILI9325_DrawBitmapBMP( dwX, dwY, dwWidth, dwHeight, pucData ) ; - } - - if ( pucData[0] == '/' ) - { - return _DBE_ILI9325_DrawBitmapBMPFile( dwX, dwY, dwWidth, dwHeight, pucData ) ; - } - - // Draw raw RGB bitmap - _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ; - _DBE_ILI9325_SetCursor( dwX, dwY ) ; - - ILI9325_IR=0 ; - ILI9325_IR=ILI9325_R22H ; - -#ifdef ILI9325_BGR_MODE -// _DBE_ILI9325_SetBGRMode() ; -#endif // ILI9325_RGB_MODE - -#ifdef ILI9325_RGB_MODE -// _DBE_ILI9325_SetBGRMode() ; -#endif // ILI9325_RGB_MODE - - for ( dwCol=0 ; dwCol < dwWidth*dwHeight ; dwCol++ ) - { -#ifdef ILI9325_BGR_MODE - ucB=((*pucData++)/*<<2*/) ; - ucG=((*pucData++)/*<<2*/) ; - ucR=((*pucData++)/*<<2*/) ; - ILI9325_D=ucR/*<<2*/ ; - ILI9325_D=ucG/*<<2*/ ; - ILI9325_D=ucB/*<<2*/ ; -#endif // ILI9325_BGR_MODE - -#ifdef ILI9325_RGB_MODE - ILI9325_D = ((*pucData++)/*<<2*/) ; - ILI9325_D = ((*pucData++)/*<<2*/) ; - ILI9325_D = ((*pucData++)/*<<2*/) ; -#endif // ILI9325_RGB_MODE - } - -#ifdef ILI9325_BGR_MODE -// _DBE_ILI9325_SetBGRMode() ; -#endif // ILI9325_RGB_MODE - -#ifdef ILI9325_RGB_MODE -// _DBE_ILI9325_SetRGBMode() ; -#endif // ILI9325_RGB_MODE - - _DBE_ILI9325_SetWindow( dwX, dwY, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ; - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawChar( uint32_t dwX, uint32_t dwY, uint8_t ucChar, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize ) -{ - uint32_t dwRow ; - uint32_t dwCol ; - -// SANITY_CHECK((ucChar >= 0x20) && (ucChar <= 0x7F) ) ; - - for ( dwCol=0 ; dwCol < 10 ; dwCol++ ) - { - for ( dwRow=0 ; dwRow < 8 ; dwRow++ ) - { - if ( (aucFont10x14[((ucChar - 0x20) * 20) + dwCol * 2] >> (7 - dwRow)) & 0x1) - { - _DBE_ILI9325_DrawPixel( dwX+dwCol, dwY+dwRow, pclrText ) ; - } - } - - for ( dwRow=0 ; dwRow < 6 ; dwRow++ ) - { - if ( (aucFont10x14[((ucChar - 0x20) * 20) + dwCol * 2 + 1] >> (7 - dwRow)) & 0x1) - { - _DBE_ILI9325_DrawPixel( dwX+dwCol, dwY+dwRow+8, pclrText ) ; - } - } - } - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_DrawText( uint32_t dwX, uint32_t dwY, uint8_t* pszText, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize ) -{ - uint32_t dwXOrg=dwX ; - - if ( (pszText == NULL) || (pclrText == NULL) || (pFont == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - while ( *pszText != 0 ) - { - if ( *pszText == '\n' ) - { - dwY+=pFont->dwHeight+2 ; - dwX=dwXOrg ; - } - else - { - _DBE_ILI9325_DrawChar( dwX, dwY, *pszText, pclrText, pFont, dwSize ) ; - dwX+=pFont->dwWidth+2 ; - } - pszText++ ; - } - - return SAMGUI_E_OK ; -} - -static uint32_t _DBE_ILI9325_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) -{ - // Check pointers -// if ( (pdwValue == NULL) || (pdwValueLength == NULL) ) -// { -// return SAMGUI_E_BAD_POINTER ; -// } - - switch ( dwCommand ) - { - case DISP_BACKEND_IOCTL_POWER_ON : - _DBE_ILI9325_LCD_On() ; - break ; - - case DISP_BACKEND_IOCTL_POWER_OFF : - _DBE_ILI9325_LCD_Off() ; - break ; - - case DISP_BACKEND_IOCTL_SET_BACKLIGHT : - _DBE_ILI9325_SetBacklight( (uint32_t)pdwValue ) ; - break ; - - case DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT : - _DBE_ILI9325_SetOrientation( DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT ) ; - break ; - - case DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE : - _DBE_ILI9325_SetOrientation( DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE ) ; - break ; - - default : - printf( "_DBE_ILI9325_IOCtl - Bad IOCtl index (%x)\r\n", dwCommand ) ; - break ; - } - - return SAMGUI_E_OK ; -} - -SDISPBackend sDISP_Backend_ILI9325= -{ - .sData= - { - .dwID=DISP_BACKEND_ILI9325, - }, - - .Reset=_DBE_ILI9325_Reset, - .Initialize=_DBE_ILI9325_Initialize, - .GetPixel=_DBE_ILI9325_GetPixel, - .DrawPixel=_DBE_ILI9325_DrawPixel, - .DrawLine=_DBE_ILI9325_DrawLine, - .DrawCircle=_DBE_ILI9325_DrawCircle, - .DrawFilledCircle=_DBE_ILI9325_DrawFilledCircle, - .DrawRectangle=_DBE_ILI9325_DrawRectangle, - .DrawFilledRectangle=_DBE_ILI9325_DrawFilledRectangle, - .DrawBitmap=_DBE_ILI9325_DrawBitmap, - .DrawText=_DBE_ILI9325_DrawText, - .Fill=NULL, - .IOCtl=_DBE_ILI9325_IOCtl -} ; diff --git a/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.h b/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.h deleted file mode 100644 index 3083bbc3a..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/backends/ILI9325/backend_ILI9325.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - * \file - * - * Interface of ILI9325 driver. - * - */ - -#ifndef _SAM_GUI_BACKEND_ILI9325_ -#define _SAM_GUI_BACKEND_ILI9325_ - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ -#include "disp/disp_backend.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern SDISPBackend sDISP_Backend_ILI9325 ; - -#endif // _SAM_GUI_BACKEND_ILI9325_ - diff --git a/src/ersky9x/libraries/sam-gui/disp/disp_backend.c b/src/ersky9x/libraries/sam-gui/disp/disp_backend.c deleted file mode 100644 index c8bb64b8f..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/disp_backend.c +++ /dev/null @@ -1,80 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "disp/disp_backend.h" -#include "disp/backends/ILI9325/backend_ILI9325.h" -#include "disp/backends/HX8347/backend_HX8347.h" -#include "sam-gui/common/sam_gui_errors.h" -#include -#include - -//#define TRACE( x ) x -#define TRACE( x ) - -static __no_init SDISPBackend* _aDISP_Backends[DISP_BACKEND_MAX] ; - -extern uint32_t DISP_Initialize( void ) -{ - _aDISP_Backends[DISP_BACKEND_HX8347]=NULL ; //&sDISP_Backend_HX8347 ; - _aDISP_Backends[DISP_BACKEND_ILI9325]=&sDISP_Backend_ILI9325 ; - - for ( int i=0 ; i < DISP_BACKEND_MAX ; i++ ) - { - TRACE( printf( "DISP_Initialize - [%d] %x\r\n", i, _aDISP_Backends[i] ) ; ) - } - - return SAMGUI_E_OK ; -} - -extern uint32_t DISP_GetBackend( uint32_t dwIndex, SDISPBackend** ppBackend ) -{ - // Check pointers - if ( ppBackend == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( dwIndex >= DISP_BACKEND_MAX ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - if ( _aDISP_Backends[dwIndex]->sData.dwID != dwIndex ) - { - TRACE( printf( "DISP_GetBackend - Inconsistent backend %x\r\n", dwIndex ) ; ) - return SAMGUI_E_WRONG_COMPONENT ; - } - - *ppBackend=_aDISP_Backends[dwIndex] ; - TRACE( printf( "DISP_GetBackend - %x %x\r\n", _aDISP_Backends[dwIndex], *ppBackend ) ; ) - - return SAMGUI_E_OK ; -} - diff --git a/src/ersky9x/libraries/sam-gui/disp/disp_backend.h b/src/ersky9x/libraries/sam-gui/disp/disp_backend.h deleted file mode 100644 index 2ece5cec2..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/disp_backend.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAM_GUI_DISP_BACKEND_ -#define _SAM_GUI_DISP_BACKEND_ - -#include "sam-gui/common/sam_gui_color.h" -#include "sam-gui/common/sam_gui_font.h" - -typedef struct _SDISPBackendData -{ - uint32_t dwID ; - uint32_t dwOrientation ; // Portrait, Landscape - uint32_t dwMode ; // RGB, BGR -} sDISPBackendData ; - -typedef struct _SDISPBackend -{ - sDISPBackendData sData ; - - uint32_t (*Reset)( void ) ; - uint32_t (*Initialize)( void ) ; - uint32_t (*GetPixel)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrResult ) ; - uint32_t (*DrawPixel)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn ) ; - uint32_t (*DrawLine)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn ) ; - uint32_t (*DrawCircle)( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder ) ; - uint32_t (*DrawFilledCircle)( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder, SGUIColor* pclrInside ) ; - uint32_t (*DrawRectangle)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame ) ; - uint32_t (*DrawFilledRectangle)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame, SGUIColor* pclrInside ) ; - uint32_t (*DrawBitmap)( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) ; - uint32_t (*DrawText)( uint32_t dwX, uint32_t dwY, uint8_t* pszText, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize ) ; - uint32_t (*Fill)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn ) ; - uint32_t (*IOCtl)( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) ; -} SDISPBackend ; - -#define DISP_BACKEND_IOCTL_POWER_ON 0x01L -#define DISP_BACKEND_IOCTL_POWER_OFF 0x02L -#define DISP_BACKEND_IOCTL_SET_BACKLIGHT 0x03L -#define DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT 0x04L -#define DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE 0x05L - -typedef enum _DISP_eBackend -{ - DISP_BACKEND_HX8347, - DISP_BACKEND_ILI9325, - DISP_BACKEND_MAX -} DISP_eBackend ; - -extern uint32_t DISP_Initialize( void ) ; -extern uint32_t DISP_GetBackend( uint32_t dwIndex, SDISPBackend** ppBackend ) ; - -#endif // _SAM_GUI_DISP_BACKEND_ diff --git a/src/ersky9x/libraries/sam-gui/disp/disp_core.c b/src/ersky9x/libraries/sam-gui/disp/disp_core.c deleted file mode 100644 index e69e0e033..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/disp_core.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - diff --git a/src/ersky9x/libraries/sam-gui/disp/disp_core.h b/src/ersky9x/libraries/sam-gui/disp/disp_core.h deleted file mode 100644 index 5fb1828bd..000000000 --- a/src/ersky9x/libraries/sam-gui/disp/disp_core.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _DISP_CORE_ -#define _DISP_CORE_ - -#include "disp/disp_backend.h" -#include - -//#define TRACE( x ) x -#define TRACE( x ) - - - -#endif // _DISP_CORE_ diff --git a/src/ersky9x/libraries/sam-gui/docs/pcx.txt b/src/ersky9x/libraries/sam-gui/docs/pcx.txt deleted file mode 100644 index 609db4b3b..000000000 --- a/src/ersky9x/libraries/sam-gui/docs/pcx.txt +++ /dev/null @@ -1,585 +0,0 @@ -ZSoft PCX File Format Technical Reference Manual - - - -Introduction 2 -Image File (.PCX) Format 3 -ZSoft .PCX FILE HEADER FORMAT 4 -Decoding .PCX Files 6 -Palette Information Description 7 -EGA/VGA 16 Color Palette Information 7 -VGA 256 Color Palette Information 7 -24-Bit .PCX Files 8 -CGA Color Palette Information 8 -CGA Color Map 8 -PC Paintbrush Bitmap Character Format 9 -Sample "C" Routines 10 -FRIEZE Technical Information 14 -General FRIEZE Information 14 -7.00 and Later FRIEZE 14 -FRIEZE Function Calls 15 -FRIEZE Error Codes 18 - - - - - -Introduction - -This booklet was designed to aid developers and users in understanding -the technical aspects of the .PCX file format and the use of FRIEZE. -Any comments, questions or suggestions about this booklet should be -sent to: - - ZSoft Corporation - Technical Services - ATTN: Code Librarian - 450 Franklin Rd. Suite 100 - Marietta, GA 30067 - - - -Technical Reference Manual information compiled by: -Dean Ansley - - -Revision 5 - -To down load additional information and the source for a complete -Turbo Pascal program to show .PCX files on a CGA/EGA/VGA graphics -display, call our BBS at (404)427-1045. You may use a 9600 baud -modem or a 2400 baud standard modem. Your modem should be set for -8 data bits, 1 stop bit, and NO parity. - -Image File (.PCX) Format - -If you have technical questions on the format, please do not call -technical support. ZSoft provides this document as a courtesy to -its users and developers. It is not the function of Technical Support -to provide programming assistance. If something is not clear, leave a -message on our BBS, Compuserve, or write us a letter at the above address. - -The information in this section will be useful if you want to write a -program to read or write PCX files (images). If you want to write a -special case program for one particular image format you should be able -to produce something that runs twice as fast as "Load from..." in -PC Paintbrush. - -Image files used by PC Paintbrush product family and FRIEZE (those with a -.PCX extension) begin with a 128 byte header. Usually you can ignore this -header, since your images will probably all have the same resolution. If -you want to process different resolutions or colors, you will need to -interpret the header correctly. The remainder of the image file consists -of encoded graphic data. The encoding method is a simple byte oriented -run-length technique. We reserve the right to change this method to -improve space efficiency. When more than one color plane is stored in -the file, each line of the image is stored by color plane (generally ordered -red, green, blue, intensity), As shown below. - -Scan line 0: RRR... (Plane 0) - GGG... (Plane 1) - BBB... (Plane 2) - III... (Plane 3) -Scan line 1: RRR... - GGG... - BBB... - III... (etc.) - -The encoding method is: - FOR each byte, X, read from the file - IF the top two bits of X are 1's then - count = 6 lowest bits of X - data = next byte following X - ELSE - count = 1 - data = X - -Since the overhead this technique requires is, on average, 25% of -the non-repeating data and is at least offset whenever bytes are repeated, -the file storage savings are usually considerable. - -ZSoft .PCX FILE HEADER FORMAT - -Byte Item Size Description/Comments - 0 Manufacturer 1 Constant Flag, 10 = ZSoft .pcx - 1 Version 1 Version information - 0 = Version 2.5 of PC Paintbrush - 2 = Version 2.8 w/palette information - 3 = Version 2.8 w/o palette information - 4 = PC Paintbrush for Windows(Plus for - Windows uses Ver 5) - 5 = Version 3.0 and > of PC Paintbrush - and PC Paintbrush +, includes - Publisher's Paintbrush . Includes - 24-bit .PCX files - 2 Encoding 1 1 = .PCX run length encoding - 3 BitsPerPixel 1 Number of bits to represent a pixel - (per Plane) - 1, 2, 4, or 8 - 4 Window 8 Image Dimensions: Xmin,Ymin,Xmax,Ymax -12 HDpi 2 Horizontal Resolution of image in DPI* -14 VDpi 2 Vertical Resolution of image in DPI* -16 Colormap 48 Color palette setting, see text -64 Reserved 1 Should be set to 0. -65 NPlanes 1 Number of color planes -66 BytesPerLine 2 Number of bytes to allocate for a scanline - plane. MUST be an EVEN number. Do NOT - calculate from Xmax-Xmin. -68 PaletteInfo 2 How to interpret palette- 1 = Color/BW, - 2 = Grayscale (ignored in PB IV/ IV +) -70 HscreenSize 2 Horizontal screen size in pixels. New field - found only in PB IV/IV Plus -72 VscreenSize 2 Vertical screen size in pixels. New field - found only in PB IV/IV Plus -74 Filler 54 Blank to fill out 128 byte header. Set all - bytes to 0 - - NOTES: - -All sizes are measured in BYTES. - -All variables of SIZE 2 are integers. - -*HDpi and VDpi represent the Horizontal and Vertical resolutions which the -image was created (either printer or scanner); i.e. an image which was -scanned might have 300 and 300 in each of these fields. - -Decoding .PCX Files - -First, find the pixel dimensions of the image by calculating -[XSIZE = Xmax - Xmin + 1] and [YSIZE = Ymax - Ymin + 1]. Then calculate -how many bytes are required to hold one complete uncompressed scan line: - -TotalBytes = NPlanes * BytesPerLine - -Note that since there are always an even number of bytes per scan line, -there will probably be unused data at the end of each scan line. TotalBytes -shows how much storage must be available to decode each scan line, including -any blank area on the right side of the image. You can now begin decoding -the first scan line - read the first byte of data from the file. If the -top two bits are set, the remaining six bits in the byte show how many times -to duplicate the next byte in the file. If the top two bits are not set, -the first byte is the data itself, with a count of one. - -Continue decoding the rest of the line. Keep a running subtotal of how -many bytes are moved and duplicated into the output buffer. When the -subtotal equals TotalBytes, the scan line is complete. There should always -be a decoding break at the end of each scan line. But there will not be a -decoding break at the end of each plane within each scan line. When the -scan line is completed, there may be extra blank data at the end of each -plane within the scan line. Use the XSIZE and YSIZE values to find where -the valid image data is. If the data is multi-plane, BytesPerLine shows -where each plane ends within the scan line. - -Continue decoding the remainder of the scan lines (do not just read to -end-of-file). There may be additional data after the end of the image -(palette, etc.) - - Palette Information Description - -EGA/VGA 16 Color Palette Information - -In standard RGB format (IBM EGA, IBM VGA) the data is stored as 16 triples. -Each triple is a 3 byte quantity of Red, Green, Blue values. The values can -range from 0-255, so some interpretation may be necessary. On an IBM EGA, -for example, there are 4 possible levels of RGB for each color. Since -256/4 = 64, the following is a list of the settings and levels: - -Setting Level - 0-63 0 - 64-127 1 -128-192 2 -193-254 3 - -VGA 256 Color Palette Information - -ZSoft has recently added the capability to store palettes containing more -than 16 colors in the .PCX image file. The 256 color palette is formatted -and treated the same as the 16 color palette, except that it is substantially -longer. The palette (number of colors x 3 bytes in length) is appended to -the end of the .PCX file, and is preceded by a 12 decimal. Since the VGA -device expects a palette value to be 0-63 instead of 0-255, you need to -divide the values read in the palette by 4. - -To access a 256 color palette: - -First, check the version number in the header; if it contains a 5 there is -a palette. - -Second, read to the end of the file and count back 769 bytes. The value -you find should be a 12 decimal, showing the presence of a 256 color palette. - - 24-Bit .PCX Files - -24 bit images are stored as version 5 or above as 8 bit, 3 plane images. - -24 bit images do not contain a palette. - -Bit planes are ordered as lines of red, green, blue in that order. - -CGA Color Palette Information - -NOTE: This is no longer supported for PC Paintbrush IV/IV Plus. - -For a standard IBM CGA board, the palette settings are a bit more complex. -Only the first byte of the triple is used. The first triple has a valid -first byte which represents the background color. To find the background, -take the (unsigned) byte value and divide by 16. This will give a result -between 0-15, hence the background color. The second triple has a valid -first byte, which represents the foreground palette. PC Paintbrush supports -8 possible CGA palettes, so when the foreground setting is encoded between -0 and 255, there are 8 ranges of numbers and the divisor is 32. - -CGA Color Map - -Header Byte #16 - -Background color is determined in the upper four bits. - -Header Byte #19 - -Only upper 3 bits are used, lower 5 bits are ignored. The first three bits -that are used are ordered C, P, I. These bits are interpreted as follows: - -c: color burst enable - 0 = color; 1 = monochrome - -p: palette - 0 = yellow; 1 = white - -i: intensity - 0 = dim; 1 = bright - - PC Paintbrush Bitmap Character Format - -NOTE: This format is for PC Paintbrush (up to Vers 3.7) and PC Paintbrush -Plus (up to Vers 1.65) - -The bitmap character fonts are stored in a particularly simple format. The -format of these characters is as follows: - - -Header - -font width byte 0xA0 + character width (in pixels) -font height byte character height (in pixels) - -Character Width Table - -char widths (256 bytes) each char's width + 1 pixel of kerning - -Character Images - -(remainder of the file) starts at char 0 (Null) - -The characters are stored in ASCII order and as many as 256 may be provided. -Each character is left justified in the character block, all characters take -up the same number of bytes. - -Bytes are organized as N strings, where each string is one scan line of the -character. - -For example, each character in a 5x7 font requires 7 bytes. A 9x14 font -uses 28 bytes per character (stored two bytes per scan line in 14 sets of -2 byte packets). Custom fonts may be any size up to the current maximum of -10K bytes allowed for a font file. There is a maximum of 4 bytes per scan -line. - - Sample "C" Routines - -The following is a simple set of C subroutines to read data from a .PCX file. - -/* This procedure reads one encoded block from the image file and stores a -count and data byte. - -Return result: 0 = valid data stored, EOF = out of data in file */ - -encget(pbyt, pcnt, fid) -int *pbyt; /* where to place data */ -int *pcnt; /* where to place count */ -FILE *fid; /* image file handle */ -{ -int i; - *pcnt = 1; /* assume a "run" length of one */ - if (EOF == (i = getc(fid))) - return (EOF); - if (0xC0 == (0xC0 & i)) - { - *pcnt = 0x3F & i; - if (EOF == (i = getc(fid))) - return (EOF); - } - *pbyt = i; - return (0); -} -/* Here's a program fragment using encget. This reads an entire file and -stores it in a (large) buffer, pointed to by the variable "bufr". "fp" is -the file pointer for the image */ - -int i; -long l, lsize; - lsize = (long )hdr.BytesPerLine * hdr.Nplanes * (1 + hdr.Ymax - hdr.Ymin); - for (l = 0; l < lsize; ) /* increment by cnt below */ - { - if (EOF == encget(&chr, &cnt, fp)) - break; - for (i = 0; i < cnt; i++) - *bufr++ = chr; - l += cnt; - } - -The following is a set of C subroutines to write data to a .PCX file. - -/* Subroutine for writing an encoded byte pair (or single byte if it -doesn't encode) to a file. It returns the count of bytes written, 0 if error */ - -encput(byt, cnt, fid) -unsigned char byt, cnt; -FILE *fid; -{ - if (cnt) { - if ((cnt == 1) && (0xC0 != (0xC0 & byt))) - { - if (EOF == putc((int )byt, fid)) - return(0); /* disk write error (probably full) */ - return(1); - } - else - { - if (EOF == putc((int )0xC0 | cnt, fid)) - return (0); /* disk write error */ - if (EOF == putc((int )byt, fid)) - return (0); /* disk write error */ - return (2); - } - } - return (0); -} - - /* This subroutine encodes one scanline and writes it to a file. -It returns number of bytes written into outBuff, 0 if failed. */ - -encLine(inBuff, inLen, fp) -unsigned char *inBuff; /* pointer to scanline data */ -int inLen; /* length of raw scanline in bytes */ -FILE *fp; /* file to be written to */ -{ -unsigned char this, last; -int srcIndex, i; -register int total; -register unsigned char runCount; /* max single runlength is 63 */ - total = 0; - runCount = 1; - last = *(inBuff); - -/* Find the pixel dimensions of the image by calculating -[XSIZE = Xmax - Xmin + 1] and [YSIZE = Ymax - Ymin + 1]. -Then calculate how many bytes are in a "run" */ - - for (srcIndex = 1; srcIndex < inLen; srcIndex++) - { - this = *(++inBuff); - if (this == last) /* There is a "run" in the data, encode it */ - { - runCount++; - if (runCount == 63) - { - if (! (i = encput(last, runCount, fp))) - return (0); - total += i; - runCount = 0; - } - } - else /* No "run" - this != last */ - { - if (runCount) - { - if (! (i = encput(last, runCount, fp))) - return(0); - total += i; - } - last = this; - runCount = 1; - } - } /* endloop */ - if (runCount) /* finish up */ - { - if (! (i = encput(last, runCount, fp))) - return (0); - return (total + i); - } - return (total); -} - - FRIEZE Technical Information - -General FRIEZE Information - -FRIEZE is a memory-resident utility that allows you to capture and save -graphic images from other programs. You can then bring these images into -PC Paintbrush for editing and enhancement. - -FRIEZE 7.10 and later can be removed from memory (this can return you up -to 90K of DOS RAM, depending on your configuration). To remove FRIEZE from -memory, change directories to your paintbrush directory and type the word -"FRIEZE". - -7.00 and Later FRIEZE - -The FRIEZE command line format is: - -FRIEZE {PD} {Xn[aarr]} {flags} {video} {hres} {vres} {vnum} -Where: -{PD} Printer driver filename (without the .PDV extension) -{Xn[aarr]} - X=S for Serial Printer, P for Parallel Printer, D for disk file. - (file is always named FRIEZE.PRN) - n = port number - aa = Two digit hex code for which return bits cause - an abort (optional) - rr = Two digit hex code for which return bits cause - a retry (optional) - NOTE: These codes represent return values from serial or - parallel port BIOS calls. For values see and IBM - BIOS reference (such as Ray Duncan's Advanced MS-DOS - Programming). -{flags}Four digit hex code - First Digit controls Length Flag - Second Digit controls Width Flag - Third Digit controls Mode Flag - Fourth Digit controls BIOS Flag - 0 - None - 1 - Dual Monitor Present - 2 - Use internal (true) B/W palette for dithering - 2 color images - 4 - Capture palette along with screen IN VGA ONLY - Frieze 8.08 & up ONLY) - -NOTE: The length, width and mode flags are printer driver specific. -See PRINTERS.DAT on disk 1 (or Setup Disk) for correct use. In general -width flag of 1 means wide carriage, and 0 means standard width. Length -flag of 0 and mode flag of 0 means use default printer driver settings. - -If you need to use more than one BIOS flag option, add the needed flag values -and use the sum as the flag value. - -{video} Video driver combination, where the leading digit signifies the - high level video driver and the rest signifies the low - level video driver - Example = 1EGA - uses DRIVE1 and EGA.DEV -{hres} Horizontal resolution of the desired graphics mode -{vres} Vertical resolution of the desired graphics mode -{vnum} Hardware specific parameter (usually number of color planes) - -Note: The last four parameters can be obtained from the CARDS.DAT file, -in your PC Paintbrush product directory. - - -FRIEZE Function Calls - -FRIEZE is operated using software interrupt number 10h (the video interrupt -call). - -To make a FRIEZE function call, load 75 (decimal) into the AH register and -the function number into the CL register, then either load AL with the -function argument or load ES and BX with a segment and offset which point -to the function argument. Do an int 10h. FRIEZE will return a result code -number in AX. All other registers are preserved. In general, a result -code of 0 means success and other values indicate errors. However, function -20 (get Frieze Version) behaves differently; see below. -No. Definition Arguments -0 Reserved -1 Load Window - ES:BX - string (filename to read from) -2 Save Window - ES:BX - string (filename to write to) -3 Reserved -4 Reserved -6 Reserved -7 Set Window Size - ES:BX - 4 element word vector of window settings: - Xmin, Ymin, Xmax, Ymax -8 Reserved -9 Set Patterns - ES:BX - 16 element vector of byte values - containing the screen-to-printer color correspondence -10 Get Patterns - ES:BX - room for 16 bytes as above -11 Set Mode -12,13,14 Reserved -15 Get Window - ES:BX - room for 4 words of the current window - settings -16 Set Print Options - ES:BX - character string of printer options. - Same format as for the FRIEZE command. -17, 18, 19 Reserved -20 Get FRIEZE Version. - AH gets the whole number portion and AL gets the - decimal portion of the version number. (eg. for - Freize vesion 7.41, AH will contain 7 and AL will - contain 41. If AH =0, you are calling a pre-7.0 - version of FRIEZE). -21 Set Parameters - ES:BX points to an 8 word table (16 bytes) of - parameter settings: TopMargin, LeftMargin, - HSize,VSize, Quality/Draft Mode, PrintHres, - PrintVres, Reserved. - Margins and sizes are specified in hundredths - of inches. - Q/D mode parameter values: - 0 - draft print mode - 1 - quality print mode - Print resolutions are specified in DPI. - Any parameter which should be left unchanged may - be filled with a (-1) (0FFFF hex). The reserved - settings should be filled with a (-1). -22 Get Parameters - ES:BX points to an 8 word table (16 bytes) where - parameter settings are held. -23 Get Printer Res - ES:BX points to a 12 word table (24 bytes) that - holds six printer resolution pairs. -24 Reserved (versions 8.00 & up) - -FRIEZE Error Codes - -When FRIEZE is called using interrupt 10 hex, it will return an error code -in the AX register. A value of zero shows that there was no error. A -nonzero result means there was an error. These error codes are explained -below. - - 0 No Error - 1 Printout was stopped by user with the ESC key - 2 Reserved - 3 File read error - 4 File write error - 5 File not found - 6 Invalid Header - not an image, wrong screen mode - 7 File close error - 8 Disk error - usually drive door open - 9 Printer error - printer is off or out of paper -10 Invalid command - CL was set to call a nonexistent FRIEZE function -11 Can't create file - write protect tab or disk is full -12 Wrong video mode - FRIEZE cannot capture text screens. - -Technical Reference Manual - -Including information for: -Publisher's Paintbrushr -PC Paintbrush IVTM -PC Paintbrush IV PlusTM -PC Paintbrush PlusTM -PC Paintbrushr -FRIEZETM Graphics -PaintbrushTM -Revision 5 - -ZSoft Corporation -450 Franklin Rd. Suite 100 -Marietta, GA 30067 -(404) 428-0008 -(404) 427-1150 Fax -(404) 427-1045 BBS - -Copyright c 1985, 1987, 1988, 1990, 1991, ZSoft Corporation -All Rights Reserved - - - diff --git a/src/ersky9x/libraries/sam-gui/file/file_fs.h b/src/ersky9x/libraries/sam-gui/file/file_fs.h deleted file mode 100644 index bc9c620b3..000000000 --- a/src/ersky9x/libraries/sam-gui/file/file_fs.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _FILE_FS_ -#define _FILE_FS_ - -#include "fat/fatfs/src/ff.h" - -#if _FS_TINY == 0 -# define STR_ROOT_DIRECTORY "0:" -#else -# define STR_ROOT_DIRECTORY "" -#endif - - -#endif // _FILE_FS_ \ No newline at end of file diff --git a/src/ersky9x/libraries/sam-gui/porting/sam_gui_embos.c b/src/ersky9x/libraries/sam-gui/porting/sam_gui_embos.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/ersky9x/libraries/sam-gui/porting/sam_gui_freertos.c b/src/ersky9x/libraries/sam-gui/porting/sam_gui_freertos.c deleted file mode 100644 index ac38e3d52..000000000 --- a/src/ersky9x/libraries/sam-gui/porting/sam_gui_freertos.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "sam_gui_porting.h" - -#if SAM_PORTING == SAM_PORTING_FREERTOS - -extern void SAMGUI_TaskDelay( uint32_t dwDelayMs ) -{ - vTaskDelay( dwDelayMs/portTICK_RATE_MS ) ; -} - -extern int SAMGUI_TaskCreate( SAMGUI_fnTask fnTask, const uint8_t* pucName, uint8_t* pucStack, uint32_t dwStackSize, - uint32_t dwPriority, void* pvParameters, SAMGUI_TaskHandle* pHandle ) -{ - xTaskCreate( fnTask, (signed char const*)pucName, dwStackSize, pvParameters, tskIDLE_PRIORITY, pHandle ) ; - - return (pHandle != NULL) ; -} - -extern void SAMGUI_TaskDelete( SAMGUI_TaskHandle Handle ) -{ - vTaskDelete( Handle ) ; -} - -#endif // SAM_PORTING == SAM_PORTING_FREERTOS diff --git a/src/ersky9x/libraries/sam-gui/porting/sam_gui_nuttx.c b/src/ersky9x/libraries/sam-gui/porting/sam_gui_nuttx.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/ersky9x/libraries/sam-gui/porting/sam_gui_porting.h b/src/ersky9x/libraries/sam-gui/porting/sam_gui_porting.h deleted file mode 100644 index 019304c84..000000000 --- a/src/ersky9x/libraries/sam-gui/porting/sam_gui_porting.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _SAM_GUI_PORTING_ -#define _SAM_GUI_PORTING_ - -#include - -#define SAM_PORTING_FREERTOS 1 -#define SAM_PORTING_EMBOS 2 -#define SAM_PORTING_NUTTX 3 - -//#define SAM_PORTING SAM_PORTING_FREERTOS - -#if !defined SAM_PORTING - #error SAM_PORTING must be defined -#endif - -/* - * Definitions for FreeRTOs - */ -#if SAM_PORTING == SAM_PORTING_FREERTOS -// FreeRTOS includes -# include "FreeRTOS.h" -# include "task.h" - -# define SAMGUI_TaskHandle xTaskHandle -#endif // SAM_PORTING == SAM_PORTING_FREERTOS - - -typedef void (*SAMGUI_fnTask)( void* pvParam ) ; - -extern void SAMGUI_TaskDelay( uint32_t dwDelayMs ) ; - -extern int SAMGUI_TaskCreate( SAMGUI_fnTask fnTask, const uint8_t* pucName, uint8_t* pucStack, uint32_t dwStackSize, - uint32_t dwPriority, void* pvParameters, SAMGUI_TaskHandle* pHandle ) ; - -void SAMGUI_TaskDelete( SAMGUI_TaskHandle Handle ) ; - -#endif // _SAM_GUI_PORTING_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.c deleted file mode 100644 index 7ff4e7220..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.c +++ /dev/null @@ -1,198 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/porting/sam_gui_porting.h" -#include "disp/disp_backend.h" -#include "sam-gui/common/sam_gui_font.h" -#include "tsd/tsd_ads7843.h" -#include "sam-gui/common/sam_gui_colors.h" -#include "sam-gui/wgt/core/wgt_core_behaviour.h" - -#include -#include - -#include "board.h" -#include "lcd/color.h" - -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" - -#define WGT_CORE_MSG_QUEUE_SIZE 32 - -SWGTCoreData g_WGT_CoreData ; - -// ------------------------------------------------------------------------------------------------ - -/** \brief -*/ -static void _WGT_TaskMessageLoop( void* pParameter ) -{ - SWGTCoreData* pData=(SWGTCoreData*)pParameter ; - SWGTCoreMessage xMessage ; - - WGT_Start() ; - - for ( ; ; ) - { - // Wait for a widget message - -// if ( xQueueReceive( pData->hMessagesQueue, &xMessage, portMAX_DELAY ) == pdPASS ) - if ( xQueueReceive( pData->hMessagesQueue, &xMessage, g_WGT_CoreData.dwTimerDelay/portTICK_RATE_MS ) == pdTRUE ) - { - if ( g_WGT_CoreData.pCurrentScreen != NULL ) - { - PreProcessMessage_Default( g_WGT_CoreData.pCurrentScreen, &xMessage ) ; - } - } - else // delay, send timer - { - if ( g_WGT_CoreData.pCurrentScreen != NULL ) - { - xMessage.dwID=WGT_MSG_TIMER ; - if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage( g_WGT_CoreData.pCurrentScreen, &xMessage ) == SAMGUI_E_OK ) - { - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ - -/** \brief -*/ -extern uint32_t WGT_Initialize( void ) -{ - uint32_t dwError ; - - // Set Timer Delay to 1s - g_WGT_CoreData.dwTimerDelay=1000 ; - - // Create the queue used by the Messages task. - g_WGT_CoreData.hMessagesQueue=xQueueCreate( WGT_CORE_MSG_QUEUE_SIZE, sizeof( SWGTCoreMessage ) ) ; - - // Create the Messages task. - xTaskCreate( _WGT_TaskMessageLoop, "WGT_ML", 512, &g_WGT_CoreData, tskIDLE_PRIORITY+1, NULL ) ; - - // Initialize LCD backend. - dwError=DISP_GetBackend( DISP_BACKEND_ILI9325, &g_WGT_CoreData.pBE ) ; - if ( dwError != SAMGUI_E_OK ) - { - printf( "_TaskLCD - Error getting Backend (%x)\r\n", dwError ) ; - return dwError ; - } - - // Initialize frontends. - WGT_Frontend_Initialize() ; - - return SAMGUI_E_OK ; -} - -/** \brief -*/ -extern uint32_t WGT_Start( void ) -{ - SGUIColor clrWhite={ .u.dwRGBA=COLOR_WHITE } ; - - // Initialize backend. - g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_POWER_OFF, NULL, NULL ) ; - g_WGT_CoreData.pBE->Initialize() ; - -// g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_SET_BACKLIGHT, (uint32_t*)1, NULL ) ; - - g_WGT_CoreData.pBE->DrawFilledRectangle( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, NULL, &clrWhite ) ; - g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_POWER_ON, NULL, NULL ) ; - - // Initialize frontends. - if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_ADS7843, &g_WGT_CoreData.pTSD ) == SAMGUI_E_OK ) - { - g_WGT_CoreData.pTSD->Initialize() ; - } - - if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_PUSHBUTTONS, &g_WGT_CoreData.pPushbuttons ) == SAMGUI_E_OK ) - { - g_WGT_CoreData.pPushbuttons->Initialize() ; - } - - if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_POTENTIOMETER, &g_WGT_CoreData.pPotentiometer ) == SAMGUI_E_OK ) - { - g_WGT_CoreData.pPotentiometer->Initialize() ; - } - - if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_QTOUCH, &g_WGT_CoreData.pQTouch ) == SAMGUI_E_OK ) - { - g_WGT_CoreData.pQTouch->Initialize() ; - } - - return SAMGUI_E_OK ; -} - -/** \brief -*/ -extern uint32_t WGT_SetTimerPeriod( uint32_t dwDelay ) -{ - uint32_t dw ; - - dw=g_WGT_CoreData.dwTimerDelay ; - g_WGT_CoreData.dwTimerDelay=dwDelay ; - - return dw ; -} - -/** \brief -*/ -extern uint32_t WGT_GetTimerPeriod( void ) -{ - return g_WGT_CoreData.dwTimerDelay ; -} - -/** \brief -*/ -extern uint32_t WGT_SetCurrentScreen( SWGTScreen* pScreen ) -{ - if ( pScreen == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - g_WGT_CoreData.pCurrentScreen=pScreen ; - - WGT_PostMessage( WGT_MSG_INIT, 0, 0 ) ; - WGT_PostMessage( WGT_MSG_ERASE_BKGND, 0, 0 ) ; - WGT_PostMessage( WGT_MSG_PAINT, 0, 0 ) ; - - return SAMGUI_E_OK ; -} - - - - diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.h deleted file mode 100644 index aea6db797..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WIDGET_CORE_ -#define _SAMGUI_WIDGET_CORE_ - -//#include "common/sam_gui_color.h" -#include "common/sam_gui_font.h" -//#include "common/sam_gui_point.h" -//#include "common/sam_gui_size.h" -#include "disp/disp_backend.h" -//#include "sam-gui/wgt/core/wgt_core_widget.h" -#include "sam-gui/wgt/core/wgt_core_screen.h" -#include "sam-gui/wgt/core/wgt_core_frontend.h" - -#include "FreeRTOS.h" -#include "queue.h" - -typedef struct _SWGTCoreData -{ - xQueueHandle hMessagesQueue ; - - SDISPBackend* pBE ; - - SWGTFrontend* pTSD ; - SWGTFrontend* pQTouch ; - SWGTFrontend* pPotentiometer ; - SWGTFrontend* pPushbuttons ; - - SWGTScreen* pCurrentScreen ; - uint32_t dwTimerDelay ; -} SWGTCoreData ; - -extern SWGTCoreData g_WGT_CoreData ; - -// ------------------------------------------------------------------------------------------------ - -extern uint32_t WGT_Initialize( void ) ; -extern uint32_t WGT_Start( void ) ; - -extern uint32_t WGT_SetTimerPeriod( uint32_t dwDelay ) ; -extern uint32_t WGT_GetTimerPeriod( void ) ; - -extern uint32_t WGT_SetCurrentScreen( SWGTScreen* pScreen ) ; - -#endif // _SAMGUI_WIDGET_CORE_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.c deleted file mode 100644 index e69e0e033..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.h deleted file mode 100644 index 9dbf615dc..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WIDGET_CORE_BEHAVIOUR_ -#define _SAMGUI_WIDGET_CORE_BEHAVIOUR_ - -extern uint32_t PreProcessMessage_Default( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) ; - -#endif // _SAMGUI_WIDGET_CORE_BEHAVIOUR_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour_default.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour_default.c deleted file mode 100644 index 164f45c43..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_behaviour_default.c +++ /dev/null @@ -1,130 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/common/sam_gui_colors.h" -#include - -#include "FreeRTOS.h" -#include "task.h" - -extern uint32_t PreProcessMessage_Default( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) -{ - SWGT_Widget* pWidget ; - SGUIColor clrBlack={ .u.dwRGBA=GUICLR_BLACK } ; - static uint32_t dwPointerTimeStampOld=0 ; - static uint32_t dwPointerTimeStamp=0 ; - - // Intercept special message for code factorization - switch ( pMsg->dwID ) - { - case WGT_MSG_POINTER : - // Draw point -// g_WGT_CoreData.pBE->DrawPixel( pMsg->dwParam1, pMsg->dwParam2, &clrBlack ) ; - - if ( WGT_Screen_GetPointedWidget( g_WGT_CoreData.pCurrentScreen, pMsg->dwParam1, pMsg->dwParam2, &pWidget ) == SAMGUI_E_OK ) - { - if ( WGT_Screen_SetSelectedWidget( g_WGT_CoreData.pCurrentScreen, pWidget ) == SAMGUI_E_OK ) - { - } - } - break ; - - case WGT_MSG_POINTER_RELEASED : -#if 0 - dwPointerTimeStampOld=dwPointerTimeStamp ; - dwPointerTimeStamp=xTaskGetTickCount() ; - - printf( "PreProcessMessage_Default - double tap %u %u\r\n", dwPointerTimeStampOld, dwPointerTimeStamp ) ; - // Check double tap - if ( ((dwPointerTimeStamp-dwPointerTimeStampOld) > 300) && - ((dwPointerTimeStamp-dwPointerTimeStampOld) < 1000) ) - { - if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK ) - { - WGT_PostMessage( WGT_MSG_WIDGET_SELECTED, (uint32_t)pWidget, 0 ) ; - } - } -#else - if ( WGT_Screen_GetPointedWidget( g_WGT_CoreData.pCurrentScreen, pMsg->dwParam1, pMsg->dwParam2, &pWidget ) == SAMGUI_E_OK ) - { - if ( WGT_Screen_SetSelectedWidget( g_WGT_CoreData.pCurrentScreen, pWidget ) == SAMGUI_E_OK ) - { - WGT_PostMessage( WGT_MSG_WIDGET_SELECTED, (uint32_t)pWidget, 0 ) ; - } - } - -#endif - // pointer has been released, repaint last selected widget -// if ( pScreen->pWidgetCurrent != NULL ) -// { -// WGT_Draw( pScreen->pWidgetCurrent, g_WGT_CoreData.pBE ) ; -// pScreen->pWidgetOld=pScreen->pWidgetCurrent=NULL ; -// } - break ; - - case WGT_MSG_INIT : - // Reset selected widget - pScreen->pWidgetOld=pScreen->pWidgetCurrent=NULL ; - if ( g_WGT_CoreData.pCurrentScreen->OnInitialize ) - { - g_WGT_CoreData.pCurrentScreen->OnInitialize( g_WGT_CoreData.pCurrentScreen ) ; - } - break ; - - case WGT_MSG_ERASE_BKGND : - WGT_Screen_OnEraseBackground( g_WGT_CoreData.pCurrentScreen ) ; - - if ( g_WGT_CoreData.pCurrentScreen->OnEraseBackground ) - { - g_WGT_CoreData.pCurrentScreen->OnEraseBackground( g_WGT_CoreData.pCurrentScreen ) ; - } - break ; - - case WGT_MSG_PAINT : - WGT_Screen_OnPaint( g_WGT_CoreData.pCurrentScreen ) ; - - if ( g_WGT_CoreData.pCurrentScreen->OnPaint ) - { - g_WGT_CoreData.pCurrentScreen->OnPaint( g_WGT_CoreData.pCurrentScreen ) ; - } - break ; - } - - // Send message to screen main callbacks - if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage != NULL ) - { - if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage( g_WGT_CoreData.pCurrentScreen, pMsg ) == SAMGUI_E_OK ) - { - } - } - - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.c deleted file mode 100644 index 34d559f9e..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.c +++ /dev/null @@ -1,84 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core_frontend.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/wgt/frontends/frontend_ADS7843.h" -#include "sam-gui/wgt/frontends/frontend_pushbuttons.h" -#include "sam-gui/wgt/frontends/frontend_potentiometer.h" -#include "sam-gui/wgt/frontends/frontend_qtouch.h" -#include -#include - -#define TRACE( x ) x -//#define TRACE( x ) - -static __no_init SWGTFrontend* _aWGT_Frontends[WGT_FRONTEND_MAX] ; - -extern uint32_t WGT_Frontend_Initialize( void ) -{ - _aWGT_Frontends[WGT_FRONTEND_ADS7843]=(void*)&sWGT_Frontend_ADS7843 ; - _aWGT_Frontends[WGT_FRONTEND_PUSHBUTTONS]=(void*)&sWGT_Frontend_PushButtons ; - _aWGT_Frontends[WGT_FRONTEND_POTENTIOMETER]=(void*)&sWGT_Frontend_Potentiometer ; - _aWGT_Frontends[WGT_FRONTEND_QTOUCH]=(void*)&sWGT_Frontend_QTouch ; - -// for ( int i=0 ; i < WGT_FRONTEND_MAX ; i++ ) -// { -// TRACE( printf( "WGT_Frontend_Initialize - [%d] %x\r\n", i, _aWGT_Frontends[i] ) ; ) -// } - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Frontend_GetFrontend( uint32_t dwIndex, SWGTFrontend** ppFrontend ) -{ - // Check pointers - if ( ppFrontend == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // Check parameters consistency - if ( dwIndex >= WGT_FRONTEND_MAX ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - if ( _aWGT_Frontends[dwIndex]->sData.dwId != dwIndex ) - { - TRACE( printf( "WGT_Frontend_GetFrontend - Inconsistent frontend %x/%x\r\n", dwIndex, _aWGT_Frontends[dwIndex]->sData.dwId ) ; ) - return SAMGUI_E_WRONG_COMPONENT ; - } - - *ppFrontend=_aWGT_Frontends[dwIndex] ; -// TRACE( printf( "WGT_Frontend_GetFrontend - %x %x\r\n", _aWGT_Frontends[dwIndex], *ppFrontend ) ; ) - - return SAMGUI_E_OK ; -} - diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.h deleted file mode 100644 index ce59a3ec8..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_frontend.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAM_GUI_WGT_FRONTEND_ -#define _SAM_GUI_WGT_FRONTEND_ - -typedef struct _SWGTFrontendData -{ - uint32_t dwId ; -} sWGTFrontendData ; - -typedef struct _SWGTFrontend -{ - sWGTFrontendData sData ; - - uint32_t (*Initialize)( void ) ; - - uint32_t (*IOCtl)( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) ; -} SWGTFrontend ; - -#define WGT_FRONTEND_IOCTL_SET_DATA 0x01L - -typedef enum _WGT_eFrontend -{ - WGT_FRONTEND_ADS7843, - WGT_FRONTEND_PUSHBUTTONS, - WGT_FRONTEND_POTENTIOMETER, - WGT_FRONTEND_QTOUCH, - WGT_FRONTEND_MAX -} WGT_eFrontend ; - -extern uint32_t WGT_Frontend_Initialize( void ) ; -extern uint32_t WGT_Frontend_GetFrontend( uint32_t dwIndex, SWGTFrontend** ppFrontend ) ; - -#endif // _SAM_GUI_WGT_FRONTEND_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.c deleted file mode 100644 index 6ed71d188..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.c +++ /dev/null @@ -1,112 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core_message.h" -#include "sam-gui/wgt/core/wgt_core.h" -#include "sam-gui/common/sam_gui_errors.h" -#include - -/** \brief -*/ -extern uint32_t WGT_SendMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Send message - if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -/** \brief -*/ -extern uint32_t WGT_PostMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Post message - if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -/** \brief -*/ -extern uint32_t WGT_SendMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Send message - if ( xQueueSendToFrontFromISR( g_WGT_CoreData.hMessagesQueue, &sMsg, NULL ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -/** \brief -*/ -extern uint32_t WGT_PostMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Post message - if ( xQueueSendToBackFromISR( g_WGT_CoreData.hMessagesQueue, &sMsg, NULL ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -// signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) -// signed portBASE_TYPE xQueueGenericSend ( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.h deleted file mode 100644 index 86f82ee40..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_message.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WIDGET_CORE_MESSAGE_ -#define _SAMGUI_WIDGET_CORE_MESSAGE_ - -typedef enum _WGT_Message -{ - WGT_MSG_INIT, // 0 - WGT_MSG_ERASE_BKGND, // 1 - WGT_MSG_PAINT, // 2 - WGT_MSG_TIMER, // 3 - WGT_MSG_POINTER_RAW, // 4 - WGT_MSG_POINTER, // 5 - WGT_MSG_POINTER_PRESSED, // 6 - WGT_MSG_POINTER_RELEASED, // 7 - WGT_MSG_WIDGET_SELECTED, // 8 - WGT_MSG_KEY_PRESSED, // 9 - WGT_MSG_KEY_RELEASED, // 10 - WGT_MSG_USER1, // 11 - WGT_MSG_USER2, - WGT_MSG_USER3, - WGT_MSG_USER4, - WGT_MSG_USER5, - WGT_MSG_MAX -} WGT_Message ; - -typedef enum _SWGT_KeyCode -{ - WGT_KEY_NRST, - WGT_KEY_PB1, - WGT_KEY_PB2, - WGT_KEY_K1, - WGT_KEY_K2, - WGT_KEY_K3, - WGT_KEY_K4, - WGT_KEY_K5, - WGT_KEY_S1, - WGT_KEY_VR1 -} SWGT_KeyCode ; - -typedef struct _SWGTCoreMessage -{ - uint32_t dwID ; - uint32_t dwParam1 ; - uint32_t dwParam2 ; -} SWGTCoreMessage ; - -extern uint32_t WGT_SendMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -extern uint32_t WGT_PostMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -extern uint32_t WGT_SendMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -extern uint32_t WGT_PostMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; - -#endif // _SAMGUI_WIDGET_CORE_MESSAGE_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.c deleted file mode 100644 index ea1876df2..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core_pointer.h" -#include "sam-gui/common/sam_gui_errors.h" - -static uint32_t _WGT_Pointer_dwStatus=0 ; - - -extern void WGT_Pointer_Disable( void ) -{ - _WGT_Pointer_dwStatus=0 ; -} - -extern void WGT_Pointer_Enable( void ) -{ - _WGT_Pointer_dwStatus=1 ; -} - -extern uint32_t WGT_Pointer_SetBitmap( void ) -{ - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Pointer_Draw( void ) -{ - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.h deleted file mode 100644 index c874a7e75..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_pointer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _WGT_CORE_POINTER_ -#define _WGT_CORE_POINTER_ - -extern void WGT_Pointer_Disable( void ) ; -extern void WGT_Pointer_Enable( void ) ; - -extern uint32_t WGT_Pointer_SetBitmap( void ) ; - -extern uint32_t WGT_Pointer_Draw( void ) ; - -#endif // _WGT_CORE_POINTER_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.c deleted file mode 100644 index 0c66e774a..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.c +++ /dev/null @@ -1,307 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core_screen.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "common/sam_gui_color.h" -#include "sam-gui/wgt/core/wgt_core.h" -#include "sam-gui/common/sam_gui_colors.h" -#include "board.h" -#include -#include - -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" - -// ------------------------------------------------------------------------------------------------ -// Screen functions -// ------------------------------------------------------------------------------------------------ -extern uint32_t WGT_Screen_Initialize( SWGTScreen* pScreen, uint32_t dwClrBackground, uint8_t* pucBmpBackground ) -{ - memset( pScreen->apWidgets, 0, sizeof( pScreen->apWidgets ) ) ; - pScreen->dwWidgets=0 ; - pScreen->pWidgetOld=NULL ; - pScreen->pWidgetCurrent=NULL ; - - pScreen->dwClrBackground=dwClrBackground ; - pScreen->pucBmpBackground=pucBmpBackground ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_AddWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) -{ - if ( pScreen->dwWidgets == WGT_MAX_WIDGETS ) - { - printf( "WGT_Screen_AddWidget - too much\r\n" ) ; - return SAMGUI_E_TOO_MUCH_WIDGETS ; - } - - pScreen->apWidgets[pScreen->dwWidgets]=pWidget ; - pWidget->dwID=pScreen->dwWidgets ; - - pScreen->dwWidgets++ ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_GetPointedWidget( SWGTScreen* pScreen, uint32_t dwX, uint32_t dwY, SWGT_Widget** ppWidget ) -{ - uint32_t dw ; - - if ( pScreen == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) - { - if ( pScreen->apWidgets[dw] ) - { - // Check bounding box - if ( (dwX >= pScreen->apWidgets[dw]->dwX) && (dwX < pScreen->apWidgets[dw]->dwX+pScreen->apWidgets[dw]->dwWidth) && - (dwY >= pScreen->apWidgets[dw]->dwY) && (dwY < pScreen->apWidgets[dw]->dwY+pScreen->apWidgets[dw]->dwHeight) ) - { - if ( pScreen->apWidgets[dw]->dwType == WGT_TYPE_BUTTON ) - { - if ( ppWidget != NULL ) - { - *ppWidget=pScreen->apWidgets[dw] ; - } - - return SAMGUI_E_OK ; - } - } - } - } - - return SAMGUI_E_NO_SELECTED_WIDGET ; -} - -extern uint32_t WGT_Screen_GetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget** ppWidget ) -{ - if ( pScreen == NULL ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - if ( ppWidget != NULL ) - { - *ppWidget=pScreen->pWidgetCurrent ; - - return SAMGUI_E_OK ; - } - - return SAMGUI_E_BAD_POINTER ; -} - -extern uint32_t WGT_Screen_SetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) -{ - uint32_t dw ; - SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ; - - if ( pScreen == NULL ) - { - return SAMGUI_E_BAD_PARAMETER ; - } - - for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) - { - if ( pScreen->apWidgets[dw] == pWidget ) - { - pScreen->pWidgetCurrent=pWidget ; - - if ( pScreen->pWidgetOld != pScreen->pWidgetCurrent ) - { - printf( "Widget changed\r\n" ) ; - // Selected widget changed, repaint previous one - if ( pScreen->pWidgetOld != NULL ) - { - WGT_Draw( pScreen->pWidgetOld, g_WGT_CoreData.pBE ) ; - } - - g_WGT_CoreData.pBE->DrawRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth-1, pWidget->dwY+pWidget->dwHeight-1, &clrSelection ) ; - pScreen->pWidgetOld=pScreen->pWidgetCurrent ; - } - - return SAMGUI_E_OK ; - } - } - - return SAMGUI_E_INVALID_WIDGET ; -} - -//extern uint32_t WGT_Screen_SelectNextWidget( SWGTScreen* pScreen ) -//{ -// uint32_t dw ; -// uint32_t dwIndex=WGT_MAX_WIDGETS ; -// uint32_t dwIndexNext=WGT_MAX_WIDGETS ; -// -// SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ; -// -// if ( pScreen == NULL ) -// { -// return SAMGUI_E_BAD_PARAMETER ; -// } -// -// for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) -// { -// if ( pScreen->apWidgets[dw] == pScreen->pWidgetCurrent ) -// { -// // Got selected -// dwIndex=dw ; -// break ; -// } -// } -// -// // Did we find the current selected button? -// if ( dwIndex != WGT_MAX_WIDGETS ) -// { -// // Find next button -// for ( dw=dwIndex ; dw < pScreen->dwWidgets ; dw++ ) -// { -// if ( pScreen->apWidgets[dw]->dwType == WGT_TYPE_BUTTON ) -// { -// // Got selected -// dwIndexNext=dw ; -// break ; -// } -// } -// -// } -// -// return SAMGUI_E_OK ; -//} -// -//extern uint32_t WGT_Screen_SelectPreviousWidget( SWGTScreen* pScreen ) -//{ -// return SAMGUI_E_OK ; -//} - -extern uint32_t WGT_Screen_OnPaint( SWGTScreen* pScreen ) -{ - uint32_t dw ; - - for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) - { - if ( pScreen->apWidgets[dw] ) - { - WGT_Draw( pScreen->apWidgets[dw], g_WGT_CoreData.pBE ) ; - } - } - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_OnEraseBackground( SWGTScreen* pScreen ) -{ - if ( pScreen->pucBmpBackground == NULL ) - { - SGUIColor clr={ .u.dwRGBA=pScreen->dwClrBackground } ; - - g_WGT_CoreData.pBE->DrawFilledRectangle( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, NULL, &clr ) ; - } - else - { - g_WGT_CoreData.pBE->DrawBitmap( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, pScreen->pucBmpBackground ) ; - } - - return SAMGUI_E_OK ; -} - -#if 0 -extern uint32_t WGT_Screen_SendMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Send message - if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_SendMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Send message - if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_PostMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Post message - if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Screen_PostMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) -{ - SWGTCoreMessage sMsg ; - - sMsg.dwID=dwMsgID ; - sMsg.dwParam1=dwParam1 ; - sMsg.dwParam2=dwParam2 ; - - // Post message - if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS ) - { - return SAMGUI_E_MSQUEUE ; - } - - return SAMGUI_E_OK ; -} -#endif // 0 diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.h deleted file mode 100644 index 1c56a1cf8..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_screen.h +++ /dev/null @@ -1,81 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WIDGET_CORE_SCREEN_ -#define _SAMGUI_WIDGET_CORE_SCREEN_ - -#include "sam-gui/wgt/core/wgt_core_widget.h" -#include "sam-gui/wgt/core/wgt_core_message.h" -//#include "sam-gui/wgt/core/wgt_core.h" - -#define WGT_MAX_WIDGETS 16 - -typedef struct _SWGTScreen -{ - // Data members - SWGT_Widget* apWidgets[WGT_MAX_WIDGETS] ; // array of widgets - uint32_t dwWidgets ; // number of widgets - uint32_t dwClrBackground ; // screen background color - uint8_t* pucBmpBackground ; // screen background bitmap - SWGT_Widget* pWidgetOld ; // previously selected widget - SWGT_Widget* pWidgetCurrent ; // current selected widget - - // Callbacks - uint32_t (*ProcessMessage)( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) ; - - uint32_t (*OnInitialize)( struct _SWGTScreen* pScreen ) ; - uint32_t (*OnEraseBackground)( struct _SWGTScreen* pScreen ) ; - uint32_t (*OnPaint)( struct _SWGTScreen* pScreen ) ; -} SWGTScreen ; - - -// ------------------------------------------------------------------------------------------------ -// Screen functions -extern uint32_t WGT_Screen_Initialize( SWGTScreen* pScreen, uint32_t dwClrBackground, uint8_t* pvBmpBackground ) ; -extern uint32_t WGT_Screen_AddWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) ; -extern uint32_t WGT_Screen_GetPointedWidget( SWGTScreen* pScreen, uint32_t dwX, uint32_t dwY, SWGT_Widget** ppWidget ) ; - -extern uint32_t WGT_Screen_GetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget** ppWidget ) ; -extern uint32_t WGT_Screen_SetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) ; -//extern uint32_t WGT_Screen_SelectNextWidget( SWGTScreen* pScreen ) ; -//extern uint32_t WGT_Screen_SelectPreviousWidget( SWGTScreen* pScreen ) ; - -// -extern uint32_t WGT_Screen_OnPaint( SWGTScreen* pScreen ) ; -extern uint32_t WGT_Screen_OnEraseBackground( SWGTScreen* pScreen ) ; - -#if 0 -extern uint32_t WGT_Screen_SendMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -extern uint32_t WGT_Screen_SendMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; - -extern uint32_t WGT_Screen_PostMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -extern uint32_t WGT_Screen_PostMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ; -#endif // 0 - -#endif // _SAMGUI_WIDGET_CORE_SCREEN_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.c deleted file mode 100644 index d5cd6c327..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "sam-gui/wgt/core/wgt_core_timer.h" -#include "porting/sam_gui_porting.h" -#include "sam-gui/common/sam_gui_errors.h" -#include - -static __no_init SWGTTimer* gs_apWGTTimers[WGT_TIMER_MAX] ; - -extern uint32_t WGT_Timer_Create( SWGTTimer* pTimer, uint32_t dwID, uint32_t dwDelay ) -{ - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Timer_Start( SWGTTimer* pTimer ) -{ - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Timer_Stop( SWGTTimer* pTimer ) -{ - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Timer_Initialize( void ) -{ - memset( gs_apWGTTimers, 0, sizeof( gs_apWGTTimers ) ) ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_Timer_Process( void ) -{ - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.h deleted file mode 100644 index 4f940cce5..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_timer.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WIDGET_CORE_TIMER_ -#define _SAMGUI_WIDGET_CORE_TIMER_ - -//#include "sam-gui/wgt/core/wgt_core_message.h" -//#include "sam-gui/wgt/core/wgt_core.h" - -// Max available timers -#define WGT_TIMER_MAX 4 - -typedef enum _eWGTTimer_State -{ - WGT_TIMER_DISABLED, // 0 - WGT_TIMER_ENABLED -} eWGTTimer_State ; - -typedef struct _SWGTTimer -{ - uint32_t dwState ; - uint32_t dwID ; - uint32_t dwDelay ; - uint32_t dwTimestamp ; -} SWGTTimer ; - -// ------------------------------------------------------------------------------------------------ -// Timer functions - -extern uint32_t WGT_Timer_Create( SWGTTimer* pTimer, uint32_t dwID, uint32_t dwDelay ) ; -extern uint32_t WGT_Timer_Start( SWGTTimer* pTimer ) ; -extern uint32_t WGT_Timer_Stop( SWGTTimer* pTimer ) ; - -extern uint32_t WGT_Timer_Initialize( void ) ; -extern uint32_t WGT_Timer_Process( void ) ; - -#endif // _SAMGUI_WIDGET_CORE_TIMER_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.c b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.c deleted file mode 100644 index 33a272b2c..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.c +++ /dev/null @@ -1,225 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/core/wgt_core_widget.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/file/file_fs.h" -#include "drivers/utility/bmp.h" -#include "freertos.h" -#include -#include - -// ------------------------------------------------------------------------------------------------ -// Widget functions -// ------------------------------------------------------------------------------------------------ -extern uint32_t WGT_CreateWidget( SWGT_Widget* pWidget, WGT_Type eType, uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight ) -{ - if ( pWidget == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - memset( pWidget, 0, sizeof( SWGT_Widget ) ) ; - pWidget->dwType=eType ; - pWidget->dwX=dwX ; - pWidget->dwY=dwY ; - pWidget->dwWidth=dwWidth ; - pWidget->dwHeight=dwHeight ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_SetBkgndColor( SWGT_Widget* pWidget, uint32_t dwColor ) -{ - if ( pWidget == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - pWidget->dwClrBackground=dwColor ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_SetTextColor( SWGT_Widget* pWidget, uint32_t dwColor ) -{ - if ( pWidget == NULL ) - { - return SAMGUI_E_BAD_POINTER ; - } - - pWidget->dwClrText=dwColor ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_SetText( SWGT_Widget* pWidget, char* pszText ) -{ - if ( (pWidget == NULL) || (pszText == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - pWidget->pvText=pszText ; - - return SAMGUI_E_OK ; -} - -extern uint32_t WGT_SetBitmap( SWGT_Widget* pWidget, uint8_t* pucBitmap ) -{ - if ( (pWidget == NULL) || (pucBitmap == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - pWidget->pvBitmap=pucBitmap ; - - return SAMGUI_E_OK ; -} - -//static uint32_t WGT_DrawBMPFile( SWGT_Widget* pWidget, SDISPBackend* pBE ) -//{ -// uint32_t dwLine ; -// uint8_t* pucLine=NULL ; -// FIL fp ; -// struct BMPHeader sHeader ; -// uint32_t dwLineLength ; -// uint32_t dwLength ; -// uint32_t dwTemp ; -// -// if ( (pWidget == NULL) || (pBE == NULL) ) -// { -// return SAMGUI_E_BAD_POINTER ; -// } -// -// // Read first 256 bytes to obtain header -// if ( f_open( &fp, pWidget->pvBitmap, FA_OPEN_EXISTING|FA_READ ) == FR_OK ) -// { -// if ( f_read( &fp, &sHeader, sizeof( sHeader ), &dwLength ) == FR_OK ) -// { -//// printf( "read %c%c\r\n", (char)(sHeader.type&0xff), (char)(sHeader.type>>8) ) ; -//// printf( " -> .compression = %u\n\r", sHeader.compression ) ; -//// printf( " -> .width = %u\n\r", sHeader.width ) ; -//// printf( " -> .height = %u\n\r", sHeader.height ) ; -//// printf( " -> .bits = %u\n\r", sHeader.bits ) ; -// -// dwLineLength=(((sHeader.width*sHeader.bits)+31)/32)*4 ; -// printf( "free heap %u, needed %u\r\n", xPortGetFreeHeapSize(), dwLineLength ) ; -// -// // if header is Windows BMP 24bpp, alloc line size bytes on HEAP -// if ( (sHeader.bits == 24) ) //&& (dwLineLength >= xPortGetFreeHeapSize()) ) -// { -// // Allocate line buffer -// pucLine=pvPortMalloc( dwLineLength ) ; -// if ( pucLine ) -// { -// // Move file pointer to begin of BMP data -// f_lseek( &fp, sHeader.offset ) ; -// -// // Read each bitmap line and write it on backend -// for ( dwLine=0 ; dwLine < pWidget->dwHeight ; dwLine++ ) -// { -// if ( f_read( &fp, pucLine, dwLineLength, &dwLength ) == FR_OK ) -// { -// for ( dwLength=0 ; dwLength < dwLineLength ; dwLength+=3 ) -// { -// dwTemp=pucLine[dwLength] ; ; -// pucLine[dwLength]=pucLine[dwLength+2] ; -// pucLine[dwLength+2]=dwTemp ; ; -// } -// -// pBE->DrawBitmap( pWidget->dwX, pWidget->dwY+pWidget->dwHeight-dwLine, pWidget->dwWidth, 1, pucLine ) ; -// } -// } -// -// // Free line buffer -// vPortFree( pucLine ) ; -// } -// } -// } -// else -// { -// printf( "failed to read\r\n" ) ; -// } -// f_close( &fp ) ; -// return SAMGUI_E_OK ; -// } -// else -// { -// printf( "failed to open %s\r\n", pWidget->pvBitmap ) ; -// } -// -// return SAMGUI_E_FILE_OPEN ; -//} - -extern uint32_t WGT_Draw( SWGT_Widget* pWidget, SDISPBackend* pBE ) -{ - SGUIColor clr ; - - if ( (pWidget == NULL) || (pBE == NULL) ) - { - return SAMGUI_E_BAD_POINTER ; - } - - // if bitmap declared, draw it - if ( pWidget->pvBitmap != NULL ) - { - // Check whether if bitmap is on external FS or internal RAM -// if ( ((uint8_t*)(pWidget->pvBitmap))[0] == '/' ) -// { -// if ( WGT_DrawBMPFile( pWidget, pBE ) != SAMGUI_E_OK ) -// { -// clr.u.dwRGBA=pWidget->dwClrBackground ; -// -// pBE->DrawFilledRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth, pWidget->dwY+pWidget->dwHeight, NULL, &clr ) ; -// } -// } -// else -// { - pBE->DrawBitmap( pWidget->dwX, pWidget->dwY, pWidget->dwWidth, pWidget->dwHeight, pWidget->pvBitmap ) ; -// } - } - // else if colors, draw background color filled rectangle - else - { - clr.u.dwRGBA=pWidget->dwClrBackground ; - - pBE->DrawFilledRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth, pWidget->dwY+pWidget->dwHeight, NULL, &clr ) ; - } - - // if label declared, draw text - if ( (pWidget->pvText != NULL) && (pWidget->dwType == WGT_TYPE_TEXT) ) - { - clr.u.dwRGBA=pWidget->dwClrText ; - - pBE->DrawText( pWidget->dwX, pWidget->dwY, pWidget->pvText, &clr, (void*)&g_Font10x14, 0 ) ; - } - - return SAMGUI_E_OK ; -} diff --git a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.h b/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.h deleted file mode 100644 index 266ce64fb..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/core/wgt_core_widget.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _SAMGUI_WGT_CORE_WIDGET_ -#define _SAMGUI_WGT_CORE_WIDGET_ - -#include "disp/disp_backend.h" - -typedef enum _WGT_Type -{ - WGT_TYPE_BUTTON, - WGT_TYPE_TEXT, - WGT_TYPE_BITMAP, - WGT_TYPE_SLIDER, - WGT_TYPE_MAX -} WGT_Type ; - -typedef enum _WGT_Status -{ - WGT_STATUS_NORMAL, - WGT_STATUS_SELECTED, - WGT_STATUS_HIDDEN, - WGT_STATUS_MAX -} WGT_Status ; - -typedef enum _WGT_Style -{ - WGT_STYLE_NONE, - WGT_STYLE_TEXT_LEFT, - WGT_STYLE_TEXT_RIGHT, - WGT_STYLE_TEXT_JUSTIFIED, - WGT_STYLE_MAX -} WGT_Style ; - -typedef struct _SWGT_Widget -{ - WGT_Type dwType ; // Widget type - - uint32_t dwID ; // Widget unique ID - - struct _SWGT_Widget* pParent ; - struct _SWGT_Widget* pSibling ; - struct _SWGT_Widget* pChild ; - - uint32_t dwX ; - uint32_t dwY ; - uint32_t dwWidth ; - uint32_t dwHeight ; - uint32_t dwClrText ; - uint32_t dwClrBackground ; - - WGT_Style dwStyle ; - - void* pvBitmap ; - void* pvFont ; - void* pvText ; - - WGT_Status dwStatus ; -} SWGT_Widget ; - -// ------------------------------------------------------------------------------------------------ -// Widget functions -extern uint32_t WGT_CreateWidget( SWGT_Widget* pWidget, WGT_Type eType, uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight ) ; - -extern uint32_t WGT_SetBkgndColor( SWGT_Widget* pWidget, uint32_t dwColor ) ; -extern uint32_t WGT_SetTextColor( SWGT_Widget* pWidget, uint32_t dwColor ) ; -extern uint32_t WGT_SetText( SWGT_Widget* pWidget, char* pszText ) ; -extern uint32_t WGT_SetBitmap( SWGT_Widget* pWidget, uint8_t* pucBitmap ) ; - -//extern uint32_t WGT_DrawBMPFile( SWGT_Widget* pWidget, SDISPBackend* pBE ) ; -extern uint32_t WGT_Draw( SWGT_Widget* pWidget, SDISPBackend* pBE ) ; - -#endif // _SAMGUI_WGT_CORE_WIDGET_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.c b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.c deleted file mode 100644 index 002a09a26..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.c +++ /dev/null @@ -1,303 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/frontends/frontend_ADS7843.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "board.h" -#include "pio/pio.h" -#include "pio/pio_it.h" -#include "tsd/tsd_ads7843.h" -#include "demo_parameters.h" -#include "sam-gui/porting/sam_gui_porting.h" -#include "sam-gui/wgt/core/wgt_core_message.h" -#include "components/ads7843/ads7843.h" - -/* RTOS operations */ -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" - -#include -#include - -/** \addtogroup Demo_Touchscreen Touchscreen driver - * The Touchscreen driver posts messages to the Widget message queue: - *
      - *
    • WGT_MSG_POINTER_RAW: pen pressed, provides uncalibrated-filtered pen position.
    • - *
    • WGT_MSG_POINTER_PRESSED: pen pressed, provides calibrated-filtered pen position.
    • - *
    • WGT_MSG_POINTER: pen moved, provides calibrated-filtered pen position.
    • - *
    • WGT_MSG_POINTER_RELEASED: pen released, provides calibrated-filtered pen position.
    • - * \n - * - * Touchscreen ADS7843 is connected to the microcontroller through SPI and an - * a signal connected to a PIO corresponding to the pen press detection. - * Each time a pen press is detected, the microcontroller is notified thrrough - * the interrupt line triggering a PIO interrupt. - * \n - * - * The touchscreen driver starts a task suspended until the PIO interrupt - * handler releases a semaphore. Then the task does measurements until the pen - * is detected as released. - * Once the pen is released, the task enters in suspend mode, waiting to get the - * semaphore ie. waiting for the next pen press detection. - * - * Related files :\n - * \ref ads7843.c\n - * \ref ads7843.h\n -*/ - -/* - * ---------------------------------------------------------------------------- - * Touchscreen driver parameters - * ---------------------------------------------------------------------------- -*/ -#define NB_SAMPLES 3 /**< Number of succesive measurements required to get an accurate pen position */ -#define SAMPLING_PERIOD 10 /**< Sampling period (in ms) when pen is pressed to detect pen mouvements */ - -/** Binary flag to check if the screen has been calibrated. Calibration calculus - * is not applied since this flag is not true. - * Only raw values are sent to the application until the calibration has been - * done */ -uint8_t gTsCalibrated = 0; - -static Ads7843CalibParameters gs_ADS7843CalibParameters; - -/** Pins used by Interrupt Signal for Touch Screen Controller */ -static const Pin _WFE_ADS7843_pinPenIRQ=PIN_TCS_IRQ ; - -/** Touch screen semaphore used to resume touch screen task when pen is pressed */ -static xSemaphoreHandle gTsSemaphore = NULL; - -/** - * \brief Returns Touchscreen pen position - * Performs several (NB_SAMPLES succesive measurements and do a mean. Then - * calibration function is applied according to the calibration parameters. -*/ -static void _WFE_ADS7843_GetPenPosition(uint32_t *pdwX, uint32_t *pdwY) -{ - uint32_t i; - uint32_t dwX, dwY; /* Measured coordinates */ - uint32_t dwTrueX, dwTrueY; /* Filtered coordinates */ - - - /* Do several successive measurements and process a mean */ - dwTrueX = 0; - dwTrueY = 0; - for (i = 0; i < NB_SAMPLES; ++i) { - ADS7843_GetPosition( &dwX, &dwY ) ; - dwTrueX += dwX; - dwTrueY += dwY; - } - dwTrueX /= NB_SAMPLES; - dwTrueY /= NB_SAMPLES; - - /* If calibration has been done, apply calibration function */ - if (gTsCalibrated) { - dwTrueX = gs_ADS7843CalibParameters.dwPointX - - ((int32_t)(gs_ADS7843CalibParameters.dwMeasureX - (int32_t)dwTrueX) * 1024) - / gs_ADS7843CalibParameters.lSlopeX ; - dwTrueY = gs_ADS7843CalibParameters.dwPointY - - ((int32_t)(gs_ADS7843CalibParameters.dwMeasureY - (int32_t)dwTrueY) * 1024) - / gs_ADS7843CalibParameters.lSlopeY ; - - if ((int32_t)dwTrueX < 0 ) /* Is pPoint[0] negative ? */ - dwTrueX = 0; - if ( dwTrueX > BOARD_LCD_WIDTH ) /* Is pPoint[0] bigger than the LCD width ? */ - dwTrueX = BOARD_LCD_WIDTH ; - - if ((int32_t)dwTrueY < 0 ) /* Is pPoint[0] negative ? */ - dwTrueY = 0; - if ( dwTrueY > BOARD_LCD_HEIGHT ) /* Is pPoint[0] bigger than the LCD width ? */ - dwTrueY = BOARD_LCD_HEIGHT ; - } - - /* Update pen position coordinates */ - *pdwX = dwTrueX; - *pdwY = dwTrueY; -} - -/** - * \brief Touch screen sampling task - * - * This task is resumed when a PIO interrupt release the semaphore, that's to - * say when the pen is pressed. Then this task reports pen activity each - * SAMPLING_RATE period until the pen is released -*/ -static void _WFE_ADS7843_Task( void* pParameter ) -{ - uint8_t isPenPressed; - uint32_t dwX, dwPrevX; - uint32_t dwY, dwPrevY; - - - while (1) { - - /* Block waiting for the semaphore to become available: */ - /* A PIO interrupt has been triggered: a key has been pressed */ - if( xSemaphoreTake( gTsSemaphore, portMAX_DELAY ) != pdTRUE ) - continue; - - /* Add a delay between interrupt and data acquisition */ - vTaskDelay( 5 ); - - isPenPressed = 1; - - /* Perform a first measurement corresponding to the key pressed */ - _WFE_ADS7843_GetPenPosition(&dwX, &dwY); - - /* If it is not calibrated send the raw value to the application */ - if (!gTsCalibrated) { - WGT_SendMessageISR( WGT_MSG_POINTER_RAW, dwX, dwY); - isPenPressed = 0; - } - else { - /* Send the key pressed position */ - WGT_SendMessageISR( WGT_MSG_POINTER_PRESSED, dwX, dwY) ; - dwPrevX = dwX; - dwPrevY = dwY; - } - - /* Perform measurements at SAMPLING_RATE while the key is pressed */ - while (isPenPressed) { - vTaskDelay( SAMPLING_PERIOD/portTICK_RATE_MS ) ; - - /* Perform measurements at SAMPLING_RATE */ - _WFE_ADS7843_GetPenPosition(&dwX, &dwY); - - /* If the touch has been released exit the loop and post release message */ - if ( PIO_Get( &_WFE_ADS7843_pinPenIRQ ) == 1) { - WGT_SendMessageISR( WGT_MSG_POINTER_RELEASED, dwPrevX, dwPrevY) ; - isPenPressed = 0; - } - - /* Else send the pen position if this one is different from the previous one */ - else if ( (dwX != dwPrevX) || (dwY != dwPrevY) ) { - WGT_SendMessageISR( WGT_MSG_POINTER, dwX, dwY) ; - dwPrevX = dwX; - dwPrevY = dwY; - } - - } - - /* Loop and wait for PIO ISR to release the semaphore */ - /* Enable the PIO interrupt */ - PIO_EnableIt( &_WFE_ADS7843_pinPenIRQ ) ; - } -} - -/** - * \brief Interrupt handler for Touchscreen. - */ -#ifdef BOARD_REV_A -void PIOA_Irq4Handler(unsigned char id) -#endif -#ifdef BOARD_REV_B -void PIOA_Irq16Handler(unsigned char id) -#endif -{ - portBASE_TYPE xHigherPriorityTaskWoken; - - /* A posedge has been received */ - xSemaphoreGiveFromISR( gTsSemaphore, &xHigherPriorityTaskWoken ); - PIO_DisableIt( &_WFE_ADS7843_pinPenIRQ ) ; -} - - -static uint32_t _WFE_ADS7843_Initialize( void ) -{ - // Initialize touchscreen - ADS7843_Initialize() ; - - /* Configure pios */ - PIO_Configure( &_WFE_ADS7843_pinPenIRQ, PIO_LISTSIZE( _WFE_ADS7843_pinPenIRQ ) ) ; - - /* Create the semaphore required for pen detection */ - vSemaphoreCreateBinary( gTsSemaphore ); - if( gTsSemaphore == NULL ) - return SAMGUI_E_NOT_ENOUGH_MEMORY; - - /* Take the semaphore, this one will be release in the PIO ISR handler, once the pen will be pressed */ - if( xSemaphoreTake( gTsSemaphore, 0 ) != pdTRUE ) - return SAMGUI_E_NOT_ENOUGH_MEMORY; /* TODO: change return code, it shall correspond to initialization error */ - - /* Get calibration parameters */ - gs_ADS7843CalibParameters.dwPointX = g_demo_parameters.sCalibration.dwPointX; - gs_ADS7843CalibParameters.dwPointY = g_demo_parameters.sCalibration.dwPointY; - gs_ADS7843CalibParameters.dwMeasureX = g_demo_parameters.sCalibration.dwMeasureX; - gs_ADS7843CalibParameters.dwMeasureY = g_demo_parameters.sCalibration.dwMeasureY; - gs_ADS7843CalibParameters.lSlopeX = g_demo_parameters.sCalibration.lSlopeX; - gs_ADS7843CalibParameters.lSlopeY = g_demo_parameters.sCalibration.lSlopeY; - - /* Check if we already have calibration data */ - if (gs_ADS7843CalibParameters.dwPointX) { - gTsCalibrated = 1; - } - - /* Enable the PIO interrupt */ - PIO_EnableIt( &_WFE_ADS7843_pinPenIRQ ) ; - - /* Create the touch screen driver task */ - if (xTaskCreate( _WFE_ADS7843_Task, "WGT_Core_TS", 512, NULL, tskIDLE_PRIORITY+2, NULL ) != pdPASS) - return SAMGUI_E_NOT_ENOUGH_MEMORY; - - return SAMGUI_E_OK ; -} - -static uint32_t _WFE_ADS7843_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) -{ - switch (dwCommand) { - case WGT_FRONTEND_IOCTL_SET_DATA: - if ( (pdwValueLength != NULL) && (*pdwValueLength == sizeof( Ads7843CalibParameters )) ) - { - memcpy( &gs_ADS7843CalibParameters, pdwValue, sizeof( Ads7843CalibParameters ) ) ; - if ( gs_ADS7843CalibParameters.lSlopeX != 0 ) - { - gTsCalibrated=1 ; - } - else - { - gTsCalibrated=0 ; - } - } - break; - - default: - break; - } - return SAMGUI_E_OK ; -} - -const SWGTFrontend sWGT_Frontend_ADS7843= -{ - .sData={ .dwId=WGT_FRONTEND_ADS7843 }, - - .Initialize=_WFE_ADS7843_Initialize, - - .IOCtl=_WFE_ADS7843_IOCtl -} ; \ No newline at end of file diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.h b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.h deleted file mode 100644 index d697ac9a8..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_ADS7843.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _WGT_FRONTEND_ADS7843_ -#define _WGT_FRONTEND_ADS7843_ - -#include "sam-gui/wgt/core/wgt_core_frontend.h" - -typedef struct _Ads7843CalibParameters -{ - uint32_t dwPointX; - uint32_t dwPointY; - uint32_t dwMeasureX; - uint32_t dwMeasureY; - int32_t lSlopeX; - int32_t lSlopeY; -} Ads7843CalibParameters; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern const SWGTFrontend sWGT_Frontend_ADS7843 ; - - -#endif // _WGT_FRONTEND_ADS7843_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.c b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.c deleted file mode 100644 index dbda339d0..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.c +++ /dev/null @@ -1,220 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ -/** \addtogroup Demo_Potentiomer Potentiometer driver - * The Potentiometer driver posts messages to the Widget message queue. - * \n - * - * Board pontentiometer is connected to the 12 bit ADC analog line. Each time the - * user turns the potentiometer, it triggers an interrupt which posts a message - * with a value from 0 to 255 corresponding to the measurement. - * - * The SAMPLING_PERIOD definition controls the sampling frequency. A timer - * counter in waveform mode is used to trigger acquisitions. It is configured to - * count from the Slow clock frequency. - * - * The window mode of the ADC is used to trigger an ADC interrupt only when the - * measure goes outside a window controlled by the NB_INTERVALS definition. - * - * Each time a new ADC interrupt occurs, a new window is calculated from the current - * measurement. - * - * During the initialization a first measure is done to get the initial value. - * Application can have access to the current measure using ioctl command. - * - * For more accurate information, please look at the ADC section of the - * Datasheet. - * - * Related files :\n - * \ref adc.c\n - * \ref adc.h\n -*/ - -#include - -#include "sam-gui/wgt/frontends/frontend_potentiometer.h" -#include "sam-gui/common/sam_gui_errors.h" -#include "sam-gui/wgt/core/wgt_core_message.h" - -#include -#include -#include -#include -#include - -/* A message is posted each time the values goes outside the [-5,+5] interval around the previous measure */ -#define NB_INTERVALS 5 -/** ADC clock */ -#define BOARD_ADC_FREQ (6000000) - -/** ADC sampling period: 10 times/sec */ -#define SAMPLING_PERIOD 32768/10 - -static uint32_t gdwPotentiometerValue; - -/** - * \brief TC0 configuration - * - * Configures Timer Counter 0 (TC0) to generate an interrupt every second. - * - */ -static void ConfigureTc0(void) -{ - - /* Enable TC0 peripheral clock*/ - PMC_EnablePeripheral(ID_TC0); - - /* Configure TC for a 1s (= 1Hz) tick*/ - TC_Configure(TC0,0, 0x4 | TC_CMR0_ACPC_SET | TC_CMR0_WAVE - | TC_CMR0_ACPA_CLEAR | (0x2 << 13)); - - /* 50% duty ,1s frequency*/ - TC0->TC_CHANNEL[0].TC_RA = SAMPLING_PERIOD/2; - TC0->TC_CHANNEL[0].TC_RC = SAMPLING_PERIOD; -} - - -void ADC_IrqHandler(void) -{ - Adc *pAdc = ADC; - int32_t dwLowPotThreshold, dwHighPotThreshold; - volatile uint32_t dummy = 0; - - /* Read the status to ack the IT */ - dummy = ADC_GetStatus(ADC); - - /* Get the potentiometer initial value */ - gdwPotentiometerValue = ADC_GetConvertedData(pAdc, ADC_CHANNEL_5); - - /* Read LCDR to clear DRDY bit */ - dummy = ADC_GetLastConvertedData(pAdc); - - /* Set Window threshold according to the initial values */ - dwLowPotThreshold = gdwPotentiometerValue - (NB_INTERVALS * (0x1000 / 256)); - if (dwLowPotThreshold < 0) - dwLowPotThreshold = 0; - dwHighPotThreshold = gdwPotentiometerValue + (NB_INTERVALS * (0x1000 / 256)); - if (dwHighPotThreshold >= 0x1000) - dwHighPotThreshold = 0x1000 - 1; - - /* Normalize the value 0 -> 255 */ - gdwPotentiometerValue = (gdwPotentiometerValue * 256) / 0xFFF; - - /* Post Message */ - WGT_SendMessageISR( WGT_MSG_KEY_PRESSED, WGT_KEY_VR1, 255 - gdwPotentiometerValue ) ; - - /* Setup Threshold*/ - ADC_SetComparisonWindow(pAdc,((dwHighPotThreshold<<16)|dwLowPotThreshold)); - -} - -static uint32_t _WFE_Potentiometer_Initialize( void ) -{ - Adc *pAdc = ADC; - int32_t dwLowPotThreshold, dwHighPotThreshold; - - /* STEP1: Realize a first measure to get potentiometer's initial position */ - /* Initialize ADC*/ - ADC_Initialize( pAdc,ID_ADC, ADC_MR_TRGEN_DIS,/*HARDWARE trigger*/ - 0,ADC_MR_SLEEP_NORMAL,ADC_MR_LOWRES_12_BIT, - BOARD_MCK,BOARD_ADC_FREQ,10,20); - - /*Enable channel 5 (potentiometer) */ - ADC_EnableChannel(pAdc, ADC_CHANNEL_5); - - /* Start convrsion */ - ADC_StartConversion(pAdc); - - /* Wait for the end of conversion */ - while ( !(ADC_GetStatus(pAdc) & ADC_ISR_EOC5) ) {} - - /* Get the potentiometer initial value */ - gdwPotentiometerValue = ADC_GetConvertedData(pAdc, ADC_CHANNEL_5); - - /* Set Window threshold according to the initial values */ - dwLowPotThreshold = gdwPotentiometerValue - (NB_INTERVALS * (0x1000 / 256)); - if (dwLowPotThreshold < 0) - dwLowPotThreshold = 0; - dwHighPotThreshold = gdwPotentiometerValue + (NB_INTERVALS * (0x1000 / 256)); - if (dwHighPotThreshold >= 0x1000) - dwHighPotThreshold = 0x1000 - 1; - - /* Normalize the value 0 -> 255 */ - gdwPotentiometerValue = (gdwPotentiometerValue * 256) / 0xFFF; - - /* STEP2: Re configure ADC to use windowing */ - /* Initialize ADC*/ - ADC_Initialize( pAdc,ID_ADC, ADC_MR_TRGEN_EN,/*HARDWARE trigger*/ - ADC_MR_TRGSEL_TIOA0,ADC_MR_SLEEP_NORMAL,ADC_MR_LOWRES_12_BIT, - BOARD_MCK,BOARD_ADC_FREQ,10,20); - - /*Enable channel 5 (potentiometer) */ - ADC_EnableChannel(pAdc, ADC_CHANNEL_5); - - /* Configure TC*/ - ConfigureTc0(); - - /*Channel 5 has to be compared*/ - ADC_SetCompareChannel(pAdc, ADC_CHANNEL_5); - /*Compare mode, in the window*/ - ADC_SetCompareMode(pAdc, ADC_EMR_CMPMODE_OUT); - - /* Setup Threshold*/ - ADC_SetComparisonWindow(pAdc,((dwHighPotThreshold<<16)|dwLowPotThreshold)); - - /* enable adc interrupt*/ - NVIC_EnableIRQ(ADC_IRQn); - - /* Enable Compare Interrupt*/ - ADC_EnableIt(pAdc, ADC_IDR_COMPE); - - /* Start TC0 and hardware trigger*/ - TC_Start(TC0,0); - - return SAMGUI_E_OK ; -} - -static uint32_t _WFE_Potentiometer_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) -{ - /* Return the current potentiometer value */ - if (pdwValue) { - *pdwValue = gdwPotentiometerValue; - if (pdwValueLength) - *pdwValueLength = sizeof(gdwPotentiometerValue); - } - return SAMGUI_E_OK ; -} - -const SWGTFrontend sWGT_Frontend_Potentiometer= -{ - .sData={ .dwId=WGT_FRONTEND_POTENTIOMETER }, - - .Initialize=_WFE_Potentiometer_Initialize, - - .IOCtl=_WFE_Potentiometer_IOCtl -} ; diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.h b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.h deleted file mode 100644 index c0e877064..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_potentiometer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _WGT_FRONTEND_POTENTIOMETER_ -#define _WGT_FRONTEND_POTENTIOMETER_ - -#include "sam-gui/wgt/core/wgt_core_frontend.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern const SWGTFrontend sWGT_Frontend_Potentiometer ; - - -#endif // _WGT_FRONTEND_POTENTIOMETER_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.c b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.c deleted file mode 100644 index 0078829a7..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.c +++ /dev/null @@ -1,66 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ -/* PIO functions */ -#include -#include - -#include "sam-gui/wgt/frontends/frontend_pushbuttons.h" -#include "sam-gui/wgt/core/wgt_core_message.h" -#include "sam-gui/common/sam_gui_errors.h" - -/** VBus pin instance. */ -const Pin gPinButton1 = PIN_PUSHBUTTON_1; -const Pin gPinButton2 = PIN_PUSHBUTTON_2; - -static uint32_t _WFE_PushButtons_Initialize( void ) -{ - /* Configure PIO */ - PIO_Configure(&gPinButton1, 1); - PIO_Configure(&gPinButton2, 1); - - /* Enable PIO interrupt */ - PIO_EnableIt(&gPinButton1); - PIO_EnableIt(&gPinButton2); - - return SAMGUI_E_OK ; -} - -static uint32_t _WFE_PushButtons_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) -{ - return SAMGUI_E_OK ; -} - -const SWGTFrontend sWGT_Frontend_PushButtons= -{ - .sData={ .dwId=WGT_FRONTEND_PUSHBUTTONS }, - - .Initialize=_WFE_PushButtons_Initialize, - - .IOCtl=_WFE_PushButtons_IOCtl -} ; diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.h b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.h deleted file mode 100644 index 5c98501da..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_pushbuttons.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _WGT_FRONTEND_PUSHBUTTONS_ -#define _WGT_FRONTEND_PUSHBUTTONS_ - -/* PIO functions */ -#include - - -#include "sam-gui/wgt/core/wgt_core_frontend.h" - -extern const Pin gPinButton1; -extern const Pin gPinButton2; - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern const SWGTFrontend sWGT_Frontend_PushButtons ; -extern void WFE_Button1Handler(unsigned char id); - -#endif // _WGT_FRONTEND_PUSHBUTTONS_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.c b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.c deleted file mode 100644 index 294c2d34c..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.c +++ /dev/null @@ -1,50 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#include "sam-gui/wgt/frontends/frontend_qtouch.h" -#include "sam-gui/common/sam_gui_errors.h" - -static uint32_t _WFE_QTouch_Initialize( void ) -{ - return SAMGUI_E_OK ; -} - -static uint32_t _WFE_QTouch_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) -{ - return SAMGUI_E_OK ; -} - -const SWGTFrontend sWGT_Frontend_QTouch= -{ - .sData={ .dwId=WGT_FRONTEND_QTOUCH }, - - .Initialize=_WFE_QTouch_Initialize, - - .IOCtl=_WFE_QTouch_IOCtl -} ; diff --git a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.h b/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.h deleted file mode 100644 index 1275bb56a..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/frontends/frontend_qtouch.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _WGT_FRONTEND_QTOUCH_ -#define _WGT_FRONTEND_QTOUCH_ - -#include "sam-gui/wgt/core/wgt_core_frontend.h" - -/*---------------------------------------------------------------------------- - * Exported functions - *----------------------------------------------------------------------------*/ - -extern const SWGTFrontend sWGT_Frontend_QTouch ; - - -#endif // _WGT_FRONTEND_QTOUCH_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.c b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.c deleted file mode 100644 index ce9e05cb9..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.c +++ /dev/null @@ -1 +0,0 @@ -#include "sam-gui/wgt/widgets/wgt_widget_button.h" diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.h b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.h deleted file mode 100644 index 414920b9f..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_button.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _SAMGUI_WIDGET_BUTTON_ -#define _SAMGUI_WIDGET_BUTTON_ - - -#endif // _SAMGUI_WIDGET_BUTTON_ diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.c b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.h b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_page.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.c b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.c deleted file mode 100644 index a502e97c0..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.c +++ /dev/null @@ -1 +0,0 @@ -#include "sam-gui/wgt/widgets/wgt_widget_static.h" diff --git a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.h b/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.h deleted file mode 100644 index e629e44fc..000000000 --- a/src/ersky9x/libraries/sam-gui/wgt/widgets/wgt_widget_static.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _SAMGUI_WIDGET_STATIC_ -#define _SAMGUI_WIDGET_STATIC_ - - -#endif // _SAMGUI_WIDGET_STATIC_ diff --git a/src/ersky9x/libraries/usb/USBFrameworkArchitecture.png b/src/ersky9x/libraries/usb/USBFrameworkArchitecture.png deleted file mode 100644 index 83e77eb6534ed26df2f1fdee5ac3f120e35b343e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5288 zcmeHL`8U)L_qUZKd!=ZIK~b{rYuR^M!x;JyAv?`rtVJ{SH4#lAgsfpOL+UMLA0ay< zWH%TFGdw=efAIbJ``mNxIrrWl?m4g5z4x4ZFUs6hkL4oIMH(6!76W~43mO_);+aZb zpg)VGKEgn0Xy|FojjeP}PfyPx%gf7W#{cAh4E%p%;8lZ+_t^k2`RUsQ($KIy{#R*B zHA*~aXgEv_wC`KN^EUDmY71{(iZer;+CFz{tba;3@A>uSp?hPe;LB9Ad-e{e&&8q! z+FS}(NH+65FW-DHE`Cm(T3^b6WR}iGmNI?zM%$T8-AcF|d?1nT6Yup?Ki~B9V?Yj6 z=+zW5Quaxe_pkeik5^~$(~Ixu!chaWi4SvCE%*<-t(**WZ+Pu&I@|?seqkkA+lM-B zAu~zD4hCI>)OF&BE08uLWwyN6s4J6@$<$#a_ykBGrR$HEw&wDn=n=lJm9{$ld|!7h*#PNbQHy5F_jt^gSJ$4uOMh?;>*}9T!(G zQl|dF`RpGiBe#=W_u~Cx9eHT_UL7=tDOa`O;;4=6zIXMGWLi=3MRB_!Pnx(Jl3kwY zSCC~4-V6Z-FX57fdOHF(U#}y_qG5r+5c}Zo_tru+HX5^fsAFG0H|bWrHD}b;B{%T9 zG>Sbg3jQUmL^rs_Q@{|WOrL{Y>{2WKbR&p zU#PH+yoIrdWFwYRRwN` z?0Qv>Jb4UWmop{thdFq{nf-T6F)*$_9kjeMWAVRsKsfDX{$~}xd>pB7;CeGxdS3;9 zgzIGKm8=Wc8)8qo6r~qtqgQ?&_h5m-faNW*hN$uj&b9>UL&`sYVb0C;68F`EYWKz@ z!$?Zs5WvvSKBQKzLgNd_5G;23d}QeAhOk44LH5vWQLv_v)6N&NkUAZl?{JP(ecEk8 zijD1k^`P_HJ$t&C&*7bi{ubLImdgC=5gn#JR{Zp;uMlJ=^P;ol5Fv@JFva*lo zf`LUpyKuxvPVTcrO!lB^O5htMOXFAK0-INSL^f@F3ZqKW*ckh5LR>y?>gCpC<}l)c z;lgGP2@b!>#jd(txHqaSWJ==O(k{v2tnweoJE0;D)h)Sj&*_y#unzW1jF?Qw!c2${ zUQW@0;LLTW#|QuIK2JYmXMCEksu|_QN~c(lT84mW9@BYV{5SvopFt+igMr1`*W+H- zEE$5>-J^zWl?bd#jNsb-Pb>x__;RCB!9aHgPc!z-m4iF^{)XYmx}?NlqP=xii1WsF zX_Rn8U+YtKn8REN?abQq7q+?Vomg5FNiwf}ThwaYD*LaVuBvPDiSnO4@erkbMidb6 zGC+tNwdCp}b>nV;W%=}AXv0aisO}9SxYQz#%E>_}O8G|z%$L`xNKf%F`C~kSjJ%?x z($d8d;ZInexk3EpDU8Zf87k7!j#Kni;(lLTk=wz!Ji7Yux3RCp%~tMr`Tk>RiDXdC z*i_X1Z=ru8i`aBy!)%=~;|>9QkxV}Vh_-e_o=J!7@6T~_!N*OD*`%~FEll*XYpupnnuE|mL8k_)VvsBZFGa?{Z^R!cLFq^dn?w0JdKxXWc&pgm6%XV zu!@MpYU~#CivO90KQN307X$`5(N!71A{dL^r*c!WIxm?OIJ8k@oY%9)GB$>8Vn~;J zV6pm>=h{t=TI!7PoOC&lmCYbVVZJM)TTP;rWUu{pPS zK6R$PSBKJv)%eUy6xzr^wl%*P&gf6(gnyg9&APQj_2yrvzExr&X2Z6%WFXPwj2uqU z2eJSoxk;OGHi?Y6_@xV(Qd6Z@$G)}pR}6flr;Dxg4wfbu1#eFyB}Us1P)OKLPz`Hq z%B={>d-{Xnp0C0qt+`D8Tpe+W1i$4*O=U``@iPBA{HJ8^^JubTm>`rSs~8)~$!JJv zP-7}dZIX+IsrO3}C*_zx{z zH&_*`P83Ik74s0?tS45-)$us9#Hl^(4SxfdYHP)5g;Kt@RMGywo6NXmMliIPhmg<9 z%|EF2=GN16AAmV%u0QT#7ush>;GLtAP=9a)7+NqO>ML*c?3c>zW}Ac6{e$#B^SR!O zHUaZ=WlKjYtq=+J>Vuu@M4Lqv5ilt!M(Ym^gy z4GQXI)EyB{FKqs)`CMASsplo2=g5Y0Ofl4BRI+w7i6LW{=U@_^-EaYiVaXEDJJN)F zPrQ*T^yX9`WFQGTk_6r8b3DJP1v&bj3OC8ANaVGRnf$59GdrDyX>q?qv5ExW%?=_= zOaiwYy-?kF&%p8RzB<{oL$Sn0YrnQf8D_1kx}<)9SH-n#R64-|c*raw)Ni+{jR;)G zy}iu}B&3EluIZL&`j%(G#dkaj?iqs&3?;+!l$V?f!(unXMhw|YNd)TSm(q* z;Jap8R6%ezh+zHVoJd4{0?PJs*q2J7mLf4!OT1v`GZ#mU4U*(P5rVt)3;nfIa^i~m zGaC$2{V#o2Wkm z5riacEx|jo{u4R@K%u&b*8`n_hL_Mkx}>h2oP>O_ADnFnmf~yaw{GaV$jJ#*iS#F} zrWw>$h}aiqXQ3zKk%j#o4x-!LwpaYI_h^-S^CG)>t-8E3N31^T`!~n!bOM=m^>R;Y z<34DTBn@uQ>el%`UZ3n#`NT$K^#sq@jsRTebd|ze__C5&1In6tS{RER#I^Fus({Vt z6`P(!Ab3XdcONncM4#tb`fU@s`A7>^VlP(hdpoG&{lBeMH!Hio_T_zWR`T=UvOf4p z%SRBKmEEuyXk*!`a1r;1n?6)Y+{gA~VSb*coWuTJ`M#NSr`@`%&DR2qW#c6qRq92d zk=3m)$z?=??GX3=f@+*k?vICd-D(|pk6caDh0;<6w8^@x(am#u>p89fHx~lcBZwAC zPA{(wVbCBHblpM~{(XSp33rY}88w6_Oa6Qp+E+joy4M6ngA+T|e9Xe69;pc4Q>-=P z_^}0wp=$UJ3vVNhNV}p17dlTx5m)dh^vOtO0klZ`u%g(91Zj~7=T{A5yDU=*0&_a; zcL0-12Oq1L{HBlZpvm6%)e~4v7D}rV$)3`L@@{062)H%(|Li;@_)*Z{*MV?R2|L1H zs0}IiyHQAY@+$gm%q?0UKqm+hZT8Dm!GutZd1>pT3&AO~XV?EWsUwSuuhhwaD;;$a za^qLtjA$bl^tNtP{V^H3Llz~8#MlaO6*NSA+Om`oQ5{hxlvA~Tgzg|UHj+J} zXgDG#xQ8!*T#nHu^UU369^0_w1}FkGR%CaUk&6D=f&SoZA)Xo;7h}+PhN|{qxZD-B z`Tjk@vyGlXhVwL{=xxOL2gd`8ZPf9LsgV|+A5hgd`rVoyQ*qLSbRGA>#Iq%?t#BOG z;?6T)f@v0~JR5u3iVVi`X3h5+7aO3Q(q`F@`;1g9XaWuqYh&oO*ELUr>pUz7ymVTd zyOVGNLcR4Z{?eq!tE)Nb`+9X%Q~jHrT(@4(W=pu`Umm~KtBWZ5)*jZwp0bo+$HvH6 z)rAGn&)@5W5Rm5WY3+{=p6>=8XXd6Uwk|D&O1;ZCtWix*k>N9*Xg>;{$U4dcI=w6~ z6^U?Y-M$;tvU18;!4?*bB9`0YUc^P8jMRWevEO&yEViJj+|(S{TH2nC{BS8{x8-$3Vru`jB2*xQC_SLy18m&DrIZQ z4)*bCV^punc>3&2x3(+|tq+Sb<((fVJr;pr7&r8%+If=MkD+N7x=*kJEeI~f5+NS; z_WO{>JC81k;0tv%P!Z>Nh9`GM7!PSU;?4P$U50?L6SAQ)TG6*_Y%qeO(LbCPR0Q&0 zTlVEfEct<3lTCY(H_bGrTxd%IF-$qN{@6 zbBjO-a@Ylt4Ig>T`Np2u$gZO2IEnEopT@C-;_IWlH+KMH*34ye_;Q>nlIwKCM`+Vf!t};K zQy7?tX0f0nO(^m!|HcauChS;mdQ16Fg;aa67^sED`Q z?bJy^UxG4CBsLZjnIZhM3*m@XQ>eBo(wp8NLdT0Uxbb_>f^gpjP9UnEoF~A=kB_x@ zW9>nM`(vvrH4inXHd0>4e-K76UquIE=OBseQ@C1Nf@-|u6P&5t${|@{ z=!vUxEKI$%P*IR@a;R8FV*sj7TFB+B#b-9lra LW2#;Gz&YkW{P7IS diff --git a/src/ersky9x/libraries/usb/common/audio/AUDControlInterfaceDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDControlInterfaceDescriptor.h deleted file mode 100644 index ada2f1e04..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDControlInterfaceDescriptor.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definitions for using USB %audio control interfaces. -/// -/// !!!Usage -/// -/// -# When declaring a standard USB interface descriptor for an %audio control -/// interface, use the "USB Audio control interface codes" constants. -//------------------------------------------------------------------------------ - -#ifndef AUDCONTROLINTERFACEDESCRIPTOR_H -#define AUDCONTROLINTERFACEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio control interface codes" -/// -/// This page lists the class, subclass and protocol codes that a USB Audio -/// Control interface descriptor should display. -/// -/// !Codes -/// - AUDControlInterfaceDescriptor_CLASS -/// - AUDControlInterfaceDescriptor_SUBCLASS -/// - AUDControlInterfaceDescriptor_PROTOCOL - -/// Class code for an audio control interface. -#define AUDControlInterfaceDescriptor_CLASS 0x01 - -/// Subclass code for an audio control interface. -#define AUDControlInterfaceDescriptor_SUBCLASS 0x01 - -/// Protocol code for an audio control interface. -#define AUDControlInterfaceDescriptor_PROTOCOL 0x00 -//------------------------------------------------------------------------------ - -#endif //#ifndef AUDCONTROLINTERFACEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDDataEndpointDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDDataEndpointDescriptor.h deleted file mode 100644 index 5963546ee..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDDataEndpointDescriptor.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definition of the USB audio-specific data endpoint descriptor. -/// -/// !!!Usage -/// -/// -# Declare an AUDDataEndpointDescriptor instance as part of the -/// configuration descriptors of a USB %audio %device. -//------------------------------------------------------------------------------ - -#ifndef AUDDATAENDPOINTDESCRIPTOR_H -#define AUDDATAENDPOINTDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Descriptor subtype for an Audio data endpoint. -#define AUDDataEndpointDescriptor_SUBTYPE 0x01 - -//------------------------------------------------------------------------------ -/// \page "USB Audio Lock delay units" -/// -/// This page lists the valid lock delay unit types. -/// -/// !Units -/// - AUDDataEndpointDescriptor_MILLISECONDS -/// - AUDDataEndpointDescriptor_PCMSAMPLES - -/// Lock delay is expressed in milliseconds. -#define AUDDataEndpointDescriptor_MILLISECONDS 1 - -/// Lock delay is expressed in decoded PCM samples. -#define AUDDataEndpointDescriptor_PCMSAMPLES 2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Gives additional information about an USB endpoint used to transmit audio -/// data to or from the host. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_ENDPOINT). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDDataEndpointDescriptor_SUBTYPE). - unsigned char bDescriptorSubType; - /// Indicates available controls and requirement on packet sizes. - unsigned char bmAttributes; - /// Indicates the units of the wLockDelay fields. - /// \sa "USB Audio Lock delay units" - unsigned char bLockDelayUnits; - /// Time it takes for the endpoint to lock its internal clock circuitry. - unsigned short wLockDelay; - -} __attribute__ ((packed)) AUDDataEndpointDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDDATAENDPOINTDESCRIPTOR_H diff --git a/src/ersky9x/libraries/usb/common/audio/AUDDeviceDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDDeviceDescriptor.h deleted file mode 100644 index f33523a8a..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDDeviceDescriptor.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Fields values for an USB Audio %device descriptor. -/// -/// !!!Usage -/// -/// -# When declaring the %device descriptor of a USB %audio %device, use -/// "USB Audio device descriptor values" defined here. -//------------------------------------------------------------------------------ - -#ifndef AUDDEVICEDESCRIPTOR_H -#define AUDDEVICEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio device descriptor values" -/// -/// This page lists the class, subclass & protocol codes that a USB audio -/// device should display in its device descriptor. -/// -/// !Codes -/// - AUDDeviceDescriptor_CLASS -/// - AUDDeviceDescriptor_SUBCLASS -/// - AUDDeviceDescriptor_PROTOCOL - -/// Class code for a USB audio device. -#define AUDDeviceDescriptor_CLASS 0x00 - -/// Subclass code for a USB audio device. -#define AUDDeviceDescriptor_SUBCLASS 0x00 - -/// Protocol code for a USB audio device. -#define AUDDeviceDescriptor_PROTOCOL 0x00 -//------------------------------------------------------------------------------ - -#endif //#ifndef AUDDEVICEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDEndpointDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDEndpointDescriptor.h deleted file mode 100644 index 9dce6abfd..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDEndpointDescriptor.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Re-definition of the standard USB endpoint descriptor with two additional -/// fields. This is required by the USB audio 1.00 specification. -/// -/// !!!Usage -/// -/// -# Declare an AUDEndpointDescriptor instance as part of the configuration -/// descriptors of an USB %audio %device. -//------------------------------------------------------------------------------ - -#ifndef AUDENDPOINTDESCRIPTOR_H -#define AUDENDPOINTDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Modified endpoint descriptor with two additional fields, with are -/// USB audio specific. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of the descriptor in bytes. - unsigned char bLength; - /// Descriptor type (USBGenericDescriptor_ENDPOINT). - unsigned char bDescriptorType; - /// Address and direction of the endpoint. - unsigned char bEndpointAddress; - /// Endpoint type and additional characteristics (for isochronous endpoints). - unsigned char bmAttributes; - /// Maximum packet size (in bytes) of the endpoint. - unsigned short wMaxPacketSize; - /// Polling rate of the endpoint. - unsigned char bInterval; - /// Refresh rate for a feedback endpoint. - unsigned char bRefresh; - /// Address of the associated feedback endpoint if any. - unsigned char bSyncAddress; - -} __attribute__ ((packed)) AUDEndpointDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDENDPOINTDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitDescriptor.h deleted file mode 100644 index a1ba45f2c..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitDescriptor.h +++ /dev/null @@ -1,116 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Class for manipulating USB %audio feature unit descriptor. -/// -/// !!!Usage -/// -/// -# Declare an AUDFeatureUnitDescriptor instance as part of the -/// configuration descriptors returned by a USB %audio %device. -//------------------------------------------------------------------------------ - -#ifndef AUDFEATUREUNITDESCRIPTOR_H -#define AUDFEATUREUNITDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio Channel controls" -/// -/// This page lists the available controls for each channel of the audio -/// interface. Each channel can have any control combination; simply perform -/// a bitwise OR ('|') to combine several values. -/// -/// !Controls -/// -# AUDFeatureUnitDescriptor_MUTE -/// -# AUDFeatureUnitDescriptor_VOLUME -/// -# AUDFeatureUnitDescriptor_BASS -/// -# AUDFeatureUnitDescriptor_MID -/// -# AUDFeatureUnitDescriptor_TREBLE - -/// Channel mute control. -#define AUDFeatureUnitDescriptor_MUTE (1 << 0) - -/// Channel volume control. -#define AUDFeatureUnitDescriptor_VOLUME (1 << 1) - -/// Channel bass control. -#define AUDFeatureUnitDescriptor_BASS (1 << 2) - -/// Channel middle control. -#define AUDFeatureUnitDescriptor_MID (1 << 3) - -/// Channel treble control. -#define AUDFeatureUnitDescriptor_TREBLE (1 << 4) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes available controls for each channel of the unit or terminal -/// it is connected to. This type must be augmented with the relevant number -/// of bmaControls fields and the iFeature field. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDGenericDescriptor_FEATURE). - unsigned char bDescriptorSubType; - /// Identifier of this feature unit. - unsigned char bUnitID; - /// Identifier of the unit or terminal this feature unit is connected to. - unsigned char bSourceID; - /// Size in bytes of a channel controls field. - unsigned char bControlSize; - -} __attribute__ ((packed)) AUDFeatureUnitDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDFEATUREUNITDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.c b/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.c deleted file mode 100644 index bc6c642c8..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDFeatureUnitRequest.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns the control selector value indicating the target of a Feature Unit -/// request. -/// \param request Pointer to a USBGenericRequest instance. -/// \sa "USB Audio Control selector values" -//------------------------------------------------------------------------------ -unsigned char AUDFeatureUnitRequest_GetControl(const USBGenericRequest *request) -{ - return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF); -} - -//------------------------------------------------------------------------------ -/// Returns the channel number of a Feature unit which should be altered by the -/// given request. -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -unsigned char AUDFeatureUnitRequest_GetChannel(const USBGenericRequest *request) -{ - return (USBGenericRequest_GetValue(request) & 0xFF); -} - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.h b/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.h deleted file mode 100644 index 289f598d2..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDFeatureUnitRequest.h +++ /dev/null @@ -1,81 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definitions of constants and methods for using USB %audio requests -/// targetted at a Feature unit. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# Use AUDFeatureUnitRequest_GetControl to determine which control -/// shall be tweaked following a host request. -// -# Use AUDFeatureUnitRequest_GetChannel to identify the channel which -// will have its control altered. -//------------------------------------------------------------------------------ - -#ifndef AUDFEATUREUNITREQUEST_H -#define AUDFEATUREUNITREQUEST_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio Control selector values" -/// -/// This page lists the available control selectors for a Feature Unit request. -/// -/// !Controls -/// - AUDFeatureUnitRequest_MUTE - -/// Mute control selector. -#define AUDFeatureUnitRequest_MUTE 0x01 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -extern unsigned char AUDFeatureUnitRequest_GetControl( - const USBGenericRequest *request); -extern unsigned char AUDFeatureUnitRequest_GetChannel( - const USBGenericRequest *request); - -#endif //#ifndef AUDFEATUREUNITREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDFormatTypeOneDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDFormatTypeOneDescriptor.h deleted file mode 100644 index 0aa6b6342..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDFormatTypeOneDescriptor.h +++ /dev/null @@ -1,101 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definitions for using USB %audio format type I descriptors. -/// -/// !!!Usage -/// -/// -# Declare an instance of AUDFormatTypeOneDescriptor as part of the -/// configuration descriptors of an audio device. -//------------------------------------------------------------------------------ - -#ifndef AUDFORMATTYPEONEDESCRIPTOR_H -#define AUDFORMATTYPEONEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Format type for a format type I descriptor. -#define AUDFormatTypeOneDescriptor_FORMATTYPEONE 0x01 - -/// AUDFormatTypeOneDescriptor_PCM - PCM format. -#define AUDFormatTypeOneDescriptor_PCM 0x0001 - -/// Indicates the sampling frequency can have any value in the provided range. -#define AUDFormatTypeOneDescriptor_CONTINUOUS 0 - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes an audio data stream that is constructed on a sample-by-sample -/// basis. This type must be augmented with either the continuous sampling -/// frequency range (if bSamFreqType = ) -/// or with an array containing the possible discrete frequencies. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDStreamingInterfaceDescriptor_FORMATTYPE). - unsigned char bDescriptorSubType; - /// Format type (AUDFormatTypeOneDescriptor_FORMATTYPEONE). - unsigned char bFormatType; - /// Number of physical channels in the audio stream. - unsigned char bNrChannels; - /// Number of bytes occupied by one audio subframe. - unsigned char bSubFrameSize; - /// Number of bits effectively used in an audio subframe. - unsigned char bBitResolution; - /// Number of supported discrete sampling frequencies, or - /// AUDFormatTypeOneDescriptor_CONTINUOUS. - unsigned char bSamFreqType; - -} __attribute__ ((packed)) AUDFormatTypeOneDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDFORMATTYPEONEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDGenericDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDGenericDescriptor.h deleted file mode 100644 index 8758a9257..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDGenericDescriptor.h +++ /dev/null @@ -1,121 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Constants for manipulating USB audio-specific descriptors. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# When declaring an Audio-specific descriptor, use the descriptor types -/// and subtypes defined in this unit (see "USB Audio descriptor types" -/// and "USB Audio descriptor subtypes"). -//------------------------------------------------------------------------------ - -#ifndef AUDGENERICDESCRIPTOR_H -#define AUDGENERICDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio descriptor types" -/// -/// This page lists the available types for USB audio-specific descriptors. -/// -/// !Types -/// - AUDGenericDescriptor_DEVICE -/// - AUDGenericDescriptor_CONFIGURATION -/// - AUDGenericDescriptor_STRING -/// - AUDGenericDescriptor_INTERFACE -/// - AUDGenericDescriptor_ENDPOINT - -/// Descriptor gives detail about the whole device. -#define AUDGenericDescriptor_DEVICE 0x21 - -/// Descriptor gives detail about a configuration. -#define AUDGenericDescriptor_CONFIGURATION 0x22 - -/// Descriptor gives detail about a string. -#define AUDGenericDescriptor_STRING 0x23 - -/// Descriptor gives detail about an interface. -#define AUDGenericDescriptor_INTERFACE 0x24 - -/// Descriptor gives detail about an endpoint. -#define AUDGenericDescriptor_ENDPOINT 0x25 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio descriptor subtypes" -/// -/// This page lists the possible subtypes for USB audio-specific descriptors. -/// -/// !Subtypes -/// - AUDGenericDescriptor_HEADER -/// - AUDGenericDescriptor_INPUTTERMINAL -/// - AUDGenericDescriptor_OUTPUTTERMINAL -/// - AUDGenericDescriptor_MIXERUNIT -/// - AUDGenericDescriptor_SELECTORUNIT -/// - AUDGenericDescriptor_FEATUREUNIT -/// - AUDGenericDescriptor_PROCESSINGUNIT -/// - AUDGenericDescriptor_EXTENSIONUNIT - -/// Header descriptor subtype. -#define AUDGenericDescriptor_HEADER 0x01 - -/// Input terminal descriptor subtype. -#define AUDGenericDescriptor_INPUTTERMINAL 0x02 - -/// Output terminal descriptor subtype. -#define AUDGenericDescriptor_OUTPUTTERMINAL 0x03 - -/// Mixer unit descriptor subtype. -#define AUDGenericDescriptor_MIXERUNIT 0x04 - -/// Selector unit descriptor subtype. -#define AUDGenericDescriptor_SELECTORUNIT 0x05 - -/// Feature unit descriptor subtype. -#define AUDGenericDescriptor_FEATUREUNIT 0x06 - -/// Processing unit descriptor subtype. -#define AUDGenericDescriptor_PROCESSINGUNIT 0x07 - -///Extension unit descriptor subtype. -#define AUDGenericDescriptor_EXTENSIONUNIT 0x08 -//------------------------------------------------------------------------------ - -#endif //#ifndef AUDGENERICDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.c b/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.c deleted file mode 100644 index c9c6e8785..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.c +++ /dev/null @@ -1,57 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDGenericRequest.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns the ID of the unit or terminal targetted by an USB audio request. -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -unsigned char AUDGenericRequest_GetEntity(const USBGenericRequest *request) -{ - return ((USBGenericRequest_GetIndex(request) >> 8) & 0xFF); -} - -//------------------------------------------------------------------------------ -/// Returns the ID of the interface targetted by an USB audio request. -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -unsigned char AUDGenericRequest_GetInterface(const USBGenericRequest *request) -{ - return (USBGenericRequest_GetIndex(request) & 0xFF); -} - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.h b/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.h deleted file mode 100644 index b0b8527db..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDGenericRequest.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Constants for using USB %audio SETUP requests. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# After receiving an Audio request from the host, use -/// AUDGenericRequest_GetEntity to determine the target Unit or Terminal. -/// -# After receiving an Audio request from the host, use -/// AUDGenericRequest_GetInterface to know which interface is referenced. -//------------------------------------------------------------------------------ - -#ifndef AUDGENERICREQUEST_H -#define AUDGENERICREQUEST_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio request codes" -/// -/// This page lists the codes of the existing Audio requests. -/// -/// !Requests -/// - AUDGenericRequest_SETCUR -/// - AUDGenericRequest_GETCUR - -/// SET_CUR request code. -#define AUDGenericRequest_SETCUR 0x01 - -/// GET_CUR request code. -#define AUDGenericRequest_GETCUR 0x81 - -/// GET_MIN request code. -#define AUDGenericRequest_GETMIN 0x82 - -/// GET_MAX request code. -#define AUDGenericRequest_GETMAX 0x83 - -/// GET_RES request code. -#define AUDGenericRequest_GETRES 0x84 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char AUDGenericRequest_GetEntity( - const USBGenericRequest *request); -extern unsigned char AUDGenericRequest_GetInterface( - const USBGenericRequest *request); - -#endif //#ifndef AUDGENERICREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDHeaderDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDHeaderDescriptor.h deleted file mode 100644 index ca30a0b6e..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDHeaderDescriptor.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Class for manipulating USB %audio header descriptors. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# Declare a AUDHeaderDescriptor as part of the configuration -/// descriptors of the %device. -//------------------------------------------------------------------------------ - -#ifndef AUDHEADERDESCRIPTOR_H -#define AUDHEADERDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio class releases" -/// This page lists the existing versions of the Audio class specification. -/// -/// -/// !Versions -/// - AUDHeaderDescriptor_AUD1_00 - -/// Indentifies the USB audio specification release 1.00. -#define AUDHeaderDescriptor_AUD1_00 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Groups the various audio interfaces to display one single function to -/// the USB host. Subclass this structure to add a particular number of -/// slave interface descriptors. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDGenericDescriptor_HEADER). - unsigned char bDescriptorSubType; - /// Audio class release number in BCD format - /// \sa "USB Audio class releases" - unsigned short bcdADC; - /// Length of all descriptors used to qualify the Audio Control interface. - unsigned short wTotalLength; - /// Number of Streaming interfaces contained in this collection. - unsigned char bInCollection; - -} __attribute__ ((packed)) AUDHeaderDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDHEADERDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDInputTerminalDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDInputTerminalDescriptor.h deleted file mode 100644 index e0895fb54..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDInputTerminalDescriptor.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Class for manipulating input terminal descriptors. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# Declare an AUDInputTerminalDescriptor instance as part of the -/// configuration of the %device. -//------------------------------------------------------------------------------ - -#ifndef AUDINPUTTERMINALDESCRIPTOR_H -#define AUDINPUTTERMINALDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio Input terminal types" -/// -/// This page lists the available types for an Input terminal. -/// -/// !Types -/// -/// - AUDInputTerminalDescriptor_USBSTREAMING -/// - AUDInputTerminalDescriptor_MICROPHONE -/// - AUDInputTerminalDescriptor_SPEAKERPHONE -/// - AUDInputTerminalDescriptor_LINEIN - -/// A terminal receiving its data from a USB isochronous endpoint. -#define AUDInputTerminalDescriptor_USBSTREAMING 0x0101 -/// A terminal sampling data from a microphone. -#define AUDInputTerminalDescriptor_MICROPHONE 0x0201 -/// A terminal sampling data from a Handset In. -#define AUDInputTerminalDescriptor_HANDSETIN 0x0401 -/// A terminal sampling data from a speakerphone -#define AUDInputTerminalDescriptor_SPEAKERPHONE 0x0403 -/// A terminal sampling data from a Phone Line In. -#define AUDInputTerminalDescriptor_LINEIN 0x0501 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio Channel spatial locations" -/// -/// This page lists the possible spatial locations for audio channels. -/// -/// !Locations -/// -/// - AUDInputTerminalDescriptor_LEFTFRONT -/// - AUDInputTerminalDescriptor_RIGHTFRONT -/// - AUDInputTerminalDescriptor_CENTERFRONT - -/// Front left channel. -#define AUDInputTerminalDescriptor_LEFTFRONT (1 << 0) - -/// Front right channel. -#define AUDInputTerminalDescriptor_RIGHTFRONT (1 << 1) - -/// Front center channel. -#define AUDInputTerminalDescriptor_CENTERFRONT (1 << 2) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes an input of a USB audio device. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDGenericDescriptor_INPUTTERMINAL). - unsigned char bDescriptorSubType; - /// ID of the terminal in the audio function. - unsigned char bTerminalID; - /// Terminal type. - /// \sa "USB Audio Input terminal types" - unsigned short wTerminalType; - /// ID of the output terminal to which this input terminal is associated. - unsigned char bAssocTerminal; - /// Number of logical output channels in this terminal. - unsigned char bNrChannels; - /// Spatial configuration of the logical channels. - unsigned short wChannelConfig; - /// Index of a string descriptor for the first logical channel. - unsigned char iChannelNames; - /// Index of a string descriptor for this terminal. - unsigned char iTerminal; - -} __attribute__ ((packed)) AUDInputTerminalDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDINPUTTERMINALDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDOutputTerminalDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDOutputTerminalDescriptor.h deleted file mode 100644 index 6ba315633..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDOutputTerminalDescriptor.h +++ /dev/null @@ -1,112 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definition of a class for using USB %audio output terminal descriptors. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# Declare a AUDOutputTerminalDescriptor instance as part of the -/// configuration descriptors of a USB %audio %device. -//------------------------------------------------------------------------------ - -#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H -#define AUDOUTPUTTERMINALDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio Output terminal types" -/// -/// This page lists the available types for an output terminal. -/// -/// !Types -/// - AUDOutputTerminalDescriptor_USBTREAMING -/// - AUDOutputTerminalDescriptor_SPEAKER -/// - AUDOutputTerminalDescriptor_HANDSETOUT -/// - AUDOutputTerminalDescriptor_LINEOUT - -/// A terminal sending data through USB isochronous endpoint. -#define AUDOutputTerminalDescriptor_USBTREAMING 0x0101 -/// A terminal sending data to a USB host through an Isochronous endpoint. -#define AUDOutputTerminalDescriptor_SPEAKER 0x0301 -/// A terminal sending data to Handset Out. -#define AUDOutputTerminalDescriptor_HANDSETOUT 0x0401 -/// A terminal sending data to Phone Line Out. -#define AUDOutputTerminalDescriptor_LINEOUT 0x0501 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// \typedef AUDOutputTerminalDescriptor -/// Describes an output of the USB audio function. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDGenericDescriptor_OUTPUTTERMINAL). - unsigned char bDescriptorSubType; - /// Identifier for this terminal. - unsigned char bTerminalID; - /// Terminal type. - /// \sa "USB Audio Output terminal types" - unsigned short wTerminalType; - /// Identifier of the associated input terminal. - unsigned char bAssocTerminal; - /// Identifier of the unit or terminal to which this terminal is connected. - unsigned char bSourceID; - /// Index of a string descriptor for this terminal. - unsigned char iTerminal; - -} __attribute__ ((packed)) AUDOutputTerminalDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/AUDStreamingInterfaceDescriptor.h b/src/ersky9x/libraries/usb/common/audio/AUDStreamingInterfaceDescriptor.h deleted file mode 100644 index 80c9cfd12..000000000 --- a/src/ersky9x/libraries/usb/common/audio/AUDStreamingInterfaceDescriptor.h +++ /dev/null @@ -1,129 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Definition of a class for manipulating USB %audio streaming interface -/// descriptors. -/// -/// !!!Usage -/// -/// - For a USB %device: -/// -# Declare an AUDStreamingInterfaceDescriptor instance as part of the -/// configuration descriptors returned by a USB %audio %device. -//------------------------------------------------------------------------------ - -#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H -#define AUDSTREAMINGINTERFACEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio streaming interface codes" -/// -/// This page lists the class, subclass and protocol codes that an Audio -/// Streaming interface should display in its descriptor. -/// -/// !Codes -/// - AUDStreamingInterfaceDescriptor_CLASS -/// - AUDStreamingInterfaceDescriptor_SUBCLASS -/// - AUDStreamingInterfaceDescriptor_PROTOCOL - -/// Class code for an USB audio streaming interface. -#define AUDStreamingInterfaceDescriptor_CLASS 0x01 - -/// Subclass code for an audio streaming interface. -#define AUDStreamingInterfaceDescriptor_SUBCLASS 0x02 - -/// Protocol code for an audio streaming interface. -#define AUDStreamingInterfaceDescriptor_PROTOCOL 0x00 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "USB Audio streaming descriptor subtypes" -/// -/// This page lists the possible subtypes for audio-specific descriptor appended -/// to an Audio Streaming interface. -/// -/// !Subtypes -/// - AUDStreamingInterfaceDescriptor_GENERAL -/// - AUDStreamingInterfaceDescriptor_FORMATTYPE -/// - AUDStreamingInterfaceDescriptor_FORMATSPECIFIC - -/// General descriptor subtype. -#define AUDStreamingInterfaceDescriptor_GENERAL 0x01 - -/// Format type descriptor subtype. -#define AUDStreamingInterfaceDescriptor_FORMATTYPE 0x02 - -/// Format specific descriptor subtype. -#define AUDStreamingInterfaceDescriptor_FORMATSPECIFIC 0x03 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Provides additional information about an audio streaming interface to -/// the USB host. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (AUDGenericDescriptor_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (AUDStreamingInterfaceDescriptor_GENERAL). - unsigned char bDescriptorSubType; - /// Terminal ID to which the interface is connected. - unsigned char bTerminalLink; - /// Delay introduced by the data path, in number of frames. - unsigned char bDelay; - /// Audio data format used by this interface. - unsigned short wFormatTag; - -} __attribute__ ((packed)) AUDStreamingInterfaceDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/audio/audio.dir b/src/ersky9x/libraries/usb/common/audio/audio.dir deleted file mode 100644 index 2bc574f7a..000000000 --- a/src/ersky9x/libraries/usb/common/audio/audio.dir +++ /dev/null @@ -1,40 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !!!Purpose -/// -/// This directory contains definitions, structures and funcions related to the -/// USB Audio Class specification. They can be divided into two groups: -/// - Audio-specific descriptors, prefixed with AUD and suffixed with -/// Descriptor. -/// - Audio-specific requests, prefixed with AUD and suffixed with Request. -//------------------------------------------------------------------------------ - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCAbstractControlManagementDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCAbstractControlManagementDescriptor.h deleted file mode 100644 index 943204c95..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCAbstractControlManagementDescriptor.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for manipulating CDC abstract control management - descriptors. - - !!!Usage - - Should be included in a list of USB configuration descriptors. -*/ - -#ifndef CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H -#define CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC ACM Capabilities" -/// This page lists the capabilities of the CDC ACM. -/// -/// !Capabilities -/// - CDCAbstractControlManagementDescriptor_COMMFEATURE -/// - CDCAbstractControlManagementDescriptor_LINE -/// - CDCAbstractControlManagementDescriptor_SENDBREAK -/// - CDCAbstractControlManagementDescriptor_NETWORKCONNECTION - -/// Device supports the request combination of SetCommFeature, ClearCommFeature -/// and GetCommFeature. -#define CDCAbstractControlManagementDescriptor_COMMFEATURE (1 << 0) -/// Device supports the request combination of SetLineCoding, GetLineCoding and -/// SetControlLineState. -#define CDCAbstractControlManagementDescriptor_LINE (1 << 1) -/// Device supports the SendBreak request. -#define CDCAbstractControlManagementDescriptor_SENDBREAK (1 << 2) -/// Device supports the NetworkConnection notification. -#define CDCAbstractControlManagementDescriptor_NETWORKCONNECTION (1 << 3) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes the command supported by the communication interface class -/// with the Abstract Control Model subclass code. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of this descriptor in bytes. - unsigned char bFunctionLength; - /// Descriptor type (CDCDescriptors_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (CDCDescriptors_ABSTRACTCONTROLMANAGEMENT). - unsigned char bDescriptorSubtype; - /// Configuration capabilities. - /// \sa "CDC ACM Capabilities". - unsigned char bmCapabilities; - -} __attribute__ ((packed)) CDCAbstractControlManagementDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCCallManagementDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCCallManagementDescriptor.h deleted file mode 100644 index 191ff61c4..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCCallManagementDescriptor.h +++ /dev/null @@ -1,97 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for managing CDC call management descriptors. - - !!!Usage - - Should be included in a list of configuration descriptors for a USB - device. -*/ - -#ifndef CDCCALLMANAGEMENTDESCRIPTOR_H -#define CDCCALLMANAGEMENTDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC CallManagement Capabilities" -/// This page lists CDC CallManagement Capabilities. -/// -/// !Capabilities -/// - CDCCallManagementDescriptor_SELFCALLMANAGEMENT -/// - CDCCallManagementDescriptor_DATACALLMANAGEMENT - -/// Device handles call management itself. -#define CDCCallManagementDescriptor_SELFCALLMANAGEMENT (1 << 0) -/// Device can exchange call management information over a Data class interface. -#define CDCCallManagementDescriptor_DATACALLMANAGEMENT (1 << 1) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes the processing of calls for the communication class interface. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of this descriptor in bytes. - unsigned char bFunctionLength; - /// Descriptor type (CDCDescriptors_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor sub-type (CDCDescriptors_CALLMANAGEMENT). - unsigned char bDescriptorSubtype; - /// Configuration capabilities ("CDC CallManagement Capabilities"). - unsigned char bmCapabilities; - /// Interface number of the data class interface used for call management - /// (optional). - unsigned char bDataInterface; - -} __attribute__ ((packed)) CDCCallManagementDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef CDCCALLMANAGEMENTDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h deleted file mode 100644 index aa1391532..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of several constants used when declaring a CDC communication - class interface descriptor. -*/ - -#ifndef CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H -#define CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Communication Interface Values" -/// This page lists the values for CDC Communication Interface Descriptor. -/// -/// !Values -/// - CDCCommunicationInterfaceDescriptor_CLASS -/// - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL -/// - CDCCommunicationInterfaceDescriptor_NOPROTOCOL - -/// Interface class code for a CDC communication class interface. -#define CDCCommunicationInterfaceDescriptor_CLASS 0x02 -/// Interface subclass code for an Abstract Control Model interface descriptor. -#define CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL 0x02 -/// Interface protocol code when a CDC communication interface does not -/// implemenent any particular protocol. -#define CDCCommunicationInterfaceDescriptor_NOPROTOCOL 0x00 -//------------------------------------------------------------------------------ - -#endif //#ifndef CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCDataInterfaceDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCDataInterfaceDescriptor.h deleted file mode 100644 index 640f8dc15..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCDataInterfaceDescriptor.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions of constants used when declaring a CDC data class interface - descriptor. -*/ - -#ifndef CDCDATAINTERFACEDESCRIPTOR_H -#define CDCDATAINTERFACEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Data Interface Values" -/// This page lists the values for CDC Data Interface Descriptor. -/// -/// !Values -/// - CDCDataInterfaceDescriptor_CLASS -/// - CDCDataInterfaceDescriptor_SUBCLASS -/// - CDCDataInterfaceDescriptor_NOPROTOCOL - -/// Interface class code for a data class interface. -#define CDCDataInterfaceDescriptor_CLASS 0x0A -/// Interface subclass code for a data class interface. -#define CDCDataInterfaceDescriptor_SUBCLASS 0x00 -/// Protocol code for a data class interface which does not implement any -/// particular protocol. -#define CDCDataInterfaceDescriptor_NOPROTOCOL 0x00 -//------------------------------------------------------------------------------ - -#endif //#ifndef CDCDATAINTERFACEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCDeviceDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCDeviceDescriptor.h deleted file mode 100644 index b1bc177d4..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCDeviceDescriptor.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of several constants used when declaring USB CDC device - descriptors. -*/ - -#ifndef CDCDEVICEDESCRIPTOR_H -#define CDCDEVICEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Device Descriptor Values" -/// This page lists the values for CDC Device Descriptor. -/// -/// !Values -/// - CDCDeviceDescriptor_CLASS -/// - CDCDeviceDescriptor_SUBCLASS -/// - CDCDeviceDescriptor_PROTOCOL - -/// Device class code when using the CDC class. -#define CDCDeviceDescriptor_CLASS 0x02 -/// Device subclass code when using the CDC class. -#define CDCDeviceDescriptor_SUBCLASS 0x00 -/// Device protocol code when using the CDC class. -#define CDCDeviceDescriptor_PROTOCOL 0x00 -//------------------------------------------------------------------------------ - -#endif //#ifndef CDCDEVICEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCGenericDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCGenericDescriptor.h deleted file mode 100644 index 3d9365667..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCGenericDescriptor.h +++ /dev/null @@ -1,91 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of several constants for declaring CDC descriptors. -*/ - -#ifndef CDCGENERICDESCRIPTOR_H -#define CDCGENERICDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Specification Release Numbers" -/// This page list the CDC Spec. Release Numbers. -/// -/// !Numbers -/// - CDCGenericDescriptor_CDC1_10 - -/// Identify CDC specification version 1.10. -#define CDCGenericDescriptor_CDC1_10 0x0110 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Descriptro Types" -/// This page lists CDC descriptor types. -/// -/// !Types -/// - CDCGenericDescriptor_INTERFACE -/// - CDCGenericDescriptor_ENDPOINT - -///Indicates that a CDC descriptor applies to an interface. -#define CDCGenericDescriptor_INTERFACE 0x24 -/// Indicates that a CDC descriptor applies to an endpoint. -#define CDCGenericDescriptor_ENDPOINT 0x25 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Descriptor Subtypes" -/// This page lists CDC descriptor sub types -/// -/// !Types -/// - CDCGenericDescriptor_HEADER -/// - CDCGenericDescriptor_CALLMANAGEMENT -/// - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT -/// - CDCGenericDescriptor_UNION - -/// Header functional descriptor subtype. -#define CDCGenericDescriptor_HEADER 0x00 -/// Call management functional descriptor subtype. -#define CDCGenericDescriptor_CALLMANAGEMENT 0x01 -/// Abstract control management descriptor subtype. -#define CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT 0x02 -/// Union descriptor subtype. -#define CDCGenericDescriptor_UNION 0x06 -//------------------------------------------------------------------------------ - -#endif //#ifndef CDCGENERICDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCGenericRequest.h b/src/ersky9x/libraries/usb/common/cdc/CDCGenericRequest.h deleted file mode 100644 index d6abd0b8f..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCGenericRequest.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Various definitions used for characterizing USB CDC requests. -*/ - -#ifndef CDCGENERICREQUEST_H -#define CDCGENERICREQUEST_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Request Codes" -/// This page lists USB CDC Request Codes. -/// -/// !Codes -/// - CDCGenericRequest_SETLINECODING -/// - CDCGenericRequest_GETLINECODING -/// - CDCGenericRequest_SETCONTROLLINESTATE - -/// SetLineCoding request code. -#define CDCGenericRequest_SETLINECODING 0x20 -/// GetLineCoding request code. -#define CDCGenericRequest_GETLINECODING 0x21 -/// SetControlLineState request code. -#define CDCGenericRequest_SETCONTROLLINESTATE 0x22 -//------------------------------------------------------------------------------ - -#endif //#ifndef CDCGENERICREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCHeaderDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCHeaderDescriptor.h deleted file mode 100644 index b04926f94..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCHeaderDescriptor.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of the CDCHeaderDescriptor class. - - !!!Usage - - Should be included in a USB configuration descriptor. -*/ - -#ifndef CDCHEADERDESCRIPTOR_H -#define CDCHEADERDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Marks the beginning of the concatenated set of functional descriptors -/// for the interface. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of this descriptor in bytes. - unsigned char bFunctionLength; - /// Descriptor type (CDCDescriptors_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor sub-type (CDCDescriptors_HEADER). - unsigned char bDescriptorSubtype; - /// USB CDC specification release number. - unsigned short bcdCDC; - -} __attribute__ ((packed)) CDCHeaderDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef CDCHEADERDESCRIPTOR_H - - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.c b/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.c deleted file mode 100644 index 4223fec27..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.c +++ /dev/null @@ -1,78 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: CDCLineCoding - - About: Purpose - Implementation of the CDCLineCoding class. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "CDCLineCoding.h" -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the bitrate, number of stop bits, parity checking and -/// number of data bits of a CDCLineCoding object. -/// \param lineCoding Pointer to a CDCLineCoding instance. -/// \param bitrate Bitrate of the virtual COM connection. -/// \param stopbits Number of stop bits ("CDC LineCoding StopBits"). -/// \param parity Parity check type ("CDC LineCoding ParityChecking"). -/// \param databits Number of data bits. -//------------------------------------------------------------------------------ -void CDCLineCoding_Initialize(CDCLineCoding *lineCoding, - unsigned int bitrate, - unsigned char stopbits, - unsigned char parity, - unsigned char databits) -{ - ASSERT(stopbits <= CDCLineCoding_TWOSTOPBITS, - "CDCLineCoding_Initialize: Invalid stopbits value (%d)\n\r", - stopbits); - ASSERT(parity <= CDCLineCoding_SPACEPARITY, - "CDCLineCoding_Initialize: Invalid parity value (%d)\n\r", - parity); - ASSERT(((databits >= 5) && (databits <= 8)) || (databits == 16), - "CDCLineCoding_Initialize: Invalid databits value (%d)\n\r", - databits); - - lineCoding->dwDTERate = bitrate; - lineCoding->bCharFormat = stopbits; - lineCoding->bParityType = parity; - lineCoding->bDataBits = databits; -} - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.h b/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.h deleted file mode 100644 index dfe3c10cb..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCLineCoding.h +++ /dev/null @@ -1,136 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Line coding structure used for by the CDC GetLineCoding and SetLineCoding - requests. - - !!!Usage - - -# Initialize a CDCLineCoding instance using CDCLineCoding_Initialize. - -# Send a CDCLineCoding object to the host in response to a GetLineCoding - request. - -# Receive a CDCLineCoding object from the host after a SetLineCoding - request. -*/ - -#ifndef CDCLINECODING_H -#define CDCLINECODING_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC LineCoding StopBits" -/// This page lists Stop Bits for CDC Line Coding. -/// -/// !Stop bits -/// - CDCLineCoding_ONESTOPBIT -/// - CDCLineCoding_ONE5STOPBIT -/// - CDCLineCoding_TWOSTOPBITS - -/// The transmission protocol uses one stop bit. -#define CDCLineCoding_ONESTOPBIT 0 -/// The transmission protocol uses 1.5 stop bit. -#define CDCLineCoding_ONE5STOPBIT 1 -/// The transmissin protocol uses two stop bits. -#define CDCLineCoding_TWOSTOPBITS 2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC LineCoding ParityCheckings" -/// This page lists Parity checkings for CDC Line Coding. -/// -/// !Parity checking -/// - CDCLineCoding_NOPARITY -/// - CDCLineCoding_ODDPARITY -/// - CDCLineCoding_EVENPARITY -/// - CDCLineCoding_MARKPARITY -/// - CDCLineCoding_SPACEPARITY - -/// No parity checking. -#define CDCLineCoding_NOPARITY 0 -/// Odd parity checking. -#define CDCLineCoding_ODDPARITY 1 -/// Even parity checking. -#define CDCLineCoding_EVENPARITY 2 -/// Mark parity checking. -#define CDCLineCoding_MARKPARITY 3 -/// Space parity checking. -#define CDCLineCoding_SPACEPARITY 4 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Format of the data returned when a GetLineCoding request is received. -//------------------------------------------------------------------------------ -typedef struct { - - /// Data terminal rate in bits per second. - unsigned int dwDTERate; - /// Number of stop bits. - /// \sa "CDC LineCoding StopBits". - char bCharFormat; - /// Type of parity checking used. - /// \sa "CDC LineCoding ParityCheckings". - char bParityType; - /// Number of data bits (5, 6, 7, 8 or 16). - char bDataBits; - -} __attribute__ ((packed)) CDCLineCoding; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void CDCLineCoding_Initialize(CDCLineCoding *lineCoding, - unsigned int bitrate, - unsigned char stopbits, - unsigned char parity, - unsigned char databits); - -#endif //#ifndef CDCLINECODING_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.c b/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.c deleted file mode 100644 index 43079ca93..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.c +++ /dev/null @@ -1,84 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - CDCSetControlLineStateRequest.c - - !!!Purpose - - Implementation of the CDCSetControlLineStateRequest class. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "CDCSetControlLineStateRequest.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Notifies if the given request indicates that the DTE signal is present. -/// \param request Pointer to a USBGenericRequest instance. -/// \return 1 if the DTE signal is present, otherwise 0. -//------------------------------------------------------------------------------ -unsigned char CDCSetControlLineStateRequest_IsDtePresent( - const USBGenericRequest *request) -{ - if ((USBGenericRequest_GetValue(request) & 0x0001) != 0) { - - return 1; - } - else { - - return 0; - } -} - -//------------------------------------------------------------------------------ -/// Notifies if the given request indicates that the device carrier should -/// be activated. -/// \param request Pointer to a USBGenericRequest instance. -/// \return 1 is the device should activate its carrier, 0 otherwise. -//------------------------------------------------------------------------------ -unsigned char CDCSetControlLineStateRequest_ActivateCarrier( - const USBGenericRequest *request) -{ - if ((USBGenericRequest_GetValue(request) & 0x0002) != 0) { - - return 1; - } - else { - - return 0; - } -} - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.h b/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.h deleted file mode 100644 index 5d6c66170..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCSetControlLineStateRequest.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for manipulating SetControlLineState requests. -*/ - -#ifndef CDCSETCONTROLLINESTATE_H -#define CDCSETCONTROLLINESTATE_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char CDCSetControlLineStateRequest_IsDtePresent( - const USBGenericRequest *request); - - -extern unsigned char CDCSetControlLineStateRequest_ActivateCarrier( - const USBGenericRequest *request); - -#endif //#ifndef CDCSETCONTROLLINESTATE_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/CDCUnionDescriptor.h b/src/ersky9x/libraries/usb/common/cdc/CDCUnionDescriptor.h deleted file mode 100644 index 0ba9eaa42..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/CDCUnionDescriptor.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for manipulating CDC union descriptors. - - !!!Usage - - Should be included in the list of USB descriptor used for a device - configuration. -*/ - -#ifndef CDCUNIONDESCRIPTOR_H -#define CDCUNIONDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Describes the relationship between a group of interfaces that can -/// be considered to form a functional unit. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of the descriptor in bytes. - unsigned char bFunctionLength; - /// Descriptor type (CDCDescriptors_INTERFACE). - unsigned char bDescriptorType; - /// Descriptor subtype (CDCDescriptors_UNION). - unsigned char bDescriptorSubtype; - /// Number of the master interface for this union. - unsigned char bMasterInterface; - /// Number of the first slave interface for this union. - unsigned char bSlaveInterface0; - -} __attribute__ ((packed)) CDCUnionDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef CDCUNIONDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/cdc/cdc.dir b/src/ersky9x/libraries/usb/common/cdc/cdc.dir deleted file mode 100644 index 8d9e99bd8..000000000 --- a/src/ersky9x/libraries/usb/common/cdc/cdc.dir +++ /dev/null @@ -1,39 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !Purpose -/// -/// This directory contains structures and definitions related to the USB CDC -/// specification. They can be divided into two groups: -/// - CDC-specific descriptors, prefixed with CDC and suffixed with Descriptor. -/// - CDC-specific requests, prefixed with CDC and suffixed with Request. -//------------------------------------------------------------------------------ - diff --git a/src/ersky9x/libraries/usb/common/common.dir b/src/ersky9x/libraries/usb/common/common.dir deleted file mode 100644 index 239696cf3..000000000 --- a/src/ersky9x/libraries/usb/common/common.dir +++ /dev/null @@ -1,55 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !!!Purpose -/// -/// This directory containes highly re-usable code from USB standard and some -/// classes specifications for general use. -/// -/// !!!Contents -/// This dircetory provides two sections of definitions: -/// -# Definitions, structures and functions from USB specification, -/// commonly used for all USB classes and projects. -/// - core: for USB specification -/// -# Definitions, structures and functions from class-specific -/// specification commonly used for class related project ONLY. -/// - cdc: for USB Communication Devie Class (CDC) -/// - hid: for USB Humen Interface Device Class (HID) -/// - massstorage: for USB Mass Storage Class (MS) -/// - audio: for USB Audio Class (AUD) -/// -/// For more information about what a particular group contains, please refer to -/// its documentation page. -/// -/// \note -/// Depending on the project, not all the subdirectories will be available -/// (i.e. the #cdc# directory will not be in non-CDC projects). -//------------------------------------------------------------------------------ \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.c b/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.c deleted file mode 100644 index c875790d0..000000000 --- a/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Includes -//----------------------------------------------------------------------------- - -#include "USBConfigurationOTG.h" - - -USBGenericOTGDescriptor *pOTGDescriptor; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// External functions -//----------------------------------------------------------------------------- -void OTG_Initialize(USBGenericOTGDescriptor *pOTGDesc) -{ - pOTGDescriptor = pOTGDesc; -} - - diff --git a/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.h b/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.h deleted file mode 100644 index d0d3b055e..000000000 --- a/src/ersky9x/libraries/usb/common/core/USBConfigurationOTG.h +++ /dev/null @@ -1,118 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Methods and definitions for configuring OTG. -/// -/// !Usage -/// -/// -# -/// -# -/// -//------------------------------------------------------------------------------ - -#ifndef USBCONFIGURATIONOTG_H -#define USBCONFIGURATIONOTG_H - -#include - - -/// OTG specific configuration -typedef struct { - - /// USB MODE CONFIGURATION - - /// ENABLE to activate the host software library support - /// Possible values ENABLE or DISABLE - unsigned char bOTGUsbHostFeature; - - /// ENABLE to activate the device software library support - /// Possible values ENABLE or DISABLE - unsigned char bOTGUsbDeviceFeature; - /// OTG MODE CONFIGURATION - /// ENABLE to enable OTG module (support A- and B- Device roles) - /// Possible values ENABLE or DISABLE - unsigned char bOTGFeature; - - /// For reduced host only allows to control VBUS generator with PIO PE.7 - unsigned char bOTGSoftwareVbusCtrl; - - /// Selects the messaging method for OTG No Silent Failure spec. - /// - /// A compliant OTG device must at least handle 3 Failure messages : - /// "Device No Response", "Unsupported Device" and "Unsupported Hub" - /// Functions must be defined for communicating messages to user (LCD display, - /// LEDs...) - /// The values available for this parameter are : - /// - OTGMSG_ALL : all messages (events and failures) are displayed - /// In this case, the following functions must be defined in user application firmware : - /// # "void Otg_messaging_init(void)", this function is called at start up to initialize the messaging peripheral - /// # "void Otg_output_failure_msg(U8)", displays the failure message choosen by ID number (see "usb_task.h") - /// # "void Otg_output_failure_clear(void)", clears the current failure message - /// # "void Otg_output_event_msg(U8)", displays the event message choosen by ID number - /// # "void Otg_output_event_clear(void)", clears the current event message - /// - OTGMSG_FAIL : only failure messages are displayed - /// In this case, the following functions must be defined in user application firmware : - /// # "void Otg_messaging_init(void)", this function is called at start up to initialize the messaging peripheral - /// # "void Otg_output_failure_msg(U8)", displays the failure message choosen by ID number (see "usb_task.h") - /// # "void Otg_output_failure_clear(void)", clears the current failure message - /// - OTGMSG_NONE : messages are not displayed (not OTG compliant device) - unsigned char bOTGMessagingOutput; - - /// ENABLE to make the A-Device send a SetFeature(b_hnp_enable) just after a SRP - /// has been received - /// This feature must be ENABLE to pass the OTG compliance program - /// Possible values ENABLE or DISABLE - unsigned char bOTGEnableHNPAfterSRP; - - /// Selects the SRP pulse for which the A Device will react and rise Vbus - /// The value is VBUS_PULSE or DATA_PULSE - unsigned char bOTGADevSRPReaction; - -} USBGenericOTGDescriptor; - -#define OTGMSG_NONE 0 // no messages displayed -#define OTGMSG_FAIL 1 // only failure messages displayed -#define OTGMSG_ALL 2 // all messages displayed - -#define VBUS_PULSE 1 // no more used -#define DATA_PULSE 0 - - -extern USBGenericOTGDescriptor *pOTGDescriptor; - -extern void OTG_Initialize(USBGenericOTGDescriptor *pOTGDesc); - - -#endif //#ifndef USBCONFIGURATIONOTG_H - diff --git a/src/ersky9x/libraries/usb/common/core/core.dir b/src/ersky9x/libraries/usb/common/core/core.dir deleted file mode 100644 index 7ac93c3f1..000000000 --- a/src/ersky9x/libraries/usb/common/core/core.dir +++ /dev/null @@ -1,53 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !!!Purpose -/// -/// This directory contains definitions, structures and functions described by -/// USB specification. They can be divided into two groups: -/// - USB descriptors, prefixed with USB and suffixed with Descriptor. -/// - USB requests, prefixed with USB and suffixed with Request. -//------------------------------------------------------------------------------ - -/** - \page "Standard USB Structures" - - !!!Standard USB Structures - - The following standard structures is implemented in the USB framework: - - Setup request data: USBGenericRequest - - Descriptor header: USBGenericDescriptor - - Device descriptor: USBDeviceDescriptor - - Configuration descriptor: USBConfigurationDescriptor - - Interface descriptor: USBInterfaceDescriptor - - %Endpoint descriptor: USBEndpointDescriptor - - Device_Qualifier descriptor: USBDeviceQualifierDescriptor -*/ diff --git a/src/ersky9x/libraries/usb/common/hid/HIDButton.h b/src/ersky9x/libraries/usb/common/hid/HIDButton.h deleted file mode 100644 index ea2557a22..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDButton.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDButton - - About: Purpose - Definitions of constants and methods for the HID Button usage page. - - About: Usage - 1 - Use the constants declared in this file when instanciating a - Report descriptor instance. - 2 - When implementing the functionality of an HID Mouse, use the - key codes defined here to indicate keys that are being pressed and - released. -*/ - -#ifndef _HIDBUTTON_H -#define _HIDBUTTON_H - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -/// Identifier for the HID button usage page -#define HIDButton_PAGEID 0x09 - - -#endif diff --git a/src/ersky9x/libraries/usb/common/hid/HIDDescriptor.h b/src/ersky9x/libraries/usb/common/hid/HIDDescriptor.h deleted file mode 100644 index ae0010287..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDDescriptor.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Methods and definitions for manipulating a HID descriptor. -*/ - -#ifndef HIDDESCRIPTOR_H -#define HIDDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Release Numbers" -/// ... -/// -/// !Numbers -/// - HIDDescriptor_HID1_11 - -/// Identifies version 1.11 of the HID specification. -#define HIDDescriptor_HID1_11 0x0111 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Identifies the length of type of subordinate descriptors of a HID -/// device. This particular type only supports one subordinate descriptor. -//------------------------------------------------------------------------------ -typedef struct { - - /// Size of descriptor in bytes. - unsigned char bLength; - /// Descriptor type (HIDGenericDescriptor_HID). - unsigned char bDescriptorType; - /// HID class specification release number in BCD format. - unsigned short bcdHID; - /// Country code of the device if it is localized. - unsigned char bCountryCode; - /// Number of subordinate descriptors. - unsigned char bNumDescriptors; - /// Type of the first subordinate descriptor. - unsigned char bDescriptorType0; - /// Size in bytes of the first subordinate descriptor. - unsigned short wDescriptorLength0; - -} __attribute__ ((packed)) HIDDescriptor; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -#endif //#ifndef HIDDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDDeviceDescriptor.h b/src/ersky9x/libraries/usb/common/hid/HIDDeviceDescriptor.h deleted file mode 100644 index 267c73e37..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDDeviceDescriptor.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions used for declaring the device descriptor of a HID device. - - !!!Usage - - Use this constants when defining an instance of USBDeviceDescriptor for - an HID device. -*/ - -#ifndef HIDDEVICEDESCRIPTOR_H -#define HIDDEVICEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Device Descriptor Codes" -/// This page lists HID device class, subclass and protocol codes. -/// -/// !Codes -/// - HIDDeviceDescriptor_CLASS -/// - HIDDeviceDescriptor_SUBCLASS -/// - HIDDeviceDescriptor_PROTOCOL - -/// Class code for a HID device. -#define HIDDeviceDescriptor_CLASS 0 -/// Subclass code for a HID device. -#define HIDDeviceDescriptor_SUBCLASS 0 -/// Protocol code for a HID device. -#define HIDDeviceDescriptor_PROTOCOL 0 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDDEVICEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDGenericDescriptor.h b/src/ersky9x/libraries/usb/common/hid/HIDGenericDescriptor.h deleted file mode 100644 index 2324d5363..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDGenericDescriptor.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions for using HID-specific descriptors. -*/ - -#ifndef HIDGENERICDESCRIPTOR_H -#define HIDGENERICDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Descriptors Types" -/// ... -/// -/// !Types -/// - HIDGenericDescriptor_HID -/// - HIDGenericDescriptor_REPORT -/// - HIDGenericDescriptor_PHYSICAL - -/// HID descriptor type. -#define HIDGenericDescriptor_HID 0x21 -/// Report descriptor type. -#define HIDGenericDescriptor_REPORT 0x22 -/// Physical descriptor type. -#define HIDGenericDescriptor_PHYSICAL 0x23 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDGENERICDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDGenericDesktop.h b/src/ersky9x/libraries/usb/common/hid/HIDGenericDesktop.h deleted file mode 100644 index ac1165c76..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDGenericDesktop.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Constants for using the HID generic desktop usage page. - - !!!Usage - - Use these constants when declaring a Report descriptor which references - the generic desktop page. -*/ - -#ifndef HIDGENERICDESKTOP_H -#define HIDGENERICDESKTOP_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID GenericDesktop Page ID" -/// ... -/// -/// !ID -/// - HIDGenericDesktop_PAGEID - -/// ID for the HID generic desktop usage page. -#define HIDGenericDesktop_PAGEID 0x01 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID GenericDesktop Usages" -/// ... -/// -/// !Usages -/// - HIDGenericDesktop_POINTER -/// - HIDGenericDesktop_MOUSE -/// - HIDGenericDesktop_JOYSTICK -/// - HIDGenericDesktop_GAMEPAD -/// - HIDGenericDesktop_KEYBOARD -/// - HIDGenericDesktop_KEYPAD -/// - HIDGenericDesktop_MULTIAXIS -/// - HIDGenericDesktop_X -/// - HIDGenericDesktop_Y - -/// Pointer usage ID. -#define HIDGenericDesktop_POINTER 0x01 -/// Mouse usage ID. -#define HIDGenericDesktop_MOUSE 0x02 -/// Joystick usage ID. -#define HIDGenericDesktop_JOYSTICK 0x04 -/// Gamepad usage ID. -#define HIDGenericDesktop_GAMEPAD 0x05 -/// Keyboard usage ID. -#define HIDGenericDesktop_KEYBOARD 0x06 -/// Keypad usage ID. -#define HIDGenericDesktop_KEYPAD 0x07 -/// Multi-axis controller usage ID. -#define HIDGenericDesktop_MULTIAXIS 0x08 - -/// Axis Usage X direction ID. -#define HIDGenericDesktop_X 0x30 -/// Axis Usage Y direction ID. -#define HIDGenericDesktop_Y 0x31 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDGENERICDESKTOP_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDGenericRequest.h b/src/ersky9x/libraries/usb/common/hid/HIDGenericRequest.h deleted file mode 100644 index 356f49843..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDGenericRequest.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDGenericRequest - - About: Purpose - Definition of constants for using HID-specific requests. - - About: Usage - When constructing or receiving an HID SETUP request, use the request - codes provided by this header file. -*/ - -#ifndef HIDGENERICREQUEST_H -#define HIDGENERICREQUEST_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Request Codes" -/// ... -/// -/// !Codes -/// - HIDGenericRequest_GETREPORT -/// - HIDGenericRequest_GETIDLE -/// - HIDGenericRequest_GETPROTOCOL -/// - HIDGenericRequest_SETREPORT -/// - HIDGenericRequest_SETIDLE -/// - HIDGenericRequest_SETPROTOCOL - -/// GetReport request code. -#define HIDGenericRequest_GETREPORT 0x01 -/// GetIdle request code. -#define HIDGenericRequest_GETIDLE 0x02 -/// GetProtocol request code. -#define HIDGenericRequest_GETPROTOCOL 0x03 -/// SetReport request code. -#define HIDGenericRequest_SETREPORT 0x09 -/// SetIdle request code. -#define HIDGenericRequest_SETIDLE 0x0A -/// SetProtocol request code. -#define HIDGenericRequest_SETPROTOCOL 0x0B -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDGENERICREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.c b/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.c deleted file mode 100644 index 640f2d5ad..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDIdleRequest implementation - - About: Purpose - Implementation of the HIDIdleRequest methods. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDIdleRequest.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Retrieves the Idle rate (in milliseconds) indicated by a SET_IDLE -/// request. -/// \param request Pointer to a USBGenericRequest instance. -/// \return New idle rate for the report. -//------------------------------------------------------------------------------ -unsigned char HIDIdleRequest_GetIdleRate(const USBGenericRequest *request) -{ - return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF); -} diff --git a/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.h b/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.h deleted file mode 100644 index 1f9a3616e..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDIdleRequest.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Methods and constants for manipulating HID-specific GET_IDLE and SET_IDLE - requests. - - !!!Usage - - -# Retrieve the idle rate indicated by a GET_IDLE or SET_IDLE request - with HIDIdleRequest_GetIdleRate. -*/ - -#ifndef HIDIDLEREQUEST_H -#define HIDIDLEREQUEST_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Infinite idle rate. -#define HIDIdleRequest_INFINITE 0 - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char HIDIdleRequest_GetIdleRate( - const USBGenericRequest *request); - -#endif //#ifndef HIDIDLEREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDInterfaceDescriptor.h b/src/ersky9x/libraries/usb/common/hid/HIDInterfaceDescriptor.h deleted file mode 100644 index 4ef1bc7e0..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDInterfaceDescriptor.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Constants used when declaring an HID interface. - - !!!Usage - - Use the constants defined here when declaring a USBInterfaceDescriptor - instance for a HID interface. -*/ - -#ifndef HIDINTERFACEDESCRIPTOR_H -#define HIDINTERFACEDESCRIPTOR_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Interface Descriptor Codes" -/// This page lists HID Interface class, subclass and protocol codes. -/// -/// !Codes -/// - HIDInterfaceDescriptor_CLASS -/// - HIDInterfaceDescriptor_SUBCLASS_NONE -/// - HIDInterfaceDescriptor_SUBCLASS_BOOT -/// - HIDInterfaceDescriptor_PROTOCOL_NONE -/// - HIDInterfaceDescriptor_PROTOCOL_KEYBOARD -/// - HIDInterfaceDescriptor_PROTOCOL_MOUSE - -/// HID interface class code. -#define HIDInterfaceDescriptor_CLASS 0x03 -/// Indicates the interface does not implement a particular subclass. -#define HIDInterfaceDescriptor_SUBCLASS_NONE 0x00 -/// Indicates the interface is compliant with the boot specification. -#define HIDInterfaceDescriptor_SUBCLASS_BOOT 0x01 -/// Indicates the interface does not implement a particular protocol. -#define HIDInterfaceDescriptor_PROTOCOL_NONE 0x00 -/// Indicates the interface supports the boot specification as a keyboard. -#define HIDInterfaceDescriptor_PROTOCOL_KEYBOARD 0x01 -/// Indicates the interface supports the boot specification as a mouse. -#define HIDInterfaceDescriptor_PROTOCOL_MOUSE 0x02 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDINTERFACEDESCRIPTOR_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDKeypad.c b/src/ersky9x/libraries/usb/common/hid/HIDKeypad.c deleted file mode 100644 index 19f533eeb..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDKeypad.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDKeypad implementation - - About: Purpose - Implementation of HID keypad usage page methods. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDKeypad.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Indicates if the given key code is associated with a modified key. -/// \param key Key code. -/// \return 1 if the key code represents a modifier key; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char HIDKeypad_IsModifierKey(unsigned char key) -{ - return ((key >= HIDKeypad_LEFTCONTROL) && (key <= HIDKeypad_RIGHTGUI)); -} - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDKeypad.h b/src/ersky9x/libraries/usb/common/hid/HIDKeypad.h deleted file mode 100644 index 06ad747ca..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDKeypad.h +++ /dev/null @@ -1,276 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - -!!!Purpose - - Definitions of constants and methods for the HID keypad usage page. - - !!!Usage - - -# Use the constants declared in this file when instanciating a - Report descriptor instance. - -# When implementing the functionality of an HID keyboard, use the - key codes defined here to indicate keys that are being pressed and - released. -*/ - -#ifndef HIDKEYPAD_H -#define HIDKEYPAD_H - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Keypad Page ID" -/// This page lists HID Keypad page ID. -/// -/// !ID -/// - HIDKeypad_PAGEID - -/// Identifier for the HID keypad usage page -#define HIDKeypad_PAGEID 0x07 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Alphabetic Keys" -/// ... -/// -/// !Keys -/// - HIDKeypad_A -/// - HIDKeypad_B -/// - HIDKeypad_C -/// - HIDKeypad_D -/// - HIDKeypad_E -/// - HIDKeypad_F -/// - HIDKeypad_G -/// - HIDKeypad_H -/// - HIDKeypad_I -/// - HIDKeypad_J -/// - HIDKeypad_K -/// - HIDKeypad_L -/// - HIDKeypad_M -/// - HIDKeypad_N -/// - HIDKeypad_O -/// - HIDKeypad_P -/// - HIDKeypad_Q -/// - HIDKeypad_R -/// - HIDKeypad_S -/// - HIDKeypad_T -/// - HIDKeypad_U -/// - HIDKeypad_V -/// - HIDKeypad_W -/// - HIDKeypad_X -/// - HIDKeypad_Y -/// - HIDKeypad_Z - -/// Key code for 'a' and 'A'. -#define HIDKeypad_A 4 -/// Key code for 'b' and 'B'. -#define HIDKeypad_B 5 -/// Key code for 'c' and 'C'. -#define HIDKeypad_C 6 -/// Key code for 'd' and 'D'. -#define HIDKeypad_D 7 -/// Key code for 'e' and 'E'. -#define HIDKeypad_E 8 -/// Key code for 'f' and 'F'. -#define HIDKeypad_F 9 -/// Key code for 'g' and 'G'. -#define HIDKeypad_G 10 -/// Key code for 'h' and 'H'. -#define HIDKeypad_H 11 -/// Key code for 'i' and 'I'. -#define HIDKeypad_I 12 -/// Key code for 'j' and 'J'. -#define HIDKeypad_J 13 -/// Key code for 'k' and 'K'. -#define HIDKeypad_K 14 -/// Key code for 'l' and 'L'. -#define HIDKeypad_L 15 -/// Key code for 'm' and 'M'. -#define HIDKeypad_M 16 -/// Key code for 'n' and 'N'. -#define HIDKeypad_N 17 -/// Key code for 'o' and 'O'. -#define HIDKeypad_O 18 -/// Key code for 'p' and 'P'. -#define HIDKeypad_P 19 -/// Key code for 'q' and 'Q'. -#define HIDKeypad_Q 20 -/// Key code for 'r' and 'R'. -#define HIDKeypad_R 21 -/// Key code for 's' and 'S'. -#define HIDKeypad_S 22 -/// Key code for 't' and 'T'. -#define HIDKeypad_T 23 -/// Key code for 'u' and 'U'. -#define HIDKeypad_U 24 -/// Key code for 'v' and 'V'. -#define HIDKeypad_V 25 -/// Key code for 'w' and 'W'. -#define HIDKeypad_W 26 -/// Key code for 'x' and 'X'. -#define HIDKeypad_X 27 -/// Key code for 'y' and 'Y'. -#define HIDKeypad_Y 28 -/// Key code for 'z' and 'Z'. -#define HIDKeypad_Z 29 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Numeric Keys" -/// ... -/// -/// !Keys -/// - HIDKeypad_1 -/// - HIDKeypad_2 -/// - HIDKeypad_3 -/// - HIDKeypad_4 -/// - HIDKeypad_5 -/// - HIDKeypad_6 -/// - HIDKeypad_7 -/// - HIDKeypad_8 -/// - HIDKeypad_9 -/// - HIDKeypad_0 - -/// Key code for '1' and '!'. -#define HIDKeypad_1 30 -/// Key code for '2' and '@'. -#define HIDKeypad_2 31 -/// Key code for '3' and '#'. -#define HIDKeypad_3 32 -/// Key code for '4' and '$'. -#define HIDKeypad_4 33 -/// Key code for '5' and '%'. -#define HIDKeypad_5 34 -/// Key code for '6' and '^'. -#define HIDKeypad_6 35 -/// Key code for '7' and '&'. -#define HIDKeypad_7 36 -/// Key code for '8' and '*'. -#define HIDKeypad_8 37 -/// Key code for '9' and '('. -#define HIDKeypad_9 38 -/// Key code for '0' and ')'. -#define HIDKeypad_0 39 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Special Keys" -/// ... -/// -/// !Keys -/// - HIDKeypad_ENTER -/// - HIDKeypad_ESCAPE -/// - HIDKeypad_BACKSPACE -/// - HIDKeypad_TAB -/// - HIDKeypad_SPACEBAR -/// - HIDKeypad_PRINTSCREEN -/// - HIDKeypad_SCROLLLOCK -/// - HIDKeypad_NUMLOCK - -/// Enter key code. -#define HIDKeypad_ENTER 40 -/// Escape key code. -#define HIDKeypad_ESCAPE 41 -/// Backspace key code. -#define HIDKeypad_BACKSPACE 42 -/// Tab key code. -#define HIDKeypad_TAB 43 -/// Spacebar key code. -#define HIDKeypad_SPACEBAR 44 -/// Printscreen key code. -#define HIDKeypad_PRINTSCREEN 70 -/// Scroll lock key code. -#define HIDKeypad_SCROLLLOCK 71 -/// Num lock key code. -#define HIDKeypad_NUMLOCK 83 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Modified Keys" -/// ... -/// -/// !Keys -/// - HIDKeypad_LEFTCONTROL -/// - HIDKeypad_LEFTSHIFT -/// - HIDKeypad_LEFTALT -/// - HIDKeypad_LEFTGUI -/// - HIDKeypad_RIGHTCONTROL -/// - HIDKeypad_RIGHTSHIFT -/// - HIDKeypad_RIGHTALT -/// - HIDKeypad_RIGHTGUI - -/// Key code for the left 'Control' key. -#define HIDKeypad_LEFTCONTROL 224 -/// Key code for the left 'Shift' key. -#define HIDKeypad_LEFTSHIFT 225 -/// Key code for the left 'Alt' key. -#define HIDKeypad_LEFTALT 226 -/// Key code for the left 'GUI' (e.g. Windows) key. -#define HIDKeypad_LEFTGUI 227 -/// Key code for the right 'Control' key. -#define HIDKeypad_RIGHTCONTROL 228 -/// Key code for the right 'Shift' key. -#define HIDKeypad_RIGHTSHIFT 229 -/// Key code for the right 'Alt' key. -#define HIDKeypad_RIGHTALT 230 -/// Key code for the right 'GUI' key. -#define HIDKeypad_RIGHTGUI 231 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Error Codes" -/// ... -/// -/// !Codes -/// - HIDKeypad_ERRORROLLOVER -/// - HIDKeypad_POSTFAIL -/// - HIDKeypad_ERRORUNDEFINED - -/// Indicates that too many keys have been pressed at the same time. -#define HIDKeypad_ERRORROLLOVER 1 -/// ? -#define HIDKeypad_POSTFAIL 2 -/// Indicates an undefined error. -#define HIDKeypad_ERRORUNDEFINED 3 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char HIDKeypad_IsModifierKey(unsigned char key); - -#endif //#ifndef HIDKEYPAD_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDLeds.h b/src/ersky9x/libraries/usb/common/hid/HIDLeds.h deleted file mode 100644 index 22ee54d25..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDLeds.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition for the HID LEDs usage page. - - !!!Usage - - Uses the constants defined in this header file when declaring a Report - descriptor which references the LEDs usage page. -*/ - -#ifndef HIDLEDS_H -#define HIDLEDS_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID LEDs Page ID" -/// This page lists the page ID of the HID LEDs usage page. -/// -/// !ID -/// - HIDLeds_PAGEID - -/// ID of the HID LEDs usage page. -#define HIDLeds_PAGEID 0x08 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID LEDs Usages" -/// This page lists the Usages of the HID LEDs. -/// -/// !Usages -/// - HIDLeds_NUMLOCK -/// - HIDLeds_CAPSLOCK -/// - HIDLeds_SCROLLLOCK - -/// Num lock LED usage. -#define HIDLeds_NUMLOCK 0x01 -/// Caps lock LED usage. -#define HIDLeds_CAPSLOCK 0x02 -/// Scroll lock LED usage. -#define HIDLeds_SCROLLLOCK 0x03 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDLEDS_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDReport.h b/src/ersky9x/libraries/usb/common/hid/HIDReport.h deleted file mode 100644 index ec02dedcb..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDReport.h +++ /dev/null @@ -1,231 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions used when declaring an HID report descriptor. - - !!!Usage - - Use the definitions provided here when declaring a report descriptor, - which shall be an unsigned char array. -*/ - -#ifndef HIDREPORT_H -#define HIDREPORT_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Main Item Tags" -/// This page lists the Main Item Tags defined for HID %device. -/// ( HID Spec. 6.2.2 ) -/// -/// !Tags -/// - HIDReport_INPUT -/// - HIDReport_OUPUT -/// - HIDReport_FEATURE -/// - HIDReport_COLLECTION -/// - HIDReport_ENDCOLLECTION - -/// Input item. -#define HIDReport_INPUT 0x80 -/// Output item. -#define HIDReport_OUTPUT 0x90 -/// Feature item. -#define HIDReport_FEATURE 0xB0 -/// Collection item. -#define HIDReport_COLLECTION 0xA0 -/// End of collection item. -#define HIDReport_ENDCOLLECTION 0xC0 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Items for Data Fields" -/// This page lists defintions for HID Input, Output and Feature items that -/// are used to create the data fields within a report. -/// ( HID Spec. 6.2.2.5 ) -/// -/// !Items -/// - HIDReport_CONSTANT -/// - HIDReport_VARIABLE -/// - HIDReport_RELATIVE -/// - HIDReport_WRAP -/// - HIDReport_NONLINEAR -/// - HIDReport_NOPREFERRED -/// - HIDReport_NULLSTATE -/// - HIDReport_VOLATILE -/// - HIDReport_BUFFEREDBYTES - -/// The report value is constant (vs. variable). -#define HIDReport_CONSTANT (1 << 0) -/// Data reported is a variable (vs. array). -#define HIDReport_VARIABLE (1 << 1) -/// Data is relative (vs. absolute). -#define HIDReport_RELATIVE (1 << 2) -/// Value rolls over when it reach a maximum/minimum. -#define HIDReport_WRAP (1 << 3) -/// Indicates that the data reported has been processed and is no longuer -/// linear with the original measurements. -#define HIDReport_NONLINEAR (1 << 4) -/// Device has no preferred state to which it automatically returns. -#define HIDReport_NOPREFERRED (1 << 5) -/// Device has a null state, in which it does not report meaningful -/// information. -#define HIDReport_NULLSTATE (1 << 6) -/// Indicates data can change without the host intervention. -#define HIDReport_VOLATILE (1 << 7) -/// Indicates the device produces a fixed-length stream of bytes. -#define HIDReport_BUFFEREDBYTES (1 << 8) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Collection Items" -/// This page lists definitions for HID Collection Items. -/// ( HID Spec. 6.2.2.6 ) -/// -/// !Items -/// - HIDReport_COLLECTION_PHYSICAL -/// - HIDReport_COLLECTION_APPLICATION -/// - HIDReport_COLLECTION_LOGICAL -/// - HIDReport_COLLECTION_REPORT -/// - HIDReport_COLLECTION_NAMEDARRAY -/// - HIDReport_COLLECTION_USAGESWITCH -/// - HIDReport_COLLECTION_USAGEMODIFIER - -/// Physical collection. -#define HIDReport_COLLECTION_PHYSICAL 0x00 -/// Application collection. -#define HIDReport_COLLECTION_APPLICATION 0x01 -/// Logical collection. -#define HIDReport_COLLECTION_LOGICAL 0x02 -/// Report collection. -#define HIDReport_COLLECTION_REPORT 0x03 -/// Named array collection. -#define HIDReport_COLLECTION_NAMEDARRAY 0x04 -/// Usage switch collection. -#define HIDReport_COLLECTION_USAGESWITCH 0x05 -/// Usage modifier collection -#define HIDReport_COLLECTION_USAGEMODIFIER 0x06 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Global Items" -/// This page lists HID Global Items. -/// ( HID Spec. 6.2.2.7 ) -/// -/// !Items -/// - HIDReport_GLOBAL_USAGEPAGE -/// - HIDReport_GLOBAL_LOGICALMINIMUM -/// - HIDReport_GLOBAL_LOGICALMAXIMUM -/// - HIDReport_GLOBAL_PHYSICALMINIMUM -/// - HIDReport_GLOBAL_PHYSICALMAXIMUM -/// - HIDReport_GLOBAL_UNITEXPONENT -/// - HIDReport_GLOBAL_UNIT -/// - HIDReport_GLOBAL_REPORTSIZE -/// - HIDReport_GLOBAL_REPORTID -/// - HIDReport_GLOBAL_REPORTCOUNT -/// - HIDReport_GLOBAL_PUSH -/// - HIDReport_GLOBAL_POP - -/// Current usage page. -#define HIDReport_GLOBAL_USAGEPAGE 0x04 -/// Minimum value that a variable or array item will report. -#define HIDReport_GLOBAL_LOGICALMINIMUM 0x14 -/// Maximum value that a variable or array item will report. -#define HIDReport_GLOBAL_LOGICALMAXIMUM 0x24 -/// Minimum value for the physical extent of a variable item. -#define HIDReport_GLOBAL_PHYSICALMINIMUM 0x34 -/// Maximum value for the physical extent of a variable item. -#define HIDReport_GLOBAL_PHYSICALMAXIMUM 0x44 -/// Value of the unit exponent in base 10. -#define HIDReport_GLOBAL_UNITEXPONENT 0x54 -/// Unit values. -#define HIDReport_GLOBAL_UNIT 0x64 -/// Size of the report fields in bits. -#define HIDReport_GLOBAL_REPORTSIZE 0x74 -/// Specifies the report ID. -#define HIDReport_GLOBAL_REPORTID 0x84 -/// Number of data fields for an item. -#define HIDReport_GLOBAL_REPORTCOUNT 0x94 -/// Places a copy of the global item state table on the stack. -#define HIDReport_GLOBAL_PUSH 0xA4 -/// Replaces the item state table with the top structure from the stack. -#define HIDReport_GLOBAL_POP 0xB4 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Local Items" -/// This page lists definitions for HID Local Items. -/// -/// !Items -/// - HIDReport_LOCAL_USAGE -/// - HIDReport_LOCAL_USAGEMINIMUM -/// - HIDReport_LOCAL_USAGEMAXIMUM -/// - HIDReport_LOCAL_DESIGNATORINDEX -/// - HIDReport_LOCAL_DESIGNATORMINIMUM -/// - HIDReport_LOCAL_DESIGNATORMAXIMUM -/// - HIDReport_LOCAL_STRINGINDEX -/// - HIDReport_LOCAL_STRINGMINIMUM -/// - HIDReport_LOCAL_STRINGMAXIMUM -/// - HIDReport_LOCAL_DELIMITER - -/// Suggested usage for an item or collection. -#define HIDReport_LOCAL_USAGE 0x08 -/// Defines the starting usage associated with an array or bitmap. -#define HIDReport_LOCAL_USAGEMINIMUM 0x18 -/// Defines the ending usage associated with an array or bitmap. -#define HIDReport_LOCAL_USAGEMAXIMUM 0x28 -/// Determines the body part used for a control. -#define HIDReport_LOCAL_DESIGNATORINDEX 0x38 -/// Defines the index of the starting designator associated with an array or -/// bitmap. -#define HIDReport_LOCAL_DESIGNATORMINIMUM 0x48 -/// Defines the index of the ending designator associated with an array or -/// bitmap. -#define HIDReport_LOCAL_DESIGNATORMAXIMUM 0x58 -/// String index for a string descriptor. -#define HIDReport_LOCAL_STRINGINDEX 0x78 -/// Specifies the first string index when assigning a group of sequential -/// strings to controls in an array or bitmap. -#define HIDReport_LOCAL_STRINGMINIMUM 0x88 -/// Specifies the last string index when assigning a group of sequential -/// strings to controls in an array or bitmap. -#define HIDReport_LOCAL_STRINGMAXIMUM 0x98 -/// Defines the beginning or end of a set of local items. -#define HIDReport_LOCAL_DELIMITER 0xA8 -//------------------------------------------------------------------------------ - -#endif //#ifndef HIDREPORT_H - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.c b/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.c deleted file mode 100644 index 3e9d2e804..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDReportRequest implementation - - About: Purpose - Implementation of the HIDReportRequest methods. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDReportRequest.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Indicates the type of report targetted by a SET_REPORT or GET_REPORT -/// request. -/// \param request Pointer to a USBGenericRequest instance. -/// \return Requested report type (see "HID Report Types"). -//------------------------------------------------------------------------------ -unsigned char HIDReportRequest_GetReportType(const USBGenericRequest *request) -{ - return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF); -} - -//------------------------------------------------------------------------------ -/// Indicates the ID of the report targetted by a SET_REPORT or GET_REPORT -/// request. This value should be 0 if report IDs are not used. -/// \param request Pointer to a USBGenericRequest instance. -/// \return Requested report ID. -//------------------------------------------------------------------------------ -unsigned char HIDReportRequest_GetReportId(const USBGenericRequest *request) -{ - return (USBGenericRequest_GetValue(request) & 0xFF); -} - diff --git a/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.h b/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.h deleted file mode 100644 index 75ea3793b..000000000 --- a/src/ersky9x/libraries/usb/common/hid/HIDReportRequest.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for manipulating HID-specific GET_REPORT and - SET_REPORT requests. - - !!!Usage - - -# Receive a GET_REPORT or SET_REPORT request from the host. - -# Retrieve the report type using HIDReportRequest_GetReportType. - -# Retrieve the report ID using HIDReportRequest_GetReportId. -*/ - -#ifndef HIDREPORTREQUEST_H -#define HIDREPORTREQUEST_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Report Types" -/// This page lists the types for USB HID Reports. -/// -/// !Types -/// - HIDReportRequest_INPUT -/// - HIDReportRequest_OUTPUT -/// - HIDReportRequest_FEATURE - -/// Input report. -#define HIDReportRequest_INPUT 1 -/// Output report. -#define HIDReportRequest_OUTPUT 2 -/// Feature report. -#define HIDReportRequest_FEATURE 3 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char HIDReportRequest_GetReportType( - const USBGenericRequest *request); - -extern unsigned char HIDReportRequest_GetReportId( - const USBGenericRequest *request); - -#endif //#ifndef HIDREPORTREQUEST_H - diff --git a/src/ersky9x/libraries/usb/common/hid/hid.dir b/src/ersky9x/libraries/usb/common/hid/hid.dir deleted file mode 100644 index d46589b56..000000000 --- a/src/ersky9x/libraries/usb/common/hid/hid.dir +++ /dev/null @@ -1,39 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !Purpose -/// -/// This directory contains structures and definitions related to the USB HID -/// specification. They can be divided into two groups: -/// - HID-specific descriptors, prefixed with HID and suffixed with Descriptor. -/// - HID-specific requests, prefixed with HID and suffixed with Request. -//------------------------------------------------------------------------------ - diff --git a/src/ersky9x/libraries/usb/device/USBDCallbackInvocationFlowchart.png b/src/ersky9x/libraries/usb/device/USBDCallbackInvocationFlowchart.png deleted file mode 100644 index af8028e16a1e8fb8e10b4984637cb78b5fa63a90..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11380 zcmeHtXHZjXzc0NvC4^q3Cm_ z@kj$^W+Pl^Vz1goMe6m7r03lI^1P%;J)9~%k59TG)Kqb?ME(GAC0V>i$)bVyF4-gN zRe>UOv(vX!89J(CR4uPhBAOgc&Ye1>d|#E)c(XM0+C`VgCP3z^Di!Evv#|_Tm65Cj zs>T76CG$3Re;A1pGcFCCsu#RoiroC^4M`G%{*KUlpiEq|ea(;J=b!ZfHinS}$rc%V z5qb>74DOj^jdU*NBEreNOSlYHAcTh3ozo8gf3GMMI4KeWsEWe`AEe#$4(1y z$6d=%RkwSQjf}aCLEo{&^0bgRRJ!cnFY6kLyJPlZCr_i~1N0*;N8du~Pgf^K+ zBWTrZ1k+F!1hZXL}Gn1JEGNcM0EUoTP z3iq@L?%H4pa>by#^!eyp0w!kU>zDId80&$sz{Ry2($T9ls+kT_hUp=qBR z{EXM1U2tGGUG^cW@tOj`;MuZ<_J0EnNF&-RDTwJz`M0aW#6Ddh^WOdFZ|;sh2kU#> zDyqj}6nt^LL_C85`T35w=D5n~OEKdE9`EI9VRhS1%r=Vja@`iVTV42cvc#KtzlibJ z9!g#$qks^UjpE#5~!Wf(0J+9t}627&t z_Nq+m6=#1w?GM2>=e`qf8F0q)jdW~Zs!e(Vu6t_p^hlC1<3!VT^dh=YW)S;$!|nM&FQ1N+gz}u1O|!WTn`Srl zXCO|wED}p>51UPKPq>v=wA=!Qo*KV~Vc!yX69f)sht5I)Df8~e&m9V+ds@_V90-kD zN$6-?*Q)|ba4(GL!@pJDVF}>*orHFX=qeu6lK_IMSY_p2#(o$vg^%pIl9l4I&**0e z3{7`kV;Q|Y)iEBU0Y8<`O836Cg>ND7QB8Nv;q@u__o`O+m92U*(W|37MaWQu-Ae&S zdu4Q4ze*7JJ`QqaNVn|?nz!P-r?`kbxlO0c>6+e0)KWeR^0tvteJ*LkuZq6&ZeEX?f58RQTOQUY_WC_U!$V--?{q0-7o2=`5%EAu@cUICVJ&TTzlm@k4s{ zol%X$2uP~tV*%r*L0LC_?_Y`RlOV3&!?h;zqOKCsk$`m zQ7w;jGpZyY6F>-~KgwoVrieMjhQxK+B59rU%;wJGW|V-t07AgJul0qH7<5V?)%;g zB+2h)itB`(kg+2X(b|0+8H24FuT8uxfED_P$%>#VS3B>=Md5eA~>0774mxQyc8R3c_8uB zJYM}`6E78$5uo@bd#JTt$fix%QKU(rY?}qVo!5Tbgxla6rKXK_fQ6DJ^=x|nVD`}0 zDu>%kVXTPg8BbY%B@ecpCo8m9qeC41H5xk3i+^z-WLj`jXD z_TJu`iX|Dymx+ugJHULt9}+sJPsQMTTuFIO+-MK)!(Ze&->t2^0z!Se`np-(kM~!@ zXnkI9F$ zy=+ka<2W(F^|EWHP0cr}Et9)!jC780n3(x6Qr!Mj2oUWX1rcAIY#Aa%%9(gds`M1_ z2lt#ITDI74idV|kGlM%vL9S0A(RW(WTFqOSXD*ib;2UDlmt)VZ^bLA#dM7$0Wn^Zg8EX zjZFKU=KPCqx_NZqk_@TuCujNv=73v(hbCNda<+7TnB@{8C6c1NS$r$|T zfY|#J6brtL<`x#X8$VupU8ir11;0{8c^FCd26#b0&OYCFn79h=7!OS~5V@H4cT$ET zHOk?9#Focuj1%*#R0TRZfYI6CP6031>+c(Emt5*~=0z0v>A4)p6vjpHlB0vLok!NR z=6ZjiZ7&iXI!8rSFQa0k?}1~KMCVY4Dyy`e zpNc35bTl(n!N6?tp@!w_!DLQ_{tBst%2!SlsL}~_@OVM=%Md}SB31Cn~};qY9dTZ!X%jn8(+!s%>IX=tFjo6(rGsU zb*|C1H)UG1DIoBpRwjQ<2L$`|vf46tzcjm=J;wCW$D&d0{@1C~PvZ%_xES$KrQ#X` zOJPQ$H1j5-7Qu29Vqd`CUwBI-QF(IDi@Yr)x~3X=v>gW`ZbFv0lOZ6jCf|=?wF3wd z(v5kQNQ;gwzueuGcTIR5AlR&!t!gO+{bv<2qhW2+kQJ%a0z3*J$X0*5xj%fpPc?bz z1@E%$693xk*guCs9DBBU#`y!z(XZZio=#xMibz;{{(i`hPg9Ci4YJ{Brr%F?FV4bn zRH8gVKsb8~Po{U#puJ#0oElQvrMo+U(l0w^gmux|Uz?FxLIBx7DDBlsgpte26~!8a z=i%34<~td?o)wAk%`%;^m!2Z7Mn`_fiik9H*$#$Yz zo~d1CV{ABmuGHr>B_Y0A>wTBKTqm+?oR;r{NBMf2n|=lv`!u+Xb4zzIX~HrZpEjq~+OP683uePIyYPZrHO#nEhP3-LuD)El_XMWTYw zUbLz!{iX#$xyKcfd7;*ZS|A5NGMU$T)@c<2+dvkytK zg;WV-R$9f;-$#v8T18w9(kVqsbX9av6?K6tzZ5Rx((!_fgM+AUm>LPq(PH$b1LUsV z^7<|xCU_5m(f?379rKcfDB^i2vrvA58t-epLT0DVdCcGX@f(yiH=qGbz?+~AddmkR z-d|$=2%s1(7nh^G3<-%?MmlE2D(K!Bv&F7tI?F1R1G{F0E-I>3ju^Td-m&eUF7L81 zHQF8ko7anx6XdMx(607d1v__~uWyh?KfZ@tM+b`|-t}kXp-JyU?maKiFC;Rwj@$0L z=hPZ$C!rpK6050tHgel zk9>HDT+{nPk~AEzaIelnp~)jv3}hG!A2||C)>p5g3adGj`W)ht#6Ch6hLKyE93KW0 z3kc_7O7fm(Z1}VVfd_7n)Z7YZ*%`P1_YMxH0ET<2ux1up&+WtVy6z_Yk(n^~#ayUL z9YG0JtP2x&Eev#USl8%%g&9B?349msMJO9G6XeDF#u5dpnO60f#v|1^T?FOgn|Jym zjUVUO&iazmFBmlVbvH?Y*gzx7vr&MCRQYU(&4e+|1imAfqNU zg;GOuou z(zz~wMIJ~M4aS;@SQ+n>r2`@X@(JjXddkqep!+(}2|`c*Cv?K~vuV8SPQ#aKY@Awe zE$`MjrniRZ1Fzi`%zHf>lYjKKA0WE#*T1q#I0gSn@i4hrW8G7MQxkJIrm}n%`eyXR zzJk{98S2+O@CSfRB3)04<=n;Tu z6j?$Yl9m^=ZASa@!&wb_nZ7QBH|VZ~mmy7TVY7PU`Y(#rfZH?%lXooSKXdyc8c+PD z4o`B_?^~>MiF$`#jj(6p7(zk z+5b7!OV0k)=T!A#TGdBxhu{T<}SKP)FEw9Ip?df7!0bgwC6n5w1`?U0hz1V-f%Oo zHPs*?IB!oq^%T~9S^gU*7%Lcfl^_#P>6b#5cFupk>Z-ADA|48j8GHJfMaxIu9G9CZ zi^v_tc6A+WN?g7~#>vJ5DuoThd;{8lhk$K}|vZR;>Nm5c# zH1icb!JY132Phg8!emnmy6MEvW=CH80|6#C zU4QLtRiXUvs;L^?@^r-haEzn#{0Q^!rU&{)Esqbc@KqEL@XrvU421g8fqN!(CQX7@5Ij4ue@r3U zT0B@0E3_~~vq={+IE38PbL30nZIl((%xK1n{ZUuOuw# zQ^n-NDmbwPKi`DMn#~9BJ~M*=E1euRD(DuZ?k(!m14p5_(9`PEsMDlh20fu8pAion zKB13NhreNvqq4*_x6u!x0Zsb#?UFaUqfIFfXoR|_uP?Wk*G4X8?FJV|8dxwI$*ClH zz&iA2!r4DSVmc`*`Zz$Lunw(B9W3IjVnWV$>;0t^7F@2yQYW&r;Ost)x<4#^PA;QZ z6b>o{ilrc87c~vX2w826>vW|Nc?yF}iSpU}7dlk0cNtc-Qs_^2&^yw4Bg2Et(-=PO z7b}c*ARtu~Z`~03ba&Z&QL$6rijp?WkSZ>WHFdi*8fC2wn7A&s-v7V6fsxji({S{~}VgCwf3GX-MU@muDfWKWe=ifF*`Vxa*^;NzLSLuGi~JXz@c$4Xlq8L> zN*Y)yx}JVYXWNQnZV&8qT*9=L)wDNmX32lPK`&*N&rPf(`+}7D!Ls0UBy^$|EV%~$ zvJ}O9Rl)>3#gmmQF7c%x{$H7eJ{*xG(FawYC6|=LgwhO5K#NL17g9#~V(jxHqSy#U z3G(SbB7yF!{ATE*5y*om&`jt9MmeK-lF*ZEkpEUx>T;V3Y6x$Eo5};jLx%t%=d#hu zCb`O!NnLxC6qMVE$5++EC*n6LbSMWa(R&k}bpZ|$a-|gHAW(eTWw_p278KVF>V>R5 zv^99UQOhW1hR3#Vb<#86sJl{hrQ1`2x`p$CklN|lObp;k?^g_j2H`?qp zP-3<5fwn%3W|=w>{SL+vbbnODjisy?b5*Fk&d1;AVR@CXZAP?(4SN+$QlDN40?yk$ zEoeZ=wwi5MrIcxJvf2}dA&n<{=vw*DL?0HpiSuu`Y}X-gPW$Wgt0Z+pzBcmcC zcub%1NgDHpT*hImof(%~#bL@MC$34~AYAx-S;`nL*XI)^pdj+~boGbdmbe7`A8j!& z_#((V!_EqMP%W4K6p0HLu`Ra) zpA)S$U^D&M6eVbjz^i|3K36cb-y$9oUwXeDKsi<;J=yOWbKWi6jDCw2cglgx9<$qF zDQ1XxHpZhdjoP*e9l&JHY{^H9fLHd7@}sF*PThtPU<(DCW)I6F+JADPk?OlRXOB>psw(;`#`~QJTS#d*UJdkSaD7 z2Fvc+{Xq2(6X3l)x4YYEEySwY=s^dF(=2v#hyV9@(hib4i*)w6qda0u=jcEn@%4VQ z&bb6+I2lQ_%tM8`OOey-^3Ytp3n`v=VG_pvU%?rEJf%myU~;-3+YYdtMf z>%7~c0W4mY6j&G_;LcI~EwC-oSxmv#nN9KH`x`3gbNFI2TbN1Ns>syHL*#`!&K|6t zCZ0m(IM_p|X^r&hRoj_YwGX)IAgc`5^?NAv{!1uP8o~z(599Ty?<&}%7q|HPciR1z zqV~V**iJjMTx|kTq~7_lsnM?jPXj=@OBK`&Rr(st#1+D1@e8l!hZho%?wXP$hpvay zQYWFrQ!;j5P$+Qez;k2nmZjwE*NP3ZF$VFe6eT&;9@{+caNH{^H;({*ec2yjR@N=) z@n4ci)|Us@J&|R2&>Sw0K?XS{Wh3lW!4!hG5wFDa>v;SmTP?uHC0Ct}?Hs)PC~Z@# z!AJNgU0hxu&A$EAMVR4hN>Y`QBG^=DN%7U$ng&6tSkmy?kvsIMX7g#_xhcV5mE00{ z>J&=Yg#1X;ivK#Im|btK9xyG`pDT!EP4tib;S--i@JRNQp9m@`L zT701_3VhlLY>Hq7i~?Vvh@W){5?oO@Oc@q(Z_cA#*}`cn#D057aCjZR-G}J_G~lOv?I~Ksc_d@PCU=9QLc>1mq61g z2xLERn>J@Om=FJ2_=9{JJ`3aH!07)b^S61r2)t1tQ^sCSdqnm$sLnGqa)E#GeHhuZ zpxdU2A@S=R51bk!?lg0V$o*Y7fmyfP7=Ck?Vcl~Kg!|SLxKGljBZ?HBbWmVR6j!*b zE-nN5_g&-ELwp%}6_y=W5@FG+vWe;ek=#5NR3Ox3}1K8=UA& z3jV&Ke%m!GgcGZo#d3UK3d*gItKbE|`e-#+*Ge2L^t{on&w1Olsa}@{xiEdO2)xE?tCT%I3H@UT(*p`}p zmeTOf(cWcoljW@>Cl!_(IylK;e~2H$YPfbC=ln`6Uv*a$=A&lQk;QJ>*jLvtE#a3A zPDKQifOX6_(sGk(0E3(3^shH>2E&M3zvy(?flrz$7Unp0A%gl^n*@qjkcH)V{L)X9 z6d-wEgY2(E6{@*au!piv37s@Gj<_f2;KBgk&qI-l-=1EUj&veP>_+_#m*u`Ld1EpK zH6AZ)^U7`d=?gHIZAczp6u$DRVB~ph68f-qm!FSVNvRKaZ@2)uDs>kEUdfj}1!cVv ze5}3kGDk|Ne=1>OwbOcE@ zFxIr~(qGgH!#0K7XFhr_SOc3!D=hk&m-oE|grQD)-nPa6YDLzlD%Je@f1tD{_-zcU zq#D9zi{raJl7=)^gEjvgBo^_p_SbYnMD^o?Magkj*+UUNI*eGj-La^%V#Jf=0}-VS;R*CtulOtV9VYfdCfobLMw&Nkc+Z+|K!Ku_V9ea2mxA^~|Bcd#PfL)l%s z(#;LKrm^}6+qqvcjPCD|^;j#fJ3T*AUiI~DTVwf#n4gI<7X@ZKivqag@WTU~4`4Z& z1#l{G7gi#kM#z$uha%Um7E5QhIOfnrY6H?0nl8R!jz0%JuOg2ub5@HIo%Z|fe?7HI zCF=k zRbZ`$h;6qYKrOcaMM2;{#>p*JF-p8#Xv*Ccf9O8)O#K;Bq2D!{PmY6Q`A0S=Pi5zAMk0hbDZ|i-g?VO#X6lD-Y z_4a42S*=zfG$uhJmSXeeUojXU3SI&x^HGDu%jvcszD*F~j-O}9$iO3}rLuVs24&@6&++?=%%orLA4@xq&dV z@*c3kNlLPd^JbAU#Z9E4EWxkyGX*Aq`{2Zj^iIli<4P>YqGu-aeF~wOm%8woj0fdG zUY2hmmbjy7k?e1-Sn?&arKd2dSAr@pYm!@5rv##uStNm?_-lr&z+5WFmD?wMc`_<4 zQH9o#fUi+snkz3(MZU=bgLXv7X~w4CE|dkyLHrfMxARI^+LCG-j$SxSA%6X~{o(8V*Zu(A=1Dyyp$Td>GATYIE;}$Nq$&;KviJrz_hW^Hw)u!V*sGI# z1k-c0YUViM$twGdLaE{4<9kvVC0MHxqj0to#8-=jxJ6md_3O8%A_9BtUXm%Bx(q7F;JaXt}SoXOmW~GPQEBIYzBc;-JelEgo3n))k^kw zl_k!k=K>z32=I({484bt&Q+Yu#DtpTbU;1^O%cYryZ_LT15`ng3{pGxVLiq&f zcfdwa;>7xZG!yD!S*LDqme&r}(@e5pX=|7B8T3zJ3E#UPJ-GO2(D(4m#ePx4iP?y^ ziy13ns z@p1S5%ipD=Tpsn5Aa{!171AL5AlSy9y~lmmKsmdvB3sbZH@wug`;z-$~NHTl$K-5OoTpf2$h|L>K-djXH_Y*{fvMFaJ!2fGe(r)@|_V zt{|2N{n1z80LY2H8V8F~@h&GBaQs6!?&pdd6qHJ_5EcjA@m~WWiEGw^fKk{_;;pA? z3a%v`VTE?y<6j}ZJ~#hi4cmIgVK4@{`(*?SK5dEeG2r&-Bh;^H!+>e~N%@wZSB-Zq zO`A1Mq4~xIfijUv=+Vya;IIdVu=Vue319TC7-tU7(%1}G;GkNNnmVaQWeHNtP_4y} zpifBHkY_S-wIwiFzoo$|n?tZ3mArkWTz~3edWl)}dxsrN;jXY0=tY{P-dSZUp}}3w za$-S7-a<3#hW0L=qzA7(p#EMLQNKbVz9J)M+qbhX$$;d*2~LYtX-n}n+THf^bcr4O zbSGMu(ibXdCcxK$&{prB=v*KNDdDf;5j74D8th@tb5s3|{NP2S_&g!7I8ThszxKq* mpq5VXObV8>NC)C(~^*oFc=!>n3Ir@5=cnM z(r%I8^z2P?d6AHilRSFxSoiw+`s>%PH=Q?)|11CJf&bq;V59-qzPbH0eg-xHBqU7F z{>1viz$yYq4&3sSEHCkMF45X%)duK>fqs_?WXz<>7B7yhr$9Ha& z74(poFP<@kdI7hY>!11VKpA4 zS$tviW)ZGD@h=94p!Axv8$!NM08G`t`vAn!%a)tnsnJg7bkuyyGLgvZqbHGnA0naC z2Q=ZQzS+2Brtf06U4?^fW`KbZm`Vme=>aS;r6azw#Z^s0)r$axoe#)|RqP4u_Le_uVx(9d1>^A=UfGdFujlI7y8chwGLH8lQS0!hDhd7q7cO8T>CFL^`-~I_( zs)F)YsIs3TklWR!+Tj4auG)5#It{@*M?tQH4552i^zQw`DD;~$#Lv@Ao(OKQf_fp} z-L?+ZZhw5kp0q+|8oH?P*;Zwy#m9M9A1+8*zRgxbrbV8Os}BdHDA#PuEi>SE>$fFI z7{9G(9*^$W;1K9fJlgoaL2GhhMwZqV9il1!>2nr{m{{nD3~0OJc{&lg+^Iyur872) zD>6<))yuw?$|u^#WXNpM5#Om`J%9p_x9{0#%W7lU{=|pb zH^hEGX4C~D0R;bc#tEo;6!+%`lu@SN;xN?`=j*hbsv{`}Y`_T_qHhteCJnDvjP_Pj z1YGqqhJESI8CN;`Als1~OSu3-rcsHdjhKDgM1mR|;0^q4#6h_5n2cAGGQk;-y#?cK zB%qFLXE(AUjt(3zb0cdxM(hWec#auT6H;=)c!-Cl<4N#wyqXv#PKtc&I~L$iiSr`w zL%LIBpjDRX5PCmxJYPmlaGd^rcyEn_0dIP0G>o>#9^>F#OwH2*rGwvd0e7^U$hm7qEYG(&fZMNm ztb3F%J6^9_;$65F>#T*65_mo9+_{X8a=2(Y>~;id+V7#$58JYIwfBUgR{%C@;^MXIvOJtkS*zY!T>> zFZsTGes*@)^GfzySN(|g6!ci3bz81)g|$G!FKAd98l)scbi5*7_ByI}f=aO5rM9%} z!siYe|D-?tq5GGU9e5i2=V*oEwTy+fqo|IjF1J}r4i01a zUeC^7b7&OnCS(dMo`Q$tGfNP^+xQOC71c4X;7;=nA#593#jw-FCF6e=W0lh~Er)9l zP6+yFAAyMC`IgTqWzHX-aNOhB+eF`JnGsLHa4_L0Wbn-8`-%Qse!aNl*EqFwR02}OZpO_56msq#deUQO7q3mjVC_%ZuI@ZO@6Mb!53|nLaPSXl!=Repc`YLMY zJ9V5UN@Z>kex3aN+va`MFTWV0$F{&NX~R0h;{F|aPJNCIyIFT(xV@+f1f1P^X{-J4 zV}$w{zu^31#2sL)ib}zZ^!6N9C~+KmCF@p*P=$@$w;!qI#P z!Oy*B0VU&lD}ceg$mPNg!U zgP2GkrD}T$^bP*9#~GF-fMR~Fco@k)L+8GTUhGKfx0*??`|3=@7Y78_>QTUa^qQ_P68RRMtA#J!ru#3!S0%Sj({zTftLHE_ zoIo!W6nwCX>!QM7y+K{O_Zm^}74)@ae~fB$=`H1h#_gIeLB5(A_0~=iM$@;@kWV0Y ztDXG?MK=-`6Au8s!dW*R;mODhfxjy!W1_hW=ETEDc^&R7zRVhc9(He&b4{*(3c6fdNt3^4b@vuY*ME%GA;&9^ z?~?_P;6E8TB<#3TwgCuP09a6TVTcFwXToPwp8d^rv+14&S$s7E&Vvm$C~+y(O57lO z`T_Mv;(^{DsvhLFFeEJym!m+^bz0bWr;MAKHnrDYJ-t@hHWs(pmgKqKn^{LcGyK90 ztU_G@h86Yr7j+ivy2`Z}8$%SMw< zbcke?`)rlpx2DLu#((>XYxlKC^gcrCrsn-0*sz77RLPT;>a$hd-e_2Ucy3~}*oM z<|KSC8ABa@xgvyD`mPRGlk-KV4$%?>-mY?#I`(N~Uk4MHmc64LeW*T);Kw6^Zz6rs zb-v!@3NoI$9(WOqsA&SiN=1iRTMdNWM zTLeF1XPlT(27m&Zl43TyAhm1Eyyw z-Fsj*JxmQ0nDBhk1_Ym?I9OOIp)%Dd0KT1h`!L5X_bn3snoRQ(>4ST^E%7m7vg?9+d!V^5S#x{| z!G&Fg@;d_GAwgOD*FH4UwJzb0ueo*g8Cf$*=0@*qJ1M}F9~uWIq5;JEq!$>DlW} zx$tUvv={el1&BYBo7gwrZgtY}MD4us zfuKAqRaB=GaKOnpFCDVhQ*b5ghkYV{n|ID-lf&x+?_ za2bX0EQnLzZ8WN_x&+$hmXl{^rT@WxVbUua|2Wp0bQ%QD-1PhQBm0*_IjU#h62HXj z13t5@4Iy43@Tvc8x8pX7yFcAP_! zP``_GSF2F9^tE{uh;tz9w>2ws-tbn9zGJ5Ysg?dkmdg)P1ay^}sp1oWIXl5!TP-^K zkrV#Xa{7#)8)g&lZ}qU8G%F-dEqwaPWZX$=m7Jn~ire%}Jwal1`=2 z9$mmm=aG@2D1!x%;J@77xkN<>@)oo1m;ljd0|kCAzN<|AWT&TY&fxFL?KEbv&FkPHTx8bm~a`m#!ab;-T+Ds-@ z=3PfRxz;FNxq1}RJJnDE7DvZ-_29Y55J=!~Dwu8^+94xK*?Yln9e1@)Gg8NtelX1yv z9so7iQsLF~qRPwAPGMN^B6GQ%!3{=v`Yd)+6wZCN`1kM*Pqa6+UL&;m#YTb*UidT1 z!(6Hq-g{Zf75kWDP)b;JS8fZfL0W0CW@r~c22XE($5g}esq_+Gp&#x%=~vGFo9Xe~ zhlv+7`BaXUMhonEjpJ`wbk{n}XF00{31(-nhC2#AFX;4Md=@$hH1^2HI37Qr@|4pQ zPF1`i^tsvpttBVYQ)tN+P3or1fCQSONrX5of1EzH=w<=wnco6pn_rv2R9_TD(+bY+ z7(6i9_&sqyGJKkZyJXH4zLA!VYM3!6{vCa;1~W@8wzBX)-TG1JjgR{cb&{(YA0Fa> z@kL}Mzk&q+} zX}$#ei@dstY=cAPzgc>X?vtZQ-!gR+j{#Jai{daPjWYI~w5;*)u6wXv3|5dMgTsZK z)>mfq1qF=gmn?)@@%P(ZPWpx!2C)kMj(u*2HzJa+5Xh4Uks`HiU1cza#&_6PswO05I2lLXAzOE+`p zv`fh=u_Ytlij3hibOggn<65C|wN!)E1M>!xINpv0Ad9ZLbFNf~$Y@;s{xAoj9zb}O zo$l!m6tLQf0`#|EvA%qo^jZ)#9>4TBmtvtEdLh<@=|jd2E%hxi!fLEI2zM+QU(WEu zt_-+_enmE3EJ~ly<#linzT_u*03QxNb>7x{{`xO;xwm`Gghyvg?V1&jiwzE|Y(8K$=bf%Cg z>b6&%MlSHprEq2i9hbqnwYNmI9I4uZ2gIckBv^$`*ZB+ibFvQ!frq0Ef=%;g*k-G- z6u!^Aw;{X1mp1>7?#@(JwbhR8y~IUhf0YKBo_Mk9{!8@jhS!q|$1Od3;Y_{G(q%{K zmjC3v$U8Vd1_I64gV77!^UA=Y5f1jL8H_uRU|9i8B6!1!eo~ZmxB14z$v#? zCn<#SWCz1WqAcesmZQmzM1xM4$>C9hY5@GfQHt0J3RiemQtgBLafp?U5QAK-d<Yjp8uFgpAR$LE;+q_-K1{j7rwp4y|2k~3w`@qk2f>Q6>pJQar1bcM_S-U6 zoGo_YYw4?KmSyv)xIUad@Jmz;{GCp{n7u+TUMYlzZ>HNzuC0IN zAaP)OxL0^_Rlk>9WH%|S{0TCHO$^po+u=5V7ro?VXyyp3pBX2GDZIkVw!Rkjz^{LS zMzFf!BQGQ0pyiihjArtbfdR`sah6ChB~n44lY7i~P>>5uTHeI$lB8BIr*^OvsuP zf~b(zg?26>Njly=Pe7tUx0;4ujjw{F|LgnZU3U>2>~j0Q6%FnOS_&M zZk4G1+sI6O`f1Gx)0@1t#nZb9pFg}}*ADmfT^dJfGjrscmGm(Vj6>_h(-sZ)cn&G9 z?L}Oa;UHLZpV19xl$*9bVgL9Ns1f!oK*BL|xjN5iZ_zY{S-)Pg9mB@}DO>Te!&!hp ziCG(iK>6%K*%;DOq{5%(F`0*!CTB}l+9j?t5Cncr( zs{4u4MjFFPT-3);6HnUbTadHXsnEg*8_KV&wQ-pRNs~}Vdzn9$^Uvg!!dP_~fBL4r z1ah?DyfrhzUe0_cwHxRZ&kAtgyFk^Zv?M8WDTokeB$^pt-y6^omyXP5FDd-X8PF+M zrNO|WZ2?@#yL7CLh?!vYa~bHwJT&DCDEgte-?b$s-mrT0mJ9#Q=V!Hs7R{z-U69!8 zn?q!BWITHgkLV;Ce^yyVc5*(aBcA^HmWHEa>52L*Jg&bNtUkS~ESws#`9edhMqRDA z{+O`x+m5hTz{SPY$M>-UTx^SEz)#G!`Kx))?!+czuDAn-6{E^RQps>fOOn}ivb60a zpaf>sGQ0R2mQyM^WgO`YPlkg`UZDQ16&UxiduVq}X-K&N!IPV@rEx64ER&TN;>z5sXKJm7U&zAt*7c^J2aDbBqO zTp4=8Otr^^M;;8aDdtSmji`=`E6L!AR`jDjmv5Ib#jBr^enP}1qK>Z$O&{VbbL(`A zU*?ZCdUdC{{e&-GSM=#vEtrdHsMx0*0(o!&39a`g*382S3@Tsn^)YBNV#0(8&&+U2 zBTwhgzeqE_ipc_jU!Y#vR+FWTlqgA=?1_|$t?$6d`ePkycH-?5AL?4Yu}^NO7gCq# z4eg>Tq4gI2$l}BU7qQU}>BP_- z@0YhAXk$yN8PT&C!f(=UHo0kag33=_*ERC2tgmZ!;TYpm4pd!7l-bnRZOt1D0P#eb zvWc^B5lOZe^GDPgnh4J#QUcD^aGex0{}PpVHTgftzvf*8rUZT$BU92SU{}@Y0TAjE zEQA_3%WV>TFUb0Q3TL3p^;&L%f=s3&pB|+u-!79UhOiLTQVRWE4?UNU^^}QjDIB=1 zh5yd3Rn}3rbwQi8={(bXI9&SW)beOB&`gS3`1x&R*vF6F6-uPG{Bp^kjok22{)^oY z(zC`F#c%&Feu%WAJ}r)>H05bJE)|B#d@|hEL0Jv3{Av*mn)@`Gs0QT1k6kOWUW=Ld zR17nz|2Qdd%g)hR#tzjfptYdAOP5!UV4qL`qKT&-btcCKoAbj~c;D~U> z|7lUBrE_qFJ?DWn^OBXa+JKGeo$}0CMdqJ0=Nw}{G=8U+bWIXxP1y_?HrtX z?`#u@@6=ox-V+G9|IKNetMt#JJ3jr;{w~ap4#t=wmrDApyl9-F{B;aACDqU$*K`fv(9eoiy~d#yqFV16a^FrB?)|6kyQ zzT$z}tG;FL0w;o_aVctu{^36st3DK}ov0&QRr$(#X_!*PIe0)4Z9QQ`|LS1etCpw6 zNwpuUm7SX~>*b)uMoZa=iR}J z)$CiO5f_!vU4H(EOeQ|0Ndc}Fe{2e`*T~4eKe}wh*QomZE;RvK=si`Xw`{>4-AF3o zw@GWViTkW3rBnrQR(#d`>A5Q(!nn5aex$_;v?3Txx6@ny1(GDv(1C9`)65t0kEFZFk*{4sL&gi{H(GE-MpzW@8>*vac9)7@14KnjLa` zdXuJ|E+DP11y}a-Xc1nEqNkgYumbTYgK6?iWo2(F;>=$`3}JUzBik!O`wcD>9({#7 zuVSY%L&olZj~`|3kD4^5gOvXBCw=$frH9jUZ}c;qAp;n{&+tk^7|+ZO8LJqKM?d<4 zJFkfa$`U&Ys`v8^_a+6!lzWh!N~P^@;hM{0cO7i~$Cb^~43f^MfUopshowV`KIlPd?Y1 znR#vp+^>Rhw9rZjNI=fSu$-$oG;nwNkgJi_J&c;iyjS4*Z5n2onTRwUTc~u!uetx~ z`8Dg-Hccg)c^%QyI;PeNAfU=7AI82#4Uu!|ESKDCn#*LGFR>m`Z;%JRMpq_$4HBO2 zL@{X{jID4jA87EQ_q(qDQm%!MpJ%Qs!}4T{Yv1K5-u($R(N4>Z0wwszMnXuhKhNWL$3i_s*{{640mrME^@G!r{ zR;pfYYrP{BCwjLUC6&e(ppd*v!I!Vv600P%_(q!G1HAcVdi13iZT>a~AgsqYW1lG2mJf4SO4;KTc_ICeknrjTLr&a)L$4xfb3%JV>zpkKMhmG>H_S&>M8AqM#3TQ> zJu3zz#;NhXtu(k3&k@g3heQS#1^blw4V0P3pw*=&{)jt?eqEqnMGjDeeA1iI_rr1N zLZ8C#lB5)F-|OvNnQlxDvCS=L!006Vk<@|wPHTxL~BI- z!RX4haA)7v^MheVLP<*3ao - -//------------------------------------------------------------------------------ -// Callbacks -//------------------------------------------------------------------------------ -/* - Function: AUDDLoopRecChannel_MuteChanged - Callback triggered when the mute status of a channel changes. This is - a default implementation which does nothing and must be overriden. - - Parameters: - channel - Pointer to a AUDDLoopRecChannel instance. - muted - New mute status. -*/ -//__attribute__ ((weak)) void AUDDLoopRecChannel_MuteChanged( -// AUDDLoopRecChannel *channel, -// unsigned char muted) -//{ -// TRACE_DEBUG("MuteChanged(%d, %d) ", channel->number, muted); -//} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the member variables of an AUDDLoopRecChannel object to the -/// given values. -/// \param channel Pointer to an AUDDLoopRecChannel instance. -/// \param number Channel number in the audio function. -/// \param muted Indicates if the channel is muted. -//------------------------------------------------------------------------------ -void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel, - unsigned char number, - unsigned char muted) -{ - channel->number = number; - channel->muted = muted; -} - -//------------------------------------------------------------------------------ -/// Indicates the number of a channel. -/// \param channel Pointer to an AUDDLoopRecChannel instance. -/// \return Channel number. -//------------------------------------------------------------------------------ -unsigned char AUDDLoopRecChannel_GetNumber(const AUDDLoopRecChannel *channel) -{ - return channel->number; -} - -//------------------------------------------------------------------------------ -/// Mutes the given channel and triggers the MuteChanged callback if -/// necessary. -/// \param channel Pointer to an AUDDLoopRecChannelInstance. -//------------------------------------------------------------------------------ -void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel) -{ - if (!channel->muted) { - - channel->muted = 1; - AUDDLoopRecChannel_MuteChanged(channel, 1); - } -} - -//------------------------------------------------------------------------------ -/// Unmutes the given channel and triggers the MuteChanged callback if -/// necessary. -/// \param channel Pointer to an AUDDLoopRecChannelInstance. -//------------------------------------------------------------------------------ -void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel) -{ - if (channel->muted) { - - channel->muted = 0; - AUDDLoopRecChannel_MuteChanged(channel, 0); - } -} - -//------------------------------------------------------------------------------ -/// Indicates if the given channel is currently muted or not. -/// \param channel Pointer an AUDDLoopRecChannel instance. -/// \return 1 if the channel is muted; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char AUDDLoopRecChannel_IsMuted(const AUDDLoopRecChannel *channel) -{ - return channel->muted; -} - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecChannel.h b/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecChannel.h deleted file mode 100644 index 6cfad6b39..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecChannel.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !Purpose - - Manipulation of the channels of an USB audio LoopRec device. - - !Usage - - -# Initialize a AUDDLoopRecChannel instance using - AUDDLoopRecChannel_Initialize. - -# Retrieves the current status of a channel with the - AUDDLoopRecChannel_IsMuted method. - -# Re-implement the AUDDLoopRecChannel_MuteChanged callback to get - notified when the status of a channel changes. -*/ - -#ifndef AUDDLOOPRECCHANNEL_H -#define AUDDLOOPRECCHANNEL_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Modelizes a channel of an USB audio LoopRec device. -//------------------------------------------------------------------------------ -typedef struct { - - /// Zero-based channel number in the audio function. - unsigned char number; - /// Indicates if the channel is currently muted. - unsigned char muted; - -} AUDDLoopRecChannel; - -//------------------------------------------------------------------------------ -// Callbacks -//------------------------------------------------------------------------------ - -extern void AUDDLoopRecChannel_MuteChanged(AUDDLoopRecChannel *channel, - unsigned char muted); - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel, - unsigned char number, - unsigned char muted); - -extern unsigned char AUDDLoopRecChannel_GetNumber( - const AUDDLoopRecChannel *channel); - -extern void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel); - -extern void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel); - -extern unsigned char AUDDLoopRecChannel_IsMuted( - const AUDDLoopRecChannel *channel); - -#endif //#ifndef AUDDLOOPRECCHANNEL_H - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.c b/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.c deleted file mode 100644 index 45534b558..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.c +++ /dev/null @@ -1,493 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDDLoopRecDriver.h" -#include "AUDDLoopRecDriverDescriptors.h" -#include "AUDDLoopRecChannel.h" -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Audio LoopRec driver internal state. -//------------------------------------------------------------------------------ -typedef struct { - - /// USB device driver instance. - USBDDriver usbdDriver; - #if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - /// Multi-Buffer-Transfer List - USBDTransferBuffer * pMbl; - /// List Size - unsigned short listSize; - /// Current buffer - unsigned short currBuffer; - #endif - /// Callback for ISO IN - AUDDFrameTransferCallback fWrCallback; - /// List of AUDDLoopRecChannel instances for playback. - AUDDLoopRecChannel channels[AUDDLoopRecDriver_NUMCHANNELS+1]; - /// List of AUDDLoopRecChannel instances for record. - AUDDLoopRecChannel recChannels[1]; - -} AUDDLoopRecDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Global USB audio LoopRec driver instance. -static AUDDLoopRecDriver auddLoopRecDriver; -/// Array for storing the current setting of each interface. -static unsigned char auddLoopRecDriverInterfaces[3]; -/// Intermediate storage variable for the mute status of a channel. -static unsigned char muted; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback triggered after the new mute status of a channel has been read -/// by AUDDLoopRecDriver_SetFeatureCurrentValue. Changes the mute status -/// of the given channel accordingly. -/// \param channel Number of the channel whose mute status has changed. -//------------------------------------------------------------------------------ -static void AUDDLoopRecDriver_MuteReceived(unsigned int channel) -{ - AUDDLoopRecChannel * pChannel; - if ((unsigned char)(channel >> 8) == - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) { - pChannel = &auddLoopRecDriver.recChannels[0]; - } - else { - pChannel = &auddLoopRecDriver.channels[channel]; - } - if (muted) { - - AUDDLoopRecChannel_Mute(pChannel); - } - else { - - AUDDLoopRecChannel_Unmute(pChannel); - } - - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Sets the current value of a particular Feature control of a channel. -/// \param entity Entity number. -/// \param channel Channel number. -/// \param control Control selector value (see TODO). -/// \param length Length of the data containing the new value. -//------------------------------------------------------------------------------ -static void AUDDLoopRecDriver_SetFeatureCurrentValue(unsigned char entity, - unsigned char channel, - unsigned char control, - unsigned short length) -{ - TRACE_INFO_WP("sFeature "); - TRACE_DEBUG("\b(E%d, CS%d, CN%d, L%d) ", - entity, control, channel, length); - - // Check the the requested control is supported - // Control/channel combination not supported - if ((control != AUDFeatureUnitRequest_MUTE) || - (length != 1) || - ((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL) && - (channel > AUDDLoopRecDriver_NUMCHANNELS)) || - ((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) && - (channel > 0))) { - - USBD_Stall(0); - } - // Mute control on master channel / speakerphone - else { - - unsigned int argument = channel | (entity << 8); - USBD_Read(0, // Endpoint #0 - &muted, - sizeof(muted), - (TransferCallback) AUDDLoopRecDriver_MuteReceived, - (void *) argument); - } -} - -//------------------------------------------------------------------------------ -/// Sends the current value of a particular channel Feature to the USB host. -/// \param entity Entity number. -/// \param channel Channel number. -/// \param control Control selector value (see TODO). -/// \param length Length of the data to return. -//------------------------------------------------------------------------------ -static void AUDDLoopRecDriver_GetFeatureCurrentValue(unsigned char entity, - unsigned char channel, - unsigned char control, - unsigned char length) -{ - TRACE_INFO_WP("gFeature "); - TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length); - - // Check that the requested control is supported - // Master channel mute control - if ((control == AUDFeatureUnitRequest_MUTE) - && (channel < (AUDDLoopRecDriver_NUMCHANNELS+1)) - && (length == 1)) { - - if (entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) { - muted = auddLoopRecDriver.channels[channel].muted; - } - else { - muted = auddLoopRecDriver.recChannels[0].muted; - } - USBD_Write(0, &muted, sizeof(muted), 0, 0); - } - else { - - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify -/// that a transaction is complete. -/// \param pArg Pointer to callback arguments. -/// \param status USBD status. -/// \param nbBuffer Number of buffer that is processed. -//------------------------------------------------------------------------------ -void AUDDLoopRecDriver_MblWriteCallback(void *pArg, - unsigned char status, - unsigned int nbBuffer) -{ - char rc = 1; - if (auddLoopRecDriver.fWrCallback) { - - rc = auddLoopRecDriver.fWrCallback(pArg, status); - } - if (rc && status == USBD_STATUS_PARTIAL_DONE) { - - while(nbBuffer --) { - USBD_MblReuse(AUDDLoopRecDriverDescriptors_DATAIN, - 0, 0); - } - } -} - -//------------------------------------------------------------------------------ -// Callback re-implementation -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Triggered when the USB host emits a new SETUP request. The request is -/// forward to . -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - AUDDLoopRecDriver_RequestHandler(request); -} -#endif - -//------------------------------------------------------------------------------ -/// Invoked whenever the active setting of an interface is changed by the -/// host. Changes the status of the third LED accordingly. -/// \param interface Interface number. -/// \param setting Newly active setting. -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface, - unsigned char setting) -{ - if ((interface == AUDDLoopRecDriverDescriptors_STREAMING) - && (setting == 0)) { - - LED_Clear(USBD_LEDOTHER); - } - else { - - LED_Set(USBD_LEDOTHER); - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes an USB audio LoopRec device driver, as well as the underlying -/// USB controller. -//------------------------------------------------------------------------------ -void AUDDLoopRecDriver_Initialize() -{ - // Reset callback function - auddLoopRecDriver.fWrCallback = 0; - - // Initialize LoopRec channels - AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[0]), - AUDDLoopRecDriver_MASTERCHANNEL, - 0); - AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[1]), - AUDDLoopRecDriver_LEFTCHANNEL, - 0); - AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[2]), - AUDDLoopRecDriver_RIGHTCHANNEL, - 0); - AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.recChannels[0]), - AUDDLoopRecDriver_RECCHANNEL, - 0); - - // Initialize the USB driver - USBDDriver_Initialize(&(auddLoopRecDriver.usbdDriver), - &auddLoopRecDriverDescriptors, - auddLoopRecDriverInterfaces); - USBD_Init(); - - // Initialize the third LED to indicate when the audio interface is active - LED_Configure(USBD_LEDOTHER); -} - -//------------------------------------------------------------------------------ -/// Handles audio-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request) -{ - unsigned char entity; - unsigned char interface; - - TRACE_INFO_WP("NewReq "); - - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - // Check if the request is supported - switch (USBGenericRequest_GetRequest(request)) { - - case AUDGenericRequest_SETCUR: - TRACE_INFO_WP( - "sCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) - ||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC)) - && (interface == AUDDLoopRecDriverDescriptors_CONTROL)) { - - AUDDLoopRecDriver_SetFeatureCurrentValue( - entity, - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - case AUDGenericRequest_GETCUR: - TRACE_INFO_WP( - "gCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) - ||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC)) - && (interface == AUDDLoopRecDriverDescriptors_CONTROL)) { - - AUDDLoopRecDriver_GetFeatureCurrentValue( - entity, - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - default: - - TRACE_WARNING( - "AUDDLoopRecDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // Forward request to the standard handler - USBDDriver_RequestHandler(&(auddLoopRecDriver.usbdDriver), request); - } - // Unsupported request type - else { - - TRACE_WARNING( - "AUDDLoopRecDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Reads incoming audio data sent by the USB host into the provided -/// buffer. When the transfer is complete, an optional callback function is -/// invoked. -/// \param buffer Pointer to the data storage buffer. -/// \param length Size of the buffer in bytes. -/// \param callback Optional callback function. -/// \param argument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the transfer is started successfully; -/// otherwise an error code. -//------------------------------------------------------------------------------ -unsigned char AUDDLoopRecDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument) -{ - return USBD_Read(AUDDLoopRecDriverDescriptors_DATAOUT, - buffer, - length, - callback, - argument); -} - -//------------------------------------------------------------------------------ -/// Initialize Frame List for sending audio data. -/// \param pMultiBufferList Pointer to the transfer list to initialize. -/// \param pBufferList Pointer list to the buffers used for frames sending. -/// \param listSize Number of frames. -/// \param frameSize Size in number of bytes of each frame. -//------------------------------------------------------------------------------ -void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList, - unsigned char **pBufferList, - unsigned short listSize, - unsigned short frameSize) -{ - int i; - - SANITY_CHECK(pMultiBufferList && pBufferList && listSize && frameSize); - -#if (defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)) && defined(DMA) - // Initialize for circled DMA LLI - { - USBDDmaDescriptor * pLl = (USBDDmaDescriptor*)pMultiBufferList; - for (i = 0; ; i ++) { - pLl[i].pDataAddr = pBufferList[i]; - pLl[i].bufferLength = frameSize; - if (i < listSize - 1) { - pLl[i].pNxtDesc = &pLl[i + 1]; - } - else { - pLl[i].pNxtDesc = &pLl[0]; - break; - } - } - } -#else - // Initialize for circled multi-buffer-list - { - USBDTransferBuffer * pMbl = (USBDTransferBuffer*)pMultiBufferList; - for (i = 0; i < listSize; i ++) { - pMbl[i].pBuffer = pBufferList[i]; - pMbl[i].size = frameSize; - pMbl[i].transferred = 0; - pMbl[i].buffered = 0; - pMbl[i].remaining = frameSize; - } - } -#endif -} - -//------------------------------------------------------------------------------ -/// Start sending audio data, through MBL window. -/// When any frame is complete, an optional callback function is invoked, return -/// 1 of the callback cause the frame buffer re-used. -/// If callback not assigned, frames always reused. -/// \param buffer Pointer to the data storage buffer. -/// \param length Size of the buffer in bytes. -/// \param callback Optional callback function. -/// \param argument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the transfer is started successfully; -/// otherwise an error code. -//------------------------------------------------------------------------------ -unsigned char AUDDLoopRecDriver_Write(void * pMbl, - unsigned short listSize, - AUDDFrameTransferCallback callback, - void * argument) -{ - auddLoopRecDriver.fWrCallback = callback; - return USBD_MblWrite(AUDDLoopRecDriverDescriptors_DATAIN, - pMbl, - listSize, - 1, - 0, - AUDDLoopRecDriver_MblWriteCallback, - argument); -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void AUDDLoopRecDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&auddLoopRecDriver.usbdDriver)) { - - USBD_RemoteWakeUp(); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.h b/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.h deleted file mode 100644 index 8db30a12a..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriver.h +++ /dev/null @@ -1,163 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !Purpose - - Definition of a USB Audio Loop Record Driver with two playback channels - and one record channel. - - !Usage - - -# Enable and setup USB related pins (see pio & board.h). - -# Configure the USB Audio Loop Record driver using - AUDDLoopRecDriver_Initialize - -# To get %audio stream frames from host, use - AUDDLoopRecDriver_Read - -# To send %audio sampling stream to host, use - AUDDLoopRecDriver_Write - -*/ - -#ifndef AUDDLoopRecDriver_H -#define AUDDLoopRecDriver_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Loop Record stream information" -/// -/// This page lists codes for USB Audio Loop Record stream information. -/// -/// !Code -/// - AUDDLoopRecDriver_SAMPLERATE -/// - AUDDLoopRecDriver_NUMCHANNELS -/// - AUDDLoopRecDriver_BYTESPERSAMPLE -/// - AUDDLoopRecDriver_BITSPERSAMPLE -/// - AUDDLoopRecDriver_SAMPLESPERFRAME -/// - AUDDLoopRecDriver_BYTESPERFRAME - -#if defined(at91sam7s) || defined(at91sam9xe) - /// Sample rate in Hz. - #define AUDDLoopRecDriver_SAMPLERATE 32000 - /// Number of channels in audio stream. - #define AUDDLoopRecDriver_NUMCHANNELS 1 - /// Number of bytes in one sample. - #define AUDDLoopRecDriver_BYTESPERSAMPLE 2 -#else - /// Sample rate in Hz. - #define AUDDLoopRecDriver_SAMPLERATE 48000 - /// Number of channels in audio stream. - #define AUDDLoopRecDriver_NUMCHANNELS 2 - /// Number of bytes in one sample. - #define AUDDLoopRecDriver_BYTESPERSAMPLE 2 -#endif -/// Number of bits in one sample. -#define AUDDLoopRecDriver_BITSPERSAMPLE (AUDDLoopRecDriver_BYTESPERSAMPLE * 8) -/// Number of bytes in one USB subframe. -#define AUDDLoopRecDriver_BYTESPERSUBFRAME (AUDDLoopRecDriver_NUMCHANNELS * \ - AUDDLoopRecDriver_BYTESPERSAMPLE) -/// Number of samples in one USB frame. -#define AUDDLoopRecDriver_SAMPLESPERFRAME (AUDDLoopRecDriver_SAMPLERATE / 1000 \ - * AUDDLoopRecDriver_NUMCHANNELS) -/// Number of bytes in one USB frame. -#define AUDDLoopRecDriver_BYTESPERFRAME (AUDDLoopRecDriver_SAMPLESPERFRAME * \ - AUDDLoopRecDriver_BYTESPERSAMPLE) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Loop Record Channel Numbers" -/// -/// This page lists codes for USB Audio Loop Record channel numbers. -/// -/// !Playback channel numbers -/// - AUDDLoopRecDriver_MASTERCHANNEL -/// - AUDDLoopRecDriver_LEFTCHANNEL -/// - AUDDLoopRecDriver_RIGHTCHANNEL -/// -/// !Record channel number -/// - AUDDLoopRecDriver_RECCHANNEL - -/// Master channel of playback. -#define AUDDLoopRecDriver_MASTERCHANNEL 0 -/// Front left channel of playback. -#define AUDDLoopRecDriver_LEFTCHANNEL 1 -/// Front right channel of playback. -#define AUDDLoopRecDriver_RIGHTCHANNEL 2 -/// Channel of record. -#define AUDDLoopRecDriver_RECCHANNEL 0 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback function for audio frames. -/// \param pArg Pointer to transfer arguments. -/// \param status Frame transfer status. -/// \return 1 to continue, 0 to stop frames. -//------------------------------------------------------------------------------ -typedef char (*AUDDFrameTransferCallback)(void* pArg, char status); - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void AUDDLoopRecDriver_Initialize(); - -extern void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned char AUDDLoopRecDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument); - -extern void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList, - unsigned char **pBufferList, - unsigned short listSize, - unsigned short frameSize); - -extern unsigned char AUDDLoopRecDriver_Write(void * pMbl, - unsigned short listSize, - AUDDFrameTransferCallback callback, - void *argument); - -extern void AUDDLoopRecDriver_RemoteWakeUp(void); - -#endif //#ifndef AUDDLoopRecDriver_H - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c b/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c deleted file mode 100644 index 9f961fd3d..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDDLoopRecDriverDescriptors.h" -#include "AUDDLoopRecDriver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Loop Record Device Codes" -/// -/// This page lists the %device IDs and release number of the USB Audio Loop Record -/// %device. -/// -/// !Codes -/// - AUDDLoopRecDriverDescriptors_VENDORID -/// - AUDDLoopRecDriverDescriptors_PRODUCTID -/// - AUDDLoopRecDriverDescriptors_RELEASE - -/// Device vendor ID. -#define AUDDLoopRecDriverDescriptors_VENDORID 0x03EB -/// Device product ID. -#define AUDDLoopRecDriverDescriptors_PRODUCTID 0x6128 -/// Device release number in BCD format. -#define AUDDLoopRecDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Audio control header descriptor with one slave interface. -//------------------------------------------------------------------------------ -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Header descriptor with 1 interface. -//------------------------------------------------------------------------------ -typedef struct { - - /// Header descriptor. - AUDHeaderDescriptor header; - /// Id of the first grouped interface - Speaker. - unsigned char bInterface0; - /// Id of the second grouped interface - Speakerphone. - unsigned char bInterface1; - -} __attribute__ ((packed)) AUDHeaderDescriptor2; // GCC - -//------------------------------------------------------------------------------ -/// Feature unit descriptor with 3 channel controls (master, right, left). -//------------------------------------------------------------------------------ -typedef struct { - - /// Feature unit descriptor. - AUDFeatureUnitDescriptor feature; - /// Available controls for each channel. - unsigned char bmaControls[3]; - /// Index of a string descriptor for the feature unit. - unsigned char iFeature; - -} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC - -//------------------------------------------------------------------------------ -/// List of descriptors for detailling the audio control interface of a -/// device using a USB Audio Loop Recorder driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Header descriptor (with one slave interface). - AUDHeaderDescriptor2 header; - /// Input terminal descriptor. - AUDInputTerminalDescriptor inputLoopRec; - /// Output terminal descriptor. - AUDOutputTerminalDescriptor outputLoopRec; - /// Feature unit descriptor - LoopRec. - AUDFeatureUnitDescriptor3 featureLoopRec; - /// Input terminal descriptor. - AUDInputTerminalDescriptor inputRec; - /// Output terminal descriptor. - AUDOutputTerminalDescriptor outputRec; - /// Feature unit descriptor - LoopRecphone. - AUDFeatureUnitDescriptor3 featureRec; - -} __attribute__ ((packed)) AUDDLoopRecDriverAudioControlDescriptors; // GCC - -//------------------------------------------------------------------------------ -/// Format type I descriptor with one discrete sampling frequency. -//------------------------------------------------------------------------------ -typedef struct { - - /// Format type I descriptor. - AUDFormatTypeOneDescriptor formatType; - /// Sampling frequency in Hz. - unsigned char tSamFreq[3]; - -} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC - -//------------------------------------------------------------------------------ -/// Holds a list of descriptors returned as part of the configuration of -/// a USB Audio Loop Record device. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard configuration. - USBConfigurationDescriptor configuration; - /// Audio control interface. - USBInterfaceDescriptor control; - /// Descriptors for the audio control interface. - AUDDLoopRecDriverAudioControlDescriptors controlDescriptors; - //- AUDIO OUT - /// Streaming out interface descriptor (with no endpoint, required). - USBInterfaceDescriptor streamingOutNoIsochronous; - /// Streaming out interface descriptor. - USBInterfaceDescriptor streamingOut; - /// Audio class descriptor for the streaming out interface. - AUDStreamingInterfaceDescriptor streamingOutClass; - /// Stream format descriptor. - AUDFormatTypeOneDescriptor1 streamingOutFormatType; - /// Streaming out endpoint descriptor. - AUDEndpointDescriptor streamingOutEndpoint; - /// Audio class descriptor for the streaming out endpoint. - AUDDataEndpointDescriptor streamingOutDataEndpoint; - //- AUDIO IN - /// Streaming in interface descriptor (with no endpoint, required). - USBInterfaceDescriptor streamingInNoIsochronous; - /// Streaming in interface descriptor. - USBInterfaceDescriptor streamingIn; - /// Audio class descriptor for the streaming in interface. - AUDStreamingInterfaceDescriptor streamingInClass; - /// Stream format descriptor. - AUDFormatTypeOneDescriptor1 streamingInFormatType; - /// Streaming in endpoint descriptor. - AUDEndpointDescriptor streamingInEndpoint; - /// Audio class descriptor for the streaming in endpoint. - AUDDataEndpointDescriptor streamingInDataEndpoint; - -} __attribute__ ((packed)) AUDDLoopRecDriverConfigurationDescriptors; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Device descriptor for a USB Audio Loop Record driver. -const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - AUDDeviceDescriptor_CLASS, - AUDDeviceDescriptor_SUBCLASS, - AUDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - AUDDLoopRecDriverDescriptors_VENDORID, - AUDDLoopRecDriverDescriptors_PRODUCTID, - AUDDLoopRecDriverDescriptors_RELEASE, - 1, // Manufacturer string descriptor index - 2, // Product string descriptor index - 3, // Index of serial number string descriptor - 1 // One possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - AUDDeviceDescriptor_CLASS, - AUDDeviceDescriptor_SUBCLASS, - AUDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -/// HS Configuration descriptors for a USB Audio Loop Record driver. -const AUDDLoopRecDriverConfigurationDescriptors hsConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(AUDDLoopRecDriverConfigurationDescriptors), - 3, // This configuration has 3 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor2), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDLoopRecDriverAudioControlDescriptors), - 2 // Two streaming interface - }, - AUDDLoopRecDriverDescriptors_STREAMING, - AUDDLoopRecDriverDescriptors_STREAMINGIN - }, - // Input terminal descriptor ( speaker ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speaker ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor ( speaker ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - }, - // Input terminal descriptor ( speakerphone ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDInputTerminalDescriptor_SPEAKERPHONE, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speakerphone ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDOutputTerminalDescriptor_USBTREAMING, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - 0 // No string descriptor - }, - // Feature unit descriptor ( speakerphone ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - 1 - }, - { - AUDFeatureUnitDescriptor_MUTE, // Mic controls - 0, - 0 - }, - 0 // No string descriptor - } - }, - // - AUIDO OUT - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDLoopRecDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - }, - //- AUDIO IN - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - AUDDLoopRecDriverDescriptors_DATAIN), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; - -/// HS Other Speed Configuration descriptors for a USB Audio Loop Record driver. -const AUDDLoopRecDriverConfigurationDescriptors - fsOtherSpeedConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(AUDDLoopRecDriverConfigurationDescriptors), - 3, // This configuration has 3 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor2), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDLoopRecDriverAudioControlDescriptors), - 2 // Two streaming interface - }, - AUDDLoopRecDriverDescriptors_STREAMING, - AUDDLoopRecDriverDescriptors_STREAMINGIN - }, - // Input terminal descriptor ( speaker ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speaker ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor ( speaker ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - }, - // Input terminal descriptor ( speakerphone ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDInputTerminalDescriptor_SPEAKERPHONE, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speakerphone ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDOutputTerminalDescriptor_USBTREAMING, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - 0 // No string descriptor - }, - // Feature unit descriptor ( speakerphone ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - 1 - }, - { - AUDFeatureUnitDescriptor_MUTE, // Mic controls - 0, - 0 - }, - 0 // No string descriptor - } - }, - // - AUIDO OUT - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDLoopRecDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - }, - //- AUDIO IN - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - AUDDLoopRecDriverDescriptors_DATAIN), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; - -/// HS Other Speed Configuration descriptors. -const AUDDLoopRecDriverConfigurationDescriptors - hsOtherSpeedConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(AUDDLoopRecDriverConfigurationDescriptors), - 3, // This configuration has 3 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor2), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDLoopRecDriverAudioControlDescriptors), - 2 // Two streaming interface - }, - AUDDLoopRecDriverDescriptors_STREAMING, - AUDDLoopRecDriverDescriptors_STREAMINGIN - }, - // Input terminal descriptor ( speaker ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speaker ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor ( speaker ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - }, - // Input terminal descriptor ( speakerphone ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDInputTerminalDescriptor_SPEAKERPHONE, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speakerphone ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDOutputTerminalDescriptor_USBTREAMING, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - 0 // No string descriptor - }, - // Feature unit descriptor ( speakerphone ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - 1 - }, - { - AUDFeatureUnitDescriptor_MUTE, // Mic controls - 0, - 0 - }, - 0 // No string descriptor - } - }, - // - AUIDO OUT - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDLoopRecDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - }, - //- AUDIO IN - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - AUDDLoopRecDriverDescriptors_DATAIN), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; - -#endif // defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// FS Configuration descriptors for a USB Audio Loop Record driver. -const AUDDLoopRecDriverConfigurationDescriptors fsConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(AUDDLoopRecDriverConfigurationDescriptors), - 3, // This configuration has 3 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor2), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDLoopRecDriverAudioControlDescriptors), - 2 // Two streaming interface - }, - AUDDLoopRecDriverDescriptors_STREAMING, - AUDDLoopRecDriverDescriptors_STREAMINGIN - }, - // Input terminal descriptor ( speaker ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speaker ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor ( speaker ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - }, - // Input terminal descriptor ( speakerphone ) - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDInputTerminalDescriptor_SPEAKERPHONE, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDDLoopRecDriver_NUMCHANNELS, - #if AUDDLoopRecDriver_NUMCHANNELS > 1 - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - #else - 0, // Mono sets no position bits. - #endif - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor ( speakerphone ) - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - AUDOutputTerminalDescriptor_USBTREAMING, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - 0 // No string descriptor - }, - // Feature unit descriptor ( speakerphone ) - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC, - 1 - }, - { - AUDFeatureUnitDescriptor_MUTE, // Mic controls - 0, - 0 - }, - 0 // No string descriptor - } - }, - // - AUIDO OUT - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDLoopRecDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - }, - //- AUDIO IN - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDLoopRecDriverDescriptors_STREAMINGIN, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDLoopRecDriver_NUMCHANNELS, - AUDDLoopRecDriver_BYTESPERSAMPLE, - AUDDLoopRecDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDLoopRecDriver_SAMPLERATE & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - AUDDLoopRecDriverDescriptors_DATAIN), - USBEndpointDescriptor_ISOCHRONOUS, - AUDDLoopRecDriver_BYTESPERFRAME, - AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; - -/// String descriptor with the supported languages. -const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(15), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('k'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('a'), - USBStringDescriptor_UNICODE('k'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('r') -}; - -/// Product serial number. -const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB Audio Loop Recorder device driver. -const USBDDriverDescriptors auddLoopRecDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &fsConfigurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &fsOtherSpeedConfigurationDescriptors, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &hsConfigurationDescriptors, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &hsOtherSpeedConfigurationDescriptors, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h b/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h deleted file mode 100644 index 259b69775..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h +++ /dev/null @@ -1,148 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Declaration of the descriptors required by a USB audio speaker driver. - - !!!Usage - - -# Initialize a USBDDriver instance using the - auddSpeakerDriverDescriptors list. -*/ - -#ifndef AUDDLOOPRECDESCRIPTORS_H -#define AUDDLOOPRECDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Endpoint Numbers" -/// -/// This page lists the endpoint number settings for USB Audio Speaker device. -/// -/// !Endpoints -/// - AUDDLoopRecDriverDescriptors_DATAOUT -/// - AUDDLoopRecDriverDescriptors_DATAIN -/// - AUDDLoopRecDriverDescriptors_HS_INTERVAL -/// - AUDDLoopRecDriverDescriptors_FS_INTERVAL - -#if defined(at91sam7s) || defined(at91sam9xe) - /// Data out endpoint number, size 64B. - #define AUDDLoopRecDriverDescriptors_DATAOUT 0x01 - /// Data in endpoint number, size 64B - #define AUDDLoopRecDriverDescriptors_DATAIN 0x02 -#elif defined(CHIP_USB_UDP) - /// Data out endpoint number, size 192B. - #define AUDDLoopRecDriverDescriptors_DATAOUT 0x04 - /// Data in endpoint number, size 192B. - #define AUDDLoopRecDriverDescriptors_DATAIN 0x05 -#elif defined(at91sam9m10ek) - /// Data out endpoint number, size 192B. - #define AUDDLoopRecDriverDescriptors_DATAOUT 0x01 - /// Data in endpoint number, size 192B - #define AUDDLoopRecDriverDescriptors_DATAIN 0x06 -#else - /// Data out endpoint number, size 192B. - #define AUDDLoopRecDriverDescriptors_DATAOUT 0x05 - /// Data in endpoint number, size 192B - #define AUDDLoopRecDriverDescriptors_DATAIN 0x06 -#endif - -/// Endpoint polling interval 2^(x-1) * 125us -#define AUDDLoopRecDriverDescriptors_HS_INTERVAL 0x04 -/// Endpoint polling interval 2^(x-1) * ms -#define AUDDLoopRecDriverDescriptors_FS_INTERVAL 0x01 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Interface IDs" -/// -/// This page lists the interface numbers for USB Audio Speaker device. -/// -/// !Interfaces -/// - AUDDLoopRecDriverDescriptors_CONTROL -/// - AUDDLoopRecDriverDescriptors_STREAMING -/// - AUDDLoopRecDriverDescriptors_STREAMINGIN - -/// Audio control interface ID. -#define AUDDLoopRecDriverDescriptors_CONTROL 0 -/// Audio streaming interface ID (OUT, for playback). -#define AUDDLoopRecDriverDescriptors_STREAMING 1 -/// Audio streaming interface ID (IN, for record). -#define AUDDLoopRecDriverDescriptors_STREAMINGIN 2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Entity IDs" -/// -/// This page lists the entity IDs for USB Audio Speaker device. -/// -/// !Entities -/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL -/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL -/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT -/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC -/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC -/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC - -/// Playback input terminal ID. -#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL 0 -/// Playback output terminal ID. -#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL 1 -/// Playback feature unit ID. -#define AUDDLoopRecDriverDescriptors_FEATUREUNIT 2 -/// Record input terminal ID. -#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC 3 -/// Record output terminal ID. -#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC 4 -/// Record feature unit ID -#define AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC 5 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -extern const USBDDriverDescriptors auddLoopRecDriverDescriptors; - -#endif //#ifndef AUDDLOOPRECDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/audio-looprec/audio-looprec.dir b/src/ersky9x/libraries/usb/device/audio-looprec/audio-looprec.dir deleted file mode 100644 index bbd6c6aec..000000000 --- a/src/ersky9x/libraries/usb/device/audio-looprec/audio-looprec.dir +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB Audio -/// Class device - USB audio-looprec demo, to implement an USB desktop speaker -/// which echos audio stream back to host. -/// -/// !!!Contents -/// There are two things for the implement of the audio-speaker device driver: -/// - Implement the audio-looprec driver structs and functions for the device, -/// to initialize, to handle audio class specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the audio-speaker device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the device as a USB audio "desktop speaker" device. -/// -/// This project is simply addon to the audio speaker demo. For more -/// information, please refer to "USB Audio Speaker Device". -//------------------------------------------------------------------------------ \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.c b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.c deleted file mode 100644 index 30f39c58b..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.c +++ /dev/null @@ -1,129 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: AUDDSpeakerChannel implementation - - About: Purpose - Implementation of the AUDDSpeakerChannel functions. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDDSpeakerChannel.h" -#include - -//------------------------------------------------------------------------------ -// Callbacks -//------------------------------------------------------------------------------ -/* - Function: AUDDSpeakerChannel_MuteChanged - Callback triggered when the mute status of a channel changes. This is - a default implementation which does nothing and must be overriden. - - Parameters: - channel - Pointer to a AUDDSpeakerChannel instance. - muted - New mute status. -*/ -//__attribute__ ((weak)) void AUDDSpeakerChannel_MuteChanged( -// AUDDSpeakerChannel *channel, -// unsigned char muted) -//{ -// TRACE_DEBUG("MuteChanged(%d, %d) ", channel->number, muted); -//} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the member variables of an AUDDSpeakerChannel object to the -/// given values. -/// \param channel Pointer to an AUDDSpeakerChannel instance. -/// \param number Channel number in the audio function. -/// \param muted Indicates if the channel is muted. -//------------------------------------------------------------------------------ -void AUDDSpeakerChannel_Initialize(AUDDSpeakerChannel *channel, - unsigned char number, - unsigned char muted) -{ - channel->number = number; - channel->muted = muted; -} - -//------------------------------------------------------------------------------ -/// Indicates the number of a channel. -/// \param channel Pointer to an AUDDSpeakerChannel instance. -/// \return Channel number. -//------------------------------------------------------------------------------ -unsigned char AUDDSpeakerChannel_GetNumber(const AUDDSpeakerChannel *channel) -{ - return channel->number; -} - -//------------------------------------------------------------------------------ -/// Mutes the given channel and triggers the MuteChanged callback if -/// necessary. -/// \param channel Pointer to an AUDDSpeakerChannelInstance. -//------------------------------------------------------------------------------ -void AUDDSpeakerChannel_Mute(AUDDSpeakerChannel *channel) -{ - if (!channel->muted) { - - channel->muted = 1; - AUDDSpeakerChannel_MuteChanged(channel, 1); - } -} - -//------------------------------------------------------------------------------ -/// Unmutes the given channel and triggers the MuteChanged callback if -/// necessary. -/// \param channel Pointer to an AUDDSpeakerChannelInstance. -//------------------------------------------------------------------------------ -void AUDDSpeakerChannel_Unmute(AUDDSpeakerChannel *channel) -{ - if (channel->muted) { - - channel->muted = 0; - AUDDSpeakerChannel_MuteChanged(channel, 0); - } -} - -//------------------------------------------------------------------------------ -/// Indicates if the given channel is currently muted or not. -/// \param channel Pointer an AUDDSpeakerChannel instance. -/// \return 1 if the channel is muted; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char AUDDSpeakerChannel_IsMuted(const AUDDSpeakerChannel *channel) -{ - return channel->muted; -} - diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.h b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.h deleted file mode 100644 index 5eeca7e30..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerChannel.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !Purpose - - Manipulation of the channels of an USB audio speaker device. - - !Usage - - -# Initialize a AUDDSpeakerChannel instance using - AUDDSpeakerChannel_Initialize. - -# Retrieves the current status of a channel with the - AUDDSpeakerChannel_IsMuted method. - -# Re-implement the AUDDSpeakerChannel_MuteChanged callback to get - notified when the status of a channel changes. -*/ - -#ifndef AUDDSPEAKERCHANNEL_H -#define AUDDSPEAKERCHANNEL_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Modelizes a channel of an USB audio speaker device. -//------------------------------------------------------------------------------ -typedef struct { - - /// Zero-based channel number in the audio function. - unsigned char number; - /// Indicates if the channel is currently muted. - unsigned char muted; - -} AUDDSpeakerChannel; - -//------------------------------------------------------------------------------ -// Callbacks -//------------------------------------------------------------------------------ - -extern void AUDDSpeakerChannel_MuteChanged(AUDDSpeakerChannel *channel, - unsigned char muted); - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void AUDDSpeakerChannel_Initialize(AUDDSpeakerChannel *channel, - unsigned char number, - unsigned char muted); - -extern unsigned char AUDDSpeakerChannel_GetNumber( - const AUDDSpeakerChannel *channel); - -extern void AUDDSpeakerChannel_Mute(AUDDSpeakerChannel *channel); - -extern void AUDDSpeakerChannel_Unmute(AUDDSpeakerChannel *channel); - -extern unsigned char AUDDSpeakerChannel_IsMuted( - const AUDDSpeakerChannel *channel); - -#endif //#ifndef AUDDSPEAKERCHANNEL_H - diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.c b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.c deleted file mode 100644 index 7ca58bdc6..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.c +++ /dev/null @@ -1,378 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDDSpeakerDriver.h" -#include "AUDDSpeakerDriverDescriptors.h" -#include "AUDDSpeakerChannel.h" -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Audio speaker driver internal state. -//------------------------------------------------------------------------------ -typedef struct { - - /// USB device driver instance. - USBDDriver usbdDriver; - /// List of AUDDSpeakerChannel instances for playback. - AUDDSpeakerChannel channels[AUDDSpeakerDriver_NUMCHANNELS+1]; - -} AUDDSpeakerDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Global USB audio speaker driver instance. -static AUDDSpeakerDriver auddSpeakerDriver; -/// Array for storing the current setting of each interface. -static unsigned char auddSpeakerDriverInterfaces[2]; -/// Intermediate storage variable for the mute status of a channel. -static unsigned char muted; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback triggered after the new mute status of a channel has been read -/// by AUDDSpeakerDriver_SetFeatureCurrentValue. Changes the mute status -/// of the given channel accordingly. -/// \param channel Number of the channel whose mute status has changed. -//------------------------------------------------------------------------------ -static void AUDDSpeakerDriver_MuteReceived(unsigned int channel) -{ - if (muted) { - - AUDDSpeakerChannel_Mute(&(auddSpeakerDriver.channels[channel])); - } - else { - - AUDDSpeakerChannel_Unmute(&(auddSpeakerDriver.channels[channel])); - } - - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Sets the current value of a particular Feature control of a channel. -/// \param entity Entity number. -/// \param channel Channel number. -/// \param control Control selector value (see TODO). -/// \param length Length of the data containing the new value. -//------------------------------------------------------------------------------ -static void AUDDSpeakerDriver_SetFeatureCurrentValue(unsigned char entity, - unsigned char channel, - unsigned char control, - unsigned short length) -{ - TRACE_INFO_WP("sFeature "); - TRACE_DEBUG("\b(E%d, CS%d, CN%d, L%d) ", - entity, control, channel, length); - - // Check the the requested control is supported - // Control/channel combination not supported - if ((control == AUDFeatureUnitRequest_MUTE) - && (channel < (AUDDSpeakerDriver_NUMCHANNELS+1)) - && (length == 1)) { - - unsigned int argument = channel; // Avoids compiler warning - USBD_Read(0, // Endpoint #0 - &muted, - sizeof(muted), - (TransferCallback) AUDDSpeakerDriver_MuteReceived, - (void *) argument); - } - // Control/channel combination not supported - else { - - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Sends the current value of a particular channel Feature to the USB host. -/// \param entity Entity number. -/// \param channel Channel number. -/// \param control Control selector value (see TODO). -/// \param length Length of the data to return. -//------------------------------------------------------------------------------ -static void AUDDSpeakerDriver_GetFeatureCurrentValue(unsigned char entity, - unsigned char channel, - unsigned char control, - unsigned char length) -{ - TRACE_INFO_WP("gFeature "); - TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length); - - // Check that the requested control is supported - // Master channel mute control - if ((control == AUDFeatureUnitRequest_MUTE) - && (channel < (AUDDSpeakerDriver_NUMCHANNELS+1)) - && (length == 1)) { - - muted = AUDDSpeakerChannel_IsMuted(&(auddSpeakerDriver.channels[channel])); - USBD_Write(0, &muted, sizeof(muted), 0, 0); - } - else { - - USBD_Stall(0); - } -} - -///* -// Function: AUDDSpeakerDriver_SetInterface -// Changes the current active alternate setting of the given interface. -// -// Parameters: -// -//*/ -//TRACE_DEBUG_M("SetInterface(%d,%d) ", setup->wIndex, setup->wValue); -// -// /* Check that interface is AudioStreaming OUT */ -// if (setup->wIndex == INTERFACE_ID_AUDIOSTREAMING_OUT) { -// -// /* Check desired alternate setting */ -// switch (setup->wValue) { -// case 0: -// case 1: -// if (speakerDriver->isOutStreamEnabled != setup->wValue) { -// -// speakerDriver->isOutStreamEnabled = setup->wValue; -// SPK_OutStreamStatusChanged(speakerDriver); -// LED_SetGlowing(LED_OTHER, setup->wValue); -// } -// USB_SendZLP0(usbDriver, 0, 0); -// break; -// -// default: -// USB_Stall(usbDriver, 0); -// } -// } -// else { -// -// USB_Stall(usbDriver, 0); -// } -// - -//------------------------------------------------------------------------------ -// Callback re-implementation -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Triggered when the USB host emits a new SETUP request. The request is -/// forward to . -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - AUDDSpeakerDriver_RequestHandler(request); -} -#endif - -//------------------------------------------------------------------------------ -/// Invoked whenever the active setting of an interface is changed by the -/// host. Changes the status of the third LED accordingly. -/// \param interface Interface number. -/// \param setting Newly active setting. -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface, - unsigned char setting) -{ - if ((interface == AUDDSpeakerDriverDescriptors_STREAMING) - && (setting == 0)) { - - LED_Clear(USBD_LEDOTHER); - } - else { - - LED_Set(USBD_LEDOTHER); - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes an USB audio speaker device driver, as well as the underlying -/// USB controller. -//------------------------------------------------------------------------------ -void AUDDSpeakerDriver_Initialize() -{ - // Initialize speaker channels - AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[0]), - AUDDSpeakerDriver_MASTERCHANNEL, - 0); - AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[1]), - AUDDSpeakerDriver_LEFTCHANNEL, - 0); - AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[2]), - AUDDSpeakerDriver_RIGHTCHANNEL, - 0); - - // Initialize the USB driver - USBDDriver_Initialize(&(auddSpeakerDriver.usbdDriver), - &auddSpeakerDriverDescriptors, - auddSpeakerDriverInterfaces); - USBD_Init(); - - // Initialize the third LED to indicate when the audio interface is active - LED_Configure(USBD_LEDOTHER); -} - -//------------------------------------------------------------------------------ -/// Handles audio-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -void AUDDSpeakerDriver_RequestHandler(const USBGenericRequest *request) -{ - unsigned char entity; - unsigned char interface; - - TRACE_INFO_WP("NewReq "); - - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - // Check if the request is supported - switch (USBGenericRequest_GetRequest(request)) { - - case AUDGenericRequest_SETCUR: - TRACE_INFO_WP( - "sCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if ((entity == AUDDSpeakerDriverDescriptors_FEATUREUNIT) - && (interface == AUDDSpeakerDriverDescriptors_CONTROL)) { - - AUDDSpeakerDriver_SetFeatureCurrentValue( - entity, - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - case AUDGenericRequest_GETCUR: - TRACE_INFO_WP( - "gCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if ((entity == AUDDSpeakerDriverDescriptors_FEATUREUNIT) - && (interface == AUDDSpeakerDriverDescriptors_CONTROL)) { - - AUDDSpeakerDriver_GetFeatureCurrentValue( - entity, - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - default: - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // Forward request to the standard handler - USBDDriver_RequestHandler(&(auddSpeakerDriver.usbdDriver), request); - } - // Unsupported request type - else { - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Reads incoming audio data sent by the USB host into the provided -/// buffer. When the transfer is complete, an optional callback function is -/// invoked. -/// \param buffer Pointer to the data storage buffer. -/// \param length Size of the buffer in bytes. -/// \param callback Optional callback function. -/// \param argument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the transfer is started successfully; -/// otherwise an error code. -//------------------------------------------------------------------------------ -unsigned char AUDDSpeakerDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument) -{ - return USBD_Read(AUDDSpeakerDriverDescriptors_DATAOUT, - buffer, - length, - callback, - argument); -} - diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.h b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.h deleted file mode 100644 index 133d6df8a..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriver.h +++ /dev/null @@ -1,201 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !Purpose - - Definition of a USB Audio Speaker Driver with two playback channels and one - record channel. - - !Usage - - -# Enable and setup USB related pins (see pio & board.h). - -# Configure the USB Audio Speaker driver using - AUDDSpeakerDriver_Initialize - -# To get %audio stream frames from host, use - AUDDSpeakerDriver_Read - -# To send %audio sampling stream to host, use - AUDDSpeakerDriver_Write - -*/ - -#ifndef AUDDSPEAKERDRIVER_H -#define AUDDSPEAKERDRIVER_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker stream information" -/// -/// This page lists codes for USB Audio Speaker stream information. -/// -/// !Code -/// - AUDDSpeakerDriver_SAMPLERATE -/// - AUDDSpeakerDriver_NUMCHANNELS -/// - AUDDSpeakerDriver_BYTESPERSAMPLE -/// - AUDDSpeakerDriver_BITSPERSAMPLE -/// - AUDDSpeakerDriver_SAMPLESPERFRAME -/// - AUDDSpeakerDriver_BYTESPERFRAME - -#if defined(at91sam7s) - /// Sample rate in Hz. - #define AUDDSpeakerDriver_SAMPLERATE 32000 - /// Number of channels in audio stream. - #define AUDDSpeakerDriver_NUMCHANNELS 1 - /// Number of bytes in one sample. - #define AUDDSpeakerDriver_BYTESPERSAMPLE 2 -#else - /// Sample rate in Hz. - #define AUDDSpeakerDriver_SAMPLERATE 48000 - /// Number of channels in audio stream. - #define AUDDSpeakerDriver_NUMCHANNELS 2 - /// Number of bytes in one sample. - #define AUDDSpeakerDriver_BYTESPERSAMPLE 2 -#endif -/// Number of bits in one sample. -#define AUDDSpeakerDriver_BITSPERSAMPLE (AUDDSpeakerDriver_BYTESPERSAMPLE * 8) -/// Number of bytes in one USB subframe. -#define AUDDSpeakerDriver_BYTESPERSUBFRAME (AUDDSpeakerDriver_NUMCHANNELS * \ - AUDDSpeakerDriver_BYTESPERSAMPLE) -/// Number of samples in one USB frame. -#define AUDDSpeakerDriver_SAMPLESPERFRAME (AUDDSpeakerDriver_SAMPLERATE / 1000 \ - * AUDDSpeakerDriver_NUMCHANNELS) -/// Number of bytes in one USB frame. -#define AUDDSpeakerDriver_BYTESPERFRAME (AUDDSpeakerDriver_SAMPLESPERFRAME * \ - AUDDSpeakerDriver_BYTESPERSAMPLE) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Channel Numbers" -/// -/// This page lists codes for USB Audio Speaker channel numbers. -/// -/// !Playback channel numbers -/// - AUDDSpeakerDriver_MASTERCHANNEL -/// - AUDDSpeakerDriver_LEFTCHANNEL -/// - AUDDSpeakerDriver_RIGHTCHANNEL -/// -/// !Record channel number -/// - AUDDSpeakerDriver_RECCHANNEL - -/// Master channel of playback. -#define AUDDSpeakerDriver_MASTERCHANNEL 0 -/// Front left channel of playback. -#define AUDDSpeakerDriver_LEFTCHANNEL 1 -/// Front right channel of playback. -#define AUDDSpeakerDriver_RIGHTCHANNEL 2 -/// Channel of record. -#define AUDDSpeakerDriver_RECCHANNEL 0 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void AUDDSpeakerDriver_Initialize(); - -extern void AUDDSpeakerDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned char AUDDSpeakerDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument); - -#endif //#ifndef AUDDSPEAKERDRIVER_H - -//#ifndef SPEAKER_DRIVER_H -//#define SPEAKER_DRIVER_H -// -////------------------------------------------------------------------------------ -//// Definitions -////------------------------------------------------------------------------------ -// -///*! Sampling frequency in Hz */ -//#define SPEAKER_SAMPLERATE 48000 -///*! Number of samples in one isochronous packet (1ms frame) */ -//#define SPEAKER_SAMPLESPERPACKET (SPEAKER_SAMPLERATE / 1000) -///*! Size of one sample (in bytes) */ -//#define SPEAKER_SAMPLESIZE 2 -///*! Number of channels */ -//#define SPEAKER_NUMCHANNELS 2 -///*! Size of one frame (number of bytes sent for one sample on all channels) */ -//#define SPEAKER_FRAMESIZE (SPEAKER_SAMPLESIZE * SPEAKER_NUMCHANNELS) -///*! Required bit rate given the sample frequency, sample size and number of -// channels. */ -//#define SPEAKER_BITRATE (SPEAKER_SAMPLERATE * SPEAKER_FRAMESIZE) -///*! Size of one isochronous packet */ -//#define SPEAKER_PACKETSIZE (SPEAKER_SAMPLESPERPACKET * SPEAKER_FRAMESIZE) -// -////------------------------------------------------------------------------------ -//// Structures -////------------------------------------------------------------------------------ -///*! -// Holds the speaker driver state. -// */ -//typedef struct { -// -// S_std_class standardDriver; -// -// unsigned char isOutStreamEnabled; -// unsigned char isChannelMuted[SPEAKER_NUMCHANNELS+1]; -// -// Callback_f outStreamStatusChanged; -// Callback_f outStreamMuteChanged; -// -//} __attribute__((packed)) S_speaker; -// -////------------------------------------------------------------------------------ -//// Exported functions -////------------------------------------------------------------------------------ -// -//extern void SPK_Init(S_speaker *speakerDriver, const S_usb *usbDriver); -//extern void SPK_SetCallbacks(S_speaker *speakerDriver, -// Callback_f outStreamStatusChanged, -// Callback_f outStreamMuteChanged); -//extern void SPK_RequestHandler(S_speaker *speakerDriver); -//extern char SPK_Read(S_speaker *speakerDriver, -// void *buffer, -// unsigned int length, -// Callback_f callback, -// void *argument); -// -//#endif //#ifndef SPEAKER_DRIVER_H -// diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.c b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.c deleted file mode 100644 index 2501120e3..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.c +++ /dev/null @@ -1,620 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "AUDDSpeakerDriverDescriptors.h" -#include "AUDDSpeakerDriver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Device Codes" -/// -/// This page lists the %device IDs and release number of the USB Audio Speaker -/// %device. -/// -/// !Codes -/// - AUDDSpeakerDriverDescriptors_VENDORID -/// - AUDDSpeakerDriverDescriptors_PRODUCTID -/// - AUDDSpeakerDriverDescriptors_RELEASE - -/// Device vendor ID. -#define AUDDSpeakerDriverDescriptors_VENDORID 0x03EB -/// Device product ID. -#define AUDDSpeakerDriverDescriptors_PRODUCTID 0x6128 -/// Device release number in BCD format. -#define AUDDSpeakerDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Audio control header descriptor with one slave interface. -//------------------------------------------------------------------------------ -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// Header descriptor with 1 interface. -//------------------------------------------------------------------------------ -typedef struct { - - /// Header descriptor. - AUDHeaderDescriptor header; - /// Id of the first grouped interface - Speaker. - unsigned char bInterface0; - -} __attribute__ ((packed)) AUDHeaderDescriptor1; // GCC - -//------------------------------------------------------------------------------ -/// Feature unit descriptor with 3 channel controls (master, right, left). -//------------------------------------------------------------------------------ -typedef struct { - - /// Feature unit descriptor. - AUDFeatureUnitDescriptor feature; - /// Available controls for each channel. - unsigned char bmaControls[3]; - /// Index of a string descriptor for the feature unit. - unsigned char iFeature; - -} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC - -//------------------------------------------------------------------------------ -/// List of descriptors for detailling the audio control interface of a -/// device using a USB audio speaker driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Header descriptor (with one slave interface). - AUDHeaderDescriptor1 header; - /// Input terminal descriptor. - AUDInputTerminalDescriptor input; - /// Output terminal descriptor. - AUDOutputTerminalDescriptor output; - /// Feature unit descriptor. - AUDFeatureUnitDescriptor3 feature; - -} __attribute__ ((packed)) AUDDSpeakerDriverAudioControlDescriptors; // GCC - -//------------------------------------------------------------------------------ -/// Format type I descriptor with one discrete sampling frequency. -//------------------------------------------------------------------------------ -typedef struct { - - /// Format type I descriptor. - AUDFormatTypeOneDescriptor formatType; - /// Sampling frequency in Hz. - unsigned char tSamFreq[3]; - -} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC - -//------------------------------------------------------------------------------ -/// Holds a list of descriptors returned as part of the configuration of -/// a USB audio speaker device. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard configuration. - USBConfigurationDescriptor configuration; - /// Audio control interface. - USBInterfaceDescriptor control; - /// Descriptors for the audio control interface. - AUDDSpeakerDriverAudioControlDescriptors controlDescriptors; - //- AUDIO OUT - /// Streaming out interface descriptor (with no endpoint, required). - USBInterfaceDescriptor streamingOutNoIsochronous; - /// Streaming out interface descriptor. - USBInterfaceDescriptor streamingOut; - /// Audio class descriptor for the streaming out interface. - AUDStreamingInterfaceDescriptor streamingOutClass; - /// Stream format descriptor. - AUDFormatTypeOneDescriptor1 streamingOutFormatType; - /// Streaming out endpoint descriptor. - AUDEndpointDescriptor streamingOutEndpoint; - /// Audio class descriptor for the streaming out endpoint. - AUDDataEndpointDescriptor streamingOutDataEndpoint; - -} __attribute__ ((packed)) AUDDSpeakerDriverConfigurationDescriptors; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Device descriptor for a USB audio speaker driver. -const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - AUDDeviceDescriptor_CLASS, - AUDDeviceDescriptor_SUBCLASS, - AUDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - AUDDSpeakerDriverDescriptors_VENDORID, - AUDDSpeakerDriverDescriptors_PRODUCTID, - AUDDSpeakerDriverDescriptors_RELEASE, - 1, // Manufacturer string descriptor index - 2, // Product string descriptor index - 3, // Index of serial number string descriptor - 1 // One possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - AUDDeviceDescriptor_CLASS, - AUDDeviceDescriptor_SUBCLASS, - AUDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -#endif - -/// Configuration descriptors for a USB audio speaker driver. -const AUDDSpeakerDriverConfigurationDescriptors fsConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(AUDDSpeakerDriverConfigurationDescriptors), - 2, // This configuration has 2 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDSpeakerDriverAudioControlDescriptors), - 1 // One streaming interface - }, - AUDDSpeakerDriverDescriptors_STREAMING - }, - // Input terminal descriptor - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL, - AUDDSpeakerDriver_NUMCHANNELS, - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - AUDDSpeakerDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDSpeakerDriverDescriptors_FEATUREUNIT, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - } - }, - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDSpeakerDriver_NUMCHANNELS, - AUDDSpeakerDriver_BYTESPERSAMPLE, - AUDDSpeakerDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDSpeakerDriver_SAMPLERATE & 0xFF, - (AUDDSpeakerDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDSpeakerDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDSpeakerDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(AUDDSpeakerDriverDescriptors_DATAOUT), - AUDDSpeakerDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Configuration descriptors for a USB audio speaker driver. -const AUDDSpeakerDriverConfigurationDescriptors hsConfigurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(AUDDSpeakerDriverConfigurationDescriptors), - 2, // This configuration has 2 interfaces - 1, // This is configuration #1 - 0, // No string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDSpeakerDriverAudioControlDescriptors), - 1 // One streaming interface - }, - AUDDSpeakerDriverDescriptors_STREAMING - }, - // Input terminal descriptor - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL, - AUDDSpeakerDriver_NUMCHANNELS, - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - AUDDSpeakerDriverDescriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDDSpeakerDriverDescriptors_FEATUREUNIT, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - } - }, - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDDSpeakerDriverDescriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDDSpeakerDriverDescriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDDSpeakerDriver_NUMCHANNELS, - AUDDSpeakerDriver_BYTESPERSAMPLE, - AUDDSpeakerDriver_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDDSpeakerDriver_SAMPLERATE & 0xFF, - (AUDDSpeakerDriver_SAMPLERATE >> 8) & 0xFF, - (AUDDSpeakerDriver_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDDSpeakerDriverDescriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(AUDDSpeakerDriverDescriptors_DATAOUT), - AUDDSpeakerDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - } -}; -#endif // defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// String descriptor with the supported languages. -const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(15), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('k'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('a'), - USBStringDescriptor_UNICODE('k'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('r') -}; - -/// Product serial number. -const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors auddSpeakerDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &fsConfigurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &hsConfigurationDescriptors, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &hsConfigurationDescriptors, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &hsConfigurationDescriptors, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; - diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.h b/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.h deleted file mode 100644 index 7bc7352ee..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/AUDDSpeakerDriverDescriptors.h +++ /dev/null @@ -1,146 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Declaration of the descriptors required by a USB audio speaker driver. - - !!!Usage - - -# Initialize a USBDDriver instance using the - auddSpeakerDriverDescriptors list. -*/ - -#ifndef AUDDSPEAKERDRIVERDESCRIPTORS_H -#define AUDDSPEAKERDRIVERDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Endpoint Numbers" -/// -/// This page lists the endpoint number settings for USB Audio Speaker device. -/// -/// !Endpoints -/// - AUDDSpeakerDriverDescriptors_DATAOUT -/// - AUDDSpeakerDriverDescriptors_DATAIN -/// - AUDDSpeakerDriverDescriptors_FS_INTERVAL -/// - AUDDSpeakerDriverDescriptors_HS_INTERVAL -/// -/// \note for UDP, uses IN EPs that support double buffer; for UDPHS, uses -/// IN EPs that support DMA and High bandwidth. - -#if defined(at91sam7s) || defined(at91sam9xe) - /// Data out endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAOUT 0x01 - /// Data in endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAIN 0x02 -#elif defined(CHIP_USB_UDP) - /// Data out endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAOUT 0x04 - /// Data in endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAIN 0x05 -#else - /// Data out endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAOUT 0x05 - /// Data in endpoint number. - #define AUDDSpeakerDriverDescriptors_DATAIN 0x06 -#endif - -/// Endpoint polling interval 2^(x-1) * 125us -#define AUDDSpeakerDriverDescriptors_HS_INTERVAL 0x04 -/// Endpoint polling interval 2^(x-1) * ms -#define AUDDSpeakerDriverDescriptors_FS_INTERVAL 0x01 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Interface IDs" -/// -/// This page lists the interface numbers for USB Audio Speaker device. -/// -/// !Interfaces -/// - AUDDSpeakerDriverDescriptors_CONTROL -/// - AUDDSpeakerDriverDescriptors_STREAMING -/// - AUDDSpeakerDriverDescriptors_STREAMINGIN - -/// Audio control interface ID. -#define AUDDSpeakerDriverDescriptors_CONTROL 0 -/// Audio streaming interface ID (OUT, for playback). -#define AUDDSpeakerDriverDescriptors_STREAMING 1 -/// Audio streaming interface ID (IN, for record). -#define AUDDSpeakerDriverDescriptors_STREAMINGIN 2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "Audio Speaker Entity IDs" -/// -/// This page lists the entity IDs for USB Audio Speaker device. -/// -/// !Entities -/// - AUDDSpeakerDriverDescriptors_INPUTTERMINAL -/// - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL -/// - AUDDSpeakerDriverDescriptors_FEATUREUNIT -/// - AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC -/// - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC -/// - AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC - -/// Playback input terminal ID. -#define AUDDSpeakerDriverDescriptors_INPUTTERMINAL 0 -/// Playback output terminal ID. -#define AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL 1 -/// Playback feature unit ID. -#define AUDDSpeakerDriverDescriptors_FEATUREUNIT 2 -/// Record input terminal ID. -#define AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC 3 -/// Record output terminal ID. -#define AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC 4 -/// Record feature unit ID -#define AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC 5 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -extern const USBDDriverDescriptors auddSpeakerDriverDescriptors; - -#endif //#ifndef AUDDSPEAKERDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeaker.png b/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeaker.png deleted file mode 100644 index bcae3009ebab2b8a9a90690f58cb7f0401e70510..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3711 zcmeH}`9IYA9>)i1k)iAcF_yAq-;%M;FxH8PlwBbeHEJ}4I+l^4F_SEF42oo_t3n(H zBU$EauOu=U@|C4Yj1jWTb?!a)aUS>n3-^2;kI(!4dA%R6pPrA;=ka-^x?#{zA(#*Z z0)aX@piV*{e4L$g-(G>8%DHpp4g?|qadYvskiRg0IXErxMcZq|1||MK*y z*u4q|@Q=%+pk^5ogGKNeO3@i35OLBo%~!lqJ~ceMNJ#Gw$w#1}g*26Z`@{T@-`_qy zjaTI;@@ zH=mgt?%2j9%r*~;pm0~sYoTf#aIZ@<9+;tk(QhrK>|UK2$P29BzjY=ym{SWW|!Un5o z&wIxe!$$h12LnEBiK8rvcj>R1jxf$CSh-!77*-eSREtxQNb8_5IuHT29Tx#5qrSs_ z8%qz~pQrX3w_Jjnr5*0W#_$f^M}0%kh^VjPLn6n%#VTko<~n|YVWpN-_AtYtaEyKN z00Ld`KE0qF$skvUKjeS=K5jpL(wyH1O^WLtZb);>(-%tPjF)fwYEjVCdmTMI-7q*X`OIAyafs~YZ2j4i)_p6A#v8-Pa*K!R^ixPK22HOJAM!I{5VNbwy+wdv!F@v>Mi z26*qw3LkjIArdgJ@=o8}9wU2Hi30EDb@zVf_LHNYU&}TRIBGLsXa}%IW;{f>HYv&9Yrc zgPI#+KO`XRzbcJd#6~|pZOq^*$K+~kc5h%`bZ1EC3!05y02Hqm68TJ>d6w4Vg_c#+ zyp|%5UXU`-uvtWP0-JDIy?kKVRUOvw$)@(?JG8Q+FAMm&IUADgFj-_lMr0Taw|eQ- z6Wt@nPDZmK;44r{DJp|utaN*Bad;O#4)#1Z_LV{*dZE=&zrpAuiX_u}Q5vM*(zF*^ zAN5TC?Ome~P;GOJgppq)Nt8<0yR>4`-UL=1#3Fu{x8D}ZM*H_H%pl}H%5l!r7TSue z%IH`MW9 zcGU>r9&m{FKF9W^fX>@um&cJnB7}2HN|#>5m{$40VW-1c{&o9?I&Eo0--8?S>j28I zN?PAW+r9K>wCs|fK4*@La*>HO0&NJfn$pNfKyr3#1&gGg{!^NIHRAL^!+IGkvJWIC zJ)ul>lBOuU%iw@j?D~~(A-tF7Z+K0tui9nyJUPcXlSS2==< z>s+&!5g6<`?(jMIK6eDVdBe{^6;wu6rG7|Oo#%>UN%XXjsqW+qy*c)5ExD{e18DG& zcTKw!+e0OFZ$07)s?Jxz3o!xK_jMZVyDf6TvRnNCIxeW-vyYNvhTLH$TrnmY5o1Ub zs8&^o)J8*(j9^~EB7ovuJF1yYi0u%c_gp|pJrm>Boeu$6nW`Mzf5Km!Q&BgI%B$8RY+9t^nRLH-(&(cwoWz%2h1ehC7NcYjwY!^U zAEq1L6!sUkOD4Wg=@y|rk#+@__0%=WZ2MT1t16K(rbt|Eqs(t@O`Lt+q!QkhvDV}CK=)C)zYt76}@((Us{tw zqAA5+JM3#h7Yf#n=SwO#VM-;ppQgS!WnjuVP$Pry8Z=fBBQi08S%;j(f-RE92V|{9 z0ussoCVoPMJWpK)S-@07;gsRpSs;pXS9?#GBs(2(c=34jhX=LA7K8#44cEFN1@J6W zMe4-nE}Y-mvvaMxv$(`?Nvk`w+$Zn=9prXkXY!_LeGT8z(<9P0;vh9O`kmDENJgxM5V9KkZjyhRp0Za8%O8a$;TM@jL85qKhd>G|8$&^WUi?Als5cY0X|cedtx zDN|^jY$`suPkNU{F8OuzK_!!_=tHL&v#Y7XR{Eie=DivNm55)_mN>WDXU7CRSA>Tc zMqj41Ji`v=SEfX7jPoC|ZmcFhR&3OMzx%t_y9!cp(aUz`$OP0W!cJ%Q`_I4};-?9V z3pec&9e$U*@yO(cTv4b+PD~+dto`YyRTjR&$KpF8t|6j>Tz5pIMfj6OME|U3f`3J^ zJNOFg&?BemR-9LKjXn1fWs)fqm!QfO90O#ygJ|}MLN?QR$un6 zQP?a^#6I46^?)oEsS|3Xi|kW&1wwuhV(kf=E1#cbcYLl=v2uBqRcAj6xH7xR%MR|^ zFzg|X3OnTg#7*VZs;=^XXG@~yYw~j0_d2b1s{B$@5R+W(;4Zim1vDxkI$-zN@^3#X mD1MI>{))JBR^XFXuI?D??t#Nan}nSd4RN%?pek(x6aEQlu)81t diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerDescriptors.png b/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerDescriptors.png deleted file mode 100644 index 251a2d1c579e1a501493ea4eef7b68b6fd552cb8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8026 zcmeHsc{o-7_wPP~c`9QAP9;-9WQ<5c2$_@V6CXL~a7>vwNTuR@P)>%-hg1kBf{0eLmmk`+V=c&+k6>x&PkZe%9X4d++yqt@ra@@3mfQ?e~hmZfd~A zevBOe04~F;S1bSkMg;(PJS&3n#lQOTB>+GG*RNUW9UL6Y&(9NyM80AaxJijGxq=JJb#)Hg4=<9uF_55(#RUzA!P zugpl^`(rCh9YZ*EG92EUHyeda>pMWlaL4^=jJ5?tX$fa)taU}StDLf2dWD{(-~$TtW{y5_JN~TPO+bHfp2DhDx7lnJidv~^ zb&|iS+f(%ywV?AkF#2DT5w82!2RMK_LBhJi|0YkSM1^p3Y4l{9aqcWUnq3K{wzq4> zxd*d4Ee?vow$GWcWI)KozzN4B6? z=XkE~V=qq*NhNRJPNXR)TNV$pMeHCuk=(<4N*j)^{WVqOvZ|$H#}xmW`~TtT0#EdK z^!gzS&2etJ;{GwF|4{Y6b*{v%meuf*A9uVTloKH2% z?gd@pul~8cd<@4nO?uBkwByDMn^l26WDlcG9~pyFo=Z!!4~XkSiz*TQLICZwwf-WH z?5J^w12RY&7M|$2@?mW5Np0fw9}hpPY%9=7n8@~Xgn31kU(DhkX$2*u_bP6j3h^7g z-(UKa!ZOW+Q@yVN{~K9@k|s(lSpD3%<9xV(k)>+YvAvK9(vHfa-ru6Zb^L zy6^f8-GF2UKned_p1wg+RPwChT|PMWa7W4y2_$qXRq~q&E2wwYtRmwO?(vPRKUGfx zLgkum-j@M6myqPKdw|2o_0#oiu$qUz881BYJ3HLF=KnadF7{(`M1OaWEwGK_`1)KH zm~i6OROEz4I$E&+<@*W|D9x8B!h`RU{MducmmL@jc^AMUZze5`y=!%eGSzM z+*;1kNhbkY1pUDX@nU5DM*hfAZ=;0p6rko5WDn5M&9|5X90Z+`FN;l_21+H-k8uy& zvyRs}Amj8K4FQMqRAY{^)xJO^rfwe>5Uidxx+k(1I5_`yc}mg8e{<>R$SWe9Nx! znx;%pg1bFvlF}wfy4nC1V@tqj)Q}DdS!ZeVryXdv@({!AZ4`mok}X z`^|g4N%b5PKHMupgy0R+uT6ZG68JMkXzkdnXv>NRb@lvXY-XU(dY!Br2X-!J`AxjB z&v7gBfg?>jY2zAYyw8LNGJ_5q-dzmP{W*F)cz`8xikDeA-TSKjeL-Y#w; zRH_>0J=;-8*Pga#-in_RD>m-cKIwYGI`9@(-(>la>4h(Bnw>rX^$K2+T{FZ78zdbn zIfGl}>{h8HdSMMA^Y&((WEWVX~NG3%$I#G5`?rMhde8|~4~t+DmS2YpR=zt7Bag-`9&q1Hf=#Qtr93$`gz z+D8a_Z@rQjIz$iAO-WC2SQ=gP<$|Qy?k=7peoFtu!)4~ai-I}8`dDfUJFoKtQJ)tb z)2yVAJ=n2@6;PQ+?b)-_>I69`E;oO)gl>aUa;82e9h3^UigX^iWqTxnK9 z*4P~vF)&z|_b1`oW|?pY#T$3$+Vop{4;$@%ep>AZX;0{uQ!eV-^`uhMx@Ujlc!KR7 z-GvyiFynHMowtiFX%1Ek3rq?=ZNl;-)ZargOX~?tv9tZiz`wN){BqhM-B9 z^Izejfp%|9f z38!AU5ZUoVT}24?4}?j<|G}_-i@<6cQ`j9tPl-_6wuCd7p!fiK>No#8a(|CgrZmf3 zCW-iXG|s^&XeXURBop(x6MC2fbwd>i-S^b>js3ZYpONENBQ(Xj&)|L zwk$le>Dh8jTtnWA)<=i=qfmD{Q92`5ZuV+PX3MmMPa6IcN4?3K0Ntzun1DkDGThw- z(-qX@OzEup03;^w6-+eC&wIh|aAtNPEc@s4Th*cw4uUjd+)&V>S!$Y+Q1EG4oe>O? zez(8z-cVJXP6kCibnVdzI??f}XpNEH z)CuqkbThUptwGeg&m!t_A-BBYs)kv9tB&3)bQ@c_kf0>MXK2 zp$uw=4osPf(x*TJBnFT>4NxBCn!ZX*mAI9Zn$rnT_jZqJ>#K<|Uub&XVfRgvR-4}@ z=IPyG!{l_B#N_;q*hNwQ7piFS6Xi}dbo_aVuu zKf`m(SM#3sJL<(sv>NN9itev@vK|fBlfmuCz0ph!N<*Uxv~6IPKIHq0bCj-2*mh76hSwDK~*!VYv}ox z;}KVT^zA?IX_g7o0yU}YpR1{|Nje$&40MYu80d1t@zq8-^*Ou$c;K{uGN|dOw;ni_ z3;AIyH@o7)ecR;{m?I~MGQjV3^&4!=a}RujNincDqDH7BiLz6}>Ky^``kB~EQ;U!B z5oMAFb1;Pf{Uk>R_?UqqeaA?h{5b7DZyl|Xi6WVxtWO{@wy@xRVSqAd_`WyY?wOsh zAn7behmL)c|Lbb18iVgJ>D_I`j0#C0>XQpUw#wZ51lD#RouT#W66^EdZ-+`+D;o%{6{)ozecY!zztQh1b+>@e{>Ge(u=`?01op!$Jd zWUoTzmZ*Hp*p2gbF)EKdwhxCI^yrr=n!Zy-T35S$9IbJNX)3h;v`Tm-_u_`HbEUH) z+W3jzMeBSvHLhk^&P*Bfigr*7~ zNvN8Z?IfhiiGXnhOtktTQN5nK0=SOnHVB7Ri>F>Uq@Jbba54H=)I>`jq2I55Kv`L? zpfyZ=5OS*1v*xlZtVqnBt$XF-f*8)YYV-Jq7!`niQ_?T}kKkI5b~8AYB_%c5Y^i-3 zel?vmN<;*ENtnMlSWJmrGyS#NApPs=c%B*}x_;fjUZFu8?cZTVv^ipGVH8og8U=KD z=_*jG-gO=#U3@NF!#}I@V<870H6(zZ{@DTx&ulY)+?n-}eNei9we%1ci783@_)Ii* zgh1d*%{_ezf0n2SP+<~Gxcbx|2%h0U;Y73VeQrz63%+$$J$Ltc6Bp9!Hfu})vQqcU zF8pCS8Kq6&+>TMH-uxl|e50GvfJd=A+_0D+#Ocq9mb7c)5mc6Z3os+yE7pd6Sc2M8 z84x8S3%K`O(8>5q=Nhi2EM?taX8v1(b((*x0pR0-UJAVv3cr%%FTe3siMmxDW{pn> zS_H;l298a1pfJv}TA=}>1sGtnpEu; zI=c1!kI#SX4@!R3Kmdx;k&lg%Boo~Q(pM3 z;Ik*2LAy~t=dggPR|fRDvDHmjE2_1`9ysQHVocGaQ^e}|YV=!uKz zHP>L5;oC&UHp+tTa$0qlo{nqbc|g9xrS9i#^{=z|nK1pqODv|C1PwdC4v@e${E+B- zU{qRY95s(QYTVPJp5Rl`)GSCvkymPoo6UkUW?%{@<>z12z8wHV7wweq-af6 z)nvy|9@%y5b2{_*VUjf7NKw3clvs^$??Zkl{Kqd$XxtXlE|sVQo&{Lu(EXNo24f?N z1wt7Dgekd(Gw3CR=_C&@uUza?&dB>%hi{&bm)Qg7-#R*B0={L20JQ5VzXUU03=zf9 zGM(pnMmd_a_O&0Cvbur>nl^@M@mgmb?xd1s^!RJu+{3lnuplu3jl@!q@^6rA&??jZ z`a6S>VXp>3_F*eTx4Q)#{$-$vV@Ps25Ut=+`aG~W9N}oDILa}4&)jJidSpG z@;=oPLhc-+DQ@&t9z)QdtssK)2Lq$zqev0YT3LrzmXM&vsQY7`kTLn<6n(rqn~wdv zU(rGi={m`UUTMv){oqbaRo+ez|K5JUe}*zKYjcB!{7Q18Qhos|Cy zt>z3h3L%)WyheMTKW#SoNUr?~2hX>ui;)k&Dp(iXDg3@K-GSIV}wU3i=p|fo(09hsnW^v zto}VMcg+#BKOUneEtSenunrfpf+I)>o+<_*Oxe%39o+E@SC=xLYMjq7)cp``qKhX`%)q|NLt}mYSx-b%; zpPuE6=p6R$2sK=y_|bgdrN4cA5}kexP9>r#W-4;dKUggr__0HhdSPG;D{DKUX}Zg^ z9_cf%pgBC|) zhwAuGVIBa8M2kSZCo*A;oh+i_aH>H^kgFOl$Ws~$D#(sD5JA=j1g1{s??$NYO_hsD z)FUyG$yC#bgF~6;az<6>f#5)n)vL`iz$(e%2uYmJBt*=zLmlXXhd(+*;wpbr7$XO# zo@69sJ$eg$4{q34>IlJThdMmZESzGn(A#rlwOBxBZpJ@%iJP)OK<{^OUfNkMt*>g} zMu&PR&g6C+B#|ppvJ>zcmAb3UrsI?;zP5vsiW}B#CQO(lW_Y)FFtgUW z?{jJBvd+l%!!VaCyBrR#`agxf27leQ3lHukpvO5WG&7rOIYcm_J6ot^UNx`6?M zGrB*MgLj-P?n?>}Sz*29x+`4p{q^;m(>Y7Si|i}tM8d~$fvKBsvI&$1SmX_i)Rt5l zJj;7n+UkArqE3S_%@GD8@BA2z=6H}HdO_{|i^ztvF6nsib^T`UH79O5E1~OUN1Vg0 zg4sCxQkJbQiB(r>TgPc7eu?5UTQboGcWtBk2Cd+hj=$=0)h7Jsm^AyQz!4>u8iF)9MgFf#h!oZ*ph+nzxQIB*xPWbd+U%D zzC)YhZn<@OnCRt4b^!L-TRWP$=|evE!gy~h2P2@fk^Pc$J67kzm02MC_w2$<_&%v< zC77b>Q3TK%z0c4KCk{wKvlHCofg6<0wT+A!MI){I$Uh z+R?Y9v|tB7O-&0Dg93(L-7>#`TjCGvshW7uFE6U$QeoUPCuuldTp5~jmmOSPDjf33 zZHG|}+B9#@)~|)WwY2pEoX32CD1O|wx@p+ybq9`b^TsoM!P!P;iT-Uxi@rOX_VFL1 zA5@Ec%M&=Aw|hEG_h@YKSkSoDPKjQh&d6feVQQk%&+0Nj4#*_0@=Qg370ER=I=KB) z7!}j+7?k`L8!7EO=eM&pHJ!LcBkz{z_c?|lHGe*hC%>W?`q8o9nDE3d$Lj9#L=Lev zHJNMc4ZNY@<9jywZD7OJrn)LhyEod?=fUJ6u**>YHo5n^YM_!g<8bJAkofK~3N$(q zOobzM%>Bp%MQuJF`SE4H${f~kdt&x}|&P!ySk^0T{ zR{(b8KWai|WpCISMj7g64Fo$;M#kf!yw|!vX#>^b|EJQy|5Q~dJizG|ZbrQ>rP?gm T(+e2|LcmbZ^h)XFKVtp|xl7dB diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorder.png b/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorder.png deleted file mode 100644 index ddbd2349a649ab367f1bcb74694c3da44aba551c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5053 zcmeHLhf~wt(heOGl8E#sD$*2!N|RtHiKqyK_5vb=j+9UoLkmV~f(QaCMUVhNLwPCE zlwK4IC?yaS5dl%kk0JpL#UOI=y>q|s`yal0X7PDB$*xotHr3qS9qP+NJX^Kko>tPYXjNA-z5+R1 zwmvwJv&Q-So;YNlw=~nKtI|5s^7Wk3UHrJ>|@DK?v zGy9u}xE;qZs-n^!%1n@@eP==G+$Z&{)bj?HRa*p?sBAIIswo4{ z`N47y-Cfh=9e80Z%HZp15PaqI!oMYQV@JDO6!VBtRpB5E#F?GffTJv!ZPMJ)A4)Qi zvHiBd%L}?NA~4o^eC?@;Eg%Ni-%|$6EJFe&Wf#;4OGK|~%k>?t4-exZ3ePSRJw3XG zw~4=(56oOPAu!?|Jy`*_7d0#8A0ywOiE+sPj=M~ea}11g_)p~a(f{P)kAdqg4linx zKifb`AvUspco zY{#;McOu@f0zHK$05+@%@2|7?meC6UY4p-bN1Ux8;lSw-$Nqzx{2fu^1#h=fzVpZL zYUD-GE~@vC+%!?>91 zUs72nDu{H-fy*3(aFq)fH>LGN6ayCD;POwh=N^=QvJ)M701(W{JmkGNoa@0-(sq%c2_O%!4H`z#;y!x|t`*iJCVU6C_o4@U=Je$q9o=x0TTX55zcrz_d(0bK(Qkedi+<;7X+<(f9LTM1A4i) z_EFwh{cLMzw2w<-Bm*a|>7d@uL4U047*m=gj5o7Bws>D3q0%D!o1*2mkpx+j2zTKv z?3<(23kQSj;#@Trya6vII5h$b-;BI+KO7_AZ?N;U~fBw|?=3xr&E8$HhwCt+8juSj02x9OBK? z$Z<5=@vygILWWL;`W$!{mWcS&3q~5>5HnR~3hJBR`hBJ1pQjI~y6X`ZU}xx@uE&GzLMq99+dn&=_)$u72rh@ZO`n zkRP*)aVKe5+^`-c#n)PCS1ekJHP21ZM{nF+shhM41b_mbk<-J66{Zd);BVr0;~T!F z<;xm|%TDo_(F|&L=8fS2&f+bz=-2JjkpttYqBKmx}9G)+8ey;)_ZPepEB|P{)nM+*$@(uPkGSDx|q zT(K^MMNVytc!~kiC#)V?-TO5dW&KNXg&us6nB3)UCP&JKZ9#JsXKsyL+_+aHnbCr=u znhM&Aa(ao$93FENwF7Rp6v^tX{=^&M6lJtaUU9!&ojw>*0R57?5h0^SDCPw0eeWF| z3LXOBi+L7_$6dEmW6>&qOB3gwEuJPk&_DfU?GA`o?|7~&9J!D9riL4(a0q4(FdJaR z+Nh9?3pCMpP0`&+*SqQstr`(E1h+Q(nlZ{+TW@8Z`mj6juJu&fN1L0WFDtT0<^1sO z%Z}-b3;V^h=odFM8a$uRE-^HzSDGUN#E)%D+)X^-CY;r02$ffh_RxyKw)rlB0AlN3 z{RsT=D65<3q@2z$^VOfwA@fY5sT5>_nH;j8^nLp3Eh)Y?t`o_7fK-d&vT?1Ya5`mR zZD;Xy-k0^Q$)ktF>)ZrL4HUF9_t!l*>d4V12F&Nd4ZxU zka9|CTNFonz5VQP&Lh7_1flx18x5sGUy@mH@k6I?CQ6#Eq5aehiG7yO|MPbx~O(8p3W8 z8E`ADA6U?Mu5X&%PX)EXPuM1YGLKXK)zw$XxHS72f0*5{=ARTSsQdLyFHVg3#B>Jl z3+Rk_KF~8U+`JWY4*hte*7!PBG3y4ad_mUuT;Q$o2r_n}lrTykT&OdMS3LgJ1alcebVh3`I(pzix^pZi|odJlvt;J3KChP9h60qO!f-)Q{(YfEtn zE3Hg0)x)?ktrcXIb2zfIT*&$IrqHY1)xLNk$rR&Ff1Sc&=VeXG%AJziHA2fI5`B~% zdRK^mwtOsJ@$$C}(0iRISPVv8>^`}@Nf`K*D}!*i`(l{^i4Je9h<@xK5Md3CNDmJ3 zOsN?YPaFu9Hm^D`;+Ky0o$E>Y#8MbL1!+IyOl!m|0?L#Xexl`-2LZ!(AS?s$`+va1-!vV*Di6^s0&TJz!T`>3sc&((f@hMOBuH=_tJT1Sb!|^3 zGsg1_htgcGS?ziQpY7hx%7?o zRgEIAEig?06JxK&`_n0?&M7gyNsfsjZM05HDO z@&&nw$lM$2;%!8mlP=r%8m|UHOH`Lid>o&mKyiLXbX=PYi;M|{JUQ;>a>a8! zs5k3^L9mI~m?Qd+^h4sXy?+3C&`yX`u4FpJxQy`?nAMLUBZ?$|rvBJD(gAk!>%KXL zg6yI`^|)#`sF^XwNzF;}ztTeV zZI>`isemPm%B7BhW9@1tTen0A(Ohg=ZOsglnSxiB=E!#P%BP)B+anpgwkAbMvd?^L zqhh-A#rFJDlM^+0`B;29@AY;%jQHb?&#g$#LV0)H0w;6#ubZe-J-B_7;3jU1-M<;r z>hb8QuH-S!K;ql@9-iUc!{m-Q(Rw;V?@Dnt!pHWuA#3B_o`ulaH_g|D^|t8@^2qF4 z7s{Ipu+ZOxn;u23Mo+EM2(H{`BD)^ z5#!tmrCO73WKEuv7w2dkPOF=zGX^sk+<%jWa%5)(vhz0RXd}DN{!g?97QpRpEFWSw zx#i!iUX886-Vu@{7o4XRs#7m%oTr(a;xqUB|L6MuP5`d@6f=D2jDKiv*)C`Ul6OSh TH2Kut3<6|kiak?}c8~uT@CZgZ diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorderDescriptors.png b/src/ersky9x/libraries/usb/device/audio-speaker/USBAudioSpeakerRecorderDescriptors.png deleted file mode 100644 index c5c3324024f0334b9d42fa6befe9142b4ea6378a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10906 zcmeHtXH-*Bmo~iyqy&sqV7wK&-zVpt!Kjxcn&F>l3%3YUpZ}vGkXP;+3&p!LHzTR~%4j~RYIyx?G zt*ZufbPNFadC0~Hwgk8RvZkYBq|?_mLLVF)$7`nnfubw9kDz7&=+Xr-=?EGPN#kKiqYMt^Vys=g|E4z7Txv_ZY{tz=1d6bTE`w*LYx7co2;0@!MOxnWC`69}fAY0huc%4_J15^MjP@&12) z&OaY>!MNvvW9%dTLH%ckZ^&iKNkqOqoCH1{OgOy%8oNj}67* z%#bj1kNncgvwqu5;BDLlsneF15xm=!JMv#H{NcDcU^Dx}+_3!$aP|MgBMu+jh3UMM zs2l3`V;R0VQw-nR+uMp=@pW_6xY@GwBBF^ZnLC(heB0r!!LQx|{$p}d^X2e19*X&c zuc>!%TCQxwSU=grh1aVDS2ywOmvT5!38?6E=VIrA6Verd!#ALZZ}h~;%Q78apT)?1 zKI>?4R|oq4^wfVY?V%&fLOzB@*GvqgoD{t&ClN(!$aAQ5>{V=KAPanFL?P%=S?Ccq zPKfEFBamDsh=-uZNhzci{1TGT#|7-8zEfS!y0~cU-?%kfCAhn}XqUTB{>A~*xjp$6 z`CdOOteO$$7^l@W(+&fcuN$F8EX2sm^wFF!4rp=l9`c>2Fa?c#NVEUXE~(H&uw9Uw z61%?GF+slBO?XvXb>Gxn3uA;7A4l6Z_bJtI-(f>XTJT6XATPPXTD_cQ?8zl8n%S{bRJ75q zBxv?p-WiG_74BboK|6ox=&(DNrKtMG+8d;9TtkC-WBJa#5pB%(HYv zUtXJo-ZlVb`%2C7S|bUq#-0br>{h%y=v7n110}a~ZDEKVYIAWooJmD#11+J1gXw(g;1u2A_;j%r;JeZxvc01Wwyt zq0SSc7u)I_$jgat*t`4@axr2{r@eGqPDDYcDhDH)yp3v&y(n*OlPx!1xlLJ^mcmBr zrKXN-?QF*5;A2$*8Tmvf^7H^bLGL* z%ji27l5ysrZ)l=rrJ%{xfwK?a?LGM&z9%@n^8KUsTwH77FU>-Fl-CuOH=~$>D7&)F zg@Wgr=)LoI(k5EY_TlZ!TIT9qG3_?BlOS5A%_wNLM9*w-&&lrk7!c@+`2c7!j-H(5 zMBvU}d_5UA?}cA`5~T*A+898{-|@$SYs#G5a#*-cD9CRk!V$Eh=cxqzq{Pc_5)eG8rsifyfmrmZq_95$#|q74tEXq4iTxRP zs}j8bZLuP7t82)Tmu$D(RZQ#b44g_n0P1C3DnG2l1oni_G%)H$mMscF3YT}a# zJ z?X84y=>DMoa87kOd~Kw%2VwY2^Mz8Vh75m7t-3=o+#lu2fSL)!NHzLonuVwYpOl;O zO!6vSgAx!B*2~HoXx=IpIm0vb!GW-Ic@q7>66&eqx)oj5+``ojVac7cUlZ)6Vd*T2 zkrQ-rU7!5Bhbjpqwymsj#OE@g=PF*VH7B>6nAkJ~>#GHN7y#7Vu~vP`gde11tzBAk zQZDn`$$JhrV3f^Z3ZdghD|!fp>|IwH*Fm7o+a^$XQhb^v1v#6HuVuT;6@X;B_8AwX z)oVw7A1X&Vb7h|ZiHME#qWouM9t5R7`R03t z9t0!#)#VY|1cFau=dp;@yxL0(ow{rQA2$~t)1 z0rk(KTSP?Drj@x1dVQ{A?SY!R? zro*#Sllc-c_IGPy#|I8*EPlm2Qk^HEY0J&WQjcmp`i#h54-xjWoIZ7J{lZ)I6PW_c zz}4k*aA4o_-27QeLql9~w4J@o`yShXH_3IdA?mMnq=QM75*og}f1va8Q%Bi3!@L)g zZ-=DkQV>nw%yh>I55p3;-n|k8Km?NJ4huvb3FNtFT{A7?a!b}Qk81l6&kV7Sis_O# zeWDrp>k+=;YhBbp82Z2Km% zDMR;-=Bnd^IxGTVX~B)GPQ_4;55x6Q=M7ioL(2^CcGz3|sO>+^*Ohj&tt$6-Y~Mu) zw)a#s2*Ab{TQL_Sp(1=N7!uZi;0Ow9$(p>?Xzl(U z*%TYkcu}2rWqQT8W%^(?k~K!c6UOt{ zV)Q<2Evd3+m(^LIR`&fXr?J1zjn?X3NhVu8Udhc(C;hsih|WC6E7=BhDmiouY_hfD zjmZmBb$vH5X)TEjx>tnbxr8UZVu>H2=;OPKSThMB7@i%b>JdvUM7o%-cgS31H!dy< zWd*M7!O@urM~WvJtBmO+WGm`n&RvQTMG|Ceb>G4`Aj;RUkDyLL5KeTA0xqtvUEiMV zS@uWag$p?Ah7pYTuC59R7|_|IfzJIdUua`E-8W*8}1uo#GQ>22ifOnykh< z=P6C5=ckxb0vD|3Phi^i2iIBbIz4}{M*Wz+BPjx67t8GEjq&lBbEQiq0ZA|I!?@Px zoGE|O>4y7LKZ*+*yi2bY6mt7Vr_f$6svHoi6tHt_v`Z&Xm!>z9aNFHoYm7%o50jh| zJKw_w^f#q^=W8>adQk7y!nX6b?zwdCC zuZ+joR32?t16y9_>loyN;eVv2$T=m?#aU-Y1y;wrJoSU>iq|yY`LsaLE`UQQP}_2A z&3$)!3Avn#L{e2wf%MUHjrNrJs^OEX8tJ26Y@BuAYN>H z^}1)gW!&z#FwBCRC~EWEunZAy_l(5Miv=bn=NQRCH|ckUq(rZ|C#~U$TY$Z5FI+mf+9@FcZhA(P z0cE)!P7{)5$(N{{rzblfWgvgG5gvNNk`fU7`g^{FmAT&|Xj_JQl4z;i@AEV=#!fmt>^HNG6RRjT?Bbcm}OpR#j}gMlX@%h_^N^x|ORse29}K%TJodJaZk(W9sO zc|yT%r3NJ}N&^Y^YYI>)2o83I$Rj4sLy{Ip4-Lk^l8sQCSf}KMiom~J4k9=eB0C8K zKCUav7p=v84eZ8;1p^Hnoird{#2rU=;EEkMJ_4rUucG1nkx5^%VM7wxn62AUJ6^wrRrfZhDC z@iXs(&R5glR}|U-spy%^3bClP3r=p)-bv+fDsg*|2iC6kcrQpQnpR0Z20O?4qqz88 zf|+=SW~LmK7@BvH6LkZ@p`aK!>qya!R<`3WwO)ehuN`V`{5mR=b zFzR@D#7yElbr2Ni8BwMnK3$4~C`~sT=m+98_ai;`KbijU%8Q|KBPb^_ zV0nmr)?_;HF}TH>%N!S%uXE6tr>YAB-txEU_t<5(*^+yV zYrDoH#;|AE=U%X9Ry-vKK;kal+LAhDDqYjs5{aYM>%={Lrf^F9Vs=yD-G)ySSF9|J z0$jHBGBF(MGIml7SH-5q2#{MaGB8n~sS_38U>|EQ|H`_?yceP9h_z0RtHMM505 zv-a`E{iq;ZNA>2uulH3S;p|4pI>%{^$h&^$7qqCfcn5NK+>cE0rq1*rQze2TwDfJZ ze67L{x2Gsy7)LBuuxDymzkEj3(CQIiookmvzfesFJfz;ed1%v{7*n0H(k`UXW0%^N zYk`_^V~gP694yrMT7Tcv?3mB?y%JR61R`(@q4C-qdAodIceYq?(p{3z_UFd{R|Uf} z2)50)q8L$e|DjTmN%o))qZDmbxCSX>% z>XF@sI)%((S!ud%V+TURO=k+@0)+d4i+bY>rqa&{k-REH#yiom#VP1t-?JIEnU?l-vfX zn{3j{CZB>!wr}}>RPIz+N0HUN@`u{<*HYGbrwz>+QEB8jSwDEhhsnQCLYG6b?)PkS z!?*er&Yr)`dZYl0xKse3~~KIbNKu5OcI&ZxO?yFh$jJhA>o4j*9AI#`AtgRumv2dMwq zIJ11nA>NJefVo~F$iJ|N6JGT+*aAq(qk6by@U)>{*5OHkM?*AH>fWGmo#%r!Ag2uo zxI3f`9ZT{f75_uFk_f^;q;Bomf>AODuv@x%n5 zF(mx7oLVi?-RAqD7YEZRDj-fF=NgSeztO{n^*Mp4J}6RTLb&N!`YTS@9i6O;cr5ND zq;BY|+f!=Rl$J*xfjB9#1dvhc)kd-fehpv1x7>yzi)1(kiDl;?!g$UpPU`_jQGVa?v& z&F;QeKGh}6L4cv!-`{>WhyYO^Io3mk$@J6A z;wVt<$Sr!TQ#pVk0drV;ni*_e0p1n|o{a>-Or(5W&iuN#wG!VBObqSoQ#@cLr))5f z1yI2cG)jNI((tMuZl1Hixlr)Xv?nbas}*krm=uJ_C8X^y4{6BaD56`JIz8%USRS&! z5nETO&~M~`?=vQmq;e%zkww~=pKf>aE}FhU8XdSRwj%4lbHfy^)>W+^t`7{|axm>r zoE!Ac7Vgq^q&p7w>)j?<&`Zg*kL?8375ew3Dr1BzkCRT;>`P^V#-$yvj+%Co~F zX1h+~Mv!UtOgV?FALZjmtZce8qV*TVO3uM5z_oM$E$~7UZY}36oxZ>S89X?ksIK?R z&V_F7LLkf?dK;_Lb`mOz?_!4hRueT-Pf9eZ&-GG6C-!!xKkwOex%}1L?yV5Vrn-+A3 zWUv2lxJJWa@3M4{nKqW*SBkQmy}ufTj745}1P>nKaq^U!(0{avH_$;8{TUcSe3oUo z82xBqa7pBRUv){7qcXr^NVuz1ZT-ht39Y@5WosD`*Mye6+j{L=`-&I27>?%o>QyHT zl(fcmu@r2yue5`d?@~L+bV&t1XRVq4A-74qZcSeMiy`^lHiAWGMam_BC{eqdKnhq8yUlD6yX-NJ+E75*{pvJq`9MuA{I;# zComldUO{qG(%N#>jB@so?-dXkVlUkq5=cIuVF^-nDaK+Nh^=~T!_%wS^EKzWB?xv659`>`&?blyK#ItXihhPBA4E^2;w;F zUJztQSW^JP{HgQ;iJ6~k?+*S%VBKzhYl~xTzw9Wny5=#_HKl?V7y?+14F5_f8} z*9IX?1+Jo!b3byhk#M5n#~74O*^;!uB`$uXaQUo4>Kg8x%yj zCN+EOf{Iw}P=&U5@Ay-iy<5CNb&upaXzk(@(5+&ESb|d~O>#y$QasSF^CgC%3k1?} z!?YMSh!YsDh@p7WP2!Aa-?2O0a|BkEQ5cyW1o**%xLdYVSWh8DB`;6HL1d*=>8Z45 zR2_G4zrKdv?-s{+Kv_O$XqJpF2g7YjZ(oQ0-YgxqmI2_9V9GC>oG2@n=gC zShMX}epYtKN7+B;yxoLVXdH>)UXu;6YHGVy4l>Exx2#&ov7>4u+yaiFk>bzkKvvDy#@$WyzZu^olf!R`dH_8w)R`Ayv3&n^9LQzm zvR7zPyXNDwT|M@&c87TTFX(`bdpK7zkp~D>C_dcBE(xtQx%joM*WOAe3>9f*N@$`3 zG~_R21PvRJr{!qRPws!ZqIFBe{UL9&zo7n9=)ko=S~&h-VPf- z6;e#o6GZWIEA7iI_Uc46xMtY#qDpjCM`5TssMES0MfgyLf{t&0*8LqlvVoMuZ#_BL zJrpmy@Z;8?ZeZ=<7N}Tf*-=``USW#X!ep#FRzkcQH6r0%QO%3|_dFbNLb}8AuQ*^OwD0L^PFD9l+S_FEC2F^aV`FUFk$#7o zmKt(e_Y0-*WCwlF9UN(!!JGymf+6lfeO1f{Mwm&_^jtqkoI4_;afY!i4XLJ_)&a zq()B(OlMRJf0=u!m(-02|5|)rb#&9t>E`kupmE;hYjdK%0ELQmJ&V3AzFm@xs1#kf zFy(oyLmzztlr4h(n-^eD9uH{z`4aHnIO1?8BqbU74(6T&PdT_b>iwAfJz{C0%V$K* zCUbKTHz2*4yb+Hr-aSBX-n5lrz}Umo*rE<-EZRoc9pXjvM6^~p5(w5%ut znb~o9W;VJ@DTDg~jiKW1S~bt%X%;V%Ac%DDIm{&aiUx3iXD~1w@FeC?TBp}t(nk$Q zsy^dkgWSBXZ|aq&n~<=5@<8B=J3YkZupz&jocQ_;PwQc@oM~SgX~{|W=6`FfA*cC9 z@7v~{P$vJi8bHh1=1>mq$T6B=dkDO3^=nW8Y+621AYb$z=NUG`3(-ikLVi zT4@NiS>E1Ohp1(hx1eIcQS)l>Lp)ORH6l}cMEv4+D z9y&efSjtPLKA-*_yt5;-{@V)fJCMHfv9(y-kssBY#k_{q8b7F>tv|XZ<~HCCmN6ad zpDZ<}IfttA*5DMe1;^Jrtc$!m@P19M2uKX%qO?>oQjqL3d1{T<%q4$!Fa1;C0+Kk3 zAs+1c>N-HE#$(?dzBuliZ<-shuejxc$KKD94`i5Esae+6oHpY+o>#){s#NMmiq5Rs zF6dd77IFkTNTiT@svmjom*m%9gS~Crm%7)%-1yts$C^1N%^vb1YrpNLz!uIb<Vqs{18OJ~@129=71ndtkeZGdKYk%6%Fz`dcZ;`Id5;C?vlvnrlLp3^2;i7Qq zCU@9Ty&q%p3JG@aF#1JJedmD=`(ZJZXLAR1s!`#OU=!ImV#74?EW`^(HcTeuL9{6P+=fJB+<3l6m0CJTPPT8#c zQ5;O}y|wLYGwfg)iBOxL2RLZSN0O)QAJ~!cmGX@WpxX?VeV3v~seqZ-|IzhWd(XSg zaZ_HfjO|}5%Ko)Z2iy{gmw=hR0Ji1acsNt;;eOc@9~Fw~KKd~FDOg}fr;XOTTB3=4 F_;0@Q_jUjP diff --git a/src/ersky9x/libraries/usb/device/audio-speaker/audio-speaker.dir b/src/ersky9x/libraries/usb/device/audio-speaker/audio-speaker.dir deleted file mode 100644 index be90df027..000000000 --- a/src/ersky9x/libraries/usb/device/audio-speaker/audio-speaker.dir +++ /dev/null @@ -1,617 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB Audio -/// Class device - USB audio-speaker demo, to implement an USB desktop speaker. -/// -/// !!!Contents -/// There are two things for the implement of the audio-speaker device driver: -/// - Implement the audio-speaker driver structs and functions for the device, -/// to initialize, to handle audio class specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the audio-speaker device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the device as a USB audio "desktop speaker" device. -/// -/// For more information about what a particular group contains, please refer to -/// "USB Audio Speaker Device". -//------------------------------------------------------------------------------ - -/** - \page "USB Audio Speaker Device" - This page describes how to use the USB framework to produce a USB Audio Class - Device driver. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Audio Device Document 1.0 - - - Audio Data Formats 1.0 - - - Autio Terminal Types 1.0 - - !!!Audio Speaker Driver API - - AUDDSpeakerDriver_Initialize - - AUDDSpeakerDriver_RequestHandler - - AUDDSpeakerDriver_Read - - !!!Audio Desktop Speaker Description - The %device described here is a USB desktop speaker. It receives a stero - %audio data stream from the Host over its Audio Streaming interface. The used - Audio Data Format is 16-bit 48KHz 2-channel PCM (or mono 16-bit 32KHz PCM for - sam7s chips). The following is the internal topology of the speaker. - - \image USBAudioSpeaker.png "USB Desktop Speaker Topology" - - The %audio function contains one Onput Terminal that represents the actual - speaker output element, followed by the Digital-to-Analog Converter (DAC). - The digital input stream of the host enters the %audio function through the - single Input %Pin of the Output terminal. There is a Feature Unit on the - %audio stream, to mute or unmute the speaker. The Input Terminal is the - representation within the %audio fucntion of the USB OUT endpoint that - eventually receives the %audio data stream from the Host. The internals of the - %audio function are presented to the Host through the (mandatory) AudioControl - interface wheras the USB OUT endpoint resides in the AudioStreaming interface. - - !!!Descriptor Hierarchy - This USB Desktop Speaker %device includes the AudioControl interface - (interface 0) and a single AudioStreaming interface (interface 1). The - AudioStreaming interface features two alternate settings. The first alternate - setting (Alternate Setting 0) has zero bandwidth associated with it so that - switching to this alternate setting effectively frees all allocated bandwidth - on the USB for this device. Zero bandwidth is indicated by the lack of a - streaming endpoint. Alternate Setting 1 is the operational part of the - interface and it has one isochronous OUT endpoint. Figure presents the - descriptor hierarchy. - - \image UsbAudioSpeakerDescriptors.png "USB Desktop Speaker Hierarchy" - - !!!Descriptors - The following sections present all the descriptors that are used to describe - the %device. - - All descriptors are combined into a list and pass to USBDDriver_Initialize - invoked in AUDDSpeakerDriver_Initialize. - -\code -const USBDDriverDescriptors auddSpeakerDriverDescriptors; -\endcode - - !!Device Descriptor -\code -const USBDeviceDescriptor deviceDescriptor; -\endcode -||Offset||Field||Size||Value||Description -|0|bLength|1|0x12|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x01|DEVICE descriptor (USBGenericDescriptor_DEVICE). -|2|bcdUSB|2|0x0200|2.00 - current revision of USB specification. -|4|bDeviceClass|1|0x00|Device defined at interface level. -|5|bDeviceSubClass|1|0x00|Unused. -|6|bDeviceProtocol|1|0x00|Unused. -|7|bMaxPacketSize0|1|0x08|8 bytes (BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0)). -|8|idVendor|2|0x03EB|Atmel Vendor ID (AUDDSpeakerDriverDescriptors_VENDORID). -|10|idProduct|2|0x6128|Product ID (AUDDSpeakerDriverDescriptors_PRODUCTID). -|12|bcdDevice|2|0x0100|Device Release Code\n - (AUDDSpeakerDriverDescriptors_RELEASE). -|14|iManufacturer|1|0x01|Index to manufacture name in Unicode\n - (manufacturerDescriptor). -|15|iProduct|1|0x02|Index to product name in Unicode (productDescriptor). -|16|iSerialNumber|1|0x03|Index to serial number in Unicode\n - (serialNumberDescriptor). -|17|bNumConfigurations|1|0x01|One configuration. - - !!Configuration Descriptor -\code -const AUDDSpeakerDriverConfigurationDescriptors configurationDescriptors; -\endcode -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x02|CONFIGURATION descriptor\n - (USBGenericDescriptor_CONFIGURATION). -|2|wTotalLength|2|0x????|Length of the total configuration block in bytes\n - including this descriptor\n - (AUDDSpeakerDriverConfigurationDescriptors) -|4|bNumInterfaces|1|0x02|Two interfaces. -|5|bConfigurationValue|1|0x01|ID of this configuration. -|6|iConfiguration|1|0x00|Unused. -|7|bmAttributes|1|0x??|BOARD_USB_BMATTRIBUTES -|8|bMaxPower|1|0x32|100mA Max. %power consumption.\n - USBConfigurationDescriptor_POWER(100) - - !!AudioControl Interface Descriptor - The AudioControl interface describes the %device structure (%audio function - topology) and is used to manipulate the Audio Controls. - - !Standard AC Interface Descriptor - The AudioControl interface has no dedicated endpoints associated with it. It - uses the default pipe (endpoint 0) for all communication purposes. Class- - specific AudioControl Requests are sent using the default pipe. There is no - Status Interrupt endpoint provided. - - See USBInterfaceDescriptor. -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x04|INTERFACE descriptor\n - (USBGenericDescriptor_INTERFACE). -|2|bInterfaceNumber|1|0x00|Index of this interface. -|3|bAlternateSetting|1|0x00|Index of this setting. -|4|bNumEndpoints|1|0x00|0 endpoints. -|5|bInterfaceClass|1|0x01|AUDIO (AUDControlInterfaceDescriptor_CLASS). -|6|bInterfaceSubClass|1|0x01|AUDIO_CONTROL\n - (AUDControlInterfaceDescriptor_SUBCLASS). -|7|bInterfaceProtocol|1|0x00|Unused. -|8|iInterface|1|0x00|Unused. - - !Class-specific AC Interface Descriptor - The Class-specific AC interface descriptor is always headed by a Header - descriptor that contains general information about the AudioControl interface. - It contains all the pointers needed to describe the AudioInterface Collection, - associated with the described %audio function. -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubtype|1|0x01|HEADER subtype (AUDGenericDescriptor_HEADER). -|3|bcdADC|2|0x0100|Revision of class specification - 1.0 -|5|wTotalLength|2|0x????|Total size of class specific descriptors\n - (AUDDSpeakerDriverAudioControlDescriptors). -|7|bInCollection|1|0x01|Number of streaming interfaces. -|8|baInterfaceNr(1)|1|0x01|AudioStreaming interface 1 belongs to this AudioControl interface. - - !Input Terminal Descriptor for playback - This descriptor describes the Input Terminal that represents the USB pipe from - the Host PC. Its Output Pin is connected to the Input Pin of the Feature Unit - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0C|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x02|INPUT_TERMINAL subtype\n - (AUDGenericDescriptor_INPUTTERMINAL). -|3|bTerminalID|1|0x00|ID of this Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL). -|4|wTerminalType|2|0x0101|Terminal is USB stream\n - (AUDInputTerminalDescriptor_USBSTREAMING). -|6|bAssocTerminal|1|0x01|Associated to Output Terminal\n - (AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL). -|7|bNrChannels|1|0x02|Two channel. -|8|wChannelConfig|2|0x0003|Left plus right front channel. -|10|iChannelNames|1|0x00|Unused. -|11|iTerminal|1|0x00|Unused. - - !Output Terminal Descriptor for playback - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x03|OUTPUT_TERMINAL subtype\n - (AUDGenericDescriptor_OUTPUTTERMINAL). -|3|bTerminalID|1|0x01|ID of this Output Terminal\n - (AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL). -|4|wTerminalType|2|0x0301|Terminal is Desktop speaker. -|6|bAssocTerminal|1|0x01|Associated to Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL). -|7|bSourceID|1|0x02|From Feature Unit\n - (AUDDSpeakerDriverDescriptors_FEATUREUNIT). -|8|iTerminal|1|0x00|Unused. - - !Feature Unit Descriptor for playback - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0A|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x02|FEATURE_UNIT subtype\n - (AUDGenericDescriptor_FEATUREUNIT). -|3|bUnitID|1|0x02|ID of this Feature Unit\n - (AUDDSpeakerDriverDescriptors_FEATUREUNIT). -|4|bSourceID|1|0x00|From Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL). -|5|bControlSize|1|0x01|1 byte per channel for controls -|6|bmaControls|3|0x000001|Master channel mute control, no other controls. -|9|iFeature|1|0x00|Unused. - - !!AudioStreaming Interface Descriptor - The AudioStreaming interface has two possible alternate settings. - - !Zero-bandwidth Alternate Setting 0 - Alternate setting 0 is a zero-bandwidth setting, used to relinquish the - claimed bandwidth on the bus when the microphone is not in use. It is the - default setting after power-up. The zero bandwidth is implemented by - specifying that this alternate setting of the interface has no endpoints - associated with it (bNumEndpoints=0). The collection of descriptors for this - alternate setting reduces to the standard interface descriptor. - - Standard AS Interface Descriptor (USBInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x04|INTERFACE descriptor\n - (USBGenericDescriptor_INTERFACE). -|2|bInterfaceNumber|1|0x01|Index of this interface. -|3|bAlternateSetting|1|0x00|Index of this setting. -|4|bNumEndpoints|1|0x00|0 endpoint. -|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS). -|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n - (AUDStreamingInterfaceDescriptor_SUBCLASS). -|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL). -|8|iInterface|1|0x00|Unused. - - !Operational Alternate Setting 1 - Alternate setting 1 is the operational setting of the interface. It contains - the standard and class-specific interface and endpoint descriptors. - - Standard AS Interface Descriptor (USBInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of USBInterfaceDescriptor in bytes. -|1|bDescriptorType|1|0x04|INTERFACE descriptor\n - (USBGenericDescriptor_INTERFACE). -|2|bInterfaceNumber|1|0x01|Index of this interface. -|3|bAlternateSetting|1|0x01|Index of this setting. -|4|bNumEndpoints|1|0x01|1 endpoint. -|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS). -|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n - (AUDStreamingInterfaceDescriptor_SUBCLASS). -|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL). -|8|iInterface|1|0x00|Unused. - - Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x06|Size of AUDStreamingInterfaceDescriptor in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x01|GENERAL subtype\n - (AUDStreamingInterfaceDescriptor_GENERAL). -|3|bTerminalLink|1|0x02|Unit ID of the Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL). -|4|bDelay|1|0x00|No interface delay. -|5|wFormatTag|2|0x0001|PCM Format (AUDFormatTypeOneDescriptor_PCM). - - Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0B|Size of AUDFormatTypeOneDescriptor1 in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\ - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n - (AUDStreamingInterfaceDescriptor_FORMATTYPE). -|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE). -|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS). -|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n - (AUDDSpeakerDriver_BYTESPERSAMPLE). -|6|bBitResolution|1|0x10|16 bits per sample\n - (AUDDSpeakerDriver_BYTESPERSAMPLE * 2). -|7|bSamFreqType|1|0x01|One frequency supported. -|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE). - - Standard %Endpoint Descriptor (AUDEndpointDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes. -|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT). -|2|bEndpointAddress|1|0x04\nTest|OUT endpoint 4\n - See USBEndpointDescriptor_ADDRESS\n - See AUDDSpeakerDriverDescriptors_DATAOUT. -|3|bmAttributes|1|0x01|Isochronous, not shared\n - (USBEndpointDescriptor_ISOCHRONOUS). -|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE(). -|6|bInterval|1|0x01|One packet per frame. -|7|bRefresh|1|0x00|Unused. -|8|bSynchAddress|1|0x00|Unused. - - Class-specific Isochronous Audio Data Endpoint Descriptor - (AUDDataEndpointDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes. -|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n - (AUDGenericDescriptor_ENDPOINT). -|2|bDescriptorSubType|1|0x01|GENERAL subtype\n - (AUDDataEndpointDescriptor_SUBTYPE). -|3|bmAttributes|1|0x00|No sampling frequency control\n - no pitch control\n - no packet padding. -|4|bLockDelayUnits|1|0x00|Unused. -|5|wLockDelay|2|0x0000|Unused. - - !!String Descriptors - There are three string descriptors available. The Manufacturer, Product and - Serial Number descriptor. - - See manufacturerDescriptor, productDescriptor, serialNumberDescriptor. - - !!!Requests - The Audio Speaker Driver supports all necessary standard requests, and some - class-specific requests. - - USBDCallbacks_RequestReceived is used to filter all requests, - AUDDSpeakerDriver_RequestHandler is invoked to handle Audio Class requests - and forward standard request to AUDDSpeakerDriver_RequestHandler. - - !!Standard requests - Set Interface request should be processed to control bandwidth allocation. - - !Set Interface - USBDDriverCallbacks_InterfaceSettingChanged is re-implemented to handle the - event. -||Offset||Field||Size||Value||Description -|0|bmRequestType|1|0x01|D7:0=Host to Device.\n - D6..5:00=Standard Request.\n - D4..0:00001=Recipient is interface. -|1|bRequest|1|0x0B|SET_INTERFACE. -|2|wValue|2|0x0000\n - or\n - 0x0001|Zero bandwidth or normal isochronous operation. -|4|wIndex|2|0x0001|Interface number of the AudioStreaming interface. -|6|wLength|2|0x0000|No Parameter Block. - - !!Class-specific requests - The only class-specific Request supported is the Set/Get Feature Unit Control - Request. For mute control of the Feature Unit. - - !Set Feature Unit Control Request -||Offset||Field||Size||Value||Description -|0|bmRequestType|1|0x01|D7:0=Host to Device.\n - D6..5:01=Class Request.\n - D4..0:00001=Recipient is interface. -|1|bRequest|1|0x01|SET_CUR. -|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n - Master channel (AUDDSpeakerDriver_MASTERCHANNEL). -|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n - and\n - AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL). -|6|wLength|2|0x0001|Paramter Block Length - - The one-byte Parameter Block contains the new bMuted value for Feature - Control. - - !Get Feature Unit Control Request -||Offset||Field||Size||Value||Description -|0|bmRequestType|1|0x01|D7:0=Host to Device.\n - D6..5:01=Class Request.\n - D4..0:00001=Recipient is interface. -|1|bRequest|1|0x81|GET_CUR. -|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n - Master channel (AUDDSpeakerDriver_MASTERCHANNEL). -|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n - and\n - AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL). -|6|wLength|2|0x0001|Paramter Block Length - - The one-byte Parameter Block contains the new bMuted value for Feature - Control. - - !!!Modify the Device Driver - You can modify your project from the USB Audio Demoes: - - usb-device-audio-speaker-ac97-project - - usb-device-audio-speaker-project - - !!Change Device ID and Display - All Device ID and Display Strings are in AUDDSpeakerDriverDescriptors.c. - - !Device IDs - You can find "Audio Speaker Device Codes" - - AUDDSpeakerDriverDescriptors_VENDORID - - AUDDSpeakerDriverDescriptors_PRODUCTID - - AUDDSpeakerDriverDescriptors_RELEASE - - !Display Strings - You can modify the string descriptors - - manufacturerDescriptor - - productDescriptor - - serialNumberDescriptor - - !!!Add Recorder Function - See "USB Audio Recorder". - -*/ - -/** - \page "USB Audio Recorder" - This page describes how to add recorder function into the - "USB Audio Speaker Device", So that you can learn how to extend your audio - device driver from current Audio Speaker demo. - - !!!Description - To add %audio record function, new Input Terminal, Output Termnial and Feature - Unit is added. - - \image UsbAudioSpeakerRecorder.png "USB Desktop Speaker Hierarchy" - - - !!!Modify the configuration descriptor: - New descriptor for the terminals and unit should be added, and according - interface, too. - - \image UsbAudioSpeakerRecorderDescriptors.png "USB Desktop Speaker Descriptors" - - - - !!Terminal Descriptors and Unit Descriptor - ... - !Input Terminal Descriptor for recording - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0C|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x03|INPUT_TERMINAL subtype\n - (AUDGenericDescriptor_INPUTTERMINAL). -|3|bTerminalID|1|0x03|ID of this Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC). -|4|wTerminalType|2|0x0403|Terminal is Speaker Phone\n - (AUDInputTerminalDescriptor_SPEAKERPHONE). -|6|bAssocTerminal|1|0x04|Associated to Output Terminal\n - (AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC). -|7|bNrChannels|1|0x02|Two channel. -|8|wChannelConfig|2|0x0003|Left plus right front channel. -|10|iChannelNames|1|0x00|Unused. -|11|iTerminal|1|0x00|Unused. - - !Output Terminal Descriptor for recording - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x04|OUTPUT_TERMINAL subtype\n - (AUDGenericDescriptor_OUTPUTTERMINAL). -|3|bTerminalID|1|0x04|ID of this Output Terminal\n - (AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC). -|4|wTerminalType|2|0x0301|Terminal is USB stream\n - (AUDOutputTerminalDescriptor_USBTREAMING). -|6|bAssocTerminal|1|0x03|Associated to Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC). -|7|bSourceID|1|0x05|From Feature Unit\n - (AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC). -|8|iTerminal|1|0x00|Unused. - - !Feature Unit Descriptor for recording - ... -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0A|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x02|FEATURE_UNIT subtype\n - (AUDGenericDescriptor_FEATUREUNIT). -|3|bUnitID|1|0x05|ID of this Feature Unit\n - (AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC). -|4|bSourceID|1|0x03|From Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC). -|5|bControlSize|1|0x01|1 byte per channel for controls -|6|bmaControls|3|0x000001|Master channel mute control, no other controls. -|9|iFeature|1|0x00|Unused. - - !!Interface Descriptor and Endpoint Descriptor for recording - ... - - !Zero-bandwidth Alternate Setting 0 - Standard AS Interface Descriptor (USBInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of this descriptor, in bytes. -|1|bDescriptorType|1|0x04|INTERFACE descriptor\n - (USBGenericDescriptor_INTERFACE). -|2|bInterfaceNumber|1|0x02|Index of this interface. -|3|bAlternateSetting|1|0x00|Index of this setting. -|4|bNumEndpoints|1|0x00|0 endpoint. -|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS). -|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n - (AUDStreamingInterfaceDescriptor_SUBCLASS). -|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL). -|8|iInterface|1|0x00|Unused. - - !Operational Alternate Setting 1 - Standard AS Interface Descriptor (USBInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of USBInterfaceDescriptor in bytes. -|1|bDescriptorType|1|0x04|INTERFACE descriptor\n - (USBGenericDescriptor_INTERFACE). -|2|bInterfaceNumber|1|0x02|Index of this interface. -|3|bAlternateSetting|1|0x01|Index of this setting. -|4|bNumEndpoints|1|0x01|1 endpoint. -|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS). -|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n - (AUDStreamingInterfaceDescriptor_SUBCLASS). -|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL). -|8|iInterface|1|0x00|Unused. - - Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x06|Size of AUDStreamingInterfaceDescriptor in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x01|GENERAL subtype\n - (AUDStreamingInterfaceDescriptor_GENERAL). -|3|bTerminalLink|1|0x02|Unit ID of the Input Terminal\n - (AUDDSpeakerDriverDescriptors_INPUTTERMINAL). -|4|bDelay|1|0x00|No interface delay. -|5|wFormatTag|2|0x0001|PCM Format (AUDFormatTypeOneDescriptor_PCM). - - Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x0B|Size of AUDFormatTypeOneDescriptor1 in bytes. -|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n - (AUDGenericDescriptor_INTERFACE). -|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n - (AUDStreamingInterfaceDescriptor_FORMATTYPE). -|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE). -|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS). -|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n - (AUDDSpeakerDriver_BYTESPERSAMPLE). -|6|bBitResolution|1|0x10|16 bits per sample\n - (AUDDSpeakerDriver_BYTESPERSAMPLE * 2). -|7|bSamFreqType|1|0x01|One frequency supported. -|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE). - - Standard %Endpoint Descriptor (AUDEndpointDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes. -|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT). -|2|bEndpointAddress|1|0x85|IN endpoint 5\n - USBEndpointDescriptor_ADDRESS()\n - AUDDSpeakerDriverDescriptors_DATAIN -|3|bmAttributes|1|0x01|Isochronous, not shared\n - (USBEndpointDescriptor_ISOCHRONOUS). -|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE(5). -|6|bInterval|1|0x01|One packet per frame. -|7|bRefresh|1|0x00|Unused. -|8|bSynchAddress|1|0x00|Unused. - - Class-specific Isochronous Audio Data Endpoint Descriptor - (AUDDataEndpointDescriptor) -||Offset||Field||Size||Value||Description -|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes. -|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n - (AUDGenericDescriptor_ENDPOINT). -|2|bDescriptorSubType|1|0x01|GENERAL subtype\n - (AUDDataEndpointDescriptor_SUBTYPE). -|3|bmAttributes|1|0x00|No sampling frequency control\n - no pitch control\n - no packet padding -|4|bLockDelayUnits|1|0x00|Unused. -|5|wLockDelay|2|0x0000|Unused. - - !!!Modified methods for new function - Several methods modified for new recorder function. - - !!Request handlers callbacks - Add handler for new Interface, Terminal and Unit IDs. - See AUDDSpeakerDriver_RequestHandler. - - !!Add function for recording USB stream - See AUDDSpeakerDriver_Write. -*/ diff --git a/src/ersky9x/libraries/usb/device/ccid/cciddriver.c b/src/ersky9x/libraries/usb/device/ccid/cciddriver.c deleted file mode 100644 index d72b4abdf..000000000 --- a/src/ersky9x/libraries/usb/device/ccid/cciddriver.c +++ /dev/null @@ -1,1503 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// CCID driver -/// -/// !Usage -/// -/// Explanation on the usage of the code made available through the header file. -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Local definition -//------------------------------------------------------------------------------ - -/// Constants: IDs: Device product ID. -#define CCIDDriverDescriptors_PRODUCTID 0x6129 -/// Constants: IDs: Device vendor ID. -#define CCIDDriverDescriptors_VENDORID 0x03EB -/// Constants: IDs: Device release number. -#define CCIDDriverDescriptors_RELEASE 0x0100 - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/// CCIDDriverConfiguration Descriptors -/// List of descriptors that make up the configuration descriptors of a -/// device using the CCID driver. -typedef struct { - - /// Configuration descriptor - USBConfigurationDescriptor configuration; - /// Interface descriptor - USBInterfaceDescriptor interface; - /// CCID descriptor - CCIDDescriptor ccid; - /// Bulk OUT endpoint descriptor - USBEndpointDescriptor bulkOut; - /// Bulk IN endpoint descriptor - USBEndpointDescriptor bulkIn; - /// Interrupt OUT endpoint descriptor - USBEndpointDescriptor interruptIn; - -} __attribute__ ((packed)) CCIDDriverConfigurationDescriptors; - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/// Driver structure for an CCID device -typedef struct { - - /// Standard USB device driver instance - USBDDriver usbdDriver; - /// CCID message - S_ccid_bulk_in_header sCcidMessage; - /// CCID command - S_ccid_bulk_out_header sCcidCommand; - /// Interrupt message answer - unsigned char BufferINT[4]; - /// Buffer data of message - unsigned char ProtocolDataStructure[10]; - /// Protocol used - unsigned char bProtocol; - /// SlotStatus - /// Bit 0 = Slot 0 current state - /// Bit 1 = Slot 0 changed status - /// Bit 2 = Slot 1 current state - /// Bit 3 = Slot 1 changed status - /// Bit 4 = Slot 2 current state - /// Bit 5 = Slot 2 changed status - unsigned char SlotStatus; - -} CCIDDriver; - -//------------------------------------------------------------------------------ -// Local variables -//------------------------------------------------------------------------------ - -/// Static instance of the CCID device driver. -static CCIDDriver ccidDriver; - -/// Standard USB device descriptor. -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0, - 0, - 0, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - CCIDDriverDescriptors_VENDORID, - CCIDDriverDescriptors_PRODUCTID, - CCIDDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; - - -/// List of configuration descriptors. -static const CCIDDriverConfigurationDescriptors configurationDescriptorsFS = { - - // Standard USB configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CCIDDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // CCID interface descriptor - // Table 4.3-1 Interface Descriptor - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // Interface 0 - 0, // No alternate settings - 3, // uses bulk-IN, bulk-OUT and interrupt–IN - SMART_CARD_DEVICE_CLASS, - 0, // Subclass code - 0, // bulk transfers optional interrupt-IN - 0 // No associated string descriptor - }, - { - sizeof(CCIDDescriptor), // bLength: Size of this descriptor in bytes - CCID_DECRIPTOR_TYPE, // bDescriptorType:Functional descriptor type - CCID1_10, // bcdCCID: CCID version - 0, // bMaxSlotIndex: Value 0 indicates that one slot is supported - VOLTS_5_0, // bVoltageSupport - PROTOCOL_TO, // dwProtocols - 3580, // dwDefaultClock - 3580, // dwMaxClock - 0, // bNumClockSupported - 9600, // dwDataRate : 9600 bauds - 9600, // dwMaxDataRate : 9600 bauds - 0, // bNumDataRatesSupported - 0xfe, // dwMaxIFSD - 0, // dwSynchProtocols - 0, // dwMechanical - //0x00010042, // dwFeatures: Short APDU level exchanges - CCID_FEATURES_AUTO_PCONF | CCID_FEATURES_AUTO_PNEGO | CCID_FEATURES_EXC_TPDU, - 0x0000010F, // dwMaxCCIDMessageLength: For extended APDU level the value shall be between 261 + 10 - 0xFF, // bClassGetResponse: Echoes the class of the APDU - 0xFF, // bClassEnvelope: Echoes the class of the APDU - 0, // wLcdLayout: no LCD - 0, // bPINSupport: No PIN - 1 // bMaxCCIDBusySlot - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_OUT, CCID_EPT_DATA_OUT ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_OUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0x00 // Does not apply to Bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_DATA_IN ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_IN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0x00 // Does not apply to Bulk endpoints - }, - // Notification endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_NOTIFICATION ), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 0x10 - } -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -static const CCIDDriverConfigurationDescriptors configurationDescriptorsHS = { - - // Standard USB configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CCIDDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // CCID interface descriptor - // Table 4.3-1 Interface Descriptor - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // Interface 0 - 0, // No alternate settings - 3, // uses bulk-IN, bulk-OUT and interrupt–IN - SMART_CARD_DEVICE_CLASS, - 0, // Subclass code - 0, // bulk transfers optional interrupt-IN - 0 // No associated string descriptor - }, - { - sizeof(CCIDDescriptor), // bLength: Size of this descriptor in bytes - CCID_DECRIPTOR_TYPE, // bDescriptorType:Functional descriptor type - CCID1_10, // bcdCCID: CCID version - 0, // bMaxSlotIndex: Value 0 indicates that one slot is supported - VOLTS_5_0, // bVoltageSupport - PROTOCOL_TO, // dwProtocols - 3580, // dwDefaultClock - 3580, // dwMaxClock - 0, // bNumClockSupported - 9600, // dwDataRate : 9600 bauds - 9600, // dwMaxDataRate : 9600 bauds - 0, // bNumDataRatesSupported - 0xfe, // dwMaxIFSD - 0, // dwSynchProtocols - 0, // dwMechanical - //0x00010042, // dwFeatures: Short APDU level exchanges - CCID_FEATURES_AUTO_PCONF | CCID_FEATURES_AUTO_PNEGO | CCID_FEATURES_EXC_TPDU, - 0x0000010F, // dwMaxCCIDMessageLength: For extended APDU level the value shall be between 261 + 10 - 0xFF, // bClassGetResponse: Echoes the class of the APDU - 0xFF, // bClassEnvelope: Echoes the class of the APDU - 0, // wLcdLayout: no LCD - 0, // bPINSupport: No PIN - 1 // bMaxCCIDBusySlot - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_OUT, CCID_EPT_DATA_OUT ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_OUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0x00 // Does not apply to Bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_DATA_IN ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_IN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0x00 // Does not apply to Bulk endpoints - }, - // Notification endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_NOTIFICATION ), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS), - 0x10 - } -}; - -/// Qualifier descriptor -const USBDeviceQualifierDescriptor deviceQualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), // Size of this descriptor in bytes - USBGenericDescriptor_DEVICEQUALIFIER, // Qualifier Descriptor Type - USBDeviceDescriptor_USB2_00, // USB specification 2.00 - 0x00, // Class is specified in interface - 0x00, // Subclass is specified in interface - 0x00, // Protocol is specified in interface - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 0x01, // One possible configuration - 0x00 // Reserved for future use, must be zero -}; - -/// OtherSpeed configuration descriptor in Full Speed mode -static const CCIDDriverConfigurationDescriptors sOtherSpeedConfigurationFS = { - - // Standard USB configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(CCIDDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // CCID interface descriptor - // Table 4.3-1 Interface Descriptor - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // Interface 0 - 0, // No alternate settings - 3, // uses bulk-IN, bulk-OUT and interrupt–IN - SMART_CARD_DEVICE_CLASS, - 0, // Subclass code - 0, // bulk transfers optional interrupt-IN - 0 // No associated string descriptor - }, - { - sizeof(CCIDDescriptor), // bLength: Size of this descriptor in bytes - CCID_DECRIPTOR_TYPE, // bDescriptorType:Functional descriptor type - CCID1_10, // bcdCCID: CCID version - 0, // bMaxSlotIndex: Value 0 indicates that one slot is supported - VOLTS_5_0, // bVoltageSupport - PROTOCOL_TO, // dwProtocols - 3580, // dwDefaultClock - 3580, // dwMaxClock - 0, // bNumClockSupported - 9600, // dwDataRate : 9600 bauds - 9600, // dwMaxDataRate : 9600 bauds - 0, // bNumDataRatesSupported - 0xfe, // dwMaxIFSD - 0, // dwSynchProtocols - 0, // dwMechanical - //0x00010042, // dwFeatures: Short APDU level exchanges - CCID_FEATURES_AUTO_PCONF | CCID_FEATURES_AUTO_PNEGO | CCID_FEATURES_EXC_TPDU, - 0x0000010F, // dwMaxCCIDMessageLength: For extended APDU level the value shall be between 261 + 10 - 0xFF, // bClassGetResponse: Echoes the class of the APDU - 0xFF, // bClassEnvelope: Echoes the class of the APDU - 0, // wLcdLayout: no LCD - 0, // bPINSupport: No PIN - 1 // bMaxCCIDBusySlot - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_OUT, CCID_EPT_DATA_OUT ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_OUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0x00 // Does not apply to Bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_DATA_IN ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_IN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0x00 // Does not apply to Bulk endpoints - }, - // Notification endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_NOTIFICATION ), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 0x10 - } -}; - -/// OtherSpeed configuration descriptor in High Speed mode -static const CCIDDriverConfigurationDescriptors sOtherSpeedConfigurationHS = { - - // Standard USB configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(CCIDDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // CCID interface descriptor - // Table 4.3-1 Interface Descriptor - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // Interface 0 - 0, // No alternate settings - 3, // uses bulk-IN, bulk-OUT and interrupt–IN - SMART_CARD_DEVICE_CLASS, - 0, // Subclass code - 0, // bulk transfers optional interrupt-IN - 0 // No associated string descriptor - }, - { - sizeof(CCIDDescriptor), // bLength: Size of this descriptor in bytes - CCID_DECRIPTOR_TYPE, // bDescriptorType:Functional descriptor type - CCID1_10, // bcdCCID: CCID version - 0, // bMaxSlotIndex: Value 0 indicates that one slot is supported - VOLTS_5_0, // bVoltageSupport - PROTOCOL_TO, // dwProtocols - 3580, // dwDefaultClock - 3580, // dwMaxClock - 0, // bNumClockSupported - 9600, // dwDataRate : 9600 bauds - 9600, // dwMaxDataRate : 9600 bauds - 0, // bNumDataRatesSupported - 0xfe, // dwMaxIFSD - 0, // dwSynchProtocols - 0, // dwMechanical - //0x00010042, // dwFeatures: Short APDU level exchanges - CCID_FEATURES_AUTO_PCONF | CCID_FEATURES_AUTO_PNEGO | CCID_FEATURES_EXC_TPDU, - 0x0000010F, // dwMaxCCIDMessageLength: For extended APDU level the value shall be between 261 + 10 - 0xFF, // bClassGetResponse: Echoes the class of the APDU - 0xFF, // bClassEnvelope: Echoes the class of the APDU - 0, // wLcdLayout: no LCD - 0, // bPINSupport: No PIN - 1 // bMaxCCIDBusySlot - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_OUT, CCID_EPT_DATA_OUT ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_OUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0x00 // Does not apply to Bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_DATA_IN ), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_DATA_IN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0x00 // Does not apply to Bulk endpoints - }, - // Notification endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( USBEndpointDescriptor_IN, CCID_EPT_NOTIFICATION ), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CCID_EPT_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS), - 0x10 - } -}; -#endif - -/// Language ID string descriptor. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(23), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('I'), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('R'), - USBStringDescriptor_UNICODE('I'), - USBStringDescriptor_UNICODE('V'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('R'), - USBStringDescriptor_UNICODE(' ') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(12), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3'), - USBStringDescriptor_UNICODE('4'), - USBStringDescriptor_UNICODE('5'), - USBStringDescriptor_UNICODE('6'), - USBStringDescriptor_UNICODE('7'), - USBStringDescriptor_UNICODE('8'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('F') -}; - -/// Array of pointers to string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor -}; - - -/// List of standard descriptors for the serial driver. -const USBDDriverDescriptors ccidDriverDescriptors = { - - &deviceDescriptor, // FS - (USBConfigurationDescriptor *) &configurationDescriptorsFS, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - (USBDeviceQualifierDescriptor *) &deviceQualifierDescriptor, // FS - (USBConfigurationDescriptor *) &sOtherSpeedConfigurationFS, - &deviceDescriptor, // HS - (USBConfigurationDescriptor *) &configurationDescriptorsHS, - (USBDeviceQualifierDescriptor *) &deviceQualifierDescriptor, // HS - (USBConfigurationDescriptor *) &sOtherSpeedConfigurationHS, -#else - 0, // No qualifier descriptor FS - 0, // No other-speed configuration FS - 0, // No device descriptor HS - 0, // No configuration HS - 0, // No qualifier descriptor HS - 0, // No other-speed configuration HS -#endif - stringDescriptors, - 4 // Four string descriptors in array -}; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Response Pipe, Bulk-IN Messages -/// Return the Slot Status to the host -/// Answer to: -/// PC_to_RDR_IccPowerOff -/// PC_to_RDR_GetSlotStatus -/// PC_to_RDR_IccClock -/// PC_to_RDR_T0APDU -/// PC_to_RDR_Mechanical -/// PC_to_RDR_Abort and Class specific ABORT request -//------------------------------------------------------------------------------ -static void RDRtoPCSlotStatus( void ) -{ - TRACE_DEBUG("RDRtoPCSlotStatus\n\r"); - - // Header fields settings - ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS; - ccidDriver.sCcidMessage.wLength = 0; - ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus; - ccidDriver.sCcidMessage.bError = 0; - // 00h Clock running - // 01h Clock stopped in state L - // 02h Clock stopped in state H - // 03h Clock stopped in an unknown state - // All other values are Reserved for Future Use. - ccidDriver.sCcidMessage.bSpecific = 0; -} - -//------------------------------------------------------------------------------ -/// Response Pipe, Bulk-IN Messages -/// Answer to PC_to_RDR_IccPowerOn -//------------------------------------------------------------------------------ -static void RDRtoPCDatablock_ATR( void ) -{ - unsigned char i; - unsigned char Atr[ATR_SIZE_MAX]; - unsigned char length; - - //TRACE_DEBUG("RDRtoPCDatablock\n\r"); - - ISO7816_Datablock_ATR( Atr, &length ); - - if( length > 5 ) { - ccidDriver.ProtocolDataStructure[1] = Atr[5]&0x0F; // TD(1) - ccidDriver.bProtocol = Atr[5]&0x0F; // TD(1) - } - - // S_ccid_protocol_t0 - // bmFindexDindex - ccidDriver.ProtocolDataStructure[0] = Atr[2]; // TA(1) - - // bmTCCKST0 - // For T=0 ,B0 – 0b, B7-2 – 000000b - // B1 – Convention used (b1=0 for direct, b1=1 for inverse) - - // bGuardTimeT0 - // Extra Guardtime between two characters. Add 0 to 254 etu to the normal - // guardtime of 12etu. FFh is the same as 00h. - ccidDriver.ProtocolDataStructure[2] = Atr[4]; // TC(1) - // AT91C_BASE_US0->US_TTGR = 0; // TC1 - - // bWaitingIntegerT0 - // WI for T=0 used to define WWT - ccidDriver.ProtocolDataStructure[3] = Atr[7]; // TC(2) - - // bClockStop - // ICC Clock Stop Support - // 00 = Stopping the Clock is not allowed - // 01 = Stop with Clock signal Low - // 02 = Stop with Clock signal High - // 03 = Stop with Clock either High or Low - ccidDriver.ProtocolDataStructure[4] = 0x00; // 0 to 3 - - // Header fields settings - ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATABLOCK; - ccidDriver.sCcidMessage.wLength = length; // Size of ATR - ccidDriver.sCcidMessage.bSizeToSend += length; // Size of ATR - // bChainParameter: 00 the response APDU begins and ends in this command - ccidDriver.sCcidMessage.bSpecific = 0; - - for( i=0; i (configurationDescriptorsFS.ccid.dwMaxCCIDMessageLength-10) ) { - - ccidDriver.sCcidMessage.bStatus = 1; - ccidDriver.sCcidMessage.bError = 0; - } - // check bBWI - else if ( 0 != ccidDriver.sCcidCommand.bSpecific_0 ) { - - TRACE_ERROR("Bad bBWI\n\r"); - } - else { - - // APDU or TPDU - switch(configurationDescriptorsFS.ccid.dwFeatures - & (CCID_FEATURES_EXC_TPDU|CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU)) { - - case CCID_FEATURES_EXC_TPDU: - if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_TO) { - - // Send commande APDU - indexMessage = ISO7816_XfrBlockTPDU_T0( ccidDriver.sCcidCommand.APDU , - ccidDriver.sCcidMessage.abData, - ccidDriver.sCcidCommand.wLength ); - } - else { - if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_T1) { - TRACE_INFO("Not supported T=1\n\r"); - } - else { - TRACE_INFO("Not supported\n\r"); - } - } - break; - - case CCID_FEATURES_EXC_APDU: - TRACE_INFO("Not supported\n\r"); - break; - - default: - break; - } - - } - - ccidDriver.sCcidMessage.wLength = indexMessage; - TRACE_DEBUG("USB: 0x%X, 0x%X, 0x%X, 0x%X, 0x%X\n\r", ccidDriver.sCcidMessage.abData[0], - ccidDriver.sCcidMessage.abData[1], - ccidDriver.sCcidMessage.abData[2], - ccidDriver.sCcidMessage.abData[3], - ccidDriver.sCcidMessage.abData[4] ); - RDRtoPCDatablock(); - -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// return parameters by the command: RDR_to_PC_Parameters -//------------------------------------------------------------------------------ -static void PCtoRDRGetParameters( void ) -{ - TRACE_DEBUG("PCtoRDRGetParameters\n\r"); - - // We support only one slot - - // bmIccStatus - if( ISO7816_StatusReset() ) { - // 0: An ICC is present and active (power is on and stable, RST is inactive - ccidDriver.sCcidMessage.bStatus = 0; - } - else { - // 1: An ICC is present and inactive (not activated or shut down by hardware error) - ccidDriver.sCcidMessage.bStatus = 1; - } - - RDRtoPCParameters(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command resets the slot parameters to their default values -//------------------------------------------------------------------------------ -static void PCtoRDRResetParameters( void ) -{ - TRACE_DEBUG("PCtoRDRResetParameters\n\r"); - - ccidDriver.SlotStatus = ICC_NOT_PRESENT; - ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus; - - RDRtoPCParameters(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command is used to change the parameters for a given slot. -//------------------------------------------------------------------------------ -static void PCtoRDRSetParameters( void ) -{ - TRACE_DEBUG("PCtoRDRSetParameters\n\r"); - - ccidDriver.SlotStatus = ccidDriver.sCcidCommand.bSlot; - ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus; - // Not all feature supported - - RDRtoPCParameters(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command allows the CCID manufacturer to define and access extended -/// features. -/// Information sent via this command is processed by the CCID control logic. -//------------------------------------------------------------------------------ -static void PCtoRDREscape( void ) -{ - TRACE_DEBUG("PCtoRDREscape\n\r"); - - // If needed by the user - ISO7816_Escape(); - - // stub, return all value send - RDRtoPCEscape( ccidDriver.sCcidCommand.wLength, ccidDriver.sCcidCommand.APDU); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command stops or restarts the clock. -//------------------------------------------------------------------------------ -static void PCtoRDRICCClock( void ) -{ - TRACE_DEBUG("PCtoRDRICCClock\n\r"); - - if( 0 == ccidDriver.sCcidCommand.bSpecific_0 ) { - // restarts the clock - ISO7816_RestartClock(); - } - else { - // stop clock in the state shown in the bClockStop field - ISO7816_StopClock(); - } - - RDRtoPCSlotStatus( ); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command changes the parameters used to perform the transportation of -/// APDU messages by the T=0 protocol. -//------------------------------------------------------------------------------ -static void PCtoRDRtoAPDU( void ) -{ - unsigned char bmChanges; - unsigned char bClassGetResponse; - unsigned char bClassEnvelope; - - TRACE_DEBUG("PCtoRDRtoAPDU\n\r"); - - if( configurationDescriptorsFS.ccid.dwFeatures == (CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU) ) { - - bmChanges = ccidDriver.sCcidCommand.bSpecific_0; - bClassGetResponse = ccidDriver.sCcidCommand.bSpecific_1; - bClassEnvelope = ccidDriver.sCcidCommand.bSpecific_2; - - ISO7816_toAPDU(); - } - - RDRtoPCSlotStatus(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This is a command message to allow entering the PIN for verification or -/// modification. -//------------------------------------------------------------------------------ -static void PCtoRDRSecure( void ) -{ - TRACE_DEBUG("PCtoRDRSecure\n\r"); - - TRACE_DEBUG("For user\n\r"); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command is used to manage motorized type CCID functionality. -/// The Lock Card function is used to hold the ICC. -/// This prevents an ICC from being easily removed from the CCID. -/// The Unlock Card function is used to remove the hold initiated by the Lock -/// Card function -//------------------------------------------------------------------------------ -static void PCtoRDRMechanical( void ) -{ - TRACE_DEBUG("PCtoRDRMechanical\n\r"); - TRACE_DEBUG("Not implemented\n\r"); - - RDRtoPCSlotStatus(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command is used with the Control pipe Abort request to tell the CCID -/// to stop any current transfer at the specified slot and return to a state -/// where the slot is ready to accept a new command pipe Bulk-OUT message. -//------------------------------------------------------------------------------ -static void PCtoRDRAbort( void ) -{ - TRACE_DEBUG("PCtoRDRAbort\n\r"); - - RDRtoPCSlotStatus(); -} - -//------------------------------------------------------------------------------ -/// Command Pipe, Bulk-OUT Messages -/// This command is used to manually set the data rate and clock frequency of -/// a specific slot. -//------------------------------------------------------------------------------ -static void PCtoRDRSetDataRateAndClockFrequency( void ) -{ - unsigned int dwClockFrequency; - unsigned int dwDataRate; - - TRACE_DEBUG("PCtoRDRSetDatarateandClockFrequency\n\r"); - - dwClockFrequency = ccidDriver.sCcidCommand.APDU[0] - + (ccidDriver.sCcidCommand.APDU[1]<<8) - + (ccidDriver.sCcidCommand.APDU[2]<<16) - + (ccidDriver.sCcidCommand.APDU[3]<<24); - - dwDataRate = ccidDriver.sCcidCommand.APDU[4] - + (ccidDriver.sCcidCommand.APDU[5]<<8) - + (ccidDriver.sCcidCommand.APDU[6]<<16) - + (ccidDriver.sCcidCommand.APDU[7]<<24); - - ISO7816_SetDataRateandClockFrequency( dwClockFrequency, dwDataRate ); - - RDRtoPCDataRateAndClockFrequency( dwClockFrequency, dwDataRate ); - -} - -//------------------------------------------------------------------------------ -/// Report the CMD_NOT_SUPPORTED error to the host -//------------------------------------------------------------------------------ -static void vCCIDCommandNotSupported( void ) -{ - // Command not supported - // vCCIDReportError(CMD_NOT_SUPPORTED); - - TRACE_DEBUG("CMD_NOT_SUPPORTED\n\r"); - - // Header fields settings - ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS; - ccidDriver.sCcidMessage.wLength = 0; - ccidDriver.sCcidMessage.bSpecific = 0; - - ccidDriver.sCcidMessage.bStatus |= ICC_CS_FAILED; - - // Send the response to the host - //vCCIDSendResponse(); -} - -//------------------------------------------------------------------------------ -/// Sent CCID response on USB -//------------------------------------------------------------------------------ -static void vCCIDSendResponse( void ) -{ - unsigned char bStatus; - - do { - bStatus = USBD_Write( CCID_EPT_DATA_IN, (void*)&ccidDriver.sCcidMessage, - ccidDriver.sCcidMessage.bSizeToSend, 0, 0 ); - } - while (bStatus != USBD_STATUS_SUCCESS); -} - - -//------------------------------------------------------------------------------ -/// Description: CCID Command dispatcher -//------------------------------------------------------------------------------ -static void CCIDCommandDispatcher( void ) -{ - unsigned char MessageToSend = 0; - - //TRACE_DEBUG("Command: 0x%X 0x%x 0x%X 0x%X 0x%X 0x%X 0x%X\n\r\n\r", - // (unsigned int)ccidDriver.sCcidCommand.bMessageType, - // (unsigned int)ccidDriver.sCcidCommand.wLength, - // (unsigned int)ccidDriver.sCcidCommand.bSlot, - // (unsigned int)ccidDriver.sCcidCommand.bSeq, - // (unsigned int)ccidDriver.sCcidCommand.bSpecific_0, - // (unsigned int)ccidDriver.sCcidCommand.bSpecific_1, - // (unsigned int)ccidDriver.sCcidCommand.bSpecific_2); - - // Check the slot number - if ( ccidDriver.sCcidCommand.bSlot > 0 ) { - - TRACE_ERROR("BAD_SLOT_NUMBER\n\r"); - } - - TRACE_DEBUG("typ=0x%X\n\r", ccidDriver.sCcidCommand.bMessageType); - - ccidDriver.sCcidMessage.bStatus = 0; - - ccidDriver.sCcidMessage.bSeq = ccidDriver.sCcidCommand.bSeq; - ccidDriver.sCcidMessage.bSlot = ccidDriver.sCcidCommand.bSlot; - - ccidDriver.sCcidMessage.bSizeToSend = sizeof(S_ccid_bulk_in_header)-(ABDATA_SIZE+1); - - - // Command dispatcher - switch ( ccidDriver.sCcidCommand.bMessageType ) { - - case PC_TO_RDR_ICCPOWERON: - PCtoRDRIccPowerOn(); - MessageToSend = 1; - break; - - case PC_TO_RDR_ICCPOWEROFF: - PCtoRDRIccPowerOff(); - MessageToSend = 1; - break; - - case PC_TO_RDR_GETSLOTSTATUS: - PCtoRDRGetSlotStatus(); - MessageToSend = 1; - break; - - case PC_TO_RDR_XFRBLOCK: - PCtoRDRXfrBlock(); - MessageToSend = 1; - break; - - case PC_TO_RDR_GETPARAMETERS: - PCtoRDRGetParameters(); - MessageToSend = 1; - break; - - case PC_TO_RDR_RESETPARAMETERS: - PCtoRDRResetParameters(); - MessageToSend = 1; - break; - - case PC_TO_RDR_SETPARAMETERS: - PCtoRDRSetParameters(); - MessageToSend = 1; - break; - - case PC_TO_RDR_ESCAPE: - PCtoRDREscape(); - MessageToSend = 1; - break; - - case PC_TO_RDR_ICCCLOCK: - PCtoRDRICCClock(); - MessageToSend = 1; - break; - - case PC_TO_RDR_T0APDU: - // Only CCIDs reporting a short or extended APDU level in the dwFeatures - // field of the CCID class descriptor may take this command into account. - if( (CCID_FEATURES_EXC_SAPDU == (CCID_FEATURES_EXC_SAPDU&configurationDescriptorsFS.ccid.dwFeatures)) - || (CCID_FEATURES_EXC_APDU == (CCID_FEATURES_EXC_APDU &configurationDescriptorsFS.ccid.dwFeatures)) ) { - - // command supported - PCtoRDRtoAPDU(); - } - else { - // command not supported - TRACE_DEBUG("PC_TO_RDR_T0APDU\n\r"); - vCCIDCommandNotSupported(); - } - MessageToSend = 1; - break; - - case PC_TO_RDR_SECURE: - PCtoRDRSecure(); - MessageToSend = 1; - break; - - case PC_TO_RDR_MECHANICAL: - PCtoRDRMechanical(); - MessageToSend = 1; - break; - - case PC_TO_RDR_ABORT: - PCtoRDRAbort(); - MessageToSend = 1; - break; - - case PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY: - PCtoRDRSetDataRateAndClockFrequency(); - MessageToSend = 1; - break; - - default: - TRACE_DEBUG("default: 0x%X\n\r", ccidDriver.sCcidCommand.bMessageType); - vCCIDCommandNotSupported(); - MessageToSend = 1; - break; - - } - - if( MessageToSend == 1 ) { - vCCIDSendResponse(); - } -} - - -//------------------------------------------------------------------------------ -/// SETUP request handler for a CCID device -/// \param pRequest Pointer to a USBGenericRequest instance -//------------------------------------------------------------------------------ -static void CCID_RequestHandler(const USBGenericRequest *pRequest) -{ - TRACE_DEBUG("CCID_RHl\n\r"); - - // Check if this is a class request - if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_CLASS) { - - // Check if the request is supported - switch (USBGenericRequest_GetRequest(pRequest)) { - - case CCIDGenericRequest_ABORT: - TRACE_DEBUG("CCIDGenericRequest_ABORT\n\r"); - break; - - case CCIDGenericRequest_GET_CLOCK_FREQUENCIES: - TRACE_DEBUG("Not supported\n\r"); - // A CCID with bNumClockSupported equal to 00h does not have - // to support this request - break; - - case CCIDGenericRequest_GET_DATA_RATES: - TRACE_DEBUG("Not supported\n\r"); - // A CCID with bNumDataRatesSupported equal to 00h does not have - // to support this request. - break; - - default: - TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(pRequest)); - USBD_Stall(0); - } - } - - else if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_STANDARD) { - - // Forward request to the standard handler - USBDDriver_RequestHandler(&(ccidDriver.usbdDriver), pRequest); - } - else { - - // Unsupported request type - TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(pRequest)); - USBD_Stall(0); - } -} - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Optional callback re-implementation -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) -// not static function -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - CCID_RequestHandler(request); -} -#endif - - -//------------------------------------------------------------------------------ -/// Handles SmartCart request -//------------------------------------------------------------------------------ -void CCID_SmartCardRequest( void ) -{ - unsigned char bStatus; - - do { - - bStatus = CCID_Read( (void*)&ccidDriver.sCcidCommand, - sizeof(S_ccid_bulk_out_header), - (TransferCallback)&CCIDCommandDispatcher, - (void*)0 ); - } - while (bStatus != USBD_STATUS_SUCCESS); - -} - -//------------------------------------------------------------------------------ -/// Initializes the CCID device driver. -//------------------------------------------------------------------------------ -void CCIDDriver_Initialize( void ) -{ - TRACE_DEBUG("CCID_Init\n\r"); - USBDDriver_Initialize(&(ccidDriver.usbdDriver), - &ccidDriverDescriptors, - 0); // Multiple interface settings not supported - USBD_Init(); -} - -//------------------------------------------------------------------------------ -/// Reads data from the Data OUT endpoint -/// \param pBuffer Buffer to store the received data -/// \param dLength data buffer length -/// \param fCallback Optional callback function -/// \param pArgument Optional parameter for the callback function -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char CCID_Read(void *pBuffer, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument) -{ - return USBD_Read(CCID_EPT_DATA_OUT, pBuffer, dLength, fCallback, pArgument); -} - -//------------------------------------------------------------------------------ -/// Sends data through the Data IN endpoint -/// \param pBuffer Buffer holding the data to transmit -/// \param dLength Length of data buffer -/// \param fCallback Optional callback function -/// \param pArgument Optional parameter for the callback function -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char CCID_Write(void *pBuffer, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument) -{ - return USBD_Write(CCID_EPT_DATA_IN, pBuffer, dLength, fCallback, pArgument); -} - -//------------------------------------------------------------------------------ -/// Sends data through the interrupt endpoint, ICC insertion event -/// RDR_to_PC_NotifySlotChange -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char CCID_Insertion( void ) -{ - TRACE_DEBUG("CCID_Insertion\n\r"); - - // Build the Interrupt-IN message - ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE; - ccidDriver.BufferINT[1] = ICC_INSERTED_EVENT; - ccidDriver.SlotStatus = ICC_INSERTED_EVENT; - - // Notify the host that a ICC is inserted - return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 ); -} - -//------------------------------------------------------------------------------ -/// Sends data through the interrupt endpoint, ICC removal event -/// RDR_to_PC_NotifySlotChange -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char CCID_Removal( void ) -{ - TRACE_DEBUG("CCID_Removal\n\r"); - - // Build the Interrupt-IN message - ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE; - ccidDriver.BufferINT[1] = ICC_NOT_PRESENT; - ccidDriver.SlotStatus = ICC_NOT_PRESENT; - - // Notify the host that a ICC is inserted - return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 ); -} - -//------------------------------------------------------------------------------ -/// Interrupt-IN Messages -/// This message is sent when any bit in the bHardwareErrorCode field is set. -/// If this message is sent when there is no “outstanding” command, the bSeq -/// field will be undefined. -/// \param bSlot ICC slot number -/// \param bSeq Sequence number of the bulk OUT command when the hardware error -/// occured -/// \param bHardwareErrorCode Hardware error code -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char RDRtoPCHardwareError( unsigned char bSlot, - unsigned char bSeq, - unsigned char bHardwareErrorCode ) -{ - TRACE_DEBUG("RDRtoPCHardwareError\n\r"); - - // Build the Interrupt-IN message - ccidDriver.BufferINT[0] = RDR_TO_PC_HARDWAREERROR; - ccidDriver.BufferINT[1] = bSlot; - ccidDriver.BufferINT[2] = bSeq; - ccidDriver.BufferINT[3] = bHardwareErrorCode; - - // Notify the host that a ICC is inserted - return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 4, 0, 0 ); -} - - diff --git a/src/ersky9x/libraries/usb/device/ccid/cciddriver.h b/src/ersky9x/libraries/usb/device/ccid/cciddriver.h deleted file mode 100644 index 8bac28690..000000000 --- a/src/ersky9x/libraries/usb/device/ccid/cciddriver.h +++ /dev/null @@ -1,378 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !Purpose -/// -/// Definition of methods for using a CCID device driver. -/// -/// !Usage -/// -/// -# CCIDDriver_Initialize -/// -# CCID_Read -/// -# CCID_Write -/// -# CCID_SmartCardRequest -/// -# CCID_Insertion -/// -# CCID_Removal -/// -# RDRtoPCHardwareError -//------------------------------------------------------------------------------ - -#ifndef CCID_DRIVER_H -#define CCID_DRIVER_H - -/// For reference, the absolute maximum block size -/// for a TPDU T=0 block is 260 bytes (5 bytes command; 255 bytes data), or -/// for a TPDU T=1 block is 259 bytes, or -/// for a short APDU T=1 block is 261 bytes, or -/// for an extended APDU T=1 block is 65544 bytes. -#define ABDATA_SIZE 260 - -/// define protocol T=0 -#define PROTOCOL_TO 0 -/// define protocol T=1 -#define PROTOCOL_T1 1 - -/// define for dwFeatures see Table 5.1-1 Smart Card Device Class Descriptors -/// No special characteristics -#define CCID_FEATURES_NADA 0x00000000 -/// Automatic parameter configuration based on ATR data -#define CCID_FEATURES_AUTO_PCONF 0x00000002 -/// Automatic activation of ICC on inserting -#define CCID_FEATURES_AUTO_ACTIV 0x00000004 -/// Automatic ICC voltage selection -#define CCID_FEATURES_AUTO_VOLT 0x00000008 -/// Automatic ICC clock frequency change according to active parameters provided -/// by the Host or self determined -#define CCID_FEATURES_AUTO_CLOCK 0x00000010 -/// Automatic baud rate change according to active parameters provided by the -/// Host or self determined -#define CCID_FEATURES_AUTO_BAUD 0x00000020 -/// Automatic parameters negotiation made by the CCID (use of warm or cold -/// resets or PPS according to a manufacturer proprietary algorithm to select -/// the communication parameters with the ICC) -#define CCID_FEATURES_AUTO_PNEGO 0x00000040 -/// Automatic PPS made by the CCID according to the active parameters -#define CCID_FEATURES_AUTO_PPS 0x00000080 -/// CCID can set ICC in clock stop mode -#define CCID_FEATURES_ICCSTOP 0x00000100 -/// NAD value other than 00 accepted (T=1 protocol in use) -#define CCID_FEATURES_NAD 0x00000200 -/// Automatic IFSD exchange as first exchange (T=1 protocol in use) -#define CCID_FEATURES_AUTO_IFSD 0x00000400 -/// TPDU level exchanges with CCID -#define CCID_FEATURES_EXC_TPDU 0x00010000 -/// Short APDU level exchange with CCID -#define CCID_FEATURES_EXC_SAPDU 0x00020000 -/// Short and Extended APDU level exchange with CCID -#define CCID_FEATURES_EXC_APDU 0x00040000 -/// USB Wake up signaling supported on card insertion and removal -#define CCID_FEATURES_WAKEUP 0x00100000 - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/// Bulk CCID Message header structure -typedef struct -{ - unsigned char bMessageType; - /// Message-specific data length - unsigned long wLength; - /// Identifies the slot number for this command - unsigned char bSlot; - /// Sequence number for command. - unsigned char bSeq; - /// Slot status register - unsigned char bStatus; - /// Slot error - unsigned char bError; - /// specific register - unsigned char bSpecific; - /// Data block sent to the CCID. - unsigned char abData[ABDATA_SIZE]; - unsigned char bSizeToSend; -} __attribute__ ((packed)) S_ccid_bulk_in_header; - -/// 6.1 Bulk Transfers -typedef struct -{ - unsigned char bMessageType; - /// Message-specific data length - unsigned long wLength; - /// Identifies the slot number for this command - unsigned char bSlot; - /// Sequence number for command. - unsigned char bSeq; - /// specific register - unsigned char bSpecific_0; - unsigned char bSpecific_1; - unsigned char bSpecific_2; - /// Application Protocol Data Unit - unsigned char APDU[ABDATA_SIZE]; -} __attribute__ ((packed)) S_ccid_bulk_out_header; - - -/// 6.1.11.2 PIN Verification Data Structure -typedef struct -{ - /// Number of seconds. - unsigned char bTimerOut; - /// Several parameters for the PIN format options - unsigned char bmFormatString; - /// Define the length of the PIN to present in the APDU command - unsigned char bmPINBlockString; - /// Allows the length PIN insertion in the APDU command - unsigned char bmPINLengthFormat; - /// Minimum PIN size in digit and Maximum PIN size in digit - unsigned char wPINMaxExtraDigit; - /// The value is a bit wise OR operation. - unsigned char bEntryValidationCondition; - /// Number of messages to display for the PIN modify command - unsigned char bNumberMessage; - /// Language used to display the messages. - unsigned char wLangId; - /// Message index in the Reader message table - unsigned char bMsgIndex; - /// T=1 I-block prologue field to use - unsigned char bTeoPrologue[3]; - /// APDU to send to the ICC - unsigned char abPINApdu[255]; -}__attribute__ ((packed)) S_ccid_PIN_Verification; - - -/// 6.1.11.7 PIN Modification Data Structure -typedef struct -{ - /// Number of seconds. If 00h then CCID default value is used. - unsigned char bTimeOut; - /// Several parameters for the PIN format options (defined in § 6.1.11.4) - unsigned char bmFormatString4; - /// Define the length of the PIN to present in the APDU command - unsigned char bmPINBlockString; - /// Allows the length PIN insertion in the APDU command (defined in § 6.1.11.6) - unsigned char bmPinLengthFormat; - /// Insertion position offset in byte for the current PIN - unsigned char bInsertionOffsetOld; - /// Insertion position offset in byte for the new PIN - unsigned char bInsertionOffsetNew; - /// XXYYh - /// XX: Minimum PIN size in digit - /// YY: Maximum PIN size in digit - unsigned char wPINMaxExtraDigit; - /// 00h,01h,02h,03h - /// Indicates if a confirmation is requested before acceptance of a new PIN (meaning that the user has to enter this new PIN twice before it is accepted) - /// Indicates if the current PIN must be entered and set in the same APDU field of not. - unsigned char bConfirmPIN; - /// The value is a bit wise OR operation. - /// 01h Max size reached - /// 02h Validation key pressed - /// 04h Timeout occurred - unsigned char bEntryValidationCondition; - /// 00h,01h,02h,03h,or FFh - /// Number of messages to display for the PIN modify command. - unsigned char bNumberMessage; - /// Language used to display the messages. The 16 bit - unsigned char wLangId; - /// Message index in the Reader message table (should be 00h or 01h). - unsigned char bMsgIndex1; - /// Message index in the Reader message table (should be 01h or 02h). - unsigned char bMsgIndex2; - /// Message index in the Reader message table (should be 02h). - unsigned char bMsgIndex3; - /// T=1 I-block prologue field to use. Significant only if protocol in use is T=1. - unsigned char bTeoPrologue[3]; - /// Byte array APDU to send to the ICC - unsigned char abPINApdu[255]; -}__attribute__ ((packed)) S_ccid_PIN_Modification; - -/// Protocol Data Structure for Protocol T=0 (bProtocolNum=0, dwLength=00000005h) -typedef struct -{ - /// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a - /// clock rate conversion factor - /// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a - /// baud rate conversion factor - unsigned char bmFindexDindex; - /// For T=0 ,B0 – 0b, B7-2 – 000000b - /// B1 – Convention used (b1=0 for direct, b1=1 for inverse) - unsigned char bmTCCKST0; // 0 to 2 - /// Extra Guardtime between two characters. Add 0 to 254 etu to the normal - /// guardtime of 12etu. FFh is the same as 00h. - unsigned char bGuardTimeT0; // 0 to FF - /// WI for T=0 used to define WWT - unsigned char bWaitingIntegerT0; // 0 to FF - /// ICC Clock Stop Support - /// 00 = Stopping the Clock is not allowed - /// 01 = Stop with Clock signal Low - /// 02 = Stop with Clock signal High - /// 03 = Stop with Clock either High or Low - unsigned char bClockStop; // 0 to 3 -} __attribute__ ((packed)) S_ccid_protocol_t0; - - -/// Protocol Data Structure for Protocol T=1 (bProtocolNum=1, dwLength=00000007h) -typedef struct -{ - /// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a - /// clock rate conversion factor - /// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a - /// baud rate conversion factor - unsigned char bmFindexDindex; - /// For T=1, B7-2 – 000100b - /// B0 – Checksum type (b0=0 for LRC, b0=1 for CRC - /// B1 – Convention used (b1=0 for direct, b1=1 for inverse) - unsigned char bmTCCKST1; // 10h, 11h, 12h, 13h - /// Extra Guardtime (0 to 254 etu between two characters). - /// If value is FFh, then guardtime is reduced by 1. - unsigned char bGuardTimeT1; // 0 to FF - /// B7-4 = BWI - /// B3-0 = CWI - unsigned char bmWaitingIntegersT1; // 0 to 9 - /// ICC Clock Stop Support - /// 00 = Stopping the Clock is not allowed - /// 01 = Stop with Clock signal Low - /// 02 = Stop with Clock signal High - /// 03 = Stop with Clock either High or Low - unsigned char bClockStop; // 0 to 3 - /// Size of negotiated IFSC - unsigned char bIFSC; // 0 to FE - /// Nad value used by CCID - unsigned char bNadValue; // 0 to FF -} __attribute__ ((packed)) S_ccid_protocol_t1; - - -/// Identifies the length of type of subordinate descriptors of a CCID device -/// Table 5.1-1 Smart Card Device Class descriptors -typedef struct -{ - /// Size of this descriptor, in bytes. - unsigned char bLength; - /// Functional Descriptor type - unsigned char bDescriptorType; - /// Integrated Circuit(s) Cards Interface Devices (CCID) Specification - /// Release Number - unsigned short bcdCCID; - /// Index of the highest available slot. An USB-ICC is regarded as a single - /// slot CCID. - unsigned char bMaxSlotIndex; - /// This value indicates what voltages the CCID can supply to its slots. - /// It is a bitwise OR operation performed on the following values: - /// - 01h 5.0V - /// - 02h 3.0V - /// - 04h 1.8V - /// Other bits are RFU. - unsigned char bVoltageSupport; - /// RRRR –Upper Word- is RFU = 0000h - /// PPPP –Lower Word- Encodes the supported protocol types. A ‘1’ in a given - /// bit position indicates support for the associated ISO protocol. - /// 0001h = Protocol T=0 - /// 0002h = Protocol T=1 - /// All other bits are reserved and must be set to zero. The field is - /// intended to correspond to the PCSC specification definitions. - unsigned long dwProtocols; - /// Default ICC clock frequency in KHz. This is an integer value. - unsigned long dwDefaultClock; - /// Maximum supported ICC clock frequency in KHz. This is an integer value. - unsigned long dwMaximumClock; - /// The number of clock frequencies that are supported by the CCID. If the - /// value is 00h, the supported clock frequencies are assumed to be the - /// default clock frequency defined by dwDefaultClock and the maximum clock - /// frequency defined by dwMaximumClock. - unsigned char bNumClockSupported; - /// Default ICC I/O data rate in bps. This is an integer value - unsigned long dwDataRate; - /// Maximum supported ICC I/O data rate in bps - unsigned long dwMaxDataRate; - /// The number of data rates that are supported by the CCID. - unsigned char bNumDataRatesSupported; - /// Indicates the maximum IFSD supported by CCID for protocol T=1. - unsigned long dwMaxIFSD; - /// - RRRR-Upper Word- is RFU = 0000h - /// - PPPP-Lower Word- encodes the supported protocol types. A ‘1’ in a given - /// bit position indicates support for the associated protocol. - /// 0001h indicates support for the 2-wire protocol 1 - /// 0002h indicates support for the 3-wire protocol 1 - /// 0004h indicates support for the I2C protocol 1 - /// All other values are outside of this specification, and must be handled - /// by vendor-supplied drivers. - unsigned long dwSynchProtocols; - /// The value is a bitwise OR operation performed on the following values: - /// - 00000000h No special characteristics - /// - 00000001h Card accept mechanism 2 - /// - 00000002h Card ejection mechanism 2 - /// - 00000004h Card capture mechanism 2 - /// - 00000008h Card lock/unlock mechanism - unsigned long dwMechanical; - /// This value indicates what intelligent features the CCID has. - unsigned long dwFeatures; - /// For extended APDU level the value shall be between 261 + 10 (header) and - /// 65544 +10, otherwise the minimum value is the wMaxPacketSize of the - /// Bulk-OUT endpoint. - unsigned long dwMaxCCIDMessageLength; - /// Significant only for CCID that offers an APDU level for exchanges. - unsigned char bClassGetResponse; - /// Significant only for CCID that offers an extended APDU level for exchanges. - unsigned char bClassEnvelope; - /// Number of lines and characters for the LCD display used to send messages for PIN entry. - unsigned short wLcdLayout; - /// This value indicates what PIN support features the CCID has. - unsigned char bPINSupport; - /// Maximum number of slots which can be simultaneously busy. - unsigned char bMaxCCIDBusySlots; - -} __attribute__ ((packed)) CCIDDescriptor; - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern unsigned char RDRtoPCHardwareError( unsigned char bSlot, - unsigned char bSeq, - unsigned char bHardwareErrorCode ); - -#if !defined(NOAUTOCALLBACK) -extern void USBDCallbacks_RequestReceived(const USBGenericRequest *pRequest); -#endif -extern void CCID_SmartCardRequest( void ); -extern void CCIDDriver_Initialize( void ); -extern unsigned char CCID_Read(void *pBuffer, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument); -extern unsigned char CCID_Write(void *pBuffer, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument); -extern unsigned char CCID_Insertion( void ); -extern unsigned char CCID_Removal( void ); - -#endif //#ifndef CCID_DRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/ccid/cciddriverdescriptors.h b/src/ersky9x/libraries/usb/device/ccid/cciddriverdescriptors.h deleted file mode 100644 index 2daea671e..000000000 --- a/src/ersky9x/libraries/usb/device/ccid/cciddriverdescriptors.h +++ /dev/null @@ -1,152 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Title: cciddriverdescriptors.h -// -// About: Purpose -// Definitions of the descriptors required by the ccid device driver. -// DWG_Smart-Card_CCID_Rev110.pdf -//------------------------------------------------------------------------------ - -#ifndef CCID_DRIVER_DESCRIPTORS_H -#define CCID_DRIVER_DESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Constants: Endpoints -// CCID_EPT_DATA_OUT endpoint data out bulk 1 -// CCID_EPT_DATA_IN endpoint data in bulk 2 -// CCID_EPT_NOTIFICATION endpoint data interupt 3 -//------------------------------------------------------------------------------ -#define CCID_EPT_DATA_OUT 1 -#define CCID_EPT_DATA_IN 2 -#define CCID_EPT_NOTIFICATION 3 - -//------------------------------------------------------------------------------ -// USB-ICC protocol -//------------------------------------------------------------------------------ -// CCID specification version 1.10 -#define CCID1_10 0x0110 - -#define SMART_CARD_DEVICE_CLASS 0x0B -// Smart Card Device Class Descriptor Type -#define CCID_DECRIPTOR_TYPE 0x21 - -// Table 5.3-1 Summary of CCID Class Specific Request -#define CCIDGenericRequest_ABORT 0x01 -#define CCIDGenericRequest_GET_CLOCK_FREQUENCIES 0x02 -#define CCIDGenericRequest_GET_DATA_RATES 0x03 - -// 6.1 Command Pipe, Bulk-OUT Messages -#define PC_TO_RDR_ICCPOWERON 0x62 -#define PC_TO_RDR_ICCPOWEROFF 0x63 -#define PC_TO_RDR_GETSLOTSTATUS 0x65 -#define PC_TO_RDR_XFRBLOCK 0x6F -#define PC_TO_RDR_GETPARAMETERS 0x6C -#define PC_TO_RDR_RESETPARAMETERS 0x6D -#define PC_TO_RDR_SETPARAMETERS 0x61 -#define PC_TO_RDR_ESCAPE 0x6B -#define PC_TO_RDR_ICCCLOCK 0x6E -#define PC_TO_RDR_T0APDU 0x6A -#define PC_TO_RDR_SECURE 0x69 -#define PC_TO_RDR_MECHANICAL 0x71 -#define PC_TO_RDR_ABORT 0x72 -#define PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY 0x73 - -// 6.2 Response Pipe, Bulk-IN Messages -#define RDR_TO_PC_DATABLOCK 0x80 -#define RDR_TO_PC_SLOTSTATUS 0x81 -#define RDR_TO_PC_PARAMETERS 0x82 -#define RDR_TO_PC_ESCAPE 0x83 -#define RDR_TO_PC_DATARATEANDCLOCKFREQUENCY 0x84 - -// 6.3 Interrupt-IN Messages -#define RDR_TO_PC_NOTIFYSLOTCHANGE 0x50 -#define RDR_TO_PC_HARDWAREERROR 0x51 - -// Table 6.2-2 Slot error register when bmCommandStatus = 1 -#define CMD_ABORTED 0xFF -#define ICC_MUTE 0xFE -#define XFR_PARITY_ERROR 0xFD -#define XFR_OVERRUN 0xFC -#define HW_ERROR 0xFB -#define BAD_ATR_TS 0xF8 -#define BAD_ATR_TCK 0xF7 -#define ICC_PROTOCOL_NOT_SUPPORTED 0xF6 -#define ICC_CLASS_NOT_SUPPORTED 0xF5 -#define PROCEDURE_BYTE_CONFLICT 0xF4 -#define DEACTIVATED_PROTOCOL 0xF3 -#define BUSY_WITH_AUTO_SEQUENCE 0xF2 -#define PIN_TIMEOUT 0xF0 -#define PIN_CANCELLED 0xEF -#define CMD_SLOT_BUSY 0xE0 -// User defined 0xC0 to 0x81 -// Reserved for futur use 0x80 -// not supported incorrect message parameter 0x7F to 0x01 -// Command not supported 0x00 - -// CCID rev 1.1, p.27 -#define VOLTS_AUTO 0x00 -#define VOLTS_5_0 0x01 -#define VOLTS_3_0 0x02 -#define VOLTS_1_8 0x03 - -// 6.3.1 RDR_to_PC_NotifySlotChange -#define ICC_NOT_PRESENT 0x00 -#define ICC_PRESENT 0x01 -#define ICC_CHANGE 0x02 -#define ICC_INSERTED_EVENT ICC_PRESENT+ICC_CHANGE - -// ICCD: Table 6.1-8 Bitmap for bStatus field -#define ICC_BS_PRESENT_ACTIVATED 0x00 // USB-ICC is present and activated -#define ICC_BS_PRESENT_NOTACTIVATED 0x01 // USB-ICC is present but not activated -#define ICC_BS_NOTPRESENT 0x02 // USB-ICC is virtually not present -#define ICC_BS_RFU 0x03 // RFU -#define ICC_CS_NO_ERROR (0x00<<6) // Processed without error -#define ICC_CS_FAILED (0x01<<6) // Failed, error condition given by bError -#define ICC_CS_TIME_EXT (0x02<<6) // Time extension is requested -#define ICC_CS_RFU (0x03<<6) // RFU - -/* -#define NO_ERROR 0x00 -#define NO_EXTRA_BYTES 0x00 -#define CCID_FLAG_INITIAL_VALUE 0x05 -#define CCID_EVENT_SIZE 0x02 -#define STATUS_MASK 0x41 -*/ -//------------------------------------------------------------------------------ -// Structures -//------------------------------------------------------------------------------ - -#endif //#ifndef CCID_DRIVER_DESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.c b/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.c deleted file mode 100644 index 3e58592b5..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.c +++ /dev/null @@ -1,300 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: CDCDSerialDriver implementation - - About: Purpose - Implementation of the CDCDSerialDriver class methods. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "CDCDSerialDriver.h" -#include "CDCDSerialDriverDescriptors.h" -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USB driver for a CDC class implementing a virtual COM serial connection. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard USBDDriver instance. - USBDDriver usbdDriver; - /// Current line coding (baudrate, parity, stop bits). - CDCLineCoding lineCoding; - /// Indicates if the RS232 carrier is active. - unsigned char isCarrierActivated; - /// Current serial port states - unsigned short serialState; - -} CDCDSerialDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Static instance of the CDC serial driver. -static CDCDSerialDriver cdcdSerialDriver; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback function which should be invoked after the data of a -/// SetLineCoding request has been retrieved. Sends a zero-length packet -/// to the host for acknowledging the request. -//------------------------------------------------------------------------------ -static void CDCDSerialDriver_SetLineCodingCallback() -{ - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Receives new line coding information from the USB host. -//------------------------------------------------------------------------------ -static void CDCDSerialDriver_SetLineCoding() -{ - TRACE_INFO_WP("sLineCoding "); - - USBD_Read(0, - (void *) &(cdcdSerialDriver.lineCoding), - sizeof(CDCLineCoding), - (TransferCallback) CDCDSerialDriver_SetLineCodingCallback, - 0); -} - -//------------------------------------------------------------------------------ -/// Sends the current line coding information to the host through Control -/// endpoint 0. -//------------------------------------------------------------------------------ -static void CDCDSerialDriver_GetLineCoding() -{ - TRACE_INFO_WP("gLineCoding "); - - USBD_Write(0, - (void *) &(cdcdSerialDriver.lineCoding), - sizeof(CDCLineCoding), - 0, - 0); -} - -//------------------------------------------------------------------------------ -/// Changes the state of the serial driver according to the information -/// sent by the host via a SetControlLineState request, and acknowledges -/// the request with a zero-length packet. -//------------------------------------------------------------------------------ -static void CDCDSerialDriver_SetControlLineState(unsigned char activateCarrier, - unsigned char isDTEPresent) -{ - TRACE_INFO_WP( - "sControlLineState(%d, %d) ", - activateCarrier, - isDTEPresent); - - cdcdSerialDriver.isCarrierActivated = activateCarrier; - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -// Optional RequestReceived() callback re-implementation -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) - -//------------------------------------------------------------------------------ -/// Re-implemented callback, invoked when a new USB Request is received. -//------------------------------------------------------------------------------ -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - CDCDSerialDriver_RequestHandler(request); -} - -#endif - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the USB Device CDC serial driver & USBD Driver. -//------------------------------------------------------------------------------ -void CDCDSerialDriver_Initialize() -{ - TRACE_INFO("CDCDSerialDriver_Initialize\n\r"); - - // Initialize Abstract Control Model attributes - CDCLineCoding_Initialize(&(cdcdSerialDriver.lineCoding), - 115200, - CDCLineCoding_ONESTOPBIT, - CDCLineCoding_NOPARITY, - 8); - cdcdSerialDriver.isCarrierActivated = 0; - cdcdSerialDriver.serialState = 0; - - // Initialize the standard driver - USBDDriver_Initialize(&(cdcdSerialDriver.usbdDriver), - &cdcdSerialDriverDescriptors, - 0); // Multiple settings for interfaces not supported - - // Initialize the USB driver - USBD_Init(); -} - -//------------------------------------------------------------------------------ -/// Handles CDC-specific SETUP requests. Should be called from a -/// re-implementation of USBDCallbacks_RequestReceived() method. -/// \param Pointer to a USBGenericRequest instance. -//------------------------------------------------------------------------------ -void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request) -{ - TRACE_INFO_WP("NewReq "); - - // Handle the request - switch (USBGenericRequest_GetRequest(request)) { - - case CDCGenericRequest_SETLINECODING: - - CDCDSerialDriver_SetLineCoding(); - break; - - case CDCGenericRequest_GETLINECODING: - - CDCDSerialDriver_GetLineCoding(); - break; - - case CDCGenericRequest_SETCONTROLLINESTATE: - - CDCDSerialDriver_SetControlLineState( - CDCSetControlLineStateRequest_ActivateCarrier(request), - CDCSetControlLineStateRequest_IsDtePresent(request)); - - break; - - default: - - USBDDriver_RequestHandler(&(cdcdSerialDriver.usbdDriver), request); - break; - } -} - -//------------------------------------------------------------------------------ -/// Receives data from the host through the virtual COM port created by -/// the CDC device serial driver. This function behaves like USBD_Read. -/// \param data Pointer to the data buffer to put received data. -/// \param size Size of the data buffer in bytes. -/// \param callback Optional callback function to invoke when the transfer -/// finishes. -/// \param argument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the read operation has been started normally; -/// otherwise, the corresponding error code. -//------------------------------------------------------------------------------ -unsigned char CDCDSerialDriver_Read(void *data, - unsigned int size, - TransferCallback callback, - void *argument) -{ - return USBD_Read(CDCDSerialDriverDescriptors_DATAOUT, - data, - size, - callback, - argument); -} - -//------------------------------------------------------------------------------ -/// Sends a data buffer through the virtual COM port created by the CDC -/// device serial driver. This function behaves exactly like USBD_Write. -/// \param data Pointer to the data buffer to send. -/// \param size Size of the data buffer in bytes. -/// \param callback Optional callback function to invoke when the transfer -/// finishes. -/// \param argument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the read operation has been started normally; -/// otherwise, the corresponding error code. -//------------------------------------------------------------------------------ -unsigned char CDCDSerialDriver_Write(void *data, - unsigned int size, - TransferCallback callback, - void *argument) -{ - return USBD_Write(CDCDSerialDriverDescriptors_DATAIN, - data, - size, - callback, - argument); -} - -//------------------------------------------------------------------------------ -/// Returns the current status of the RS-232 line. -//------------------------------------------------------------------------------ -unsigned short CDCDSerialDriver_GetSerialState() -{ - return cdcdSerialDriver.serialState; -} - -//------------------------------------------------------------------------------ -/// Sets the current serial state of the device to the given value. -/// \param serialState New device state. -//------------------------------------------------------------------------------ -void CDCDSerialDriver_SetSerialState(unsigned short serialState) -{ - ASSERT((serialState & 0xFF80) == 0, - "CDCDSerialDriver_SetSerialState: Bits D7-D15 are reserved\n\r"); - - // If new state is different from previous one, send a notification to the - // host - if (cdcdSerialDriver.serialState != serialState) { - - cdcdSerialDriver.serialState = serialState; - USBD_Write(CDCDSerialDriverDescriptors_NOTIFICATION, - &(cdcdSerialDriver.serialState), - 2, - 0, - 0); - - // Reset one-time flags - cdcdSerialDriver.serialState &= ~(CDCDSerialDriver_STATE_OVERRUN - | CDCDSerialDriver_STATE_PARITY - | CDCDSerialDriver_STATE_FRAMING - | CDCDSerialDriver_STATE_RINGSIGNAL - | CDCDSerialDriver_STATE_BREAK); - } -} - diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.h b/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.h deleted file mode 100644 index 5ccc9017d..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriver.h +++ /dev/null @@ -1,117 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of a class for implementing a USB device CDC serial driver. - - !!!Usage - - -# Re-implement the USBDCallbacks_RequestReceived method to pass - received requests to CDCDSerialDriver_RequestHandler. *This is - automatically done unless the NOAUTOCALLBACK symbol is defined*. - -# Initialize the CDC serial and USB drivers using - CDCDSerialDriver_Initialize. - -# Logically connect the device to the host using USBD_Connect. - -# Send serial data to the USB host using CDCDSerialDriver_Write. - -# Receive serial data from the USB host using CDCDSerialDriver_Read. -*/ - -#ifndef CDCDSERIALDRIVER_H -#define CDCDSERIALDRIVER_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Serial Port States" -/// This page lists the bit map for CDC Serial Port States. -/// -/// !BitMaps -/// - CDCDSerialDriver_STATE_RXDRIVER -/// - CDCDSerialDriver_STATE_TXCARRIER -/// - CDCDSerialDriver_STATE_BREAK -/// - CDCDSerialDriver_STATE_RINGSIGNAL -/// - CDCDSerialDriver_STATE_FRAMING -/// - CDCDSerialDriver_STATE_PARITY -/// - CDCDSerialDriver_STATE_OVERRUN - -/// Indicates the receiver carrier signal is present. -#define CDCDSerialDriver_STATE_RXDRIVER (1 << 0) -/// Indicates the transmission carrier signal is present. -#define CDCDSerialDriver_STATE_TXCARRIER (1 << 1) -/// Indicates a break has been detected. -#define CDCDSerialDriver_STATE_BREAK (1 << 2) -/// Indicates a ring signal has been detected. -#define CDCDSerialDriver_STATE_RINGSIGNAL (1 << 3) -/// Indicates a framing error has occured. -#define CDCDSerialDriver_STATE_FRAMING (1 << 4) -/// Indicates a parity error has occured. -#define CDCDSerialDriver_STATE_PARITY (1 << 5) -/// Indicates a data overrun error has occured. -#define CDCDSerialDriver_STATE_OVERRUN (1 << 6) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void CDCDSerialDriver_Initialize(); - -extern void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned char CDCDSerialDriver_Write( - void *data, - unsigned int size, - TransferCallback callback, - void *argument); - -extern unsigned char CDCDSerialDriver_Read( - void *data, - unsigned int size, - TransferCallback callback, - void *argument); - -extern unsigned short CDCDSerialDriver_GetSerialState(); - -extern void CDCDSerialDriver_SetSerialState(unsigned short serialState); - -#endif //#ifndef CDCSERIALDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c b/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c deleted file mode 100644 index 8864451f6..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c +++ /dev/null @@ -1,661 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "CDCDSerialDriverDescriptors.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Serial Device IDs" -/// This page lists the IDs used in the CDC Serial Device Descriptor. -/// -/// !IDs -/// - CDCDSerialDriverDescriptors_PRODUCTID -/// - CDCDSerialDriverDescriptors_VENDORID -/// - CDCDSerialDriverDescriptors_RELEASE - -/// Device product ID. -#define CDCDSerialDriverDescriptors_PRODUCTID 0x6119 -/// Device vendor ID (Atmel). -#define CDCDSerialDriverDescriptors_VENDORID 0x03EB -/// Device release number. -#define CDCDSerialDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Macros -//------------------------------------------------------------------------------ - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//------------------------------------------------------------------------------ -// Internal structures -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Configuration descriptor list for a device implementing a CDC serial driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; -#if defined(CHIP_USB_OTGHS) - // OTG descriptor - USBOtgDescriptor otgDescriptor; -#endif - /// Communication interface descriptor. - USBInterfaceDescriptor communication; - /// CDC header functional descriptor. - CDCHeaderDescriptor header; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor callManagement; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor abstractControlManagement; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor union1; - /// Notification endpoint descriptor. - USBEndpointDescriptor notification; - /// Data interface descriptor. - USBInterfaceDescriptor data; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor dataOut; - /// Data IN endpoint descriptor. - USBEndpointDescriptor dataIn; - -} __attribute__ ((packed)) CDCDSerialDriverConfigurationDescriptors; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the CDC serial driver -const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - CDCDeviceDescriptor_CLASS, - CDCDeviceDescriptor_SUBCLASS, - CDCDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - CDCDSerialDriverDescriptors_VENDORID, - CDCDSerialDriverDescriptors_PRODUCTID, - CDCDSerialDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - CDCDeviceDescriptor_CLASS, - CDCDeviceDescriptor_SUBCLASS, - CDCDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -#endif - -/// Standard USB configuration descriptor for the CDC serial driver -const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsFS = { - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CDCDSerialDriverConfigurationDescriptors), - 2, // There are two interfaces in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, -#if defined(CHIP_USB_OTGHS) - // OTG descriptor - { - sizeof(USBOtgDescriptor), - USBGenericDescriptor_OTG, - USBOTGDescriptor_HNP_SRP - }, -#endif - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - 0 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - 0, // Number of master interface is #0 - 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 10 // Endpoint is polled every 10ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - } -}; - -/// Language ID string descriptor -const unsigned char languageIdStringDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Other-speed configuration descriptor (when in full-speed). -const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = { - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(CDCDSerialDriverConfigurationDescriptors), - 2, // There are two interfaces in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, -#if defined(CHIP_USB_OTGHS) - // OTG descriptor - { - sizeof(USBOtgDescriptor), - USBGenericDescriptor_OTG, - USBOTGDescriptor_HNP_SRP - }, -#endif - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - 0 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - 0, // Number of master interface is #0 - 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS), - 10 // Endpoint is polled every 10ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // Must be 0 for full-speed bulk endpoints - } -}; - - -/// Configuration descriptor (when in high-speed). -const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = { - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CDCDSerialDriverConfigurationDescriptors), - 2, // There are two interfaces in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, -#if defined(CHIP_USB_OTGHS) - // OTG descriptor - { - sizeof(USBOtgDescriptor), - USBGenericDescriptor_OTG, - USBOTGDescriptor_HNP_SRP - }, -#endif - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - 0 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - 0, // Number of master interface is #0 - 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS), - 8 // Endpoint is polled every 16ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // Must be 0 for full-speed bulk endpoints - } -}; - -/// Other-speed configuration descriptor (when in high-speed). -const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = { - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(CDCDSerialDriverConfigurationDescriptors), - 2, // There are two interfaces in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, -#if defined(CHIP_USB_OTGHS) - // OTG descriptor - { - sizeof(USBOtgDescriptor), - USBGenericDescriptor_OTG, - USBOTGDescriptor_HNP_SRP - }, -#endif - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - 0 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - 0, // Number of master interface is #0 - 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 10 // Endpoint is polled every 10ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - } -}; -#endif - -/// Product string descriptor -const unsigned char productStringDescriptor[] = { - - USBStringDescriptor_LENGTH(13), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('U'), - USBStringDescriptor_UNICODE('S'), - USBStringDescriptor_UNICODE('B'), - USBStringDescriptor_UNICODE('S'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('r'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('a'), - USBStringDescriptor_UNICODE('l') -}; - -/// List of string descriptors used by the device -const unsigned char *stringDescriptors[] = { - - languageIdStringDescriptor, - productStringDescriptor, -}; - -/// List of standard descriptors for the serial driver. -USBDDriverDescriptors cdcdSerialDriverDescriptors = { - - &deviceDescriptor, - (USBConfigurationDescriptor *) &(configurationDescriptorsFS), -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS), - &deviceDescriptor, - (USBConfigurationDescriptor *) &(configurationDescriptorsHS), - &qualifierDescriptor, - (USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS), -#else - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration - 0, // No high-speed device descriptor - 0, // No high-speed configuration descriptor - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor - -#endif - stringDescriptors, - 2 // 2 string descriptors in list -}; - diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.h b/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.h deleted file mode 100644 index 8ab4edf7f..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/CDCDSerialDriverDescriptors.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of the USB descriptors required by a CDC device serial - driver. -*/ - -#ifndef CDCDSERIALDRIVERDESCRIPTORS_H -#define CDCDSERIALDRIVERDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "CDC Serial Endpoints" -/// This page lists the endpoints used in CDC Serial Device. -/// -/// !Endpoints -/// - CDCDSerialDriverDescriptors_DATAOUT -/// - CDCDSerialDriverDescriptors_DATAIN -/// - CDCDSerialDriverDescriptors_NOTIFICATION - -/// Data OUT endpoint number. -#define CDCDSerialDriverDescriptors_DATAOUT 1 -/// Data IN endpoint number. -#define CDCDSerialDriverDescriptors_DATAIN 2 -/// Notification endpoint number. -#define CDCDSerialDriverDescriptors_NOTIFICATION 3 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors for a CDC device serial driver. -extern USBDDriverDescriptors cdcdSerialDriverDescriptors; - -#endif //#ifndef CDCDDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/CDCarchitecture.png b/src/ersky9x/libraries/usb/device/cdc-serial/CDCarchitecture.png deleted file mode 100644 index 9d0e9243171a1671bd8d7a4186b2b414cd798af4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28223 zcmaHyWmFq&w6>8_tax#EcPm=l-K9uzD-;MC+-ZU0?leeoD;li0yR`&&2@>2s-g6e` z=Xb9?ndE-<%*tGktXY|zXbm-a3^WonI5;>AMFklxI5>FN%f^g?_~K}lQYpg0A;M{> z=*Yf&go8tYgTsbHL4iY|MnNG$L19M0#zw)WM!|l0BZNXEg+i@_{URbIY$7deYG!O| zA#7?RY-&qvW+7~5BWz|zY-V?CZYd&aW+G-GB4#BbW+NhIM=}6G>?iNmUX_HB$d4W@_e_;HG94qGnd2<`$wBlA;z;q88Gk7BZq1vZNNurj|0I zmI6_~U?q+}$d z<@i70E~FJBq?IjX6eDDmEo2E2a(otYkCFN>OG`@0NXiH(WtlBy36ip`lyU@1g=I^H zRZ1l{DoIHx{U@`;}rEm0r@aU!q^@MUG)w?qDt8 zON?s)AzEP&Ezr1DB}A(cV)PP_hchrwo%x)Q5eK1Y}Y7e-YEInsB+v0 zy!$_KZRzN4=^kbYO#UyzK$c;ZmN6j9m|e@{XUpte%l>Q2aj50^v*U~0-5r5pj=*Hc z7?5L3rDO6-fE_{Cj-Y49`Dgc+_OKZDWRQDurF$~iz46(7_ZjH!4va|#CWC<4FVP6h z1_MFkz{;0^02`ly(C4r)U|2FJEW0wS5faw88}p)MP)v4Z45%>%)F0D09@7YkdGW#5 zG5y!c|1~xygLjk1uan20vtLx%nBDji;B4@CHW-rKzneY&3~KBLjqifypDRJ2$`^sh zEBogw`yrL%yOs0Tm5}Gg#>&QVNF(GL{G$0?Fytk!!O-Xa7eS!?yU+d5=keX^aVT^g z`aJ)lm)GlO$cvtzp-|{G6#9I9Eg+MT`!WMizbY8I!@*(p{=-Qb$K8h*UkDF4~|pWU48oo(T|NOvM%Jmmj9-owq(8t(Er^zb!J z+U3g^Yi9u5)o5zxi}&`wG#z_@lQmrF$u#53q5!8TBdOz^eGJC%)|qSJYK=(eRP;De z9cR3H^Y9+Wk1be3JoHSGIa`aX7rAlqobe;YUl%Eb z%d6R?3s<0;LnV@v?631A#9oRoCFH;dNt~(Cn6`J)?yHy2RgDX|L1=o3DLG=mdDBA^ z=<|J5V_*a<>ineKWwf*C85;B0=Cxm5O@UX(@L;(M{&D12)R{fB?N#mUvz2h&IQjhP zddtlBZY0ADVkUfCM8N@LT(%nf{W(YYJ3XAP`+LJ12vnhsci zqz#YTQ^Djt10Z&=v>Bsff0?*3sMm>qd3#%O``yzJ_+=dYFN=!_(*%n`8Fep{X( z=HoVB8Z-fTKhxZy7oeI-aR}B86e=24J6GtOyf<1}a@qH+Wez zn7F~+3XqcRG4(%d^4@&k3+i73GxmM4q@baoRq#vJ%Yij8`U0q5B815EXh=WD_D5%+ zZ|yCavY8u{J`BQnZp+i-alQzeQR5ZPGuxL=4S3LEfO*lX?RO|q2#wwN1%R+n!6lg* zTC0p6H6Nc2aPy-7lrKfxYJZ>{mARlUXC59Mcj=XdyC})+?U`ll)_|CLq6;~6>BDi+ zrpVC4rvEm4kT@MIS9z!b2+a}4267SC(R|gdy?e+;4DgU}b{TMcX2tY&v8CCy!jYD}4R@1^DW-|NIC*aP(|LubRU*Cnk z`{?}2;{Vr=M@NCGcB`zN4A)mF#t--3+0+xCSDxdZJM>Z$uS)_UA6~|s@zXiVzTw^O z1nKuDH=~j1oS(ZzIDwDtQ+u2xwe4nJ*)W(W&+|q9%W&^-bLzc68n~e_yz{Y~HdE8T zEj^jouoX;;+k2)?6W5G;Zp~E6eC|3So!N2mxqdm~;3HGqu;qZ-<6z$Ps@W$#3Xz?S z0p|Pry;w$4%FoKK8~Q0g@#U6=Go3X1nL>{lghpDL1a0y2U6bND+0ZaSxsk#W{O@@q ztJ4gaj9-U`YZXjt&M~CMA7s08dTZYb#6HZdbTPQRve+L8OPyhXF`@=?{bLGb*orZG z`e>?J*o|)dJWCk%6o5*d&?O=c*+Y~H48tDyTV9+rVb2c(pgkJHTGl|GUnsHfSjLy+atJ;p&W$#poHF{$2wkRAIA_1gKiXYk5Stb z&PSU7Mo$~Qp)(nIgO?fwW+Z;7`x%ro_P5^;?OY{&URi+J{AKp0%&lL}1C(NW9G!pw z(?Q6r_cfrrTW&C8FZenm9by}P@)hb&1%#ryLSND`uOX4_;2(5uk4qvPFQ5P0Jucnb zbLPD)ASvmPJaEypeAvrw^L6Ki*CI|fb00OC!wsHjy%tXdUmFW^JaRuaqy-e@rQ+7n zctLlAlqU8AD$1}{W!Aq!R}b*GAJaGEo^!oWg)YpjuidrCE84GJ`lp}oPV!d8bggZ} zM2SoN662pgSkpemCV%9lf4L0uGLi7ndHPd7CW53yWfTvlv z&QpSDirPq~c32DABP_WG?Oe>bLtb)kBA1{*dWdo?@YH)VX#k_3lVoL|cYgPwVzDkj z&7UMIk6X}VSWr+;`m<}k(8p)tXo_*;uJeh+{-TaOI=PWI{e$^x4b&tkKcdfeckAll zgVstdj||e@N#)`k_jF^$6IP%%Xf&WJ>rc7?@?2sb7@&@R+#8IwNVVO#I;WBs;?3Hk zwmsn;?!AXdtJEU9RKYC0T%om}^$1^Cn8fhW1sp)Ib}Prt_Zxkl>GouQ66w^cqU&l5 z_pzU@5h>bR;fLHQ6HO6IYttuOmDHl@)rmC$w8`Df_b1-}3(cAB_ssU}^J-!t_&xh* zi2C@^q4nY_KQTI$;BDyyzUE{_4PCbYwl6FSnx&wvybvQN9r*=bONE_Zk??%{HX<9N z)*Uyw)i&p;vbii$K@HjhBGoxff3jy^3773p%-56ZJat>*riSU4mpxjC{=!u&E*k&J zvTV;pxT}2a?77P=7GqjM<4TID0m3k<6Jc%X$@c4Su+tnU)e**~F{}8Su5hp2J*bqj zS%k!v^BbYyxe%M~^k+r3B8E`5`JkOT^(%{H{*;ggHE*k*e5+I5R8j zrRl_PN^u*A{cJ792n~j86P{2B;C9h{<`rj8+b1aa^MjORdX9lGkO&HXW%20c!*NFTqrotRbl(5a61w?IFugtK*-|`=XZjt0jvT zPKY#{X7ur5Dq6gZh@Ts#2#0C1cJMy<5Pc?R>&`7a%5PawDZaJWh%()8vb?&lPa z)*oE&1%(Kut=Wwj*`QjQ-Em#E0wY=^qE!C%AkYM-#2f#Je;VG^nKDH`Pd1y%uJBK& z)X7Q?SD_|KjzjeWW~|g{sqrA6oM}?e@;z5<`yy!3q>VLHO8cX~ikD6XJX3GtP7?5X zdkl8JRoGglI1Dzz2}aLtxefw#cIj_rTO9hyfKlyFuW(KN$p3hCY4-KB)10%rledxOU~cyK{{??|FjNRsKWQu1WlqZAjF- zBXdVp?+@*2KY(Ti43?N!$&Z<HWI6|~ zkl@(KEIC$TM3PriR$l=y z($7AlRK-fAJm4yp-9gq*_5JQ^=GHed&$PI7Q!8A6#k?&NRmt@!x_SZ#x-Gq!<1UQ7 zV2)X`ar#Vr0Fh=h31N0PFx*vWsb~?k`cuH&OlMB~%0g^{?NJ;X8g+1h6YF(%+nQM9 z72kC369v2FaZ4}u9x$U#XgxT{?2l!s9VMY5%p_4+*L<=oJVgJ3Sv7cjl750&dc_dQ zA>M(TY+ZB9uCnLs*+$lQtdXPEV~sWqrtD{CI9A`?_pw*!K%?LNbPC zZFRg1vLFw_dU264_b`<_Zma#jRYzinxY>?e{|LVi;V&RMLIDiQ^cedZVS=lE7vfrvuAkw{fXCpH;oRZ-6_e)!`&SlI)$t`%W_fA>zz0pOi#!*B zkdwJYk*7oO?Ua8atx#;6(l}2?i+Jp2d~C}(*5Wk&W(YTUk&c`=gF@K0O1Txun$&3> z)n=cAc6d4U1dYJ(+Bc{&tepnW0BC!dFA8j;AOFqm^_0)AEYSIWJy_7%Nl-ZK-}+sr z;oCeX&!co{{gMnz_O$EQe-p{l(L^RWm z31Dy%_Y5iKAh1>GYUyem0(tN?#TbiK3KC8$Hl|$RS?EUP{ z4=v2Phz~?I@ypB(E6e*ZZSm0X-TmQ@=jo9C8 zfJ4vBQ&nq1=P8yszLKxqvpHtL(@Sm6iLO-Z6gudAzsZpwN5S{0Wh2a4lxn|;mQNuq z6+<>nT2>9TXsS4s@kd)8dOpN)LA2Ix?(zzVCf0bOBe!wsCpsiENLiAQ_V(S4O#E-m zZ$AL_m(VuA_AY8AUodyX-;=sSZ?l)$PD92aW1>C&jLE6L`Z(+}JvT_c{qUdDduNXm z`7g!|%CT{@XLBQU$dWZt1<6xU!I~?FL*`*%3GO#^&#l52VKfP2QF>+JK1+2IM6w$b zz9)eY(X@66d#Ai*bwy!bA|{@xxa4;Qdp^4^D}6p95jys`jgExAaH z0POmnc+6#eHME<>jk7;5%y26JEPqzc{YIV_Uo<7tsO_WE-u&F;xu0C^!bC9E06&Ox z$)lR@GR3AMI-kt@#;zJ1`M0L}Cj9nrBPaz2sWkP3d;s8wt$_YW_M0I(BSFjJUQU4S z?fZop)s5ain0q0?%AvD@_<<%iHVM)HvcCxEseS8a0^?05!*=RA4p=>U5<-y1$j053 zC#V}?yjP-P@o#A=>Ij^furtWGR97%{E#_NyCV0_HjyJBdtz~G7G#c8Cf;UC6f2E||lpQ+Vpv4B#?MZNncl$`MEDG36 zh8Z_U8okI&-6WG6G`9WIIc}9Q$I`zkrXt53nUtq=`&HUxI*WPE8!aW~)J4Q?dtW(! zQZET5m_63Y1b+Vg{a^48*xMzvo>4x_S)JohV%ieCvd#nv=DyJ#KkW(w3wZ5`ov$i{ z_5d~Ukq9H9B!fS0ewCRD#&ts1dn7^As};0Bd57?~G7M`)kjxBm3NDSnbpfAX)08q)TZT zS?}r0kpbIyI&m-nnvt({7xI^>L?Q+ypEW$>@{_|iG!!=%n>E8E-Y8uTK~5nHH+^5m zF|kS-^Zj!Qp-MpiC7@u=mscA-S;??C?gO?0z28Mv*YYq#6Q!G^bc`o5gRR?WVWN?T zRp48E0fnv{!q5S5i?5{KVJn-0!eiuD1qO2~op$&7w_y)u`)EuvvLHEu^5CIT{hO!% zV^LN%XqRu;g6k3%pjxemB1X{*@DLND{mQ+wKkvu*eQ&m+M*_*!$o%|$RX4R>R&okB z%hCZXA5B{)jbrWJ(I`<|iQIy=Y+$M`Uoen%J^1-L;+W}hBs+u~4PN(#C2TJtBq@Px zO_ZP3SFPW>k5VWr=@;z;HO4rLvBbC}h%D38M^~;j`rQa*f4S}IZx8rcj!lA8sk%`D zmfF3%u)}sXNWIQ#7WIiiivi@Wcjdg}oPAo631d33dOz3Udq65g;6D7*!EG4qIF`>; z3fxkWO?g>;m9Q<$QH}RIW(~s|dIif3f@2Ns*>);_r)8_WEb{Q{Au5YeW+ZPg>4qF> zRbI!11DEsu;*p!%u~@n82=}VYRo0($H0ue6=d_f{cgRu6ikP2mpu>-@)w_<2=?Oq< zQQ~cG(D>it+&^doQ@BeayiEAdvlshP!iHyz4JuRx#i;+->i*rbhaO)99=@<7jObG1axH9hytnS0^2&t{07@qbNNI?^8l&A_m}@ z#zfXr5MEgfA6VMs@d$5+fy&eWEPqQM=hA|gqA8G6_-*CR!WU)7h#arHIZVl9XyK@% zWNrmzY8t&ue{5xP*<@?!61SXvxxM*Eoo72yLI_MV)EoR``14s81NaBiV`dT6GW9q4 zJnOqSAB6R+6nvWE&Ei{8gS&bpNgoar#tQRX3!PAYp6{|)!Bcuy%RmAltn0PBofH?C zm|G+U-0i~C_kNhv$#$1Al6rgg2c^&K7xFmu=TWB{`RaaaUBIpLmb6y%*sZ34)n%_9 z2{L+>k8U@UQLV%xK>a&RJmuoxm6a8tXQrci`F&RcBhOI4c@6X}q$@Wk+&}f$zNqMy zO!#UpF9>h^l?8XueR_+RE~4j?K(t@Y559m0vAS9~{`Xk($?%{*Ru4rLZ{fGS$uIHu zXgh?*0fB5aHaAKV@A&>?u4jE-p|krSK0Eed3H*|dK7EYeH_||zvVT~2} zCcV{5E^p$RGPDuDIKdW6eh5gZ{Is+9WEspqFbhr1=d~chOh%mcwx%nV$B*ln;4~}> z%PsRXKh9}^(|E8=ReP4b$~io62uSp|^;I3)q@-xAFShARkVbcKARrS$xWC6D_h~3T znU`J)EGui-%sImI;GbE&J!SNuC4D|!clY3r4IJ$0aK4VLo}HUN9)9R>wpyt=f;x6e z6++v2GZ9=;GuB>NJmSGUDqd+=hW)!HVpIt%AcRZ*9 zirnM9g{67$H@av}Hnu(J6HS`LdU#Y@J;Q}Q^4v$t!5w${o2ZiiX+1Hkdw(eZgRI4D zBj7m!i;_swYqtQ4vbwBoeK7K!Bb>>?P010bR&7BBZ=lIArl{}Y9hqGl1aD_GuKc&&PR4`yMIM*y-&%NF$PN_$|a9Y^?{iep(P@1!q-QOwTyF@G)HZ%S8uL4 zoh|RlInVuV9iVaKe}%PkM0(FKKS18zbF{8z9sGNA`RSyN)^)s{-=+n8B4ln!nbk>} zvPXl-Vi+N$+=Jh}OtfE;Gh&p92-f*R9XSLYoZtM>;8mF`<{(7o$bWL6*9sNeaAW|+ zAoGEA{J&S}`65ln9Vu)dx-z6|PmcUtCorr4>@9KefnukHv28!sWTS!Kf|XG@>Maou z!IFNTJ1q~ZwV-U~SfzJDV3l0fm&-}H4OBIbKTs;sE(9EhOJAw#mi++?{}MDJxrAd% zfyfmCPou{H2g3P$v{A1tp2X8Do#Go%`^g0T5rA`bBV@*c2NsbJ07j9M_lw~vfVHj< z+x-nQ6}P8ZR{fIok8vnPeywv0u`o!3>Z&Q?VZ&zV%7xG9B0qHDSKwEP zpo913Z7)yPOa&%QuNspAJnLc??E5_qNDNn*yF7v?M~H&JxEzz?3VH6>lCoTFS1eH$ zFfcO^F8oa-bKJh*cm~H54gHnM_x&Xui8UY&-{E452aVe;C8?AIe)G%(3<2AhaDz%` ztRPJOcQHQ*#l!t8DjVp49zIh;=)GLd&{H3IM*EqlGQ`(m?qlXEn4i7(pY zD(rzZWdLmpbDA~|L~WaSWuXY@L=t@ba(A?ri-<y5f zZ~)0Ev}+2Lzonnap0WF3J4#eunPiei+)Tmi9wQ|Xdrm4oV>f_jWLj9?g>xjyV2~tL z<7hbT9z4z*2+p--AC>4m_H-PGE#H$670Zm`pE1UE)Mf%$Drvrbo3O_>_1<>QKPRVc z0BIoy$~esYQYZPNMyp|cteW!5qTibbrI>#&nItc7u0IwbPRn01pYM{xuwVuaQJz(I z%C6;dlL5MvO+NFH z=&V7--JqvFaH49Z`UnDcysr9k+6iR6kNj5I5b{*}%S2?4@eyc^>_V?Dfv4G+qARL8 z=uU!}y#(L3GPkPlQOF2o^!>6KS}*o7u}fFmhY5SJGp%-jPe6?jPkbTJ`3;Q=yxWXP zj$05p8l`8<{;G9;qi(&$-zxIN(aMH2*Q@KM#Ql4G<2RX|frWP|D6 zJ?RB)7Y@3LEzPQ*sh1_Y{N(0-b-l8PEJrEwEN{=x`ZG~C_3fcU$iD1$f909SR_@Q` z<>kV~#}@6#hFP<~$ID;cm(3|vy_JXZv1RgN75yk3AywlGMdCM`zH`WH%cA+$|ZeJ)^6YPS?ew) znxmd!!}z~TGL*r`{dAv7(?b3S&LdWe1m|3;62S*t0cg*1hO}^m{sa0vBW^OXz1rh< z{>be=P5mOa=jgdR?9;pqyt$-BXX>#j(RuDgiM)rCkr2Z!EBx)xtOL?mF5E$lwIbh& zdVke^6fLc%$S84C&%^Zr-c8*#+j^+)6}%UZkhAC!Dn9CL)b+UJ;t^;gOWky)8)|rC z?vYs8uyq@Gy_TML%Es=W)4C%3gZ=UA@%MjC6Y0!C#MrUL!pYRlMoN7aiB{RRItEz_ zEJXWfCvRDkO^HH{dwvK$I0}PoyWLWi>k&pnURiwX1H_fxTvrp^P)ibh5){hD1`sFP zsc70p`^0nB1#4yM*($5z+XNA?ov{7DBdS0aHBZe}5_=5syJzmm%?+$f-GAzas>}5# z3l;s2Sj&=sf3?K0u0DnBmkc=c zPHCW$a`#%_mH>UG|D{M=>Su8s%j={Vi@@M=hrWf8D0oX>mf_(2JNtkY1i0j@>&QK^ zjqA8{aU%a*ZWB`G7`4FWyPx!J>&7a6Ki-p|`u8~IcBge<4yEXC#wOf`I?;SAB3A6$p}+r89Xqg4rAp;KV^k@Q zr!%sVz1N(og;1-G>Q!lzOeD9@oR-ry`nn z+1X;1ZD=lKOv^0d>UMj7-8DvdMKZ8Y4H|F;gNI!v{%?+edES(adcY})evmdvJW%>v zw90zXcDUd+_oa#^;ass&n5A%Z^mK7>+89aKwB0IU;TyK4l?iz8f!T{-7q%b^3^2Z#Yl#r6A~kYf+jMZkf6eKAKN_ zGM~^760`b(puItDJ9tp24Zux^8dav+V4esPV>Raf$PIS~`Yed=%kLk<sR&pF;mko_yhxh`8(TvTO*#O?Y8Jp*Zc>U*^jJ-e7GH|{vYMglVxOf~2a zizlX9g^?`I)s4QK;r{Wc>{RBBAZw{CjsLS!M#&;5a9-_Uo zQ@bCZ6e^UC=L%B`a(u6m3AjD`X)#bI`%|n49$Ovg$>F;Y<<@|DQ_L=8*an9_<@!^S z`ZGaqvLOv54)(IywO*GFzv#2kvodKf=IIQq5K$V&mOsEuSv4TY7~gtcS?Fk{z+E*Y zQvW5C+d!42&|v(?j7UVi%}Wo&tz=L5yP#oW+?ZJB%wJQ7lw{3vD8%;5%_s6~94AJNYsVI&p-sQ|A4QoGgYO{G$>h0mX8nohdp7i8Mo7 z>Fp=>cAI?_^9cp>38HEwiIjeD%3N4>Cu&6Hk7OzN;avEzcL-O#wyD99NRK%xOMmWp zDFDAjX3v&^PmPrDlvjcV73e&CYCaf&6278FEpFTGgQGIMOy-5TeAP~6RT~akX2-Sa zOkTkc7PE^D$`ngNukd>LiV0>LOD{k@dtD-wX6R- zM{-QQTI%i-vw2<1#cd}ejGKDw52qBtZEGeBvDzjK{?z3i+B&YM3Dp-!lauSIB4Kj5 zV!B<+C{Jrljys=E41cCzEShJdz0CiOzQ9JRlVJB&32(JRfvy;?pLeL|xPEXjbw@#r z7pb}+la)2f7H2T3W+O@K)$}0XE96nCyJ^0 zK{7n_x;9LkiljUsh_#&8)4zJ;s-NJzY)}CQl8qi8nyV zx7M#LOl3X(X=~&B8m5&;c+|CQng~zFlxtY|D_+LJU6Pzj!7q?-Gw=aWUaioJ+VF*3 z$OYf9MXc8UNFgo9QrjgXxQZXt4BG~MZN&wWx~o7+xluDJ+24E)5zK1v*T82wQfR%` z5^#nXXLADBpcu8 z+8~jdfVKs=qiBt*n9Rlq+}g)GNfk!}fxkYh1?@NN7?#I5ZkC61w65-`W=6vFD_Q!Q z6szBZp|33HwQ-Xj6x8HWY;S(`E| zyZ`DxZ7D2IBT?6=0ESfAPVajf;Znb5C zoi3lSS85}vDAb60K)uJov!JY#lB%DkFLUAm${jBkqpS-}O~BXWnNB(~l=(G6jJ!|9 zemx_zW{4>M%A!iHV-bB-C@C<*)L><0Eraddxu$_{$gf)_9?$c-Uy7sKKwiZ;!QHW# zb93Pzr&|HKi1m?*R$E))=8sfWcRX(V@%$hf+~_8jXZ~})U&B-|CJb+k)of9polh=q z{M#d?-PnbL`9tW8ngrA06gRy?8a5n!JA}W1>Vrb0razL0%$tu=S5V#Hd=Kltdze5AQcwjbv^i3daOEMsIFApFAEk9^$^nx;gtLSci97tii0__*i|kRZ`J z+jKiyc4L_#9jUv#;*|v`Pn{i;C!QsL#nDhX2i4$?spdK3`3d@W00BsoEQaB}z=c`$ z#pa!Tf&1Aw(s}S_T3{rzvA%Dl{XXUoRBnG~(GK6SMFnLG{NO(<2autyW_@u1%nXOd zs93KAZr06soXTJs%+fm>(Exs8L?H!#QB$*%xg_heaKxPh8BC(TXo;)hws3TAmeeK& z#4Q2$@zq?)$n2b7q6WH+y-g7ff7=tBy6ae3x6|`1)wd^pIbi37J(}J1WOmdAh~?3S zR`FLvbC&-Kded4+f=kQQ%fbR>i6&rjwjkg?5&{8)Nz4q9U=y2CF5xnmv$Zev0B*Gh znrAo1YY_dUj4a%<%Eh@?7CMfRGFgIS^zKa)Y)GW$QYHP(@iF!VM}|nbA2FHVSWhsy zV0=DO6jdM*s3bNXEBR->AAgK;jmapnn(yOJHy$pI7G{dJ!hi^*igkK>#mCr>0MwIX zaCBL?eJM`xwwfP>1g4`I`A)WlCe~@eyRx7Cpu;7WRV~a-W;8Ot(=as~PHXP!{<9UM zQ(+N-aX?0`Tl7nSe&=0O{Im_HDH6UVl3k|1jb{zZt1M$I2Y4!VqrILbMk<=6WlWTCV3T_N_33=xI0ku0wIm=Qq1+ zMw^L@>LvE#a~r3LiN|b9L;t<90Kb*73HF!(NkwWW-+x8$hM!@kYHOz`{%pCIj1flR z0>?1+W`d$1l>+Ai!{xKkJA>N9){RE&Nt&N`4-UWlxOl^?%+dT(zqKd=z72T8MU&;+ zNyTIsqnV_gg-u%?!O!c*;2$xE*L0$NAhKV((6HGzk@t%P-HV$PLssHz$l8t}#>U2( z1r1z5(FDTvAYysmoK}H9n)RQYugvHFst`7o;$2Z#?HU;tH3Fh`c96Ff*s)6}KOrGw zO>bw|#7l2<%VHsn=r`3^#RzIIw&Ms)X2W*57ppH)3(C3Sg8BPUP$8|YK6VI#xE&g*Os*xl!+^~@-MC?S91Fl_{ zJ$tsc&^83@iImR6U-qF{C*~L!#;1ent0~5m|mW+mZu!SlRMbl za$92UbR({8aG-5=crgI1_lw*3aD^s?IH@04OmriZ7?W z!kIJ)XRI6eHX%=CFiXQb{1e``MBikpKHAz#QHhxJLQ~WCTjSk#9jOdw>n8MQ4!gC) zq5}z)W7EFs8v_fDJ|YomYp9Rc-e8MRBduM&Z+CB?Thwgtfp7HRi-_)=3kiw_=h%(A zCO=$;-H6)k1LepF1Xb{Vr!N8Z&AQq?y|OT}g({s&wh4X;!tSUfYX8Xd5%%NDOxSz3 zHpMPrxwQY65h+za&;{U8BeYfhlaiUrl1jrR&j-tj*3m*ggt{oaf9Q6(7AcxvxM?NY z?1R!b<~SElG54P9wV%6iy=O#6MUq@W3W~nk zYEI;vpuvm{Guof(x;{&f;}@)Vszj*l$j}!@ao1Iwk|mnnCyOt)0o_UG=48R!p%b;$+C2k;PZz{lsYwX~*qG zIuPLC32DMEMFVViRRsl{^s+)nr(I%0Da8M;c5Sl{h(S(V(xKeL%l#o5YhJ%%}Io%N|Tp&uLdF~>nDV3dVEuN==y)@!=a3(K-{K%+le&5tI!$rptOx2>Bgbb#Y2*C|%O zBO5%!_~|#1BQ(cXR&5`(kgT@L{YZ6b89|G^5jP8)izrEU{SWiEF>aXG&hpKs)tw?Y zY>_Z_zp_~IkUPwAYW971aTC~<3|)El;8S*e-dE0`???W!P2TIcar+&4QmMHbe8x%! zGArC0#e5h{!d7%WT?P;?zy~W~XaC(L5&ytRlaH_C!fwB%(#@ye8vu~|Cua&j^|UQh zBlOu=-a`K#^5H)EYFgX%y2G{?x#y)g;l4@pisD!3+q(H&5n0s~#k?cu@KZRV>P2il zkx{Lz*oLTbCuFZxC8etwMmMaVm}{jFMHfmt{%OTn9IY~S7hn`isAMKYT`WwRB4(AX zw^qc~`}|60aTzFeZ-!-Q>9GlZbsAia!W3+zr>fw*hv4i)iJ_L z7njLESnjKya1+fJ`j2>65HGIFA_pnCk6x$dnP;PO|2IdTKr_fwW_Q0E4QhxAWrs^v zv5gek#98+^7*P7OqR9fSrUoI`V&(?ICb!YmvDIQNu_t=vfhJHNgKlGHfDx3${8BMy zH-gH!+{wD?%OSuQdXlr+5g2jkGRyE%vYsl6NW-vgwY1jDPknNg94PC3y5BUf*NZ4% zy;+^X!){UqMpwR09cw=d8R<9mbo+aH!D*SN_lRW4+2-r~iA9KMwm4kh%s(+7@$YT$ zXPD=`1CF9z?6*Vg^<#G!xIu_U4j>5A);qFj1yDf7SD#w(D{E zz73UeZ%Zq2e+ffh8u9)1GrVf>)nVR}=UmPDLjvMvQlb)`&vqU?%T)8g) zxJB)EhQI|-jg7!JDxdWcyG&~!)2IgHNY(78Fr!sRBN8f6ylWT8*3a{%tFPS(HU*|( ziIg^8+g2flFV1x(7p>#&&4mfv&n%8|o(N1{9wO@VU{(|ReX(ddLO%2@K)`=F(Yg)ScIg=3bHbIXOTW$$FULN_{x#juP72of zJG?k6fw&xb-57P_YX}RW?PrDzu5f{@w5(*f2* zyoj4ijNd%@I#tNZy(fJXI_yzagpxo@A_l^}urR^xVH&nQ>r#uqNRE5SYY6o}(8(x< z<$8kCHdVBp2J6C_*QCsvU@-Tx*Pw3?J_#URlhV$hfyyOCx~U zT{HAfK7cy=rHrJu>6?HL(=468Q{`NI4-+{(e>N#M`f5LMW*H%JlGY6+Byo9o`c3hy zNnXSkwrZ&$lD%`Ms5|Q)({hBW4|;`&K(m7t`>X{;{L8v`;aC*7sGYuHv>~II+97K! zNYpZjrcQB{B6Oz$+O`#K~|hAtP174_u!tY{ea? zEJ2GXAE6hdU(^-2g0qBp;~`Bz%y#$fL~vA=04L4M?gw?R{bfq$Pi;vpkU* zpW=-0E$imUVCHOID=$0ftEEXO;s$>X;kC;seZM{!?S!Vw0mzbtSX{lbKwh_y*$R&# zuHwi>X6rq!7GiTL zC(-p1ethh5E;JYkJAtX}@qXF?X9&OTd1{>eUKVvZwqcjh|CXv7QP}z~P+HK;cOqly z-oyTiEvp6~ND>i`(9?KUN6ZBDy^J^%}rBL}XQnC19w#8S1~kT7?m=3cS;eq$}!y^L*c8|1gY+^hQjs4mmba_i~u2_LEMmsb|6e@=d_ zMUyqc@<$O54xQf@vr29)!DG1QYWb;zz_Z+p*=tF@duQcs`UjkIcjn0pRIg1}!xOSq zNt37y&fe%}q9)T(Y04;nW-BH7)~A@11JB83*_tyL98I|>r*PX@lXeygRIf>=U{H%S zu)D!T?`AkZ-g6txEc9k{O2bpuSH+_S(5vHTSyPw_v2uuZ?Gkdy`1p6x2+25miE|#}-cL$< zVO*sgX()VDj9FwILcP2ACh13oFv>*!)JY6Pr> zAeL0XN%T-GKvYD;wRiV6~~X%6xl)x)=iNcrfQqcV%KL6w_%&_ zCVpyfny0}T^Y63l4k((tM_dTxH-m|^=kI0)A+p=54-T8plrxD-@ZZjosRI^AT!DC4p!cFQ8w*V2>Xh+fCMn;eDQ zo;-7CN_5fd3owft(5__~9JL1{C?h0RQK^je zhx0KYUQw?UR=&YC5^<7H@g<-JbLwj(q8hiBXmN4bp&4ewn+Qc}@pU-m2dTaksV02B zzIkOa`kD3eZ5N>`(tIxO+H$eMoP@KM6^od=B#6D1p=^8M@j!n9sj1Q!%1QlmXP?hF zyTw;3DHivcOe&(^LK`_%C5E4vBP*vop3s{fu|LUiX&;q-^6+1MjsM}F#mP1Q07YqxjK}qFg671OC0A31hV_$s%&VU>OL*My{N$c{ObhYsD zpW}Sq4?faWVesP|EnofE1lD_~|7P)6eD?3NHPyu+Ax|y$gWR9{~ICNQhia$$7 z1Wl_69d??0;3gmqTo2!ry)HwHaKqGjGGWuZTnz`+mpAPC4>hX|A>(BnN?xH8+n@a< zB-McQzp{9s0&faS6{?ec7(4-bag0x{$Z%1km1Qq)hf(ipPM2VUeg1`S2HkLCz>P+z z61_E0BXfg%SPr3{>6IZOHRG8B$<0ne!PeP&FGqlv$dgg(7>C#4A9@=syeR@wxV3yLS$HE zx6R~Z$g}G!iwt3K?g>2!!=l6BrHukoT}I-$k{bm%x0Wd;ruj`!;y2gY#JcnPk~m5Y zJ;f&xeBq?}Qz=9auhm5JN~Jp9+1NP7glRN5ziznUxoFTfJ~jjOsjf~Or2#@4>YE3Q z6%6LGQYKow%wIH!EQV_>EpJ2}Z);G^PgVBpG+J1gO(_QTY+){yJy&mD-|epTRPU-@EpOZCTsL;iCIA5e;_qPsi*BX% z7Yxb==;D)l5a0VLk{M-CK3Onbx;cDv`)Z#fVlKl7>0xAYpdea-XMz1(mwRBf0jWHGa6(tJqn}}kcHR9#F^o22oY&#NdviIsH@u~f`_tu zB8Krhi|qqdjVl|}nfkM|4!Bq2xOJpvIec>JJaat;kdi;3ktVd?9vIP;6dkxHzB3eU z(i=fCL}VwelN+f?$`oE>M*TXD`TG}qFTZ~YQl>?o{WW zU^Q2$91!0vSFXnN5deVK~wH%79A^OM0ghDkY3IHYSVP_FjG z4@;X)g&jsYZMc60$gtYlPBUagHS%J(L-vuD7ST>c*fS-+Ev06O;qb){+N!`>kMhf^ zh|%P^JRJrv$e&=YaZRZ@h$vL`2DXO`IB_K6!68JI82 zln7_zJzaI}Lz%&q)BbhA`aboJJ2YZ2f3n~Y4^43R(xk$Y@f_wjo+4$!ltEdVXz!lp z$>9p2$8rE~J+m-#Hv!tzb462IQjtMT@lZB_-i_%x`j!>F*;pW)A+}depDsQV8vjrn zGbbr+*3x~t(fx<^w=b;l;bxuT^mL(8Qni6dvzeK2;SWsvS55nim?|Bx>hW(@B@dJL)nVt)E2MDFr!1!=78~YWI-V{ZP%i=@=PS78F(=SiRWWN~m zg+-<5-eLJKx{{oN0>(LEpHl!jCnGni2U1g5$cK7~wCprC{;d|reA@XZ3*n!XjCxRGwtg-q7f8K7A$?~N4-GMl zRYdfo@{ApAtf`wXX}-=FVM74-MpYk&e_9LTR*BNfYQPY;9nOlf2bLnhA}OmP+(1-q z{u`YxHLo51n+@418bI?6drG<5@u&sb@s25xE|)XgPgF`qIX0{j^gzORCYv9xKo8?o7w7$J0z;-H3Thjz+lmPP!~ z&6H_7XSk+zczD9-3xT>Szx~S+hLQ3F3@kTFf#}WzE_R%>EwyN%UeBu`XRB!ZhZ}}$+ho2NHLLJ;_5Kl`xP1!)bL3wx` z?!wcuY=^!QwR<^5Kx62A!DOLQh0^a#WPd_otf(_X3|Js?TL}VPyMwm-BLy2?hU@}@ zLE7-uCJZ-FTOhvp8jHIDNz0Xdg4noQZRtT4^KcxuXO=s+uY_NZ-13W+$jiJ3HyL^Z zr9gaxBYoyUofA|MJiX)4H}=3JaiK{38Ik1FLG2(bHG%muC7!qOWH)tC6ijT0gAUSG z8H%g}Ca}Sy^*jxp3kM03Sw&?sYnfbQZZbIWodT@1cx2{y!^;MtlMU1R zl!S9Q*Pg2|nlWZg^JKj%A-2n%KnyncuUYMBjYmnkvvYwpoPq`yO87hrRkyk(M70Jw zyx)9Ps70Je7w*#9E(j|JvroO1nF?Tkv2xplQxxo590ta=ub78av*{mikuq)JHcC6^ zgG!zYChKH1Te2DDSk_K$5H1cCkX`gOJkUd%H-?prKUpM*lPk#0FXBt>ERoDdzH_bYz5w@u8Yx@@taf%V|>LPjw?3qzWv}bjG!~r&?=w2A8xDwO~!&vhnr6cifd zNVk$pBflN%xIHNAgwzT0Sv5~iN^Y&QOayQ@t|0abY>_&aRsGm5o!w06R2fuzVXBU~@*_W6h z;zPFy8bMaBBPr&&sdFBGIXIXo6zE&j^s$*7H~LzpAUJvE752#jsAP3XnYwi-{InjP zEFe3QsnTD1F}+vl!xRnRBAB@rhqgi&XDj#>ifh)bf|l)ZV{#fK&0jQEuYL17`uPT|NPF3hwT*;h z?SrCYn2Fqya9o~VkQn@n3AgEZ<*cBQ%=tAdK;v+9!?bGX6TIdsmHx4;?ANbwp_@eC zU|>beroh{|MG~^)2A4ez;7kK@0&hsBJOIvHo|dfv!1Dt={ITEiZ5bVeM(gigc$NR4 zI@H1@R>AezMTLkJ^9>XKY=4 zBJq~*-dJ0GE&^96SL^{jFme38q>M1(y#V2))SjZ;B}_-do$wu`7lmLQ_dtx#1Mz5HKU8A{hu4(&KX8s zMmPJMg7wyHBWo^H;8bQcI;ROJYX1mVz=!xb=n>M$ykLucLC@{6$sjS8CE_)^ z@+tE-4i%)yqS(R2YTkNwgT+2Hc4Ut)lOVhLMc-kL6(g>P5M(;Jn%sZ)5g*UmuXzc7 z=zmD4JlmZM z-*roZ$rntIag)pPO}O_%Q`UAOQ+_#9*J_FYxBr|Ss=8v-djZk5h^!Y~F= z-0@ci`XRAgv7O0juup6C5wHZ~p@Q78UsIqXV4dQ{;$gGyCWc&J@a3BxmU2TD$ySdt zGbZxha1&KeF5WgD+}6kX+BYO6?!qDx-HC3seJlHRY=Rl zE#wTMp=s2HsL+P=)c|Y~r_8&xb#2Ios&!lQ1ENyf{7U5tS!K1;S^b)4p{CD;j9t6o zI<{}Gyl?gb&mJ+TcA@gL__xlY%Y0hl^Be4(d|~tTgt@szAJ0wl_l+YOE9@xmO~I4{ zE7kLgzg+G~>z$j&Vuh&eI&zkyaT4}t-A}NATF*z~Cd(ba0D#1?i_&!wGBD?>M%fgH z1ybF&=477+x-YN_DR);a-m006BP{WL6=`@|~ z`YiB|(9J&mkn437LcD^#sM}(Rv{X_RlWd97Y>6~3C|pyOgBA!SUNs`{J=yp_7WX`p zEEuCYaqoUtzCkr)9iwYwrPeQfP|rV$R&HisJI=fuuc;Uj#pOGH_4}`swMeRXH^0~7 z?yqdTo0w_7v{_=e6oq}=*o!`MK}eOqcwD*{8GJ>GX|d^tgH72pzAc0$RPu$LaK2tR z^Od?7zTx&5_liziyncJbo;gOAv3Qv`zO^6@nS+u#D-Su9BYumYC5m4||AXPHn)k_qBI?@x>_nM?>B)I&oRunKKctgp&12Hm$DZwRD`eateJ@bFdoy0^+2GMFc^|_Kb8N$lS* z`T}WZ$6m1k!B51oDTG?z56f5BJ{}j>f-DNKJxHf(z^qf4LCb@_LTzWM<4Qw0fu4eE zm^1c(ntpo-Vb5>ao+q)WyY<-&!YcWTy@z1~9EBiu$adl=ALxf^Jg_>W)GoEN`zpK^ zSk=?T7J9L0tV767nnD4F>bt)3FtN%mBDz<&MyxI)CFGe+q%JaiK~uf z%p$)jxaIC!4LV)1b4~H_A7B?E*AwsOYGhCZ>QjV(K1d$8Ea&ISH@dx@T+XSu-i5tS*zC@^8*i6;cnD7> zU{5WKAEQs^UCTa&)eRu3H(t)!d2kW1Ta2z4ykRsj1oa*;u%{_>q&oc(^QgNz0r*LI zD&7C??3JR>d-bg~NNi?*HgJl|UZMN&1be{h-x>GV`#gl`A$61+H+xQV)4m~D=?@}@ z;2bvMioC^p<0kds)`YW&`n}EE@*sHZNQbzyEs&y`UhqVkJx#57C!Iw*mA=N>x_hxX zCJ`Mht{)6Yv_x0!h`cE-_WY`N{sVS(HN`7gNB)HZk^g+0M3A^s)Y378b)PBO7MaJ) z|9pS*fxpn6uiF>F3-y4F3rTZ}!PoTR3cX7W3GBhe47Z7H00kV`w?M`>#TNg*#|um! z0#e5f14=Fj{dyq!sGNprRFOj_JNERYiL)#^>=ixWTL_XaVi|X(qd%4eH5ZL|Mh>mk z#KZP$clM`Wd`x>pL=N+vjA-TWWnk-O3VC{iinzwBj8v4}l4Hyy@4kLq4b(jsZZb>^jAESH~r7rw|a`h+a+)d_gl4enWBS5wF>XVF6@L{BW}HHribh z<|5H$LDE!pW`%{@mXp?#24o}JQ@;X#m>mDL#OxX1zj$l@GQ)$uNDdZ>hbJ2QPqAz9gpzw> z^%P;lTzY8ef^2teV5t8d&Rv6FqjzwO^RF2~2fEgtn?}GPovDj>k$)t+u%4rAELj|v zJEBukKBXFm+9!(}?D)f}Dh~BjYlE!dry9rmIpHT>hdeCSU)+(KSMncY2Ih1HkAi$X>xz)qm6|)^# zWu6KKua*i2Ut*f}4z2SKo?nNoGvD>!-?PT8gAx&QYkWynIVA0VfIvK7?-SJEqziCa zsoIV2vG3buNgWvl>LVOWY56n6CWxI>&yUvOG1b&)h54&hq> z_1!Pf`E6jZ2UO&uLz|FvSB{};*5oQ}f@H@o<~<0Ta-!{1_@tJTvZqlg z>4S!Un%LKD1=!cny&|dF#wrC&a^17e+6SqgXF3oPFtm3Aei6~ReM zj3ZDpOeVdxnt2f;w<9TkvdFg7H+ggsGvmM>B(HPPryFfz@UCz_i1^N!XED7W1M!Uv zg_)_WfN$dOxz1AGR3p5*Co$YBN=**hs1YOw)kL_CVD+j?uZRigRN+^~u%RMmLM-N^i7Nh{ znu6nd7I&0a5jD!VS=}&Mc=O33jf_Tcuz@9qBmAy3srY$5$Ml!7Ylc&*hosgo74@#w z*3GYdT%EqNv$6Q3yY+2|PJ-hw>D;Fb&5td=oRU093Qm$T=QIPH#9`ahn2+k~R%SV2 z;))Bj(}t*JL4Npk@$HENkAA^_g`UdlzU(#qQA&ReKJ--0QSPP8gAd7Mo8Ko)TDH-M zw7(d%y$N}|o6m<%3&Th1mm||ZYA$0Y8usyrN504tZ&clFa>L1)&y>qgNNIj^lU~Kl z%x8Z6Q<*w_)Uy%+qH?ng7pLXVLFUFBTlanF07nOJ;7zTE$>>|Yt|g7_Q4eTWwDIAM zZt|--JYx*RVyHppOd8Xm9l|5^_+;V0FAupy&O+Nj_dY2_ucDQKCZR!SJX-L;=X&vl zCa*i?@qo9bd9op9OtZ)=;S6^N_Bjy6m^A=_kPcuKv$X)WCy(Vd zik#kK1%erjr&q+@IJY}()~?S_{ir3p$A4`HMIFDO2exUW85|(dJ7sj_=r5d+8TVTB z3V8&TsmG2SJM|VKQg}U=y=ZKDMDTy2cDo_wjwp6nGg({5>)(-RXUlpLiSl(?0G}H7A{}(x296pJFNAr~7T1 z>S#R>59WwsRC$Y|8eQ}gj`#3@;UB$(6~=W@#XrSTx2_)fQ=g;OQvZZ+x{8#CQDFKf`{>O#9mw0+NtJ0sXwi6TeH;{^J3|)06Ffb}e zV*h?L{NS>AVzaB5v|fMWv3b^bYrRN<~ijf-l;T+IqKN5Qtp?`rz6+bg! zq?wKCV#pH%3P;dN~PA)Ju6PnYE zyj_{bn2AS{_kB$y`q`~y`Tg#v73-PH1n~Bj=#vHEHsxr9M=NG~UAvtdiv^eqb>kj4 zU1H#ngywpbiUdUeQ}QgGxUEz){iQf4nh(4}P_h3j&@_g^2)YOmT0Qqh@Xf3U2&^es zjq#7CQlb<2g%oT)Uu+783i;|n=qO{m@**1FKt)`EW%b~3mQEz#sG-Cr>MNtP5*yb| zaNu2KSCeE%9ZL@`;#2*l@kB(r4VVStVbsgTg2|&IK*A}a4Js>p0I4ZMB=*kEmz;Q zR0s<{YtoIHw*{L_&(}4F$LpWBeKsFyw-Qr3sQgcBtS-PR)z7GPl}#QQg=8HnKO!NE zP-KoKUs3FLxojz+Y3;vErVfMhSrp3V3gFwk<$O~{#)y)%L{xW7`hIh77QKFK64H0% z(RG(m;yBs{@{f`J%F!JP^h0vIbyaRTaZ{yvTktwZOjeRoOGopbSwilB?PxMB zW}9IJl+oVx2h({gL|x8n`;1EG6Hf8&D^@jfEI zCz};hA12&#SvL#VDO~(h5`Xg=>DS_F=8As>F4_iB#mNDus;48HV^uZzyH&hXJ z!D_kBF6ZkI0W#`F^r3(>i%Z^! zXJY+E9E1WS0y9pH@=LbO#sDYFt(IN0EZhv9tF0tNWz?%_776d#x-!AGQFmB$9&ty+ zY;cR-L$$iFWu&$&iMP|}6wUm>pjRj^xlCxFwO)Xu!(kNn`HztHS&Gt)iWSZ%-G0xJ zwFM1xuCzCfoD%BDn=MRP$fzy;5IkEpzoJ_rt<%{tN3!{jQrYX&fK^$TOSPaULYnsi zM6n(MwiU19vGJ&=hq_RbfKs`*KeM@=WlkFSCT*M8Km zS_QK&-+rs%D`vwiHvM95BKGz}nFBIiEA~)VYqrV@rmtygg!!IPK#msblJCO_?gAn{ZRo4pwJa!w9 zG2K|ce_c2d8d#&KI(QO>41xLg&J(e3vwaFPOXtAZ6QEQ!_#G?ylLeR)`AT0*bnISA zASvs zf%b)-4eJ^L^(AKBYo!kUn@KV!WSrxm~Y+Ot{e)!Y-9t7S_@7y28zOM3)6|tvnqbGLXSSe03NW--BH;> z!kohs6_Q308*9TFYCJg*eVGP(vfRTL=sOP#aBegDPIv?J5e>eLZ0SP5<7q_nMfs+9 z8U8Mju_biAIJKp*Ir`A<bw%cmih)MQ+0$ ze%FA1F7d6p17UN1N{p7N1nF+SvBX{yzSLk=p9w{thvUHM7r}$CRl8FO2^4t_jspNF z{kcT3VOyx9pTg1MoO;T_gR+Em+pT-#N-z~IH8l`mh>X9akFX|hm_1Brl*B8*lVXKp z@h_st<9cA{KC}RS>|rO050axj86{A}vP=flI7*KIT_gNJ3DP{k577*+r6|#~UMQo5 z^@;*XbyoP3=R({aA$HHuMU0&jQ;k{Na>KxI=W=Y@ z_Zor}NH_;F$qu&UGFU8iVG?ZWNV;`C{9s)@)lT;tS(DVb1d3=O0vfGO_gA$M-lBY1 z`g$Fn!O7dPq9?k?q26(|U2_Eq=Cui{d)sF??~mGPIW*7041?Z;55LW8%iuQoeeBs# zIPJd|U>t=_tS65k{`t|NIb;G3TMO9|vpLr(jZg;3EjiZYrBK_~z;*E(zg_y;72xD~ z!rjD%&b%C8@TOLJK7b)XcZT^8VLo-whArk}=BC>=z;4Ksbn*q?dWR~OEqXhT=$8APgUGrCnPZm6Rw zt=!VUKa~9o(vTpfh?Ru@q13L(#0!kM`ysizyexEcEImxZAA`>;Wu{DiQ9({&k}wpK z>^Xp<^G97ha>RsTi$~cHO`g=6C58c+smX|*tw{UvhvYdb*u8$3|K`n* zkM&s_OU)dY$feJJ_#;y;unv6;`F-_Zz{XFI<;7U(GZGXGsBj}9Z$Keno^7xrQsMBt z>dEZ{y>J$(3mq;nWuta91q}1TPabsEAKXJS1$jW8?muL4BQ7MPlfC4^;OuWNm&d3fB85p*s?0nnx7VqoJs% zNlMRW#uJWq;Viw0>wfm8Sy|BOuC|LO8W(vKTnZZnggD z7h_Rn7rt!z-dabp6Rv!nZ??yDSziPB3BL41F@J1&SXX^QmPFwYc=sAu8;Mh_y503% zx->y@xd4Z?J^oj`i(g?Texp$Sz|6mqR;V{`uvrB0Hv)|V3z#xgGSR@#9lY9PJQNAF z_{8*hY~-34ailI0=@n3SYuVBUmSbJmy0;rPU`s~}ORo>)e|fYMT^5wLbw|3c;Bc66 z?bP~V>-A>qaNk01E?iS{+bUfm&3R)#PDkj*fq(t$Q0S&}DVm=0j&MW&oY2t2d#D-g zfOpgSANPPCQ3R-vK_WG`P^*pE4FIU8-uTUnZ4mWny!z340AH%p!{MFn@*Nw_CZKglS=F zj4J1tObH(*`eZ8df?^&ZJ$FOl+a$VJ^W~NqZ&- zs|MXJbo^L3M{Z#Su)G*3zseaLoNG1^0pGw`QIuRoI1XaFDVP1jI8;$c{B=G(abczp z;BcOxUGx3Gu#Ou zhyUGj|KIYi|GT3{6}tyMi8jJarTz9u$RlCpEw$?=?>LS$)(G)@a5~>}fycGkc2Q3lX>hfIbV-qbJ_D5ZjD-V|=EHGL%hbkYfS_k(E0k-roAN%x9~ zRp7mq_U}{ww`@91XBET6b-j1!QZrKTB8~w)$t~;*()%~XHp7kgERS@r6cv~F_Nj#r zBf5YWicaRvuHMmgkK0|l-B!Gtjc2@e_&<&FxFjpEs2^4Y?`(#~5;`#$GcRv$hVT&) zu62yooNN2iOnP#~&wMI3WIf&ZxjA&Sz5P_q+xxfPCt4aB8l2B;@Hy`7%!V7z zx9n7Y%WDhZa(wJy`hP40CmtTLGspqaZF#y@iT9bwx>^9Zw?(;k=>Hkzx~tDUxEMKL z-A48c;?<)7TtxBHY>2~J+TRX(zV0E>hP2*X*MI07-ygq8d3XRjNMzClX5D5do?lmR z>qAGZUfve)8*Y6k1xjwb?^2lGI5aoh&dlEruwO9R)tag*&ns090a^tkMdKUr)@|@> zFU~<9IE>q;eP6b&?>&z(P}@Fm+W=hK}pKsdq|+#H?1c21gweYnY_-!5wr z@qE172EOo!g3_Z$^)6?DZw~tj0|yiDkENQ^?*d!h^!jzdS(qPR1N$K+Ct4w_@Be=Q Dlo^QX diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/USB-SerialConverter.png b/src/ersky9x/libraries/usb/device/cdc-serial/USB-SerialConverter.png deleted file mode 100644 index bc05c1fcbb4a974b916f5226a5c002c47501674f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10177 zcmX|{by$;M+{TA=qqO`02_;1V>FyRB-JPRH$p~qIQPSPb072S;NQZO^4x~dF2snE0 zeBX=r-o5X2p8I^a>v}%d+4Rj?b{(lnV7sFVdUmjz1eoUxtBKA-6n3tG5rmBmn zV+<6-b8;UAc#6B5{QwB3DCqAXaWM-+5&Ac6$}Jn3;|+hK~Nw#5(viBG$16;p^<6jk$D)yB4HDem=K1DY?+8` zS%_@G40fS;<f9WD69qAf`DQ|I06dCR3sFRf)1k6pwKjo%3IQ47{k*Bchd%u zX_$Nvoi>3?n?UDb)Y6jI0?%t1%!6Y*kvD|#?=ZgrLQhp=FaSW- z|L={J&O^q43Gsc@w3P6d2&nO2h&?w7asS^)$;d~}*T>1j8&F+8u8N6Bd@zxsJ=oUU z+0)0_!yQ0L$ijxniT>pZ9-eQ#ogJNg0CnW!;+T}|e^YOJ>wm3Je4O3v0YWHpLd*=| zzZqQ*2OocHZ+n2bC;DGI@&A6gGuYPE8q?|xX#4Uh2@@0iiw&*4-JRVX0bdw)VlWy0 z|9#%q+twa%j*d9IZ&UDabF+8%0sI}$=)q)o|JwANeO&DURYx-%n2iCTrYNTukT)Mp z>O*N5_;+dzDIHPqW!=g{6Vcy_m$enQ5vABE`6li8D8mnKLcNln4!WQ}kO&1w9s_^u}YZc>tSlK(+_)Ya$ZMv@o zLz`UL5<*{Jjb=C;t#gcz zvoI@8(ep<{c&mQ75P_#B9t+4{qTk>C)!faVm=MgbVfJd)B@vr7rc$6L9GD@i4!URY zkZrW<;N3>P;KuaKFY)cq;u_wfvzI1A3-diW{lPS=elgdEv+uAT6&{W-g#sHw}uq2rIZ zM#Jt|tS9hzZEn0NuUFhADp{vaXQN)M3-H>0uR>Y#m_mO&laCM=yh!6B4N2_2XTF{}eaDW{=We z3AcD_aViTWCUJ}ux9gEwW%c`~8JN{G6XmAQ#kpW5=IS|PaaC675zoMP;>Mmi@ahF6 z3KJSV*~7~Hlsn&lAz%GeJpqjEzOwXlbBx^Yxb*x`2Pf5)!2QojSQsaiqUR+5Hy2Cq zAuDffPw_pAlFrOy4Gug!*3XgFd9Ebn52dgoqF;=jD|+Ll4J$n}pJ6qV1eU#}+Qs5X zL#)@HDZ|3N$n6JtCiu(pvNA%R)TygMv=W;r4b^02#Mw2HHdCl*4EH31?&huC)0(MZ zkocr$%6t=dLPNfiC{YPFH3;zGtB=yBS#h!?1w~SGzAbF@`iu)YazXKj{qR>zgCx#3EvHj$!hd+m|$j z(K2l9AJ$W6*)JTJ*Js$7>g*b`Gt+J~-za&G^`-x)(muH*stK+78zz)adNAtqXODjr zbvo@#Q}?CvVoqR|n2DqH^mf9NZa)9rY-|SuSl*EL{iDQKY2&5kwWO>9Uol;I5}p<# z+2bb?KfMN3A9JI=8CthAF>Y-(`B9U4KDQP>mpekxV6~K2?_cuXBDn^Jr;9o!lf!5bR(2uaG}g zeiTF=m;RoK&Y4YI=bnZ5T*!y`&!UnaR2405(vp5HeedItkzQK)v+7c_{ojzKlSdDM zu7sB#sNt7Ra{N|dePfccokF$Wg6->QhN8G}iTqoF-0(?yD&T8c-Yw72!Tku1DD0{) zy6&SJy?ecLf4Z~4By17ho`AxVhwM|$fvMTvy*yYBQuDl9xn~Y+H40=kBTjrcoOAy0}>D!BNTO5mcd&k;eYz% z*#D=~Y6PSnHz~;4W*I;Jnd>h~Y}|^x9-4ugD>?r0M=i z?k8<4P8I*jGZ~FPvsx6w(lzj$c}Ze|C($ok^nhm6NnuY&?o2>d#sV~gTNj7q3v-V) z%qwo@BJd$H!nLF%X%?2#!VZfWnZA{$S#Ks1r@dJue#=;=D|h>R%q1XOPgvVN5?^b| zqg2|zw3dG~JBG)u^W1!(Ov8XNjA@$>NGs|tRYbCOw4K_6H`a6cZ4JBOq$+%?z%px7 z`(4os`j+TPm__n6KdDr|I4a@td7JzBbf3by6(34Ef9u7Z52CZh zu@}vhC8Wsvt|n?Y->LidTQ$1})6nw1p{t`H@8}a%YJlPpkqt#eNG~Z`kb)fFo6tw@ zjH4uTB*LppDacCS2=P#E5>Pp|jn^Hj$Yne|k8kex{n-*rqP*}^qw(;h!8lIUQg$Et z_ugG*d=$|_N>1)HO?s{G)R-SZX#)CPKX|{_C%9TT&D$~@Gk?+II5Wkoa89OmFcmwr z8=l%h{w0DZqru%M+BGl@9ly0RM|IBvSF*=dtZX;T1n1eOBg2W16@a+=UHerGBjfM& zjW@yKy)qu_$`=KRG*{9j;?PzH{z6qUb8&T!53A|MNDi04fIBO;Ng<}rOA)<|2YY*a zOQaTEq6|473UXB4$%BhZOL1=&v9Mo=?Di8URIJt1&F71#7173_ubst+q5>SeF)P7$ z>8qQ0&$?pI-)FtCMI{QH?~7DAi1qyHa8hvIJ>_+L9$tX!&^+>)dq<4Z2|S#z~ej;bOGfY+TLqI5z^{5RL-VRwz!|?e^GGm zad)s!JzOGt=+p007ReIuOhZ&VVWs*IJLA!L!GJG!;ZO~|zz^I@9wWn)ysKcHVhLaN zUQc~IK`Bj^vDD`TSd^no;e0yQbQ`=`jc%#U4QczW-6^aUecszNt-I}Z_07Uxr?rb< z78Gz<(o@2tohG5Gi_5>NcMNN2~tBX&&L-;HUHc$pU( z5^^*&M-h6se_0Z^Ynrhodbc+Me#zfWOCnbRmXz!_ua+=^q%c1~honxLf5yvKb|Q3n zr1Klx@t;gu2x7SUaiAijKG{`(IXm7jTzfg$qGZzwF!86yK4+j-BEQ&uIePfGVo?Lp zn1t5fAnDvm;=eh1cZPa3vMbF@PP6%eMp%F|3QiSiGu&nbQBJ?$ctsF}Eb@ol=uUp; z=j6p%CY(TZPhfSOK7N8usC0R%TVT~!3ujYH@3WUgpN5Zy=fN#&KW9C{GI$E}$}&!{ z=e``zYm>c^GSZSUzb;(Gx0>Y0pBh#W>Lq>W2M|fWUl-KOL4RKOuX;&|p~iYT{^k#& zrK?nm7`*X8(wE;r>tiBbsn1i|f%A8{mS6F#Ha~#S#wa0aAQ(@8kt=Guh5S$KS=@Jx z!uHw*vm)u}1I9D6p4Xwjzqfcy^n{&9O8zIyr`Hw8{M_2=o1Mbd5KDwCuSe;hxBWhq z1f2{^r%Zdo__Ca!81W3h(LH+(yFeqvM*xv}YI58Bn=60-=cftRFoc9sHm^?GwUhep zS6bHnLumF48$R2trmk{YGB!N~C$N}M#~}-5sxnIi=g~(tKG&Or#RZ9lkPGFOER=o- z(NdY7D-0PWFCuQJmQGe?JXyW=(bqoWRN5E+P?l;F{O0*Ri}PPWvJvx{qV85|LiTjS zw*>s~zAu)RQt=B77M`}`?o9);_*Kg-U1CSrZ2HYt+_cqVnS(H~BXa;~c6fgN>{kZ| z7(O>Nk^&;`Ju*XXxVZe(agSMQVLSg(%9Af%K`h7iSws;P4vQ0rie#NK4}4E*(@H(X z7ffM5A}BY>p*if69ynQ%T-3g7#8mxWzUCb%geZs7?#&-AGnV-s)^v_h2_;u;ER|uZ zwB#W5^tS^Cx90W3MjHzZ=#$HCmT^Amz-}a~YqJtQ-URBLEMBU0btpImC-kHCckMFD z;N6&+D#K^X@#3JE7%Ta99{tM4G zXmz-!EM=J0I7+aO*4z+>)N9<4Ih(rom7$_JY z5Q;~Wt$&>;)1g*R$j^DH4o`YS>q;BxQ%-vG88-7;*_hi9$u`RQeswlmag(DRV!kTR z;fj$4UpA@8Z>i~{kscz)N@GwpYjwr<| z|Moo37C4vwD9XdU{7|_XHEn2v^-5p;8--GmWvn|JH3S*_XD@3Gt6{qo8pGvhc%&Me z7{~uc{R4~(o>s*z^jz3{Wv{i*=UTKJSccG0G~jjN>i?wOA)X$KzGpEt^*U3v?D4?N z6QzjeH(ohWlA?UkHG=~lsZ&OoB}@y2Tot=Q-&(R&;o1>;b%?d?v<|+w&ib2FI`CuM zFxA8qPPWvO7fN%=?W|hGY$BwOvSj~t)+1E(NLk!E%?)}6Y&T|(RlT4q4gw*(N?KoN z`bqfBb2aM_m1f+?Jhhr7F)^;kl$rlUz2P4nW|zJz=L8G(>}gt37xez()<-&x1Fd(r zqzRo@bxZ8ja>`jY%LIEL0@=EcHOVKf{7kM8o7{ne_BGUQ>6e*0!7A}UU3Aj9e;44= zvd&a+8xBhSLTe5OH_;CDI`C&^t#Ys=g{pJsXe6ec&@&SMUjDGtch3S$xNUkfoPH2L zai(wm^lPWO*e#$Ia@^xE3wzOF{sd!s4_ z(pSTMNpZ_=PVIbKfuCaZnYk{eTMqp# ze{$H*+P=O9%Va&H`o;9ne;Go){9xA6fJn~t-D+xdH_9no=4z_m|K^8<%oQ?2+No`C zR=;V!JP~t3;9=^OI3%3i)p|$1w#Thj;?rC!YI<{`VW>dntA>^d3ReGe&tm0niaz9# zCTgi~R^(O++57>Y<|$I@lW&d`p+rGkWjRtRMf&5+WYLFbp-ok7@ph}&I!m*tRAcBO z+KEkhi6Qe1K-Rod@%%VU+V)l`jzJX-A`e2;IloAqdmFun&zExC?4Bi@5 zKx~vmt)6cD`D;`1_LlYMdg0=W!KZPuN_zY*w5K~chsk^Uv~7)|K-w!xkuBY>v@Ino zHNJ!Y;<@91Sg#ur*@Xn8^iP_fq^lE6IzNP?*2|cfUuaxSYsST0BOo14fs@U3MsvWh z>!+Gj?`}n9f!j7x$)O{1DTle@Ec0wh0V)axX<=zWZQ*dAaHA7dvk%UF zB2_usE#2)#-o)+*EUCN9Jmg{|wAG*6Fo{qgYXf013c%O1?uM4b-v^eUj`Hp}N>2&S zM&~6m+q-{$>NlY$?a|btp1%DMg5u5%p?+KLq(Z^%*xFcPqjR!oS~eZ~g2O{q9d245 z&`(y?k?4nTogO}`tH6hHr_%j-tcd)*Tik}|nQlwM5k+h=X5Xq#z(;=B#g*+-Z>Me9i{&~wENgrnyz>cv9i?**;?^!&5 zB=2W-hF}!zJqwTS_FsCPR2Pb$SsD3pt9fKg*QXPjSQAIV$v&y+aHWRRS;s?_Q2d9! zlX~qn@HbExg9Q%g;P$yr0zHtD5G;yOs)&iow(ZR5Mh$;2tQF$~Sw!s(I4soGJc-lb zz#=`?E?6-95;`J~3*(l|RR<(x(MmN5#b1U<@-;&0gV;i9|LH|49m%eZIp zqa=zp_zRo%k1xXcbCK>Px749ukops;q!D_ATgnl2K~(kefwHapQGX1cz3*^DR8XEv zD`=8SM9K?t)&|o(FpvvqqOC!ByuFR<;_YxWS7%TgG@@p|-u}RvLC0I`Z!=ro=zbaL z{#3t%aS?Vy>t()Qml6~rH2ZB^s=e?5U-3&_1SG%#?*E{(%L=ckZse0SAO~0CK`_h^ zxA>P`yrhD8^{>5FT0&h#;a{rE6v$h;vtUPLmFY8$L(8ma9>=r27_cV65wz^N4$gG$cnl2idnqJe@ zithXfiP{g?ZN$>&a=4cAyq-kX!B)1;nHoZ(w4463x8)& zX}4`S+e|^A;(*cI!aR8q7d|L{2-R_Z(V@dCAqCF;|aqXPv6^lKSjbB#k^s3{0=f-oLjEL zIA!ix%wH`h%;#DziBwpzg*zp#a8h2hN6!T+v{V4 zX!YepTK79B_cq2H!~uKR#r$%WC$jo98OG42bChY3+c-cwG_hQZ&3OnGKd^YmO)WnXJ2^&cBM&{Jcl7$C`HX=`I9H*xi;B3B zJKBeCq{-mhfIXIv)QzJeoaeXA&b5&0SW_;8@eAJzfxd1+zmIq1Jzl6Cld@3|8M(l( zm?1~_x5m1*tBWV4Ms79H+p!8cs-(+y(|^N+`R3T z$4SCtTib|wwxU_C-tfhIei34NqI5Tlp!dsK-XEnCN13p(i%GYm)Oq(bgw6Eo5%1+K0Fh*tMkpM-Ps!fYT-snFi*4$=%DacCZPj5rZ z)-&jKk?kt-k<7kZ+t#H;eyUa&JsZOdAvy3x<{|m#*BoyV2YnH|679rK%tLFg2-t+W zZ{tw)RsIg4LPYi}I|6qHLwB+EGLn8dKLR*3f0ix;1`&ZS6kHEO9T~^m^AsY!MVuNm zh4^uh+D6^8kT{Q5B5%|LF-keI^)Y#rRj*y*dj}5{Zb%H5AC7itw?!ycM0_<$%p(w2 zT#8#fA9swT!ZO#(;(O3ZDj)@T*ho`EIzN47Wr4p3{A-K+AySVjn8rQ@J9XsInYb$= zAJzes1tf4|q+i(i^3nTPjXRzT2RwXjg!L<&7$#@UV;)>;m1$L{)7@;qB8Hdv5}x~G zZuljH%X4xEEkYo-Y_Q2__6aBabpymNpe}H8?^(RdzY8=XKeFuK$U~T&Mz%7vB+Y}BWK}**tL%+B+j{v5Hmc?42~c#YNKaQ48E;gWe?5a;l1}Jk z;O?C8TzC$0L-+NY$o&tLl~t%zw=xxX=6YGp6|)|6X`9Fk7&hwjQ0uoG(={D@i!VDl z9h73>A%A~%;U6w`pZsC)f5DiyA{-F3kkYHf^Fqdx11E5WM*C68u|@85mldls6lhgfr`^hL9W=d!QxnDS?FWr$tFv5oziah+8b&P)2rN2se& zk1BRg7L|;VXuf@!!1h7jD$i>hiq|W^~ zOgY;8Y-(GHyf-U?xh3p-&ViWkP^=cZS#YK$6I}QwA?K?tsU}4yYXu}3IGL4@yg&Rg zZvTO3cnQL7xUSMUH9Yd3g$q%5>VspeFecl85E~>T%$$Aw+@6=5C@MTTQ?BjsD{k?K zF-~B+x+hCT3>MZ80~akKKNirlHd>xE7M4f;Bl_;JU!AE;{5ziK63My|$&fW{k3L|} zXK%!|$M|h+YpY|oH0}4ZTM}@bNnEaxDqMq+7cqUnXc)CvtIe{?)CKZL^mF>rWZ_)PzB zDS8zjFX;E6_fazin}`e7){ys>W>yfFI1fNFlN+0eex~fvt?x)m^M|OStB<|poizfs z0=L45F2=VvT*GG+0&n~v3HK~!{JKawN1}63M6+0SEg$KH*m2}MSduhXj(F6_eJ7~u zF78GT?uhk^tF+lKhQGJ*8#*pGr&@>S(hI9%W+=k{{Y6SK@xhQy^+jP)Ydcu;=y}^%<8gp@=IY zgNpy)oa<8osp29_q*Lh|l?7ed|3Ax-!1?_CiA^V>N+FoIfV&it#&WoX`!3{FQ$X5t zjbaAgo_q^I&1eHc#2=E(&2u437aVehZ?~P+3z<9N_)A*)qC{PD>-fW1wua$7DhG`J zIixLnxSS{ExDHF%C5jmIeKPoZEOL}HzXa&sU|c16%)oHiE67{JHJ-2U)NtfGh=f-z z=!A;63U=dwvJ2sdAsM$sFXs?RpN9tr4;+o^^mKMf*5b1*CW1e-R=a+wU2?qMXL`NNJaeVM|#1uNM%b9fR zsD>j0$TjuQkk%1`ebW<|OLXG#6W+!>&`d zWAK7C4z05e__MAu7Hs>UA0t5#5?!h>xBl$Qmzt*fAw*HwR%m#dy+v&ASccgEw3z6z?XSd0}mmwL1)6`Qv0(NlwD zOlZO#)kRt>1nfi`3}9uBOyqH0jOO;mx`{JsPo|xlDbdU;NEW;f+$uB3HQa0)_Z293 zJ=Y~*vr;Z)e`zW;8f|tcu$-LVt48%ft8gS+(4@dVKIo9K=M|}qdV75Ua&-K1q{&Pu zpdq+(PV-v|@%XQC`sb5PO2VqMWzR;G)cXB83FgZ#rE(6@v=tiP_QtbE3+)v&WqxNC za^yXz=fUPP|8vvHWz{i$jwaSEf(eQt;Tz{ohpYd8mV=lc&n88_FBf<2;t{yzdizBQ z$f9dKtyF)#w)$nDqi4DiaZM74?0)wWtlh46;}Fx={oWV#_am;A zJQo(?rRAAEq2WupdsFV=M^NniEIq$e>DWh?_H9hO;}vth2Ftgj>f`P@nT^ubLdKN$ z^=Bi_*MkafQx1En%IZGxX2B;bH*aRq2FnQ>{_W%Mx=C@?GxI;gs)6_# z5$)4%%iMKlw`*IJtFc;jlF#4%VMf1LAeBAm{{!2+Pg4;1Ml%VBpnZf{~3@Obq{ z|3x&odf_c1@cr90oK)qZG+yrP&%T}2M+(p2Yb@Pi{2sG66^Bjik!y6n z>Mp)D|MgQnFQ&dW9-O>bRtvFuT!+q%sZX&lC%d_mDdnG4tE^G~F)6T;+2=CaP<=xR z-GgTN1~Sv5mfd@iJ9HE{Y$51~*=gonzJ33VjyZbU0Z`t}!%Q*&-!A=s&jjWlB|V6ynH{ziGAjXP#_Vqd;j#iB|TQNxRKCiv&>%s~s3 zCz=@)jc9#o&k7%Z_+m$9{sWU5`$et)O=$*03v9;Qp!|_w)XDWM%cj;WXgVcQ^YLPf z*JH%)w#ZIMF>cSdOr%+nTS8Sh=5dQ{Li>2_Bv&y!^Y_MevnxRIm7E7Alcd=Ts1nq6 zMbB}lWTEJ_P`ra9@6=Y7!4h$pgSVF~$zGc&W5JiR_e0M9uhr9UMo;Xn;~Rocwqu?r yt?&djyMJtV(-xP)T6-1rK)S7Ohw5+>jh}+u2}pHxw#3{&KuzhjV!gao`2PUjJ%&X9 diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/cdc-serial.dir b/src/ersky9x/libraries/usb/device/cdc-serial/cdc-serial.dir deleted file mode 100644 index ff18ab06b..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/cdc-serial.dir +++ /dev/null @@ -1,646 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB CDC -/// %device - USB CDC Serial Converter demo, to implement an USB Serial COM port -/// driver. -/// -/// !!!Contents -/// -/// There are two things for the implement of the USB CDC Serial %device driver: -/// - Implement the CDC Serial driver structs and functions for the %device, -/// to initialize, to handle CDC-specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the CDC Serial device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the %device as a USB CDC Serial COM port %device. -/// -/// For more information about what a particular group contains, please refer to -/// "USB CDC Serial Device". -//------------------------------------------------------------------------------ - -/** - \page "USB CDC Serial Device" - This page describes how to use the USB framework to produce a USB CDC Serial - Device driver, which appears as a virtual COM port on host. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Communication Device Class Documents (.zip file format) - - Abstract Control Model Serial Emulation (USB Class Definitions for - Communication Devices, section 3.6.2.1). - - !!!Communication Device Class - - You can get some basic information about the Communication Device Class. - - !!Purpose - - CDC is used to connect communication devices, such as modems (digital or - analog), telephones or networking devices. Its generic framework supports a - wide variety of physical layers (xDSL, ATM, etc.) and protocols. - - In this document, CDC is used to implement a USB to a serial data converter. - A USB to serial converter can be used in this case to bridge a legacy RS-232 - interface with a USB port. - - !!Architecture - ... - - !Communication Class Interface - The #Communication Class Interface# is used for %device management. It - includes requests to manage the %device state, its responses, as well as - event notifications. This interface can also be optionally used for call - management, i.e., setting up and terminating calls as well as managing - their parameters. - - The interface requires at least one endpoint (#Default EP0#) to used for - %device management. Optionally, another endpoint can be dedicated to - event notification. This will usually be an #Interrupt IN# endpoint. - - !Data Class Interface - The #Data Class Interface# is used for generic data transmissions. It provides - a means for a communication %device to actually transfer data to and from the - host. In addition, it also enables the multiplexing of data and commands on - the same interface, through the use of wrappers. - - %Endpoints for this interface must exist in pairs of the same type. This is - necessary to allow both IN and OUT communication. Only the #Bulk# and - #Isochronous# types can be used for these %endpoints. - - \image CDCArchitecture.png "CDC Class Driver Architecture" - - !Models - To account for the wide variety of existing communication devices, several - #models# have been defined, for more details you can refer to CDC spec. 1.1. - - POTS (Plain Old Telephone Service) - - Direct Line Control Model - - Datapump Model - - Abstract Control Model (ACM) - - Telephone - - Telephone Control Model - - ISDN - - Multi-Channel Model - - USB CAPI Model - - Networking - - Ethernet Networking Model - - ATM Networking Control Model - - !Class-specific Descriptors - CDC-specific information is described using Functional Descriptors. They - define various parameters of an interface, such as how the %device handles - call management, or model-specific attributes. - - Since the CDC specification defines quite a number of functional descriptors, - they are not detailed here. Instead, they are presented in the various case - studies of this document in which they are used. - - !!Host Drivers - Most Operating Systems (OS) now include generic drivers for a wide variety of - USB classes. This makes developing a %device simpler, since the host complexity - is now handled by the OS. Manufacturers can thus concentrate on the %device - itself, not on developing specific host drivers. - - Here is a brief list of the various CDC implementations supported by several - OS: - - Windows - - Abstract Control Model - - Remote NDIS - - Linux - - Abstract Control Model - - Ethernet Model - - !!!USB to Serial Converter - This section describes the implementation of the USB to serial converter using - the CDC class and the AT91 USB Device Framework. - - !!Bridging a Legacy Device and a Host with USB-Serial Converter - \image USB-SerialConverter.png - - !!Model - The CDC specification defines a model which suits this application perfectly: - the #Abstract Control Model (ACM)#. It implements the requests and - notifications necessary to communicate with an RS-232 interface. - - The Abstract Control Model requires two interfaces, one #Communication Class - Interface# and one #Data Class Interface#. Each of them must have two - associated endpoints. The former shall have one endpoint dedicated to %device - management (default Control endpoint 0) and one for events notification - (additional Interrupt IN endpoint). - - The Data Class Interface needs two endpoints through which to carry data to - and from the host. Depending on the application, these endpoints can either - be Bulk or Isochronous. In the case of a USB to serial converter, using Bulk - endpoints is probably more appropriate, since the reliability of the - transmission is important and the data transfers are not time-critical. - - !!Descriptors - The descriptors are modtly standard ones. The following code examples thus - use the structures described in the "AT91 USB device framework". - - For CDC-specific descriptors, some new types are defined: - - CDCHeaderDescriptor - - CDCCallManagementDescriptor - - CDCAbstractControlManagementDescriptor - - CDCUnionDescriptor - - All the descriptors can be found in CDCDSerialDriverDescriptors.c. - - !Device Descriptor - \code -const USBDeviceDescriptor deviceDescriptor = { - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - CDCDeviceDescriptor_CLASS, - CDCDeviceDescriptor_SUBCLASS, - CDCDeviceDescriptor_PROTOCOL, - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), - CDCDSerialDriverDescriptors_VENDORID, - CDCDSerialDriverDescriptors_PRODUCTID, - CDCDSerialDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - \endcode - The Vendor ID and Product ID fields are used to determine which driver to use - when the %device is enumerated. The Vendor ID is provided by the USB-IF - organization after registration; the product ID is completely vendor-specific. - In the example implementation provided with this document, the Atmel vendor ID - (03EBh) is used along with a custom product ID (6119h). - - The configuration descriptor is followed by interface, endpoint and class- - specific descriptors. -\code -const CDCDSerialDriverConfigurationDescriptors configurationDescriptors[]; -\endcode - - !Configuration Descriptor -\code - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CDCDSerialDriverConfigurationDescriptors), - 2, // There are two interfaces in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, -\endcode - - !Communication Class Interface Descriptor - The bInterfaceClass should be set to 0x02 and bInterfaceSubClass should be set - to 0x02. -\code - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, -\endcode - - !Functional - Header Descriptor -\code - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, -\endcode - - !Functional - Call Management Descriptor -\code - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - 0 // No associated data interface - }, -\endcode - - !Functional - Abstract Control Management Descriptor -\code - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, -\endcode - - !Functional - Union Descriptor -\code - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - 0, // Number of master interface is #0 - 1 // First slave interface is #1 - }, -\endcode - - !Notification Endpoint Descriptor - The EP is defined as CDCDSerialDriverDescriptors_NOTIFICATION. -\code - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_INTERRUPT, - MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( - CDCDSerialDriverDescriptors_NOTIFICATION), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 10 // Endpoint is polled every 10ms - }, -\endcode - - !Data Class Interface Descriptor -\code - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, -\endcode - - !Data Endpoint Descriptors - The EPs are defined as CDCDSerialDriverDescriptors_DATAOUT & - CDCDSerialDriverDescriptors_DATAIN. -\code - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_BULK, - MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( - CDCDSerialDriverDescriptors_DATAOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_BULK, - MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( - CDCDSerialDriverDescriptors_DATAIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, -\endcode - - !String Descriptors - Several descriptors (device, configuration, interface, etc.) can specify the - index of a string descriptor to comment their use. - - The actual string code is defined: - productStringDescriptor. - - !!Class-specific Requests - The CDC specification defines a set of #class-specific requests# for devices - implementing the ACM. This section details these requests. Please refer to - section 3.6.2.1 of the CDC spec. 1.1 for more information. - - !SetLineCoding, GetLineCoding - These requests are sent by the host to modify or retrieve the configuration of - the serial line, which includes: - - Baudrate - - Number of stop bits - - Parity check - - Number of data bits - - When the terminal application (such as HyperTerminal) on the host (PC) side - changes the setting of the COM port, a SetLineCoding request is sent with the - new parameters. The host may also retrieve the current setting using - GetLineCoding, not modifying them if they are correct. - - When a SET_LINE_CODING request is received, the %device should read the new - parameters. Then program the new parameters in the USART. A callback must be - provided to the USBD_Read function. - See CDCDSerialDriver_SetLineCoding. - - The code handling GET_LINE_CODING shall simply invoke the USBD_Write function - to send the current settings of the USART to the host. - See CDCDSerialDriver_GetLineCoding. - - !SetControlLineState - This request is sent by the host to notify the %device of two state changes. - The first bit (D0) of the wValue field of the request indicates whether or not - a terminal is connected to the virtual COM port. Bit D1 indicates that the - USART should enable/disable its carrier signal to start/stop receiving and - transmitting data. - - In practice, the USB to serial converter should operate only when those two - bits are set. Otherwise, it should not transmit or receive data. - - Since the SET_CONTROL_LINE_STATE request does not have a data payload, the - %device only has to acknowledge the request by sending a ZLP (zero-length - packet), using the USBD_Write method. - See CDCDSerialDriver_SetControlLineState. - - Before that, the wValue field should be parsed to retrieve the new control - line state. A single boolean variable can be used to keep track of the - connection state. If both the D0 and D1 bits are set, then the converter - should operate normally, i.e., forward data between the USART and the USB - host. Otherwise, it should stop its activity. - - !!Notifications - Notifications are sent by the %device when an event, such as a serial line - state change, has occurred. In this example, they are transmitted through a - dedicated Interrupt IN endpoint. A special header must precede the data - payload of each notification. This header has the same format of a SETUP - request, so the USBGenericRequest structure defined in the - "AT91 USB device framework" can be used. - - Note that the %device should only send a notification when there is a state - change, and not continuously. This does not really matter in practice, but - only sending notifications sporadically will reduce the stress on the %device. - - When the serial state is changed by CDCDSerialDriver_SetSerialState, the - notification is sent to the host. - - !!!CDC Serial Driver API - - CDCDSerialDriver_Initialize - - CDCDSerialDriver_RequestHandler - - CDCDSerialDriver_Read - - CDCDSerialDriver_Write - - CDCDSerialDriver_GetSerialState - - CDCDSerialDriver_SetSerialState - - !!!Main Application - The job of the main application is to bridge the USART and the USB. This means - that data read from one end must be forwarded to the other end. This section - describes several possibilities to do this. - - !!USB Operation - Reading data coming from the host is done using the CDCDSerialDriver_Read. - Since this is an asynchronous function, it does not block the execution flow. - This means that other actions (like reading data from the USART) can be - performed while the transfer is going on. Whenever some data is sent by the - host, the transfer terminates and the associated callback function is invoked. - This callback (UsbDataReceived) can be programmed to forward the received data - through the USART. - - Likewise, the CDCDSerialDriver_Write function can be called as soon as there - is data to transmit, again without block the program flow. However, there - cannot be two write operations at the same time, so the program must check - whether or not the last transfer is complete. This can be done by checking the - result code of the CDCDSerialDriver_Write method. If USB_STATUS_LOCKED is - returned, then there is already another operation in progress. The %device - will have to buffer the data retrieved from the USART until the endpoint - becomes free again. - - !!USART Operation - The USART peripheral present on AT91 chips can be used in two different ways. - The classic way is to read and write one byte at a time in the correct - registers to send and receive data. - - A more powerful method is available on AT91SAM chips, by using the embedded - Peripheral DMA Controller (PDC). The PDC can take care of transfers between - the processor, memory and %peripherals, thus freeing the processor to perform - other tasks. Since the PDC interrupt happens on the buffer full, Some timer - can be used to check if there is any data frags input from the USART. - - !!!Using a Generic Host Driver - See "USB CDC Serial Host Driver". - - !!!Add two or more ports in one USB device - See "USB Dual Port CDC Serial Device". - -*/ - -/** - \page "USB CDC Serial Host Driver" - Both Microsoft Windows and Linux offer a generic driver for using a USB to - serial converter %device. This page details the steps required to make use - of them. - - !!!Windows - On Microsoft Windows, the standard USB serial driver is named usbser.sys and - is part of the standard set of drivers. It has been available since Windows - 98SE. However, conversely to other generic driver such as the one for Mass - Storage Devices (MSD), usbser.sys is not automatically loaded when a CDC - %device is plugged in. - - !!Writing a Windows Driver File - For Windows to recognize the %device correctly, it is necessary to write a - .inf file. The Windows Driver Development Kit (DDK) contains information on - this topic. A basic driver, named 6119.inf in the example software provided, - will now be described. The driver file is made up of several sections. - - The first section of the .inf file must be the #[Version]# section. It - contains information about the driver version, provider, release data, and so - on. -\code -[Version] -Signature="$Chicago$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} -Provider=%ATMEL% -DriverVer=09/12/2006,1.1.1.1 -\endcode - - The Signature attribute is mandatory and can be either "$Windows 95$", - "$Windows NT$" or "$Chicago$", depending on which Windows version(s) the - driver supports. "$Chicago$" is used to notify that every Windows version is - supported. Since in this example, the USB to serial converter is a virtual COM - port, the Class attribute should be equal to "Ports". The value of ClassGuid - depends on which class the %device uses. The Provider value indicates that the - string descriptor for the driver provider will be defined further, under the - tag ATMEL. Finally, the last tag show the driver version and release date. For - the version number, each digit is optional (except the first one), but must - not be null if present. - - Next come two sections, #[SourceDisksNames]# and #[SourceDisksFiles]#. They - are used to specify the installation disks required and the location of each - needed files on these disks. But they are not implemented because the file - is offered by windows or its install disk automatically. -\code -;[SourceDisksNames] -;1="Windows Install CD" -;[SourceDisksFiles] -;usbser.sys=1 -\endcode - - The driver file must now specify where copied files will be stored, using the - #[DestinationDirs]# section. -\code -[DestinationDirs] -DefaultDestDir=12 -\endcode - The target directory must be identified by its ID, which is system-defined. - The ID for the drivers directory is 12. - - The #[Manufacturer]# section lists the possible manufacturers for all devices - supported by this driver. In this case, the only supported %device is an ATMEL - one, so this will be the only value. -\code -[Manufacturer] -%ATMEL%=AtmelMfg -\endcode - - The attribute must be a string tag; its value must be the name of the Models - section in which all supported devices from this manufacturer will be listed. - In this case, it will be named AtmelMfg, which is the next section. - - Each Models section must list the hardware ID of each supported %device. For - USB devices, the hardware ID is made up of the Vendor ID, the Product ID and - (optionally) the Device Release Number. Those values are extracted from the - %device descriptor provided during the enumeration phase. -\code -[AtmelMfg] -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6119 -\endcode - - The attribute name is again a string tag, which will be used to describe the - %device. The value is comprised of both the %device install section name - (USBtoSer.Install) and the hardware ID. The hardware ID is the same as the one - defined in "CDC Serial Device IDs". - - Now, the .inf file must detail the install section of each %device previously - listed. In this example, there is only one install section, named - #[USBtoSer.Install]#: -\code -[USBtoSer.Install] -CopyFiles=USBtoSer.CopyFiles -AddReg=USBtoSer.AddReg - -[USBtoSer.CopyFiles] -usbser.sys,,,0x00000002 - -[USBtoSer.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,usbser.sys - -[USBtoSer.Install.Services] -AddService=usbser,0x00000002,USBtoSer.AddService - -[USBtoSer.AddService] -DisplayName=%USBSer% -ServiceType=1r -StartType=3 -ServiceBinary=%12%\usbser.sys -\endcode - - The install section is actually divided in five. In the first section, two - other section names are specified: one for the list of files to copy, and one - for the keys to add to the Windows registry. There is only one file to copy, - usbser.sys; a flag (0x00000002) is used to specify that the user cannot skip - copying it. The registry keys are needed to install the driver on older - versions of Windows (such as Windows 98). For newer versions, the - #[USBtoSer.Install.Services]# registers the needed kernel services; each - service is actually listed in a section on its own. - - Finally, the last section, [Strings], defines all the string constants used - through this file: -\code -[Strings] -ATMEL="ATMEL Corp." -USBtoSerialConverter="AT91 USB to Serial Converter" -USBSer="USB Serial Driver" -\endcode - - !!Using the Driver - When a new %device is plugged in for the first time, Windows looks for an - appropriate specific or generic driver to use it. If it does not find one, the - user is asked what to do. - - This is the case with the USB to serial converter, since there is no generic - driver for it. To install the custom driver given in the previous section, - Windows must be told where to look for it. This can be done by selecting the - second option, "Install from a list or specific location", when the driver - installation wizards pops up. It will then ask for the directory where the - driver is located. After that, it should recognize the "AT91 USB to Serial - Converter" driver as an appropriate one and display it in the list. - - During the installation, the wizard asks for the location of the usbser.sys - file. If it is already installed on the system, it can be found in - "C:\Windows\System32\Drivers\". Otherwise, it is present on the Windows - installation CD. - - Once the driver is installed properly, a new COM port is added to the system - and can be used with HyperTerminal, for example. - - !!!Linux - Linux has two different generic drivers which are appropriate for a USB to - serial converter. The first one is an Abstract Control Model driver designed - for modem devices, and is simply named #acm#. The other one is a generic USB - to serial driver named #usbserial#. - - If the support for the #acm# driver has been compiled in the kernel, Linux - will automatically load it. A new terminal %device will be created under - /dev/ttyACMx. - - The usbserial driver must be loaded manually by using the modprobe command - with the vendor ID and product ID values used by the %device: -\code - modprobe usbserial vendor=0x03EB product=0x6119 -\endcode - - Once the driver is loaded, a new terminal entry appears and should be named - /dev/ttyUSBx. -*/ - -/** - \page "USB Dual Port CDC Serial Device" - -*/ diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/drv/6119.inf b/src/ersky9x/libraries/usb/device/cdc-serial/drv/6119.inf deleted file mode 100644 index 14bd8d318..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/drv/6119.inf +++ /dev/null @@ -1,45 +0,0 @@ -; $Id: 6119.inf,v 1.1.2.1 2006/12/05 08:33:25 danielru Exp $ - -[Version] ; Version section -Signature="$Chicago$" ; All Windows versions -Class=Ports ; This is a serial port driver -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} ; Associated GUID -Provider=%ATMEL% ; Driver is provided by ATMEL -DriverVer=09/12/2006,1.1.1.5 ; Driver version 1.1.1.5 published on 23 February 2007 - -[DestinationDirs] ; DestinationDirs section -DefaultDestDir=12 ; Default install directory is \drivers or \IOSubSys - -[Manufacturer] ; Manufacturer section -%ATMEL%=AtmelMfg ; Only one manufacturer (ATMEL), models section is named - ; AtmelMfg - -[AtmelMfg] ; Models section corresponding to ATMEL -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6119 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6119h. Corresponding Install section - ; is named USBtoSer.Install - -[USBtoSer.Install] ; Install section -include=mdmcpq.inf -CopyFiles=FakeModemCopyFileSection -AddReg=USBtoSer.AddReg ; Registry keys to add are listed in USBtoSer.AddReg - -[USBtoSer.AddReg] ; AddReg section -HKR,,DevLoader,,*ntkern ; -HKR,,NTMPDriver,,usbser.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[USBtoSer.Install.Services] ; Services section -AddService=usbser,0x00000002,USBtoSer.AddService ; Assign usbser as the PnP driver for the device - -[USBtoSer.AddService] ; Service install section -DisplayName=%USBSer% ; Name of the serial driver -ServiceType=1 ; Service kernel driver -StartType=3 ; Driver is started by the PnP manager -ErrorControl=1 ; Warn about errors -ServiceBinary=%12%\usbser.sys ; Driver filename - -[Strings] ; Strings section -ATMEL="ATMEL Corp." ; String value for the ATMEL symbol -USBtoSerialConverter="AT91 USB to Serial Converter" ; String value for the USBtoSerialConverter symbol -USBSer="USB Serial Driver" ; String value for the USBSer symbol \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/cdc-serial/drv/drv.dir b/src/ersky9x/libraries/usb/device/cdc-serial/drv/drv.dir deleted file mode 100644 index a2ff78a58..000000000 --- a/src/ersky9x/libraries/usb/device/cdc-serial/drv/drv.dir +++ /dev/null @@ -1,41 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides install file for a CDC serial port %device. -/// -/// !!!Contents -/// -/// 6119.inf -/// -//------------------------------------------------------------------------------ diff --git a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.c b/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.c deleted file mode 100644 index a1645aa62..000000000 --- a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.c +++ /dev/null @@ -1,282 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include -// USB -#include -// AUDIO -#include -#include - -#include "AUDDFunctionDriver.h" -#include "AUDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USB audio speaker driver instance. -static AUDDSpeakerChannel auddSpeakerChannels[AUDD_NUMCHANNELS+1]; -/// Intermediate storage variable for the mute status of a channel. -static unsigned char muted; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Changes the mute status of the given channel accordingly. -/// \param channel Number of the channel whose mute status has changed. -//----------------------------------------------------------------------------- -static void AUDD_MuteReceived(unsigned char channel) -{ - AUDDSpeakerChannel *pChannel = &auddSpeakerChannels[channel]; - if (muted) { - - if (!pChannel->muted) { - - pChannel->muted = 1; - AUDDSpeakerChannel_MuteChanged(pChannel, 1); - } - } - else { - - if (pChannel->muted) { - - pChannel->muted = 0; - AUDDSpeakerChannel_MuteChanged(pChannel, 0); - } - } - - USBD_Write(0, 0, 0, 0, 0); -} - -//----------------------------------------------------------------------------- -/// Sets the current value of a particular Feature control of a channel. -/// \param channel Number of the channel whose feature will change. -/// \param control The feature control that will change. -/// \param length The feature data size. -//----------------------------------------------------------------------------- -static void AUDD_SetFeatureCurrentValue(unsigned char channel, - unsigned char control, - unsigned short length) -{ - TRACE_INFO_WP("sFeature "); - TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length); - - // Check the the requested control is supported - // Mute control on master channel - if ((control == AUDFeatureUnitRequest_MUTE) - && (channel < (AUDD_NUMCHANNELS+1)) - && (length == 1)) { - - unsigned int argument = channel; // Avoids compiler warning - USBD_Read(0, // Endpoint #0 - &muted, - sizeof(muted), - (TransferCallback) AUDD_MuteReceived, - (void *) argument); - } - // Control/channel combination not supported - else { - - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Sends the current value of a particular channel Feature to the USB host. -/// \param channel Number of the channel whose feature will be sent. -/// \param control The feature control that will be sent. -/// \param length The feature data size. -//----------------------------------------------------------------------------- -static void AUDD_GetFeatureCurrentValue(unsigned char channel, - unsigned char control, - unsigned char length) -{ - TRACE_INFO_WP("gFeature "); - TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length); - - // Check that the requested control is supported - // Master channel mute control - if ((control == AUDFeatureUnitRequest_MUTE) - && (channel < (AUDD_NUMCHANNELS+1)) - && (length == 1)) { - - muted = auddSpeakerChannels[channel].muted; - USBD_Write(0, &muted, sizeof(muted), 0, 0); - } - else { - - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes an USB audio speaker function driver -//----------------------------------------------------------------------------- -void AUDDFunctionDriver_Initialize() -{ - auddSpeakerChannels[0].muted = 0; - auddSpeakerChannels[0].number = AUDD_MASTERCHANNEL; - auddSpeakerChannels[1].muted = 0; - auddSpeakerChannels[1].number = AUDD_LEFTCHANNEL; - auddSpeakerChannels[2].muted = 0; - auddSpeakerChannels[2].number = AUDD_RIGHTCHANNEL; - - // Initialize the third LED to indicate when the audio interface is active - LED_Configure(USBD_LEDOTHER); -} - -//----------------------------------------------------------------------------- -/// Handles AUDIO-specific USB requests sent by the host -/// \param request Pointer to a USBGenericRequest instance. -/// \return 0 if the request is Unsupported, 1 if the request handled. -//----------------------------------------------------------------------------- -unsigned char AUDDFunctionDriver_RequestHandler( - const USBGenericRequest *request) -{ - unsigned char entity; - unsigned char interface; - - // Check if the request is supported - switch (USBGenericRequest_GetRequest(request)) { - - case AUDGenericRequest_SETCUR: - TRACE_INFO_WP( - "sCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if ((entity == AUDD_Descriptors_FEATUREUNIT) - && (interface == AUDD_Descriptors_CONTROL)) { - - AUDD_SetFeatureCurrentValue( - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - case AUDGenericRequest_GETCUR: - TRACE_INFO_WP( - "gCur(0x%04X) ", - USBGenericRequest_GetIndex(request)); - - // Check the target interface and entity - entity = AUDGenericRequest_GetEntity(request); - interface = AUDGenericRequest_GetInterface(request); - if ((entity == AUDD_Descriptors_FEATUREUNIT) - && (interface == AUDD_Descriptors_CONTROL)) { - - AUDD_GetFeatureCurrentValue( - AUDFeatureUnitRequest_GetChannel(request), - AUDFeatureUnitRequest_GetControl(request), - USBGenericRequest_GetLength(request)); - } - else { - - TRACE_WARNING( - "AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r", - USBGenericRequest_GetIndex(request)); - USBD_Stall(0); - } - break; - - default: - return 0; - } - return 1; -} - -//----------------------------------------------------------------------------- -/// Invoked whenever the active setting of an interface is changed by the -/// host. Changes the status of the third LED accordingly. -/// \param interface Interface number. -/// \param setting Newly active setting. -//----------------------------------------------------------------------------- -void AUDDFunctionCallbacks_InterfaceSettingChanged(unsigned char interface, - unsigned char setting) -{ - if ((interface == AUDD_Descriptors_STREAMING) && (setting == 0)) { - - LED_Clear(USBD_LEDOTHER); - } - else { - - LED_Set(USBD_LEDOTHER); - } -} - -//----------------------------------------------------------------------------- -/// Reads incoming audio data sent by the USB host into the provided buffer. -/// When the transfer is complete, an optional callback function is invoked. -/// \param buffer Pointer to the data storage buffer. -/// \param length Size of the buffer in bytes. -/// \param callback Optional callback function. -/// \param argument Optional argument to the callback function. -/// \return if the transfer is started successfully; -/// otherwise an error code. -//----------------------------------------------------------------------------- -unsigned char AUDDSpeakerDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument) -{ - return USBD_Read(AUDD_Descriptors_DATAOUT, - buffer, - length, - callback, - argument); -} - -#endif // (AUDIO defined) - diff --git a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.h b/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.h deleted file mode 100644 index 637fc6775..000000000 --- a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriver.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef AUDDFUNCTIONDRIVER_H -#define AUDDFUNCTIONDRIVER_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Sample rate in Hz. -#define AUDD_SAMPLERATE 48000 -/// Number of channels in audio stream. -#define AUDD_NUMCHANNELS 2 -/// Number of bytes in one sample. -#define AUDD_BYTESPERSAMPLE 2 -/// Number of bits in one sample. -#define AUDD_BITSPERSAMPLE (AUDD_BYTESPERSAMPLE * 8) -/// Number of samples in one USB subframe. -#define AUDD_BYTESPERSUBFRAME (AUDD_NUMCHANNELS * AUDD_BYTESPERSAMPLE) -/// Number of samples in one USB frame. -#define AUDD_SAMPLESPERFRAME (AUDD_SAMPLERATE / 1000 * AUDD_NUMCHANNELS) -/// Number of bytes in one USB frame. -#define AUDD_BYTESPERFRAME (AUDD_SAMPLESPERFRAME * AUDD_BYTESPERSAMPLE) -/// Master channel. -#define AUDD_MASTERCHANNEL 0 -/// Front left channel. -#define AUDD_LEFTCHANNEL 1 -/// Front right channel. -#define AUDD_RIGHTCHANNEL 2 - -//----------------------------------------------------------------------------- -// Structs -//----------------------------------------------------------------------------- - -/// AUDIO Speaker channel struct -typedef struct { - - unsigned char number; - unsigned char muted; - -} AUDDSpeakerChannel; - -//----------------------------------------------------------------------------- -// Callbacks -//----------------------------------------------------------------------------- -extern void AUDDSpeakerChannel_MuteChanged(AUDDSpeakerChannel *channel, - unsigned char muted); - -extern void AUDDFunctionCallbacks_InterfaceSettingChanged( - unsigned char interface, - unsigned char setting); - - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//- Function API For composite device -extern void AUDDFunctionDriver_Initialize(); - -extern unsigned char AUDDFunctionDriver_RequestHandler( - const USBGenericRequest * request); - -//- AUDIO Speaker API -extern unsigned char AUDDSpeakerDriver_Read(void *buffer, - unsigned int length, - TransferCallback callback, - void *argument); - -#endif // #define AUDDFUNCTIONDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriverDescriptors.h deleted file mode 100644 index a5a64f456..000000000 --- a/src/ersky9x/libraries/usb/device/composite/AUDDFunctionDriverDescriptors.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef AUDDFUNCTIONDRIVERDESCRIPTORS_H -#define AUDDFUNCTIONDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// COMPOSITE option -#if defined(usb_CDCAUDIO) -#define AUDD_Descriptors_INTERFACE 2 -#elif defined(usb_HIDAUDIO) -#define AUDD_Descriptors_INTERFACE 1 -#endif - -/// - Endpoint numbers -/// Data out endpoint number -#define AUDD_Descriptors_DATAOUT 0x05 - -/// - Interface IDs -/// Audio control interface ID -#define AUDD_Descriptors_CONTROL (AUDD_Descriptors_INTERFACE + 0) -/// Audio streaming interface ID -#define AUDD_Descriptors_STREAMING (AUDD_Descriptors_INTERFACE + 1) - -/// - Entity IDs -/// Input terminal ID. -#define AUDD_Descriptors_INPUTTERMINAL 0 -/// Output terminal ID. -#define AUDD_Descriptors_OUTPUTTERMINAL 1 -/// Feature unit ID. -#define AUDD_Descriptors_FEATUREUNIT 2 - -#endif // #define AUDDFUNCTIONDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.c b/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.c deleted file mode 100644 index 4e4201568..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.c +++ /dev/null @@ -1,337 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -// USB -#include -#include -// CDC -#include -#include - -#include "CDCDFunctionDriver.h" -#include "CDCDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -/// CDC Function Driver Struct -typedef struct { - USBDDriver * pUsbdDriver; - CDCDSerialPort * pCdcPorts; - unsigned char numPorts; -} CDCFunDriver; - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// CDC Function Driver instance -static CDCFunDriver cdcFunDriver; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Callback function which should be invoked after the data of a -/// SetLineCoding request has been retrieved. Sends a zero-length packet -/// to the host for acknowledging the request. -//----------------------------------------------------------------------------- -static void CDCD_SetLineCodingCallback() -{ - USBD_Write(0, 0, 0, 0, 0); -} - -//----------------------------------------------------------------------------- -/// Return the port index that host send this request for. -//----------------------------------------------------------------------------- -static char CDCD_GetSerialPort(const USBGenericRequest *request) -{ - unsigned char i; - for (i = 0; i < cdcFunDriver.numPorts; i ++) { - if (request->wIndex == cdcFunDriver.pCdcPorts[i].interfaceNum + 1) - return i; - } - return 0xFF; -} - -//----------------------------------------------------------------------------- -/// Receives new line coding information from the USB host. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -static void CDCD_SetLineCoding(const USBGenericRequest *request) -{ - unsigned char serial; - serial = CDCD_GetSerialPort(request); - - TRACE_INFO_WP("sLineCoding_%d ", serial); - - USBD_Read(0, - (void *) &(cdcFunDriver.pCdcPorts[serial].lineCoding), - sizeof(CDCLineCoding), - (TransferCallback) CDCD_SetLineCodingCallback, - 0); -} - -//----------------------------------------------------------------------------- -/// Sends the current line coding information to the host through Control -/// endpoint 0. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -static void CDCD_GetLineCoding(const USBGenericRequest *request) -{ - unsigned char serial; - serial = CDCD_GetSerialPort(request); - - TRACE_INFO_WP("gLineCoding_%d ", serial); - - USBD_Write(0, - (void *) &(cdcFunDriver.pCdcPorts[serial].lineCoding), - sizeof(CDCLineCoding), - 0, - 0); -} - -//----------------------------------------------------------------------------- -/// Changes the state of the serial driver according to the information -/// sent by the host via a SetControlLineState request, and acknowledges -/// the request with a zero-length packet. -/// \param request Pointer to a USBGenericRequest instance. -/// \param activateCarrier The active carrier state to set. -/// \param isDTEPresent The DTE status. -//----------------------------------------------------------------------------- -static void CDCD_SetControlLineState(const USBGenericRequest *request, - unsigned char activateCarrier, - unsigned char isDTEPresent) -{ - unsigned char serial; - serial = CDCD_GetSerialPort(request); - - TRACE_INFO_WP( - "sControlLineState_%d(%d, %d) ", - serial, - activateCarrier, - isDTEPresent); - - cdcFunDriver.pCdcPorts[serial].isCarrierActivated = activateCarrier; - USBD_Write(0, 0, 0, 0, 0); -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device CDC serial function driver. -//----------------------------------------------------------------------------- -void CDCDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - CDCDSerialPort * pCdcPorts, - unsigned char numPorts) -{ - unsigned char serial; - - TRACE_INFO("CDCDFunctionDriver_Initialize\n\r"); - - cdcFunDriver.pUsbdDriver = pUsbdDriver; - cdcFunDriver.pCdcPorts = pCdcPorts; - cdcFunDriver.numPorts = numPorts; - - for (serial = 0; serial < numPorts; serial ++) { - - CDCDSerialPort * pSerial = &cdcFunDriver.pCdcPorts[serial]; - - // Initialize Abstract Control Model attributes - CDCLineCoding_Initialize(&(pSerial->lineCoding), - 115200, - CDCLineCoding_ONESTOPBIT, - CDCLineCoding_NOPARITY, - 8); - pSerial->isCarrierActivated = 0; - pSerial->serialState = 0; - } -} - -//----------------------------------------------------------------------------- -/// Handles CDC/ACM-specific USB requests sent by the host -/// \param request Pointer to a USBGenericRequest instance. -/// \return 0 if the request is Unsupported, 1 if the request handled. -//----------------------------------------------------------------------------- -unsigned char CDCDFunctionDriver_RequestHandler( - const USBGenericRequest *request) -{ - switch (USBGenericRequest_GetRequest(request)) { - - case CDCGenericRequest_SETLINECODING: - - CDCD_SetLineCoding(request); - break; - - case CDCGenericRequest_GETLINECODING: - - CDCD_GetLineCoding(request); - break; - - case CDCGenericRequest_SETCONTROLLINESTATE: - - CDCD_SetControlLineState(request, - CDCSetControlLineStateRequest_ActivateCarrier(request), - CDCSetControlLineStateRequest_IsDtePresent(request)); - - break; - - // Unsupported request - default: - return 0; - - } - return 1; -} - -//----------------------------------------------------------------------------- -/// Receives data from the host through the virtual COM port created by -/// the CDC function serial driver. This function behaves like . -/// \param Port Port index to receive. -/// \param Pointer to the data buffer to send. -/// \param Size of the data buffer in bytes. -/// \param callback Optional callback function to invoke when the transfer -/// finishes. -/// \param argument Optional argument to the callback function. -/// \return if the read operation started normally; -/// otherwise, the corresponding error code. -//----------------------------------------------------------------------------- -unsigned char CDCDSerialDriver_Read(unsigned char port, - void *data, - unsigned int size, - TransferCallback callback, - void *argument) -{ - unsigned char ep = cdcFunDriver.pCdcPorts[port].bulkOutEndpoint; - - if (port > cdcFunDriver.numPorts) - return USBD_STATUS_INVALID_PARAMETER; - - return USBD_Read(ep, - data, - size, - callback, - argument); -} - -//----------------------------------------------------------------------------- -/// Sends a data buffer through the virtual COM port created by the CDC -/// function serial driver. This function behaves exactly like . -/// \param port Port index to receive. -/// \param data - Pointer to the data buffer to send. -/// \param size - Size of the data buffer in bytes. -/// \param callback - Optional callback function to invoke when the transfer -/// finishes. -/// \param argument - Optional argument to the callback function. -/// \return if the write operation started normally; -/// otherwise, the corresponding error code. -//----------------------------------------------------------------------------- -unsigned char CDCDSerialDriver_Write(unsigned char port, - void *data, - unsigned int size, - TransferCallback callback, - void *argument) -{ - unsigned char ep = cdcFunDriver.pCdcPorts[port].bulkInEndpoint; - - if (port > cdcFunDriver.numPorts) - return USBD_STATUS_INVALID_PARAMETER; - - return USBD_Write(ep, - data, - size, - callback, - argument); -} - -//------------------------------------------------------------------------------ -/// Returns the current status of the RS-232 line. -/// \param port The port number that checked. -//------------------------------------------------------------------------------ -unsigned short CDCDSerialDriver_GetSerialState(unsigned char port) -{ - if (port > cdcFunDriver.numPorts) - return USBD_STATUS_INVALID_PARAMETER; - - return cdcFunDriver.pCdcPorts[port].serialState; -} - -//------------------------------------------------------------------------------ -/// Sets the current serial state of the device to the given value. -/// \param port The port number that the port state should be changed. -/// \param serialState New device state. -//------------------------------------------------------------------------------ -void CDCDSerialDriver_SetSerialState(unsigned char port, - unsigned short serialState) -{ - CDCDSerialPort * pPort; - unsigned char ep; - - ASSERT((serialState & 0xFF80) == 0, - "CDCDSerialDriver_SetSerialState: Bits D7-D15 are reserved!\n\r"); - - if (port > cdcFunDriver.numPorts) - return; - - // If new state is different from previous one, send a notification to the - // host - pPort = &cdcFunDriver.pCdcPorts[port]; - ep = pPort->interruptInEndpoint; - if (pPort->serialState != serialState) { - - pPort->serialState = serialState; - USBD_Write(ep, - &(pPort->serialState), - 2, - 0, - 0); - - // Reset one-time flags - pPort->serialState &= ~(CDCD_STATE_OVERRUN - | CDCD_STATE_PARITY - | CDCD_STATE_FRAMING - | CDCD_STATE_RINGSIGNAL - | CDCD_STATE_BREAK); - } -} diff --git a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.h b/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.h deleted file mode 100644 index 0a9e5d2f3..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriver.h +++ /dev/null @@ -1,128 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef CDCDFUNCTIONDRIVER_H -#define CDCDFUNCTIONDRIVER_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Indicates the receiver carrier signal is present. -#define CDCD_STATE_RXDRIVER (1 << 0) -/// Indicates the transmission carrier signal is present. -#define CDCD_STATE_TXCARRIER (1 << 1) -/// Indicates a break has been detected. -#define CDCD_STATE_BREAK (1 << 2) -/// Indicates a ring signal has been detected. -#define CDCD_STATE_RINGSIGNAL (1 << 3) -/// Indicates a framing error has occured. -#define CDCD_STATE_FRAMING (1 << 4) -/// Indicates a parity error has occured. -#define CDCD_STATE_PARITY (1 << 5) -/// Indicates a data overrun error has occured. -#define CDCD_STATE_OVERRUN (1 << 6) - -//----------------------------------------------------------------------------- -// Structs -//----------------------------------------------------------------------------- - -/// CDC Serial port struct -typedef struct _CDCDSerialPort{ - - /// USB interface settings - unsigned char interfaceNum; - unsigned char interruptInEndpoint; - unsigned char bulkInEndpoint; - unsigned char bulkOutEndpoint; - /// serial port settings - CDCLineCoding lineCoding; - unsigned char isCarrierActivated; - unsigned short serialState; - -} CDCDSerialPort; - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -#define CDCDFunctionDriver_ConfigurePort(pPort,ifNum,intIN,bulkIN,bulkOUT) \ -{\ - (pPort)->interfaceNum=(ifNum);(pPort)->interruptInEndpoint=(intIN); \ - (pPort)->bulkInEndpoint=(bulkIN);(pPort)->bulkOutEndpoint=(bulkOUT); \ -} - -//----------------------------------------------------------------------------- -// Callbacks -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//- Function API for composite device -extern void CDCDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - CDCDSerialPort * pCdcPorts, - unsigned char numPorts); - -extern unsigned char CDCDFunctionDriver_RequestHandler( - const USBGenericRequest * request); - -//- CDC Serial Port API -extern unsigned char CDCDSerialDriver_Write( - unsigned char port, - void *data, - unsigned int size, - TransferCallback callback, - void *argument); - -extern unsigned char CDCDSerialDriver_Read( - unsigned char port, - void *data, - unsigned int size, - TransferCallback callback, - void *argument); - -extern unsigned short CDCDSerialDriver_GetSerialState(unsigned char port); - -extern void CDCDSerialDriver_SetSerialState( - unsigned char port, - unsigned short serialState); - - -#endif // #define CDCDFUNCTIONDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriverDescriptors.h deleted file mode 100644 index 33490ae09..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCDFunctionDriverDescriptors.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef CDCDFUNCTIONDRIVERDESCRIPTORS_H -#define CDCDFUNCTIONDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -#if defined(usb_CDCAUDIO) -#define CDCD_Descriptors_INTERFACENUM0 0 -#define CDCD_Descriptors_NOTIFICATION0 3 -#define CDCD_Descriptors_DATAIN0 2 -#define CDCD_Descriptors_DATAOUT0 1 -#endif - -/// Default CDC interrupt endpoints max packat size (8). -#define CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE 8 -/// Default CDC bulk endpoints max packat size (128, for HS actually). -#define CDCD_Descriptors_BULK_MAXPACKETSIZE 128 - -/// Default CDC interrupt IN endpoint polling rate of Full Speed (16ms). -#define CDCD_Descriptors_INTERRUPTIN_POLLING_FS 16 -/// Default CDC interrupt IN endpoint polling rate of High Speed (16ms). -#define CDCD_Descriptors_INTERRUPTIN_POLLING_HS 8 -/// Default interrupt OUT endpoint polling rate of Full Speed (16ms). -#define CDCD_Descriptors_INTERRUPTOUT_POLLING_FS 16 -/// Default interrupt OUT endpoint polling rate of High Speed (16ms). -#define CDCD_Descriptors_INTERRUPTOUT_POLLING_HS 8 - -#endif // #define CDCFUNCTIONDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.c b/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.c deleted file mode 100644 index 84c16a606..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.c +++ /dev/null @@ -1,227 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include - -// USB -#include -#include - -//- HID -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -//- MSD -#if defined(usb_CDCMSD) || defined(usb_HIDMSD) -#endif - -//- CDCHID -#include "CDCHIDDDriver.h" -#include "CDCHIDDDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -/// Interface setting spaces (4 byte aligned) -#define NUM_INTERFACES ((CDCHIDDDriverDescriptors_NUMINTERFACE+3)&0xFC) - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USBDDriver instance -static USBDDriver usbdDriver; - -/// CDCDSeriaoPort instance -static CDCDSerialPort cdcdPort; - -/// Array for storing the current setting of each interface -static unsigned char cdchiddDriverInterfaces[NUM_INTERFACES]; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Optional RequestReceived() callback re-implementation -//----------------------------------------------------------------------------- -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - CDCHIDDDriver_RequestHandler(request); -} - -#endif - -//----------------------------------------------------------------------------- -// ConfigurationChanged() callback re-implementation -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration value of a device is changed by the host -/// \param cfgnum Configuration number. -//----------------------------------------------------------------------------- -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - // HID - HIDDFunctionCallbacks_ConfigurationChanged(cfgnum); -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device composite device driver. -//----------------------------------------------------------------------------- -void CDCHIDDDriver_Initialize() -{ - // CDC - CDCDFunctionDriver_ConfigurePort(&cdcdPort, - CDCD_Descriptors_INTERFACENUM0, - CDCD_Descriptors_NOTIFICATION0, - CDCD_Descriptors_DATAIN0, - CDCD_Descriptors_DATAOUT0); - CDCDFunctionDriver_Initialize(&usbdDriver, - &cdcdPort, - 1); - - // HID - HIDDFunctionDriver_Initialize(&usbdDriver, - HIDD_Descriptors_INTERFACENUM, - HIDD_Descriptors_INTERRUPTIN, - HIDD_Descriptors_INTERRUPTOUT); - - // Initialize the standard USB driver - USBDDriver_Initialize(&usbdDriver, - &cdchiddDriverDescriptors, - cdchiddDriverInterfaces); - - // Initialize the USB driver - USBD_Init(); -} - -//----------------------------------------------------------------------------- -/// Handles composite-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request) -{ - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned char rc = 0; - - // CDC class request - if (rc == 0) { - - rc = CDCDFunctionDriver_RequestHandler(request); - } - - // HID class request - if (rc == 0) { - - rc = HIDDFunctionDriver_RequestHandler(request); - } - - if (!rc) { - - TRACE_WARNING( - "CDCHIDDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - unsigned char rc = 0; - - rc = HIDDFunctionDriver_RequestHandler(request); - - // Forward request to the standard handler - if (rc == 0) { - - USBDDriver_RequestHandler(&(usbdDriver), request); - } - } - // Unsupported request type - else { - - TRACE_WARNING( - "CDCHIDDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void CDCHIDDDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&usbdDriver)) { - - USBD_RemoteWakeUp(); - } - // Remote wake-up NOT enabled - else { - - TRACE_WARNING("CDCHIDDDriver_RemoteWakeUp: not enabled\n\r"); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.h b/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.h deleted file mode 100644 index d7ef7550c..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriver.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// -/// !Purpose -/// -/// Definitions and methods for USB composite device implement. -/// -/// !Usage -/// -/// -# Initialize USB function specified driver ( for MSD currently ) -/// - MSDDFunctionDriver_Initialize -/// -/// -# Initialize USB composite driver and USB driver -/// - CDCHIDDDriver_Initialize -/// -/// -# Handle and dispach USB requests -/// - CDCHIDDDriver_RequestHandler -/// -/// -# Try starting a remote wake-up sequence -/// - CDCHIDDDriver_RemoteWakeUp -//----------------------------------------------------------------------------- - -#ifndef CDCHIDDDRIVER_H -#define CDCHIDDDRIVER_H - - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -#include "CDCDFunctionDriver.h" -#include "HIDDFunctionDriver.h" - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -// -CDCHID -extern void CDCHIDDDriver_Initialize(); - -extern void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request); - -extern void CDCHIDDDriver_RemoteWakeUp(void); - -#endif //#ifndef CDCHIDDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.c deleted file mode 100644 index e19ba2ddd..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.c +++ /dev/null @@ -1,592 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//- Composite -#include "CDCHIDDDriver.h" -#include "CDCHIDDDriverDescriptors.h" - -//- USB Generic -#include -#include -#include -#include -#include -#include - -//- CDC -#include -#include -#include -#include -#include -#include -#include -#include -#include "CDCDFunctionDriverDescriptors.h" - -//- HID -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "HIDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Device product ID. -#define CDCHIDDDriverDescriptors_PRODUCTID 0x6130 - -/// Device vendor ID (Atmel). -#define CDCHIDDDriverDescriptors_VENDORID 0x03EB - -/// Device release number. -#define CDCHIDDDriverDescriptors_RELEASE 0x0003 - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//----------------------------------------------------------------------------- -/// Configuration descriptor list for a device implementing a composite driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; - - /// --- CDC 0 - /// IAD 0 - USBInterfaceAssociationDescriptor cdcIAD0; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication0; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader0; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement0; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion0; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification0; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData0; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut0; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn0; - - /// --- HID - USBInterfaceDescriptor hidInterface; - HIDDescriptor hid; - USBEndpointDescriptor hidInterruptIn; - USBEndpointDescriptor hidInterruptOut; - -} __attribute__ ((packed)) CdcHidDriverConfigurationDescriptors; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the composite device driver -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - CDCHIDDDriverDescriptors_VENDORID, - CDCHIDDDriverDescriptors_PRODUCTID, - CDCHIDDDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -/// USB configuration descriptors for the composite device driver -static const CdcHidDriverConfigurationDescriptors configurationDescriptorsHS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CdcHidDriverConfigurationDescriptors), - CDCHIDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC 0 - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE), - CDCD_Descriptors_INTERRUPTOUT_POLLING_HS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // HID - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - HIDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDD_Descriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDD_Descriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_HS - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDD_Descriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDD_Descriptors_INTERRUPTOUT_POLLING_HS - } -}; - -#endif - -/// USB configuration descriptors for the composite device driver -static const CdcHidDriverConfigurationDescriptors configurationDescriptorsFS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CdcHidDriverConfigurationDescriptors), - CDCHIDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC 0 - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - CDCD_Descriptors_INTERRUPTOUT_POLLING_FS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // HID - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - HIDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDD_Descriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDD_Descriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_FS - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDD_Descriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDD_Descriptors_INTERRUPTOUT_POLLING_FS - } -}; - -/// String descriptor with the supported languages. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(14), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('o') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors cdchiddDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; diff --git a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.h deleted file mode 100644 index 0a34f8ae8..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCHIDDDriverDescriptors.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef CDCHIDDDRIVERDESCRIPTORS_H -#define CDCHIDDDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Number of interfaces of the device -#define CDCHIDDDriverDescriptors_NUMINTERFACE 3 - -/// Number of the CDC interface. -#define CDCD_Descriptors_INTERFACENUM0 0 -/// Address of the CDC interrupt-in endpoint. -#define CDCD_Descriptors_NOTIFICATION0 3 -/// Address of the CDC bulk-in endpoint. -#define CDCD_Descriptors_DATAIN0 2 -/// Address of the CDC bulk-out endpoint. -#define CDCD_Descriptors_DATAOUT0 1 - -/// Number of the HID interface. -#define HIDD_Descriptors_INTERFACENUM 2 -/// Address of the HID interrupt IN endpoint. -#define HIDD_Descriptors_INTERRUPTIN 4 -/// Address of the HID interrupt OUT endpoint. -#define HIDD_Descriptors_INTERRUPTOUT 5 - - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -extern const USBDDriverDescriptors cdchiddDriverDescriptors; - -#endif //#ifndef CDCHIDDDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.c b/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.c deleted file mode 100644 index 9a605a7af..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.c +++ /dev/null @@ -1,213 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include - -// USB -#include -#include - -//- CDCMSD -#include "CDCMSDDDriver.h" -#include "CDCMSDDDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -/// Interface setting spaces (4 byte aligned) -#define NUM_INTERFACES ((CDCMSDDDriverDescriptors_NUMINTERFACE+3)&0xFC) - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USBDDriver instance -static USBDDriver usbdDriver; - -/// CDCDSeriaoPort instance -static CDCDSerialPort cdcdPort; - -/// Array for storing the current setting of each interface -static unsigned char cdcmsddDriverInterfaces[NUM_INTERFACES]; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Optional RequestReceived() callback re-implementation -//----------------------------------------------------------------------------- -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - CDCMSDDDriver_RequestHandler(request); -} - -#endif - -//----------------------------------------------------------------------------- -// ConfigurationChanged() callback re-implementation -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration value of a device is changed by the host -/// \param cfgnum Configuration number. -//----------------------------------------------------------------------------- -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - // MSD - MSDDFunctionCallbacks_ConfigurationChanged(cfgnum); -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device CDCMSD device driver. -//----------------------------------------------------------------------------- -void CDCMSDDDriver_Initialize(MSDLun *pLuns, unsigned char numLuns) -{ - // CDC - CDCDFunctionDriver_ConfigurePort(&cdcdPort, - CDCD_Descriptors_INTERFACENUM0, - CDCD_Descriptors_NOTIFICATION0, - CDCD_Descriptors_DATAIN0, - CDCD_Descriptors_DATAOUT0); - CDCDFunctionDriver_Initialize(&usbdDriver, - &cdcdPort, - 1); - - // MSD - MSDDFunctionDriver_Initialize(&usbdDriver, - pLuns, numLuns, - MSDD_Descriptors_INTERFACENUM, - MSDD_Descriptors_BULKIN, - MSDD_Descriptors_BULKOUT); - - // Initialize the standard USB driver - USBDDriver_Initialize(&usbdDriver, - &cdcmsddDriverDescriptors, - cdcmsddDriverInterfaces); - - // Initialize the USB driver - USBD_Init(); -} - -//----------------------------------------------------------------------------- -/// Handles CDCMSD-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -void CDCMSDDDriver_RequestHandler(const USBGenericRequest *request) -{ - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned char rc = 0; - - // CDC class request - if (rc == 0) { - - rc = CDCDFunctionDriver_RequestHandler(request); - } - - // MSD class request - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - - if (!rc) { - - TRACE_WARNING( - "CDCMSDDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - unsigned char rc = 0; - - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - - // Forward request to the standard handler - if (rc == 0) { - - USBDDriver_RequestHandler(&(usbdDriver), request); - } - } - // Unsupported request type - else { - - TRACE_WARNING( - "CDCMSDDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void CDCMSDDDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&usbdDriver)) { - - USBD_RemoteWakeUp(); - } - // Remote wake-up NOT enabled - else { - - TRACE_WARNING("CDCMSDDDriver_RemoteWakeUp: not enabled\n\r"); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.h b/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.h deleted file mode 100644 index e6a68349a..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriver.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// -/// !Purpose -/// -/// Definitions and methods for USB CDCMSD device implement. -/// -/// !Usage -/// -/// -# Initialize USB function specified driver ( for MSD currently ) -/// - MSDDFunctionDriver_Initialize -/// -/// -# Initialize USB CDCMSD driver and USB driver -/// - CDCMSDDDriver_Initialize -/// -/// -# Handle and dispach USB requests -/// - CDCMSDDDriver_RequestHandler -/// -/// -# Try starting a remote wake-up sequence -/// - CDCMSDDDriver_RemoteWakeUp -//----------------------------------------------------------------------------- - -#ifndef CDCMSDDDRIVER_H -#define CDCMSDDDRIVER_H - - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include - -#include "CDCDFunctionDriver.h" -#include "MSDDFunctionDriver.h" - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -// -CDCMSD -extern void CDCMSDDDriver_Initialize(MSDLun *pLuns, unsigned char numLuns); - -extern void CDCMSDDDriver_RequestHandler(const USBGenericRequest *request); - -extern void CDCMSDDDriver_RemoteWakeUp(void); - -#endif //#ifndef CDCMSDDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.c deleted file mode 100644 index 27932ac2e..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.c +++ /dev/null @@ -1,568 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "CDCMSDDDriver.h" -#include "CDCMSDDDriverDescriptors.h" -#include - -//- USB Generic -#include -#include -#include -#include -#include -#include - -//- CDC -#include -#include -#include -#include -#include -#include -#include -#include -#include "CDCDFunctionDriverDescriptors.h" - -//- MSD -#include -#include -#include "MSDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Device product ID. -#define CDCMSDDDriverDescriptors_PRODUCTID 0x6132 - -/// Device vendor ID (Atmel). -#define CDCMSDDDriverDescriptors_VENDORID 0x03EB - -/// Device release number. -#define CDCMSDDDriverDescriptors_RELEASE 0x0003 - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//----------------------------------------------------------------------------- -/// Configuration descriptor list for a device implementing a CDCMSD driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; - - /// --- CDC 0 - /// IAD 0 - USBInterfaceAssociationDescriptor cdcIAD0; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication0; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader0; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement0; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion0; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification0; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData0; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut0; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn0; - - /// --- MSD - /// Mass storage interface descriptor. - USBInterfaceDescriptor msdInterface; - /// Bulk-out endpoint descriptor. - USBEndpointDescriptor msdBulkOut; - /// Bulk-in endpoint descriptor. - USBEndpointDescriptor msdBulkIn; - -} __attribute__ ((packed)) CDCMSDDriverConfigurationDescriptors; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the CDCMSD device driver -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - CDCMSDDDriverDescriptors_VENDORID, - CDCMSDDDriverDescriptors_PRODUCTID, - CDCMSDDDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -/// USB configuration descriptors for the CDCMSD device driver -static const CDCMSDDriverConfigurationDescriptors configurationDescriptorsHS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CDCMSDDriverConfigurationDescriptors), - CDCMSDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE), - CDCD_Descriptors_INTERRUPTIN_POLLING_HS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // Mass Storage interface descriptor. - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - MSDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0. - 2, // Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, - MSInterfaceDescriptor_SCSI, - MSInterfaceDescriptor_BULKONLY, - 0 // No string descriptor for interface. - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // No string descriptor for endpoint. - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // No string descriptor for endpoint. - } - -}; - -#endif - -/// USB configuration descriptors for the CDCMSD device driver -static const CDCMSDDriverConfigurationDescriptors configurationDescriptorsFS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CDCMSDDriverConfigurationDescriptors), - CDCMSDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE), - CDCD_Descriptors_INTERRUPTIN_POLLING_FS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // Mass Storage interface descriptor. - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - MSDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0. - 2, // Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, - MSInterfaceDescriptor_SCSI, - MSInterfaceDescriptor_BULKONLY, - 0 // No string descriptor for interface. - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - } - -}; - -/// String descriptor with the supported languages. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(14), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('o') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors cdcmsddDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; diff --git a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.h deleted file mode 100644 index 5db1a0cd4..000000000 --- a/src/ersky9x/libraries/usb/device/composite/CDCMSDDDriverDescriptors.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef CDCMSDDDRIVERDESCRIPTORS_H -#define CDCMSDDDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Number of interfaces of the device -#define CDCMSDDDriverDescriptors_NUMINTERFACE 3 - -/// Number of the CDC interface. -#define CDCD_Descriptors_INTERFACENUM0 0 -/// Address of the CDC interrupt-in endpoint. -#define CDCD_Descriptors_NOTIFICATION0 3 -/// Address of the CDC bulk-in endpoint. -#define CDCD_Descriptors_DATAIN0 2 -/// Address of the CDC bulk-out endpoint. -#define CDCD_Descriptors_DATAOUT0 1 - -/// Number of the Mass Storage interface. -#define MSDD_Descriptors_INTERFACENUM 2 - -/// Address of the Mass Storage bulk-out endpoint. -#define MSDD_Descriptors_BULKOUT 4 - -/// Address of the Mass Storage bulk-in endpoint. -#define MSDD_Descriptors_BULKIN 5 - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -extern const USBDDriverDescriptors cdcmsddDriverDescriptors; - -#endif //#ifndef CDCMSDDDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.c b/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.c deleted file mode 100644 index 88d64b65b..000000000 --- a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.c +++ /dev/null @@ -1,292 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include - -// USB -#include -#include - -//- HID -#if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - #include - #include - #include - #include - #include - - #include - #include - #include - #include - #include - #include -#endif // (HID defined) - -//- MSD -#if defined(usb_CDCMSD) || defined(usb_HIDMSD) -#endif - -//- COMPOSITE -#include "COMPOSITEDDriver.h" -#include "COMPOSITEDDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -/// Interface setting spaces (4 byte aligned) -#define NUM_INTERFACES ((COMPOSITEDDriverDescriptors_NUMINTERFACE+3)&0xFC) - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USBDDriver instance -static USBDDriver usbdDriver; - -// CDC -#if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) -/// CDCDSeriaoPort instance -static CDCDSerialPort cdcdPort; -#endif // CDC defined - -/// Array for storing the current setting of each interface -static unsigned char compositedDriverInterfaces[NUM_INTERFACES]; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Optional RequestReceived() callback re-implementation -//----------------------------------------------------------------------------- -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - COMPOSITEDDriver_RequestHandler(request); -} - -#endif - -//----------------------------------------------------------------------------- -/// Invoked whenever the active setting of an interface is changed by the -/// host. Changes the status of the third LED accordingly. -/// \param interface Interface number. -/// \param setting Newly active setting. -//----------------------------------------------------------------------------- -void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface, - unsigned char setting) -{ - // AUDIO - #if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - AUDDFunctionCallbacks_InterfaceSettingChanged(interface, setting); - #endif -} - -//----------------------------------------------------------------------------- -// ConfigurationChanged() callback re-implementation -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration value of a device is changed by the host -/// \param cfgnum Configuration number. -//----------------------------------------------------------------------------- -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - // HID - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - HIDDFunctionCallbacks_ConfigurationChanged(cfgnum); - #endif -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device composite device driver. -//----------------------------------------------------------------------------- -void COMPOSITEDDriver_Initialize() -{ - // CDC - #if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) - CDCDFunctionDriver_ConfigurePort(&cdcdPort, - CDCD_Descriptors_INTERFACENUM0, - CDCD_Descriptors_NOTIFICATION0, - CDCD_Descriptors_DATAIN0, - CDCD_Descriptors_DATAOUT0); - CDCDFunctionDriver_Initialize(&usbdDriver, - &cdcdPort, - 1); - #endif - - // AUDIO - #if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - AUDDFunctionDriver_Initialize(); - #endif - - // HID - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - HIDDFunctionDriver_Initialize(&usbdDriver, - HIDD_Descriptors_INTERFACENUM, - HIDD_Descriptors_INTERRUPTIN, - HIDD_Descriptors_INTERRUPTOUT); - #endif - - // MSD - #if defined(usb_CDCMSD) || defined(usb_HIDMSD) - // Function driver initialize is put to main() for additional LUN list - #endif - - // Initialize the standard USB driver - USBDDriver_Initialize(&usbdDriver, - &compositedDriverDescriptors, - compositedDriverInterfaces); - - // Initialize the USB driver - USBD_Init(); -} - -//----------------------------------------------------------------------------- -/// Handles composite-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -void COMPOSITEDDriver_RequestHandler(const USBGenericRequest *request) -{ - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned char rc = 0; - - // AUDIO class request - #if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - if (rc == 0) { - - rc = AUDDFunctionDriver_RequestHandler(request); - } - #endif - - // CDC class request - #if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCMSD) || defined(usb_CDCCDC) - if (rc == 0) { - - rc = CDCDFunctionDriver_RequestHandler(request); - } - #endif - - // MSD class request - #if defined(usb_CDCMSD) || defined(usb_HIDMSD) - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - #endif - - // HID class request - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - if (rc == 0) { - - rc = HIDDFunctionDriver_RequestHandler(request); - } - #endif - - if (!rc) { - - TRACE_WARNING( - "COMPOSITEDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - unsigned char rc = 0; - - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - rc = HIDDFunctionDriver_RequestHandler(request); - #endif - - #if defined(usb_CDCMSD) || defined(usb_HIDMSD) - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - #endif - - // Forward request to the standard handler - if (rc == 0) { - - USBDDriver_RequestHandler(&(usbdDriver), request); - } - } - // Unsupported request type - else { - - TRACE_WARNING( - "COMPOSITEDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void COMPOSITEDDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&usbdDriver)) { - - USBD_RemoteWakeUp(); - } - // Remote wake-up NOT enabled - else { - - TRACE_WARNING("COMPOSITEDDriver_RemoteWakeUp: not enabled\n\r"); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.h b/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.h deleted file mode 100644 index 6106a9f15..000000000 --- a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriver.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// -/// !Purpose -/// -/// Definitions and methods for USB composite device implement. -/// -/// !Usage -/// -/// -# Initialize USB function specified driver ( for MSD currently ) -/// - MSDDFunctionDriver_Initialize -/// -/// -# Initialize USB composite driver and USB driver -/// - COMPOSITEDDriver_Initialize -/// -/// -# Handle and dispach USB requests -/// - COMPOSITEDDriver_RequestHandler -/// -/// -# Try starting a remote wake-up sequence -/// - COMPOSITEDDriver_RemoteWakeUp -//----------------------------------------------------------------------------- - -#ifndef COMPOSITEDDRIVER_H -#define COMPOSITEDDRIVER_H - - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -#if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) - #include "CDCDFunctionDriver.h" - #include "CDCDFunctionDriverDescriptors.h" -#endif - -#if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - #include "AUDDFunctionDriver.h" -#endif - -#if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - #include "HIDDFunctionDriver.h" - #include "HIDDFunctionDriverDescriptors.h" -#endif - -#if defined(usb_CDCMSD) || defined(usb_HIDMSD) - #include "MSDDFunctionDriver.h" -#endif - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -// -COMPOSITE -extern void COMPOSITEDDriver_Initialize(); - -extern void COMPOSITEDDriver_RequestHandler(const USBGenericRequest *request); - -extern void COMPOSITEDDriver_RemoteWakeUp(void); - -#endif //#ifndef COMPOSITEDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.c deleted file mode 100644 index db195af45..000000000 --- a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.c +++ /dev/null @@ -1,954 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "COMPOSITEDDriver.h" -#include "COMPOSITEDDriverDescriptors.h" -#include - -//- USB Generic -#include -#include -#include -#include -#include -#include - -//- CDC -#if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) - #include - #include - #include - #include - #include - #include - #include - #include - #include "CDCDFunctionDriverDescriptors.h" -#endif // (CDC defined) - -//- HID -#if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include "HIDDFunctionDriverDescriptors.h" -#endif // (HID defined) - -//- AUDIO -#if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include "AUDDFunctionDriverDescriptors.h" -#endif // (AUDIO defined) - -//- MSD -#if defined(usb_CDCMSD) || defined(usb_HIDMSD) - #include - #include - #include "MSDDFunctionDriverDescriptors.h" -#endif // (MSD defined) - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Device product ID. -#if defined(usb_CDCHID) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6130 -#elif defined(usb_CDCAUDIO) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6131 -#elif defined(usb_CDCMSD) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6132 -#elif defined(usb_CDCCDC) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6133 -#elif defined(usb_HIDAUDIO) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6134 -#elif defined(usb_HIDMSD) -#define COMPOSITEDDriverDescriptors_PRODUCTID 0x6135 -#else -#error COMPOSITE Device Classes not defined! -#endif - -/// Device vendor ID (Atmel). -#define COMPOSITEDDriverDescriptors_VENDORID 0x03EB - -/// Device release number. -#define COMPOSITEDDriverDescriptors_RELEASE 0x0003 - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Audio control header descriptor with one slave interface. -//----------------------------------------------------------------------------- -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//- AUDIO -#if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) -typedef struct { - - /// Header descriptor. - AUDHeaderDescriptor header; - /// Id of the first grouped interface. - unsigned char bInterface0; - -} __attribute__ ((packed)) AUDHeaderDescriptor1; // GCC - -//----------------------------------------------------------------------------- -/// Feature unit descriptor with 3 channel controls (master, right, left). -//----------------------------------------------------------------------------- -typedef struct { - - /// Feature unit descriptor. - AUDFeatureUnitDescriptor feature; - /// Available controls for each channel. - unsigned char bmaControls[3]; - /// Index of a string descriptor for the feature unit. - unsigned char iFeature; - -} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC - -//----------------------------------------------------------------------------- -/// List of descriptors for detailling the audio control interface of a -/// device using a USB audio speaker driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Header descriptor (with one slave interface). - AUDHeaderDescriptor1 header; - /// Input terminal descriptor. - AUDInputTerminalDescriptor input; - /// Output terminal descriptor. - AUDOutputTerminalDescriptor output; - /// Feature unit descriptor. - AUDFeatureUnitDescriptor3 feature; - -} __attribute__ ((packed)) AUDDSpeakerDriverAudioControlDescriptors; // GCC - -//----------------------------------------------------------------------------- -/// Format type I descriptor with one discrete sampling frequency. -//----------------------------------------------------------------------------- -typedef struct { - - /// Format type I descriptor. - AUDFormatTypeOneDescriptor formatType; - /// Sampling frequency in Hz. - unsigned char tSamFreq[3]; - -} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC -#endif // (AUDIO defined) - -//----------------------------------------------------------------------------- -/// Configuration descriptor list for a device implementing a composite driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; - - #if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) - /// --- CDC 0 - /// IAD 0 - USBInterfaceAssociationDescriptor cdcIAD0; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication0; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader0; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement0; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion0; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification0; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData0; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut0; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn0; - #endif // (CDC defined) - - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - /// --- HID - USBInterfaceDescriptor hidInterface; - HIDDescriptor hid; - USBEndpointDescriptor hidInterruptIn; - USBEndpointDescriptor hidInterruptOut; - #endif // (HID defined) - - #if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - /// --- AUDIO - /// IAD 1 - USBInterfaceAssociationDescriptor audIAD; - /// Audio control interface. - USBInterfaceDescriptor audInterface; - /// Descriptors for the audio control interface. - AUDDSpeakerDriverAudioControlDescriptors audControl; - /// -- AUDIO out - /// Streaming out interface descriptor (with no endpoint, required). - USBInterfaceDescriptor audStreamingOutNoIsochronous; - /// Streaming out interface descriptor. - USBInterfaceDescriptor audStreamingOut; - /// Audio class descriptor for the streaming out interface. - AUDStreamingInterfaceDescriptor audStreamingOutClass; - /// Stream format descriptor. - AUDFormatTypeOneDescriptor1 audStreamingOutFormatType; - /// Streaming out endpoint descriptor. - AUDEndpointDescriptor audStreamingOutEndpoint; - /// Audio class descriptor for the streaming out endpoint. - AUDDataEndpointDescriptor audStreamingOutDataEndpoint; - #endif // (AUDIO defined) - - #if defined(usb_CDCCDC) - /// --- CDC 1 - /// IAD 1 - USBInterfaceAssociationDescriptor cdcIAD1; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication1; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader1; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement1; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion1; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification1; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData1; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut1; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn1; - #endif // (Another CDC defined) - - #if defined(usb_CDCMSD) || defined(usb_HIDMSD) - /// --- MSD - /// Mass storage interface descriptor. - USBInterfaceDescriptor msdInterface; - /// Bulk-out endpoint descriptor. - USBEndpointDescriptor msdBulkOut; - /// Bulk-in endpoint descriptor. - USBEndpointDescriptor msdBulkIn; - #endif // (MSD defined) - -} __attribute__ ((packed)) CompositeDriverConfigurationDescriptors; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the composite device driver -const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - #if defined(usb_HIDMSD) - 0x00, - 0x00, - 0x00, - #else - 0xEF,// MI - 0x02,// - 0x01,// - #endif - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - COMPOSITEDDriverDescriptors_VENDORID, - COMPOSITEDDriverDescriptors_PRODUCTID, - COMPOSITEDDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - #if defined(usb_HIDMSD) - 0x00, - 0x00, - 0x00, - #else - 0xEF,// MI - 0x02,// - 0x01,// - #endif - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -#endif - -/// USB configuration descriptors for the composite device driver -const CompositeDriverConfigurationDescriptors configurationDescriptors = { - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(CompositeDriverConfigurationDescriptors), - COMPOSITEDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - #if defined(usb_CDCAUDIO) || defined(usb_CDCHID) || defined(usb_CDCCDC) || defined(usb_CDCMSD) - // CDC - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 10 // Endpoint is polled every 10ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - #endif // (CDC defined) - - #if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - HIDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDD_Descriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDD_Descriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDD_Descriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING - }, - #endif // (HID defined) - - #if defined(usb_CDCAUDIO) || defined(usb_HIDAUDIO) - // AUDIO - // IAD for AUDIO function - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - AUDD_Descriptors_INTERFACE, - 2, - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor for this interface - }, - // Audio control interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDD_Descriptors_CONTROL, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoint - AUDControlInterfaceDescriptor_CLASS, - AUDControlInterfaceDescriptor_SUBCLASS, - AUDControlInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio control interface descriptors - { - // Header descriptor - { - { - sizeof(AUDHeaderDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_HEADER, - AUDHeaderDescriptor_AUD1_00, - sizeof(AUDDSpeakerDriverAudioControlDescriptors), - 1 // One streaming interface - }, - AUDD_Descriptors_STREAMING - }, - // Input terminal descriptor - { - sizeof(AUDInputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_INPUTTERMINAL, - AUDD_Descriptors_INPUTTERMINAL, - AUDInputTerminalDescriptor_USBSTREAMING, - AUDD_Descriptors_OUTPUTTERMINAL, - AUDD_NUMCHANNELS, - AUDInputTerminalDescriptor_LEFTFRONT - | AUDInputTerminalDescriptor_RIGHTFRONT, - 0, // No string descriptor for channels - 0 // No string descriptor for input terminal - }, - // Output terminal descriptor - { - sizeof(AUDOutputTerminalDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_OUTPUTTERMINAL, - AUDD_Descriptors_OUTPUTTERMINAL, - AUDOutputTerminalDescriptor_SPEAKER, - AUDD_Descriptors_INPUTTERMINAL, - AUDD_Descriptors_FEATUREUNIT, - 0 // No string descriptor - }, - // Feature unit descriptor - { - { - sizeof(AUDFeatureUnitDescriptor3), - AUDGenericDescriptor_INTERFACE, - AUDGenericDescriptor_FEATUREUNIT, - AUDD_Descriptors_FEATUREUNIT, - AUDD_Descriptors_INPUTTERMINAL, - 1, // 1 byte per channel for controls - }, - { - AUDFeatureUnitDescriptor_MUTE, // Master channel controls - 0, // Right channel controls - 0 // Left channel controls - }, - 0 // No string descriptor - } - }, - // Audio streaming interface with 0 endpoints - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDD_Descriptors_STREAMING, - 0, // This is alternate setting #0 - 0, // This interface uses no endpoints - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming interface with data endpoint - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - AUDD_Descriptors_STREAMING, - 1, // This is alternate setting #1 - 1, // This interface uses 1 endpoint - AUDStreamingInterfaceDescriptor_CLASS, - AUDStreamingInterfaceDescriptor_SUBCLASS, - AUDStreamingInterfaceDescriptor_PROTOCOL, - 0 // No string descriptor - }, - // Audio streaming class-specific descriptor - { - sizeof(AUDStreamingInterfaceDescriptor), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_GENERAL, - AUDD_Descriptors_INPUTTERMINAL, - 0, // No internal delay because of data path - AUDFormatTypeOneDescriptor_PCM - }, - // Format type I descriptor - { - { - sizeof(AUDFormatTypeOneDescriptor1), - AUDGenericDescriptor_INTERFACE, - AUDStreamingInterfaceDescriptor_FORMATTYPE, - AUDFormatTypeOneDescriptor_FORMATTYPEONE, - AUDD_NUMCHANNELS, - AUDD_BYTESPERSAMPLE, - AUDD_BYTESPERSAMPLE*8, - 1 // One discrete frequency supported - }, - { - AUDD_SAMPLERATE & 0xFF, - (AUDD_SAMPLERATE >> 8) & 0xFF, - (AUDD_SAMPLERATE >> 16) & 0xFF - } - }, - // Audio streaming endpoint standard descriptor - { - sizeof(AUDEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - AUDD_Descriptors_DATAOUT), - USBEndpointDescriptor_ISOCHRONOUS, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(AUDD_Descriptors_DATAOUT), - 1, // Polling interval = 2^(x-1) milliseconds (1 ms) - 0, // This is not a synchronization endpoint - 0 // No associated synchronization endpoint - }, - // Audio streaming endpoint class-specific descriptor - { - sizeof(AUDDataEndpointDescriptor), - AUDGenericDescriptor_ENDPOINT, - AUDDataEndpointDescriptor_SUBTYPE, - 0, // No attributes - 0, // Endpoint is not synchronized - 0 // Endpoint is not synchronized - }, - #endif // (AUDIO defined) - - #if defined(usb_CDCCDC) - // CDC 1 - // IAD for CDC/ACM port 1 - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM1, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1, // This is interface #2 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM1 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM1, // Number of master interface is #2 - CDCD_Descriptors_INTERFACENUM1+1 // First slave interface is #3 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION1), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION1), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - 10 // Endpoint is polled every 10ms - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1 + 1, // This is interface #3 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT1), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN1), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - #endif // (2 CDCs defined) - - #if defined(usb_CDCMSD) || defined(usb_HIDMSD) - // Mass Storage interface descriptor. - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - MSDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0. - 2, // Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, - MSInterfaceDescriptor_SCSI, - MSInterfaceDescriptor_BULKONLY, - 0 // No string descriptor for interface. - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - }, - #endif // (MSD defined) - -}; - -/// String descriptor with the supported languages. -const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(14), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('o') -}; - -/// Product serial number. -const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors compositedDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; - -#if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD) -/// Report descriptor used by the driver. -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_KEYBOARD, - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, - - // Input report: modifier keys - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_REPORTCOUNT + 1, 8, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDD_Descriptors_FIRSTMODIFIERKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDD_Descriptors_LASTMODIFIERKEY, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, - - // Input report: standard keys - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, - HIDD_Descriptors_FIRSTSTANDARDKEY, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, - HIDD_Descriptors_LASTSTANDARDKEY, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDD_Descriptors_FIRSTSTANDARDKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDD_Descriptors_LASTSTANDARDKEY, - HIDReport_INPUT + 1, 0 /* Data array */, - - // Output report: LEDs - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK, - HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK, - HIDReport_OUTPUT + 1, HIDReport_VARIABLE, - - // Output report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_OUTPUT + 1, HIDReport_CONSTANT, - - HIDReport_ENDCOLLECTION -}; -#endif // (HID defined) - diff --git a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.h deleted file mode 100644 index c82f9bcb1..000000000 --- a/src/ersky9x/libraries/usb/device/composite/COMPOSITEDDriverDescriptors.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef COMPOSITEDDRIVERDESCRIPTORS_H -#define COMPOSITEDDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Number of interfaces of the device -#if defined(usb_CDCAUDIO) || defined(usb_CDCCDC) - #define COMPOSITEDDriverDescriptors_NUMINTERFACE 4 -#elif defined(usb_CDCHID) || defined(usb_CDCMSD) || defined(usb_HIDAUDIO) - #define COMPOSITEDDriverDescriptors_NUMINTERFACE 3 -#elif defined(usb_HIDMSD) - #define COMPOSITEDDriverDescriptors_NUMINTERFACE 2 -#else - #error USB Composite class not defined. -#endif - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -extern const USBDDriverDescriptors compositedDriverDescriptors; - -#endif //#ifndef COMPOSITEDDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.c b/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.c deleted file mode 100644 index cced6f342..000000000 --- a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include - -// USB -#include -#include - -//- DUALCDC -#include "DUALCDCDDriver.h" -#include "DUALCDCDDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -/// Interface setting spaces (4 byte aligned) -#define NUM_INTERFACES ((DUALCDCDDriverDescriptors_NUMINTERFACE+3)&0xFC) - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USBDDriver instance -static USBDDriver usbdDriver; - -/// CDCDSeriaoPort instance for 2 CDC/CAM serial ports. -static CDCDSerialPort cdcdPorts[2]; - -/// Array for storing the current setting of each interface -static unsigned char compositedDriverInterfaces[NUM_INTERFACES]; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Optional RequestReceived() callback re-implementation -//----------------------------------------------------------------------------- -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - DUALCDCDDriver_RequestHandler(request); -} - -#endif - -//----------------------------------------------------------------------------- -// ConfigurationChanged() callback re-implementation -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device composite device driver. -//----------------------------------------------------------------------------- -void DUALCDCDDriver_Initialize() -{ - // CDC - CDCDFunctionDriver_ConfigurePort(&cdcdPorts[0], - CDCD_Descriptors_INTERFACENUM0, - CDCD_Descriptors_NOTIFICATION0, - CDCD_Descriptors_DATAIN0, - CDCD_Descriptors_DATAOUT0); - CDCDFunctionDriver_ConfigurePort(&cdcdPorts[1], - CDCD_Descriptors_INTERFACENUM1, - CDCD_Descriptors_NOTIFICATION1, - CDCD_Descriptors_DATAIN1, - CDCD_Descriptors_DATAOUT1); - CDCDFunctionDriver_Initialize(&usbdDriver, - cdcdPorts, - 2); - - // Initialize the standard USB driver - USBDDriver_Initialize(&usbdDriver, - &dualcdcdDriverDescriptors, - compositedDriverInterfaces); - - // Initialize the USB driver - USBD_Init(); -} - -//----------------------------------------------------------------------------- -/// Handles composite-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request) -{ - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned char rc = 0; - - if (rc == 0) { - - rc = CDCDFunctionDriver_RequestHandler(request); - } - - if (!rc) { - - TRACE_WARNING( - "DUALCDCDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - unsigned char rc = 0; - - // Forward request to the standard handler - if (rc == 0) { - - USBDDriver_RequestHandler(&(usbdDriver), request); - } - } - // Unsupported request type - else { - - TRACE_WARNING( - "DUALCDCDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void DUALCDCDDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&usbdDriver)) { - - USBD_RemoteWakeUp(); - } - // Remote wake-up NOT enabled - else { - - TRACE_WARNING("DUALCDCDDriver_RemoteWakeUp: not enabled\n\r"); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.h b/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.h deleted file mode 100644 index 8ff2c662f..000000000 --- a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriver.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// -/// !Purpose -/// -/// Definitions and methods for USB composite device implement. -/// -/// !Usage -/// -/// -# Initialize USB function specified driver ( for MSD currently ) -/// - MSDDFunctionDriver_Initialize -/// -/// -# Initialize USB composite driver and USB driver -/// - DUALCDCDDriver_Initialize -/// -/// -# Handle and dispach USB requests -/// - DUALCDCDDriver_RequestHandler -/// -/// -# Try starting a remote wake-up sequence -/// - DUALCDCDDriver_RemoteWakeUp -//----------------------------------------------------------------------------- - -#ifndef DUALCDCDDRIVER_H -#define DUALCDCDDRIVER_H - - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -#include "CDCDFunctionDriver.h" - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -// -DUALCDC -extern void DUALCDCDDriver_Initialize(); - -extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request); - -extern void DUALCDCDDriver_RemoteWakeUp(void); - -#endif //#ifndef DUALCDCDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.c deleted file mode 100644 index f39b29e50..000000000 --- a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.c +++ /dev/null @@ -1,702 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "DUALCDCDDriver.h" -#include "DUALCDCDDriverDescriptors.h" -#include - -//- USB Generic -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "CDCDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Device product ID. -#define DUALCDCDDriverDescriptors_PRODUCTID 0x6133 - -/// Device vendor ID (Atmel). -#define DUALCDCDDriverDescriptors_VENDORID 0x03EB - -/// Device release number. -#define DUALCDCDDriverDescriptors_RELEASE 0x0003 - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//----------------------------------------------------------------------------- -/// Configuration descriptor list for a device implementing a composite driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; - - /// --- CDC 0 - /// IAD 0 - USBInterfaceAssociationDescriptor cdcIAD0; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication0; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader0; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement0; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion0; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification0; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData0; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut0; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn0; - - /// --- CDC 1 - /// IAD 1 - USBInterfaceAssociationDescriptor cdcIAD1; - /// Communication interface descriptor - USBInterfaceDescriptor cdcCommunication1; - /// CDC header functional descriptor. - CDCHeaderDescriptor cdcHeader1; - /// CDC call management functional descriptor. - CDCCallManagementDescriptor cdcCallManagement1; - /// CDC abstract control management functional descriptor. - CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1; - /// CDC union functional descriptor (with one slave interface). - CDCUnionDescriptor cdcUnion1; - /// Notification endpoint descriptor. - USBEndpointDescriptor cdcNotification1; - /// Data interface descriptor. - USBInterfaceDescriptor cdcData1; - /// Data OUT endpoint descriptor. - USBEndpointDescriptor cdcDataOut1; - /// Data IN endpoint descriptor. - USBEndpointDescriptor cdcDataIn1; - -} __attribute__ ((packed)) DualCdcDriverConfigurationDescriptors; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the composite device driver -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - DUALCDCDDriverDescriptors_VENDORID, - DUALCDCDDriverDescriptors_PRODUCTID, - DUALCDCDDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - 0xEF,// MI - 0x02,// - 0x01,// - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -/// USB configuration descriptors for the composite device driver -static const DualCdcDriverConfigurationDescriptors configurationDescriptorsHS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(DualCdcDriverConfigurationDescriptors), - DUALCDCDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC 0 - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE), - CDCD_Descriptors_INTERRUPTIN_POLLING_HS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // CDC 1 - // IAD for CDC/ACM port 1 - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM1, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1, // This is interface #2 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM1 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM1, // Number of master interface is #2 - CDCD_Descriptors_INTERFACENUM1+1 // First slave interface is #3 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION1), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION1), - CDCD_Descriptors_INTERRUPT_MAXPACKETSIZE), - CDCD_Descriptors_INTERRUPTIN_POLLING_HS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1 + 1, // This is interface #3 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT1), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN1), - CDCD_Descriptors_BULK_MAXPACKETSIZE), - 0 // Must be 0 for full-speed bulk endpoints - } - -}; - -#endif - -/// USB configuration descriptors for the composite device driver -static const DualCdcDriverConfigurationDescriptors configurationDescriptorsFS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(DualCdcDriverConfigurationDescriptors), - DUALCDCDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // CDC 0 - // IAD for CDC/ACM port - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM0, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0, // This is interface #0 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM0 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM0, // Number of master interface is #0 - CDCD_Descriptors_INTERFACENUM0 + 1 // First slave interface is #1 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - CDCD_Descriptors_INTERRUPTIN_POLLING_FS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM0 + 1, // This is interface #1 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - - // CDC 1 - // IAD for CDC/ACM port 1 - { - sizeof(USBInterfaceAssociationDescriptor), - USBGenericDescriptor_INTERFACEASSOCIATION, - CDCD_Descriptors_INTERFACENUM1, - 2, - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Communication class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1, // This is interface #2 - 0, // This is alternate setting #0 for this interface - 1, // This interface uses 1 endpoint - CDCCommunicationInterfaceDescriptor_CLASS, - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL, - CDCCommunicationInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Class-specific header functional descriptor - { - sizeof(CDCHeaderDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_HEADER, - CDCGenericDescriptor_CDC1_10 - }, - // Class-specific call management functional descriptor - { - sizeof(CDCCallManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_CALLMANAGEMENT, - CDCCallManagementDescriptor_SELFCALLMANAGEMENT, - CDCD_Descriptors_INTERFACENUM1 + 1 // No associated data interface - }, - // Class-specific abstract control management functional descriptor - { - sizeof(CDCAbstractControlManagementDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT, - CDCAbstractControlManagementDescriptor_LINE - }, - // Class-specific union functional descriptor with one slave interface - { - sizeof(CDCUnionDescriptor), - CDCGenericDescriptor_INTERFACE, - CDCGenericDescriptor_UNION, - CDCD_Descriptors_INTERFACENUM1, // Number of master interface is #2 - CDCD_Descriptors_INTERFACENUM1+1 // First slave interface is #3 - }, - // Notification endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_NOTIFICATION1), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION1), - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), - CDCD_Descriptors_INTERRUPTIN_POLLING_FS - }, - // Data class interface standard descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - CDCD_Descriptors_INTERFACENUM1 + 1, // This is interface #3 - 0, // This is alternate setting #0 for this interface - 2, // This interface uses 2 endpoints - CDCDataInterfaceDescriptor_CLASS, - CDCDataInterfaceDescriptor_SUBCLASS, - CDCDataInterfaceDescriptor_NOPROTOCOL, - 0 // No string descriptor for this interface - }, - // Bulk-OUT endpoint standard descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, - CDCD_Descriptors_DATAOUT1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT1), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, - CDCD_Descriptors_DATAIN1), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN1), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // Must be 0 for full-speed bulk endpoints - } - -}; - -/// String descriptor with the supported languages. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(14), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('o') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors dualcdcdDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; diff --git a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.h deleted file mode 100644 index 13e1f4d8e..000000000 --- a/src/ersky9x/libraries/usb/device/composite/DUALCDCDDriverDescriptors.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef DUALCDCDDRIVERDESCRIPTORS_H -#define DUALCDCDDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Number of interfaces of the device -#define DUALCDCDDriverDescriptors_NUMINTERFACE 4 - -/// Number of the CDC0 interface. -#define CDCD_Descriptors_INTERFACENUM0 0 -/// Address of the CDC0 interrupt-in endpoint. -#define CDCD_Descriptors_NOTIFICATION0 3 -/// Address of the CDC0 bulk-in endpoint. -#define CDCD_Descriptors_DATAIN0 2 -/// Address of the CDC0 bulk-out endpoint. -#define CDCD_Descriptors_DATAOUT0 1 - -/// Number of the CDC1 interface. -#define CDCD_Descriptors_INTERFACENUM1 2 -/// Address of the CDC1 interrupt-in endpoint. -#define CDCD_Descriptors_NOTIFICATION1 6 -/// Address of the CDC1 bulk-in endpoint. -#define CDCD_Descriptors_DATAIN1 5 -/// Address of the CDC1 bulk-out endpoint. -#define CDCD_Descriptors_DATAOUT1 4 - - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -extern const USBDDriverDescriptors dualcdcdDriverDescriptors; - -#endif //#ifndef DUALCDCDDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.c b/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.c deleted file mode 100644 index 315e42915..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.c +++ /dev/null @@ -1,477 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -// USB -#include -#include -#include -// HID -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HIDDFunctionDriver.h" -#include "HIDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Internal types -//----------------------------------------------------------------------------- - -/// Driver structure for an HID device implementing keyboard functionalities. -typedef struct { - - /// Pointer to USB device driver instance - USBDDriver * pUsbdDriver; - /// Interface Number to access this function - unsigned char interfaceNum; - /// Interrupt IN endpoint address - unsigned char interruptInEndpoint; - /// Interrupt OUT endpoint address - unsigned char interruptOutEndpoint; - /// Idle rate (in milliseconds) of the input report - unsigned char inputReportIdleRate; - /// Input report instance. - HIDDKeyboardInputReport inputReport; - /// Output report instance. - HIDDKeyboardOutputReport outputReport; - -} HIDDKeyboardDriver; - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// Static instance of the HID keyboard device driver. -static HIDDKeyboardDriver hiddKeyboardDriver; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Returns the descriptor requested by the host. -/// \param type Descriptor type. -/// \param length Maximum number of bytes to send. -/// \return 1 if the request has been handled by this function, otherwise 0. -//----------------------------------------------------------------------------- -static unsigned char HIDD_GetDescriptor(unsigned char type, - unsigned char length) -{ - const USBConfigurationDescriptor *pConfiguration; - HIDDescriptor *hidDescriptor; - - switch (type) { - - case HIDGenericDescriptor_REPORT: - TRACE_INFO_WP("Report "); - - // Adjust length and send report descriptor - if (length > HIDD_Descriptors_REPORTSIZE) { - - length = HIDD_Descriptors_REPORTSIZE; - } - USBD_Write(0, &hiddReportDescriptor, length, 0, 0); - break; - - case HIDGenericDescriptor_HID: - TRACE_INFO_WP("HID "); - - // Configuration descriptor is different depending on speed - if (USBD_IsHighSpeed()) { - - pConfiguration = hiddKeyboardDriver - .pUsbdDriver->pDescriptors->pHsConfiguration; - } - else { - - pConfiguration = hiddKeyboardDriver - .pUsbdDriver->pDescriptors->pFsConfiguration; - } - - // Parse the device configuration to get the HID descriptor - USBConfigurationDescriptor_Parse(pConfiguration, - 0, - 0, - (USBGenericDescriptor **) &hidDescriptor); - - // Adjust length and send HID descriptor - if (length > sizeof(HIDDescriptor)) { - - length = sizeof(HIDDescriptor); - } - USBD_Write(0, hidDescriptor, length, 0, 0); - break; - - default: - return 0; - } - - return 1; -} - -//----------------------------------------------------------------------------- -/// Sends the current Idle rate of the input report to the host. -//----------------------------------------------------------------------------- -static void HIDD_GetIdle() -{ - TRACE_INFO_WP("gIdle "); - - USBD_Write(0, &(hiddKeyboardDriver.inputReportIdleRate), 1, 0, 0); -} - -//----------------------------------------------------------------------------- -/// Retrieves the new idle rate of the input report from the USB host. -/// \param idleRate New input report idle rate. -//----------------------------------------------------------------------------- -static void HIDD_SetIdle(unsigned char idleRate) -{ - TRACE_INFO_WP("sIdle(%d) ", idleRate); - - hiddKeyboardDriver.inputReportIdleRate = idleRate; - USBD_Write(0, 0, 0, 0, 0); -} - -//----------------------------------------------------------------------------- -/// Sends the requested report to the host. -/// \param type Report type. -/// \param length Maximum number of bytes to send. -//----------------------------------------------------------------------------- -static void HIDD_GetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO_WP("gReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - TRACE_INFO_WP("In "); - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardInputReport)) { - - length = sizeof(HIDDKeyboardInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.inputReport), - length, - 0, // No callback - 0); - break; - - case HIDReportRequest_OUTPUT: - TRACE_INFO_WP("Out "); - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardOutputReport)) { - - length = sizeof(HIDDKeyboardOutputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Callback invoked when an output report has been received from the host. -/// Forward the new status of the LEDs to the user program via the -//----------------------------------------------------------------------------- -static void HIDD_ReportReceived() -{ - TRACE_INFO_WP("oReport "); - - // Trigger callback - HIDDKeyboardCallbacks_LedsChanged( - HIDDKeyboardOutputReport_GetNumLockStatus( - &(hiddKeyboardDriver.outputReport)), - HIDDKeyboardOutputReport_GetCapsLockStatus( - &(hiddKeyboardDriver.outputReport)), - HIDDKeyboardOutputReport_GetScrollLockStatus( - &(hiddKeyboardDriver.outputReport))); - - // Restart transfer - USBD_Read(hiddKeyboardDriver.interruptOutEndpoint, - &(hiddKeyboardDriver.outputReport), - sizeof(HIDDKeyboardOutputReport), - (TransferCallback) HIDD_ReportReceived, - 0); // No argument for callback function -} - -//----------------------------------------------------------------------------- -/// Retrieves the new value of a report from the host and saves it. -/// \param type Report type. -/// \param length Report length. -//----------------------------------------------------------------------------- -static void HIDD_SetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO_WP("sReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - case HIDReportRequest_OUTPUT: - // Check report length - if (length != sizeof(HIDDKeyboardOutputReport)) { - - USBD_Stall(0); - } - else { - - USBD_Read(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - (TransferCallback) HIDD_ReportReceived, - 0); // No argument to the callback function - } - break; - - default: - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes an USB HID keyboard function driver. -/// \param pUsbdDriver Pointer to the USB driver instance. -/// \param interfaceNum Interface number to access the MSD function -/// \param interruptInEndpoint Interrupt IN endpoint address -/// \param interruptOutEndpoint Interrupt OUT endpoint address -//----------------------------------------------------------------------------- -void HIDDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - unsigned char interfaceNum, - unsigned char interruptInEndpoint, - unsigned char interruptOutEndpoint) -{ - hiddKeyboardDriver.inputReportIdleRate = 0; - HIDDKeyboardInputReport_Initialize(&(hiddKeyboardDriver.inputReport)); - HIDDKeyboardOutputReport_Initialize(&(hiddKeyboardDriver.outputReport)); - - hiddKeyboardDriver.pUsbdDriver = pUsbdDriver; - hiddKeyboardDriver.interfaceNum = interfaceNum; - hiddKeyboardDriver.interruptInEndpoint = interruptInEndpoint; - hiddKeyboardDriver.interruptOutEndpoint = interruptOutEndpoint; -} - -//----------------------------------------------------------------------------- -/// Handles HID-specific SETUP request sent by the host. -/// \param request Pointer to a USBGenericRequest instance. -/// \return 0 if the request is Unsupported, 1 if the request handled. -//----------------------------------------------------------------------------- -unsigned char HIDDFunctionDriver_RequestHandler( - const USBGenericRequest *request) -{ - TRACE_INFO_WP("NewReq "); - - // Check if this is a standard request - if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // This is a standard request - switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, otherwise forward it to - // the standard driver - if (!HIDD_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(hiddKeyboardDriver.pUsbdDriver, - request); - } - break; - - default: - return 0; - } - } - // Check if this is a class request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - // This is a class-specific request - switch (USBGenericRequest_GetRequest(request)) { - - case HIDGenericRequest_GETIDLE: - HIDD_GetIdle(); - break; - - case HIDGenericRequest_SETIDLE: - HIDD_SetIdle(HIDIdleRequest_GetIdleRate(request)); - break; - - case HIDGenericRequest_GETREPORT: - HIDD_GetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - case HIDGenericRequest_SETREPORT: - HIDD_SetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - default: - return 0; - } - } - return 1; -} - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration of the device is changed by the host. -/// \param cfgnum Newly configuration number. -//----------------------------------------------------------------------------- -void HIDDFunctionCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - if (cfgnum > 0) { - - // Start receiving output reports - USBD_Read(hiddKeyboardDriver.interruptOutEndpoint, - &(hiddKeyboardDriver.outputReport), - sizeof(HIDDKeyboardOutputReport), - (TransferCallback) HIDD_ReportReceived, - 0); // No argument for callback function - } -} - -//----------------------------------------------------------------------------- -/// Reports a change in which keys are currently pressed or release to the -/// host. -/// \param pressedKeys Pointer to an array of key codes indicating keys that -/// have been pressed since the last call to -/// . -/// \param pressedKeysSize Number of key codes in the pressedKeys array. -/// \param releasedKeys Pointer to an array of key codes indicates keys that -/// have been released since the last call to -/// . -/// \param releasedKeysSize Number of key codes in the releasedKeys array. -/// \return if the report has been sent to the host; -/// otherwise an error code. -//----------------------------------------------------------------------------- -unsigned char HIDDKeyboardDriver_ChangeKeys(unsigned char *pressedKeys, - unsigned char pressedKeysSize, - unsigned char *releasedKeys, - unsigned char releasedKeysSize) -{ - // Press keys - while (pressedKeysSize > 0) { - - // Check if this is a standard or modifier key - if (HIDKeypad_IsModifierKey(*pressedKeys)) { - - // Set the corresponding bit in the input report - HIDDKeyboardInputReport_PressModifierKey( - &(hiddKeyboardDriver.inputReport), - *pressedKeys); - } - else { - - HIDDKeyboardInputReport_PressStandardKey( - &(hiddKeyboardDriver.inputReport), - *pressedKeys); - } - - pressedKeysSize--; - pressedKeys++; - } - - // Release keys - while (releasedKeysSize > 0) { - - // Check if this is a standard or modifier key - if (HIDKeypad_IsModifierKey(*releasedKeys)) { - - // Set the corresponding bit in the input report - HIDDKeyboardInputReport_ReleaseModifierKey( - &(hiddKeyboardDriver.inputReport), - *releasedKeys); - } - else { - - HIDDKeyboardInputReport_ReleaseStandardKey( - &(hiddKeyboardDriver.inputReport), - *releasedKeys); - } - - releasedKeysSize--; - releasedKeys++; - } - - // Send input report through the interrupt IN endpoint - return USBD_Write(hiddKeyboardDriver.interruptInEndpoint, - &(hiddKeyboardDriver.inputReport), - sizeof(HIDDKeyboardInputReport), - 0, - 0); -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void HIDDKeyboardDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(hiddKeyboardDriver.pUsbdDriver)) { - - USBD_RemoteWakeUp(); - } -} diff --git a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.h b/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.h deleted file mode 100644 index a788d57db..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriver.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef HIDDFUNCTIONDRIVER_H -#define HIDDFUNCTIONDRIVER_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//- Function API for composite device -extern void HIDDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - unsigned char interfaceNum, - unsigned char interruptInEndpoint, - unsigned char interruptOutEndpoint); - -extern unsigned char HIDDFunctionDriver_RequestHandler( - const USBGenericRequest *request); - -extern void HIDDFunctionCallbacks_ConfigurationChanged(unsigned char cfgnum); - -//- HID Keyboard API -extern unsigned char HIDDKeyboardDriver_ChangeKeys( - unsigned char *pressedKeys, - unsigned char pressedKeysSize, - unsigned char *releasedKeys, - unsigned char releasedKeysSize); - -extern void HIDDKeyboardDriver_RemoteWakeUp(void); - -#endif // #define HIDDFUNCTIONDRIVER_H diff --git a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.c deleted file mode 100644 index 747a5fbeb..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.c +++ /dev/null @@ -1,118 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//- HID -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "HIDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// Report descriptor used by the HID function driver. -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_KEYBOARD, - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, - - // Input report: modifier keys - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_REPORTCOUNT + 1, 8, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDD_Descriptors_FIRSTMODIFIERKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDD_Descriptors_LASTMODIFIERKEY, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, - - // Input report: standard keys - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, - HIDD_Descriptors_FIRSTSTANDARDKEY, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, - HIDD_Descriptors_LASTSTANDARDKEY, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDD_Descriptors_FIRSTSTANDARDKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDD_Descriptors_LASTSTANDARDKEY, - HIDReport_INPUT + 1, 0 /* Data array */, - - // Output report: LEDs - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK, - HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK, - HIDReport_OUTPUT + 1, HIDReport_VARIABLE, - - // Output report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_OUTPUT + 1, HIDReport_CONSTANT, - - HIDReport_ENDCOLLECTION -}; diff --git a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.h deleted file mode 100644 index 7f643219b..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDDFunctionDriverDescriptors.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef HIDDFUNCTIONDRIVERDESCRIPTORS_H -#define HIDDFUNCTIONDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -//- Interface & Endpoints -/// Interface Number. -/// Interrupt IN endpoint number. -/// Interrupt OUT endpoint number. -/// Interrupt IN endpoint polling rate (in milliseconds). -/// Interrupt OUT endpoint polling rate (in milliseconds). -#if defined(usb_HIDAUDIO) -#define HIDD_Descriptors_INTERFACENUM 0 -#define HIDD_Descriptors_INTERRUPTIN 1 -#define HIDD_Descriptors_INTERRUPTOUT 2 -#define HIDD_Descriptors_INTERRUPTIN_POLLING 10 -#endif - -/// Default HID interrupt IN endpoint polling rate (16ms). -#define HIDD_Descriptors_INTERRUPTIN_POLLING_FS 16 -#define HIDD_Descriptors_INTERRUPTIN_POLLING_HS 8 -/// Default interrupt OUT endpoint polling rate (16ms). -#define HIDD_Descriptors_INTERRUPTOUT_POLLING_FS 16 -#define HIDD_Descriptors_INTERRUPTOUT_POLLING_HS 8 - -//- Keypad keys -/// Key code of the first accepted modifier key. -#define HIDD_Descriptors_FIRSTMODIFIERKEY HIDKeypad_LEFTCONTROL -/// Key code of the last accepted modifier key. -#define HIDD_Descriptors_LASTMODIFIERKEY HIDKeypad_RIGHTGUI -/// Key code of the first accepted standard key. -#define HIDD_Descriptors_FIRSTSTANDARDKEY 0 -/// Key code of the last accepted standard key. -#define HIDD_Descriptors_LASTSTANDARDKEY HIDKeypad_NUMLOCK - -//- Report descriptor -/// Size of the report descriptor in bytes. -#define HIDD_Descriptors_REPORTSIZE 61 - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -/// Report descriptor used by the driver. -extern const unsigned char hiddReportDescriptor[]; - -#endif // #define HIDDFUNCTIONDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.c b/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.c deleted file mode 100644 index 2ef2ea7b4..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.c +++ /dev/null @@ -1,227 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -#include - -// USB -#include -#include - -//- HID -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -//- MSD - -//- HIDMSD -#include "HIDMSDDDriver.h" -#include "HIDMSDDDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Defines -//----------------------------------------------------------------------------- - -/// Interface setting spaces (4 byte aligned) -#define NUM_INTERFACES ((HIDMSDDDriverDescriptors_NUMINTERFACE+3)&0xFC) - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// USBDDriver instance -static USBDDriver usbdDriver; - -/// Array for storing the current setting of each interface -static unsigned char hidmsddDriverInterfaces[NUM_INTERFACES]; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Optional RequestReceived() callback re-implementation -//----------------------------------------------------------------------------- -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - HIDMSDDDriver_RequestHandler(request); -} - -#endif - -//----------------------------------------------------------------------------- -// ConfigurationChanged() callback re-implementation -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration value of a device is changed by the host -/// \param cfgnum Configuration number. -//----------------------------------------------------------------------------- -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - // HID - HIDDFunctionCallbacks_ConfigurationChanged(cfgnum); - - // MSD - MSDDFunctionCallbacks_ConfigurationChanged(cfgnum); -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes the USB device HIDMSD device driver. -//----------------------------------------------------------------------------- -void HIDMSDDDriver_Initialize(MSDLun *pLuns, unsigned char numLuns) -{ - // HID - HIDDFunctionDriver_Initialize(&usbdDriver, - HIDD_Descriptors_INTERFACENUM, - HIDD_Descriptors_INTERRUPTIN, - HIDD_Descriptors_INTERRUPTOUT); - - // MSD - MSDDFunctionDriver_Initialize(&usbdDriver, - pLuns, numLuns, - MSDD_Descriptors_INTERFACENUM, - MSDD_Descriptors_BULKIN, - MSDD_Descriptors_BULKOUT); - - // Initialize the standard USB driver - USBDDriver_Initialize(&usbdDriver, - &hidmsddDriverDescriptors, - hidmsddDriverInterfaces); - - // Initialize the USB driver - USBD_Init(); -} - -//----------------------------------------------------------------------------- -/// Handles HIDMSD-specific USB requests sent by the host, and forwards -/// standard ones to the USB device driver. -/// \param request Pointer to a USBGenericRequest instance. -//----------------------------------------------------------------------------- -void HIDMSDDDriver_RequestHandler(const USBGenericRequest *request) -{ - // Check if this is a class request - if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned char rc = 0; - - // MSD class request - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - - // HID class request - if (rc == 0) { - - rc = HIDDFunctionDriver_RequestHandler(request); - } - - if (!rc) { - - TRACE_WARNING( - "HIDMSDDDriver_RequestHandler: Unsupported request (%d)\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - - } - // Check if this is a standard request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - unsigned char rc = 0; - - rc = HIDDFunctionDriver_RequestHandler(request); - - if (rc == 0) { - - rc = MSDDFunctionDriver_RequestHandler(request); - } - - // Forward request to the standard handler - if (rc == 0) { - - USBDDriver_RequestHandler(&(usbdDriver), request); - } - } - // Unsupported request type - else { - - TRACE_WARNING( - "HIDMSDDDriver_RequestHandler: Unsupported request type (%d)\n\r", - USBGenericRequest_GetType(request)); - USBD_Stall(0); - } -} - -//----------------------------------------------------------------------------- -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//----------------------------------------------------------------------------- -void HIDMSDDDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&usbdDriver)) { - - USBD_RemoteWakeUp(); - } - // Remote wake-up NOT enabled - else { - - TRACE_WARNING("HIDMSDDDriver_RemoteWakeUp: not enabled\n\r"); - } -} - - diff --git a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.h b/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.h deleted file mode 100644 index ba3720566..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriver.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// -/// !Purpose -/// -/// Definitions and methods for USB HID + MSD HIDMSD device implement. -/// -/// !Usage -/// -/// -# Initialize USB function specified driver ( for MSD currently ) -/// - MSDDFunctionDriver_Initialize -/// -/// -# Initialize USB HIDMSD driver and USB driver -/// - HIDMSDDDriver_Initialize -/// -/// -# Handle and dispach USB requests -/// - HIDMSDDDriver_RequestHandler -/// -/// -# Try starting a remote wake-up sequence -/// - HIDMSDDDriver_RemoteWakeUp -//----------------------------------------------------------------------------- - -#ifndef HIDMSDDDRIVER_H -#define HIDMSDDDRIVER_H - - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -#include "HIDDFunctionDriver.h" -#include "MSDDFunctionDriver.h" - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -// -HIDMSD Composite device -extern void HIDMSDDDriver_Initialize(MSDLun *pLuns, - unsigned char numLuns); - -extern void HIDMSDDDriver_RequestHandler(const USBGenericRequest *request); - -extern void HIDMSDDDriver_RemoteWakeUp(void); - -#endif //#ifndef HIDMSDDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.c b/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.c deleted file mode 100644 index aecfd618b..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.c +++ /dev/null @@ -1,449 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDMSDDDriver.h" -#include "HIDMSDDDriverDescriptors.h" -#include - -//- USB Generic -#include -#include -#include -#include -#include -#include - -//- HID -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "HIDDFunctionDriverDescriptors.h" - -//- MSD -#include -#include -#include "MSDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Device product ID. -#define HIDMSDDDriverDescriptors_PRODUCTID 0x6135 - -/// Device vendor ID (Atmel). -#define HIDMSDDDriverDescriptors_VENDORID 0x03EB - -/// Device release number. -#define HIDMSDDDriverDescriptors_RELEASE 0x0003 - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//----------------------------------------------------------------------------- -// Internal structures -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Audio control header descriptor with one slave interface. -//----------------------------------------------------------------------------- -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//----------------------------------------------------------------------------- -/// Configuration descriptor list for a device implementing a composite driver. -//----------------------------------------------------------------------------- -typedef struct { - - /// Standard configuration descriptor. - USBConfigurationDescriptor configuration; - - /// --- HID - USBInterfaceDescriptor hidInterface; - HIDDescriptor hid; - USBEndpointDescriptor hidInterruptIn; - USBEndpointDescriptor hidInterruptOut; - - /// --- MSD - /// Mass storage interface descriptor. - USBInterfaceDescriptor msdInterface; - /// Bulk-out endpoint descriptor. - USBEndpointDescriptor msdBulkOut; - /// Bulk-in endpoint descriptor. - USBEndpointDescriptor msdBulkIn; - -} __attribute__ ((packed)) HidMsdDriverConfigurationDescriptors; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Standard USB device descriptor for the composite device driver -static const USBDeviceDescriptor deviceDescriptor = -{ - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0x00, - 0x00, - 0x00, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDMSDDDriverDescriptors_VENDORID, - HIDMSDDDriverDescriptors_PRODUCTID, - HIDMSDDDriverDescriptors_RELEASE, - 0, // No string descriptor for manufacturer - 1, // Index of product string descriptor is #1 - 0, // No string descriptor for serial number - 1 // Device has 1 possible configuration -}; - -#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - -/// USB device qualifier descriptor. -static const USBDeviceQualifierDescriptor qualifierDescriptor = -{ - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - USBDeviceDescriptor_USB2_00, - 0x00, - 0x00, - 0x00, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // Device has one possible configuration - 0 // Reserved -}; - -/// USB configuration descriptors for the composite device driver -static const HidMsdDriverConfigurationDescriptors configurationDescriptorsHS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HidMsdDriverConfigurationDescriptors), - HIDMSDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - HIDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDD_Descriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDD_Descriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_HS - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDD_Descriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_HS - }, - - // Mass Storage interface descriptor. - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - MSDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0. - 2, // Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, - MSInterfaceDescriptor_SCSI, - MSInterfaceDescriptor_BULKONLY, - 0 // No string descriptor for interface. - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // No string descriptor for endpoint. - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_HS), - 0 // No string descriptor for endpoint. - } - -}; - -#endif - -/// USB FS configuration descriptors for the composite device driver -static const HidMsdDriverConfigurationDescriptors configurationDescriptorsFS = -{ - - // Standard configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HidMsdDriverConfigurationDescriptors), - HIDMSDDDriverDescriptors_NUMINTERFACE, - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - HIDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDD_Descriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDD_Descriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_FS - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDD_Descriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDD_Descriptors_INTERRUPTIN_POLLING_FS - }, - - // Mass Storage interface descriptor. - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - MSDD_Descriptors_INTERFACENUM, - 0, // This is alternate setting #0. - 2, // Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, - MSInterfaceDescriptor_SCSI, - MSInterfaceDescriptor_BULKONLY, - 0 // No string descriptor for interface. - }, - // Bulk-OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - }, - // Bulk-IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_BULK, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), - 0 // No string descriptor for endpoint. - } - -}; - -/// String descriptor with the supported languages. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('l') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(14), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('C'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('p'), - USBStringDescriptor_UNICODE('o'), - USBStringDescriptor_UNICODE('s'), - USBStringDescriptor_UNICODE('i'), - USBStringDescriptor_UNICODE('t'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE('e'), - USBStringDescriptor_UNICODE('m'), - USBStringDescriptor_UNICODE('o') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(4), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3') -}; - -/// Array of pointers to the four string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors required by an USB audio speaker device driver. -const USBDDriverDescriptors hidmsddDriverDescriptors = { - - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &deviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsHS, - &qualifierDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptorsFS, -#else - 0, 0, 0, 0, 0, 0, -#endif - stringDescriptors, - 4 // Number of string descriptors -}; diff --git a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.h deleted file mode 100644 index 85739be11..000000000 --- a/src/ersky9x/libraries/usb/device/composite/HIDMSDDDriverDescriptors.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef HIDMSDDDRIVERDESCRIPTORS_H -#define HIDMSDDDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -/// Number of interfaces of the device -#define HIDMSDDDriverDescriptors_NUMINTERFACE 2 - -#define HIDD_Descriptors_INTERFACENUM 0 -/// Address of the HID interrupt IN endpoint. -#define HIDD_Descriptors_INTERRUPTIN 1 -/// Address of the HID interrupt OUT endpoint. -#define HIDD_Descriptors_INTERRUPTOUT 2 - -#define MSDD_Descriptors_INTERFACENUM 1 -/// Address of the Mass Storage bulk-out endpoint. -#define MSDD_Descriptors_BULKOUT 4 -/// Address of the Mass Storage bulk-in endpoint. -#define MSDD_Descriptors_BULKIN 5 - - -//----------------------------------------------------------------------------- -// Exported variables -//----------------------------------------------------------------------------- - -extern const USBDDriverDescriptors hidmsddDriverDescriptors; - -#endif //#ifndef HIDMSDDDRIVERDESCRIPTORS_H diff --git a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.c b/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.c deleted file mode 100644 index 840294e28..000000000 --- a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.c +++ /dev/null @@ -1,327 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -// Includes -//----------------------------------------------------------------------------- - -// GENERAL -#include -#include -// USB -#include -#include -#include -#include -// MSD -#include -#include -#include "MSDDFunctionDriverDescriptors.h" - -//----------------------------------------------------------------------------- -// Internal types -//----------------------------------------------------------------------------- - -/// Driver structure for an HID device implementing keyboard functionalities. -typedef struct { - - /// Pointer to USB device driver instance - USBDDriver * pUsbdDriver; - /// Pointer to MSD driver instance - MSDDriver * pMsdDriver; - /// Interface Number of MS Function - unsigned char interfaceNum; - /// Interrupt IN endpoint address - unsigned char bulkInEndpoint; - /// Interrupt OUT endpoint address - unsigned char bulkOutEndpoint; - -} MSDFunctionDriver; - -//----------------------------------------------------------------------------- -// Internal variables -//----------------------------------------------------------------------------- - -/// Mass storage general driver instance. -static MSDDriver msdDriver; - -/// Mass storage function driver instance. -static MSDFunctionDriver msdFunDriver; - -//----------------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Resets the state of the MSD driver -//----------------------------------------------------------------------------- -static void MSDD_Reset() -{ - TRACE_INFO_WP("MSDReset "); - - msdDriver.state = MSDD_STATE_READ_CBW; - msdDriver.waitResetRecovery = 0; - msdDriver.commandState.state = 0; -} - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// Initializes a MSD driver -/// \param luns Pointer to a list of LUNs -/// \param numLuns Number of LUN in list -/// \param interfaceNum Interface number to access the MSD function -/// \param bulkInEndpoint Bulk IN endpoint address -/// \param bulkOutEndpoint Bulk OUT endpoint address -//----------------------------------------------------------------------------- -void MSDDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - MSDLun *luns, unsigned char numLuns, - unsigned char interfaceNum, - unsigned char bulkInEndpoint, - unsigned char bulkOutEndpoint) -{ - TRACE_INFO("MSD init\n\r"); - - msdFunDriver.pUsbdDriver = pUsbdDriver; - msdFunDriver.pMsdDriver = &msdDriver; - msdFunDriver.interfaceNum = interfaceNum; - msdFunDriver.bulkInEndpoint = bulkInEndpoint; - msdFunDriver.bulkOutEndpoint = bulkOutEndpoint; - - // Command state initialization - msdDriver.commandState.state = 0; - msdDriver.commandState.postprocess = 0; - msdDriver.commandState.length = 0; - msdDriver.commandState.transfer.semaphore = 0; - - // LUNs - msdDriver.luns = luns; - msdDriver.maxLun = (unsigned char) (numLuns - 1); - - // Reset BOT driver - MSDD_Reset(); -} - -//----------------------------------------------------------------------------- -/// Invoked when a new SETUP request is received from the host. Forwards the -/// request to the Mass Storage device driver handler function. -/// \param request Pointer to a USBGenericRequest instance. -/// \return 0 if the request is Unsupported, 1 if the request handled. -//----------------------------------------------------------------------------- -unsigned char MSDDFunctionDriver_RequestHandler( - const USBGenericRequest *request) -{ - // Handle requests - switch (USBGenericRequest_GetRequest(request)) { - //--------------------- - case USBGenericRequest_CLEARFEATURE: - //--------------------- - TRACE_INFO_WP("ClrFeat "); - - switch (USBFeatureRequest_GetFeatureSelector(request)) { - - //--------------------- - case USBFeatureRequest_ENDPOINTHALT: - //--------------------- - TRACE_INFO_WP("Hlt "); - - // Do not clear the endpoint halt status if the device is waiting - // for a reset recovery sequence - if (!msdDriver.waitResetRecovery) { - - // Forward the request to the standard handler - return 0; - } - else { - - TRACE_INFO_WP("No "); - } - - USBD_Write(0, 0, 0, 0, 0); - break; - - //------ - default: - //------ - // Forward the request to the standard handler - return 0; - } - break; - - //------------------- - case MSD_GET_MAX_LUN: - //------------------- - TRACE_INFO_WP("gMaxLun "); - - // Check request parameters - if ((request->wValue == 0) - && (request->wIndex == msdFunDriver.interfaceNum) - && (request->wLength == 1)) { - - USBD_Write(0, &(msdDriver.maxLun), 1, 0, 0); - - } - else { - - TRACE_WARNING( - "MSDDriver_RequestHandler: GetMaxLUN(%d,%d,%d)\n\r", - request->wValue, request->wIndex, request->wLength); - USBD_Stall(0); - } - break; - - //----------------------- - case MSD_BULK_ONLY_RESET: - //----------------------- - TRACE_INFO_WP("Rst "); - - // Check parameters - if ((request->wValue == 0) - && (request->wIndex == msdFunDriver.interfaceNum) - && (request->wLength == 0)) { - - // Reset the MSD driver - MSDD_Reset(); - USBD_Write(0, 0, 0, 0, 0); - } - else { - - TRACE_WARNING( - "MSDDriver_RequestHandler: Reset(%d,%d,%d)\n\r", - request->wValue, request->wIndex, request->wLength); - USBD_Stall(0); - } - break; - - //------ - default: - //------ - // Forward request to standard handler - return 0; - } - - return 1; -} - -//----------------------------------------------------------------------------- -/// Invoked whenever the configuration of the device is changed by the host. -/// \param cfgnum Newly configuration number. -//----------------------------------------------------------------------------- -void MSDDFunctionCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - if (cfgnum > 0) { - - MSDD_Reset(); - } -} - -//----------------------------------------------------------------------------- -/// Reads from host through MSD defined pipe. Act as USBD_Read. -/// \param data Pointer to the data buffer that contains data read from host. -/// \param size The number of bytes should be read (buffer size). -/// \param callback Pointer to the function invoked on end of reading. -/// \param argument Pointer to additional argument data struct. -//----------------------------------------------------------------------------- -char MSDD_Read(void *data, - unsigned int size, - TransferCallback callback, - void *argument) - -{ - return USBD_Read(msdFunDriver.bulkOutEndpoint, - data, - size, - callback, - argument); -} - -//----------------------------------------------------------------------------- -/// Writes to host through MSD defined pipe. Act as USBD_Write. -/// \param data Pointer to the data that writes to the host. -/// \param size The number of bytes should be write. -/// \param callback Pointer to the function invoked on end of writing. -/// \param argument Pointer to additional argument data struct. -//----------------------------------------------------------------------------- -char MSDD_Write(void *data, - unsigned int size, - TransferCallback callback, - void *argument) -{ - return USBD_Write(msdFunDriver.bulkInEndpoint, - data, - size, - callback, - argument); -} - -//----------------------------------------------------------------------------- -/// HALT Specified USB pipe. -/// \param stallCASE Case of the stall condition (Bulk In/Out/Both). -//----------------------------------------------------------------------------- -void MSDD_Halt(unsigned int stallCASE) -{ - if (stallCASE & MSDD_CASE_STALL_OUT) { - - USBD_Halt(msdFunDriver.bulkOutEndpoint); - } - - if (stallCASE & MSDD_CASE_STALL_IN) { - - USBD_Halt(msdFunDriver.bulkInEndpoint); - } -} - -//----------------------------------------------------------------------------- -/// Return halted status -/// \return stallCASE bitmap, case of the stall condition -/// (bit: MSDD_CASE_STALL_OUT or MSDD_CASE_STALL_IN) -//----------------------------------------------------------------------------- -unsigned int MSDD_IsHalted(void) -{ - unsigned int stallCASE = 0; - if (USBD_IsHalted(msdFunDriver.bulkOutEndpoint)) { - - stallCASE |= MSDD_CASE_STALL_OUT; - } - if (USBD_IsHalted(msdFunDriver.bulkInEndpoint)) { - - stallCASE |= MSDD_CASE_STALL_IN; - } - return stallCASE; -} - -//----------------------------------------------------------------------------- -/// State machine for the MSD driver -//----------------------------------------------------------------------------- -void MSDDriver_StateMachine(void) -{ - MSDD_StateMachine(&msdDriver); -} diff --git a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.h b/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.h deleted file mode 100644 index c96fbfdc5..000000000 --- a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriver.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//----------------------------------------------------------------------------- -/// \unit -/// !Purpose -/// -/// Mass storage function driver implementation. -/// -/// !Usage -/// TODO -//----------------------------------------------------------------------------- - -#ifndef MSDDFUNCTIONDRIVER_H -#define MSDDFUNCTIONDRIVER_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- - -//- Function API for composite device -extern void MSDDFunctionDriver_Initialize(USBDDriver * pUsbdDriver, - MSDLun *luns, unsigned char numLuns, - unsigned char interfaceNum, - unsigned char bulkInEndpoint, - unsigned char bulkOutEndpoint); - -extern unsigned char MSDDFunctionDriver_RequestHandler( - const USBGenericRequest *request); - -extern void MSDDFunctionCallbacks_ConfigurationChanged(unsigned char cfgnum); - -//- MSD APIs -extern void MSDDriver_StateMachine(void); - -#endif // #define MSDDFUNCTIONDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriverDescriptors.h b/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriverDescriptors.h deleted file mode 100644 index 6da6214e3..000000000 --- a/src/ersky9x/libraries/usb/device/composite/MSDDFunctionDriverDescriptors.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef MSDDFUNCTIONDRIVERDESCRIPTORS_H -#define MSDDFUNCTIONDRIVERDESCRIPTORS_H - -//----------------------------------------------------------------------------- -// Headers -//----------------------------------------------------------------------------- - -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -/// \page "MS interface & endpoint descriptor settings" -/// This page lists the definition used by the Mass Storage driver. -/// -/// !Settings -/// -/// - MSDD_Descriptors_INTERFACENUM -/// - MSDD_Descriptors_BULKOUT -/// - MSDD_Descriptors_BULKIN - -/// Number of the Mass Storage interface. -#if defined(usb_CDCMSD) -#define MSDD_Descriptors_INTERFACENUM 2 -#elif defined(usb_HIDMSD) -#define MSDD_Descriptors_INTERFACENUM 1 -#endif - -/// Address of the Mass Storage bulk-out endpoint. -#define MSDD_Descriptors_BULKOUT 4 - -/// Address of the Mass Storage bulk-in endpoint. -#define MSDD_Descriptors_BULKIN 5 -//----------------------------------------------------------------------------- - - -#endif // #define MSDDFUNCTIONDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/composite/drv/CompositeCDCSerial.inf b/src/ersky9x/libraries/usb/device/composite/drv/CompositeCDCSerial.inf deleted file mode 100644 index 973a14b13..000000000 --- a/src/ersky9x/libraries/usb/device/composite/drv/CompositeCDCSerial.inf +++ /dev/null @@ -1,57 +0,0 @@ -; $Id: 6119.inf,v 1.1.2.1 2006/12/05 08:33:25 danielru Exp $ - -[Version] ; Version section -Signature="$Chicago$" ; All Windows versions -Class=Ports ; This is a serial port driver -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} ; Associated GUID -Provider=%ATMEL% ; Driver is provided by ATMEL -DriverVer=09/12/2006,1.1.1.5 ; Driver version 1.1.1.5 published on 23 February 2007 - -[DestinationDirs] ; DestinationDirs section -DefaultDestDir=12 ; Default install directory is \drivers or \IOSubSys - -[Manufacturer] ; Manufacturer section -%ATMEL%=AtmelMfg ; Only one manufacturer (ATMEL), models section is named - ; AtmelMfg - -[AtmelMfg] ; Models section corresponding to ATMEL -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6130&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6130h. Corresponding Install section - ; is named USBtoSer.Install ( CDCHID ) -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6131&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6131h. Corresponding Install section - ; is named USBtoSer.Install ( CDCAUDIO ) -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6132&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6132h. Corresponding Install section - ; is named USBtoSer.Install ( CDCMSD ) -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6133&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6133h. Corresponding Install section - ; is named USBtoSer.Install ( CDCCDC ) -%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6133&MI_02 ; Identifies a device with ATMEL Vendor ID (03EBh) and - ; Product ID equal to 6133h. Corresponding Install section - ; is named USBtoSer.Install ( CDCCDC ) - -[USBtoSer.Install] ; Install section -include=mdmcpq.inf -CopyFiles=FakeModemCopyFileSection -AddReg=USBtoSer.AddReg ; Registry keys to add are listed in USBtoSer.AddReg - -[USBtoSer.AddReg] ; AddReg section -HKR,,DevLoader,,*ntkern ; -HKR,,NTMPDriver,,usbser.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[USBtoSer.Install.Services] ; Services section -AddService=usbser,0x00000002,USBtoSer.AddService ; Assign usbser as the PnP driver for the device - -[USBtoSer.AddService] ; Service install section -DisplayName=%USBSer% ; Name of the serial driver -ServiceType=1 ; Service kernel driver -StartType=3 ; Driver is started by the PnP manager -ErrorControl=1 ; Warn about errors -ServiceBinary=%12%\usbser.sys ; Driver filename - -[Strings] ; Strings section -ATMEL="ATMEL Corp." ; String value for the ATMEL symbol -USBtoSerialConverter="AT91 USB to Serial Converter" ; String value for the USBtoSerialConverter symbol -USBSer="USB Composite Serial Driver" ; String value for the USBSer symbol \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/composite/drv/drv.dir b/src/ersky9x/libraries/usb/device/composite/drv/drv.dir deleted file mode 100644 index 1f2d5d61a..000000000 --- a/src/ersky9x/libraries/usb/device/composite/drv/drv.dir +++ /dev/null @@ -1,45 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides install file for -/// - CDC HID -/// - CDC AUDIO -/// - CDC MSD -/// - CDC CDC -/// -/// !!!Contents -/// -/// CompositeCDCSerial.inf -/// -//------------------------------------------------------------------------------ diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_RequestReceived.c b/src/ersky9x/libraries/usb/device/core/USBDCallbacks_RequestReceived.c deleted file mode 100644 index 29468ff46..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_RequestReceived.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDCallbacks.h" - -//------------------------------------------------------------------------------ -// Exported function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USBDCallbacks_RequestReceived - Invoked when a new SETUP request is -/// received. Does nothing by default. -/// \param pRequest Pointer to the request to handle. -//------------------------------------------------------------------------------ -void USBDCallbacks_RequestReceived(const USBGenericRequest *pRequest) -{ - // Does nothing -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c b/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c deleted file mode 100644 index 64d9aaaaa..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c +++ /dev/null @@ -1,47 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDCallbacks.h" - -//------------------------------------------------------------------------------ -// Exported function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Invoked when the USB driver is reset. Does nothing by default. -//------------------------------------------------------------------------------ -void USBDCallbacks_Reset(void) -{ - // Does nothing -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c b/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c deleted file mode 100644 index f98db34f5..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDCallbacks.h" -#include "USBD.h" -#include - -//------------------------------------------------------------------------------ -// Exported function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Invoked when the USB device leaves the Suspended state. By default, -/// configures the LEDs. -//------------------------------------------------------------------------------ -void USBDCallbacks_Resumed(void) -{ - // Initialize LEDs - /* LED_Configure(USBD_LEDPOWER); - LED_Set(USBD_LEDPOWER); - LED_Configure(USBD_LEDUSB); - LED_Clear(USBD_LEDUSB); */ -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c b/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c deleted file mode 100644 index dd752bb3c..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDCallbacks.h" -#include "USBD.h" -#include - -//------------------------------------------------------------------------------ -// Exported function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Invoked when the USB device gets suspended. By default, turns off all LEDs. -//------------------------------------------------------------------------------ -void USBDCallbacks_Suspended(void) -{ - // Turn off LEDs - // LED_Clear(USBD_LEDPOWER); - // LED_Clear(USBD_LEDUSB); -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriverCb_CfgChanged.c b/src/ersky9x/libraries/usb/device/core/USBDDriverCb_CfgChanged.c deleted file mode 100644 index 08e2b2fa7..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDDriverCb_CfgChanged.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDDriverCallbacks.h" -#include - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Indicates that the current configuration of the device has changed. -/// \param cfgnum New device configuration index. -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - TRACE_INFO_WP("ConfigurationChanged "); -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c b/src/ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c deleted file mode 100644 index c9049e675..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBDDriverCallbacks.h" -#include - -//------------------------------------------------------------------------------ -// Global functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Notifies of a change in the currently active setting of an interface. -/// \param interface Number of the interface whose setting has changed. -/// \param setting New interface setting. -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_InterfaceSettingChanged( - unsigned char interface, - unsigned char setting) -{ - TRACE_INFO_WP("InterfaceSettingChanged "); -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBD_OTGHS.c b/src/ersky9x/libraries/usb/device/core/USBD_OTGHS.c deleted file mode 100644 index 3a8a02e67..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBD_OTGHS.c +++ /dev/null @@ -1,1696 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBD.h" -#include "USBDCallbacks.h" -#include "USBDDriver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Maximum number of endpoints interrupts. -#define NUM_IT_MAX \ - (AT91C_BASE_OTGHS->OTGHS_IPFEATURES & AT91C_OTGHS_EPT_NBR_MAX) -/// Maximum number of endpoint DMA interrupts -#define NUM_IT_MAX_DMA \ - ((AT91C_BASE_OTGHS->OTGHS_IPFEATURES & AT91C_OTGHS_DMA_CHANNEL_NBR)>>4) -/// Bits that should be shifted to access DMA control bits. -#define SHIFT_DMA 24 -/// Bits that should be shifted to access interrupt bits. -#define SHIFT_INTERUPT 12 - -/// Max size of the FMA FIFO -#define DMA_MAX_FIFO_SIZE 32768 - -#define EPT_VIRTUAL_SIZE 8192 - -//------------------------------------------------------------------------------ -/// \page "Endpoint states" -/// This page lists the endpoint states. -/// !States -// - UDP_ENDPOINT_DISABLED -// - UDP_ENDPOINT_HALTED -// - UDP_ENDPOINT_IDLE -// - UDP_ENDPOINT_SENDING -// - UDP_ENDPOINT_RECEIVING - -/// Endpoint states: Endpoint is disabled -#define UDP_ENDPOINT_DISABLED 0 -/// Endpoint states: Endpoint is halted (i.e. STALLs every request) -#define UDP_ENDPOINT_HALTED 1 -/// Endpoint states: Endpoint is idle (i.e. ready for transmission) -#define UDP_ENDPOINT_IDLE 2 -/// Endpoint states: Endpoint is sending data -#define UDP_ENDPOINT_SENDING 3 -/// Endpoint states: Endpoint is receiving data -#define UDP_ENDPOINT_RECEIVING 4 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Structures -//------------------------------------------------------------------------------ - -/// Describes an ongoing transfer on a UDP endpoint. -typedef struct -{ - /// Pointer to a data buffer used for emission/reception. - char *pData; - /// Number of bytes which have been written into the UDP internal FIFO - /// buffers. - volatile int buffered; - /// Number of bytes which have been sent/received. - volatile int transferred; - /// Number of bytes which have not been buffered/transferred yet. - volatile int remaining; - /// Optional callback to invoke when the transfer completes. - volatile TransferCallback fCallback; - /// Optional argument to the callback function. - void *pArgument; -} Transfer; - -//------------------------------------------------------------------------------ -/// Describes the state of an endpoint of the UDP controller. -//------------------------------------------------------------------------------ -typedef struct -{ - /// Current endpoint state. - volatile unsigned char state; - /// Current reception bank (0 or 1). - unsigned char bank; - /// Maximum packet size for the endpoint. - unsigned short size; - /// Describes an ongoing transfer (if current state is either - /// or ) - Transfer transfer; - /// Special case for send a ZLP - unsigned char sendZLP; -} Endpoint; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Holds the internal state for each endpoint of the UDP. -static Endpoint endpoints[CHIP_USB_NUMENDPOINTS]; -/// Device current state. -static unsigned char deviceState; -/// Indicates the previous device state -static unsigned char previousDeviceState; - -/// 7.1.20 Test Mode Support -/// Test codes for the USB HS test mode. -static const char test_packet_buffer[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // JKJKJKJK * 9 - 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, // JJKKJJKK * 8 - 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE, // JJJJKKKK * 8 - 0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // JJJJJJJKKKKKKK * 8 - 0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD, // JJJJJJJK * 8 - 0xFC,0x7E,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0x7E // {JKKKKKKK * 10}, JK -}; - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Enable UDPHS clock -//------------------------------------------------------------------------------ -static inline void OTGHS_EnableUsbClock( void ) -{ - -} - -//------------------------------------------------------------------------------ -/// Disable UDPHS clock -//------------------------------------------------------------------------------ -static inline void OTGHS_DisableUsbClock( void ) -{ - -} - -//------------------------------------------------------------------------------ -/// Enables the transceiver of the USB controller -//------------------------------------------------------------------------------ -static void OTGHS_EnableTransceiver(void) -{ - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_OTGPADE; -} - -//------------------------------------------------------------------------------ -/// Disables the transceiver of the USB controller associated with the specified -/// USB driver -//------------------------------------------------------------------------------ -static void OTGHS_DisableTransceiver(void) -{ - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_OTGPADE; -} - -//------------------------------------------------------------------------------ -/// Handles a completed transfer on the given endpoint, invoking the -/// configured callback if any. -/// \param bEndpoint Number of the endpoint for which the transfer has completed. -/// \param bStatus Status code returned by the transfer operation -//------------------------------------------------------------------------------ -static void OTGHS_EndOfTransfer( unsigned char bEndpoint, char bStatus ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - - // Check that endpoint was sending or receiving data - if( (pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING) ) { - - TRACE_DEBUG_WP("Eo"); - if(pEndpoint->state == UDP_ENDPOINT_SENDING) { - pEndpoint->sendZLP = 0; - } - // Endpoint returns in Idle state - pEndpoint->state = UDP_ENDPOINT_IDLE; - - // Invoke callback is present - if (pTransfer->fCallback != 0) { - - ((TransferCallback) pTransfer->fCallback) - (pTransfer->pArgument, - bStatus, - pTransfer->transferred, - pTransfer->remaining + pTransfer->buffered); - } - else { - TRACE_DEBUG_WP("No callBack\n\r"); - } - } -} - -//------------------------------------------------------------------------------ -/// Transfers a data payload from the current tranfer buffer to the endpoint -/// FIFO -/// \param bEndpoint Number of the endpoint which is sending data. -//------------------------------------------------------------------------------ -static void OTGHS_WritePayload( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - char *pFifo; - signed int size; - unsigned int dCtr; - - pFifo = (char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO + (EPT_VIRTUAL_SIZE * bEndpoint)); - - // Get the number of bytes to send - size = pEndpoint->size; - if (size > pTransfer->remaining) { - - size = pTransfer->remaining; - } - - // Update transfer descriptor information - pTransfer->buffered += size; - pTransfer->remaining -= size; - - // Write packet in the FIFO buffer - dCtr = 0; - while (size > 0) { - - pFifo[dCtr] = *(pTransfer->pData); - pTransfer->pData++; - size--; - dCtr++; - } -} - -//------------------------------------------------------------------------------ -/// Transfers a data payload from an endpoint FIFO to the current transfer buffer -/// \param bEndpoint Endpoint number. -/// \param wPacketSize Size of received data packet -//------------------------------------------------------------------------------ -static void OTGHS_ReadPayload( unsigned char bEndpoint, int wPacketSize ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - char *pFifo; - unsigned char dBytes=0; - - pFifo = (char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO + (EPT_VIRTUAL_SIZE * bEndpoint)); - - // Check that the requested size is not bigger than the remaining transfer - if (wPacketSize > pTransfer->remaining) { - - pTransfer->buffered += wPacketSize - pTransfer->remaining; - wPacketSize = pTransfer->remaining; - } - - // Update transfer descriptor information - pTransfer->remaining -= wPacketSize; - pTransfer->transferred += wPacketSize; - - // Retrieve packet - while (wPacketSize > 0) { - - *(pTransfer->pData) = pFifo[dBytes]; - pTransfer->pData++; - wPacketSize--; - dBytes++; - } -} - -//------------------------------------------------------------------------------ -/// Received SETUP packet from endpoint 0 FIFO -/// \param pRequest Generic USB SETUP request sent over Control endpoints -//------------------------------------------------------------------------------ -static void OTGHS_ReadRequest( USBGenericRequest *pRequest ) -{ - unsigned int *pData = (unsigned int *)pRequest; - unsigned int fifo; - - fifo = (AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0[0]); - *pData = fifo; - fifo = (AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0[0]); - pData++; - *pData = fifo; - //TRACE_ERROR("SETUP: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n\r", pData[0],pData[1],pData[2],pData[3],pData[4],pData[5],pData[6],pData[7]); -} - -//------------------------------------------------------------------------------ -/// Reset all endpoint transfer descriptors -//------------------------------------------------------------------------------ -static void OTGHS_ResetEndpoints( void ) -{ - Endpoint *pEndpoint; - Transfer *pTransfer; - - unsigned char bEndpoint; - - // Reset the transfer descriptor of every endpoint - for( bEndpoint = 0; bEndpoint < CHIP_USB_NUMENDPOINTS; bEndpoint++ ) { - - pEndpoint = &(endpoints[bEndpoint]); - pTransfer = &(pEndpoint->transfer); - - // Reset endpoint transfer descriptor - pTransfer->pData = 0; - pTransfer->transferred = -1; - pTransfer->buffered = -1; - pTransfer->remaining = -1; - pTransfer->fCallback = 0; - pTransfer->pArgument = 0; - - // Reset endpoint state - pEndpoint->bank = 0; - pEndpoint->state = UDP_ENDPOINT_DISABLED; - // Reset ZLP - pEndpoint->sendZLP = 0; - } -} - - -//------------------------------------------------------------------------------ -/// Disable all endpoints (except control endpoint 0), aborting current -/// transfers if necessary -//------------------------------------------------------------------------------ -static void OTGHS_DisableEndpoints( void ) -{ - unsigned char bEndpoint; - - // Disable each endpoint, terminating any pending transfer - - - // Control endpoint 0 is not disabled - for( bEndpoint = 1; bEndpoint < CHIP_USB_NUMENDPOINTS; bEndpoint++ ) { - - OTGHS_EndOfTransfer( bEndpoint, USBD_STATUS_ABORTED ); - endpoints[bEndpoint].state = UDP_ENDPOINT_DISABLED; - } -} - - -//------------------------------------------------------------------------------ -/// Endpoint interrupt handler. -/// Handle IN/OUT transfers, received SETUP packets and STALLing -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -static void OTGHS_EndpointHandler( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - unsigned int status = AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[bEndpoint]; - unsigned short wPacketSize; - USBGenericRequest request; - - TRACE_DEBUG_WP("E%d ", bEndpoint); - TRACE_DEBUG_WP("st:0x%X ", status); - - // Handle interrupts - // IN packet sent - if((AT91C_BASE_OTGHS->OTGHS_DEVEPTIMR[bEndpoint] & AT91C_OTGHS_TXINI) - && (status & AT91C_OTGHS_TXINI )) { - - TRACE_DEBUG_WP("Wr "); - - // Check that endpoint was in Sending state - if( pEndpoint->state == UDP_ENDPOINT_SENDING ) { - - if (pTransfer->buffered > 0) { - pTransfer->transferred += pTransfer->buffered; - pTransfer->buffered = 0; - } - - if( ((pTransfer->buffered)==0) - &&((pTransfer->transferred)==0) - &&((pTransfer->remaining)==0) - &&(pEndpoint->sendZLP == 0)) { - pEndpoint->sendZLP = 1; - } - - // End of transfer ? - if( (pTransfer->remaining > 0) - ||(pEndpoint->sendZLP == 1)) { - - pEndpoint->sendZLP = 2; - // Transfer remaining data - TRACE_DEBUG_WP(" %d ", pEndpoint->size); - // Send next packet - OTGHS_WritePayload(bEndpoint); - - // Send Token IN - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_TXINI; - // For a non-control endpoint, the FIFOCON bit must be cleared - // to start the transfer - if ((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - != AT91C_OTGHS_EPT_TYPE_CTL_EPT) { - // Send IN - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_FIFOCON; - } - } - else { - - TRACE_DEBUG_WP("\n\r0pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("0pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("0pTransfer->remaining %d \n\r", pTransfer->remaining); - - TRACE_DEBUG_WP(" %d ", pTransfer->transferred); - - // Disable interrupt if this is not a control endpoint - if ((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - != AT91C_OTGHS_EPT_TYPE_CTL_EPT) { - - AT91C_BASE_OTGHS->OTGHS_DEVIDR = 1<OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_TXINI; - OTGHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - pEndpoint->sendZLP = 0; - } - } - else { - TRACE_DEBUG("Error Wr %d", pEndpoint->sendZLP); - } - } - - // OUT packet received - if( AT91C_OTGHS_RXOUT == (status & AT91C_OTGHS_RXOUT) ) { - - // Check that the endpoint is in Receiving state - if (pEndpoint->state != UDP_ENDPOINT_RECEIVING) { - - // Check if an ACK has been received on a Control endpoint - if( ((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - == AT91C_OTGHS_EPT_TYPE_CTL_EPT) - && (0 == (status & AT91C_OTGHS_BYCT)) ) { - - // Control endpoint, 0 bytes received - // Acknowledge the data and finish the current transfer - TRACE_DEBUG_WP("Ack "); - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_RXOUT; - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_RXOUT; - //OTGHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - } - // Check if the data has been STALLed - else if( AT91C_OTGHS_STALL == (status & AT91C_OTGHS_STALL)) { - - // Discard STALLed data - TRACE_DEBUG_WP("Discard "); - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_RXOUT; - } - else { - // NAK the data - TRACE_DEBUG_WP("Nak "); - AT91C_BASE_OTGHS->OTGHS_DEVIDR = 1<> 20) & 0x7FF); - - //TRACE_ERROR_WP("out:%d ", wPacketSize); - OTGHS_ReadPayload(bEndpoint, wPacketSize); - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_RXOUT; - if((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - != AT91C_OTGHS_EPT_TYPE_CTL_EPT) { - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_FIFOCON; - } - - // Check if the transfer is finished - if ((pTransfer->remaining == 0) || (wPacketSize < pEndpoint->size)) { - - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_RXOUT; - - // Disable interrupt if this is not a control endpoint - if ((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - != AT91C_OTGHS_EPT_TYPE_CTL_EPT) { - - AT91C_BASE_OTGHS->OTGHS_DEVIDR = 1<OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_STALL; - - // If the endpoint is not halted, clear the STALL condition - if (pEndpoint->state != UDP_ENDPOINT_HALTED) { - - TRACE_WARNING("_ " ); - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_STALLRQ; - } - } - - // SETUP packet received - if( AT91C_OTGHS_RXSTP == (status & AT91C_OTGHS_RXSTP) ) { - - TRACE_DEBUG_WP("Stp "); - - // If a transfer was pending, complete it - // Handles the case where during the status phase of a control write - // transfer, the host receives the device ZLP and ack it, but the ack - // is not received by the device - if ((pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING)) { - - OTGHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - } - - // Copy the setup packet - OTGHS_ReadRequest(&request); - - // Acknowledge setup packet - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_RXSTP; - - // Forward the request to the upper layer - USBDCallbacks_RequestReceived(&request); - } -} - -//------------------------------------------------------------------------------ -// Interrupt service routine -//------------------------------------------------------------------------------ -#ifdef DMA -//---------------------------------------------------------------------------- -/// Endpoint DMA interrupt handler. -/// This function (ISR) handles dma interrupts -/// \param bEndpoint Index of endpoint -//---------------------------------------------------------------------------- -static void OTGHS_DmaHandler( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - int justTransferred; - unsigned int status; - unsigned char result = USBD_STATUS_SUCCESS; - - status = AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMASTATUS; - TRACE_DEBUG_WP("Dma Ept%d ", bEndpoint); - - // Disable DMA interrupt to avoid receiving 2 interrupts (B_EN and TR_EN) - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL &= - ~(unsigned int)(AT91C_OTGHS_END_TR_EN | AT91C_OTGHS_END_B_EN); - - AT91C_BASE_OTGHS->OTGHS_DEVIDR = (1<buffered - - ((status & (unsigned int)AT91C_OTGHS_BUFF_COUNT) >> 16); - pTransfer->transferred += justTransferred; - - pTransfer->buffered = ((status & (unsigned int)AT91C_OTGHS_BUFF_COUNT) >> 16); - - pTransfer->remaining -= justTransferred; - - TRACE_DEBUG_WP("\n\r1pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("1pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("1pTransfer->remaining %d \n\r", pTransfer->remaining); - - if( (pTransfer->remaining + pTransfer->buffered) > 0 ) { - - // Prepare an other transfer - if( pTransfer->remaining > DMA_MAX_FIFO_SIZE ) { - - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - pTransfer->buffered = pTransfer->remaining; - } - - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMAADDRESS = - (unsigned int)((pTransfer->pData) + (pTransfer->transferred)); - - // Clear unwanted interrupts - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMASTATUS; - - // Enable DMA endpoint interrupt - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1 << SHIFT_DMA << bEndpoint); - // DMA config for receive the good size of buffer, or an error buffer - - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = 0; // raz - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = - ( ((pTransfer->buffered << 16) & AT91C_OTGHS_BUFF_COUNT) - | AT91C_OTGHS_END_TR_EN - | AT91C_OTGHS_END_TR_IT - | AT91C_OTGHS_END_B_EN - | AT91C_OTGHS_END_BUFFIT - | AT91C_OTGHS_CHANN_ENB ); - } - } - else if( AT91C_OTGHS_END_TR_ST == (status & AT91C_OTGHS_END_TR_ST) ) { - - TRACE_DEBUG_WP("EndTransf "); - - pTransfer->transferred = pTransfer->buffered - - ((status & (unsigned int)AT91C_OTGHS_BUFF_COUNT) >> 16); - pTransfer->remaining = 0; - TRACE_DEBUG_WP("\n\r0pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("0pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("0pTransfer->remaining %d \n\r", pTransfer->remaining); - } - else { - - TRACE_ERROR("OTGHS_DmaHandler: Error (0x%08X)\n\r", status); - result = USBD_STATUS_ABORTED; - } - - // Invoke callback - if( pTransfer->remaining == 0 ) { - - TRACE_DEBUG_WP("EOT "); - OTGHS_EndOfTransfer(bEndpoint, result); - } -} -#endif - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USB device interrupt handler -/// Manages device resume, suspend, end of bus reset. -/// Forwards endpoint interrupts to the appropriate handler. -//------------------------------------------------------------------------------ -void USBD_IrqHandler(void) -{ - unsigned int status; - unsigned char numIT; - - if (deviceState >= USBD_STATE_POWERED) { - - LED_Set(USBD_LEDUSB); - } - -#ifndef OTG_PROJECT - // Get interrupts status - status = AT91C_BASE_OTGHS->OTGHS_SR & AT91C_BASE_OTGHS->OTGHS_CTRL & 0xFF; - while (status != 0) { - //TRACE_ERROR_WP("~"); - if((status&AT91C_OTGHS_VBUSTI)==AT91C_OTGHS_VBUSTI) { - TRACE_DEBUG_WP("__VBus\n\r"); - - USBD_Connect(); - - // Acknowledge the interrupt - AT91C_BASE_OTGHS->OTGHS_SCR = AT91C_OTGHS_VBUSTI; - } - - // Don't treat others interrupt for this time - AT91C_BASE_OTGHS->OTGHS_SCR = AT91C_OTGHS_IDT | AT91C_OTGHS_SRP - | AT91C_OTGHS_VBERR | AT91C_OTGHS_BCERR - | AT91C_OTGHS_ROLEEX | AT91C_OTGHS_HNPERR - | AT91C_OTGHS_STO; - - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_IDT; - - status = AT91C_BASE_OTGHS->OTGHS_SR & AT91C_BASE_OTGHS->OTGHS_CTRL & 0xFF; - } -#endif - - // Get OTG Device interrupts status - status = AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_BASE_OTGHS->OTGHS_DEVIMR; - //TRACE_ERROR_WP("S=0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_DEVISR ); - //TRACE_ERROR_WP("M=0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_DEVIMR ); - while (status != 0) { - //TRACE_ERROR_WP("="); - // Start Of Frame (SOF) - if((status&AT91C_OTGHS_SOF)==AT91C_OTGHS_SOF) { - TRACE_DEBUG_WP("SOF "); - - // Invoke the SOF callback - //USB_StartOfFrameCallback(); - - // Acknowledge interrupt - AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_SOF; - status &= ~(unsigned int)AT91C_OTGHS_SOF; - } - - // Suspend - // This interrupt is always treated last (hence the '==') - else if (status == AT91C_OTGHS_SUSP) { - - TRACE_DEBUG_WP("S"); - - // The device enters the Suspended state - // MCK + UDPCK must be off - // Pull-Up must be connected - // Transceiver must be disabled - - LED_Clear(USBD_LEDUSB); - - // Enable wakeup - AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_EORST | AT91C_OTGHS_WAKEUP | AT91C_OTGHS_EORSM; - - // Acknowledge interrupt - AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_SUSP; - previousDeviceState = deviceState; - deviceState = USBD_STATE_SUSPENDED; - OTGHS_DisableTransceiver(); - OTGHS_DisableUsbClock(); - // Invoke the Suspend callback - USBDCallbacks_Suspended(); - } - - // Resume - else if( ((status & AT91C_OTGHS_WAKEUP) != 0) // line activity - || ((status & AT91C_OTGHS_EORSM) != 0)) { // pc wakeup - - // Invoke the Resume callback - USBDCallbacks_Resumed(); - - TRACE_DEBUG_WP("R"); - - OTGHS_EnableUsbClock(); - OTGHS_EnableTransceiver(); - - // The device enters Configured state - // MCK + UDPCK must be on - // Pull-Up must be connected - // Transceiver must be enabled - - deviceState = previousDeviceState; - - AT91C_BASE_OTGHS->OTGHS_DEVICR = - (AT91C_OTGHS_WAKEUP | AT91C_OTGHS_EORSM | AT91C_OTGHS_SUSP); - AT91C_BASE_OTGHS->OTGHS_DEVIER = (AT91C_OTGHS_EORST | AT91C_OTGHS_SUSP); - AT91C_BASE_OTGHS->OTGHS_DEVICR = (AT91C_OTGHS_WAKEUP | AT91C_OTGHS_EORSM); - AT91C_BASE_OTGHS->OTGHS_DEVIDR = AT91C_OTGHS_WAKEUP; - - } - - // End of bus reset - else if ((status & AT91C_OTGHS_EORST) == AT91C_OTGHS_EORST) { - - TRACE_DEBUG_WP("EoB "); - - // The device enters the Default state - deviceState = USBD_STATE_DEFAULT; - // MCK + UDPCK are already enabled - // Pull-Up is already connected - // Transceiver must be enabled - // Endpoint 0 must be enabled - - OTGHS_EnableTransceiver(); - USBDDriver_clearOTGFeatures(); - - // The device leaves the Address & Configured states - OTGHS_ResetEndpoints(); - OTGHS_DisableEndpoints(); - USBD_ConfigureEndpoint(0); - - // Flush and enable the Suspend interrupt - AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_WAKEUP | AT91C_OTGHS_SUSP; - - //// Enable the Start Of Frame (SOF) interrupt if needed - //if (pCallbacks->startOfFrame != 0) - //{ - // AT91C_BASE_OTGHS->OTGHS_DEVIER |= AT91C_OTGHS_SOF; - //} - - // Invoke the Reset callback - USBDCallbacks_Reset(); - - // Acknowledge end of bus reset interrupt - AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_EORST; - } - - // Handle upstream resume interrupt - else if (status & AT91C_OTGHS_UPRSM) { - - TRACE_DEBUG_WP("ExtRes "); - - // - Acknowledge the IT - AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_UPRSM; - } - - // Endpoint interrupts - else { -#ifndef DMA - - // Handle endpoint interrupts - for (numIT = 0; numIT < NUM_IT_MAX; numIT++) { - - if ((status & (1 << SHIFT_INTERUPT << numIT)) != 0) { - - OTGHS_EndpointHandler(numIT); - } - } -#else - // Handle endpoint control interrupt - if ((status & (1 << SHIFT_INTERUPT << 0)) != 0) { - - OTGHS_EndpointHandler( 0 ); - } - else { - - numIT = 1; - while((status&(0x7E<OTGHS_DEVISR & AT91C_BASE_OTGHS->OTGHS_DEVIMR; - - TRACE_DEBUG_WP("\n\r"); - - if (status != 0) { - - TRACE_DEBUG_WP(" - "); - } - } - - if (deviceState >= USBD_STATE_POWERED) { - - LED_Clear(USBD_LEDUSB); - } -} - -//------------------------------------------------------------------------------ -/// Configure an endpoint with the provided endpoint descriptor -/// \param pDdescriptor Pointer to the endpoint descriptor -//------------------------------------------------------------------------------ -void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor) - -{ - Endpoint *pEndpoint; - unsigned char bEndpoint; - unsigned char bType; - unsigned char bEndpointDir; - unsigned char bSizeEpt = 0; - - // NULL descriptor -> Control endpoint 0 - if (pDescriptor == 0) { - - bEndpoint = 0; - pEndpoint = &(endpoints[bEndpoint]); - bType = USBEndpointDescriptor_CONTROL; - bEndpointDir = 0; - pEndpoint->size = CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0); - pEndpoint->bank = CHIP_USB_ENDPOINTS_BANKS(0); - } - else { - - // The endpoint number - bEndpoint = USBEndpointDescriptor_GetNumber(pDescriptor); - pEndpoint = &(endpoints[bEndpoint]); - // Transfer type: Control, Isochronous, Bulk, Interrupt - bType = USBEndpointDescriptor_GetType(pDescriptor); - // Direction, ignored for control endpoints - bEndpointDir = USBEndpointDescriptor_GetDirection(pDescriptor); - pEndpoint->size = USBEndpointDescriptor_GetMaxPacketSize(pDescriptor); - pEndpoint->bank = CHIP_USB_ENDPOINTS_BANKS(bEndpoint); - } - - // Abort the current transfer is the endpoint was configured and in - // Write or Read state - if( (pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING) ) { - - OTGHS_EndOfTransfer(bEndpoint, USBD_STATUS_RESET); - } - pEndpoint->state = UDP_ENDPOINT_IDLE; - - // Disable endpoint - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_TXINI - | AT91C_OTGHS_RXOUT - | AT91C_OTGHS_RXSTP - | AT91C_OTGHS_NAKOUT - | AT91C_OTGHS_NAKIN - | AT91C_OTGHS_OVERFL - | AT91C_OTGHS_STALL - | AT91C_OTGHS_SHRTPACK - | AT91C_OTGHS_MADATA - | AT91C_OTGHS_DATAX - | AT91C_OTGHS_ERRTRANS - | AT91C_OTGHS_NBUSYBK - | AT91C_OTGHS_FIFOCON - | AT91C_OTGHS_EPDISHDMA - | AT91C_OTGHS_NYETDIS - | AT91C_OTGHS_STALLRQ; - - // Reset Endpoint Fifos - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= (1<OTGHS_DEVEPT &= ~(1<size <= 8 ) { - bSizeEpt = 0; - } - else if ( pEndpoint->size <= 16 ) { - bSizeEpt = 1; - } - else if ( pEndpoint->size <= 32 ) { - bSizeEpt = 2; - } - else if ( pEndpoint->size <= 64 ) { - bSizeEpt = 3; - } - else if ( pEndpoint->size <= 128 ) { - bSizeEpt = 4; - } - else if ( pEndpoint->size <= 256 ) { - bSizeEpt = 5; - } - else if ( pEndpoint->size <= 512 ) { - bSizeEpt = 6; - } - else if ( pEndpoint->size <= 1024 ) { - bSizeEpt = 7; - } //else { - // sizeEpt = 0; // control endpoint - //} - - // Enable endpoint - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= (1<OTGHS_DEVIER = 1<OTGHS_DEVEPTCFG[bEndpoint] = (bSizeEpt << 4) - | (bEndpointDir << 8) - | (bType << 11) - | (((pEndpoint->bank)-1) << 2); - - if (bType == USBEndpointDescriptor_CONTROL) { - - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_RXSTP; - } -#ifdef DMA - else { - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint] |= AT91C_OTGHS_AUTOSW; - } -#endif - - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_NYETDIS;// with nyet - //AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_NYETDIS; // without nyet - - // Check if the configuration is ok - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint] |= AT91C_OTGHS_ALLOC; - if((AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[bEndpoint]&AT91C_OTGHS_CFGOK)==0) { - - TRACE_ERROR("PB bEndpoint: 0x%X\n\r", bEndpoint); - TRACE_ERROR("PB bSizeEpt: 0x%X\n\r", bSizeEpt); - TRACE_ERROR("PB bEndpointDir: 0x%X\n\r", bEndpointDir); - TRACE_ERROR("PB bType: 0x%X\n\r", bType); - TRACE_ERROR("PB pEndpoint->bank: 0x%X\n\r", pEndpoint->bank); - TRACE_ERROR("PB OTGHS_EPTCFG: 0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]); - for(;;); - } -} - -//------------------------------------------------------------------------------ -/// Sends data through an USB endpoint (IN) -/// Sets up the transfer descriptor, write one or two data payloads -/// (depending on the number of FIFO banks for the endpoint) and then -/// starts the actual transfer. The operation is complete when all -/// the data has been sent. -/// \param bEndpoint Index of endpoint -/// \param *pData Data to be written -/// \param dLength Data length to be send -/// \param fCallback Callback to be call after the success command -/// \param *pArgument Callback argument -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -char USBD_Write( unsigned char bEndpoint, - const void *pData, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); -//unsigned char i; -//unsigned char * data; - - // Return if the endpoint is not in IDLE state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Write%d(%d) ", bEndpoint, dLength); - pEndpoint->sendZLP = 0; - // Setup the transfer descriptor - pTransfer->pData = (void *) pData; - pTransfer->remaining = dLength; - pTransfer->buffered = 0; - pTransfer->transferred = 0; - pTransfer->fCallback = fCallback; - pTransfer->pArgument = pArgument; - - // Send one packet - pEndpoint->state = UDP_ENDPOINT_SENDING; - -#ifdef DMA - // Test if endpoint type control - if (AT91C_OTGHS_EPT_TYPE_CTL_EPT == (AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint])) { -#endif - // Enable endpoint IT - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1<OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_TXINI; - -#ifdef DMA - } - else { - if( CHIP_USB_ENDPOINTS_DMA(bEndpoint) == 0 ) { - TRACE_FATAL("Endpoint has no DMA\n\r"); - } - if( pTransfer->remaining == 0 ) { - - // DMA not handle ZLP - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_TXINI; - // For a non-control endpoint, the FIFOCON bit must be cleared - // to start the transfer - if ((AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]) - != AT91C_OTGHS_EPT_TYPE_CTL_EPT) { - - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_FIFOCON; - } - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_TXINI; - - // Enable endpoint IT - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1<remaining > DMA_MAX_FIFO_SIZE ) { - - // Transfer the max - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - // Transfer the good size - pTransfer->buffered = pTransfer->remaining; - } - - TRACE_DEBUG_WP("\n\r_WR:%d ", pTransfer->remaining ); - TRACE_DEBUG_WP("B:%d ", pTransfer->buffered ); - TRACE_DEBUG_WP("T:%d ", pTransfer->transferred ); - - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMAADDRESS = (unsigned int)(pTransfer->pData); - - // Clear unwanted interrupts - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMASTATUS; - - // Enable DMA endpoint interrupt - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1<OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = 0; // raz - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = - (((pTransfer->buffered<<16)&AT91C_OTGHS_BUFF_LENGTH) - | AT91C_OTGHS_END_B_EN - | AT91C_OTGHS_END_BUFFIT - | AT91C_OTGHS_CHANN_ENB); - } - } -#endif - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Reads incoming data on an USB endpoint (OUT) -/// \param bEndpoint Index of endpoint -/// \param *pData Data to be readen -/// \param dLength Data length to be receive -/// \param fCallback Callback to be call after the success command -/// \param *pArgument Callback argument -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -char USBD_Read( unsigned char bEndpoint, - void *pData, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = &(pEndpoint->transfer); - - // Return if the endpoint is not in IDLE state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Read%d(%d) ", bEndpoint, dLength); - //TRACE_ERROR_WP("Read%d(%d) ", bEndpoint, dLength); - - // Endpoint enters Receiving state - pEndpoint->state = UDP_ENDPOINT_RECEIVING; - - // Set the transfer descriptor - pTransfer->pData = pData; - pTransfer->remaining = dLength; - pTransfer->buffered = 0; - pTransfer->transferred = 0; - pTransfer->fCallback = fCallback; - pTransfer->pArgument = pArgument; - -#ifdef DMA - // Test if endpoint type control - if (AT91C_OTGHS_EPT_TYPE_CTL_EPT == (AT91C_OTGHS_EPT_TYPE & AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint])) { -#endif - // Control endpoint - // Enable endpoint IT - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1<OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_RXOUT; -#ifdef DMA - } - else { - if( CHIP_USB_ENDPOINTS_DMA(bEndpoint) == 0 ) { - TRACE_FATAL("Endpoint has no DMA\n\r"); - } - TRACE_DEBUG_WP("Read%d(%d) ", bEndpoint, dLength); - - // Others endpoints (not control) - if( pTransfer->remaining > DMA_MAX_FIFO_SIZE ) { - - // Transfer the max - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - // Transfer the good size - pTransfer->buffered = pTransfer->remaining; - } - - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMAADDRESS = (unsigned int)(pTransfer->pData); - - // Clear unwanted interrupts - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMASTATUS; - - // Enable DMA endpoint interrupt - AT91C_BASE_OTGHS->OTGHS_DEVIER = (1<remaining ); - TRACE_DEBUG_WP("B:%d ", pTransfer->buffered ); - TRACE_DEBUG_WP("T:%d ", pTransfer->transferred ); - - // DMA config - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = 0; // raz - AT91C_BASE_OTGHS->OTGHS_DEVDMA[bEndpoint].OTGHS_DEVDMACONTROL = - (((pTransfer->buffered<<16)&AT91C_OTGHS_BUFF_LENGTH) - | AT91C_OTGHS_END_TR_EN - | AT91C_OTGHS_END_TR_IT - | AT91C_OTGHS_END_B_EN - | AT91C_OTGHS_END_BUFFIT - | AT91C_OTGHS_CHANN_ENB); - } -#endif - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Put endpoint into Halt state -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -void USBD_Halt( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - - TRACE_INFO("usbd_Halt%d ", bEndpoint); - //TRACE_ERROR("usbd_Halt%d ", bEndpoint); - - // Check that endpoint is enabled and not already in Halt state - if( (pEndpoint->state != UDP_ENDPOINT_DISABLED) - && (pEndpoint->state != UDP_ENDPOINT_HALTED) ) { - - TRACE_INFO("Halt%d ", bEndpoint); - - // Abort the current transfer if necessary - OTGHS_EndOfTransfer(bEndpoint, USBD_STATUS_ABORTED); - - pEndpoint->state = UDP_ENDPOINT_HALTED; - // Put endpoint into Halt state - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_STALLRQ; - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_STALL; - } -} - -//------------------------------------------------------------------------------ -/// Clears the Halt feature on the given endpoint. -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -void USBD_Unhalt( unsigned char bEndpoint ) -{ - unsigned int cfgSav; - - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - - // Check if the endpoint is enabled - if (pEndpoint->state != UDP_ENDPOINT_DISABLED) { - - TRACE_DEBUG_WP("Unhalt%d ", bEndpoint); - //TRACE_ERROR("Unhalt%d ", bEndpoint); - - // Return endpoint to Idle state - pEndpoint->state = UDP_ENDPOINT_IDLE; - - cfgSav = AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[bEndpoint]; - - // Reset Endpoint Fifos - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= (1<OTGHS_DEVEPT &= ~(1<OTGHS_DEVEPTCFG[bEndpoint] = cfgSav; - - if((AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[bEndpoint]&AT91C_OTGHS_CFGOK)==0) { - - TRACE_ERROR("PB bEndpoint: 0x%X\n\r", bEndpoint); - for(;;); - } - - // Reset data-toggle - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_RSTDT; - - // Clear FORCESTALL flag - // Disable stall on endpoint - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[bEndpoint] = AT91C_OTGHS_STALLRQ; - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[bEndpoint] = AT91C_OTGHS_STALL; - } -} - -//------------------------------------------------------------------------------ -/// Returns the current Halt status of an endpoint. -/// \param bEndpoint Index of endpoint -/// \return 1 if the endpoint is currently halted; otherwise 0 -//------------------------------------------------------------------------------ -unsigned char USBD_IsHalted( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - unsigned char status = 0; - - if (pEndpoint->state == UDP_ENDPOINT_HALTED) { - status = 1; - } - return( status ); -} - -//------------------------------------------------------------------------------ -/// IS High Speed device working in High Speed ? -/// \return 1 if the device is in High Speed; otherwise 0 (Full Speed) -//------------------------------------------------------------------------------ -unsigned char USBD_IsHighSpeed( void ) -{ - unsigned char status = 0; - - if(AT91C_OTGHS_SPEED_SR_HS == (AT91C_BASE_OTGHS->OTGHS_SR & (0x03<<12))) { - // High Speed - TRACE_DEBUG_WP("High Speed\n\r"); - status = 1; - } - else { - TRACE_DEBUG_WP("Full Speed\n\r"); - } - return( status ); -} - -//------------------------------------------------------------------------------ -/// Causes the endpoint to acknowledge the next received packet with a STALL -/// handshake. -/// Further packets are then handled normally. -/// \param bEndpoint Index of endpoint -/// \return Operation result code: USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char USBD_Stall( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - - // Check that endpoint is in Idle state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - TRACE_WARNING("UDP_Stall: Endpoint%d locked\n\r", bEndpoint); - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Stall%d ", bEndpoint); - - // Sends a STALL handshake for the next host request. - // A STALL handshake will be sent for each following request until a SETUP - // or a Clear Halt Feature occurs for this endpoint. - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[bEndpoint] = AT91C_OTGHS_STALLRQ|AT91C_OTGHS_RXSTP; - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Activates a remote wakeup procedure -//------------------------------------------------------------------------------ -void USBD_RemoteWakeUp(void) -{ - TRACE_DEBUG_WP("Remote WakeUp\n\r"); - - // Device is currently suspended - if (deviceState == USBD_STATE_SUSPENDED) { - - TRACE_DEBUG_WP("RW\n\r"); - OTGHS_EnableUsbClock(); - OTGHS_EnableTransceiver(); - - // Activates a remote wakeup - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_RMWKUP; - } - // Device is NOT suspended - else { - - TRACE_WARNING("USBD_RemoteWakeUp: Device is not suspended\n\r"); - } -} - -//------------------------------------------------------------------------------ -/// Sets the device address -/// \param address Adress to be set -//------------------------------------------------------------------------------ -void USBD_SetAddress( unsigned char address ) -{ - TRACE_DEBUG_WP("SetAddr(%d) ", address); - - // Set address - AT91C_BASE_OTGHS->OTGHS_DEVCTRL &= ~(unsigned int)AT91C_OTGHS_UADD; - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= address & AT91C_OTGHS_UADD; - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_ADDEN; - - // If the address is 0, the device returns to the Default state - if (address == 0) { - deviceState = USBD_STATE_DEFAULT; - } - // If the address is non-zero, the device enters the Address state - else { - deviceState = USBD_STATE_ADDRESS; - } -} - -//------------------------------------------------------------------------------ -/// Changes the device state from Address to Configured, or from Configured -/// to Address. -/// This method directly access the last received SETUP packet to decide on -/// what to do. -/// \param cfgnum configuration number -//------------------------------------------------------------------------------ -void USBD_SetConfiguration( unsigned char cfgnum ) -{ - TRACE_DEBUG_WP("SetCfg(%d) ", cfgnum); - - // Check the request - if( cfgnum != 0 ) { - - // Enter Configured state - deviceState = USBD_STATE_CONFIGURED; - } - // If the configuration number is zero, the device goes back to the Address - // state - else { - - // Go back to Address state - deviceState = USBD_STATE_ADDRESS; - - // Abort all transfers - OTGHS_DisableEndpoints(); - } -} - - -//------------------------------------------------------------------------------ -/// Enables the pull-up on the D+ line to connect the device to the USB. -//------------------------------------------------------------------------------ -void USBD_Connect( void ) -{ - TRACE_DEBUG_WP("Conn "); -#if defined(CHIP_USB_PULLUP_INTERNAL) - AT91C_BASE_OTGHS->OTGHS_DEVCTRL &= ~(unsigned int)AT91C_OTGHS_DETACH; -#else - #error "not defined" -#endif -} - -//------------------------------------------------------------------------------ -/// Disables the pull-up on the D+ line to disconnect the device from the bus. -//------------------------------------------------------------------------------ -void USBD_Disconnect( void ) -{ - TRACE_DEBUG_WP("Disc "); -#if defined(CHIP_USB_PULLUP_INTERNAL) - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_DETACH; - -#else - #error "not defined" -#endif - // Device returns to the Powered state - if (deviceState > USBD_STATE_POWERED) { - - deviceState = USBD_STATE_POWERED; - } -} - -//------------------------------------------------------------------------------ -/// Certification test for High Speed device. -/// \param bIndex Test to be done -//------------------------------------------------------------------------------ -void USBD_Test( unsigned char bIndex ) -{ - char *pFifo; - unsigned char i; - - AT91C_BASE_OTGHS->OTGHS_DEVIDR &= ~(unsigned int)AT91C_OTGHS_SUSP; - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_SPDCONF_HS; // remove suspend ? - - switch( bIndex ) { - case USBFeatureRequest_TESTPACKET: - TRACE_DEBUG_WP("TEST_PACKET "); - - AT91C_BASE_OTGHS->OTGHS_DEVDMA[1].OTGHS_DEVDMACONTROL = 0; // raz - AT91C_BASE_OTGHS->OTGHS_DEVDMA[2].OTGHS_DEVDMACONTROL = 0; // raz - - // Configure endpoint 2, 64 bytes, direction IN, type BULK, 1 bank - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[2] = AT91C_OTGHS_EPT_SIZE_64 - | AT91C_OTGHS_EPT_DIR_IN - | AT91C_OTGHS_EPT_TYPE_BUL_EPT - | AT91C_OTGHS_BK_NUMBER_1; - // Check if the configuration is ok - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[2] |= AT91C_OTGHS_ALLOC; - while((AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[2]&AT91C_OTGHS_CFGOK)==0) { - } - - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= AT91C_OTGHS_EPEN2; - - // Write FIFO - pFifo = (char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO + (EPT_VIRTUAL_SIZE * 2)); - for( i=0; iOTGHS_DEVCTRL |= AT91C_OTGHS_TSTPCKT; - // Send packet - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[2] = AT91C_OTGHS_TXINI; - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[2] = AT91C_OTGHS_FIFOCON; - break; - - case USBFeatureRequest_TESTJ: - TRACE_DEBUG_WP("TEST_J "); - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_TSTJ; - break; - - case USBFeatureRequest_TESTK: - TRACE_DEBUG_WP("TEST_K "); - AT91C_BASE_OTGHS->OTGHS_DEVCTRL |= AT91C_OTGHS_TSTK; - break; - - case USBFeatureRequest_TESTSE0NAK: - TRACE_DEBUG_WP("TEST_SEO_NAK "); - AT91C_BASE_OTGHS->OTGHS_DEVIDR = 0xFFFFFFFF; - break; - - case USBFeatureRequest_TESTSENDZLP: - //while( 0 != (AT91C_BASE_UDPHS->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_TX_PK_RDY ) ) {} - AT91C_BASE_OTGHS->OTGHS_DEVEPTICR[0] = AT91C_OTGHS_TXINI; - //while( 0 != (AT91C_BASE_UDPHS->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_TX_PK_RDY ) ) {} - TRACE_DEBUG_WP("SEND_ZLP "); - break; - } - TRACE_DEBUG_WP("\n\r"); -} - -//------------------------------------------------------------------------------ -/// Initializes the specified USB driver -/// This function initializes the current FIFO bank of endpoints, -/// configures the pull-up and VBus lines, disconnects the pull-up and -/// then trigger the Init callback. -//------------------------------------------------------------------------------ -void USBD_Init(void) -{ - // forceFS must not be used ! - unsigned int i; - - TRACE_DEBUG_WP("USBD Init()\n\r"); - - // Enable USB macro - *AT91C_OTGHS_CTRL |= AT91C_OTGHS_USBECTRL; - - // Automatic mode speed for device - *AT91C_OTGHS_DEVCTRL &= ~(unsigned int)AT91C_OTGHS_SPDCONF_FS; // Normal mode - - *AT91C_OTGHS_DEVCTRL &= ~(unsigned int)( AT91C_OTGHS_LS | AT91C_OTGHS_TSTJ - | AT91C_OTGHS_TSTK | AT91C_OTGHS_TSTPCKT - | AT91C_OTGHS_OPMODE2 ); // Normal mode - - AT91C_BASE_OTGHS->OTGHS_DEVCTRL = 0; - AT91C_BASE_OTGHS->OTGHS_HSTCTRL = 0; - - // Enable OTG pad - *AT91C_OTGHS_CTRL |= AT91C_OTGHS_OTGPADE; - - // Enable clock OTG pad - *AT91C_OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_FRZCLKCTRL; - - //Usb_disable(); - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_USBECTRL; - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_OTGPADE; - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_FRZCLKCTRL; - //Usb_enable(); - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_USBECTRL; - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_OTGPADE; - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_FRZCLKCTRL; - //Usb_select_device(); - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_UIDE; - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_UIMOD; - - // Device is in the Attached state - deviceState = USBD_STATE_SUSPENDED; - previousDeviceState = USBD_STATE_POWERED; - - - PMC_EnablePeripheral(AT91C_ID_OTGHS); - - // Reset endpoint structures - OTGHS_ResetEndpoints(); - - // Enables the USB Clock - OTGHS_EnableUsbClock(); - - //926C - // Enable USB macro and clear all other bit - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_USBECTRL; - AT91C_BASE_OTGHS->OTGHS_CTRL = AT91C_OTGHS_USBECTRL; - - // Configure the pull-up on D+ and disconnect it - USBD_Disconnect(); - - // Enable clock OTG pad - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_FRZCLKCTRL; - TRACE_DEBUG("AT91C_OTGHS_CTRL: 0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_CTRL ); - - // Clear General IT - AT91C_BASE_OTGHS->OTGHS_SCR = 0x01FF; - - // Clear OTG Device IT - AT91C_BASE_OTGHS->OTGHS_DEVICR = 0xFF; - - // Clear OTG Host IT - AT91C_BASE_OTGHS->OTGHS_HSTICR = 0x7F; - - // Reset all Endpoints Fifos - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= (0x7F<<16); - AT91C_BASE_OTGHS->OTGHS_DEVEPT &= ~(unsigned int)(0x7F<<16); - - // Disable all endpoints - AT91C_BASE_OTGHS->OTGHS_DEVEPT &= ~(unsigned int)0x7F; - - AT91C_BASE_OTGHS->OTGHS_TSTA2 = 0; - - // Device is in the Attached state - deviceState = USBD_STATE_SUSPENDED; - previousDeviceState = USBD_STATE_POWERED; - - // Automatic mode speed for device - AT91C_BASE_OTGHS->OTGHS_DEVCTRL &= ~(unsigned int)AT91C_OTGHS_SPDCONF_FS; - // Force Full Speed mode for device - //*AT91C_OTGHS_DEVCTRL = AT91C_OTGHS_SPDCONF_FS; - // Force High Speed mode for device - //*AT91C_OTGHS_DEVCTRL = AT91C_OTGHS_SPDCONF_HS; - - AT91C_BASE_OTGHS->OTGHS_DEVCTRL &= ~(unsigned int)( AT91C_OTGHS_LS - | AT91C_OTGHS_TSTJ - | AT91C_OTGHS_TSTK - | AT91C_OTGHS_TSTPCKT - | AT91C_OTGHS_OPMODE2 ); - - - // Automatic mode speed for host - AT91C_BASE_OTGHS->OTGHS_HSTCTRL &= ~(unsigned int)AT91C_OTGHS_SPDCONF_HST_FS; - // Force Full Speed mode for host - //AT91C_BASE_OTGHS->OTGHS_HSTCTRL = AT91C_OTGHS_SPDCONF_HST_FS; - // Force High Speed mode for host - //*AT91C_BASE_OTGHS->OTGHS_HSTCTRL = AT91C_OTGHS_SPDCONF_HST_HS; - - // Enable USB macro - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_USBECTRL; - - // Enable the UID pin select - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_UIDE; - - // Enable OTG pad - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_OTGPADE; - - // Enable clock OTG pad - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_FRZCLKCTRL; - - - // With OR without DMA !!! - // Initialization of DMA - for( i=1; i<=(unsigned int)((AT91C_BASE_OTGHS->OTGHS_IPFEATURES & AT91C_OTGHS_DMA_CHANNEL_NBR)>>4); i++ ) { - - // RESET endpoint canal DMA: - // DMA stop channel command - AT91C_BASE_OTGHS->OTGHS_DEVDMA[i].OTGHS_DEVDMACONTROL = 0; // STOP command - - // Disable endpoint - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[i] = 0XFFFFFFFF; - - // Reset endpoint config - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[i] = 0; - - // Reset DMA channel (Buff count and Control field) - AT91C_BASE_OTGHS->OTGHS_DEVDMA[i].OTGHS_DEVDMACONTROL = 0x02; // NON STOP command - - // Reset DMA channel 0 (STOP) - AT91C_BASE_OTGHS->OTGHS_DEVDMA[i].OTGHS_DEVDMACONTROL = 0; // STOP command - - // Clear DMA channel status (read the register for clear it) - AT91C_BASE_OTGHS->OTGHS_DEVDMA[i].OTGHS_DEVDMASTATUS = AT91C_BASE_OTGHS->OTGHS_DEVDMA[i].OTGHS_DEVDMASTATUS; - - } - - - // Configure interrupts - USBDCallbacks_Initialized(); - - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_VBUSTI; - - TRACE_DEBUG("AT91C_OTGHS_CTRL: 0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_CTRL ); - TRACE_DEBUG("AT91C_OTGHS_SR: 0x%X\n\r", AT91C_BASE_OTGHS->OTGHS_SR ); - - AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_WAKEUP; - - TRACE_DEBUG("NUM_IT_MAX_DMA: 0x%X\n\r", NUM_IT_MAX_DMA ); - TRACE_DEBUG("NUM_IT_MAX: 0x%X\n\r", NUM_IT_MAX ); - -} - - -//------------------------------------------------------------------------------ -/// Returns the current state of the USB device. -/// \return Device current state. -//------------------------------------------------------------------------------ -unsigned char USBD_GetState( void ) -{ - return deviceState; -} - diff --git a/src/ersky9x/libraries/usb/device/core/USBD_UDPHS.c b/src/ersky9x/libraries/usb/device/core/USBD_UDPHS.c deleted file mode 100644 index dba705856..000000000 --- a/src/ersky9x/libraries/usb/device/core/USBD_UDPHS.c +++ /dev/null @@ -1,2360 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "USBD.h" -#include "USBDCallbacks.h" -#include "USBDDriver.h" -#include -#include -#include -#include -#include -#include -#include - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Maximum number of endpoints interrupts. -#define NUM_IT_MAX \ - (AT91C_BASE_UDPHS->UDPHS_IPFEATURES & AT91C_UDPHS_EPT_NBR_MAX) -/// Maximum number of endpoint DMA interrupts -#define NUM_IT_MAX_DMA \ - ((AT91C_BASE_UDPHS->UDPHS_IPFEATURES & AT91C_UDPHS_DMA_CHANNEL_NBR)>>4) -/// Bits that should be shifted to access DMA control bits. -#define SHIFT_DMA 24 -/// Bits that should be shifted to access interrupt bits. -#define SHIFT_INTERUPT 8 - -/// Max size of the FMA FIFO -#define DMA_MAX_FIFO_SIZE 65536 - -#define EPT_VIRTUAL_SIZE 16384 - -//------------------------------------------------------------------------------ -/// \page "Endpoint states" -/// This page lists the endpoint states. -/// !States -// - UDP_ENDPOINT_DISABLED -// - UDP_ENDPOINT_HALTED -// - UDP_ENDPOINT_IDLE -// - UDP_ENDPOINT_SENDING -// - UDP_ENDPOINT_RECEIVING - -/// Endpoint states: Endpoint is disabled -#define UDP_ENDPOINT_DISABLED 0 -/// Endpoint states: Endpoint is halted (i.e. STALLs every request) -#define UDP_ENDPOINT_HALTED 1 -/// Endpoint states: Endpoint is idle (i.e. ready for transmission) -#define UDP_ENDPOINT_IDLE 2 -/// Endpoint states: Endpoint is sending data -#define UDP_ENDPOINT_SENDING 3 -/// Endpoint states: Endpoint is receiving data -#define UDP_ENDPOINT_RECEIVING 4 -/// Endpoint states: Endpoint is sending MBL -#define UDP_ENDPOINT_SENDINGM 5 -/// Endpoint states: Endpoint is receiving MBL -#define UDP_ENDPOINT_RECEIVINGM 6 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Macros -//------------------------------------------------------------------------------ - -/// Check if DMA is used to transfer data -#define UDP_IsDmaUsed(ep) (CHIP_USB_ENDPOINTS_DMA(ep)) - -//------------------------------------------------------------------------------ -// Structures -//------------------------------------------------------------------------------ - -/// Describes an ongoing transfer on a UDP endpoint. -typedef struct -{ - /// Pointer to a data buffer used for emission/reception. - char *pData; - /// Number of bytes which have been written into the UDP internal FIFO - /// buffers. - volatile int buffered; - /// Number of bytes which have been sent/received. - volatile int transferred; - /// Number of bytes which have not been buffered/transferred yet. - volatile int remaining; - /// Optional callback to invoke when the transfer completes. - volatile TransferCallback fCallback; - /// Optional argument to the callback function. - void *pArgument; -} Transfer; - -/// Describes Multi Buffer List transfer on a UDP endpoint. -typedef struct { - /// Pointer to frame list - USBDTransferBuffer *pMbl; - /// Pointer to last loaded buffer - USBDTransferBuffer *pLastLoaded; - /// List size - unsigned short listSize; - /// Current processing frame - unsigned short currBuffer; - /// First freed frame to re-use - unsigned short freedBuffer; - /// Frame setting, circle frame list - unsigned char circList; - /// All buffer listed is used - unsigned char allUsed; - /// Optional callback to invoke when the transfer completes. - MblTransferCallback fCallback; - /// Optional argument to the callback function. - void *pArgument; -} MblTransfer; - -/// Describes DMA Link List transfer on a UDPHS endpoint. -typedef struct { - /// Pointer to frame list - USBDDmaDescriptor *pMbl; - /// Pointer to current buffer - USBDDmaDescriptor *pCurrBuffer; - /// Pointer to freed buffer - USBDDmaDescriptor *pFreedBuffer; - /// List size - unsigned short listSize; - /// Frame setting, circle frame list - unsigned char circList; - /// All buffer listed is used - unsigned char allUsed; - /// Optional callback to invoke when the transfer completes. - MblTransferCallback fCallback; - /// Optional argument to the callback function. - void *pArgument; -} DmaLlTransfer; - -//------------------------------------------------------------------------------ -/// Describes the state of an endpoint of the UDP controller. -//------------------------------------------------------------------------------ -typedef struct -{ - /// Current endpoint state. - volatile unsigned char state; - /// Current reception bank (0 or 1). - unsigned char bank; - /// Maximum packet size for the endpoint. - unsigned short size; - /// Describes an ongoing transfer (if current state is either - /// or ) - union { - Transfer singleTransfer; - MblTransfer mblTransfer; - DmaLlTransfer dmaTransfer; - } transfer; - /// Special case for send a ZLP - unsigned char sendZLP; -} Endpoint; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Holds the internal state for each endpoint of the UDP. -static Endpoint endpoints[CHIP_USB_NUMENDPOINTS]; -/// Device current state. -static unsigned char deviceState; -/// Indicates the previous device state -static unsigned char previousDeviceState; - -/// 7.1.20 Test Mode Support -/// Test codes for the USB HS test mode. -static const char test_packet_buffer[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // JKJKJKJK * 9 - 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, // JJKKJJKK * 8 - 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE, // JJJJKKKK * 8 - 0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // JJJJJJJKKKKKKK * 8 - 0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD, // JJJJJJJK * 8 - 0xFC,0x7E,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0x7E // {JKKKKKKK * 10}, JK -}; - -// Force HS -static const unsigned char forceUsbFS = 0; - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Disables the BIAS of the USB controller -//------------------------------------------------------------------------------ -static inline void UDPHS_DisableBIAS( void ) -{ - AT91C_BASE_PMC->PMC_UCKR &= ~AT91C_CKGR_BIASEN_ENABLED; -} - -//------------------------------------------------------------------------------ -/// Enables the BIAS of the USB controller -//------------------------------------------------------------------------------ -static inline void UDPHS_EnableBIAS( void ) -{ - UDPHS_DisableBIAS(); - AT91C_BASE_PMC->PMC_UCKR |= AT91C_CKGR_BIASEN_ENABLED; -} - -//------------------------------------------------------------------------------ -/// Enable UDPHS clock -//------------------------------------------------------------------------------ -static inline void UDPHS_EnableUsbClock( void ) -{ -#if !defined (PMC_BY_HARD) - AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_UDPHS); - // Enable 480MHZ - //AT91C_BASE_CKGR->CKGR_UCKR |= (AT91C_CKGR_PLLCOUNT & (3 << 20)) | AT91C_CKGR_UPLLEN; - AT91C_BASE_CKGR->CKGR_UCKR |= ((0xf << 20) & (3 << 20)) | AT91C_CKGR_UPLLEN; - // Wait until UTMI PLL is locked - while ((AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCKU) == 0); -#endif -} - -//------------------------------------------------------------------------------ -/// Disable UDPHS clock -//------------------------------------------------------------------------------ -static inline void UDPHS_DisableUsbClock( void ) -{ -#if !defined (PMC_BY_HARD) - AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_UDPHS); - // 480MHZ - AT91C_BASE_CKGR->CKGR_UCKR &= ~AT91C_CKGR_UPLLEN; -#endif -} - -//------------------------------------------------------------------------------ -/// Handles a completed transfer on the given endpoint, invoking the -/// configured callback if any. -/// \param bEndpoint Number of the endpoint for which the transfer has completed. -/// \param bStatus Status code returned by the transfer operation -//------------------------------------------------------------------------------ -static void UDPHS_EndOfTransfer( unsigned char bEndpoint, char bStatus ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - - // Check that endpoint was sending or receiving data - if( (pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING) ) { - - TRACE_DEBUG_WP("Eo"); - if(pEndpoint->state == UDP_ENDPOINT_SENDING) { - pEndpoint->sendZLP = 0; - } - // Endpoint returns in Idle state - pEndpoint->state = UDP_ENDPOINT_IDLE; - - // Invoke callback is present - if (pTransfer->fCallback != 0) { - - ((TransferCallback) pTransfer->fCallback) - (pTransfer->pArgument, - bStatus, - pTransfer->transferred, - pTransfer->remaining + pTransfer->buffered); - } - else { - TRACE_DEBUG_WP("No callBack\n\r"); - } - } - else if ( (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM) - || (pEndpoint->state == UDP_ENDPOINT_SENDINGM) ) { - - MblTransfer* pMblt = (MblTransfer*)&(pEndpoint->transfer); - MblTransferCallback fCallback; - void* pArg; - - TRACE_DEBUG_WP("EoMT "); - - #ifdef DMA - { DmaLlTransfer *pDmat = (DmaLlTransfer*)&(pEndpoint->transfer); - fCallback = UDP_IsDmaUsed(bEndpoint) ? - pDmat->fCallback : pMblt->fCallback; - pArg = UDP_IsDmaUsed(bEndpoint) ? - pDmat->pArgument : pMblt->pArgument; - } - #else - fCallback = pMblt->fCallback; - pArg = pMblt->pArgument; - #endif - - // Endpoint returns in Idle state - pEndpoint->state = UDP_ENDPOINT_IDLE; - // Invoke callback - if (fCallback != 0) { - - (fCallback)(pArg, bStatus, 0); - } - else { - TRACE_DEBUG_WP("NoCB "); - } - } -} - -//------------------------------------------------------------------------------ -/// Clears the correct RX flag in endpoint status register -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -static void UDPHS_ClearRxFlag( unsigned char bEndpoint ) -{ - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_RX_BK_RDY; -} - -//------------------------------------------------------------------------------ -/// Update multi-buffer-transfer descriptors. -/// \param pTransfer Pointer to instance MblTransfer. -/// \param size Size of bytes that processed. -/// \param forceEnd Force the buffer END. -/// \return 1 if current buffer ended. -//------------------------------------------------------------------------------ -static char UDPHS_MblUpdate(MblTransfer *pTransfer, - USBDTransferBuffer * pBi, - unsigned short size, - unsigned char forceEnd) -{ - // Update transfer descriptor - pBi->remaining -= size; - // Check if current buffer ended - if (pBi->remaining == 0 || forceEnd) { - - // Process to next buffer - if ((++ pTransfer->currBuffer) == pTransfer->listSize) { - if (pTransfer->circList) { - pTransfer->currBuffer = 0; - } - else { - pTransfer->allUsed = 1; - } - } - // All buffer in the list is processed - if (pTransfer->currBuffer == pTransfer->freedBuffer) { - pTransfer->allUsed = 1; - } - // Continue transfer, prepare for next operation - if (pTransfer->allUsed == 0) { - pBi = &pTransfer->pMbl[pTransfer->currBuffer]; - pBi->buffered = 0; - pBi->transferred = 0; - pBi->remaining = pBi->size; - } - return 1; - } - return 0; -} -/* -void UDPHS_WriteFifo(volatile char* pFifo, - unsigned char* pBuffer, - unsigned int size) -{ - register unsigned int c8 = size >> 3; - register unsigned int c1 = size & 0x7; - for (; c8; c8 --) { - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - *pFifo = *(pBuffer ++); - } - for (; c1; c1 --) { - *pFifo = *(pBuffer ++); - } -} -*/ -//------------------------------------------------------------------------------ -/// Transfers a data payload from the current tranfer buffer to the endpoint -/// FIFO -/// \param bEndpoint Number of the endpoint which is sending data. -//------------------------------------------------------------------------------ -static char UDPHS_MblWriteFifo(unsigned char bEndpoint) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer); - USBDTransferBuffer *pBi = &(pTransfer->pMbl[pTransfer->currBuffer]); - volatile char *pFifo; - signed int size; - - volatile unsigned char * pBytes; - volatile char bufferEnd = 1; - - // Get the number of bytes to send - size = pEndpoint->size; - if (size > pBi->remaining) { - - size = pBi->remaining; - } - - TRACE_DEBUG_WP("w%d.%d ", pTransfer->currBuffer, size); - if (size == 0) { - - return 1; - } - - pTransfer->pLastLoaded = pBi; - pBytes = &(pBi->pBuffer[pBi->transferred + pBi->buffered]); - pBi->buffered += size; - bufferEnd = UDPHS_MblUpdate(pTransfer, pBi, size, 0); - - // Write packet in the FIFO buffer - pFifo = (char*)((unsigned int *)AT91C_BASE_UDPHS_EPTFIFO - + (EPT_VIRTUAL_SIZE * bEndpoint)); - if (size) { - signed int c8 = size >> 3; - signed int c1 = size & 0x7; - //printf("%d[%x] ", pBi->transferred, pBytes); - for (; c8; c8 --) { - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - *(pFifo++) = *(pBytes ++); - } - for (; c1; c1 --) { - *(pFifo++) = *(pBytes ++); - } - } - return bufferEnd; -} - -//------------------------------------------------------------------------------ -/// Transfers a data payload from the current tranfer buffer to the endpoint -/// FIFO -/// \param bEndpoint Number of the endpoint which is sending data. -//------------------------------------------------------------------------------ -static void UDPHS_WritePayload( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - char *pFifo; - signed int size; - unsigned int dCtr; - - pFifo = (char*)((unsigned int *)AT91C_BASE_UDPHS_EPTFIFO + (EPT_VIRTUAL_SIZE * bEndpoint)); - - // Get the number of bytes to send - size = pEndpoint->size; - if (size > pTransfer->remaining) { - - size = pTransfer->remaining; - } - - // Update transfer descriptor information - pTransfer->buffered += size; - pTransfer->remaining -= size; - - // Write packet in the FIFO buffer - dCtr = 0; - while (size > 0) { - - pFifo[dCtr] = *(pTransfer->pData); - pTransfer->pData++; - size--; - dCtr++; - } -} - -//------------------------------------------------------------------------------ -/// Transfers a data payload from an endpoint FIFO to the current transfer buffer -/// \param bEndpoint Endpoint number. -/// \param wPacketSize Size of received data packet -//------------------------------------------------------------------------------ -static void UDPHS_ReadPayload( unsigned char bEndpoint, int wPacketSize ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - char *pFifo; - unsigned char dBytes=0; - - pFifo = (char*)((unsigned int *)AT91C_BASE_UDPHS_EPTFIFO + (EPT_VIRTUAL_SIZE * bEndpoint)); - - // Check that the requested size is not bigger than the remaining transfer - if (wPacketSize > pTransfer->remaining) { - - pTransfer->buffered += wPacketSize - pTransfer->remaining; - wPacketSize = pTransfer->remaining; - } - - // Update transfer descriptor information - pTransfer->remaining -= wPacketSize; - pTransfer->transferred += wPacketSize; - - // Retrieve packet - while (wPacketSize > 0) { - - *(pTransfer->pData) = pFifo[dBytes]; - pTransfer->pData++; - wPacketSize--; - dBytes++; - } -} - - -//------------------------------------------------------------------------------ -/// Received SETUP packet from endpoint 0 FIFO -/// \param pRequest Generic USB SETUP request sent over Control endpoints -//------------------------------------------------------------------------------ -static void UDPHS_ReadRequest( USBGenericRequest *pRequest ) -{ - unsigned int *pData = (unsigned int *)pRequest; - unsigned int fifo; - - fifo = (AT91C_BASE_UDPHS_EPTFIFO->UDPHS_READEPT0[0]); - *pData = fifo; - fifo = (AT91C_BASE_UDPHS_EPTFIFO->UDPHS_READEPT0[0]); - pData++; - *pData = fifo; - //TRACE_ERROR("SETUP: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n\r", pData[0],pData[1],pData[2],pData[3],pData[4],pData[5],pData[6],pData[7]); -} - -//------------------------------------------------------------------------------ -/// Reset all endpoint transfer descriptors -//------------------------------------------------------------------------------ -static void UDPHS_ResetEndpoints( void ) -{ - Endpoint *pEndpoint; - Transfer *pTransfer; - unsigned char bEndpoint; - - // Reset the transfer descriptor of every endpoint - for( bEndpoint = 0; bEndpoint < CHIP_USB_NUMENDPOINTS; bEndpoint++ ) { - - pEndpoint = &(endpoints[bEndpoint]); - pTransfer = (Transfer*)&(pEndpoint->transfer); - - // Reset endpoint transfer descriptor - pTransfer->pData = 0; - pTransfer->transferred = -1; - pTransfer->buffered = -1; - pTransfer->remaining = -1; - pTransfer->fCallback = 0; - pTransfer->pArgument = 0; - - // Reset endpoint state - pEndpoint->bank = 0; - pEndpoint->state = UDP_ENDPOINT_DISABLED; - // Reset ZLP - pEndpoint->sendZLP = 0; - } -} - - -//------------------------------------------------------------------------------ -/// Disable all endpoints (except control endpoint 0), aborting current -/// transfers if necessary -//------------------------------------------------------------------------------ -static void UDPHS_DisableEndpoints( void ) -{ - unsigned char bEndpoint; - - // Disable each endpoint, terminating any pending transfer - // Control endpoint 0 is not disabled - for( bEndpoint = 1; bEndpoint < CHIP_USB_NUMENDPOINTS; bEndpoint++ ) { - - UDPHS_EndOfTransfer( bEndpoint, USBD_STATUS_ABORTED ); - endpoints[bEndpoint].state = UDP_ENDPOINT_DISABLED; - } -} - -//------------------------------------------------------------------------------ -/// Endpoint interrupt handler. -/// Handle IN/OUT transfers, received SETUP packets and STALLing -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -static void UDPHS_EndpointHandler( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - MblTransfer *pMblt = (MblTransfer*)&(pEndpoint->transfer); - unsigned int status = AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSTA; - unsigned short wPacketSize; - USBGenericRequest request; - - TRACE_DEBUG_WP("E%d ", bEndpoint); - TRACE_DEBUG_WP("st:0x%X ", status); - - // Handle interrupts - // IN packet sent - if( (AT91C_UDPHS_TX_PK_RDY == (AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTL & AT91C_UDPHS_TX_PK_RDY)) - && (0 == (status & AT91C_UDPHS_TX_PK_RDY )) ) { - - TRACE_DEBUG_WP("Wr "); - - // Check that endpoint was sending multi-buffer-list - if( pEndpoint->state == UDP_ENDPOINT_SENDINGM ) { - - USBDTransferBuffer * pMbli = pMblt->pLastLoaded; - - TRACE_DEBUG_WP("TxM%d.%d,%d ", - pMblt->allUsed, pMbli->buffered, pMbli->remaining); - - // End of transfer ? - if (pMblt->allUsed && pMbli->remaining == 0) { - - pMbli->transferred += pMbli->buffered; - pMbli->buffered = 0; - - // Disable interrupt - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1<UDPHS_EPT[bEndpoint].UDPHS_EPTCTLDIS = - AT91C_UDPHS_TX_PK_RDY; - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - } - else { - - // Transfer remaining data - TRACE_DEBUG_WP("%d ", pEndpoint->size); - - if (pMbli->buffered > pEndpoint->size) { - pMbli->transferred += pEndpoint->size; - pMbli->buffered -= pEndpoint->size; - } - else { - pMbli->transferred += pMbli->buffered; - pMbli->buffered = 0; - } - - // Send next packet - UDPHS_MblWriteFifo(bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = - AT91C_UDPHS_TX_PK_RDY; - - if (pMbli->remaining == 0 && pMbli->buffered == 0) { - - if (pMblt->fCallback) { - ((MblTransferCallback) pTransfer->fCallback) - (pTransfer->pArgument, - USBD_STATUS_PARTIAL_DONE, - 1); - } - } - } - } - - // Check that endpoint was in Sending state - if( pEndpoint->state == UDP_ENDPOINT_SENDING ) { - - if (pTransfer->buffered > 0) { - pTransfer->transferred += pTransfer->buffered; - pTransfer->buffered = 0; - } - - if( ((pTransfer->buffered)==0) - &&((pTransfer->transferred)==0) - &&((pTransfer->remaining)==0) - &&(pEndpoint->sendZLP == 0)) { - pEndpoint->sendZLP = 1; - } - - // End of transfer ? - if( (pTransfer->remaining > 0) - ||(pEndpoint->sendZLP == 1)) { - - pEndpoint->sendZLP = 2; - TRACE_DEBUG_WP("\n\r1pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("1pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("1pTransfer->remaining %d \n\r", pTransfer->remaining); - - // Transfer remaining data - TRACE_DEBUG_WP(" %d ", pEndpoint->size); - - // Send next packet - UDPHS_WritePayload(bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = AT91C_UDPHS_TX_PK_RDY; - } - else { - TRACE_DEBUG_WP("\n\r0pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("0pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("0pTransfer->remaining %d \n\r", pTransfer->remaining); - - TRACE_DEBUG_WP(" %d ", pTransfer->transferred); - - // Disable interrupt if this is not a control endpoint - if( AT91C_UDPHS_EPT_TYPE_CTL_EPT != (AT91C_UDPHS_EPT_TYPE&(AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG)) ) { - - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1<UDPHS_EPT[bEndpoint].UDPHS_EPTCTLDIS = AT91C_UDPHS_TX_PK_RDY; - - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - pEndpoint->sendZLP = 0; - } - } - else { - - TRACE_DEBUG("Error Wr %d", pEndpoint->sendZLP); - } - } - - // OUT packet received - if( AT91C_UDPHS_RX_BK_RDY == (status & AT91C_UDPHS_RX_BK_RDY) ) { - - TRACE_DEBUG_WP("Rd "); - - // Check that the endpoint is in Receiving state - if (pEndpoint->state != UDP_ENDPOINT_RECEIVING) { - - // Check if an ACK has been received on a Control endpoint - if( (0 == (AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG & AT91C_UDPHS_EPT_TYPE)) - && (0 == (status & AT91C_UDPHS_BYTE_COUNT)) ) { - - // Control endpoint, 0 bytes received - // Acknowledge the data and finish the current transfer - TRACE_DEBUG_WP("Ack "); - UDPHS_ClearRxFlag(bEndpoint); - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - //todo remove endoftranfer and test - } - // Check if the data has been STALLed - else if( AT91C_UDPHS_FRCESTALL == (status & AT91C_UDPHS_FRCESTALL)) { - - // Discard STALLed data - TRACE_DEBUG_WP("Discard "); - UDPHS_ClearRxFlag(bEndpoint); - } - // NAK the data - else { - - TRACE_DEBUG_WP("Nak "); - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1<>20); - - TRACE_DEBUG_WP("%d ", wPacketSize); - UDPHS_ReadPayload(bEndpoint, wPacketSize); - UDPHS_ClearRxFlag(bEndpoint); - - // Check if the transfer is finished - if ((pTransfer->remaining == 0) || (wPacketSize < pEndpoint->size)) { - - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLDIS = AT91C_UDPHS_RX_BK_RDY; - - // Disable interrupt if this is not a control endpoint - if( AT91C_UDPHS_EPT_TYPE_CTL_EPT != (AT91C_UDPHS_EPT_TYPE & (AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG)) ) { - - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1<UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_STALL_SNT; - - // If the endpoint is not halted, clear the STALL condition - if (pEndpoint->state != UDP_ENDPOINT_HALTED) { - - TRACE_WARNING( "_ " ); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_FRCESTALL; - } - } - - // SETUP packet received - if( AT91C_UDPHS_RX_SETUP == (status & AT91C_UDPHS_RX_SETUP) ) { - - TRACE_DEBUG_WP("Stp "); - - // If a transfer was pending, complete it - // Handles the case where during the status phase of a control write - // transfer, the host receives the device ZLP and ack it, but the ack - // is not received by the device - if ((pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING)) { - - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_SUCCESS); - } - // Copy the setup packet - UDPHS_ReadRequest(&request); - - // Acknowledge setup packet - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_RX_SETUP; - - // Forward the request to the upper layer - USBDCallbacks_RequestReceived(&request); - } - -} - -//------------------------------------------------------------------------------ -// Interrupt service routine -//------------------------------------------------------------------------------ -#ifdef DMA -//---------------------------------------------------------------------------- -/// Endpoint DMA interrupt handler. -/// This function (ISR) handles dma interrupts -/// \param bEndpoint Index of endpoint -//---------------------------------------------------------------------------- -static void UDPHS_DmaHandler( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - int justTransferred; - unsigned int status; - unsigned char result = USBD_STATUS_SUCCESS; - - status = AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMASTATUS; - TRACE_DEBUG_WP("DmaE%d,%x ", bEndpoint, status); - - if (pEndpoint->state == UDP_ENDPOINT_SENDINGM) { - - DmaLlTransfer *pDmat = (DmaLlTransfer*)&(pEndpoint->transfer); - USBDDmaDescriptor *pDi = pDmat->pCurrBuffer; - USBDDmaDescriptor *pNi = (USBDDmaDescriptor*)AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMANXTDSC; - unsigned char bufCnt = 0; - - if (AT91C_UDPHS_END_BF_ST == (status & AT91C_UDPHS_END_BF_ST)) { - - // Stop loading descriptors - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL &= - ~(AT91C_UDPHS_LDNXT_DSC); - - //printf("%x,%x|", - // (char)status, - // (short)AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMANXTDSC); - - while( pDi->pNxtDesc != pNi ) { - - // All descriptor processed - if (pDi == 0) break; - if (pDi->used) break; - - // Current descriptor processed - /* - pDi->ctrlSettings = 0 - //|AT91C_UDPHS_CHANN_ENB - //| AT91C_UDPHS_LDNXT_DSC - //| AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - //| AT91C_UDPHS_END_B_EN - //| AT91C_UDPHS_END_BUFFIT - //| AT91C_UDPHS_DESC_LD_IT - ; */ - pDi->used = 1; // Flag as used - bufCnt ++; - pDi = pDi->pNxtDesc; - } - pDmat->pCurrBuffer = pDi; - - if (bufCnt) { - - if (pDmat->fCallback) { - - pDmat->fCallback(pDmat->pArgument, - ((result == USBD_STATUS_SUCCESS) ? - USBD_STATUS_PARTIAL_DONE : result), - bufCnt); - } - } - - if ( (pNi == 0) - || (pNi->used && pNi) ) { - - // Disable DMA endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = 0; - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1 << SHIFT_DMA << bEndpoint); - - TRACE_DEBUG_WP("EoMDT "); - //printf("E:N%x,C%d ", (short)pNi, bufCnt); - - UDPHS_EndOfTransfer(bEndpoint, result); - } - else { - - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL |= - (AT91C_UDPHS_LDNXT_DSC); - } - } - else { - - TRACE_ERROR("UDPHS: Dma(0x%X)\n\r", status); - result = USBD_STATUS_ABORTED; - UDPHS_EndOfTransfer(bEndpoint, result); - } - return; - } - else if (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM) { - return; - } - - // Disable DMA interrupt to avoid receiving 2 interrupts (B_EN and TR_EN) - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL &= - ~(AT91C_UDPHS_END_TR_EN | AT91C_UDPHS_END_B_EN); - - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1 << SHIFT_DMA << bEndpoint); - - if( AT91C_UDPHS_END_BF_ST == (status & AT91C_UDPHS_END_BF_ST) ) { - - TRACE_DEBUG_WP("EndBuffer "); - - // BUFF_COUNT holds the number of untransmitted bytes. - // BUFF_COUNT is equal to zero in case of good transfer - justTransferred = pTransfer->buffered - - ((status & AT91C_UDPHS_BUFF_COUNT) >> 16); - pTransfer->transferred += justTransferred; - - pTransfer->buffered = ((status & AT91C_UDPHS_BUFF_COUNT) >> 16); - - pTransfer->remaining -= justTransferred; - - TRACE_DEBUG_WP("\n\r1pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("1pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("1pTransfer->remaining %d \n\r", pTransfer->remaining); - - if( (pTransfer->remaining + pTransfer->buffered) > 0 ) { - - // Prepare an other transfer - if( pTransfer->remaining > DMA_MAX_FIFO_SIZE ) { - - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - pTransfer->buffered = pTransfer->remaining; - } - - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMAADDRESS = - (unsigned int)((pTransfer->pData) + (pTransfer->transferred)); - - // Clear unwanted interrupts - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMASTATUS; - - // Enable DMA endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_DMA << bEndpoint); - // DMA config for receive the good size of buffer, or an error buffer - - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = 0; // raz - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = - ( ((pTransfer->buffered << 16) & AT91C_UDPHS_BUFF_COUNT) - | AT91C_UDPHS_END_TR_EN - | AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - | AT91C_UDPHS_CHANN_ENB ); - } - } - else if( AT91C_UDPHS_END_TR_ST == (status & AT91C_UDPHS_END_TR_ST) ) { - - TRACE_DEBUG_WP("EndTransf "); - - pTransfer->transferred = pTransfer->buffered - - ((status & AT91C_UDPHS_BUFF_COUNT) >> 16); - pTransfer->remaining = 0; - TRACE_DEBUG_WP("\n\r0pTransfer->buffered %d \n\r", pTransfer->buffered); - TRACE_DEBUG_WP("0pTransfer->transferred %d \n\r", pTransfer->transferred); - TRACE_DEBUG_WP("0pTransfer->remaining %d \n\r", pTransfer->remaining); - } - else { - - TRACE_ERROR("UDPHS_DmaHandler: Error (0x%08X)\n\r", status); - result = USBD_STATUS_ABORTED; - } - - // Invoke callback - if( pTransfer->remaining == 0 ) { - - TRACE_DEBUG_WP("EOT "); - UDPHS_EndOfTransfer(bEndpoint, result); - } -} -#endif - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USB device interrupt handler -/// Manages device resume, suspend, end of bus reset. -/// Forwards endpoint interrupts to the appropriate handler. -//------------------------------------------------------------------------------ -void USBD_IrqHandler(void) -{ - unsigned int status; - unsigned char numIT; - - if (deviceState >= USBD_STATE_POWERED) { - - LED_Set(USBD_LEDUSB); - } - - // Get interrupts status - status = AT91C_BASE_UDPHS->UDPHS_INTSTA & AT91C_BASE_UDPHS->UDPHS_IEN; - - // Handle all UDPHS interrupts - TRACE_DEBUG_WP("H"); - while (status != 0) { - - // Start Of Frame (SOF) - if ((status & AT91C_UDPHS_IEN_SOF) != 0) { - - TRACE_DEBUG_WP("SOF "); - - // Invoke the SOF callback - //USB_StartOfFrameCallback(pUsb); - - // Acknowledge interrupt - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_IEN_SOF; - status &= ~AT91C_UDPHS_IEN_SOF; - } - // Suspend - // This interrupt is always treated last (hence the '==') - else if (status == AT91C_UDPHS_DET_SUSPD) { - - TRACE_DEBUG_WP("S"); - - // The device enters the Suspended state - // MCK + UDPCK must be off - // Pull-Up must be connected - // Transceiver must be disabled - - LED_Clear(USBD_LEDUSB); - - UDPHS_DisableBIAS(); - - // Enable wakeup - AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM; - AT91C_BASE_UDPHS->UDPHS_IEN &= ~AT91C_UDPHS_DET_SUSPD; - - // Acknowledge interrupt - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_DET_SUSPD | AT91C_UDPHS_WAKE_UP; - previousDeviceState = deviceState; - deviceState = USBD_STATE_SUSPENDED; - UDPHS_DisableUsbClock(); - - // Invoke the Suspend callback - USBDCallbacks_Suspended(); - } - // Resume - else if( ((status & AT91C_UDPHS_WAKE_UP) != 0) // line activity - || ((status & AT91C_UDPHS_ENDOFRSM) != 0)) { // pc wakeup - { - // Invoke the Resume callback - USBDCallbacks_Resumed(); - - TRACE_DEBUG_WP("R"); - - UDPHS_EnableUsbClock(); - UDPHS_EnableBIAS(); - - // The device enters Configured state - // MCK + UDPCK must be on - // Pull-Up must be connected - // Transceiver must be enabled - - deviceState = previousDeviceState; - - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM | AT91C_UDPHS_DET_SUSPD; - - AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_ENDOFRSM | AT91C_UDPHS_DET_SUSPD; - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM; - AT91C_BASE_UDPHS->UDPHS_IEN &= ~AT91C_UDPHS_WAKE_UP; - } - } - // End of bus reset - else if ((status & AT91C_UDPHS_ENDRESET) == AT91C_UDPHS_ENDRESET) { - -// TRACE_DEBUG_WP("EoB "); - - // The device enters the Default state - deviceState = USBD_STATE_DEFAULT; - // MCK + UDPCK are already enabled - // Pull-Up is already connected - // Transceiver must be enabled - // Endpoint 0 must be enabled - - UDPHS_ResetEndpoints(); - UDPHS_DisableEndpoints(); - USBD_ConfigureEndpoint(0); - - // Flush and enable the Suspend interrupt - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_DET_SUSPD; - - //// Enable the Start Of Frame (SOF) interrupt if needed - //if (pCallbacks->startOfFrame != 0) - //{ - // AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_IEN_SOF; - //} - - // Invoke the Reset callback - USBDCallbacks_Reset(); - - // Acknowledge end of bus reset interrupt - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_ENDRESET; - - AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_DET_SUSPD; - } - // Handle upstream resume interrupt - else if (status & AT91C_UDPHS_UPSTR_RES) { - - TRACE_DEBUG_WP("ExtRes "); - - // - Acknowledge the IT - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_UPSTR_RES; - } - // Endpoint interrupts - else { -#ifndef DMA - // Handle endpoint interrupts - for (numIT = 0; numIT < NUM_IT_MAX; numIT++) { - - if ((status & (1 << SHIFT_INTERUPT << numIT)) != 0) { - - UDPHS_EndpointHandler(numIT); - } - } -#else - // Handle endpoint control interrupt - if ((status & (1 << SHIFT_INTERUPT << 0)) != 0) { - - UDPHS_EndpointHandler( 0 ); - } - else { - - numIT = 1; - while((status&(0x7E<UDPHS_INTSTA & AT91C_BASE_UDPHS->UDPHS_IEN; - - TRACE_DEBUG_WP("\n\r"); - if (status != 0) { - - TRACE_DEBUG_WP(" - "); - } - } - - if (deviceState >= USBD_STATE_POWERED) { - - LED_Clear(USBD_LEDUSB); - } -} - -//------------------------------------------------------------------------------ -/// Configure an endpoint with the provided endpoint descriptor -/// \param pDdescriptor Pointer to the endpoint descriptor -//------------------------------------------------------------------------------ -void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor) -{ - Endpoint *pEndpoint; - unsigned char bEndpoint; - unsigned char bType; - unsigned char bEndpointDir; - //unsigned char bInterval = 0; - unsigned char bNbTrans = 1; - unsigned char bSizeEpt = 0; - unsigned char bHs = ((AT91C_BASE_UDPHS->UDPHS_INTSTA & AT91C_UDPHS_SPEED) - > 0); - - // NULL descriptor -> Control endpoint 0 - if (pDescriptor == 0) { - - bEndpoint = 0; - pEndpoint = &(endpoints[bEndpoint]); - bType = USBEndpointDescriptor_CONTROL; - bEndpointDir = 0; - pEndpoint->size = CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0); - pEndpoint->bank = CHIP_USB_ENDPOINTS_BANKS(0); - } - else { - - // The endpoint number - bEndpoint = USBEndpointDescriptor_GetNumber(pDescriptor); - pEndpoint = &(endpoints[bEndpoint]); - // Transfer type: Control, Isochronous, Bulk, Interrupt - bType = USBEndpointDescriptor_GetType(pDescriptor); - // interval - //bInterval = USBEndpointDescriptor_GetInterval(pDescriptor); - // Direction, ignored for control endpoints - bEndpointDir = USBEndpointDescriptor_GetDirection(pDescriptor); - pEndpoint->size = USBEndpointDescriptor_GetMaxPacketSize(pDescriptor); - pEndpoint->bank = CHIP_USB_ENDPOINTS_BANKS(bEndpoint); - - // Convert descriptor value to EP configuration - if (bHs) { // HS Interval, *125us - - // MPS: Bit12,11 specify NB_TRANS - bNbTrans = ((pEndpoint->size >> 11) & 0x3); - if (bNbTrans == 3) - bNbTrans = 1; - else - bNbTrans ++; - - // Mask, bit 10..0 is the size - pEndpoint->size &= 0x3FF; - } - } - - // Abort the current transfer is the endpoint was configured and in - // Write or Read state - if( (pEndpoint->state == UDP_ENDPOINT_RECEIVING) - || (pEndpoint->state == UDP_ENDPOINT_SENDING) - || (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM) - || (pEndpoint->state == UDP_ENDPOINT_SENDINGM) ) { - - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_RESET); - } - pEndpoint->state = UDP_ENDPOINT_IDLE; - - // Disable endpoint - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLDIS = AT91C_UDPHS_SHRT_PCKT - | AT91C_UDPHS_BUSY_BANK - | AT91C_UDPHS_NAK_OUT - | AT91C_UDPHS_NAK_IN - | AT91C_UDPHS_STALL_SNT - | AT91C_UDPHS_RX_SETUP - | AT91C_UDPHS_TX_PK_RDY - | AT91C_UDPHS_TX_COMPLT - | AT91C_UDPHS_RX_BK_RDY - | AT91C_UDPHS_ERR_OVFLW - | AT91C_UDPHS_MDATA_RX - | AT91C_UDPHS_DATAX_RX - | AT91C_UDPHS_NYET_DIS - | AT91C_UDPHS_INTDIS_DMA - | AT91C_UDPHS_AUTO_VALID - | AT91C_UDPHS_EPT_DISABL; - - // Reset Endpoint Fifos - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_TOGGLESQ | AT91C_UDPHS_FRCESTALL; - AT91C_BASE_UDPHS->UDPHS_EPTRST = 1<size <= 8 ) { - bSizeEpt = 0; - } - else if ( pEndpoint->size <= 16 ) { - bSizeEpt = 1; - } - else if ( pEndpoint->size <= 32 ) { - bSizeEpt = 2; - } - else if ( pEndpoint->size <= 64 ) { - bSizeEpt = 3; - } - else if ( pEndpoint->size <= 128 ) { - bSizeEpt = 4; - } - else if ( pEndpoint->size <= 256 ) { - bSizeEpt = 5; - } - else if ( pEndpoint->size <= 512 ) { - bSizeEpt = 6; - } - else if ( pEndpoint->size <= 1024 ) { - bSizeEpt = 7; - } //else { - // sizeEpt = 0; // control endpoint - //} - - // Configure endpoint - if (bType == USBEndpointDescriptor_CONTROL) { - - // Enable endpoint IT for control endpoint - AT91C_BASE_UDPHS->UDPHS_IEN |= (1<UDPHS_EPT[bEndpoint].UDPHS_EPTCFG = bSizeEpt - | ( bEndpointDir << 3) - | ( bType << 4) - | ((pEndpoint->bank) << 6) - | ( bNbTrans << 8) - ; - - while( (signed int)AT91C_UDPHS_EPT_MAPD != (signed int)((AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG) & AT91C_UDPHS_EPT_MAPD) ) { - - // resolved by clearing the reset IT in good place - TRACE_ERROR("PB bEndpoint: 0x%X\n\r", bEndpoint); - TRACE_ERROR("PB bSizeEpt: 0x%X\n\r", bSizeEpt); - TRACE_ERROR("PB bEndpointDir: 0x%X\n\r", bEndpointDir); - TRACE_ERROR("PB bType: 0x%X\n\r", bType); - TRACE_ERROR("PB pEndpoint->bank: 0x%X\n\r", pEndpoint->bank); - TRACE_ERROR("PB UDPHS_EPTCFG: 0x%X\n\r", AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG); - for(;;); - } - - if (bType == USBEndpointDescriptor_CONTROL) { - - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_RX_BK_RDY - | AT91C_UDPHS_RX_SETUP - | AT91C_UDPHS_EPT_ENABL; - } - else { -#ifndef DMA - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_EPT_ENABL; -#else - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_AUTO_VALID - | AT91C_UDPHS_EPT_ENABL; -#endif - } - -} - -//------------------------------------------------------------------------------ -/// Sends data through an USB endpoint (IN) -/// Sets up the transfer descriptor, write one or two data payloads -/// (depending on the number of FIFO banks for the endpoint) and then -/// starts the actual transfer. The operation is complete when all -/// the data has been sent. -/// \param bEndpoint Index of endpoint -/// \param *pData Data to be written -/// \param dLength Data length to be send -/// \param fCallback Callback to be call after the success command -/// \param *pArgument Callback argument -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -char USBD_Write( unsigned char bEndpoint, - const void *pData, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - - // Return if the endpoint is not in IDLE state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Write%d(%d) ", bEndpoint, dLength); - pEndpoint->sendZLP = 0; - // Setup the transfer descriptor - pTransfer->pData = (void *) pData; - pTransfer->remaining = dLength; - pTransfer->buffered = 0; - pTransfer->transferred = 0; - pTransfer->fCallback = fCallback; - pTransfer->pArgument = pArgument; - - // Send one packet - pEndpoint->state = UDP_ENDPOINT_SENDING; - -#ifdef DMA - // Test if endpoint type control - if(AT91C_UDPHS_EPT_TYPE_CTL_EPT == (AT91C_UDPHS_EPT_TYPE&(AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG))) { -#endif - // Enable endpoint IT - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_INTERUPT << bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_TX_PK_RDY; - -#ifdef DMA - } - else { - if( CHIP_USB_ENDPOINTS_DMA(bEndpoint) == 0 ) { - TRACE_FATAL("Endpoint has no DMA\n\r"); - } - if( pTransfer->remaining == 0 ) { - // DMA not handle ZLP - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = AT91C_UDPHS_TX_PK_RDY; - // Enable endpoint IT - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_INTERUPT << bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_TX_PK_RDY; - } - else { - // Others endpoints (not control) - if( pTransfer->remaining > DMA_MAX_FIFO_SIZE ) { - - // Transfer the max - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - // Transfer the good size - pTransfer->buffered = pTransfer->remaining; - } - - TRACE_DEBUG_WP("\n\r_WR[%x]:%d ", pTransfer->pData, pTransfer->remaining ); - TRACE_DEBUG_WP("B:%d ", pTransfer->buffered ); - TRACE_DEBUG_WP("T:%d ", pTransfer->transferred ); - - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMAADDRESS = (unsigned int)(pTransfer->pData); - - // Clear unwanted interrupts - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMASTATUS; - // Enable DMA endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_DMA << bEndpoint); - // DMA config - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = 0; // raz - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = - ( ((pTransfer->buffered << 16) & AT91C_UDPHS_BUFF_COUNT) - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - | AT91C_UDPHS_CHANN_ENB ); - } - } -#endif - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Sends data frames through a USB endpoint. Sets up the transfer descriptor -/// list, writes one or two data payloads (depending on the number of FIFO bank -/// for the endpoint) and then starts the actual transfer. The operation invoke -/// a callback with RC USBD_STATUS_PARTIAL_DONE each time when a buffer is -/// transferred and is complete when all the data has been sent. -/// -/// *If the size of the frame is greater than the size of the endpoint -/// (or twice the size if the endpoint has two FIFO banks), then the buffer -/// must be kept allocated until the frame is finished*. This means that -/// it is not possible to declare it on the stack (i.e. as a local variable -/// of a function which returns after starting a transfer). -/// -/// \param bEndpoint Endpoint number. -/// \param pMbl Pointer to a frame list with the data to send. -/// Two different list is supported, for EPs that support DMA, -/// the frame is described by USBDDmaDescriptor link list, -/// for EPs that uses FIFO the frame is described by -/// USBDTransferBuffer array. -/// For DMA transfer, the size of each frame is limited by the -/// max size of one DMA transfer. When using DMA, the frame list -/// size and size of each frame should be larger so that more -/// efficiency is achieved and CPU could have more time on -/// handler of each buffer end event. -/// \param wListSize Size of the frame list. -/// \param bCircList Circle the list. -/// \param wStartNdx Starting buffer index in the list. -/// \param fCallback Optional callback function to invoke when the transfer is -/// complete. -/// \param pArgument Optional argument to the callback function. -/// \return USBD_STATUS_SUCCESS if the transfer has been started; -/// otherwise, the corresponding error status code. -/// \see USBDDmaDescriptor, USBDTransferBuffer -//------------------------------------------------------------------------------ -char USBD_MblWrite( unsigned char bEndpoint, - void *pMbl, - unsigned short wListSize, - unsigned char bCircList, - unsigned short wStartNdx, - MblTransferCallback fCallback, - void *pArgument ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer); - unsigned short i; - - // EP0 is not suitable for Mbl - if (bEndpoint == 0) { - - return USBD_STATUS_INVALID_PARAMETER; - } - - // Check that the endpoint is in Idle state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - //return USBD_STATUS_LOCKED; - } - // Setup state - pEndpoint->state = UDP_ENDPOINT_SENDINGM; - - TRACE_DEBUG_WP("WriteM%d(0x%x,%d) ", bEndpoint, pMbl, wListSize); - - // Start from first if not circled list - if (!bCircList) wStartNdx = 0; - -#ifdef DMA - if (UDP_IsDmaUsed(bEndpoint)) { - - DmaLlTransfer *pDmallt = (DmaLlTransfer*)&(pEndpoint->transfer); - USBDDmaDescriptor * pDi = (USBDDmaDescriptor*)pMbl; - - // DMA config - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = 0; - AT91C_BASE_UDPHS->UDPHS_IEN &= ~(1 << SHIFT_DMA << bEndpoint); - - // Setup the transfer descriptor - pDmallt->pMbl = (USBDDmaDescriptor*)pMbl; - pDmallt->listSize = wListSize; - pDmallt->fCallback = fCallback; - pDmallt->pArgument = pArgument; - pDmallt->circList = bCircList; - pDmallt->allUsed = 0; - - // Check all buffers, fill settings - for (i = 0; i < wListSize - 1; i ++) { - - if (pDi->bufferLength > DMA_MAX_FIFO_SIZE) { - - TRACE_ERROR("DMA buffer size %d exceeds max %d\n\r", - pDi->bufferLength, DMA_MAX_FIFO_SIZE); - return USBD_STATUS_INVALID_PARAMETER; - } - - // Channel control value - pDi->ctrlSettings = AT91C_UDPHS_CHANN_ENB - | AT91C_UDPHS_LDNXT_DSC - | AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - | AT91C_UDPHS_DESC_LD_IT - ; - pDi->used = 0; - pDi = pDi->pNxtDesc; - } - - // Circled list check - pDi->used = 0; - if (bCircList) { - - pDi->pNxtDesc = pDmallt->pMbl; - pDi->ctrlSettings = AT91C_UDPHS_CHANN_ENB - | AT91C_UDPHS_LDNXT_DSC - | AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - //| AT91C_UDPHS_DESC_LD_IT - ; - } - else { - - pDi->pNxtDesc = 0; - pDi->ctrlSettings = AT91C_UDPHS_CHANN_ENB - //| AT91C_UDPHS_LDNXT_DSC - | AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - //| AT91C_UDPHS_DESC_LD_IT - ; - } - - // Start from 'wStartNdx'th descriptor - pDi = (USBDDmaDescriptor*)pMbl; - for (;wStartNdx; wStartNdx --) { - pDi = pDi->pNxtDesc; - } - pDmallt->pCurrBuffer = (USBDDmaDescriptor*)pDi; - pDmallt->pFreedBuffer = (USBDDmaDescriptor*)pDi; - - // Disable DMA when interrupt happenned - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_INTDIS_DMA; - - // Clear unwanted interrupts - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMASTATUS; - // Enable DMA endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_DMA << bEndpoint); - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMANXTDSC = (unsigned int)pMbl; - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = AT91C_UDPHS_LDNXT_DSC - //| AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - //| AT91C_UDPHS_END_B_EN - //| AT91C_UDPHS_END_BUFFIT - //| AT91C_UDPHS_DESC_LD_IT - ; - - return USBD_STATUS_SUCCESS; - } -#endif - - // DMA is not used - { - unsigned char nbBanks = CHIP_USB_ENDPOINTS_BANKS(bEndpoint); - - // Setup the transfer descriptor - pTransfer->pMbl = (USBDTransferBuffer*)pMbl; - pTransfer->listSize = wListSize; - pTransfer->fCallback = fCallback; - pTransfer->pArgument = pArgument; - pTransfer->currBuffer = wStartNdx; - pTransfer->freedBuffer = 0; - pTransfer->pLastLoaded = &(((USBDTransferBuffer*)pMbl)[wStartNdx]); - pTransfer->circList = bCircList; - pTransfer->allUsed = 0; - - // Clear all buffer - for (i = 0; i < wListSize; i ++) { - - pTransfer->pMbl[i].transferred = 0; - pTransfer->pMbl[i].buffered = 0; - pTransfer->pMbl[i].remaining = pTransfer->pMbl[i].size; - } - - // Fill data into FIFO - for (; - nbBanks && pTransfer->pMbl[pTransfer->currBuffer].remaining; - nbBanks --) { - - UDPHS_MblWriteFifo(bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = - AT91C_UDPHS_TX_PK_RDY; - } - - // Enable interrup - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_INTERUPT << bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = 0 - //| AT91C_UDPHS_TX_COMPLT - | AT91C_UDPHS_TX_PK_RDY - ; - return USBD_STATUS_SUCCESS; - } -} - -//------------------------------------------------------------------------------ -/// Reads incoming data on an USB endpoint (OUT) -/// \param bEndpoint Index of endpoint -/// \param *pData Data to be readen -/// \param dLength Data length to be receive -/// \param fCallback Callback to be call after the success command -/// \param *pArgument Callback argument -/// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -char USBD_Read( unsigned char bEndpoint, - void *pData, - unsigned int dLength, - TransferCallback fCallback, - void *pArgument ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); - - // Return if the endpoint is not in IDLE state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Read%d(%d) ", bEndpoint, dLength); - - // Endpoint enters Receiving state - pEndpoint->state = UDP_ENDPOINT_RECEIVING; - - // Set the transfer descriptor - pTransfer->pData = pData; - pTransfer->remaining = dLength; - pTransfer->buffered = 0; - pTransfer->transferred = 0; - pTransfer->fCallback = fCallback; - pTransfer->pArgument = pArgument; - -#ifdef DMA - // Test if endpoint type control - if(AT91C_UDPHS_EPT_TYPE_CTL_EPT == (AT91C_UDPHS_EPT_TYPE&(AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG))) { -#endif - // Control endpoint - // Enable endpoint IT - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_INTERUPT << bEndpoint); - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCTLENB = AT91C_UDPHS_RX_BK_RDY; -#ifdef DMA - } - else { - if( CHIP_USB_ENDPOINTS_DMA(bEndpoint) == 0 ) { - TRACE_FATAL("Endpoint has no DMA\n\r"); - } - TRACE_DEBUG_WP("Read%d(%d) ", bEndpoint, dLength); - - // Others endpoints (not control) - if( pTransfer->remaining > DMA_MAX_FIFO_SIZE ) { - - // Transfer the max - pTransfer->buffered = DMA_MAX_FIFO_SIZE; - } - else { - // Transfer the good size - pTransfer->buffered = pTransfer->remaining; - } - - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMAADDRESS = (unsigned int)(pTransfer->pData); - - // Clear unwanted interrupts - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMASTATUS; - - // Enable DMA endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_IEN |= (1 << SHIFT_DMA << bEndpoint); - - TRACE_DEBUG_WP("\n\r_RR:%d ", pTransfer->remaining ); - TRACE_DEBUG_WP("B:%d ", pTransfer->buffered ); - TRACE_DEBUG_WP("T:%d ", pTransfer->transferred ); - - // DMA config - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = 0; // raz - AT91C_BASE_UDPHS->UDPHS_DMA[bEndpoint].UDPHS_DMACONTROL = - ( ((pTransfer->buffered << 16) & AT91C_UDPHS_BUFF_COUNT) - | AT91C_UDPHS_END_TR_EN - | AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - | AT91C_UDPHS_CHANN_ENB ); - } -#endif - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Reuse first used/released buffer with new buffer address and size to be used -/// in transfer again. Only valid when frame list is ringed. Can be used for -/// both read & write. -/// \param bEndpoint Endpoint number. -/// \param pNewBuffer Pointer to new buffer with data to send (0 to keep last). -/// \param wNewSize Size of the data buffer -//------------------------------------------------------------------------------ -char USBD_MblReuse( unsigned char bEndpoint, - unsigned char *pNewBuffer, - unsigned short wNewSize ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer); - USBDTransferBuffer *pBi = &(pTransfer->pMbl[pTransfer->freedBuffer]); - - // Only for Multi-buffer-circle list - if (bEndpoint != 0 - && (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM - || pEndpoint->state == UDP_ENDPOINT_SENDINGM)) { - } - else { - - return USBD_STATUS_WRONG_STATE; - } - - TRACE_DEBUG_WP("MblReuse(%d), st%x, circ%d\n\r", - bEndpoint, pEndpoint->state, pTransfer->circList); - -#ifdef DMA - if (UDP_IsDmaUsed(bEndpoint)) { - - DmaLlTransfer *pDmallt = (DmaLlTransfer*)&(pEndpoint->transfer); - USBDDmaDescriptor *pDi = pDmallt->pFreedBuffer; - - // ONLY for circled list - if (!pDmallt->circList) { - - return USBD_STATUS_WRONG_STATE; - } - - // Check if there is freed buffer - if ((pDi == 0) || (pDi && !pDi->used) ) { - - return USBD_STATUS_LOCKED; - } - - // Update transfer information - pDmallt->pFreedBuffer = pDi->pNxtDesc; - if (pNewBuffer) { - - pDi->pDataAddr = pNewBuffer; - pDi->bufferLength = wNewSize; - } - /* - pDi->ctrlSettings = AT91C_UDPHS_CHANN_ENB - | AT91C_UDPHS_LDNXT_DSC - | AT91C_UDPHS_END_TR_EN - //| AT91C_UDPHS_END_TR_IT - | AT91C_UDPHS_END_B_EN - | AT91C_UDPHS_END_BUFFIT - | AT91C_UDPHS_DESC_LD_IT - ; */ - pDi->used = 0; - - pDmallt->allUsed = 0; - - return USBD_STATUS_SUCCESS; - } -#endif - - // DMA is not used - { - - // ONLY for circled list - if (!pTransfer->circList) { - - return USBD_STATUS_WRONG_STATE; - } - - // Check if there is freed buffer - if (pTransfer->freedBuffer == pTransfer->currBuffer - && !pTransfer->allUsed) { - - return USBD_STATUS_LOCKED; - } - - // Update transfer information - if ((++ pTransfer->freedBuffer) == pTransfer->listSize) - pTransfer->freedBuffer = 0; - if (pNewBuffer) { - - pBi->pBuffer = pNewBuffer; - pBi->size = wNewSize; - } - pBi->buffered = 0; - pBi->transferred = 0; - pBi->remaining = pBi->size; - - // At least one buffer is not processed - pTransfer->allUsed = 0; - } - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Put endpoint into Halt state -/// \param bEndpoint Index of endpoint -//------------------------------------------------------------------------------ -void USBD_Halt( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - - TRACE_INFO("usbd_Halt%d ", bEndpoint); - // Check that endpoint is enabled and not already in Halt state - if( (pEndpoint->state != UDP_ENDPOINT_DISABLED) - && (pEndpoint->state != UDP_ENDPOINT_HALTED) ) { - - TRACE_INFO("Halt%d ", bEndpoint); - - // Abort the current transfer if necessary - UDPHS_EndOfTransfer(bEndpoint, USBD_STATUS_ABORTED); - - // Put endpoint into Halt state - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = AT91C_UDPHS_FRCESTALL; - pEndpoint->state = UDP_ENDPOINT_HALTED; - -#ifdef DMA - // Test if endpoint type control - if(AT91C_UDPHS_EPT_TYPE_CTL_EPT == (AT91C_UDPHS_EPT_TYPE&(AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCFG))) { -#endif - // Enable the endpoint interrupt - AT91C_BASE_UDPHS->UDPHS_IEN |= (1<UDPHS_IEN |= (1<state != UDP_ENDPOINT_DISABLED) { - - TRACE_DEBUG_WP("Unhalt%d ", bEndpoint); - - // Return endpoint to Idle state - pEndpoint->state = UDP_ENDPOINT_IDLE; - - // Clear FORCESTALL flag - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTCLRSTA = AT91C_UDPHS_TOGGLESQ | AT91C_UDPHS_FRCESTALL; - - // Reset Endpoint Fifos - AT91C_BASE_UDPHS->UDPHS_EPTRST = (1<state == UDP_ENDPOINT_HALTED) { - status = 1; - } - return( status ); -} - -//------------------------------------------------------------------------------ -/// IS High Speed device working in High Speed ? -/// \return 1 if the device is in High Speed; otherwise 0 (Full Speed) -//------------------------------------------------------------------------------ -unsigned char USBD_IsHighSpeed( void ) -{ - unsigned char status = 0; - - if( AT91C_UDPHS_SPEED == (AT91C_BASE_UDPHS->UDPHS_INTSTA & AT91C_UDPHS_SPEED) ) - { - // High Speed - TRACE_DEBUG_WP("High Speed\n\r"); - status = 1; - } - else { - TRACE_DEBUG_WP("Full Speed\n\r"); - } - return( status ); -} - - -//------------------------------------------------------------------------------ -/// Causes the endpoint to acknowledge the next received packet with a STALL -/// handshake. -/// Further packets are then handled normally. -/// \param bEndpoint Index of endpoint -/// \return Operation result code: USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS -//------------------------------------------------------------------------------ -unsigned char USBD_Stall( unsigned char bEndpoint ) -{ - Endpoint *pEndpoint = &(endpoints[bEndpoint]); - - // Check that endpoint is in Idle state - if (pEndpoint->state != UDP_ENDPOINT_IDLE) { - - TRACE_WARNING("UDP_Stall: Endpoint%d locked\n\r", bEndpoint); - return USBD_STATUS_LOCKED; - } - - TRACE_DEBUG_WP("Stall%d ", bEndpoint); - - AT91C_BASE_UDPHS->UDPHS_EPT[bEndpoint].UDPHS_EPTSETSTA = AT91C_UDPHS_FRCESTALL; - - return USBD_STATUS_SUCCESS; -} - -//------------------------------------------------------------------------------ -/// Activates a remote wakeup procedure -//------------------------------------------------------------------------------ -void USBD_RemoteWakeUp(void) -{ - TRACE_DEBUG_WP("Remote WakeUp\n\r"); - - // Device is currently suspended - if (deviceState == USBD_STATE_SUSPENDED) { - - TRACE_DEBUG_WP("RW\n\r"); - UDPHS_EnableUsbClock(); - - // Activates a remote wakeup - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_REWAKEUP; - - while ((AT91C_BASE_UDPHS->UDPHS_CTRL&AT91C_UDPHS_REWAKEUP) == AT91C_UDPHS_REWAKEUP) { - - TRACE_DEBUG_WP("W"); - } - UDPHS_EnableBIAS(); - } - // Device is NOT suspended - else { - - TRACE_WARNING("USBD_RemoteWakeUp: Device is not suspended\n\r"); - } -} - -//------------------------------------------------------------------------------ -/// Sets the device address -/// \param address Adress to be set -//------------------------------------------------------------------------------ -void USBD_SetAddress( unsigned char address ) -{ - TRACE_DEBUG_WP("SetAddr(%d) ", address); - - // Set address - AT91C_BASE_UDPHS->UDPHS_CTRL &= ~AT91C_UDPHS_DEV_ADDR; // RAZ Address - AT91C_BASE_UDPHS->UDPHS_CTRL |= address | AT91C_UDPHS_FADDR_EN; - - // If the address is 0, the device returns to the Default state - if (address == 0) { - deviceState = USBD_STATE_DEFAULT; - } - // If the address is non-zero, the device enters the Address state - else { - deviceState = USBD_STATE_ADDRESS; - } -} - -//------------------------------------------------------------------------------ -/// Changes the device state from Address to Configured, or from Configured -/// to Address. -/// This method directly access the last received SETUP packet to decide on -/// what to do. -/// \param cfgnum configuration number -//------------------------------------------------------------------------------ -void USBD_SetConfiguration( unsigned char cfgnum ) -{ - TRACE_DEBUG_WP("SetCfg(%d) ", cfgnum); - - // Check the request - if( cfgnum != 0 ) { - - // Enter Configured state - deviceState = USBD_STATE_CONFIGURED; - } - // If the configuration number is zero, the device goes back to the Address - // state - else { - - // Go back to Address state - deviceState = USBD_STATE_ADDRESS; - - // Abort all transfers - UDPHS_DisableEndpoints(); - } -} - -//------------------------------------------------------------------------------ -/// Enables the pull-up on the D+ line to connect the device to the USB. -//------------------------------------------------------------------------------ -void USBD_Connect( void ) -{ - TRACE_DEBUG_WP("Conn "); -#if defined(CHIP_USB_PULLUP_INTERNAL) - AT91C_BASE_UDPHS->UDPHS_CTRL &= ~AT91C_UDPHS_DETACH; // Pull Up on DP - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_PULLD_DIS; // Disable Pull Down - -#elif defined(CHIP_USB_PULLUP_INTERNAL_BY_MATRIX) - TRACE_DEBUG_WP("PUON 1\n\r"); - AT91C_BASE_MATRIX->MATRIX_USBPCR |= AT91C_MATRIX_USBPCR_PUON; - -#elif defined(CHIP_USB_PULLUP_EXTERNAL) - -#ifdef PIN_USB_PULLUP - const Pin pinPullUp = PIN_USB_PULLUP; - if( pinPullUp.attribute == PIO_OUTPUT_0 ) { - - PIO_Set(&pinPullUp); - } - else { - - PIO_Clear(&pinPullUp); - } -#else - #error unsupported now -#endif - -#elif !defined(CHIP_USB_PULLUP_ALWAYSON) - #error Unsupported pull-up type. - -#endif -} - -//------------------------------------------------------------------------------ -/// Disables the pull-up on the D+ line to disconnect the device from the bus. -//------------------------------------------------------------------------------ -void USBD_Disconnect( void ) -{ - TRACE_DEBUG_WP("Disc "); - -#if defined(CHIP_USB_PULLUP_INTERNAL) - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_DETACH; // detach - AT91C_BASE_UDPHS->UDPHS_CTRL &= ~AT91C_UDPHS_PULLD_DIS; // Enable Pull Down - -#elif defined(CHIP_USB_PULLUP_INTERNAL_BY_MATRIX) - AT91C_BASE_MATRIX->MATRIX_USBPCR &= ~AT91C_MATRIX_USBPCR_PUON; - -#elif defined(CHIP_USB_PULLUP_EXTERNAL) - -#ifdef PIN_USB_PULLUP - const Pin pinPullUp = PIN_USB_PULLUP; - if (pinPullUp.attribute == PIO_OUTPUT_0) { - - PIO_Clear(&pinPullUp); - } - else { - - PIO_Set(&pinPullUp); - } -#else - #error unsupported now -#endif - -#elif !defined(CHIP_USB_PULLUP_ALWAYSON) - #error Unsupported pull-up type. - -#endif - - // Device returns to the Powered state - if (deviceState > USBD_STATE_POWERED) { - - deviceState = USBD_STATE_POWERED; - } - if (previousDeviceState > USBD_STATE_POWERED) { - - previousDeviceState = USBD_STATE_POWERED; - } -} - -//------------------------------------------------------------------------------ -/// Certification test for High Speed device. -/// \param bIndex Test to be done -//------------------------------------------------------------------------------ -void USBD_Test( unsigned char bIndex ) -{ - char *pFifo; - unsigned char i; - - AT91C_BASE_UDPHS->UDPHS_IEN &= ~AT91C_UDPHS_DET_SUSPD; // remove suspend for TEST - AT91C_BASE_UDPHS->UDPHS_TST |= AT91C_UDPHS_SPEED_CFG_HS; // force High Speed (remove suspend) - - switch( bIndex ) { - - case USBFeatureRequest_TESTPACKET: - TRACE_DEBUG_WP("TEST_PACKET "); - - AT91C_BASE_UDPHS->UDPHS_DMA[1].UDPHS_DMACONTROL = 0; - AT91C_BASE_UDPHS->UDPHS_DMA[2].UDPHS_DMACONTROL = 0; - - // Configure endpoint 2, 64 bytes, direction IN, type BULK, 1 bank - AT91C_BASE_UDPHS->UDPHS_EPT[2].UDPHS_EPTCFG = AT91C_UDPHS_EPT_SIZE_64 | AT91C_UDPHS_EPT_DIR_IN | AT91C_UDPHS_EPT_TYPE_BUL_EPT | AT91C_UDPHS_BK_NUMBER_1; - while( (signed int)(AT91C_BASE_UDPHS->UDPHS_EPT[2].UDPHS_EPTCFG & AT91C_UDPHS_EPT_MAPD) != (signed int)AT91C_UDPHS_EPT_MAPD ) {} - - AT91C_BASE_UDPHS->UDPHS_EPT[2].UDPHS_EPTCTLENB = AT91C_UDPHS_EPT_ENABL; - - // Write FIFO - pFifo = (char*)((unsigned int *)(AT91C_BASE_UDPHS_EPTFIFO->UDPHS_READEPT0) + (EPT_VIRTUAL_SIZE * 2)); - for( i=0; iUDPHS_TST |= AT91C_UDPHS_TST_PKT; - // Send packet - AT91C_BASE_UDPHS->UDPHS_EPT[2].UDPHS_EPTSETSTA = AT91C_UDPHS_TX_PK_RDY; - break; - - case USBFeatureRequest_TESTJ: - TRACE_DEBUG_WP("TEST_J "); - AT91C_BASE_UDPHS->UDPHS_TST = AT91C_UDPHS_TST_J; - break; - - case USBFeatureRequest_TESTK: - TRACE_DEBUG_WP("TEST_K "); - AT91C_BASE_UDPHS->UDPHS_TST = AT91C_UDPHS_TST_K; - break; - - case USBFeatureRequest_TESTSE0NAK: - TRACE_DEBUG_WP("TEST_SEO_NAK "); - AT91C_BASE_UDPHS->UDPHS_IEN = 0; // for test - break; - - case USBFeatureRequest_TESTSENDZLP: - //while( 0 != (AT91C_BASE_UDPHS->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_TX_PK_RDY ) ) {} - AT91C_BASE_UDPHS->UDPHS_EPT[0].UDPHS_EPTSETSTA = AT91C_UDPHS_TX_PK_RDY; - //while( 0 != (AT91C_BASE_UDPHS->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_TX_PK_RDY ) ) {} - TRACE_DEBUG_WP("SEND_ZLP "); - break; - } - TRACE_DEBUG_WP("\n\r"); -} - - -//------------------------------------------------------------------------------ -/// Initializes the specified USB driver -/// This function initializes the current FIFO bank of endpoints, -/// configures the pull-up and VBus lines, disconnects the pull-up and -/// then trigger the Init callback. -//------------------------------------------------------------------------------ -void USBD_Init(void) -{ - unsigned char i; - - TRACE_DEBUG_WP("USBD Init()\n\r"); - - // Reset endpoint structures - UDPHS_ResetEndpoints(); - - // Enables the USB Clock - UDPHS_EnableUsbClock(); - - // Configure the pull-up on D+ and disconnect it -#if defined(CHIP_USB_PULLUP_INTERNAL) - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_DETACH; // detach - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_PULLD_DIS; // Disable Pull Down - -#elif defined(CHIP_USB_PULLUP_INTERNAL_BY_MATRIX) - TRACE_DEBUG_WP("PUON 0\n\r"); - AT91C_BASE_MATRIX->MATRIX_USBPCR &= ~AT91C_MATRIX_USBPCR_PUON; - -#elif defined(CHIP_USB_PULLUP_EXTERNAL) -#ifdef PIN_USB_PULLUP - const Pin pinPullUp = PIN_USB_PULLUP; - PIO_Configure(&pinPullUp, 1); - if (pinPullUp.attribute == PIO_OUTPUT_0) { - - PIO_Clear(&pinPullUp); - } - else { - - PIO_Set(&pinPullUp); - } -#else - #error unsupported now -#endif -#elif !defined(CHIP_USB_PULLUP_ALWAYSON) - #error Unsupported pull-up type. - -#endif - - // Reset and enable IP UDPHS - AT91C_BASE_UDPHS->UDPHS_CTRL &= ~AT91C_UDPHS_EN_UDPHS; - AT91C_BASE_UDPHS->UDPHS_CTRL |= AT91C_UDPHS_EN_UDPHS; - // Enable and disable of the transceiver is automaticaly done by the IP. - - // With OR without DMA !!! - // Initialization of DMA - for( i=1; i<=((AT91C_BASE_UDPHS->UDPHS_IPFEATURES & AT91C_UDPHS_DMA_CHANNEL_NBR)>>4); i++ ) { - - // RESET endpoint canal DMA: - // DMA stop channel command - AT91C_BASE_UDPHS->UDPHS_DMA[i].UDPHS_DMACONTROL = 0; // STOP command - - // Disable endpoint - AT91C_BASE_UDPHS->UDPHS_EPT[i].UDPHS_EPTCTLDIS = AT91C_UDPHS_SHRT_PCKT - | AT91C_UDPHS_BUSY_BANK - | AT91C_UDPHS_NAK_OUT - | AT91C_UDPHS_NAK_IN - | AT91C_UDPHS_STALL_SNT - | AT91C_UDPHS_RX_SETUP - | AT91C_UDPHS_TX_PK_RDY - | AT91C_UDPHS_TX_COMPLT - | AT91C_UDPHS_RX_BK_RDY - | AT91C_UDPHS_ERR_OVFLW - | AT91C_UDPHS_MDATA_RX - | AT91C_UDPHS_DATAX_RX - | AT91C_UDPHS_NYET_DIS - | AT91C_UDPHS_INTDIS_DMA - | AT91C_UDPHS_AUTO_VALID - | AT91C_UDPHS_EPT_DISABL; - - // Clear status endpoint - AT91C_BASE_UDPHS->UDPHS_EPT[i].UDPHS_EPTCLRSTA = AT91C_UDPHS_TOGGLESQ - | AT91C_UDPHS_FRCESTALL - | AT91C_UDPHS_RX_BK_RDY - | AT91C_UDPHS_TX_COMPLT - | AT91C_UDPHS_RX_SETUP - | AT91C_UDPHS_STALL_SNT - | AT91C_UDPHS_NAK_IN - | AT91C_UDPHS_NAK_OUT; - - // Reset endpoint config - AT91C_BASE_UDPHS->UDPHS_EPT[i].UDPHS_EPTCTLENB = 0; - - // Reset DMA channel (Buff count and Control field) - AT91C_BASE_UDPHS->UDPHS_DMA[i].UDPHS_DMACONTROL = AT91C_UDPHS_LDNXT_DSC; // NON STOP command - - // Reset DMA channel 0 (STOP) - AT91C_BASE_UDPHS->UDPHS_DMA[i].UDPHS_DMACONTROL = 0; // STOP command - - // Clear DMA channel status (read the register for clear it) - AT91C_BASE_UDPHS->UDPHS_DMA[i].UDPHS_DMASTATUS = AT91C_BASE_UDPHS->UDPHS_DMA[i].UDPHS_DMASTATUS; - - } - - AT91C_BASE_UDPHS->UDPHS_TST = forceUsbFS ? AT91C_UDPHS_SPEED_CFG_FS : 0; - AT91C_BASE_UDPHS->UDPHS_IEN = 0; - AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_UPSTR_RES - | AT91C_UDPHS_ENDOFRSM - | AT91C_UDPHS_WAKE_UP - | AT91C_UDPHS_ENDRESET - | AT91C_UDPHS_IEN_SOF - | AT91C_UDPHS_MICRO_SOF - | AT91C_UDPHS_DET_SUSPD; - - // Device is in the Attached state - deviceState = USBD_STATE_SUSPENDED; - previousDeviceState = USBD_STATE_POWERED; - - // Enable interrupts - AT91C_BASE_UDPHS->UDPHS_IEN = AT91C_UDPHS_ENDOFRSM - | AT91C_UDPHS_WAKE_UP - | AT91C_UDPHS_DET_SUSPD; - - // Disable USB clocks - UDPHS_DisableUsbClock(); - - // Configure interrupts - USBDCallbacks_Initialized(); -} - -//------------------------------------------------------------------------------ -/// Configure USB Speed, should be invoked before USB attachment. -/// \param forceFS Force to use FS mode. -//------------------------------------------------------------------------------ -void USBD_ConfigureSpeed(unsigned char forceFS) -{ - if (forceFS) { - AT91C_BASE_UDPHS->UDPHS_TST |= AT91C_UDPHS_SPEED_CFG_FS; - } - else { - AT91C_BASE_UDPHS->UDPHS_TST &= ~AT91C_UDPHS_SPEED_CFG_FS; - } -} - - -//------------------------------------------------------------------------------ -/// Returns the current state of the USB device. -/// \return Device current state. -//------------------------------------------------------------------------------ -unsigned char USBD_GetState( void ) -{ - return deviceState; -} - - diff --git a/src/ersky9x/libraries/usb/device/core/core.dir b/src/ersky9x/libraries/usb/device/core/core.dir deleted file mode 100644 index fcf0dc086..000000000 --- a/src/ersky9x/libraries/usb/device/core/core.dir +++ /dev/null @@ -1,41 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !Purpose -/// -/// This directory contains structures, definitions and functions for AT91 UDP. -/// They can be divided into two groups: -/// - Hardware layer: low-level operations on the USB UDP controller -/// - USBD_OTGHS.c USBD_UDP.c USBD_UDPHS.c -/// - USB Device API: other files in the directory, offers hardware-independent -/// methods and structures -//------------------------------------------------------------------------------ - diff --git a/src/ersky9x/libraries/usb/device/device.dir b/src/ersky9x/libraries/usb/device/device.dir deleted file mode 100644 index 2988e1e22..000000000 --- a/src/ersky9x/libraries/usb/device/device.dir +++ /dev/null @@ -1,655 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for USB %device -/// applications with Atmel AT91 microcontrollers and USB %device framework. -/// -/// You can develop your own USB %device products based on the class-specific -/// driver code provided, or just take them as a refference. -/// -/// !!!Contents -/// There are two groups for the implement: -/// -# The hardware interface driver for USB peripheral on AT91 -/// microcontrollers (UDP or UDPHS), this is a part of the "AT91 USB -/// framework". -/// - "core": hardware interface driver for AT91 USB peripheral -/// -# The %device class driver to class-specific %device. -/// - "audio-speaker" -/// - "ccid" -/// - "cdc-serial" -/// - "hid-keyboard" -/// - "massstorage" -/// -/// For more information about what a particular group contains, please refer to -/// its documentation page. -/// -/// \note -/// Depending on the project, not all the subdirectories will be available -/// (i.e. the #ccid# directory will not be in projects without USB CCID -/// function). -//------------------------------------------------------------------------------ - -/** - \page "USBD API" - - See "USBD API Structures" and "USBD API Methods".\n - - !!!USBD API Structures - - Several specific structures are used by the USBD API to perform various - operations, such as invoking callbacks or accessing the USBD controller. - - There are two %main structures: - - USBDDriver: - It is the %main structure of the USB API. It should be instanciated - in class-specific USB %device driver or user application. - - USBDDriverDescriptors: - It is a list of all descriptors used by a USB %device driver. It - should be instanciated in class-specific USB %device driver or - user application and passed to USBD by USBDDriver_Initialize. - - !!!USBD API Methods - - The USB API provides serveral methods to perform the following operations: - - Changing the %device state - - USBD_Init - - USBD_Connect, USBD_Disconnect - - USBD_SetAddress - - USBD_SetConfiguration - - USBD_GetState - - "USB Device State Diagram" - - Handling events coming from the USB controller - - USBD_IrqHandler - - Modifying the behavior of an endpoint - - USBD_ConfigureEndpoint - - USBD_Stall - - USBD_Halt - - USBD_Unhalt - - USBD_IsHalted - - Transferring data - - USBD_Write - - USBD_Read - - USBD_IsoWrite - - Special functions - - USBD_RemoteWakeUp - - See "USBD API Methods" for detailed informations. - -*/ - -/** - \page "USBD API Structures" - - !!!USBD API Structures - - Several specific structures are used by the USBD API to perform various - operations, such as invoking callbacks or accessing the USBD controller. - - There are two %main structures: - - USBDDriver: - It is the %main structure of the USB API. It should be instanciated - in class-specific USB %device driver or user application. - - USBDDriverDescriptors: - It is a list of all descriptors used by a USB %device driver. It - should be instanciated in class-specific USB %device driver or - user application and passed to USBD by USBDDriver_Initialize. - - */ - -/** - \page "USBD API Methods" - - !!!USB API methods - - The USB API provides serveral methods to perform the following operations: - - Changing the %device state - - USBD_Init - - USBD_Connect, USBD_Disconnect - - USBD_SetAddress - - USBD_SetConfiguration - - USBD_GetState - - "USB Device State Diagram" - - Handling events coming from the USB controller - - USBD_IrqHandler - - Modifying the behavior of an endpoint - - USBD_ConfigureEndpoint - - USBD_Stall - - USBD_Halt - - USBD_Unhalt - - USBD_IsHalted - - Transferring data - - USBD_Write - - USBD_Read - - USBD_IsoWrite - - Special functions - - USBD_RemoteWakeUp - - !!!Controlling the Device State - - Chapter 9 of the USB specification 2.0 describes the various states a %device - can be in. Most of the methods of this API are used to change between those - states. - - !!USBD_Init - - USBD_Init is the first method to call in a user application. Technically, it - must occur just before entering the Attached state. It performs the following - actions: - - USB Device driver and endpoint state initialization - - D+ pull-up configuration and disabling - - UDP hardware initialization (Peripheral and clock init) - - A USB %device uses a pull-up on the D+ line to signal its connection to the - host. Depending on the USB controller present on the chip, either an - internal or external pull-up is used. In both cases, its configuration is - performed directly by this method. Please refer to the documentation of a - particular controller for more information about the D+ pull-up. - - The ini callback has to perform several mandatory operations at this point. - You can find the default operations in USBDCallbacks_Initialized. - - !!USBD_Connect, USBD_Disconnect - - These two methods control the state of the D+ upll-up. This makes it possible - to connect of disconnect the %device by software when needed. USBD_Connect - changes the %device state from Powered to Default, while USBD_Disconnect - changes from either Default, Address or Configured to Powered. - - !!USBD_SetAddress - - USBD_SetAddress extracts the information from the last received - SETUP packet to either change the %device state from Default to - Address or from Address to Default. The difference is made - depending on the value of the wValue field of the request. - - This method must only be called right after the SET_ADDRESS - request is received. - - !!USBD_SetConfiguration - - This function operates in a way similar to USBD_SetAddress. When the SETUP - packet containing a SET_CONFIGURATION request is received, - USBD_SetConfiguration should be called to extract the new configuration - value to adopt. If the wValue field of the request is non-zero, then the - %device must adopt the new configuration and enter the Configuration state; - otherwise, it returns (or stays) in the Address state. - - !!USBD_GetState - - As its name implies, USBD_GetState simply returns the current state of the USB - driver. See state definitions on "USB %device states". - - USBD_STATE_SUSPENDED - - USBD_STATE_ATTACHED - - USBD_STATE_POWERED - - USBD_STATE_DEFAULT - - USBD_STATE_ADDRESS - - USBD_STATE_CONFIGURED - - !!Device State Diagram - See "USB Device State Diagram" - - !!!Event Handling (USBD_IrqHandler) - Several events can occur at the USB controller level: - - End of bus reset - - Reception of a SETUP packet - - Change of bus activity (active -> idle -> active ..) - - Completin of an endpoint operation - - ... - - Whenever such an event occurs, it must be forwarded to the USBD API to be - handled in an appropriate way. The USBD_IrqHandler performs this - functionality, so the controller interrupt must be configured to call it. - - Several #callbacks# can be triggered depending on the event notified by - the controller: - - Suspend, when the bus is idle - - Resume, when the bus becomes active again - - NewRequest, when a setup packet is received on a control endpoint - - StartOfFrame, every 1 ms (for full-speed controllers) or 125us (for high- - speed controllers) - - More information about these callbacks and their expected behavior can be - found in "USBD Callback API". - - !!!Endpoint Behavior Modification - - The USBD API offers following functions to control how an endpoint operates. - - USBD_ConfigureEndpoint - - USBD_Stall - - USBD_Halt - - USBD_Unhalt - - USBD_IsHalted - - !!USBD_ConfigureEndpoint - USBD_ConfigureEndpoint is used to configure an endpoint at the USB controller - level. An appropriate endpoint descriptor must be provided to do that. The - descriptor is used to configure the endpoint type (either Control, Bulk, - Interrupt or Isochronous), direction (IN or OUT) and address. - - Control endpoint 0 is automatically configured by the USBD API when the End of - bus reset event is signalled by the USB controller. Therefore, there is no need - to do it manually. - - !!USBD_Stall - The USBD_Stall method causes and endpoint to acknowledge its next received - packet with a STALL handshake. Further packets are then handled normally. - - Most of the time, this method should be used with endpoint 0 to signal the - host that the %device cannot process a command. - - !!USBD_Halt, USBD_Unhalt, USBD_IsHalted - USBD_Halt sets the Halt status of an endpoint. When in Halt mode, every - received packet is acknowledged with a STALL handshake instead of being - handled normally. - - #}USB_Halt#} can be called either with the USB_SET_FEATURE, USB_CLEAR_FEATURE - or USB_GET_STATUS parameter to modify the endpoint Halt state. - - USBD_Unhalt clears the Halt status of an endpoint. - - USBD_IsHalted gets the Halt status of an endpoint. - - !!!Data Transfer - Data transfer (IN or OUT) on an endpoint can be performed by calling two - methods, USBD_Write and USBD_Read. - - !!USBD_Write - The USBD_Write function sends a data payload on a specific endpoint. If the - data payload equals or exceeds the maximum packet size of the endpoint, then - several IN transactions are necessary. This method should only be called on an - IN or Control endpoint. - - The write is performed #asynchronously#, i.e., the function returns immediately - without waiting for the transfer to finish. When the transfer is complete, an - optional user-provided callback function is called. This makes it possible to - create an #OS-friendly synchronous function# by locking and unlocking a - semaphore before and after each write. - - This function handles double-buffering, if it is supported by the USB - controller and if it has been enabled for the endpoint. Do not forget that - using double-buffering is mandatory for isochronous transactions. - - - #Note# - The double-buffering this function supported is only in period of each - write action. That is, when the function is invoked to start transfer - trunk of data, the data is automatically splitted to several IN - transactions and ping-pong is started on the 2nd transaction. But when - all the data of the trunk is finished the ping-pong is stopped. So it can - not process the list of buffer that should use double-buffering all the - time. See USBD_IsoWrite for such kind of operations. - - !!USBD_Read - The USBD_Read reads incoming data on an endpoint. The transfer stops either - when the provided buffer is full, or a short packet (size inferior to the - endpoint maximum packet size) is received. This method must only be called on - an OUT or Control endpoint. - - The read is performed #asynchronously#, i.e., the function returns immediately - without waiting for the transfer to finish. When the transfer is complete, an - optional user-provided callback function is called. This makes it possible to - create an #OS-friendly synchronous function# by locking and unlocking a - semaphore before and after each read. - - This function handles #double-buffering#, if it is supported by the USB - controller and if it has been enabled for the endpoint. Do not forget that - using double-buffering is mandatory for isochronous transactions. - - !!USBD_IsoWrite - The USBD_IsoWrite function sends a buffer list on a specific endpoint. The each - buffer's payload should be equals or less than the maximum packet size of the - endpoint. The transfer ends when all buffera are sent out. And the buffer is - previously sent can be filled with new data before the transfer ends. To - maitain a ring buffer for the outgoing stream. This method should only be - called on an ISO IN endpoint. - - The write is performed #asynchronously#, i.e., the function returns immediately - without waiting for the transfer to finish. When the transfer is complete, an - optional user-provided callback function is called. This makes it possible to - create an #OS-friendly synchronous function# by locking and unlocking a - semaphore before and after each write. - - This function handles double-buffering, if it is supported by the USB - controller and if it has been enabled for the endpoint. Do not forget that - using double-buffering is mandatory for isochronous transactions. - - !!!Special Functions - - - USBD_RemoteWakeUp: This method starts a remote wakeup procedure. This makes - it possible for a suspended %device to wake a host with may itself be - suspended. - -*/ - -/** - \page "USB Device State Diagram" - - \image USBDeviceStateDiagram.png "Changing the Device State" - -*/ - -/* (Image Link Backup) -USBDeviceStateDiagram.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -USBDCallbackInvocationFlowchart.png -*/ - -/** - \page "USBD Callback API" - - !!!Callback API - - The callback API is a means of communication between the user application and - the USBD API. When particular operations must be performed, the USB driver - calls serveral external functions, refferred to as #callbacks#. They can also - be invoked to notify the user application of pending events. - - Defining all callbacks is not mandatory. For example, if the %device shall not - enter low-power mode, then it is appropriate not to provide a Suspend callback. - If a callback is mandatory, this is notified in its description. - - See USBDCallbacks.h for callback definitions. - - !!!Callback Invocation - The following events can trigger a callback: - - USB initialization: USBDCallbacks_Initialized - - End of bus reset: USBDCallbacks_Reset - - Device suspend: USBDCallbacks_Suspended - - Device resume: USBDCallbacks_Resumed - - SETUP request received: USBDCallbacks_RequestReceived - - Start of a new USB frame - - \image USBDCallbackInvocationFlowchart.png "Callback Invocation Flowchart" - - !!Init - The USBDCallbacks_Initialized callback is invoked when the USBD_Init method is - called. It has to perform several mandatory steps to make it possible to use - the API: - - If an OS is used, perform any specific operation to install the driver - - Configure USB controller interrupt - - Configure Vbus monitoring PIO and interrupt ( but it's in app layer now ) - The USB controller interrupt must be configured to #call the - USBD_IrqHandler# API function when triggered. This is necessary to have - events happening at the USB controller level handled appropriately by the API. - - If a PIO pin is connected to VBus, it is possible to monitor it by configuring - the pin as an input and enabling the PIO interrupt. The interrupt service - routine should simply check the Vbus status and then %call the USBD_Connect - and USBD_Disconnect$ function to put %device into right state. - - Finally, if an OS is being used, then the driver should probably be installed - prior to use. Interrupt configuration may also be done differently. Please - refer to the documentation of the OS for more information. - - This callback is #mandatory#. - - !!Reset - When an End of bus reset has been detected, the USBDCallbacks_Reset callback - is triggered. The callback should perform #initialization# or #re- - initialization# of the user-level application. For example, a class driver - like MSD should re-initialize its internal state when a USB reset is performed. - - !!Suspend - When the USB %device enters the Suspended state, the USB API notifies this state - change by invoking the USBDCallbacks_Suspended callback. This can happen either - when the bus is idle or when the %device is disconnected from the USB. - - If the %device should enter low-power mode when suspended, then this callback - must perform the required operations to do so, e.g., switching to a slow clock, - disabling PLLs, etc. - - - }Note: The electrical specification of the USB 2.0 defines a maximum current - consumption of 500uA for suspended %device. This includes the current passing - through pull-ups and upll-downs.} - - !!Resume - The USBDCallbacks_Resumed callback is invoked when the USB %device leaves the - Suspended state and returns to its previous state (either Powered, Default, - Address or Configured). This may happen when activity is detected on the USB, - or when the %device gets connected. - - If the %device was in low-power mode because of the Suspend callback, then this - callback must perform the necessary poerations to return the %device into a - normal operation mode, e.g., switching to a fast clock. - - !!NewRequest - When a SETUP request is received on a control endpoint, the USBD API layer - triggers the USBDCallbacks_RequestReceived callback to notify the user - application. The received request can then be accessed through the - corresponding USBGenericRequest structure. - - SETUP packets are used for class-specific requests (e.g. }GetMaxLUN} in MSD) - as well as standard USB requests (e.g. }SetConfiguration}). The former are - described in }USB Device Class Documents}, such as the }Mass Storage Bulk - Only 1.0}, the latter are defined in the USB Specification 2.0. - - - }Note: that SETUP requests which are not understood by the %device should - be acknowledged with a STALL handshake. This notifies the host that the - %device cannot process the command.} - - This callback is #mandatory#. - - !!StartOfFrame - Every 1ms (for a full-speed %device) or 125us (for a high-speed %device) a - new USB frame starts. A callback can be invoked whenever this occurs. - - Because the start-of-frame interrupt %puts some stress on the processor - (since it is called a lot), it is only activated the corresponding - callback is defined (#now it's NOT defined in current framework#). - -*/ - -/** - \page "USBD Standard Request Handler" - - !!!Standard Request Handler - - Chapter 9 of the USB specification 2.0 defines a set of standard requests - which have to be implemented by all devices. Since most class drivers treat - those requests in the standard way, the USB framework provides a way to easily - do that. - - !!!USBDDriver_RequestHandler - - USBDDriver_RequestHandler handles the standard requests in an appropriate way. - It can answer the following commands: - - - GET_DESCRIPTOR - - SET_ADDRESS - - SET_CONFIGURATION - - GET_CONFIGURATION - - CLEAR_FEATURE - - SET_FEATURE - - GET_STATUS - - Simply using this standard request handler enables a %device to be enumerated - correctly. - - !!Get Descriptor - The GET_DESCRIPTOR request is used by the host to retrieve information about - the %device by means of several descriptors. - - The standard request handler simply sends the corresponding descriptor to the - host. How these descriptors are provided to the function is discussed in - Structures. - - !!Set Address - Whenever the host wants to change the %device state from Default to Address, or - vice-versa, it sends a SET_ADDRESS request. The wValue field contains the new - address of the %device; if it is null, then the %device returns to the Default - state. - - The USBD_SetAddress function is called to perform this operation. Note that a - zero-length packet must be sent prior to doing that, to acknowledge the SETUP - transfer. - - !!Set Configuration & GetConfiguration - The SET_CONFIGURATION request makes it possible for the host to select between - one or more configurations for the %device. GET_CONFIGURATION is used to - retrieve the currently selected one. - - Those two requests are handled in a very basic way by - USBDDriver_RequestHandler: it assumes that the %device has only one - configuration. Therefore, the SET_CONFIGURATION request is simply acknowledged - with a zero-length packet, and GET_CONFIGURATION is answered with either 0 - or 1. If the user application needs more than one configuration, it will be - the duty of the class driver handler to service those requests. - - In addition, when the SET_CONFIGURATION request causes the %device to enter the - Configured state, the standard request handler calls the USBD_ConfigureEndpoint - method for each endpoint used by the %device; - - !!Clear Feature, Set Feature & Get Status - Several features of a %device can either be activated or deactivated by the USB - host: - - Remote wakeup - - Endpoint Halt state - Three requests can be used to either set, clear or get the status of these two - features: SET_FEATURE, CLEAR_FEATURE and GET_STATUS. - - The USBDDriver_RequestHandler method answers a Halt state operation by calling - the USBD_Halt method on the endpoint with the request. - - !!!Structures - Several pieces of information must be known to the USBDDriver_RequestHandler - to be able to process some SETUP commands. For example, all the descriptors - (configuration, etc.) used by the %device are needed since they must be sent - to the host when a GET_DESCRIPTOR is received. - - The USBGenericRequest structure is a "standard USB class driver" object used - to hold the required information. It must be passed as an argument to the - USBDDriver_RequestHandler method. Another structure, USBDDriverDescriptors, is - used to store the descriptors list. - - !!!Usage - The NewRequest callback is used to notify the user application that a new SETUP - request has been received. SETUP request can either be class-specific or - standard. - - The correct way to handle incoming requests is to first process class-specific - requests using a class handler. For example, a Mass Storage implementation will - define the NewRequest callback to call MSDDriver_RequestHandler. This function - will handle the necessary requests, and forward the rest to - USBDDriver_RequestHandler. - - If a request cannot be processed, USBDDriver_RequestHandler will STALL control - endpoint 0. - -*/ - -/** - \page "VID, PID, SN & Strings" - - This page collects the definition for USB %device to indicate the Vendor and - Product information. - - - If you need only the functions in demo %driver, you can easily modify these - definitions to change your device's Identification and Display strings. - - They are defined in the driver c code file that suffixed with - "DriverDescriptors" under the driver directory. - - !!!VID, PID & SN in Device Descriptor - - Defined as const and used in USBDeviceDescriptor instance initialization. - Gives identivication to the USB %device by VID and PID. The INF installation - file should mach the VID & PID so that the %device can be installed. - -\code -const USBDeviceDescriptor deviceDescriptor = {...}; -\endcode - - - "audio-speaker": "Audio Speaker Device Codes" - - ccid: "CCID Device IDs" - - "cdc-serial": "CDC Serial Device IDs" - - "hid-keyboard": "HID Device Descriptor IDs" - - massstorage: "MSD Device Descriptor IDs" - - !!!Strings - - The strings gives additional information on the USB %device, normally string - description about the vendor, product and serial number. - - The strings are defined as a list to initialize the driver's - USBDDriverDescriptors instance: - - - "audio-speaker": auddSpeakerDriverDescriptors - - ccid: ccidDriverDescriptors - - "cdc-serial": cdcdSerialDriverDescriptors - - "hid-keyboard": hiddKeyboardDriverDescriptors - - massstorage: msdDriverDescriptors - -\code -// String descriptors -const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor, -}; -\endcode -*/ diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDClassArch.png b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDClassArch.png deleted file mode 100644 index 6d0958075cd5c5eff5ac1874cac0786013bf4648..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3495 zcmeHJeK^y58=sO8lgjbZk|>>s7vywgQI?r=G=X(Bp{&=20p7Xu#@8|m7pZmK1xL>~ab*G>7 zbW>Hea_xw$^_8&4&f_5vwV$}4Vn1)E;QB+<>1gnyG0{56rE!ox4zExCw5C{p3Ly^qqw+O9{~s4Fo|!ih1SF}gJx zc%AICGDJ-;03;*%jW>KlD!26t?UxkDQG7yn;%E5RWNBv_xF?l2t{El??%viNHV1cirNioAivUTGFla` z8I)X-ZB(8fE{lF9q1@107p^&pbRFwZHxDjDey>JTP{K@So5~Hi`*uWBuMK~ zr3~x52Kyj+xMs1T;^zMd)85mi>+9PRqt+8c`U&Xt`Gr&u;Q)I7HzlOXHtJap1=rMj z3WDI}SQZ-~Ph+q8H0Ft>fKEwa%?>|z6{z4R&Del(T^jfCg_U0D_;u4T4#xj@MeWQ) zUu8VDl9Kvn3;p<~$GuOopDMK$2hH^{$D%Y_+kMfX3#VeYgUD|-06QU|wblSJd=v_XCW*dT`oxA`Ist06xhIJfmh!mEhCs|g zd73Q*h%hS?;n>)oD*0O#rl@OmgZB5s+{`Oz8kcTZJ~I~yG)f(2*W%0pu9@Qx(ob^) z&-BF?E&6IsiI=-OubS1mXEdw-jnB=?c6-q#Z=U(Obf?-5OEc^2? zd@~wP-z|>G5?v;T3J!&hsUoF;BLU{4zg4c(*zVFF5cVW$2<(Q7f^Dz7O7AlsI;mea za&3s1RTIj_)~wbo^1Jp1u8sqCRYbeDr!k@j&&1F#YXr{_4r<8DP7x8f=8B_5iGGWq zd)(OmJiD+ae9LZsM(pLKg-sqJCmf?E|v*YZvrViAlqh*Wd7C#~?v-nDM( zL%%oc94>JFUi9LzL^2xSTIV9{<6s=--ezg9B{Xqv*pyL4v#f5PJts(AON1N2%hTAL zP4F+i65K20m@ACNskh~?)h(we+#FtLOGG=c&wLm)5l2$RvKn1kP3GDEsxj8<1j7-_JQNsNVs1doFin6AID6>`c28Z+bmkB`pF9vskd+ z+z;R|_wA`fmp#Qy`BMrTri#*eNP*5W*UvhqcNjAB(kK!GDGYndx@AL#X&g-9K8D{DG zk;_}8Bd|>l{bJt3q9nZ`y&CrgxLB&d0rz0Yu=<6<$7eDg8Ar`w*FBllt6p|KANDsb z#Zqg2bF`vGYy@0opGxk(h{b85&JJ(U>PLUaa^m`?2dO2fSHGUBNHqeH3H5|ZMhdtV zsGUa~RJV49*C?W-IY4HE0qEC%8nf#F-0E4tDB=xvebpiCz{?yh*t@eF+PjMgY7Lm6 z2F}W?M?kW1UcPTcS4(lw%3&~PXo96-TAuejM+P??5z{pt2|HO*dqn^3XZPq}a@|MEZSO zYhfX8MvL9X07VXKg#dQV2$(vnD6jRIuZE0gJHB&BT?`v?K+-4tmYJ znG)FhvC3(o`FqqSuT}TZ@Yjv7g+N~?B2=Xg?I%W(>lUdi>KHU;KyY3xd8sWhv{(uO zo*;G;?xa!bOBlXD<1)sznwtF5Z|R{Pt_h6x9x&PG@a&POIgvT$Vo}&hv|{{NcEC6S zzAftj4-n|hI6X%jdxkSihU+?V_R*@)h!lI}N5|OZQ=>{p#Ak#VC;QG^2FG>gDN(!( zkIzP0ZFH=zs-Wxa94mVIN1^@8F8EI7MN7@B5zz>9w|zqt+T;iY_c;t~C-r7b6YP%F zBslNN99YiodbRQAS)ucc%6&1SH>pj9rz^fwmLAPo{(+N1yPKx@LA`{(Y7iqF>MwdsxmCUr_(HwWP>-+}%dYRMB3}r#<`Oop zC|15-6PG3Y3NBXFSH{%wg_QU6hZdjWvB47wj(>6v<@{$M!PS)r7ae b-<=SvQAa(5cdBLECdA#<)1~t8#pJ&OwVhPx diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks.h b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks.h deleted file mode 100644 index 6bbfaead6..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit HIDDKeyboardCallbacks - - !!!Purpose - - Definitions of callbacks used by the HID keyboard device driver to - notify the application of events. - - !!!Usage - - -# Re-implement any number of these callbacks anywhere in the program; - they will be called automatically by the driver when the related - event occurs. -*/ - -#ifndef HIDDKEYBOARDCALLBACKS_H -#define HIDDKEYBOARDCALLBACKS_H - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void HIDDKeyboardCallbacks_LedsChanged(unsigned char numLockStatus, - unsigned char capsLockStatus, - unsigned char scrollLockStatus); - -#endif //#ifndef HIDDKEYBOARDCALLBACKS_H - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks_LedsChanged.c b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks_LedsChanged.c deleted file mode 100644 index be8963d32..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardCallbacks_LedsChanged.c +++ /dev/null @@ -1,59 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDKeyboardCallbacks.h" -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Indicates that the status of one or more LEDs has been changed by the -/// host. -/// \param numLockStatus Indicates the current status of the num. lock key. -/// \param capsLockStatus Indicates the current status of the caps lock key. -/// \param scrollLockStatus Indicates the current status of the scroll lock key. -//------------------------------------------------------------------------------ -void HIDDKeyboardCallbacks_LedsChanged( - unsigned char numLockStatus, - unsigned char capsLockStatus, - unsigned char scrollLockStatus) -{ - TRACE_INFO( - "LEDs status: %d, %d, %d\n\r", - numLockStatus, - capsLockStatus, - scrollLockStatus); -} - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.c b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.c deleted file mode 100644 index 2fc8075e9..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.c +++ /dev/null @@ -1,477 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDKeyboardDriver.h" -#include "HIDDKeyboardDriverDescriptors.h" -#include "HIDDKeyboardCallbacks.h" -#include "HIDDKeyboardInputReport.h" -#include "HIDDKeyboardOutputReport.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Driver structure for an HID device implementing keyboard functionalities. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard USB device driver instance. - USBDDriver usbdDriver; - /// Idle rate (in milliseconds) of the input report. - unsigned char inputReportIdleRate; - /// Input report instance. - HIDDKeyboardInputReport inputReport; - /// Output report instance. - HIDDKeyboardOutputReport outputReport; - -} HIDDKeyboardDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Static instance of the HID keyboard device driver. -static HIDDKeyboardDriver hiddKeyboardDriver; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -/** - Returns the descriptor requested by the host. - -\param type Descriptor type. -\param length Maximum number of bytes to send. -\return 1 if the request has been handled by this function, otherwise 0. -*/ -static unsigned char HIDDKeyboardDriver_GetDescriptor(unsigned char type, - unsigned char length) -{ - const USBConfigurationDescriptor *pConfiguration; - HIDDescriptor *hidDescriptor; - - switch (type) { - - case HIDGenericDescriptor_REPORT: - TRACE_INFO_WP("Report "); - - // Adjust length and send report descriptor - if (length > HIDDKeyboardDriverDescriptors_REPORTSIZE) { - - length = HIDDKeyboardDriverDescriptors_REPORTSIZE; - } - USBD_Write(0, &hiddReportDescriptor, length, 0, 0); - break; - - case HIDGenericDescriptor_HID: - TRACE_INFO_WP("HID "); - - // Configuration descriptor is different depending on configuration - if (USBD_IsHighSpeed()) { - - pConfiguration = hiddKeyboardDriver.usbdDriver.pDescriptors->pHsConfiguration; - } - else { - - pConfiguration = hiddKeyboardDriver.usbdDriver.pDescriptors->pFsConfiguration; - } - - // Parse the device configuration to get the HID descriptor - USBConfigurationDescriptor_Parse( - pConfiguration, - 0, - 0, - (USBGenericDescriptor **) &hidDescriptor); - - // Adjust length and send HID descriptor - if (length > sizeof(HIDDescriptor)) { - - length = sizeof(HIDDescriptor); - } - USBD_Write(0, hidDescriptor, length, 0, 0); - break; - - default: - return 0; - } - - return 1; -} - -/** - Sends the current Idle rate of the input report to the host. -*/ -static void HIDDKeyboardDriver_GetIdle() -{ - TRACE_INFO_WP("gIdle "); - - USBD_Write(0, &(hiddKeyboardDriver.inputReportIdleRate), 1, 0, 0); -} - -/** - Retrieves the new idle rate of the input report from the USB host. - - \param idleRate New input report idle rate. -*/ -static void HIDDKeyboardDriver_SetIdle(unsigned char idleRate) -{ - TRACE_INFO_WP("sIdle(%d) ", idleRate); - - hiddKeyboardDriver.inputReportIdleRate = idleRate; - USBD_Write(0, 0, 0, 0, 0); -} - -/** - Sends the requested report to the host. - -\param type Report type. -\param length Maximum number of bytes to send. -*/ -static void HIDDKeyboardDriver_GetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO_WP("gReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - TRACE_INFO_WP("In "); - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardInputReport)) { - - length = sizeof(HIDDKeyboardInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.inputReport), - length, - 0, // No callback - 0); - break; - - case HIDReportRequest_OUTPUT: - TRACE_INFO_WP("Out "); - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardOutputReport)) { - - length = sizeof(HIDDKeyboardOutputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -} - -/** - Callback invoked when an output report has been received from the host. - Forward the new status of the LEDs to the user program via the - HIDDKeyboardCallbacks_LedsChanged callback. -*/ -static void HIDDKeyboardDriver_ReportReceived() -{ - TRACE_INFO_WP("oReport "); - - // Trigger callback - HIDDKeyboardCallbacks_LedsChanged( - HIDDKeyboardOutputReport_GetNumLockStatus(&(hiddKeyboardDriver.outputReport)), - HIDDKeyboardOutputReport_GetCapsLockStatus(&(hiddKeyboardDriver.outputReport)), - HIDDKeyboardOutputReport_GetScrollLockStatus(&(hiddKeyboardDriver.outputReport))); - - // Restart transfer - USBD_Read(HIDDKeyboardDriverDescriptors_INTERRUPTOUT, - &(hiddKeyboardDriver.outputReport), - sizeof(HIDDKeyboardOutputReport), - (TransferCallback) HIDDKeyboardDriver_ReportReceived, - 0); // No argument for callback function -} - -/** - Retrieves the new value of a report from the host and saves it. - -\param type Report type. -\param length Report length. -*/ -static void HIDDKeyboardDriver_SetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO_WP("sReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - case HIDReportRequest_OUTPUT: - // Check report length - if (length != sizeof(HIDDKeyboardOutputReport)) { - - USBD_Stall(0); - } - else { - - USBD_Read(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - (TransferCallback) HIDDKeyboardDriver_ReportReceived, - 0); // No argument to the callback function - } - break; - - default: - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -// Optional RequestReceived() callback re-implementation -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) - -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - HIDDKeyboardDriver_RequestHandler(request); -} - -#endif - -//------------------------------------------------------------------------------ -// ConfigurationChanged() callback re-implementation -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - if (cfgnum > 0) { - - // Start receiving output reports - USBD_Read(HIDDKeyboardDriverDescriptors_INTERRUPTOUT, - &(hiddKeyboardDriver.outputReport), - sizeof(HIDDKeyboardOutputReport), - (TransferCallback) HIDDKeyboardDriver_ReportReceived, - 0); // No argument for callback function - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -/** - Initializes the HID keyboard device driver. -*/ -void HIDDKeyboardDriver_Initialize() -{ - hiddKeyboardDriver.inputReportIdleRate = 0; - HIDDKeyboardInputReport_Initialize(&(hiddKeyboardDriver.inputReport)); - HIDDKeyboardOutputReport_Initialize(&(hiddKeyboardDriver.outputReport)); - USBDDriver_Initialize(&(hiddKeyboardDriver.usbdDriver), - &hiddKeyboardDriverDescriptors, - 0); // Multiple interface settings not supported - USBD_Init(); -} - -/** - Handles HID-specific SETUP request sent by the host. - - \param request Pointer to a USBGenericRequest instance. -*/ -void HIDDKeyboardDriver_RequestHandler(const USBGenericRequest *request) -{ - TRACE_INFO_WP("NewReq "); - - // Check if this is a standard request - if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // This is a standard request - switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, otherwise forward it to - // the standard driver - if (!HIDDKeyboardDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); - } - } - // Check if this is a class request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - // This is a class-specific request - switch (USBGenericRequest_GetRequest(request)) { - - case HIDGenericRequest_GETIDLE: - HIDDKeyboardDriver_GetIdle(); - break; - - case HIDGenericRequest_SETIDLE: - HIDDKeyboardDriver_SetIdle(HIDIdleRequest_GetIdleRate(request)); - break; - - case HIDGenericRequest_GETREPORT: - HIDDKeyboardDriver_GetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - case HIDGenericRequest_SETREPORT: - HIDDKeyboardDriver_SetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - default: - TRACE_WARNING( - "HIDDKeyboardDriver_RequestHandler: Unknown REQ 0x%02X\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - } - else { - - // Vendor request ? - USBD_Stall(0); - } -} - -/** - Reports a change in which keys are currently pressed or release to the - host. - -\param pressedKeys Pointer to an array of key codes indicating keys that have - been pressed since the last call to HIDDKeyboardDriver_ChangeKeys. -\param pressedKeysSize Number of key codes in the pressedKeys array. -\param releasedKeys Pointer to an array of key codes indicates keys that have - been released since the last call to HIDDKeyboardDriver_ChangeKeys. -\param releasedKeysSize Number of key codes in the releasedKeys array. -\return USBD_STATUS_SUCCESS if the report has been sent to the host; - otherwise an error code. -*/ -unsigned char HIDDKeyboardDriver_ChangeKeys(unsigned char *pressedKeys, - unsigned char pressedKeysSize, - unsigned char *releasedKeys, - unsigned char releasedKeysSize) -{ - // Press keys - while (pressedKeysSize > 0) { - - // Check if this is a standard or modifier key - if (HIDKeypad_IsModifierKey(*pressedKeys)) { - - // Set the corresponding bit in the input report - HIDDKeyboardInputReport_PressModifierKey( - &(hiddKeyboardDriver.inputReport), - *pressedKeys); - } - else { - - HIDDKeyboardInputReport_PressStandardKey( - &(hiddKeyboardDriver.inputReport), - *pressedKeys); - } - - pressedKeysSize--; - pressedKeys++; - } - - // Release keys - while (releasedKeysSize > 0) { - - // Check if this is a standard or modifier key - if (HIDKeypad_IsModifierKey(*releasedKeys)) { - - // Set the corresponding bit in the input report - HIDDKeyboardInputReport_ReleaseModifierKey( - &(hiddKeyboardDriver.inputReport), - *releasedKeys); - } - else { - - HIDDKeyboardInputReport_ReleaseStandardKey( - &(hiddKeyboardDriver.inputReport), - *releasedKeys); - } - - releasedKeysSize--; - releasedKeys++; - } - - // Send input report through the interrupt IN endpoint - return USBD_Write(HIDDKeyboardDriverDescriptors_INTERRUPTIN, - &(hiddKeyboardDriver.inputReport), - sizeof(HIDDKeyboardInputReport), - 0, - 0); -} - -//------------------------------------------------------------------------------ -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//------------------------------------------------------------------------------ -void HIDDKeyboardDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&(hiddKeyboardDriver.usbdDriver))) { - - USBD_RemoteWakeUp(); - } -} - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.h b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.h deleted file mode 100644 index 42dc0a295..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriver.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit HIDDKeyboardDriver - - !!!Purpose - - Definition of methods for using a HID keyboard device driver. - - !!!Usage - - -# Re-implement the USBDCallbacks_RequestReceived callback to forward - requests to HIDDKeyboardDriver_RequestHandler. This is done - automatically unless the NOAUTOCALLBACK symbol is defined during - compilation. - -# Initialize the driver using HIDDKeyboardDriver_Initialize. The - USB driver is automatically initialized by this method. - -# Call the HIDDKeyboardDriver_ChangeKeys method when one or more - keys are pressed/released. -*/ - -#ifndef HIDDKEYBOARDDRIVER_H -#define HIDDKEYBOARDDRIVER_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void HIDDKeyboardDriver_Initialize(); - -extern void HIDDKeyboardDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned char HIDDKeyboardDriver_ChangeKeys( - unsigned char *pressedKeys, - unsigned char pressedKeysSize, - unsigned char *releasedKeys, - unsigned char releasedKeysSize); - -extern void HIDDKeyboardDriver_RemoteWakeUp(void); - -#endif //#ifndef HIDDKEYBOARDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.c b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.c deleted file mode 100644 index 51dfb484d..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.c +++ /dev/null @@ -1,420 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDKeyboardDriverDescriptors - - About: Purpose - Declaration of the descriptors used by the HID device keyboard driver. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDKeyboardDriverDescriptors.h" -#include "HIDDKeyboardInputReport.h" -#include "HIDDKeyboardOutputReport.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Device Descriptor IDs" -/// This page lists VID, PID & Release number. -/// -/// !IDs -/// - HIDDKeyboardDriverDescriptors_PRODUCTID -/// - HIDDKeyboardDriverDescriptors_VENDORID -/// - HIDDKeyboardDriverDescriptors_RELEASE - -/// Device product ID. -#define HIDDKeyboardDriverDescriptors_PRODUCTID 0x6127 -/// Device vendor ID. -#define HIDDKeyboardDriverDescriptors_VENDORID 0x03EB -/// Device release number. -#define HIDDKeyboardDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// List of descriptors that make up the configuration descriptors of a -/// device using the HID keyboard driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Configuration descriptor. - USBConfigurationDescriptor configuration; - /// Interface descriptor. - USBInterfaceDescriptor interface; - /// HID descriptor. - HIDDescriptor hid; - /// Interrupt IN endpoint descriptor. - USBEndpointDescriptor interruptIn; - /// Interrupt OUT endpoint descriptor. - USBEndpointDescriptor interruptOut; - -} __attribute__ ((packed)) HIDDKeyboardDriverConfigurationDescriptors; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Device descriptor. -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDKeyboardDriverDescriptors_VENDORID, - HIDDKeyboardDriverDescriptors_PRODUCTID, - HIDDKeyboardDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Device qualifier descriptor (high-speed only). -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // One possible configuration - 0 // Reserved -}; -#endif - -/// Configuration descriptor. -static const HIDDKeyboardDriverConfigurationDescriptors configurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDKeyboardDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDKeyboardDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDKeyboardDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDKeyboardDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING - } -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Other-speed configuration descriptor. -static const HIDDKeyboardDriverConfigurationDescriptors otherSpeedDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(HIDDKeyboardDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDKeyboardDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDKeyboardDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDKeyboardDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTOUT_POLLING - } -}; -#endif - -/// Language ID string descriptor. -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -/// Manufacturer name. -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L') -}; - -/// Product name. -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(23), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('H'), - USBStringDescriptor_UNICODE('I'), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('K'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('Y'), - USBStringDescriptor_UNICODE('B'), - USBStringDescriptor_UNICODE('O'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('R'), - USBStringDescriptor_UNICODE('D') -}; - -/// Product serial number. -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(12), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3'), - USBStringDescriptor_UNICODE('4'), - USBStringDescriptor_UNICODE('5'), - USBStringDescriptor_UNICODE('6'), - USBStringDescriptor_UNICODE('7'), - USBStringDescriptor_UNICODE('8'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('F') -}; - -/// Array of pointers to string descriptors. -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors used by the HID keyboard driver. -USBDDriverDescriptors hiddKeyboardDriverDescriptors = { - - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, -#else - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration - 0, // No high-speed device descriptor - 0, // No high-speed configuration descriptor - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor -#endif - stringDescriptors, - 4 // Four string descriptors in list -}; - -/// Report descriptor used by the driver. -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_KEYBOARD, - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, - - // Input report: modifier keys - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_REPORTCOUNT + 1, 8, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, - - // Input report: standard keys - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - HIDReport_INPUT + 1, 0 /* Data array */, - - // Output report: LEDs - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK, - HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK, - HIDReport_OUTPUT + 1, HIDReport_VARIABLE, - - // Output report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_OUTPUT + 1, HIDReport_CONSTANT, - - HIDReport_ENDCOLLECTION -}; - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.h b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.h deleted file mode 100644 index 9a2dc2fa7..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardDriverDescriptors.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit HIDDKeyboardDriverDescriptors - - !!!Purpose - - Definitions of the descriptors required by the HID device keyboard - driver. - - !!!Usage - - -# Use the hiddKeyboardDriverDescriptors variable to initialize a - USBDDriver instance. - -# Send hiddReportDescriptor to the host when a GET_DESCRIPTOR request - for the report descriptor is received. -*/ - -#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H -#define HIDDKEYBOARDDRIVERDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Endpoints" -/// This page lists endpoint addresses and polling settings. -/// -/// !Endpoints -/// - HIDDKeyboardDriverDescriptors_INTERRUPTIN -/// - HIDDKeyboardDriverDescriptors_INTERRUPTOUT -/// -/// !Polling Rates -/// - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING -/// - HIDDKeyboardDriverDescriptors_INTERRUPTOUT_POLLING - -/// Interrupt IN endpoint number. -#define HIDDKeyboardDriverDescriptors_INTERRUPTIN 1 -/// Interrupt IN endpoint polling rate (in milliseconds). -#define HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING 10 -/// Interrupt OUT endpoint number. -#define HIDDKeyboardDriverDescriptors_INTERRUPTOUT 2 -/// Interrupt OUT endpoint polling rate (in milliseconds). -#define HIDDKeyboardDriverDescriptors_INTERRUPTOUT_POLLING 10 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Keypad keys" -/// This page lists definition for HID keypad keys. -/// -/// !Keys -/// - HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY -/// - HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY -/// - HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY -/// - HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY - -/// Key code of the first accepted modifier key. -#define HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY HIDKeypad_LEFTCONTROL -/// Key code of the last accepted modifier key. -#define HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY HIDKeypad_RIGHTGUI -/// Key code of the first accepted standard key. -#define HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY 0 -/// Key code of the last accepted standard key. -#define HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY HIDKeypad_NUMLOCK -//------------------------------------------------------------------------------ - -/// Size of the report descriptor in bytes. -#define HIDDKeyboardDriverDescriptors_REPORTSIZE 61 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -extern USBDDriverDescriptors hiddKeyboardDriverDescriptors; - -extern const unsigned char hiddReportDescriptor[]; - -#endif //#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.c b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.c deleted file mode 100644 index 3257bdbae..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.c +++ /dev/null @@ -1,164 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDKeyboardInputReport implementation - - About: Purpose - Implementation of the HIDDKeyboardInputReport class. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDKeyboardInputReport.h" -#include "HIDDKeyboardDriverDescriptors.h" -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes a keyboard input report instance. -/// \param report Pointer to a HIDDKeyboardInputReport instance. -//------------------------------------------------------------------------------ -void HIDDKeyboardInputReport_Initialize(HIDDKeyboardInputReport *report) -{ - unsigned int i; - - report->bmModifierKeys = 0; - for (i = 0; i < HIDDKeyboardInputReport_MAXKEYPRESSES; i++) { - - report->pressedKeys[i] = 0; - } -} - -//------------------------------------------------------------------------------ -/// Reports a standard key as being pressed. -/// \param report Pointer to a HIDDKeyboardInputReport instance. -/// \param key Key code of the standard key. -//------------------------------------------------------------------------------ -void HIDDKeyboardInputReport_PressStandardKey(HIDDKeyboardInputReport *report, - unsigned char key) -{ - ASSERT(key <= HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - "Invalid standard key code (%d)\n\r", - key); - - // Find first available slot - unsigned int i = 0; - unsigned char found = 0; - while ((i < HIDDKeyboardInputReport_MAXKEYPRESSES) && !found) { - - // Free slot: no key referenced (code = 0) or ErrorRollOver - if ((report->pressedKeys[i] == 0) - || (report->pressedKeys[i] == HIDKeypad_ERRORROLLOVER)) { - - found = 1; - report->pressedKeys[i] = key; - } - - i++; - } - - // Report ErrorRollOver in all fields if too many keys are pressed - if (!found) { - - for (i=0; i < HIDDKeyboardInputReport_MAXKEYPRESSES; i++) { - - report->pressedKeys[i] = HIDKeypad_ERRORROLLOVER; - } - } -} - -//------------------------------------------------------------------------------ -/// Reports a standard key as not being pressed anymore. -/// \param report Pointer to a HIDDKeyboardInputReport instance. -/// \param key Key code of the standard key -//------------------------------------------------------------------------------ -void HIDDKeyboardInputReport_ReleaseStandardKey(HIDDKeyboardInputReport *report, - unsigned char key) -{ - ASSERT(key <= HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - "Invalid standard key code (%d)\n\r", - key); - - // Look for key in array - unsigned int i = 0; - unsigned char found = 0; - while ((i < HIDDKeyboardInputReport_MAXKEYPRESSES) && !found) { - - if (report->pressedKeys[i] == key) { - - found = 1; - report->pressedKeys[i] = 0; - } - - i++; - } -} - -//------------------------------------------------------------------------------ -/// Reports a modifier key as being currently pressed. -/// \param report Pointer to a HIDDKeyboardInputReport instance. -/// \param key Key code of the modifier key. -//------------------------------------------------------------------------------ -void HIDDKeyboardInputReport_PressModifierKey(HIDDKeyboardInputReport *report, - unsigned char key) -{ - ASSERT((key >= HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY) - && (key <= HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY), - "Invalid standard key code (%d)\n\r", - key); - - // Set corresponding bit - unsigned char bit = key - HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY; - report->bmModifierKeys |= 1 << bit; -} - -//------------------------------------------------------------------------------ -/// Reports a modifier key as not being pressed anymore. -/// \param report Pointer to a HIDDKeyboardInputReport instance. -/// \param key Key code of the modifier key. -//------------------------------------------------------------------------------ -void HIDDKeyboardInputReport_ReleaseModifierKey(HIDDKeyboardInputReport *report, - unsigned char key) -{ - ASSERT((key >= HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY) - && (key <= HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY), - "Invalid standard key code (%d)\n\r", - key); - - // Clear corresponding bit - unsigned char bit = key - HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY; - report->bmModifierKeys &= ~(1 << bit); -} - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.h b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.h deleted file mode 100644 index 7eeafd820..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardInputReport.h +++ /dev/null @@ -1,149 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit HIDDKeyboardInputReport.h - - !!!Purpose - - Class for manipulating HID keyboard input reports. - - !!!Usage - - -# Initialize a newly created input report with - HIDDKeyboardInputReport_Initialize. - -# Change the standard keys that are pressed and released using - HIDDKeyboardInputReport_PressStandardKey and - HIDDKeyboardInputReport_ReleaseStandardKey. - -# Change the modifier keys that are currently pressed and released - using HIDDKeyboardInputReport_PressModifierKey and - HIDDKeyboardInputReport_ReleaseModifierKey. -*/ - -#ifndef HIDDKEYBOARDINPUTREPORT_H -#define HIDDKEYBOARDINPUTREPORT_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Maximum number of simultaneous key presses. -#define HIDDKeyboardInputReport_MAXKEYPRESSES 3 - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// HID input report structure used by the keyboard driver to notify the -/// host of pressed keys. -/// -/// The first byte is used to report the state of modifier keys. The -/// other three contains the keycodes of the currently pressed keys. -//------------------------------------------------------------------------------ -typedef struct { - - /// State of modifier keys. - unsigned char bmModifierKeys:8; - /// Key codes of pressed keys. - unsigned char pressedKeys[HIDDKeyboardInputReport_MAXKEYPRESSES]; - -} __attribute__ ((packed)) HIDDKeyboardInputReport; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -/* - Function: HIDDKeyboardInputReport_Initialize - Initializes a keyboard input report instance. - - Parameters: - report - Pointer to a HIDDKeyboardInputReport instance. -*/ -extern void HIDDKeyboardInputReport_Initialize(HIDDKeyboardInputReport *report); - -/* - Function: HIDDKeyboardInputReport_PressStandardKey - Reports a standard key as being pressed. - - Parameters: - report - Pointer to a HIDDKeyboardInputReport instance. - key - Key code of the standard key. -*/ -extern void HIDDKeyboardInputReport_PressStandardKey( - HIDDKeyboardInputReport *report, - unsigned char key); - -/* - Function: HIDDKeyboardInputReport_ReleaseStandardKey - Reports a standard key as not being pressed anymore. - - Parameters: - report - Pointer to a HIDDKeyboardInputReport instance. - key - Key code of the standard key -*/ -extern void HIDDKeyboardInputReport_ReleaseStandardKey( - HIDDKeyboardInputReport *report, - unsigned char key); - -/* - Function: HIDDKeyboardInputReport_PressModifierKey - Reports a modifier key as being currently pressed. - - Parameters: - report - Pointer to a HIDDKeyboardInputReport instance. - key - Key code of the modifier key. -*/ -extern void HIDDKeyboardInputReport_PressModifierKey( - HIDDKeyboardInputReport *report, - unsigned char key); - -/* - Function: HIDDKeyboardInputReport_ReleaseModifierKey - Reports a modifier key as not being pressed anymore. - - Parameters: - report - Pointer to a HIDDKeyboardInputReport instance. - key - Key code of the modifier key. -*/ -extern void HIDDKeyboardInputReport_ReleaseModifierKey( - HIDDKeyboardInputReport *report, - unsigned char key); - -#endif //#ifndef HIDDKEYBOARDINPUTREPORT_H - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.c b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.c deleted file mode 100644 index f79d7accc..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.c +++ /dev/null @@ -1,94 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDKeyboardOutputReport implementation - - About: Purpose - Implementation of the HIDDKeyboardOutputReport class. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDKeyboardOutputReport.h" - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes a keyboard output report. -/// \param report Pointer to a HIDDKeyboardOutputReport instance. -//------------------------------------------------------------------------------ -void HIDDKeyboardOutputReport_Initialize(HIDDKeyboardOutputReport *report) -{ - report->numLockStatus = 0; - report->capsLockStatus = 0; - report->scrollLockStatus = 0; - report->padding = 0; -} - -//------------------------------------------------------------------------------ -/// Indicates the current status of the num. lock LED according to the -/// given report. -/// \param report Pointer to a HIDDKeyboardOutputReport instance. -/// \return 1 if the num. lock LED is light on; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char HIDDKeyboardOutputReport_GetNumLockStatus( - const HIDDKeyboardOutputReport *report) -{ - return report->numLockStatus; -} - -//------------------------------------------------------------------------------ -/// Indicates the current status of the caps lock LED according to the -/// given report. -/// \param report Pointer to a HIDDKeyboardOutputReport instance. -/// \return 1 if the caps lock LED is light on; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char HIDDKeyboardOutputReport_GetCapsLockStatus( - const HIDDKeyboardOutputReport *report) -{ - return report->capsLockStatus; -} - -//------------------------------------------------------------------------------ -/// Indicates the current status of the scroll lock LED according to the -/// given report. -/// \param report Pointer to a HIDDKeyboardOutputReport instance. -/// \return 1 if the scroll lock LED is light on; otherwise 0. -//------------------------------------------------------------------------------ -unsigned char HIDDKeyboardOutputReport_GetScrollLockStatus( - const HIDDKeyboardOutputReport *report) -{ - return report->scrollLockStatus; -} - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.h b/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.h deleted file mode 100644 index 760df1b2f..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/HIDDKeyboardOutputReport.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit HIDDKeyboardOutputReport - - !!!Purpose - - Definition of a class for manipulating HID keyboard output reports. - - !!!Usage - - -# Initialize a newly-created output report instance with - HIDDKeyboardOutputReport_Initialize. - -# Retrieve the status of the three LEDs using - HIDDKeyboardOutputReport_GetNumLockStatus, - HIDDKeyboardOutputReport_GetCapsLockStatus and - HIDDKeyboardOutputReport_GetScrollLockStatus. -*/ - -#ifndef HIDKEYBOARDOUTPUTREPORT_H -#define HIDKEYBOARDOUTPUTREPORT_H - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// HID output report structure used by the host to control the state of -/// the keyboard LEDs. -/// -/// Only the first three bits are relevant, the other 5 are used as -/// padding bits. -//------------------------------------------------------------------------------ -typedef struct { - - unsigned char numLockStatus:1, /// State of the num. lock LED. - capsLockStatus:1, /// State of the caps lock LED. - scrollLockStatus:1, /// State of the scroll lock LED. - padding:5; /// Padding bits. - -} __attribute__ ((packed)) HIDDKeyboardOutputReport; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void HIDDKeyboardOutputReport_Initialize( - HIDDKeyboardOutputReport *report); - -extern unsigned char HIDDKeyboardOutputReport_GetNumLockStatus( - const HIDDKeyboardOutputReport *report); - -extern unsigned char HIDDKeyboardOutputReport_GetCapsLockStatus( - const HIDDKeyboardOutputReport *report); - -extern unsigned char HIDDKeyboardOutputReport_GetScrollLockStatus( - const HIDDKeyboardOutputReport *report); - -#endif //#ifndef HIDKEYBOARDOUTPUTREPORT_H - diff --git a/src/ersky9x/libraries/usb/device/hid-keyboard/hid-keyboard.dir b/src/ersky9x/libraries/usb/device/hid-keyboard/hid-keyboard.dir deleted file mode 100644 index 923a36201..000000000 --- a/src/ersky9x/libraries/usb/device/hid-keyboard/hid-keyboard.dir +++ /dev/null @@ -1,787 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB HID -/// %device - USB HID Keyboard driver, to implement an USB keyboard %device. -/// -/// !!!Contents -/// -/// There are three things for the implement of the USB HID Keyboard driver: -/// - Implement the USB HID driver structs and functions for the %device, -/// to initialize, to handle HID-specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the HID Keyboard device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the %device as a USB Keyboard %device. -/// - Implement methods to update the keyboard keys status, so that host can -/// get it through USB. -/// -/// For more information about what a particular group contains, please refer to -/// "USB HID Keyboard". -//------------------------------------------------------------------------------ - -/** - \page "USB HID Keyboard" - This page describes how to use the "AT91 USB device framework" to produce a USB - HID Keyboard driver, which appears as a USB keyboard on host. - - Details about the USB and the HID class can be found in the }USB specification - 2.0} and the }HID specification 1.11}, respectively. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Device Class Definition for HID 1.11 - - - HID Usage Tables 1.12 - - !!!HID Basic - See "USB HID Basic". - - !!!Architecture - See "USB Device Framework Architecture". - - !!!Descriptors - - ... - - !!Device Descriptor - The Device descriptor of an HID %device is very basic, since the HID class - code is only specified at the Interface level. Thus, it only contains - standard values, as shown below: -\code -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDKeyboardDriverDescriptors_VENDORID, - HIDDKeyboardDriverDescriptors_PRODUCTID, - HIDDKeyboardDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; -\endcode - Note that the Vendor ID is a special value attributed by the USB-IF - organization. The product ID can be chosen freely by the vendor. - - !!Configuration Descriptor - Since one interface is required by the HID specification, this must be - specified in the Configuration descriptor. There is no other value of - interest to put here. -\code -// Configuration descriptor -{ - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDKeyboardDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) -}, -\endcode - When the Configuration descriptor is requested by the host (by using the - GET_DESCRIPTOR command), the %device must also sent all the related - descriptors, i.e. Interface, Endpoint and Class-Specific descriptors. It is - convenient to create a single structure to hold all this data, for sending - everything in one chunk. In the example software, a - HIDDKeyboardDriverConfigurationDescriptors structure has been declared for - that. - - !!HID Class Interface Descriptor - Since a keyboard %device needs to transmit as well as receive data, two - Interrupt (IN & OUT) endpoints are needed. This must be indicated in the - Interface descriptor. Conversely to the mouse example, the Boot protocol is - not implemented here, since there are more constraints on a keyboard %device. -\code -// Interface descriptor -{ - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor -}, -\endcode - - !!HID Descriptor - While a HID keyboard produces two different reports, one Input and one Output, - only one Report descriptor can be used to describe them. Since having Physical - descriptors is also useless for a keyboard, there will only be one HID class - descriptor specified here. - - For a keyboard, the }bCountryCode} field can be used to specify the language - of the key caps. As this is optional, it is simply set to 00h in the example: -\code -// HID descriptor -{ - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDKeyboardDriverDescriptors_REPORTSIZE -}, -\endcode - - !!Report Descriptor - Two current reports are defined in the Report descriptor. The first one is - used to notify the host of which keys are pressed, with both modifier keys - (alt, ctrl, etc.) and alphanumeric keys. The second report is necessary for - the host to send the LED (num lock, caps lock, etc.) states. - - The Report descriptor starts with the global %device functionality, described - with a #Usage Page# and a #Usage# items: -\code -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_KEYBOARD, -\endcode - - As in the mouse example, the }Generic Desktop} page is used. This time, the - specific usage is the }Keyboard} one. An Application collection is then - defined to group the reports together: -\code - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, -\endcode - - The first report to be defined is the modifier keys. They are represented as a - bitmap field, indicating whether or not each key is pressed. A single byte is - used to map keys \#224-231 defined in the }HID Usage Tables} document: - LeftControl, LeftShift, LeftAlt, LeftGUI (e.g. Windows key), - RightControl, RightShift, RightAlt and RightGUI. - The }Keypad} usage page must be specified for this report, and since this is a - bitmap value, the data is flagged as }Variable}: -\code - // Input report: modifier keys - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_REPORTCOUNT + 1, 8, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTMODIFIERKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTMODIFIERKEY, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, -\endcode - - Then, the actual alphanumeric key report is described. This is done by - defining several bytes of data, one for each pressed key. In the example, - up to three keys can be pressed at the same time (and detected) by the user. - Once again, the usage page is set to }Keypad}. This time however, the data - must be specified as an }Array}, since the same control (the keypad) produces - several values: -\code - // Input report: standard keys - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDKeyboardDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDKeyboardDriverDescriptors_LASTSTANDARDKEY, - HIDReport_INPUT + 1, 0 /* Data array */, -\endcode - - The LED array is then defined, with the associated usage page. The Report - descriptor is formatted in this order to avoid redefining unchanged }Global} - items, in order to save memory. This time again, the LED status is reported as - a bitmap field. Three LEDs are used here: Num Lock, Caps Lock and Scroll Lock - (IDs 01h to 03h). It is important to note that this is an #Output# report: -\code - // Output report: LEDs - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK, - HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK, - HIDReport_OUTPUT + 1, HIDReport_VARIABLE, -\endcode - - Since the previous report only contains 3 bits, the data must be padded to a - multiple of one byte. This is done by using constant Output data, as follows: -\code - // Output report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_OUTPUT + 1, HIDReport_CONSTANT, -\endcode - - The last item, }End Collection}, is necessary to close the previously opened - }Application Collection}. -\code - HIDReport_ENDCOLLECTION -}; -\endcode - - The Input and Output reports defined by this descriptor can be modeled by the - following structures: -\code -// HID Input Report -typedef struct { - - // State of modifier keys. - unsigned char bmModifierKeys:8; - // Key codes of pressed keys. - unsigned char pressedKeys[HIDDKeyboardInputReport_MAXKEYPRESSES]; - -} __attribute__ ((packed)) HIDDKeyboardInputReport; // GCC -// HID Output Report -typedef struct { - - unsigned char numLockStatus:1, // State of the num. lock LED. - capsLockStatus:1, // State of the caps lock LED. - scrollLockStatus:1, // State of the scroll lock LED. - padding:5; // Padding bits. - -} __attribute__ ((packed)) HIDDKeyboardOutputReport; // GCC -\endcode - - An instance of each one of the reports is stored in a HIDDKeyboardDriver - structure, which holds the standard class driver and HID keyboard-specific - data. - - !!Physical Descriptor - A Physical descriptor is useless for a keyboard %device, so none are defined - in this example. - - !!Endpoint Descriptor - Following the Interface and HID-specific descriptors, the two necessary - endpoints are defined. -\code -// Interrupt IN endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDKeyboardDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING -}, -// Interrupt OUT endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDKeyboardDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING -} -\endcode - - !!String Descriptors - Please refer to "Usage: USBD VID, PID & Strings". - - !!!Class-specific requests - A driver request handler should first differentiate between class-specific and - standard requests using the corresponding bits in the }bmRequestType} field. - In most cases, standard requests can be immediately forwarded to the standard - request handler method; class-specific methods must be decoded and treated by - the custom handler. - - !!GetDescriptor - Three values have been added by the HID specification for the #GET_DESCRIPTOR# - request. The high byte of the }wValue} field contains the type of the - requested descriptor; in addition to the standard types, the #HID - specification# adds the #HID descriptor# (21h), the #Report descriptor# - (22h) and the #Physical descriptor# (23h) types. - - There is no particular action to perform besides sending the descriptor. This - can be done by using the USBD_Write method, after the requested descriptor has - been identified: -\code -switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, - // otherwise forward it to - // the standard driver - if (!HIDDKeyboardDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); -} -\endcode - A slight complexity of the GET_DESCRIPTOR and SET_DESCRIPTOR requests is that - those are standard requests, but the standard request handler - (USBDDriver_RequestHandler) must not always be called to treat them (since - they may refer to HID descriptors). The solution is to first identify - GET/SET_DESCRIPTOR requests, treat the HID-specific cases and, finally, - forward any other request to the standard handler. - - In this case, a GET_DESCRIPTOR request for the Physical descriptor is first - forwarded to the standard handler, and STALLed there because it is not - recognized. This is done because the %device does not have any Physical - descriptors, and thus, does not need to handle the associated request. - - !!SetDescriptor - This request is optional and is never issued by most hosts. It is not - implemented in this example. - - !!GetReport - Since the HID keyboard defines two different reports, the Report Type value - specified by this request (upper byte of the }wValue} field) must be examined - to decide which report to send. If the type value is 01h, then the Input - report must be returned; if it is 02h, the Output report is requested: -\code -case HIDGenericRequest_GETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch (type) { - - case HIDReportRequest_INPUT: - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardInputReport)) { - - length = sizeof(HIDDKeyboardInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.inputReport), - length, - 0, // No callback - 0); - break; - - case HIDReportRequest_OUTPUT: - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardOutputReport)) { - - length = sizeof(HIDDKeyboardOutputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetReport - For an HID keyboard, the #SET_REPORT# command can be sent by the host to - change the state of the LEDs. Normally, the dedicated Interrupt OUT endpoint - will be used for this; but in some cases, using the default Control endpoint - can save some bandwidth on the host side. - - Note that the SET_REPORT request can be directed at the Input report of the - keyboard; in this case, it can be safely discarded, according to the HID - specification. Normally, most host drivers only target the Output report. The - Report Type value is stored in the upper byte of the }wValue} field. - - The length of the data phase to follow is stored in the }wLength} field of the - request. It should be equal to the total length of the Output report. If it is - different, the report status must still be updated with the received data as - best as possible. - - When the reception of the new data is completed, some processing must be done - to enable/disable the corresponding LEDs. This is done in the callback - function passed as an argument to USBD_Read: -\code -case HIDGenericRequest_SETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch(type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - case HIDReportRequest_OUTPUT: - // Check report length - if (length != sizeof(HIDDKeyboardOutputReport)) { - - USBD_Stall(0); - } - else { - - USBD_Read(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - (TransferCallback) HIDDKeyboardDriver_ReportReceived, - 0); // No argument to the callback function - } - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetIdle - In this case study, the #SET_IDLE# request is used to set a delay before a key - is repeated. This is common behavior on keyboard devices. Usually, this delay - is set to about 500 ms by the host. - - The only action here is to store the new Idle rate. The management of this - setting must be done in the main function, since Interrupt IN reports are sent - from there. - - In practice, it is not necessary to perform any action, apart from sending a - zero-length packet to acknowledge it. The main application however has to make - sure that only new reports are sent by the %device. -\code -case HIDGenericRequest_SETIDLE: -//----------------------------- - hiddKeyboardDriver.inputReportIdleRate = - HIDIdleRequest_GetIdleRate(request); - USBD_Write(0, 0, 0, 0, 0); -break; -\endcode - - !!GetIdle - The only necessary operation for this request is to send the previously saved - Idle rate. This is done by calling the USBD_Write method with the one-byte - variable as its parameter: -\code -case HIDGenericRequest_GETIDLE: -//----------------------------- - USBD_Write(0, &(hiddKeyboardDriver.inputReportIdleRate), 1, 0, 0); -break; -\endcode - - !!GetProtocol, SetProtocol - This HID keyboard example does not support the Boot protocol, so there is no - need to implement the SET_PROTOCOL and GET_PROTOCOL requests. This means they - can be safely STALLed when received. - - !!!Main Application - Like the mouse example, the main program must perform two different - operations. First, it has to monitor the physical inputs used as keys. In the - example software, the buttons present on the evaluation boards are used to - produce several modifier and alphanumeric keys. - - Also, the main program is in charge of sending reports as they are modified, - taking into account the Idle rate specified by the host. Idle rate management - can be carried out by firing/resetting a timer once a new report is sent; if - the timer expires, this means the Input report has not changed since. - According to the HID specification, a single instance of the report must be - sent in this case. - - Finally, the HID specification also defines that if too many keys are pressed - at the same time, the %device should report an }ErrorRollOver} usage value - (01h) in every byte of the key array. This has to be handled by the main - application as well. - -*/ - -/** - \page "USB HID Mouse" - This page describes how to implement a mouse %device using the HID class and - the "AT91 USB device framework". Details about the USB and the HID class can - be found in the }USB specification 2.0} and the }HID specification 1.11} - documents, respectively. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Device Class Definition for HID 1.11 - - - HID Usage Tables 1.12 - - - -*/ - -/** - \page "USB HID Basic" - - This page gives generic details on the HID class, including its purpose, - architecture and how it is supported by various operating systems. - - !!!Purpose - - The HID class has been specifically designed for Human Interface Devices, - i.e., devices which are manipulated by humans to control a computer or an - electronic %device. This includes common peripherals such as a keyboard, a - mouse or a joystick, as well as many other interfaces: remote controllers, - switches, buttons, dedicated game controls, and so on. - - It is also possible to use the HID class for devices which do not require - human interaction, but still deliver information in a similar format. For - example, devices like a thermometer or a battery indicator are supported. - - In addition, the HID class also makes it possible to not only receive data - from devices but also to send commands to them. Indeed, many devices offer - some kind of display to give back information to the user, e.g., the LEDs on a - keyboard. - - Finally, since it is quite simple to send and receive data using the HID - class, it can be used as a generic means of communication between a %device - and a host. This is made possible because of the very flexible framework - defined in the HID specification. - - In this document, three uses of the HID class will be detailed step-by-step, - each showing one particular feature of the class. The first example shows the - interaction with a simple mouse. In the second example, a keyboard is - implemented to demonstrate the possibility to send data to a peripheral. The - last example explains how to use HID as a simple two-way communication - channel. - - !!!Architecture - ... - - !!Interface - An HID %device only needs #one interface descriptor#. It should have the HID - interface class code in its bInterfaceClass field. There are special subclass - and protocol codes to specify if the HID %device is a mouse or a keyboard, and - must be supported by the BIOS. In such a case, the interface must be declared - as a Boot Interface, and the type of the %device (mouse or keyboard) must be - given in the bInterfaceProtocol field. - - !!Endpoints - Up to three endpoints can be used with an HID interface. The first two are the - default Control endpoint 0, as well as an Interrupt IN endpoint. They are - mandatory and shall always be declared. An optional Interrupt OUT endpoint can - be added as well. - - Endpoint 0 is used for class-specific requests, as well as receiving data from - the host if no Interrupt OUT endpoint has been defined. In addition, the host - can also explicitly request or send report data through this endpoint. - - The Interrupt IN and OUT pipes are used for sending asynchronous data to the - host, and to receive low-latency information. - - \image HIDClassArch.png "HID Class Driver Architecture" - - !!Class-Specific Descriptors - There are three class-specific descriptors defined in the }HID specification - 1.11}: the HID descriptor, the report descriptor and the physical descriptor. - - !HID Descriptor - The HID descriptor gives information about the HID specification revision - used, the country for which a %device is localized, and lists the number of - class-specific descriptors, including their length and type. - - HID Descriptor Format -||Field||Size(bytes)||Description -|bLength|1|Total length of the HID descriptor -|bDescriptorType|1|HID descriptor type (21h) -|bcdHID|2|HID specification release number in BCD format -|bCountryCode|1|Code of the country for which the %device is located.\n - Should be 0 if the %device is not localized. -|bNumDescriptors|1|Number of class-specific descriptors used by the %device. -|bDescriptorType|1|Type of the first class-specific descriptor. -|bDescriptorLength|1|Total length of the first class-specific descriptor. -|[bDescriptorType]|1|Type of the second class-specific descriptor. -|[bDescriptorLength]|1|Total length of the second class-specific descriptor. -|...| | - - There is always at least one Report descriptor for an HID %device, so the - corresponding fields must be present in the HID descriptor. If other - descriptors are defined, they must also be described here. - - !Report Descriptor - A HID %device must have at least one #Report descriptor#. It defines the type - of data manipulated by the %device, which is referred to as report. When the - %device wants to notify that the cursor has moved, for example, it sends the - corresponding report in the format previously defined in the Report - descriptor. - - This descriptor is quite different from others, as it does not have a fixed - table of values. Instead, it is made up of a variable number of items, which - collectively identify the information that a host can expect from or send to - the %device. - - There are five categories of items: - - #Input# items, which define the format and type of the data sent by the - %device. - - #Output# items, which define the format and type of the data expected by - the %device - - #Feature# items, which define data sent to or received from the %device, - and not intended for the end user, such as configuration parameters. -- #Collection# items, which identify a set of data as related to the same - group. -- #End Collection# items, which close other Collection items. - - Usually, a Report descriptor defines only one use (report) for a %device, e.g., - a mouse. However, it is possible to declare several reports to perform - different tasks, e.g., mouse & keyboard. This is done by assigning a different - #Report ID# to each report; this makes it possible for the %device to send - both reports through the same Interrupt endpoint, while still permitting the - host to correctly identify the data. Using only a single endpoint for several - functionalities is very powerful, as the remaining ones can then be used by - other interfaces (CDC, MSD, etc.) for an even more versatile %device. - - More details about Report descriptors will be given in the implementation - examples. For more information about the possible items, tags and values, - please refer to the }HID specification 1.11.} - - !Physical Descriptor - A #Physical descriptor# can be used to give information about which human body - part is used to activate a particular control. While this is a useless piece - of information for most devices, it can be relevant for complex devices which - provide many similar controls. In such a case, a Physical descriptor allows an - application to assign its functionalities more appropriately; for example, a - game controller often has a large number of buttons, with some of them more - accessible than the others. Those buttons would be assigned the most useful - actions. - - Since physical descriptors are not used very often, and are not useful in the - case studies described in this document, they will not be discussed further. - - !!Class-specific Requests - ... - - !GetDescriptor - While #GET_DESCRIPTOR# is a standard request (defined in the }USB - specification 2.0}), new descriptor type values have been added for the HID - class. They make it possible for the host to request the HID descriptor, - Report descriptor and Physical descriptors used by the %device. - - When requesting a HID-specific descriptor, the }wIndex} field of the request - must be set to the HID interface number. For standard requests, this field is - either set to 0 or, for String descriptors, to the index of the language ID - used. - - !SetDescriptor - Similarly, #SET_DESCRIPTOR# is a standard request with added HID-specific - values. It is used by the host to change the HID descriptors of a %device. - This is an optional request, and has few practical uses. - - !GetReport - The host can explicitly ask the %device for a report by using the #GET_REPORT# - request. However, it should be used primarily to get the state of feature - items and absolute values at initialization time, not for consistent %device - polling. - - The requested report is identified either by its Report ID (if they are used), - and/or by its type (Input, Output or Feature). - - Please note that a GET_REPORT request is different from a GET_DESCRIPTOR - request for the Report descriptor. The latter returns the whole Report - descriptor, i.e., all the items declared. The former returns the data defined - by this descriptor. - - !SetReport - #SET_REPORT# is similar to GET_REPORT, except this request is used for - changing the state of a report, instead of simply retrieving it. - - For an Input report, this request can either be considered meaningless, or can - be used to reset the current status of a control. For example, it could be - used to calibrate the neutral position of a joystick. - - !SetIdle - This request is used to specify the minimum amount of time, called #Idle - rate#, that a %device must wait before transmitting a report if its state has - not changed. This means the %device must NAK all polls on its Interrupt IN - endpoint until the report state changes, or the guarding period expires. - - The SET_IDLE command can either be issued for a particular duration, or for an - undefined period of time. The upper byte of the wValue field is used to - specify this duration. In addition, if the %device generates multiple reports, - the Report ID of the target report to affect can be specified in the lower - byte. - - In practice, this request is often used with a keyboard to put a small delay - before a key is repeated continuously. For a mouse, it must be set to 0, - meaning that the %device should never report an unchanged state. - - !GetIdle - The GET_IDLE request is issued by the host to retrieve the current Idle rate - of the %device. A particular Report can be specified with its Report ID. - - !GetProtocol - This request returns the protocol currently used by the %device. This can - either be the Report protocol (}wValue} set to 0) or the Boot protocol - (}wValue} set to 1). Since a %device supporting the Boot protocol can operate - differently depending on which mode it is in, the host system can retrieve or - change this mode with the GET_PROTOCOL and SET_PROTOCOL requests. - - This request is only need for devices supporting the Boot protocol. - - !SetProtocol - Whenever an HID %device starts up, it should use the Report protocol by - default. However, the host driver shall still use the SET_PROTOCOL - request to specify if the %device should use the Report protocol or the - Boot protocol. - - !!!Host Drivers - Most operating systems provide a generic HID driver which automatically - handles standard devices, such as keyboard, mice and joystick. In addition, - the driver can also be used by the application to easily access custom and - vendor-specific devices. - -*/ \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.c b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.c deleted file mode 100644 index 3cf1cd9e2..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.c +++ /dev/null @@ -1,392 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDMouseDriver.h" -#include "HIDDMouseDriverDescriptors.h" -#include "HIDDMouseInputReport.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Internal Defines -//------------------------------------------------------------------------------ - -/// Tag bit (Always 1) -#define HIDDMouse_TAG (1 << 3) - -/// Xsign bit -#define HIDDMouse_Xsign (1 << 4) - -/// Ysign bit -#define HIDDMouse_Ysign (1 << 5) - - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Driver structure for an HID device implementing keyboard functionalities. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard USB device driver instance. - USBDDriver usbdDriver; - /// Idle rate (in milliseconds) of the input report. - unsigned char inputReportIdleRate; - /// - unsigned char inputProtocol; - /// Input report instance. - HIDDMouseInputReport inputReport; - -} HIDDMouseDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Static instance of the HID mouse device driver. -static HIDDMouseDriver hiddMouseDriver; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns the descriptor requested by the host. -/// \param type Descriptor type. -/// \param length Maximum number of bytes to send. -/// \return 1 if the request has been handled by this function, otherwise 0. -//------------------------------------------------------------------------------ -static unsigned char HIDDMouseDriver_GetDescriptor(unsigned char type, - unsigned char length) -{ - const USBConfigurationDescriptor *pConfiguration; - HIDDescriptor *hidDescriptor; - - switch (type) { - - case HIDGenericDescriptor_REPORT: - TRACE_INFO("Report "); - - // Adjust length and send report descriptor - if (length > HIDDMouseDriverDescriptors_REPORTSIZE) { - - length = HIDDMouseDriverDescriptors_REPORTSIZE; - } - USBD_Write(0, &hiddReportDescriptor, length, 0, 0); - break; - - case HIDGenericDescriptor_HID: - TRACE_INFO("HID "); - - // Configuration descriptor is different depending on configuration - if (USBD_IsHighSpeed()) { - - pConfiguration = - hiddMouseDriver.usbdDriver.pDescriptors->pHsConfiguration; - } - else { - - pConfiguration = - hiddMouseDriver.usbdDriver.pDescriptors->pFsConfiguration; - } - - // Parse the device configuration to get the HID descriptor - USBConfigurationDescriptor_Parse(pConfiguration, 0, 0, - (USBGenericDescriptor **) &hidDescriptor); - - // Adjust length and send HID descriptor - if (length > sizeof(HIDDescriptor)) { - - length = sizeof(HIDDescriptor); - } - USBD_Write(0, hidDescriptor, length, 0, 0); - break; - - default: - return 0; - } - - return 1; -} - -//------------------------------------------------------------------------------ -/// Sends the current Idle rate of the input report to the host. -//------------------------------------------------------------------------------ -static void HIDDMouseDriver_GetIdle() -{ - TRACE_INFO("gIdle "); - - USBD_Write(0, &(hiddMouseDriver.inputReportIdleRate), 1, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Retrieves the new idle rate of the input report from the USB host. -/// \param idleRate New input report idle rate. -//------------------------------------------------------------------------------ -static void HIDDMouseDriver_SetIdle(unsigned char idleRate) -{ - TRACE_INFO("sIdle(%d) ", idleRate); - - hiddMouseDriver.inputReportIdleRate = idleRate; - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Sends the requested report to the host. -/// \param type Report type. -/// \param length Maximum number of bytes to send. -//------------------------------------------------------------------------------ -static void HIDDMouseDriver_GetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO("gReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - TRACE_INFO("In "); - - // Adjust size and send report - if (length > sizeof(HIDDMouseInputReport)) { - - length = sizeof(HIDDMouseInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddMouseDriver.inputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Retrieves the new value of a report from the host and saves it. -/// \param type Report type. -/// \param length Report length. -//------------------------------------------------------------------------------ -static void HIDDMouseDriver_SetReport(unsigned char type, - unsigned short length) -{ - TRACE_INFO("sReport "); - - // Check report type - switch (type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - default: - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -// Optional RequestReceived() callback re-implementation -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) - -//------------------------------------------------------------------------------ -/// Callback function when new request receivce from host -/// \param request Pointer to the USBGenericRequest instance -//------------------------------------------------------------------------------ -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - HIDDMouseDriver_RequestHandler(request); -} - -#endif - -//------------------------------------------------------------------------------ -// ConfigurationChanged() callback re-implementation -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback function when configureation changed -/// \param cfgnum New configuration number -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - if (cfgnum > 0) { - - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the HID Mouse %device driver. -//------------------------------------------------------------------------------ -void HIDDMouseDriver_Initialize(void) -{ - hiddMouseDriver.inputReportIdleRate = 0; - HIDDMouseInputReport_Initialize(&(hiddMouseDriver.inputReport)); - USBDDriver_Initialize(&(hiddMouseDriver.usbdDriver), - &hiddMouseDriverDescriptors, - 0); // Multiple interface settings not supported - USBD_Init(); -} - -//------------------------------------------------------------------------------ -/// Handles HID-specific SETUP request sent by the host. -/// \param request Pointer to a USBGenericRequest instance -//------------------------------------------------------------------------------ -void HIDDMouseDriver_RequestHandler(const USBGenericRequest *request) -{ - TRACE_INFO("NewReq "); - - // Check if this is a standard request - if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // This is a standard request - switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, otherwise forward it to - // the standard driver - if (!HIDDMouseDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddMouseDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddMouseDriver.usbdDriver), - request); - } - } - // Check if this is a class request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - // This is a class-specific request - switch (USBGenericRequest_GetRequest(request)) { - - case HIDGenericRequest_GETIDLE: - HIDDMouseDriver_GetIdle(); - break; - - case HIDGenericRequest_SETIDLE: - HIDDMouseDriver_SetIdle(HIDIdleRequest_GetIdleRate(request)); - break; - - case HIDGenericRequest_GETREPORT: - HIDDMouseDriver_GetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - case HIDGenericRequest_SETREPORT: - HIDDMouseDriver_SetReport( - HIDReportRequest_GetReportType(request), - USBGenericRequest_GetLength(request)); - break; - - case HIDGenericRequest_GETPROTOCOL: - USBD_Write(0, &hiddMouseDriver.inputProtocol, 1, 0, 0); - break; - - case HIDGenericRequest_SETPROTOCOL: - hiddMouseDriver.inputProtocol = request->wValue; - USBD_Write(0, 0, 0, 0, 0); - break; - - default: - TRACE_WARNING( - "HIDDMouseDriver_RequestHandler: Unknown request 0x%02X\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - } - else { - - // Vendor request ? - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Update the Mouse button status and location changes via input report -/// to host -/// \param bmButtons Bit map of the button status -/// \param deltaX Movment on X direction -/// \param deltaY Movment on Y direction -//------------------------------------------------------------------------------ -unsigned char HIDDMouseDriver_ChangePoints(unsigned char bmButtons, - signed char deltaX, - signed char deltaY) -{ - hiddMouseDriver.inputReport.bmButtons = (bmButtons & 0x07) - | HIDDMouse_TAG; - hiddMouseDriver.inputReport.bX = deltaX; - hiddMouseDriver.inputReport.bY = deltaY; - // Send input report through the interrupt IN endpoint - return USBD_Write(HIDDMouseDriverDescriptors_INTERRUPTIN, - &(hiddMouseDriver.inputReport), - sizeof(HIDDMouseInputReport), - 0, - 0); -} - -//------------------------------------------------------------------------------ -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//------------------------------------------------------------------------------ -void HIDDMouseDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&(hiddMouseDriver.usbdDriver))) { - - USBD_RemoteWakeUp(); - } -} - diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.h b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.h deleted file mode 100644 index 94dac3a99..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriver.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of methods for using a HID mouse device driver. - - !!!Usage - - -# Re-implement the USBDCallbacks_RequestReceived callback to forward - requests to HIDDMouseDriver_RequestHandler. This is done - automatically unless the NOAUTOCALLBACK symbol is defined during - compilation. - -# Initialize the driver using HIDDMouseDriver_Initialize. The - USB driver is automatically initialized by this method. - -# Call the HIDDMouseDriver_ChangePoints method when one or more - keys are pressed/released. -*/ - -#ifndef HIDDKEYBOARDDRIVER_H -#define HIDDKEYBOARDDRIVER_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Mouse Button bitmaps" -/// ... -/// !Bits -/// - HIDDMouse_LEFT_BUTTON -/// - HIDDMouse_RIGHT_BUTTON -/// - HIDDMouse_MIDDLE_BUTTON - -/// Left mouse button -#define HIDDMouse_LEFT_BUTTON (1 << 0) - -/// Right mouse button -#define HIDDMouse_RIGHT_BUTTON (1 << 1) - -/// Middle mouse button -#define HIDDMouse_MIDDLE_BUTTON (1 << 2) - -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ -/* - Function: HIDDMouseDriver_Initialize - Initializes the HID keyboard device driver. -*/ -extern void HIDDMouseDriver_Initialize(void); - -/* - Function: HIDDMouseDriver_RequestHandler - Handles HID-specific SETUP request sent by the host. - - Parameters: - request - Pointer to a USBGenericRequest instance. -*/ -extern void HIDDMouseDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned char HIDDMouseDriver_ChangePoints(unsigned char bmButtons, - signed char deltaX, - signed char deltaY); - -extern void HIDDMouseDriver_RemoteWakeUp(void); - -#endif //#ifndef HIDDKEYBOARDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.c b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.c deleted file mode 100644 index 6a66d83ad..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.c +++ /dev/null @@ -1,385 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDMouseDriverDescriptors - - About: Purpose - Declaration of the descriptors used by the HID device keyboard driver. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDMouseDriverDescriptors.h" -#include "HIDDMouseInputReport.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Mouse Device Descriptor IDs" -/// ... -/// -/// !IDs -/// - HIDDMouseDriverDescriptors_PRODUCTID -/// - HIDDMouseDriverDescriptors_VENDORID -/// - HIDDMouseDriverDescriptors_RELEASE - -/// Device product ID. -#define HIDDMouseDriverDescriptors_PRODUCTID 0x6200 -/// Device vendor ID. -#define HIDDMouseDriverDescriptors_VENDORID 0x03EB -/// Device release number. -#define HIDDMouseDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// List of descriptors that make up the configuration descriptors of a -/// %device using the HID Mouse driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Configuration descriptor. - USBConfigurationDescriptor configuration; - /// Interface descriptor. - USBInterfaceDescriptor interface; - /// HID descriptor. - HIDDescriptor hid; - /// Interrupt IN endpoint descriptor. - USBEndpointDescriptor interruptIn; - -} __attribute__ ((packed)) HIDDMouseDriverConfigurationDescriptors; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Device descriptor. -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDMouseDriverDescriptors_VENDORID, - HIDDMouseDriverDescriptors_PRODUCTID, - HIDDMouseDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Device qualifier descriptor (high-speed only). -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // One possible configuration - 0 // Reserved -}; -#endif - -/// Configuration descriptor. -static const HIDDMouseDriverConfigurationDescriptors configurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDMouseDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 1, // One endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_MOUSE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDMouseDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDMouseDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDMouseInputReport), - HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING - } -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Other-speed configuration descriptor. -static const HIDDMouseDriverConfigurationDescriptors otherSpeedDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(HIDDMouseDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_MOUSE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDMouseDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDMouseDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDMouseInputReport), - HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING - } -}; -#endif - -/* - Variables: String descriptors - languageIdDescriptor - Language ID string descriptor. - manufacturerDescriptor - Manufacturer name. - productDescriptor - Product name. - serialNumberDescriptor - Product serial number. - stringDescriptors - Array of pointers to string descriptors. -*/ -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L') -}; - -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(19), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('H'), - USBStringDescriptor_UNICODE('I'), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('O'), - USBStringDescriptor_UNICODE('U'), - USBStringDescriptor_UNICODE('S'), - USBStringDescriptor_UNICODE('E'), -}; - -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(12), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3'), - USBStringDescriptor_UNICODE('4'), - USBStringDescriptor_UNICODE('5'), - USBStringDescriptor_UNICODE('6'), - USBStringDescriptor_UNICODE('7'), - USBStringDescriptor_UNICODE('8'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('F') -}; - -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors used by the HID keyboard driver. -USBDDriverDescriptors hiddMouseDriverDescriptors = { - - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, -#else - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration - 0, // No high-speed device descriptor - 0, // No high-speed configuration descriptor - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor -#endif - stringDescriptors, - 4 // Four string descriptors in list -}; - -/// Report descriptor used by the driver. -const unsigned char hiddReportDescriptor[] = { - - // Global Usage Page - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - // Collection: Application - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_MOUSE, - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, - // Physical collection: Pointer - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_POINTER, - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_PHYSICAL, - - // Input report: buttons - HIDReport_GLOBAL_USAGEPAGE + 1, HIDButton_PAGEID, - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, 1, - HIDReport_LOCAL_USAGEMAXIMUM + 1, 3, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, // 3 button bits - - // Input report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_INPUT + 1, HIDReport_CONSTANT, // 5 bit padding - - // Input report: pointer - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_REPORTCOUNT + 1, 2, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_X, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Y, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -127, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 127, - HIDReport_INPUT + 1, HIDReport_VARIABLE | HIDReport_RELATIVE, - - HIDReport_ENDCOLLECTION, - HIDReport_ENDCOLLECTION -}; - diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.h b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.h deleted file mode 100644 index 4f27decec..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseDriverDescriptors.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions of the descriptors required by the HID device keyboard - driver. - - !!!Usage - -# Use the hiddMouseDriverDescriptors variable to initialize a - USBDDriver instance. - -# Send hiddReportDescriptor to the host when a GET_DESCRIPTOR request - for the report descriptor is received. -*/ - -#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H -#define HIDDKEYBOARDDRIVERDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -/* - Constants: Endpoints - HIDDMouseDriverDescriptors_INTERRUPTIN - Interrupt IN endpoint number. - HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING - Interrupt IN endpoint - polling rate (in milliseconds). -*/ -#define HIDDMouseDriverDescriptors_INTERRUPTIN 1 -#define HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING 10 - -/* - Constants: Report descriptor - HIDDMouseDriverDescriptors_REPORTSIZE - Size of the report descriptor - in bytes. -*/ -#define HIDDMouseDriverDescriptors_REPORTSIZE 50 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ -/* - Variables: HID keyboard driver descriptors - hiddMouseDriverDescriptors - List of descriptors used by the HID - keyboard driver. - hiddReportDescriptor - Report descriptor used by the driver. -*/ -extern USBDDriverDescriptors hiddMouseDriverDescriptors; -extern const unsigned char hiddReportDescriptor[]; - -#endif //#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.c b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.c deleted file mode 100644 index 1c1c979bc..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDMouseInputReport implementation - - About: Purpose - Implementation of the HIDDMouseInputReport class. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDMouseInputReport.h" -#include "HIDDMouseDriverDescriptors.h" -#include - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes a mouse input report instance. -/// \param report Pointer to a HIDDMouseInputReport instance. -//------------------------------------------------------------------------------ -void HIDDMouseInputReport_Initialize(HIDDMouseInputReport *report) -{ - report->bmButtons = 0; - report->bX = 0; - report->bY = 0; -} - -/* -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void HIDDMouseInputReport_UpdateButtons(HIDDMouseInputReport *report) -{ -} - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void HIDDMouseInputReport_UpdateAxis(HIDDMouseInputReport *report) -{ -} -*/ diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.h b/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.h deleted file mode 100644 index ca074fde8..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/HIDDMouseInputReport.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Class for manipulating HID Mouse input reports. - - !!!Usage - - -# Initialize a newly created input report with - HIDDMouseInputReport_Initialize -*/ - -#ifndef HIDDKEYBOARDINPUTREPORT_H -#define HIDDKEYBOARDINPUTREPORT_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Mouse Keys" - -/// Mouse Left Click Button -#define HIDDMouseInputReport_LEFT_BUTTON (1 << 0) -/// Mouse Right Click Button -#define HIDDMouseInputReport_RIGHT_BUTTON (1 << 1) -/// Mouse Middle Button -#define HIDDMouseInputReport_MIDDLE_BUTTON (1 << 2) -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -#ifdef __ICCARM__ // IAR -#pragma pack(1) // IAR -#define __attribute__(...) // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -/// HID input report structure used by the Mouse driver to notify the -/// host of pressed keys. -//------------------------------------------------------------------------------ -typedef struct { - - unsigned char bmButtons; /// Bitmap state of three mouse buttons. - signed char bX; /// Pointer displacement along the X axis. - signed char bY; /// Pointer displacement along the Y axis. - -} __attribute__ ((packed)) HIDDMouseInputReport; // GCC - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void HIDDMouseInputReport_Initialize(HIDDMouseInputReport *report); - -#endif //#ifndef HIDDKEYBOARDINPUTREPORT_H - diff --git a/src/ersky9x/libraries/usb/device/hid-mouse/hid-mouse.dir b/src/ersky9x/libraries/usb/device/hid-mouse/hid-mouse.dir deleted file mode 100644 index 9dd733bf6..000000000 --- a/src/ersky9x/libraries/usb/device/hid-mouse/hid-mouse.dir +++ /dev/null @@ -1,544 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB HID -/// %device - USB HID Mouse driver, to implement an USB Mouse %device. -/// -/// !!!Contents -/// -/// There are three things for the implement of the USB HID Mouse driver: -/// - Implement the USB HID driver structs and functions for the %device, -/// to initialize, to handle HID-specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the HID Mouse device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the %device as a USB Mouse %device. -/// - Implement methods to update the Mouse keys status, so that host can -/// get it through USB. -/// -/// For more information about what a particular group contains, please refer to -/// "USB HID Mouse". -//------------------------------------------------------------------------------ - -/** - \page "USB HID Mouse" - This page describes how to use the "AT91 USB device framework" to produce a USB - HID Mouse driver, which appears as a USB Mouse on host. - - Details about the USB and the HID class can be found in the }USB specification - 2.0} and the }HID specification 1.11}, respectively. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Device Class Definition for HID 1.11 - - - HID Usage Tables 1.12 - - !!!HID Basic - See "USB HID Basic". - - !!!Architecture - See "USB Device Framework Architecture". - - !!!Descriptors - - ... - - !!Device Descriptor - The Device descriptor of an HID %device is very basic, since the HID class - code is only specified at the Interface level. Thus, it only contains - standard values, as shown below: -\code -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDMouseDriverDescriptors_VENDORID, - HIDDMouseDriverDescriptors_PRODUCTID, - HIDDMouseDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; -\endcode - Note that the Vendor ID is a special value attributed by the USB-IF - organization. The product ID can be chosen freely by the vendor. - - !!Configuration Descriptor - Since one interface is required by the HID specification, this must be - specified in the Configuration descriptor. There is no other value of - interest to put here. -\code -// Configuration descriptor -{ - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDMouseDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) -}, -\endcode - When the Configuration descriptor is requested by the host (by using the - GET_DESCRIPTOR command), the %device must also sent all the related - descriptors, i.e. Interface, Endpoint and Class-Specific descriptors. It is - convenient to create a single structure to hold all this data, for sending - everything in one chunk. In the example software, a - HIDDMouseDriverConfigurationDescriptors structure has been declared for - that. - - !!HID Class Interface Descriptor - Since a Mouse %device needs to transmit as well as receive data, two - Interrupt (IN & OUT) endpoints are needed. This must be indicated in the - Interface descriptor. Conversely to the mouse example, the Boot protocol is - not implemented here, since there are more constraints on a Mouse %device. -\code -// Interface descriptor -{ - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor -}, -\endcode - - !!HID Descriptor - While a HID Mouse produces two different reports, one Input and one Output, - only one Report descriptor can be used to describe them. Since having Physical - descriptors is also useless for a Mouse, there will only be one HID class - descriptor specified here. - - For a Mouse, the }bCountryCode} field can be used to specify the language - of the key caps. As this is optional, it is simply set to 00h in the example: -\code -// HID descriptor -{ - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDMouseDriverDescriptors_REPORTSIZE -}, -\endcode - - !!Report Descriptor - Two current reports are defined in the Report descriptor. The first one is - used to notify the host of which keys are pressed, with both modifier keys - (alt, ctrl, etc.) and alphanumeric keys. The second report is necessary for - the host to send the LED (num lock, caps lock, etc.) states. - - The Report descriptor starts with the global %device functionality, described - with a #Usage Page# and a #Usage# items: -\code -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, - HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Mouse, -\endcode - - As in the mouse example, the }Generic Desktop} page is used. This time, the - specific usage is the }Mouse} one. An Application collection is then - defined to group the reports together: -\code - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, -\endcode - - The first report to be defined is the modifier keys. They are represented as a - bitmap field, indicating whether or not each key is pressed. A single byte is - used to map keys \#224-231 defined in the }HID Usage Tables} document: - LeftControl, LeftShift, LeftAlt, LeftGUI (e.g. Windows key), - RightControl, RightShift, RightAlt and RightGUI. - The }Keypad} usage page must be specified for this report, and since this is a - bitmap value, the data is flagged as }Variable}: -\code - // Input report: modifier keys - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_REPORTCOUNT + 1, 8, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDMouseDriverDescriptors_FIRSTMODIFIERKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDMouseDriverDescriptors_LASTMODIFIERKEY, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_INPUT + 1, HIDReport_VARIABLE, -\endcode - - Then, the actual alphanumeric key report is described. This is done by - defining several bytes of data, one for each pressed key. In the example, - up to three keys can be pressed at the same time (and detected) by the user. - Once again, the usage page is set to }Keypad}. This time however, the data - must be specified as an }Array}, since the same control (the keypad) produces - several values: -\code - // Input report: standard keys - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, - HIDDMouseDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, - HIDDMouseDriverDescriptors_LASTSTANDARDKEY, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID, - HIDReport_LOCAL_USAGEMINIMUM + 1, - HIDDMouseDriverDescriptors_FIRSTSTANDARDKEY, - HIDReport_LOCAL_USAGEMAXIMUM + 1, - HIDDMouseDriverDescriptors_LASTSTANDARDKEY, - HIDReport_INPUT + 1, 0 /* Data array */, -\endcode - - The LED array is then defined, with the associated usage page. The Report - descriptor is formatted in this order to avoid redefining unchanged }Global} - items, in order to save memory. This time again, the LED status is reported as - a bitmap field. Three LEDs are used here: Num Lock, Caps Lock and Scroll Lock - (IDs 01h to 03h). It is important to note that this is an #Output# report: -\code - // Output report: LEDs - HIDReport_GLOBAL_REPORTCOUNT + 1, 3, - HIDReport_GLOBAL_REPORTSIZE + 1, 1, - HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, - HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK, - HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK, - HIDReport_OUTPUT + 1, HIDReport_VARIABLE, -\endcode - - Since the previous report only contains 3 bits, the data must be padded to a - multiple of one byte. This is done by using constant Output data, as follows: -\code - // Output report: padding - HIDReport_GLOBAL_REPORTCOUNT + 1, 1, - HIDReport_GLOBAL_REPORTSIZE + 1, 5, - HIDReport_OUTPUT + 1, HIDReport_CONSTANT, -\endcode - - The last item, }End Collection}, is necessary to close the previously opened - }Application Collection}. -\code - HIDReport_ENDCOLLECTION -}; -\endcode - - The Input and Output reports defined by this descriptor can be modeled by the - following structures: -\code -// HID Input Report -typedef struct { - - // State of modifier keys. - unsigned char bmModifierKeys:8; - // Key codes of pressed keys. - unsigned char pressedKeys[HIDDMouseInputReport_MAXKEYPRESSES]; - -} __attribute__ ((packed)) HIDDMouseInputReport; // GCC -// HID Output Report -typedef struct { - - unsigned char numLockStatus:1, // State of the num. lock LED. - capsLockStatus:1, // State of the caps lock LED. - scrollLockStatus:1, // State of the scroll lock LED. - padding:5; // Padding bits. - -} __attribute__ ((packed)) HIDDMouseOutputReport; // GCC -\endcode - - An instance of each one of the reports is stored in a HIDDMouseDriver - structure, which holds the standard class driver and HID Mouse-specific - data. - - !!Physical Descriptor - A Physical descriptor is useless for a Mouse %device, so none are defined - in this example. - - !!Endpoint Descriptor - Following the Interface and HID-specific descriptors, the two necessary - endpoints are defined. -\code -// Interrupt IN endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDMouseDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDMouseInputReport), - HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING -}, -// Interrupt OUT endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDMouseDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDMouseOutputReport), - HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING -} -\endcode - - !!String Descriptors - Please refer to "Usage: USBD VID, PID & Strings". - - !!!Class-specific requests - A driver request handler should first differentiate between class-specific and - standard requests using the corresponding bits in the }bmRequestType} field. - In most cases, standard requests can be immediately forwarded to the standard - request handler method; class-specific methods must be decoded and treated by - the custom handler. - - !!GetDescriptor - Three values have been added by the HID specification for the #GET_DESCRIPTOR# - request. The high byte of the }wValue} field contains the type of the - requested descriptor; in addition to the standard types, the #HID - specification# adds the #HID descriptor# (21h), the #Report descriptor# - (22h) and the #Physical descriptor# (23h) types. - - There is no particular action to perform besides sending the descriptor. This - can be done by using the USBD_Write method, after the requested descriptor has - been identified: -\code -switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, - // otherwise forward it to - // the standard driver - if (!HIDDMouseDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddMouseDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddMouseDriver.usbdDriver), - request); -} -\endcode - A slight complexity of the GET_DESCRIPTOR and SET_DESCRIPTOR requests is that - those are standard requests, but the standard request handler - (USBDDriver_RequestHandler) must not always be called to treat them (since - they may refer to HID descriptors). The solution is to first identify - GET/SET_DESCRIPTOR requests, treat the HID-specific cases and, finally, - forward any other request to the standard handler. - - In this case, a GET_DESCRIPTOR request for the Physical descriptor is first - forwarded to the standard handler, and STALLed there because it is not - recognized. This is done because the %device does not have any Physical - descriptors, and thus, does not need to handle the associated request. - - !!SetDescriptor - This request is optional and is never issued by most hosts. It is not - implemented in this example. - - !!GetReport - Since the HID Mouse defines two different reports, the Report Type value - specified by this request (upper byte of the }wValue} field) must be examined - to decide which report to send. If the type value is 01h, then the Input - report must be returned; if it is 02h, the Output report is requested: -\code -case HIDGenericRequest_GETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch (type) { - - case HIDReportRequest_INPUT: - - // Adjust size and send report - if (length > sizeof(HIDDMouseInputReport)) { - - length = sizeof(HIDDMouseInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddMouseDriver.inputReport), - length, - 0, // No callback - 0); - break; - - case HIDReportRequest_OUTPUT: - - // Adjust size and send report - if (length > sizeof(HIDDMouseOutputReport)) { - - length = sizeof(HIDDMouseOutputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddMouseDriver.outputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetReport - For an HID Mouse, the #SET_REPORT# command can be sent by the host to - change the state of the LEDs. Normally, the dedicated Interrupt OUT endpoint - will be used for this; but in some cases, using the default Control endpoint - can save some bandwidth on the host side. - - Note that the SET_REPORT request can be directed at the Input report of the - Mouse; in this case, it can be safely discarded, according to the HID - specification. Normally, most host drivers only target the Output report. The - Report Type value is stored in the upper byte of the }wValue} field. - - The length of the data phase to follow is stored in the }wLength} field of the - request. It should be equal to the total length of the Output report. If it is - different, the report status must still be updated with the received data as - best as possible. - - When the reception of the new data is completed, some processing must be done - to enable/disable the corresponding LEDs. This is done in the callback - function passed as an argument to USBD_Read: -\code -case HIDGenericRequest_SETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch(type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - case HIDReportRequest_OUTPUT: - // Check report length - if (length != sizeof(HIDDMouseOutputReport)) { - - USBD_Stall(0); - } - else { - - USBD_Read(0, // Endpoint #0 - &(hiddMouseDriver.outputReport), - length, - (TransferCallback) HIDDMouseDriver_ReportReceived, - 0); // No argument to the callback function - } - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetIdle - In this case study, the #SET_IDLE# request is used to set a delay before a key - is repeated. This is common behavior on Mouse devices. Usually, this delay - is set to about 500 ms by the host. - - The only action here is to store the new Idle rate. The management of this - setting must be done in the main function, since Interrupt IN reports are sent - from there. - - In practice, it is not necessary to perform any action, apart from sending a - zero-length packet to acknowledge it. The main application however has to make - sure that only new reports are sent by the %device. -\code -case HIDGenericRequest_SETIDLE: -//----------------------------- - hiddMouseDriver.inputReportIdleRate = - HIDIdleRequest_GetIdleRate(request); - USBD_Write(0, 0, 0, 0, 0); -break; -\endcode - - !!GetIdle - The only necessary operation for this request is to send the previously saved - Idle rate. This is done by calling the USBD_Write method with the one-byte - variable as its parameter: -\code -case HIDGenericRequest_GETIDLE: -//----------------------------- - USBD_Write(0, &(hiddMouseDriver.inputReportIdleRate), 1, 0, 0); -break; -\endcode - - !!GetProtocol, SetProtocol - This HID Mouse example does not support the Boot protocol, so there is no - need to implement the SET_PROTOCOL and GET_PROTOCOL requests. This means they - can be safely STALLed when received. - - !!!Main Application - Like the mouse example, the main program must perform two different - operations. First, it has to monitor the physical inputs used as keys. In the - example software, the buttons present on the evaluation boards are used to - produce several modifier and alphanumeric keys. - - Also, the main program is in charge of sending reports as they are modified, - taking into account the Idle rate specified by the host. Idle rate management - can be carried out by firing/resetting a timer once a new report is sent; if - the timer expires, this means the Input report has not changed since. - According to the HID specification, a single instance of the report must be - sent in this case. - - Finally, the HID specification also defines that if too many keys are pressed - at the same time, the %device should report an }ErrorRollOver} usage value - (01h) in every byte of the key array. This has to be handled by the main - application as well. - -*/ \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.c b/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.c deleted file mode 100644 index ef9872822..000000000 --- a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.c +++ /dev/null @@ -1,453 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDTransferDriver.h" -#include "HIDDTransferDriverDesc.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Driver structure for an HID device implementing keyboard functionalities. -//------------------------------------------------------------------------------ -typedef struct { - - /// Standard USB device driver instance. - USBDDriver usbdDriver; - - // OUT Report - block input - unsigned short iReportLen; - unsigned char iReportBuf[HIDDTransferDriver_REPORTSIZE]; - - // IN Report - block output - unsigned short oReportLen; - unsigned char oReportBuf[HIDDTransferDriver_REPORTSIZE]; - - // Interrupt OUT Data - input - /// Input data length - unsigned short iLen; - /// Input (report) Buffer - unsigned char iBuf[HIDDTransferDriver_REPORTSIZE]; - - // Nothing more now... - -} HIDDTransferDriver; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Static instance of the HID Transfer device driver. -static HIDDTransferDriver hiddTransferDriver; - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Returns the descriptor requested by the host. -/// \param type Descriptor type. -/// \param length Maximum number of bytes to send. -/// \return 1 if the request has been handled by this function, otherwise 0. -//------------------------------------------------------------------------------ -static unsigned char HIDDTransferDriver_GetDescriptor(unsigned char type, - unsigned char length) -{ - const USBConfigurationDescriptor *pConfiguration; - HIDDescriptor *hidDescriptor; - - switch (type) { - - case HIDGenericDescriptor_REPORT: - TRACE_INFO("Report "); - - // Adjust length and send report descriptor - if (length > HIDDTransferDriverDescriptors_REPORTSIZE) { - - length = HIDDTransferDriverDescriptors_REPORTSIZE; - } - USBD_Write(0, &hiddReportDescriptor, length, 0, 0); - break; - - case HIDGenericDescriptor_HID: - TRACE_INFO("HID "); - - // Configuration descriptor is different depending on configuration - if (USBD_IsHighSpeed()) { - - pConfiguration = - hiddTransferDriver.usbdDriver.pDescriptors->pHsConfiguration; - } - else { - - pConfiguration = - hiddTransferDriver.usbdDriver.pDescriptors->pFsConfiguration; - } - - // Parse the device configuration to get the HID descriptor - USBConfigurationDescriptor_Parse(pConfiguration, 0, 0, - (USBGenericDescriptor **) &hidDescriptor); - - // Adjust length and send HID descriptor - if (length > sizeof(HIDDescriptor)) { - - length = sizeof(HIDDescriptor); - } - USBD_Write(0, hidDescriptor, length, 0, 0); - break; - - default: - return 0; - } - - return 1; -} - -//------------------------------------------------------------------------------ -/// Callback function when SetReport request data received from host -/// \param pArg Pointer to additional argument struct -/// \param status Result status -/// \param transferred Number of bytes transferred -/// \param remaining Number of bytes that are not transferred yet -//------------------------------------------------------------------------------ -static void HIDDTransferDriver_ReportReceived(void *pArg, - unsigned char status, - unsigned int transferred, - unsigned int remaining) -{ - hiddTransferDriver.iReportLen = transferred; - USBD_Write(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Callback function when GetReport request data sent to host -/// \param pArg Pointer to additional argument struct -/// \param status Result status -/// \param transferred Number of bytes transferred -/// \param remaining Number of bytes that are not transferred yet -//------------------------------------------------------------------------------ -static void HIDDTransferDriver_ReportSent(void *pArg, - unsigned char status, - unsigned int transferred, - unsigned int remaining) -{ - USBD_Read(0, 0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -/// Callback function when interrupt OUT data received from host -/// \param pArg Pointer to additional argument -/// \param status Result status -/// \param transferred Number of bytes transferred -/// \param remaining Number of bytes that are not transferred yet -//------------------------------------------------------------------------------ -static void HIDDTransferDriver_DataReceived(void *pArg, - unsigned char status, - unsigned int transferred, - unsigned int remaining) -{ - hiddTransferDriver.iLen = transferred; - - USBD_Read(HIDDTransferDriverDescriptors_INTERRUPTOUT, - hiddTransferDriver.iBuf, - HIDDTransferDriver_REPORTSIZE, - (TransferCallback)HIDDTransferDriver_DataReceived, - 0); -} - -//------------------------------------------------------------------------------ -// Optional RequestReceived() callback re-implementation -//------------------------------------------------------------------------------ -#if !defined(NOAUTOCALLBACK) - -//------------------------------------------------------------------------------ -/// Callback function when new request receivce from host -/// \param request Pointer to the USBGenericRequest instance -//------------------------------------------------------------------------------ -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - HIDDTransferDriver_RequestHandler(request); -} - -#endif - -//------------------------------------------------------------------------------ -// ConfigurationChanged() callback re-implementation -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Callback function when configureation changed -/// \param cfgnum New configuration number -//------------------------------------------------------------------------------ -void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) -{ - if (cfgnum > 0) { - - hiddTransferDriver.iLen = 0; - USBD_Read(HIDDTransferDriverDescriptors_INTERRUPTOUT, - hiddTransferDriver.iBuf, - HIDDTransferDriver_REPORTSIZE, - HIDDTransferDriver_DataReceived, - 0); - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// Initializes the HID Transfer %device driver. -//------------------------------------------------------------------------------ -void HIDDTransferDriver_Initialize() -{ - hiddTransferDriver.iReportLen = 0; - - USBDDriver_Initialize(&(hiddTransferDriver.usbdDriver), - &hiddTransferDriverDescriptors, - 0); // Multiple interface settings not supported - USBD_Init(); -} - -//------------------------------------------------------------------------------ -/// Handles HID-specific SETUP request sent by the host. -/// \param request Pointer to a USBGenericRequest instance -//------------------------------------------------------------------------------ -void HIDDTransferDriver_RequestHandler(const USBGenericRequest *request) -{ - TRACE_INFO("NewReq "); - - // Check if this is a standard request - if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { - - // This is a standard request - switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, otherwise forward it to - // the standard driver - if (!HIDDTransferDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddTransferDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddTransferDriver.usbdDriver), - request); - } - } - // Check if this is a class request - else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { - - unsigned short length = USBGenericRequest_GetLength(request); - unsigned char type = HIDReportRequest_GetReportType(request); - - switch (USBGenericRequest_GetRequest(request)) { - - case HIDGenericRequest_SETREPORT: - - if (length <= HIDDTransferDriver_REPORTSIZE && - type == HIDReportRequest_OUTPUT) { - - USBD_Read(0, - hiddTransferDriver.iReportBuf, - length, - HIDDTransferDriver_ReportReceived, - 0); // No argument to the callback function - } - else { - - USBD_Stall(0); - } - break; - - case HIDGenericRequest_GETREPORT: - - if (length <= HIDDTransferDriver_REPORTSIZE && - type == HIDReportRequest_INPUT) { - - USBD_Write(0, - hiddTransferDriver.oReportBuf, - length, - HIDDTransferDriver_ReportSent, - 0); - } - else { - - USBD_Stall(0); - } - break; - - default: - TRACE_WARNING( - "HIDDTransferDriver_RequestHandler: request 0x%02X\n\r", - USBGenericRequest_GetRequest(request)); - USBD_Stall(0); - } - } - else { - - // Vendor request ? - USBD_Stall(0); - } -} - -//------------------------------------------------------------------------------ -/// Try to read request buffer of SetReport. -/// Set pData to 0 to get current data length only. -/// \param pData Pointer to data buffer -/// \param dLength Data buffer length -/// \return Number of bytes read -//------------------------------------------------------------------------------ -unsigned short HIDDTransferDriver_ReadReport(void *pData, - unsigned int dLength) -{ - if (pData == 0) { - - return hiddTransferDriver.iReportLen; - } - - if (dLength > HIDDTransferDriver_REPORTSIZE) { - - dLength = HIDDTransferDriver_REPORTSIZE; - } - if (dLength > hiddTransferDriver.iReportLen) { - - dLength = hiddTransferDriver.iReportLen; - } - hiddTransferDriver.iReportLen = 0; - memcpy(pData, hiddTransferDriver.iReportBuf, dLength); - - return dLength; -} - -//------------------------------------------------------------------------------ -/// Try to read request buffer of interrupt OUT EP. -/// Set pData to 0 to get current data length only. -/// \param pData Pointer to data buffer -/// \param dLength Data buffer length -/// \return Number of bytes read -//------------------------------------------------------------------------------ -unsigned short HIDDTransferDriver_Read(void *pData, - unsigned int dLength) -{ - if (pData == 0) { - - return hiddTransferDriver.iLen; - } - - if (dLength > HIDDTransferDriver_REPORTSIZE) { - - dLength = HIDDTransferDriver_REPORTSIZE; - } - if (dLength > hiddTransferDriver.iLen) { - - dLength = hiddTransferDriver.iLen; - } - hiddTransferDriver.iLen = 0; - memcpy(pData, hiddTransferDriver.iBuf, dLength); - - return dLength; -} - -//------------------------------------------------------------------------------ -/// Set data in IN report buffer, which will be sent when GetReport request -/// issued. -/// \param pData Pointer to the data sent. -/// \param dLength The data length. -//------------------------------------------------------------------------------ -void HIDDTransferDriver_SetReport(const void *pData, - unsigned int dLength) -{ - if (pData == 0 || dLength == 0) - return; - if (dLength != HIDDTransferDriver_REPORTSIZE) { - dLength = HIDDTransferDriver_REPORTSIZE; - } - if (hiddTransferDriver.oReportLen) { - TRACE_INFO("Changing IN report!\n\r"); - } - memcpy(hiddTransferDriver.oReportBuf, pData, dLength); - hiddTransferDriver.oReportLen = dLength; -} - -//------------------------------------------------------------------------------ -/// Write data through USB interrupt IN EP. -/// \param pData Pointer to the data sent. -/// \param dLength The data length. -/// \param fCallback Callback function invoked when transferring done. -/// \param pArg Pointer to additional arguments. -//------------------------------------------------------------------------------ -unsigned char HIDDTransferDriver_Write(const void *pData, - unsigned int dLength, - TransferCallback fCallback, - void *pArg) -{ - if (dLength != HIDDTransferDriver_REPORTSIZE) { - - dLength = HIDDTransferDriver_REPORTSIZE; - } - return USBD_Write(HIDDTransferDriverDescriptors_INTERRUPTIN, - pData, dLength, - fCallback, pArg); -} - -//------------------------------------------------------------------------------ -/// Starts a remote wake-up sequence if the host has explicitely enabled it -/// by sending the appropriate SET_FEATURE request. -//------------------------------------------------------------------------------ -void HIDDTransferDriver_RemoteWakeUp(void) -{ - // Remote wake-up has been enabled - if (USBDDriver_IsRemoteWakeUpEnabled(&(hiddTransferDriver.usbdDriver))) { - - USBD_RemoteWakeUp(); - } -} - diff --git a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.h b/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.h deleted file mode 100644 index f374ae008..000000000 --- a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriver.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definition of methods for using a HID transfer %device driver. - - !!!Usage - - -# Re-implement the USBDCallbacks_RequestReceived callback to forward - requests to HIDDTransferDriver_RequestHandler. This is done - automatically unless the NOAUTOCALLBACK symbol is defined during - compilation. - -# Initialize the driver using HIDDTransferDriver_Initialize. The - USB driver is automatically initialized by this method. - -# Call the HIDDTransferDriver_Write method when sendint data to host. - -# Call the HIDDTransferRead, HIDDTransferReadReport when checking and getting - received data from host. -*/ - -#ifndef HIDDKEYBOARDDRIVER_H -#define HIDDKEYBOARDDRIVER_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void HIDDTransferDriver_Initialize(); - -extern void HIDDTransferDriver_RequestHandler(const USBGenericRequest *request); - -extern unsigned short HIDDTransferDriver_Read(void *pData, - unsigned int dLength); - -extern unsigned short HIDDTransferDriver_ReadReport(void *pData, - unsigned int dLength); - -extern unsigned char HIDDTransferDriver_Write(const void *pData, - unsigned int size, - TransferCallback callback, - void *pArg); - - -extern void HIDDTransferDriver_RemoteWakeUp(void); - -#endif //#ifndef HIDDKEYBOARDDRIVER_H - diff --git a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.c b/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.c deleted file mode 100644 index 5cd63632a..000000000 --- a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.c +++ /dev/null @@ -1,417 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/* - Title: HIDDTransferDriverDescriptors - - About: Purpose - Declaration of the descriptors used by the HID device Transfer driver. -*/ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include "HIDDTransferDriverDesc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \page "HID Transfer Device Descriptor IDs" -/// ... -/// -/// !IDs -/// - HIDDTransferDriverDescriptors_PRODUCTID -/// - HIDDTransferDriverDescriptors_VENDORID -/// - HIDDTransferDriverDescriptors_RELEASE - -/// Device product ID. -#define HIDDTransferDriverDescriptors_PRODUCTID 0x6201 -/// Device vendor ID. -#define HIDDTransferDriverDescriptors_VENDORID 0x03EB -/// Device release number. -#define HIDDTransferDriverDescriptors_RELEASE 0x0100 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Macros -//------------------------------------------------------------------------------ - -/// Returns the minimum between two values. -#define MIN(a, b) ((a < b) ? a : b) - -//------------------------------------------------------------------------------ -// Internal types -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -/// List of descriptors that make up the configuration descriptors of a -/// device using the HID Transfer driver. -//------------------------------------------------------------------------------ -typedef struct { - - /// Configuration descriptor. - USBConfigurationDescriptor configuration; - /// Interface descriptor. - USBInterfaceDescriptor interface; - /// HID descriptor. - HIDDescriptor hid; - /// Interrupt IN endpoint descriptor. - USBEndpointDescriptor interruptIn; - /// Interrupt OUT endpoint descriptor. - USBEndpointDescriptor interruptOut; - -} __attribute__ ((packed)) HIDDTransferDriverConfigurationDescriptors; - -//------------------------------------------------------------------------------ -// Internal variables -//------------------------------------------------------------------------------ - -/// Device descriptor. -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDTransferDriverDescriptors_VENDORID, - HIDDTransferDriverDescriptors_PRODUCTID, - HIDDTransferDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Device qualifier descriptor (high-speed only). -static const USBDeviceQualifierDescriptor qualifierDescriptor = { - - sizeof(USBDeviceQualifierDescriptor), - USBGenericDescriptor_DEVICEQUALIFIER, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), - 1, // One possible configuration - 0 // Reserved -}; -#endif - -/// Configuration descriptor. -static const HIDDTransferDriverConfigurationDescriptors configurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDTransferDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDTransferDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDTransferDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE( - HIDDTransferDriverDescriptors_INTERRUPTIN), - MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS, - HIDDTransferDriver_REPORTSIZE)), - HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDTransferDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE( - HIDDTransferDriverDescriptors_INTERRUPTOUT), - MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS, - HIDDTransferDriver_REPORTSIZE)), - HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING - } -}; - -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) -/// Other-speed configuration descriptor. -static const HIDDTransferDriverConfigurationDescriptors otherSpeedDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_OTHERSPEEDCONFIGURATION, - sizeof(HIDDTransferDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor - }, - // HID descriptor - { - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDTransferDriverDescriptors_REPORTSIZE - }, - // Interrupt IN endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDTransferDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE( - HIDDTransferDriverDescriptors_INTERRUPTIN), - MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_HS, - HIDDTransferDriver_REPORTSIZE)), - HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING - }, - // Interrupt OUT endpoint descriptor - { - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDTransferDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE( - HIDDTransferDriverDescriptors_INTERRUPTOUT), - MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_HS, - HIDDTransferDriver_REPORTSIZE)), - HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING - } -}; -#endif - -/* - Variables: String descriptors - languageIdDescriptor - Language ID string descriptor. - manufacturerDescriptor - Manufacturer name. - productDescriptor - Product name. - serialNumberDescriptor - Product serial number. - stringDescriptors - Array of pointers to string descriptors. -*/ -static const unsigned char languageIdDescriptor[] = { - - USBStringDescriptor_LENGTH(1), - USBGenericDescriptor_STRING, - USBStringDescriptor_ENGLISH_US -}; - -static const unsigned char manufacturerDescriptor[] = { - - USBStringDescriptor_LENGTH(5), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L') -}; - -static const unsigned char productDescriptor[] = { - - USBStringDescriptor_LENGTH(22), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('M'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('L'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('H'), - USBStringDescriptor_UNICODE('I'), - USBStringDescriptor_UNICODE('D'), - USBStringDescriptor_UNICODE(' '), - USBStringDescriptor_UNICODE('T'), - USBStringDescriptor_UNICODE('R'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('N'), - USBStringDescriptor_UNICODE('S'), - USBStringDescriptor_UNICODE('F'), - USBStringDescriptor_UNICODE('E'), - USBStringDescriptor_UNICODE('R'), -}; - -static const unsigned char serialNumberDescriptor[] = { - - USBStringDescriptor_LENGTH(12), - USBGenericDescriptor_STRING, - USBStringDescriptor_UNICODE('0'), - USBStringDescriptor_UNICODE('1'), - USBStringDescriptor_UNICODE('2'), - USBStringDescriptor_UNICODE('3'), - USBStringDescriptor_UNICODE('4'), - USBStringDescriptor_UNICODE('5'), - USBStringDescriptor_UNICODE('6'), - USBStringDescriptor_UNICODE('7'), - USBStringDescriptor_UNICODE('8'), - USBStringDescriptor_UNICODE('9'), - USBStringDescriptor_UNICODE('A'), - USBStringDescriptor_UNICODE('F') -}; - -static const unsigned char *stringDescriptors[] = { - - languageIdDescriptor, - manufacturerDescriptor, - productDescriptor, - serialNumberDescriptor -}; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -/// List of descriptors used by the HID Transfer driver. -USBDDriverDescriptors hiddTransferDriverDescriptors = { - - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, -#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS) - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, - &deviceDescriptor, - (USBConfigurationDescriptor *) &configurationDescriptors, - &qualifierDescriptor, - (USBConfigurationDescriptor *) &otherSpeedDescriptors, -#else - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration - 0, // No high-speed device descriptor - 0, // No high-speed configuration descriptor - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor -#endif - stringDescriptors, - 4 // Four string descriptors in list -}; - -/// Report descriptor used by the driver. -const unsigned char hiddReportDescriptor[] = { - - // Global Usage Page - HIDReport_GLOBAL_USAGEPAGE + 2, 0xFF, 0xFF, // Vendor-defined - // Collection: Application - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, - // Input report: Vendor-defined - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined usage - HIDReport_GLOBAL_REPORTCOUNT + 1, HIDDTransferDriver_REPORTSIZE, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -128, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, (unsigned char) 127, - HIDReport_INPUT + 1, 0, // No Modifiers - - // Output report: vendor-defined - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined usage - HIDReport_GLOBAL_REPORTCOUNT + 1, HIDDTransferDriver_REPORTSIZE, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -128, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, (unsigned char) 127, - HIDReport_OUTPUT + 1, 0, // No Modifiers - - HIDReport_ENDCOLLECTION -}; - diff --git a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.h b/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.h deleted file mode 100644 index 6b9beb7dc..000000000 --- a/src/ersky9x/libraries/usb/device/hid-transfer/HIDDTransferDriverDesc.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/** - \unit - - !!!Purpose - - Definitions of the descriptors required by the HID transfer %device driver. - - !!!Usage - - -# Use the hiddTransferDriverDescriptors variable to initialize a - USBDDriver instance. - -# Send hiddReportDescriptor to the host when a GET_DESCRIPTOR request - for the report descriptor is received. -*/ - -#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H -#define HIDDKEYBOARDDRIVERDESCRIPTORS_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Interrupt IN endpoint number. -#define HIDDTransferDriverDescriptors_INTERRUPTIN 1 -/// Polling rate in ms -#define HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING 50 -/// Interrupt IN endpoint polling rate (in milliseconds). -#define HIDDTransferDriverDescriptors_INTERRUPTOUT 2 -/// Polling rate in ms -#define HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING 50 - -/// Size of the report descriptor in bytes. -#define HIDDTransferDriverDescriptors_REPORTSIZE 32 - -/// Size of the input and output report, in bytes -#define HIDDTransferDriver_REPORTSIZE 32 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ -/* - Variables: HID keyboard driver descriptors - hiddTransferDriverDescriptors - List of descriptors used by the HID - keyboard driver. - hiddReportDescriptor - Report descriptor used by the driver. -*/ -extern USBDDriverDescriptors hiddTransferDriverDescriptors; -extern const unsigned char hiddReportDescriptor[]; - -#endif //#ifndef HIDDKEYBOARDDRIVERDESCRIPTORS_H - diff --git a/src/ersky9x/libraries/usb/device/hid-transfer/hid-transfer.dir b/src/ersky9x/libraries/usb/device/hid-transfer/hid-transfer.dir deleted file mode 100644 index a478e5070..000000000 --- a/src/ersky9x/libraries/usb/device/hid-transfer/hid-transfer.dir +++ /dev/null @@ -1,473 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB HID -/// %device - USB HID Transfer driver, to implement an USB HID compatible -/// %device for customized data transmitting. -/// -/// !!!Contents -/// -/// There are three things for the implement of the USB HID Transfer driver: -/// - Implement the USB HID driver structs and functions for the %device, -/// to initialize, to handle HID-specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// endpoints, -/// - Create the HID Transfer device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the %device as a USB Transfer %device. -/// - Implement methods to read/write data through interrupt endpoints, so that -/// host and device can exchange data. -/// -/// For more information about what a particular group contains, please refer to -/// "USB HID Transfer". -//------------------------------------------------------------------------------ - -/** - \page "USB HID Transfer" - This page describes how to use the "AT91 USB device framework" to produce a USB - HID Transfer driver, which appears as a USB HID complient device on host. - - Details about the USB and the HID class can be found in the }USB specification - 2.0} and the }HID specification 1.11}, respectively. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Device Class Definition for HID 1.11 - - - HID Usage Tables 1.12 - - !!!HID Basic - See "USB HID Basic". - - !!!Architecture - See "USB Device Framework Architecture". - - !!!Descriptors - - ... - - !!Device Descriptor - The Device descriptor of an HID %device is very basic, since the HID class - code is only specified at the Interface level. Thus, it only contains - standard values, as shown below: -\code -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - HIDDeviceDescriptor_CLASS, - HIDDeviceDescriptor_SUBCLASS, - HIDDeviceDescriptor_PROTOCOL, - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), - HIDDKeyboardDriverDescriptors_VENDORID, - HIDDKeyboardDriverDescriptors_PRODUCTID, - HIDDKeyboardDriverDescriptors_RELEASE, - 1, // Index of manufacturer description - 2, // Index of product description - 3, // Index of serial number description - 1 // One possible configuration -}; -\endcode - Note that the Vendor ID is a special value attributed by the USB-IF - organization. The product ID can be chosen freely by the vendor. - - !!Configuration Descriptor - Since one interface is required by the HID specification, this must be - specified in the Configuration descriptor. There is no other value of - interest to put here. -\code -// Configuration descriptor -{ - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(HIDDKeyboardDriverConfigurationDescriptors), - 1, // One interface in this configuration - 1, // This is configuration #1 - 0, // No associated string descriptor - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) -}, -\endcode - When the Configuration descriptor is requested by the host (by using the - GET_DESCRIPTOR command), the %device must also sent all the related - descriptors, i.e. Interface, Endpoint and Class-Specific descriptors. It is - convenient to create a single structure to hold all this data, for sending - everything in one chunk. In the example software, a - HIDDKeyboardDriverConfigurationDescriptors structure has been declared for - that. - - !!HID Class Interface Descriptor - Since a keyboard %device needs to transmit as well as receive data, two - Interrupt (IN & OUT) endpoints are needed. This must be indicated in the - Interface descriptor. Conversely to the mouse example, the Boot protocol is - not implemented here, since there are more constraints on a keyboard %device. -\code -// Interface descriptor -{ - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is alternate setting #0 - 2, // Two endpoints used - HIDInterfaceDescriptor_CLASS, - HIDInterfaceDescriptor_SUBCLASS_NONE, - HIDInterfaceDescriptor_PROTOCOL_NONE, - 0 // No associated string descriptor -}, -\endcode - - !!HID Descriptor - While a HID keyboard produces two different reports, one Input and one Output, - only one Report descriptor can be used to describe them. Since having Physical - descriptors is also useless for a keyboard, there will only be one HID class - descriptor specified here. - - For a keyboard, the }bCountryCode} field can be used to specify the language - of the key caps. As this is optional, it is simply set to 00h in the example: -\code -// HID descriptor -{ - sizeof(HIDDescriptor), - HIDGenericDescriptor_HID, - HIDDescriptor_HID1_11, - 0, // Device is not localized, no country code - 1, // One HID-specific descriptor (apart from this one) - HIDGenericDescriptor_REPORT, - HIDDKeyboardDriverDescriptors_REPORTSIZE -}, -\endcode - - !!Report Descriptor - Two current reports are defined in the Report descriptor. The first one is - used to notify the host of which keys are pressed, with both modifier keys - (alt, ctrl, etc.) and alphanumeric keys. The second report is necessary for - the host to send the LED (num lock, caps lock, etc.) states. - - The Report descriptor starts with the global %device functionality, described - with a #Usage Page# and a #Usage# items: -\code -const unsigned char hiddReportDescriptor[] = { - - HIDReport_GLOBAL_USAGEPAGE + 2, 0xFF, 0xFF, // Vendor-defined - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined -\endcode - - An Application collection is then defined to group the reports together: -\code - HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, -\endcode - - The first report to be defined is the input report, all data in the buffer - is vendor defined: -\code - // Input report: Vendor-defined - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined usage - HIDReport_GLOBAL_REPORTCOUNT + 1, HIDDTransferDriver_REPORTSIZE, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -128, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, (unsigned char) 127, - HIDReport_INPUT + 1, 0, // No Modifiers -\endcode - - The output report is then defined, data is for the user to decode: -\code - // Output report: vendor-defined - HIDReport_LOCAL_USAGE + 1, 0xFF, // Vendor-defined usage - HIDReport_GLOBAL_REPORTCOUNT + 1, HIDDTransferDriver_REPORTSIZE, - HIDReport_GLOBAL_REPORTSIZE + 1, 8, - HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -128, - HIDReport_GLOBAL_LOGICALMAXIMUM + 1, (unsigned char) 127, - HIDReport_OUTPUT + 1, 0, // No Modifiers -\endcode - - The last item, }End Collection}, is necessary to close the previously opened - }Application Collection}. -\code - HIDReport_ENDCOLLECTION -}; -\endcode - - The input report and output report are all user defined. We define the first - byte as bit map of push buttons and LEDs, remaining bytes as data. - - !!Physical Descriptor - A Physical descriptor is useless for a general transfer %device, so none is - defined in this example. - - !!Endpoint Descriptor - Following the Interface and HID-specific descriptors, the two necessary - endpoints are defined. -\code -// Interrupt IN endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - HIDDKeyboardDriverDescriptors_INTERRUPTIN), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardInputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING -}, -// Interrupt OUT endpoint descriptor -{ - sizeof(USBEndpointDescriptor), - USBGenericDescriptor_ENDPOINT, - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - HIDDKeyboardDriverDescriptors_INTERRUPTOUT), - USBEndpointDescriptor_INTERRUPT, - sizeof(HIDDKeyboardOutputReport), - HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING -} -\endcode - - !!String Descriptors - Please refer to "Usage: USBD VID, PID & Strings". - - !!!Class-specific requests - A driver request handler should first differentiate between class-specific and - standard requests using the corresponding bits in the }bmRequestType} field. - In most cases, standard requests can be immediately forwarded to the standard - request handler method; class-specific methods must be decoded and treated by - the custom handler. - - !!GetDescriptor - Three values have been added by the HID specification for the #GET_DESCRIPTOR# - request. The high byte of the }wValue} field contains the type of the - requested descriptor; in addition to the standard types, the #HID - specification# adds the #HID descriptor# (21h), the #Report descriptor# - (22h) and the #Physical descriptor# (23h) types. - - There is no particular action to perform besides sending the descriptor. This - can be done by using the USBD_Write method, after the requested descriptor has - been identified: -\code -switch (USBGenericRequest_GetRequest(request)) { - - case USBGenericRequest_GETDESCRIPTOR: - // Check if this is a HID descriptor, - // otherwise forward it to - // the standard driver - if (!HIDDKeyboardDriver_GetDescriptor( - USBGetDescriptorRequest_GetDescriptorType(request), - USBGenericRequest_GetLength(request))) { - - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); - } - break; - - default: - USBDDriver_RequestHandler(&(hiddKeyboardDriver.usbdDriver), - request); -} -\endcode - A slight complexity of the GET_DESCRIPTOR and SET_DESCRIPTOR requests is that - those are standard requests, but the standard request handler - (USBDDriver_RequestHandler) must not always be called to treat them (since - they may refer to HID descriptors). The solution is to first identify - GET/SET_DESCRIPTOR requests, treat the HID-specific cases and, finally, - forward any other request to the standard handler. - - In this case, a GET_DESCRIPTOR request for the Physical descriptor is first - forwarded to the standard handler, and STALLed there because it is not - recognized. This is done because the %device does not have any Physical - descriptors, and thus, does not need to handle the associated request. - - !!SetDescriptor - This request is optional and is never issued by most hosts. It is not - implemented in this example. - - !!GetReport - Since the HID keyboard defines two different reports, the Report Type value - specified by this request (upper byte of the }wValue} field) must be examined - to decide which report to send. If the type value is 01h, then the Input - report must be returned; if it is 02h, the Output report is requested: -\code -case HIDGenericRequest_GETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch (type) { - - case HIDReportRequest_INPUT: - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardInputReport)) { - - length = sizeof(HIDDKeyboardInputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.inputReport), - length, - 0, // No callback - 0); - break; - - case HIDReportRequest_OUTPUT: - - // Adjust size and send report - if (length > sizeof(HIDDKeyboardOutputReport)) { - - length = sizeof(HIDDKeyboardOutputReport); - } - USBD_Write(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - 0, // No callback - 0); - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetReport - For an HID keyboard, the #SET_REPORT# command can be sent by the host to - change the state of the LEDs. Normally, the dedicated Interrupt OUT endpoint - will be used for this; but in some cases, using the default Control endpoint - can save some bandwidth on the host side. - - Note that the SET_REPORT request can be directed at the Input report of the - keyboard; in this case, it can be safely discarded, according to the HID - specification. Normally, most host drivers only target the Output report. The - Report Type value is stored in the upper byte of the }wValue} field. - - The length of the data phase to follow is stored in the }wLength} field of the - request. It should be equal to the total length of the Output report. If it is - different, the report status must still be updated with the received data as - best as possible. - - When the reception of the new data is completed, some processing must be done - to enable/disable the corresponding LEDs. This is done in the callback - function passed as an argument to USBD_Read: -\code -case HIDGenericRequest_SETREPORT: -//------------------------------- - type = HIDReportRequest_GetReportType(request); - length = USBGenericRequest_GetLength(request); - switch(type) { - - case HIDReportRequest_INPUT: - // SET_REPORT requests on input reports are ignored - USBD_Stall(0); - break; - - case HIDReportRequest_OUTPUT: - // Check report length - if (length != sizeof(HIDDKeyboardOutputReport)) { - - USBD_Stall(0); - } - else { - - USBD_Read(0, // Endpoint #0 - &(hiddKeyboardDriver.outputReport), - length, - (TransferCallback) HIDDKeyboardDriver_ReportReceived, - 0); // No argument to the callback function - } - break; - - default: - USBD_Stall(0); - } -break; -\endcode - - !!SetIdle - In this case study, the #SET_IDLE# request is used to set a delay before a key - is repeated. This is common behavior on keyboard devices. Usually, this delay - is set to about 500 ms by the host. - - The only action here is to store the new Idle rate. The management of this - setting must be done in the main function, since Interrupt IN reports are sent - from there. - - In practice, it is not necessary to perform any action, apart from sending a - zero-length packet to acknowledge it. The main application however has to make - sure that only new reports are sent by the %device. -\code -case HIDGenericRequest_SETIDLE: -//----------------------------- - hiddKeyboardDriver.inputReportIdleRate = - HIDIdleRequest_GetIdleRate(request); - USBD_Write(0, 0, 0, 0, 0); -break; -\endcode - - !!GetIdle - The only necessary operation for this request is to send the previously saved - Idle rate. This is done by calling the USBD_Write method with the one-byte - variable as its parameter: -\code -case HIDGenericRequest_GETIDLE: -//----------------------------- - USBD_Write(0, &(hiddKeyboardDriver.inputReportIdleRate), 1, 0, 0); -break; -\endcode - - !!GetProtocol, SetProtocol - This HID keyboard example does not support the Boot protocol, so there is no - need to implement the SET_PROTOCOL and GET_PROTOCOL requests. This means they - can be safely STALLed when received. - - !!!Main Application - Like the mouse example, the main program must perform two different - operations. First, it has to monitor the physical inputs used as keys. In the - example software, the buttons present on the evaluation boards are used to - produce several modifier and alphanumeric keys. - - Also, the main program is in charge of sending reports as they are modified, - taking into account the Idle rate specified by the host. Idle rate management - can be carried out by firing/resetting a timer once a new report is sent; if - the timer expires, this means the Input report has not changed since. - According to the HID specification, a single instance of the report must be - sent in this case. - - Finally, the HID specification also defines that if too many keys are pressed - at the same time, the %device should report an }ErrorRollOver} usage value - (01h) in every byte of the key array. This has to be handled by the main - application as well. - -*/ \ No newline at end of file diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDAppArch.png b/src/ersky9x/libraries/usb/device/massstorage/MSDAppArch.png deleted file mode 100644 index eec0f15980d81e2d9ac86e44efe8e887056ee1f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7248 zcmbt(cTm$^w{CcO6%eE-Rl2|{s1y+?p@Z};U}ym$A_CG02uKr9IwD{I1q3yrB*dtc z1Oq4~0xDo6krsMOz(@&53EX(*J9qA!@0>e#=KitwZ)X4Y?7e60wbt{jXJ;PnV8-6l0EcswvRcO(0{^%yW>beS`^LW><>fXU*PIXDZ2I4W3 zFsi@?=vmZjhr%}0L2p+UVxb_iS4=KGxZGBU4PB>ksG-Pg5ZrgoP_@q z)wLGo1XbxrW7~($oFBAoX69lN67&pQ)x;e5e%-wndZ%Gy|1N1kPpZmq5aLT;VE;C^ zZiSRf5y%{m(u`hnBHadO+8*TDJQ>?=r){u3B+M0Ip!2@_oIK$IxhT1mLe!q~l{?Dr z2nUV@Cdcvu4j$~n?f%T5MaXYOFO@N}62nzsT`Eo_`&{Wa1fB29#z51{#M29nl?Y;6 zAA%t`i3-QfPu08F523XB5tDB6bi2o=*)1%J|LdjL#M9qvkmIjZ39Vw(iH#+yg=z=% zbczno#~UK%=cFVFO(-@MkQQmseQME+G`4Mzl!GK}4W%L@I-oagV;~6pB6g+IY{-)%CGt=A zjh_Z^6!en>WSb!W?NZsus7)rX1bmf#EnLy}*wORtZ0P6-Ld1lZTBi+|T+UB%;PHSHo8?A!0(26;uHn7{3pZ>`_{j3ASCoz#8m^tr;4sKD!u!wFFId~4#+Ucn zll2VVw(8i9Q&0<^nU3n^!73;%SY+eS4qmQBb3qyehF{L zBI=Bor0-;UgULi46s?JM@9k<>>2&oev&H>Sw;QQ}%hA;4U#=rC}+Z3U@L~HB=ZG-GJ^G0GI%%cJlo^xEgoX; z*5AaX^>|d;Vj;{Lgl!LbMUdGMiM!`WhEDAeqh1n=)Dov?cHNs7^PoB;Asu)FBL)m2 zLko3nDu_}K3NC&vw+=~Q*~PUi%CLCxO!b|+Opz-Ecb-+;3UxB3fiD*9-@rUM=ls(d z-i;HZ&C&|qGad^aX>Yr?4Mv(EUel@QUiG?J?($sf02eA{1;( z?{jFpZfV93Y`zK*nU|>yFt}bNGd$?Ad(on5>QdCtb9aOVXbRH~PG_x8MvK9+FD2<$ zgjV<%kfhTa$ME;&Uaj;TBkkry4;zbO-!hC#u`?#?3@&^7Vuz8>kvdThOV{x6ggNKr^8J&$ z03+-qCA3AWEE2KfF7oHkOHFY=O_4xsd=;bB4R&hu4&aCBiQV1;3Y$^j|4!1o>+$&3 zY+=BOq2?Vj%`A)+@EfL_#t$U{k>}c|CV8l$RlpuZP$i1Gx1)o*`Pb)z`lua{>sK@>8v+j{mo5qx=6F!v6w{|K~}s;_==O8_~e{ zJivjgD>O!6dbX&_TXvwby&QkE^{wXmcp$k}U!6xf;o{L*7E;6>YhD8zgunY6gly1f z-ZOxd)CHDj+H~2M!wdP&KFE|>xJd}2)(RJH=TE4v7Ao>)LKDG$@RJ7z%>A9{AXis9 zoj$nqHe|dxL{8XW^g%0kx73*G(ZQ18)YKFzPu|kiwd+?z8@@03QvY42dfu>>7Q@5e z{<9ac=&=v6O}4Kv&nnr6PkX>HKdL?ucEktGB*o(S6PM%mY4m`~}KD zl2TgJ$$L4_UG-GnG}~>Vb=kDE)gJ{&3bgNQl2TW+VG;|g*j065DaNH2n?iJXOqVSV zcXnb8rlqIXfAfr8*&@b9&dcO}70ugiYq2+!46S}~=_bMVK5%svc6KFX8trzDIMZb~ z+Lxb(lFBxY`~5^IT=oE~T)Ia*G#zra$jlSz1^f`lvw+;15s%MbMWOef)a`wn+uZ#w zEsnNdy0qx!)xLDF*QWB@7!i18XGi?>!Ao?qj`MAD`Z2qzr#g}$39-pxdLPtPuZ#M%qMZ&5(^{HJ$8NKNQ>`612wgrqLG*Is(P~_q>z4c z^4UaRSQW6b)@BW79{0LVHK4v>$OO@V=u5gxOne0i+V3esMlp>Yqp1mwoYlfjrdAGZ zox_S<4iR_MQ0<|Unb0PFNGi3?VDem@>5_=g)N8)6Y`<2tuY1EF(mg@!M)N|sm-~oAqk+PMej)4b$9!iNGfXJ?_`52 zqEtLlX(lTAsAfHj+WW4}A;S?TG2r0kjfcv1uWgf>VNh-N4nYWn(uScwC-;zr(-YzRaWJ%6TzQM2FLl4Kjv^u!({> z=6!95jBnS%HRGiPX|oB>FB=uMz4v1RvvV02ms6ACkyYUeJY~GkT@VE<9*s^fgw@p& zIFJJSeLL2rZ%X17Z1?7coT=+s3OX}5=-vvz8X9j125OMRTsa);i54RzDb8@OqS#}H zdA@Y#D3SMf^{ii+jjDsmJ^b{uKK$q zb;~K{baR$?A$@e{r`{1n>=r`mKubBR^)zSekjn{IfA#iT2zzNQ>aQ-c5!qdB53{M4 zmsRUlsy7EqZUTpKCm=dhg~Y`O2^4Y3`gVn3?EyxVp%xr^&=Rnn(K?;E|Wr_fy~5cZCU& zTd?n2?evjT$OR3}n9#%L8-#B=_`_(?<1Y%YVlUCxw*N_H+gShoev%?p;810Ex!yhi z)qqU|=0k?sV^-xLBlYRMkrE18nvTimF9fWEgKiBn-!yKtJaR<@Q9PgqO+ZjtwMF)@ z=J%^QJ$HjvnOGC4xb&}0*{s}?MZu}BWqyHvSv=J9fZcc>i|J}SbQI@9(xAmdPOp2E zN61nxhl)u3QT98lC|&B%-i^8T=JtV0lg|AtLwGMmF_19%EzWY45NK3+FrSrVbv`BD z1EX>fQ|SP1gH1c9^gs?@yBQ{_)~aWgEeg=ch2Le+5}S7CNQv8w*=WqnTpXSXdwf4h zGSF-xY$lVTXz{3YG}z!(`O{@F8e;yX9BI(dAIS7<(LPeT6zliC@-|}XG%R3kp1#|k zd`Oo(*EL&hciX8uQ9sCJ081>8468dRHZwHY)Sn+LV5FH90OrE;+V6Ey1`LfRjI3sU z5XUm->|n@e91^vFRvr6#aQ-JpID z1xkLgUk6RlpK5nIY^CC2-sLSDI!S8q-f$U?#+9P)K~(Sl3?}$7TnAD99xhr0#GQvD zhEDh$nOvu?USsO*8RI6Z{ezx2Vy8u(J{h#pjnF6%B#;X8iy`>C89nhaNKB=@5Q|wy zrl|qc5Qlzi1qijy*)&#_(owrPUP&Zg{db!9C*XR7XoE|aVchZj6>~L=3Z5>GH9L>k z;XPrOBy-`X9Djhf-vmkY?SRj#L0Ipl&{%^{?5{x8Ee~MD8Sz3Fs#R$w)LJqq*bat&`%xnOo-=2q}riW}hs#xL<)uTPHO8LMmKO}{+h4-2cWk+?B#>xfi1xe3+IJ7KXvdurW$hM9kGSB{@Zq$#g^mb-TA&B&z5(lZ>^4- z0>z<8NQB`u03fDgNUC;Dp06A{Cm92{@Jxah52}!1Pg%1!@UQ=RvY%t6>ioo0Z@!Rm zO}nC78R7jJc3D;GB~k^0g4ryz&|I5mA+8f6C-#TV7r>3S%aF-4zM!v7E6qMwO#re> z$@%|O9sX-p>l8rlgsV>X{^SZ3!SGIVcKz~A2ai*TSlUd`e+>Nx`Fu9Lr4n+L$h(ha z(PIuP<-_eqAFCSV{VF`Y*kF%MwtGsx`ye;zEsaTYYyCT+F17rE=+{PMg*SmqQ(@rb z@Pt}j(p!uftbI3N5;QBF@M^zNgfTfgG*i{7Yu z>Q--}T}VPftIszvS4Yj}2Ka6Zt2k@o_mi-o5j7BZLled+?0(?I@^<*z&6Sc?ZY|Oq z;Ka_4UpfSrOvuP#UaFgeBa#I(NjEn)b*aU1riU$ zwl*U-&@Sbk^Jp3lcSz7a>_})P%th&tp29~Hq@|rF&o}E8F;h-fMfvS-A{G4f?ZhGA zm_TBIq0rCDFG%`P(V=;qhwXMz@_?Wb@QpZJlrS8y<&%dHfkZTj_<^_GUI?9Io73KV zc5pGQEA1}nRLY$4q5g{&-sf&130f+qifQ{3br(oBYZ#RnGn>g@GSNR&71{(u`vN5X zA*_vMQh+IbCFLtWPajX{iPyiB2t~L`58^R^aC!2v{4O6@<+o46DxqMbkIMt%6= z)GE0voK90rmj7u~qSww6JvgibMT!2UK#GOVgS z$kxdrFUPiKOKE!<)esuVWR^<@&q#`kyKqH9sd9yF)~3UrgS>bsJLsc~&7MV#gy9z% zZbtXktF?it>%Df1%_{D@V6HjQ7nU8plI!*G{j0Ab$C=-6-&jexGQWO%&GahPI}WjK zI>>(YxcyLOM1Rb|le*G6X9gjB59GwG`yPBEZG}!eH0KxZsF;Kzlnv)(5CL_;Ig3%O zJD1S5(JZHGe6s1#;0B5?I$>eUd_^pp9L}g3|C_e7x^mE@neG2xq5nGlZYrd|#%J11 zUM2kV*G3WTuiyv4@9S&BKKC_*jTEnd1V&D6DQ>;ji`_q#pDz^Wo%#N*@A_=y1T>gI zBOkdVqEh8jZqR_Md*kGjy2#hWje?1EAyW6=1m|#X%_`ML&7692&lOk*NM# zP^r#N4Jnqs(mu8O^63O8tFBPCi#fwHx{^dAAsQszWv}ymyt!0rEIJ5UGMA##Tc92X z*$ltB=Bd->KCnabr&5)7g$fo<1!CzsYn5t%e#eK&r~QG~E-|;4TKczlf4V-)Ji*34sj`z^2G0uju5=&tD)botTB3VB2;7dz9uaRk zCiK_K#d67V2F8GCEBmgqe48INbIk(3_PaI_$K`QL(1kNaa8;diZfexa_aL;uwc9KM z5P)425YQokqBRH1Ggwjt4)ig1iY_Ryx4m)vYb`%O9K~|0p;K3rfn$v>(9h@&vy-Oc z^lvYMo?#D&z)fG)6pkn_E@v*;%0UF92_9%IX;e##4{b0T7MJRFvaut+_eNv2uDdSW zj{4y+P9d+sn(+Z+i!@w}M)SRvfwkQO`h*RuFlCUc1_KHc^<&{Vky?76{FJNZyM7fy zp2h~?%9kF!kxvgR`%96ec298BGuAVcv9X7$tQgwR)Z+w0W!#})U6nL}EfSmMXkORv z+)mCVwdnQ<@pcK?o2hd0Ve@0pnJF&iTU}}Cq*K;si}abAs@yBd9tJsi8(a4dV_bKIyk=v||_O4j=B{BZM5iW}@^ z?}CE$)Mdg+zEfj7nT)@CvY}1yL^HAj6WW5xlP#3`J{%ZUAhVznF9OSpcepW?@K%iX z>t;O7RrV<5m7cd;0m@Gc9B!ksGz-3K023y^i5f3^a&G6%JicqkoTbT0 zhlfm0&h^7XO7j}l|31Z4`a$&{mE)8&j zaGE~UKSsLz%BsSEL9ZuX&?`Oa1h&B~P|>T^@{gh?JN5jn z-*ja^aFTkA=OHrP?2bNxTuZ)l90glbsSIU=RYU!$OQ8#F7ve0#Ms-)qk?w}I?tb8V zlG!WW{l^qe(cTobGrx({gBaby)h1!mHo|(`C{C~(@ z@!739=Tk;98S}Na=O);YMo2_YX5?c@BgLc!-w(&qO8#NHndcT;S05xnNCSD0o8s>s zjJdMi7BzxrLUl*23>92^K(8yCVqA}p9e*U}H~F(TDL%+DM#kcqdXo&1Z9d0Mt8k@X zJ6}W(!ZV-$KPu?|RelS15GBsG*p5gF6C%D#=k$FMVIV%n(NrMzJD)9Po7IeB{@nZi zs`|?XCKFEs5_rI5MxrVNlV+8Wgq#}*nY5MDkZ9FC9lw~WA?)MQo03b!&hysj?7SQb&S9406o(LqNsnL>}_l{piwHucujVB7wjABI7+5U%D ziT|`IZiNxQK53JcLrRqppb5+CrrZ;ty;Z4PjUGw0jo1Xhf+?0pEYjl(C_76Marq-= g=9?D*-fSC2jd@G?Q?3ZIo(KU}X7*PbO>W%(UoM=A8UO$Q diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriverArch.png b/src/ersky9x/libraries/usb/device/massstorage/MSDDriverArch.png deleted file mode 100644 index 4063440b3c91915e4f7dfe90d4faaec1a9aa0f36..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4889 zcmb_gYdBPG+g?%;qK8QKLbgdLn-M}8$q))-mttf$8qC;bR}UhaXpqg=n<&+AIEfta7<5#s>> z;G_lE%oYGRHrV4G?j!88ovF-E_T|JQuv0Jq2zdNHI9?m!d;mbO&%*4QeOSTD)Vqu_ z-7}qt7M-|hKJF6JM@QX}E8+b7?_|TY9&sDe!~IMiDgCK&mJvEcxGR$R;!j{{{cvm) zE&f0@?5CP12d=jEqL&^9!UGHm=%jv&DS{|c0|4W>f>G9!$7!5SmpFi7Gszsq zcBmsUb_^0=eAwRJ9+J-rK-~q5&xF8mmXg2^T?~Xk;V?cuq7OVXfpP)2!8AaI$43${ zlf`q!DwQLFQ}GDeVtxztb;}1xz2#h|Xmi@?5}zTfgHH#W0Q}2kXR+Ruy{JpQNy)8YH17LJn zOcf?Z2e>H!#(Fxb(r?4vwnzUI!l+E7yq^6VBq-+r7^9zJkyGPl>2`M9JT~3e$oc>n z`GFAqGrIZ8AE%46<*>-7v^p^}o7i}M3>#G8`wAr0v*@h{FWY?hpOIYxXO8;R6x+0v z{RDWCO5g`d{}cLu`}IE?O%5JgsJ{%v_fzPCZRE@z`0{cqUI z!py}I-nBuj*R?PjIPy}6eroo}G6%3R(c<7ehqmq>AzCaVRk#5qugpDq!2tm-wvLXPGlQCQF(%7f^p3wd`%DI3X4K98 z4i0fNFr>Q74?;~L-xdn*a|V}t7JH$#ccpK>p)rYmQCoO7NWhmhnI;eS43EYE{nSUbqOX4)YCiMP!4=I{olM}b|6s7g_sIlm9%Hiebt%!JcWIzF&nAYKrLp+Q;zY!9 zNH)<*Pb}fimj%E6B@O|r(BzxS@)e$hwO2iJ8hpE#DCJBMOOVi^%%l_N9 z%Ib)G{Ai`$ih+I9-CnuMM31_hDUhN(ucbz9&Y4J0|Es5k9vc)6QqgJ{*0W`V#4&#i zv2dn8*z}{}Q3iNx{nc2I^-Y=+NgIewE*$ixY?B|em)?BhGQBV1O^&Dwj1o<-864et9Bpv0v%jxOB0eNj zsqRHZF;US67pu->N)})Ka693HZhJ>ZBu!S-YZe-8Zh>%E- zHIzC(0X^K`FMxPDyilpf_wWztvZpaf%jxR|NnzWX_<;$B#|D-+pj2_Ux07~8s95z= z=4Ts-qY}S!Df-^bZck4lxp6bh;McIr+ajaG)R4XgPR0}6&!>{gLN!vBoCUDVJr)FN zBsLPq#|8zKFfuf}8LgQWv2+3WbYn&z2*G{@ivq@b|4PSl9zUg{eP71ue(nT|+8gV? z`0o)AYn!o$w^m$m3$9+1^!JY;HN5Gpd`_`ccK(n#SabW={D#~Hvao?u_gWFYQ~O5C z*w!ixRbRDwy!#Iq5aSr)yCEvWWYmw|mdCT$HJHG|*F7A`)w8pQKip;ZN-tr@MAumy=sV$!KgtuHMnJU|83;W+mfeECt$Omn+Dp7v0W zsXA@T`?MJab#LG%nL4j5v6Pek6Pl+XcGa@l> zS2e*8CUGMfcFduoBpT?#yIb{#>5m_aMMcd@r(-42H%tO4q`#Wlo#-aAcI}jiA9ik< z{8YmmT`tvRb(})hH>OXH&_%tfi0QzEYND0*06sr9(!)sVa52UbdM?MpVY;$y*y!G3 zWQyx+{=};V4(zasD!b7>Ve0;Ay7b)4W|Be}4HomDN1WG5HFJWf{7b7reeW%0<@j@W z$&VT=e~$vyfn!a*M74N?*`!ebPMDVqxhg6qERlSN_@sh z%!0P$e!YK{%hIrdvfry6dKoFMShbKLQ6f09ONXNf1h+Pkqr0I`5ShLSsq)BaLoCwV(g?QnQI~9+xRvbo!*83Rp}OX?q8$=G z-Gpf4{^&?WXdy+Q>dlZ)j|wW?M?Q_Z8J^c{1*H~hjJdRPm9Dz};h#FxM@HUinTfaz z^PHF#en;UZ8Km~0adI4;ale@yow~}FB(J+cf**_78KP7}@Hn9V-Wm%$k~!+m?BI!ZSJ@r{G-|A`Mm#`isu@*(dX)~AyCC=PmlSJVJA|gft2ug4csTO z8)hcl5GubWv}V6+x>jC@Sz=}qQJ8Z|oze4qD}nMLN3Mc=GQ72* zA4~u1VdQ5Gz6fIYussvy9)cV5tJJJq2^b4w=2hNmi|9^3SKaceYEm9oTB-Xj_g;ZA zEok2Z|Cj##eTl zWK|nCUn&FI7n<)_LES&VWj;L=16Z?Rqp%TTY@ssnLbkq$B~UTSj5sO$M|gAS_8#eT zrE9H2V@Uv{%gr7ez$xbDKqAbnJsOS8-9U-0%BE0e@r23~_0; z4&+@BoxWs1PRm$g_{2>&n^-1&(PM!hUI#j#>705H`Y7ewy7vBol~dL@MhkWLMT2in z_bXF-+equG-fm3r4XwxST0Ws`uXe2dA)bna?G=1dkI_dEhi~b@5M<#=gdO<=C;i;E zQWYv|$<0Jk?9OVSknj2YE++4$My0~Z<#%Gr4+VTmTaO#(9^B}v4tOkFB)54@V=l;RAY}VLEmxwD-X7| zjBxf5_pfk)AzT9|PPeG)s>P%v{0iVv(8pUJ7GOI35g52Cex9H%(AqP?%dW*sAN6dR0#RWPdQ%w4&P!lw#usdC(IUiy(p zq4Bd)adlO(xGp1k0_Yt*kW7mdtO7 zJ_F~h(w&pE60>#N-NZ9&d%=?Q6r=Ml$(QhrcH!P7-D8Dst8qO+_b(S@ZA2TKMzg)h zjvw(n$rC~sDSPlAU~rL?vKE1CezS1kl-`#S#eo4AOgVv{p%8?Q*DQh1`dOZN8(QeA zUO%TK#|t0E$ZJRWMm+t#)E{PQ*#-?|U4CAdvv@(?UZ=J5iLeuR!WwIAe$L!!k!uSZ zqiN+09a`UPWh|9U(qRo5Zr0{)FRBwX@UXuh&YDMU`?xw8)#oX*tNc7|Q*vWUt*>zA zon{r)BgWwbawso5w$?i9fjR_XRKq*JW}usL0!Earn)yHEa8v(oMsN}sE4 zNXJ4o1QS5IH6~v^vYQl<$`IN+cHJO4D^i+2qWM;UQzDLZdPWFqfd5wZ)+2aTXS5dl zAa0SfN<~*TTMI4;+;i3zOc+K!>AxcK%&;yqzQgrG06y6NIr=Y$Kcb3>=(3B^-!bf7 z2?R&(x_xqM0u+LmL7PdxKDTa@Eb#Pp(+JU3F$5oGEwkHcV!81X%I=ob@q+MLY{EAS zx4Rh?6%`ME(3N``&>nzSR)zVw&d5Asig5rV<=Ra#IHt{0Nnl75_ofEDYwGS_i6&0L zV-9u{bDnYAwk3jGSPNcit0tp9>0QgJWarGnyo-E7>;7_EwtzQ`%V<_t2@~BfAbxjSx`{p%{?Dd zQLA~fy=M#u3}uFyjNkWhRYvM(83_vjHqYT*g9{;-^C>ZdA^MXsne!a?0w4~zZq`sT oM~Hj5<7xuH>lzt7ze6rw6%k=ct=JuQuM4oa4l%1Sx%cG10Lq4W$p8QV diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriverClasses.png b/src/ersky9x/libraries/usb/device/massstorage/MSDDriverClasses.png deleted file mode 100644 index 3fd68d14a5d37e210b5391e0a38b710938d39ae9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12031 zcmb7qcQjmI+x8Gb3=t(mq9!_{CTf%@AtFd5dS{5}C3=lc)X__b61_7R#^_}XL6qo5 z7t!13zR9z`-?N_gUGMv?_5CsTb>^IX&OYVddtdi;-w|)rl*mXPk^lezGUb;F8UO&k zHUNM(ON@`(^Qnhc69;!3U+TI50OY2Be|SYQg&zR`W`MGS?0b*Q?YX(>{IVZKZw>!+ zEqJc@(YcLM-=Uyh<-ksE{P_qR`T3H1WIA?v63`ayyWm}kf4e4u5U;Ujx6b?2d_9vm zf?uDggS@@>vl6K5w>pTG+3~#5^_yTvM4LSS1@fkK{tp1~TofV;2r&MCnbgT^?F08S z1pG!q@aWy4sXu)$#m!eAZnQx%*!aAPZk>+& zZoGuoGe)-TvUnr%T*T$-oPXzW&#%-P76-<2agzv>L_|8bMD$?jLrBvcQ|yxR~d z0=A4hC9qF0WcZRM40LnQN{%I!9Fda#9Q-hWU{k~a1ddmEPfnHU#l%^Blj89s!2 z*#+H-wCVR2iX$8bS*gZ9Yv#fG^-`#m>1%}G+_lx{bS0}5pAGG3 zFHK{uvASr4I!rbG5qGm@!qkTaC;?;BTDN4rJ_Ye<=XQkS;G*9w@x*4~`ryp6u7X$9Z&e=iSVCDdnR#-KJLM zHwcph+hKTYXX4(%O6<0KZC8Bt-rB+0WO8+{%980tbT-7T`Ir~_QpKv4ZC}M!n1xj-GH*^*+|J%(N4{`ZK0ufV#6~NcXVb-{tR>qol!V_Kx@21 zuaafion3NlkR{IRd7uD7xb1j6yc?w~;$nw3w}$UTavK1be(XtNB06TCz}%e>bH}n& zy_NH&qp4W14s^WFrw`TLlaLCRoO+z_$mxL!D(0{-P~fi>BFmq*f=SnXiY~%43_B2+t3$?nXp6thu?^1hjpe+Ji^u#EShNjd`!Riyc z1tN5F(IgofC+6pGTy@Ey_~;X`@Yc_R4=NB@jO*MxHT&PJat3^FU8Dv zl!rQgS+lOjE-ggQ2&vN~Nha!@=5LCr=U41cY9X!?eB)=v+z8lfyJ9)eVTsWpAmrf- zL(~3tzJ7Co`<+;omDfbpZUL@eK; zCxN_~KSigttfQcbjw{A|nv_p!d@6qMx*Q~4)VK+zS%}6r_21aMZb-4oyem?zfpLXo zH$D|7G#Hw{Dn4VSAHQ96$@lUxeUtOawA4fU9)pUA>fuZ&4VYF{_oGkOIrf|0&0v~j z=Ny>xzT@SwMkXy<^|~$f$KGV!1=92trQH6JM=Qsw%=Kd?{Y&Jxs89})nQzk}jIE57 z>^06AP1Y&J>vl|K5CcrK!b^HSc`2ult|X0FxPepZ7h7_w1FN+#-4gN`UZHkW{#yGD zL7Fn!{8XdmN0elCyl>gb%36!?N7!sAkN8V^=R%BKCcgb>G=)^|+dKM+;MJr2wKx7X z;N@1-Mbn~@`{k(GJVoJyCxYyk5Aq{f2DkB3$3mG!pi@!84l^Z#wEI6~v^{K^6LfXRI~xczmj1kVwX~zVOu;Y^J|cLNsYKYT zxHV3_@p(32A(oQlvoH5-A*p2Ad)lbv%d4smMH^Ah8s<-IIYR+MzsIEG0wRK4$_`sq z@2Zm%ogPW$hLA`07b=i%O9{btk9EqJV3*b9TJp+tNV1hn`8lplvPTcZH<9%`T$Pfq zTM>s3a|N-k_GPa%dK$}Z=-=$VcqWyrx}sMVX6!aT=&HAZG_h(X-`6NbhqiID06D(Q zB-6Q`=w1WA*fftUea+oj+7{JYNtaBknAdEPtgPW#sH63!TnXWE@J|tSqu1TLb20m( z<+i|e#(QWcePzRMtsM%ouqNBt*j5?PDI}H;L{_+*a#{2%@_uAe z#aE_mkFv)_$drRLV4*#7Hmx7W@j6CU!s5ZdYMns_l?%6Sl}ISryE4wLbRjkYi&lE` z+wYpD$}VWuJN&h{;fy8nhR036OFO_z6kckA~lsbrLi@rCl8ZwhDOuK<4@{pV`fw9;OD zrJds1Xc#oK-WEWKtTD0Ud0x7hM$aHU#?aM)k<6vBNs=K_Tp{0xK1^*?Ybbn$tYLPP z?|l?9m{8F`l&gK9c(2Db#w8S6O_-h7=+oqhmXXNQGV`gMFUa`R)^z>`er4;ugLeo1 zXZv`7SIsa1x;n2TuPcUC3sCj8(lfL=OP3LK!1!)O3maeLoT>n&`K=HK80S}Zp0Ktt zONXd28q=a?aKi#Wkj_}vlIH9!${A>0CMl*;V9Ylrt-+WswI@x5e{fmp6rb%)?&l)nIjZ)kn zH%dk1N_j)W+_sfsR=Q3VdN~a!ZI#b(b4+*&a+gR89jJ6=Gh%~X+W)hYzVvL9&&Ks= zV&cjB(zh@n`Et1a>IZFjhbV2~^`_^#0j{*TcK&n;NwXNSp~D9dCxR5K$#gLKe~%noTbpEUS{)c7pb%G z{Xuc_+_xUh4;d0lm3Sq;8cIcCK+$h`7+R;J^po0n9`(8v->6Q8#9lg-O&4D8ex>w{ z!gXe|Uw#_+8@XuaKusk+fCI~ax(?uSGl3Aeuw8R=Zqj|uM`Pa| zuQ-Nh{BTF_&0SQv7tO$7h#%Yl(^UitLyFJAeZB&fSLZlNH>h-$5gc{U zvk5b_NA=U%+}|yR9$*{oqS86V@6|8O+0pZVv1=G~!gSM+>tBt_p>&bygweG(kS3=! zUvrDG4&UucX`|8d7cI}lrL<9RPZV8sV~Ha-$WT*=OHOgYe$D&F4s8A$A)STFS8yH??;IGFQdRE)lS_R3T)tX% zG{yO29DDn*3;a>49V-JU3;s80vzc{zwh=h<w4aHK4x|bSHg>+?^~+An)H!W9 zkAM3u|Mfu(IUK64h2*a>kv}Qb-#Qd<1&RN9)ySWE8_!ou`a#3$Rx?+PYQ)0Hl)>fQ zp9djp=~W>aA`K@4L#GcMCd1JjA6~XkljUK-#I$ny_tYi1{X3og&xq{DLe{i?>Ue?+ zR=~X*v>q3U_Vg9C-J%mZj6+X+ETJ9`Q?Zp*Jc{$4ZLe=>|^&^{uL9IFln&f%@Ri^#jVH=M=N;d z2^(A#9(G#%+5Le`2%hE9PY#|ZK-{g87;VS$m4w#KiW%zf4&Z`_I_-=z$k5M2iN)dQ zikE7?`U2Z{I=I}NnJjKD@(y!GA_`gM$(QB}g?}^)CWfUsM0cTbj)}?#u#;^E4V4OjZnslnyR1b`G z6+!btc5wzpdM=C8F+qiER2RE5MoSR~h5{LlB<~C9_+z;InW7&aDtfvm=WH!2b$<9e z8htWmBD&OG>Pw^82&2?RM*?Z}U#otvju1IE`_il$U0r@UFd%(@CU-@faZY`VT_+; z5}Fh(%nlp9(}I^8fpzfIg~NYB1wm^I&0H@hY#dHwDCDdP-%VJwU3 zWn01r?R|yg*8M0pa|M^f`Rj1O+)?v)KCyN&RJ!+CwxTEq0UnAV0>J5uf0>(8rdjUO z`O~1@y$3tMT%cm_WoH2(6Jw&(wm}OBu))bkI$GPlL}6I2zCZw=b%W_9NS`o(N`-L? zYeeO;JSX_YPU8Qbq_b@|B~u4 z+bZ_EKYtZS_a2~tMq|w4u|b*2p*T*X7}!R~^dC#S5a&7#I%H{!IKJ!VP5R*=FDOHt z{;1~CE5jaU)flacC)VB`6Cjui0N~sicTfM#(DED;b@l)_CcKx()Q695WI+TNlIZye z#II@{iZH#jnW4{gL}eDe=fLIumcDXZ=s=5J0nuHp^_4 z4gF_^j}dD5Z&Du$|fbVIP=^Y7@k;lG^};7fZ_x$x9@hx2-U+T%ftp^@sm zZ^HcEj<>=pD8hZ_U(#P^vL=wc<62R68@T1Uc=gFTPfFCcj=0y`Sumk47zK~Febm`? z8aos$aP6EkNH)#lwX;T{HWjc&Y?~->emg2Fh%ZOjRT4WCsF}gfEFIqfg009&d{#Z&6?t z2N*@cSaHaxg}iB@CD&v#BuN=veg*M7&XXFA|L&J(pdO;=Hmx7wPtZF(`94 zPh8lt9>gJ$LpJrI(1NdxPhS#t4ejaINuxM|gGlK%PO@U;*OkqPFBAt&HIEbhSyrJ99gHfCsb-t%)NZ4l*V&+fLX?&$<&ZcciAmyz<1h4t%;iYjMZB65K=~bV; zVG?IWRG)srk=d3Mw(}`kGYov1|Hx`Syl9R>l>5vtCsoeW)&TVE+U+Zaq#vR#&qn^G zTLNFf%?51}V!dJ2ThO?Ae?vTwA7^7>0@-L>S z&zaNd=DYQA)U3D)(NYHS?Y{-HUVV06yWbE$amN=o%ZGG=!zs2ZkAG z|DXS=?v=dr`HdDW@~vfly||3SdN64WHhhU_m*NEtLW$aN@2@Aj|1)m>i`TZ3To|`# z6Ku12yT!8JL>Jonht2iYaA&2XpbO=)UW8E8 zP?~$8`lE){-yNd-2Fg>Ln&rHmZ$5B0wF{kPCU&)`%8$cO_`P^y zY8TS8-7_QVFjlJ=s@AA+|HY8JJ>MUQtmb%Ja_toN0=BpEgH7aF*Rv}{K(I%1W&?K= zkVbXZ>)rhqgYxzeo)7JGzYcOfIyzGla7|sn;@=n{t8zSHDv@IDx!jQxJA_GEKLTM{ zb;Nb-39lpoCstO(qk7Hq2QK~_-2rXaK=;q&}`VW_lTR6@ zpoEvUiN?pj4?B@OUE~3-=|w}mMVKnNdpMrSkTn?ppy6k`JJNV@)YEUSn8G``TC8!o zFsl@@u8+R9@3E6jXdQY}>nP3~=7{lU`5PF`lzWYisDKEhnbm)0|0*t! zNTXS7FTJ=rz0Y1!EGX)$2$7wOKO=Ku7Mnklirg0UEm4{3Qe^;FYU}5_bv_&|TxJ6z zouGGD)UwBK`fE?+NgYu4pCro(u=Eki+r@Qp=&N$mr&TT_5_|LQki-JJGCCGvm=xoQ z@lf9&(lt+CdeXxlql%Wupht{L9EBWE&`=RPfA5oCa3LyB*-dpDF-y~hZR8I>>yt$+ zE`Hu~xV#Lo-C8;biG7fms9aKh`bv05>M3t_uT`ToN+aNR9HHQMt-?dqtcG_k+no|N zDa6`H{|_A@2Z;ADwrQpPjy6(aGkTxQ0V7(MKdw8>oEFiZ z78MfLNa^=iPYV=}R}Fd)>OanDkY=eNbKj=OFsmVc70_awpKNknRv1ExRDZhjL>6pG zWi%rEO1MuP=R3ZXuxK<3g&c+^4ty49Y?MVCF42*F^UcXFg}52v`UR8{JyAMUh*7Lm zioKOrmE;d4?O!KbC_=zJH3qV<$`if4D=o0<6G?zAfOxY4}W#X?YL`P>5j*LX}tj!$zo1{&8XAy3r zZ*k}jtHfGW+_Fonu)|0#A~E=6**t8bNiI@Fejad;B+ACWxirkCT{t@Zj){XOFS)rWCZ`|Mpuz?(9e+4 z1X}e;OC?cdfcHJwe9!s=pBtkzVf)40$OB+)k@+mJQWg)KN;q!cu(x2)@Vuh3jZ>W} zXf)na##kTT9DDFo2I>1Uk+01vFMVslAgEZ&Z#OT#eBuLT19i=KRpD5&Ht_W}y7EbP z!I#+e;YaX@57$evBD~nX)TulQ!I}YfjgJ~ShHvOmo4H}fP6DqfygyGXj*A#5qIjQp zseJ7=N`s4R)o;>`ZOxew^qwgxgI=#4*B-AKPIPQdID#PUndsZwm&?kar%(e8xZ$>f zzVKuUJ&TvZEeha=w-siuTyyP?vi9!99D=++*Xex93j-bXBbBq{}`B@@Rb0i#4)8roh{4M zs&3Fl2rU^y7Cab2YC>c`Rj<*$#n8bmpORJp31eFM&!ULzP*d{Nvt5mh-h6=7zQE^C z3?P6}oWzWsA}?h3&9KYf%=je9DDV)c85^H<7Hh^<5sm-Vk-he9`5f|Qk6>>D)eS%-jYwB^y$jwlb6X~8K* zc41pRTRPRctMl@BGVB;)Rud)5*lWMzU>>RGc@VE>r;!0p;CWNiA}H&G`OJS3Ah__ zWG?DEm=SLfR1fhM)&hau$8KUUr7^~)W_-|4Jx@UAw2j{;zrB7I1PqhaA1~8&%vixI zn|-BLeE>KwQMG(z!I$0i@SzlN&5LD0jS;@eNEifIelXsT(^%&383XIB{gWLkL+Kc( zR(5WoJ2ubJbnu!3G@k=}HeUqh=WT}S$1Zt(8dycnbNe$t=CU0s6tM(Ms1XmwKE&LK(cBvZo-ouzZ8ers8(B7 z50U4tw`ZpXab!yo6kJCxtav0D;qm+D#dv>p2?sB6IeF7dFNHfDlzEVL?cELMX4;S_ zI&Kt~n`DD)=_%iOQi!|V>tI2LMb*LCrStP^ zB<2IU0~3>@*gI?4@NAdY>13Ndp3vb#`(6Y6Ll_NZQ}3SvYVuN?RP8 z;=h>}N(oXPTyW1!q!pmW^e*YXsi!!(%7D6Y?{q(`RfP|Ff-*-ihF?S03|+vulv8T6 zmFQNxE<*6(=I9_l(O0y85iNH?rPE&@ZPDAgUD`OyZCi`F=Ha|5uwg~`0VmN_DFYnhUc}*uEk8wnWNaj_b zemKa)2$#}lsvzWlQ29oHB&GG4;`WeC?gCzlR5lPXzAasb; zHN-zU!udpOZY{FqtmU%>PHUkEscUHa&L|+1Mbt*_rNEE+EC6?(?B5r1^7J;d=R0PB zcfkj6{Q}ytM7@i@Yw@s$_In++M*=`CO-^lFKHN+MdcJ2jvofRyJMIB$y8zQa1+6!6 zuA1jO!74DeIOuy{b(WrL6)4I?RB)wp#8?og%As*X&N$3=d7Kl}9M@ z%s2hyXE}_xXfkI$m*athz{Kw{)dVJjIGxg2V@UiudG`jg4A6S!d#Jx5|U!YY0u9XHvwoVq;ilv4*{SgIz>RsJ?yz#_% z10mq>o|nM@oXDr(%_;||Wd<(Y$Kg91^5SqA*WC*o2I0^Uhb%aB#bM`T;1Upr<~U@* z;Vm3K!(kpSoBa-l@;J1?;WDo1DRx;5se3QtUiA<@`O7W3{jk;(-y0zyrH2^KU&H^u zbdo&8Gj@bJj~{9UZiXtYU(x66JTK*6JwKRXvyo<)XK;z7XvqMzoqP(@BDwwgL!ynW zCuuOXhr&{9M^~fpo$jTB1>(~4RXM>xgCqMifJniu(@9RESQ$ka_`aphL2-DomcPFld8=Uz&VF$h3eNEzq@3ae|rap%XaueYMU zcJsdSz)i2A1^H~y_2Zs?6Xk|mscish0a=hF+b;;2reQ+JTA8D2jPcL}H5CsjW*Ts7 zZ+Js@Z@d1vo2emmF8{fjXi(0yXCCQ3Vk#vm9Q(J->3VTaa3j#< zIW7nCzm!awMQt!`s%QDt&&s-e&KAr?Sq@!+D$d2i&TX1fl1OX5^mfs{{q%GeW|Gp| z_amqZ?bO%4@Z#WbN2x27&s{5XbL^FLTS7`3Ri{NevQK&5$MOEpKLo(%5ueYkAz>P` zDqP-Rmv>_w%2z2ZI@X@9zRo^N_jCVe2Iw0Gm<5aFc-U}mKB zWHgycb+ZH+&4}yy4URc4Kawu#EQH^FDT3#A*1-jT(RDn-qbt75u+ zQxrMcOn^P|fNb=OncE%rI`X*Htb@4o>q@9~V8j46%fUbxqa~6(;$3-g;%tb-d&q^r zRM)S-%AU69{s`qpq1la8Rl0FEs5}6wzFc63ZusP^(7CFl9Fjs6{R;ZqT3esr*vRn{ zyb)!0!s-m|Kq-0qSw-nh7O`f{-8IQ8;gx_yIiz!vjyX7f{}QA4(O)odwH6~b2A*{C zJ$Jr79!W`Id~3p~9Lp&V*a!g=AGN2xHo;Y;{G*CS#S~vJW;lg@66xJYoZ0RMv~ z7j@qQ?QN?PuK+2mqm$5xk(JO3ULW|Yyd0&v;OWk^3qE-4lG3il1J?>deDH^PlQ#V8 zn|iyOE3EPE`0y2W!5_D|aC41qy}8=;?{&)b&$jVq6uG&A?Rs<{=LkzU%7clHD8C(jg*?vb<5!KSEI{aw_buaj_y3Wd#$arA^I$L)U$ zRn^eB;uL-U9;8*8&e!JrFLJQ~7Hj_fkgEn`PynpT^!!B+WCkKtjH+Uyz+zwF_~0hmIqs>`N&x8nqw|R+mQ|5RI1_fxPmr>4=>%3ZP)1gMl65Yf%;k zX8k=*_lYZ!q-XN6yvONJ0pE8Vdo0PXziR3>#?Fqp`Em=erL@8spQ>M`aP3 zhrJAzT|`(f8pwaFW625dD#)y3S>=f^lH=j0(lGtwK%irH#v+lXqSX`r9qQwM3omLl zI*U+#CSL@kS$KJ%w|xu76A=UD$@1`Tp)gVO6h7|P5sHb?A~pd#9Dy5!9}4wG6S2yP z2`fK>;Z1Ne|E?fl#PN3!<4m?No|B79-lF%1?{W8yCs7&ALp=VwWBqEjxTt^o+~v@S zk6LG7!(3sU&H)~Kg7r5RsOT@sfm{(Ct=>N@MMF{i4LqVQVrIlH&Cn3pfe_rc&%=fzH$59D0VdWJwahFFfHv`8 zxKt5_{;$F1X#toNtYB`qI1>vulVx1?ZTJTcd&!C*ydXTkGJjs3X9S6l^6Vdw?N_vf z>3!wosYdsHDbmx&zi(xB1tym4N+PMMdQtQ3eC=Y-_^iqFn4!!1%-}0L#0)Q`SyMF< zmL`N$^r0Cx*ALj91Ii`6ik{A z)eI;oD06|w!g(s-l>ypc#=sN3>%(X66co%BXAjCx%0;gzD6Z#es;L1mwJg#;lf*6@W!(jg6n)^UaBIf}VF z-)!dE8+ZzPbu{H*bTst`c6PdZQj(xxTWc^ye;0%z{T-Y_n)kmtAR~?LT9$Ac-O!x* z^?pTefotqY-6V|{;rV_St--${)NwUVNEef2ev|I`GER0ni^gE#h?;mdFYtV1lJ%4_ zvHnT%g?K5<_TjN?FRrG^tO85)Ec=A5z${7Wj2s>Zw#8Wrx2D%xnDv+s!s zj#jdv%_(PvH%RWDLqx zx8TL3U*Y(cX4>zY4?7xpm+v>HIBZl_y2mt{RoFahZmI6Q^1>i?BEi3rZ^2BABLA$w z=zWM{sWoIwfq%()t=Yrtcs{UQe$z8PbQ^Au>D$Oq7PrN8rk!gDe3rcITi>=Dx`cnt zRrqRw$iujV=b2gfBCG=nBmQ-99isSYv;HM+Zj08a>F+1Cj~8Vp)^JT>xMDAGe(7Zi z<~tn1E1z_O+HY5{Nm8;kA7?~oESEE=y}Y{h8kf8pn7x`jj12vb5^A>e%P-Df9{o@< z-PiOW*Y!wxYQ~mdwKVeY3$F|CXgRl#*Ea3-dsy7@W`Y!O>4Lvsc*F8YFwJtOAL8@qJ%EtUAUjO^VMhTW4Az!up zX%&qCefmCN=I({=5tMyaNYE{1Hx-*@q^nZ{{{Gk?zaWGK~}hRfGEcvq6jnZ_FI zK;&DLFQ&~_N9SgPUTAYYp(g`hY9w&?iC;0E2S2FZp6ZzW}uFHh^~yt)>9ts{5#;fpY@y7~P0ta}VS6nhD^W_hUnrJ6nTkqQXpX#Ez@D zDuLdtw_Hasj^=aGN#uztfCk816oTJ5|G=c5xCPX83f+sR%pwu+>HQ{GfI}`1ND*; zi!rJ`dpx7{{P?x>?tLwP#+io3?PVm+&MSSA=Xp+B-1cB#Z!a_e-*nBLB66G*QG4e! z(%Hno9K8nlte4xqE|o)E3zXU=F|gBhWN}=OX=;Sc?jKh;CN+MUZJ_maDGoYk4ZaA^ zO(X=)JIXrgu6wt_^sK?IA>yj*Tex1FGqy)uM4-MoQAxxKba7?U;+c~DwPp@ycCOf+ z$a>jk_A))gd5x}U|FE{>>&YypEDZ&s3R&LVVQo@B;_P%wYYh$>X#_D?P|JcfrzGnhFih)3ELr`nc$U zmSLhEc%B@p{E^CUk+OzauJrVMRm1gB+I(bihJAmGS}Urg>>f(roirjXAw>SDOEq9# zU_{A}FR`GGyp^P8dM;DN(V2!yQmhAY$LDwa=4SVNT1?aWqnU(BNLAEP5kzF^%h8Kf z>SbQ@zV8fLu@h<&jEx zLjH3Hg@MYP!587OW?CRZ8y&fjL&E~GAu3=(I!~>)+8VrZ zbDI&m+fc8s>wzc?%Q{-$ih;OGt<*SqaX=a}T@I37!@>(Q_4zeW!Ehtt&zj$yXF7Fb z(0{gMiI16D@S#VL72DVeojF66)#Der=2GeG^UoCS{qlx|h6-A6BNOSq7K ziubzh(T-!5M%u+0>;&135tAtbc#?cdP#w6!eNq$G@3)~nRpaEH)JIWjX(>4Xx-`i> zt)lAvXgiCUjm(klY<^1I}8bdD8ALXME!SFhiB^W6O# z-a5D9KxDY(B0CZp54UgE2~weydj}r|rk~SzyY7=#75+)MPfrTAlPlI3#rDo5)l#Y& z7VD*=H5}nzxB1@FG$=5zeEJDtI>yDhs#XryP`msx+fu3?My1QTL7=)L4}4sI{_cME zrmPVx+`FpjSfa|6f&42#z0jNW>bdZx)#Vw{U!=MS{^(@d?E3_Yw|5UT~&C+-t@2BAetqwi0Sr>+Vr zrZ758C&0b>e-#AR&NcN;qpT16bYYxoMA+{LPzsE(7-RH1qIth@*1V7Mwq=XJOxuxg zJzVoI_A2}rrL_BbI3MD)?4+FMp4YpQQ&HS(Xf*YLE>l?gMd&Wq%;`aW^J%j0BWUQM zywRzEk_){gC>%AI=GM|`YN{v!kp!W>r{sF=ubXA7Yls#uVM>ZtgS?JeuDJ(4#DaQ{ zAXc_hgNf|4yOHuT13vQ|ImU+bCVj<8LOy})k2AyLsGh8~8G&uoG;!4*)@GyU3HYk`^8l%J=W zJAib#`aBS$?T~4W@9(d6!Wm?U_FASupCAnqbWcAM(`Ofs1G$~4r|h$r$Y&~5>*Rmj z^ZL~7=;$bw3^dJ$U(7n_T;5yLufLhz{?4cXGM&~s>DVzEIyWNP@A0rgV)`k_ybQuk zM|oXKj!m=ZD&XrHe6w{hJ3~$5Gr}5`lKd+jyKs9njY;*i6AsOEnffMRya>Tk;dN(n z^+EGYuI$yp?kL6lor$gXgr=gW*?uzhQCGa3iN~a>zk11A@nMv9qP=-*pRTiPQ*=(O zP;jTSZMuC8CAsB9EX~xhE3x&kE>F)veOh(CEvideqGbwvYQ`>S(PXOhF};aqx%E2p z5q*C-)d0_;`aQJHi1dVA1`-4H#`;ubBgFh1@KwO9tsq?ya-Be7DH?JdO^w}o$;~8U zeK}DcQ{_9>XnnKYR2Eu!Qi;>(t@W4SM-iLcKtZ@-rm3EWT?t%9Q)-gV$pTc13bcy@fkCTM0%WttS4Y7&mUbi`Fcfb%oPuPjeTIs~TvJbaQ&@B;`CKCF5r@Y!TkNkQtyR%2!|VWzJeX4P1m#)W_hAADj!#XBuiQxvRG%+K}NZ z+z#^}NvrbrF#Z8p8+b*W>Nyg*!TO{Z^YT_wUq`Z6%(I%0X<%ubNU!D37Rw&T!~For zsLgzujQwXtyg}StQZwEx$--$-GVdp>u$ z`1j9RmnE>!N#T|9!mZnhFz3xW_wJ8Bmxdl+jcgXOcFk#&`B)_MmB=hdA%Zq~tlCZC zxQ|+G3Mr9Z_+>eBX(w;VP9YxdCP6yyH?)p0rOEXBhY1XaEnuNC+{@fK8p(|}%TY`B>OZWofMz1)GiyYjI1()$7ygpo(*j#-f!ovi#_&EG*oRNs+{_K_*C?6sfenGK$eYhwX5Udc32KzM zIL3O1*>!vNk~RG)j1Rx@Q5?TqdjB#h_+$|`u30$u3NS;%6TAW~O-|R-o$`wG_Yitz zWQMpV zsP+U}MVC_j#wh+Wp|u9{)de`w-LmVb@_bMN2uf0=Gu!q1Xq9W}ZV*89&O#~QwU16^ z!c>$1_uM%pl)o~S@rWVf2gT)DYMdT9)rdryF1m7PX$Buvl{*GTkq;55ew#Q}Q0}5H zKs+R}KduH_(YGhwiNVDAig%8k*E$)r2FqIx_p9SVFE@U{FAtaf($ju<)%4Evur_js zVh`!2Cacs zp8N!MrInE5kpwYG(?dd1IhojzlN_{X(?1jlmHMfH!H>Q%H~FsJcRA;Yd!XO6JUztm z8SBZ1ycNLQ>6$$cVjW3m?jJ3y{lh^j>S)h5sni{p;^7vR@iGe@p;%VOWlTFFn>jXmK-QgRuL` zabM;*Yi}!KxVijFN1}&bAPT;^zUbIe4ycnCr;F7gzP@~$R1nSI;L|c&D_#8o$pP z%I^IWur9{8%)~l-31Lgq&T4)0VwPy|8g`uP-j_V9OOI!8?O_?-ZA$e~n{Tn9EI~y* zP?6J7Qc?QW5bcOElbjc(IL&xHd5@oLIs-+)o^^MHK=>(d-oofIRlsnn*LhlL$klzEpO3nqIOtD$ol z%}%8`VvF*=Bu=ThM?>d?XSm#E9ud}232+1N*4$s6qfechZ-L|A+$oRLY7{nJ(}LR# zc0rz9Gk(CoVS2L<{-*q!OXpofNxypvpt#F}#-U1k7q}2ciZRVXC6Y~s*@(Z&<`Z*|H66ybnG@B7mlrj{{%!LR=VLZs&WShV&~nz)`MVMc~y+fP>baqeIDV z9}|SHI$595fV7t=-hkdF-EF?qdg==;BAfc)D?lt{G>(3;&9W)O46|UJ`2@&x>5GPG z41kF3L0>KnJJN1?*wnO=Ia$`iE=+KW03(b%9*YD@*rp->mW@L1>%1|K8hReimhR?d zZb5%toXhl-i345_7iV)=_61#*)D>IgQW1A<3I8SbKdL81Gm8JACqA}JG)-H zT}k=xr|;ns825RtR$yeJn@MJQ{o8$2Pu^+#iSk4EEMTB6UOdlLE~7JWx}XEiy#LQT ziiJ^H8dv#aG4`%Msr$LSbfIdUhX2`yI|DYn!U<>g3}`SfD-ag`{-~}SvhzbdBf}9% zid^LCECXbpPh!P3f87mgHV)qrQb(&q1BSbP`e~t#JmAHF(!q_SWieIsC}huUP5;_L z?$!`=5^lc|vG^jKHtWeZ{9v_4hRcnS52ZB<9&e&msrATuu;p4%c(ag0>4>sU?raG? zpz%eT+oEbMo?tzjDe(4SGe}t9y=9i=xzh(dyDdP7?%!xV!4Zn)lYz1lAyV@kV=?!(oJ+-$nEt$i1HiFf8M z==K#Gd-i?5J8~u4lL7O=MmGBmED-6U>6AI~pqsAybB+~A89T4r&P)*dRZFM7{rd<$ zkLx!c`24NHFQbkqP{ibeLf94+Gv)0H9;qRFi$h13gpSl^17;2u%{bvdD@Ass_=KQe za3%_tr36tm92Y;`%Wl~;FP*13+Bb%r8h80IV94P|d7K!rfD0Scs^*k*EVRVf$JQtGIqmg1&DwO@t#Zz=sdZen+SJP(Cb9DO<2IIxEfJ%2zX z9hXe+B5~9qb9E+8(VH)_qBJ;@Z6sc(v#r@Wzw$zO*!(uQLHpE3aR0gl=^=HYXWzk1FjzK7e_~-R!x43)HXOA|>vVQLh5lP2%M%0`-n7*5tD9ju}$;L-` zfwSFexY$k!ZgBxgiU9PmM8 zv(R<;-sC&|)zypS;rJs-Z0sj*%-#Lgb9NP!dp_QH4VU#w6)&gA{?R~sh{^`Abwin( zVsmnGTsAnFNUodC>kKZ=I@3IGhn4_dnj84RVM3vaPlkg~oxzYg8bDChM=4TbN%|EX zRj<2H7J_Ns*0HaQ{z^Z5(52XZLq01r%d$$PdQgIL9ddZ>u6OS9>ZNg(OOF?}1nb(L zq{@l9+8)%wuDM>+&{Qbr4xp^RU&_Q!^9|p&B#r$nd zY@5fz4hb%zQHx%g{%=GSpRs1E^uAU+S9AoL{m)sgdjn!tT)MiE_PK+6oxdG@VSY(c zuvaF*w&t!1Yj#0KmXtlQeqbBy{2GhIHIzLd^L?21EIBen80aP?iqDF!x*@K+l?mD* z^`}dH``u81TH3q;3^9-hph_rich^~U6dKVjh7*wYk8_AE7oRAujX9(tZp|)*x&gs! zOEPTNci?CjVXBvZNx-oCl2~;`x}B2m{PuC9Mo-H7mQ&BVZ11FzI>);|9nM3huh>q7 zqN6yabp~Eg`h>SdD-e728-!WJQ}6^gfn%6ntqzm}zPkGx5nlPy%D=E1vAg*`t@h)K z=Ov%|#PS3VC3iIi#et9-){^tYPXVALP2(-)`qbzU&~XQtvZxhh1)?wq){`ZPEbh_^ zXqA^&nNmkWb>z!#SwPo30hZKF>-AWbTh`u=`NLIb3ElCC1h8VWx_VHyqgS0*!9bb4 zQ9G>61zv~jEbP&8^~>#|Xs>OJD@cnWvz#uwy)M;2tK1=ZebfHsdu#$)0k)xo_|5Cq s7sAghH~vp+{{Jk6tzxw)(vP_>>FWImR*DS(R@fAp4|LVa@0-8*KZD4IhyVZp diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDMediaArch.png b/src/ersky9x/libraries/usb/device/massstorage/MSDMediaArch.png deleted file mode 100644 index b641e97c31dea66e6cc4cd4b871797bafd88e423..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3622 zcmb_fc{E$w9u96N9keyIhUzV@8cK~7BviGu2sO20x_Rb#2&ysO)=ViXxg~~DjiHp7 zDek3Ovl3H8q=pERn5BsD;;nn%d+V+D$9-$Pv(|Thd+oi?KKtzTec$>{f+( z>jgf;WC-yx4F;#=VQC-6b>97ex*Aj|sjjo3I&pDI*H3r?5~l43H_AXCqGt@3zh8ZP zeQqcoKCsBITBm~g{{2b)1UbOERVf%cn$^F!bZWr8$h`>D+Z*uOt~N7##RkunlWP^I z=dwNYHKE6dY!OU}+~0ZVWb|uri#;xe$>Wbev_6Nr3(=QKvB?V-4V!z+srt&o&=g+; z)UL!zi0V!~n^Vz;BG8f3Qd7Gq6sj;b*4h3aS8F(P0o_bm#UuL*Fx-hX!-2eJ13=j% zxcm)67w{-<;K^ru_*g3+&RjLy#vMT~`Cw#$bSTI~5O=|k&8>276=9y$)eZ-eaK&=| zkf$vxVJFn;V{=RKq%`@^EMkcXkgWW^H)l1$_iOt&3{mQ3DQo;4WZavcXTlM6E`U2q zgN>$C^zwnRuZckJcs^!tEVlshGWVV{417#S6!_ObES$Gs%nI;qEb36ftzs=B6k$5> zvX6}IC6IfEq+@DCi#^N3k$@IWcaYLdb~9KytU$cSE51r+2`$BMxLV=TAtDk!B>w_y zj_S9WE+!_&^0KQ7x1Dzzru$eCPX_317Zcii^i*2?-VhlmRHdw+5pB5Mm$a{;rsW_Q zNuq9RfV`Ru?Qrcrj}yEv&4hT(Rg0tf&$XV^K3F=9e6_rEVL07|C%w{{kiv_B{_7>Y z?bzbB)n@w-2d1YF?V4lAyXh6L!@WuQBf&3KgVFJWZ?ozS8yjuO=&W$Y!OnVzn8!?; zR4OcayW1x&M?90;OdWEie<4fkVc7QWE6s2Fx_iNs3f9?jLjp91HvgYYrEuCjqj^hN zf;0mzAXzk=PryhZ_XdBO6{UCVqnG$HWh78T&o}Dz8!fq%j7{%~r|XZBI^Z6Z3%o5H z)0Lam)o<~6E)KF|=bn%6x{s!2oCq}SPgNh`*=I`gu0-8Ph!9t<@*STNbJMfQ7EK2w zo*poHaaPqfSN<}gq>A3R@=a~r{ve`9ujmSsWcj6g@Jb@spKopaB>Is z)u6O-5Jp*F3qb`QgF_*;l5&QuO>;^yVO(FmG-^)k0ffU%@UK!qAF?~hT<-)KKi=uK zM3nlD#=RtVY^lhc-joI`cl`k{dF1)WZEs?!ve1?Velo+{{ts3L**+Wd_Bji(tZoyx zW2iKn`$Mc_gRGy8S({t6aN^8w6QJ&OL_^YJYk9mVgY-LXr`=XkGt~=G>gXzK>>OOi(CiJ4pBx z9lM_Lt7S{w=!vfa_<(Jdn+I1!|DmTNP5r;n6a>t)_r+w&t}T|?6PCH$AQob20o@FL zlg2Uf2$LDw5QIOyT2qYhF5}4u!a4(cBne+YBXcq|`TRorvPI%*|)?S%D6=fR@+q7uV?h%uJ|-{ShG z=@9iH{_K;CU*zNeck28}q5odPx*}>13g4W3)+PO;$zh_;;I!mE36v^-ur$Eh_CNh# zi@~^OQL@{R(sAS~{-d#pv@#m~vzOnFYPo0Vq@a%!b!n;O+e{VAlS!RJX1dk!ssG|z z#dAI2f#H^x7X5y$laeI^-|X#48F9T7i+z)PwjI6K5FtjQ7W~#WS6P3hRg|G7L4)i} zON5nO4D$1Oy4T?N#0Z}??E(#knx^2)9LLIVYbz&}sIK(6U5mvSvQ>P`O6B0TzRyQiuob4WN z>zAe;`ZZy1ZR|snAGq`B)^Ry4S2XtNr%C3XT>OF@E*0xx(CIBZw6OQhsSi`LgIZs7 z2<@+5iT=QFtOsQ)8JV0P&U;s#OcN-G!T&DTIH&6#KGl}-zEY1@^>Q{4@*#FpG0$Uk z62&4*Sr@>KW~{TZ@E3)y@?~|}R$>rH$&6Oh%QXrAkkSx_7Q%z}14A#eL&_C#QA23v zlLuZOJrP5Wn|d6MC78r1f-2p9G>Kkr-&~yM1F!7|^4&fTj5+?6_ujdII9&*bso(-1 zWr(9#90T}EV0K9#0)<*9&g%rt#4$zKMA`e37+^9VrWjx$n1c>*+>|ch*5SvmCBS=> zl8ZV0l#+7%l*rhl?%#Gl>-NNuQm-6-3#cN5xobqtMVl9RU3j)gP&rd?vrA08)nV}S^-{s z04#U*v`#A8%f2zrjyW!d9sZH5Jwk$GhnYj$0b`r$OKLl$ALSevlY7?S`XU-xUUZoq zbjmW}10LIodFi6Jurz1Pj-iTv`|T7@Jk+>m0@XXdOd(0CDEdUdH+LR<9v~q?$w!ut zS|zdEB3oD4i&dogcTAjV{AP11CHju&5VjWT?*F(fDLmOUa;l3P^F`BN0$uoX@0dqL zXR8(K5Tp?`md3WfBh&^ih&d*rSKU_n?&3<(1s*k>9cz7I|C?_&b!f+l*loQVbG_<) ziI>aZ!{FQ_`v6i^c}{g(fB3n^Zx1i{$Pfo^Y7GW|>{0BdyhI7dQWOrx{KxsKlDzxu z8=WrYnq2z)=}z?AnLi$cS0S%CI8)nF7-$atqG{ZopZQYoyIY|ysn;x9!*}`w1h-gB zQXJ(KXqa{f?f0nC_jDS15 z7SN)aQZ?lqbqeSqWihhaoJQN)b?d_*%Yb=M&rwg>kU}b+9=FLk5GdzLo+Q;uM#g+g zKfZfe<%Z2QO@gQ<>Cu|M>^{pvV{mXfW#tM>+Pq0(vOVxMmZ`~jVupW`!^>1{&hF&j zbwtZVYS+H?jAaHHzdrKSvOT(WF2Elk;AY%QZcq~MtQx*dHv`Ut_ z*ICw{R3ts>cf;<(r&m|)bW>p@bgce9#z(Cq;d}m zT2nS61qEJ&n3L~xRrCumhm_dzPC;`@$nDoPe)%~413RD*+3E{!Ca!!BEkFGlmWp-N zP`?Oy>5bPu+*kN`G72SsU+`d$8fgVW*xaatveM=6%BD~S*_sRFE>lidoH?n0q#h_I zR{WkS4gQJxw{-_$e+iNK2DVxcf0-|~LRC76`O#ZwHfL!{nnkp(cdO?sBqLz>;9 zI_j6fTSo)r8f5u30?8}?3y=(6jY^x$(9Zy6`n6veOsljmXD{`2RN=J{Z7V pYHM^V^yE*kF3^0T6^C5w53io@(AoQq{o@C?e;1-xq5Jc*zXNYq7XknP diff --git a/src/ersky9x/libraries/usb/device/massstorage/massstorage.dir b/src/ersky9x/libraries/usb/device/massstorage/massstorage.dir deleted file mode 100644 index bc793c542..000000000 --- a/src/ersky9x/libraries/usb/device/massstorage/massstorage.dir +++ /dev/null @@ -1,1005 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// -/// !!!Purpose -/// -/// This directory provides definitions, structs and functions for a USB Mass -/// Storage %device (MSD) - USB Mass Storage demo. -/// -/// !!!Contents -/// -/// There are four things for the implement of the USB MSD driver: -/// - Implement the MSD driver structs and functions for the %device, -/// to initialize, to handle MSD-specific requests and dispach -/// standard requests in USBD callbacks, to read/write through assigned USB -/// %endpoints, -/// - Create the MSD device's descriptors that should be passed to -/// the USBDDriver instance on initialization, so that the host can -/// recognize the %device as a USB Mass Storage %device. -/// - Implement state machine for MSD command/data/status handling. -/// - Implement storage media interface for MSD disk accessing. -/// -/// For more information about what a particular group contains, please refer to -/// "USB MSD Driver". -//------------------------------------------------------------------------------ - -/** - \page "USB MSD Driver" - This page describes how to use the USB framework to produce a USB MSD driver, - which appears as a USB Disk on host. - - !!!References - - "AT91 USB device framework" - - "USB Device Enumeration" - - - Universal Serial Bus Revision 2.0 specification - (.zip file format, size 9.80 MB) - - - Mass Storage Overview 1.2 - - - Mass Storage Bulk Only 1.0 - - SCSI Standards - - SCSI Block Commands - 3 (SBC-3) - - SCSI Primary Commands - 4 (SPC-4) - - !!!Mass Storage Class Basic - This section gives generic details on the MSD class. - - See "USB MSD Basic". - - !!!Mass Storage SCSI Disk - - This section describes how to implement a USB disk by using the MSD class with - the SCSI transparent command set and the AT91 USB Framework. For more - information about the framework, please refer to the "AT91 USB device - framework" application note; details about the USB and the Mass Storage class - can be found in the USB specification 2.0 and the MSC Bulk-Only Transport - specification 1.0 documents, respectively. - - The software example provided with this document uses the ram disk of the chip - as its storage medium, but has been designed in a modular way to allow easy - modification for any medium, e.g. internal flash, DataFlash, SD card, external - Flash chip. - - !!Architecture - The MSD driver is based on framework, See "USB Device Framework Architecture". - - The internal architecture of the Application layer is extended for the - following factors: - - The Command/Data/Status flow described in "USB MSD Basic" requires the use - of a #state machine# for non-blocking operation. - - The example software has been designed to be easily extended with support - for other media. - - The example software has been designed to support multiple LUNs on one or - more media. - - \image MSDAppArch.png "Application Layer Architecture" - - !!Descriptors - There are no class-specific descriptors for a device using the MSD class with - the Bulk-only transport protocol. This section thus only details the values - which must be set in the standard descriptors. - - !Device Descriptor -\code -static const USBDeviceDescriptor deviceDescriptor = { - - sizeof(USBDeviceDescriptor), // bLength: Size of descriptor (18 bytes) - USBGenericDescriptor_DEVICE, // bDescriptorType: Device descriptor - USBDeviceDescriptor_USB2_00, // bcdUSB: USB 2.00 - MSDeviceDescriptor_CLASS, // bDeviceClass: 0 - MSDeviceDescriptor_SUBCLASS, // bDeviceSubClass: 0 - MSDeviceDescriptor_PROTOCOL, // bDeviceProtocol: 0 - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), // bMaxPacketSize0: Max Size EP0 - MSDDriverDescriptors_VENDORID, // idVendor: Vendor ID ATMEL (0x03eb) - MSDDriverDescriptors_PRODUCTID,// idProduct: Product ID (0x6202) - MSDDriverDescriptors_RELEASE, // bcdDevice: 0x0001, Version 0.01 - 1, // iManufacturer: Manufacturer string (manufacturerDescriptor) index. - 2, // iProduct: Product string (productDescriptor) index. - 3, // iSerialNumber: Serial number string (serialNumberDescriptor) index. - 1 // bNumConfigurations: Device has one possible configuration. -}; -\endcode - Note that the Vendor ID is a special value attributed by the USB-IF - organization. The product ID can be chosen freely by the vendor. - - !Configuration Descriptor - The descriptors are defined as: -\code -const MSDConfigurationDescriptors configurationDescriptorsFS; -\endcode - - Configuration descriptor -\code -// Standard configuration descriptor. -{ - sizeof(USBConfigurationDescriptor), // bLength: 9 bytes - USBGenericDescriptor_CONFIGURATION, // bDescriptorType: Configuration - sizeof(MSDConfigurationDescriptors),// wTotalLength: Length of all - 1, // bNumInterface: Configuration has one interface. - 1, // bConfigurationValue: This is configuration #1. - 0, // iConfiguration: No string descriptor for configuration. - BOARD_USB_BMATTRIBUTES, // bmAttributes: Power and remote wakeup - USBConfigurationDescriptor_POWER(100) // 100mA max power -}, -\endcode - - !Interface Descriptor - The interface descriptor must indicate several features: - - #Mass Storage Device# class code (08h) in the }bInterfaceClass} field - - #Data Transport Protocol# code in the }bInterfaceSubclass} field - - #Bulk-Only Transport# protocol code (50h) in the }bInterfaceProtocol} field - This example uses the SCSI transparent command set (code 06h). This is the - most appropriate setting for a Flash %device, given that the RBC command set - is not supported by Microsoft Windows. -\code -// Mass Storage interface descriptor. -{ - sizeof(USBInterfaceDescriptor), // bLength: Size of descriptor(9 bytes) - USBGenericDescriptor_INTERFACE, // bDescriptorType: Interface descriptor - 0, // bInterfaceNumber: This is interface #0. - 0, // bAlternateSetting: This is alternate setting #0. - 2, // bNumEndpoints: Interface uses two endpoints. - MSInterfaceDescriptor_CLASS, // bInterfaceClass: Mass Storage Device Class - MSInterfaceDescriptor_SCSI, // bInterfaceSubClass: SCSI transparent command - MSInterfaceDescriptor_BULKONLY,// bInterfaceProtocol: Bulk-Only transport - 0 // iInterface: No string descriptor for interface. -}, -\endcode - - !Endpoint Descriptors - No special requirements on these apart from being Bulk-IN and Bulk-OUT. -\code -// Bulk-OUT endpoint descriptor -{ - sizeof(USBEndpointDescriptor), // bLength: 7 bytes - USBGenericDescriptor_ENDPOINT, // bDescriptorType: Endpoint descriptor - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_OUT, - MSDDriverDescriptors_BULKOUT), // bEndpointAddress: OUT 0x01 - USBEndpointDescriptor_BULK, // bmAttributes: Bulk endpoint - MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(MSDDriverDescriptors_BULKOUT), - USBEndpointDescriptor_MAXBULKSIZE_FS), // wMaxPacketSize: 64 bytes - 0 // bInterval: Must be 0 for full-speed Bulk endpoints. -}, -// Bulk-IN endpoint descriptor -{ - sizeof(USBEndpointDescriptor), // bLength: 7 bytes - USBGenericDescriptor_ENDPOINT, // bDescriptorType: Endpoint descriptor - USBEndpointDescriptor_ADDRESS( - USBEndpointDescriptor_IN, - MSDDriverDescriptors_BULKIN), // bEndpointAddress: IN 0x82 - USBEndpointDescriptor_BULK, // bmAttributes: Bulk endpoint - MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(MSDDriverDescriptors_BULKIN), - USBEndpointDescriptor_MAXBULKSIZE_FS), // wMaxPacketSize: 64 - 0 // bInterval: Must be 0 for full-speed Bulk endpoints. -} -\endcode - - !String descriptors - Several descriptors can be commented with a String descriptor. The latter are - completely optional and do not influence the detection of the device by the - operating system. Whether or not to include them is entirely up to the - programmer. - - There is one exception to this rule when using the MSD class. According to the - specification, there must be a Serial Number string. It must contains at least - 12 characters, and these characters must only be either letters (a-z, A-Z) or - numbers (0-9). This cause no problem for the driver in practice, but this is a - strict requirement for certification. Also remember that string descriptors - use the Unicode format. - - See manufacturerDescriptor, productDescriptor, serialNumberDescriptor. - - !!Class-specific Requests - There are two Mass Storage-specific requests: - - GetMaxLUN - - Bulk-Only Mass Storage Reset - - Standard requests can be forwarded to the USBDDriver_RequestHandler, with one - exception: #CLEAR_FEATURE#. This is necessary for Reset Recovery sequence. - - !ClearFeature - As previously stated, the CLEAR_FEATURE request must be handled in a - particular way, depending on whether or not the device is waiting for a Reset - Recovery sequence. If it is, then CLEAR_FEATURE requests to unhalt a Bulk - endpoint must be discarded. - - In the example software, this behavior is indicated by a boolean field in the - driver structure, named waitResetRecovery. The handler only has to check this - field value to decide whether to forward the request to the standard handler - or to discard it. -\code -// Handle requests -switch (USBGenericRequest_GetRequest(request)) { -//--------------------- -case USBGenericRequest_CLEARFEATURE: -//--------------------- - - switch (USBFeatureRequest_GetFeatureSelector(request)) { - - //--------------------- - case USBFeatureRequest_ENDPOINTHALT: - //--------------------- - - // Do not clear the endpoint halt status if the device is waiting - // for a reset recovery sequence - if (!msdDriver.waitResetRecovery) { - - // Forward the request to the standard handler - USBDDriver_RequestHandler(&usbdDriver, request); - } - - USBD_Write(0, 0, 0, 0, 0); - break; - - //------ - default: - //------ - // Forward the request to the standard handler - USBDDriver_RequestHandler(&usbdDriver, request); - } - break; -} -\endcode - - !GetMaxLUN - Usually, the first request issued by the host right after the enumeration - phase will be a GET_MAX_LUN request. It enables it to discover how many - different logical units the device has; each of these LUNs can then be queried - in turn by the host when needed. - - After the request is received by the device, it should return one byte of data - indicating the maximum Logical Unit Number (LUN). It is equal to the number of - LUNs used by the device minus one. For example, a device with three LUNs shall - return a GET_MAX_LUN value of two. - - Sending this byte is done by calling the USBD_Write method on Control endpoint - 0. Note that the data must be held in a permanent buffer (since the transfer - is asynchronous); in the software provided with this application note, a - dedicated field is used in the driver structure (MSDDriver) to store this - value. - - In addition due to the }Mass Storage Bulk-Only Transport} specification the - }wValue} should be 0, }wLength} should be 1, }wIndex} should be the interface - number also 0. A request which does not comply to these requirements must be - STALLed. -\code -//------------------- -case MSD_GET_MAX_LUN: -//------------------- - // Check request parameters - if ((request->wValue == 0) - && (request->wIndex == 0) - && (request->wLength == 1)) { - USBD_Write(0, &(msdDriver.maxLun), 1, 0, 0); - } - else { - USBD_Stall(0); - } - break; -\endcode - - !Bulk-Only Mass Storage Reset - The host issues #RESET# requests to return the MSD driver of the device to its - initial state, i.e., ready to receive a new command. However, this request - does not impact the USB controller state; in particular, endpoints must not be - reset. This means the data toggle bit must not be altered, and Halted endpoint - must not be returned to a normal state. After processing the reset, the device - must return a Zero-Length Packet (ZLP) to acknowledge the SETUP transfer. - - Like GET_MAX_LUN, this request must be issued with specific parameters - - wValue, wIndex and wLength should be zero. A request which does not have valid - values in its field must be acknowledged with a STALL handshake from the - %device. - - The handler for this request must return the state machine to its initial state. -\code -//----------------------- -case MSD_BULK_ONLY_RESET: -//----------------------- - // Check parameters - if ((request->wValue == 0) - && (request->wIndex == 0) - && (request->wLength == 0)) { - - // Reset the MSD driver - MSDDriver_Reset(); - USBD_Write(0, 0, 0, 0, 0); - } - else { - USBD_Stall(0); - } - break; -\endcode - - !!State Machine - ... - - !Rationale - A state machine is necessary for #non-blocking# operation of the driver. As - previously stated, there are three steps when processing a command: - - Reception of the CBW - - Processing of the command (with data transfers if required) - - Emission of the CSW - - Without a state machine, the program execution would be stopped at each step - to wait for transfers completion or command processing. For example, reception - of a CBW does not always happen immediately (the host does not have to issue - commands regularly) and can block the system for a long time. - - Developing an asynchronous design based on a state machine is made easier when - using Atmel "AT91 USB device framework", as most methods are asynchronous. For - example, a write operation (using the USBD_Write function) returns - immediately; a callback function can then be invoked when the transfer - actually completes. - - !States - Apart from the three states corresponding to the command processing flow (CBW, - command processing and CSW), two more can be identified. The - reception/emission of CBW/CSW will be broken down into two different states: - the first state is used to issue the read/write operation, while the second - one waits for the transfer to finish. This can be done by monitoring a - "transfer complete" flag which is set using a callback function. - - In addition, some commands can be quite complicated to process: they may - require several consecutive data transfers mixed with media access. Each - command thus has its own second-tier state machine. During execution of a - command, the main state machine remains in the "processing" state, and - proceeds to the next one (CSW emission) only when the command is complete. - - Here is the states list: - - MSDDriver_STATE_READ_CBW: Start of CBW reception - (initial state after reset) - - MSDDriver_STATE_WAIT_CBW: Waiting for CBW reception - - MSDDriver_STATE_PROCESS_CBW: Command processing - - MSDDriver_STATE_SEND_CSW: Start of CSW emission - - MSDDriver_STATE_WAIT_CSW: Waiting for CSW emission - - A single function, named MSDDriver_StateMachine, is provided by the driver. It - must be called regularly during the program execution. The following - subsections describe the actions that must be performed during each state. - - \image MSDDriverStates.png "MSD Driver State Machine" - - #MSDDriver_STATE_READ_CBW# - - As said previously, this state is used to start the reception of a new Command - Block Wrapper. This is done using the USB_Read method of the USB framework. - The result code of the function is checked for any error; the - USB_STATUS_SUCCESS code indicates that the transfer has been successfully - started. -\code -//---------------------- -case MSDDriver_STATE_READ_CBW: -//---------------------- - // Start the CBW read operation - transfer->semaphore = 0; - status = USBD_Read(MSDDriverDescriptors_BULKOUT, - cbw, - MSD_CBW_SIZE, - (TransferCallback) MSDDriver_Callback, - (void *) transfer); - - // Check operation result code - if (status == USBD_STATUS_SUCCESS) { - - // If the command was successful, wait for transfer - msdDriver.state = MSDDriver_STATE_WAIT_CBW; - } - break; -\endcode - A callback function to invoke when the transfer is complete is provided to the - USBD_Read method, to update a MSDTransfer structure. This structure - indicates the transfer completion, the returned result code and the number of - transferred and remaining bytes. -\code -typedef struct { - unsigned int transferred; //!< Number of bytes transferred - unsigned int remaining; //!< Number of bytes not transferred - unsigned char semaphore; //!< Semaphore to indicate transfer completion - unsigned char status; //!< Operation result code -} MSDTransfer; -\endcode - The callback function is trivial and thus not listed here. - - #MSDDriver_STATE_WAIT_CBW# - - The first step here is to monitor the }semaphore} field of the MSDTransfer - structure (see above); this will enable detection of the transfer end. Please - note that this field must be declared as volatile in C, or accesses to it - might get optimized by the compiler; this can result in endless loops. - - If the transfer is complete, then the result code must be checked to see if - there was an error. If the operation is successful, the state machine can - proceed to command processing. Otherwise, it returns to the READ_CBW state. -\code -//---------------------- -case MSDDriver_STATE_WAIT_CBW: -//---------------------- - // Check transfer semaphore - if (transfer->semaphore > 0) { - - // Take semaphore and terminate transfer - transfer->semaphore--; - - // Check if transfer was successful - if (transfer->status == USBD_STATUS_SUCCESS) { - - // Process received command - msdDriver.state = MSDDriver_STATE_PROCESS_CBW; - } - else if (transfer->status == USBD_STATUS_RESET) { - - msdDriver.state = MSDDriver_STATE_READ_CBW; - } - else { - - msdDriver.state = MSDDriver_STATE_READ_CBW; - } - } - break; -\endcode - - #MSDDriver_STATE_PROCESS_CBW# - - Once the CBW has been received, its validity must be checked. A CBW is not - valid if: - - it has not been received right after a CSW was sent or a reset occured or - - it is not exactly 31 bytes long or - - its signature field is not equal to 43425355h - - The state machine prevents the first case from happening, so only the two - other cases have to be verified. - - The number of bytes transferred during a USBD_Read operation is passed as an - argument to the callback function, if one has been specified. As stated - previously, such a function is used to fill a MSDTransfer structure. - Therefore, it is trivial to check that the CBW is indeed 31 bytes by verifying - that the number of bytes transferred is 31, and that there are no remaining - bytes. The following table illustrates the three cases which may happen: -||Number of bytes transferred||Number of bytes remaining||Meaning -|transferred<31|remaining==0|CBW is too short -|transferred==31|remaining>0|CBW is too long -|transferred==31|remaining==0|CBW length is correct - - Checking the signature is simply done by comparing the dCBWSignature field - with the expected value (43425355h). - - If the CBW is not valid, then the device must immediately halt both Bulk - endpoints, to STALL further traffic from the host. In addition, it should stay - in this state until a Reset Recovery is performed by the host. This is done by - setting the waitResetRecovery flag in the MSDDriver structure. Finally, the - CSW status is set to report an error, and the state machine is returned to - MSDDriver_STATE_READ_CBW. - - Otherwise, if the CBW is correct, then the command can be processed. Remember - the CBW tag must be copied regardless of the validity of the CBW. - - Note that these steps are only necessary for a new command (remember commands - are asynchronous and are carried out in several calls, so a check can be - performed to avoid useless processing. A value of zero for the internal - command state indicates a new command. -\code -//------------------------- -case MSDDriver_STATE_PROCESS_CBW: -//------------------------- - // Check if this is a new command - if (commandState->state == 0) { - - // Copy the CBW tag - csw->dCSWTag = cbw->dCBWTag; - - // Check that the CBW is 31 bytes long - if ((transfer->transferred != MSD_CBW_SIZE) || - (transfer->remaining != 0)) { - - // Wait for a reset recovery - msdDriver.waitResetRecovery = 1; - - // Halt the Bulk-IN and Bulk-OUT pipes - USBD_Halt(MSDDriverDescriptors_BULKOUT); - USBD_Halt(MSDDriverDescriptors_BULKIN); - - csw->bCSWStatus = MSD_CSW_COMMAND_FAILED; - msdDriver.state = MSDDriver_STATE_READ_CBW; - - } - // Check the CBW Signature - else if (cbw->dCBWSignature != MSD_CBW_SIGNATURE) { - - // Wait for a reset recovery - msdDriver.waitResetRecovery = 1; - - // Halt the Bulk-IN and Bulk-OUT pipes - USBD_Halt(MSDDriverDescriptors_BULKOUT); - USBD_Halt(MSDDriverDescriptors_BULKIN); - - csw->bCSWStatus = MSD_CSW_COMMAND_FAILED; - msdDriver.state = MSDDriver_STATE_READ_CBW; - } - else { - - // Pre-process command - MSDDriver_PreProcessCommand(); - } - } - - // Process command - if (csw->bCSWStatus == MSDDriver_STATUS_SUCCESS) { - - if (MSDDriver_ProcessCommand()) { - - // Post-process command if it is finished - MSDDriver_PostProcessCommand(); - msdDriver.state = MSDDriver_STATE_SEND_CSW; - } - } - - break; -\endcode - - #MSDDriver_STATE_SEND_CSW# - - This state is similar to MSDDriver_STATE_READ_CBW, except that a write - operation is performed instead of a read and the CSW is sent, not the CBW. The - same callback function is used to fill the transfer structure, which is - checked in the next state: -\code -//---------------------- -case MSDDriver_STATE_SEND_CSW: -//---------------------- - // Set signature - csw->dCSWSignature = MSD_CSW_SIGNATURE; - - // Start the CSW write operation - status = USBD_Write(MSDDriverDescriptors_BULKIN, - csw, - MSD_CSW_SIZE, - (TransferCallback) MSDDriver_Callback, - (void *) transfer); - - // Check operation result code - if (status == USBD_STATUS_SUCCESS) { - - // Wait for end of transfer - msdDriver.state = MSDDriver_STATE_WAIT_CSW; - } - break; -\endcode - - #MSDDriver_STATE_WAIT_CSW# - - Again, this state is very similar to MSDDriver_STATE_WAIT_CBW. The only - difference is that the state machine is set to MSDDriver_STATE_READ_CBW - regardless of the operation result code: -\code -//---------------------- -case MSDDriver_STATE_WAIT_CSW: -//---------------------- - // Check transfer semaphore - if (transfer->semaphore > 0) { - - // Take semaphore and terminate transfer - transfer->semaphore--; - - // Read new CBW - msdDriver.state = MSDDriver_STATE_READ_CBW; - } - break; -\endcode - - !!Media - - USB MSD Media access is three-level abstraction. - - \image MSDMediaArch.png "Media Architecture" - - The bottom level is the specific driver for each media type (See memories). - - In the middle, a structure Media is used to hide which specific driver a media - instance is using. This enables transparent use of any media driver once it - has been initialized (See _Media). - - Finally, a LUN abstraction is made over the media structure to allow multiple - partitions over one media. This also makes it possible to place the LUN at any - address and use any block size. When performing a write or read operation on a - LUN, it forwards the operation to the underlying media while translating it to - the correct address and length. - - !Media Drivers - A media driver must provide several functions for: - - Reading data from the media - - Writing data on the media - - Handling interrupts on the media - The last function may be empty if the media does not require interrupts for - asynchronous operation, or if synchronous operation produces an acceptable - delay. - - In addition, it should also define a function for initializing a Media - structure with the correct values, as well as perform the necessary step for - the media to be useable. - - For the drivers see: - - MEDSdram.h: }Internal Flash Driver} - - MEDFlash.h: }SDRAM disk driver} - - !!SCSI Commands - - The example software described in this application note uses SCSI commands - with the MSD class, since this is the most appropriate setting for a Flash - device. This section details how SCSI commands are processed. - - !Documents - - There are several documents covering SCSI commands. In this application note, - the reference document used is SCSI Block Commands - 3 (SBC-3). However, it - makes many references to another SCSI document, SCSI Primary Commands - 4 - (SPC-4). Both are needed for full details on required commands. - - !Endianness - - SCSI commands use the big-endian format for storing word- and double word- - sized data. This means the Most Significant Bit (MSB) is stored at the - lowest address, and the Least Significant Bit (LSB) at the highest one. - - On ARM Thumb microcontrollers, the endianness of the core is selectable. - However, the little-endian mode is most often used. Therefore, SCSI command - data must be converted before being usable. This is done by declaring - word- and dword-sized fields as byte arrays, and then using a macro for - loading or storing data. Several of them are available in the provided - software: - - Load - - WORDB: Converts a big-endian word value to little-endian - - DWORDB: Converts a big-endian double-word value to little-endian - - Store - - STORE_WORDB: Stores a little-endian word value in big-endian format - - STORE_DWORDB: Stores a little-endian double-word value in big-endian format - - !Sense Data - - When an error happens during the execution of a command, it is recorded by the - device. The host may then issue a Request Sense command to retrieve - #Sense Data#, i.e., information about previous errors. - - While the sense data structure has many fields, only three are really - important. The first one is the Sense Key. It indicates the result of the last - command performed: success, media not ready, hardware error, etc. Two other - fields can then be specified to give a more accurate description of the - problem. They are named }Additional Sense Code} and }Additional Sense Code - Qualifier}. - - In the example application, each LUN has its own sense data. It is updated - during command execution if there is any error. - - !Commands - - The SBC-3 specification gives a list of mandatory and optional commands that - are relevant for a block device (like a Flash drive). In practice, only a - subset of the mandatory commands is effectively used by operating systems; - conversely, several commands which are supposed to be optional are required. - The software provided with this application note implements the following list - of commands: - - SBC-3 - - Prevent/Allow Medium Removal - - Read (10) - - Read Capacity (10) - - Verify (10) - - Write (10) - - SPC-4 - - Inquiry - - Mode Sense (6) - - Request Sense - - Test Unit Ready - The commands are actually processed in SBC_ProcessCommand. - - }Internal State Machine} - - As previously stated, most commands have an internal state machine to prevent - blocking the whole system during a data transfer (on the USB or when accessing - a media). A result code is used to indicate that the corresponding function - must be called again for the command to complete (MSDDriver_STATUS_SUCCESS). - - A command state structure is used by the driver to record several parameters - during command processing: -\code -typedef struct { - - MSDTransfer transfer; //!< Current transfer status - MSCbw cbw; //!< Received CBW - MSCsw csw; //!< CSW to send - unsigned char state; //!< Current command state - unsigned char postprocess; //!< Actions to perform when command is complete - unsigned int length; //!< Remaining length of command - -} MSDCommandState; -\endcode - - Note that the }state} field must be initialized when the command is first - called. A value of 0 means that no command is currently being executed. - - For the commands descriptions and implementation, please reffer to the SCSI - spec. and source code. - - Functions to handle SCSI commands: - - SBC_Inquiry - - SBC_Read10 - - SBC_ReadCapacity10 - - SBC_RequestSense - - SBC_TestUnitReady - - SBC_Write10 - - SBC_ModeSense6 - - !Command Processing - - }Flow} - - Command processing is actually divided into three phases in the example - software: - - Pre-processing: MSDDriver_PreProcessCommand - - Processing: MSDDriver_ProcessCommand - - Post-processing: MSDDriver_PostProcessCommand - - }The Thirteen Cases} - - There are basically three actions that should be performed depending on the - case: - - STALL the Bulk-IN endpoint - - STALL the Bulk-OUT endpoint - - Report a Phase Error in the CSW - - The table below lists all cases along with the actions which must be taken - after the command, including the correct length/direction of the transfer. The - following notation is used to characterize host and %device expectations: - - Data %Transfer Characterization -||Notation||Meaning||Notation||Meaning -|Hn|Host expects no data transfer|Dn|Device expects no data transfer -|Hi|Host expects to #receive# data|Di|Device expects to #send# data -|Ho|Host expects to #send# data|Do|Device expects to #receive# data -|Lh|Length of data expected by the host|Ld|Length of data expected by the %device - -|Hx=Dx|Host and %device agree on transfer length and direction (x is either n, i or o) -|Hx>Dx|Host and %device agree on transfer direction, host expects a larger transfer than %device -|HxDx|Host and %device disagree on transfer direction - - The Thirteen Cases -||\#||Case||Length||Residue||Direction||STALL IN?||STALL OUT?||Phase Error? -|1|Hn = Dn|0|0|Irrelevant| | | -|2|Hn < Di|0|Ld - Lh|Irrelevant| | |X -|3|Hn < Do|0|Ld - Lh|Irrelevant| | |X -|4|Hi > Dn|0|Lh|Irrelevant|X| | -|5|Hi > Di|Ld|Lh - Ld|In|X| | -|6|Hi = Di|Ld|0|In| | | -|7|Hi < Di|Lh|Ld - Lh|In| | |X -|8|Hi <> Do|0|0|Irrelevant|X| |X -|9|Ho > Dn|0|Lh|Irrelevant| |X| -|10|Ho <> Di|0|0|Irrelevant| |X|X -|11|Ho > Do|Ld|Lh - Ld|Out| |X| -|12|Ho = Do|Ld|0|Out| | | -|13|Ho < Do|Lh|Lh - Ld|Out| | |X - - !!Main Application - After the MSD driver and the media have been initialized using the - corresponding functions, the only requirement for the main application is to - regularly call the state machine function. This is necessary for processing - received commands in a fully asynchronous way. - - The application is otherwise free of doing any other task; for example, it - could implement a filesystem and a serial port interface to be accessed with a - standard terminal. An MP3 player could also continue playing a song while its - memory is accessed like an external hard disk. - - \image MSDDriverClasses.png "Driver Class Diagram" - -*/ -/** - \page "USB MSD Basic" - - This page gives generic details on the MSD class. - - !!!Purpose - - The MSD class defines how devices such as a hard disk, a USB floppy disk drive - or a disk-on-key shall operate on the USB. These devices are referred to as - mass storage devices, since they usually offer a high storage capacity. When - plugged to a PC, a %device complying to the MSD specification is accessed like - any other disk on the system. - - In practice, the specification only defines a way to wrap existing data - transfer protocols, such as SCSI or the Reduced Block Commands (RBC) set. A - list of the supported protocols and their uses will be given in the following - section. - - !!!Data Transfer Protocols - - The }Mass Storagae Class Specification Overview 1.2} supports the following - set of %devices: - - Protocols for MSD %devices -||Subclass Code||Command Block Spec.||Used by -|01h|Reduced Block Commands(RBC)|Flash %devices -|02h|SFF-8020i, MMC-2|CD & DVD %devices -|03h|QIC-157|Tape %devices -|04h|UFI|Floppy disk drives -|05h|SFF-8070i|Floppy disk drives -|06h|SCSI transparent command set|Any - - The SCSI transparent command set comprises all SCSI-related specifications, - such as SCSI Primary Commands (SPC), SCSI Block Commands (SBC), and so on. A - command will be issued by the host to determine exactly with which standard - the %device is compliant. - - The protocol used by the %device is specified in its Interface descriptor, in - the }bInterfaceSubclass} field. - - !!!Transfer Protocols - - There are actually two different transport protocols for the MSD class: - - Control/Bulk/Interface (CBI) transport - - Bulk-Only Transport (BOT) - - These two methods are described in two separate stand-alone documents. CBI can - be considered obsolete and is being completely replaced by BOT. It was - originally targeted at full-speed floppy disk drives. Therefore, the rest of - this document will talk about Bulk-Only Transport exclusively. - - Transport Protocol Codes -||bInterfaceProtocol||Protocol Implementation -|00h|Control/Bulk/Interrupt protocol (with command completion interrupt) -|01h|Control/Bulk/Interrupt protocol (without command completion interrupt) -|50h|Bulk-only transport - - !!!Architecture - ... - - !!Interfaces & Endpoints - - An MSD %device only needs one single interface. The bInterfaceClass field of - the interface descriptor should be set to MSD class code (0x08), the - corresponding data transfer protocol code in the }bInterfaceSubclass} field - and transport protocol code in the }bInterfaceProtocol} field can be found in - the tables on above. - - Exactly three %endpoints (when using the Bulk-Only Transport protocol) are - necessary for MSD %devices. - - The first one is the Control endpoint 0, and is used for class-specific - requests and for clearing Halt conditions on the other two %endpoints. - Endpoints are halted in response to errors and host bad behavior during data - transfers, and the CLEAR_FEATURE request is consequently used to return them - to a functional state. - - The other two %endpoints, which are of type Bulk, are used for transferring - commands and data over the bus. There must be one Bulk-IN and one Bulk-OUT - endpoint. - - \image MSDDriverArch.png "Mass Storage Device Driver Architecture" - - !!Class-Specific Descriptors - No class-specific descriptors for an MSD %device using the Bulk-only transfport - protocol. - - !!Class-Specific Requests - Two class specific requests should be handled. - - !GetMaxLUN - A %device can feature one or more Logical Unit (LU). Each of these units will - be treated as a separate disk when plugged to a computer. A %device can have up - to 15 logical units. - - The GET_MAX_LUN request is issued by the host to determine the maximum Logical - Unit Number (LUN) supported by the %device. This is not equivalent to the - number of LU on the %device; since units are numbered starting from 0, a %device - with 5 LUs should report a value of 4, which will be the index of the fifth - unit. - - Optionally, a %device with only one LUN may STALL this request instead of - returning a value of zero. - - !Bulk-Only Mass Storage Reset - This request is used to reset the state of the %device and prepare it to - receive commands and data. Note that the data toggle bits must not be altered - by a RESET command; same for the Halt state of %endpoints, i.e., halted - %endpoints must not be reset to a normal state. - - !!Command/Data/Status - Each MSD transaction is divided into three steps: - - Command stage - - Data stage (optional) - - Status stage - - During the command stage, a Command Block Wrapper (CBW) is transmitted by the - host to the %device. The CBW describes several parameters of the transaction - (direction, length, LUN) and carries a variable-length command block. The - command block contains data in the format defined by the transfer protocol - used by the %device. - - Command Block Wrapper Data Format -||Offset||Field Name||Length||Comment -|0|dCBWSignature|4 bytes|Signature to identify CBW, must be 43425355h -|4|dCBWTag|4 bytes|Tag sent by the host, echoed in the CSW -|8|dCBWTransferLength|4 bytes|Length of transfer during the data stage -|12|bmCBWFlags|1 byte|Bits 0-6: Reserved/obsolete\n - Bit 7: Transfer direction (0 = OUT, 1 = IN) -|13|bCBWLUN|1 byte|Bits 0-3: LUN to which the command is sent\n - Bits 4-7: Reserved -|14|bCBWCBLength|1 byte|Bits 0-5: Length of command block in bytes\n - Bits 6-7: Reserved -|15|CBWCB|0-16 bytes|Command block to be executed by the %device - - After the %device has received and interpreted the command, an optional data - stage may take place if the command requires it. During this step, data is - transferred either to or from the %device depending on the command, in several - IN/OUT transfers. - - Once the data stage is complete, the host issues a final IN request on the - Bulk-IN endpoint of the %device to request the Command Status Wrapper (CSW). - The CSW is used to report correct or incorrect execution of the command, as - well as indicating the length of remaining data that has not been transferred. - - Command Status Wrapper -||Offset||Field Name||Length||Comment -|0|dCSWSignature|4 bytes|Signature to identify CSW, must be 53425355h -|4|dCSWTag|4 bytes|Copy of previous CBW tag -|8|dCSWDataResidue|4 bytes|Difference between expected and real transfer length -|12|bCSWStatus|1 byte|Indicates the success or failure of the command - - These steps are all performed on the two Bulk %endpoints, and do not involve - Control endpoint 0 at all. - - !!Reset Recovery - When severe errors occur during command or data transfers (as defined in the - }Mass Storage Bulk-only Transport 1.0} document), the %device must halt both - Bulk %endpoints and wait for a #Reset Recovery# procedure. The Reset Recovery - sequence goes as follows: - - The host issues a Bulk-Only Mass Storage Reset request - - The host issues two #CLEAR_FEATURE# requests to unhalt each endpoint - - A %device waiting for a Reset Recovery must not carry out CLEAR_FEATURE - requests trying to unhalt either Bulk endpoint until after a Reset request has - been received. This enables the host to distinguish between severe and minor - errors. - - The only major error defined by the Bulk-Only Transport standard is when a CBW - is not valid. This means one or more of the following: - - The CBW is not received after a CSW has been sent or a reset. - - The CBW is not exactly 31 bytes in length. - - The dCBWSignature field of the CBW is not equal to 43425355h. - - !!!Host Drivers - Almost all operating systems now provide a generic driver for the MSD class. - However, the set of supported data transfer protocols may vary. For example, - Microsoft Windows does not currently support the Reduced Block Command set. - -*/ diff --git a/src/ersky9x/libraries/usb/host/core/USBH.h b/src/ersky9x/libraries/usb/host/core/USBH.h deleted file mode 100644 index 7836619db..000000000 --- a/src/ersky9x/libraries/usb/host/core/USBH.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// -/// !!!Purpose -/// -/// Collection of methods for using the USB device controller on AT91 -/// microcontrollers. -/// -/// !!!Usage -/// -/// Please refer to the corresponding application note. -/// - "AT91 USB device framework" -/// - "USBD API" . "USBD API Methods" -//------------------------------------------------------------------------------ - -#ifndef USBH_H -#define USBH_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -//#include -//#include -#include -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void USBH_Init(OHCI_HCCA* pHCCA); -extern void USBH_ResetPort(unsigned char portNumber); -extern unsigned char USBH_IsDeviceConnectedOnPort(unsigned char portNumber); -extern void USBH_program(unsigned int* pBHED, unsigned int* pBCED, OHCI_HCCA* pHCCA); -extern void USBH_enablingPort(void); - - -#endif //#ifndef USBD_H - diff --git a/src/ersky9x/libraries/usb/host/core/USB_UHP.c b/src/ersky9x/libraries/usb/host/core/USB_UHP.c deleted file mode 100644 index 59c3b4c84..000000000 --- a/src/ersky9x/libraries/usb/host/core/USB_UHP.c +++ /dev/null @@ -1,223 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include -#include -#include -#include "USBH.h" -#include - - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// HcFmInterval Register: -/// FrameInterval specifies the interval between 2 consecutive SOFs in bit times -/// 1/12 = 0,08333333 -/// 1(ms) / 0,0833333 = 12 -/// FrameInterval = 12x1000 = 12000 -#define FRAMEINTERVAL 12000 -/// FSLargestDataPacket -/// This field specifies a value which is loaded into the Largest -/// Data Packet Counter at the beginning of each frame. - -/// overhead. -/// The value of MAXIMUM_OVERHEAD below is 210 bit times. -#define MAXIMUM_OVERHEAD 210 -/// FSLargestDataPacket initializes a counter within the Host Controller that is -/// used to determine if a transaction on USB can be completed before EOF -/// processing must start. -/// It is a function of the new FrameInterval and is calculated by subtracting -/// from FrameInterval the maximum number of bit times for transaction overhead -/// on USB and the number of bit times needed for EOF processing, then -/// multiplying the result by 6/7 to account for the worst case bit stuffing -#define FSLARGESTDATAPACKET (((FRAMEINTERVAL-MAXIMUM_OVERHEAD) * 6) / 7) -#define OHCI_FMINTERVAL ((FSLARGESTDATAPACKET << 16) | FRAMEINTERVAL) - -/// HcPeriodicStart Register -// The HcPeriodicStart register has a 14-bit programmable value which -// determines when is the earliest time HC should start processing the -// periodic list. -/// Set HcPeriodicStart to a value that is 90% of the value in FrameInterval -/// field of the HcFmInterval register. -#define OHCI_PRDSTRT (FRAMEINTERVAL*90/100) - - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - -#ifdef AT91C_BASE_UHPHS_OHCI -#define AT91C_ID_UHP AT91C_ID_UHPHS -#define AT91C_BASE_UHP AT91C_BASE_UHPHS_OHCI -#define UHP_HcRhPortStatus UHPHS_OHCI_HcRhPortStatus -#define UHP_HcControlHeadED UHPHS_OHCI_HcControlHeadED -#define UHP_HcControlCurrentED UHPHS_OHCI_HcControlCurrentED -#define UHP_HcBulkDoneHead UHPHS_OHCI_HcBulkDoneHead -#define UHP_HcControl UHPHS_OHCI_HcControl -#define UHP_HcRhStatus UHPHS_OHCI_HcRhStatus -#define UHP_HcHCCA UHPHS_OHCI_HcHCCA -#define UHP_HcFmInterval UHPHS_OHCI_HcFmInterval -#define UHP_HcPeriodicStart UHPHS_OHCI_HcPeriodicStart -#endif - -//------------------------------------------------------------------------------ -/// Enable UHP clock -//------------------------------------------------------------------------------ -static inline void UHP_EnablePeripheralClock(void) -{ - AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_UHP); -} - -//------------------------------------------------------------------------------ -/// Disable UHP clock -//------------------------------------------------------------------------------ -static inline void UHP_DisablePeripheralClock( void ) -{ - AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_UHP); -} - -//------------------------------------------------------------------------------ -/// Enables the 48MHz USB clock. -//------------------------------------------------------------------------------ -static inline void UHP_EnableUsbClock(void) -{ -#ifdef AT91C_PMC_USBS_USB_UPLL - AT91C_BASE_PMC->PMC_USB = AT91C_PMC_USBS_USB_UPLL | AT91C_PMC_USBDIV_10; -#endif -#ifdef AT91C_CKGR_UPLLEN_ENABLED - AT91C_BASE_PMC->PMC_UCKR = AT91C_CKGR_UPLLEN_ENABLED; -#endif - AT91C_BASE_PMC->PMC_SCER = AT91C_PMC_UHP; -} - -//------------------------------------------------------------------------------ -/// Disables the 48MHz USB clock. -//------------------------------------------------------------------------------ -static inline void UHP_DisableUsbClock(void) -{ - AT91C_BASE_PMC->PMC_SCDR = AT91C_PMC_UHP; -#ifdef AT91C_CKGR_UPLLEN_ENABLED - AT91C_BASE_PMC->PMC_UCKR = AT91C_CKGR_UPLLEN_ENABLED; -#endif -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Detect a connected device -//------------------------------------------------------------------------------ -unsigned char USBH_IsDeviceConnectedOnPort(unsigned char portNumber) -{ - return (AT91C_BASE_UHP->UHP_HcRhPortStatus[portNumber] & 0x01); -} - -//------------------------------------------------------------------------------ -/// Reset the port number -//------------------------------------------------------------------------------ -void USBH_ResetPort(unsigned char portNumber) -{ - // SetPortReset - AT91C_BASE_UHP->UHP_HcRhPortStatus[portNumber] = (1 << 4); - // Wait for the end of reset - while (AT91C_BASE_UHP->UHP_HcRhPortStatus[portNumber] & (1 << 4)); - // SetPortEnable - AT91C_BASE_UHP->UHP_HcRhPortStatus[portNumber] = (1 << 1); -} - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void USBH_program(unsigned int* pBHED, unsigned int* pBCED, OHCI_HCCA* pHCCA) -{ - // Programming the BHED - // The HcBulkHeadED register contains the physical address of the first - // Endpoint Descriptor of the Bulk list. - AT91C_BASE_UHP->UHP_HcControlHeadED = (unsigned int) pBHED; - - // Programming the BCED - // The HcBulkCurrentED register contains the physical address of the current - // endpoint of the Bulk list. - AT91C_BASE_UHP->UHP_HcControlCurrentED = (unsigned int) pBCED; - - // Initializing the UHP_HcDoneHead - AT91C_BASE_UHP->UHP_HcBulkDoneHead = 0x00; - pHCCA->UHP_HccaDoneHead = 0x0000; - - // Forcing UHP_Hc to Operational State - AT91C_BASE_UHP->UHP_HcControl = 0x80; -} - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void USBH_enablingPort(void) -{ - // Enabling port power - AT91C_BASE_UHP->UHP_HcRhPortStatus[0] = 0x00000100; - AT91C_BASE_UHP->UHP_HcRhPortStatus[1] = 0x00000100; - AT91C_BASE_UHP->UHP_HcRhStatus = 0x00010000; -} - -//------------------------------------------------------------------------------ -/// Initializes the specified USB driver -/// This function initializes the current FIFO bank of endpoints, -/// configures the pull-up and VBus lines, disconnects the pull-up and -/// then trigger the Init callback. -//------------------------------------------------------------------------------ -void USBH_Init(OHCI_HCCA* pHCCA) -{ - TRACE_DEBUG_WP("USBH Init()\n\r"); - - UHP_EnablePeripheralClock(); - UHP_EnableUsbClock(); - - // Forcing UHP_Hc to reset - AT91C_BASE_UHP->UHP_HcControl = 0; - - // Writing the UHP_HCCA - AT91C_BASE_UHP->UHP_HcHCCA = (unsigned int) &pHCCA; - - // Enabling list processing - AT91C_BASE_UHP->UHP_HcControl = 0; - - // HcFmInterval register is used to control the length of USB frames - AT91C_BASE_UHP->UHP_HcFmInterval = OHCI_FMINTERVAL; - // The HcPeriodicStart register has a 14-bit programmable value which - // determines when is the earliest time HC should start processing the - // periodic list. - AT91C_BASE_UHP->UHP_HcPeriodicStart = OHCI_PRDSTRT; -} - diff --git a/src/ersky9x/libraries/usb/host/ohci/ohci.c b/src/ersky9x/libraries/usb/host/ohci/ohci.c deleted file mode 100644 index d125559f1..000000000 --- a/src/ersky9x/libraries/usb/host/ohci/ohci.c +++ /dev/null @@ -1,124 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// OHCI ED, TD HCCA definitions + inlined functions - - -#include "ohci.h" - - -//------------------------------------------------------------------------------ -/// Init a pre-allocated endpoint descriptor -/// TD must be aligned on a 16 bytes boundary -//------------------------------------------------------------------------------ -void OHCI_CreateEd( unsigned int EDAddr, - unsigned int MaxPacket, - unsigned int TDFormat, - unsigned int Skip, - unsigned int Speed, - unsigned int Direction, - unsigned int EndPt, - unsigned int FuncAddress, - unsigned int TDQTailPntr, - unsigned int TDQHeadPntr, - unsigned int ToggleCarry, - unsigned int NextED ) -{ - OHCIEndpointDescriptor *pED = (OHCIEndpointDescriptor*) EDAddr; - - pED->Control = (MaxPacket << 16) | (TDFormat << 15) | - (Skip << 14) | (Speed << 13) | (Direction << 11) | - (EndPt << 7) | FuncAddress; - pED->TailP = (TDQTailPntr & 0xFFFFFFF0); - pED->HeadP = (TDQHeadPntr & 0xFFFFFFF0) | (ToggleCarry << 1); - pED->NextEd = (NextED & 0xFFFFFFF0); -} - -//------------------------------------------------------------------------------ -/// Init a pre-allocated transfer descriptor -/// TD must be aligned on a 16 bytes boundary -//------------------------------------------------------------------------------ -void OHCI_CreateGenTd( unsigned int GenTdAddr, - unsigned int DataToggle, - unsigned int DelayInterrupt, - unsigned int Direction, - unsigned int BufRnding, - unsigned int CurBufPtr, - unsigned int NextTD, - unsigned int BuffLen) -{ - OHCITransferDescriptor *pTD = (OHCITransferDescriptor*) GenTdAddr; - - pTD->Control = (DataToggle << 24) | (DelayInterrupt << 21) - | (Direction << 19) | (BufRnding << 18); - pTD->CBP = CurBufPtr; - pTD->NextTD = (NextTD & 0xFFFFFFF0); - pTD->BE = (BuffLen) ? (CurBufPtr + BuffLen - 1) : CurBufPtr; -} - -//------------------------------------------------------------------------------ -/// Init a pre-allocated periodic transfer descriptor -/// TD must be aligned on a 16 bytes boundary -//------------------------------------------------------------------------------ -void OHCI_CreateGenITd( unsigned int GenTdAddr, - unsigned int CondCode, - unsigned int FrameCount, - unsigned int DelayInterrupt, - unsigned int StartFrame, - unsigned int BuffPage0, - unsigned int NextTD, - unsigned int BufEnd, - unsigned int PswOffset0, - unsigned int PswOffset1, - unsigned int PswOffset2, - unsigned int PswOffset3, - unsigned int PswOffset4, - unsigned int PswOffset5, - unsigned int PswOffset6, - unsigned int PswOffset7) -{ - OHCIPeriodicTransferDescriptor *pITD = (OHCIPeriodicTransferDescriptor*) GenTdAddr; - - pITD->Control = (CondCode << 28) | (FrameCount << 24) - | (DelayInterrupt << 21) | StartFrame; - pITD->BP0 = (BuffPage0 << 12); - pITD->NextTD = (NextTD << 4); - pITD->BE = BufEnd; - pITD->PSW0 = PswOffset0; - pITD->PSW1 = PswOffset1; - pITD->PSW2 = PswOffset2; - pITD->PSW3 = PswOffset3; - pITD->PSW4 = PswOffset4; - pITD->PSW5 = PswOffset5; - pITD->PSW6 = PswOffset6; - pITD->PSW7 = PswOffset7; - -} - - diff --git a/src/ersky9x/libraries/usb/host/ohci/ohci.h b/src/ersky9x/libraries/usb/host/ohci/ohci.h deleted file mode 100644 index 804d75b85..000000000 --- a/src/ersky9x/libraries/usb/host/ohci/ohci.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// OHCI ED, TD HCCA definitions + inlined functions - -#ifndef _OHCI_H -#define _OHCI_H - -#ifdef __ICCARM__ // IAR -#pragma pack(8) -#define __attribute__(...) // IAR -#endif // IAR -// Endpoint Descriptor Field Definitions -typedef struct { - // FunctionAddress | EndpointNumber | Direction | Speed | sKip | Format - // MaximumPacketSize - volatile unsigned int Control; - // TailP: TDQueueTailPointer - // If TailP and HeadP are the same, then the list contains no TD that the HC - // can process. If TailP and HeadP are different, then the list contains a TD to be - // processed. - volatile unsigned int TailP; - // HeadP: TDQueueHeadPointer Points to the next TD to be processed for this - // endpoint. - volatile unsigned int HeadP; - // NextED: If nonzero, then this entry points to the next ED on the list - volatile unsigned int NextEd; -} __attribute__((aligned(16))) OHCIEndpointDescriptor; - -/// General Transfer Descriptor Format -typedef struct { - volatile unsigned int Control; // bufferRounding | Direction/PID | DelayInterrupt - // DataToggle | ErrorCount | ConditionCode - volatile unsigned int CBP; // Current Buffer Pointer - volatile unsigned int NextTD; // Next TD - volatile unsigned int BE; // Buffer End -} __attribute__((aligned(16))) OHCITransferDescriptor; - -typedef struct { - volatile unsigned int Control; // StartingFrame | DelayInterrupt | FrameCount - // ConditionCode - volatile unsigned int BP0; // Buffer Page 0 - volatile unsigned int NextTD; // NextTD - volatile unsigned int BE; // Buffer End - volatile unsigned int PSW0; // Offset0/PSW0 - volatile unsigned int PSW1; // Offset1/PSW1 - volatile unsigned int PSW2; // Offset2/PSW2 - volatile unsigned int PSW3; // Offset3/PSW3 - volatile unsigned int PSW4; // Offset4/PSW4 - volatile unsigned int PSW5; // Offset5/PSW5 - volatile unsigned int PSW6; // Offset6/PSW6 - volatile unsigned int PSW7; // Offset7/PSW7 -} __attribute__((aligned(8))) OHCIPeriodicTransferDescriptor; - -//Host Controller Communications Area Description -typedef struct { - // pointers to an Interrupt List each of which is a list of EDs - volatile unsigned int UHP_HccaInterruptTable[32]; - // This 16-bit value is updated by the Host Controller on each frame. - volatile unsigned short UHP_HccaFrameNumber; // current frame number - // When the HC updates HccaFrameNumber, it sets this word to 0. - volatile unsigned short UHP_HccaPad1; - // When a TD is complete (with or without an error) it is unlinked from the - // queue that it is on and linked to the Done Queue - volatile unsigned int UHP_HccaDoneHead; - // Reserved for use by HC - volatile unsigned char reserved[116]; -} __attribute__((aligned(8))) OHCI_HCCA; - -#ifdef __ICCARM__ // IAR -#pragma pack() // IAR -#endif // IAR - - -extern void OHCI_CreateEd( unsigned int EDAddr, - unsigned int MaxPacket, - unsigned int TDFormat, - unsigned int Skip, - unsigned int Speed, - unsigned int Direction, - unsigned int EndPt, - unsigned int FuncAddress, - unsigned int TDQTailPntr, - unsigned int TDQHeadPntr, - unsigned int ToggleCarry, - unsigned int NextED ); -extern void OHCI_CreateGenTd( unsigned int GenTdAddr, - unsigned int DataToggle, - unsigned int DelayInterrupt, - unsigned int Direction, - unsigned int BufRnding, - unsigned int CurBufPtr, - unsigned int NextTD, - unsigned int BuffLen); -extern void OHCI_CreateGenITd( unsigned int GenTdAddr, - unsigned int CondCode, - unsigned int FrameCount, - unsigned int DelayInterrupt, - unsigned int StartFrame, - unsigned int BuffPage0, - unsigned int NextTD, - unsigned int BufEnd, - unsigned int PswOffset0, - unsigned int PswOffset1, - unsigned int PswOffset2, - unsigned int PswOffset3, - unsigned int PswOffset4, - unsigned int PswOffset5, - unsigned int PswOffset6, - unsigned int PswOffset7); -#endif //_OHCI_H - - diff --git a/src/ersky9x/libraries/usb/otg/compiler.h b/src/ersky9x/libraries/usb/otg/compiler.h deleted file mode 100644 index b85521b24..000000000 --- a/src/ersky9x/libraries/usb/otg/compiler.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _COMPILER_H_ -#define _COMPILER_H_ - -typedef float Float16; -typedef unsigned char U8 ; -typedef unsigned short U16; -typedef unsigned long U32; -typedef unsigned char Bool; - -typedef unsigned char Byte; - -typedef char bit; - -#define MSB0(u32) (((U8* )&u32)[3]) -#define MSB1(u32) (((U8* )&u32)[2]) -#define MSB2(u32) (((U8* )&u32)[1]) -#define MSB3(u32) (((U8* )&u32)[0]) -#define LSB0(u32) MSB3(u32) -#define LSB1(u32) MSB2(u32) -#define LSB2(u32) MSB1(u32) -#define LSB3(u32) MSB0(u32) -#define MSB(u16) (((U8* )&u16)[1]) -#define LSB(u16) (((U8* )&u16)[0]) -#define MSW(u32) (((U16*)&u32)[1]) -#define LSW(u32) (((U16*)&u32)[0]) - - -// Constants -#define DISABLE 0 -#define ENABLE 1 - -#define TRUE (1 == 1) -#define FALSE (0 == 1) - -#endif /* _COMPILER_H_ */ - diff --git a/src/ersky9x/libraries/usb/otg/usb_drv.c b/src/ersky9x/libraries/usb/otg/usb_drv.c deleted file mode 100644 index c29689cc0..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_drv.c +++ /dev/null @@ -1,246 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "usb_drv.h" -#include - -U8 global_pipe_nb=0; -U8 global_endpoint_nb=0; -unsigned char dBytes=0; -char* pFifo; - - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//! This function configures an endpoint with the selected type. -U8 dev_configure_endpoint(U8 ept, U8 type, U8 dir, U8 size, U8 bank, U8 nyet) -{ - unsigned char status=0; - - // Enable endpoint - AT91C_BASE_OTGHS->OTGHS_DEVEPT |= (1<OTGHS_DEVEPTCFG[ept] = (bank<<2)|(size<<4)|(dir<<8) - |AT91C_OTGHS_AUTOSW |(type<<11); - - AT91C_BASE_OTGHS->OTGHS_DEVEPTCFG[ept] |= AT91C_OTGHS_ALLOC; - if(!(AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[ept]&AT91C_OTGHS_CFGOK)) { - TRACE_ERROR("Bad endpoint configuration\n\r"); - status = 1; - } - if(nyet == NYET_ENABLED) { - AT91C_BASE_OTGHS->OTGHS_DEVEPTIDR[ept] = AT91C_OTGHS_NYETDIS; - } - else { - AT91C_BASE_OTGHS->OTGHS_DEVEPTIER[ept] = AT91C_OTGHS_NYETDIS; - } - return status; -} - - - - -//------------------------------------------------------------------------------ -// HOST -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -//! This function configures a pipe with the selected type. -//! @param config0 -//! @param config1 -//! @return Is_endpoint_configured. -//------------------------------------------------------------------------------ -U8 host_config_pipe(U8 config0, U8 config1) -{ - TRACE_DEBUG("host_config_pipe\n\r"); - Host_enable_pipe(); -// UPCFG0X = config0; -// UPCFG1X = config1; - Host_allocate_memory(); - return (Is_pipe_configured()); -} - -//------------------------------------------------------------------------------ -//! This function returns the size configuration register value according -//! to the endpint size detected inthe device enumeration process. -//! @return pipe size register value. -//------------------------------------------------------------------------------ -U8 host_determine_pipe_size(U16 size) -{ - //TRACE_DEBUG("host_determine_pipe_size\n\r"); - if(size <= 8 ) {return (SIZE_8 );} - else if(size <= 16 ) {return (SIZE_16 );} - else if(size <= 32 ) {return (SIZE_32 );} - else if(size <= 64 ) {return (SIZE_64 );} - else if(size <= 128) {return (SIZE_128 );} - else if(size <= 256) {return (SIZE_256 );} - else if(size <= 512) {return (SIZE_512 );} - else {return (SIZE_1024);} -} - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -U16 host_get_pipe_length(void) -{ - unsigned int size; - - size = (AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb]&AT91C_OTGHS_PSIZE)>>4; - //TRACE_DEBUG("host_get_pipe_length = %d\n\r", (int)size); - - if(size == SIZE_8 ) {return (8 );} - else if(size == SIZE_16 ) {return (16 );} - else if(size == SIZE_32 ) {return (32 );} - else if(size == SIZE_64 ) {return (64 );} - else if(size == SIZE_128) {return (128);} - else if(size == SIZE_256) {return (256);} - else if(size == SIZE_512) {return (512);} - else if(size == SIZE_1024){return (1024);} - else {TRACE_ERROR("Error size\n\r");return 0;} -} - - -//------------------------------------------------------------------------------ -//! host_disable_all_pipe. -//! -//! This function disable all pipes for the host controller -//! Usefull to execute upon device disconnection. -//! -//! @return none. -//------------------------------------------------------------------------------ -void host_disable_all_pipe(void) -{ - U8 i; - - TRACE_DEBUG("host_disable_all_pipe\n\r"); - for (i=0; i<7; i++) { - Host_reset_pipe(i); - Host_select_pipe(i); - Host_unallocate_memory(); - Host_disable_pipe(); - } -} - -//------------------------------------------------------------------------------ -//! @brief Returns the pipe number that generates a USB communication interrupt -//! -//! This function sould be called only when an interrupt has been detected. Otherwize -//! the return value is incorect -//! -//! @param none -//! -//! @return pipe_number -//------------------------------------------------------------------------------ -U8 host_get_nb_pipe_interrupt(void) -{ - U8 interrupt_flags; - U8 i; - - TRACE_DEBUG("host_get_nb_pipe_interrupt\n\r"); - interrupt_flags = Host_get_pipe_interrupt(); - for(i=0; iOTGHS_HSTADDR1 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P0; - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 |= ((addr<<0) & AT91C_OTGHS_UHADDR_P0); - } - else if( pipe == 1 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P1; - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 |= ((addr<<8) & AT91C_OTGHS_UHADDR_P1); - } - else if( pipe == 2 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P2; - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 |= ((addr<<16) & AT91C_OTGHS_UHADDR_P2); - } - else if( pipe == 3 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P3; - AT91C_BASE_OTGHS->OTGHS_HSTADDR1 |= ((addr<<24) & AT91C_OTGHS_UHADDR_P3); - } - else if( pipe == 4 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P4; - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 |= ((addr<<0) & AT91C_OTGHS_UHADDR_P4); - } - else if( pipe == 5 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P5; - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 |= ((addr<<8) & AT91C_OTGHS_UHADDR_P5); - } - else if( pipe == 6 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P6; - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 |= ((addr<<16) & AT91C_OTGHS_UHADDR_P6); - } - else if( pipe == 7 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P7; - AT91C_BASE_OTGHS->OTGHS_HSTADDR2 |= ((addr<<24) & AT91C_OTGHS_UHADDR_P7); - } - else if( pipe == 8 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR3 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P8; - AT91C_BASE_OTGHS->OTGHS_HSTADDR3 |= ((addr<<0) & AT91C_OTGHS_UHADDR_P8); - } - else if( pipe == 9 ) { - AT91C_BASE_OTGHS->OTGHS_HSTADDR3 &= ~(unsigned int)AT91C_OTGHS_UHADDR_P9; - AT91C_BASE_OTGHS->OTGHS_HSTADDR3 |= ((addr<<8) & AT91C_OTGHS_UHADDR_P9); - } - else { - TRACE_ERROR("pipe not defined\n\r"); - } -} - - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void host_configure_pipe(U8 pip, U8 type, U8 token, U8 ep_num, U8 size, U8 bank, U8 freq) -{ - AT91C_BASE_OTGHS->OTGHS_HSTPIP |= (1<OTGHS_HSTPIPCFG[pip] = (bank<< 2) | (size << 4) | (token<< 8) - | (type<<12) |(ep_num<<16)| (freq <<24); - AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[pip] |= AT91C_OTGHS_ALLOC; -} - - diff --git a/src/ersky9x/libraries/usb/otg/usb_drv.h b/src/ersky9x/libraries/usb/otg/usb_drv.h deleted file mode 100644 index c9276fe84..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_drv.h +++ /dev/null @@ -1,859 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// This file contains the USB low level driver definition - - -#ifndef _USB_DRV_H -#define _USB_DRV_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include "board.h" - -extern unsigned char dBytes; -extern char* pFifo_ctrl; -extern char* pFifo; - -//#define Address_fifo_endpoint(ep) (char*)&(AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0[EPT_VIRTUAL_SIZE*ep]) -#define Address_fifochar_endpoint(ep) pFifo = (char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO + (EPT_VIRTUAL_SIZE * ep));dBytes=0 -//#define Address_fifochar_endpoint(ep) (char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO + (EPT_VIRTUAL_SIZE * ep)) -#define Address_fifo_endpoint(ep) (int*) ((int)(AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0) + (EPT_VIRTUAL_SIZE*(ep))) - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// USB_low_level_drivers USB low level drivers module - -#define MAX_EP_NB 7 - -#define EPT_VIRTUAL_SIZE 8192 - -#define EP_CONTROL 0 -#define PIPE_CONTROL 0 - -// USB EndPoint -#define MSK_EP_DIR 0x7F - -// Parameters for endpoint configuration -// These define are the values used to enable and configure an endpoint. -#define TYPE_CONTROL 0 -#define TYPE_ISOCHRONOUS 1 -#define TYPE_BULK 2 -#define TYPE_INTERRUPT 3 - -#define DIRECTION_OUT 0 -#define DIRECTION_IN 1 - -#define SIZE_8 0 -#define SIZE_16 1 -#define SIZE_32 2 -#define SIZE_64 3 -#define SIZE_128 4 -#define SIZE_256 5 -#define SIZE_512 6 -#define SIZE_1024 7 - -#define ONE_BANK 0 -#define TWO_BANKS 1 -#define TREE_BANKS 2 - -#define NYET_ENABLED 0 -#define NYET_DISABLED 1 - -#define TOKEN_SETUP 0 -#define TOKEN_IN 1 -#define TOKEN_OUT 2 - -#define Is_ep_addr_in(x) (x & 0x80) - -//Set_bits(AVR32_USB_uatst1,AVR32_USB_UATST1_LOADCNTA_MASK); -#define Usb_load_tsta1_countMask() AT91C_BASE_OTGHS->OTGHS_TSTA1 &= ~(unsigned int)AT91C_OTGHS_COUNTERA - -//#define AVR32_USB_UATST1_LOADCNTA_MASK_NONZERO 0x00008001 -#define Usb_load_tsta1_counta() AT91C_BASE_OTGHS->OTGHS_TSTA1 = AT91C_OTGHS_LOADCNTA | (AT91C_OTGHS_COUNTERA&0x01) - -//#define AVR32_USB_UATST2_FORCE_51MS_RESETHS_MASK 0x00000080 -#define USb_ForceHSRst_50ms() AT91C_BASE_OTGHS->OTGHS_TSTA2 |= AT91C_OTGHS_FORCHSRST - -//#define AVR32_USB_UATST2_FORCE_RESET_UTMI 0x00000100 -#define Usb_SetForceResetUTMI() AT91C_BASE_OTGHS->OTGHS_TSTA2 |= AT91C_OTGHS_UTMIRESET -#define Usb_ClrForceResetUTMI() AT91C_BASE_OTGHS->OTGHS_TSTA2 &= ~(unsigned int)AT91C_OTGHS_UTMIRESET - -//#define AVR32_USB_UATST2_HOSTHSDISCONNECTDISABLE_MASK -#define Usb_SetHSTDiconnectDisableMask() AT91C_BASE_OTGHS->OTGHS_TSTA2 |= AT91C_OTGHS_HSTHSDISCDIS -#define Usb_ClrHSTDiconnectDisableMask() AT91C_BASE_OTGHS->OTGHS_TSTA2 &= ~(unsigned int)AT91C_OTGHS_HSTHSDISCDIS - -#define Usb_enable_vbus_error_interrupt() AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_VBERR - -#define Is_Usb_InHighSpeed() (AT91C_BASE_OTGHS->OTGHS_SR&AT91C_OTGHS_SPEED_SR) == AT91C_OTGHS_SPEED_SR_HS - -/// OTG Timers customizing -// HOST : Minimum delay after Vbus requested to get it > Va_vbus_valid (otherwise => error) -//#define VBUSRISE_20MS 0x00 -//#define VBUSRISE_50MS 0x01 -#define VBUSRISE_70MS 0x02 -//#define VBUSRISE_100MS 0x03 -// DEVICE : Duration of Vbus pulse during SRP protocol -//#define VBUSPULSE_15MS 0x20 -//#define VBUSPULSE_23MS 0x21 -//#define VBUSPULSE_31MS 0x22 -#define VBUSPULSE_40MS 0x23 -// DEVICE : Minimum delay after Vbus < Vb_sess_end to enable SRP -//#define VFALLTMOUT_93MS 0x40 -//#define VFALLTMOUT_105MS 0x41 -//#define VFALLTMOUT_118MS 0x42 -#define VFALLTMOUT_131MS 0x43 -// HOST : Minimum pulse duration accepted as SRP pulse -//#define SRPMINDET_10US 0x60 -#define SRPMINDET_100US 0x61 -//#define SRPMINDET_1MS 0x62 -//#define SRPMINDET_11MS 0x63 - -//------------------------------------------------------------------------------ -// A R B I T R E R -//------------------------------------------------------------------------------ - -/// gen_usb USB common management drivers -/// These macros manage the USB controller - -/// Enable external UID pin -//#define Usb_enable_uid_pin() (UHWCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_UIDE -/// Disable external UID pin -//#define Usb_disable_uid_pin() AT91C_BASE_OTGHS->OTGHS_CTRL &= ~AT91C_OTGHS_UIDE -/// Disable external UID pin and force device mode -//#define Usb_force_device_mode() //{AT91C_BASE_OTGHS->OTGHS_CTRL &= ~AT91C_OTGHS_UIDE; - // AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_UIMOD;} -/// Disable external UID pin and force host mode -//#define Usb_force_host_mode() //{AT91C_BASE_OTGHS->OTGHS_CTRL &= ~AT91C_OTGHS_UIDE; - // AT91C_BASE_OTGHS->OTGHS_CTRL &= ~AT91C_OTGHS_UIMOD;} -/// Enable external UVCON pin -//#define Usb_enable_uvcon_pin() // (UHWCON |= (1<OTGHS_DEVCTRL |= AT91C_OTGHS_LS - -#define Usb_enable() AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_USBECTRL -#define Usb_disable() AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_USBECTRL - -/// Enable VBUS pad -//#define Usb_enable_vbus_pad() (USBCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_USBECTRL;\ - AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_OTGPADE;\ - AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_FRZCLKCTRL;} -/// Disable VBUS pad -//#define Usb_disable_vbus_pad() (USBCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_OTGPADE - -#define Usb_select_device() Usb_enable_uid_pin() -#define Usb_select_host() Usb_enable_uid_pin() -#define Is_usb_device_enabled() (AT91C_BASE_OTGHS->OTGHS_SR & AT91C_OTGHS_ID) -#define Is_usb_host_enabled() !Is_usb_device_enabled() -/// Stop internal USB clock in interface (freeze the interface register) -//#define Usb_freeze_clock() (USBCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_FRZCLKCTRL -//jcb -//#define Usb_unfreeze_clock() (USBCON &= ~(1<OTGHS_CTRL &= ~AT91C_OTGHS_FRZCLKCTRL -//#define Is_usb_clock_freezed() ((USBCON & (1<OTGHS_CTRL & AT91C_OTGHS_FRZCLKCTRL) - -//#define Usb_enable_id_interrupt() (USBCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_IDT -//#define Usb_disable_id_interrupt() (USBCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_IDT -//#define Is_usb_id_interrupt_enabled() ((USBCON & (1<OTGHS_CTRL & AT91C_OTGHS_IDT) -//#define Is_usb_id_device() ((USBSTA & (1<OTGHS_SR & AT91C_OTGHS_ID) -//#define Is_usb_id_host() ((USBSTA & (1<OTGHS_SCR = AT91C_OTGHS_IDT -//#define Is_usb_id_transition() ((USBINT & (1<OTGHS_SR & AT91C_OTGHS_IDT) - -//#define Usb_enable_vbus_interrupt() (USBCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_VBUSTI -//#define Usb_disable_vbus_interrupt() (USBCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_VBUSTI -//#define Is_usb_vbus_interrupt_enabled() ((USBCON & (1<OTGHS_CTRL & AT91C_OTGHS_VBUSTI) -//#define Is_usb_vbus_high() ((USBSTA & (1<OTGHS_SR&AT91C_OTGHS_VBUSSR)==AT91C_OTGHS_VBUSSR) -//#define Is_usb_vbus_low() ((USBSTA & (1<OTGHS_SR&AT91C_OTGHS_VBUSSR)!=AT91C_OTGHS_VBUSSR) -//#define Usb_ack_vbus_transition() (USBINT = ~(1<OTGHS_SCR = AT91C_OTGHS_VBUSTI -//#define Is_usb_vbus_transition() ((USBINT & (1<OTGHS_CTRL & AT91C_OTGHS_VBUSTI) - -/// requests for VBus activation -//#define Usb_enable_vbus() (OTGCON |= (1<OTGHS_SFR = AT91C_OTGHS_VBUSRQ //JCB -/// requests for VBus desactivation -#define Usb_disable_vbus() AT91C_BASE_OTGHS->OTGHS_SCR = AT91C_OTGHS_VBUSRQ //JCB -/// Manually request VBUS without UVCON signal from USB interface -//#define Usb_disable_uvcon_pin() (UHWCON &= ~(1<OTGHS_SFR = AT91C_OTGHS_VBUSRQ //JCB -/// Manually request VBUS OFF without UVCON signal from USB interface -//#define Usb_disable_manual_vbus() (PORTE&=~0x80,DDRE|=0x80,Usb_enable_uvcon_pin()) -#define Usb_disable_manual_vbus() AT91C_BASE_OTGHS->OTGHS_SCR = AT91C_OTGHS_VBUSRQ //JCB - -/// initiates a Host Negociation Protocol -//#define Usb_device_initiate_hnp() (OTGCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_HNPREQ -/// stops a Host Negociation Protocol -//#define Usb_device_stop_hnp() (OTGCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_HNPREQ -/// accepts a Host Negociation Protocol -//#define Usb_host_accept_hnp() (OTGCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_HNPREQ -/// rejects a Host Negociation Protocol -//#define Usb_host_reject_hnp() (OTGCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_HNPREQ -/// initiates a Session Request Protocol -//#define Usb_device_initiate_srp() (OTGCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_SRPREQ -/// selects VBus as SRP method -//#define Usb_select_vbus_srp_method() (OTGCON |= (1<OTGHS_CTRL |= AT91C_OTGHS_SRPSEL -/// selects data line as SRP method -//#define Usb_select_data_srp_method() (OTGCON &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_SRPSEL - - -/// enables hardware control on VBus -#define Usb_enable_vbus_hw_control() // AT91C_BASE_OTGHS->OTGHS_CTRL &= ~AT91C_OTGHS_VBUSHWC -/// disables hardware control on VBus -#define Usb_disable_vbus_hw_control() AT91C_BASE_OTGHS->OTGHS_CTRL |= AT91C_OTGHS_VBUSHWC -/// tests if VBus has been requested -//#define Is_usb_vbus_enabled() ((OTGCON & (1<OTGHS_SR&AT91C_OTGHS_ROLEEX) == AT91C_OTGHS_ROLEEX) -/// tests if a SRP from device occurs -//#define Is_usb_device_srp() ((OTGCON & (1<OTGHS_CTRL&AT91C_OTGHS_SRPREQ) - -/// acks suspend time out interrupt -//#define Usb_ack_suspend_time_out_interrupt() (OTGINT &= ~(1<OTGHS_SCR = AT91C_OTGHS_STO -/// enables suspend time out interrupt -//#define Usb_enable_suspend_time_out_interrupt() (OTGIEN |= (1<OTGHS_CTRL |= AT91C_OTGHS_STO -/// disables suspend time out interrupt -//#define Usb_disable_suspend_time_out_interrupt() (OTGIEN &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_STO -//#define Is_suspend_time_out_interrupt_enabled() ((OTGIEN & (1<OTGHS_CTRL&AT91C_OTGHS_STO)==AT91C_OTGHS_STO) -/// tests if a suspend time out occurs -//#define Is_usb_suspend_time_out_interrupt() ((OTGINT & (1<OTGHS_SR&AT91C_OTGHS_STO)==AT91C_OTGHS_STO) - -/// enables HNP error interrupt -//#define Usb_enable_hnp_error_interrupt() (OTGIEN |= (1<OTGHS_CTRL |= AT91C_OTGHS_HNPERR -/// disables HNP error interrupt -//#define Usb_disable_hnp_error_interrupt() (OTGIEN &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_HNPERR -//#define Is_hnp_error_interrupt_enabled() ((OTGIEN & (1<OTGHS_CTRL&AT91C_OTGHS_HNPERR)==AT91C_OTGHS_HNPERR) -/// acks HNP error interrupt -//#define Usb_ack_hnp_error_interrupt() (OTGINT &= ~(1<OTGHS_SCR |= AT91C_OTGHS_HNPERR -/// tests if a HNP error occurs -//#define Is_usb_hnp_error_interrupt() ((OTGINT & (1<OTGHS_SR&AT91C_OTGHS_HNPERR) == AT91C_OTGHS_HNPERR) - -/// enables role exchange interrupt -//#define Usb_enable_role_exchange_interrupt() (OTGIEN |= (1<OTGHS_CTRL |= AT91C_OTGHS_ROLEEX -/// disables role exchange interrupt -//#define Usb_disable_role_exchange_interrupt() (OTGIEN &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_ROLEEX -//#define Is_role_exchange_interrupt_enabled() ((OTGIEN & (1<OTGHS_CTRL&AT91C_OTGHS_ROLEEX)==AT91C_OTGHS_ROLEEX) -/// acks role exchange interrupt -//#define Usb_ack_role_exchange_interrupt() (OTGINT &= ~(1<OTGHS_SCR |= AT91C_OTGHS_ROLEEX -/// tests if a role exchange occurs -//#define Is_usb_role_exchange_interrupt() ((OTGINT & (1<OTGHS_SR&AT91C_OTGHS_ROLEEX)==AT91C_OTGHS_ROLEEX) - -/// enables B device connection error interrupt -//#define Usb_enable_bconnection_error_interrupt() (OTGIEN |= (1<OTGHS_CTRL |= AT91C_OTGHS_BCERR -/// disables B device connection error interrupt -//#define Usb_disable_bconnection_error_interrupt() (OTGIEN &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_BCERR -//#define Is_bconnection_error_interrupt_enabled() ((OTGIEN & (1<OTGHS_SCR = AT91C_OTGHS_BCERR -/// tests if a B device connection error occurs -#define Is_usb_bconnection_error_interrupt() FALSE//jcb (AT91C_BASE_OTGHS->OTGHS_SR & AT91C_OTGHS_BCERR) - -/// enables VBus error interrupt -//#define Usb_enable_vbus_error_interrupt() (OTGIEN |= (1<OTGHS_SCR = AT91C_OTGHS_VBERR -/// tests if a VBus error occurs -#define Is_usb_vbus_error_interrupt() ((AT91C_BASE_OTGHS->OTGHS_SR&AT91C_OTGHS_VBERR)==AT91C_OTGHS_VBERR) - -/// enables SRP interrupt -//#define Usb_enable_srp_interrupt() (OTGIEN |= (1<OTGHS_CTRL |= AT91C_OTGHS_SRP -/// disables SRP interrupt -//#define Usb_disable_srp_interrupt() (OTGIEN &= ~(1<OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_SRP -//#define Is_srp_interrupt_enabled() ((OTGIEN & (1<OTGHS_CTRL&AT91C_OTGHS_SRP)==AT91C_OTGHS_SRP) -/// acks SRP interrupt -#define Usb_ack_srp_interrupt() AT91C_BASE_OTGHS->OTGHS_SCR = AT91C_OTGHS_SRP -/// tests if a SRP occurs -#define Is_usb_srp_interrupt() ((AT91C_BASE_OTGHS->OTGHS_SR&AT91C_OTGHS_SRP)==AT91C_OTGHS_SRP) - - -//------------------------------------------------------------------------------ -// D E V I C E -//------------------------------------------------------------------------------ - -/// USB_device_driver USB device controller drivers -/// These macros manage the USB Device controller. - -/// test if remote wake-up still running -//#define Is_usb_pending_remote_wake_up() ((UDCON & (1<OTGHS_DEVCTRL | AT91C_OTGHS_RMWKUP) -/// acks remote wake-up -//#define Usb_ack_remote_wake_up_start() (UDINT = ~(1<OTGHS_DEVICR = AT91C_OTGHS_UPRSM - -/// enables resume interrupt -//#define Usb_enable_resume_interrupt() (UDIEN |= (1<OTGHS_DEVIDR = AT91C_OTGHS_EORSM -#define Is_resume_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_EORSM) -/// acks resume -#define Usb_ack_resume() AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_EORSM -/// tests if resume occurs -#define Is_usb_resume() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_EORSM) - -/// enables wake-up interrupt -#define Usb_enable_wake_up_interrupt() AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_WAKEUP -/// disables wake-up interrupt -#define Usb_disable_wake_up_interrupt() AT91C_BASE_OTGHS->OTGHS_DEVIDR = AT91C_OTGHS_WAKEUP -#define Is_swake_up_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_DEVIMR & AT91C_OTGHS_WAKEUP) -/// acks wake-up -#define Usb_ack_wake_up() AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_WAKEUP -/// tests if wake-up occurs -#define Is_usb_wake_up() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_WAKEUP) - -/// enables USB reset interrupt -#define Usb_enable_reset_interrupt() AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_EORST -/// disables USB reset interrupt -//#define Usb_disable_reset_interrupt() (UDIEN &= ~(1<OTGHS_DEVIMR & AT91C_OTGHS_EORST) -/// acks USB reset -#define Usb_ack_reset() AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_EORST -/// tests if USB reset occurs -#define Is_usb_reset() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_EORST) - -/// enables Start Of Frame Interrupt -#define Usb_enable_sof_interrupt() AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_SOF -/// disables Start Of Frame Interrupt -//#define Usb_disable_sof_interrupt() (UDIEN &= ~(1<OTGHS_DEVIDR = AT91C_OTGHS_SOF -#define Is_sof_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_DEVIMR & AT91C_OTGHS_SOF) -/// acks Start Of Frame -#define Usb_ack_sof() AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_SOF -/// tests if Start Of Frame occurs -#define Is_usb_sof() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_SOF) - -/// enables suspend state interrupt -#define Usb_enable_suspend_interrupt() AT91C_BASE_OTGHS->OTGHS_DEVIER = AT91C_OTGHS_SUSP -/// disables suspend state interrupt -//#define Usb_disable_suspend_interrupt() (UDIEN &= ~(1<OTGHS_DEVIDR = AT91C_OTGHS_SUSP -#define Is_suspend_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_DEVIMR & AT91C_OTGHS_SUSP) -/// acks Suspend -#define Usb_ack_suspend() AT91C_BASE_OTGHS->OTGHS_DEVICR = AT91C_OTGHS_SUSP -/// tests if Suspend state detected -#define Is_usb_suspend() (AT91C_BASE_OTGHS->OTGHS_DEVISR & AT91C_OTGHS_SUSP) - -/// returns the last frame number -//#define Usb_frame_number() ((unsigned short)((((unsigned short)UDFNUMH) << 8) | ((unsigned short)UDFNUML))) -/// tests if a crc error occurs in frame number -//#define Is_usb_frame_number_crc_error() ((UDMFN & (1<OTGHS_DEVFNUM&AT91C_OTGHS_FRAME_NUMBER)>>3) - - -// **************************************************************************** -// **************************************************************************** -// H O S T -// **************************************************************************** -// **************************************************************************** - -/// @defgroup host_management USB host controller drivers -/// These macros manage the USB Host controller. -/// @{ -/// allocates the current configuration in DPRAM memory -//#define Host_allocate_memory() (UPCFG1X |= (1<OTGHS_HSTPIPISR[pip] & AT91C_OTGHS_CFGOK))?FALSE:TRUE) - -/// enables SOF generation -//#define Host_enable_sof() (UHCON |= (1<OTGHS_HSTCTRL |= AT91C_OTGHS_SOFHST - -/// disables SOF generation -#define Host_disable_sof() AT91C_BASE_OTGHS->OTGHS_HSTCTRL &= ~(unsigned int)AT91C_OTGHS_SOFHST - -/// sends a USB Reset to the device -#define Host_send_reset() AT91C_BASE_OTGHS->OTGHS_HSTCTRL |= AT91C_OTGHS_RESET -// *AT91C_OTGHS_TSTA2 |= AT91C_OTGHS_FORCHSRST; -// *AT91C_OTGHS_TSTA2 |= AT91C_OTGHS_UTMIRESET; -// *AT91C_OTGHS_TSTA2 &= ~AT91C_OTGHS_UTMIRESET - -/// tests if USB Reset running -#define Is_host_sending_reset() (AT91C_BASE_OTGHS->OTGHS_HSTCTRL&AT91C_OTGHS_RESET) -//#define Host_is_reset() ((UHCON & (1<OTGHS_HSTCTRL&AT91C_OTGHS_RESET) -#define Is_host_reset() (AT91C_BASE_OTGHS->OTGHS_HSTCTRL&AT91C_OTGHS_RESET) - -/// sends a USB Resume to the device -#define Host_send_resume() AT91C_BASE_OTGHS->OTGHS_HSTCTRL |= AT91C_OTGHS_RESUME -/// tests if USB Resume running -//#define Host_is_resume() ((UHCON & (1<OTGHS_HSTCTRL&AT91C_OTGHS_RESUME) - -/// enables host start of frame interrupt -//#define Host_enable_sof_interrupt() (UHIEN |= (1<OTGHS_HSTIER = AT91C_OTGHS_HSOFI -/// enables host start of frame interrupt -#define Host_disable_sof_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIDR = AT91C_OTGHS_HSOFI -#define Is_host_sof_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_HSTIMR&AT91C_OTGHS_HSOFI) -/// tests if SOF detected -//#define Host_is_sof() ((UHINT & (1<OTGHS_HSTISR&AT91C_OTGHS_HSOFI) -#define Host_ack_sof() AT91C_BASE_OTGHS->OTGHS_HSTICR = AT91C_OTGHS_HSOFI - -/// enables host wake up interrupt detection -#define Host_enable_hwup_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIER = AT91C_OTGHS_HWUPI -/// disables host wake up interrupt detection -#define Host_disable_hwup_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIDR = AT91C_OTGHS_HWUPI -#define Is_host_hwup_interrupt_enabled() (AT91C_BASE_OTGHS->OTGHS_HSTIMR&AT91C_OTGHS_HWUPI) -/// tests if host wake up detected -//#define Host_is_hwup() ((UHINT & (1<OTGHS_HSTISR&AT91C_OTGHS_HWUPI) -#define Host_ack_hwup() AT91C_BASE_OTGHS->OTGHS_HSTICR = AT91C_OTGHS_HWUPI - - -/// enables host down stream rsm sent interrupt detection -#define Host_enable_down_stream_resume_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIER = AT91C_OTGHS_RSMEDI -/// disables host down stream rsm sent interrupt detection -#define Host_disable_down_stream_resume_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIDR = AT91C_OTGHS_RSMEDI -//#define Is_host_down_stream_resume_interrupt_enabled() ((UHIEN & (1<OTGHS_HSTISR&AT91C_OTGHS_RSMEDI) -//#define Host_ack_down_stream_resume() (UHINT &= ~(1<OTGHS_HSTICR = AT91C_OTGHS_RSMEDI - -/// enables host remote wake up interrupt detection -//#define Host_enable_remote_wakeup_interrupt() (UHIEN |= (1<OTGHS_HSTIER = AT91C_OTGHS_RXRSMI -/// disables host remote wake up interrupt detection -//#define Host_disable_remote_wakeup_interrupt() (UHIEN &= ~(1<OTGHS_HSTIDR = AT91C_OTGHS_RXRSMI -//#define Is_host_remote_wakeup_interrupt_enabled() ((UHIEN & (1<OTGHS_HSTISR&AT91C_OTGHS_RXRSMI) -/// tests if host wake up detected -//#define Host_is_remote_wakeup() ((UHINT & (1<OTGHS_HSTISR&AT91C_OTGHS_RXRSMI) == AT91C_OTGHS_RXRSMI) -#define Host_ack_remote_wakeup() AT91C_BASE_OTGHS->OTGHS_HSTICR = AT91C_OTGHS_RXRSMI - -#define Host_disable_device_connection_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIDR = AT91C_OTGHS_DCONN -/// enables host device connection interrupt -//#define Host_enable_device_connection_interrupt() (UHIEN |= (1<OTGHS_HSTIER = AT91C_OTGHS_DCONN -/// disables USB device connection interrupt -//#define Host_disable_device_connection_interrupt() (UHIEN &= ~(1<OTGHS_HSTIMR & AT91C_OTGHS_DCONN) -/// tests if a USB device has been detected -//#define Is_device_connection() (UHINT & (1<OTGHS_HSTISR & AT91C_OTGHS_DCONN) -#define Is_host_device_connection() (AT91C_BASE_OTGHS->OTGHS_HSTISR & AT91C_OTGHS_DCONN) -/// acks device connection -//#define Host_ack_device_connection() (UHINT = ~(1<OTGHS_HSTICR = AT91C_OTGHS_DCONN - -/// tests if a USB device has been removed -//#define Is_device_disconnection() (UHINT & (1<OTGHS_HSTISR & AT91C_OTGHS_DDIS) -/// enables host device disconnection interrupt -//#define Host_enable_device_disconnection_interrupt() (UHIEN |= (1<OTGHS_HSTIER = AT91C_OTGHS_DDIS -/// disables USB device connection interrupt -//#define Host_disable_device_disconnection_interrupt() (UHIEN &= ~(1<OTGHS_HSTIDR = AT91C_OTGHS_DDIS -//#define Is_host_device_disconnection_interrupt_enabled() ((UHIEN & (1<OTGHS_HSTIMR & AT91C_OTGHS_DDIS) -/// tests if a USB device has been removed -//#define Is_device_disconnection() (UHINT & (1<OTGHS_HSTISR & AT91C_OTGHS_DDIS) -/// acks device disconnection -//#define Host_ack_device_disconnection() (UHINT = ~(1<OTGHS_HSTICR = AT91C_OTGHS_DDIS - -#define host_get_device_descriptor_incomplete() (usb_request.uncomplete_read == TRUE) -#define Host_enable_reset_sent_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIER = AT91C_OTGHS_RSTI - - -#define Host_disable_reset_sent_interrupt() AT91C_BASE_OTGHS->OTGHS_HSTIDR = AT91C_OTGHS_RSTI -/// enables host USB reset interrupt -//#define Host_enable_reset_interrupt() (UHIEN |= (1<OTGHS_HSTIDR = AT91C_OTGHS_RSTI) -//#define Is_host_reset_interrupt_enabled() ((UHIEN & (1<OTGHS_HSTICR = AT91C_OTGHS_RSTI -/// tests if USB reset has been sent - - -/// switches on VBus -//#define Host_vbus_request() (OTGCON |= (1<OTGHS_SCR = AT91C_OTGHS_VBUSRQ //JCB -/// configures the address to use for the device -//#define Host_configure_address(addr) (UHADDR = addr & MSK_HADDR) -//#define Host_configure_address(addr) AT91C_BASE_OTGHS->OTGHS_HSTCTRL |= addr & 0x3F -//#define Host_configure_address(addr) AT91C_BASE_OTGHS->OTGHS_HSTADDR1 &= ~AT91C_OTGHS_UHADDR_P0; -// AT91C_BASE_OTGHS->OTGHS_HSTADDR1 |= (addr & AT91C_OTGHS_UHADDR_P0) - -/// Get connected device speed, returns TRUE when in full speed mode -#define Is_host_full_speed() (AT91C_BASE_OTGHS->OTGHS_SR&AT91C_OTGHS_SPEED) -/// @} - -#define Usb_disable_otg_pad() AT91C_BASE_OTGHS->OTGHS_CTRL &= ~(unsigned int)AT91C_OTGHS_OTGPADE - - - -/// @defgroup general_pipe USB pipe drivers -/// These macros manage the common features of the pipes. -/// @{ -/// selects pipe for CPU interface -//#define Host_select_pipe(p) (UPNUM = (unsigned char)p) -#define Host_select_pipe(p) global_pipe_nb = p - -/// get the currently selected pipe number -//#define Host_get_selected_pipe() (UPNUM ) -#define Host_get_selected_pipe() (global_pipe_nb) - -/// enables pipe -//#define Host_enable_pipe() (UPCONX |= (1<OTGHS_HSTPIP |= (1<OTGHS_HSTPIP &= ~(unsigned int)(1<OTGHS_HSTPIPCFG[global_pipe_nb] &= ~(unsigned int)AT91C_OTGHS_PTOKEN;\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb] |= AT91C_OTGHS_PTOKEN_SETUP -/// sets IN token -//#define Host_set_token_in() (UPCFG0X = (UPCFG0X & ~MSK_TOKEN_SETUP) | MSK_TOKEN_IN) -#define Host_set_token_in() AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb] &= ~(unsigned int)AT91C_OTGHS_PTOKEN;\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb] |= AT91C_OTGHS_PTOKEN_IN -/// sets OUT token -//#define Host_set_token_out() (UPCFG0X = (UPCFG0X & ~MSK_TOKEN_SETUP) | MSK_TOKEN_OUT) -#define Host_set_token_out() AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb] &= ~(unsigned int)AT91C_OTGHS_PTOKEN;\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb] |= AT91C_OTGHS_PTOKEN_OUT - -/// returns the number of the endpoint associated to the current pipe -//#define Host_get_endpoint_number() (UPCFG0X & (1<OTGHS_HSTPIPCFG[global_pipe_nb]&AT91C_OTGHS_PEPNUM)>>16) - -/// returns pipe interrupt register -#define Host_get_pipe_interrupt() ((AT91C_BASE_OTGHS->OTGHS_HSTISR>>8)&0x7F) - -/// sets the interrupt frequency -//#define Host_set_interrupt_frequency(pip, frq) (AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[pip]|=AT91C_OTGHS_INTFRQ&(frq<<24)) - -/// tests if current pipe is configured -#define Is_pipe_configured() (AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[global_pipe_nb]&AT91C_OTGHS_CFGOK) -/// tests if at least one bank is busy -//#define Is_host_one_bank_busy() ((UPSTAX & (1<OTGHS_HSTPIPISR[pip]&AT91C_OTGHS_NBUSYBK)!=0) -/// returns the number of busy banks -//#define Host_number_of_busy_bank() (UPSTAX & (1<OTGHS_HSTPIP|=(1<<16<OTGHS_HSTPIP&=~(unsigned int)(1<<16<OTGHS_READEPT0[global_pipe_nb << 14]=data -//#define Host_write_byte(data) (((char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0))[dBytes++])=data -#define Host_write_byte(data) pFifo[dBytes++]=data - -#define Host_write_32(data) AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0[0]=data -/// reads a byte from the pipe FIFO -//#define Host_read_byte() (UPDATX) -//#define Host_read_byte() (U8)(((char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0))[dBytes++]) -#define Host_read_byte() pFifo[dBytes++] -//#define Host_read_byte_index(pip, index) pfifo[index] = pEndpoint->pData[index++]; -//#define Host_read_32(pip) AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0[pip << 14] - -/// freezes the pipe -//#define Host_freeze_pipe() (UPCONX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_FREEZE -#define Host_freeze_pipe() AT91C_BASE_OTGHS->OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_FREEZE -/// un-freezees the pipe -//#define Host_unfreeze_pipe() (UPCONX &= ~(1<OTGHS_HSTPIPIMR[global_pipe_nb] & AT91C_OTGHS_FREEZE)); -// AT91C_BASE_OTGHS->OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_FREEZE -#define Host_unfreeze_pipe() while(!(AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[global_pipe_nb] & AT91C_OTGHS_FREEZE));\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_FREEZE -/// tests if the current pipe is frozen -//#define Is_host_pipe_freeze() (UPCONX & (1<OTGHS_HSTPIPIMR[global_pipe_nb] & AT91C_OTGHS_FREEZE) - -/// resets data toggle -#define Host_reset_pipe_data_toggle(pip) AT91C_BASE_OTGHS->OTGHS_HSTPIPIER[pip] = AT91C_OTGHS_RSTDT - -/// tests if SETUP has been sent -#define Is_host_setup_sent() (AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[0] & AT91C_OTGHS_TXSTPI) -/// tests if control IN has been received -#define Is_host_control_in_received() (AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[0] & AT91C_OTGHS_RXINI) -/// tests if control OUT has been sent -//#define Is_host_control_out_sent() ((UPINTX & (1<OTGHS_HSTPIPISR[0] & AT91C_OTGHS_TXOUT) -/// tests if a STALL has been received -//#define Is_host_stall() ((UPINTX & (1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_RXSTALL) -/// tests if an error occurs on current pipe -//#define Is_host_pipe_error() ((UPINTX & (1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_PERR) - -/// sends a setup -//#define Host_send_setup() (UPINTX &= ~(1<OTGHS_HSTPIPIDR[0] = AT91C_OTGHS_FIFOCON -/// sends a control IN -//#define Host_send_control_in() (UPINTX &= ~(1<OTGHS_HSTPIPIDR[0] = AT91C_OTGHS_FIFOCON -#define Host_send_control() AT91C_BASE_OTGHS->OTGHS_HSTPIPIDR[0] = AT91C_OTGHS_FIFOCON -/// sends a control OUT -//#define Host_send_control_out() (UPINTX &= ~(1<OTGHS_HSTPIPIDR[0] = AT91C_OTGHS_FIFOCON - -/// acks control OUT -//#define Host_ack_control_out() (UPINTX &= ~(1<OTGHS_HSTPIPICR[0] = AT91C_OTGHS_TXOUT -/// acks control IN -//#define Host_ack_control_in() (UPINTX &= ~(1<OTGHS_HSTPIPICR[0] = AT91C_OTGHS_RXINI -/// acks setup -//#define Host_ack_setup() (UPINTX &= ~(1<OTGHS_HSTPIPICR[0] = AT91C_OTGHS_TXSTPI -/// acks STALL reception -//#define Host_ack_stall() (UPINTX &= ~(1<OTGHS_HSTPIPICR[global_pipe_nb] = AT91C_OTGHS_RXSTALL - -/// sends a OUT -//#define Host_send_out() (UPINTX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_FIFOCON -/// tests if OUT has been sent -//#define Is_host_out_sent() ((UPINTX & (1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_TXOUT) -/// acks OUT sent -//#define Host_ack_out_sent() (UPINTX &= ~(1<OTGHS_HSTPIPICR[global_pipe_nb] = AT91C_OTGHS_TXOUT - -/// tests if IN received -//#define Is_host_in_received() ((UPINTX & (1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_RXINI) -/// acks IN reception -//#define Host_ack_in_received() (UPINTX &= ~(1<OTGHS_HSTPIPICR[global_pipe_nb] = AT91C_OTGHS_RXINI -/// sends a IN -//#define Host_send_in() (UPINTX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_FIFOCON -/// tests if nak handshake has been received -//#define Is_host_nak_received() ((UPINTX & (1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_NAKEDI) -/// acks NAk received sent -//#define Host_ack_nak_received() (UPINTX &= ~(1<OTGHS_HSTPIPICR[global_pipe_nb] = AT91C_OTGHS_NAKEDI - -/// tests if endpoint read allowed -//#define Is_host_read_enabled() (UPINTX&(1<OTGHS_HSTPIPISR[global_pipe_nb] & AT91C_OTGHS_RWALL) -/// tests if endpoint read allowed -//#define Is_host_write_enabled() (UPINTX&(1<OTGHS_HSTPIPINRQ[global_pipe_nb] &= ~(unsigned int)AT91C_OTGHS_INMOD -/// sets IN in continuous mode -//#define Host_continuous_in_mode() (UPCONX |= (1<OTGHS_HSTPIPINRQ[global_pipe_nb] |= AT91C_OTGHS_INMOD - -/// sets number of IN requests to perform before freeze -//#define Host_in_request_number(in_num) (UPINRQX = (unsigned char)in_num) -#define Host_in_request_number(pip, in_num) AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[pip] &= ~(unsigned int)AT91C_OTGHS_INMOD;\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[pip] &= ~(unsigned int)AT91C_OTGHS_INRQ;\ - AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[pip] |= in_num -/// returns number of remaining IN requests -//#define Host_get_in_request_number() (UPINRQX) - -/// returns number of bytes (8 bits) -//#define Host_data_length_U8() (UPBCLX) -#define Host_data_length_U8() (unsigned short)((AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[global_pipe_nb]&AT91C_OTGHS_PBYCT)>>20) -#define UPBCLX (unsigned short)((AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[global_pipe_nb]&AT91C_OTGHS_PBYCT)>>20) - -/// returns number of bytes (16 bits) -//#define Host_data_length_U16() ((((unsigned short)UPBCHX)<<8) | UPBCLX) -#define Host_data_length_U16() (unsigned short)((AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[global_pipe_nb]&AT91C_OTGHS_PBYCT)>>20) -/// for device compatibility -//#define Host_byte_counter() Host_data_length_U16() -#define Host_byte_counter() Host_data_length_U16() -/// for device compatibility -//#define Host_byte_counter_8() Host_data_length_U8() - -/// returns the size of the current pipe -//#define Host_get_pipe_length() ((unsigned short)0x08 << ((UPCFG1X & MSK_PSIZE)>>4)) -//#define Host_get_pipe_length() (unsigned short)(((AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb]&AT91C_OTGHS_PSIZE)>>4)? -// (8<<((AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb]&AT91C_OTGHS_PSIZE)>>4)):8) - -/// returns the type of the current pipe -//#define Host_get_pipe_type() (UPCFG0X>>6) -#define Host_get_pipe_type() ((AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[global_pipe_nb]&AT91C_OTGHS_PTYPE)>>12) - -/// tests if error occurs on pipe -//#define Host_error_status() (UPERRX & MSK_ERROR) -#define Host_error_status() (unsigned long)(AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[global_pipe_nb]) -/// acks all pipe error -//#define Host_ack_all_errors() (UPERRX = 0x00) -#define Host_ack_all_errors() AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[global_pipe_nb] = 0 - -/// Enable pipe end transmission interrupt -//#define Host_enable_transmit_interrupt() (UPIENX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_TXOUT -/// Disable pipe end transmission interrupt -//#define Host_disable_transmit_interrupt() (UPIENX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_TXOUT - -/// Enable pipe reception interrupt -//#define Host_enable_receive_interrupt() (UPIENX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_RXINI -/// Disable pipe recption interrupt -//#define Host_disable_receive_interrupt() (UPIENX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_RXINI - -/// Enable pipe stall interrupt -//#define Host_enable_stall_interrupt() (UPIENX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_RXSTALL -/// Disable pipe stall interrupt -//#define Host_disable_stall_interrupt() (UPIENX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_RXSTALL - -/// Enable pipe error interrupt -//#define Host_enable_error_interrupt() (UPIENX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_PERR -/// Disable pipe error interrupt -//#define Host_disable_error_interrupt() (UPIENX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_PERR - -/// Enable pipe NAK interrupt -//#define Host_enable_nak_interrupt() (UPIENX |= (1<OTGHS_HSTPIPIER[global_pipe_nb] = AT91C_OTGHS_NAKEDI -/// Disable pipe NAK interrupt -//#define Host_disable_nak_interrupt() (UPIENX &= ~(1<OTGHS_HSTPIPIDR[global_pipe_nb] = AT91C_OTGHS_NAKEDI - -//#define Get_pipe_token(x) ((x & (0x80)) ? TOKEN_IN : TOKEN_OUT) -#define Get_pipe_token(x) ((x & (0x80)) ? TOKEN_IN : TOKEN_OUT) - - -//_____ D E C L A R A T I O N ______________________________________________ - -extern unsigned char dev_configure_endpoint(unsigned char ept, - unsigned char type, - unsigned char dir, - unsigned char size, - unsigned char bank, - unsigned char nyet); - - -extern unsigned char usb_select_enpoint_interrupt (void); -extern unsigned char usb_send_packet(unsigned char, unsigned char*, unsigned char); -extern unsigned char usb_read_packet(unsigned char, unsigned char*, unsigned char); - -extern unsigned char host_config_pipe(unsigned char, unsigned char); -extern unsigned char host_determine_pipe_size(unsigned short); -extern void host_disable_all_pipe(void); -extern unsigned char host_get_nb_pipe_interrupt(void); -extern U16 host_get_pipe_length(void); -extern void host_configure_address( unsigned char pipe, unsigned char addr); - -#endif // _USB_DRV_H - diff --git a/src/ersky9x/libraries/usb/otg/usb_host_enum.c b/src/ersky9x/libraries/usb/otg/usb_host_enum.c deleted file mode 100644 index 69c9ba59f..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_host_enum.c +++ /dev/null @@ -1,670 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -/// This file manages the host enumeration process - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include "usb/otg/usb_drv.h" -#include "usb_host_enum.h" -#include "usb/otg/usb_task.h" -#include "usb_host_task.h" -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#if (MAX_INTERFACE_SUPPORTED<1) -#error MAX_INTERFACE_SUPPORTED<1 : The host controller should support at least one interface... -#endif - -#ifndef VID_PID_TABLE - #error VID_PID_TABLE should be defined somewhere (conf_usb.h) - // VID_PID_TABLE format definition: - // #define VID_PID_TABLE {VID1, number_of_pid_for_this_VID1, PID11_value,..., PID1X_Value - // ... - // ,VIDz, number_of_pid_for_this_VIDz, PIDz1_value,..., PIDzX_Value} -#endif - -#ifndef CLASS_SUBCLASS_PROTOCOL - #error CLASS_SUBCLASS_PROTOCOL shoud be defined somewhere (conf_usb.h) - // CLASS_SUBCLASS_PROTOCOL format definition: - // #define CLASS_SUBCLASS_PROTOCOL {CLASS1, SUB_CLASS1,PROTOCOL1, - // ... - // CLASSz, SUB_CLASSz,PROTOCOLz} -#endif - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -//! Const table of known devices (see conf_usb.h for table content) -U16 registered_VID_PID[] = VID_PID_TABLE; - -//! Const table of known class (see conf_usb.h for table content) -U8 registered_class[] = CLASS_SUBCLASS_PROTOCOL; - -//! Physical EP to address device endpoints look-up table -// This table is dynamically built with the "host_configure_endpoint_class" function -U8 ep_table[MAX_EP_NB]={0,0,0,0,0,0,0}; - -//! The number of interface the host is able to support in the device connected -U8 nb_interface_supported=0; - -S_interface interface_supported[MAX_INTERFACE_SUPPORTED]; - -//! PID of device connected -U16 device_PID; -//! VID of device connected -U16 device_VID; -//! bmAttributes byte of the connected device -U8 bmattributes; -//! maxpower byte of the connected device (Caution, unit is 2mA) -U8 maxpower; - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// checks if the VID and the PID are supported -/// (if the VID/PID belongs to the VID_PID table) -//------------------------------------------------------------------------------ -U8 host_check_VID_PID(void) -{ - U8 nb_of_vid; - U8 nb_of_pid; - - TRACE_DEBUG("host_check_VID_PID\n\r"); - // Rebuild VID PID from data stage - LSB(device_VID) = data_stage[OFFSET_FIELD_LSB_VID]; - MSB(device_VID) = data_stage[OFFSET_FIELD_MSB_VID]; - LSB(device_PID) = data_stage[OFFSET_FIELD_LSB_PID]; - MSB(device_PID) = data_stage[OFFSET_FIELD_MSB_PID]; - - // Compare detected VID PID with supported table - nb_of_vid=0; - while (nb_of_vid< sizeof(registered_VID_PID)/2) // /2 because registered_VID_PID table is U16... - { - TRACE_DEBUG("registered_VID_PID[%d]: 0x%X\n\r", nb_of_vid, registered_VID_PID[nb_of_vid]); - TRACE_DEBUG("device_VID: 0x%X\n\r", device_VID); - if (registered_VID_PID[nb_of_vid] == device_VID) // VID is correct - { - TRACE_DEBUG("Good VID\n\r"); - nb_of_pid = (U8)registered_VID_PID[nb_of_vid+1]; // store nb of PID for this VID - while (nb_of_pid != 0) - { - TRACE_DEBUG("registered_VID_PID[%d]: 0x%X\n\r", nb_of_vid+nb_of_pid+1, registered_VID_PID[nb_of_vid+nb_of_pid+1]); - TRACE_DEBUG("device_PID: 0x%X\n\r", device_PID); - if (registered_VID_PID[nb_of_vid+nb_of_pid+1] == device_PID) - { - TRACE_DEBUG("Good PID\n\r"); - return HOST_TRUE; - } - nb_of_pid--; - } - } - nb_of_vid+=registered_VID_PID[nb_of_vid+1]+2; - } - return HOST_FALSE; -} - - -//------------------------------------------------------------------------------ -/// checks if the device class is supported. -/// The function looks in all interface declared in the received dewcriptors, if -/// one of them match with the CLASS/SUB_CLASS/PROTOCOL table -//------------------------------------------------------------------------------ -U8 host_check_class(void) -{ - U8 class_table; - T_DESC_OFFSET descriptor_offset; - T_DESC_OFFSET conf_offset_end; - U16 config_size; - U8 device_class; - U8 device_subclass; - U8 device_protocol; - - TRACE_DEBUG("host_check_class\n\r"); - nb_interface_supported=0; //First asumes ,no interface is supported! - if (data_stage[OFFSET_FIELD_DESCRIPTOR_TYPE] != USBGenericDescriptor_CONFIGURATION) // check if configuration descriptor - { - TRACE_DEBUG("host_check_class problem\n\r"); - return HOST_FALSE; - } - LSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT]; - MSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT+1]; - bmattributes = data_stage[OFFSET_FIELD_BMATTRIBUTES]; - maxpower = data_stage[OFFSET_FIELD_MAXPOWER]; - descriptor_offset = 0; - conf_offset_end = descriptor_offset + config_size; - - // Look in all interfaces declared in the configuration - while(descriptor_offset < conf_offset_end) - { - // Find next interface descriptor - while (data_stage[descriptor_offset+OFFSET_FIELD_DESCRIPTOR_TYPE] != USBGenericDescriptor_INTERFACE) - { - descriptor_offset += data_stage[descriptor_offset]; - if(descriptor_offset >= conf_offset_end) - { - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem2\n\r"); - return HOST_FALSE; - } - } - } - // Found an interface descriptor - // Get charateristics of this interface - device_class = data_stage[descriptor_offset + OFFSET_FIELD_CLASS]; - device_subclass = data_stage[descriptor_offset + OFFSET_FIELD_SUB_CLASS]; - device_protocol = data_stage[descriptor_offset + OFFSET_FIELD_PROTOCOL]; - // Look in registered class table for match - class_table=0; - while (class_table< sizeof(registered_class)) - { - if (registered_class[class_table] == device_class) // class is correct! - { - if (registered_class[class_table+1] == device_subclass) // sub class is correct! - { - if (registered_class[class_table+2] == device_protocol) // protocol is correct! - { - // Prepare for another item CLASS/SUB_CLASS/PROTOCOL in table - class_table+=3; - // Store this interface as supported interface - // Memorize its interface nb - interface_supported[nb_interface_supported].interface_nb=data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB]; - // its alternate setting - interface_supported[nb_interface_supported].altset_nb=data_stage[descriptor_offset+OFFSET_FIELD_ALT]; - // its USB class - interface_supported[nb_interface_supported].class=device_class; - // its USB subclass - interface_supported[nb_interface_supported].subclass=device_subclass; - // its USB protocol - interface_supported[nb_interface_supported].protocol=device_protocol; - // the number of endpoints associated to this interface - // Note: The associated endpoints addresses are stored during pipe attribution... - interface_supported[nb_interface_supported].nb_ep=data_stage[descriptor_offset+OFFSET_FIELS_NB_OF_EP]; - // Update the number of interface supported - nb_interface_supported++; - // Check the maximum number of interfaces we can support - if(nb_interface_supported>=MAX_INTERFACE_SUPPORTED) - { - TRACE_DEBUG("host_check_class ok1\n\r"); - return HOST_TRUE; - } - } - } - } - class_table+=3; // Check other item CLASS/SUB_CLASS/PROTOCOL in table - } - descriptor_offset += data_stage[descriptor_offset]; // Next descriptor - if(descriptor_offset > SIZEOF_DATA_STAGE) // Check overflow - { - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok3\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem3\n\r"); - return HOST_FALSE; - } - } - } - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok4\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem4\n\r"); - return HOST_FALSE; - } -} - -//------------------------------------------------------------------------------ -/// configures the pipe according to the device class of the -//------------------------------------------------------------------------------ -U8 host_auto_configure_endpoint(void) -{ - U8 nb_endpoint_to_configure; - T_DESC_OFFSET descriptor_offset; - U8 physical_pipe=1; // =1 cause lookup table assumes that physiacl pipe 0 is reserved for control - U8 i; - U8 ep_index; - - TRACE_DEBUG("host_auto_configure_endpoint\n\r"); - // For all interfaces to configure... - for(i=0;i SIZEOF_DATA_STAGE) // No more endpoint descriptor found -> Errror ! - { - TRACE_DEBUG("PB\n\r"); - return HOST_FALSE; - } - } - - // Select the new physical pipe to configure and get ride of any previous configuration for this physical pipe - Host_select_pipe(physical_pipe); - Host_disable_pipe(); - Host_enable_pipe(); - - // Build the pipe configuration according to the endpoint descriptors fields received - // - // host_configure_pipe( - // physical_pipe, // pipe nb in USB interface - // data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE], // pipe type (interrupt/BULK/ISO) - // Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]), // pipe addr - // (data_stage[descriptor_offset+2] & MSK_EP_DIR), // pipe dir (IN/OUT) - // host_determine_pipe_size((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE]),// pipe size - // ONE_BANK, // bumber of bank to allocate for pipe - // data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL] // interrupt period (for interrupt pipe) - // ); - - host_configure_pipe( - physical_pipe, - data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE], - Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]), - (data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR] & MSK_EP_DIR), - host_determine_pipe_size( - (U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE_LOW] - + (((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE_HIGH])<<8)), - ONE_BANK, - data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL] ); - - host_configure_address(physical_pipe, DEVICE_ADDRESS); - - // Update Physical Pipe lookup table with device enpoint address - ep_table[physical_pipe]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]; - physical_pipe++; - // Update endpoint addr table in supported interface structure - interface_supported[i].ep_addr[ep_index++]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]; - descriptor_offset += data_stage[descriptor_offset]; // pointing on next descriptor - - // All target endpoints configured ? - nb_endpoint_to_configure--; - } //for(i=0;i SIZEOF_DATA_STAGE) - { - return HOST_FALSE; - } - } - if (data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB]==interface - && data_stage[descriptor_offset+OFFSET_FIELD_ALT]==alt) - { - return descriptor_offset; - } - descriptor_offset += data_stage[descriptor_offset]; - } - return descriptor_offset; -} - -//------------------------------------------------------------------------------ -/// returns the physical pipe number linked to a logical endpoint address. -//------------------------------------------------------------------------------ -U8 host_get_hwd_pipe_nb(U8 ep_addr) -{ - U8 i; - - for(i=0; iOTGHS_HSTPIPISR[0] & AT91C_OTGHS_TXSTPI) != 0); - // Freeze the pipe - Host_freeze_pipe(); - - status=(CONTROL_GOOD); - goto host_send_control_end; - } - - // OUT request management --------------------------------------------- - else // Data stage OUT (bmRequestType==0) - { - Host_set_token_out(); - Host_ack_control_out(); - while(data_length != 0) - { - Host_unfreeze_pipe(); - status = host_get_pipe_length(); - if ( (U16)status > data_length) - { - status = (U8)data_length; - data_length = 0; - } - else - { - data_length -= status; - } - Address_fifochar_endpoint(global_pipe_nb); - while (status!=0) - { - Host_write_byte(*data_pointer); - data_pointer++; - status--; - } - Host_send_control_out(); - while (!Is_host_control_out_sent()) - { - if (Is_host_emergency_exit()) - { - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if(Is_host_pipe_error()) - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_control_end; - } - if(Is_host_stall()) - { - status=CONTROL_STALL; - Host_ack_stall(); - goto host_send_control_end; - } - } - Host_ack_control_out(); - } // end of OUT data stage - Host_freeze_pipe(); - Host_set_token_in(); - Host_unfreeze_pipe(); - while(!Is_host_control_in_received()) - { - if (Is_host_emergency_exit()) - { - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if(Is_host_pipe_error()) - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_control_end; - } - if(Is_host_stall()) - { - status=CONTROL_STALL; - Host_ack_stall(); - goto host_send_control_end; - } - } - Host_ack_control_in(); - Host_freeze_pipe(); - Host_send_control_in(); - status=(CONTROL_GOOD); - goto host_send_control_end; - } - -host_send_control_end: - return ((U8)status); -} - - diff --git a/src/ersky9x/libraries/usb/otg/usb_host_enum.h b/src/ersky9x/libraries/usb/otg/usb_host_enum.h deleted file mode 100644 index 959cb52f7..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_host_enum.h +++ /dev/null @@ -1,329 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -#ifndef _USB_HOST_ENUM_H_ -#define _USB_HOST_ENUM_H_ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#ifndef SIZEOF_DATA_STAGE - #error SIZEOF_DATA_STAGE should be defined in conf_usb.h -#endif - -#if (SIZEOF_DATA_STAGE<0xFF) //! Optimize descriptor offset index according to data_stage[] size - #define T_DESC_OFFSET U8 //! U8 is enought and faster -#else - #define T_DESC_OFFSET U16 //! U16 required ! -#endif - -#ifndef MAX_EP_PER_INTERFACE - #define MAX_EP_PER_INTERFACE 4 -#endif - - - - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ -typedef struct -{ - U8 bmRequestType; //!< Characteristics of the request - U8 bRequest; //!< Specific request - U16 wValue; //!< field that varies according to request - U16 wIndex; //!< field that varies according to request - U16 wLength; //!< Number of bytes to transfer if Data - U8 uncomplete_read; //!< 1 = only one read -} S_usb_setup_data; - - -typedef struct -{ - U8 interface_nb; - U8 altset_nb; - U16 class; - U16 subclass; - U16 protocol; - U8 nb_ep; - U8 ep_addr[MAX_EP_PER_INTERFACE]; -} S_interface; - -#define CONTROL_GOOD 0 -#define CONTROL_TIMEOUT 0x08 -#define CONTROL_STALL 0x20 - - -//!< Set of defines for offset in data stage -#define OFFSET_FIELD_MAXPACKETSIZE 7 -#define OFFSET_FIELD_MSB_VID 9 -#define OFFSET_FIELD_LSB_VID 8 -#define OFFSET_FIELD_MSB_PID 11 -#define OFFSET_FIELD_LSB_PID 10 - -#define OFFSET_DESCRIPTOR_LENGHT 0 -#define OFFSET_FIELD_DESCRIPTOR_TYPE 1 -#define OFFSET_FIELD_TOTAL_LENGHT 2 -#define OFFSET_FIELD_BMATTRIBUTES 7 -#define OFFSET_FIELD_MAXPOWER 8 - -#define OFFSET_FIELD_OTG_FEATURES 2 -#define OTG_DESCRIPTOR_bLength 0x03 - -//! OFFSET for INTERFACE DESCRIPTORS -#define OFFSET_FIELD_INTERFACE_NB 2 -#define OFFSET_FIELD_ALT 3 -#define OFFSET_FIELS_NB_OF_EP 4 -#define OFFSET_FIELD_NB_INTERFACE 4 // Nb of endpoint used by this interface -#define OFFSET_FIELD_CLASS 5 -#define OFFSET_FIELD_SUB_CLASS 6 -#define OFFSET_FIELD_PROTOCOL 7 - - -#define OFFSET_FIELD_EP_ADDR 2 -#define OFFSET_FIELD_EP_TYPE 3 -#define OFFSET_FIELD_EP_SIZE_LOW 4 -#define OFFSET_FIELD_EP_SIZE_HIGH 5 -#define OFFSET_FIELD_EP_INTERVAL 6 - -//! defines for Hub detection -#define OFFSET_DEV_DESC_CLASS 4 // offset for the CLASS field in the Device Descriptor -#define HUB_CLASS_CODE 9 // value of Hub CLASS - - -#define HOST_FALSE 0 -#define HOST_TRUE 1 - - -//----------------------------------------------------------------------------- -// Exported macro -//----------------------------------------------------------------------------- - -/// send a clear endpoint request -#define host_clear_endpoint_feature(ep) (usb_request.bmRequestType = 0x02,\ - usb_request.bRequest = USBGenericRequest_CLEARFEATURE,\ - usb_request.wValue = USBFeatureRequest_ENDPOINTHALT << 8,\ - usb_request.wIndex = ep,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// send a get configuration request -#define host_get_configuration() (usb_request.bmRequestType = 0x80,\ - usb_request.bRequest = USBGenericRequest_GETCONFIGURATION,\ - usb_request.wValue = 0,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 1,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// send a set configuration request -#define host_set_configuration(cfg_nb) (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETCONFIGURATION,\ - usb_request.wValue = cfg_nb,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// send a set interface request to specify a specific alt setting for an -/// interface -#define host_set_interface(interface_nb,alt_setting) \ - (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETINTERFACE,\ - usb_request.wValue = alt_setting,\ - usb_request.wIndex = interface_nb,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -/// send a get device desriptor request. -/// The descriptor table received is stored in data_stage array. -/// The received descriptors is limited to the control pipe lenght -#define host_get_device_descriptor_uncomplete() \ - (usb_request.bmRequestType = 0x80,\ - usb_request.bRequest = USBGenericRequest_GETDESCRIPTOR,\ - usb_request.wValue = USBGenericDescriptor_DEVICE << 8,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 64,\ - usb_request.uncomplete_read = TRUE,\ - host_send_control(data_stage)) - -/// send a get device desriptor request. -/// The descriptor table received is stored in data_stage array. -#define host_get_device_descriptor() (usb_request.bmRequestType = 0x80,\ - usb_request.bRequest = USBGenericRequest_GETDESCRIPTOR,\ - usb_request.wValue = USBGenericDescriptor_DEVICE << 8,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 18,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// send a get device configuration request. -/// The configuration descriptor table received is stored in data_stage array. -#define host_get_configuration_descriptor()(usb_request.bmRequestType = 0x80,\ - usb_request.bRequest = USBGenericRequest_GETDESCRIPTOR,\ - usb_request.wValue = USBGenericDescriptor_CONFIGURATION << 8,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 255,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -#define host_get_descriptor_uncomplete() (usb_request.bmRequestType = 0x80,\ - usb_request.bRequest = USBGenericRequest_GETDESCRIPTOR,\ - usb_request.wValue = 0,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 64,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// send a set address request. -#define host_set_address(addr) (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETADDRESS,\ - usb_request.wValue = (U16)addr,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -/// send a set feature device remote wakeup -#define host_set_feature_remote_wakeup() (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETFEATURE,\ - usb_request.wValue = 1,\ - usb_request.wIndex = 1,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -/// send a set feature "a_hnp_support" to tell to B-Device that A-Device support HNP -#define host_set_feature_a_hnp_support() (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETFEATURE,\ - usb_request.wValue = 4,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -/// send a set feature "b_hnp_enable" to make B-Device initiating a HNP -#define host_set_feature_b_hnp_enable() (usb_request.bmRequestType = 0x00,\ - usb_request.bRequest = USBGenericRequest_SETFEATURE,\ - usb_request.wValue = 3,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 0,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) - -/// send the mass storage specific request "get max lun" -#define host_ms_get_max_lun() (usb_request.bmRequestType = 0xA1,\ - usb_request.bRequest = MS_GET_MAX_LUN,\ - usb_request.wValue = 0,\ - usb_request.wIndex = 0,\ - usb_request.wLength = 1,\ - usb_request.uncomplete_read = FALSE,\ - host_send_control(data_stage)) -/// returns the VID of the device connected -#define Get_VID() (device_VID) - -/// returns the PID of the device connected -#define Get_PID() (device_PID) - -/// returns the maximum power consumption ot hte connected device (unit is 2mA) -#define Get_maxpower() (maxpower) - -/// returns the USB class associated to the specified interface -#define Get_class(s_interface) (interface_supported[s_interface].class) - -/// returns the USB subclass associated to the specified interface -#define Get_subclass(s_interface) (interface_supported[s_interface].subclass) - -/// returns the USB protocol associated to the specified interface -#define Get_protocol(s_interface) (interface_supported[s_interface].protocol) - -/// returns endpoint address associated to the specified interface and -/// endpoint number in this interface. -#define Get_ep_addr(s_interface,n_ep) (interface_supported[s_interface].ep_addr[n_ep]) - -/// returns number of endpoints associated to -#define Get_nb_ep(s_interface) (interface_supported[s_interface].nb_ep) - -/// returns number of the alternate setting field associated to -#define Get_alts_s(s_interface) (interface_supported[s_interface].altset_nb) - -/// returns number of the interface number associated to -#define Get_interface_number(s_interface) (interface_supported[s_interface].interface_nb) - -/// returns the number of interface supported in the device connected -#define Get_nb_supported_interface() (nb_interface_supported) - -#define BIT_SELF_POWERED 6 // offset -/// returns true if the device connected is self powered -#define Is_device_self_powered() ((bmattributes & (1< -#include "usb/otg/usb_drv.h" -#include "usb_host_enum.h" -#include "usb/otg/usb_task.h" -#include "usb_host_task.h" -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#if (MAX_INTERFACE_SUPPORTED<1) -#error MAX_INTERFACE_SUPPORTED<1 : The host controller should support at least one interface... -#endif - -#ifndef VID_PID_TABLE - #error VID_PID_TABLE should be defined somewhere (conf_usb.h) - // VID_PID_TABLE format definition: - // #define VID_PID_TABLE {VID1, number_of_pid_for_this_VID1, PID11_value,..., PID1X_Value - // ... - // ,VIDz, number_of_pid_for_this_VIDz, PIDz1_value,..., PIDzX_Value} -#endif - -#ifndef CLASS_SUBCLASS_PROTOCOL - #error CLASS_SUBCLASS_PROTOCOL shoud be defined somewhere (conf_usb.h) - // CLASS_SUBCLASS_PROTOCOL format definition: - // #define CLASS_SUBCLASS_PROTOCOL {CLASS1, SUB_CLASS1,PROTOCOL1, - // ... - // CLASSz, SUB_CLASSz,PROTOCOLz} -#endif - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -//! Const table of known devices (see conf_usb.h for table content) -U16 registered_VID_PID[] = VID_PID_TABLE; - -//! Const table of known class (see conf_usb.h for table content) -U8 registered_class[] = CLASS_SUBCLASS_PROTOCOL; - -//! Physical EP to address device endpoints look-up table -// This table is dynamically built with the "host_configure_endpoint_class" function -U8 ep_table[MAX_EP_NB]={0,0,0,0,0,0,0}; - -//! The number of interface the host is able to support in the device connected -U8 nb_interface_supported=0; - -S_interface interface_supported[MAX_INTERFACE_SUPPORTED]; - -//! PID of device connected -U16 device_PID; -//! VID of device connected -U16 device_VID; -//! bmAttributes byte of the connected device -U8 bmattributes; -//! maxpower byte of the connected device (Caution, unit is 2mA) -U8 maxpower; - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// checks if the VID and the PID are supported -/// (if the VID/PID belongs to the VID_PID table) -//------------------------------------------------------------------------------ -U8 host_check_VID_PID(void) -{ - U8 nb_of_vid; - U8 nb_of_pid; - - TRACE_DEBUG("host_check_VID_PID\n\r"); - // Rebuild VID PID from data stage - LSB(device_VID) = data_stage[OFFSET_FIELD_LSB_VID]; - MSB(device_VID) = data_stage[OFFSET_FIELD_MSB_VID]; - LSB(device_PID) = data_stage[OFFSET_FIELD_LSB_PID]; - MSB(device_PID) = data_stage[OFFSET_FIELD_MSB_PID]; - - // Compare detected VID PID with supported table - nb_of_vid=0; - while (nb_of_vid< sizeof(registered_VID_PID)/2) // /2 because registered_VID_PID table is U16... - { - TRACE_DEBUG("registered_VID_PID[%d]: 0x%X\n\r", nb_of_vid, registered_VID_PID[nb_of_vid]); - TRACE_DEBUG("device_VID: 0x%X\n\r", device_VID); - if (registered_VID_PID[nb_of_vid] == device_VID) // VID is correct - { - TRACE_DEBUG("Good VID\n\r"); - nb_of_pid = (U8)registered_VID_PID[nb_of_vid+1]; // store nb of PID for this VID - while (nb_of_pid != 0) - { - TRACE_DEBUG("registered_VID_PID[%d]: 0x%X\n\r", nb_of_vid+nb_of_pid+1, registered_VID_PID[nb_of_vid+nb_of_pid+1]); - TRACE_DEBUG("device_PID: 0x%X\n\r", device_PID); - if (registered_VID_PID[nb_of_vid+nb_of_pid+1] == device_PID) - { - TRACE_DEBUG("Good PID\n\r"); - return HOST_TRUE; - } - nb_of_pid--; - } - } - nb_of_vid+=registered_VID_PID[nb_of_vid+1]+2; - } - return HOST_FALSE; -} - -//------------------------------------------------------------------------------ -/// checks if the OTG descriptor has been received and -/// indicates which features are supported -//------------------------------------------------------------------------------ -U8 host_check_OTG_features(void) -{ - U8 index; // variable offset used to search the OTG descriptor - U8 nb_bytes; // number of bytes of the config descriptor - - TRACE_DEBUG("host_check_OTG_features\n\r"); - Peripheral_is_not_otg_device(); // init - otg_features_supported = 0; - - nb_bytes = data_stage[OFFSET_FIELD_TOTAL_LENGHT]; - index = 0; - if (nb_bytes > 0x09) // check this is not a reduced/uncomplete config descriptor - { - while (index < nb_bytes) // search in the descriptors - { - if (data_stage[index+OFFSET_FIELD_DESCRIPTOR_TYPE] != USBGenericDescriptor_OTG) // IS the pointed descriptor THE OTG DESCRIPTOR ? - { - index += data_stage[index+OFFSET_DESCRIPTOR_LENGHT]; // NO, skip to next descriptor - } - else - { - if (data_stage[index+OFFSET_DESCRIPTOR_LENGHT] == OTG_DESCRIPTOR_bLength) // YES, check descriptor length - { - Peripheral_is_otg_device(); // an OTG descriptor has been found - otg_features_supported = data_stage[index+OFFSET_FIELD_OTG_FEATURES]; // load otg features supported - TRACE_DEBUG("OK\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("PB\n\r"); - return HOST_FALSE; // bad descriptor length - } - } - } - } - else - { - TRACE_DEBUG("PB1\n\r"); - return HOST_FALSE; // this was only a reduced/uncomplete configuration descriptor - } - TRACE_DEBUG("OK1\n\r"); - return HOST_TRUE; -} - - -//------------------------------------------------------------------------------ -/// checks if the device class is supported. -/// The function looks in all interface declared in the received dewcriptors, if -/// one of them match with the CLASS/SUB_CLASS/PROTOCOL table -//------------------------------------------------------------------------------ -U8 host_check_class(void) -{ - U8 class_table; - T_DESC_OFFSET descriptor_offset; - T_DESC_OFFSET conf_offset_end; - U16 config_size; - U8 device_class; - U8 device_subclass; - U8 device_protocol; - - TRACE_DEBUG("host_check_class\n\r"); - nb_interface_supported=0; //First asumes ,no interface is supported! - if (data_stage[OFFSET_FIELD_DESCRIPTOR_TYPE] != USBGenericDescriptor_CONFIGURATION) // check if configuration descriptor - { - TRACE_DEBUG("host_check_class problem\n\r"); - return HOST_FALSE; - } - LSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT]; - MSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT+1]; - bmattributes = data_stage[OFFSET_FIELD_BMATTRIBUTES]; - maxpower = data_stage[OFFSET_FIELD_MAXPOWER]; - descriptor_offset = 0; - conf_offset_end = descriptor_offset + config_size; - - // Look in all interfaces declared in the configuration - while(descriptor_offset < conf_offset_end) - { - // Find next interface descriptor - while (data_stage[descriptor_offset+OFFSET_FIELD_DESCRIPTOR_TYPE] != USBGenericDescriptor_INTERFACE) - { - descriptor_offset += data_stage[descriptor_offset]; - if(descriptor_offset >= conf_offset_end) - { - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem2\n\r"); - return HOST_FALSE; - } - } - } - // Found an interface descriptor - // Get charateristics of this interface - device_class = data_stage[descriptor_offset + OFFSET_FIELD_CLASS]; - device_subclass = data_stage[descriptor_offset + OFFSET_FIELD_SUB_CLASS]; - device_protocol = data_stage[descriptor_offset + OFFSET_FIELD_PROTOCOL]; - // Look in registered class table for match - class_table=0; - while (class_table< sizeof(registered_class)) - { - if (registered_class[class_table] == device_class) // class is correct! - { - if (registered_class[class_table+1] == device_subclass) // sub class is correct! - { - if (registered_class[class_table+2] == device_protocol) // protocol is correct! - { - // Prepare for another item CLASS/SUB_CLASS/PROTOCOL in table - class_table+=3; - // Store this interface as supported interface - // Memorize its interface nb - interface_supported[nb_interface_supported].interface_nb=data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB]; - // its alternate setting - interface_supported[nb_interface_supported].altset_nb=data_stage[descriptor_offset+OFFSET_FIELD_ALT]; - // its USB class - interface_supported[nb_interface_supported].class=device_class; - // its USB subclass - interface_supported[nb_interface_supported].subclass=device_subclass; - // its USB protocol - interface_supported[nb_interface_supported].protocol=device_protocol; - // the number of endpoints associated to this interface - // Note: The associated endpoints addresses are stored during pipe attribution... - interface_supported[nb_interface_supported].nb_ep=data_stage[descriptor_offset+OFFSET_FIELS_NB_OF_EP]; - // Update the number of interface supported - nb_interface_supported++; - // Check the maximum number of interfaces we can support - if(nb_interface_supported>=MAX_INTERFACE_SUPPORTED) - { - TRACE_DEBUG("host_check_class ok1\n\r"); - return HOST_TRUE; - } - } - } - } - class_table+=3; // Check other item CLASS/SUB_CLASS/PROTOCOL in table - } - descriptor_offset += data_stage[descriptor_offset]; // Next descriptor - if(descriptor_offset > SIZEOF_DATA_STAGE) // Check overflow - { - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok3\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem3\n\r"); - return HOST_FALSE; - } - } - } - if(nb_interface_supported) - { - TRACE_DEBUG("host_check_class ok4\n\r"); - return HOST_TRUE; - } - else - { - TRACE_DEBUG("host_check_class problem4\n\r"); - return HOST_FALSE; - } -} - -//------------------------------------------------------------------------------ -/// configures the pipe according to the device class of the -//------------------------------------------------------------------------------ -U8 host_auto_configure_endpoint(void) -{ - U8 nb_endpoint_to_configure; - T_DESC_OFFSET descriptor_offset; - U8 physical_pipe=1; // =1 cause lookup table assumes that physiacl pipe 0 is reserved for control - U8 i; - U8 ep_index; - - TRACE_DEBUG("host_auto_configure_endpoint\n\r"); - // For all interfaces to configure... - for(i=0;i SIZEOF_DATA_STAGE) // No more endpoint descriptor found -> Errror ! - { - TRACE_DEBUG("PB\n\r"); - return HOST_FALSE; - } - } - - // Select the new physical pipe to configure and get ride of any previous configuration for this physical pipe - Host_select_pipe(physical_pipe); - Host_disable_pipe(); - Host_enable_pipe(); - - // Build the pipe configuration according to the endpoint descriptors fields received - // - // host_configure_pipe( - // physical_pipe, // pipe nb in USB interface - // data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE], // pipe type (interrupt/BULK/ISO) - // Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]), // pipe addr - // (data_stage[descriptor_offset+2] & MSK_EP_DIR), // pipe dir (IN/OUT) - // host_determine_pipe_size((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE]),// pipe size - // ONE_BANK, // bumber of bank to allocate for pipe - // data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL] // interrupt period (for interrupt pipe) - // ); - - host_configure_pipe( - physical_pipe, - data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE], - Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]), - (data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR] & MSK_EP_DIR), - host_determine_pipe_size( - (U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE_LOW] - + (((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE_HIGH])<<8)), - ONE_BANK, - data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL] ); - - host_configure_address(physical_pipe, DEVICE_ADDRESS); - - // Update Physical Pipe lookup table with device enpoint address - ep_table[physical_pipe]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]; - physical_pipe++; - // Update endpoint addr table in supported interface structure - interface_supported[i].ep_addr[ep_index++]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]; - descriptor_offset += data_stage[descriptor_offset]; // pointing on next descriptor - - // All target endpoints configured ? - nb_endpoint_to_configure--; - } //for(i=0;i SIZEOF_DATA_STAGE) - { - return HOST_FALSE; - } - } - if (data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB]==interface - && data_stage[descriptor_offset+OFFSET_FIELD_ALT]==alt) - { - return descriptor_offset; - } - descriptor_offset += data_stage[descriptor_offset]; - } - return descriptor_offset; -} - -//------------------------------------------------------------------------------ -/// returns the physical pipe number linked to a logical endpoint address. -//------------------------------------------------------------------------------ -U8 host_get_hwd_pipe_nb(U8 ep_addr) -{ - U8 i; - - for(i=0; iOTGHS_HSTPIPISR[0] & AT91C_OTGHS_TXSTPI) != 0); - // Freeze the pipe - Host_freeze_pipe(); - - status=(CONTROL_GOOD); - goto host_send_control_end; - } - - // OUT request management --------------------------------------------- - else // Data stage OUT (bmRequestType==0) - { - Host_set_token_out(); - Host_ack_control_out(); - while(data_length != 0) - { - Host_unfreeze_pipe(); - status = host_get_pipe_length(); - if ( (U16)status > data_length) - { - status = (U8)data_length; - data_length = 0; - } - else - { - data_length -= status; - } - Address_fifochar_endpoint(global_pipe_nb); - while (status!=0) - { - Host_write_byte(*data_pointer); - data_pointer++; - status--; - } - Host_send_control_out(); - while (!Is_host_control_out_sent()) - { - if (Is_host_emergency_exit()) - { - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if (Is_timeout_bdev_response_overflow()) - { - Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC); - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if(Is_host_pipe_error()) - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_control_end; - } - if(Is_host_stall()) - { - status=CONTROL_STALL; - Host_ack_stall(); - goto host_send_control_end; - } - } - Host_ack_control_out(); - } // end of OUT data stage - Host_freeze_pipe(); - Host_set_token_in(); - Host_unfreeze_pipe(); - while(!Is_host_control_in_received()) - { - if (Is_host_emergency_exit()) - { - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if (Is_timeout_bdev_response_overflow()) - { - Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC); - status=CONTROL_TIMEOUT; - Host_freeze_pipe(); - Host_reset_pipe(0); - goto host_send_control_end; - } - if(Is_host_pipe_error()) - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_control_end; - } - if(Is_host_stall()) - { - status=CONTROL_STALL; - Host_ack_stall(); - goto host_send_control_end; - } - } - Host_ack_control_in(); - Host_freeze_pipe(); - Host_send_control_in(); - status=(CONTROL_GOOD); - goto host_send_control_end; - } - -host_send_control_end: - return ((U8)status); -} - - diff --git a/src/ersky9x/libraries/usb/otg/usb_host_task.c b/src/ersky9x/libraries/usb/otg/usb_host_task.c deleted file mode 100644 index 6d3840087..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_host_task.c +++ /dev/null @@ -1,1260 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "conf_usb.h" -#include -#include -#include -#include "usb/otg/usb_task.h" -#include "usb_host_task.h" -#include "usb/otg/usb_drv.h" -#include "usb/otg/usb_host_enum.h" -#include -#include "main.h" - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -//jcb #define WAIT_100MS 100 -// Wait 100 x 125 us = 12,5 ms before USB reset -//#define WAIT_100MS 800 -#define WAIT_100MS 100 - -#ifndef DEVICE_ADDRESS -#error DEVICE_ADDRESS should be defined somewhere in config files (conf_usb.h) -#endif - -#ifndef SIZEOF_DATA_STAGE -#error SIZEOF_DATA_STAGE should be defined in conf_usb.h -#endif - -#ifndef HOST_CONTINUOUS_SOF_INTERRUPT -#error HOST_CONTINUOUS_SOF_INTERRUPT should be defined as ENABLE or DISABLE in conf_usb.h -#endif - -#ifndef Usb_id_transition_action -#define Usb_id_transition_action() -#endif -#ifndef Host_device_disconnection_action -#define Host_device_disconnection_action() -#endif -#ifndef Host_device_connection_action -#define Host_device_connection_action() -#endif -#ifndef Host_sof_action -#define Host_sof_action() -#endif -#ifndef Host_suspend_action -#define Host_suspend_action() -#endif -#ifndef Host_hwup_action -#define Host_hwup_action() -#endif -#ifndef Host_device_not_supported_action -#define Host_device_not_supported_action() -#endif -#ifndef Host_device_class_not_supported_action -#define Host_device_class_not_supported_action() -#endif -#ifndef Host_device_supported_action -#define Host_device_supported_action() -#endif -#ifndef Host_device_error_action -#define Host_device_error_action() -#endif - -extern U8 id_changed_to_host_event; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -volatile S_pipe_int it_pipe_str[MAX_EP_NB]; -volatile U8 pipe_nb_save; -U8 g_sav_int_sof_enable; - -//! Its value represent the current state of the -//! device connected to the usb host controller -//! Value can be: -//! - DEVICE_ATTACHED -//! - DEVICE_POWERED -//! - DEVICE_SUSPENDED -//! - DEVICE_DEFAULT -//! - DEVICE_ADDRESSED -//! - DEVICE_CONFIGURED -//! - DEVICE_ERROR -//! - DEVICE_UNATTACHED -//! - DEVICE_READY -//! - DEVICE_WAIT_RESUME -//! - DEVICE_DISCONNECTED -//! - DEVICE_DISCONNECTED_ACK -//! - and these have been added for OTG : -//! - A_PERIPHERAL -//! - A_INIT_HNP -//! - A_SUSPEND -//! - A_END_HNP_WAIT_VFALL -U8 device_state; - -//! For control requests management over pipe 0 -S_usb_setup_data usb_request; - -//! Internal RAM buffer for USB data stage content -//! This buffer is required to setup host enumeration process -//! Its contains the device descriptors received. -//! Depending on the device descriptors lenght, its size can be optimized -//! with the SIZEOF_DATA_STAGE define of conf_usb.h file -U8 data_stage[SIZEOF_DATA_STAGE]; - -U8 device_status; -U8 request_resume; - - -U8 new_device_connected=0; - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ -static U16 hostSOFCounter; // As internal host start of frame counter - - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// This function initializes the USB controller in host mode and the associated -/// variables. -/// This function enables the USB controller for host mode operation. -//------------------------------------------------------------------------------ -void usb_host_task_init(void) -{ - unsigned int i; - - TRACE_DEBUG("usb_host_task_init\n\r"); - - for( i=0; ibOTGSoftwareVbusCtrl == ENABLE) { - if( Is_usb_bconnection_error_interrupt()||Is_usb_vbus_error_interrupt()) - { - Usb_ack_bconnection_error_interrupt(); - Usb_ack_vbus_error_interrupt(); - Host_clear_vbus_request(); - } - if (Is_usb_id_host()) { - Host_ack_device_connection(); - // Usb_enable_manual_vbus(); - Usb_ack_bconnection_error_interrupt(); - Usb_enable_vbus_pad(); - Usb_enable_vbus(); - Host_vbus_action(); - } - - Usb_disable_vbus_pad(); - Usb_enable_manual_vbus(); - - if(Is_usb_srp_interrupt()) { - Usb_ack_srp_interrupt(); - // if Vbus was not already delivered, it is really an SRP (OTG B-Device) - device_state=DEVICE_ATTACHED; - Usb_ack_bconnection_error_interrupt(); - Usb_enable_vbus_pad(); - Usb_enable_vbus(); - Host_vbus_action(); - } - } - else { - Usb_enable_vbus(); // Give at least device power supply!!! - Host_vbus_action(); - if(Is_usb_vbus_high()) { - device_state=DEVICE_ATTACHED; - } // If VBUS ok goto to device connection expectation - } - } - break; - - case DEVICE_ATTACHED : - // DEVICE_ATTACHED state - // - Vbus is on - // - Try to detect device connection - if (Is_device_connection()) { // Device pull-up detected - //TRACE_DEBUG("Is_device_connection\n\r"); - Host_ack_device_connection(); - // Now device is connected, enable disconnection interrupt - Host_enable_device_disconnection_interrupt(); - // Reset device status - Host_clear_device_supported(); - Host_clear_configured(); - Host_clear_device_ready(); - Host_ack_sof(); - - TRACE_DEBUG("begin timer\n\r"); - gSystemTick = 0; - DelayMS(200); - TRACE_DEBUG("end timer\n\r"); - // Clear bad VBUS error - Usb_ack_vbus_error_interrupt(); - Host_disable_device_disconnection_interrupt(); - - Host_send_reset(); // First USB reset - Host_enable_sof(); // Start Start Of Frame generation - Host_enable_sof_interrupt(); // SOF will be detected under interrupt - - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()) { - } // Active wait of end of reset send - Host_ack_reset(); - //Workaround for some bugly devices with powerless pull up - //usually low speed where data line rise slowly and can be interpretaded as disconnection - for(hostSOFCounter=0;hostSOFCounter!=0xFFFF;hostSOFCounter++) { // Basic Timeout counter - if(Is_usb_event(EVT_HOST_SOF)) { //If we detect SOF, device is still alive and connected, just clear false disconnect flag - if(Is_device_disconnection()) { - Host_ack_device_connection(); - Host_ack_device_disconnection(); - break; - } - } - } - Host_enable_device_disconnection_interrupt(); - hostSOFCounter = 0; - while (hostSOFCounter Retry the connection process from the begining - if( Is_usb_bconnection_error_interrupt()||Is_usb_vbus_error_interrupt()||Is_usb_vbus_low()) { - TRACE_DEBUG("HOST device_attached_error\n\r"); - TRACE_DEBUG("Is_usb_bconnection_error_interrupt: 0x%X\n\r", Is_usb_bconnection_error_interrupt()); - TRACE_DEBUG("Is_usb_vbus_error_interrupt: 0x%X\n\r", Is_usb_vbus_error_interrupt()); - TRACE_DEBUG("Is_usb_vbus_low: 0x%X\n\r", Is_usb_vbus_low()); - //while(1); //JCB for test, to be removed. - if (Is_usb_id_host()) { - Usb_ack_bconnection_error_interrupt(); - Usb_enable_vbus_hw_control(); - device_state=DEVICE_UNATTACHED; - Usb_disable_vbus(); - Usb_disable_vbus_pad(); - Usb_enable_vbus_pad(); - Usb_ack_vbus_error_interrupt(); - Usb_enable_vbus(); - Usb_disable_vbus_hw_control(); - Host_disable_sof(); - Host_vbus_action(); - } - else { - device_state = DEVICE_UNATTACHED; - } - } - break; - - case DEVICE_POWERED : - // DEVICE_POWERED state - // - // - Device connection (attach) as been detected, - // - Wait 100ms and configure default control pipe - // - //TRACE_INFO("Device Connection\n\r"); - Host_device_connection_action(); - if (Is_usb_event(EVT_HOST_SOF)) { - Usb_ack_event(EVT_HOST_SOF); - if (hostSOFCounter++ >= WAIT_100MS) { - device_state = DEVICE_DEFAULT; - Host_select_pipe(PIPE_CONTROL); - Host_enable_pipe(); - host_configure_pipe(PIPE_CONTROL, - TYPE_CONTROL, - TOKEN_SETUP, - EP_CONTROL, - SIZE_64, - ONE_BANK, - 0 ); - device_state = DEVICE_DEFAULT; - } - } - break; - - case DEVICE_DEFAULT : - // DEVICE_DEFAULT state - // - Get device descriptor - // - Reconfigure Pipe 0 according to Device EP0 - // - Attribute device address - TRACE_DEBUG("DEVICE_DEFAULT\n\r"); - // Get first device descriptor - - if( CONTROL_GOOD == host_get_device_descriptor_uncomplete()) { - hostSOFCounter = 0; - while(hostSOFCounter<20) { // wait 20ms before USB reset (special buggly devices...) - if (Is_usb_event(EVT_HOST_SOF)) { - Usb_ack_event(EVT_HOST_SOF); - hostSOFCounter++; - } - if (Is_host_emergency_exit() || Is_usb_bconnection_error_interrupt()) { - break; - } - } - Host_disable_device_disconnection_interrupt(); - Host_send_reset(); // First USB reset - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()); // Active wait of end of reset send - Host_ack_reset(); - - - //Workaround for some bugly devices with powerless pull up - //usually low speed where data line rise slowly and can be interpretaded as disconnection - for(hostSOFCounter=0;hostSOFCounter!=0xFFFF;hostSOFCounter++) { // Basic Timeout counter - if(Is_usb_event(EVT_HOST_SOF)) { //If we detect SOF, device is still alive and connected, just clear false disconnect flag - if(Is_device_disconnection()) { - Host_ack_device_connection(); - Host_ack_device_disconnection(); - break; - } - } - } - Host_enable_device_disconnection_interrupt(); - hostSOFCounter = 0; - while(hostSOFCounter<200) { // wait 200ms after USB reset - if (Is_usb_event(EVT_HOST_SOF)) { - Usb_ack_event(EVT_HOST_SOF); - hostSOFCounter++; - } - if (Is_host_emergency_exit() || Is_usb_bconnection_error_interrupt()) { - break; - } - } - - Host_select_pipe(PIPE_CONTROL); - Host_disable_pipe(); - Host_unallocate_memory(); - Host_enable_pipe(); - // Re-Configure the Ctrl Pipe according to the device ctrl EP - - TRACE_DEBUG("Size: 0x%X\n\r", (U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE]); - TRACE_DEBUG("Size Pipe: 0x%X\n\r", host_determine_pipe_size((U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE])); - - host_configure_pipe(PIPE_CONTROL, - TYPE_CONTROL, - TOKEN_SETUP, - EP_CONTROL, - host_determine_pipe_size((U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE]), - ONE_BANK, - 0 ); - // Give an absolute device address - host_set_address(DEVICE_ADDRESS); - host_configure_address(PIPE_CONTROL, DEVICE_ADDRESS); - device_state = DEVICE_ADDRESSED; - } - else { - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_ADDRESSED : - // DEVICE_ADDRESSED state - // - Check if VID PID is in supported list - TRACE_DEBUG("DEVICE_ADDRESSED\n\r"); - if (CONTROL_GOOD == host_get_device_descriptor()) { - // Detect if the device connected belongs to the supported devices table - if (HOST_TRUE == host_check_VID_PID()) { - Host_set_device_supported(); - Host_device_supported_action(); - device_state = DEVICE_CONFIGURED; - } - else - { - } - - } - else {// Can not get device descriptor - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_CONFIGURED : - // DEVICE_CONFIGURED state - // - Configure pipes for the supported interface - // - Send Set_configuration() request - // - Goto full operating mode (device ready) - TRACE_DEBUG("DEVICE_CONFIGURED\n\r"); - if (CONTROL_GOOD == host_get_configuration_descriptor()) { - if (HOST_FALSE != host_check_class()) { // Class support OK? - host_auto_configure_endpoint(); - - if (Is_host_configured()) { - if (CONTROL_GOOD== host_set_configuration(1)) { // Send Set_configuration - // host_set_interface(interface_bound,interface_bound_alt_set); - // device and host are now fully configured - // goto DEVICE READY normal operation - device_state = DEVICE_READY; - // monitor device disconnection under interrupt - Host_enable_device_disconnection_interrupt(); - // If user host application requires SOF interrupt event - // Keep SOF interrupt enable otherwize, disable this interrupt -#if (HOST_CONTINUOUS_SOF_INTERRUPT==DISABLE) - Host_disable_sof_interrupt(); -#endif - new_device_connected=TRUE; - TRACE_INFO("Device Enumerated\n\r"); - } - else { // Problem during Set_configuration request... - device_state = DEVICE_ERROR; - } - } - } - else { // device class not supported... - device_state = DEVICE_ERROR; - TRACE_INFO("Unsupported Device\n\r"); - Host_device_class_not_supported_action(); - } - } - else { // Can not get configuration descriptors... - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_READY : - // DEVICE_READY state - // - Full standard operating mode - // - Nothing to do... - // Host full std operating mode! - new_device_connected=FALSE; - - // Handles user requests : "stop Vbus" and "suspend" - break; - - case DEVICE_ERROR : - //------------------------------------------------------ - // DEVICE_ERROR state - // - Error state - // - Do custom action call (probably go to default mode...) - TRACE_DEBUG("DEVICE_ERROR\n\r"); - Host_device_error_action(); - break; - - case DEVICE_SUSPENDED : - // DEVICE_SUSPENDED state - // - Host application request to suspend the device activity - // - State machine comes here thanks to Host_request_suspend() - TRACE_DEBUG("DEVICE_SUSPENDED\n\r"); - device_state=DEVICE_WAIT_RESUME; // wait for device resume event - if(Is_device_supports_remote_wakeup()) { // If the connected device supports remote wake up - if (CONTROL_GOOD != host_set_feature_remote_wakeup()) { - device_state = DEVICE_DISCONNECTED; // stop connexion because device has not accepted the feature - } - } - TRACE_INFO("Usb suspend\n\r"); - hostSOFCounter = Is_host_sof_interrupt_enabled(); //Save current sof interrupt enable state - Host_disable_sof_interrupt(); - Host_ack_sof(); - Host_disable_sof(); // Stop start of frame generation, this generates the suspend state - Host_ack_remote_wakeup(); - Host_enable_remote_wakeup_interrupt(); - Host_ack_hwup(); - Host_enable_hwup_interrupt(); // Enable host wake-up interrupt - // (this is the unique USB interrupt able to wake up the CPU core from power-down mode) - Usb_freeze_clock(); - Host_suspend_action(); // Custom action here! (for example go to power-save mode...) - } - break; - - case DEVICE_WAIT_RESUME : - // DEVICE_WAIT_RESUME state - // - Wait in this state till the host receives an upstream resume from the device - // - or the host software request the device to resume - TRACE_DEBUG("DEVICE_WAIT_RESUME\n\r"); - if(Is_usb_event(EVT_HOST_REMOTE_WAKEUP)|| Is_host_request_resume()) { // Remote wake up has been detected - // or Local resume request has been received - if(Is_host_request_resume()) { // Not a remote wakeup, but an host application request - Host_disable_hwup_interrupt(); // Wake up interrupt should be disable host is now wake up ! - // CAUTION HWUP can be cleared only when USB clock is active - // Pll_start_auto(); // First Restart the PLL for USB operation - // Wait_pll_ready(); // Get sure pll is lock - Usb_unfreeze_clock(); // Enable clock on USB interface - } - Host_ack_hwup(); // Clear HWUP interrupt flag - Host_enable_sof(); - - if (Is_usb_event(EVT_HOST_REMOTE_WAKEUP)) { - Usb_ack_event(EVT_HOST_REMOTE_WAKEUP); // Ack software event - Host_disable_sof_interrupt(); - Host_ack_device_disconnection(); - Host_disable_device_disconnection_interrupt(); - - Host_send_resume(); // this other downstream resume is done to ensure min. 20ms of HOST DRIVING RESUME (not Device) - while (!Is_device_disconnection() && Host_is_resume()); - hostSOFCounter = 0; - Host_ack_sof(); - while (!Is_device_disconnection() && (hostSOFCounter != 12)) { // wait for min. 10ms of device recovery time - if (Is_host_sof()) { - Host_ack_sof(); - hostSOFCounter++; - } - } - if (Is_device_disconnection()) { - usb_host_task_init(); - device_state = DEVICE_DISCONNECTED; - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - } - else { - device_state = DEVICE_READY; - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - } - Host_enable_device_disconnection_interrupt(); - Host_ack_sof(); - } - else { - Host_send_resume(); // Send down stream resume - //----------------------- - // Work-around for case of Device disconnection during Suspend - // The disconnection is never detected and the Resume bit remains high (and RSMEDI flag never set) - // If the timeout elapses, it implies that the device has disconnected => macro is reset (to reset the Resume bit) - dec = 0; - while (dec < 0x4FFFF) { // several hundreds of ms - if (Is_host_down_stream_resume()) { // Wait Down stream resume sent - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - if(hostSOFCounter) { - Host_enable_sof_interrupt(); - } // Restore SOF interrupt enable state before suspend - device_state=DEVICE_READY; // Come back to full operating mode - TRACE_INFO("Usb resumed\n\r"); - dec = 0x3FFFFE; // will cause a loop end - } - dec++; - } - if (dec != 0x3FFFFF) { // if resume failed - usb_host_task_init(); - device_state = DEVICE_DISCONNECTED; - } - else - { - hostSOFCounter = 0; - Host_ack_sof(); - while (!Is_device_disconnection() && (hostSOFCounter != 12)) { // wait for min. 10ms of device recovery time - if (Is_host_sof()) { - Host_ack_sof(); - hostSOFCounter++; - } - } - } - //-----------------------End of Work Around - } - } - break; - - case DEVICE_DISCONNECTED : - // DEVICE_DISCONNECTED state - // - Device disconnection has been detected - // - Run scheduler in this state at least two times to get sure event is detected by all host application tasks - // - Go to DEVICE_DISCONNECTED_ACK state before DEVICE_UNATTACHED, to get sure scheduler calls all app tasks... - TRACE_DEBUG("DEVICE_DISCONNECTED\n\r"); - device_state = DEVICE_DISCONNECTED_ACK; - break; - - case DEVICE_DISCONNECTED_ACK : - // DEVICE_DISCONNECTED_ACK state - // - Device disconnection has been detected and managed bu applicatives tasks - // - Go to DEVICE_UNATTACHED state - TRACE_DEBUG("DEVICE_DISCONNECTED_ACK\n\r"); - host_disable_all_pipe(); - device_state = DEVICE_UNATTACHED; - break; - - - default : - // default state - // - Default case: ERROR - // - Goto no device state - TRACE_DEBUG("default\n\r"); - device_state = DEVICE_UNATTACHED; - break; - } -} - -//------------------------------------------------------------------------------ -/// This function send nb_data pointed with *buf with the pipe number specified -/// This function will activate the host sof interrupt to detect timeout. The -/// interrupt enable sof will be restore. -//------------------------------------------------------------------------------ -U8 host_send_data(U8 pipe, U16 nb_data, U8 *buf) -{ - U16 length; - U8 status=PIPE_GOOD; - U8 sav_int_sof_enable; - U8 nak_timeout; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - U16 cpt_nak; -#endif - U16 nb_data_loaded; - - TRACE_DEBUG("host_send_data[]%d: %d\n\r", pipe, nb_data); - - sav_int_sof_enable=Is_host_sof_interrupt_enabled(); // Save state of enable sof interrupt - Host_enable_sof_interrupt(); - Host_select_pipe(pipe); - - Host_set_token_in(); - - Host_set_token_out(); - Host_ack_out_sent(); - /* - TRACE_DEBUG("CTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_CTRL); - TRACE_DEBUG("SR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_SR); - TRACE_DEBUG("DEVCTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVCTRL); - TRACE_DEBUG("DEVISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVISR); - TRACE_DEBUG("DEVIMR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVIMR); - TRACE_DEBUG("DEVEPTISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[0]); - TRACE_DEBUG("HSTCTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTCTRL); - TRACE_DEBUG("HSTISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTISR); - TRACE_DEBUG("HSTIMR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTIMR); - TRACE_DEBUG("HSTPIP: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIP); - TRACE_DEBUG("HSTPIPCFG[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[0]); - TRACE_DEBUG("HSTPIPCFG[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[1]); - TRACE_DEBUG("HSTPIPCFG[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[2]); - TRACE_DEBUG("HSTPIPINRQ[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[0]); - TRACE_DEBUG("HSTPIPINRQ[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[1]); - TRACE_DEBUG("HSTPIPINRQ[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[2]); - TRACE_DEBUG("HSTPIPERR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[0]); - TRACE_DEBUG("HSTPIPERR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[1]); - TRACE_DEBUG("HSTPIPERR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[2]); - TRACE_DEBUG("HSTPIPISR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[0]); - TRACE_DEBUG("HSTPIPISR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[1]); - TRACE_DEBUG("HSTPIPISR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[2]); - TRACE_DEBUG("HSTPIPIMR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[0]); - TRACE_DEBUG("HSTPIPIMR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[1]); - TRACE_DEBUG("HSTPIPIMR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[2]); - */ - while (nb_data != 0) { // While there is something to send... - Host_unfreeze_pipe(); - // Prepare data to be sent - length = host_get_pipe_length(); - TRACE_DEBUG("size=%d\n\r", length); - - if ( length > nb_data) { - nb_data_loaded = nb_data; - length = nb_data; - } - else { - nb_data_loaded = length; - } - Address_fifochar_endpoint(global_pipe_nb); - while (length!=0) { // Load Pipe buffer - Host_write_byte(*buf++); - //(((char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0))[dBytes++])=*(buf++); - //pFifo[dBytes++] = *buf; - //buf++; - length--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine -#if (NAK_TIMEOUT_ENABLE==ENABLE) - cpt_nak=0; -#endif - nak_timeout=0; - Host_ack_out_sent(); - Host_send_out(); - while (!Is_host_out_sent()) { - if (Is_host_emergency_exit()) { // Async disconnection or role change detected under interrupt - TRACE_DEBUG("Emergency exit\n\r"); - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - if (private_sof_counter>=250) { // Count 250ms (250sof) - TRACE_DEBUG("TimeOut Send Data\n\r"); - private_sof_counter=0; - if (nak_timeout++>=TIMEOUT_DELAY) { // Inc timeout and check for overflow - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - } - if (Is_host_pipe_error()) { // Any error ? - TRACE_DEBUG("pipe error\n\r"); - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_data_end; - } - if (Is_host_stall()) { // Stall management - TRACE_DEBUG("stall\n\r"); - status =PIPE_STALL; - Host_ack_stall(); - goto host_send_data_end; - } -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if(Is_host_nak_received()) { //NAK received - Host_ack_nak_received(); - if (cpt_nak++>NAK_SEND_TIMEOUT) { - TRACE_DEBUG("NAK timeout\n\r"); - status = PIPE_NAK_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - } -#endif - } - // Here OUT sent - nb_data -= nb_data_loaded; - status=PIPE_GOOD; // Frame correctly sent - Host_ack_out_sent(); - } - Host_freeze_pipe(); - -host_send_data_end: - // Restore sof interrupt enable state - if (sav_int_sof_enable==FALSE) { - Host_disable_sof_interrupt(); - } - // And return... - return ((U8)status); -} - - - -//------------------------------------------------------------------------------ -/// This function receives nb_data pointed with *buf with the pipe number specified -/// The nb_data parameter is passed as a U16 pointer, thus the data pointed by this pointer -/// is updated with the final number of data byte received. -//------------------------------------------------------------------------------ -U8 host_get_data(U8 pipe, U16 *nb_data, U8 *buf) -{ - U8 status=PIPE_GOOD; - U8 sav_int_sof_enable; - U8 nak_timeout; - U16 n; - U16 i; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - U16 cpt_nak; -#endif - - // TRACE_DEBUG("host_get_data[%d]\n\r", pipe); - n=*nb_data; - *nb_data=0; - - sav_int_sof_enable=Is_host_sof_interrupt_enabled(); - Host_enable_sof_interrupt(); - - Host_select_pipe(pipe); - Host_set_token_in(); - Host_continuous_in_mode(); - // Host_ack_in_received(); - - while (n) { // While missing data... - // start IN request generation - Host_unfreeze_pipe(); - Host_send_in(); - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - nak_timeout=0; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - cpt_nak=0; -#endif - while (!Is_host_in_received()) - { - if (Is_host_emergency_exit()) // Async disconnection or role change detected under interrupt - { - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - if (private_sof_counter>=250) // Timeout management - { - private_sof_counter=0; // Done in host SOF interrupt - if (nak_timeout++>=TIMEOUT_DELAY)// Check for local timeout - { - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - } - if(Is_host_pipe_error()) // Error management - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_get_data_end; - } - if(Is_host_stall()) // STALL management - { - status =PIPE_STALL; - Host_reset_pipe(pipe); - Host_ack_stall(); - goto host_get_data_end; - } -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if(Is_host_nak_received()) //NAK received - { - Host_ack_nak_received(); - if (cpt_nak++>NAK_RECEIVE_TIMEOUT) - { - status = PIPE_NAK_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - } -#endif - } - status=PIPE_GOOD; - Host_freeze_pipe(); - if (Host_byte_counter()<=n) - { - if ((Host_byte_counter() < n)&&(Host_byte_counter() nb_data) // Pipe size> remaining data - { - i = nb_data; - nb_data = 0; - } - else // Pipe size < remaining data - { - nb_data -= i; - } - it_pipe_str[pipe].nb_byte_on_going+=i; // Update nb data processed - Address_fifochar_endpoint(global_pipe_nb); - while (i!=0) // Load Pipe buffer - { - Host_write_byte(*ptr_buf++); - i--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe].timeout=0; // Refresh timeout counter - Host_ack_out_sent(); - Host_ack_stall(); - Host_ack_nak_received(); - - Host_enable_stall_interrupt(); - Host_enable_error_interrupt(); -#if (NAK_TIMEOUT_ENABLE==ENABLE) - Host_enable_nak_interrupt(); -#endif - Host_enable_transmit_interrupt(); - Host_send_out(); // Send the USB frame - return HOST_TRUE; - } -} - -//------------------------------------------------------------------------------ -//! @brief USB pipe interrupt subroutine -//! -//! @param none -//! -//! @return none -//------------------------------------------------------------------------------ -void usb_pipe_interrupt(void) -{ - U8 pipe_nb; - U8 *ptr_buf; - void (*fct_handle)(U8 status,U16 nb_byte); - U16 n; - U8 i; - U8 do_call_back=FALSE; - - TRACE_DEBUG("usb_pipe_interrupt\n\r"); - - if(Host_get_pipe_interrupt()) { - - pipe_nb_save = Host_get_selected_pipe(); // Important! Save here working pipe number - pipe_nb=host_get_nb_pipe_interrupt(); // work with the correct pipe number that generates the interrupt - Host_select_pipe(pipe_nb); // Select this pipe - fct_handle=*(it_pipe_str[pipe_nb].handle); - - // Now try to detect what event generate an interrupt... - if (Is_host_pipe_error()) // Any error ? - { - TRACE_DEBUG("host_pipe_error\n\r"); - it_pipe_str[pipe_nb].status = Host_error_status(); - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - Host_ack_all_errors(); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - - if (Is_host_stall()) // Stall handshake received ? - { - TRACE_DEBUG("host_stall\n\r"); - it_pipe_str[pipe_nb].status=PIPE_STALL; - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if (Is_host_nak_received()) // NAK ? - { - Host_ack_nak_received(); - // check if number of NAK timeout error occurs (not for interrupt type pipe) - if((--it_pipe_str[pipe_nb].nak_timeout==0) && (Host_get_pipe_type()!=TYPE_INTERRUPT)) - { - it_pipe_str[pipe_nb].status=PIPE_NAK_TIMEOUT; - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - } -#endif - - if (Is_host_in_received()) // Pipe IN reception ? - { - TRACE_DEBUG("host_in received\n\r"); - ptr_buf = it_pipe_str[pipe_nb].ptr_buf; - ptr_buf += it_pipe_str[pipe_nb].nb_byte_processed; // Build pointer to data buffer - n = it_pipe_str[pipe_nb].nb_byte_to_process; - n -= it_pipe_str[pipe_nb].nb_byte_processed; // Remaining data bytes - Host_freeze_pipe(); - if (Host_byte_counter()<=n) - { - if ((Host_byte_counter() < n)&&(Host_byte_counter()0) //still something to process - { - Host_unfreeze_pipe(); // Request another IN transfer - Host_send_in(); - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe_nb].timeout=0; // Reset timeout - it_pipe_str[pipe_nb].nak_timeout=NAK_RECEIVE_TIMEOUT; - } - else //end of transfer - { - it_pipe_str[pipe_nb].enable=DISABLE; - it_pipe_str[pipe_nb].status=PIPE_GOOD; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - } - } - - if(Is_host_out_sent()) // Pipe OUT sent ? - { - TRACE_DEBUG("host_out send\n\r"); - Host_ack_out_sent(); - it_pipe_str[pipe_nb].nb_byte_processed+=it_pipe_str[pipe_nb].nb_byte_on_going; - it_pipe_str[pipe_nb].nb_byte_on_going=0; - ptr_buf = it_pipe_str[pipe_nb].ptr_buf; - ptr_buf += it_pipe_str[pipe_nb].nb_byte_processed; // Build pointer to data buffer - n = it_pipe_str[pipe_nb].nb_byte_to_process; - n -= it_pipe_str[pipe_nb].nb_byte_processed; // Remaining data bytes - if(n>0) // Still data to process... - { - Host_unfreeze_pipe(); - // Prepare data to be sent - i = host_get_pipe_length(); - if ( i > n) // Pipe size> remaining data - { - i = n; - n = 0; - } - else // Pipe size < remaining data - { - n -= i; - } - it_pipe_str[pipe_nb].nb_byte_on_going+=i; // Update nb data processed - Address_fifochar_endpoint(global_pipe_nb); - while (i!=0) // Load Pipe buffer - { - Host_write_byte(*ptr_buf++); i--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe_nb].timeout=0; // Refresh timeout counter - it_pipe_str[pipe_nb].nak_timeout=NAK_SEND_TIMEOUT; - Host_send_out(); // Send the USB frame - } - else //n==0 Transfer is finished - { - it_pipe_str[pipe_nb].enable=DISABLE; // Tranfer end - it_pipe_str[pipe_nb].status=PIPE_GOOD; // Status OK - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - } - } - -usb_pipe_interrupt_end: - Host_select_pipe(pipe_nb_save); // Restore pipe number !!!! - if (is_any_interrupt_pipe_active()==FALSE) // If no more transfer is armed - { - if (g_sav_int_sof_enable==FALSE) - { - Host_disable_sof_interrupt(); - } - } - if(do_call_back) // Any callback functions to perform ? - { - fct_handle(it_pipe_str[pipe_nb].status,it_pipe_str[pipe_nb].nb_byte_processed); - } - - } - -} - - - diff --git a/src/ersky9x/libraries/usb/otg/usb_host_task.h b/src/ersky9x/libraries/usb/otg/usb_host_task.h deleted file mode 100644 index af752ec96..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_host_task.h +++ /dev/null @@ -1,230 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ -#ifndef _USB_HOST_TASK_H_ -#define _USB_HOST_TASK_H_ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ -#include -#include - -#include "main.h" - -//! @brief Selects the Reset Length (x11ms) -//! This value is the number of consecutives Reset sent by the Host -#define OTG_RESET_LENGTH 1 - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ -typedef struct -{ - bit enable; - U16 nb_byte_to_process; - U16 nb_byte_processed; - U16 nb_byte_on_going; - U8 *ptr_buf; - void(*handle)(U8 status, U16 nb_byte); - U8 status; - U8 timeout; - U16 nak_timeout; -} S_pipe_int; - - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -#define PIPE_GOOD 0 -//#define PIPE_DATA_TOGGLE 0x01 -//#define PIPE_DATA_PID 0x02 -//#define PIPE_PID 0x04 -//#define PIPE_TIMEOUT 0x08 -//#define PIPE_CRC16 0x10 -#define PIPE_STALL 0x20 -#define PIPE_NAK_TIMEOUT 0x40 -#define PIPE_DELAY_TIMEOUT 0x80 - -// usb_host_task USB host task module -// Returns true when device connected and correctly enumerated. -// The host high level application should tests this before performing any applicative requests -// to the device connected -#define Is_host_ready() ((device_state==DEVICE_READY) ? TRUE : FALSE) - -/// Check if host controller is in suspend mode -#define Is_host_suspended() (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED)) ? TRUE : FALSE) - -/// Check if host controller is not suspend mode -#define Is_host_not_suspended() (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED)) ? FALSE : TRUE) - -/// This function should be called to make the host controller enter USB suspend mode -#define Host_request_suspend() (device_state=DEVICE_SUSPENDED) - -/// This function should be called to request the host controller to resume the USB bus -#define Host_request_resume() (request_resume=TRUE) - -/// Private ack for software event -#define Host_ack_request_resume() (request_resume=FALSE) - -/// Private check for resume sequence -#define Is_host_request_resume() ((request_resume==TRUE) ? TRUE : FALSE) - -/// Returns true when a new device is enumerated -#define Is_new_device_connection_event() (new_device_connected ? TRUE : FALSE) - -/// Returns true when the device disconnects from the host -#define Is_device_disconnection_event() ((device_state==DEVICE_DISCONNECTED_ACK || device_state==DEVICE_DISCONNECTED) ? TRUE : FALSE) - -/// Stop all interrupt attached to a pipe -#define Host_stop_pipe_interrupt(i) {Host_disable_transmit_interrupt();\ - Host_disable_receive_interrupt();\ - Host_disable_stall_interrupt();\ - Host_disable_error_interrupt();\ - Host_disable_nak_interrupt();\ - Host_reset_pipe(i); } - -/// device_state_value Host controller states -/// Defines for device state coding -#define DEVICE_UNATTACHED 0 -#define DEVICE_ATTACHED 1 -#define DEVICE_POWERED 2 -#define DEVICE_DEFAULT 3 -#define DEVICE_ADDRESSED 4 -#define DEVICE_CONFIGURED 5 -#define DEVICE_READY 6 -#define DEVICE_ERROR 7 -#define DEVICE_SUSPENDED 8 -#define DEVICE_WAIT_RESUME 9 -#define DEVICE_DISCONNECTED 10 -#define DEVICE_DISCONNECTED_ACK 11 -#define A_PERIPHERAL 12 // used for A-Device in OTG mode -#define A_INIT_HNP 13 -#define A_SUSPEND 14 -#define A_END_HNP_WAIT_VFALL 15 -#define A_TEMPO_VBUS_DISCHARGE 16 - - -#define Host_set_device_supported() (device_status |= 0x01) -#define Host_clear_device_supported() (device_status &= ~0x01) - -#define Host_set_device_ready() (device_status |= 0x02) -#define Host_clear_device_ready() (device_status &= ~0x02) - -#define Host_set_configured() (device_status |= 0x04) -#define Host_clear_configured() (device_status &= ~0x04) -#define Is_host_configured() (device_status & 0x04) - - - - -/// Has a SRP been received, and waiting for a connect of B-Device (Vbus delivered) -#define Srp_received_and_waiting_connect() (otg_a_device_srp |= 0x01) -#define Ack_srp_received_and_connect() (otg_a_device_srp &= ~0x01) -#define Is_srp_received_and_waiting_connect() (((otg_a_device_srp&0x01) != 0) ? TRUE : FALSE) -/// Is the current session has been started with SRP -#define Host_session_started_srp() (otg_a_device_srp |= 0x02) -#define Host_end_session_started_srp() (otg_a_device_srp &= ~0x02) -#define Is_host_session_started_srp() (((otg_a_device_srp&0x02) != 0) ? TRUE : FALSE) - -/// Is the current peripheral is an OTG device ? -#define Peripheral_is_not_otg_device() (otg_device_connected = 0x00) -#define Peripheral_is_otg_device() (otg_device_connected = 0x11) -#define Is_peripheral_otg_device() ((otg_device_connected != 0) ? TRUE : FALSE) - -/// Check if counter of Vbus delivery time after SRP is elapsed -// 0xDAC = 3500, 3500x2 = 7000 => 7s -#define T_VBUS_DELIV_AFTER_SRP 0xDAC // minimum time (x2ms) with Vbus ON once a SRP has been received (5s T_VBUS_DELIV_AFTER_SRP) ? TRUE : FALSE) - -/// Check if counter of A-Suspend delay is elapsed -/// Max. delay for a B-DEVICE to disconnect once the A-HOST has set suspend mode -// Min 200 ms -// 0x96 = 150 ,150x2 = 300 => 300 ms -#define TA_AIDL_BDIS 0x96 // minimum time (x2ms) in A_suspend state before stop Vbus (must be > 200ms) - // if value = 0, this is an infinite delay -#define Init_ta_aidl_bdis_counter() (otg_ta_aidl_bdis_tmr = TA_AIDL_BDIS) -#define Is_ta_aidl_bdis_counter_overflow() ((otg_ta_aidl_bdis_tmr == 0x0001) ? TRUE : FALSE) - -/// Check if counter otg_timeout_bdev_respond is elapsed -// 0xD00 = 3328, 3328x2 = 6656 => 6s -#define TM_OUT_MAX_BDEV_RESPONSE 0xD00 // maximum delay for the A-Device waiting for a response from B-Device once attached -#define Init_timeout_bdev_response() (otg_timeout_bdev_respond = TM_OUT_MAX_BDEV_RESPONSE) -#define Is_timeout_bdev_response_overflow() ((otg_timeout_bdev_respond == 0) ? TRUE : FALSE) - -/// Check if counter otg_ta_vbus_rise is elapsed -// 0x28 = 40, 40x2 = 80 => 80ms -#define TA_VBUS_RISE 0x28 // maximum delay for Vbus to reach the Va_vbus_valid threshold after being requested (must be < 100ms) -#define Init_ta_vbus_rise_counter() (otg_ta_vbus_rise = TA_VBUS_RISE) -#define Is_ta_vbus_rise_counter_overflow() ((otg_ta_vbus_rise == 0) ? TRUE : FALSE) - -/// Check if counter otg_ta_vbus_fall is elapsed -// 50x2 = 100 => 100ms -#define TA_VBUS_FALL 50 -#define Init_ta_vbus_fall_counter() (otg_end_hnp_vbus_delay = TA_VBUS_FALL) -#define Is_ta_vbus_fall_counter_overflow() ((otg_end_hnp_vbus_delay == 0) ? TRUE : FALSE) - - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ -extern U8 g_sav_int_sof_enable; -extern U8 device_state; -extern U8 request_resume; -extern U8 new_device_connected; - -// OTG Defines, Variables and Macros -// See "usb_host_task.c" file for description of variables role and use -extern U16 otg_ta_srp_wait_connect; -extern U16 otg_ta_aidl_bdis_tmr; -extern U8 otg_ta_vbus_rise; -extern U16 otg_timeout_bdev_respond; -extern U16 otg_end_hnp_vbus_delay; - -extern U8 otg_a_device_srp; -extern U8 otg_device_connected; -extern S_usb_setup_data usb_request; -extern U8 device_status; -extern U8 data_stage[SIZEOF_DATA_STAGE]; - -//----------------------------------------------------------------------------- -// Exported functions -//----------------------------------------------------------------------------- -extern void usb_host_task_init(void); -extern void usb_host_task(void); -extern U8 host_send_data(U8 pipe, U16 nb_data, U8 *buf); -extern U8 host_get_data(U8 pipe, U16 *nb_data, U8 *buf); -extern void reset_it_pipe_str(void); -extern U8 is_any_interrupt_pipe_active(void); -extern U8 host_get_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void (*handle)(U8 status, U16 nb_byte)); -extern U8 host_send_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void (*handle)(U8 status, U16 nb_byte)); -extern void usb_pipe_interrupt(void); - -#endif // _USB_HOST_TASK_H_ - diff --git a/src/ersky9x/libraries/usb/otg/usb_host_task_with_srp_hnp.c b/src/ersky9x/libraries/usb/otg/usb_host_task_with_srp_hnp.c deleted file mode 100644 index 4cf02b78c..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_host_task_with_srp_hnp.c +++ /dev/null @@ -1,1493 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "conf_usb.h" -#include -#include -#include -#include -#include "usb/otg/usb_task.h" -#include "usb_host_task.h" -#include "usb/otg/usb_drv.h" -#include "usb/otg/usb_host_enum.h" -#include -#include "main.h" - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ -//jcb #define WAIT_100MS 100 -// Wait 100 x 125 us = 12,5 ms before USB reset -//#define WAIT_100MS 800 -#define WAIT_100MS 100 - -#if (HOST_STRICT_VID_PID_TABLE != ENABLE) -#warning HOST_STRICT_VID_PID_TABLE must be defined to ENABLE to comply with Targeted Peripheral List requirements -#endif - - -#ifndef DEVICE_ADDRESS -#error DEVICE_ADDRESS should be defined somewhere in config files (conf_usb.h) -#endif - -#ifndef SIZEOF_DATA_STAGE -#error SIZEOF_DATA_STAGE should be defined in conf_usb.h -#endif - -#ifndef HOST_CONTINUOUS_SOF_INTERRUPT -#error HOST_CONTINUOUS_SOF_INTERRUPT should be defined as ENABLE or DISABLE in conf_usb.h -#endif - -#ifndef Usb_id_transition_action -#define Usb_id_transition_action() -#endif -#ifndef Host_device_disconnection_action -#define Host_device_disconnection_action() -#endif -#ifndef Host_device_connection_action -#define Host_device_connection_action() -#endif -#ifndef Host_sof_action -#define Host_sof_action() -#endif -#ifndef Host_suspend_action -#define Host_suspend_action() -#endif -#ifndef Host_hwup_action -#define Host_hwup_action() -#endif -#ifndef Host_device_not_supported_action -#define Host_device_not_supported_action() -#endif -#ifndef Host_device_class_not_supported_action -#define Host_device_class_not_supported_action() -#endif -#ifndef Host_device_supported_action -#define Host_device_supported_action() -#endif -#ifndef Host_device_error_action -#define Host_device_error_action() -#endif - -extern U8 id_changed_to_host_event; - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -volatile S_pipe_int it_pipe_str[MAX_EP_NB]; -volatile U8 pipe_nb_save; -U8 g_sav_int_sof_enable; - -//! Min. delay after an SRP received, with VBUS delivered ON (waiting for a B-DEV connect) -U16 otg_ta_srp_wait_connect; -//! Max. delay for a B-DEVICE to disconnect once the A-HOST has set suspend mode -U16 otg_ta_aidl_bdis_tmr; -//! Max. delay for vbus to reach Va_vbus_valid threshold -U8 otg_ta_vbus_rise; -//! Max. delay once B-Device attached to respond to the first A-Device requests -U16 otg_timeout_bdev_respond; -//! Indicates if the connected peripheral is an OTG Device or not -U8 otg_device_connected; -//! Stores special events about SRP in A-Device mode -U8 otg_a_device_srp; -//! Variable used for timing Vbus discharge to avoid bounces around vbus_valid threshold -U16 otg_end_hnp_vbus_delay; - -//! Its value represent the current state of the -//! device connected to the usb host controller -//! Value can be: -//! - DEVICE_ATTACHED -//! - DEVICE_POWERED -//! - DEVICE_SUSPENDED -//! - DEVICE_DEFAULT -//! - DEVICE_ADDRESSED -//! - DEVICE_CONFIGURED -//! - DEVICE_ERROR -//! - DEVICE_UNATTACHED -//! - DEVICE_READY -//! - DEVICE_WAIT_RESUME -//! - DEVICE_DISCONNECTED -//! - DEVICE_DISCONNECTED_ACK -//! - and these have been added for OTG : -//! - A_PERIPHERAL -//! - A_INIT_HNP -//! - A_SUSPEND -//! - A_END_HNP_WAIT_VFALL -U8 device_state; - -//! For control requests management over pipe 0 -S_usb_setup_data usb_request; - -//! Internal RAM buffer for USB data stage content -//! This buffer is required to setup host enumeration process -//! Its contains the device descriptors received. -//! Depending on the device descriptors lenght, its size can be optimized -//! with the SIZEOF_DATA_STAGE define of conf_usb.h file -U8 data_stage[SIZEOF_DATA_STAGE]; - -U8 device_status; -U8 request_resume; - - -U8 new_device_connected=0; - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ -static U16 hostSOFCounter; // As internal host start of frame counter - - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// This function initializes the USB controller in host mode and the associated -/// variables. -/// This function enables the USB controller for host mode operation. -//------------------------------------------------------------------------------ -void usb_host_task_init(void) -{ - unsigned int i; - - TRACE_DEBUG("usb_host_task_init\n\r"); - - for( i=0; ibOTGADevSRPReaction == VBUS_PULSE) { - Usb_select_vbus_srp_method(); - } - else { - Usb_select_data_srp_method(); - } - device_state=DEVICE_UNATTACHED; -} - -//------------------------------------------------------------------------------ -/// Entry point of the USB host management -/// The aim is to manage the device target connection and enumeration -/// depending on the device_state, the function performs the required operations -/// to get the device enumerated and configured -/// Once the device is operationnal, the device_state value is DEVICE_READY -/// This state should be tested by the host task application before performing -/// any applicative requests to the device. -//------------------------------------------------------------------------------ -void usb_host_task(void) -{ - U32 dec; - U8 desc_temp; - - //TRACE_DEBUG("host_task "); - switch (device_state) { - case DEVICE_UNATTACHED: - // DEVICE_UNATTACHED state - // - Default init state - // - Try to give device power supply - //TRACE_DEBUG("DEVICE_UNATTACHED\n\r"); - for (hostSOFCounter=0; hostSOFCounterbOTGSoftwareVbusCtrl == ENABLE) { - if( Is_usb_bconnection_error_interrupt()||Is_usb_vbus_error_interrupt()) - { - Usb_ack_bconnection_error_interrupt(); - Usb_ack_vbus_error_interrupt(); - Host_clear_vbus_request(); - } - - if(Is_usb_srp_interrupt()) { - Usb_ack_srp_interrupt(); - // if Vbus was not already delivered, it is really an SRP (OTG B-Device) - Otg_print_new_event_message(OTGMSG_SRP_RECEIVED,OTG_TEMPO_2SEC); - Host_session_started_srp(); - Init_ta_srp_counter(); - Srp_received_and_waiting_connect(); - Init_ta_vbus_rise_counter(); - device_state=DEVICE_ATTACHED; - Usb_ack_bconnection_error_interrupt(); - Usb_enable_vbus_pad(); - Usb_enable_vbus(); - Host_vbus_action(); - } - } - else { - Usb_enable_vbus(); // Give at least device power supply!!! - Host_vbus_action(); - if(Is_usb_vbus_high()) { - device_state=DEVICE_ATTACHED; - } // If VBUS ok goto to device connection expectation - } - } - else if (b_uut_device_state == B_HOST) { - device_state = DEVICE_ATTACHED; - } - break; - - case DEVICE_ATTACHED : - // DEVICE_ATTACHED state - // - Vbus is on - // - Try to detect device connection - if (Is_device_connection() || (Is_usb_id_device() && (b_uut_device_state == B_HOST))) { - //TRACE_DEBUG("Is_device_connection\n\r"); - Host_ack_device_connection(); - Ack_srp_received_and_connect(); // connection might have been requested by SRP - // Now device is connected, enable disconnection interrupt - Host_enable_device_disconnection_interrupt(); - // Reset device status - Host_clear_device_supported(); - Host_clear_configured(); - Host_clear_device_ready(); - Host_ack_sof(); - - TRACE_DEBUG("begin timer\n\r"); - gSystemTick = 0; - DelayMS(200); - TRACE_DEBUG("end timer\n\r"); - // Clear bad VBUS error - Usb_ack_vbus_error_interrupt(); - Host_disable_device_disconnection_interrupt(); - - Host_send_reset(); // First USB reset - Host_enable_sof(); // Start Start Of Frame generation - Host_enable_sof_interrupt(); // SOF will be detected under interrupt - - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()) { - if (Is_usb_device_enabled()) { - break; - } - } // Active wait of end of reset send - Host_ack_reset(); - // User can choose the number of consecutive resets sent - hostSOFCounter = 1; - while (hostSOFCounter != OTG_RESET_LENGTH ) { - Host_send_reset(); - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()) { - if (Is_usb_device_enabled()) { - break; - } - }// Active wait of end of reset send - Host_ack_reset(); - hostSOFCounter++; - } - - //Workaround for some bugly devices with powerless pull up - //usually low speed where data line rise slowly and can be interpretaded as disconnection - for(hostSOFCounter=0;hostSOFCounter!=0xFFFF;hostSOFCounter++) { // Basic Timeout counter - if(Is_usb_event(EVT_HOST_SOF)) { //If we detect SOF, device is still alive and connected, just clear false disconnect flag - if(Is_device_disconnection()) { - Host_ack_device_connection(); - Host_ack_device_disconnection(); - break; - } - } - } - Host_enable_device_disconnection_interrupt(); - hostSOFCounter = 0; - while (hostSOFCounter= WAIT_100MS) { - device_state = DEVICE_DEFAULT; - Host_select_pipe(PIPE_CONTROL); - Host_enable_pipe(); - host_configure_pipe(PIPE_CONTROL, - TYPE_CONTROL, - TOKEN_SETUP, - EP_CONTROL, - SIZE_64, - ONE_BANK, - 0 ); - device_state = DEVICE_DEFAULT; - } - } - break; - - case DEVICE_DEFAULT : - // DEVICE_DEFAULT state - // - Get device descriptor - // - Reconfigure Pipe 0 according to Device EP0 - // - Attribute device address - TRACE_DEBUG("DEVICE_DEFAULT\n\r"); - // Get first device descriptor - Peripheral_is_not_otg_device(); // init status variable - Init_timeout_bdev_response(); // init B-Device "waiting response" delay (handled by timer interrupt in usb_task.c) - - if( CONTROL_GOOD == host_get_device_descriptor_uncomplete()) { - hostSOFCounter = 0; - while(hostSOFCounter<20) { // wait 20ms before USB reset (special buggly devices...) - if (Is_usb_event(EVT_HOST_SOF)) { - Usb_ack_event(EVT_HOST_SOF); - hostSOFCounter++; - } - if (Is_host_emergency_exit() || Is_usb_bconnection_error_interrupt()) { - break; - } - } - Host_disable_device_disconnection_interrupt(); - Host_send_reset(); // First USB reset - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()); // Active wait of end of reset send - Host_ack_reset(); - hostSOFCounter = 1; - while (hostSOFCounter != OTG_RESET_LENGTH) { - Host_send_reset(); - Usb_ack_event(EVT_HOST_SOF); - while (Is_host_reset()); // Active wait of end of reset send - Host_ack_reset(); - hostSOFCounter++; - } - - //Workaround for some bugly devices with powerless pull up - //usually low speed where data line rise slowly and can be interpretaded as disconnection - for(hostSOFCounter=0;hostSOFCounter!=0xFFFF;hostSOFCounter++) { // Basic Timeout counter - if(Is_usb_event(EVT_HOST_SOF)) { //If we detect SOF, device is still alive and connected, just clear false disconnect flag - if(Is_device_disconnection()) { - Host_ack_device_connection(); - Host_ack_device_disconnection(); - break; - } - } - } - Host_enable_device_disconnection_interrupt(); - hostSOFCounter = 0; - while(hostSOFCounter<200) { // wait 200ms after USB reset - if (Is_usb_event(EVT_HOST_SOF)) { - Usb_ack_event(EVT_HOST_SOF); - hostSOFCounter++; - } - if (Is_host_emergency_exit() || Is_usb_bconnection_error_interrupt()) { - break; - } - } - - Host_select_pipe(PIPE_CONTROL); - Host_disable_pipe(); - Host_unallocate_memory(); - Host_enable_pipe(); - // Re-Configure the Ctrl Pipe according to the device ctrl EP - - TRACE_DEBUG("Size: 0x%X\n\r", (U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE]); - TRACE_DEBUG("Size Pipe: 0x%X\n\r", host_determine_pipe_size((U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE])); - - host_configure_pipe(PIPE_CONTROL, - TYPE_CONTROL, - TOKEN_SETUP, - EP_CONTROL, - host_determine_pipe_size((U16)data_stage[OFFSET_FIELD_MAXPACKETSIZE]), - ONE_BANK, - 0 ); - // Give an absolute device address - host_set_address(DEVICE_ADDRESS); - host_configure_address(PIPE_CONTROL, DEVICE_ADDRESS); - device_state = DEVICE_ADDRESSED; - } - else { - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_ADDRESSED : - // DEVICE_ADDRESSED state - // - Check if VID PID is in supported list - TRACE_DEBUG("DEVICE_ADDRESSED\n\r"); - if (CONTROL_GOOD == host_get_device_descriptor()) { - // Detect if the device connected belongs to the supported devices table - if (HOST_TRUE == host_check_VID_PID()) { - Host_set_device_supported(); - Host_device_supported_action(); - device_state = DEVICE_CONFIGURED; - // In OTG A-HOST state, initiate a HNP if the OTG B-DEVICE has requested this session with a SRP - if ((pOTGDescriptor->bOTGEnableHNPAfterSRP == ENABLE) && Is_host_session_started_srp() && Is_usb_id_host()) { - device_state = A_INIT_HNP; - } - else { - if (Is_device_supports_hnp()) { - if (CONTROL_GOOD != host_set_feature_a_hnp_support()) { - device_state = A_END_HNP_WAIT_VFALL; // end session if Device STALLs the request - } - } - } - } - else - { - // In OTG, if the B-DEVICE VID/PID does not match the Target Peripheral List, it is seen as "Unsupported" - // - a HNP must be initiated if the device supports it - // - an error message must be displayed (and difference must be made between "Std device" and "Hub") - desc_temp = data_stage[OFFSET_DEV_DESC_CLASS]; // store the device class (for future hub check) - if (b_uut_device_state != B_HOST) { - if (Is_host_session_started_srp()) { - if (CONTROL_GOOD == host_get_configuration_descriptor()) { - host_check_OTG_features(); - if (Is_device_supports_hnp()) { - device_state = A_INIT_HNP; // unsupported (or test) device will cause a HNP request - } - else { - device_state = A_END_HNP_WAIT_VFALL; - if (desc_temp == HUB_CLASS_CODE) { - // Display "Hub unsupported" message - Otg_print_new_failure_message(OTGMSG_UNSUPPORTED_HUB,OTG_TEMPO_4SEC); - } - else { - // Display "Class unsupported" message - TRACE_DEBUG("Class unsupported\n\r"); - Otg_print_new_failure_message(OTGMSG_UNSUPPORTED,OTG_TEMPO_4SEC); - } - } - } - else { - device_state = A_END_HNP_WAIT_VFALL; - } - } - else { - device_state = A_INIT_HNP; - } - } - else - { - TRACE_DEBUG("VID/PID does not match the Target Peripheral List\n\r"); - Otg_print_new_failure_message(OTGMSG_UNSUPPORTED,OTG_TEMPO_4SEC); - Set_user_request_disc(); // ask end of session now - Set_user_request_suspend(); - } - } - - } - else {// Can not get device descriptor - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_CONFIGURED : - // DEVICE_CONFIGURED state - // - Configure pipes for the supported interface - // - Send Set_configuration() request - // - Goto full operating mode (device ready) - TRACE_DEBUG("DEVICE_CONFIGURED\n\r"); - if (CONTROL_GOOD == host_get_configuration_descriptor()) { - if (HOST_FALSE != host_check_class()) { // Class support OK? - // Collect information about peripheral OTG descriptor if present - host_check_OTG_features(); - host_auto_configure_endpoint(); - - if (Is_host_configured()) { - if (CONTROL_GOOD== host_set_configuration(1)) { // Send Set_configuration - // host_set_interface(interface_bound,interface_bound_alt_set); - // device and host are now fully configured - // goto DEVICE READY normal operation - device_state = DEVICE_READY; - // monitor device disconnection under interrupt - Host_enable_device_disconnection_interrupt(); - // If user host application requires SOF interrupt event - // Keep SOF interrupt enable otherwize, disable this interrupt -#if (HOST_CONTINUOUS_SOF_INTERRUPT==DISABLE) - Host_disable_sof_interrupt(); -#endif - new_device_connected=TRUE; - TRACE_INFO("Device Enumerated\n\r"); - } - else { // Problem during Set_configuration request... - device_state = DEVICE_ERROR; - } - } - } - else { // device class not supported... - device_state = DEVICE_ERROR; - TRACE_INFO("Unsupported Device\n\r"); - Host_device_class_not_supported_action(); - } - } - else { // Can not get configuration descriptors... - device_state = DEVICE_ERROR; - } - break; - - case DEVICE_READY : - // DEVICE_READY state - // - Full standard operating mode - // - Nothing to do... - // Host full std operating mode! - new_device_connected=FALSE; - - // Handles user requests : "stop Vbus" and "suspend" - if (Is_usb_id_host()) { - if (Is_user_requested_suspend() || Is_user_requested_hnp()) { - // Before entering suspend mode, A-Host must send a SetFeature(b_hnp_enable) if supported by the B-Periph - Ack_user_request_hnp(); - Ack_user_request_suspend(); - device_state = A_INIT_HNP; - } - } - break; - - case DEVICE_ERROR : - //------------------------------------------------------ - // DEVICE_ERROR state - // - Error state - // - Do custom action call (probably go to default mode...) - TRACE_DEBUG("DEVICE_ERROR\n\r"); - device_state=DEVICE_UNATTACHED; - Host_device_error_action(); - break; - - case DEVICE_SUSPENDED : - // DEVICE_SUSPENDED state - // - Host application request to suspend the device activity - // - State machine comes here thanks to Host_request_suspend() - TRACE_DEBUG("DEVICE_SUSPENDED\n\r"); - // If OTG device, initiate a HNP process (go to specific state) - if (Is_peripheral_otg_device()) { - device_state = A_INIT_HNP; - } - else { - device_state=DEVICE_WAIT_RESUME; // wait for device resume event - if(Is_device_supports_remote_wakeup()) { // If the connected device supports remote wake up - if (CONTROL_GOOD != host_set_feature_remote_wakeup()) { - device_state = DEVICE_DISCONNECTED; // stop connexion because device has not accepted the feature - } - } - TRACE_INFO("Usb suspend\n\r"); - hostSOFCounter = Is_host_sof_interrupt_enabled(); //Save current sof interrupt enable state - Host_disable_sof_interrupt(); - Host_ack_sof(); - Host_disable_sof(); // Stop start of frame generation, this generates the suspend state - Host_ack_remote_wakeup(); - Host_enable_remote_wakeup_interrupt(); - Host_ack_hwup(); - Host_enable_hwup_interrupt(); // Enable host wake-up interrupt - // (this is the unique USB interrupt able to wake up the CPU core from power-down mode) - Usb_freeze_clock(); - Host_suspend_action(); // Custom action here! (for example go to power-save mode...) - } - break; - - case DEVICE_WAIT_RESUME : - // DEVICE_WAIT_RESUME state - // - Wait in this state till the host receives an upstream resume from the device - // - or the host software request the device to resume - TRACE_DEBUG("DEVICE_WAIT_RESUME\n\r"); - if(Is_usb_event(EVT_HOST_REMOTE_WAKEUP)|| Is_host_request_resume()) { // Remote wake up has been detected - // or Local resume request has been received - if(Is_host_request_resume()) { // Not a remote wakeup, but an host application request - Host_disable_hwup_interrupt(); // Wake up interrupt should be disable host is now wake up ! - // CAUTION HWUP can be cleared only when USB clock is active - // Pll_start_auto(); // First Restart the PLL for USB operation - // Wait_pll_ready(); // Get sure pll is lock - Usb_unfreeze_clock(); // Enable clock on USB interface - } - Host_ack_hwup(); // Clear HWUP interrupt flag - Host_enable_sof(); - - if (Is_usb_event(EVT_HOST_REMOTE_WAKEUP)) { - Usb_ack_event(EVT_HOST_REMOTE_WAKEUP); // Ack software event - Host_disable_sof_interrupt(); - Host_ack_device_disconnection(); - Host_disable_device_disconnection_interrupt(); - - Host_send_resume(); // this other downstream resume is done to ensure min. 20ms of HOST DRIVING RESUME (not Device) - while (!Is_device_disconnection() && Host_is_resume()); - hostSOFCounter = 0; - Host_ack_sof(); - while (!Is_device_disconnection() && (hostSOFCounter != 12)) { // wait for min. 10ms of device recovery time - if (Is_host_sof()) { - Host_ack_sof(); - hostSOFCounter++; - } - } - if (Is_device_disconnection()) { - usb_host_task_init(); - device_state = DEVICE_DISCONNECTED; - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - } - else { - device_state = DEVICE_READY; - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - } - Host_enable_device_disconnection_interrupt(); - Host_ack_sof(); - } - else { - Host_send_resume(); // Send down stream resume - //----------------------- - // Work-around for case of Device disconnection during Suspend - // The disconnection is never detected and the Resume bit remains high (and RSMEDI flag never set) - // If the timeout elapses, it implies that the device has disconnected => macro is reset (to reset the Resume bit) - dec = 0; - while (dec < 0x4FFFF) { // several hundreds of ms - if (Is_host_down_stream_resume()) { // Wait Down stream resume sent - Host_ack_remote_wakeup(); // Ack remote wake-up reception - Host_ack_request_resume(); // Ack software request - Host_ack_down_stream_resume(); // Ack down stream resume sent - if(hostSOFCounter) { - Host_enable_sof_interrupt(); - } // Restore SOF interrupt enable state before suspend - device_state=DEVICE_READY; // Come back to full operating mode - TRACE_INFO("Usb resumed\n\r"); - dec = 0x3FFFFE; // will cause a loop end - } - dec++; - } - if (dec != 0x3FFFFF) { // if resume failed - usb_host_task_init(); - device_state = DEVICE_DISCONNECTED; - } - else - { - hostSOFCounter = 0; - Host_ack_sof(); - while (!Is_device_disconnection() && (hostSOFCounter != 12)) { // wait for min. 10ms of device recovery time - if (Is_host_sof()) { - Host_ack_sof(); - hostSOFCounter++; - } - } - } - //-----------------------End of Work Around - } - } - break; - - case DEVICE_DISCONNECTED : - // DEVICE_DISCONNECTED state - // - Device disconnection has been detected - // - Run scheduler in this state at least two times to get sure event is detected by all host application tasks - // - Go to DEVICE_DISCONNECTED_ACK state before DEVICE_UNATTACHED, to get sure scheduler calls all app tasks... - TRACE_DEBUG("DEVICE_DISCONNECTED\n\r"); - device_state = DEVICE_DISCONNECTED_ACK; - break; - - case DEVICE_DISCONNECTED_ACK : - // DEVICE_DISCONNECTED_ACK state - // - Device disconnection has been detected and managed bu applicatives tasks - // - Go to DEVICE_UNATTACHED state - TRACE_DEBUG("DEVICE_DISCONNECTED_ACK\n\r"); - host_disable_all_pipe(); - device_state = DEVICE_UNATTACHED; - End_session_with_srp(); - Usb_ack_srp_interrupt(); - break; - - case A_PERIPHERAL: - // OTG Specific states : A_PERIPHERAL (A-Host has been turned into a Device after a HNP) - // - End session (and stop driving Vbus) when detecting suspend condition - // - Disconnect on user request - // - Call standard (non-OTG) device task to handle the Endpoint 0 requests - TRACE_DEBUG("A_PERIPHERAL\n\r"); - // End of role exchange : A_PERIPH go into DEVICE_DISCONNECTED mode : stop supplying VBUS - if (Is_usb_event(EVT_USB_SUSPEND)) { - Clear_all_user_request(); - Usb_ack_event(EVT_USB_SUSPEND); - Usb_disable_wake_up_interrupt(); - Usb_ack_role_exchange_interrupt(); - Usb_select_host(); - USBD_Connect();//Usb_attach(); - Usb_unfreeze_clock(); - b_uut_device_state = B_IDLE; - device_state = A_END_HNP_WAIT_VFALL; - Usb_ack_srp_interrupt(); - } - if (Is_user_requested_disc() || Is_user_requested_vbus()) { - Clear_all_user_request(); - Usb_disable_suspend_interrupt(); - Usb_ack_role_exchange_interrupt(); - Usb_select_host(); - Usb_unfreeze_clock(); - b_uut_device_state = B_IDLE; - device_state = A_END_HNP_WAIT_VFALL; - } - if (!Is_device_disconnection_event() && (device_state != A_END_HNP_WAIT_VFALL)) { - //usb_device_task(); - //MSDDriver_StateMachine(); - Scheduler_task_3(); - } - break; - - case A_INIT_HNP: - // OTG Specific states : A_INIT_HNP - // - Software enters this state when it has been requested to initiate a HNP - // - Handle "set feature" commands such as B_HNP_ENABLE or REMOTE_WAKE_UP - // - Handle failures - TRACE_DEBUG("A_INIT_HNP\n\r"); - Ack_user_request_hnp(); - Ack_user_request_suspend(); - if (Is_peripheral_otg_device() || !Is_host_configured()) { - device_state = A_SUSPEND; - if(Is_device_supports_remote_wakeup() && Is_host_configured()) { // If the connected device supports remote wake up - if (CONTROL_GOOD == host_set_feature_remote_wakeup()) { - Host_ack_remote_wakeup(); - Host_enable_remote_wakeup_interrupt(); - Host_ack_hwup(); - Host_enable_hwup_interrupt(); // Enable host wake-up interrupt - } - else { - device_state = A_END_HNP_WAIT_VFALL; // stop connection because device has STALLed the feature - } - } - if (Is_device_supports_hnp() || !Is_host_configured()) { - if (CONTROL_GOOD == host_set_feature_b_hnp_enable()) { - // B-Device has not STALLed the SetFeature - Usb_host_accept_hnp(); - Usb_ack_role_exchange_interrupt(); - Usb_ack_hnp_error_interrupt(); - Usb_enable_role_exchange_interrupt(); - Usb_enable_hnp_error_interrupt(); - Host_disable_device_disconnection_interrupt(); - Host_disable_device_connection_interrupt(); - } - else { - Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC); - device_state = A_END_HNP_WAIT_VFALL; - } - } - Host_ack_remote_wakeup(); - Host_enable_remote_wakeup_interrupt(); - Init_ta_aidl_bdis_counter(); - Host_disable_sof_interrupt(); - Host_ack_sof(); - Host_disable_sof(); // Stop start of frame generation, this generates the suspend state - Usb_disable_suspend_interrupt(); - } - else { - device_state = DEVICE_SUSPENDED; - } - break; - - case A_SUSPEND: - // OTG Specific states : A_SUSPEND - // - A-Host enters this state when it has requested the B-DEVICE to start HNP, and have entered Suspend mode - // - Detects device silences (with HNP time-out management) and Resume condition - TRACE_DEBUG("A_SUSPEND\n\r"); - Usb_ack_suspend(); - // HNP is managed by interrupt (HNPERRI/ROLEEXI) - if (Is_ta_aidl_bdis_counter_overflow()) { - device_state = A_END_HNP_WAIT_VFALL; // stop Vbus = end of current session - } - if (Is_usb_event(EVT_HOST_HWUP)|| Is_host_request_resume()) { - device_state = DEVICE_WAIT_RESUME; - } - break; - - case A_END_HNP_WAIT_VFALL: - // OTG Specific states : A_END_HNP_WAIT_VFALL - // - A-PERIPH enters this state when it has detected a Suspend from the B-Host - // - It stop Vbus delivery and waits line discharge (to avoid spurious SRP detection) - TRACE_DEBUG("A_END_HNP_WAIT_VFALL\n\r"); - Usb_disable_manual_vbus(); - Usb_disable_vbus(); - usb_configuration_nb = 0; - Host_vbus_action(); - Clear_all_user_request(); - device_state = DEVICE_DISCONNECTED; - usb_host_task_init(); - break; - - case A_TEMPO_VBUS_DISCHARGE: - // OTG Specific states : A_TEMPO_VBUS_DISCHARGE - // - State entered from A_END_HNP_WAIT_VFALL, when Vbus has just reached the vbus_valid threshold - // - In this state we wait long enough (50ms) to be sure that Vbus is not valid on the other device (if still connected) - // - When delay is elapsed, go to reset state - TRACE_DEBUG("A_TEMPO_VBUS_DISCHARGE\n\r"); - if (otg_end_hnp_vbus_delay == 0) { - Host_ack_device_connection(); - Host_ack_device_disconnection(); - Usb_ack_role_exchange_interrupt(); - Usb_ack_srp_interrupt(); - device_state = DEVICE_DISCONNECTED; - } - break; - - default : - // default state - // - Default case: ERROR - // - Goto no device state - TRACE_DEBUG("default\n\r"); - device_state = DEVICE_UNATTACHED; - break; - } -} - -//------------------------------------------------------------------------------ -/// This function send nb_data pointed with *buf with the pipe number specified -/// This function will activate the host sof interrupt to detect timeout. The -/// interrupt enable sof will be restore. -//------------------------------------------------------------------------------ -U8 host_send_data(U8 pipe, U16 nb_data, U8 *buf) -{ - U16 length; - U8 status=PIPE_GOOD; - U8 sav_int_sof_enable; - U8 nak_timeout; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - U16 cpt_nak; -#endif - U16 nb_data_loaded; - - TRACE_DEBUG("host_send_data[]%d: %d\n\r", pipe, nb_data); - - sav_int_sof_enable=Is_host_sof_interrupt_enabled(); // Save state of enable sof interrupt - Host_enable_sof_interrupt(); - Host_select_pipe(pipe); - - Host_set_token_in(); - - Host_set_token_out(); - Host_ack_out_sent(); - /* - TRACE_DEBUG("CTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_CTRL); - TRACE_DEBUG("SR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_SR); - TRACE_DEBUG("DEVCTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVCTRL); - TRACE_DEBUG("DEVISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVISR); - TRACE_DEBUG("DEVIMR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVIMR); - TRACE_DEBUG("DEVEPTISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_DEVEPTISR[0]); - TRACE_DEBUG("HSTCTRL: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTCTRL); - TRACE_DEBUG("HSTISR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTISR); - TRACE_DEBUG("HSTIMR: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTIMR); - TRACE_DEBUG("HSTPIP: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIP); - TRACE_DEBUG("HSTPIPCFG[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[0]); - TRACE_DEBUG("HSTPIPCFG[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[1]); - TRACE_DEBUG("HSTPIPCFG[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPCFG[2]); - TRACE_DEBUG("HSTPIPINRQ[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[0]); - TRACE_DEBUG("HSTPIPINRQ[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[1]); - TRACE_DEBUG("HSTPIPINRQ[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPINRQ[2]); - TRACE_DEBUG("HSTPIPERR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[0]); - TRACE_DEBUG("HSTPIPERR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[1]); - TRACE_DEBUG("HSTPIPERR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPERR[2]); - TRACE_DEBUG("HSTPIPISR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[0]); - TRACE_DEBUG("HSTPIPISR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[1]); - TRACE_DEBUG("HSTPIPISR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPISR[2]); - TRACE_DEBUG("HSTPIPIMR[0]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[0]); - TRACE_DEBUG("HSTPIPIMR[1]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[1]); - TRACE_DEBUG("HSTPIPIMR[2]: 0x%X\n\r",AT91C_BASE_OTGHS->OTGHS_HSTPIPIMR[2]); - */ - while (nb_data != 0) { // While there is something to send... - Host_unfreeze_pipe(); - // Prepare data to be sent - length = host_get_pipe_length(); - TRACE_DEBUG("size=%d\n\r", length); - - if ( length > nb_data) { - nb_data_loaded = nb_data; - length = nb_data; - } - else { - nb_data_loaded = length; - } - Address_fifochar_endpoint(global_pipe_nb); - while (length!=0) { // Load Pipe buffer - Host_write_byte(*buf++); - //(((char*)((unsigned int *)AT91C_BASE_OTGHS_EPTFIFO->OTGHS_READEPT0))[dBytes++])=*(buf++); - //pFifo[dBytes++] = *buf; - //buf++; - length--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine -#if (NAK_TIMEOUT_ENABLE==ENABLE) - cpt_nak=0; -#endif - nak_timeout=0; - Host_ack_out_sent(); - Host_send_out(); - while (!Is_host_out_sent()) { - if (Is_host_emergency_exit()) { // Async disconnection or role change detected under interrupt - TRACE_DEBUG("Emergency exit\n\r"); - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - if (private_sof_counter>=250) { // Count 250ms (250sof) - TRACE_DEBUG("TimeOut Send Data\n\r"); - private_sof_counter=0; - if (nak_timeout++>=TIMEOUT_DELAY) { // Inc timeout and check for overflow - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - } - if (Is_host_pipe_error()) { // Any error ? - TRACE_DEBUG("pipe error\n\r"); - status = Host_error_status(); - Host_ack_all_errors(); - goto host_send_data_end; - } - if (Is_host_stall()) { // Stall management - TRACE_DEBUG("stall\n\r"); - status =PIPE_STALL; - Host_ack_stall(); - goto host_send_data_end; - } -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if(Is_host_nak_received()) { //NAK received - Host_ack_nak_received(); - if (cpt_nak++>NAK_SEND_TIMEOUT) { - TRACE_DEBUG("NAK timeout\n\r"); - status = PIPE_NAK_TIMEOUT; - Host_reset_pipe(pipe); - goto host_send_data_end; - } - } -#endif - } - // Here OUT sent - nb_data -= nb_data_loaded; - status=PIPE_GOOD; // Frame correctly sent - Host_ack_out_sent(); - } - Host_freeze_pipe(); - -host_send_data_end: - // Restore sof interrupt enable state - if (sav_int_sof_enable==FALSE) { - Host_disable_sof_interrupt(); - } - // And return... - return ((U8)status); -} - - - -//------------------------------------------------------------------------------ -/// This function receives nb_data pointed with *buf with the pipe number specified -/// The nb_data parameter is passed as a U16 pointer, thus the data pointed by this pointer -/// is updated with the final number of data byte received. -//------------------------------------------------------------------------------ -U8 host_get_data(U8 pipe, U16 *nb_data, U8 *buf) -{ - U8 status=PIPE_GOOD; - U8 sav_int_sof_enable; - U8 nak_timeout; - U16 n; - U16 i; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - U16 cpt_nak; -#endif - - // TRACE_DEBUG("host_get_data[%d]\n\r", pipe); - n=*nb_data; - *nb_data=0; - - sav_int_sof_enable=Is_host_sof_interrupt_enabled(); - Host_enable_sof_interrupt(); - - Host_select_pipe(pipe); - Host_set_token_in(); - Host_continuous_in_mode(); - // Host_ack_in_received(); - - while (n) { // While missing data... - // start IN request generation - Host_unfreeze_pipe(); - Host_send_in(); - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - nak_timeout=0; -#if (NAK_TIMEOUT_ENABLE==ENABLE) - cpt_nak=0; -#endif - while (!Is_host_in_received()) - { - if (Is_host_emergency_exit()) // Async disconnection or role change detected under interrupt - { - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - if (private_sof_counter>=250) // Timeout management - { - private_sof_counter=0; // Done in host SOF interrupt - if (nak_timeout++>=TIMEOUT_DELAY)// Check for local timeout - { - status=PIPE_DELAY_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - } - if(Is_host_pipe_error()) // Error management - { - status = Host_error_status(); - Host_ack_all_errors(); - goto host_get_data_end; - } - if(Is_host_stall()) // STALL management - { - status =PIPE_STALL; - Host_reset_pipe(pipe); - Host_ack_stall(); - goto host_get_data_end; - } -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if(Is_host_nak_received()) //NAK received - { - Host_ack_nak_received(); - if (cpt_nak++>NAK_RECEIVE_TIMEOUT) - { - status = PIPE_NAK_TIMEOUT; - Host_reset_pipe(pipe); - goto host_get_data_end; - } - } -#endif - } - status=PIPE_GOOD; - Host_freeze_pipe(); - if (Host_byte_counter()<=n) - { - if ((Host_byte_counter() < n)&&(Host_byte_counter() nb_data) // Pipe size> remaining data - { - i = nb_data; - nb_data = 0; - } - else // Pipe size < remaining data - { - nb_data -= i; - } - it_pipe_str[pipe].nb_byte_on_going+=i; // Update nb data processed - Address_fifochar_endpoint(global_pipe_nb); - while (i!=0) // Load Pipe buffer - { - Host_write_byte(*ptr_buf++); - i--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe].timeout=0; // Refresh timeout counter - Host_ack_out_sent(); - Host_ack_stall(); - Host_ack_nak_received(); - - Host_enable_stall_interrupt(); - Host_enable_error_interrupt(); -#if (NAK_TIMEOUT_ENABLE==ENABLE) - Host_enable_nak_interrupt(); -#endif - Host_enable_transmit_interrupt(); - Host_send_out(); // Send the USB frame - return HOST_TRUE; - } -} - -//------------------------------------------------------------------------------ -//! @brief USB pipe interrupt subroutine -//! -//! @param none -//! -//! @return none -//------------------------------------------------------------------------------ -void usb_pipe_interrupt(void) -{ - U8 pipe_nb; - U8 *ptr_buf; - void (*fct_handle)(U8 status,U16 nb_byte); - U16 n; - U8 i; - U8 do_call_back=FALSE; - - TRACE_DEBUG("usb_pipe_interrupt\n\r"); - - if(Host_get_pipe_interrupt()) { - - pipe_nb_save = Host_get_selected_pipe(); // Important! Save here working pipe number - pipe_nb=host_get_nb_pipe_interrupt(); // work with the correct pipe number that generates the interrupt - Host_select_pipe(pipe_nb); // Select this pipe - fct_handle=*(it_pipe_str[pipe_nb].handle); - - // Now try to detect what event generate an interrupt... - if (Is_host_pipe_error()) // Any error ? - { - TRACE_DEBUG("host_pipe_error\n\r"); - it_pipe_str[pipe_nb].status = Host_error_status(); - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - Host_ack_all_errors(); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - - if (Is_host_stall()) // Stall handshake received ? - { - TRACE_DEBUG("host_stall\n\r"); - it_pipe_str[pipe_nb].status=PIPE_STALL; - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - -#if (NAK_TIMEOUT_ENABLE==ENABLE) - if (Is_host_nak_received()) // NAK ? - { - Host_ack_nak_received(); - // check if number of NAK timeout error occurs (not for interrupt type pipe) - if((--it_pipe_str[pipe_nb].nak_timeout==0) && (Host_get_pipe_type()!=TYPE_INTERRUPT)) - { - it_pipe_str[pipe_nb].status=PIPE_NAK_TIMEOUT; - it_pipe_str[pipe_nb].enable=DISABLE; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - goto usb_pipe_interrupt_end; - } - } -#endif - - if (Is_host_in_received()) // Pipe IN reception ? - { - TRACE_DEBUG("host_in received\n\r"); - ptr_buf = it_pipe_str[pipe_nb].ptr_buf; - ptr_buf += it_pipe_str[pipe_nb].nb_byte_processed; // Build pointer to data buffer - n = it_pipe_str[pipe_nb].nb_byte_to_process; - n -= it_pipe_str[pipe_nb].nb_byte_processed; // Remaining data bytes - Host_freeze_pipe(); - if (Host_byte_counter()<=n) - { - if ((Host_byte_counter() < n)&&(Host_byte_counter()0) //still something to process - { - Host_unfreeze_pipe(); // Request another IN transfer - Host_send_in(); - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe_nb].timeout=0; // Reset timeout - it_pipe_str[pipe_nb].nak_timeout=NAK_RECEIVE_TIMEOUT; - } - else //end of transfer - { - it_pipe_str[pipe_nb].enable=DISABLE; - it_pipe_str[pipe_nb].status=PIPE_GOOD; - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - } - } - - if(Is_host_out_sent()) // Pipe OUT sent ? - { - TRACE_DEBUG("host_out send\n\r"); - Host_ack_out_sent(); - it_pipe_str[pipe_nb].nb_byte_processed+=it_pipe_str[pipe_nb].nb_byte_on_going; - it_pipe_str[pipe_nb].nb_byte_on_going=0; - ptr_buf = it_pipe_str[pipe_nb].ptr_buf; - ptr_buf += it_pipe_str[pipe_nb].nb_byte_processed; // Build pointer to data buffer - n = it_pipe_str[pipe_nb].nb_byte_to_process; - n -= it_pipe_str[pipe_nb].nb_byte_processed; // Remaining data bytes - if(n>0) // Still data to process... - { - Host_unfreeze_pipe(); - // Prepare data to be sent - i = host_get_pipe_length(); - if ( i > n) // Pipe size> remaining data - { - i = n; - n = 0; - } - else // Pipe size < remaining data - { - n -= i; - } - it_pipe_str[pipe_nb].nb_byte_on_going+=i; // Update nb data processed - Address_fifochar_endpoint(global_pipe_nb); - while (i!=0) // Load Pipe buffer - { - Host_write_byte(*ptr_buf++); i--; - } - private_sof_counter=0; // Reset the counter in SOF detection sub-routine - it_pipe_str[pipe_nb].timeout=0; // Refresh timeout counter - it_pipe_str[pipe_nb].nak_timeout=NAK_SEND_TIMEOUT; - Host_send_out(); // Send the USB frame - } - else //n==0 Transfer is finished - { - it_pipe_str[pipe_nb].enable=DISABLE; // Tranfer end - it_pipe_str[pipe_nb].status=PIPE_GOOD; // Status OK - Host_stop_pipe_interrupt(pipe_nb); - do_call_back=TRUE; - } - } - -usb_pipe_interrupt_end: - Host_select_pipe(pipe_nb_save); // Restore pipe number !!!! - if (is_any_interrupt_pipe_active()==FALSE) // If no more transfer is armed - { - if (g_sav_int_sof_enable==FALSE) - { - Host_disable_sof_interrupt(); - } - } - if(do_call_back) // Any callback functions to perform ? - { - fct_handle(it_pipe_str[pipe_nb].status,it_pipe_str[pipe_nb].nb_byte_processed); - } - - } - -} - - - diff --git a/src/ersky9x/libraries/usb/otg/usb_task.c b/src/ersky9x/libraries/usb/otg/usb_task.c deleted file mode 100644 index 043879ff9..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_task.c +++ /dev/null @@ -1,999 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "main.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "otg_user_task.h" -#include "usb_task.h" -#include "usb/otg/usb_drv.h" - -#if ((USB_HOST_FEATURE == ENABLE)) - #include "usb/otg/usb_host_task.h" -#endif - -#if ((USB_DEVICE_FEATURE == ENABLE)) -#include -#include -#include -#include -#include -#include -#include -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - - - -extern volatile unsigned int timer_set_counter; -#define Timer16_select(...) -#define Timer16_set_counter(value) timer_set_counter = value -#define Timer16_get_counter_low() (unsigned char)timer_set_counter - - -/// Returns the OTG features sent by the host by a SetFeature -/// Allow also to clear the features (only on a bus Reset or Session End) -#define Is_host_requested_hnp() (((otg_features_supported&USBFeatureRequest_OTG_B_HNP_ENABLE) != 0) ? TRUE : FALSE) -#define Clear_otg_features_from_host() (otg_features_supported = 0) - -#define Set_otg_custom_timer(ep) // STUB: todo - -#define USB_MODE_UNDEFINED 0x00 -#define USB_MODE_HOST 0x01 -#define USB_MODE_DEVICE 0x02 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -U8 otg_device_sessions; -U8 b_uut_device_state; -U16 otg_tb_srp_cpt; - -/// usb_connected is used to store USB events detected upon -/// USB general interrupt subroutine -/// Its value is managed by the following macros (See usb_task.h file) -/// Usb_send_event(x) -/// Usb_ack_event(x) -/// Usb_clear_all_event() -/// Is_usb_event(x) -/// Is_not_usb_event(x) -volatile U16 g_usb_event=0; - - -#if (USB_DEVICE_FEATURE == ENABLE) -/// -/// Public : (bit) usb_connected -/// usb_connected is set to TRUE when VBUS has been detected -/// usb_connected is set to FALSE otherwise -/// Used with USB_DEVICE_FEATURE == ENABLE only -//// -bit usb_connected; - -/// -/// Public : (U8) usb_configuration_nb -/// Store the number of the USB configuration used by the USB device -/// when its value is different from zero, it means the device mode is enumerated -/// Used with USB_DEVICE_FEATURE == ENABLE only -//// -U8 usb_configuration_nb; - -/// -/// Public : (U8) remote_wakeup_feature -/// Store a host request for remote wake up (set feature received) -//// -U8 remote_wakeup_feature; -#endif - - -#if (USB_HOST_FEATURE == ENABLE) -/// -/// Private : (U8) private_sof_counter -/// Incremented by host SOF interrupt subroutime -/// This counter is used to detect timeout in host requests. -/// It must not be modified by the user application tasks. -//// -volatile U8 private_sof_counter=0; - -extern volatile S_pipe_int it_pipe_str[MAX_EP_NB]; - -#endif - -#if ((USB_DEVICE_FEATURE == ENABLE)&& (USB_HOST_FEATURE == ENABLE)) -/// -/// Public : (U8) g_usb_mode -/// Used in dual role application (both device/host) to store -/// the current mode the usb controller is operating -//// - U8 g_usb_mode=USB_MODE_UNDEFINED; - U8 g_old_usb_mode; -#endif - - -#if (USB_OTG_FEATURE == ENABLE) - /// - /// Public : (U8) otg_features_supported; - /// -> A-Device side : indicates if the B-Device supports HNP and SRP (this is the bmAttributes field of OTG Decriptor) - /// -> B-Device side : indicates if the A-Device has enabled the "a_hnp_support" and "b_hnp_enable" features - volatile U8 otg_features_supported; - - /// Public : (U8) otg_user_request; - /// Store the last request of the user (see usb_device_task.h) - U8 otg_user_request; - - /// Public : (U16) otg_msg_event_delay; - /// Contains the current display duration of the OTG event message - U16 otg_msg_event_delay; - - /// Public : (U16) otg_msg_failure_delay; - /// Contains the current display duration of the OTG failure message - U16 otg_msg_failure_delay; - - /// Public : (U16) g_otg_event; - /// Contains several bits corresponding to differents OTG events (similar to g_usb_event) - volatile U16 g_otg_event; - - /// Public : (U8) otg_device_nb_hnp_retry; - /// Counts the number of times a HNP fails, before aborting the operations - U8 otg_device_nb_hnp_retry; - - U8 id_changed_to_host_event; - - volatile U8 otg_last_sof_received; // last SOF received in SOF interrupt - volatile U8 otg_last_sof_stored; // last SOF value stored in OTG Timer interrupt - volatile U8 reset_received; // indicates if a reset has been received from B-Host after a HNP (used in A-Periph mode) - - /// @brief VBUS Overload management - /// - /// Nothing to do ! If the condition is not defined in the board driver file - /// (i.e. if the board does not support Vbus overcurrent detection), - /// the macro is defined to false for firmware compatibility -#define Is_vbus_overcurrent() (FALSE) - - /// Private function prototypes - /// Tasks for OTG Messaging features - void Otg_message_task_init(void); - void Otg_message_task(void); -#endif - - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the USB process -/// Depending on the mode supported (HOST/DEVICE/DUAL_ROLE) the function calls -/// the coresponding USB mode initialization function -//------------------------------------------------------------------------------ -void usb_task_init(void) -{ - -// ---- DUAL ROLE DEVICE USB MODE --------------------------------------------- -#if (USB_OTG_FEATURE == ENABLE) - Otg_message_task_init(); // OTG program needs to display event messages to the user - b_uut_device_state = B_IDLE; // init state machines variables -#if (USB_HOST_FEATURE == ENABLE) - device_state = DEVICE_UNATTACHED; -#endif - otg_device_nb_hnp_retry = BDEV_HNP_NB_RETRY; - Clear_all_user_request(); -#endif - -#if (((USB_DEVICE_FEATURE == ENABLE) && (USB_HOST_FEATURE == ENABLE)) || (USB_OTG_FEATURE == ENABLE)) -#if (USB_OTG_FEATURE == ENABLE) - Usb_enable_uid_pin(); -#endif - - // delay=PORTA; - g_usb_mode=USB_MODE_UNDEFINED; - - if(Is_usb_id_device()) - { - g_usb_mode=USB_MODE_DEVICE; - //usb_device_task_init(); - MSDDriver_Initialize(luns, numMedias); - -#if (USB_OTG_FEATURE == ENABLE) - id_changed_to_host_event = DISABLE; -#endif - } - else - { - Usb_send_event(EVT_USB_HOST_FUNCTION); - g_usb_mode=USB_MODE_HOST; - Usb_ack_id_transition(); // REQUIRED !!! Startup with ID=0, Ack ID pin transistion (default hwd start up is device mode) - Usb_enable_id_interrupt(); - usb_host_task_init(); -#if (USB_OTG_FEATURE == ENABLE) - id_changed_to_host_event = ENABLE; -#endif - } -#if ((USB_DEVICE_FEATURE == ENABLE)&& (USB_HOST_FEATURE == ENABLE)) - g_old_usb_mode = g_usb_mode; // Store current usb mode, for mode change detection -#endif - // ------------------------------------------------------------------------- - - // ---- DEVICE ONLY USB MODE ----------------------------------------------- -#elif ((USB_DEVICE_FEATURE == ENABLE)&& (USB_HOST_FEATURE == DISABLE)) - //jcbUsb_force_device_mode(); - //usb_device_task_init(); - MSDDriver_Initialize(luns, numMedias); - // ------------------------------------------------------------------------- - - // ---- REDUCED HOST ONLY USB MODE ----------------------------------------- -#elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLE)) - //jcbUsb_force_host_mode(); - usb_host_task_init(); -#elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE)) -#error at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled -#endif - // ------------------------------------------------------------------------- - -} - - -//------------------------------------------------------------------------------ -/// Entry point of the USB mamnagement -/// Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function -/// calls the coresponding USB management function -//------------------------------------------------------------------------------ -void usb_task(void) -{ - // ---- DUAL ROLE DEVICE USB MODE --------------------------------------------- -#if ((USB_DEVICE_FEATURE == ENABLE) && (USB_HOST_FEATURE == ENABLE)) - if(Is_usb_id_device()) { - g_usb_mode = USB_MODE_DEVICE; - } - else { - g_usb_mode = USB_MODE_HOST; - } - g_old_usb_mode = g_usb_mode; // Store current usb mode, for mode change detection - // Depending on current usb mode, launch the correct usb task (device or host) - -#if (USB_OTG_FEATURE == ENABLE) - // Configure OTG timers - Set_otg_custom_timer(VBUSRISE_70MS); - Set_otg_custom_timer(VBUSPULSE_40MS); - Set_otg_custom_timer(VFALLTMOUT_131MS); - Set_otg_custom_timer(SRPMINDET_100US); -#endif - - switch(g_usb_mode) { - case USB_MODE_DEVICE: - //usb_device_task(); - MSDDriver_StateMachine(); - break; - - case USB_MODE_HOST: - if( pOTGDescriptor.bOTGADevSRPReaction == VBUS_PULSE) { - Usb_select_vbus_srp_method(); - } - else { - Usb_select_data_srp_method(); - } - usb_host_task(); - // Handle Vbus overcurrent error (auto-disabled if not supported or not defined in board driver file) -#if (USB_OTG_FEATURE == ENABLE) - if (Is_vbus_overcurrent()) { - Otg_print_new_event_message(OTGMSG_VBUS_SURCHARGE,OTG_TEMPO_3SEC); - } -#endif - break; - - case USB_MODE_UNDEFINED: // No break ! - default: - break; - } - // ------------------------------------------------------------------------- - // ---- DEVICE ONLY USB MODE ----------------------------------------------- -#elif ((USB_DEVICE_FEATURE == ENABLE)&& (USB_HOST_FEATURE == DISABLE)) - //usb_device_task(); - MSDDriver_StateMachine(); - // ------------------------------------------------------------------------- - - // ---- REDUCED HOST ONLY USB MODE ----------------------------------------- -#elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLE)) - usb_host_task(); - // ------------------------------------------------------------------------- - - /// ---- ERROR, NO MODE ENABLE --------------------------------------------- -#elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE)) -#error at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled -#error otherwise the usb task has nothing to do ... -#endif - // ------------------------------------------------------------------------- - -#if (USB_OTG_FEATURE == ENABLE) - Otg_message_task(); -#endif -} - - - -//------------------------------------------------------------------------------ -/// USB interrupt subroutine -/// -/// This function is called each time a USB interrupt occurs. -/// The following USB DEVICE events are taken in charge: -/// - VBus On / Off -/// - Start Of Frame -/// - Suspend -/// - Wake-Up -/// - Resume -/// - Reset -/// - Start of frame -/// -/// The following USB HOST events are taken in charge: -/// - Device connection -/// - Device Disconnection -/// - Start Of Frame -/// - ID pin change -/// - SOF (or Keep alive in low speed) sent -/// - Wake up on USB line detected -/// -/// The following USB HOST events are taken in charge: -/// - HNP success (Role Exchange) -/// - HNP failure (HNP Error) -/// -/// For each event, the user can launch an action by completing -/// the associate define (See conf_usb.h file to add action upon events) -/// -/// Note: Only interrupts events that are enabled are processed -//------------------------------------------------------------------------------ -void usb_general_interrupt(void) -{ - U8 i; - U8 save_pipe_nb; - - // ---------- DEVICE events management ----------------------------------- - // ----------------------------------------------------------------------- -#if ((USB_DEVICE_FEATURE == ENABLE) || (USB_OTG_FEATURE == ENABLE)) - - //- VBUS state detection - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - if (Is_usb_vbus_transition() && Is_usb_vbus_interrupt_enabled() - && Is_usb_id_device()) { - Usb_ack_vbus_transition(); - - if (Is_usb_vbus_high()) { - usb_connected = TRUE; - Usb_vbus_on_action(); - Usb_send_event(EVT_USB_POWERED); - //jcb Usb_enable_reset_interrupt(); - //usb_start_device(); - USBD_Connect();//Usb_attach(); - } - else { - TRACE_DEBUG("VBUS low\n\r"); - USBD_Disconnect(); -#if (USB_OTG_FEATURE == ENABLE) - Usb_device_stop_hnp(); - TRACE_DEBUG("Usb_select_device4\n\r"); - Usb_select_device(); - Clear_all_user_request(); -#endif - Usb_vbus_off_action(); - usb_connected = FALSE; - usb_configuration_nb = 0; - Usb_send_event(EVT_USB_UNPOWERED); - } - - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Device start of frame received - if (Is_usb_sof() && Is_sof_interrupt_enabled()) { - // TRACE_DEBUG_WP("F"); // device - Usb_ack_sof(); - Usb_sof_action(); -#if (USB_OTG_FEATURE == ENABLE) - //sof_seen_in_session = TRUE; - otg_last_sof_received = UDFNUML; // store last frame number received -#endif - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Device Suspend event (no more USB activity detected) - if (Is_usb_suspend()) { //&& Is_suspend_interrupt_enabled()) { - //TRACE_DEBUG_WP("D\n\r"); -#if (USB_OTG_FEATURE == ENABLE) - // 1st : B-PERIPH mode ? - if (Is_usb_id_device()) { - // HNP Handler - TRACE_DEBUG("HNP Handler\n\r"); - //TRACE_DEBUG("device_state = %d\n\r", device_state); - //TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - if (Is_host_requested_hnp() // "b_hnp_enable" feature received - && (Is_session_started_with_srp() || Is_user_requested_hnp() { - if (otg_device_nb_hnp_retry == 0) { - otg_features_supported &= ~USBFeatureRequest_OTG_B_HNP_ENABLE; - } - else { - Ack_user_request_hnp(); - Usb_ack_hnp_error_interrupt(); - Usb_ack_role_exchange_interrupt(); - Usb_enable_role_exchange_interrupt(); - Usb_enable_hnp_error_interrupt(); - Usb_device_initiate_hnp(); - otg_device_nb_hnp_retry--; - } - } - else - { - // Remote wake-up handler - //TRACE_DEBUG("Remote wake-up handler\n\r"); - //TRACE_DEBUG("device_state = %d\n\r", device_state); - //TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - if ((remote_wakeup_feature == ENABLE) && (usb_configuration_nb != 0)) - { - //TRACE_DEBUG("enabled\n\r"); - // After that user can execute "Usb_initiate_remote_wake_up()" to initiate a remote wake-up - // Note that the suspend interrupt flag SUSPI must still be set to enable upstream resume - // So the SUSPE enable bit must be cleared to avoid redundant interrupt - // **************** - // Please note also that is Vbus is lost during an upstream resume (Host disconnection), - // the RMWKUP bit (used to initiate remote wake up and that is normally cleared by hardware when sent) - // remains set after the event, so that a good way to handle this feature is : - // Usb_initiate_remote_wake_up(); - // while (Is_usb_pending_remote_wake_up()) - // { - // if (Is_usb_vbus_low()) - // { - // // Emergency action (reset macro, etc.) if Vbus lost during resuming - // break; - // } - // } - // Usb_ack_remote_wake_up_start(); - // **************** - } - else { - //TRACE_DEBUG("disabled: %d %d\n\r", usb_configuration_nb, remote_wakeup_feature); - // No remote wake-up supported - Usb_send_event(EVT_USB_SUSPEND); - } - } - } - else - { - //TRACE_DEBUG("ici\n\r"); - // A-PERIPH mode (will cause a session end, handled in usb_host_task.c) - Usb_send_event(EVT_USB_SUSPEND); - Usb_suspend_action(); - //jcb Usb_ack_suspend(); - } -#else - // Remote wake-up handler - if ((remote_wakeup_feature == ENABLE) && (usb_configuration_nb != 0)) { - TRACE_DEBUG("Remote wake-up handler\n\r"); - Usb_disable_suspend_interrupt(); - Usb_ack_wake_up(); - Usb_enable_wake_up_interrupt(); - Usb_suspend_action(); - Usb_freeze_clock(); - // After that user can execute "Usb_initiate_remote_wake_up()" to initiate a remote wake-up - // Note that the suspend interrupt flag SUSPI must still be set to enable upstream resume - // So the SUSPE enable bit must be cleared to avoid redundant interrupt - // **************** - // Please note also that is Vbus is lost during an upstream resume (Host disconnection), - // the RMWKUP bit (used to initiate remote wake up and that is normally cleared by hardware when sent) - // remains set after the event, so that a good way to handle this feature is : - // Usb_unfreeze_clock(); - // Usb_initiate_remote_wake_up(); - // while (Is_usb_pending_remote_wake_up()) - // { - // if (Is_usb_vbus_low()) - // { - // // Emergency action (reset macro, etc.) if Vbus lost during resuming - // break; - // } - // } - // Usb_ack_remote_wake_up_start(); - // **************** - } - else { - // No remote wake-up supported - Usb_send_event(EVT_USB_SUSPEND); - Usb_suspend_action(); - Usb_ack_suspend(); - Usb_ack_wake_up(); // clear wake up to detect next event - Usb_enable_wake_up_interrupt(); - Usb_freeze_clock(); - } -#endif - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Wake up event (USB activity detected): Used to resume - if (Is_usb_wake_up() && Is_swake_up_interrupt_enabled()) { - TRACE_DEBUG("W\n\r"); - Usb_unfreeze_clock(); - Usb_send_event(EVT_USB_WAKE_UP); - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Resume state bus detection - if (Is_usb_resume() && Is_resume_interrupt_enabled()) { - TRACE_DEBUG("Resume state bus detect\n\r"); - Usb_send_event(EVT_USB_RESUME); - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - USB bus reset detection - if (Is_usb_reset()&& Is_reset_interrupt_enabled()) { - TRACE_DEBUG_WP("B\n\r"); -#if (USB_OTG_FEATURE == ENABLE) - if (Is_usb_id_host()) { - //TRACE_DEBUG_WP("id_host\n\r"); - dev_configure_endpoint(EP_CONTROL, - TYPE_CONTROL, - DIRECTION_OUT, - SIZE_64, - ONE_BANK, - NYET_DISABLED); - } - // First initialization is important to be synchronized - // A reset must first have been received - if (device_state == A_PERIPHERAL) { - //TRACE_DEBUG_WP("r A_PERIPHERAL\n\r"); - otg_last_sof_received = UDFNUML; - otg_last_sof_stored = UDFNUML; - Usb_ack_sof(); - Usb_enable_sof_interrupt(); - reset_received = TRUE; - Timer16_set_counter(0); - } -#endif - Usb_reset_action(); - Usb_send_event(EVT_USB_RESET); - } - - // ---------- OTG events management ------------------------------------ - // --------------------------------------------------------------------- -#if (USB_OTG_FEATURE == ENABLE) && (USB_HOST_FEATURE == ENABLE) - - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - OTG HNP Success detection - if (Is_usb_role_exchange_interrupt() && Is_role_exchange_interrupt_enabled()) { - // TRACE_DEBUG("OTG HNP detect\n\r"); - Usb_ack_role_exchange_interrupt(); - Host_ack_device_connection(); - Host_ack_device_disconnection(); - Otg_send_event(EVT_OTG_HNP_SUCCESS); - End_session_with_srp(); - Clear_otg_features_from_host(); - if (Is_usb_id_host()) { - // HOST (A- or B-) mode - if ((device_state != A_PERIPHERAL) && (device_state != A_END_HNP_WAIT_VFALL)) { - static volatile unsigned int jcb; - // Current mode is A-HOST, device will take the A-PERIPHERAL role - b_uut_device_state = B_PERIPHERAL; - device_state = A_PERIPHERAL; - usb_connected = FALSE; - usb_configuration_nb = 0; - Usb_select_device(); - USBD_Connect();//Usb_attach(); - Usb_unfreeze_clock(); - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Usb_device_stop_hnp(); - Usb_ack_reset(); - Timer16_set_counter(0); - Usb_freeze_clock(); // USB clock can be freezed to slow down events and condition detection - //jcb while (Timer16_get_counter_low() != 20); - jcb=0; - while( jcb <100000){ jcb++; } - - Usb_unfreeze_clock(); - reset_received = FALSE; - Usb_disable_sof_interrupt(); // will be set in the next OTG Timer IT (mandatory) - - Usb_enable_suspend_interrupt(); - Usb_enable_reset_interrupt(); - dev_configure_endpoint(EP_CONTROL, - TYPE_CONTROL, - DIRECTION_OUT, - SIZE_64, - ONE_BANK, - NYET_DISABLED); - } - } - else { - // In B_HOST mode, the HNPREQ bit must not be cleared because it releases the bus in suspend mode (and sof can't start) - if ((b_uut_device_state != B_HOST) && (b_uut_device_state != B_END_HNP_SUSPEND)) { - static volatile unsigned int jcb2; - // Current mode is B-PERIPHERAL, device will go into B-HOST role - End_session_with_srp(); - Clear_otg_features_from_host(); - b_uut_device_state = B_HOST; - device_state = DEVICE_ATTACHED; - usb_connected = FALSE; - usb_configuration_nb = 0; - TRACE_DEBUG("Select host 3\n\r"); - Usb_select_host(); - - TRACE_DEBUG("Send reset\n\r"); - Host_send_reset(); // send the first RESET - while (Host_is_reset()); - TRACE_DEBUG("Reset passed\n\r"); - - jcb2=0; - while( jcb2 <1000000){ jcb2++; } - Host_enable_sof(); // start Host (sof) - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Clear_all_user_request(); - - TRACE_DEBUG("Select host 3\n\r"); - } - } - } - - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - OTG HNP Failure detection - if (Is_usb_hnp() && Is_usb_hnp_error_interrupt()&& Is_hnp_error_interrupt_enabled()) { - TRACE_DEBUG("OTG HNP failure\n\r"); - Usb_device_stop_hnp(); - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Usb_ack_hnp_error_interrupt(); - if (Is_usb_id_device()) { - Otg_send_event(EVT_OTG_HNP_ERROR); - Clear_all_user_request(); - } - } -#endif -#endif// End DEVICE FEATURE MODE && USB_HOST_FEATURE - - // ---------- HOST events management ----------------------------------- - // --------------------------------------------------------------------- -#if (((USB_HOST_FEATURE == ENABLE) && (USB_DEVICE_FEATURE == ENABLE)) || (USB_OTG_FEATURE == ENABLE)) - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - ID pin change detection - if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled()) { - TRACE_DEBUG("ID pin change\n\r"); - TRACE_DEBUG("device_state = %d\n\r", device_state); - TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - Usb_device_stop_hnp(); -#if (USB_OTG_FEATURE == ENABLE) - Clear_all_user_request(); -#endif - if(Is_usb_id_device()) { - g_usb_mode = USB_MODE_DEVICE; - } - else { - g_usb_mode = USB_MODE_HOST; - } - Usb_ack_id_transition(); - if( g_usb_mode != g_old_usb_mode) { // Basic Debounce - if(Is_usb_id_device()) { // Going into device mode - Usb_send_event(EVT_USB_DEVICE_FUNCTION); -#if (USB_OTG_FEATURE == ENABLE) - b_uut_device_state = B_IDLE; -#endif - device_state = DEVICE_UNATTACHED; -#if (USB_OTG_FEATURE == ENABLE) - id_changed_to_host_event = DISABLE; -#endif - } - else { // Going into host mode -#if (USB_OTG_FEATURE == ENABLE) - b_uut_device_state = B_IDLE; -#endif - device_state = DEVICE_UNATTACHED; - Usb_send_event(EVT_USB_HOST_FUNCTION); -#if (USB_OTG_FEATURE == ENABLE) - id_changed_to_host_event = ENABLE; -#endif - } - Usb_id_transition_action(); - TRACE_INFO("Pin Id changed\n\r"); -#if ( ID_PIN_CHANGE_GENERATE_RESET == ENABLE) - // Hot ID transition generates wdt reset -#endif - } - } - -#endif -#if ((USB_HOST_FEATURE == ENABLE) || (USB_OTG_FEATURE == ENABLE)) - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - The device has been disconnected - // JCB to be fix - if(Is_device_disconnection() && Is_host_device_disconnection_interrupt_enabled()) { - TRACE_DEBUG("device disconnect\n\r"); - host_disable_all_pipe(); - Host_ack_device_disconnection(); - device_state=DEVICE_DISCONNECTED; - Usb_send_event(EVT_HOST_DISCONNECTION); - TRACE_INFO("Device disconnected\n\r"); - Host_device_disconnection_action(); -#if (USB_OTG_FEATURE == ENABLE) - Clear_all_user_request(); -#endif - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Device connection - if(Is_device_connection() && Is_host_device_connection_interrupt_enabled()) { - TRACE_DEBUG("device connect\n\r"); - Host_ack_device_connection(); - host_disable_all_pipe(); - Host_device_connection_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Start of frame has been sent - if (Is_host_sof() && Is_host_sof_interrupt_enabled()) { - //TRACE_DEBUG_WP("_"); // host - Host_ack_sof(); - Usb_send_event(EVT_HOST_SOF); - private_sof_counter++; - - // delay timeout management for interrupt tranfer mode in host mode - if (private_sof_counter>=250) { // Count 1/4 sec - private_sof_counter=0; - for(i=0;iTIMEOUT_DELAY) && (Host_get_pipe_type()!=TYPE_INTERRUPT)) { - it_pipe_str[i].enable=DISABLE; - it_pipe_str[i].status=PIPE_DELAY_TIMEOUT; - Host_stop_pipe_interrupt(i); - if (is_any_interrupt_pipe_active()==FALSE) { // If no more transfer is armed - if (g_sav_int_sof_enable==FALSE) { - Host_disable_sof_interrupt(); - } - } - it_pipe_str[i].handle(PIPE_DELAY_TIMEOUT,it_pipe_str[i].nb_byte_processed); - } - Host_select_pipe(save_pipe_nb); - } - } - } - Host_sof_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Wake-up has been received - if (Is_host_hwup() && Is_host_hwup_interrupt_enabled()) { - TRACE_DEBUG("Host wake up\n\r"); - Host_disable_hwup_interrupt(); // Wake up interrupt should be disable host is now wake up ! - Host_disable_remote_wakeup_interrupt(); - // CAUTION HWUP can be cleared only when USB clock is active (not frozen)! - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Host_ack_hwup(); // Clear HWUP interrupt flag - Host_ack_remote_wakeup(); - Usb_send_event(EVT_HOST_HWUP); // Send software event - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Host_hwup_action(); // Map custom action -#if (USB_OTG_FEATURE == ENABLE) - if (Is_usb_hnp()) { - Usb_host_reject_hnp(); - Usb_disable_hnp_error_interrupt(); - Usb_disable_role_exchange_interrupt(); - } -#endif - Host_send_resume(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // Remote Wake Up has been received - if (Is_host_remote_wakeup_interrupt_enabled() && Is_host_remote_wakeup()) { - TRACE_DEBUG("Remote wake up\n\r"); - Host_disable_remote_wakeup_interrupt(); - Host_disable_hwup_interrupt(); - Host_ack_remote_wakeup(); - Host_ack_hwup(); // Clear HWUP interrupt flag - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Usb_send_event(EVT_HOST_HWUP); // Send software event -#if (USB_OTG_FEATURE == ENABLE) - if (Is_usb_hnp()) { - Usb_host_reject_hnp(); - Usb_disable_hnp_error_interrupt(); - Usb_disable_role_exchange_interrupt(); - } -#endif - Host_send_resume(); - } -#endif // End HOST FEATURE MODE -} - - -#if (USB_OTG_FEATURE == ENABLE) - -//------------------------------------------------------------------------------ -/// OTG TIMER interrupt subroutine -/// This function is called each time a OTG Timer interrupt occurs -/// Function decrements the variables required by OTG program -void otg_timer_interrupt(void) -{ - /// OTG Messaging timer - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) - || (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_FAIL)) { - if ((Get_failure_msg_delay() != 0x0000) && (Get_failure_msg_delay() != 0xFFFF)) { - Decrement_failure_msg_delay(); - } - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) { - if ((Get_event_msg_delay() != 0x0000) && (Get_event_msg_delay() != 0xFFFF)) { - Decrement_event_msg_delay(); - } - } - } - /// Increments Tb_Srp counter if needed - if (Is_srp_sent_and_waiting_answer()) { - otg_tb_srp_cpt++; - } - /// Increments T_vbus_wait_connect if needed - if (Is_srp_received_and_waiting_connect()) { - otg_ta_srp_wait_connect++; - } - /// Decrements Ta_aidl_bdis timer if needed (A_suspend state) - if ((device_state == A_SUSPEND) && (otg_ta_aidl_bdis_tmr > 1)) { - otg_ta_aidl_bdis_tmr--; - } - /// Decrements Timeout_bdev_respond timer if needed - if ((device_state == DEVICE_DEFAULT) && (!Is_timeout_bdev_response_overflow())) { - otg_timeout_bdev_respond--; - } - /// Decrements Ta_vbus_rise timer if needed - if (!Is_ta_vbus_rise_counter_overflow()) { - otg_ta_vbus_rise--; - } - /// Decrements Ta_vbus_fall timer if needed - if (!Is_ta_vbus_fall_counter_overflow()) { - otg_end_hnp_vbus_delay--; - } - - /// Needed for compliance only - if (device_state == A_PERIPHERAL) { - if (Is_sof_interrupt_enabled() && (reset_received == TRUE)) { - if (otg_last_sof_stored != otg_last_sof_received) { - // No SOF is missing - otg_last_sof_received = otg_last_sof_stored; - } - else { - // SOF seems to be missing.. - Usb_freeze_clock(); - Usb_disable_sof_interrupt(); - reset_received = FALSE; - //jcb while (Timer16_get_counter_low() != 20); // overflow set to 62 in usb_task.h - Usb_unfreeze_clock(); - } - otg_last_sof_received = UDFNUML; - otg_last_sof_stored = UDFNUML; - } - } -} - - -//------------------------------------------------------------------------------ -/// OTG Messaging task initialization -/// Initializes variables and screen to prepare next messages to be handled -//------------------------------------------------------------------------------ -void Otg_message_task_init(void) -{ - TRACE_DEBUG("Otg_message_task_init\n\r"); - Otg_messaging_init(); - otg_msg_event_delay = 0; - otg_msg_failure_delay = 0; -} - - -//------------------------------------------------------------------------------ -/// OTG Messaging main task -/// OTG specifies that user must be kept informed of several events -/// This task allows user to display two kinds of messages : EVENT or FAILURE -/// For each new message, it can specify if the message remains displayed all -/// the time or only during a specified delay -//------------------------------------------------------------------------------ -void Otg_message_task(void) -{ - // Check if an OTG message must be erased (if it was set up for a specified delay) - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) - || (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_FAIL)) { - if (Get_failure_msg_delay() == 0) { - Otg_clear_failure_message(); - } - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) { - if (Get_event_msg_delay() == 0) { - Otg_clear_event_message(); - } - } - } -} -#endif // #if (USB_OTG_FEATURE == ENABLE) - - -//------------------------------------------------------------------------------ -/// Message "OTG not supported" -//------------------------------------------------------------------------------ -void otg_not_supported_device(void) -{ - TRACE_DEBUG("otg_not_supported_device\n\r"); - Otg_send_event(EVT_OTG_DEV_UNSUPPORTED); -} - - diff --git a/src/ersky9x/libraries/usb/otg/usb_task.h b/src/ersky9x/libraries/usb/otg/usb_task.h deleted file mode 100644 index 0ad2529ef..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_task.h +++ /dev/null @@ -1,232 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - -//! @brief This file manages the USB task either device/host or both. -//! -//! The USB task selects the correct USB task (usb_device task or usb_host task -//! to be executed depending on the current mode available. -//! -//! This module also contains the general USB interrupt subroutine. This subroutine is used -//! to detect asynchronous USB events. -//! -//! Note: -//! - The usb_task belongs to the scheduler, the usb_device_task and usb_host do not, they are called -//! from the general usb_task -//! - See conf_usb.h file for more details about the configuration of this module - -#ifndef _USB_TASK_H_ -#define _USB_TASK_H_ - -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -/// Definitions of B-Device states -#define B_IDLE 0 -//#define B_SRP_INIT 1 -#define B_PERIPHERAL 2 -//#define B_WAIT_ACON 3 -#define B_HOST 4 -#define B_END_HNP_SUSPEND 5 - -// OTG B-Device SRP protocole specific states or events - -//! Is the current session a result of a SRP ? -//#define Start_session_with_srp() (otg_device_sessions |= 0x01) -#define End_session_with_srp() (otg_device_sessions &= ~0x01) -#define Is_session_started_with_srp() (((otg_device_sessions&0x01) != 0) ? TRUE : FALSE) - -//! Has a SRP been sent, and waiting for an answer -//#define Srp_sent_and_waiting_answer() (otg_device_sessions |= 0x02) -//#define Ack_srp_sent_and_answer() (otg_device_sessions &= ~0x02) -#define Is_srp_sent_and_waiting_answer() (((otg_device_sessions&0x02) != 0) ? TRUE : FALSE) - -//! Is the Tb_Srp counter enabled ? Cleared by timer if Tb_Srp_Fail elapsed -//! Tb_Srp_Fail must be between 5 and 6 sec. With an interrupt routine executed each 2ms, its value becomes 2500 (used:5.2sec) -// 0x0A28 = 2600, 2600x2 = 5200 => 5s -//#define TB_SRP_FAIL_MIN 0x0A28 -//extern U16 otg_tb_srp_cpt; -//#define Init_tb_srp_counter() (otg_tb_srp_cpt = 0) -//#define Is_tb_srp_counter_overflow() ((otg_tb_srp_cpt > TB_SRP_FAIL_MIN) ? TRUE : FALSE) - -// usb_task USB task entry point module - -//! usb_software_evts USB software Events Management -//! Macros to manage USB events detected under interrupt -#define Usb_send_event(x) g_usb_event |= (1< -#include "main.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "otg_user_task.h" -#include "usb_task.h" -#include "usb/otg/usb_drv.h" -#include "usb/otg/usb_host_task.h" - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - - - -extern volatile unsigned int timer_set_counter; -#define Timer16_select(...) -#define Timer16_set_counter(value) timer_set_counter = value -#define Timer16_get_counter_low() (unsigned char)timer_set_counter - - -/// Returns the OTG features sent by the host by a SetFeature -/// Allow also to clear the features (only on a bus Reset or Session End) -#define Is_host_requested_hnp() (((otg_features_supported&USBFeatureRequest_OTG_B_HNP_ENABLE) != 0) ? TRUE : FALSE) -#define Clear_otg_features_from_host() (otg_features_supported = 0) - -#define Set_otg_custom_timer(ep) // STUB: todo - -#define USB_MODE_UNDEFINED 0x00 -#define USB_MODE_HOST 0x01 -#define USB_MODE_DEVICE 0x02 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -U8 otg_device_sessions; -U8 b_uut_device_state; -U16 otg_tb_srp_cpt; - -/// usb_connected is used to store USB events detected upon -/// USB general interrupt subroutine -/// Its value is managed by the following macros (See usb_task.h file) -/// Usb_send_event(x) -/// Usb_ack_event(x) -/// Usb_clear_all_event() -/// Is_usb_event(x) -/// Is_not_usb_event(x) -volatile U16 g_usb_event=0; - - -/// -/// Private : (U8) private_sof_counter -/// Incremented by host SOF interrupt subroutime -/// This counter is used to detect timeout in host requests. -/// It must not be modified by the user application tasks. -//// -volatile U8 private_sof_counter=0; -extern volatile S_pipe_int it_pipe_str[MAX_EP_NB]; - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the USB process -/// Depending on the mode supported (HOST/DEVICE/DUAL_ROLE) the function calls -/// the coresponding USB mode initialization function -//------------------------------------------------------------------------------ -void usb_task_init(void) -{ - // ---- REDUCED HOST ONLY USB MODE ----------------------------------------- - //jcbUsb_force_host_mode(); - usb_host_task_init(); -} - - -//------------------------------------------------------------------------------ -/// Entry point of the USB mamnagement -/// Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function -/// calls the coresponding USB management function -//------------------------------------------------------------------------------ -void usb_task(void) -{ - // ---- REDUCED HOST ONLY USB MODE ----------------------------------------- - usb_host_task(); -} - - - -//------------------------------------------------------------------------------ -/// USB interrupt subroutine -/// -/// This function is called each time a USB interrupt occurs. -/// The following USB DEVICE events are taken in charge: -/// - VBus On / Off -/// - Start Of Frame -/// - Suspend -/// - Wake-Up -/// - Resume -/// - Reset -/// - Start of frame -/// -/// The following USB HOST events are taken in charge: -/// - Device connection -/// - Device Disconnection -/// - Start Of Frame -/// - ID pin change -/// - SOF (or Keep alive in low speed) sent -/// - Wake up on USB line detected -/// -/// The following USB HOST events are taken in charge: -/// - HNP success (Role Exchange) -/// - HNP failure (HNP Error) -/// -/// For each event, the user can launch an action by completing -/// the associate define (See conf_usb.h file to add action upon events) -/// -/// Note: Only interrupts events that are enabled are processed -//------------------------------------------------------------------------------ -void usb_general_interrupt(void) -{ - //TRACE_DEBUG("usb_general_interrupt\n\r"); - U8 i; - U8 save_pipe_nb; - - // ---------- HOST events management ----------------------------------- - // --------------------------------------------------------------------- - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - The device has been disconnected - if(Is_device_disconnection() && Is_host_device_disconnection_interrupt_enabled()) { - TRACE_DEBUG("device disconnect\n\r"); - host_disable_all_pipe(); - Host_ack_device_disconnection(); - device_state=DEVICE_DISCONNECTED; - Usb_send_event(EVT_HOST_DISCONNECTION); - TRACE_INFO("Device disconnected\n\r"); - Host_device_disconnection_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Device connection - if(Is_device_connection() && Is_host_device_connection_interrupt_enabled()) { - TRACE_DEBUG("device connect\n\r"); - Host_ack_device_connection(); - host_disable_all_pipe(); - Host_device_connection_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Start of frame has been sent - if (Is_host_sof() && Is_host_sof_interrupt_enabled()) { - //TRACE_DEBUG_WP("_"); // host - Host_ack_sof(); - Usb_send_event(EVT_HOST_SOF); - private_sof_counter++; - - // delay timeout management for interrupt tranfer mode in host mode -#if ((USB_HOST_PIPE_INTERRUPT_TRANSFER==ENABLE) && (TIMEOUT_DELAY_ENABLE==ENABLE)) - if (private_sof_counter>=250) { // Count 1/4 sec - private_sof_counter=0; - for(i=0;iTIMEOUT_DELAY) && (Host_get_pipe_type()!=TYPE_INTERRUPT)) { - it_pipe_str[i].enable=DISABLE; - it_pipe_str[i].status=PIPE_DELAY_TIMEOUT; - Host_stop_pipe_interrupt(i); - if (is_any_interrupt_pipe_active()==FALSE) { // If no more transfer is armed - if (g_sav_int_sof_enable==FALSE) { - Host_disable_sof_interrupt(); - } - } - it_pipe_str[i].handle(PIPE_DELAY_TIMEOUT,it_pipe_str[i].nb_byte_processed); - } - Host_select_pipe(save_pipe_nb); - } - } - } -#endif // (USB_HOST_PIPE_INTERRUPT_TRANSFER==ENABLE) && (TIMEOUT_DELAY_ENABLE==ENABLE)) - Host_sof_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Wake-up has been received - if (Is_host_hwup() && Is_host_hwup_interrupt_enabled()) { - TRACE_DEBUG("Host wake up\n\r"); - Host_disable_hwup_interrupt(); // Wake up interrupt should be disable host is now wake up ! - Host_disable_remote_wakeup_interrupt(); - // CAUTION HWUP can be cleared only when USB clock is active (not frozen)! - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Host_ack_hwup(); // Clear HWUP interrupt flag - Host_ack_remote_wakeup(); - Usb_send_event(EVT_HOST_HWUP); // Send software event - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Host_hwup_action(); // Map custom action - Host_send_resume(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // Remote Wake Up has been received - if (Is_host_remote_wakeup_interrupt_enabled() && Is_host_remote_wakeup()) { - TRACE_DEBUG("Remote wake up\n\r"); - Host_disable_remote_wakeup_interrupt(); - Host_disable_hwup_interrupt(); - Host_ack_remote_wakeup(); - Host_ack_hwup(); // Clear HWUP interrupt flag - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Usb_send_event(EVT_HOST_HWUP); // Send software event - Host_send_resume(); - } -} - -//------------------------------------------------------------------------------ -/// Message "OTG not supported" -//------------------------------------------------------------------------------ -void otg_not_supported_device(void) -{ - TRACE_DEBUG("otg_not_supported_device\n\r"); - Otg_send_event(EVT_OTG_DEV_UNSUPPORTED); -} - - diff --git a/src/ersky9x/libraries/usb/otg/usb_task_with_SRP_HNP.c b/src/ersky9x/libraries/usb/otg/usb_task_with_SRP_HNP.c deleted file mode 100644 index e5204deee..000000000 --- a/src/ersky9x/libraries/usb/otg/usb_task_with_SRP_HNP.c +++ /dev/null @@ -1,852 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - - - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -#include -#include "main.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "otg_user_task.h" -#include "usb_task.h" -#include "usb/otg/usb_drv.h" -#include "usb/otg/usb_host_task.h" - -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - - - -extern volatile unsigned int timer_set_counter; -#define Timer16_select(...) -#define Timer16_set_counter(value) timer_set_counter = value -#define Timer16_get_counter_low() (unsigned char)timer_set_counter - - -/// Returns the OTG features sent by the host by a SetFeature -/// Allow also to clear the features (only on a bus Reset or Session End) -#define Is_host_requested_hnp() (((otg_features_supported&USBFeatureRequest_OTG_B_HNP_ENABLE) != 0) ? TRUE : FALSE) -#define Clear_otg_features_from_host() (otg_features_supported = 0) - -#define Set_otg_custom_timer(ep) // STUB: todo - -#define USB_MODE_UNDEFINED 0x00 -#define USB_MODE_HOST 0x01 -#define USB_MODE_DEVICE 0x02 - -//------------------------------------------------------------------------------ -// Exported variables -//------------------------------------------------------------------------------ - -U8 otg_device_sessions; -U8 b_uut_device_state; -U16 otg_tb_srp_cpt; - -/// usb_connected is used to store USB events detected upon -/// USB general interrupt subroutine -/// Its value is managed by the following macros (See usb_task.h file) -/// Usb_send_event(x) -/// Usb_ack_event(x) -/// Usb_clear_all_event() -/// Is_usb_event(x) -/// Is_not_usb_event(x) -volatile U16 g_usb_event=0; - -/// -/// Public : (bit) usb_connected -/// usb_connected is set to TRUE when VBUS has been detected -/// usb_connected is set to FALSE otherwise -bit usb_connected; - -/// -/// Public : (U8) usb_configuration_nb -/// Store the number of the USB configuration used by the USB device -/// when its value is different from zero, it means the device mode is enumerated -U8 usb_configuration_nb; - -/// -/// Public : (U8) remote_wakeup_feature -/// Store a host request for remote wake up (set feature received) -//// -U8 remote_wakeup_feature; - -/// -/// Private : (U8) private_sof_counter -/// Incremented by host SOF interrupt subroutime -/// This counter is used to detect timeout in host requests. -/// It must not be modified by the user application tasks. -//// -volatile U8 private_sof_counter=0; - -extern volatile S_pipe_int it_pipe_str[MAX_EP_NB]; - - -/// -/// Public : (U8) g_usb_mode -/// Used in dual role application (both device/host) to store -/// the current mode the usb controller is operating -//// -U8 g_usb_mode=USB_MODE_UNDEFINED; -U8 g_old_usb_mode; - - -/// -/// Public : (U8) otg_features_supported; -/// -> A-Device side : indicates if the B-Device supports HNP and SRP (this is the bmAttributes field of OTG Decriptor) -/// -> B-Device side : indicates if the A-Device has enabled the "a_hnp_support" and "b_hnp_enable" features -volatile U8 otg_features_supported; - -/// Public : (U8) otg_user_request; -/// Store the last request of the user (see usb_device_task.h) -U8 otg_user_request; - -/// Public : (U16) otg_msg_event_delay; -/// Contains the current display duration of the OTG event message -U16 otg_msg_event_delay; - -/// Public : (U16) otg_msg_failure_delay; -/// Contains the current display duration of the OTG failure message -U16 otg_msg_failure_delay; - -/// Public : (U16) g_otg_event; -/// Contains several bits corresponding to differents OTG events (similar to g_usb_event) -volatile U16 g_otg_event; - -/// Public : (U8) otg_device_nb_hnp_retry; -/// Counts the number of times a HNP fails, before aborting the operations -U8 otg_device_nb_hnp_retry; - -U8 id_changed_to_host_event; - -volatile U8 otg_last_sof_received; // last SOF received in SOF interrupt -volatile U8 otg_last_sof_stored; // last SOF value stored in OTG Timer interrupt -volatile U8 reset_received; // indicates if a reset has been received from B-Host after a HNP (used in A-Periph mode) - -/// @brief VBUS Overload management -/// -/// Nothing to do ! If the condition is not defined in the board driver file -/// (i.e. if the board does not support Vbus overcurrent detection), -/// the macro is defined to false for firmware compatibility -#define Is_vbus_overcurrent() (FALSE) - -/// Private function prototypes -/// Tasks for OTG Messaging features -void Otg_message_task_init(void); -void Otg_message_task(void); - - -//------------------------------------------------------------------------------ -// Local Variables -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Internal Functions -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Initializes the USB process -/// Depending on the mode supported (HOST/DEVICE/DUAL_ROLE) the function calls -/// the coresponding USB mode initialization function -//------------------------------------------------------------------------------ -void usb_task_init(void) -{ - // DUAL ROLE DEVICE USB MODE - Otg_message_task_init(); // OTG program needs to display event messages to the user - b_uut_device_state = B_IDLE; // init state machines variables - device_state = DEVICE_UNATTACHED; - otg_device_nb_hnp_retry = BDEV_HNP_NB_RETRY; - Clear_all_user_request(); - Usb_enable_uid_pin(); - - g_usb_mode=USB_MODE_UNDEFINED; - - if(Is_usb_id_device()) { - g_usb_mode=USB_MODE_DEVICE; -#ifdef MSD_PROJECT - MSDDriver_Initialize(luns, numMedias); -#else - // HID - HIDDMouseDriver_Initialize(); -#endif - id_changed_to_host_event = DISABLE; - } - else { - Usb_send_event(EVT_USB_HOST_FUNCTION); - g_usb_mode=USB_MODE_HOST; - // Startup with ID=0, Ack ID pin transistion (default hwd start up is device mode) - Usb_ack_id_transition(); - Usb_enable_id_interrupt(); - usb_host_task_init(); - id_changed_to_host_event = ENABLE; - } - // Store current usb mode, for mode change detection - g_old_usb_mode = g_usb_mode; -} - - -//------------------------------------------------------------------------------ -/// Entry point of the USB mamnagement -/// Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function -/// calls the coresponding USB management function -//------------------------------------------------------------------------------ -void usb_task(void) -{ - // DUAL ROLE DEVICE USB MODE - if(Is_usb_id_device()) { - g_usb_mode = USB_MODE_DEVICE; - } - else { - g_usb_mode = USB_MODE_HOST; - } - g_old_usb_mode = g_usb_mode; // Store current usb mode, for mode change detection - // Depending on current usb mode, launch the correct usb task (device or host) - - // Configure OTG timers - Set_otg_custom_timer(VBUSRISE_70MS); - Set_otg_custom_timer(VBUSPULSE_40MS); - Set_otg_custom_timer(VFALLTMOUT_131MS); - Set_otg_custom_timer(SRPMINDET_100US); - - switch(g_usb_mode) { - case USB_MODE_DEVICE: - //usb_device_task(); - //MSDDriver_StateMachine(); - Scheduler_task_3(); - break; - - case USB_MODE_HOST: - if( pOTGDescriptor->bOTGADevSRPReaction == VBUS_PULSE) { - Usb_select_vbus_srp_method(); - } - else { - Usb_select_data_srp_method(); - } - usb_host_task(); - // Handle Vbus overcurrent error (auto-disabled if not supported or not defined in board driver file) - if (Is_vbus_overcurrent()) { - Otg_print_new_event_message(OTGMSG_VBUS_SURCHARGE,OTG_TEMPO_3SEC); - } - break; - - case USB_MODE_UNDEFINED: // No break ! - default: - break; - } - Otg_message_task(); -} - - - -//------------------------------------------------------------------------------ -/// USB interrupt subroutine -/// -/// This function is called each time a USB interrupt occurs. -/// The following USB DEVICE events are taken in charge: -/// - VBus On / Off -/// - Start Of Frame -/// - Suspend -/// - Wake-Up -/// - Resume -/// - Reset -/// - Start of frame -/// -/// The following USB HOST events are taken in charge: -/// - Device connection -/// - Device Disconnection -/// - Start Of Frame -/// - ID pin change -/// - SOF (or Keep alive in low speed) sent -/// - Wake up on USB line detected -/// -/// The following USB HOST events are taken in charge: -/// - HNP success (Role Exchange) -/// - HNP failure (HNP Error) -/// -/// For each event, the user can launch an action by completing -/// the associate define (See conf_usb.h file to add action upon events) -/// -/// Note: Only interrupts events that are enabled are processed -//------------------------------------------------------------------------------ -void usb_general_interrupt(void) -{ - //TRACE_DEBUG("usb_general_interrupt\n\r"); - - // ---------- DEVICE events management ----------------------------------- - // ----------------------------------------------------------------------- - - //- VBUS state detection - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - if (Is_usb_vbus_transition() && Is_usb_vbus_interrupt_enabled() - && Is_usb_id_device()) { - Usb_ack_vbus_transition(); - - if (Is_usb_vbus_high()) { - usb_connected = TRUE; - Usb_vbus_on_action(); - Usb_send_event(EVT_USB_POWERED); - //jcb Usb_enable_reset_interrupt(); - //usb_start_device(); - USBD_Connect();//Usb_attach(); - } - else { - TRACE_DEBUG("VBUS low\n\r"); - USBD_Disconnect(); - Usb_device_stop_hnp(); - TRACE_DEBUG("Usb_select_device4\n\r"); - Usb_select_device(); - Clear_all_user_request(); - Usb_vbus_off_action(); - usb_connected = FALSE; - usb_configuration_nb = 0; - Usb_send_event(EVT_USB_UNPOWERED); - } - - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Device start of frame received - if (Is_usb_sof() && Is_sof_interrupt_enabled()) { - // TRACE_DEBUG_WP("F"); // device - Usb_ack_sof(); - Usb_sof_action(); - //sof_seen_in_session = TRUE; - otg_last_sof_received = UDFNUML; // store last frame number received - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Device Suspend event (no more USB activity detected) - if (Is_usb_suspend()) { //&& Is_suspend_interrupt_enabled()) { - //TRACE_DEBUG_WP("D\n\r"); - // 1st : B-PERIPH mode ? - if (Is_usb_id_device()) { - // HNP Handler - TRACE_DEBUG("HNP Handler\n\r"); - //TRACE_DEBUG("device_state = %d\n\r", device_state); - //TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - if (Is_host_requested_hnp() // "b_hnp_enable" feature received - && (Is_session_started_with_srp() || Is_user_requested_hnp() )) { - if (otg_device_nb_hnp_retry == 0) { - otg_features_supported &= ~USBFeatureRequest_OTG_B_HNP_ENABLE; - } - else { - Ack_user_request_hnp(); - Usb_ack_hnp_error_interrupt(); - Usb_ack_role_exchange_interrupt(); - Usb_enable_role_exchange_interrupt(); - Usb_enable_hnp_error_interrupt(); - Usb_device_initiate_hnp(); - otg_device_nb_hnp_retry--; - } - } - else - { - // Remote wake-up handler - //TRACE_DEBUG("Remote wake-up handler\n\r"); - //TRACE_DEBUG("device_state = %d\n\r", device_state); - //TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - if ((remote_wakeup_feature == ENABLE) && (usb_configuration_nb != 0)) - { - //TRACE_DEBUG("enabled\n\r"); - // After that user can execute "Usb_initiate_remote_wake_up()" to initiate a remote wake-up - // Note that the suspend interrupt flag SUSPI must still be set to enable upstream resume - // So the SUSPE enable bit must be cleared to avoid redundant interrupt - // **************** - // Please note also that is Vbus is lost during an upstream resume (Host disconnection), - // the RMWKUP bit (used to initiate remote wake up and that is normally cleared by hardware when sent) - // remains set after the event, so that a good way to handle this feature is : - // Usb_initiate_remote_wake_up(); - // while (Is_usb_pending_remote_wake_up()) - // { - // if (Is_usb_vbus_low()) - // { - // // Emergency action (reset macro, etc.) if Vbus lost during resuming - // break; - // } - // } - // Usb_ack_remote_wake_up_start(); - // **************** - } - else { - //TRACE_DEBUG("disabled: %d %d\n\r", usb_configuration_nb, remote_wakeup_feature); - // No remote wake-up supported - Usb_send_event(EVT_USB_SUSPEND); - } - } - } - else - { - //TRACE_DEBUG("ici\n\r"); - // A-PERIPH mode (will cause a session end, handled in usb_host_task.c) - Usb_send_event(EVT_USB_SUSPEND); - Usb_suspend_action(); - //jcb Usb_ack_suspend(); - } - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Wake up event (USB activity detected): Used to resume - if (Is_usb_wake_up() && Is_swake_up_interrupt_enabled()) { - TRACE_DEBUG("W\n\r"); - Usb_unfreeze_clock(); - Usb_send_event(EVT_USB_WAKE_UP); - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - Resume state bus detection - if (Is_usb_resume() && Is_resume_interrupt_enabled()) { - TRACE_DEBUG("Resume state bus detect\n\r"); - Usb_send_event(EVT_USB_RESUME); - } - - // ----------------------------------------------------------------------- - /// Device - // ----------------------------------------------------------------------- - // - USB bus reset detection - if (Is_usb_reset()&& Is_reset_interrupt_enabled()) { - TRACE_DEBUG_WP("B\n\r"); - if (Is_usb_id_host()) { - //TRACE_DEBUG_WP("id_host\n\r"); - dev_configure_endpoint(EP_CONTROL, - TYPE_CONTROL, - DIRECTION_OUT, - SIZE_64, - ONE_BANK, - NYET_DISABLED); - } - // First initialization is important to be synchronized - // A reset must first have been received - if (device_state == A_PERIPHERAL) { - //TRACE_DEBUG_WP("r A_PERIPHERAL\n\r"); - otg_last_sof_received = UDFNUML; - otg_last_sof_stored = UDFNUML; - Usb_ack_sof(); - Usb_enable_sof_interrupt(); - reset_received = TRUE; - Timer16_set_counter(0); - } - Usb_reset_action(); - Usb_send_event(EVT_USB_RESET); - } - - // ---------- OTG events management ------------------------------------ - // --------------------------------------------------------------------- - - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - OTG HNP Success detection - if (Is_usb_role_exchange_interrupt() && Is_role_exchange_interrupt_enabled()) { - // TRACE_DEBUG("OTG HNP detect\n\r"); - Usb_ack_role_exchange_interrupt(); - Host_ack_device_connection(); - Host_ack_device_disconnection(); - Otg_send_event(EVT_OTG_HNP_SUCCESS); - End_session_with_srp(); - Clear_otg_features_from_host(); - if (Is_usb_id_host()) { - // HOST (A- or B-) mode - if ((device_state != A_PERIPHERAL) && (device_state != A_END_HNP_WAIT_VFALL)) { - static volatile unsigned int jcb; - // Current mode is A-HOST, device will take the A-PERIPHERAL role - b_uut_device_state = B_PERIPHERAL; - device_state = A_PERIPHERAL; - usb_connected = FALSE; - usb_configuration_nb = 0; - Usb_select_device(); - USBD_Connect();//Usb_attach(); - Usb_unfreeze_clock(); - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Usb_device_stop_hnp(); - Usb_ack_reset(); - Timer16_set_counter(0); - Usb_freeze_clock(); // USB clock can be freezed to slow down events and condition detection - //jcb while (Timer16_get_counter_low() != 20); - jcb=0; - while( jcb <100000){ jcb++; } - - Usb_unfreeze_clock(); - reset_received = FALSE; - Usb_disable_sof_interrupt(); // will be set in the next OTG Timer IT (mandatory) - - Usb_enable_suspend_interrupt(); - Usb_enable_reset_interrupt(); - dev_configure_endpoint(EP_CONTROL, - TYPE_CONTROL, - DIRECTION_OUT, - SIZE_64, - ONE_BANK, - NYET_DISABLED); - } - } - else { - // In B_HOST mode, the HNPREQ bit must not be cleared because it releases the bus in suspend mode (and sof can't start) - if ((b_uut_device_state != B_HOST) && (b_uut_device_state != B_END_HNP_SUSPEND)) { - static volatile unsigned int jcb2; - // Current mode is B-PERIPHERAL, device will go into B-HOST role - End_session_with_srp(); - Clear_otg_features_from_host(); - b_uut_device_state = B_HOST; - device_state = DEVICE_ATTACHED; - usb_connected = FALSE; - usb_configuration_nb = 0; - TRACE_DEBUG("Select host 3\n\r"); - Usb_select_host(); - - TRACE_DEBUG("Send reset\n\r"); - Host_send_reset(); // send the first RESET - while (Host_is_reset()); - TRACE_DEBUG("Reset passed\n\r"); - - jcb2=0; - while( jcb2 <1000000){ jcb2++; } - Host_enable_sof(); // start Host (sof) - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Clear_all_user_request(); - - TRACE_DEBUG("Select host 3\n\r"); - } - } - } - - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - OTG HNP Failure detection - if (Is_usb_hnp() && Is_usb_hnp_error_interrupt()&& Is_hnp_error_interrupt_enabled()) { - TRACE_DEBUG("OTG HNP failure\n\r"); - Usb_device_stop_hnp(); - Usb_disable_role_exchange_interrupt(); - Usb_disable_hnp_error_interrupt(); - Usb_ack_hnp_error_interrupt(); - if (Is_usb_id_device()) { - Otg_send_event(EVT_OTG_HNP_ERROR); - Clear_all_user_request(); - } - } - - // ---------- HOST events management ----------------------------------- - // --------------------------------------------------------------------- - - // ----------------------------------------------------------------------- - /// Arbitrer - // ----------------------------------------------------------------------- - // - ID pin change detection - if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled()) { - TRACE_DEBUG("ID pin change\n\r"); - TRACE_DEBUG("device_state = %d\n\r", device_state); - TRACE_DEBUG("b_uut_device_state = %d\n\r", b_uut_device_state); - Usb_device_stop_hnp(); - Clear_all_user_request(); - if(Is_usb_id_device()) { - g_usb_mode = USB_MODE_DEVICE; - } - else { - g_usb_mode = USB_MODE_HOST; - } - Usb_ack_id_transition(); - if( g_usb_mode != g_old_usb_mode) { // Basic Debounce - if(Is_usb_id_device()) { // Going into device mode - Usb_send_event(EVT_USB_DEVICE_FUNCTION); - b_uut_device_state = B_IDLE; - device_state = DEVICE_UNATTACHED; - id_changed_to_host_event = DISABLE; - } - else { // Going into host mode - b_uut_device_state = B_IDLE; - device_state = DEVICE_UNATTACHED; - Usb_send_event(EVT_USB_HOST_FUNCTION); - id_changed_to_host_event = ENABLE; - } - Usb_id_transition_action(); - TRACE_INFO("Pin Id changed\n\r"); - } - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - The device has been disconnected - // JCB to be fix - if(Is_device_disconnection() && Is_host_device_disconnection_interrupt_enabled()) { - TRACE_DEBUG("device disconnect\n\r"); - host_disable_all_pipe(); - Host_ack_device_disconnection(); - device_state=DEVICE_DISCONNECTED; - Usb_send_event(EVT_HOST_DISCONNECTION); - TRACE_INFO("Device disconnected\n\r"); - Host_device_disconnection_action(); - Clear_all_user_request(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Device connection - if(Is_device_connection() && Is_host_device_connection_interrupt_enabled()) { - TRACE_DEBUG("device connect\n\r"); - Host_ack_device_connection(); - host_disable_all_pipe(); - Host_device_connection_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Start of frame has been sent - if (Is_host_sof() && Is_host_sof_interrupt_enabled()) { - //TRACE_DEBUG_WP("_"); // host - Host_ack_sof(); - Usb_send_event(EVT_HOST_SOF); - private_sof_counter++; - - // delay timeout management for interrupt tranfer mode in host mode -#if ((USB_HOST_PIPE_INTERRUPT_TRANSFER==ENABLE) && (TIMEOUT_DELAY_ENABLE==ENABLE)) - if (private_sof_counter>=250) { // Count 1/4 sec - private_sof_counter=0; - for(i=0;iTIMEOUT_DELAY) && (Host_get_pipe_type()!=TYPE_INTERRUPT)) { - it_pipe_str[i].enable=DISABLE; - it_pipe_str[i].status=PIPE_DELAY_TIMEOUT; - Host_stop_pipe_interrupt(i); - if (is_any_interrupt_pipe_active()==FALSE) { // If no more transfer is armed - if (g_sav_int_sof_enable==FALSE) { - Host_disable_sof_interrupt(); - } - } - it_pipe_str[i].handle(PIPE_DELAY_TIMEOUT,it_pipe_str[i].nb_byte_processed); - } - Host_select_pipe(save_pipe_nb); - } - } - } -#endif // (USB_HOST_PIPE_INTERRUPT_TRANSFER==ENABLE) && (TIMEOUT_DELAY_ENABLE==ENABLE)) - Host_sof_action(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // - Host Wake-up has been received - if (Is_host_hwup() && Is_host_hwup_interrupt_enabled()) { - TRACE_DEBUG("Host wake up\n\r"); - Host_disable_hwup_interrupt(); // Wake up interrupt should be disable host is now wake up ! - Host_disable_remote_wakeup_interrupt(); - // CAUTION HWUP can be cleared only when USB clock is active (not frozen)! - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Host_ack_hwup(); // Clear HWUP interrupt flag - Host_ack_remote_wakeup(); - Usb_send_event(EVT_HOST_HWUP); // Send software event - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Host_hwup_action(); // Map custom action - if (Is_usb_hnp()) { - Usb_host_reject_hnp(); - Usb_disable_hnp_error_interrupt(); - Usb_disable_role_exchange_interrupt(); - } - Host_send_resume(); - } - - // ----------------------------------------------------------------------- - /// Host - // ----------------------------------------------------------------------- - // Remote Wake Up has been received - if (Is_host_remote_wakeup_interrupt_enabled() && Is_host_remote_wakeup()) { - TRACE_DEBUG("Remote wake up\n\r"); - Host_disable_remote_wakeup_interrupt(); - Host_disable_hwup_interrupt(); - Host_ack_remote_wakeup(); - Host_ack_hwup(); // Clear HWUP interrupt flag - Usb_unfreeze_clock(); // Enable clock on USB interface - Host_enable_sof(); // start sending SOF - Usb_send_event(EVT_HOST_REMOTE_WAKEUP); - Usb_send_event(EVT_HOST_HWUP); // Send software event - if (Is_usb_hnp()) { - Usb_host_reject_hnp(); - Usb_disable_hnp_error_interrupt(); - Usb_disable_role_exchange_interrupt(); - } - Host_send_resume(); - } -} - - -//------------------------------------------------------------------------------ -/// OTG TIMER interrupt subroutine -/// This function is called each time a OTG Timer interrupt occurs -/// Function decrements the variables required by OTG program -void otg_timer_interrupt(void) -{ - /// OTG Messaging timer - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) - || (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_FAIL)) { - if ((Get_failure_msg_delay() != 0x0000) && (Get_failure_msg_delay() != 0xFFFF)) { - Decrement_failure_msg_delay(); - } - if(pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) { - if ((Get_event_msg_delay() != 0x0000) && (Get_event_msg_delay() != 0xFFFF)) { - Decrement_event_msg_delay(); - } - } - } - /// Increments Tb_Srp counter if needed - if (Is_srp_sent_and_waiting_answer()) { - otg_tb_srp_cpt++; - } - /// Increments T_vbus_wait_connect if needed - if (Is_srp_received_and_waiting_connect()) { - otg_ta_srp_wait_connect++; - } - /// Decrements Ta_aidl_bdis timer if needed (A_suspend state) - if ((device_state == A_SUSPEND) && (otg_ta_aidl_bdis_tmr > 1)) { - otg_ta_aidl_bdis_tmr--; - } - /// Decrements Timeout_bdev_respond timer if needed - if ((device_state == DEVICE_DEFAULT) && (!Is_timeout_bdev_response_overflow())) { - otg_timeout_bdev_respond--; - } - /// Decrements Ta_vbus_rise timer if needed - if (!Is_ta_vbus_rise_counter_overflow()) { - otg_ta_vbus_rise--; - } - /// Decrements Ta_vbus_fall timer if needed - if (!Is_ta_vbus_fall_counter_overflow()) { - otg_end_hnp_vbus_delay--; - } - - /// Needed for compliance only - if (device_state == A_PERIPHERAL) { - if (Is_sof_interrupt_enabled() && (reset_received == TRUE)) { - if (otg_last_sof_stored != otg_last_sof_received) { - // No SOF is missing - otg_last_sof_received = otg_last_sof_stored; - } - else { - // SOF seems to be missing.. - Usb_freeze_clock(); - Usb_disable_sof_interrupt(); - reset_received = FALSE; - //jcb while (Timer16_get_counter_low() != 20); // overflow set to 62 in usb_task.h - Usb_unfreeze_clock(); - } - otg_last_sof_received = UDFNUML; - otg_last_sof_stored = UDFNUML; - } - } -} - - -//------------------------------------------------------------------------------ -/// OTG Messaging task initialization -/// Initializes variables and screen to prepare next messages to be handled -//------------------------------------------------------------------------------ -void Otg_message_task_init(void) -{ - TRACE_DEBUG("Otg_message_task_init\n\r"); - Otg_messaging_init(); - otg_msg_event_delay = 0; - otg_msg_failure_delay = 0; -} - - -//------------------------------------------------------------------------------ -/// OTG Messaging main task -/// OTG specifies that user must be kept informed of several events -/// This task allows user to display two kinds of messages : EVENT or FAILURE -/// For each new message, it can specify if the message remains displayed all -/// the time or only during a specified delay -//------------------------------------------------------------------------------ -void Otg_message_task(void) -{ - // Check if an OTG message must be erased (if it was set up for a specified delay) - if( (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) - || (pOTGDescriptor->bOTGMessagingOutput == OTGMSG_FAIL)) { - if (Get_failure_msg_delay() == 0) { - Otg_clear_failure_message(); - } - if(pOTGDescriptor->bOTGMessagingOutput == OTGMSG_ALL) { - if (Get_event_msg_delay() == 0) { - Otg_clear_event_message(); - } - } - } -} - - -//------------------------------------------------------------------------------ -/// Message "OTG not supported" -//------------------------------------------------------------------------------ -void otg_not_supported_device(void) -{ - TRACE_DEBUG("otg_not_supported_device\n\r"); - Otg_send_event(EVT_OTG_DEV_UNSUPPORTED); -} - - diff --git a/src/ersky9x/libraries/usb/usb.dir b/src/ersky9x/libraries/usb/usb.dir deleted file mode 100644 index bd207b17c..000000000 --- a/src/ersky9x/libraries/usb/usb.dir +++ /dev/null @@ -1,532 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \dir -/// !!!Purpose -/// -/// This directory provides a library of highly re-usable code to build -/// USB applications with Atmel AT91 microcontrollers. -/// -/// !!!Contents -/// The directory can basically be divided into three sections for their usage: -/// - common: %common USB definitions and routines, including standard USB -/// spec. and the following classes: audio, cdc, hid, massstorage; -/// - device: re-usable & portable software USB %device modules, including -/// general UDP driver for AT91 microcontroller and the following -/// devices: audio-speaker, ccid, cdc-serial, hid-keyboard, -/// massstorage; -/// - host: re-usable & portable software USB host modules -/// -/// !!!AT91 USB device framework -/// "AT91 USB device framework" is architectured as following: -/// - #Hardware layer#: low-level operations on the USB UDP controller -/// - device/core, suffixed with UDP, UDPHS, OTGHS -/// - #USB %device API#: offers hardware-independent methods and structures -/// - device/core, other files: driver, events and callbacks -/// - common/core: general USB descriptors and requests -/// - common/, other directories: general USB class descriptors and requests -/// - #Applicatioin layer#: the USB class driver and user/demo applicaiton -/// - device/, other directories, named with the class driver function -/// - project directory, with main.c -/// -/// "USB Device Framework Architecture" -/// \image USBFrameworkArchitecture.png "USB Framework Architecture" -/// -/// --- -/// -/// For more information about what a particular group contains, please refer to -/// its documentation page. -/// -/// \note -/// Depending on the project, not all the subdirectories will be available -/// (i.e. the #host# directory will not be in projects without USB host). -//------------------------------------------------------------------------------ - -/** - \page "AT91 USB device framework" - - AT91 USB %device framework is a device-side USB framework. It enables rapid - development of USB-compliant class drivers such as the Mass Storage Device - (MSD) or the Communication Device Class (CDC) and etc. - - This page shows the index to describe the AT91 USB %device framework. - - USBD: USB Device - - -# "USB Device Framework Architecture" - -# "USB Device Framework Description" - -# "Standard USB Structures" - -# "USBD API" - -# "USBD Callback API" - -# "USBD Standard Request Handler" - -# "USB Device Framework Usage" - -# "USBD File Architecture" - -# "USBD Headers" - -# "Building the Framework" - -# "USB Device Enumeration" - -*/ - -/** - \page "USB Device Framework Architecture" - - !!!Framework Architecture - - The following three-tiered structure is used: - - A #hardware layer# which performs low-level operations on the USB controller. - - The #USB API# offers hardware-independent methods and structures. - - The #application layer#, made up of a USB class driver and the user - application. - - The framework includes the USBD API and the hardware layer as well as a standard - request handler. The application layer is build on top of that to provide the - %device functionalty. - - There are also callbacks automatically called by the USBD API to perform - specific operations, to perform communication between the USBD API and the - application layer. - - \image USBFrameworkArchitecture.png "USB Framework Architecture" - -*/ - -/* (Image Link Backup) -USBFrameworkArchitecture.png - - - - - - - - -*/ - -/** - \page "USB Device Framework Description" - - !!!Framework Discription - - The framework is comprised of serveral components: - -# "Standard USB Structures" - -# "USBD API" - - Structures - - Methods - -# "USBD Callback API" - -# "USBD Standard Request Handler" -*/ - -/** - \page "USB Device Framework Usage" - - !!!File Architecture - - The USB framework is made up of the following files: - at91lib\\boards: %device register definition, board-related code and - %device startup code in assembly language\n - at91lib\\utility: debug methods and definitions\n - at91lib\\peripherals\\dbgu: DBGU port usage for debug\n - at91lib\\peripherals\\pio: PIO interface usage for Vbus ...\n - at91lib\\peripherals\\aic: Interrupt configurationi functions\n - at91lib\\usb\\common\\core: structures and methods of standard descriptors - and requests\n - at91lib\\usb\\device\\core: UDP controller driver methods and USBD API - definitions\n - usb-device-core-project: basic enumeration program, with main.c and - Makefile to build the project\n - - !!!Headers - - When programming your own application, most if not all the headers described - in the file architecture of the framework must be included. However, since - each header has its own dependencies, they must be included in a particular - order. - - Here is the standard inclusion order: -\code -#include -#include -#include -#include -#include -#include -#include -#include -#include -\endcode - If a custom class driver has been added, then its header must probably be - linked last. - - !!!Building the Framework - - A Makefile is provided to make it easier to compile the framework. The }make} - program and arm-elf-gcc is necessary to use it. - - Several options are available to build the framework in different ways: - - CHIP - - Target chip for which to build the program. - - Possible values: at91sam7s64, at91sam7s128, at91sam7s256, at91sam7s512, - at91sam7s321, at91sam7se32, at91sam7se256, at91sam7se512, at91sam7x128, - at91sam7x256, at91sam7s512, at91sam7xc128, at91sam7xc256, at91sam7xc512, - at91sam9260, at91sam9261, at91sam9263 - - Default: at91sam7s256 - - BOARD - - Board used with the chip. - - Possible values: at91sam7s-ek, at91sam7se-ek, at91sam7x-ek, - at91sam7xc-ek, at91sam7a3-ek, at91sam9260-ek, at91sam9261-ek, - at91sam9263-ek - - Default: at91sam7s-ek - -*/ - -/** - \page "USB Device Enumeration" - - This page is a step-by-step guide on how to use the USB Device framework - to produce a simple program that performs USB enumeration. In this example, - everything is put into a single file. You can look at the main.c file provided - with the framework to view the end result. - - !!!Including the Necessary Headers - - Prior to using the framework, several header files have to be included. Please - refer to "USB Device Framework Usage" for more information. - - !!!Declaring Global Varibles - - Several object instances are necessary to use the various functions and methods - of the USB framework. As following. - - !!USBD Driver - The very first step is declare the USB driver which is then used by the Class - driver. The USBDDriver structure is used as a container for several variables, - which must therefore be created first. - - !Endpoints - Depending on the application, a particular number of endpoints have to be - defined. For example, an MSD driver needs three endpoints whereas a CDC driver - needs four. Refer to the corresponding specification for more information - about the required number of endpoints. Since this example should only perform - the USB enumeration, it will declare only one endpoint: Control endpoint 0. - - Endpoints is configrued by USBEndpointDescriptor in USBDDriverDescriptors for - the driver. The FIFO banks is automatically set to its maximum value. - - !Callbacks - To replace the default callback, you should remove the default callback file - from makefile and add your own function defintion. - -||callback function file||callback function -|USBDCallbacks_Initialized.o|USBDCallbacks_Initialized -|USBDCallbacks_Reset.o|USBDCallbacks_Reset -|USBDCallbacks_Suspended.o|USBDCallbacks_Suspended -|USBDCallbacks_Resumed.o|USBDCallbacks_Resumed -|- #MUST# be defined|USBDCallbacks_RequestReceived - - !Driver - Depending on the chip used, there may or may not be a need to declare a low- - level driver variable. - - The default driver global variable is simply called usbdDriver, and will - sufficient for this example. - \code -USBDDriver usbdDriver; - \endcode - - !!Descriptors - The USB specification 2.0 defines a set of descriptors used to give - information about the %device. Depending on the USB class implemented, - different descriptors have to be used with varying values. - - In this example program, only a few descriptors are required,. The %device - descriptor is always mandatory, so it will have to be defined. At least one - configuration descriptor is required, so one is implemented. The described - configuration must have at least one interface, so one more descriptor is - needed. Finally, no string descriptors are used: - - !Device Descriptor - The device descriptor used by this example looks like this: - \code -/// Device descriptor. -const USBDeviceDescriptor usbDeviceDescriptor = { - - sizeof(USBDeviceDescriptor), - USBGenericDescriptor_DEVICE, - USBDeviceDescriptor_USB2_00, - 0, // No device class code - 0, // No device subclass code - 0, // No device protocol code - BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), - 0x03EB, // Atmel vendor ID - 0x0001, // Product ID - 0x0001, // Product release 0.01 - 0, // No manufacturer string descriptor - 0, // No product string descriptor - 0, // No serial number string descriptor - 1 // One possible configuration -}; - \endcode - The values are nothing special here. Note that the first three fields have the - same data in them (unless using USB 1.1). It is also very common to define the - class, subclass and protocol values at the interface level. - - - Note: The }vendor ID} value is provided by the USB-IF organization. The - }product ID} is vendor-specific and can be assigned any value. - - !Configuration & Interface - When the configuration descriptor is requested by the host, via the - GET_DESCRIPTOR command, the device must not only transmit this descriptor but - also all the necessary interface and endpoint descriptors. - - In order to do that easily, a structure must be defined for holding all the - information. This way, the data to send is contiguous, making the request - much simpler to fulfill. In the current example, the configuration descriptor - must be followed by the first interface descriptor. The following structure is - declared for that: - \code -// Configuration descriptors with one interface. -struct SimpleConfigurationDescriptors { - - USBConfigurationDescriptor configuration; - USBInterfaceDescriptor interface; -}; - \endcode - Now, the actual descriptors can be declared: - \code -// Configuration descriptors. -const struct SimpleConfigurationDescriptors configurationDescriptors = { - - // Configuration descriptor - { - sizeof(USBConfigurationDescriptor), - USBGenericDescriptor_CONFIGURATION, - sizeof(struct SimpleConfigurationDescriptors), - 0, // No interface in this configuration - 1, // This is configuration #1 - 0, // No string descriptor for this configuration - BOARD_USB_BMATTRIBUTES, - USBConfigurationDescriptor_POWER(100) - }, - // Interface descriptor - { - sizeof(USBInterfaceDescriptor), - USBGenericDescriptor_INTERFACE, - 0, // This is interface #0 - 0, // This is setting #0 for interface - 0, // Interface has no endpoint - 0, // No interface class code - 0, // No interface subclass code - 0, // No interface protocol code - 0, // No string descriptor - } -}; - \endcode - Again, those are very generic values. For the interface descriptor, most of - them are zeroed. This is because this example does not implement any - functionality other than doing the USB enumeration. - - !!Class Driver - The demonstration program is going to use the standard request handler - discussed in "USBD Standard Request Handler" to perform the USB enumeration. - To be able to do that, several structures must be declared. - - !Descriptors List - The USBDDriver object needs a pointer to a list of descriptors. This is - necessary to be able to answer the GET_DESCRIPTOR request. A - USBDDriverDescriptors can be used to do that. - - The actual descriptors list can be instantiated: - \code -// List of descriptors used by the device. -const USBDDriverDescriptors usbdDriverDescriptors = { - - &usbDeviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, -#ifdef BOARD_USB_UDPHS - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration descriptor - &usbDeviceDescriptor, - (const USBConfigurationDescriptor *) &configurationDescriptors, - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor -#else - 0, // No full-speed device qualifier descriptor - 0, // No full-speed other speed configuration descriptor - 0, // No high-speed device descriptor - 0, // No high-speed configuration descriptor - 0, // No high-speed device qualifier descriptor - 0, // No high-speed other speed configuration descriptor -#endif - 0, // No string descriptor - 0 // No string descriptor -}; - \endcode - The core configuration descriptor, which is actually made up of the - configuation descriptor and the first interface descriptor, has to be cast to - the USBConfigurationDescriptor type. - - !!!Interrupt Service Routines - - . - - !!USB Controller Interrupt - The USB controller peripheral generates an interrupt when an event occurs. - Since that event must be forwarded to the USBD_IrqHandler method, an - interrupt service routine must be installed to do that. - \code - void ISR_Usb() - { - USBD_IrqHandler(); - } - \endcode - Currently the default USBDCallbacks_Initialized will initialize the - interrupt service routine automatically: - \code -void USBDCallbacks_Initialized() -{ - AIC_ConfigureIT(AT91C_ID_UDP, 0, USBD_IrqHandler); - AIC_EnableIT(AT91C_ID_UDP); -} - \endcode - So the only thing you should do to initialize the interrupt service is to call - USBD_Init() in main(). - - !!VBus PIO Interrupt - The Vbus power line can be monitored (if a PIO pin is connected to it) by the - user application to enable or disable the USB controller peripheral when the - %device is connected/disconnected. To do that, an interrupt must be programmed - when the status of Vbus changes. The ISR should call the USBD_Connect or - USBD_Disconnect function as follows: - \code -void ISR_Vbus(const Pin *pPin) -{ - // Check current level on VBus - if (PIO_Get(&pinVbus)) { - USBD_Connect(); - } - else { - USBD_Disconnect(); - } -} - \endcode - - !!!Callbacks - A typical application based on this USB framework needs to instantiate most of - the callbacks available. This section describes how to do that for a simple - enumeration program. - - !!Init - When an OS is not being used, the primary function that the {Init{ callback - must perform is interrupt handler installation. The previously defined ISR - is thus configured and enabled: - \code -void USBDCallbacks_Initialized() -{ - // Configure and enable the UDP interrupt - AIC_ConfigureIT(AT91C_ID_UDP, 0, USBD_IrqHandler); - AIC_EnableIT(AT91C_ID_UDP); -} - \endcode - The default callback is defined in USBDCallbacks_Initialized.c. - - !!Suspend & Resume - The Suspend callback is used by the USBD API to notify the device that it - should enter low-power mode if required. The default callback is defined - in USBDCallbacks_Suspended.c. - \code -void USBDCallbacks_Suspended(void) -{ - // Turn off LEDs - LED_Clear(USBD_LEDPOWER); - LED_Clear(USBD_LEDUSB); -} - \endcode - The Resume callback has to perform the reverse operation. The default callback - is defined in USBDCallbacks_Resumed.c. - \code -void USBDCallbacks_Resumed(void) -{ - // Initialize LEDs - LED_Configure(USBD_LEDPOWER); - LED_Set(USBD_LEDPOWER); - LED_Configure(USBD_LEDUSB); - LED_Clear(USBD_LEDUSB); -} - \endcode - - - Note: }It is not necessary to disable the USB controller logic (transceiver, - clocks, %peripheral) here. This is done directly by the USBD_IrqHandler - function prior to triggering the callback. Typically, the callback must carry - out the following operations: - - Disable the PLL - - Switch to the slow 32 KHz clock - - Turn off the clocks of used peripherals} - - !!NewRequest - Since this example software should only perform the USB enumeration, the - NewRequest callback can simply forward the call to the standard request - handler method: - \code -void USBDCallbacks_RequestReceived(const USBGenericRequest *request) -{ - USBDDriver_RequestHandler(&usbdDriver, request); -} - \endcode - - !!!Main - The Main function of the program is used for PIO and driver (Class and USB) - initialization, software connections of the device (by using USBD_Connect), - and implementation of the product functionality. - - In this case, the Main performs the first two steps. After that, since the - enumeration is done through the event handler and the device does not do - anything, it can simply enter an infinite loop: - - \code -int main() -{ - // If they are present, configure Vbus & Wake-up pins - PIO_InitializeInterrupts(0); - - // USB initialization - USBDDriver_Initialize(&usbdDriver, &usbdDriverDescriptors, 0); - USBD_Init(); - - // connect if needed - VBUS_CONFIGURE(); - while (USBD_GetState() < USBD_STATE_CONFIGURED); - - // Main loop - while(1) - { - // Put USB class driver implementaion here - } -} - \endcode -*/ \ No newline at end of file diff --git a/src/ersky9x/massstorage.cpp b/src/ersky9x/massstorage.cpp new file mode 100644 index 000000000..c1636fdf8 --- /dev/null +++ b/src/ersky9x/massstorage.cpp @@ -0,0 +1,154 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../open9x.h" + +#ifndef SIMU + +extern "C" { +#include "usb/device/massstorage/MSDDriver.h" +extern unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID); +} + +/** Size of one block in bytes. */ +#define BLOCK_SIZE 512 + +/** Size of the MSD IO buffer in bytes (6K, more the better). */ +#define MSD_BUFFER_SIZE (12*BLOCK_SIZE) + +/** LUN read/write buffer. */ +unsigned char msdBuffer[MSD_BUFFER_SIZE]; + +unsigned int msdReadTotal=0, msdWriteTotal=0; + +static void ConfigureUsbClock(void) +{ + /* Enable PLLB for USB */ + PMC->CKGR_PLLBR = CKGR_PLLBR_DIVB(1) + | CKGR_PLLBR_MULB(7) + | CKGR_PLLBR_PLLBCOUNT_Msk; + while((PMC->PMC_SR & PMC_SR_LOCKB) == 0); // TODO && (timeout++ < CLOCK_TIMEOUT)); + /* USB Clock uses PLLB */ + PMC->PMC_USB = PMC_USB_USBDIV(1) /* /2 */ + | PMC_USB_USBS; /* PLLB */ +} + +/** Maximum number of LUNs which can be defined. */ +#define MAX_LUNS 1 + +/** Media index for different disks */ +#define DRV_SDMMC 0 /** SD card */ + +Media medias[MAX_LUNS]; + +/*---------------------------------------------------------------------------- + * Local variables + *----------------------------------------------------------------------------*/ + +/** Device LUNs. */ +MSDLun luns[MAX_LUNS]; + +char *bytes2Str(char *str, uint32_t bytes) +{ + if (bytes < 1024*100) + sprintf(str, "%lu.%luK", bytes / 1024, (bytes % 1024) / 103); + else if (bytes < 1024*1024) + sprintf(str, "%luK", bytes / 1024); + else if (bytes < 1024*1024*100) + sprintf(str, "%lu.%luM", bytes / (1024*1024), (bytes % (1024*1024)) / 104858); + else + sprintf(str, "%luM", bytes / (1024*1024)); + return str; +} + +static void MSDCallbacks_Data( unsigned char flowDirection, unsigned int dataLength, + unsigned int fifoNullCount, unsigned int fifoFullCount ) +{ + if (flowDirection) + msdReadTotal += dataLength; + else + msdWriteTotal += dataLength; + + char rdStr[10]; + char wrStr[10]; + + sprintf(statusLineMsg, "USB Rd:%s Wr:%s", bytes2Str(rdStr, msdReadTotal), bytes2Str(wrStr, msdWriteTotal)); + showStatusLine(); +} + +void usbMassStorage() +{ + static bool initialized = false; + + if (usbPlugged() && sd_card_ready()) { + TRACE_DEBUG("usbMassStorage\n\r"); + + if (sd_card_mounted()) { + Card_state = SD_ST_DATA; + audioQueue.stopSD(); + closeLogs(); + f_mount(0, 0); // unmount SD + } + + if (!initialized) { + + ConfigureUsbClock(); + + /* Initialize LUN */ + MEDSdcard_Initialize(&(medias[DRV_SDMMC]), 0); + + LUN_Init(&(luns[DRV_SDMMC]), &(medias[DRV_SDMMC]), + msdBuffer, MSD_BUFFER_SIZE, + 0, 0, 0, 0, + MSDCallbacks_Data); + + /* BOT driver initialization */ + MSDDriver_Initialize(luns, 1); + + // VBus_Configure(); + USBD_Connect(); + + initialized = true; + } + + /* Mass storage state machine */ + for (uint8_t i=0; i<50; i++) + MSDDriver_StateMachine(); + } + else { + msdReadTotal = 0; + msdWriteTotal = 0; + } +} + +#endif diff --git a/src/ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.c b/src/ersky9x/usb/common/core/USBConfigurationDescriptor.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.c rename to src/ersky9x/usb/common/core/USBConfigurationDescriptor.c diff --git a/src/ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.h b/src/ersky9x/usb/common/core/USBConfigurationDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBConfigurationDescriptor.h rename to src/ersky9x/usb/common/core/USBConfigurationDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBDeviceDescriptor.h b/src/ersky9x/usb/common/core/USBDeviceDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBDeviceDescriptor.h rename to src/ersky9x/usb/common/core/USBDeviceDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBDeviceQualifierDescriptor.h b/src/ersky9x/usb/common/core/USBDeviceQualifierDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBDeviceQualifierDescriptor.h rename to src/ersky9x/usb/common/core/USBDeviceQualifierDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c b/src/ersky9x/usb/common/core/USBEndpointDescriptor.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c rename to src/ersky9x/usb/common/core/USBEndpointDescriptor.c diff --git a/src/ersky9x/libraries/usb/common/core/USBEndpointDescriptor.h b/src/ersky9x/usb/common/core/USBEndpointDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBEndpointDescriptor.h rename to src/ersky9x/usb/common/core/USBEndpointDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBFeatureRequest.c b/src/ersky9x/usb/common/core/USBFeatureRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBFeatureRequest.c rename to src/ersky9x/usb/common/core/USBFeatureRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBFeatureRequest.h b/src/ersky9x/usb/common/core/USBFeatureRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBFeatureRequest.h rename to src/ersky9x/usb/common/core/USBFeatureRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBGenericDescriptor.c b/src/ersky9x/usb/common/core/USBGenericDescriptor.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGenericDescriptor.c rename to src/ersky9x/usb/common/core/USBGenericDescriptor.c diff --git a/src/ersky9x/libraries/usb/common/core/USBGenericDescriptor.h b/src/ersky9x/usb/common/core/USBGenericDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGenericDescriptor.h rename to src/ersky9x/usb/common/core/USBGenericDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBGenericRequest.c b/src/ersky9x/usb/common/core/USBGenericRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGenericRequest.c rename to src/ersky9x/usb/common/core/USBGenericRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBGenericRequest.h b/src/ersky9x/usb/common/core/USBGenericRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGenericRequest.h rename to src/ersky9x/usb/common/core/USBGenericRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.c b/src/ersky9x/usb/common/core/USBGetDescriptorRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.c rename to src/ersky9x/usb/common/core/USBGetDescriptorRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.h b/src/ersky9x/usb/common/core/USBGetDescriptorRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBGetDescriptorRequest.h rename to src/ersky9x/usb/common/core/USBGetDescriptorRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBInterfaceAssociationDescriptor.h b/src/ersky9x/usb/common/core/USBInterfaceAssociationDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBInterfaceAssociationDescriptor.h rename to src/ersky9x/usb/common/core/USBInterfaceAssociationDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBInterfaceDescriptor.h b/src/ersky9x/usb/common/core/USBInterfaceDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBInterfaceDescriptor.h rename to src/ersky9x/usb/common/core/USBInterfaceDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/core/USBInterfaceRequest.c b/src/ersky9x/usb/common/core/USBInterfaceRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBInterfaceRequest.c rename to src/ersky9x/usb/common/core/USBInterfaceRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBInterfaceRequest.h b/src/ersky9x/usb/common/core/USBInterfaceRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBInterfaceRequest.h rename to src/ersky9x/usb/common/core/USBInterfaceRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBIrqHandler.c b/src/ersky9x/usb/common/core/USBIrqHandler.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBIrqHandler.c rename to src/ersky9x/usb/common/core/USBIrqHandler.c diff --git a/src/ersky9x/libraries/usb/common/core/USBIrqHandler.h b/src/ersky9x/usb/common/core/USBIrqHandler.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBIrqHandler.h rename to src/ersky9x/usb/common/core/USBIrqHandler.h diff --git a/src/ersky9x/libraries/usb/common/core/USBSetAddressRequest.c b/src/ersky9x/usb/common/core/USBSetAddressRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBSetAddressRequest.c rename to src/ersky9x/usb/common/core/USBSetAddressRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBSetAddressRequest.h b/src/ersky9x/usb/common/core/USBSetAddressRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBSetAddressRequest.h rename to src/ersky9x/usb/common/core/USBSetAddressRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.c b/src/ersky9x/usb/common/core/USBSetConfigurationRequest.c similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.c rename to src/ersky9x/usb/common/core/USBSetConfigurationRequest.c diff --git a/src/ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.h b/src/ersky9x/usb/common/core/USBSetConfigurationRequest.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBSetConfigurationRequest.h rename to src/ersky9x/usb/common/core/USBSetConfigurationRequest.h diff --git a/src/ersky9x/libraries/usb/common/core/USBStringDescriptor.h b/src/ersky9x/usb/common/core/USBStringDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/core/USBStringDescriptor.h rename to src/ersky9x/usb/common/core/USBStringDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/massstorage/MSDeviceDescriptor.h b/src/ersky9x/usb/common/massstorage/MSDeviceDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/massstorage/MSDeviceDescriptor.h rename to src/ersky9x/usb/common/massstorage/MSDeviceDescriptor.h diff --git a/src/ersky9x/libraries/usb/common/massstorage/MSInterfaceDescriptor.h b/src/ersky9x/usb/common/massstorage/MSInterfaceDescriptor.h similarity index 100% rename from src/ersky9x/libraries/usb/common/massstorage/MSInterfaceDescriptor.h rename to src/ersky9x/usb/common/massstorage/MSInterfaceDescriptor.h diff --git a/src/ersky9x/libraries/usb/device/core/USBD.h b/src/ersky9x/usb/device/core/USBD.h similarity index 100% rename from src/ersky9x/libraries/usb/device/core/USBD.h rename to src/ersky9x/usb/device/core/USBD.h diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c b/src/ersky9x/usb/device/core/USBDCallbacks.c similarity index 73% rename from src/ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c rename to src/ersky9x/usb/device/core/USBDCallbacks.c index 72674d000..91dfd853f 100644 --- a/src/ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c +++ b/src/ersky9x/usb/device/core/USBDCallbacks.c @@ -34,18 +34,46 @@ #include "USBDCallbacks.h" #include "USBD.h" #include -#include +#include -//------------------------------------------------------------------------------ -// Exported function -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// Invoked after the USB driver has been initialized. By default, configures -/// the UDP/UDPHS interrupt. -//------------------------------------------------------------------------------ void USBDCallbacks_Initialized(void) { NVIC_EnableIRQ(UDP_IRQn); } +#if 0 +void USBDCallbacks_RequestReceived(const USBGenericRequest *pRequest) +{ + // Does nothing +} +#endif + +void USBDCallbacks_Reset(void) +{ + // Does nothing +} + +void USBDCallbacks_Resumed(void) +{ + // Does nothing +} + +void USBDCallbacks_Suspended(void) +{ + // Does nothing +} + +#if 0 +void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum) +{ + TRACE_INFO_WP("ConfigurationChanged "); +} +#endif + +void USBDDriverCallbacks_InterfaceSettingChanged( + unsigned char interface, + unsigned char setting) +{ + // TRACE_INFO_WP("InterfaceSettingChanged "); +} + diff --git a/src/ersky9x/libraries/usb/device/core/USBDCallbacks.h b/src/ersky9x/usb/device/core/USBDCallbacks.h similarity index 100% rename from src/ersky9x/libraries/usb/device/core/USBDCallbacks.h rename to src/ersky9x/usb/device/core/USBDCallbacks.h diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriver.c b/src/ersky9x/usb/device/core/USBDDriver.c similarity index 97% rename from src/ersky9x/libraries/usb/device/core/USBDDriver.c rename to src/ersky9x/usb/device/core/USBDDriver.c index 3362e8455..d44adab66 100644 --- a/src/ersky9x/libraries/usb/device/core/USBDDriver.c +++ b/src/ersky9x/usb/device/core/USBDDriver.c @@ -35,7 +35,7 @@ #include "USBDDriverCallbacks.h" #include "USBD.h" #include -#include +#include "debug.h" #include #include #include diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriver.h b/src/ersky9x/usb/device/core/USBDDriver.h similarity index 100% rename from src/ersky9x/libraries/usb/device/core/USBDDriver.h rename to src/ersky9x/usb/device/core/USBDDriver.h diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriverCallbacks.h b/src/ersky9x/usb/device/core/USBDDriverCallbacks.h similarity index 100% rename from src/ersky9x/libraries/usb/device/core/USBDDriverCallbacks.h rename to src/ersky9x/usb/device/core/USBDDriverCallbacks.h diff --git a/src/ersky9x/libraries/usb/device/core/USBDDriverDescriptors.h b/src/ersky9x/usb/device/core/USBDDriverDescriptors.h similarity index 100% rename from src/ersky9x/libraries/usb/device/core/USBDDriverDescriptors.h rename to src/ersky9x/usb/device/core/USBDDriverDescriptors.h diff --git a/src/ersky9x/libraries/usb/device/core/USBD_UDP.c b/src/ersky9x/usb/device/core/USBD_UDP.c similarity index 91% rename from src/ersky9x/libraries/usb/device/core/USBD_UDP.c rename to src/ersky9x/usb/device/core/USBD_UDP.c index 3506db29b..93b4ec984 100644 --- a/src/ersky9x/libraries/usb/device/core/USBD_UDP.c +++ b/src/ersky9x/usb/device/core/USBD_UDP.c @@ -44,13 +44,123 @@ #include "USBD.h" #include "USBDCallbacks.h" #include -#include -#include -#include -#include +//#include +#include "debug.h" +//#include +//#include #include #include + +//------------------------------------------------------------------------------ +// Local definitions +//------------------------------------------------------------------------------ +#define MASK_STATUS0 0xFFFFFFFC +#define MASK_STATUS1 0xFFFFFFFF + + +/*---------------------------------------------------------------------------- + * Exported functions + *----------------------------------------------------------------------------*/ + +/** + * \brief Enables the clock of a peripheral. The peripheral ID is used + * to identify which peripheral is targetted. + * \note The ID must NOT be shifted (i.e. 1 << ID_xxx). + * \param id Peripheral ID (ID_xxx). + */ +void PMC_EnablePeripheral(unsigned int id) +{ + // SANITY_CHECK(id < 35); + + if (id < 32) { + if ((PMC->PMC_PCSR0 & (1 << id)) == (1 << id)) { + + TRACE_DEBUG("PMC_EnablePeripheral: clock of peripheral" " %u is already enabled\n\r", id); + } + else { + PMC->PMC_PCER0 = 1 << id; + } + } + else { + id -= 32; + if ((PMC->PMC_PCSR1 & (1 << id)) == (1 << id)) { + + TRACE_DEBUG("PMC_EnablePeripheral: clock of peripheral" " %u is already enabled\n\r", id + 32); + } + else { + PMC->PMC_PCER1 = 1 << id; + } + } +} + +/** + * \brief Disables the clock of a peripheral. The peripheral ID is used + * to identify which peripheral is targetted. + * \note The ID must NOT be shifted (i.e. 1 << ID_xxx). + * \param id Peripheral ID (ID_xxx). + */ +void PMC_DisablePeripheral(unsigned int id) +{ + // SANITY_CHECK(id < 35); + if (id < 32) { + if ((PMC->PMC_PCSR0 & (1 << id)) != (1 << id)) { + TRACE_DEBUG("PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", id); + } + else { + PMC->PMC_PCDR0 = 1 << id; + } + } + else { + id -= 32; + if ((PMC->PMC_PCSR1 & (1 << id)) != (1 << id)) { + TRACE_DEBUG("PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", id + 32); + } + else { + PMC->PMC_PCDR1 = 1 << id; + } + } +} + +/** + * \brief Enable all the periph clock via PMC + */ +void PMC_EnableAllPeripherals(void) +{ + PMC->PMC_PCER0 = MASK_STATUS0; + while( (PMC->PMC_PCSR0 & MASK_STATUS0) != MASK_STATUS0); + PMC->PMC_PCER1 = MASK_STATUS1; + while( (PMC->PMC_PCSR1 & MASK_STATUS1) != MASK_STATUS1); + TRACE_DEBUG("Enable all periph clocks\n\r"); +} +/** + * \brief Disable all the periph clock via PMC + */ +void PMC_DisableAllPeripherals(void) +{ + PMC->PMC_PCDR0 = MASK_STATUS0; + while((PMC->PMC_PCSR0 & MASK_STATUS0) != 0); + PMC->PMC_PCDR1 = MASK_STATUS1; + while((PMC->PMC_PCSR1 & MASK_STATUS1) != 0); + TRACE_DEBUG("Disable all periph clocks\n\r"); +} + +/** + * \brief Get Periph Status for the given peripheral ID. + * \param id Peripheral ID (ID_xxx). + */ +unsigned int PMC_IsPeriphEnabled(unsigned int id) +{ + // SANITY_CHECK(id < 35); + + if (id < 32) { + return (PMC->PMC_PCSR0 & (1 << id)); + } + else { + return (PMC->PMC_PCSR1 & (1 << (id - 32))); + } +} + //------------------------------------------------------------------------------ // Definitions //------------------------------------------------------------------------------ diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSD.h b/src/ersky9x/usb/device/massstorage/MSD.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSD.h rename to src/ersky9x/usb/device/massstorage/MSD.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c b/src/ersky9x/usb/device/massstorage/MSDDStateMachine.c similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c rename to src/ersky9x/usb/device/massstorage/MSDDStateMachine.c diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.h b/src/ersky9x/usb/device/massstorage/MSDDStateMachine.h similarity index 97% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.h rename to src/ersky9x/usb/device/massstorage/MSDDStateMachine.h index 77e5cc83d..c52adc93f 100644 --- a/src/ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.h +++ b/src/ersky9x/usb/device/massstorage/MSDDStateMachine.h @@ -53,7 +53,7 @@ #include "MSD.h" #include "MSDLun.h" -#include +#include "debug.h" //----------------------------------------------------------------------------- // Definitions diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriver.c b/src/ersky9x/usb/device/massstorage/MSDDriver.c similarity index 96% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDriver.c rename to src/ersky9x/usb/device/massstorage/MSDDriver.c index fbaebb052..1890f3308 100644 --- a/src/ersky9x/libraries/usb/device/massstorage/MSDDriver.c +++ b/src/ersky9x/usb/device/massstorage/MSDDriver.c @@ -31,11 +31,11 @@ // Includes //------------------------------------------------------------------------------ -#include +#include #include "MSDDriver.h" #include "MSDDriverDescriptors.h" #include "SBCMethods.h" -#include +#include "debug.h" #include #include #include diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriver.h b/src/ersky9x/usb/device/massstorage/MSDDriver.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDriver.h rename to src/ersky9x/usb/device/massstorage/MSDDriver.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c b/src/ersky9x/usb/device/massstorage/MSDDriverDescriptors.c similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c rename to src/ersky9x/usb/device/massstorage/MSDDriverDescriptors.c diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.h b/src/ersky9x/usb/device/massstorage/MSDDriverDescriptors.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.h rename to src/ersky9x/usb/device/massstorage/MSDDriverDescriptors.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDIOFifo.h b/src/ersky9x/usb/device/massstorage/MSDIOFifo.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDIOFifo.h rename to src/ersky9x/usb/device/massstorage/MSDIOFifo.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDLun.c b/src/ersky9x/usb/device/massstorage/MSDLun.c similarity index 97% rename from src/ersky9x/libraries/usb/device/massstorage/MSDLun.c rename to src/ersky9x/usb/device/massstorage/MSDLun.c index 42999d793..61cfe825d 100644 --- a/src/ersky9x/libraries/usb/device/massstorage/MSDLun.c +++ b/src/ersky9x/usb/device/massstorage/MSDLun.c @@ -33,7 +33,7 @@ #include "MSDLun.h" -#include +#include "debug.h" #include //------------------------------------------------------------------------------ diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDLun.h b/src/ersky9x/usb/device/massstorage/MSDLun.h similarity index 97% rename from src/ersky9x/libraries/usb/device/massstorage/MSDLun.h rename to src/ersky9x/usb/device/massstorage/MSDLun.h index c46e3ad58..15754f403 100644 --- a/src/ersky9x/libraries/usb/device/massstorage/MSDLun.h +++ b/src/ersky9x/usb/device/massstorage/MSDLun.h @@ -51,7 +51,7 @@ //------------------------------------------------------------------------------ #include "SBC.h" -#include +#include #include #include diff --git a/src/ersky9x/libraries/usb/device/massstorage/SBC.h b/src/ersky9x/usb/device/massstorage/SBC.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/SBC.h rename to src/ersky9x/usb/device/massstorage/SBC.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/SBCMethods.c b/src/ersky9x/usb/device/massstorage/SBCMethods.c similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/SBCMethods.c rename to src/ersky9x/usb/device/massstorage/SBCMethods.c diff --git a/src/ersky9x/libraries/usb/device/massstorage/SBCMethods.h b/src/ersky9x/usb/device/massstorage/SBCMethods.h similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/SBCMethods.h rename to src/ersky9x/usb/device/massstorage/SBCMethods.h diff --git a/src/ersky9x/libraries/usb/device/massstorage/MSDIOFifo.c b/src/ersky9x/usb/device/massstorage/_MSDIOFifo.c similarity index 100% rename from src/ersky9x/libraries/usb/device/massstorage/MSDIOFifo.c rename to src/ersky9x/usb/device/massstorage/_MSDIOFifo.c diff --git a/src/general_menus.cpp b/src/general_menus.cpp index dd863e83e..878d78fd0 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -541,40 +541,26 @@ extern uint32_t sdAvailableAudioFiles; // TODO move that! #endif #if defined(SDCARD) -#if defined(PCBARM) && !defined(SIMU) -// TODO rewrite this ... -extern uint32_t Cmd_A41_resp; -#define OCR_SD_CCS (1UL << 30) -#else -#define Cmd_A41_resp 0 -#define OCR_SD_CCS (0) -#endif - void menuProcSdInfo(uint8_t event) { SIMPLE_SUBMENU(PSTR("SD INFO"), 1); lcd_putsLeft(2*FH, PSTR("Type:")); + lcd_puts(10*FW, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD); + lcd_putsLeft(3*FH, PSTR("Size:")); + lcd_outdezAtt(10*FW, 3*FH, SD_GET_SIZE_MB(), LEFT); + lcd_putc(lcdLastPos, 3*FH, 'M'); lcd_putsLeft(4*FH, PSTR("Sectors:")); -#if defined(PCBARM) - if (Cmd_A41_resp & OCR_SD_CCS) { - lcd_outdezAtt(10*FW, 4*FH, (SD_CSD_C_SIZE_HC(Card_CSD) + 1), LEFT); - lcd_putc(lcdLastPos, 4*FH, 'k'); - } - else { - lcd_outdezAtt(10*FW, 4*FH, SD_CSD_C_SIZE(Card_CSD), LEFT); - } -#endif + lcd_outdezAtt(10*FW, 4*FH, SD_GET_BLOCKNR()/1000, LEFT); + lcd_putc(lcdLastPos, 4*FH, 'k'); lcd_putsLeft(5*FH, PSTR("Speed:")); -#if defined(PCBARM) - lcd_outdezAtt(10*FW, 5*FH, transSpeed/1000, LEFT); + lcd_outdezAtt(10*FW, 5*FH, SD_GET_SPEED()/1000, LEFT); lcd_puts(lcdLastPos, 5*FH, "kb/s"); -#endif - lcd_putsLeft(7*FH, PSTR("CSD:")); + // lcd_putsLeft(7*FH, PSTR("CSD:")); } void menuProcSd(uint8_t event) @@ -595,7 +581,7 @@ void menuProcSd(uint8_t event) event = 0; } - SIMPLE_MENU(Cmd_A41_resp & OCR_SD_CCS ? STR_SDHC_CARD : STR_SD_CARD, menuTabDiag, e_Sd, 1+reusableBuffer.sd.count); + SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabDiag, e_Sd, 1+reusableBuffer.sd.count); if (s_editMode > 0) s_editMode = 0; diff --git a/src/logs.cpp b/src/logs.cpp index e49106f74..f59ab005e 100644 --- a/src/logs.cpp +++ b/src/logs.cpp @@ -45,8 +45,8 @@ const pm_char * openLogs() DIR folder; char filename[24]; - // close any file left open. E.G. Changing models with log switch still on. - if (g_oLogFile.fs) f_close(&g_oLogFile); + if (!sd_card_mounted()) + return STR_NO_SDCARD; strcpy_P(filename, STR_LOGS_PATH); @@ -130,16 +130,25 @@ void closeLogs() lastLogTime = 0; } +// when disk full void writeLogs() { + static const pm_char * error_displayed = NULL; + if (isFunctionActive(FUNC_LOGS) && logDelay > 0) { tmr10ms_t tmr10ms = get_tmr10ms(); if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) { lastLogTime = tmr10ms; if (!g_oLogFile.fs) { - if (!sd_card_mounted() || openLogs() != 0) + const pm_char * result = openLogs(); + if (result != NULL) { + if (result != error_displayed) { + error_displayed = result; + s_global_warning = result; + } return; + } } #if defined(PCBV4) @@ -183,12 +192,14 @@ void writeLogs() #endif #if defined(WS_HOW_HIGH) - if (g_model.frsky.usrProto == USR_PROTO_WS_HOW_HIGH) + if (g_model.frsky.usrProto == USR_PROTO_WS_HOW_HIGH) { f_printf(&g_oLogFile, "%d,", frskyData.hub.baroAltitude_bp); + } #endif - for (uint8_t i=0; i -#include -#include - -/* Include USB definitions */ -#include - -/** Size of one block in bytes. */ -#define BLOCK_SIZE 512 - -/** Size of the MSD IO buffer in bytes (6K, more the better). */ -#define MSD_BUFFER_SIZE (12*BLOCK_SIZE) - -/** LUN read/write buffer. */ -unsigned char msdBuffer[MSD_BUFFER_SIZE]; - -static void ConfigureUsbClock(void) -{ - /* Enable PLLB for USB */ - PMC->CKGR_PLLBR = CKGR_PLLBR_DIVB(1) - | CKGR_PLLBR_MULB(7) - | CKGR_PLLBR_PLLBCOUNT_Msk; - while((PMC->PMC_SR & PMC_SR_LOCKB) == 0); // TODO && (timeout++ < CLOCK_TIMEOUT)); - /* USB Clock uses PLLB */ - PMC->PMC_USB = PMC_USB_USBDIV(1) /* /2 */ - | PMC_USB_USBS; /* PLLB */ -} - -/** Maximum number of LUNs which can be defined. */ -#define MAX_LUNS 1 - -/** Media index for different disks */ -#define DRV_SDMMC 0 /** SD card */ - -Media medias[MAX_LUNS]; - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -/** Device LUNs. */ -MSDLun luns[MAX_LUNS]; - -char *bytes2Str(char *str, uint32_t bytes) -{ - if (bytes < 1024*100) - sprintf(str, "%lu.%luK", bytes / 1024, (bytes % 1024) / 103); - else if (bytes < 1024*1024) - sprintf(str, "%luK", bytes / 1024); - else if (bytes < 1024*1024*100) - sprintf(str, "%lu.%luM", bytes / (1024*1024), (bytes % (1024*1024)) / 104858); - else - sprintf(str, "%luM", bytes / (1024*1024)); - return str; -} - -unsigned int msdReadTotal=0, msdWriteTotal=0; - -static void MSDCallbacks_Data( unsigned char flowDirection, unsigned int dataLength, - unsigned int fifoNullCount, unsigned int fifoFullCount ) -{ - if (flowDirection) - msdReadTotal += dataLength; - else - msdWriteTotal += dataLength; - - char rdStr[10]; - char wrStr[10]; - - sprintf(statusLineMsg, "USB Rd:%s Wr:%s", bytes2Str(rdStr, msdReadTotal), bytes2Str(wrStr, msdWriteTotal)); - showStatusLine(); -} - -unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID); - -void usbMassStorage() -{ - static bool initialized = false; - - if (usbPlugged()) { - TRACE_DEBUG("usbMassStorage\n\r"); - - if (!initialized) { - - ConfigureUsbClock(); - - /* Initialize LUN */ - MEDSdcard_Initialize(&(medias[DRV_SDMMC]), 0); - - LUN_Init(&(luns[DRV_SDMMC]), &(medias[DRV_SDMMC]), - msdBuffer, MSD_BUFFER_SIZE, - 0, 0, 0, 0, - MSDCallbacks_Data); - - /* BOT driver initialization */ - MSDDriver_Initialize(luns, 1); - - // VBus_Configure(); - USBD_Connect(); - - initialized = true; - } - - /* Mass storage state machine */ - for (uint8_t i=0; i<50; i++) - MSDDriver_StateMachine(); - } - else { - msdReadTotal = 0; - msdWriteTotal = 0; - } -} -} // extern "C" - void menusTask(void * pdata) { open9xInit(); @@ -3433,7 +3316,7 @@ void menusTask(void * pdata) perMain(); for (uint8_t i=0; i<5; i++) { usbMassStorage(); - CoTickDelay(1); // 10ms for now + CoTickDelay(1); // 5*2ms for now } } diff --git a/src/sdcard.h b/src/sdcard.h index 5c6e7ea83..49bf6851f 100644 --- a/src/sdcard.h +++ b/src/sdcard.h @@ -81,6 +81,18 @@ extern uint32_t sd_card_mounted(); #define sd_card_mounted() (true) #endif +#if defined(PCBARM) +#define O9X_FOURCC 0x32783967 // o9x for sky9x +#elif defined(PCBV4) +#define O9X_FOURCC 0x31783967 // o9x for gruvin9x +#endif + +#if defined(PCBV4) +#define SD_IS_HC() (0) +#define SD_GET_BLOCKNR() (0) +#define SD_GET_SIZE_MB() (0) +#define SD_GET_SPEED() (0) +#endif #endif