From 279a81716a7550402ea3b84b28c03ebd098ad771 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 22 Dec 2020 01:05:05 +0100 Subject: [PATCH] Control code is now in main loop, keystrokes are send over i2c to keyboard device, added basic upload of code over i2c --- .mxproject | 8 +- Inc/firmware.h | 8 + Inc/stm32f4xx_hal_conf.h | 4 +- Inc/stm32f4xx_it.h | 1 - Makefile | 9 +- Src/control.c | 40 ++-- Src/firmware.c | 69 +++++++ Src/main.c | 146 +++++++-------- Src/stm32f4xx_hal_msp.c | 115 +++++++----- Src/stm32f4xx_it.c | 15 -- z80-stm32-v2.ioc | 387 +++++++++++++++++++++------------------ 11 files changed, 457 insertions(+), 345 deletions(-) create mode 100644 Inc/firmware.h create mode 100644 Src/firmware.c diff --git a/.mxproject b/.mxproject index 006d0b2..ea6734d 100644 --- a/.mxproject +++ b/.mxproject @@ -1,14 +1,14 @@ [PreviousGenFiles] -HeaderPath=/home/tim/Projects/z80/z80-stm32-v2/Inc +HeaderPath=/home/tim/Projects/z80/stm32/Inc HeaderFiles=ffconf.h;bsp_driver_sd.h;sd_diskio.h;fatfs.h;fatfs_platform.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_storage_if.h;stm32f4xx_it.h;stm32f4xx_hal_conf.h;main.h; -SourcePath=/home/tim/Projects/z80/z80-stm32-v2/Src +SourcePath=/home/tim/Projects/z80/stm32/Src SourceFiles=bsp_driver_sd.c;sd_diskio.c;fatfs.c;fatfs_platform.c;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_storage_if.c;stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; [PreviousLibFiles] -LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_version.h; +LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_sdmmc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_version.h; [PreviousUsedMakefileFiles] -SourceFiles=Src/main.c;Src/bsp_driver_sd.c;Src/sd_diskio.c;Src/fatfs.c;Src/fatfs_platform.c;Src/usb_device.c;Src/usbd_conf.c;Src/usbd_desc.c;Src/usbd_storage_if.c;Src/stm32f4xx_it.c;Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Src/system_stm32f4xx.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c; +SourceFiles=Src/main.c;Src/bsp_driver_sd.c;Src/sd_diskio.c;Src/fatfs.c;Src/fatfs_platform.c;Src/usb_device.c;Src/usbd_conf.c;Src/usbd_desc.c;Src/usbd_storage_if.c;Src/stm32f4xx_it.c;Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c;Src/system_stm32f4xx.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c; HeaderPath=Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;Middlewares/Third_Party/FatFs/src;Middlewares/ST/STM32_USB_Device_Library/Core/Inc;Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc;Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Inc; CDefines=USE_HAL_DRIVER;STM32F407xx;USE_HAL_DRIVER;USE_HAL_DRIVER; diff --git a/Inc/firmware.h b/Inc/firmware.h new file mode 100644 index 0000000..4708bdd --- /dev/null +++ b/Inc/firmware.h @@ -0,0 +1,8 @@ +#ifndef FIRMWARE_H +#define FIRMWARE_H + +#include "stm32f4xx_hal.h" + +void firmware_update(); + +#endif diff --git a/Inc/stm32f4xx_hal_conf.h b/Inc/stm32f4xx_hal_conf.h index 578bdb0..a358457 100644 --- a/Inc/stm32f4xx_hal_conf.h +++ b/Inc/stm32f4xx_hal_conf.h @@ -51,7 +51,7 @@ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_SDRAM_MODULE_ENABLED */ /* #define HAL_HASH_MODULE_ENABLED */ -/* #define HAL_I2C_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ @@ -61,7 +61,7 @@ #define HAL_SD_MODULE_ENABLED /* #define HAL_MMC_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ -#define HAL_TIM_MODULE_ENABLED +/* #define HAL_TIM_MODULE_ENABLED */ #define HAL_UART_MODULE_ENABLED /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ diff --git a/Inc/stm32f4xx_it.h b/Inc/stm32f4xx_it.h index e6f67e3..05b79a5 100644 --- a/Inc/stm32f4xx_it.h +++ b/Inc/stm32f4xx_it.h @@ -56,7 +56,6 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); -void TIM3_IRQHandler(void); void USART2_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/Makefile b/Makefile index 932dc15..ab2b63a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.7.1] date: [Wed Sep 02 18:41:02 CEST 2020] +# File automatically-generated by tool: [projectgenerator] version: [3.7.1] date: [Thu Oct 01 22:37:12 CEST 2020] ########################################################################################################################## # ------------------------------------------------ @@ -20,7 +20,7 @@ TARGET = z80-stm32-v2 # building variables ###################################### # debug build? -DEBUG = 1 +DEBUG = 0 # optimization OPT = -O3 @@ -37,6 +37,7 @@ BUILD_DIR = .build # C sources C_SOURCES = \ Src/main.c \ +Src/firmware.c \ Src/restart.c \ Src/control.c \ Src/profiling.c \ @@ -83,7 +84,9 @@ Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \ Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c \ Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c \ Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c \ -Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c \ +Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \ +Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c # ASM sources ASM_SOURCES = \ diff --git a/Src/control.c b/Src/control.c index 1450cff..6517f4f 100644 --- a/Src/control.c +++ b/Src/control.c @@ -10,8 +10,8 @@ // The top 4 address bits determine which device is used. (16 pages, 256 devices) // 0xFF means that the device does not exist // WATCH OUT THE DEVICE ADDRESS NEED TO BE REVERSED (MSB IS ON THE RIGHT) -uint8_t memory_map_0[8] = {0b00010000, 0b10001000, 0b01001000, 0b11001000, 0b00101000, 0b10101000, 0b01101000, 0b11101000}; -uint8_t memory_map_1[8] = {0b00001000, 0b10001000, 0b01001000, 0b11001000, 0b00101000, 0b10101000, 0b01101000, 0b11101000}; +uint8_t memory_map_0[16] = {0b00010000, 0b10001000, 0b01001000, 0b11001000, 0b00101000, 0b10101000, 0b01101000, 0b11101000, 0b00011000, 0b10011000, 0b01011000, 0b11011000, 0b00111000, 0b10111000, 0b01111000, 0b11111000}; +uint8_t memory_map_1[16] = {0b00001000, 0b10001000, 0b01001000, 0b11001000, 0b00101000, 0b10101000, 0b01101000, 0b11101000, 0b00011000, 0b10011000, 0b01011000, 0b11011000, 0b00111000, 0b10111000, 0b01111000, 0b11111000}; Control control; @@ -24,10 +24,6 @@ Control control; uint8_t get_device(uint16_t address) { uint8_t page = address >> 12; - if (page >= 8) { - return 0xFF; - } - if (control.memory_config == 0) { return memory_map_0[page]; } else if (control.memory_config == 1) { @@ -143,14 +139,21 @@ void handle_io_read() { uint8_t address = read_address() & 0xFF; switch (address) { - case 0x02: - write_data(control.input.c); - control.input.received = 0; - break; + // Stand in for graphics hardware + /* case 0x03: */ + /* write_data(0x01); */ + /* break; */ - case 0x03: - write_data(0x01 | 0x02*control.input.received); - break; + // Stand in for the keyboard hardware + /* case 0x1E: */ + /* write_data(control.input.c); */ + /* control.input.received = 0; */ + /* break; */ + + // Stand in for the keyboard hardware + /* case 0x1F: */ + /* write_data(0x01 * control.input.received); */ + /* break; */ case 0x08: if (control.storage.ready && control.storage.action == 0x20) { @@ -183,9 +186,13 @@ void handle_io_read() { write_data(0x08*control.storage.ready); break; - default: - printf("IO Read: 0x00 @ %.2X\n\r", address); - write_data(0x00); + default: { + /* uint8_t value = read_data(); */ + /* #<{(| if (value == 0) { |)}># */ + /* printf("IO Read: %.2X @ %.2X\n\r", value, address); */ + /* #<{(| } |)}># */ + return; + } } enable_data_out(1); @@ -364,6 +371,7 @@ uint8_t control_receive_program(uint8_t byte) { if (i >= control.eeprom.length) { i = 0; + c = 0; control.eeprom.programming = 1; return 1; } diff --git a/Src/firmware.c b/Src/firmware.c new file mode 100644 index 0000000..ec2e5a4 --- /dev/null +++ b/Src/firmware.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include "firmware.h" + +extern I2C_HandleTypeDef hi2c1; +extern UART_HandleTypeDef huart2; + +typedef enum { + TARGET_NONE = 0, + TARGET_ROM, + TARGET_I2C +} UpdateTarget; + +void firmware_update() { + printf("FIRMWARE UPDATE\n\r"); + + UpdateTarget target; + HAL_UART_Receive(&huart2, &target, 1, 1000); + printf("T: %i\n\r", target); + + uint8_t address = 0; + if (target == TARGET_I2C) { + HAL_UART_Receive(&huart2, &address, 1, 1000); + printf("A: %i\n\r", address); + } + + uint8_t length_buffer[2]; + HAL_UART_Receive(&huart2, length_buffer, 2, 1000); + uint16_t length = length_buffer[0] + (length_buffer[1] << 8); + printf("L: %i\n\r", length); + + uint8_t* data = malloc(length); + HAL_UART_Receive(&huart2, data, length, 1000); + + printf("Firmware received!\n\r"); + printf("Uploading to target...\n\r"); + + switch (target) { + case TARGET_I2C: { + // Upload the application + uint8_t upload_command[4 + length]; + upload_command[0] = 0x02; + upload_command[1] = 0x01; + + for (uint16_t offset = 0; offset < 8; ++offset) { + upload_command[2] = ((offset*0x80) >> 8) & 0xFF; + upload_command[3] = (offset*0x80) & 0xFF; + + // We need to handle the last section properly + memcpy(&upload_command[4], &data[offset*0x80], 0x80); + + HAL_I2C_Master_Transmit(&hi2c1, address << 1, upload_command, sizeof(upload_command), 1000); + } + + // Start application + uint8_t start_command[] = {0x01, 0x80}; + HAL_I2C_Master_Transmit(&hi2c1, address << 1, start_command, sizeof(start_command), 1000); + break; + } + + default: + printf("Target not implemented!\n\r"); + break; + } + + printf("Complete!\n\r"); +} + diff --git a/Src/main.c b/Src/main.c index c815710..fa915a2 100644 --- a/Src/main.c +++ b/Src/main.c @@ -30,6 +30,7 @@ #include #include "restart.h" #include "control.h" +#include "firmware.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -49,9 +50,9 @@ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ -SD_HandleTypeDef hsd; +I2C_HandleTypeDef hi2c1; -TIM_HandleTypeDef htim3; +SD_HandleTypeDef hsd; UART_HandleTypeDef huart2; @@ -63,8 +64,8 @@ extern Control control; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); -static void MX_TIM3_Init(void); static void MX_USART2_UART_Init(void); +static void MX_I2C1_Init(void); static void MX_SDIO_SD_Init(void); /* USER CODE BEGIN PFP */ @@ -78,8 +79,6 @@ upload_callback_t upload_callback = NULL; uint8_t byte; void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if (huart->Instance == USART2) { - HAL_UART_Receive_IT(&huart2, &byte, 1); - /* printf("0x%X\n\r", byte); */ if (upload_callback) { if (upload_callback(byte)) { upload_callback = NULL; @@ -87,6 +86,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { printf("Done\n\r"); } } else { + static uint8_t cmd_buffer[128]; static uint32_t cmd_buffer_len = 0; @@ -135,6 +135,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { // ONLY SEND THE FIRST CHAR if (cmd_buffer_len > 0) { send_key(byte); + HAL_I2C_Master_Transmit(&hi2c1, 0x04 << 1, &byte, 1, 1000); } cmd_buffer_len = 0; } else if (handle_command && is_command) { @@ -161,6 +162,11 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { case '#': send_key('#'); + HAL_I2C_Master_Transmit(&hi2c1, 0x04 << 1, &byte, 1, 1000); + break; + + case 'a': + firmware_update(); break; default: @@ -175,6 +181,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { is_command = 0; } } + HAL_UART_Receive_IT(&huart2, &byte, 1); } } @@ -278,8 +285,8 @@ int main(void) /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_TIM3_Init(); MX_USART2_UART_Init(); + MX_I2C1_Init(); MX_SDIO_SD_Init(); MX_FATFS_Init(); MX_USB_DEVICE_Init(); @@ -294,8 +301,6 @@ int main(void) HAL_UART_Receive_IT(&huart2, &byte, 1); - HAL_TIM_Base_Start_IT(&htim3); - /* USER CODE END 2 */ /* Infinite loop */ @@ -305,6 +310,7 @@ int main(void) /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ + // @todo Speed up the main loop uint8_t temp = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4); if (!temp && zrst) { printf("Restarting Z80\n\r"); @@ -327,6 +333,8 @@ int main(void) rst = temp; restart_check(); + + control_execute_state(); } /* USER CODE END 3 */ } @@ -373,6 +381,40 @@ void SystemClock_Config(void) } } +/** + * @brief I2C1 Initialization Function + * @param None + * @retval None + */ +static void MX_I2C1_Init(void) +{ + + /* USER CODE BEGIN I2C1_Init 0 */ + + /* USER CODE END I2C1_Init 0 */ + + /* USER CODE BEGIN I2C1_Init 1 */ + + /* USER CODE END I2C1_Init 1 */ + hi2c1.Instance = I2C1; + hi2c1.Init.ClockSpeed = 100000; + hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; + hi2c1.Init.OwnAddress1 = 0; + hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; + hi2c1.Init.OwnAddress2 = 0; + hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; + hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; + if (HAL_I2C_Init(&hi2c1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN I2C1_Init 2 */ + + /* USER CODE END I2C1_Init 2 */ + +} + /** * @brief SDIO Initialization Function * @param None @@ -401,51 +443,6 @@ static void MX_SDIO_SD_Init(void) } -/** - * @brief TIM3 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM3_Init(void) -{ - - /* USER CODE BEGIN TIM3_Init 0 */ - - /* USER CODE END TIM3_Init 0 */ - - TIM_ClockConfigTypeDef sClockSourceConfig = {0}; - TIM_MasterConfigTypeDef sMasterConfig = {0}; - - /* USER CODE BEGIN TIM3_Init 1 */ - - /* USER CODE END TIM3_Init 1 */ - htim3.Instance = TIM3; - htim3.Init.Prescaler = 40; - htim3.Init.CounterMode = TIM_COUNTERMODE_UP; - htim3.Init.Period = 1; - htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - if (HAL_TIM_Base_Init(&htim3) != HAL_OK) - { - Error_Handler(); - } - sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; - if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) - { - Error_Handler(); - } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN TIM3_Init 2 */ - - /* USER CODE END TIM3_Init 2 */ - -} - /** * @brief USART2 Initialization Function * @param None @@ -537,10 +534,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - /*Configure GPIO pins : PC13 PC0 PC3 PC6 - PC7 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_6 - |GPIO_PIN_7; + /*Configure GPIO pins : PC13 PC0 PC3 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -552,16 +547,18 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA1 PA8 PA9 - PA10 PA14 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_9 - |GPIO_PIN_10|GPIO_PIN_14|GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA1 PA8 PA14 + PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_14 + |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PA4 PA5 PA6 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; + /*Configure GPIO pins : PA4 PA5 PA6 PA9 + PA10 */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_9 + |GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -589,11 +586,21 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PD12 PD13 PD14 PD15 - PD0 PD1 PD3 PD4 + /*Configure GPIO pins : PD12 PD13 PD14 PD15 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PC6 PC7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PD0 PD1 PD3 PD4 PD5 PD6 PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 - |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4 |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -610,11 +617,6 @@ static void MX_GPIO_Init(void) } /* USER CODE BEGIN 4 */ -void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { - if (htim->Instance == htim3.Instance) { - control_execute_state(); - } -} /* USER CODE END 4 */ /** diff --git a/Src/stm32f4xx_hal_msp.c b/Src/stm32f4xx_hal_msp.c index f97bd07..27c7fff 100644 --- a/Src/stm32f4xx_hal_msp.c +++ b/Src/stm32f4xx_hal_msp.c @@ -77,6 +77,71 @@ void HAL_MspInit(void) /* USER CODE END MspInit 1 */ } +/** +* @brief I2C MSP Initialization +* This function configures the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspInit 0 */ + + /* USER CODE END I2C1_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**I2C1 GPIO Configuration + PB6 ------> I2C1_SCL + PB7 ------> I2C1_SDA + */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_I2C1_CLK_ENABLE(); + /* USER CODE BEGIN I2C1_MspInit 1 */ + + /* USER CODE END I2C1_MspInit 1 */ + } + +} + +/** +* @brief I2C MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) +{ + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspDeInit 0 */ + + /* USER CODE END I2C1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_I2C1_CLK_DISABLE(); + + /**I2C1 GPIO Configuration + PB6 ------> I2C1_SCL + PB7 ------> I2C1_SDA + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7); + + /* USER CODE BEGIN I2C1_MspDeInit 1 */ + + /* USER CODE END I2C1_MspDeInit 1 */ + } + +} + /** * @brief SD MSP Initialization * This function configures the hardware resources used in this example @@ -162,56 +227,6 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd) } -/** -* @brief TIM_Base MSP Initialization -* This function configures the hardware resources used in this example -* @param htim_base: TIM_Base handle pointer -* @retval None -*/ -void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) -{ - if(htim_base->Instance==TIM3) - { - /* USER CODE BEGIN TIM3_MspInit 0 */ - - /* USER CODE END TIM3_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_TIM3_CLK_ENABLE(); - /* TIM3 interrupt Init */ - HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(TIM3_IRQn); - /* USER CODE BEGIN TIM3_MspInit 1 */ - - /* USER CODE END TIM3_MspInit 1 */ - } - -} - -/** -* @brief TIM_Base MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param htim_base: TIM_Base handle pointer -* @retval None -*/ -void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) -{ - if(htim_base->Instance==TIM3) - { - /* USER CODE BEGIN TIM3_MspDeInit 0 */ - - /* USER CODE END TIM3_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_TIM3_CLK_DISABLE(); - - /* TIM3 interrupt DeInit */ - HAL_NVIC_DisableIRQ(TIM3_IRQn); - /* USER CODE BEGIN TIM3_MspDeInit 1 */ - - /* USER CODE END TIM3_MspDeInit 1 */ - } - -} - /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example diff --git a/Src/stm32f4xx_it.c b/Src/stm32f4xx_it.c index 08040b8..1b15265 100644 --- a/Src/stm32f4xx_it.c +++ b/Src/stm32f4xx_it.c @@ -57,7 +57,6 @@ /* External variables --------------------------------------------------------*/ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern TIM_HandleTypeDef htim3; extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ @@ -199,20 +198,6 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ -/** - * @brief This function handles TIM3 global interrupt. - */ -void TIM3_IRQHandler(void) -{ - /* USER CODE BEGIN TIM3_IRQn 0 */ - - /* USER CODE END TIM3_IRQn 0 */ - HAL_TIM_IRQHandler(&htim3); - /* USER CODE BEGIN TIM3_IRQn 1 */ - - /* USER CODE END TIM3_IRQn 1 */ -} - /** * @brief This function handles USART2 global interrupt. */ diff --git a/z80-stm32-v2.ioc b/z80-stm32-v2.ioc index 362c51e..0ff53a1 100644 --- a/z80-stm32-v2.ioc +++ b/z80-stm32-v2.ioc @@ -1,251 +1,139 @@ #MicroXplorer Configuration settings - do not modify -Mcu.Family=STM32F4 -ProjectManager.MainLocation=Src PB13.GPIOParameters=GPIO_Speed -USB_DEVICE.CLASS_NAME_FS=MSC +PC7.GPIOParameters=GPIO_PuPd PH0-OSC_IN.Signal=RCC_OSC_IN USART2.IPParameters=VirtualMode -RCC.CortexFreq_Value=168000000 -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F407VETx -FATFS0.BSP.semaphore= -PD9.GPIOParameters=GPIO_Speed FATFS0.BSP.api=Unknown VP_FATFS_VS_SDIO.Mode=SDIO +PA10.GPIO_PuPd=GPIO_PULLDOWN RCC.PLLCLKFreq_Value=168000000 -PC10.Signal=SDIO_D2 PC12.Signal=SDIO_CK RCC.PLLQCLKFreq_Value=48000000 -PC5.Locked=true PC7.Locked=true -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_TIM3_Init-TIM3-false-HAL-true,4-MX_USART2_UART_Init-USART2-false-HAL-true PD8.Locked=true -PD9.GPIO_Speed=GPIO_SPEED_FREQ_LOW PC3.Locked=true -PA11.Mode=Device_Only RCC.RTCFreq_Value=32000 -PD6.Locked=true -PC2.GPIO_Speed=GPIO_SPEED_FREQ_LOW PD0.Locked=true PD4.Locked=true -PC1.Locked=true -PB11.Signal=GPIO_Output PB13.Signal=GPIO_Output -PB15.Signal=GPIO_Output PinOutPanel.RotationAngle=0 -PE5.GPIOParameters=GPIO_PuPd RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -ProjectManager.StackSize=0x400 PB11.GPIO_Speed=GPIO_SPEED_FREQ_LOW -PD13.Signal=GPIO_Input -Mcu.IP4=SYS -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP5=TIM3 -PD13.Locked=true NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false -Mcu.IP2=RCC -Mcu.IP3=SDIO -Mcu.IP0=FATFS -Mcu.IP1=NVIC -PA12.Signal=USB_OTG_FS_DP -PE4.GPIOParameters=GPIO_Speed,PinState -Mcu.UserConstants= -PE5.GPIO_PuPd=GPIO_PULLUP -PA7.PinState=GPIO_PIN_RESET +PD15.GPIOParameters=GPIO_PuPd VP_FATFS_VS_SDIO.Signal=FATFS_VS_SDIO -PC1.GPIOParameters=GPIO_Speed,PinState -Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=9 -RCC.I2SClocksFreq_Value=96000000 -ProjectManager.PreviousToolchain= PD4.Signal=GPIO_Input RCC.APB2TimFreq_Value=168000000 -TIM3.Period=1 -RCC.VcooutputI2S=96000000 +PB6.Signal=I2C1_SCL PC7.Signal=GPIO_Input -PD8.GPIOParameters=GPIO_Speed +PB6.Mode=I2C PC3.Signal=GPIO_Input -Mcu.Pin6=PC14-OSC32_IN PD0.Signal=GPIO_Input -Mcu.Pin7=PC15-OSC32_OUT PD8.Signal=GPIO_Output PE5.Signal=GPIO_Input -Mcu.Pin8=PH0-OSC_IN -Mcu.Pin9=PH1-OSC_OUT PE1.Signal=GPIO_Input PC1.PinState=GPIO_PIN_SET -RCC.AHBFreq_Value=168000000 -PH0-OSC_IN.Mode=HSE-External-Oscillator PB13.Locked=true FATFS0.BSP.ip=GPIO -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -PD10.GPIOParameters=GPIO_Speed -Mcu.Pin5=PC13-ANTI_TAMP ProjectManager.ProjectBuild=false -RCC.HSE_VALUE=25000000 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false -PA4.GPIO_PuPd=GPIO_PULLDOWN PA8.Locked=true FATFS0.BSP.i2caddr=0 PA4.Locked=true PC13-ANTI_TAMP.Signal=GPIO_Input -NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0 -PC4.GPIO_Speed=GPIO_SPEED_FREQ_LOW MxDb.Version=DB.5.0.60 -PA6.GPIO_PuPd=GPIO_PULLDOWN ProjectManager.BackupPrevious=false -PC14-OSC32_IN.Mode=LSE-External-Oscillator -RCC.VCOInputFreq_Value=1000000 -PE4.GPIO_Speed=GPIO_SPEED_FREQ_LOW -TIM3.Prescaler=160 PA5.GPIO_PuPd=GPIO_PULLDOWN -File.Version=6 PC9.Mode=SD_4_bits_Wide_bus -PE3.GPIOParameters=GPIO_Speed -PE3.Locked=true PE2.Signal=GPIO_Input PA8.Signal=GPIO_Input -PB8.Locked=true +PD14.GPIO_PuPd=GPIO_PULLDOWN PE1.Locked=true NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false -PD10.GPIO_Speed=GPIO_SPEED_FREQ_LOW -PE4.Signal=GPIO_Output +PB6.GPIO_PuPdOD=GPIO_NOPULL ProjectManager.HalAssertFull=false -ProjectManager.ProjectName=z80-stm32-v2 -PH1-OSC_OUT.Mode=HSE-External-Oscillator RCC.MCO2PinFreq_Value=168000000 Mcu.Package=LQFP100 PB9.Signal=GPIO_Input -PA6.Signal=GPIO_Input -PA7.Locked=true PA5.Locked=true PD11.Locked=true -USART2.VirtualMode=VM_ASYNC PD12.Signal=GPIO_Input FATFS0.BSP.solution=PA8 PA14.Locked=true -NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:false\:true -ProjectManager.ToolChainLocation= -PD14.Locked=true -RCC.LSI_VALUE=32000 VP_SYS_VS_Systick.Signal=SYS_VS_Systick PA10.Signal=GPIO_Input -USB_OTG_FS.VirtualMode=Device_Only -PA15.Signal=GPIO_Input +PC6.GPIO_PuPd=GPIO_PULLDOWN PA5.GPIOParameters=GPIO_PuPd PC11.Mode=SD_4_bits_Wide_bus PB14.GPIOParameters=GPIO_Speed RCC.APB2CLKDivider=RCC_HCLK_DIV2 RCC.APB1TimFreq_Value=84000000 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false -PC4.Locked=true -PC5.Signal=GPIO_Output VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS.Mode=MSC_FS USB_OTG_FS.IPParameters=VirtualMode PE6.Locked=true -PD6.Signal=GPIO_Input PD5.Locked=true PD15.Signal=GPIO_Input ProjectManager.CustomerFirmwarePackage= PC4.GPIOParameters=GPIO_Speed -VP_TIM3_VS_ClockSourceINT.Mode=Internal -PB15.Locked=true -PB3.Locked=true -PB4.Signal=GPIO_Input -PA3.Signal=USART2_RX VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_MSC_FS PA6.GPIOParameters=GPIO_PuPd -PC15-OSC32_OUT.Mode=LSE-External-Oscillator FATFS0.BSP.STBoard=false -USB_DEVICE.VirtualMode-MSC_FS=Msc ProjectManager.ProjectFileName=z80-stm32-v2.ioc -Mcu.PinsNb=70 -ProjectManager.NoMain=false -USB_DEVICE.VirtualModeFS=Msc_FS -PC11.Signal=SDIO_D3 +Mcu.PinsNb=71 FATFS0.BSP.mode=Input PD3.Signal=GPIO_Input -PC8.Signal=SDIO_D0 -PC2.Signal=GPIO_Output -PC4.Signal=GPIO_Output +Mcu.Pin70=VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS PC6.Signal=GPIO_Input -PC10.Mode=SD_4_bits_Wide_bus +PC2.Signal=GPIO_Output +PD13.GPIOParameters=GPIO_PuPd PD7.Signal=GPIO_Input PD1.Signal=GPIO_Input -ProjectManager.DefaultFWLocation=true -PD9.Signal=GPIO_Output -PD5.Signal=GPIO_Input -PB12.Locked=true -ProjectManager.DeletePrevious=true -Mcu.Pin68=VP_TIM3_VS_ClockSourceINT -Mcu.Pin69=VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS +Mcu.Pin68=VP_FATFS_VS_SDIO +Mcu.Pin69=VP_SYS_VS_Systick PC0.Signal=GPIO_Input PB14.Locked=true RCC.APB1CLKDivider=RCC_HCLK_DIV4 PC14-OSC32_IN.Signal=RCC_OSC32_IN -Mcu.Pin62=PB8 -USB_DEVICE.IPParameters=VirtualMode-MSC_FS,VirtualModeFS,CLASS_NAME_FS -Mcu.Pin63=PB9 +Mcu.Pin62=PB6 +Mcu.Pin63=PB7 Mcu.Pin60=PB4 -NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true Mcu.Pin61=PB5 -Mcu.Pin66=VP_FATFS_VS_SDIO -Mcu.Pin67=VP_SYS_VS_Systick -RCC.FamilyName=M -Mcu.Pin64=PE0 -Mcu.Pin65=PE1 +Mcu.Pin66=PE0 +Mcu.Pin67=PE1 +Mcu.Pin64=PB8 +Mcu.Pin65=PB9 PA0-WKUP.Signal=GPIO_Input -PA0-WKUP.Locked=true -PD12.Locked=true -FATFS0.BSP.instance=PA8 PD10.Signal=GPIO_Output PA3.Mode=Asynchronous PA15.Locked=true Mcu.Pin59=PB3 Mcu.Pin57=PD6 Mcu.Pin58=PD7 -ProjectManager.TargetToolchain=Makefile PB14.GPIO_Speed=GPIO_SPEED_FREQ_LOW Mcu.Pin51=PD0 Mcu.Pin52=PD1 -FATFS0.BSP.condition= +I2C1.I2C_Mode=I2C_Standard Mcu.Pin50=PC12 PD11.GPIO_Speed=GPIO_SPEED_FREQ_LOW Mcu.Pin55=PD4 Mcu.Pin56=PD5 Mcu.Pin53=PD2 Mcu.Pin54=PD3 -PC5.GPIOParameters=GPIO_Speed PC6.Locked=true PA9.Signal=GPIO_Input PB13.GPIO_Speed=GPIO_SPEED_FREQ_LOW -PE4.Locked=true PB11.GPIOParameters=GPIO_Speed PB5.Locked=true PB9.Locked=true -PC2.Locked=true -PE0.Locked=true -VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT +PC7.GPIO_PuPd=GPIO_PULLDOWN PD7.Locked=true -PC15-OSC32_OUT.Signal=RCC_OSC32_OUT -PD3.Locked=true -PA1.Signal=GPIO_Input Mcu.Pin48=PC10 -PB12.GPIO_Speed=GPIO_SPEED_FREQ_LOW Mcu.Pin49=PC11 Mcu.Pin46=PA14 Mcu.Pin47=PA15 -RCC.VCOI2SOutputFreq_Value=192000000 PB14.Signal=GPIO_Output -PD2.Mode=SD_4_bits_Wide_bus FATFS.BSP.number=1 PA5.Signal=GPIO_Input Mcu.Pin40=PC9 @@ -254,16 +142,9 @@ Mcu.Pin44=PA11 PC12.Mode=SD_4_bits_Wide_bus Mcu.Pin45=PA12 Mcu.Pin42=PA9 -board=custom Mcu.Pin43=PA10 -RCC.VCOOutputFreq_Value=336000000 -PC13-ANTI_TAMP.Locked=true ProjectManager.LastFirmware=true PA7.GPIO_Speed=GPIO_SPEED_FREQ_LOW -NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:true\:true -PD11.GPIOParameters=GPIO_Speed -RCC.APB2Freq_Value=84000000 -MxCube.Version=5.6.0 Mcu.Pin37=PC6 Mcu.Pin38=PC7 Mcu.Pin35=PD14 @@ -272,64 +153,42 @@ Mcu.Pin39=PC8 FATFS0.BSP.i2creg= PC2.GPIOParameters=GPIO_Speed,PinState Mcu.Pin30=PD9 -VP_SYS_VS_Systick.Mode=SysTick RCC.EthernetFreq_Value=168000000 Mcu.Pin33=PD12 -TIM3.IPParameters=Prescaler,Period -PH1-OSC_OUT.Signal=RCC_OSC_OUT Mcu.Pin34=PD13 Mcu.Pin31=PD10 -PC1.GPIO_Speed=GPIO_SPEED_FREQ_LOW Mcu.Pin32=PD11 +PC1.GPIO_Speed=GPIO_SPEED_FREQ_LOW PA9.Locked=true NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false -PA4.GPIOParameters=GPIO_PuPd -PE5.Locked=true -PE6.Signal=GPIO_Input +PB7.GPIO_PuPdOD=GPIO_NOPULL ProjectManager.FreePins=false -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F407V(E-G)Tx -PE0.Signal=GPIO_Input Mcu.Pin26=PB13 Mcu.Pin27=PB14 RCC.RTCHSEDivFreq_Value=12500000 -PA2.Signal=USART2_TX Mcu.Pin24=PB11 ProjectManager.UnderRoot=false Mcu.Pin25=PB12 -Mcu.IP8=USB_OTG_FS Mcu.Pin28=PB15 -PD14.Signal=GPIO_Input -Mcu.IP6=USART2 -Mcu.Pin29=PD8 PC8.Mode=SD_4_bits_Wide_bus -Mcu.IP7=USB_DEVICE -ProjectManager.CoupleFile=false +Mcu.Pin29=PD8 PB4.Locked=true -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=GPIO_Input +PD14.GPIOParameters=GPIO_PuPd PA4.Signal=GPIO_Input -RCC.SYSCLKFreq_VALUE=168000000 Mcu.Pin22=PC4 PB5.Signal=GPIO_Input Mcu.Pin23=PC5 -PA1.Locked=true Mcu.Pin20=PA6 Mcu.Pin21=PA7 -PC2.PinState=GPIO_PIN_SET PD10.Locked=true -PA12.Mode=Device_Only PA10.Locked=true NVIC.ForceEnableDMAVector=true -KeepUserPlacement=false PE3.GPIO_Speed=GPIO_SPEED_FREQ_LOW PD11.Signal=GPIO_Output NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false ProjectManager.CompilerOptimize=6 PD15.Locked=true PA11.Signal=USB_OTG_FS_DM -PA14.Signal=GPIO_Input ProjectManager.HeapSize=0x200 Mcu.Pin15=PA1 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false @@ -339,36 +198,200 @@ Mcu.Pin14=PA0-WKUP Mcu.Pin19=PA5 ProjectManager.ComputerToolchain=false Mcu.Pin17=PA3 -RCC.HSI_VALUE=16000000 Mcu.Pin18=PA4 PD8.GPIO_Speed=GPIO_SPEED_FREQ_LOW -RCC.PLLQ=7 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 Mcu.Pin11=PC1 -Mcu.Pin12=PC2 PC5.GPIO_Speed=GPIO_SPEED_FREQ_LOW -FATFS0.BSP.component= -RCC.PLLM=25 -RCC.PLLN=336 +Mcu.Pin12=PC2 Mcu.Pin10=PC0 -PE2.Locked=true PE3.Signal=GPIO_Output -PA2.Mode=Asynchronous -PB8.Signal=GPIO_Input +PE2.Locked=true PE4.PinState=GPIO_PIN_SET -PC9.Signal=SDIO_D1 PD2.Signal=SDIO_CMD -PD9.Locked=true -RCC.APB1Freq_Value=42000000 PD1.Locked=true PA7.GPIOParameters=GPIO_Speed,PinState PC0.Locked=true -PB11.Locked=true -ProjectManager.DeviceId=STM32F407VETx PC1.Signal=GPIO_Output PB12.GPIOParameters=GPIO_Speed -PB12.Signal=GPIO_Output FATFS0.BSP.name=Detect_SDIO +Mcu.Family=STM32F4 +ProjectManager.MainLocation=Src +USB_DEVICE.CLASS_NAME_FS=MSC +RCC.CortexFreq_Value=168000000 +ProjectManager.KeepUserCode=true +Mcu.UserName=STM32F407VETx +FATFS0.BSP.semaphore= +PD9.GPIOParameters=GPIO_Speed +PC10.Signal=SDIO_D2 +PC5.Locked=true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SDIO_SD_Init-SDIO-false-HAL-true,6-MX_FATFS_Init-FATFS-false-HAL-false,7-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false +PA9.GPIOParameters=GPIO_PuPd +PD9.GPIO_Speed=GPIO_SPEED_FREQ_LOW +PA11.Mode=Device_Only +PD6.Locked=true +PC2.GPIO_Speed=GPIO_SPEED_FREQ_LOW +PC1.Locked=true +PB11.Signal=GPIO_Output +PB15.Signal=GPIO_Output +PE5.GPIOParameters=GPIO_PuPd +ProjectManager.StackSize=0x400 +PD13.Signal=GPIO_Input +Mcu.IP4=SDIO +RCC.FCLKCortexFreq_Value=168000000 +Mcu.IP5=SYS +Mcu.IP2=NVIC +I2C1.IPParameters=ClockSpeed,I2C_Mode +PD13.Locked=true +Mcu.IP3=RCC +Mcu.IP0=FATFS +Mcu.IP1=I2C1 +PA12.Signal=USB_OTG_FS_DP +PE4.GPIOParameters=GPIO_Speed,PinState +Mcu.UserConstants= +PE5.GPIO_PuPd=GPIO_PULLUP +PA7.PinState=GPIO_PIN_RESET +I2C1.ClockSpeed=100000 +PC1.GPIOParameters=GPIO_Speed,PinState +Mcu.ThirdPartyNb=0 +RCC.HCLKFreq_Value=168000000 +Mcu.IPNb=9 +RCC.I2SClocksFreq_Value=96000000 +ProjectManager.PreviousToolchain= +RCC.VcooutputI2S=96000000 +PD8.GPIOParameters=GPIO_Speed +Mcu.Pin6=PC14-OSC32_IN +Mcu.Pin7=PC15-OSC32_OUT +Mcu.Pin8=PH0-OSC_IN +Mcu.Pin9=PH1-OSC_OUT +RCC.AHBFreq_Value=168000000 +PH0-OSC_IN.Mode=HSE-External-Oscillator +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +GPIO.groupedBy=Group By Peripherals +Mcu.Pin2=PE4 +Mcu.Pin3=PE5 +Mcu.Pin4=PE6 +PD10.GPIOParameters=GPIO_Speed +Mcu.Pin5=PC13-ANTI_TAMP +RCC.HSE_VALUE=25000000 +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false +PA4.GPIO_PuPd=GPIO_PULLDOWN +NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true +PC4.GPIO_Speed=GPIO_SPEED_FREQ_LOW +PA6.GPIO_PuPd=GPIO_PULLDOWN +PC14-OSC32_IN.Mode=LSE-External-Oscillator +RCC.VCOInputFreq_Value=1000000 +PE4.GPIO_Speed=GPIO_SPEED_FREQ_LOW +File.Version=6 +PE3.GPIOParameters=GPIO_Speed +PE3.Locked=true +PB7.Signal=I2C1_SDA +PB8.Locked=true +PD10.GPIO_Speed=GPIO_SPEED_FREQ_LOW +PE4.Signal=GPIO_Output +PB6.GPIOParameters=GPIO_PuPdOD +ProjectManager.ProjectName=z80-stm32-v2 +PH1-OSC_OUT.Mode=HSE-External-Oscillator +PA6.Signal=GPIO_Input +PA7.Locked=true +USART2.VirtualMode=VM_ASYNC +NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:false\:true +ProjectManager.ToolChainLocation= +PD15.GPIO_PuPd=GPIO_PULLDOWN +PD14.Locked=true +RCC.LSI_VALUE=32000 +USB_OTG_FS.VirtualMode=Device_Only +PA15.Signal=GPIO_Input +PC4.Locked=true +PC5.Signal=GPIO_Output +PD6.Signal=GPIO_Input +PB15.Locked=true +PB3.Locked=true +PB4.Signal=GPIO_Input +PA3.Signal=USART2_RX +PC15-OSC32_OUT.Mode=LSE-External-Oscillator +USB_DEVICE.VirtualMode-MSC_FS=Msc +ProjectManager.NoMain=false +USB_DEVICE.VirtualModeFS=Msc_FS +PC11.Signal=SDIO_D3 +PC8.Signal=SDIO_D0 +PC4.Signal=GPIO_Output +PC10.Mode=SD_4_bits_Wide_bus +ProjectManager.DefaultFWLocation=true +PD9.Signal=GPIO_Output +PD5.Signal=GPIO_Input +PB12.Locked=true +ProjectManager.DeletePrevious=true +USB_DEVICE.IPParameters=VirtualMode-MSC_FS,VirtualModeFS,CLASS_NAME_FS +PA9.GPIO_PuPd=GPIO_PULLDOWN +NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true +RCC.FamilyName=M +PA0-WKUP.Locked=true +PD12.Locked=true +FATFS0.BSP.instance=PA8 +PD12.GPIOParameters=GPIO_PuPd +ProjectManager.TargetToolchain=Makefile +FATFS0.BSP.condition= +PB7.GPIOParameters=GPIO_PuPdOD +PC5.GPIOParameters=GPIO_Speed +PE4.Locked=true +PC2.Locked=true +ProjectManager.RegisterCallBack= +PE0.Locked=true +PC15-OSC32_OUT.Signal=RCC_OSC32_OUT +PD3.Locked=true +PA1.Signal=GPIO_Input +PB12.GPIO_Speed=GPIO_SPEED_FREQ_LOW +RCC.VCOI2SOutputFreq_Value=192000000 +PD2.Mode=SD_4_bits_Wide_bus +board=custom +RCC.VCOOutputFreq_Value=336000000 +PC13-ANTI_TAMP.Locked=true +PD11.GPIOParameters=GPIO_Speed +RCC.APB2Freq_Value=84000000 +MxCube.Version=5.6.0 +VP_SYS_VS_Systick.Mode=SysTick +PA10.GPIOParameters=GPIO_PuPd +PH1-OSC_OUT.Signal=RCC_OSC_OUT +PD13.GPIO_PuPd=GPIO_PULLDOWN +PA4.GPIOParameters=GPIO_PuPd +PE5.Locked=true +PE6.Signal=GPIO_Input +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S +ProjectManager.AskForMigrate=true +Mcu.Name=STM32F407V(E-G)Tx +PE0.Signal=GPIO_Input +PA2.Signal=USART2_TX +Mcu.IP8=USB_OTG_FS +PD14.Signal=GPIO_Input +Mcu.IP6=USART2 +Mcu.IP7=USB_DEVICE +ProjectManager.CoupleFile=false +RCC.48MHZClocksFreq_Value=48000000 +PB3.Signal=GPIO_Input +RCC.SYSCLKFreq_VALUE=168000000 +PA1.Locked=true +PC2.PinState=GPIO_PIN_SET +PA12.Mode=Device_Only +KeepUserPlacement=false +PB7.Mode=I2C +PA14.Signal=GPIO_Input +PC6.GPIOParameters=GPIO_PuPd +RCC.HSI_VALUE=16000000 +RCC.PLLQ=7 +FATFS0.BSP.component= +RCC.PLLM=25 +RCC.PLLN=336 +PA2.Mode=Asynchronous +PB8.Signal=GPIO_Input +PC9.Signal=SDIO_D1 +PD9.Locked=true +RCC.APB1Freq_Value=42000000 +PB11.Locked=true +ProjectManager.DeviceId=STM32F407VETx +PB12.Signal=GPIO_Output ProjectManager.LibraryCopy=0 +PD12.GPIO_PuPd=GPIO_PULLDOWN PA7.Signal=GPIO_Output PA6.Locked=true