├── .cproject ├── .gitignore ├── .mxproject ├── .project ├── .settings └── language.settings.xml ├── Add ├── CMON32.HEX ├── CMON32.h ├── CPM_BASIC.HEX ├── CPM_BASIC.h ├── Makefile ├── boot_rom.asm ├── boot_rom.c ├── boot_rom.h ├── boot_rom.hex ├── boot_rom.lk ├── boot_rom.lst ├── boot_rom.map ├── boot_rom.noi ├── boot_rom.rel ├── boot_rom.sym └── lla.he ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F4xx │ │ │ └── Include │ │ │ ├── stm32f407xx.h │ │ │ ├── stm32f4xx.h │ │ │ └── system_stm32f4xx.h │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h └── STM32F4xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f4xx_hal.h │ ├── stm32f4xx_hal_adc.h │ ├── stm32f4xx_hal_adc_ex.h │ ├── stm32f4xx_hal_cortex.h │ ├── stm32f4xx_hal_def.h │ ├── stm32f4xx_hal_dma.h │ ├── stm32f4xx_hal_dma_ex.h │ ├── stm32f4xx_hal_flash.h │ ├── stm32f4xx_hal_flash_ex.h │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal_gpio_ex.h │ ├── stm32f4xx_hal_hcd.h │ ├── stm32f4xx_hal_pwr.h │ ├── stm32f4xx_hal_pwr_ex.h │ ├── stm32f4xx_hal_rcc.h │ ├── stm32f4xx_hal_rcc_ex.h │ ├── stm32f4xx_hal_rtc.h │ ├── stm32f4xx_hal_rtc_ex.h │ ├── stm32f4xx_hal_sd.h │ ├── stm32f4xx_hal_spi.h │ ├── stm32f4xx_hal_sram.h │ ├── stm32f4xx_hal_tim.h │ ├── stm32f4xx_hal_tim_ex.h │ ├── stm32f4xx_hal_uart.h │ ├── stm32f4xx_ll_bus.h │ ├── stm32f4xx_ll_cortex.h │ ├── stm32f4xx_ll_dma.h │ ├── stm32f4xx_ll_exti.h │ ├── stm32f4xx_ll_fsmc.h │ ├── stm32f4xx_ll_gpio.h │ ├── stm32f4xx_ll_pwr.h │ ├── stm32f4xx_ll_rcc.h │ ├── stm32f4xx_ll_sdmmc.h │ ├── stm32f4xx_ll_system.h │ ├── stm32f4xx_ll_tim.h │ ├── stm32f4xx_ll_usb.h │ └── stm32f4xx_ll_utils.h │ └── Src │ ├── stm32f4xx_hal.c │ ├── stm32f4xx_hal_adc.c │ ├── stm32f4xx_hal_adc_ex.c │ ├── stm32f4xx_hal_cortex.c │ ├── stm32f4xx_hal_dma.c │ ├── stm32f4xx_hal_dma_ex.c │ ├── stm32f4xx_hal_flash.c │ ├── stm32f4xx_hal_flash_ex.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ ├── stm32f4xx_hal_gpio.c │ ├── stm32f4xx_hal_hcd.c │ ├── stm32f4xx_hal_pwr.c │ ├── stm32f4xx_hal_pwr_ex.c │ ├── stm32f4xx_hal_rcc.c │ ├── stm32f4xx_hal_rcc_ex.c │ ├── stm32f4xx_hal_rtc.c │ ├── stm32f4xx_hal_rtc_ex.c │ ├── stm32f4xx_hal_sd.c │ ├── stm32f4xx_hal_spi.c │ ├── stm32f4xx_hal_sram.c │ ├── stm32f4xx_hal_tim.c │ ├── stm32f4xx_hal_tim_ex.c │ ├── stm32f4xx_hal_uart.c │ ├── stm32f4xx_ll_dma.c │ ├── stm32f4xx_ll_exti.c │ ├── stm32f4xx_ll_fsmc.c │ ├── stm32f4xx_ll_gpio.c │ ├── stm32f4xx_ll_rcc.c │ ├── stm32f4xx_ll_sdmmc.c │ ├── stm32f4xx_ll_tim.c │ ├── stm32f4xx_ll_usb.c │ └── stm32f4xx_ll_utils.c ├── Images └── IMG_20201121_203223.jpg ├── Inc ├── 128-0.h ├── 128-1.h ├── 5x5_font.h ├── bsp_driver_sd.h ├── common_data.h ├── fatfs.h ├── ffconf.h ├── ili9341.h ├── lcd.h ├── main.h ├── main_ROM.h ├── sd_diskio.h ├── stm32_assert.h ├── stm32f4xx_hal_conf.h ├── stm32f4xx_it.h ├── usb_host.h ├── usbh_conf.h └── z80.h ├── LICENSE ├── Middlewares ├── ST │ └── STM32_USB_Host_Library │ │ ├── Class │ │ └── HID │ │ │ ├── Inc │ │ │ ├── usbh_hid.h │ │ │ ├── usbh_hid_keybd.h │ │ │ ├── usbh_hid_mouse.h │ │ │ ├── usbh_hid_parser.h │ │ │ └── usbh_hid_usage.h │ │ │ └── Src │ │ │ ├── usbh_hid.c │ │ │ ├── usbh_hid_keybd.c │ │ │ ├── usbh_hid_mouse.c │ │ │ └── usbh_hid_parser.c │ │ └── Core │ │ ├── Inc │ │ ├── usbh_core.h │ │ ├── usbh_ctlreq.h │ │ ├── usbh_def.h │ │ ├── usbh_ioreq.h │ │ └── usbh_pipes.h │ │ └── Src │ │ ├── usbh_core.c │ │ ├── usbh_ctlreq.c │ │ ├── usbh_ioreq.c │ │ └── usbh_pipes.c └── Third_Party │ └── FatFs │ └── src │ ├── diskio.c │ ├── diskio.h │ ├── ff.c │ ├── ff.h │ ├── ff_gen_drv.c │ ├── ff_gen_drv.h │ ├── integer.h │ └── option │ ├── ccsbcs.c │ └── syscall.c ├── README.md ├── Release ├── spectrum128_cpm_8bit.elf ├── spectrum128_cpm_8bit.hex ├── spectrum128_cpm_8bit_480.elf └── spectrum128_cpm_8bit_480.hex ├── STM32F407VETx_FLASH.ld ├── Src ├── BKLC.c ├── bsp_driver_sd.c ├── clock.c ├── common_data.c ├── cpm_machine.c ├── db_c.c ├── fatfs.c ├── fileDispatch.c ├── font12.c ├── font16.c ├── font20.c ├── font24.c ├── font4.c ├── font4x8.c ├── font8.c ├── font8a.c ├── font9x16.c ├── fonts.h ├── ili9341.c ├── main.c ├── main_menu.c ├── mp3play.c ├── opcode_base.h ├── opcode_cb.h ├── opcode_dd.h ├── opcode_ddcb.h ├── opcode_ed.h ├── sd_diskio.c ├── smain.c ├── stm32f4xx_hal_msp.c ├── stm32f4xx_hal_timebase_tim.c ├── stm32f4xx_it.c ├── system_stm32f4xx.c ├── tables.h ├── tape.c ├── touch_ADS7843.c ├── usb_host.c ├── usbh_conf.c └── z80.c ├── lib └── mp3 │ ├── LICENSE.txt │ ├── RCSL.txt │ ├── RPSL.txt │ ├── mp3dec.c │ ├── mp3tabs.c │ ├── platform.h │ ├── pub │ ├── CVS │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── LICENSE.txt │ ├── RCSL.txt │ ├── RPSL.txt │ ├── mp3common.h │ ├── mp3dec.h │ ├── mpadecobjfixpt.h │ └── statname.h │ ├── readme.txt │ └── real │ ├── CVS │ ├── Entries │ ├── Entries.Log │ ├── Repository │ └── Root │ ├── LICENSE.txt │ ├── RCSL.txt │ ├── RPSL.txt │ ├── assembly.h │ ├── bitstream.c │ ├── buffers.c │ ├── coder.h │ ├── dct32.c │ ├── dequant.c │ ├── dqchan.c │ ├── huffman.c │ ├── hufftabs.c │ ├── imdct.c │ ├── polyphase.c │ ├── scalfact.c │ ├── stproc.c │ ├── subband.c │ └── trigtabs_fixpt.c ├── spectrum128_cpm_8bit Debug.cfg ├── spectrum128_cpm_8bit Run.cfg ├── spectrum128_cpm_8bit.ioc ├── spectrum128_cpm_8bit.xml ├── startup └── startup_stm32f407xx.s └── syscalls.c /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spectrum128_cpm_8bit 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | fr.ac6.mcu.ide.core.MCUProjectNature 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Add/CMON32.HEX: -------------------------------------------------------------------------------- 1 | :10000000F3C3B40000000000181600000000000058 2 | :10001000C53A00084FED78E60128FA0CED78C1C921 3 | :10002000C5F53A00084FED78E60A28FA0CF1ED79AB 4 | :10003000C1C90C5072657373205B53504143455DD9 5 | :1000400020746F20616374697661746520636F6EDC 6 | :10005000736F6C650D0A000D0A5A3830204D756CAF 7 | :100060007469636F6D70204D756C7469626F6F7425 8 | :10007000204D6F6E69746F722076332E320D0A62D6 9 | :1000800061736564206F6E2064657369676E2062BA 10 | :100090007920472E20536561726C650D0A0A202075 11 | :1000A0007072657373203F20666F722068656C7094 12 | :1000B0000D0A0A000604AFD3F8D3FD3C10F93168ED 13 | :1000C000083E95D380D3823E07D37BD37C3E8032DB 14 | :1000D0000008213200E5CD0E013E82320008E1CD5C 15 | :1000E0000E013E804FED78E60120080C0CED78E61D 16 | :1000F0000128EF0CED78FE2020E80D793200083E53 17 | :100100000CD381D383215700CD0E01C350027EE66C 18 | :100110007FC8CF2318F83E0DCD20003E0AC3200033 19 | :100120000D0A42616420566F6C756D656E756D6267 20 | :10013000657200CDFB017AB7201A7B3DFEFE3014BC 21 | :100140003C3203087EFE2CC023CDDC017AB3C8ED1F 22 | :10015000530108C9212001CD0E01E1C9CDD001FE16 23 | :100160000DC8FE08282FFE03285EFE1B285AFE47F6 24 | :1001700030EAFE41300CFE3A30E2FE303004FE2C14 25 | :1001800020DA77CD20000423360078FE20280618D8 26 | :10019000CB08200800E5219101CD0E01E105282EB4 27 | :1001A0002B360018B70D61626F72746564202020D1 28 | :1001B000202020202020202020202020202020203F 29 | :1001C0002020202020200D0021A501CD0E01E1C915 30 | :1001D000CD1000FE40D8FE7BD0E65FC9110000D5EF 31 | :1001E0007ED6303814FE0A3802D6075F1600E3299F 32 | :1001F00029292919E323C3E001D1C9110000D57EC3 33 | :10020000FE413013D630380D5FE3444D29290929CA 34 | :1002100019E32318EAD1C9D11100FFC97CCD21020D 35 | :100220007DF50F0F0F0FCD2A02F1CD3002C3200054 36 | :10023000E60FC69027CE4027C90D0A3E20000D0AC2 37 | :10024000556E6B6E6F776E20436F6D6D616E6400DF 38 | :10025000215002E5210000220108213902CD0E01C2 39 | :10026000CDD001FE2038F9FE3ACA8203FE3FCA20F3 40 | :1002700006212808772336000601CD2000CD5C0139 41 | :100280002B7EFE2C200236002128087E23FE52CA37 42 | :100290002606FE53CA2B06FE49CAD606FE47CA5E8C 43 | :1002A00006FE50CA8406FE44CABD02FE43CA2703A6 44 | :1002B000213E02CD0E01C9092020202000ED5B2641 45 | :1002C0000813AFBE2803CDDC017BE6F05FD5E52146 46 | :1002D0007F0019300321FFFF222608EBE17EFE2C70 47 | :1002E000200423CDDC01E1CD1601E5CD1C023E202A 48 | :1002F000CD200006103E20CD20007ECD210223100F 49 | :10030000F421B702CD0E01E106107EE67FFE20301B 50 | :10031000023E2EFE7F30FACD20002310ED7DB4C8C2 51 | :100320007B957A9CD818C0CDDC01EB222608CD162F 52 | :1003300001CD1C023E20CD20007E5FCD21023E205B 53 | :10034000CD2000212C08AF770604CD5C01212C08BC 54 | :100350007EFE002806FE2CC8CDDC012A2608732369 55 | :1003600018C9436865636B73756D206572726F722F 56 | :10037000004845586C6F616420436F6D706C657404 57 | :1003800065001E00CDC10357CDC10367CDC1036F0A 58 | :10039000CDC103FE012009CDC1037BA7281D18157F 59 | :1003A0007AA7280BCDC10377233E2ECF1518F1CDA8 60 | :1003B000C1037BA7C8216203C30E01217103C30ED1 61 | :1003C00001D747D74F78D630FE0A3802D60707073D 62 | :1003D00007074779D630FE0A3802D607804F7B914F 63 | :1003E0005F79C90D0A2020417661696C61626C6594 64 | :1003F00020436F6D6D616E64733A0D0A0A20203AD6 65 | :100400006363787878786969626262626262094CD3 66 | :100410006F616420496E74656C2D4865782066694B 67 | :100420006C65207265636F72640D0A2020527878C3 68 | :100430007878090952756E2066726F6D2061646468 69 | :100440007265737320787878780D0A20205364647D 70 | :1004500064090953797374656D20626F6F740D0AB6 71 | :100460002020496464640909496E69743A20466F22 72 | :10047000726D6174206469726563746F72790D0ABC 73 | :100480002020506464645B2C787878785D0950751E 74 | :10049000745379733A207772697465207379737431 75 | :1004A000656D20696D6167655B2C6C6F616461646B 76 | :1004B00064726573735D0D0A0909284E6F206164CB 77 | :1004C00064726573733A2072652D757365206C6173 78 | :1004D0007374206C6F616461646472657373290D59 79 | :1004E0000A2020476464645B2C787878785D09473B 80 | :1004F00065745379733A206C6F61642073797374F7 81 | :10050000656D20747261636B0D0A0A20204478784F 82 | :1005100078785B2C797979795D0944756D70206DF7 83 | :10052000656D6F72792066726F6D207878787820AB 84 | :100530005B2C746F20797979795D0D0A0909442063 85 | :10054000286E6F2061646472657373292073686F0D 86 | :100550007773206E65787420626C6F636B0D0A2070 87 | :1005600020437878787809094368616E67652F734E 88 | :10057000686F77206D656D6F72792061742078786F 89 | :1005800078780D0A0909435220616476616E6365CB 90 | :100590007320222C222071756974730D0A0A2020A1 91 | :1005A000646464206973206120646563696D616CB3 92 | :1005B00020766F6C756D65206E756D6265722C0DA1 93 | :1005C0000A2020787878782C2079797979206973D5 94 | :1005D00020612068657861646563696D616C206184 95 | :1005E0006464726573732E0D0A20204C6561646922 96 | :1005F0006E67207A65726F73206D61792062652065 97 | :100600006F6D69747465642E0D0A20204553432074 98 | :100610006F72205E432061626F7274732E0D0A0048 99 | :1006200021E303C30E01CDDC01EBE9CD3301CDA6FF 100 | :1006300007CD1F07CD9607EDB03A0008E6020FEE92 101 | :1006400001F54F3A0308F547D92AFEFFE90D0A5391 102 | :10065000797374656D2052656164204F4B00CD3312 103 | :1006600001CDA607CD1F07CD9607EDB0214D06C3DE 104 | :100670000E010D0A53797374656D205772697465A4 105 | :10068000204F4B00CD3301ED5B0108AFB2B3280A18 106 | :10069000ED53FEBFCD9607EBEDB0CDA607CD4107DC 107 | :1006A000217206C30E01002020566F6C756D6530F7 108 | :1006B00030300000000000000000000000000000DA 109 | :1006C000000000000000E50D0A466F726D617420A5 110 | :1006D0004F4B202D2000CD330121A6061105080126 111 | :1006E0002100EDB03A03086F0608110000CB157B1E 112 | :1006F0008F275F7A8F275710F4216808737A0603D3 113 | :10070000110E08C63012ED6F1310FA210E08CBFE41 114 | :10071000CD640721C706CD0E01210608C30E0116C0 115 | :1007200002CDB307AFD389DB89FEE020FADB8877FF 116 | :100730002310F41520F13A04083C3204081D20DF90 117 | :10074000C91602CDB3073E01D389DB89FEA020FA8A 118 | :100750007ED3882310F41520F13A04083C320408B3 119 | :100760001D20DEC93E2032040806002105081602BD 120 | :10077000CDB3073E01D389DB89FEA020FA7ED38862 121 | :10078000FEE528012310F01520ED3A04083C320460 122 | :1007900008FE4020D9C9ED5BFEBF7AED44477BEDF2 123 | :1007A000444F210080C9AF3204082100801E207B05 124 | :1007B0000600C9C5F53A0308CB0FCB0F4FE63FD370 125 | :1007C0008C79E6C0D38BDB89FE8020FA3A0408D30B 126 | :1007D0008AF1C1C900000000000000000000000014 127 | :1007E0000000000000000000000000000000000009 128 | :1007F00000000000000000000000000000000000F9 129 | :00000001FF 130 | -------------------------------------------------------------------------------- /Add/Makefile: -------------------------------------------------------------------------------- 1 | SDCC=sdcc 2 | CPU=z80 3 | CODE=boot_rom 4 | 5 | all: $(CODE).hex $(CODE).h 6 | 7 | %.ihx: %.c 8 | $(SDCC) -m$(CPU) -O2 -DUSE_FLOATS=1 --opt-code-speed --peep-asm $< 9 | 10 | %.hex: %.ihx 11 | mv $< $@ 12 | 13 | %.bin: %.hex 14 | srec_cat $< -intel -o $@ -binary 15 | 16 | %.h: %.hex 17 | srec_cat $< -intel -Output $@ -C-Array 18 | 19 | disasm: $(CODE).bin 20 | z80dasm -a -t -g 0 $< 21 | 22 | clean: 23 | rm -rf *~ *.asm *.ihx *.lk *.lst *.map *.noi *.rel *.sym 24 | -------------------------------------------------------------------------------- /Add/boot_rom.lk: -------------------------------------------------------------------------------- 1 | -mjwx 2 | -i boot_rom.ihx 3 | -b _CODE = 0x0200 4 | -b _DATA = 0x8000 5 | -k /usr/bin/../share/sdcc/lib/z80 6 | -k /usr/share/sdcc/lib/z80 7 | -l z80 8 | /usr/bin/../share/sdcc/lib/z80/crt0.rel 9 | boot_rom.rel 10 | 11 | -e 12 | -------------------------------------------------------------------------------- /Add/boot_rom.noi: -------------------------------------------------------------------------------- 1 | DEF .__.ABS. 0x0 2 | DEF l__BSEG 0x0 3 | DEF l__BSS 0x0 4 | DEF l__CABS 0x0 5 | DEF l__DABS 0x0 6 | DEF l__HEADER 0x0 7 | DEF l__HEAP 0x0 8 | DEF s__CABS 0x0 9 | DEF s__DABS 0x0 10 | DEF s__HEADER 0x0 11 | DEF s__HEADER0 0x0 12 | DEF s__HEADER1 0x0 13 | DEF s__HEADER2 0x0 14 | DEF s__HEADER3 0x0 15 | DEF s__HEADER4 0x0 16 | DEF s__HEADER5 0x0 17 | DEF s__HEADER6 0x0 18 | DEF s__HEADER7 0x0 19 | DEF s__HEADER8 0x0 20 | DEF s__HEADER9 0x0 21 | DEF l__GSFINAL 0x1 22 | DEF l__HEADER1 0x2 23 | DEF l__HEADER2 0x2 24 | DEF l__HEADER3 0x2 25 | DEF l__HEADER4 0x2 26 | DEF l__HEADER5 0x2 27 | DEF l__HEADER6 0x2 28 | DEF l__HEADER0 0x3 29 | DEF l__HEADER7 0x3 30 | DEF l__HEADER8 0x3 31 | DEF l__INITIALIZED 0xA 32 | DEF l__INITIALIZER 0xA 33 | DEF l__HEADER9 0xC 34 | DEF l__GSINIT 0xF 35 | DEF s__CODE 0x200 36 | DEF l__HOME 0x961 37 | DEF l__DATA 0xFA0 38 | DEF l__CODE 0x12FC 39 | DEF s__HOME 0x14FC 40 | DEF s__INITIALIZER 0x1E5D 41 | DEF s__GSINIT 0x1E67 42 | DEF s__GSFINAL 0x1E76 43 | DEF s__DATA 0x8000 44 | DEF s__INITIALIZED 0x8FA0 45 | DEF s__BSEG 0x8FAA 46 | DEF s__BSS 0x8FAA 47 | DEF s__HEAP 0x8FAA 48 | DEF __clock 0x200 49 | DEF _exit 0x204 50 | DEF __IM1_InterruptHandler 0x20A 51 | DEF __NMI_InterruptHandler 0x219 52 | DEF _CLOCK32F 0x231 53 | DEF _CLOCK16F 0x264 54 | DEF _Delay 0x274 55 | DEF _putchar 0x29A 56 | DEF _HAL_GetTick 0x2DD 57 | DEF _xx_time_get_time 0x2E0 58 | DEF _perfTest 0x2E3 59 | DEF _main 0x66F 60 | DEF _vprintf 0x8D8 61 | DEF _printf 0x8F8 62 | DEF __divsint 0x915 63 | DEF __divschar 0x91E 64 | DEF __div8 0x925 65 | DEF __div_signexte 0x929 66 | DEF __div16 0x92D 67 | DEF __get_remainder 0x953 68 | DEF __print_format 0xA6E 69 | DEF __mulint 0x148F 70 | DEF __mul16 0x1497 71 | DEF __divuint 0x14AB 72 | DEF __divuchar 0x14B3 73 | DEF __divu8 0x14BA 74 | DEF __divu16 0x14BD 75 | DEF ___sdcc_call_hl 0x14EC 76 | DEF _strlen 0x14ED 77 | DEF ___fs2slong 0x14FC 78 | DEF ___fs2ulong 0x1579 79 | DEF ___fslt 0x163E 80 | DEF ___fsadd 0x173B 81 | DEF ___sint2fs 0x1B90 82 | DEF __mullong 0x1BAB 83 | DEF ___slong2fs 0x1D2F 84 | DEF ___ulong2fs 0x1D77 85 | DEF gsinit 0x1E67 86 | DEF _sarr 0x8000 87 | DEF _mess 0x8FA0 88 | DEF _temp1 0x8FA2 89 | DEF _A 0x8FA4 90 | DEF _B 0x8FA6 91 | DEF _C 0x8FA8 92 | LOAD boot_rom.ihx 93 | -------------------------------------------------------------------------------- /Add/boot_rom.sym: -------------------------------------------------------------------------------- 1 | ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1. 2 | Hexadecimal [16-Bits] 3 | 4 | Symbol Table 5 | 6 | .__.$$$. = 2710 L 7 | .__.ABS. = 0000 G 8 | .__.CPU. = 0000 L 9 | .__.H$L. = 0000 L 10 | 2 _A 0004 GR 11 | 2 _B 0006 GR 12 | 2 _C 0008 GR 13 | 0 _CLOCK16F 005A GR 14 | 0 _CLOCK32F 0027 GR 15 | 0 _Delay 006A GR 16 | 0 _HAL_GetTick 00D3 GR 17 | _IO2 = 0002 18 | _IO4 = 0004 19 | _IO60 = 0060 20 | _IO61 = 0061 21 | _IO62 = 0062 22 | _IO63 = 0063 23 | _IO80 = 0080 24 | _IO81 = 0081 25 | _L0 = 0005 26 | _L1 = 0006 27 | _L2 = 0007 28 | 0 __IM1_InterruptHandler 0000 GR 29 | 0 __NMI_InterruptHandler 000F GR 30 | ___fs2slong **** GX 31 | ___fsadd **** GX 32 | ___sint2fs **** GX 33 | 0 ___str_0 042C R 34 | 0 ___str_1 0439 R 35 | 0 ___str_2 044E R 36 | 0 ___str_3 066C R 37 | 0 ___str_4 0682 R 38 | 0 ___str_5 0694 R 39 | 0 ___str_6 06A7 R 40 | 0 ___str_7 06B7 R 41 | __divsint **** GX 42 | __mullong **** GX 43 | 7 __xinit__A 0004 R 44 | 7 __xinit__B 0006 R 45 | 7 __xinit__C 0008 R 46 | 7 __xinit__mess 0000 R 47 | 7 __xinit__temp1 0002 R 48 | 0 _main 0465 GR 49 | 2 _mess 0000 GR 50 | 0 _perfTest 00D9 GR 51 | _printf **** GX 52 | 0 _putchar 0090 GR 53 | 1 _sarr 0000 GR 54 | 2 _temp1 0002 GR 55 | 0 _xx_time_get_time 00D6 GR 56 | 57 | 58 | ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2. 59 | Hexadecimal [16-Bits] 60 | 61 | Area Table 62 | 63 | 0 _CODE size 6C2 flags 0 64 | 1 _DATA size FA0 flags 0 65 | 2 _INITIALIZED size A flags 0 66 | 3 _DABS size 0 flags 8 67 | 4 _HOME size 0 flags 0 68 | 5 _GSINIT size 0 flags 0 69 | 6 _GSFINAL size 0 flags 0 70 | 7 _INITIALIZER size A flags 0 71 | 8 _CABS size 0 flags 8 72 | 73 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f4xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F4XX_H 48 | #define __SYSTEM_STM32F4XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F4xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F4xx_System_Exported_types 64 | * @{ 65 | */ 66 | /* This variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | 76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F4xx_System_Exported_Constants 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F4xx_System_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup STM32F4xx_System_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | extern void SystemInit(void); 104 | extern void SystemCoreClockUpdate(void); 105 | /** 106 | * @} 107 | */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /*__SYSTEM_STM32F4XX_H */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_DMA_EX_H 38 | #define __STM32F4xx_HAL_DMA_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup DMAEx 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 57 | * @brief DMAEx Exported types 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @brief HAL DMA Memory definition 63 | */ 64 | typedef enum 65 | { 66 | MEMORY0 = 0x00U, /*!< Memory 0 */ 67 | MEMORY1 = 0x01U /*!< Memory 1 */ 68 | }HAL_DMA_MemoryTypeDef; 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /* Exported functions --------------------------------------------------------*/ 75 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 76 | * @brief DMAEx Exported functions 77 | * @{ 78 | */ 79 | 80 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 81 | * @brief Extended features functions 82 | * @{ 83 | */ 84 | 85 | /* IO operation functions *******************************************************/ 86 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 87 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 88 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 89 | 90 | /** 91 | * @} 92 | */ 93 | /** 94 | * @} 95 | */ 96 | 97 | /* Private functions ---------------------------------------------------------*/ 98 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 99 | * @brief DMAEx Private functions 100 | * @{ 101 | */ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 38 | #define __STM32F4xx_FLASH_RAMFUNC_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 44 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup FLASH_RAMFUNC 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /* Exported functions --------------------------------------------------------*/ 60 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 61 | * @{ 62 | */ 63 | 64 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 65 | * @{ 66 | */ 67 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 68 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 69 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 70 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | 93 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 94 | 95 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 96 | -------------------------------------------------------------------------------- /Images/IMG_20201121_203223.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/Images/IMG_20201121_203223.jpg -------------------------------------------------------------------------------- /Inc/5x5_font.h: -------------------------------------------------------------------------------- 1 | #ifndef BASIC_5X5_FONT_H 2 | #define BASIC_5X5_FONT_H 3 | //~ #include "main_ROM.h" 4 | //~ #define CHAR_WIDTH 6 5 | //~ #define CHAR_HEIGHT 8 6 | //#define CHAR_WIDTH 8 7 | //#define CHAR_HEIGHT 8 8 | extern const uint8_t fuse_roms_48_rom[]; 9 | //static const unsigned char *font = &fuse_roms_48_rom[0x3D00]; 10 | //~ (0x3D00 11 | #if 0 12 | static const unsigned char font[96][6] = { 13 | {0x00,0x00,0x00,0x00,0x00,0x00}, // 14 | {0x5c,0x00,0x00,0x00,0x00,0x00}, // ! 15 | {0x06,0x00,0x06,0x00,0x00,0x00}, // " 16 | {0x28,0x7c,0x28,0x7c,0x28,0x00}, // # 17 | {0x5c,0x54,0xfe,0x54,0x74,0x00}, // $ 18 | {0x44,0x20,0x10,0x08,0x44,0x00}, // % 19 | {0x28,0x54,0x54,0x20,0x50,0x00}, // & 20 | {0x06,0x00,0x00,0x00,0x00,0x00}, // ' 21 | {0x38,0x44,0x00,0x00,0x00,0x00}, // ( 22 | {0x44,0x38,0x00,0x00,0x00,0x00}, // ) 23 | {0x02,0x07,0x02,0x00,0x00,0x00}, // * 24 | {0x10,0x10,0x7c,0x10,0x10,0x00}, // + 25 | {0xc0,0x00,0x00,0x00,0x00,0x00}, // , 26 | {0x10,0x10,0x10,0x10,0x10,0x00}, // - 27 | {0x40,0x00,0x00,0x00,0x00,0x00}, // . 28 | {0x60,0x10,0x0c,0x00,0x00,0x00}, // / 29 | {0x7c,0x64,0x54,0x4c,0x7c,0x00}, // 0 30 | {0x48,0x7c,0x40,0x00,0x00,0x00}, // 1 31 | {0x64,0x54,0x54,0x54,0x48,0x00}, // 2 32 | {0x44,0x54,0x54,0x54,0x6c,0x00}, // 3 33 | {0x3c,0x20,0x70,0x20,0x20,0x00}, // 4 34 | {0x5c,0x54,0x54,0x54,0x24,0x00}, // 5 35 | {0x7c,0x54,0x54,0x54,0x74,0x00}, // 6 36 | {0x04,0x04,0x64,0x14,0x0c,0x00}, // 7 37 | {0x7c,0x54,0x54,0x54,0x7c,0x00}, // 8 38 | {0x5c,0x54,0x54,0x54,0x7c,0x00}, // 9 39 | {0x44,0x00,0x00,0x00,0x00,0x00}, // : 40 | {0xc4,0x00,0x00,0x00,0x00,0x00}, // ; 41 | {0x10,0x28,0x44,0x00,0x00,0x00}, // < 42 | {0x28,0x28,0x28,0x28,0x28,0x00}, // = 43 | {0x44,0x28,0x10,0x00,0x00,0x00}, // > 44 | {0x08,0x04,0x54,0x08,0x00,0x00}, // ? 45 | {0x7c,0x44,0x54,0x54,0x5c,0x00}, // @ 46 | {0x7c,0x24,0x24,0x24,0x7c,0x00}, // A 47 | {0x7c,0x54,0x54,0x54,0x6c,0x00}, // B 48 | {0x7c,0x44,0x44,0x44,0x44,0x00}, // C 49 | {0x7c,0x44,0x44,0x44,0x38,0x00}, // D 50 | {0x7c,0x54,0x54,0x54,0x44,0x00}, // E 51 | {0x7c,0x14,0x14,0x14,0x04,0x00}, // F 52 | {0x7c,0x44,0x44,0x54,0x74,0x00}, // G 53 | {0x7c,0x10,0x10,0x10,0x7c,0x00}, // H 54 | {0x44,0x44,0x7c,0x44,0x44,0x00}, // I 55 | {0x60,0x40,0x40,0x44,0x7c,0x00}, // J 56 | {0x7c,0x10,0x10,0x28,0x44,0x00}, // K 57 | {0x7c,0x40,0x40,0x40,0x40,0x00}, // L 58 | {0x7c,0x08,0x10,0x08,0x7c,0x00}, // M 59 | {0x7c,0x08,0x10,0x20,0x7c,0x00}, // N 60 | {0x38,0x44,0x44,0x44,0x38,0x00}, // O 61 | {0x7c,0x14,0x14,0x14,0x08,0x00}, // P 62 | {0x3c,0x24,0x64,0x24,0x3c,0x00}, // Q 63 | {0x7c,0x14,0x14,0x14,0x68,0x00}, // R 64 | {0x5c,0x54,0x54,0x54,0x74,0x00}, // S 65 | {0x04,0x04,0x7c,0x04,0x04,0x00}, // T 66 | {0x7c,0x40,0x40,0x40,0x7c,0x00}, // U 67 | {0x0c,0x30,0x40,0x30,0x0c,0x00}, // V 68 | {0x3c,0x40,0x30,0x40,0x3c,0x00}, // W 69 | {0x44,0x28,0x10,0x28,0x44,0x00}, // X 70 | {0x0c,0x10,0x60,0x10,0x0c,0x00}, // Y 71 | {0x44,0x64,0x54,0x4c,0x44,0x00}, // Z 72 | {0x7c,0x44,0x00,0x00,0x00,0x00}, // [ 73 | {0x0c,0x10,0x60,0x00,0x00,0x00}, // "\" 74 | {0x44,0x7c,0x00,0x00,0x00,0x00}, // ] 75 | {0x00,0x01,0x00,0x01,0x00,0x00}, // ^ 76 | {0x40,0x40,0x40,0x40,0x40,0x40}, // _ 77 | {0x00,0x01,0x00,0x00,0x00,0x00}, // ` 78 | {0x7c,0x24,0x24,0x24,0x7c,0x00}, // a 79 | {0x7c,0x54,0x54,0x54,0x6c,0x00}, // b 80 | {0x7c,0x44,0x44,0x44,0x44,0x00}, // c 81 | {0x7c,0x44,0x44,0x44,0x38,0x00}, // d 82 | {0x7c,0x54,0x54,0x54,0x44,0x00}, // e 83 | {0x7c,0x14,0x14,0x14,0x04,0x00}, // f 84 | {0x7c,0x44,0x44,0x54,0x74,0x00}, // g 85 | {0x7c,0x10,0x10,0x10,0x7c,0x00}, // h 86 | {0x44,0x44,0x7c,0x44,0x44,0x00}, // i 87 | {0x60,0x40,0x40,0x44,0x7c,0x00}, // j 88 | {0x7c,0x10,0x10,0x28,0x44,0x00}, // k 89 | {0x7c,0x40,0x40,0x40,0x40,0x00}, // l 90 | {0x7c,0x08,0x10,0x08,0x7c,0x00}, // m 91 | {0x7c,0x08,0x10,0x20,0x7c,0x00}, // n 92 | {0x38,0x44,0x44,0x44,0x38,0x00}, // o 93 | {0x7c,0x14,0x14,0x14,0x08,0x00}, // p 94 | {0x3c,0x24,0x64,0x24,0x3c,0x00}, // q 95 | {0x7c,0x14,0x14,0x14,0x68,0x00}, // r 96 | {0x5c,0x54,0x54,0x54,0x74,0x00}, // s 97 | {0x04,0x04,0x7c,0x04,0x04,0x00}, // t 98 | {0x7c,0x40,0x40,0x40,0x7c,0x00}, // u 99 | {0x0c,0x30,0x40,0x30,0x0c,0x00}, // v 100 | {0x3c,0x40,0x30,0x40,0x3c,0x00}, // w 101 | {0x44,0x28,0x10,0x28,0x44,0x00}, // x 102 | {0x0c,0x10,0x60,0x10,0x0c,0x00}, // y 103 | {0x44,0x64,0x54,0x4c,0x44,0x00}, // z 104 | {0x10,0x7c,0x44,0x00,0x00,0x00}, // { 105 | {0x6c,0x00,0x00,0x00,0x00,0x00}, // | 106 | {0x44,0x7c,0x10,0x00,0x00,0x00}, // } 107 | {0x02,0x01,0x02,0x01,0x00,0x00}, // ~ 108 | {0x00,0x00,0x00,0x00,0x00,0x00} 109 | }; 110 | #endif 111 | #endif 112 | -------------------------------------------------------------------------------- /Inc/bsp_driver_sd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file bsp_driver_sd.h for F4 (based on stm324x9i_eval_sd.h) 4 | * @brief This file contains the common defines and functions prototypes for 5 | * the bsp_driver_sd.c driver. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2020 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __STM32F4_SD_H 52 | #define __STM32F4_SD_H 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "stm32f4xx_hal.h" 60 | 61 | /* Exported types --------------------------------------------------------*/ 62 | /** 63 | * @brief SD Card information structure 64 | */ 65 | #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef 66 | 67 | /* Exported constants --------------------------------------------------------*/ 68 | /** 69 | * @brief SD status structure definition 70 | */ 71 | #define MSD_OK ((uint8_t)0x00) 72 | #define MSD_ERROR ((uint8_t)0x01) 73 | 74 | /** 75 | * @brief SD transfer state definition 76 | */ 77 | #define SD_TRANSFER_OK ((uint8_t)0x00) 78 | #define SD_TRANSFER_BUSY ((uint8_t)0x01) 79 | 80 | #define SD_PRESENT ((uint8_t)0x01) 81 | #define SD_NOT_PRESENT ((uint8_t)0x00) 82 | #define SD_DATATIMEOUT ((uint32_t)100000000) 83 | 84 | #ifdef OLD_API 85 | /* kept to avoid issue when migrating old projects. */ 86 | /* USER CODE BEGIN 0 */ 87 | 88 | /* USER CODE END 0 */ 89 | #else 90 | /* USER CODE BEGIN BSP_H_CODE */ 91 | /* Exported functions --------------------------------------------------------*/ 92 | uint8_t BSP_SD_Init(void); 93 | uint8_t BSP_SD_ITConfig(void); 94 | void BSP_SD_DetectIT(void); 95 | void BSP_SD_DetectCallback(void); 96 | uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout); 97 | uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout); 98 | uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks); 99 | uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks); 100 | uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr); 101 | void BSP_SD_IRQHandler(void); 102 | void BSP_SD_DMA_Tx_IRQHandler(void); 103 | void BSP_SD_DMA_Rx_IRQHandler(void); 104 | uint8_t BSP_SD_GetCardState(void); 105 | void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo); 106 | uint8_t BSP_SD_IsDetected(void); 107 | 108 | /* These functions can be modified in case the current settings (e.g. DMA stream) 109 | need to be changed for specific application needs */ 110 | void BSP_SD_AbortCallback(void); 111 | void BSP_SD_WriteCpltCallback(void); 112 | void BSP_SD_ReadCpltCallback(void); 113 | /* USER CODE END BSP_H_CODE */ 114 | #endif 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* __STM32F4_SD_H */ 121 | 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Inc/common_data.h: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | char* getFileName(); 3 | //struct sSincData SincData; 4 | uint8_t * getRamBuffer0x4000(int k); 5 | //cache init in real 6 | void realAllocPages(); 7 | #define SOUND_EVENT_ARRAY_SIZE 256 8 | #define TAPE_EVENT_ARRAY_SIZE 128 9 | 10 | union a_event 11 | { 12 | struct 13 | { 14 | int t :19; 15 | unsigned ay :1; 16 | unsigned cmd :4; 17 | unsigned data :8; 18 | } u; 19 | int32_t event; 20 | }; 21 | union t_event 22 | { 23 | struct 24 | { 25 | int t :31; 26 | unsigned data :1; 27 | } u; 28 | int32_t event; 29 | }; 30 | struct SINCL_SKEY_EVENT 31 | { 32 | unsigned code :16; 33 | unsigned pressed:1; 34 | unsigned wait_for_next:15; 35 | }; 36 | struct CBuff 37 | { 38 | int head; 39 | int tail; 40 | uint8_t bb[0x40]; 41 | }; 42 | 43 | #define SKEY_QUE_SIZE 32 44 | 45 | #define AY_REGISTERS 16 46 | 47 | typedef struct ayinfo { 48 | int current_register; 49 | uint8_t registers[ AY_REGISTERS ]; 50 | } ayinfo; 51 | 52 | #define NUM_TONES 5 53 | struct soundModule 54 | { 55 | uint8_t reg[16]; 56 | int counters[NUM_TONES]; 57 | int counters_period[NUM_TONES]; 58 | int counters_period_inv[NUM_TONES]; 59 | 60 | int counters_state[NUM_TONES]; 61 | int tick_inv[NUM_TONES]; 62 | int noise_toggle; 63 | int pattern_nu; 64 | int count; 65 | int val; 66 | 67 | }; 68 | 69 | struct sSincData 70 | { 71 | uint8_t ATTR_RAM_MOD[(0x5B00-0x5800)>>3]; 72 | union a_event aSOUND_EVENTS[SOUND_EVENT_ARRAY_SIZE]; 73 | int aSOUND_EVENTS_head; 74 | int aSOUND_EVENTS_tail; 75 | 76 | union t_event tTAPE_EVENTS[TAPE_EVENT_ARRAY_SIZE]; 77 | int tTAPE_EVENTS_head; 78 | int tTAPE_EVENTS_tail; 79 | 80 | struct SINCL_SKEY_EVENT SKEY_QUE[SKEY_QUE_SIZE]; 81 | 82 | int SKEY_QUE_head; 83 | int SKEY_QUE_tail; 84 | struct CBuff SB; 85 | ayinfo ay_z80; 86 | struct soundModule soundModule_sm; 87 | 88 | }; 89 | struct sVector 90 | { 91 | int Count; 92 | void* Vect[0x100]; 93 | }; 94 | 95 | 96 | 97 | 98 | union uCommonData 99 | { 100 | struct sSincData SincData; 101 | //struct sNesData NesData; 102 | }; 103 | 104 | 105 | 106 | #define MINI_VERS 107 | void *MALLOC(size_t bytes); 108 | void FREE(void*pnt); 109 | 110 | void initBlocks16(int size,uint8_t *basePointer); 111 | void initBlocks8(int size,uint8_t *basePointer); 112 | 113 | //uint8_t* getPntPage8R(uint32_t offset); 114 | //uint8_t* getPntPage16R(uint32_t offset); 115 | /* 116 | void setRomFilePos(size_t pos); 117 | void setVRomFilePos(size_t pos,int vrom_pages0x2000); 118 | void setFile(FCEUFILE *fp); 119 | typedef void (*wfunc)(uint16_t A,uint8_t v); 120 | typedef uint8_t (*rfunc)(uint16_t A); 121 | uint32 CalcCRC32VR(uint32 crc, struct md5_context *ctx,uint32 len); 122 | uint32 CalcCRC32R(uint32 crc, struct md5_context *ctx,uint32 len); 123 | */ 124 | 125 | -------------------------------------------------------------------------------- /Inc/fatfs.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fatfs.h 4 | * @brief Header for fatfs applications 5 | ****************************************************************************** 6 | * This notice applies to any and all portions of this file 7 | * that are not between comment pairs USER CODE BEGIN and 8 | * USER CODE END. Other portions of this file, whether 9 | * inserted by the user or by software development tools 10 | * are owned by their respective copyright owners. 11 | * 12 | * Copyright (c) 2020 STMicroelectronics International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | /* Define to prevent recursive inclusion -------------------------------------*/ 50 | #ifndef __fatfs_H 51 | #define __fatfs_H 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | #include "ff.h" 57 | #include "ff_gen_drv.h" 58 | #include "sd_diskio.h" /* defines SD_Driver as external */ 59 | 60 | /* USER CODE BEGIN Includes */ 61 | 62 | /* USER CODE END Includes */ 63 | 64 | extern uint8_t retSD; /* Return value for SD */ 65 | extern char SDPath[4]; /* SD logical drive path */ 66 | extern FATFS SDFatFS; /* File system object for SD logical drive */ 67 | extern FIL SDFile; /* File object for SD */ 68 | 69 | void MX_FATFS_Init(void); 70 | 71 | /* USER CODE BEGIN Prototypes */ 72 | 73 | /* USER CODE END Prototypes */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #endif /*__fatfs_H */ 78 | 79 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /Inc/lcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file lcd.h 4 | * @author MCD Application Team 5 | * @version V4.0.1 6 | * @date 21-July-2015 7 | * @brief This file contains all the functions prototypes for the LCD driver. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __LCD_H 40 | #define __LCD_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include 48 | 49 | /** @addtogroup BSP 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup Components 54 | * @{ 55 | */ 56 | 57 | /** @addtogroup LCD 58 | * @{ 59 | */ 60 | 61 | /** @defgroup LCD_Exported_Types 62 | * @{ 63 | */ 64 | 65 | /** @defgroup LCD_Driver_structure LCD Driver structure 66 | * @{ 67 | */ 68 | typedef struct 69 | { 70 | void (*Init)(void); 71 | uint16_t (*ReadID)(void); 72 | void (*DisplayOn)(void); 73 | void (*DisplayOff)(void); 74 | void (*SetCursor)(uint16_t, uint16_t); 75 | void (*WritePixel)(uint16_t, uint16_t, uint16_t); 76 | uint16_t (*ReadPixel)(uint16_t, uint16_t); 77 | 78 | /* Optimized operation */ 79 | void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t); 80 | void (*DrawHLine)(uint16_t, uint16_t, uint16_t, uint16_t); 81 | void (*DrawVLine)(uint16_t, uint16_t, uint16_t, uint16_t); 82 | 83 | uint16_t (*GetLcdPixelWidth)(void); 84 | uint16_t (*GetLcdPixelHeight)(void); 85 | void (*DrawBitmap)(uint16_t, uint16_t, uint8_t*); 86 | void (*DrawRGBImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*); 87 | }LCD_DrvTypeDef; 88 | /** 89 | * @} 90 | */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __LCD_H */ 113 | 114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 115 | -------------------------------------------------------------------------------- /Inc/sd_diskio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sd_diskio.h (based on sd_diskio_template.h v2.0.2) 4 | * @brief Header for sd_diskio.c module 5 | ****************************************************************************** 6 | * This notice applies to any and all portions of this file 7 | * that are not between comment pairs USER CODE BEGIN and 8 | * USER CODE END. Other portions of this file, whether 9 | * inserted by the user or by software development tools 10 | * are owned by their respective copyright owners. 11 | * 12 | * Copyright (c) 2020 STMicroelectronics International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | /* Define to prevent recursive inclusion -------------------------------------*/ 50 | #ifndef __SD_DISKIO_H 51 | #define __SD_DISKIO_H 52 | 53 | /* USER CODE BEGIN firstSection */ 54 | /* can be used to modify / undefine following code or add new definitions */ 55 | /* USER CODE END firstSection */ 56 | 57 | /* Includes ------------------------------------------------------------------*/ 58 | #include "bsp_driver_sd.h" 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* Exported constants --------------------------------------------------------*/ 61 | /* Exported functions ------------------------------------------------------- */ 62 | extern const Diskio_drvTypeDef SD_Driver; 63 | 64 | /* USER CODE BEGIN lastSection */ 65 | /* can be used to modify / undefine previous code or add new definitions */ 66 | /* USER CODE END lastSection */ 67 | 68 | #endif /* __SD_DISKIO_H */ 69 | 70 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 71 | 72 | -------------------------------------------------------------------------------- /Inc/stm32_assert.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_assert.h 4 | * @brief STM32 assert file. 5 | ****************************************************************************** 6 | * This notice applies to any and all portions of this file 7 | * that are not between comment pairs USER CODE BEGIN and 8 | * USER CODE END. Other portions of this file, whether 9 | * inserted by the user or by software development tools 10 | * are owned by their respective copyright owners. 11 | * 12 | * Copyright (c) 2020 STMicroelectronics International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | /* Define to prevent recursive inclusion -------------------------------------*/ 50 | #ifndef __STM32_ASSERT_H 51 | #define __STM32_ASSERT_H 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | /* Includes ------------------------------------------------------------------*/ 60 | /* Exported macro ------------------------------------------------------------*/ 61 | #ifdef USE_FULL_ASSERT 62 | /** 63 | * @brief The assert_param macro is used for function's parameters check. 64 | * @param expr: If expr is false, it calls assert_failed function 65 | * which reports the name of the source file and the source 66 | * line number of the call that failed. 67 | * If expr is true, it returns no value. 68 | * @retval None 69 | */ 70 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 71 | /* Exported functions ------------------------------------------------------- */ 72 | void assert_failed(uint8_t* file, uint32_t line); 73 | #else 74 | #define assert_param(expr) ((void)0U) 75 | #endif /* USE_FULL_ASSERT */ 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32_ASSERT_H */ 82 | 83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 84 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2020 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* USER CODE END Header */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_IT_H 38 | #define __STM32F4xx_IT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Private includes ----------------------------------------------------------*/ 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* Exported types ------------------------------------------------------------*/ 50 | /* USER CODE BEGIN ET */ 51 | 52 | /* USER CODE END ET */ 53 | 54 | /* Exported constants --------------------------------------------------------*/ 55 | /* USER CODE BEGIN EC */ 56 | 57 | /* USER CODE END EC */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN EM */ 61 | 62 | /* USER CODE END EM */ 63 | 64 | /* Exported functions prototypes ---------------------------------------------*/ 65 | void NMI_Handler(void); 66 | void HardFault_Handler(void); 67 | void MemManage_Handler(void); 68 | void BusFault_Handler(void); 69 | void UsageFault_Handler(void); 70 | void SVC_Handler(void); 71 | void DebugMon_Handler(void); 72 | void PendSV_Handler(void); 73 | void SysTick_Handler(void); 74 | void EXTI0_IRQHandler(void); 75 | void EXTI3_IRQHandler(void); 76 | void EXTI4_IRQHandler(void); 77 | void EXTI9_5_IRQHandler(void); 78 | void TIM2_IRQHandler(void); 79 | void TIM3_IRQHandler(void); 80 | void USART2_IRQHandler(void); 81 | void SDIO_IRQHandler(void); 82 | void DMA2_Stream1_IRQHandler(void); 83 | void DMA2_Stream2_IRQHandler(void); 84 | void DMA2_Stream3_IRQHandler(void); 85 | void OTG_FS_IRQHandler(void); 86 | /* USER CODE BEGIN EFP */ 87 | 88 | /* USER CODE END EFP */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __STM32F4xx_IT_H */ 95 | 96 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 97 | -------------------------------------------------------------------------------- /Inc/usb_host.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usb_host.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usb_host.c file. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2020 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USB_HOST__H__ 52 | #define __USB_HOST__H__ 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "stm32f4xx.h" 60 | #include "stm32f4xx_hal.h" 61 | 62 | /* USER CODE BEGIN INCLUDE */ 63 | 64 | /* USER CODE END INCLUDE */ 65 | 66 | /** @addtogroup USBH_OTG_DRIVER 67 | * @{ 68 | */ 69 | 70 | /** @defgroup USBH_HOST USBH_HOST 71 | * @brief Host file for Usb otg low level driver. 72 | * @{ 73 | */ 74 | 75 | /** @defgroup USBH_HOST_Exported_Variables USBH_HOST_Exported_Variables 76 | * @brief Public variables. 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** Status of the application. */ 85 | typedef enum { 86 | APPLICATION_IDLE = 0, 87 | APPLICATION_START, 88 | APPLICATION_READY, 89 | APPLICATION_DISCONNECT 90 | }ApplicationTypeDef; 91 | 92 | /** @defgroup USBH_HOST_Exported_FunctionsPrototype USBH_HOST_Exported_FunctionsPrototype 93 | * @brief Declaration of public functions for Usb host. 94 | * @{ 95 | */ 96 | 97 | /* Exported functions -------------------------------------------------------*/ 98 | 99 | /** @brief USB Host initialization function. */ 100 | void MX_USB_HOST_Init(void); 101 | 102 | void MX_USB_HOST_Process(void); 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* __USB_HOST__H__ */ 121 | 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_mouse.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hid_mouse.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file contains all the prototypes for the usbh_hid_mouse.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_HID_MOUSE_H 30 | #define __USBH_HID_MOUSE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_hid.h" 38 | 39 | /** @addtogroup USBH_LIB 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBH_CLASS 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup USBH_HID_CLASS 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBH_HID_MOUSE 52 | * @brief This file is the Header file for usbh_hid_mouse.c 53 | * @{ 54 | */ 55 | 56 | 57 | /** @defgroup USBH_HID_MOUSE_Exported_Types 58 | * @{ 59 | */ 60 | 61 | typedef struct _HID_MOUSE_Info 62 | { 63 | uint8_t x; 64 | uint8_t y; 65 | uint8_t buttons[3]; 66 | } 67 | HID_MOUSE_Info_TypeDef; 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBH_HID_MOUSE_Exported_Defines 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBH_HID_MOUSE_Exported_Macros 81 | * @{ 82 | */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBH_HID_MOUSE_Exported_Variables 88 | * @{ 89 | */ 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup USBH_HID_MOUSE_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | USBH_StatusTypeDef USBH_HID_MouseInit(USBH_HandleTypeDef *phost); 98 | HID_MOUSE_Info_TypeDef *USBH_HID_GetMouseInfo(USBH_HandleTypeDef *phost); 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* __USBH_HID_MOUSE_H */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 126 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_parser.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hid_parser.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file is the header file of the usbh_hid_parser.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive -----------------------------------------------*/ 29 | #ifndef __USBH_HID_PARSER_H 30 | #define __USBH_HID_PARSER_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_hid.h" 38 | #include "usbh_hid_usage.h" 39 | 40 | /** @addtogroup USBH_LIB 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup USBH_CLASS 45 | * @{ 46 | */ 47 | 48 | /** @addtogroup USBH_HID_CLASS 49 | * @{ 50 | */ 51 | 52 | /** @defgroup USBH_HID_PARSER 53 | * @brief This file is the Header file for usbh_hid_parser.c 54 | * @{ 55 | */ 56 | 57 | 58 | /** @defgroup USBH_HID_PARSER_Exported_Types 59 | * @{ 60 | */ 61 | typedef struct 62 | { 63 | uint8_t *data; 64 | uint32_t size; 65 | uint8_t shift; 66 | uint8_t count; 67 | uint8_t sign; 68 | uint32_t logical_min; /*min value device can return*/ 69 | uint32_t logical_max; /*max value device can return*/ 70 | uint32_t physical_min; /*min vale read can report*/ 71 | uint32_t physical_max; /*max value read can report*/ 72 | uint32_t resolution; 73 | } 74 | HID_Report_ItemTypedef; 75 | 76 | 77 | uint32_t HID_ReadItem (HID_Report_ItemTypedef *ri, uint8_t ndx); 78 | uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx); 79 | 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* __USBH_HID_PARSER_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 107 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hid_parser.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file is the HID Layer Handlers for USB Host HID class. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbh_hid_parser.h" 29 | 30 | 31 | /** @addtogroup USBH_LIB 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup USBH_CLASS 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup USBH_HID_CLASS 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_HID_PARSER 44 | * @brief This file includes HID parsers for USB Host HID class. 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBH_HID_PARSER_Private_TypesDefinitions 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | /** @defgroup USBH_HID_PARSER_Private_Defines 57 | * @{ 58 | */ 59 | /** 60 | * @} 61 | */ 62 | 63 | 64 | /** @defgroup USBH_HID_PARSER_Private_Macros 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBH_HID_PARSER_Private_FunctionPrototypes 72 | * @{ 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | 80 | /** @defgroup USBH_HID_PARSER_Private_Variables 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | 89 | /** @defgroup USBH_HID_PARSER_Private_Functions 90 | * @{ 91 | */ 92 | 93 | /** 94 | * @brief HID_ReadItem 95 | * The function read a report item. 96 | * @param ri: report item 97 | * @param ndx: report index 98 | * @retval status (0 : fail / otherwise: item value) 99 | */ 100 | uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx) 101 | { 102 | uint32_t val=0; 103 | uint32_t x=0; 104 | uint32_t bofs; 105 | uint8_t *data=ri->data; 106 | uint8_t shift=ri->shift; 107 | 108 | /* get the logical value of the item */ 109 | 110 | /* if this is an array, wee may need to offset ri->data.*/ 111 | if (ri->count > 0) 112 | { 113 | /* If app tries to read outside of the array. */ 114 | if (ri->count <= ndx) 115 | { 116 | return(0); 117 | } 118 | 119 | /* calculate bit offset */ 120 | bofs = ndx*ri->size; 121 | bofs += shift; 122 | /* calculate byte offset + shift pair from bit offset. */ 123 | data+=bofs/8; 124 | shift=(uint8_t)(bofs%8); 125 | } 126 | /* read data bytes in little endian order */ 127 | for(x=0; x < ((ri->size & 0x7) ? (ri->size/8)+1 : (ri->size/8)); x++) 128 | { 129 | val=(uint32_t)(*data << (x*8)); 130 | } 131 | val=(val >> shift) & ((1<size)-1); 132 | 133 | if (val < ri->logical_min || val > ri->logical_max) 134 | { 135 | return(0); 136 | } 137 | 138 | /* convert logical value to physical value */ 139 | /* See if the number is negative or not. */ 140 | if ((ri->sign) && (val & (1<<(ri->size-1)))) 141 | { 142 | /* yes, so sign extend value to 32 bits. */ 143 | int vs=(int)((-1 & ~((1<<(ri->size))-1)) | val); 144 | 145 | if(ri->resolution == 1) 146 | { 147 | return((uint32_t)vs); 148 | } 149 | return((uint32_t)(vs*ri->resolution)); 150 | } 151 | else 152 | { 153 | if(ri->resolution == 1) 154 | { 155 | return(val); 156 | } 157 | return(val*ri->resolution); 158 | } 159 | } 160 | 161 | /** 162 | * @brief HID_WriteItem 163 | * The function write a report item. 164 | * @param ri: report item 165 | * @param ndx: report index 166 | * @retval status (1: fail/ 0 : Ok) 167 | */ 168 | uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx) 169 | { 170 | uint32_t x; 171 | uint32_t mask; 172 | uint32_t bofs; 173 | uint8_t *data=ri->data; 174 | uint8_t shift=ri->shift; 175 | 176 | if (value < ri->physical_min || value > ri->physical_max) 177 | { 178 | return(1); 179 | } 180 | 181 | /* if this is an array, wee may need to offset ri->data.*/ 182 | if (ri->count > 0) 183 | { 184 | /* If app tries to read outside of the array. */ 185 | if (ri->count >= ndx) 186 | { 187 | return(0); 188 | } 189 | /* calculate bit offset */ 190 | bofs = ndx*ri->size; 191 | bofs += shift; 192 | /* calculate byte offset + shift pair from bit offset. */ 193 | data+=bofs/8; 194 | shift=(uint8_t)(bofs%8); 195 | 196 | } 197 | 198 | /* Convert physical value to logical value. */ 199 | if (ri->resolution != 1) 200 | { 201 | value=value/ri->resolution; 202 | } 203 | 204 | /* Write logical value to report in little endian order. */ 205 | mask=(uint32_t)((1<size)-1); 206 | value = (value & mask) << shift; 207 | 208 | for(x=0; x < ((ri->size & 0x7) ? (ri->size/8)+1 : (ri->size/8)); x++) 209 | { 210 | *(ri->data+x)=(uint8_t)((*(ri->data+x) & ~(mask>>(x*8))) | ((value>>(x*8)) & (mask>>(x*8)))); 211 | } 212 | return(0); 213 | } 214 | 215 | /** 216 | * @} 217 | */ 218 | 219 | /** 220 | * @} 221 | */ 222 | 223 | /** 224 | * @} 225 | */ 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | 232 | /** 233 | * @} 234 | */ 235 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 236 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_core.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_core.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_CORE_H 30 | #define __USBH_CORE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_conf.h" 38 | #include "usbh_def.h" 39 | #include "usbh_ioreq.h" 40 | #include "usbh_pipes.h" 41 | #include "usbh_ctlreq.h" 42 | 43 | /** @addtogroup USBH_LIB 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup USBH_LIB_CORE 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBH_CORE 52 | * @brief This file is the Header file for usbh_core.c 53 | * @{ 54 | */ 55 | 56 | 57 | /** @defgroup USBH_CORE_Exported_Defines 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | #define HOST_USER_SELECT_CONFIGURATION 1 65 | #define HOST_USER_CLASS_ACTIVE 2 66 | #define HOST_USER_CLASS_SELECTED 3 67 | #define HOST_USER_CONNECTION 4 68 | #define HOST_USER_DISCONNECTION 5 69 | #define HOST_USER_UNRECOVERED_ERROR 6 70 | 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | 77 | 78 | /** @defgroup USBH_CORE_Exported_Macros 79 | * @{ 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup USBH_CORE_Exported_Variables 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup USBH_CORE_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | 98 | 99 | USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t ), uint8_t id); 100 | USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost); 101 | USBH_StatusTypeDef USBH_RegisterClass(USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass); 102 | USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface); 103 | uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, 104 | uint8_t Class, 105 | uint8_t SubClass, 106 | uint8_t Protocol); 107 | uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost); 108 | 109 | uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, 110 | uint8_t interface_number, 111 | uint8_t alt_settings); 112 | 113 | USBH_StatusTypeDef USBH_Start (USBH_HandleTypeDef *phost); 114 | USBH_StatusTypeDef USBH_Stop (USBH_HandleTypeDef *phost); 115 | USBH_StatusTypeDef USBH_Process (USBH_HandleTypeDef *phost); 116 | USBH_StatusTypeDef USBH_ReEnumerate (USBH_HandleTypeDef *phost); 117 | 118 | /* USBH Low Level Driver */ 119 | USBH_StatusTypeDef USBH_LL_Init (USBH_HandleTypeDef *phost); 120 | USBH_StatusTypeDef USBH_LL_DeInit (USBH_HandleTypeDef *phost); 121 | USBH_StatusTypeDef USBH_LL_Start (USBH_HandleTypeDef *phost); 122 | USBH_StatusTypeDef USBH_LL_Stop (USBH_HandleTypeDef *phost); 123 | 124 | USBH_StatusTypeDef USBH_LL_Connect (USBH_HandleTypeDef *phost); 125 | USBH_StatusTypeDef USBH_LL_Disconnect (USBH_HandleTypeDef *phost); 126 | USBH_SpeedTypeDef USBH_LL_GetSpeed (USBH_HandleTypeDef *phost); 127 | USBH_StatusTypeDef USBH_LL_ResetPort (USBH_HandleTypeDef *phost); 128 | uint32_t USBH_LL_GetLastXferSize (USBH_HandleTypeDef *phost, uint8_t ); 129 | USBH_StatusTypeDef USBH_LL_DriverVBUS (USBH_HandleTypeDef *phost, uint8_t ); 130 | 131 | USBH_StatusTypeDef USBH_LL_OpenPipe (USBH_HandleTypeDef *phost, uint8_t, uint8_t, uint8_t, uint8_t , uint8_t, uint16_t ); 132 | USBH_StatusTypeDef USBH_LL_ClosePipe (USBH_HandleTypeDef *phost, uint8_t ); 133 | USBH_StatusTypeDef USBH_LL_SubmitURB (USBH_HandleTypeDef *phost, uint8_t, uint8_t,uint8_t, uint8_t, uint8_t*, uint16_t, uint8_t ); 134 | USBH_URBStateTypeDef USBH_LL_GetURBState (USBH_HandleTypeDef *phost, uint8_t ); 135 | #if (USBH_USE_OS == 1) 136 | USBH_StatusTypeDef USBH_LL_NotifyURBChange (USBH_HandleTypeDef *phost); 137 | #endif 138 | USBH_StatusTypeDef USBH_LL_SetToggle (USBH_HandleTypeDef *phost, uint8_t , uint8_t ); 139 | uint8_t USBH_LL_GetToggle (USBH_HandleTypeDef *phost, uint8_t ); 140 | 141 | /* USBH Time base */ 142 | void USBH_Delay (uint32_t Delay); 143 | void USBH_LL_SetTimer (USBH_HandleTypeDef *phost, uint32_t ); 144 | void USBH_LL_IncTimer (USBH_HandleTypeDef *phost); 145 | /** 146 | * @} 147 | */ 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif /* __USBH_CORE_H */ 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_ctlreq.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_ctlreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_CTLREQ_H 30 | #define __USBH_CTLREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_core.h" 38 | 39 | /** @addtogroup USBH_LIB 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBH_LIB_CORE 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBH_CTLREQ 48 | * @brief This file is the 49 | * @{ 50 | */ 51 | 52 | 53 | /** @defgroup USBH_CTLREQ_Exported_Defines 54 | * @{ 55 | */ 56 | /*Standard Feature Selector for clear feature command*/ 57 | #define FEATURE_SELECTOR_ENDPOINT 0X00 58 | #define FEATURE_SELECTOR_DEVICE 0X01 59 | 60 | 61 | #define INTERFACE_DESC_TYPE 0x04 62 | #define ENDPOINT_DESC_TYPE 0x05 63 | #define INTERFACE_DESC_SIZE 0x09 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | 70 | /** @defgroup USBH_CTLREQ_Exported_Types 71 | * @{ 72 | */ 73 | /** 74 | * @} 75 | */ 76 | 77 | 78 | /** @defgroup USBH_CTLREQ_Exported_Macros 79 | * @{ 80 | */ 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBH_CTLREQ_Exported_Variables 86 | * @{ 87 | */ 88 | extern uint8_t USBH_CfgDesc[512]; 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup USBH_CTLREQ_Exported_FunctionsPrototype 94 | * @{ 95 | */ 96 | USBH_StatusTypeDef USBH_CtlReq (USBH_HandleTypeDef *phost, 97 | uint8_t *buff, 98 | uint16_t length); 99 | 100 | USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, 101 | uint8_t req_type, 102 | uint16_t value_idx, 103 | uint8_t* buff, 104 | uint16_t length ); 105 | 106 | USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, 107 | uint8_t length); 108 | 109 | USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost, 110 | uint8_t string_index, 111 | uint8_t *buff, 112 | uint16_t length); 113 | 114 | USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, 115 | uint16_t configuration_value); 116 | 117 | USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost, 118 | uint16_t length); 119 | 120 | USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost, 121 | uint8_t DeviceAddress); 122 | 123 | USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, 124 | uint8_t ep_num, uint8_t altSetting); 125 | 126 | USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, 127 | uint8_t ep_num); 128 | 129 | USBH_DescHeader_t *USBH_GetNextDesc (uint8_t *pbuf, 130 | uint16_t *ptr); 131 | /** 132 | * @} 133 | */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* __USBH_CTLREQ_H */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 154 | 155 | 156 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_ioreq.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_ioreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_IOREQ_H 30 | #define __USBH_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_conf.h" 38 | #include "usbh_core.h" 39 | 40 | /** @addtogroup USBH_LIB 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup USBH_LIB_CORE 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBH_IOREQ 49 | * @brief This file is the header file for usbh_ioreq.c 50 | * @{ 51 | */ 52 | 53 | 54 | /** @defgroup USBH_IOREQ_Exported_Defines 55 | * @{ 56 | */ 57 | 58 | #define USBH_PID_SETUP 0 59 | #define USBH_PID_DATA 1 60 | 61 | #define USBH_EP_CONTROL 0 62 | #define USBH_EP_ISO 1 63 | #define USBH_EP_BULK 2 64 | #define USBH_EP_INTERRUPT 3 65 | 66 | #define USBH_SETUP_PKT_SIZE 8 67 | /** 68 | * @} 69 | */ 70 | 71 | 72 | /** @defgroup USBH_IOREQ_Exported_Types 73 | * @{ 74 | */ 75 | /** 76 | * @} 77 | */ 78 | 79 | 80 | /** @defgroup USBH_IOREQ_Exported_Macros 81 | * @{ 82 | */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBH_IOREQ_Exported_Variables 88 | * @{ 89 | */ 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup USBH_IOREQ_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | USBH_StatusTypeDef USBH_CtlSendSetup (USBH_HandleTypeDef *phost, 98 | uint8_t *buff, 99 | uint8_t hc_num); 100 | 101 | USBH_StatusTypeDef USBH_CtlSendData (USBH_HandleTypeDef *phost, 102 | uint8_t *buff, 103 | uint16_t length, 104 | uint8_t hc_num, 105 | uint8_t do_ping ); 106 | 107 | USBH_StatusTypeDef USBH_CtlReceiveData(USBH_HandleTypeDef *phost, 108 | uint8_t *buff, 109 | uint16_t length, 110 | uint8_t hc_num); 111 | 112 | USBH_StatusTypeDef USBH_BulkReceiveData(USBH_HandleTypeDef *phost, 113 | uint8_t *buff, 114 | uint16_t length, 115 | uint8_t hc_num); 116 | 117 | USBH_StatusTypeDef USBH_BulkSendData (USBH_HandleTypeDef *phost, 118 | uint8_t *buff, 119 | uint16_t length, 120 | uint8_t hc_num, 121 | uint8_t do_ping ); 122 | 123 | USBH_StatusTypeDef USBH_InterruptReceiveData(USBH_HandleTypeDef *phost, 124 | uint8_t *buff, 125 | uint8_t length, 126 | uint8_t hc_num); 127 | 128 | USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost, 129 | uint8_t *buff, 130 | uint8_t length, 131 | uint8_t hc_num); 132 | 133 | 134 | USBH_StatusTypeDef USBH_IsocReceiveData(USBH_HandleTypeDef *phost, 135 | uint8_t *buff, 136 | uint32_t length, 137 | uint8_t hc_num); 138 | 139 | 140 | USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost, 141 | uint8_t *buff, 142 | uint32_t length, 143 | uint8_t hc_num); 144 | /** 145 | * @} 146 | */ 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | 152 | #endif /* __USBH_IOREQ_H */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 167 | 168 | 169 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_pipes.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_pipes.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_PIPES_H 30 | #define __USBH_PIPES_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_core.h" 38 | 39 | /** @addtogroup USBH_LIB 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBH_LIB_CORE 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBH_PIPES 48 | * @brief This file is the header file for usbh_pipes.c 49 | * @{ 50 | */ 51 | 52 | /** @defgroup USBH_PIPES_Exported_Defines 53 | * @{ 54 | */ 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBH_PIPES_Exported_Types 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBH_PIPES_Exported_Macros 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBH_PIPES_Exported_Variables 75 | * @{ 76 | */ 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USBH_PIPES_Exported_FunctionsPrototype 82 | * @{ 83 | */ 84 | 85 | USBH_StatusTypeDef USBH_OpenPipe (USBH_HandleTypeDef *phost, 86 | uint8_t ch_num, 87 | uint8_t epnum, 88 | uint8_t dev_address, 89 | uint8_t speed, 90 | uint8_t ep_type, 91 | uint16_t mps); 92 | 93 | USBH_StatusTypeDef USBH_ClosePipe (USBH_HandleTypeDef *phost, 94 | uint8_t pipe_num); 95 | 96 | uint8_t USBH_AllocPipe (USBH_HandleTypeDef *phost, 97 | uint8_t ep_addr); 98 | 99 | USBH_StatusTypeDef USBH_FreePipe (USBH_HandleTypeDef *phost, 100 | uint8_t idx); 101 | 102 | 103 | 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /* __USBH_PIPES_H */ 115 | 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 130 | 131 | 132 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_pipes.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file implements functions for opening and closing Pipes 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbh_pipes.h" 30 | 31 | /** @addtogroup USBH_LIB 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup USBH_LIB_CORE 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBH_PIPES 40 | * @brief This file includes opening and closing Pipes 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBH_PIPES_Private_Defines 45 | * @{ 46 | */ 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup USBH_PIPES_Private_TypesDefinitions 52 | * @{ 53 | */ 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | /** @defgroup USBH_PIPES_Private_Macros 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBH_PIPES_Private_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | 76 | /** @defgroup USBH_PIPES_Private_Functions 77 | * @{ 78 | */ 79 | static uint16_t USBH_GetFreePipe (USBH_HandleTypeDef *phost); 80 | 81 | 82 | /** 83 | * @brief USBH_Open_Pipe 84 | * Open a pipe 85 | * @param phost: Host Handle 86 | * @param pipe_num: Pipe Number 87 | * @param dev_address: USB Device address allocated to attached device 88 | * @param speed : USB device speed (Full/Low) 89 | * @param ep_type: end point type (Bulk/int/ctl) 90 | * @param mps: max pkt size 91 | * @retval USBH Status 92 | */ 93 | USBH_StatusTypeDef USBH_OpenPipe (USBH_HandleTypeDef *phost, 94 | uint8_t pipe_num, 95 | uint8_t epnum, 96 | uint8_t dev_address, 97 | uint8_t speed, 98 | uint8_t ep_type, 99 | uint16_t mps) 100 | { 101 | 102 | USBH_LL_OpenPipe(phost, 103 | pipe_num, 104 | epnum, 105 | dev_address, 106 | speed, 107 | ep_type, 108 | mps); 109 | 110 | return USBH_OK; 111 | 112 | } 113 | 114 | /** 115 | * @brief USBH_ClosePipe 116 | * Close a pipe 117 | * @param phost: Host Handle 118 | * @param pipe_num: Pipe Number 119 | * @retval USBH Status 120 | */ 121 | USBH_StatusTypeDef USBH_ClosePipe (USBH_HandleTypeDef *phost, 122 | uint8_t pipe_num) 123 | { 124 | 125 | USBH_LL_ClosePipe(phost, pipe_num); 126 | 127 | return USBH_OK; 128 | 129 | } 130 | 131 | /** 132 | * @brief USBH_Alloc_Pipe 133 | * Allocate a new Pipe 134 | * @param phost: Host Handle 135 | * @param ep_addr: End point for which the Pipe to be allocated 136 | * @retval Pipe number 137 | */ 138 | uint8_t USBH_AllocPipe (USBH_HandleTypeDef *phost, uint8_t ep_addr) 139 | { 140 | uint16_t pipe; 141 | 142 | pipe = USBH_GetFreePipe(phost); 143 | 144 | if (pipe != 0xFFFF) 145 | { 146 | phost->Pipes[pipe] = 0x8000 | ep_addr; 147 | } 148 | return pipe; 149 | } 150 | 151 | /** 152 | * @brief USBH_Free_Pipe 153 | * Free the USB Pipe 154 | * @param phost: Host Handle 155 | * @param idx: Pipe number to be freed 156 | * @retval USBH Status 157 | */ 158 | USBH_StatusTypeDef USBH_FreePipe (USBH_HandleTypeDef *phost, uint8_t idx) 159 | { 160 | if(idx < 11) 161 | { 162 | phost->Pipes[idx] &= 0x7FFF; 163 | } 164 | return USBH_OK; 165 | } 166 | 167 | /** 168 | * @brief USBH_GetFreePipe 169 | * @param phost: Host Handle 170 | * Get a free Pipe number for allocation to a device endpoint 171 | * @retval idx: Free Pipe number 172 | */ 173 | static uint16_t USBH_GetFreePipe (USBH_HandleTypeDef *phost) 174 | { 175 | uint8_t idx = 0; 176 | 177 | for (idx = 0 ; idx < 11 ; idx++) 178 | { 179 | if ((phost->Pipes[idx] & 0x8000) == 0) 180 | { 181 | return idx; 182 | } 183 | } 184 | return 0xFFFF; 185 | } 186 | /** 187 | * @} 188 | */ 189 | 190 | /** 191 | * @} 192 | */ 193 | 194 | /** 195 | * @} 196 | */ 197 | 198 | /** 199 | * @} 200 | */ 201 | 202 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 203 | 204 | 205 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/FatFs/src/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl function */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | 34 | 35 | DSTATUS disk_initialize (BYTE pdrv); 36 | DSTATUS disk_status (BYTE pdrv); 37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 40 | DWORD get_fattime (void); 41 | 42 | /* Disk Status Bits (DSTATUS) */ 43 | 44 | #define STA_NOINIT 0x01 /* Drive not initialized */ 45 | #define STA_NODISK 0x02 /* No medium in the drive */ 46 | #define STA_PROTECT 0x04 /* Write protected */ 47 | 48 | 49 | /* Command code for disk_ioctrl fucntion */ 50 | 51 | /* Generic command (Used by FatFs) */ 52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 57 | 58 | /* Generic command (Not used by FatFs) */ 59 | #define CTRL_POWER 5 /* Get/Set power status */ 60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 61 | #define CTRL_EJECT 7 /* Eject media */ 62 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 63 | 64 | /* MMC/SDC specific ioctl command */ 65 | #define MMC_GET_TYPE 10 /* Get card type */ 66 | #define MMC_GET_CSD 11 /* Get CSD */ 67 | #define MMC_GET_CID 12 /* Get CID */ 68 | #define MMC_GET_OCR 13 /* Get OCR */ 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/FatFs/src/ff_gen_drv.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file ff_gen_drv.h 4 | * @author MCD Application Team 5 | * @version V2.0.2 6 | * @date 10-November-2017 7 | * @brief Header for ff_gen_drv.c module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© Copyright (c) 2017 STMicroelectronics International N.V. 12 | * All rights reserved.

13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted, provided that the following conditions are met: 16 | * 17 | * 1. Redistribution of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of other 23 | * contributors to this software may be used to endorse or promote products 24 | * derived from this software without specific written permission. 25 | * 4. This software, including modifications and/or derivative works of this 26 | * software, must execute solely and exclusively on microcontroller or 27 | * microprocessor devices manufactured by or for STMicroelectronics. 28 | * 5. Redistribution and use of this software other than as permitted under 29 | * this license is void and will automatically terminate your rights under 30 | * this license. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 35 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 36 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 37 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 38 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 39 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 40 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 43 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | * 45 | ****************************************************************************** 46 | */ 47 | 48 | /* Define to prevent recursive inclusion -------------------------------------*/ 49 | #ifndef __FF_GEN_DRV_H 50 | #define __FF_GEN_DRV_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /* Includes ------------------------------------------------------------------*/ 57 | #include "diskio.h" 58 | #include "ff.h" 59 | #include "stdint.h" 60 | 61 | 62 | /* Exported types ------------------------------------------------------------*/ 63 | 64 | /** 65 | * @brief Disk IO Driver structure definition 66 | */ 67 | typedef struct 68 | { 69 | DSTATUS (*disk_initialize) (BYTE); /*!< Initialize Disk Drive */ 70 | DSTATUS (*disk_status) (BYTE); /*!< Get Disk Status */ 71 | DRESULT (*disk_read) (BYTE, BYTE*, DWORD, UINT); /*!< Read Sector(s) */ 72 | #if _USE_WRITE == 1 73 | DRESULT (*disk_write) (BYTE, const BYTE*, DWORD, UINT); /*!< Write Sector(s) when _USE_WRITE = 0 */ 74 | #endif /* _USE_WRITE == 1 */ 75 | #if _USE_IOCTL == 1 76 | DRESULT (*disk_ioctl) (BYTE, BYTE, void*); /*!< I/O control operation when _USE_IOCTL = 1 */ 77 | #endif /* _USE_IOCTL == 1 */ 78 | 79 | }Diskio_drvTypeDef; 80 | 81 | /** 82 | * @brief Global Disk IO Drivers structure definition 83 | */ 84 | typedef struct 85 | { 86 | uint8_t is_initialized[_VOLUMES]; 87 | const Diskio_drvTypeDef *drv[_VOLUMES]; 88 | uint8_t lun[_VOLUMES]; 89 | volatile uint8_t nbr; 90 | 91 | }Disk_drvTypeDef; 92 | 93 | /* Exported constants --------------------------------------------------------*/ 94 | /* Exported macro ------------------------------------------------------------*/ 95 | /* Exported functions ------------------------------------------------------- */ 96 | uint8_t FATFS_LinkDriver(const Diskio_drvTypeDef *drv, char *path); 97 | uint8_t FATFS_UnLinkDriver(char *path); 98 | uint8_t FATFS_LinkDriverEx(const Diskio_drvTypeDef *drv, char *path, BYTE lun); 99 | uint8_t FATFS_UnLinkDriverEx(char *path, BYTE lun); 100 | uint8_t FATFS_GetAttachedDriversNbr(void); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __FF_GEN_DRV_H */ 107 | 108 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 109 | 110 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/FatFs/src/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | typedef unsigned __int64 QWORD; 13 | 14 | 15 | #else /* Embedded platform */ 16 | 17 | /* These types MUST be 16-bit or 32-bit */ 18 | typedef int INT; 19 | typedef unsigned int UINT; 20 | 21 | /* This type MUST be 8-bit */ 22 | typedef unsigned char BYTE; 23 | 24 | /* These types MUST be 16-bit */ 25 | typedef short SHORT; 26 | typedef unsigned short WORD; 27 | typedef unsigned short WCHAR; 28 | 29 | /* These types MUST be 32-bit */ 30 | typedef long LONG; 31 | typedef unsigned long DWORD; 32 | 33 | /* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */ 34 | typedef unsigned long long QWORD; 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spectrum128_cpm_8bit 2 | 3 | Spectrum 128 & spectrum48 & AY-3-8910 complete emulation on stm32f407vt6 + 3.2 inch ILI9341 4 | USB keyboard. (Delete resistor R21 1.5K: 3.3v<->USB D+.) 5 | 6 | 7 | CPM part: 8 | https://www.youtube.com/watch?v=-h3XCy79aJw 9 | 10 | 11 | Take disk image here: 12 | https://obsolescence.wixsite.com/obsolescence/multicomp-fpga-cpm-demo-disk 13 | 14 | 15 | Spectrum part: 16 | https://www.youtube.com/watch?v=WKQc5I55Ji8&t=712s 17 | 18 | SD card: 19 | Partition 1 type Start 2048 : W95 FAT32 (b) 20 | Attributes: 80 21 | Filesystem UUID: xxxx-xxxx 22 | Filesystem: vfat 23 | 24 | Dirs on root: 25 | 26 | Z48 27 | Put spectrum48 files here.Форматы: .TAP,.Z80,.SNA 28 | 29 | 30 | Z128 31 | Put spectrum128 files here spectrum128.Форматы: .TAP,.Z80,.SNA 32 | 33 | MP3 34 | Put mp3 files here 35 | 36 | Short decription in russian: 37 | https://habr.com/ru/post/524498/ 38 | -------------------------------------------------------------------------------- /Release/spectrum128_cpm_8bit.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/Release/spectrum128_cpm_8bit.elf -------------------------------------------------------------------------------- /Release/spectrum128_cpm_8bit_480.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/Release/spectrum128_cpm_8bit_480.elf -------------------------------------------------------------------------------- /STM32F407VETx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Abstract : Linker script for STM32F407VETx Device with 8 | ** 512KByte FLASH, 128KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ** (c)Copyright Ac6. 22 | ** You may use this file as-is or modify it according to the needs of your 23 | ** project. Distribution of this file (unmodified or modified) is not 24 | ** permitted. Ac6 permit registered System Workbench for MCU users the 25 | ** rights to distribute the assembled, compiled & linked contents of this 26 | ** file as part of an application binary file, provided that it is built 27 | ** using the System Workbench for MCU toolchain. 28 | ** 29 | ***************************************************************************** 30 | */ 31 | 32 | /* Entry Point */ 33 | ENTRY(Reset_Handler) 34 | 35 | /* Highest address of the user mode stack */ 36 | _estack = 0x20020000; /* end of RAM */ 37 | /* Generate a link error if heap and stack don't fit into RAM */ 38 | _Min_Heap_Size = 0x200; /* required amount of heap */ 39 | _Min_Stack_Size = 0x400; /* required amount of stack */ 40 | 41 | /* Specify the memory areas */ 42 | MEMORY 43 | { 44 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 45 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K 46 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 47 | } 48 | 49 | /* Define output sections */ 50 | SECTIONS 51 | { 52 | /* The startup code goes first into FLASH */ 53 | .isr_vector : 54 | { 55 | . = ALIGN(4); 56 | KEEP(*(.isr_vector)) /* Startup code */ 57 | . = ALIGN(4); 58 | } >FLASH 59 | 60 | /* The program code and other data goes into FLASH */ 61 | .text : 62 | { 63 | . = ALIGN(4); 64 | *(.text) /* .text sections (code) */ 65 | *(.text*) /* .text* sections (code) */ 66 | *(.glue_7) /* glue arm to thumb code */ 67 | *(.glue_7t) /* glue thumb to arm code */ 68 | *(.eh_frame) 69 | 70 | KEEP (*(.init)) 71 | KEEP (*(.fini)) 72 | 73 | . = ALIGN(4); 74 | _etext = .; /* define a global symbols at end of code */ 75 | } >FLASH 76 | 77 | /* Constant data goes into FLASH */ 78 | .rodata : 79 | { 80 | . = ALIGN(4); 81 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 82 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 83 | . = ALIGN(4); 84 | } >FLASH 85 | 86 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 87 | .ARM : { 88 | __exidx_start = .; 89 | *(.ARM.exidx*) 90 | __exidx_end = .; 91 | } >FLASH 92 | 93 | .preinit_array : 94 | { 95 | PROVIDE_HIDDEN (__preinit_array_start = .); 96 | KEEP (*(.preinit_array*)) 97 | PROVIDE_HIDDEN (__preinit_array_end = .); 98 | } >FLASH 99 | .init_array : 100 | { 101 | PROVIDE_HIDDEN (__init_array_start = .); 102 | KEEP (*(SORT(.init_array.*))) 103 | KEEP (*(.init_array*)) 104 | PROVIDE_HIDDEN (__init_array_end = .); 105 | } >FLASH 106 | .fini_array : 107 | { 108 | PROVIDE_HIDDEN (__fini_array_start = .); 109 | KEEP (*(SORT(.fini_array.*))) 110 | KEEP (*(.fini_array*)) 111 | PROVIDE_HIDDEN (__fini_array_end = .); 112 | } >FLASH 113 | 114 | /* used by the startup to initialize data */ 115 | _sidata = LOADADDR(.data); 116 | 117 | /* Initialized data sections goes into RAM, load LMA copy after code */ 118 | .data : 119 | { 120 | . = ALIGN(4); 121 | _sdata = .; /* create a global symbol at data start */ 122 | *(.data) /* .data sections */ 123 | *(.data*) /* .data* sections */ 124 | 125 | . = ALIGN(4); 126 | _edata = .; /* define a global symbol at data end */ 127 | } >RAM AT> FLASH 128 | 129 | _siccmram = LOADADDR(.ccmram); 130 | 131 | /* CCM-RAM section 132 | * 133 | * IMPORTANT NOTE! 134 | * If initialized variables will be placed in this section, 135 | * the startup code needs to be modified to copy the init-values. 136 | */ 137 | .ccmram : 138 | { 139 | . = ALIGN(4); 140 | _sccmram = .; /* create a global symbol at ccmram start */ 141 | *(.ccmram) 142 | *(.ccmram*) 143 | 144 | . = ALIGN(4); 145 | _eccmram = .; /* create a global symbol at ccmram end */ 146 | } >CCMRAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /Src/clock.c: -------------------------------------------------------------------------------- 1 | #include "stm32f4xx_hal.h" 2 | #include "main.h" 3 | #include 4 | #include "ili9341.h" 5 | extern RTC_HandleTypeDef hrtc; 6 | int oldSec = -1; 7 | int clock_dispatch(struct SYS_EVENT* ev) 8 | { 9 | if(ev->message==MESS_OPEN) 10 | { 11 | clearFullScreen(); 12 | ev->message = MESS_IDLE; 13 | return 1; 14 | } 15 | else if(ev->message==MESS_IDLE) 16 | { 17 | RTC_TimeTypeDef sTime; 18 | RTC_DateTypeDef Date; 19 | HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BCD); 20 | HAL_RTC_GetDate(&hrtc, &Date, RTC_FORMAT_BCD); 21 | //mprintf("%02x:%02x:%02x\r\n",sTime.Hours,sTime.Minutes,sTime.Seconds); 22 | if(oldSec!=sTime.Seconds) 23 | { 24 | char buffer[0x20]; 25 | sprintf(buffer,"%02x:%02x:%02x",sTime.Hours,sTime.Minutes,sTime.Seconds); 26 | LCD_Draw_Text2(buffer,(LCD_getWidth()-strlen(buffer)*4*8)/2,LCD_getHeight()/2-16*4, GREEN, 4,16,BLACK); 27 | sprintf(buffer,"%02x %02x",Date.Date,Date.Month); 28 | LCD_Draw_Text(buffer,(LCD_getWidth()-strlen(buffer)*4*8)/2,0, GREEN, 4,BLACK); 29 | oldSec=sTime.Seconds; 30 | Delay(2); 31 | } 32 | Delay(2); 33 | return 1; 34 | } 35 | else if(ev->message==MESS_KEYBOARD) 36 | { 37 | if(ev->param1==K_ESC) 38 | { 39 | ev->message = MESS_CLOSE; 40 | return 0; 41 | } 42 | ev->message = MESS_IDLE; 43 | return 1; 44 | } 45 | else 46 | { 47 | ev->message = MESS_IDLE; 48 | } 49 | return 1; 50 | } 51 | -------------------------------------------------------------------------------- /Src/common_data.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | #include 5 | #include "ili9341.h" 6 | #include "common_data.h" 7 | 8 | union uCommonData CommonData; 9 | 10 | int to_update = 1; 11 | 12 | typedef char* pchar; 13 | 14 | void Timer(int param); 15 | 16 | void initFuncTables(); 17 | void compressFuncTables(); 18 | int bRun = 0; 19 | void sound_push(int32_t data) 20 | { 21 | const int volume = MAX_VOLUME; 22 | } 23 | void init_retro(char* filename) 24 | { 25 | 26 | } 27 | 28 | int nes_dispatch(struct SYS_EVENT* ev) 29 | { 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /Src/db_c.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | int memoryBalanse = 0; 6 | #define CHECK_MEM 7 | #ifdef CHECK_MEM 8 | void *MALLOC(size_t bytes) 9 | { 10 | size_t* rpnt = malloc(bytes+sizeof(size_t)); 11 | *rpnt = bytes; 12 | memoryBalanse += bytes; 13 | printf("bytes+ %d all %d pnt = %x \n",bytes,memoryBalanse,(void*)(rpnt+1)); 14 | return (void*)(rpnt+1); 15 | } 16 | 17 | void FREE(void*pnt) 18 | { 19 | if((size_t)pnt<16) 20 | { 21 | printf("bytes- free 0 all %d\n",memoryBalanse); 22 | return ; 23 | } 24 | size_t* rpnt = pnt; 25 | rpnt--; 26 | int bytes = *rpnt; 27 | printf("bytes- %d all %d pnt=%x\n",bytes,memoryBalanse,pnt); 28 | memoryBalanse -= bytes; 29 | free(rpnt); 30 | } 31 | #else 32 | void *MALLOC(size_t bytes) 33 | { 34 | printf("bytes+ %d\n",bytes); 35 | return malloc(bytes); 36 | } 37 | void FREE(void*pnt) 38 | { 39 | printf("free+ %x\n",pnt); 40 | free(pnt); 41 | } 42 | #endif 43 | struct node 44 | { 45 | char *key; 46 | char *value; 47 | struct node *left, *right; 48 | }; 49 | 50 | // C function to search a given key in a given BST 51 | struct node* search(struct node* root, char *key) 52 | { 53 | // Base Cases: root is null or key is present at root 54 | if (root == NULL || strcmp(root->key, key)==0) 55 | return root; 56 | 57 | // Key is greater than root's key 58 | if (strcmp(root->key, key)<0) 59 | return search(root->right, key); 60 | 61 | // Key is smaller than root's key 62 | return search(root->left, key); 63 | } 64 | 65 | 66 | // A utility function to create a new BST node 67 | struct node *newNode(char * key,char *value) 68 | { 69 | struct node *temp = (struct node *)MALLOC(sizeof(struct node)); 70 | temp->key = MALLOC(strlen(key)+1); 71 | strcpy(temp->key,key); 72 | temp->value = MALLOC(strlen(value)+1); 73 | strcpy(temp->value,value); 74 | temp->left = temp->right = NULL; 75 | return temp; 76 | } 77 | 78 | // A utility function to do inorder traversal of BST 79 | void inorder(struct node *root) 80 | { 81 | if (root != NULL) 82 | { 83 | inorder(root->left); 84 | printf("%s %s \n", root->key,root->value); 85 | inorder(root->right); 86 | } 87 | } 88 | void inorder_destroy(struct node *root) 89 | { 90 | if (root != NULL) 91 | { 92 | inorder_destroy(root->left); 93 | //printf("%s \n", root->key); 94 | inorder_destroy(root->right); 95 | FREE(root->key) ; 96 | FREE(root->value) ; 97 | FREE(root); 98 | } 99 | } 100 | 101 | /* A utility function to insert a new node with given key in BST */ 102 | struct node* insert(struct node* node,char* key,char* value) 103 | { 104 | /* If the tree is empty, return a new node */ 105 | if (node == NULL) return newNode(key,value); 106 | 107 | /* Otherwise, recur down the tree */ 108 | int res = strcmp(key ,node->key); 109 | if (res<0) 110 | { 111 | node->left = insert(node->left, key,value); 112 | } 113 | //else if (key > node->key) 114 | else 115 | { 116 | node->right = insert(node->right, key,value); 117 | } 118 | 119 | /* return the (unchanged) node pointer */ 120 | return node; 121 | } 122 | 123 | struct node *root = NULL; 124 | 125 | void nodes_init() 126 | { 127 | root = NULL; 128 | #ifdef CHECK_MEM 129 | memoryBalanse = 0; 130 | #endif 131 | } 132 | 133 | void nodes_destroy() 134 | { 135 | inorder_destroy(root); 136 | #ifdef CHECK_MEM 137 | printf("memoryBalanse = %d\n",memoryBalanse); 138 | #endif 139 | } 140 | 141 | void add_Key(char* key,char* val) 142 | { 143 | if(!root) 144 | { 145 | root = insert(root,key,val); 146 | } 147 | else 148 | { 149 | insert(root,key,val); 150 | } 151 | //key_map.insert(std::pair(key,val)); 152 | } 153 | 154 | const char* find_Key(char* key) 155 | { 156 | struct node* res = search(root,key); 157 | if(res) 158 | { 159 | if(!strcmp(res->key,key)) 160 | { 161 | return res->value; 162 | } 163 | else return NULL; 164 | } 165 | return NULL; 166 | } 167 | #ifdef MAIN_TEST 168 | int main() 169 | { 170 | nodes_init(); 171 | add_Key("hello","hello123"); 172 | add_Key("Alo","1234"); 173 | add_Key("bello","12345"); 174 | add_Key("bello","1234"); 175 | add_Key("cello","1234"); 176 | inorder(root); 177 | char* val = find_Key("bello"); 178 | if(val) 179 | { 180 | printf("found %s \n",val); 181 | } 182 | nodes_destroy(); 183 | return 0; 184 | } 185 | #endif 186 | -------------------------------------------------------------------------------- /Src/fatfs.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fatfs.c 4 | * @brief Code for fatfs applications 5 | ****************************************************************************** 6 | * This notice applies to any and all portions of this file 7 | * that are not between comment pairs USER CODE BEGIN and 8 | * USER CODE END. Other portions of this file, whether 9 | * inserted by the user or by software development tools 10 | * are owned by their respective copyright owners. 11 | * 12 | * Copyright (c) 2020 STMicroelectronics International N.V. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted, provided that the following conditions are met: 17 | * 18 | * 1. Redistribution of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of other 24 | * contributors to this software may be used to endorse or promote products 25 | * derived from this software without specific written permission. 26 | * 4. This software, including modifications and/or derivative works of this 27 | * software, must execute solely and exclusively on microcontroller or 28 | * microprocessor devices manufactured by or for STMicroelectronics. 29 | * 5. Redistribution and use of this software other than as permitted under 30 | * this license is void and will automatically terminate your rights under 31 | * this license. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | #include "fatfs.h" 50 | 51 | uint8_t retSD; /* Return value for SD */ 52 | char SDPath[4]; /* SD logical drive path */ 53 | FATFS SDFatFS; /* File system object for SD logical drive */ 54 | FIL SDFile; /* File object for SD */ 55 | 56 | /* USER CODE BEGIN Variables */ 57 | 58 | /* USER CODE END Variables */ 59 | 60 | void MX_FATFS_Init(void) 61 | { 62 | /*## FatFS: Link the SD driver ###########################*/ 63 | retSD = FATFS_LinkDriver(&SD_Driver, SDPath); 64 | 65 | /* USER CODE BEGIN Init */ 66 | /* additional user code for init */ 67 | /* USER CODE END Init */ 68 | } 69 | 70 | /** 71 | * @brief Gets Time from RTC 72 | * @param None 73 | * @retval Time in DWORD 74 | */ 75 | DWORD get_fattime(void) 76 | { 77 | /* USER CODE BEGIN get_fattime */ 78 | return 0; 79 | /* USER CODE END get_fattime */ 80 | } 81 | 82 | /* USER CODE BEGIN Application */ 83 | 84 | /* USER CODE END Application */ 85 | 86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 87 | -------------------------------------------------------------------------------- /Src/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fonts.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-February-2014 7 | * @brief Header for fonts.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __FONTS_H 40 | #define __FONTS_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include 48 | 49 | /** @addtogroup Utilities 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup STM32_EVAL 54 | * @{ 55 | */ 56 | 57 | /** @addtogroup Common 58 | * @{ 59 | */ 60 | 61 | /** @addtogroup FONTS 62 | * @{ 63 | */ 64 | 65 | /** @defgroup FONTS_Exported_Types 66 | * @{ 67 | */ 68 | typedef struct _tFont 69 | { 70 | const uint8_t *table; 71 | uint16_t Width; 72 | uint16_t Height; 73 | 74 | } sFONT; 75 | 76 | extern sFONT Font24; 77 | extern sFONT Font20; 78 | extern sFONT Font16; 79 | extern sFONT Font12; 80 | extern sFONT Font8; 81 | extern sFONT Font4x8; 82 | extern sFONT Font9x16; 83 | extern sFONT FONT_CURR; 84 | //Font4x8 85 | 86 | #define FONT_CURR Font12 87 | 88 | 89 | #define CHAR_WIDTH (FONT_CURR.Width) 90 | #define CHAR_HEIGHT (FONT_CURR.Height) 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** @defgroup FONTS_Exported_Constants 97 | * @{ 98 | */ 99 | #define LINE(x) ((x) * (((sFONT *)BSP_LCD_GetFont())->Height)) 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** @defgroup FONTS_Exported_Macros 106 | * @{ 107 | */ 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup FONTS_Exported_Functions 113 | * @{ 114 | */ 115 | /** 116 | * @} 117 | */ 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif /* __FONTS_H */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /Src/main_menu.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "ili9341.h" 3 | 4 | int testTouch_dispatch(struct SYS_EVENT* ev); 5 | int clock_dispatch(struct SYS_EVENT* ev); 6 | int file_dispatch(struct SYS_EVENT* ev); 7 | #define ITEMS_ON_SCREEN 3 8 | #define strMenuArraySize 8 9 | 10 | void StandbyMode(void) 11 | { 12 | /* Enable Power Clock */ 13 | __HAL_RCC_PWR_CLK_ENABLE(); 14 | 15 | /* Allow access to Backup */ 16 | HAL_PWR_EnableBkUpAccess(); 17 | 18 | /* Reset RTC Domain */ 19 | __HAL_RCC_BACKUPRESET_FORCE(); 20 | __HAL_RCC_BACKUPRESET_RELEASE(); 21 | 22 | /* Disable all used wakeup sources: Pin1(PA.0) */ 23 | HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); 24 | 25 | /* Clear all related wakeup flags */ 26 | __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 27 | 28 | /* Re-enable all used wakeup sources: Pin1(PA.0) */ 29 | HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); 30 | 31 | /*## Enter Standby Mode ####################################################*/ 32 | /* Request to enter STANDBY mode */ 33 | HAL_PWR_EnterSTANDBYMode(); 34 | } 35 | 36 | struct sMenuState 37 | { 38 | int header_position; 39 | int header_position0; 40 | //int item_position; 41 | int lines_vpos[strMenuArraySize]; 42 | int lines_vpos0[strMenuArraySize]; 43 | } MenuState; 44 | 45 | 46 | char* strMenuArray [strMenuArraySize] = 47 | { 48 | " ZX48 ", 49 | " ZX128 ", 50 | " MP3 ", 51 | " Paint ", 52 | " Calibr", 53 | " SysInf", 54 | " CLOCK ", 55 | " STB " 56 | }; 57 | 58 | int nofrendo_main(int argc, char *argv[]); 59 | 60 | #define LAST strMenuArraySize 61 | int menu_dispatch(struct SYS_EVENT* ev) 62 | { 63 | if(ev->message!=0) 64 | { 65 | //printf("dummy mess = %x\r\n",ev->message); 66 | } 67 | if(ev->message==MESS_OPEN) 68 | { 69 | MenuState.header_position = 0; 70 | MenuState.header_position0 = 0; 71 | for(int i=0;imessage = MESS_REPAINT; 77 | return 1; 78 | } 79 | if(ev->message==MESS_REPAINT) 80 | { 81 | clearFullScreen(); 82 | for(int k=0;kmessage = MESS_IDLE; 97 | return 1; 98 | 99 | } 100 | else if(ev->message==MESS_KEYBOARD) 101 | { 102 | if(ev->param1==K_UP) 103 | { 104 | //if(MenuState.item_position>0) 105 | { 106 | // MenuState.item_position--; 107 | } 108 | } 109 | else if(ev->param1==K_DOWN) 110 | { 111 | 112 | } 113 | else if(ev->param1==K_LEFT) 114 | { 115 | if(MenuState.header_position>0) 116 | { 117 | MenuState.header_position--; 118 | if(MenuState.header_position - MenuState.header_position0<0) 119 | { 120 | MenuState.header_position0 = MenuState.header_position; 121 | } 122 | } 123 | } 124 | else if(ev->param1==K_RIGHT) 125 | { 126 | if(MenuState.header_positionITEMS_ON_SCREEN-1) 130 | { 131 | MenuState.header_position0 =MenuState.header_position-ITEMS_ON_SCREEN+1; 132 | } 133 | } 134 | } 135 | else if(ev->param1==K_FIRE) 136 | { 137 | if(MenuState.header_position==4) 138 | { 139 | ReCalibrateTouch(1); 140 | } 141 | else if(MenuState.header_position==3) 142 | { 143 | setCurrentFunc(&testTouch_dispatch); 144 | ev->message = MESS_OPEN; 145 | clearKey(); 146 | return 1; 147 | //testTouch(); 148 | } 149 | else if(MenuState.header_position==2) 150 | { 151 | setCurrentFunc(&file_dispatch); 152 | ev->param1 = 2; 153 | ev->message = MESS_OPEN; 154 | clearKey(); 155 | return 1; 156 | //testTouch(); 157 | } 158 | else if(MenuState.header_position==1) 159 | { 160 | setCurrentFunc(&file_dispatch); 161 | ev->param1 = 1; 162 | ev->message = MESS_OPEN; 163 | clearKey(); 164 | return 1; 165 | //testTouch(); 166 | } 167 | else if(MenuState.header_position==0) 168 | { 169 | setCurrentFunc(&file_dispatch); 170 | ev->param1 = 0; 171 | ev->message = MESS_OPEN; 172 | clearKey(); 173 | return 1; 174 | //testTouch(); 175 | } 176 | else if(MenuState.header_position==6) 177 | { 178 | setCurrentFunc(&clock_dispatch); 179 | ev->message = MESS_OPEN; 180 | clearKey(); 181 | return 1; 182 | } 183 | else if(MenuState.header_position==7) 184 | { 185 | //ili9341_DisplayOff(); 186 | //StandbyMode(); 187 | setCurrentFunc(&file_dispatch); 188 | ev->param1 = 3; 189 | ev->message = MESS_OPEN; 190 | clearKey(); 191 | return 1; 192 | } 193 | 194 | } 195 | 196 | ev->message=MESS_REPAINT; 197 | clearKey(); 198 | return 1; 199 | } 200 | else if(ev->message==MESS_IDLE) 201 | { 202 | // printf("dummy mess = %x\r\n",ev->message); 203 | // printf("dummy param1 = %x\r\n",ev->param1); 204 | // printf("dummy param2 = %x\r\n",ev->param2); 205 | Delay(1); 206 | } 207 | else if(ev->message==MESS_CLOSE) 208 | { 209 | ev->message=MESS_REPAINT; 210 | return 1; 211 | } 212 | ev->message=MESS_IDLE; 213 | return 1; 214 | } 215 | -------------------------------------------------------------------------------- /Src/opcode_cb.h: -------------------------------------------------------------------------------- 1 | //~ void opcode_cb(u8 bt) 2 | { 3 | switch (opcode) 4 | { 5 | /*RLC B*/ 6 | case 0x07: 7 | case 0x00 ... 0x05: 8 | RLC(RC(opcode&7)); 9 | EMPTY; 10 | break; 11 | /*RLC (HL)*/ 12 | case 0x06: 13 | temp8=READ_BYTE(HL); 14 | RLC(temp8); 15 | WRITE_BYTE(HL, temp8); 16 | T_WAIT_UNTIL(11-4); 17 | break; 18 | 19 | case 0x0f: 20 | case 0x08 ... 0xd: 21 | RRC(RC(opcode&7)); 22 | EMPTY; 23 | break; 24 | /*RRC (HL)*/ 25 | case 0x0e: 26 | temp8=READ_BYTE(HL); 27 | RRC(temp8); 28 | WRITE_BYTE(HL, temp8); 29 | T_WAIT_UNTIL(11-4); 30 | break; 31 | /*RL B*/ 32 | case 0x17: 33 | case 0x10 ... 0x15: 34 | RL(RC(opcode&7)); 35 | EMPTY; 36 | break; 37 | /*RL (HL)*/ 38 | case 0x16: 39 | temp8=READ_BYTE(HL); 40 | RL(temp8); 41 | WRITE_BYTE(HL, temp8); 42 | T_WAIT_UNTIL(11-4); 43 | break; 44 | /*RL A*/ 45 | //~ case 0x17: 46 | //~ RL(A); 47 | //~ EMPTY; 48 | //~ break; 49 | /*RR B*/ 50 | case 0x1f: 51 | case 0x18 ... 0x1d: 52 | RR(RC(opcode&7)); 53 | EMPTY; 54 | break; 55 | /*RR (HL)*/ 56 | case 0x1e: 57 | temp8=READ_BYTE(HL); 58 | RR(temp8); 59 | WRITE_BYTE(HL, temp8); 60 | T_WAIT_UNTIL(11-4); 61 | break; 62 | /*RR A*/ 63 | //~ case 0x1f: 64 | //~ RR(A); 65 | //~ EMPTY; 66 | //~ break; 67 | /*SLA B*/ 68 | case 0x27: 69 | case 0x20 ... 0x25: 70 | SLA(RC(opcode&7)); 71 | EMPTY; 72 | break; 73 | /*SLA (HL)*/ 74 | case 0x26: 75 | temp8=READ_BYTE(HL); 76 | SLA(temp8); 77 | WRITE_BYTE(HL, temp8); 78 | T_WAIT_UNTIL(11-4); 79 | break; 80 | /*SRA B*/ 81 | case 0x2f: 82 | case 0x28 ... 0x2d: 83 | SRA(RC(opcode&7)); 84 | EMPTY; 85 | break; 86 | case 0x2e: 87 | temp8=READ_BYTE(HL); 88 | SRA(temp8); 89 | WRITE_BYTE(HL, temp8); 90 | T_WAIT_UNTIL(11-4); 91 | break; 92 | case 0x37: 93 | case 0x30 ... 0x35: 94 | SLL(RC(opcode&7)); 95 | EMPTY; 96 | break; 97 | 98 | /*SLL (HL)*/ 99 | case 0x36: 100 | temp8=READ_BYTE(HL); 101 | SLL(temp8); 102 | WRITE_BYTE(HL, temp8); 103 | T_WAIT_UNTIL(11-4); 104 | break; 105 | /*SRL B*/ 106 | case 0x3f: 107 | case 0x38 ... 0x3d: 108 | SRL(RC(opcode&7)); 109 | EMPTY; 110 | break; 111 | /*SRL (HL)*/ 112 | case 0x3e: 113 | temp8=READ_BYTE(HL); 114 | SRL(temp8); 115 | WRITE_BYTE(HL, temp8); 116 | T_WAIT_UNTIL(11-4); 117 | break; 118 | /*BIT 0, B*/ 119 | case 0x47: 120 | case 0x40 ... 0x45: 121 | case 0x4f: 122 | case 0x48 ... 0x4d: 123 | case 0x57: 124 | case 0x50 ... 0x55: 125 | case 0x5f: 126 | case 0x58 ... 0x5d: 127 | case 0x67: 128 | case 0x60 ... 0x65: 129 | case 0x6f: 130 | case 0x68 ... 0x6d: 131 | case 0x77: 132 | case 0x70 ... 0x75: 133 | case 0x7f: 134 | case 0x78 ... 0x7d: 135 | BIT(((opcode&0b111000)>>3), RC(opcode&7)); 136 | EMPTY; 137 | break; 138 | /*BIT 0, (HL)*/ 139 | case 0x46: 140 | case 0x4e: 141 | case 0x56: 142 | case 0x5e: 143 | case 0x66: 144 | case 0x6e: 145 | case 0x76: 146 | case 0x7e: 147 | temp8=READ_BYTE(HL); 148 | BIT_MPTR(((opcode&0b111000)>>3), temp8); 149 | T_WAIT_UNTIL(8-4); 150 | break; 151 | 152 | /*RES 0, B*/ 153 | case 0x87: 154 | case 0x80 ... 0x85: 155 | case 0x8f: 156 | case 0x88 ... 0x8d: 157 | case 0x97: 158 | case 0x90 ... 0x95: 159 | case 0x9f: 160 | case 0x98 ... 0x9d: 161 | case 0xa7: 162 | case 0xa0 ... 0xa5: 163 | case 0xaf: 164 | case 0xa8 ... 0xad: 165 | case 0xb7: 166 | case 0xb0 ... 0xb5: 167 | case 0xbf: 168 | case 0xb8 ... 0xbd: 169 | RES(((opcode&0b111000)>>3), RC(opcode&7)); 170 | EMPTY; 171 | break; 172 | case 0x86: 173 | case 0x8e: 174 | case 0x96: 175 | case 0x9e: 176 | case 0xa6: 177 | case 0xae: 178 | case 0xb6: 179 | case 0xbe: 180 | temp8=READ_BYTE(HL); 181 | RES(((opcode&0b111000)>>3), temp8); 182 | WRITE_BYTE(HL, temp8); 183 | T_WAIT_UNTIL(11-4); 184 | break; 185 | /*SET 0, B*/ 186 | case 0xc7: 187 | case 0xc0 ... 0xc5: 188 | case 0xcf: 189 | case 0xc8 ... 0xcd: 190 | 191 | case 0xd7: 192 | case 0xd0 ... 0xd5: 193 | case 0xdf: 194 | case 0xd8 ... 0xdd: 195 | 196 | case 0xe7: 197 | case 0xe0 ... 0xe5: 198 | case 0xef: 199 | case 0xe8 ... 0xed: 200 | 201 | case 0xf7: 202 | case 0xf0 ... 0xf5: 203 | case 0xff: 204 | case 0xf8 ... 0xfd: 205 | 206 | SET(((opcode&0b111000)>>3), RC(opcode&7)); 207 | EMPTY; 208 | break; 209 | case 0xc6: 210 | case 0xce: 211 | case 0xd6: 212 | case 0xde: 213 | case 0xe6: 214 | case 0xee: 215 | case 0xf6: 216 | case 0xfe: 217 | temp8=READ_BYTE(HL); 218 | SET(((opcode&0b111000)>>3), temp8); 219 | WRITE_BYTE(HL, temp8); 220 | T_WAIT_UNTIL(11-4); 221 | break; 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /Src/opcode_ddcb.h: -------------------------------------------------------------------------------- 1 | /*LD B, RLC (IX+$)*/ 2 | //~ void opcode_ddcb(u8 opcode) 3 | { 4 | //~ if((bt>=0x40)&&(bt<0x80)) bt|=7; 5 | switch (prefix) 6 | { 7 | case 0x00 ... 0x07: 8 | RLC(temp8); 9 | LD(RC(prefix&7), temp8); 10 | EMPTY; 11 | break; 12 | /*LD B, RRC (IX+$)*/ 13 | case 0x08 ... 0x0f: 14 | RRC(temp8); 15 | LD(RC(prefix&7), temp8); 16 | EMPTY; 17 | break; 18 | /*LD B, RL (IX+$)*/ 19 | case 0x10 ... 0x17: 20 | RL(temp8); 21 | LD16(RC(prefix&7), temp8); 22 | EMPTY; 23 | break; 24 | /*LD B, RR (IX+$)*/ 25 | case 0x18 ... 0x1f: 26 | RR(temp8); 27 | LD16(RC(prefix&7), temp8); 28 | EMPTY; 29 | break; 30 | /*LD B, SLA (IX+$)*/ 31 | case 0x20 ... 0x27: 32 | SLA(temp8); 33 | LD(RC(prefix&7), temp8); 34 | EMPTY; 35 | break; 36 | /*LD B, SRA (IX+$)*/ 37 | case 0x28 ... 0x2f: 38 | SRA(temp8); 39 | LD(RC(prefix&7), temp8); 40 | EMPTY; 41 | break; 42 | /*LD B, SLL (IX+$)*/ 43 | case 0x30 ... 0x37: 44 | SLL(temp8); 45 | LD(RC(prefix&7), temp8); 46 | EMPTY; 47 | break; 48 | /*LD B, SRL (IX+$)*/ 49 | case 0x38 ... 0x3f: 50 | SRL(temp8); 51 | LD(RC(prefix&7), temp8); 52 | EMPTY; 53 | break; 54 | /*BIT 0, (IX+$)*/ 55 | case 0x40 ... 0x7f: 56 | BIT_MPTR(((prefix&0b111000)>>3), temp8); 57 | T_WAIT_UNTIL(-3); 58 | break; 59 | /*LD B, RES 0, (IX+$)*/ 60 | case 0x80 ... 0xbf: 61 | RES(((prefix&0b111000)>>3), temp8); 62 | LD(RC(prefix&7), temp8); 63 | EMPTY; 64 | break; 65 | /*LD B, SET 0, (IX+$)*/ 66 | case 0xc0 ... 0xff: 67 | SET(((prefix&0b111000)>>3), temp8); 68 | LD(RC(prefix&7), temp8); 69 | EMPTY; 70 | break; 71 | default: 72 | T_WAIT_UNTIL(-19); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Src/opcode_ed.h: -------------------------------------------------------------------------------- 1 | //~ void opcode_ed(u8 bt) 2 | { 3 | switch (opcode) 4 | { 5 | /*IN B, (C)*/ 6 | case 0x40: 7 | IN(B, BC); 8 | T_WAIT_UNTIL(8); 9 | break; 10 | /*OUT (C), B*/ 11 | case 0x41: 12 | OUT(BC, B); 13 | T_WAIT_UNTIL(8); 14 | break; 15 | /*SUBC HL, BC*/ 16 | case 0x42: 17 | SUBC16(HL, BC); 18 | T_WAIT_UNTIL(11); 19 | break; 20 | /*LD (@), BC*/ 21 | case 0x43: 22 | nn=NEXT_WORD; 23 | LD_RP_TO_ADDR_MPTR_16(temp16, BC, nn); 24 | WRITE_WORD(nn, temp16); 25 | T_WAIT_UNTIL(16); 26 | break; 27 | /*NEG*/ 28 | case 0x44: 29 | case 0x4c: 30 | case 0x54: 31 | case 0x5c: 32 | case 0x64: 33 | case 0x6c: 34 | case 0x74: 35 | case 0x7c: /* NEG */ 36 | 37 | NEG(); 38 | T_WAIT_UNTIL(4); 39 | break; 40 | /*RETN*/ 41 | case 0x45: 42 | case 0x4d: 43 | case 0x55: 44 | case 0x5d: 45 | case 0x65: 46 | case 0x6d: 47 | case 0x75: 48 | case 0x7d: /* RETN */ 49 | RETN(); 50 | T_WAIT_UNTIL(10); 51 | break; 52 | /*IM 0*/ 53 | case 0x46: 54 | case 0x4e: 55 | case 0x66: 56 | case 0x6e: /* IM 0 */ 57 | IM_MODE(0); 58 | T_WAIT_UNTIL(4); 59 | break; 60 | /*LD I, A*/ 61 | case 0x47: 62 | LD(I, A); 63 | T_WAIT_UNTIL(5); 64 | break; 65 | /*IN C, (C)*/ 66 | case 0x48: 67 | IN(C, BC); 68 | T_WAIT_UNTIL(8); 69 | break; 70 | /*OUT (C), C*/ 71 | case 0x49: 72 | OUT(BC, C); 73 | T_WAIT_UNTIL(8); 74 | break; 75 | /*ADDC HL, BC*/ 76 | case 0x4a: 77 | ADDC16(HL, BC); 78 | T_WAIT_UNTIL(11); 79 | break; 80 | /*LD BC, (@)*/ 81 | case 0x4b: 82 | nn=NEXT_WORD; 83 | temp16=READ_WORD(nn); 84 | LD_RP_FROM_ADDR_MPTR_16(BC, temp16, nn); 85 | T_WAIT_UNTIL(16); 86 | break; 87 | /*LD R, A*/ 88 | case 0x4f: 89 | LD_R_A(); 90 | T_WAIT_UNTIL(5); 91 | break; 92 | /*IN D, (C)*/ 93 | case 0x50: 94 | IN(D, BC); 95 | T_WAIT_UNTIL(8); 96 | break; 97 | /*OUT (C), D*/ 98 | case 0x51: 99 | OUT(BC, D); 100 | T_WAIT_UNTIL(8); 101 | break; 102 | /*SUBC HL, DE*/ 103 | case 0x52: 104 | SUBC16(HL, DE); 105 | T_WAIT_UNTIL(11); 106 | break; 107 | /*LD (@), DE*/ 108 | case 0x53: 109 | nn=NEXT_WORD; 110 | LD_RP_TO_ADDR_MPTR_16(temp16, DE, nn); 111 | WRITE_WORD(nn, temp16); 112 | T_WAIT_UNTIL(16); 113 | break; 114 | /*IM 1*/ 115 | case 0x56: 116 | case 0x76: 117 | IM_MODE(1); 118 | T_WAIT_UNTIL(4); 119 | break; 120 | /*LD A, I*/ 121 | case 0x57: 122 | LD_A_I(); 123 | T_WAIT_UNTIL(5); 124 | break; 125 | /*IN E, (C)*/ 126 | case 0x58: 127 | IN(E, BC); 128 | T_WAIT_UNTIL(8); 129 | break; 130 | /*OUT (C), E*/ 131 | case 0x59: 132 | OUT(BC, E); 133 | T_WAIT_UNTIL(8); 134 | break; 135 | /*ADDC HL, DE*/ 136 | case 0x5a: 137 | ADDC16(HL, DE); 138 | T_WAIT_UNTIL(11); 139 | break; 140 | /*LD DE, (@)*/ 141 | case 0x5b: 142 | nn=NEXT_WORD; 143 | temp16=READ_WORD(nn); 144 | LD_RP_FROM_ADDR_MPTR_16(DE, temp16, nn); 145 | T_WAIT_UNTIL(16); 146 | break; 147 | /*IM 2*/ 148 | case 0x5e: 149 | case 0x7e: 150 | IM_MODE(2); 151 | T_WAIT_UNTIL(4); 152 | break; 153 | /*LD A, R*/ 154 | case 0x5f: 155 | LD_A_R(); 156 | T_WAIT_UNTIL(5); 157 | break; 158 | /*IN H, (C)*/ 159 | case 0x60: 160 | IN(H, BC); 161 | T_WAIT_UNTIL(8); 162 | break; 163 | /*OUT (C), H*/ 164 | case 0x61: 165 | OUT(BC, H); 166 | T_WAIT_UNTIL(8); 167 | break; 168 | /*SUBC HL, HL*/ 169 | case 0x62: 170 | SUBC16(HL, HL); 171 | T_WAIT_UNTIL(11); 172 | break; 173 | /*LD (@), HL*/ 174 | case 0x63: 175 | nn=NEXT_WORD; 176 | LD_RP_TO_ADDR_MPTR_16(temp16, HL, nn); 177 | WRITE_WORD(nn, temp16); 178 | T_WAIT_UNTIL(16); 179 | break; 180 | /*RRD*/ 181 | case 0x67: 182 | RRD(); 183 | T_WAIT_UNTIL(14); 184 | break; 185 | /*IN L, (C)*/ 186 | case 0x68: 187 | IN(L, BC); 188 | T_WAIT_UNTIL(8); 189 | break; 190 | /*OUT (C), L*/ 191 | case 0x69: 192 | OUT(BC, L); 193 | T_WAIT_UNTIL(8); 194 | break; 195 | /*ADDC HL, HL*/ 196 | case 0x6a: 197 | ADDC16(HL, HL); 198 | T_WAIT_UNTIL(11); 199 | break; 200 | /*LD HL, (@)*/ 201 | case 0x6b: 202 | nn=NEXT_WORD; 203 | temp16=READ_WORD(nn); 204 | LD_RP_FROM_ADDR_MPTR_16(HL, temp16, nn); 205 | T_WAIT_UNTIL(16); 206 | break; 207 | /*RLD*/ 208 | case 0x6f: 209 | RLD(); 210 | T_WAIT_UNTIL(14); 211 | break; 212 | /*IN_F (C)*/ 213 | case 0x70: 214 | IN_F(BC); 215 | T_WAIT_UNTIL(8); 216 | break; 217 | /*OUT (C), 0*/ 218 | case 0x71: 219 | OUT(BC, 0); 220 | T_WAIT_UNTIL(8); 221 | break; 222 | /*SUBC HL, SP*/ 223 | case 0x72: 224 | SUBC16(HL, SP); 225 | T_WAIT_UNTIL(11); 226 | break; 227 | /*LD (@), SP*/ 228 | case 0x73: 229 | nn=NEXT_WORD; 230 | LD_RP_TO_ADDR_MPTR_16(temp16, SP, nn); 231 | WRITE_WORD(nn, temp16); 232 | T_WAIT_UNTIL(16); 233 | break; 234 | /*IN A, (C)*/ 235 | case 0x78: 236 | IN(A, BC); 237 | T_WAIT_UNTIL(8); 238 | break; 239 | /*OUT (C), A*/ 240 | case 0x79: 241 | OUT(BC, A); 242 | T_WAIT_UNTIL(8); 243 | break; 244 | /*ADDC HL, SP*/ 245 | case 0x7a: 246 | ADDC16(HL, SP); 247 | T_WAIT_UNTIL(11); 248 | break; 249 | /*LD SP, (@)*/ 250 | case 0x7b: 251 | nn=NEXT_WORD; 252 | temp16=READ_WORD(nn); 253 | LD_RP_FROM_ADDR_MPTR_16(SP, temp16, nn); 254 | T_WAIT_UNTIL(16); 255 | break; 256 | /*LDI*/ 257 | case 0xa0: 258 | LDI(); 259 | T_WAIT_UNTIL(12); 260 | break; 261 | /*CPI*/ 262 | case 0xa1: 263 | CPI(); 264 | T_WAIT_UNTIL(12); 265 | break; 266 | /*INI*/ 267 | case 0xa2: 268 | INI(); 269 | T_WAIT_UNTIL(12); 270 | break; 271 | /*OUTI*/ 272 | case 0xa3: 273 | OUTI(); 274 | T_WAIT_UNTIL(12); 275 | break; 276 | /*LDD*/ 277 | case 0xa8: 278 | LDD(); 279 | T_WAIT_UNTIL(12); 280 | break; 281 | /*CPD*/ 282 | case 0xa9: 283 | CPD(); 284 | T_WAIT_UNTIL(12); 285 | break; 286 | /*IND*/ 287 | case 0xaa: 288 | IND(); 289 | T_WAIT_UNTIL(12); 290 | break; 291 | /*OUTD*/ 292 | case 0xab: 293 | OUTD(); 294 | T_WAIT_UNTIL(12); 295 | break; 296 | /*LDIR*/ 297 | case 0xb0: 298 | LDIR(); 299 | break; 300 | /*CPIR*/ 301 | case 0xb1: 302 | CPIR(); 303 | break; 304 | /*INIR*/ 305 | case 0xb2: 306 | INIR(); 307 | break; 308 | /*OTIR*/ 309 | case 0xb3: 310 | OTIR(); 311 | break; 312 | /*LDDR*/ 313 | case 0xb8: 314 | LDDR(); 315 | break; 316 | /*CPDR*/ 317 | case 0xb9: 318 | CPDR(); 319 | break; 320 | /*INDR*/ 321 | case 0xba: 322 | INDR(); 323 | break; 324 | /*OTDR*/ 325 | case 0xbb: 326 | OTDR(); 327 | break; 328 | /*NONI*/ 329 | default: 330 | T_WAIT_UNTIL(4); 331 | } 332 | } 333 | -------------------------------------------------------------------------------- /Src/usb_host.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usb_host.c 4 | * @version : v1.0_Cube 5 | * @brief : This file implements the USB Host 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2020 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Includes ------------------------------------------------------------------*/ 51 | 52 | #include "usb_host.h" 53 | #include "usbh_core.h" 54 | #include "usbh_hid.h" 55 | 56 | /* USER CODE BEGIN Includes */ 57 | 58 | /* USER CODE END Includes */ 59 | 60 | /* USER CODE BEGIN PV */ 61 | /* Private variables ---------------------------------------------------------*/ 62 | 63 | /* USER CODE END PV */ 64 | 65 | /* USER CODE BEGIN PFP */ 66 | /* Private function prototypes -----------------------------------------------*/ 67 | 68 | /* USER CODE END PFP */ 69 | 70 | /* USB Host core handle declaration */ 71 | USBH_HandleTypeDef hUsbHostFS; 72 | ApplicationTypeDef Appli_state = APPLICATION_IDLE; 73 | 74 | /* 75 | * -- Insert your variables declaration here -- 76 | */ 77 | /* USER CODE BEGIN 0 */ 78 | uint8_t usb_mode; 79 | /* USER CODE END 0 */ 80 | 81 | /* 82 | * user callback declaration 83 | */ 84 | static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); 85 | 86 | /* 87 | * -- Insert your external function declaration here -- 88 | */ 89 | /* USER CODE BEGIN 1 */ 90 | 91 | /* USER CODE END 1 */ 92 | 93 | /** 94 | * Init USB host library, add supported class and start the library 95 | * @retval None 96 | */ 97 | void MX_USB_HOST_Init(void) 98 | { 99 | /* USER CODE BEGIN USB_HOST_Init_PreTreatment */ 100 | 101 | /* USER CODE END USB_HOST_Init_PreTreatment */ 102 | 103 | /* Init host Library, add supported class and start the library. */ 104 | USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS); 105 | 106 | USBH_RegisterClass(&hUsbHostFS, USBH_HID_CLASS); 107 | 108 | USBH_Start(&hUsbHostFS); 109 | 110 | /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ 111 | 112 | /* USER CODE END USB_HOST_Init_PostTreatment */ 113 | } 114 | 115 | /* 116 | * Background task 117 | */ 118 | void MX_USB_HOST_Process(void) 119 | { 120 | /* USB Host Background task */ 121 | USBH_Process(&hUsbHostFS); 122 | } 123 | /* 124 | * user callback definition 125 | */ 126 | static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) 127 | { 128 | /* USER CODE BEGIN CALL_BACK_1 */ 129 | usb_mode = id; 130 | switch(id) 131 | { 132 | case HOST_USER_SELECT_CONFIGURATION: 133 | break; 134 | 135 | case HOST_USER_DISCONNECTION: 136 | Appli_state = APPLICATION_DISCONNECT; 137 | break; 138 | 139 | case HOST_USER_CLASS_ACTIVE: 140 | Appli_state = APPLICATION_READY; 141 | break; 142 | 143 | case HOST_USER_CONNECTION: 144 | Appli_state = APPLICATION_START; 145 | break; 146 | 147 | default: 148 | break; 149 | } 150 | /* USER CODE END CALL_BACK_1 */ 151 | } 152 | 153 | /** 154 | * @} 155 | */ 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 162 | -------------------------------------------------------------------------------- /Src/z80.c: -------------------------------------------------------------------------------- 1 | #include "z80.h" 2 | //~ #include 3 | 4 | int32_t tstates = 0; 5 | int32_t interrupts_enabled_at; 6 | 7 | /*include z80 registr*/ 8 | ZReg reg; 9 | ZReg_Shadow reg_; 10 | ZINTRFlags IFlags; 11 | 12 | 13 | 14 | 15 | #include "tables.h" 16 | 17 | /*include opcodes*/ 18 | 19 | 20 | void z80_reset( int hard_reset ) 21 | { 22 | /* 23 | int i,j,k; 24 | uint8_t parity; 25 | 26 | for(i=0;i<0x100;i++) { 27 | sz53_table[i]= i & ( FLAG_3 | FLAG_5 | FLAG_S ); 28 | if(i==0) 29 | { 30 | sz53_table[i] = 0x40; 31 | } 32 | //~ if(sz53_table[i]!=sz53_table_b[i]) 33 | //~ { 34 | //~ printf("sz53_table %x, %x, %x \n",i,(int)sz53_table[i],(int)sz53_table_b[i]); 35 | //~ } 36 | j=i; parity=0; 37 | for(k=0;k<8;k++) { parity ^= j & 1; j >>=1; } 38 | uint8_t parity_table_i = ( parity ? 0 : FLAG_P ); 39 | sz53p_table[i] = sz53_table[i] | parity_table_i; 40 | //~ if(sz53p_table[i]!=sz53p_table_b[i]) 41 | //~ { 42 | //~ printf(" sz53p_table %x, %x, %x \n",i,(int)sz53p_table[i],(int)sz53p_table_b[i]); 43 | //~ } 44 | } 45 | 46 | */ 47 | 48 | AF_=0xffff; 49 | F=0xff;A=0xff; 50 | I=R=R7=0; 51 | PC=0; 52 | SP=0xffff; 53 | IFF1=IFF2=IM=0; 54 | halt=0; 55 | if( hard_reset ) { 56 | BC =DE =HL =0; 57 | BC_=DE_=HL_=0; 58 | IX=IY=0; 59 | MEMPTR=0; 60 | } 61 | screen_IRQ = 0; 62 | interrupts_enabled_at = 0; 63 | tstates = 0; 64 | 65 | 66 | //~ z80.iff2_read=0; 67 | //~ AF=0; 68 | //~ AF=0; 69 | //~ BC=0; 70 | //~ DE=0; 71 | //~ HL=0; 72 | //~ IX=0; 73 | //~ IY=0; 74 | //~ SP=0; 75 | //~ PC=0; 76 | //~ IFF1=IFF2=0; 77 | //~ IM=0; 78 | //~ MEMPTR=0; 79 | 80 | return; 81 | } 82 | //~ u16 i; 83 | #define EMPTY ; 84 | void z80_run(int num_reps) 85 | { 86 | 87 | union 88 | { 89 | u8 u; 90 | s8 s; 91 | }d; 92 | 93 | u16 temp16; 94 | u8 temp8; 95 | u8 opcode; 96 | u8 lookup; 97 | u8 n; 98 | u8 prefix; 99 | u16 nn; 100 | //~ u16 tempR; 101 | int kk; 102 | //for(int k=0;k interrupts_enabled_at)) 107 | { 108 | if(halt) 109 | { 110 | PC++; 111 | halt = 0; 112 | tstates+=4; 113 | } 114 | //~ if(IFF1) 115 | { 116 | IFF1=0; 117 | IFF2=1; 118 | screen_IRQ=0; 119 | if(IM==1||IM==0) 120 | { 121 | R++; 122 | RST(0x38); 123 | tstates+=m_cycle; 124 | } 125 | else if(IM==2) 126 | { 127 | uint16_t addr = (((uint16_t)(I))<<8)|0xff; 128 | uint16_t jmp_addr=peek16(addr); 129 | //~ printf("addr = %4x %4x\n",addr,jmp_addr); 130 | R++; 131 | RST(jmp_addr); 132 | tstates+=m_cycle; 133 | } 134 | } 135 | m_cycle = 0; 136 | //return; 137 | } 138 | opcode=NEXT_BYTE; 139 | R++; 140 | #include "opcode_base.h" 141 | tstates+=m_cycle; 142 | } 143 | } 144 | #if 0 145 | void z80_run(void) 146 | { 147 | 148 | union 149 | { 150 | u8 u; 151 | s8 s; 152 | }d; 153 | 154 | u16 temp16; 155 | u8 temp8; 156 | u8 opcode; 157 | u8 lookup; 158 | u8 n; 159 | u8 prefix; 160 | u16 nn; 161 | //~ u16 tempR; 162 | int kk; 163 | 164 | //~ CONT: 165 | //~ if (halt==0) 166 | //~ u8 prefix = 0; 167 | //~ const int rtable [] = {1,0,3,2,5,4,21,7}; // 168 | #if 0 169 | if (screen_IRQ&&IFF1&&(tstates > interrupts_enabled_at)) 170 | { 171 | if(halt) 172 | { 173 | PC++; 174 | halt = 0; 175 | } 176 | IFF1=0; 177 | IFF2=1; 178 | screen_IRQ=0; 179 | if(IM==1||IM==0) 180 | { 181 | RST(0x38); 182 | //~ tstates+=m_cycle; 183 | } 184 | else if(IM==2) 185 | { 186 | uint16_t addr = (((uint16_t)I)<<8)|0xff; 187 | uint16_t jmp_addr=peek16(addr); 188 | //~ printf("addr = %4x %4x\n",addr,jmp_addr); 189 | RST(jmp_addr); 190 | //~ tstates+=m_cycle; 191 | } 192 | return; 193 | } 194 | #endif 195 | for(kk=0;kk<1024;kk++) 196 | { 197 | u16 m_cycle = 0; 198 | opcode=NEXT_BYTE; 199 | R++; 200 | #include "opcode_base.h" 201 | tstates+=m_cycle; 202 | } 203 | } 204 | 205 | #endif 206 | -------------------------------------------------------------------------------- /lib/mp3/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. 2 | 3 | The contents of this directory, and (except where otherwise 4 | indicated) the directories included within this directory, are 5 | subject to the current version of the RealNetworks Public Source 6 | License (the "RPSL") available at RPSL.txt in this directory, unless 7 | you have licensed the directory under the current version of the 8 | RealNetworks Community Source License (the "RCSL") available at 9 | RCSL.txt in this directory, in which case the RCSL will apply. You 10 | may also obtain the license terms directly from RealNetworks. You 11 | may not use the files in this directory except in compliance with the 12 | RPSL or, if you have a valid RCSL with RealNetworks applicable to 13 | this directory, the RCSL. Please see the applicable RPSL or RCSL for 14 | the rights, obligations and limitations governing use of the contents 15 | of the directory. 16 | 17 | This directory is part of the Helix DNA Technology. RealNetworks is 18 | the developer of the Original Code and owns the copyrights in the 19 | portions it created. 20 | 21 | This directory, and the directories included with this directory, are 22 | distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY 23 | OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY 24 | DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 25 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 26 | QUIET ENJOYMENT OR NON-INFRINGEMENT. 27 | 28 | Technology Compatibility Kit Test Suite(s) Location: 29 | http://www.helixcommunity.org/content/tck 30 | 31 | -------------------------------------------------------------------------------- /lib/mp3/RCSL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/lib/mp3/RCSL.txt -------------------------------------------------------------------------------- /lib/mp3/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * platform.h 3 | * 4 | * Created on: 21 jan 2012 5 | * Author: benjamin 6 | */ 7 | 8 | #ifndef PLATFORM_H_ 9 | #define PLATFORM_H_ 10 | 11 | #include 12 | 13 | #define ARM_TEST 14 | 15 | typedef long long Word64; 16 | typedef uint32_t ULONG32; 17 | 18 | #endif /* PLATFORM_H_ */ 19 | -------------------------------------------------------------------------------- /lib/mp3/pub/CVS/Entries: -------------------------------------------------------------------------------- 1 | /LICENSE.txt/1.1/Fri Feb 6 15:27:51 2004// 2 | /RCSL.txt/1.1/Fri Feb 6 15:27:51 2004// 3 | /RPSL.txt/1.1/Fri Feb 6 15:27:51 2004// 4 | /mp3common.h/1.2/Wed Jul 23 22:12:09 2003// 5 | /mp3dec.h/1.7/Thu Jan 24 12:31:54 2008// 6 | /mpadecobjfixpt.h/1.4/Fri Jun 19 06:45:58 2009// 7 | /statname.h/1.2/Fri Jun 19 06:45:58 2009// 8 | D 9 | -------------------------------------------------------------------------------- /lib/mp3/pub/CVS/Repository: -------------------------------------------------------------------------------- 1 | mp3/codec/fixpt/pub 2 | -------------------------------------------------------------------------------- /lib/mp3/pub/CVS/Root: -------------------------------------------------------------------------------- 1 | :ext:vedder@cvs.helixcommunity.org:/cvsroot/datatype 2 | -------------------------------------------------------------------------------- /lib/mp3/pub/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. 2 | 3 | The contents of this directory, and (except where otherwise 4 | indicated) the directories included within this directory, are 5 | subject to the current version of the RealNetworks Public Source 6 | License (the "RPSL") available at RPSL.txt in this directory, unless 7 | you have licensed the directory under the current version of the 8 | RealNetworks Community Source License (the "RCSL") available at 9 | RCSL.txt in this directory, in which case the RCSL will apply. You 10 | may also obtain the license terms directly from RealNetworks. You 11 | may not use the files in this directory except in compliance with the 12 | RPSL or, if you have a valid RCSL with RealNetworks applicable to 13 | this directory, the RCSL. Please see the applicable RPSL or RCSL for 14 | the rights, obligations and limitations governing use of the contents 15 | of the directory. 16 | 17 | This directory is part of the Helix DNA Technology. RealNetworks is 18 | the developer of the Original Code and owns the copyrights in the 19 | portions it created. 20 | 21 | This directory, and the directories included with this directory, are 22 | distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY 23 | OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY 24 | DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 25 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 26 | QUIET ENJOYMENT OR NON-INFRINGEMENT. 27 | 28 | Technology Compatibility Kit Test Suite(s) Location: 29 | http://www.helixcommunity.org/content/tck 30 | 31 | -------------------------------------------------------------------------------- /lib/mp3/pub/RCSL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/lib/mp3/pub/RCSL.txt -------------------------------------------------------------------------------- /lib/mp3/pub/mp3common.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: RCSL 1.0/RPSL 1.0 3 | * 4 | * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 5 | * 6 | * The contents of this file, and the files included with this file, are 7 | * subject to the current version of the RealNetworks Public Source License 8 | * Version 1.0 (the "RPSL") available at 9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed 10 | * the file under the RealNetworks Community Source License Version 1.0 11 | * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 12 | * in which case the RCSL will apply. You may also obtain the license terms 13 | * directly from RealNetworks. You may not use this file except in 14 | * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 15 | * applicable to this file, the RCSL. Please see the applicable RPSL or 16 | * RCSL for the rights, obligations and limitations governing use of the 17 | * contents of the file. 18 | * 19 | * This file is part of the Helix DNA Technology. RealNetworks is the 20 | * developer of the Original Code and owns the copyrights in the portions 21 | * it created. 22 | * 23 | * This file, and the files included with this file, is distributed and made 24 | * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 25 | * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 26 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 27 | * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 28 | * 29 | * Technology Compatibility Kit Test Suite(s) Location: 30 | * http://www.helixcommunity.org/content/tck 31 | * 32 | * Contributor(s): 33 | * 34 | * ***** END LICENSE BLOCK ***** */ 35 | 36 | /************************************************************************************** 37 | * Fixed-point MP3 decoder 38 | * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) 39 | * June 2003 40 | * 41 | * mp3common.h - implementation-independent API's, datatypes, and definitions 42 | **************************************************************************************/ 43 | 44 | #ifndef _MP3COMMON_H 45 | #define _MP3COMMON_H 46 | 47 | #include "mp3dec.h" 48 | #include "statname.h" /* do name-mangling for static linking */ 49 | 50 | #define MAX_SCFBD 4 /* max scalefactor bands per channel */ 51 | #define NGRANS_MPEG1 2 52 | #define NGRANS_MPEG2 1 53 | 54 | /* 11-bit syncword if MPEG 2.5 extensions are enabled */ 55 | #define SYNCWORDH 0xff 56 | #define SYNCWORDL 0xe0 57 | 58 | /* 12-bit syncword if MPEG 1,2 only are supported 59 | * #define SYNCWORDH 0xff 60 | * #define SYNCWORDL 0xf0 61 | */ 62 | 63 | typedef struct _MP3DecInfo { 64 | /* pointers to platform-specific data structures */ 65 | void *FrameHeaderPS; 66 | void *SideInfoPS; 67 | void *ScaleFactorInfoPS; 68 | void *HuffmanInfoPS; 69 | void *DequantInfoPS; 70 | void *IMDCTInfoPS; 71 | void *SubbandInfoPS; 72 | 73 | /* buffer which must be large enough to hold largest possible main_data section */ 74 | unsigned char *mainBuf; 75 | 76 | /* special info for "free" bitrate files */ 77 | int freeBitrateFlag; 78 | int freeBitrateSlots; 79 | 80 | /* user-accessible info */ 81 | int bitrate; 82 | int nChans; 83 | int samprate; 84 | int nGrans; /* granules per frame */ 85 | int nGranSamps; /* samples per granule */ 86 | int nSlots; 87 | int layer; 88 | MPEGVersion version; 89 | 90 | int mainDataBegin; 91 | int mainDataBytes; 92 | 93 | int part23Length[MAX_NGRAN][MAX_NCHAN]; 94 | 95 | } MP3DecInfo; 96 | 97 | typedef struct _SFBandTable { 98 | short l[23]; 99 | short s[14]; 100 | } SFBandTable; 101 | 102 | /* decoder functions which must be implemented for each platform */ 103 | MP3DecInfo *AllocateBuffers(void); 104 | void FreeBuffers(MP3DecInfo *mp3DecInfo); 105 | int CheckPadBit(MP3DecInfo *mp3DecInfo); 106 | int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf); 107 | int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf); 108 | int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch); 109 | int Dequantize(MP3DecInfo *mp3DecInfo, int gr); 110 | int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch); 111 | int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch); 112 | int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf); 113 | 114 | /* mp3tabs.c - global ROM tables */ 115 | extern const int samplerateTab[3][3]; 116 | extern const short bitrateTab[3][3][15]; 117 | extern const short samplesPerFrameTab[3][3]; 118 | extern const short bitsPerSlotTab[3]; 119 | extern const short sideBytesTab[3][2]; 120 | extern const short slotTab[3][3][15]; 121 | extern const SFBandTable sfBandTable[3][3]; 122 | 123 | #endif /* _MP3COMMON_H */ 124 | -------------------------------------------------------------------------------- /lib/mp3/pub/mp3dec.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: RCSL 1.0/RPSL 1.0 3 | * 4 | * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 5 | * 6 | * The contents of this file, and the files included with this file, are 7 | * subject to the current version of the RealNetworks Public Source License 8 | * Version 1.0 (the "RPSL") available at 9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed 10 | * the file under the RealNetworks Community Source License Version 1.0 11 | * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 12 | * in which case the RCSL will apply. You may also obtain the license terms 13 | * directly from RealNetworks. You may not use this file except in 14 | * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 15 | * applicable to this file, the RCSL. Please see the applicable RPSL or 16 | * RCSL for the rights, obligations and limitations governing use of the 17 | * contents of the file. 18 | * 19 | * This file is part of the Helix DNA Technology. RealNetworks is the 20 | * developer of the Original Code and owns the copyrights in the portions 21 | * it created. 22 | * 23 | * This file, and the files included with this file, is distributed and made 24 | * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 25 | * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 26 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 27 | * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 28 | * 29 | * Technology Compatibility Kit Test Suite(s) Location: 30 | * http://www.helixcommunity.org/content/tck 31 | * 32 | * Contributor(s): 33 | * 34 | * ***** END LICENSE BLOCK ***** */ 35 | 36 | /************************************************************************************** 37 | * Fixed-point MP3 decoder 38 | * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) 39 | * June 2003 40 | * 41 | * mp3dec.h - public C API for MP3 decoder 42 | **************************************************************************************/ 43 | 44 | #ifndef _MP3DEC_H 45 | #define _MP3DEC_H 46 | 47 | #include "../platform.h" 48 | 49 | #if defined(_WIN32) && !defined(_WIN32_WCE) 50 | # 51 | #elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM) 52 | # 53 | #elif defined(_WIN32) && defined(WINCE_EMULATOR) 54 | # 55 | #elif defined(ARM_ADS) 56 | # 57 | #elif defined(_SYMBIAN) && defined(__WINS__) /* Symbian emulator for Ix86 */ 58 | # 59 | #elif defined(__GNUC__) && defined(ARM) 60 | # 61 | #elif defined(__GNUC__) && defined(__i386__) 62 | # 63 | #elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR) 64 | # 65 | #elif defined(_AEE_SIMULATOR) || defined(_BREW) 66 | # 67 | #elif defined(ARM_TEST) 68 | # 69 | #else 70 | #error No platform defined. See valid options in mp3dec.h 71 | #endif 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif 76 | 77 | /* determining MAINBUF_SIZE: 78 | * max mainDataBegin = (2^9 - 1) bytes (since 9-bit offset) = 511 79 | * max nSlots (concatenated with mainDataBegin bytes from before) = 1440 - 9 - 4 + 1 = 1428 80 | * 511 + 1428 = 1939, round up to 1940 (4-byte align) 81 | */ 82 | #define MAINBUF_SIZE 1940 83 | 84 | #define MAX_NGRAN 2 /* max granules */ 85 | #define MAX_NCHAN 2 /* max channels */ 86 | #define MAX_NSAMP 576 /* max samples per channel, per granule (576 default) */ 87 | 88 | /* map to 0,1,2 to make table indexing easier */ 89 | typedef enum { 90 | MPEG1 = 0, 91 | MPEG2 = 1, 92 | MPEG25 = 2 93 | } MPEGVersion; 94 | 95 | typedef void *HMP3Decoder; 96 | 97 | enum { 98 | ERR_MP3_NONE = 0, 99 | ERR_MP3_INDATA_UNDERFLOW = -1, 100 | ERR_MP3_MAINDATA_UNDERFLOW = -2, 101 | ERR_MP3_FREE_BITRATE_SYNC = -3, 102 | ERR_MP3_OUT_OF_MEMORY = -4, 103 | ERR_MP3_NULL_POINTER = -5, 104 | ERR_MP3_INVALID_FRAMEHEADER = -6, 105 | ERR_MP3_INVALID_SIDEINFO = -7, 106 | ERR_MP3_INVALID_SCALEFACT = -8, 107 | ERR_MP3_INVALID_HUFFCODES = -9, 108 | ERR_MP3_INVALID_DEQUANTIZE = -10, 109 | ERR_MP3_INVALID_IMDCT = -11, 110 | ERR_MP3_INVALID_SUBBAND = -12, 111 | 112 | ERR_UNKNOWN = -9999 113 | }; 114 | 115 | typedef struct _MP3FrameInfo { 116 | int bitrate; 117 | int nChans; 118 | int samprate; 119 | int bitsPerSample; 120 | int outputSamps; 121 | int layer; 122 | int version; 123 | } MP3FrameInfo; 124 | 125 | /* public API */ 126 | HMP3Decoder MP3InitDecoder(void); 127 | void MP3FreeDecoder(HMP3Decoder hMP3Decoder); 128 | int MP3Decode(HMP3Decoder hMP3Decoder, unsigned char **inbuf, int *bytesLeft, short *outbuf, int useSize); 129 | 130 | void MP3GetLastFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo); 131 | int MP3GetNextFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo, unsigned char *buf); 132 | int MP3FindSyncWord(unsigned char *buf, int nBytes); 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | 138 | #endif /* _MP3DEC_H */ 139 | -------------------------------------------------------------------------------- /lib/mp3/pub/mpadecobjfixpt.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: RCSL 1.0/RPSL 1.0 3 | * 4 | * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 5 | * 6 | * The contents of this file, and the files included with this file, are 7 | * subject to the current version of the RealNetworks Public Source License 8 | * Version 1.0 (the "RPSL") available at 9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed 10 | * the file under the RealNetworks Community Source License Version 1.0 11 | * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 12 | * in which case the RCSL will apply. You may also obtain the license terms 13 | * directly from RealNetworks. You may not use this file except in 14 | * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 15 | * applicable to this file, the RCSL. Please see the applicable RPSL or 16 | * RCSL for the rights, obligations and limitations governing use of the 17 | * contents of the file. 18 | * 19 | * This file is part of the Helix DNA Technology. RealNetworks is the 20 | * developer of the Original Code and owns the copyrights in the portions 21 | * it created. 22 | * 23 | * This file, and the files included with this file, is distributed and made 24 | * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 25 | * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 26 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 27 | * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 28 | * 29 | * Technology Compatibility Kit Test Suite(s) Location: 30 | * http://www.helixcommunity.org/content/tck 31 | * 32 | * Contributor(s): 33 | * 34 | * ***** END LICENSE BLOCK ***** */ 35 | 36 | #ifndef _MPADECOBJFIXPT_H_ 37 | #define _MPADECOBJFIXPT_H_ 38 | 39 | #include "mp3dec.h" /* public C API for new MP3 decoder */ 40 | 41 | class CMpaDecObj 42 | { 43 | public: 44 | CMpaDecObj(); 45 | ~CMpaDecObj(); 46 | 47 | /////////////////////////////////////////////////////////////////////////// 48 | // Function: Init_n 49 | // Purpose: Initialize the mp3 decoder. 50 | // Parameters: pSync a pointer to a syncword 51 | // ulSize the size of the buffer pSync points to 52 | // bUseSize this tells the decoder to use the input frame 53 | // size on the decode instead of calculating 54 | // the frame size. This is necessary when 55 | // our formatted mp3 data (main_data_begin always 56 | // equal to 0). 57 | // 58 | // Returns: returns 1 on success, 0 on failure 59 | /////////////////////////////////////////////////////////////////////////// 60 | int Init_n(unsigned char *pSync, 61 | unsigned long ulSize, 62 | unsigned char bUseSize=0); 63 | 64 | /////////////////////////////////////////////////////////////////////////// 65 | // Function: DecodeFrame_v 66 | // Purpose: Decodes one mp3 frame 67 | // Parameters: pSource pointer to an mp3 frame (at a syncword) 68 | // pulSize size of the buffer pSource points to. It will 69 | // contain the number of mp3 bytes decoded upon 70 | // return. 71 | // pPCM pointer to a buffer to decode into 72 | // pulPCMSize size of the PCM buffer. It will contain the 73 | // number of PCM bytes prodced upon return. 74 | /////////////////////////////////////////////////////////////////////////// 75 | void DecodeFrame_v(unsigned char *pSource, 76 | unsigned long *pulSize, 77 | unsigned char *pPCM, 78 | unsigned long *pulPCMSize); 79 | 80 | // overloaded new version that returns error code in errCode 81 | void DecodeFrame_v(unsigned char *pSource, 82 | unsigned long *pulSize, 83 | unsigned char *pPCM, 84 | unsigned long *pulPCMSize, 85 | int *errCode); 86 | 87 | void GetPCMInfo_v(unsigned long &ulSampRate, 88 | int &nChannels, 89 | int &nBitsPerSample); 90 | 91 | // return number of samples per frame, PER CHANNEL (renderer multiplies this result by nChannels) 92 | int GetSamplesPerFrame_n(); 93 | 94 | void SetTrustPackets(unsigned char bTrust) { m_bTrustPackets = bTrust; } 95 | 96 | private: 97 | void * m_pDec; // generic void ptr 98 | 99 | void * m_pDecL1; // not implemented (could use old Xing mpadecl1.cpp) 100 | void * m_pDecL2; // not implemented (could use old Xing mpadecl2.cpp) 101 | HMP3Decoder m_pDecL3; 102 | 103 | MP3FrameInfo m_lastMP3FrameInfo; 104 | unsigned char m_bUseFrameSize; 105 | unsigned char m_bTrustPackets; 106 | int decoder_state; 107 | }; 108 | 109 | #endif /* _MPADECOBJFIXPT_H_ */ 110 | -------------------------------------------------------------------------------- /lib/mp3/pub/statname.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: RCSL 1.0/RPSL 1.0 3 | * 4 | * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 5 | * 6 | * The contents of this file, and the files included with this file, are 7 | * subject to the current version of the RealNetworks Public Source License 8 | * Version 1.0 (the "RPSL") available at 9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed 10 | * the file under the RealNetworks Community Source License Version 1.0 11 | * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 12 | * in which case the RCSL will apply. You may also obtain the license terms 13 | * directly from RealNetworks. You may not use this file except in 14 | * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 15 | * applicable to this file, the RCSL. Please see the applicable RPSL or 16 | * RCSL for the rights, obligations and limitations governing use of the 17 | * contents of the file. 18 | * 19 | * This file is part of the Helix DNA Technology. RealNetworks is the 20 | * developer of the Original Code and owns the copyrights in the portions 21 | * it created. 22 | * 23 | * This file, and the files included with this file, is distributed and made 24 | * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 25 | * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 26 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 27 | * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 28 | * 29 | * Technology Compatibility Kit Test Suite(s) Location: 30 | * http://www.helixcommunity.org/content/tck 31 | * 32 | * Contributor(s): 33 | * 34 | * ***** END LICENSE BLOCK ***** */ 35 | 36 | /************************************************************************************** 37 | * Fixed-point MP3 decoder 38 | * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) 39 | * June 2003 40 | * 41 | * statname.h - name mangling macros for static linking 42 | **************************************************************************************/ 43 | 44 | #ifndef _STATNAME_H 45 | #define _STATNAME_H 46 | 47 | /* define STAT_PREFIX to a unique name for static linking 48 | * all the C functions and global variables will be mangled by the preprocessor 49 | * e.g. void FFT(int *fftbuf) becomes void cook_FFT(int *fftbuf) 50 | */ 51 | #define STAT_PREFIX xmp3fixpt 52 | 53 | #define STATCC1(x,y,z) STATCC2(x,y,z) 54 | #define STATCC2(x,y,z) x##y##z 55 | 56 | #ifdef STAT_PREFIX 57 | #define STATNAME(func) STATCC1(STAT_PREFIX, _, func) 58 | #else 59 | #define STATNAME(func) func 60 | #endif 61 | 62 | /* these symbols are common to all implementations */ 63 | #define CheckPadBit STATNAME(CheckPadBit) 64 | #define UnpackFrameHeader STATNAME(UnpackFrameHeader) 65 | #define UnpackSideInfo STATNAME(UnpackSideInfo) 66 | #define AllocateBuffers STATNAME(AllocateBuffers) 67 | #define FreeBuffers STATNAME(FreeBuffers) 68 | #define DecodeHuffman STATNAME(DecodeHuffman) 69 | #define Dequantize STATNAME(Dequantize) 70 | #define IMDCT STATNAME(IMDCT) 71 | #define UnpackScaleFactors STATNAME(UnpackScaleFactors) 72 | #define Subband STATNAME(Subband) 73 | 74 | #define samplerateTab STATNAME(samplerateTab) 75 | #define bitrateTab STATNAME(bitrateTab) 76 | #define samplesPerFrameTab STATNAME(samplesPerFrameTab) 77 | #define bitsPerSlotTab STATNAME(bitsPerSlotTab) 78 | #define sideBytesTab STATNAME(sideBytesTab) 79 | #define slotTab STATNAME(slotTab) 80 | #define sfBandTable STATNAME(sfBandTable) 81 | 82 | /* in your implementation's top-level include file (e.g. real\coder.h) you should 83 | * add new #define sym STATNAME(sym) lines for all the 84 | * additional global functions or variables which your 85 | * implementation uses 86 | */ 87 | 88 | #endif /* _STATNAME_H */ 89 | -------------------------------------------------------------------------------- /lib/mp3/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/lib/mp3/readme.txt -------------------------------------------------------------------------------- /lib/mp3/real/CVS/Entries: -------------------------------------------------------------------------------- 1 | /LICENSE.txt/1.1/Fri Feb 6 15:27:51 2004// 2 | /RCSL.txt/1.1/Fri Feb 6 15:27:51 2004// 3 | /RPSL.txt/1.1/Fri Feb 6 15:27:51 2004// 4 | /assembly.h/1.8/Thu Jan 24 12:31:55 2008// 5 | /bitstream.c/1.2/Wed Jul 23 22:12:09 2003// 6 | /buffers.c/1.2/Wed Aug 6 23:30:55 2003// 7 | /coder.h/1.7/Thu May 5 16:15:10 2005// 8 | /dct32.c/1.1/Fri Jul 11 18:22:36 2003// 9 | /dequant.c/1.2/Tue Aug 5 21:25:37 2003// 10 | /dqchan.c/1.3/Tue Aug 5 21:25:37 2003// 11 | /huffman.c/1.2/Wed Jul 23 22:12:09 2003// 12 | /hufftabs.c/1.3/Mon Apr 4 18:30:23 2005// 13 | /imdct.c/1.1/Fri Jul 11 18:22:36 2003// 14 | /polyphase.c/1.3/Wed May 11 14:36:23 2005// 15 | /scalfact.c/1.2/Wed Jul 23 22:12:09 2003// 16 | /stproc.c/1.3/Mon Apr 4 18:30:23 2005// 17 | /subband.c/1.1/Fri Jul 11 18:22:36 2003// 18 | /trigtabs_fixpt.c/1.2/Fri Jun 19 06:50:58 2009// 19 | D 20 | -------------------------------------------------------------------------------- /lib/mp3/real/CVS/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/arm//// 2 | A D/projects//// 3 | -------------------------------------------------------------------------------- /lib/mp3/real/CVS/Repository: -------------------------------------------------------------------------------- 1 | mp3/codec/fixpt/real 2 | -------------------------------------------------------------------------------- /lib/mp3/real/CVS/Root: -------------------------------------------------------------------------------- 1 | :ext:vedder@cvs.helixcommunity.org:/cvsroot/datatype 2 | -------------------------------------------------------------------------------- /lib/mp3/real/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. 2 | 3 | The contents of this directory, and (except where otherwise 4 | indicated) the directories included within this directory, are 5 | subject to the current version of the RealNetworks Public Source 6 | License (the "RPSL") available at RPSL.txt in this directory, unless 7 | you have licensed the directory under the current version of the 8 | RealNetworks Community Source License (the "RCSL") available at 9 | RCSL.txt in this directory, in which case the RCSL will apply. You 10 | may also obtain the license terms directly from RealNetworks. You 11 | may not use the files in this directory except in compliance with the 12 | RPSL or, if you have a valid RCSL with RealNetworks applicable to 13 | this directory, the RCSL. Please see the applicable RPSL or RCSL for 14 | the rights, obligations and limitations governing use of the contents 15 | of the directory. 16 | 17 | This directory is part of the Helix DNA Technology. RealNetworks is 18 | the developer of the Original Code and owns the copyrights in the 19 | portions it created. 20 | 21 | This directory, and the directories included with this directory, are 22 | distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY 23 | OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY 24 | DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 25 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 26 | QUIET ENJOYMENT OR NON-INFRINGEMENT. 27 | 28 | Technology Compatibility Kit Test Suite(s) Location: 29 | http://www.helixcommunity.org/content/tck 30 | 31 | -------------------------------------------------------------------------------- /lib/mp3/real/RCSL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdima1357/spectrum128_cpm_8bit/70d75f0aeacb7ac60bf601deda75806269d20ff9/lib/mp3/real/RCSL.txt -------------------------------------------------------------------------------- /lib/mp3/real/subband.c: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: RCSL 1.0/RPSL 1.0 3 | * 4 | * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 5 | * 6 | * The contents of this file, and the files included with this file, are 7 | * subject to the current version of the RealNetworks Public Source License 8 | * Version 1.0 (the "RPSL") available at 9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed 10 | * the file under the RealNetworks Community Source License Version 1.0 11 | * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 12 | * in which case the RCSL will apply. You may also obtain the license terms 13 | * directly from RealNetworks. You may not use this file except in 14 | * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 15 | * applicable to this file, the RCSL. Please see the applicable RPSL or 16 | * RCSL for the rights, obligations and limitations governing use of the 17 | * contents of the file. 18 | * 19 | * This file is part of the Helix DNA Technology. RealNetworks is the 20 | * developer of the Original Code and owns the copyrights in the portions 21 | * it created. 22 | * 23 | * This file, and the files included with this file, is distributed and made 24 | * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 25 | * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 26 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 27 | * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 28 | * 29 | * Technology Compatibility Kit Test Suite(s) Location: 30 | * http://www.helixcommunity.org/content/tck 31 | * 32 | * Contributor(s): 33 | * 34 | * ***** END LICENSE BLOCK ***** */ 35 | 36 | /************************************************************************************** 37 | * Fixed-point MP3 decoder 38 | * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) 39 | * June 2003 40 | * 41 | * subband.c - subband transform (synthesis filterbank implemented via 32-point DCT 42 | * followed by polyphase filter) 43 | **************************************************************************************/ 44 | 45 | #include "coder.h" 46 | #include "assembly.h" 47 | 48 | /************************************************************************************** 49 | * Function: Subband 50 | * 51 | * Description: do subband transform on all the blocks in one granule, all channels 52 | * 53 | * Inputs: filled MP3DecInfo structure, after calling IMDCT for all channels 54 | * vbuf[ch] and vindex[ch] must be preserved between calls 55 | * 56 | * Outputs: decoded PCM data, interleaved LRLRLR... if stereo 57 | * 58 | * Return: 0 on success, -1 if null input pointers 59 | **************************************************************************************/ 60 | int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf) 61 | { 62 | int b; 63 | HuffmanInfo *hi; 64 | IMDCTInfo *mi; 65 | SubbandInfo *sbi; 66 | 67 | /* validate pointers */ 68 | if (!mp3DecInfo || !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->IMDCTInfoPS || !mp3DecInfo->SubbandInfoPS) 69 | return -1; 70 | 71 | hi = (HuffmanInfo *)mp3DecInfo->HuffmanInfoPS; 72 | mi = (IMDCTInfo *)(mp3DecInfo->IMDCTInfoPS); 73 | sbi = (SubbandInfo*)(mp3DecInfo->SubbandInfoPS); 74 | 75 | if (mp3DecInfo->nChans == 2) { 76 | /* stereo */ 77 | for (b = 0; b < BLOCK_SIZE; b++) { 78 | FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]); 79 | FDCT32(mi->outBuf[1][b], sbi->vbuf + 1*32, sbi->vindex, (b & 0x01), mi->gb[1]); 80 | PolyphaseStereo(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef); 81 | sbi->vindex = (sbi->vindex - (b & 0x01)) & 7; 82 | pcmBuf += (2 * NBANDS); 83 | } 84 | } else { 85 | /* mono */ 86 | for (b = 0; b < BLOCK_SIZE; b++) { 87 | FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]); 88 | PolyphaseMono(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef); 89 | sbi->vindex = (sbi->vindex - (b & 0x01)) & 7; 90 | pcmBuf += NBANDS; 91 | } 92 | } 93 | 94 | return 0; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /spectrum128_cpm_8bit Debug.cfg: -------------------------------------------------------------------------------- 1 | # This is an spectrum128_cpm_8bit board with a single STM32F407VETx chip 2 | # 3 | # Generated by System Workbench for STM32 4 | # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) 5 | 6 | source [find interface/stlink.cfg] 7 | 8 | set WORKAREASIZE 0x8000 9 | 10 | transport select "hla_swd" 11 | 12 | set CHIPNAME STM32F407VETx 13 | set BOARDNAME spectrum128_cpm_8bit 14 | 15 | # CHIPNAMES state 16 | set CHIPNAME_CPU0_ACTIVATED 1 17 | 18 | # Enable debug when in low power modes 19 | set ENABLE_LOW_POWER 1 20 | 21 | # Stop Watchdog counters when halt 22 | set STOP_WATCHDOG 1 23 | 24 | # STlink Debug clock frequency 25 | set CLOCK_FREQ 8000 26 | 27 | # use hardware reset, connect under reset 28 | # connect_assert_srst needed if low power mode application running (WFI...) 29 | reset_config srst_only srst_nogate connect_assert_srst 30 | set CONNECT_UNDER_RESET 1 31 | 32 | # BCTM CPU variables 33 | 34 | 35 | 36 | source [find target/stm32f4x.cfg] 37 | -------------------------------------------------------------------------------- /spectrum128_cpm_8bit Run.cfg: -------------------------------------------------------------------------------- 1 | # This is an spectrum128_cpm_8bit board with a single STM32F407VETx chip 2 | # 3 | # Generated by System Workbench for STM32 4 | # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) 5 | 6 | source [find interface/stlink.cfg] 7 | 8 | set WORKAREASIZE 0x8000 9 | 10 | transport select "hla_swd" 11 | 12 | set CHIPNAME STM32F407VETx 13 | set BOARDNAME spectrum128_cpm_8bit 14 | 15 | # CHIPNAMES state 16 | set CHIPNAME_CPU0_ACTIVATED 1 17 | 18 | # Enable debug when in low power modes 19 | set ENABLE_LOW_POWER 1 20 | 21 | # Stop Watchdog counters when halt 22 | set STOP_WATCHDOG 1 23 | 24 | # STlink Debug clock frequency 25 | set CLOCK_FREQ 8000 26 | 27 | # use hardware reset, connect under reset 28 | # connect_assert_srst needed if low power mode application running (WFI...) 29 | reset_config srst_only srst_nogate connect_assert_srst 30 | set CONNECT_UNDER_RESET 1 31 | 32 | # BCTM CPU variables 33 | 34 | 35 | 36 | source [find target/stm32f4x.cfg] 37 | -------------------------------------------------------------------------------- /spectrum128_cpm_8bit.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ]> 11 | 12 | 13 | spectrum128_cpm_8bit 14 | SWD 15 | ST-Link 16 | stm32f407vetx 17 | 18 | 19 | -------------------------------------------------------------------------------- /syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : syscalls.c 5 | ** 6 | ** Abstract : System Workbench Minimal System calls file 7 | ** 8 | ** For more information about which c-functions 9 | ** need which of these lowlevel functions 10 | ** please consult the Newlib libc-manual 11 | ** 12 | ** Environment : System Workbench for MCU 13 | ** 14 | ** Distribution: The file is distributed as is without any warranty 15 | ** of any kind. 16 | ** 17 | ***************************************************************************** 18 | ** 19 | **

© COPYRIGHT(c) 2014 Ac6

20 | ** 21 | ** Redistribution and use in source and binary forms, with or without modification, 22 | ** are permitted provided that the following conditions are met: 23 | ** 1. Redistributions of source code must retain the above copyright notice, 24 | ** this list of conditions and the following disclaimer. 25 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 26 | ** this list of conditions and the following disclaimer in the documentation 27 | ** and/or other materials provided with the distribution. 28 | ** 3. Neither the name of Ac6 nor the names of its contributors 29 | ** may be used to endorse or promote products derived from this software 30 | ** without specific prior written permission. 31 | ** 32 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | ** 43 | ***************************************************************************** 44 | */ 45 | 46 | /* Includes */ 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | 57 | /* Variables */ 58 | //#undef errno 59 | extern int errno; 60 | extern int __io_putchar(int ch) __attribute__((weak)); 61 | extern int __io_getchar(void) __attribute__((weak)); 62 | 63 | register char * stack_ptr asm("sp"); 64 | 65 | char *__env[1] = { 0 }; 66 | char **environ = __env; 67 | 68 | 69 | /* Functions */ 70 | void initialise_monitor_handles() 71 | { 72 | } 73 | 74 | int _getpid(void) 75 | { 76 | return 1; 77 | } 78 | 79 | int _kill(int pid, int sig) 80 | { 81 | errno = EINVAL; 82 | return -1; 83 | } 84 | 85 | void _exit (int status) 86 | { 87 | _kill(status, -1); 88 | while (1) {} /* Make sure we hang here */ 89 | } 90 | 91 | int _read (int file, char *ptr, int len) 92 | { 93 | int DataIdx; 94 | 95 | for (DataIdx = 0; DataIdx < len; DataIdx++) 96 | { 97 | *ptr++ = __io_getchar(); 98 | } 99 | 100 | return len; 101 | } 102 | 103 | int _write(int file, char *ptr, int len) 104 | { 105 | int DataIdx; 106 | 107 | for (DataIdx = 0; DataIdx < len; DataIdx++) 108 | { 109 | __io_putchar(*ptr++); 110 | } 111 | return len; 112 | } 113 | 114 | caddr_t _sbrk(int incr) 115 | { 116 | extern char end asm("end"); 117 | static char *heap_end; 118 | char *prev_heap_end; 119 | 120 | if (heap_end == 0) 121 | heap_end = &end; 122 | 123 | prev_heap_end = heap_end; 124 | if (heap_end + incr > stack_ptr) 125 | { 126 | // write(1, "Heap and stack collision\n", 25); 127 | // abort(); 128 | errno = ENOMEM; 129 | return (caddr_t) -1; 130 | } 131 | 132 | heap_end += incr; 133 | 134 | return (caddr_t) prev_heap_end; 135 | } 136 | 137 | int _close(int file) 138 | { 139 | return -1; 140 | } 141 | 142 | 143 | int _fstat(int file, struct stat *st) 144 | { 145 | st->st_mode = S_IFCHR; 146 | return 0; 147 | } 148 | 149 | int _isatty(int file) 150 | { 151 | return 1; 152 | } 153 | 154 | int _lseek(int file, int ptr, int dir) 155 | { 156 | return 0; 157 | } 158 | 159 | int _open(char *path, int flags, ...) 160 | { 161 | /* Pretend like we always fail */ 162 | return -1; 163 | } 164 | 165 | int _wait(int *status) 166 | { 167 | errno = ECHILD; 168 | return -1; 169 | } 170 | 171 | int _unlink(char *name) 172 | { 173 | errno = ENOENT; 174 | return -1; 175 | } 176 | 177 | int _times(struct tms *buf) 178 | { 179 | return -1; 180 | } 181 | 182 | int _stat(char *file, struct stat *st) 183 | { 184 | st->st_mode = S_IFCHR; 185 | return 0; 186 | } 187 | 188 | int _link(char *old, char *new) 189 | { 190 | errno = EMLINK; 191 | return -1; 192 | } 193 | 194 | int _fork(void) 195 | { 196 | errno = EAGAIN; 197 | return -1; 198 | } 199 | 200 | int _execve(char *name, char **argv, char **env) 201 | { 202 | errno = ENOMEM; 203 | return -1; 204 | } 205 | --------------------------------------------------------------------------------