├── .gitignore ├── BootLoopMK ├── .cproject ├── .project ├── Documentation.doxyfile ├── Project_Headers │ ├── MK20DN32M5.h │ ├── bitband.h │ ├── clock_configure.h │ ├── cmsis_gcc.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSimd.h │ ├── delay.h │ ├── derivative.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── BootLoopMK-Debug.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap-mk20dn32m5.ld ├── ReadMe.md ├── Sources │ └── main.c └── Startup_Code │ ├── clock.c │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c ├── BootLoopMKE ├── .cproject ├── .project ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── MKE02Z16M2.h │ ├── MKE02Z16M4.h │ ├── bme.h │ ├── clock_configure.h │ ├── cmsis_gcc.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── delay.h │ ├── derivative.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── BootLoopMKE-Debug.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ ├── MemoryMap-mke02z16m2.ld │ │ └── MemoryMap-mke02z16m4.ld ├── ReadMe.md ├── Sources │ └── main.c └── Startup_Code │ ├── clock.c │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c ├── BootLoopMKL ├── .cproject ├── .project ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── MKL25Z32M4.h │ ├── bme.h │ ├── clock_configure.h │ ├── cmsis_gcc.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── delay.h │ ├── derivative.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── BootLoopMKL-Debug.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap-mkl25z32m4.ld ├── ReadMe.md ├── Sources │ └── main.c └── Startup_Code │ ├── clock.c │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c ├── BootLoopMKL05_SWD_Disabled ├── .cproject ├── .project ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── Board_LEDs.h │ ├── MKL05Z4.h │ ├── bme.h │ ├── clock_configure.h │ ├── cmsis_gcc.h │ ├── console.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── delay.h │ ├── derivative.h │ ├── leds.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── BootLoopMKL05_SWD_Disabled_Debug_USBDM.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap.ld ├── ReadMe.md ├── Sources │ ├── delay.cpp │ ├── leds.c │ └── main.c └── Startup_Code │ ├── clock.c │ ├── console.c │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system-gcc.cpp │ ├── system.c │ └── vectors.c ├── FRDM_KL25_POWER_ON_ERASE_CHALLENGE ├── .cproject ├── .project ├── Project_Headers │ ├── FRDM_KL25Z.h │ ├── bme.h │ ├── cmsis_gcc.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── delay.h │ ├── derivative.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── FRDM_KL25_POWER_ON_ERASE_CHALLENGE-Debug.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap-frdm_kl25z.ld ├── ReadMe.md ├── Sources │ └── main.c └── Startup_Code │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c ├── FRDM_MK20_POWER_ON_ERASE_CHALLENGE ├── .cproject ├── .project ├── Project_Headers │ ├── FRDM_K20D50M.h │ ├── bitband.h │ ├── cmsis_gcc.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSimd.h │ ├── delay.h │ ├── derivative.h │ ├── system.h │ └── utilities.h ├── Project_Settings │ ├── FRDM_MK20_POWER_ON_ERASE_CHALLENGE-Debug.launch │ └── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap-frdm_k20d50m.ld ├── ReadMe.md ├── Sources │ └── main.c └── Startup_Code │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c ├── OpenSDA_MassEraseKinetisTarget ├── .cproject ├── .gitignore ├── .project ├── Project_Headers │ ├── BDM.h │ ├── BDMCommon.h │ ├── Board_LEDs.h │ ├── Commands.h │ ├── Common.h │ ├── Configure.h │ ├── FRDM_K20D50M.h │ ├── MK20D5.h │ ├── SPI.h │ ├── SWD.h │ ├── TargetDefines.h │ ├── USBDM_OpenSDA.h │ ├── bitband.h │ ├── clock_configure.h │ ├── cmsis_gcc.h │ ├── console.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSimd.h │ ├── delay.h │ ├── derivative.h │ ├── leds.h │ ├── system.h │ ├── uart.h │ └── utilities.h ├── Project_Settings │ ├── Linker_Files │ │ ├── Linker-rom.ld │ │ ├── MemoryMap-frdm_k20d50m.ld │ │ └── MemoryMap-mk20dx128m5.ld │ ├── OpenSDA_MassEraseKinetisTarget-Debug.launch │ └── PowerOnMassEraseKinetis-Debug.launch ├── ReadMe.md ├── Sources │ ├── BDMCommon.c │ ├── SPI.c │ ├── SWD.c │ └── main.c └── Startup_Code │ ├── clock.c │ ├── console.c │ ├── newlib_stubs.c │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ ├── uart.c │ └── vectors.c ├── README.md ├── TestClock_MK22F ├── .cproject ├── .project ├── Configure.usbdmProject ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── KinetisPowerModes.png │ ├── MK22F51212.h │ ├── PowerModes.png │ ├── USBDM_Documentation.h │ ├── adc.h │ ├── bitband.h │ ├── cmp.h │ ├── cmsis_gcc.h │ ├── console.h │ ├── control.h │ ├── core_cm4.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSimd.h │ ├── crc.h │ ├── dac.h │ ├── delay.h │ ├── derivative.h │ ├── dma.h │ ├── dmamux.h │ ├── error.h │ ├── ewm.h │ ├── flash.h │ ├── flexbus.h │ ├── fmc.h │ ├── formatted_io.h │ ├── ftfa.h │ ├── ftm.h │ ├── gpio.h │ ├── hardware.h │ ├── i2c.h │ ├── i2s.h │ ├── llwu.h │ ├── lptmr.h │ ├── lpuart.h │ ├── mcg.h │ ├── mcm.h │ ├── osc.h │ ├── pcr.h │ ├── pdb.h │ ├── pin_mapping.h │ ├── pit.h │ ├── pmc.h │ ├── rcm.h │ ├── rnga.h │ ├── rtc.h │ ├── sim.h │ ├── smc.h │ ├── spi.h │ ├── stringFormatter.h │ ├── system.h │ ├── uart.h │ ├── uart_queue.h │ ├── usb.h │ ├── usb_defs.h │ ├── usb_endpoint.h │ ├── utilities.h │ ├── vref.h │ └── wdog.h ├── Project_Settings │ ├── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap.ld │ └── frdm_mk22f_Debug_USBDM.launch ├── Sources │ ├── delay.cpp │ ├── ftfa.cpp │ ├── hardware.cpp │ ├── hardware.h │ ├── i2c.cpp │ ├── main.cpp │ ├── spi.cpp │ └── usbdmError.cpp └── Startup_Code │ ├── console.cpp │ ├── mcg.cpp │ ├── newlib_stubs.c │ ├── rtc.cpp │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system-gcc.cpp │ ├── system.cpp │ └── vectors.cpp ├── TestClock_MKL05 ├── .cproject ├── .project ├── Configure.usbdmProject ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── KinetisPowerModes.png │ ├── MKL05Z4.h │ ├── USBDM_Documentation.h │ ├── adc.h │ ├── bme.h │ ├── cmp.h │ ├── cmsis_gcc.h │ ├── console.h │ ├── control.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── dac.h │ ├── delay.h │ ├── derivative.h │ ├── dma.h │ ├── error.h │ ├── flash.h │ ├── formatted_io.h │ ├── ftfa.h │ ├── gpio.h │ ├── hardware.h │ ├── i2c.h │ ├── llwu.h │ ├── lptmr.h │ ├── mcg.h │ ├── osc.h │ ├── pcr.h │ ├── pin_mapping.h │ ├── pit.h │ ├── pmc.h │ ├── rcm.h │ ├── rtc.h │ ├── smc.h │ ├── spi.h │ ├── stringFormatter.h │ ├── system.h │ ├── tpm.h │ ├── tsi.h │ ├── uart.h │ ├── uart_queue.h │ └── utilities.h ├── Project_Settings │ ├── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap.ld │ └── klo5_Debug_USBDM.launch ├── Snippets │ ├── analogue-comparison-example.cpp │ ├── analogue-example.cpp │ ├── analogue-interrupt-example.cpp │ ├── analogue-joystick-example.cpp │ ├── bitband-example.cpp │ ├── clkout-example.cpp │ ├── cmp-example.cpp │ ├── console-example.cpp │ ├── dac-example.cpp │ ├── digital-example1.cpp │ ├── digital-example2.cpp │ ├── digital-interrupt-example.cpp │ ├── digital-rotary-encoder-example.cpp │ ├── dma-memory-example-mkl.cpp │ ├── dma-memory-template-example-mkl.cpp │ ├── dma-uart-example-mkl25.cpp │ ├── flash-programming-example.cpp │ ├── fxos8700cq-example.cpp │ ├── fxos8700cq.cpp │ ├── fxos8700cq.h │ ├── hmc5883l-example.cpp │ ├── hmc5883l.cpp │ ├── hmc5883l.h │ ├── i2c-example.cpp │ ├── llwu-example-mkl25z.cpp │ ├── lptmr-example.cpp │ ├── lptmr-reaction-time.cpp │ ├── lsm303dlh.cpp │ ├── lsm303dlh.h │ ├── mag3310-example.cpp │ ├── mag3310.cpp │ ├── mag3310.h │ ├── mcg-test.cpp │ ├── mma845x-example.cpp │ ├── mma845x.cpp │ ├── mma845x.h │ ├── mma8491q-example.cpp │ ├── mma8491q.cpp │ ├── mma8491q.h │ ├── pca9685-example.cpp │ ├── pca9685.cpp │ ├── pca9685.h │ ├── pit-example1.cpp │ ├── pit-example2.cpp │ ├── pmc-example.cpp │ ├── rcm-example.cpp │ ├── rtc-example.cpp │ ├── sht10-example.cpp │ ├── sht10.h │ ├── spi-example-MKL.cpp │ ├── spi-example-cmsis-MKL.cpp │ ├── tpm-ic-example.cpp │ ├── tpm-oc-example.cpp │ ├── tpm-pwm-example.cpp │ ├── tsi-mkl-example.cpp │ ├── uart-example.cpp │ └── vector.h ├── Sources │ ├── delay.cpp │ ├── ftfa.cpp │ ├── hardware.cpp │ ├── hardware.h │ ├── i2c.cpp │ ├── main.cpp │ ├── spi.cpp │ └── usbdmError.cpp └── Startup_Code │ ├── console.cpp │ ├── mcg_no_pll.cpp │ ├── newlib_stubs.c │ ├── rtc.cpp │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system-gcc.cpp │ ├── system.cpp │ └── vectors.cpp ├── TestClock_MKL25 ├── .cproject ├── .project ├── Configure.usbdmProject ├── Documentation.doxyfile ├── Documentation │ └── html │ │ └── index.html ├── Project_Headers │ ├── KinetisPowerModes.png │ ├── MKL25Z4.h │ ├── USBDM_Documentation.h │ ├── adc.h │ ├── bme.h │ ├── cmp.h │ ├── cmsis_gcc.h │ ├── console.h │ ├── control.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── dac.h │ ├── delay.h │ ├── derivative.h │ ├── dma.h │ ├── error.h │ ├── flash.h │ ├── formatted_io.h │ ├── ftfa.h │ ├── gpio.h │ ├── hardware.h │ ├── i2c.h │ ├── llwu.h │ ├── lptmr.h │ ├── mcg.h │ ├── osc.h │ ├── pcr.h │ ├── pin_mapping.h │ ├── pit.h │ ├── pmc.h │ ├── rcm.h │ ├── rtc.h │ ├── smc.h │ ├── spi.h │ ├── stringFormatter.h │ ├── system.h │ ├── tpm.h │ ├── tsi.h │ ├── uart.h │ ├── uart_queue.h │ ├── usb.h │ ├── usb_defs.h │ ├── usb_endpoint.h │ └── utilities.h ├── Project_Settings │ ├── Linker_Files │ │ ├── Linker-rom.ld │ │ └── MemoryMap.ld │ └── mkl25_Debug_USBDM.launch ├── Sources │ ├── delay.cpp │ ├── ftfa.cpp │ ├── hardware.cpp │ ├── hardware.h │ ├── i2c.cpp │ ├── main.cpp │ ├── spi.cpp │ └── usbdmError.cpp └── Startup_Code │ ├── console.cpp │ ├── mcg_mkl.cpp │ ├── newlib_stubs.c │ ├── rtc.cpp │ ├── security.c │ ├── startup_ARMLtdGCC.S │ ├── system-gcc.cpp │ ├── system.cpp │ └── vectors.cpp ├── USBDM_JB16_V4_10 ├── .gitignore ├── C_Layout.hwl ├── Default.old0.mem ├── HC08_Full_Chip_Simulator.ini ├── MON08_Interface.ini ├── README.md ├── Sources │ ├── BDM.c │ ├── BDM.h │ ├── BDMCommon.c │ ├── BDMCommon.h │ ├── BDMMacros.h │ ├── BDM_RS08.c │ ├── BDM_RS08.h │ ├── Backup │ │ └── bdm_cf.c │ ├── CmdProcessing.c │ ├── CmdProcessing.h │ ├── CmdProcessingCFV1.c │ ├── CmdProcessingCFV1.h │ ├── CmdProcessingCFVx.h │ ├── CmdProcessingHCS.c │ ├── CmdProcessingHCS.h │ ├── Commands.h │ ├── Common.h │ ├── Configure.h │ ├── Derivative.h │ ├── ICP.c │ ├── ICP.h │ ├── OSBDME_JB16.h │ ├── OSBDM_JB16.h │ ├── Start08.c │ ├── TBDML(Swin)_JB16.h │ ├── TBDML_JB16.h │ ├── TargetDefines.h │ ├── USB.c │ ├── USB.h │ ├── USBDM_JB16.h │ ├── USBDefs.h │ ├── USBSPYDER_JB16.h │ ├── UserVectorTable.c │ ├── WTBDM_JB16.h │ ├── bdm_cf.h │ ├── bdmcfMacros.h │ ├── led.h │ ├── main.c │ └── main.h ├── USBDM_JB16_V4_10.mcp ├── cmd │ ├── HC08_Full_Chip_Simulator_Postload.cmd │ ├── HC08_Full_Chip_Simulator_Preload.cmd │ ├── HC08_Full_Chip_Simulator_Reset.cmd │ ├── HC08_Full_Chip_Simulator_Startup.cmd │ ├── MON08_Interface_Postload.cmd │ ├── MON08_Interface_Preload.cmd │ ├── MON08_Interface_Reset.cmd │ └── MON08_Interface_Startup.cmd └── prm │ ├── Project.prm │ └── burner.bbl ├── USBDM_JMxx_V4_12 ├── .cproject ├── .cwGeneratedFileSetLog ├── .gitignore ├── .project ├── .settings │ └── com.freescale.core.ide.newprojectwizard.prefs ├── Collect.cmd ├── Collect_Images ├── Configure │ ├── Configure.h │ ├── USBDM_CF_JMxxCLD.h │ ├── USBDM_CF_JS16CWJ.h │ ├── USBDM_CF_SER_JMxxCLD.h │ ├── USBDM_CF_SER_JS16CWJ.h │ ├── USBDM_JMxxCLC.h │ ├── USBDM_JMxxCLD.h │ ├── USBDM_JMxx_56F8006Demo.h │ ├── USBDM_JS16CWJ.h │ ├── USBDM_SER_JS16CWJ.h │ ├── USBDM_SWD_JS16CWJ.h │ ├── USBDM_SWD_SER_JS16CWJ.h │ ├── USBDM_TWR.h │ ├── USBDM_TWR_CFV1.h │ ├── USBDM_TWR_CFVx.h │ ├── USBDM_TWR_HCS08.h │ ├── USBDM_TWR_HCS12.h │ ├── USBDM_TWR_Kinetis.h │ └── main.h ├── External_Documentation_V4.doxyfile ├── FlashImages │ ├── JMxx │ │ ├── USBDM_CF_JMxxCLD_V4.sx │ │ ├── USBDM_CF_SER_JMxxCLD_V4.sx │ │ ├── USBDM_JMxxCLC_V4.sx │ │ ├── USBDM_JMxxCLD_V4.sx │ │ └── USBDM_JMxx_MC56F8006Demo_V4.sx │ ├── JS16 │ │ ├── USBDM_CF_JS16CWJ_V4.sx │ │ ├── USBDM_CF_SER_JS16CWJ_V4.sx │ │ ├── USBDM_JS16CWJ_V4.sx │ │ ├── USBDM_SER_JS16CWJ_V4.sx │ │ ├── USBDM_SWD_JS16CWJ_V4.sx │ │ └── USBDM_SWD_SER_JS16CWJ_V4.sx │ └── Tower │ │ ├── USBDM_TWR_CFV1_V4.sx │ │ ├── USBDM_TWR_CFVx_V4.sx │ │ ├── USBDM_TWR_HCS08_V4.sx │ │ ├── USBDM_TWR_HCS12_V4.sx │ │ └── USBDM_TWR_KINETIS_V4.sx ├── GeneratedFiles │ ├── JMxx │ │ ├── USBDM_CF_JMxxCLD_V1.7.pdf │ │ ├── USBDM_CF_JMxxCLD_V3.pdf │ │ ├── USBDM_CF_JMxxCLD_V4.sx │ │ ├── USBDM_CF_SER_JMxxCLD_V4.sx │ │ ├── USBDM_JMxxCLC_V4.sx │ │ ├── USBDM_JMxxCLD.pdf │ │ ├── USBDM_JMxxCLD_V4.sx │ │ └── USBDM_JMxx_MC56F8006Demo_V4.sx │ ├── JS16 │ │ ├── USBDM_CF_JS16CWJ.pdf │ │ ├── USBDM_CF_JS16CWJ_V4.sx │ │ ├── USBDM_CF_SER_JS16CWJ.pdf │ │ ├── USBDM_CF_SER_JS16CWJ_V4.sx │ │ ├── USBDM_JS16CWJ.pdf │ │ ├── USBDM_JS16CWJ_V4.sx │ │ ├── USBDM_SER_JS16CWJ.pdf │ │ ├── USBDM_SER_JS16CWJ_V4.sx │ │ ├── USBDM_SWD_JS16CWJ.pdf │ │ ├── USBDM_SWD_JS16CWJ_V4.sx │ │ ├── USBDM_SWD_SER_JS16CWJ.pdf │ │ └── USBDM_SWD_SER_JS16CWJ_V4.sx │ └── Tower │ │ ├── USBDM_TWR_CFV1_V4.sx │ │ ├── USBDM_TWR_CFVx_V4.sx │ │ ├── USBDM_TWR_HCS08_V4.sx │ │ ├── USBDM_TWR_HCS12_V4.sx │ │ └── USBDM_TWR_KINETIS_V4.sx ├── Lib │ ├── mc9s08jm16.c │ └── mc9s08js16.c ├── Project_Settings │ ├── Debugger │ │ ├── MC9S08JM60.mem │ │ ├── MC9S08JM60.tcl │ │ ├── MC9S08JS16.mem │ │ ├── MC9S08JS16.tcl │ │ └── USBDM_JMxx_USBDM.launch │ ├── Linker_Files │ │ ├── Project_JM.prm │ │ ├── Project_JM_CF.prm │ │ ├── Project_JS.prm │ │ ├── Project_JS_Boot.prm │ │ ├── Project_JS_CF.prm │ │ └── burner.bbl │ └── Startup_Code │ │ └── start08.c ├── README.md ├── RemoteLaunch │ └── results │ │ └── remotelaunch.log ├── RemoteSystemsTempFiles │ └── .project ├── SaAnalysispointsManager.apconfig ├── Sources │ ├── ARM.c │ ├── ARM.h │ ├── BDM.c │ ├── BDM.h │ ├── BDMCommon.c │ ├── BDMCommon.h │ ├── BDMMacros.h │ ├── BDM_CF.c │ ├── BDM_CF.h │ ├── BDM_RS08.c │ ├── BDM_RS08.h │ ├── CmdProcessing.c │ ├── CmdProcessing.h │ ├── CmdProcessingARM.c │ ├── CmdProcessingARM.h │ ├── CmdProcessingCFV1.c │ ├── CmdProcessingCFV1.h │ ├── CmdProcessingCFVx.c │ ├── CmdProcessingCFVx.h │ ├── CmdProcessingHCS.c │ ├── CmdProcessingHCS.h │ ├── CmdProcessingSWD.c │ ├── CmdProcessingSWD.h │ ├── Commands.h │ ├── Common.h │ ├── DummyUserVectorTable.c │ ├── EDOUT │ ├── ICP.c │ ├── ICP.h │ ├── ICP_USB.c │ ├── ICP_USB.h │ ├── JTAG.c │ ├── JTAGSequence.c │ ├── JTAGSequence.h │ ├── SCI.c │ ├── SCI.h │ ├── SCI_Debug.c │ ├── SCI_Debug.h │ ├── SPI.c │ ├── SPI.h │ ├── SWD.c │ ├── SWD.h │ ├── SaAnalysispointsManager.apconfig │ ├── TargetDefines.h │ ├── USB.c │ ├── USB.h │ ├── USBDefs.h │ ├── UserVectorTable.c │ ├── bdmcfMacros.h │ ├── main.c │ ├── main.h │ ├── stdbool.h │ └── stdint.h └── rseHostSettingsCache.xml ├── USBDM_Kinetis_OpenSDA_old ├── .cproject ├── .cwGeneratedFileSetLog ├── .gitignore ├── .project ├── Collect.cmd ├── Collect_Images ├── Project_Headers │ ├── BDM.h │ ├── BDMCommon.h │ ├── CDC.h │ ├── CmdProcessing.h │ ├── CmdProcessingSWD.h │ ├── Commands.h │ ├── Common.h │ ├── Configure.h │ ├── MK20D5.h │ ├── SPI.h │ ├── SWD.h │ ├── TargetDefines.h │ ├── USB.h │ ├── USBDM_OpenSDA.h │ ├── bitband.h │ ├── clock_configure.h │ ├── console.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── derivative.h │ ├── dspiColdfire.h │ ├── icp.h │ ├── leds.h │ ├── system.h │ ├── usb_defs.h │ └── utilities.h ├── Project_Settings │ ├── Debugger │ │ └── USBDM_Kinetis_USBDM.launch │ └── Linker_Files │ │ ├── ARMLtd_GCC-rom.ld │ │ ├── MemoryMap-mk20dx128m5.ld │ │ ├── OpenSDA.ld │ │ ├── OpenSDAv2_0.ld │ │ └── OpenSDAv2_1.ld ├── README.md ├── RemoteSystemsTempFiles │ └── .project ├── Sources │ ├── BDMCommon.c │ ├── CDC.c │ ├── CmdProcessing.c │ ├── CmdProcessingSWD.c │ ├── SPI.c │ ├── SWD.c │ ├── USB.c │ └── main.c └── Startup_Code │ ├── clock.c │ ├── console.c │ ├── newlib_stubs.c │ ├── startup_ARMLtdGCC.S │ ├── system.c │ └── vectors.c └── Usbdm_Kinetis_OpenSDA_V5 ├── .cproject ├── .gitignore ├── .project ├── .settings └── org.eclipse.core.resources.prefs ├── Collect.cmd ├── Collect_Images ├── Configure.usbdmProject ├── Documentation.doxyfile ├── Project_Headers ├── KinetisPowerModes.png ├── MK20D5.h ├── PowerModes.png ├── USBDM_Documentation.h ├── adc.h ├── bitband.h ├── cmp.h ├── cmsis_gcc.h ├── cmt.h ├── console.h ├── control.h ├── core_cm4.h ├── core_cmFunc.h ├── core_cmInstr.h ├── core_cmSimd.h ├── crc.h ├── delay.h ├── derivative.h ├── dma.h ├── dmamux.h ├── error.h ├── ewm.h ├── flash.h ├── fmc.h ├── formatted_io.h ├── ftfl.h ├── ftm.h ├── gpio.h ├── i2c.h ├── i2s.h ├── llwu.h ├── lptmr.h ├── mcg.h ├── mcm.h ├── osc.h ├── pcr.h ├── pdb.h ├── pin_mapping.h ├── pit.h ├── pmc.h ├── rcm.h ├── rtc.h ├── sim.h ├── smc.h ├── spi.h ├── stringFormatter.h ├── system.h ├── tsi.h ├── uart.h ├── uart_queue.h ├── usb.h ├── usb_defs.h ├── usb_endpoint.h ├── usbdcd.h ├── utilities.h ├── vref.h └── wdog.h ├── Project_Settings ├── Linker_Files │ ├── Linker-rom-OpenSDA.ld │ ├── Linker-rom.ld │ ├── MemoryMap-OpenSDA.ld │ ├── MemoryMap-OpenSDAv2_0.ld │ ├── MemoryMap-OpenSDAv2_1.ld │ └── MemoryMap.ld ├── Usbdm_Kinetis_OpenSDA_V5_Debug_USBDM.launch └── Usbdm_Kinetis_OpenSDA_V5_OpenSDAv1_USBDM.launch ├── Sources ├── .gitignore ├── Names.cpp ├── Names.h ├── USBDM_ErrorMessages.h ├── cmdProcessing.cpp ├── cmdProcessing.h ├── cmdProcessingSWD.cpp ├── cmdProcessingSWD.h ├── commands.h ├── configure.h ├── delay.cpp ├── ftfl.cpp ├── hardware.h ├── interface.h ├── interfaceCommon.cpp ├── interfaceCommon.h ├── main.cpp ├── resetInterface.h ├── swd.cpp ├── swd.h ├── targetDefines.h ├── targetVddInterface.h ├── usb.cpp ├── usb_cdc_uart.h ├── usb_implementation.h ├── usb_implementation_composite.cpp └── usb_implementation_composite.h └── Startup_Code ├── console.cpp ├── mcg.cpp ├── newlib_stubs.c ├── rtc.cpp ├── security.c ├── startup_ARMLtdGCC.S ├── system-gcc.cpp ├── system.cpp └── vectors.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Release/ 3 | /.metadata/ 4 | /RemoteLaunch/ 5 | /RemoteSystemsTempFiles/ 6 | com.freescale.core.ide.cdt.toolchain.prefs 7 | /USBDM_Kinetis - Copy/ 8 | /mc9s08dn16/ 9 | /MC9S09PA4/ 10 | /MC9S12ZVCA192/ 11 | /MC9S12HY64/ 12 | /bdm_kinetis_mk22f/ 13 | /bdm_frdm (copy)/ 14 | /Delme/ 15 | /kl02_Test/ 16 | /kl03_Test/ 17 | /m20_Test/ 18 | /delme/ 19 | /frdm_kl25z/ 20 | /ReadFrdm/ 21 | -------------------------------------------------------------------------------- /BootLoopMK/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BootLoopMK 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 | net.sourceforge.usbdm.cdt.tools.cnature 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /BootLoopMK/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MK20DN32M5.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MK20DN32M5.h" 8 | -------------------------------------------------------------------------------- /BootLoopMK/Project_Settings/BootLoopMK-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /BootLoopMK/ReadMe.md: -------------------------------------------------------------------------------- 1 | BootLoopMK 2 | =========== 3 | 4 | This is an example file that can be programmed to the _target device_ on a FRDM_K board to disable the pins associated with the on-chip SWD interface. 5 | This allows the on-chip SWD interface to be used to program other chips. 6 | It requires the addition of a 10-pin SWD connector if not already on the board. 7 | -------------------------------------------------------------------------------- /BootLoopMK/Sources/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * main.c 4 | * 5 | * Created on: 04/12/2012 6 | * Author: podonoghue 7 | ============================================================================ 8 | */ 9 | #include 10 | #include "system.h" 11 | #include "derivative.h" 12 | #include "utilities.h" 13 | 14 | int main(void) { 15 | // Real programs never die! 16 | for(;;) { 17 | __asm__("wfi"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /BootLoopMKE/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BootLoopMKE 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /BootLoopMKE/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /BootLoopMKE/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MKE02Z16M2.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MKE02Z16M2.h" 8 | -------------------------------------------------------------------------------- /BootLoopMKE/Project_Settings/BootLoopMKE-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /BootLoopMKE/Project_Settings/Linker_Files/MemoryMap-mke02z16m2.ld: -------------------------------------------------------------------------------- 1 | /* MemoryMap.ld 2 | * 3 | * Memory map for devices without SRAM_U allocation for bit-band/bme 4 | */ 5 | 6 | /* ---- <<< Use Configuration Wizard in Context Menu >>> ---- */ 7 | 8 | /* Stack Size 9 | Required amount of stack space 10 | In CMSIS this will determine the ISR stack size 11 | <0x0-0x800> 12 | */ 13 | __stack_size = 0x200; 14 | 15 | /* Minimum Heap Size 16 | Actual heap may be larger as it fills all unused RAM up to STACK 17 | <0x0-0x800> 18 | */ 19 | __heap_size = 0x200; 20 | 21 | /* 22 | * Memory Map generated by USBDM New Project Wizard for MKE02Z16M2 23 | */ 24 | MEMORY 25 | { 26 | eeprom (r) : ORIGIN = 0x10000000, LENGTH = 0x00000100 27 | aips (rw) : ORIGIN = 0x40000000, LENGTH = 0x00080000 28 | gpio (rw) : ORIGIN = 0x400FF000, LENGTH = 0x00001000 29 | bme (rw) : ORIGIN = 0x44000000, LENGTH = 0x1C000000 30 | peripherals (rw) : ORIGIN = 0xE0000000, LENGTH = 0x00100000 31 | romTable (rw) : ORIGIN = 0xF0002000, LENGTH = 0x00001000 32 | mcm (rw) : ORIGIN = 0xF0003000, LENGTH = 0x00001000 33 | fgpio (rw) : ORIGIN = 0xF8000000, LENGTH = 0x08000000 34 | /* 35 | * FLASH address 36 | * FLASH size 37 | */ 38 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00004000 39 | /* 40 | * RAM address 41 | * RAM size 42 | */ 43 | ram (rwx) : ORIGIN = 0x1FFFFE00, LENGTH = 0x00000800 44 | /* Guard region above stack for GDB */ 45 | gdbGuard (r) : ORIGIN = 0x20000600, LENGTH = 0x00000020 46 | }; 47 | 48 | 49 | -------------------------------------------------------------------------------- /BootLoopMKE/Project_Settings/Linker_Files/MemoryMap-mke02z16m4.ld: -------------------------------------------------------------------------------- 1 | /* MemoryMap.ld 2 | * 3 | * Memory map for devices without SRAM_U allocation for bit-band/bme 4 | */ 5 | 6 | /* ---- <<< Use Configuration Wizard in Context Menu >>> ---- */ 7 | 8 | /* Stack Size 9 | Required amount of stack space 10 | In CMSIS this will determine the ISR stack size 11 | <0x0-0x800> 12 | */ 13 | __stack_size = 0x200; 14 | 15 | /* Minimum Heap Size 16 | Actual heap may be larger as it fills all unused RAM up to STACK 17 | <0x0-0x800> 18 | */ 19 | __heap_size = 0x200; 20 | 21 | /* 22 | * Memory Map generated by USBDM New Project Wizard for MKE02Z16M4 23 | */ 24 | MEMORY 25 | { 26 | unknown (r) : ORIGIN = 0x10000000, LENGTH = 0x00000100 27 | aips (rw) : ORIGIN = 0x40000000, LENGTH = 0x00080000 28 | gpio (rw) : ORIGIN = 0x400FF000, LENGTH = 0x00001000 29 | bme (rw) : ORIGIN = 0x44000000, LENGTH = 0x1C000000 30 | peripheral (rw) : ORIGIN = 0xE0000000, LENGTH = 0x00100000 31 | romTable (rw) : ORIGIN = 0xF0002000, LENGTH = 0x00001000 32 | mcm (rw) : ORIGIN = 0xF0003000, LENGTH = 0x00001000 33 | fgpio (rw) : ORIGIN = 0xF8000000, LENGTH = 0x08000000 34 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00004000 35 | ram (rwx) : ORIGIN = 0x1FFFFE00, LENGTH = 0x00000800 36 | /* Guard region above stack for GDB */ 37 | gdbGuard (r) : ORIGIN = 0x20000600, LENGTH = 0x00000020 38 | }; 39 | 40 | 41 | -------------------------------------------------------------------------------- /BootLoopMKE/ReadMe.md: -------------------------------------------------------------------------------- 1 | BootLoopMKE 2 | =========== 3 | 4 | This is an example file that can be programmed to the _target device_ on a FRDM_KE board to disable the pins associated with the on-chip SWD interface. 5 | This allows the on-chip SWD interface to be used to program other chips. 6 | It requires the addition of a 10-pin SWD connector if not already on the board. 7 | -------------------------------------------------------------------------------- /BootLoopMKE/Sources/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * main.c 4 | * 5 | * Created on: 04/12/2012 6 | * Author: podonoghue 7 | ============================================================================ 8 | */ 9 | #include 10 | #include "system.h" 11 | #include "derivative.h" 12 | #include "utilities.h" 13 | 14 | int main(void) { 15 | // Real programs never die! 16 | for(;;) { 17 | __asm__("wfi"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /BootLoopMKL/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BootLoopMKL 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /BootLoopMKL/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /BootLoopMKL/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MKL25Z32M4.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MKL25Z32M4.h" 8 | -------------------------------------------------------------------------------- /BootLoopMKL/Project_Settings/BootLoopMKL-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /BootLoopMKL/Project_Settings/Linker_Files/MemoryMap-mkl25z32m4.ld: -------------------------------------------------------------------------------- 1 | /* MemoryMap.ld 2 | * 3 | * Memory map for devices without SRAM_U allocation for bit-band/bme 4 | */ 5 | 6 | /* ---- <<< Use Configuration Wizard in Context Menu >>> ---- */ 7 | 8 | /* Stack Size 9 | Required amount of stack space 10 | In CMSIS this will determine the ISR stack size 11 | <0x0-0x1000> 12 | */ 13 | __stack_size = 0x400; 14 | 15 | /* Minimum Heap Size 16 | Actual heap may be larger as it fills all unused RAM up to STACK 17 | <0x0-0x1000> 18 | */ 19 | __heap_size = 0x400; 20 | 21 | /* 22 | * Memory Map generated by USBDM New Project Wizard for MKL25Z32M4 23 | */ 24 | MEMORY 25 | { 26 | aips (rw) : ORIGIN = 0x40000000, LENGTH = 0x00080000 27 | gpio (rw) : ORIGIN = 0x400FF000, LENGTH = 0x00001000 28 | bme (rw) : ORIGIN = 0x44000000, LENGTH = 0x1C000000 29 | peripherals (rw) : ORIGIN = 0xE0000000, LENGTH = 0x00100000 30 | mtb (rw) : ORIGIN = 0xF0000000, LENGTH = 0x00001000 31 | mtbdwt (rw) : ORIGIN = 0xF0001000, LENGTH = 0x00001000 32 | romTable (rw) : ORIGIN = 0xF0002000, LENGTH = 0x00001000 33 | mcm (rw) : ORIGIN = 0xF0003000, LENGTH = 0x00001000 34 | fgpio (rw) : ORIGIN = 0xF8000000, LENGTH = 0x08000000 35 | /* 36 | * FLASH address 37 | * FLASH size 38 | */ 39 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00008000 40 | /* 41 | * RAM address 42 | * RAM size 43 | */ 44 | ram (rwx) : ORIGIN = 0x1FFFFC00, LENGTH = 0x00001000 45 | /* Guard region above stack for GDB */ 46 | gdbGuard (r) : ORIGIN = 0x20000C00, LENGTH = 0x00000020 47 | }; 48 | 49 | 50 | -------------------------------------------------------------------------------- /BootLoopMKL/ReadMe.md: -------------------------------------------------------------------------------- 1 | BootLoopMKL 2 | =========== 3 | 4 | This is an example file that can be programmed to the _target device_ on a FRDM_KL board to disable the pins associated with the on-chip SWD interface. 5 | This allows the on-chip SWD interface to be used to program other chips. 6 | It requires the addition of a 10-pin SWD connector if not already on the board. 7 | -------------------------------------------------------------------------------- /BootLoopMKL/Sources/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * main.c 4 | * 5 | * Created on: 04/12/2012 6 | * Author: podonoghue 7 | ============================================================================ 8 | */ 9 | #include 10 | #include "system.h" 11 | #include "derivative.h" 12 | #include "utilities.h" 13 | 14 | int main(void) { 15 | // Real programs never die! 16 | for(;;) { 17 | __asm__("wfi"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BootLoopMKL05_SWD_Disabled 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | 31 | Documentation.html 32 | 1 33 | PROJECT_LOC/Documentation/html/index.html 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Project_Headers/console.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file console.h (100.ARM_DeviceOptions/Project_Headers/console.h) 3 | * @brief Basic UART routines for console 4 | * @date 13 June 2015 5 | */ 6 | 7 | /* 8 | * ***************************** 9 | * *** DO NOT EDIT THIS FILE *** 10 | * ***************************** 11 | * 12 | * This file is generated automatically. 13 | * Any manual changes will be lost. 14 | */ 15 | 16 | #ifndef INCLUDE_USBDM_CONSOLE_H_ 17 | #define INCLUDE_USBDM_CONSOLE_H_ 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- 25 | 26 | // UART default baud rate 27 | // Used by default UART setup for stdio 28 | // Note: Manually change Custom value 29 | // <110=> 110 30 | // <300=> 300 31 | // <600=> 600 32 | // <1200=> 1200 33 | // <2400=> 2400 34 | // <4800=> 4800 35 | // <9600=> 9600 36 | // <14400=> 14400 37 | // <19200=> 19200 38 | // <28800=> 28800 39 | // <38400=> 38400 40 | // <56000=> 56000 41 | // <57600=> 57600 42 | // <115200=> 115200 43 | // <115200=> Default 44 | 45 | #ifndef DEFAULT_BAUD_RATE 46 | /** 47 | * Default baud rate for UART used for stdio 48 | */ 49 | #define DEFAULT_BAUD_RATE 115200 50 | #endif 51 | 52 | /** 53 | * The following functions are a C-wrapper used by the C library 54 | * low-level stdio support. 55 | */ 56 | /** 57 | * Initialises the Console 58 | */ 59 | void console_initialise(); 60 | /** 61 | * Set Console baud rate 62 | * 63 | * @param[in] baudRate - the baud rate to use 64 | */ 65 | void console_setBaudRate(int baudRate); 66 | /** 67 | * Transmits a single character over the Console (blocking) 68 | * 69 | * @param[in] ch - character to send 70 | */ 71 | void console_txChar(int ch); 72 | /** 73 | * Receives a single character over the Console (blocking) 74 | * 75 | * @return - character received 76 | */ 77 | int console_rxChar(void); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif /* INCLUDE_USBDM_CONSOLE_H_ */ 83 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MKL05Z4.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MKL05Z4.h" 8 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Project_Headers/leds.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file leds.h 3 | * @brief Basic LED control for demo boards 4 | * @date 13 June 2015 5 | */ 6 | #ifndef LEDS_H_ 7 | #define LEDS_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * @addtogroup Demo_board_LED_control_group Demo board LED control 15 | * @brief Basic functions for on-board LEDs 16 | * @{ 17 | */ 18 | 19 | /** 20 | * Turn on green LED 21 | */ 22 | void greenLedOn(void); 23 | /** 24 | * Turn off green LED 25 | */ 26 | void greenLedOff(void); 27 | /** 28 | * Toggle green LED 29 | */ 30 | void greenLedToggle(void); 31 | /** 32 | * Turn on red LED 33 | */ 34 | void redLedOn(void); 35 | /** 36 | * Turn off red LED 37 | */ 38 | void redLedOff(void); 39 | /** 40 | * Toggle red LED 41 | */ 42 | void redLedToggle(void); 43 | /** 44 | * Turn on blue LED 45 | */ 46 | void blueLedOn(void); 47 | /** 48 | * Turn off blue LED 49 | */ 50 | void blueLedOff(void); 51 | /** 52 | * Toggle blue LED 53 | */ 54 | void blueLedToggle(void); 55 | /** 56 | * Enable blue LED 57 | */ 58 | void blueLedEnable(void); 59 | /** 60 | * Disable blue LED 61 | */ 62 | void blueLedDisable(void); 63 | /** 64 | * Turn off orange LED 65 | */ 66 | void orangeLedOn(void); 67 | /** 68 | * Turn off orange LED 69 | */ 70 | void orangeLedOff(void); 71 | /** 72 | * Toggle orange LED 73 | */ 74 | void orangeLedToggle(void); 75 | /** 76 | * Initialise all LED 77 | */ 78 | void led_initialise(void); 79 | 80 | /** 81 | * @} 82 | */ /* end of group Demo_board_LED_control_group */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LEDS_H_ */ 89 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Project_Settings/BootLoopMKL05_SWD_Disabled_Debug_USBDM.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/ReadMe.md: -------------------------------------------------------------------------------- 1 | BootLoopMKL05_SWD_Disabled 2 | ========================== 3 | 4 | The BootLoopMKL05_SWD_Disabled.elf file can be used with a FRDM-KL05 board to enable the 5 | external programming interface without cutting tracks etc. This is necessary due to a hardware 6 | design fault with the board where the links are in the wrong location. 7 | 8 | It achieves this by disabling the SWD interface on the on-board KL05 so that it does not interfere with the 9 | external programming connector signals. 10 | This also disables programming of the target chip!!! 11 | To restore programming the chip must be erased (see below to restore). 12 | 13 | To use: 14 | - Program the USBDM firmware to the OpenSDA interface in the usual manner. 15 | - Use the USBDM programmer to program KL05_SWD_Disable.elf to the target KL05. 16 | - You can now use the external programming interface without changing any jumpers or links. 17 | 18 | To erase the chip - 19 | Pull PTB8 (=A0) low and then plug in the board. The firmware will erase itself. 20 | Note the chip will be mass-erased which leaves the chip secured but re-programmable. 21 | 22 | -------------------------------------------------------------------------------- /BootLoopMKL05_SWD_Disabled/Startup_Code/system-gcc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file system-gcc.cpp 3 | * 4 | * GCC specific code 5 | * 6 | * Created on: 25/5/2017 7 | */ 8 | #include 9 | 10 | /* Prevents the exception handling name demangling code getting pulled in */ 11 | namespace __gnu_cxx { 12 | void __verbose_terminate_handler() { 13 | abort(); 14 | } 15 | } 16 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void); 17 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void) { 18 | exit(1); 19 | } 20 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FRDM_KL25_POWER_ON_ERASE_CHALLENGE 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 | net.sourceforge.usbdm.cdt.usbdmNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 27 | 28 | 29 | 30 | Documentation.html 31 | 1 32 | PROJECT_LOC/Documentation/html/index.html 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file FRDM_KL25Z.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "FRDM_KL25Z.h" 8 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/Project_Settings/FRDM_KL25_POWER_ON_ERASE_CHALLENGE-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/Project_Settings/Linker_Files/MemoryMap-frdm_kl25z.ld: -------------------------------------------------------------------------------- 1 | /* MemoryMap.ld 2 | * 3 | * Memory map for devices without SRAM_U allocation for bit-band/bme 4 | */ 5 | 6 | /* ---- <<< Use Configuration Wizard in Context Menu >>> ---- */ 7 | 8 | /* Stack Size 9 | Required amount of stack space 10 | In CMSIS this will determine the ISR stack size 11 | <0x0-0x4000> 12 | */ 13 | __stack_size = 0x1000; 14 | 15 | /* Minimum Heap Size 16 | Actual heap may be larger as it fills all unused RAM up to STACK 17 | <0x0-0x4000> 18 | */ 19 | __heap_size = 0x1000; 20 | 21 | /* 22 | * Memory Map generated by USBDM New Project Wizard for FRDM_KL25Z 23 | */ 24 | MEMORY 25 | { 26 | aips (rw) : ORIGIN = 0x40000000, LENGTH = 0x00080000 27 | gpio (rw) : ORIGIN = 0x400FF000, LENGTH = 0x00001000 28 | bme (rw) : ORIGIN = 0x44000000, LENGTH = 0x1C000000 29 | peripherals (rw) : ORIGIN = 0xE0000000, LENGTH = 0x00100000 30 | mtb (rw) : ORIGIN = 0xF0000000, LENGTH = 0x00001000 31 | mtbdwt (rw) : ORIGIN = 0xF0001000, LENGTH = 0x00001000 32 | romTable (rw) : ORIGIN = 0xF0002000, LENGTH = 0x00001000 33 | mcm (rw) : ORIGIN = 0xF0003000, LENGTH = 0x00001000 34 | fgpio (rw) : ORIGIN = 0xF8000000, LENGTH = 0x08000000 35 | /* 36 | * FLASH address 37 | * FLASH size 38 | */ 39 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000 40 | /* 41 | * RAM address 42 | * RAM size 43 | */ 44 | ram (rwx) : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000 45 | /* Guard region above stack for GDB */ 46 | gdbGuard (r) : ORIGIN = 0x20003000, LENGTH = 0x00000020 47 | }; 48 | 49 | 50 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/ReadMe.md: -------------------------------------------------------------------------------- 1 | Example Project that secures a device and disables the SWD interface pins. 2 | It is intended as a test case of a difficult to erase device. 3 | Intended for a FRDM_KL25 board. 4 | The SWD interface will be re-enabled if the RESCUE pin (PTB0) is taken low. 5 | -------------------------------------------------------------------------------- /FRDM_KL25_POWER_ON_ERASE_CHALLENGE/Sources/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main implementation: use this 'C' sample to create your own application 3 | * 4 | */ 5 | 6 | #include "derivative.h" /* include peripheral declarations */ 7 | 8 | void recover(void) { 9 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; 10 | PORTA->PCR[0] = PORT_PCR_MUX(7); // Restore SWD-CLK 11 | PORTA->PCR[3] = PORT_PCR_MUX(7); // Restore SWD-DATA 12 | } 13 | 14 | void delay(void) { 15 | int i; 16 | for (i=0; i<100000; i++) { 17 | __asm("nop"); 18 | } 19 | } 20 | 21 | #define RED_LED (1<<18) 22 | #define GREEN_LED (1<<19) 23 | #define RESCUE (1<<0) 24 | 25 | int main(void) { 26 | // Just in case while testing 27 | // delay(); 28 | 29 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; 30 | PORTA->PCR[0] = PORT_PCR_MUX(1); // Disable SWD-CLK 31 | PORTA->PCR[3] = PORT_PCR_MUX(1); // Disable SWD-DATA 32 | PORTA->PCR[20] = PORT_PCR_MUX(1); // Enable RESET as a GPIO 33 | 34 | GPIOA->PDDR |= ((1<<0)|(1<<3)|(1<<20)); 35 | GPIOA->PCOR |= ((1<<0)|(1<<3)|(1<<20)); 36 | 37 | SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK; 38 | PORTB->PCR[18] = PORT_PCR_MUX(1)|PORT_PCR_DSE_MASK; 39 | PORTB->PCR[19] = PORT_PCR_MUX(1)|PORT_PCR_DSE_MASK; 40 | PORTB->PCR[0] = PORT_PCR_MUX(1)|PORT_PCR_PE_MASK|PORT_PCR_PS_MASK; 41 | GPIOB->PDDR |= RED_LED|GREEN_LED; 42 | GPIOB->PDDR &= ~RESCUE; 43 | 44 | 45 | for(;;) { 46 | if ((PORTA->PCR[0]&PORT_PCR_MUX(7)) != PORT_PCR_MUX(7)) { 47 | GPIOB->PTOR = RED_LED; 48 | GPIOB->PSOR = GREEN_LED; 49 | } 50 | else { 51 | GPIOB->PTOR = GREEN_LED; 52 | GPIOB->PSOR = RED_LED; 53 | } 54 | delay(); 55 | if ((GPIOB->PDIR&RESCUE) == 0) { 56 | recover(); 57 | } 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /FRDM_MK20_POWER_ON_ERASE_CHALLENGE/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FRDM_MK20_POWER_ON_ERASE_CHALLENGE 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 | net.sourceforge.usbdm.cdt.usbdmNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 27 | 28 | 29 | 30 | Documentation.html 31 | 1 32 | PROJECT_LOC/Documentation/html/index.html 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /FRDM_MK20_POWER_ON_ERASE_CHALLENGE/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file FRDM_K20D50M.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "FRDM_K20D50M.h" 8 | -------------------------------------------------------------------------------- /FRDM_MK20_POWER_ON_ERASE_CHALLENGE/Project_Settings/FRDM_MK20_POWER_ON_ERASE_CHALLENGE-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /FRDM_MK20_POWER_ON_ERASE_CHALLENGE/ReadMe.md: -------------------------------------------------------------------------------- 1 | Example Project that secures a device and disables the SWD interface pins. 2 | It is intended as a test case of a difficult to erase device. 3 | Intended for a FRDM_K20D50 board. 4 | The SWD interface will be re-enabled if the RESCUE pin (PTA12) is taken low. 5 | -------------------------------------------------------------------------------- /FRDM_MK20_POWER_ON_ERASE_CHALLENGE/Sources/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main implementation: use this 'C' sample to create your own application 3 | * 4 | */ 5 | 6 | #include "derivative.h" /* include peripheral declarations */ 7 | 8 | void recover(void) { 9 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; 10 | PORTA->PCR[0] = PORT_PCR_MUX(7); // Restore SWD-CLK 11 | PORTA->PCR[3] = PORT_PCR_MUX(7); // Restore SWD-DATA 12 | } 13 | 14 | void delay(void) { 15 | int i; 16 | for (i=0; i<100000; i++) { 17 | __asm("nop"); 18 | } 19 | } 20 | 21 | #define RED_LED (1<<3) // C.3 22 | //#define GREEN_LED (1<<4) // D.4 23 | #define BLUE_LED (1<<2) // A.2 24 | #define RESCUE (1<<12) // A.12 25 | 26 | int main(void) { 27 | // Just in case while testing 28 | delay(); 29 | 30 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; 31 | PORTA->PCR[0] = PORT_PCR_MUX(1); // Disable SWD-CLK 32 | PORTA->PCR[3] = PORT_PCR_MUX(1); // Disable SWD-DATA 33 | 34 | // Just to be difficult set all the SWD pins low 35 | GPIOA->PDDR |= ((1<<0)|(1<<3)|(1<<20)); 36 | GPIOA->PCOR |= ((1<<0)|(1<<3)|(1<<20)); 37 | 38 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK|SIM_SCGC5_PORTC_MASK|SIM_SCGC5_PORTD_MASK; 39 | 40 | PORTC->PCR[3] = PORT_PCR_MUX(1)|PORT_PCR_DSE_MASK; // RED 41 | PORTA->PCR[2] = PORT_PCR_MUX(1)|PORT_PCR_DSE_MASK; // BLUE 42 | 43 | PORTA->PCR[12] = PORT_PCR_MUX(1)|PORT_PCR_PE_MASK|PORT_PCR_PS_MASK; // RESCUE 44 | 45 | GPIOC->PDDR |= RED_LED; // C.3 46 | GPIOA->PDDR |= BLUE_LED; // A.2 47 | 48 | GPIOA->PDDR &= ~RESCUE; // A.12 49 | 50 | for(;;) { 51 | if ((PORTA->PCR[0]&PORT_PCR_MUX(7)) != PORT_PCR_MUX(7)) { 52 | GPIOC->PTOR = RED_LED; 53 | GPIOA->PSOR = BLUE_LED; 54 | } 55 | else { 56 | GPIOA->PTOR = BLUE_LED; 57 | GPIOC->PSOR = RED_LED; 58 | } 59 | delay(); 60 | if ((GPIOA->PDIR&RESCUE) == 0) { 61 | recover(); 62 | } 63 | } 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/.gitignore: -------------------------------------------------------------------------------- 1 | /OpenSDAv1/ 2 | /OpenSDAv2_0/ 3 | /OpenSDAv2_1/ 4 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenSDA_MassEraseKinetisTarget 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPI.h 3 | * 4 | * Created on: 07/08/2012 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef SPI_H_ 9 | #define SPI_H_ 10 | 11 | #include 12 | #include 13 | 14 | #define DEFAULT_SPI_FREQUENCY (1000) //!< Initial SPI frequency 1000 kHz 15 | 16 | extern volatile uint8_t bitDelay; //!< Required software delay used with SPI base Tx/Rx 17 | extern volatile uint8_t rxTiming1; //!< bdm_Rx timing constant #1 18 | extern volatile uint8_t txTiming1; //!< bdm_Tx timing constant #1 19 | 20 | void spi_init(uint32_t ctar0, uint32_t ctar1); 21 | void spi_finalise(void); 22 | uint8_t spi_setSpeed(uint16_t freq); 23 | 24 | uint8_t f_CMD_SPI_SET_SPEED(void); 25 | uint8_t f_CMD_SPI_GET_SPEED(void); 26 | 27 | extern uint32_t spiBaudValue; 28 | 29 | //! Set SPI.CTAR0 value (non-persistent) 30 | //! 31 | //! @param ctar 32-bit CTAR value (excluding baud) 32 | //! 33 | __forceinline 34 | static inline void spi_setCTAR0(uint32_t ctar) { 35 | SPI0->CTAR[0] = spiBaudValue|ctar; 36 | } 37 | 38 | //! Set SPI.CTAR1 value (non-persistent) 39 | //! 40 | //! @param ctar 32-bit CTAR value (excluding baud) 41 | //! 42 | __forceinline 43 | static inline void spi_setCTAR1(uint32_t ctar) { 44 | SPI0->CTAR[1] = spiBaudValue|ctar; 45 | } 46 | 47 | #endif /* SPI_H_ */ 48 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/SWD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SWD.h 3 | * 4 | * Created on: 04/08/2012 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef SWD_H_ 9 | #define SWD_H_ 10 | 11 | #include "Common.h" 12 | #include 13 | 14 | // Ack values displaced by offset introduced during read (left justified 8-bit value) 15 | #define SWD_ACK_OK (0x1) 16 | #define SWD_ACK_WAIT (0x2) 17 | #define SWD_ACK_FAULT (0x4) 18 | #define SWD_ACK_PROTOCOL (0x7) 19 | 20 | void swd_interfaceIdle(void); 21 | void swd_init(void); 22 | void swd_txIdle8(void); 23 | 24 | uint8_t swd_test(uint8_t *returnSize, uint8_t *buff); 25 | void swd_reset_capture_mass_erase(void); 26 | 27 | uint8_t swd_sendCommandWithWait(uint8_t command); 28 | 29 | uint8_t swd_connect(void); 30 | uint8_t swd_readReg(uint8_t command, uint8_t *data); 31 | uint8_t swd_writeReg(uint8_t command, const uint8_t *data); 32 | uint8_t swd_readAPReg(const uint8_t *address, uint8_t *buff); 33 | uint8_t swd_writeAPReg(const uint8_t *address, const uint8_t *buff); 34 | uint8_t swd_clearStickyError(void); 35 | uint8_t swd_abortAP(void); 36 | #endif /* SWD_H_ */ 37 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/console.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file console.h 3 | * @brief Basic UART routines for console 4 | * @date 13 June 2015 5 | */ 6 | #include 7 | 8 | /* 9 | * ***************************** 10 | * *** DO NOT EDIT THIS FILE *** 11 | * ***************************** 12 | * 13 | * This file is generated automatically. 14 | * Any manual changes will be lost. 15 | */ 16 | 17 | #ifndef CONSOLE_H_ 18 | #define CONSOLE_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * The following functions are a C-wrapper used by the C library 26 | * low-level stdio support. 27 | */ 28 | /** 29 | * Initialises the Console 30 | */ 31 | void console_initialise(); 32 | /** 33 | * Set Console baud rate 34 | * 35 | * @param baudRate - the baud rate to use 36 | */ 37 | void console_setBaudRate(int baudRate); 38 | /** 39 | * Transmits a single character over the Console (blocking) 40 | * 41 | * @param ch - character to send 42 | */ 43 | void console_txChar(int ch); 44 | /** 45 | * Receives a single character over the Console (blocking) 46 | * 47 | * @return - character received 48 | */ 49 | int console_rxChar(void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif /* CONSOLE_H_ */ 55 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file FRDM_K20D50M.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "FRDM_K20D50M.h" 8 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/leds.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file leds.h 3 | * @brief Basic LED control for demo boards 4 | * @date 13 June 2015 5 | */ 6 | #ifndef LEDS_H_ 7 | #define LEDS_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * @addtogroup Demo_board_LED_control_group Demo board LED control 15 | * @brief Basic functions for on-board LEDs 16 | * @{ 17 | */ 18 | 19 | /** 20 | * Turn on green LED 21 | */ 22 | void greenLedOn(void); 23 | /** 24 | * Turn off green LED 25 | */ 26 | void greenLedOff(void); 27 | /** 28 | * Toggle green LED 29 | */ 30 | void greenLedToggle(void); 31 | /** 32 | * Turn on red LED 33 | */ 34 | void redLedOn(void); 35 | /** 36 | * Turn off red LED 37 | */ 38 | void redLedOff(void); 39 | /** 40 | * Toggle red LED 41 | */ 42 | void redLedToggle(void); 43 | /** 44 | * Turn on blue LED 45 | */ 46 | void blueLedOn(void); 47 | /** 48 | * Turn off blue LED 49 | */ 50 | void blueLedOff(void); 51 | /** 52 | * Toggle blue LED 53 | */ 54 | void blueLedToggle(void); 55 | /** 56 | * Enable blue LED 57 | */ 58 | void blueLedEnable(void); 59 | /** 60 | * Disable blue LED 61 | */ 62 | void blueLedDisable(void); 63 | /** 64 | * Turn off orange LED 65 | */ 66 | void orangeLedOn(void); 67 | /** 68 | * Turn off orange LED 69 | */ 70 | void orangeLedOff(void); 71 | /** 72 | * Toggle orange LED 73 | */ 74 | void orangeLedToggle(void); 75 | /** 76 | * Initialise all LED 77 | */ 78 | void led_initialise(void); 79 | 80 | /** 81 | * @} 82 | */ /* end of group Demo_board_LED_control_group */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LEDS_H_ */ 89 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Headers/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * uart.h 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #include 9 | 10 | #ifndef UART_H_ 11 | #define UART_H_ 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void uart_initialise(int baudRate); 18 | void uart_txChar(int ch); 19 | int uart_rxChar(void); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #endif /* UART_H_ */ 25 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Project_Settings/OpenSDA_MassEraseKinetisTarget-Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/ReadMe.md: -------------------------------------------------------------------------------- 1 | OpenSDA_MassEraseKinetisTarget 2 | ============================== 3 | 4 | This is a small program that may be downloaded to a FRDM board using the bootloader. 5 | It then attempts to mass erase the target device. 6 | -------------------------------------------------------------------------------- /OpenSDA_MassEraseKinetisTarget/Sources/main.c: -------------------------------------------------------------------------------- 1 | #include "derivative.h" /* include peripheral declarations */ 2 | 3 | #include "BDMCommon.h" 4 | #include "Commands.h" 5 | #include "SPI.h" 6 | #include "SWD.h" 7 | 8 | void initPorts(void) { 9 | // Enable all port clocks 10 | SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK 11 | | SIM_SCGC5_PORTB_MASK 12 | | SIM_SCGC5_PORTC_MASK 13 | | SIM_SCGC5_PORTD_MASK 14 | | SIM_SCGC5_PORTE_MASK; 15 | ledInit(); 16 | } 17 | 18 | int main(void) 19 | { 20 | 21 | initPorts(); 22 | initTimers(); 23 | 24 | bdm_setTarget(T_ARM_SWD); 25 | spi_setSpeed(12000 /* kHz */); 26 | 27 | swd_reset_capture_mass_erase(); 28 | 29 | for(;;) { 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | USBDM 2 | ===== 3 | 4 | BDM firmware for USBDM BDMs 5 | 6 | Refer to sourceforge for release files 7 | 8 | Release files: http://sourceforge.net/projects/usbdm/files/ 9 | 10 | Documentation: http://usbdm.sourceforge.net/ 11 | 12 | The following projects are Codewarrior Eclipse project and should be imported into Codewarrior 10.6.4. 13 | 14 | USBDM_JMxx 15 | 16 | The project in the following directory is for Codewarrior for HC08 (non-eclipse version). 17 | 18 | USBDM_JB16_V4_10 19 | 20 | The remaining projects are intended for Eclipse, Kinetis Design Studio or MCUXpresso (all with USBDM plugin) 21 | 22 | USBDM_Kinetis etc 23 | 24 | -------------------------------------------------------------------------------- /TestClock_MK22F/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestClock_MK22F 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | 31 | Documentation.html 32 | 1 33 | copy_PROJECT_LOC/Documentation/html/index.html 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /TestClock_MK22F/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/KinetisPowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/TestClock_MK22F/Project_Headers/KinetisPowerModes.png -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/PowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/TestClock_MK22F/Project_Headers/PowerModes.png -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/control.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file control.h (180.ARM_Peripherals/Project_Headers/control.h) 3 | * @brief CONTROL routines 4 | * 5 | * @version V4.12.1.270 6 | * @date 20 November 2021 7 | */ 8 | #ifndef HEADER_CONTROL_H 9 | #define HEADER_CONTROL_H 10 | /* 11 | * ***************************** 12 | * *** DO NOT EDIT THIS FILE *** 13 | * ***************************** 14 | * 15 | * This file is generated automatically. 16 | * Any manual changes will be lost. 17 | */ 18 | 19 | namespace USBDM { 20 | 21 | /** 22 | * @addtogroup Control_Group CONTROL, Control 23 | * @brief Abstraction for Control 24 | * @{ 25 | */ 26 | 27 | 28 | /** 29 | * End CONTROL_Group 30 | * @} 31 | */ 32 | 33 | } // End namespace USBDM 34 | 35 | #endif /* HEADER_CONTROL_H */ 36 | 37 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MK22F51212.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MK22F51212.h" 8 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file flash.h (180.ARM_Peripherals/Project_Headers/flash.h) 3 | * @brief Flash support 4 | * 5 | * Created on: 21 Sep 2016 6 | * Author: podonoghue 7 | */ 8 | #include "ftfa.h" 9 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/osc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file osc.h (180.ARM_Peripherals/Project_Headers/osc.h) 3 | * @brief Oscillator interface 4 | * 5 | * @version V4.12.1.80 6 | * @date 13 April 2016 7 | */ 8 | 9 | #ifndef HEADER_OSC_H 10 | #define HEADER_OSC_H 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #include "pin_mapping.h" 20 | 21 | namespace USBDM { 22 | /** 23 | * @addtogroup OSC_Group OSC, Crystal Oscillator 24 | * @brief Abstraction for Crystal Oscillator 25 | * @{ 26 | */ 27 | 28 | /** 29 | * Template class providing interface to Oscillator 30 | * 31 | * @tparam info Information class for OSC 32 | * 33 | * @code 34 | * using osc = OscBase_T; 35 | * 36 | * osc::configure(); 37 | * 38 | * @endcode 39 | */ 40 | template 41 | class OscBase_T :public Info { 42 | 43 | private: 44 | /** Class to static check OSC signal is mapped to a pin - Assumes existence */ 45 | template class CheckPinMapped { 46 | private: 47 | // Check mapping - no need to check existence 48 | static constexpr bool Test1 = (Info::info[xtalPin].pinIndex >= PinIndex::MIN_PIN_INDEX); 49 | 50 | static_assert(Test1, "OSC XTAL/EXTAL signal is not mapped to a pin - Modify Configure.usbdm"); 51 | 52 | public: 53 | /// Dummy for inline checking 54 | static constexpr bool checker = false; 55 | }; 56 | 57 | protected: 58 | /** Hardware instance */ 59 | static constexpr HardwarePtr osc = Info::baseAddress; 60 | 61 | public: 62 | // No class Info found 63 | 64 | 65 | 66 | }; 67 | 68 | 69 | /** 70 | * End OSC_Group 71 | * @} 72 | */ 73 | } // End namespace USBDM 74 | 75 | #endif /* HEADER_OSC_H */ 76 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/sim.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sim.h (180.ARM_Peripherals/Project_Headers/sim.h) 3 | * @brief System Integration Module 4 | * 5 | * @version V4.12.1.210 6 | * @date 13 April 2016 7 | */ 8 | 9 | #ifndef HEADER_SIM_H 10 | #define HEADER_SIM_H 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #include "pin_mapping.h" 20 | 21 | namespace USBDM { 22 | 23 | /** 24 | * @addtogroup SIM_Group SIM, System Integration Module 25 | * @brief Abstraction for System Integration Module 26 | * @{ 27 | */ 28 | 29 | /** 30 | * @brief Template class representing the System Integration Module (SIM) 31 | * 32 | */ 33 | class Sim : public SimInfo { 34 | public: 35 | }; 36 | 37 | /** 38 | * End SIM_Group 39 | * @} 40 | */ 41 | 42 | } // End namespace USBDM 43 | 44 | #endif /* HEADER_SIM_H */ 45 | -------------------------------------------------------------------------------- /TestClock_MK22F/Project_Headers/vref.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vref.h (180.ARM_Peripherals/Project_Headers/vref.h) 3 | * @brief Voltage Reference 4 | * 5 | * @version V4.12.1.210 6 | * @date 13 April 2016 7 | * Author: podonoghue 8 | */ 9 | 10 | #ifndef HEADER_VREF_H 11 | #define HEADER_VREF_H 12 | /* 13 | * ***************************** 14 | * *** DO NOT EDIT THIS FILE *** 15 | * ***************************** 16 | * 17 | * This file is generated automatically. 18 | * Any manual changes will be lost. 19 | */ 20 | #include "derivative.h" 21 | #include "pin_mapping.h" 22 | 23 | namespace USBDM { 24 | 25 | /** 26 | * @addtogroup VREF_Group VREF, Voltage Reference 27 | * @brief C++ Class allowing access to Voltage Reference 28 | * @{ 29 | */ 30 | 31 | /** 32 | * Template class representing a Voltage Reference 33 | * 34 | * @tparam info Information class for VREF 35 | * 36 | * @code 37 | * using vref = VrefBase_T; 38 | * 39 | * vref::initialise(); 40 | * 41 | * @endcode 42 | */ 43 | template 44 | class VrefBase_T : public Info { 45 | 46 | CreatePeripheralPinChecker("VREF"); 47 | 48 | private: 49 | /** 50 | * This class is not intended to be instantiated 51 | */ 52 | VrefBase_T(const VrefBase_T&) = delete; 53 | VrefBase_T(VrefBase_T&&) = delete; 54 | 55 | public: 56 | /** Hardware instance pointer */ 57 | static constexpr HardwarePtr vref = Info::baseAddress; 58 | 59 | VrefBase_T() { 60 | }; 61 | 62 | public: 63 | 64 | // No class Info found 65 | /** 66 | * Enable Vref output pin as Vref output. 67 | * Configures all Pin Control Register (PCR) values 68 | */ 69 | static void setOutput() { 70 | CheckPinExistsAndIsMapped::check(); 71 | 72 | using Pcr = PcrTable_T; 73 | 74 | // Enable and map pin to Vref_out is needed 75 | Pcr::setPCR(); 76 | } 77 | }; 78 | 79 | 80 | /** 81 | * End VREF_Group 82 | * @} 83 | */ 84 | 85 | } // End namespace USBDM 86 | 87 | #endif /* HEADER_VREF_H */ 88 | -------------------------------------------------------------------------------- /TestClock_MK22F/Sources/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hardware.h (180.ARM_Peripherals/Sources/hardware.h) 3 | * 4 | * Main header file for USBDM library. 5 | * Generated code is included via this file. 6 | * 7 | * @version V4.12.1.270 8 | * @date 1 December 2021 9 | */ 10 | 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | 20 | #ifndef INCLUDE_USBDM_HARDWARE_H_ 21 | #define INCLUDE_USBDM_HARDWARE_H_ 22 | 23 | #include "error.h" 24 | #include "pin_mapping.h" 25 | #include "delay.h" 26 | #include "console.h" 27 | 28 | // No header file inclusions found 29 | 30 | namespace USBDM { 31 | 32 | /** 33 | * Map all configured pins to peripheral signals. 34 | * 35 | * PCRs of allocated pins are set according to settings in Configure.usbdmProject 36 | * 37 | * @note Only the lower 16-bits of the PCR registers are initialised 38 | */ 39 | extern void mapAllPins(); 40 | // /HARDWARE_H/Declarations not found 41 | } // End namespace USBDM 42 | 43 | #endif /* INCLUDE_USBDM_HARDWARE_H_ */ 44 | -------------------------------------------------------------------------------- /TestClock_MK22F/Sources/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file main.cpp (180.ARM_Peripherals/Sources/main.cpp) 4 | * @brief Basic C++ demo 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "mcg.h" 12 | 13 | // Allow access to USBDM methods without USBDM:: prefix 14 | using namespace USBDM; 15 | 16 | /** 17 | * See more examples in Snippets directory 18 | */ 19 | 20 | // LED connection - change as required 21 | using Led = GpioA<1,ActiveLow>; 22 | 23 | void report() { 24 | console.setBaudRate(defaultBaudRate); 25 | console.setWidth(10).setPadding(Padding_LeadingSpaces); 26 | console.write(SystemCoreClock).write(',').write(SystemBusClock).write(": ").writeln(Mcg::getClockModeName()); 27 | console.flushOutput(); 28 | } 29 | 30 | int main() { 31 | console.writeln("Starting\n"); 32 | 33 | Led::setOutput(); 34 | 35 | for(;;) { 36 | Led::toggle(); 37 | ClockConfig index = (ClockConfig)(rand()%8); 38 | report(); 39 | Mcg::clockTransition(Mcg::clockInfo[index]); 40 | } 41 | report(); 42 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_84MHz]); 43 | report(); 44 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEE_80MHz]); 45 | report(); 46 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPI_4MHz]); 47 | report(); 48 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPE_8MHz]); 49 | report(); 50 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_84MHz]); 51 | report(); 52 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FBE_8MHz]); 53 | report(); 54 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_PBE_8MHz]); 55 | report(); 56 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_PEE_48M]); 57 | report(); 58 | 59 | for(int count = 0;;count++) { 60 | Led::toggle(); 61 | waitMS(100); 62 | console.write(count).writeln(": Tick..."); 63 | } 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /TestClock_MK22F/Startup_Code/console.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file console.cpp (180.ARM_Peripherals/Startup_Code/console.cpp) 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #include "derivative.h" 9 | #include "system.h" 10 | #include "pin_mapping.h" 11 | #include "console.h" 12 | 13 | /* 14 | * ***************************** 15 | * *** DO NOT EDIT THIS FILE *** 16 | * ***************************** 17 | * 18 | * This file is generated automatically. 19 | * Any manual changes will be lost. 20 | */ 21 | 22 | namespace USBDM { 23 | 24 | #if USE_CONSOLE 25 | 26 | /** 27 | * Print simple log message to console 28 | * 29 | * @param msg Message to print 30 | */ 31 | void log_error(const char *msg) { 32 | (void)msg; 33 | console.WRITELN(msg); 34 | } 35 | 36 | /** 37 | * @addtogroup CONSOLE_Group Console 38 | * @brief Console serial interface 39 | * @{ 40 | */ 41 | 42 | // Console instance 43 | Console console; 44 | 45 | /* 46 | * Initialises the Console 47 | */ 48 | extern "C" 49 | void console_initialise() { 50 | console.initialise(); 51 | console.setBaudRate(defaultBaudRate); 52 | console.setEcho(); 53 | console.configureAllPins(); 54 | } 55 | 56 | 57 | 58 | /* 59 | * Set Console baud rate 60 | * 61 | * @param baudRate - the baud rate to use 62 | */ 63 | extern "C" 64 | void console_setBaudRate(int baudRate = defaultBaudRate) { 65 | console.setBaudRate(baudRate); 66 | } 67 | 68 | /* 69 | * Transmits a single character to Console 70 | * 71 | * @param ch - character to send 72 | */ 73 | extern "C" 74 | void console_txChar(int ch) { 75 | console.write((char)ch); 76 | } 77 | 78 | /* 79 | * Receives a single character from Console (blocking) 80 | * 81 | * @return - character received 82 | */ 83 | extern "C" 84 | int console_rxChar(void) { 85 | return console.readChar(); 86 | } 87 | 88 | /** 89 | * @} 90 | */ 91 | #else 92 | 93 | Console console; 94 | 95 | #endif /* USE_CONSOLE */ 96 | 97 | } // End namespace USBDM 98 | -------------------------------------------------------------------------------- /TestClock_MK22F/Startup_Code/rtc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file rtc.cpp (180.ARM_Peripherals/Startup_Code/rtc.cpp) 3 | * 4 | * Created on: 21/09/2013 5 | * Author: podonoghue 6 | */ 7 | 8 | #include 9 | #include "derivative.h" 10 | #include "rtc.h" 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #if false // /RTC/enablePeripheralSupport 20 | /* 21 | * To support time.h functions 22 | * 23 | * @param tp 24 | * @param tzp 25 | */ 26 | extern "C" __attribute__ ((__weak__)) 27 | int _gettimeofday(struct timeval *tp, void *) { 28 | // Enable RTC interface 29 | USBDM::Rtc::enableClock(); 30 | tp->tv_sec = USBDM::Rtc::getTime(); 31 | tp->tv_usec = 0; 32 | return 0; 33 | } 34 | 35 | /* 36 | * To support time.h functions 37 | * 38 | * @param tp 39 | * @param tzp 40 | */ 41 | extern "C" 42 | int settimeofday(const struct timeval *tp, const struct timezone *) { 43 | // Enable RTC interface 44 | USBDM::Rtc::enableClock(); 45 | USBDM::Rtc::setTime(tp->tv_sec); 46 | return 0; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /TestClock_MK22F/Startup_Code/system-gcc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file system-gcc.cpp (180.ARM_Peripherals/Startup_Code/system-gcc.cpp) 3 | * 4 | * GCC specific code 5 | * 6 | * Created on: 25/5/2017 7 | */ 8 | #include 9 | #include "pin_mapping.h" 10 | 11 | /* Prevents the exception handling name demangling code getting pulled in */ 12 | namespace __gnu_cxx { 13 | void __verbose_terminate_handler() { 14 | USBDM::setAndCheckErrorCode(USBDM::E_TERMINATED); 15 | } 16 | } 17 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void); 18 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void) { 19 | exit(1); 20 | } 21 | -------------------------------------------------------------------------------- /TestClock_MKL05/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestClock_MKL05 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | 31 | Documentation.html 32 | 1 33 | copy_PROJECT_LOC/Documentation/html/index.html 34 | 35 | 36 | 37 | 38 | copy_PROJECT_LOC 39 | $%7BPARENT-1-PROJECT_LOC%7D/klo5 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /TestClock_MKL05/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /TestClock_MKL05/Project_Headers/KinetisPowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/TestClock_MKL05/Project_Headers/KinetisPowerModes.png -------------------------------------------------------------------------------- /TestClock_MKL05/Project_Headers/control.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file control.h (180.ARM_Peripherals/Project_Headers/control.h) 3 | * @brief CONTROL routines 4 | * 5 | * @version V4.12.1.270 6 | * @date 20 November 2021 7 | */ 8 | #ifndef HEADER_CONTROL_H 9 | #define HEADER_CONTROL_H 10 | /* 11 | * ***************************** 12 | * *** DO NOT EDIT THIS FILE *** 13 | * ***************************** 14 | * 15 | * This file is generated automatically. 16 | * Any manual changes will be lost. 17 | */ 18 | 19 | namespace USBDM { 20 | 21 | /** 22 | * @addtogroup Control_Group CONTROL, Control 23 | * @brief Abstraction for Control 24 | * @{ 25 | */ 26 | 27 | 28 | /** 29 | * End CONTROL_Group 30 | * @} 31 | */ 32 | 33 | } // End namespace USBDM 34 | 35 | #endif /* HEADER_CONTROL_H */ 36 | 37 | -------------------------------------------------------------------------------- /TestClock_MKL05/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MKL05Z4.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MKL05Z4.h" 8 | -------------------------------------------------------------------------------- /TestClock_MKL05/Project_Headers/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file flash.h (180.ARM_Peripherals/Project_Headers/flash.h) 3 | * @brief Flash support 4 | * 5 | * Created on: 21 Sep 2016 6 | * Author: podonoghue 7 | */ 8 | #include "ftfa.h" 9 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/analogue-interrupt-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file analogue-interrupt-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Example showing use of a interrupts with an ADC channel 5 | * 6 | * Created on: 10/6/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "adc.h" 12 | 13 | using namespace USBDM; 14 | 15 | /* 16 | * Demonstrates conversion on a single channel with interrupts 17 | */ 18 | 19 | // Connection mapping - change as required 20 | // (ADC Ch(19) = light sensor on FRDM-K20 21 | using MyAdcChannel = Adc0::Channel<8>; 22 | using MyAdc = MyAdcChannel::OwningAdc; 23 | 24 | /** 25 | * NOTE: This is not a sensible approach 26 | * Using serial I/O in a ISR is very silly!!!! 27 | */ 28 | void handler(uint32_t result, int) { 29 | result = result/10; 30 | for (unsigned i=0; i; 26 | using JOYSTICK_Y = Adc0::Channel<9>; 27 | using JOYSTICK_K = GpioD<5, ActiveLow>; 28 | 29 | int main(void) { 30 | 31 | // Enable and configure ADC 32 | MyAdc::configure(AdcResolution_8bit_se); 33 | 34 | // Calibrate before use 35 | MyAdc::calibrate(); 36 | 37 | // Connect ADC channels to pins 38 | JOYSTICK_X::setInput(); 39 | JOYSTICK_Y::setInput(); 40 | 41 | // Connect and configure digital input pin 42 | JOYSTICK_K::setInput(PinPull_Up); 43 | 44 | for(;;) { 45 | int x = JOYSTICK_X::readAnalogue(); 46 | int y = JOYSTICK_Y::readAnalogue(); 47 | bool button = JOYSTICK_K::isPressed(); 48 | console.write("Joystick (X,Y,K) = ", x, ", ", y, ", ", button?"Pressed":"Released"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/bitband-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ================================================================================== 3 | * @file bitband-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Demonstration of use of ARM Cortex-M4 bitband region for variables 5 | * 6 | * Created on: 7/1/2022 7 | * Author: podonoghue 8 | * 9 | * @note It is necessary to allocate some space to bit-band use in configure.usbdm 10 | ================================================================================== 11 | */ 12 | #include "hardware.h" 13 | 14 | using namespace USBDM; 15 | 16 | /** 17 | * Allocate a pair of variables 18 | * - The first is located in .bitband_ram and is a conventional variable in RAM 19 | * - The second is located in .bitband and is a word->bit mapping to the first variable 20 | */ 21 | // Variable allocated in bit-band accessible region (.bitband_ram) 22 | // May be uint8_t, uint16_t or uint32_t 23 | __attribute__ ((section(".bitband_ram"))) 24 | uint8_t variable; 25 | 26 | // Each word of 'variable_bits' maps to an individual bit of 'variable' in bit-band region (.bitband) 27 | __attribute__ ((section(".bitband"))) 28 | uint32_t variable_bits[8*sizeof(variable)]; 29 | 30 | int main() { 31 | console.writeln("Starting\n"); 32 | 33 | // Note that variable is NOT initialised before entering main() 34 | variable = 0; 35 | 36 | // Set each bit in variable from LSB to MSB by writing '1' to variable_bits 37 | console.writeln("\nSetting each bit"); 38 | for (unsigned bitNum=0; bitNum'7')) { 30 | // Ignore invalid input 31 | continue; 32 | } 33 | SimClkoutSel simClkoutSel = (SimClkoutSel)SIM_SOPT2_CLKOUTSEL(ch-'0'); 34 | SimInfo::setClkout(simClkoutSel); 35 | console.write((char)ch).write(" : clkout = "); 36 | switch(simClkoutSel) { 37 | case SimClkoutSel_FlexBus : console.write("FlexBus \r"); break; 38 | case SimClkoutSel_Reserved1 : console.write("Reserved1\r"); break; 39 | case SimClkoutSel_Flash : console.write("Flash \r"); break; 40 | case SimClkoutSel_Lpo : console.write("Lpo 1kHz \r"); break; 41 | case SimClkoutSel_McgirClk : console.write("McgirClk \r"); break; 42 | case SimClkoutSel_RTC : console.write("RTC \r"); break; 43 | case SimClkoutSel_OscerClk0 : console.write("OscerClk0\r"); break; 44 | #ifdef USB_CLK_RECOVER_IRC_EN_REG_EN_MASK 45 | case SimClkoutSel_Irc48MHz : console.write("IRC 48MHz\r"); break; 46 | #endif 47 | default: break; 48 | } 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/dac-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file dac-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Basic C++ demo using DAC class 5 | * 6 | * Created on: 30/10/2018 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "dac.h" 12 | 13 | using namespace USBDM; 14 | 15 | // 100 samples 16 | static constexpr unsigned NUM_SAMPLES = 100; 17 | 18 | // Table of values for a sine wave 19 | static uint16_t sineTable[NUM_SAMPLES]; 20 | 21 | using Dac = Dac0; 22 | 23 | constexpr float PI = 3.14159265358979323846; 24 | 25 | /** 26 | * Fill sineTable with scaled sine waveform 27 | */ 28 | void initSineTable() { 29 | 30 | for (unsigned index = 0; index<(sizeof(sineTable)/sizeof(sineTable[0])); index++) { 31 | sineTable[index] = roundf(Dac::getRange() * (1 + sin(index*2*PI/NUM_SAMPLES))/2); 32 | } 33 | } 34 | 35 | /** 36 | * Configure DAC for simple software use 37 | */ 38 | static void configureDac() { 39 | 40 | // Basic configuration 41 | Dac::configure( 42 | DacReferenceSelect_Vdda, 43 | DacPower_High, 44 | DacTriggerSelect_Software); 45 | 46 | // No buffer 47 | Dac::configureBuffer( 48 | DacBufferMode_Disabled); 49 | 50 | // Connect output to pin (if necessary) 51 | Dac::setOutput(); 52 | } 53 | 54 | int main() { 55 | console.writeln("Starting"); 56 | 57 | initSineTable(); 58 | configureDac(); 59 | 60 | // Loop through DAC values 61 | for(;;) { 62 | for (unsigned i=0; i<(sizeof(sineTable)/sizeof(sineTable[0])); i++) { 63 | Dac::writeValue(sineTable[i]); 64 | waitUS(10); 65 | } 66 | } 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/digital-example1.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file digital-example1.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Basic C++ GPIO output example 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | 12 | using namespace USBDM; 13 | 14 | /* 15 | * Simple example flashing LEDs on digital outputs 16 | */ 17 | 18 | // Connection mapping - change as required 19 | using RedLED = GpioA<1, ActiveLow>; 20 | using GreenLED = GpioA<2, ActiveLow>; 21 | using BlueLED = GpioD<5, ActiveLow>; 22 | 23 | int main() { 24 | RedLED::setOutput( 25 | PinDriveStrength_High, 26 | PinDriveMode_PushPull, 27 | PinSlewRate_Slow); 28 | GreenLED::setOutput( 29 | PinDriveStrength_High, 30 | PinDriveMode_PushPull, 31 | PinSlewRate_Slow); 32 | BlueLED::setOutput( 33 | PinDriveStrength_High, 34 | PinDriveMode_PushPull, 35 | PinSlewRate_Slow); 36 | 37 | console.setEcho(EchoMode_Off); 38 | 39 | for(;;) { 40 | console.write("\rPress (R)ed or (G)reen or (B)lue :"); 41 | switch(console.readChar()) { 42 | case 'r': case 'R' : RedLED::toggle(); break; 43 | case 'g': case 'G' : GreenLED::toggle(); break; 44 | case 'b': case 'B' : BlueLED::toggle(); break; 45 | default: break; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/digital-example2.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file digital-example2.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Basic C++ GPIO input/output example 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | 12 | using namespace USBDM; 13 | 14 | /* 15 | * Simple Digital I/O example 16 | * 17 | * Echoes an external switch to an external LED 18 | * 19 | * Switch + LED 20 | * 1 x Digital input 21 | * 1 x Digital output 22 | * 23 | */ 24 | 25 | // Connection mapping - change as required 26 | using Switch = GpioB<17, ActiveLow>; 27 | using Led = GpioA<1, ActiveLow>; 28 | 29 | int main(void) { 30 | Led::setOutput( 31 | PinDriveStrength_High, 32 | PinDriveMode_PushPull, 33 | PinSlewRate_Slow); 34 | Switch::setInput( 35 | PinPull_Up, 36 | PinAction_None, 37 | PinFilter_Passive); 38 | 39 | for(;;) { 40 | Led::write(!Switch::read()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/hmc5883l-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file hmc5883l-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Demonstrates use of HMC5883L Magnetometer over I2C 5 | * @version V4.11.1.90 6 | * @author podonoghue 7 | * @note You may need to change the pin-mapping of the I2C interface 8 | ============================================================================ 9 | */ 10 | #include 11 | #include "system.h" 12 | #include "derivative.h" 13 | #include "hardware.h" 14 | #include "i2c.h" 15 | #include "hmc5883l.h" 16 | 17 | // Allows access to USBDM library name-space 18 | using namespace USBDM; 19 | 20 | /************************************************* 21 | * Global objects representing hardware 22 | **************************************************/ 23 | 24 | // I2C interface 25 | I2c0 i2c0; 26 | 27 | // Magnetometer via I2C 28 | HMC5883L magnetometer(i2c0); 29 | 30 | /**************************************************/ 31 | 32 | /** 33 | * Report magnetometer values 34 | * 35 | * @param magnetometer Magnetometer to use 36 | */ 37 | void report(HMC5883L &magnetometer) { 38 | int16_t compassX,compassY,compassZ; 39 | magnetometer.doMeasurement(&compassX, &compassY, &compassZ); 40 | console. 41 | write("X=").write(compassX). 42 | write("Y=").write(compassY). 43 | write("Z=").writeln(compassZ); 44 | } 45 | 46 | int main() { 47 | console.writeln("Starting"); 48 | 49 | uint32_t id = magnetometer.readID(); 50 | console.write("Device ID = ").write(id).writeln(" (should be 0x483433)\n"); 51 | 52 | // magnetometer.setGain(3); 53 | 54 | for(;;) { 55 | report(magnetometer); 56 | waitMS(120); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/i2c-example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file i2c-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Basic C++ demo of using I2C interface 5 | * 6 | * Created on: 10/6/2017 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "i2c.h" 12 | 13 | using namespace USBDM; 14 | 15 | // Address (LSB = R/W bit) 16 | static const unsigned I2C_ADDRESS = 0x1D<<1; 17 | static const unsigned I2C_SPEED = 400_kHz; 18 | 19 | // Declare I2C interface 20 | I2c0 i2c{I2C_SPEED, I2cMode_Polled}; 21 | 22 | int main() { 23 | #define SELECT 2 24 | 25 | for(;;) { 26 | #if SELECT == 0 27 | { 28 | /* 29 | * Transmits 4 bytes and receives 2 bytes using different buffers 30 | * This will use a repeated start at turnover 31 | */ 32 | static const uint8_t txData[] = { 0xA1,0xB2,0xC3,0xD4,}; 33 | uint8_t rxData[2] = {}; 34 | 35 | i2c.startTransaction(); 36 | i2c.txRx(I2C_ADDRESS, txData, rxData); 37 | i2c.endTransaction(); 38 | } 39 | #elif SELECT == 1 40 | { 41 | /* 42 | * Transmits 2 bytes and receives 4 bytes into same buffer 43 | * This will use a repeated start at turnover 44 | */ 45 | uint8_t data[4] = { 0xA1,0xB2, }; 46 | 47 | i2c.startTransaction(); 48 | i2c.txRx(I2C_ADDRESS, 2, sizeof(data), data); 49 | i2c.endTransaction(); 50 | } 51 | #elif SELECT == 2 52 | { 53 | /* 54 | * Transmits 4 bytes 55 | */ 56 | static const uint8_t data[] = { 0xA1,0xB2,0xC3,0xD4,}; 57 | 58 | i2c.startTransaction(); 59 | i2c.transmit(I2C_ADDRESS, data); 60 | i2c.endTransaction(); 61 | } 62 | #else 63 | { 64 | /* 65 | * Receive 4 bytes 66 | */ 67 | uint8_t data[4] = {}; 68 | 69 | i2c.startTransaction(); 70 | i2c.receive(I2C_ADDRESS, data); 71 | i2c.endTransaction(); 72 | } 73 | #endif 74 | waitMS(100); 75 | } 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/lptmr-example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file lptmr-example.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Basic C++ LPTMR demo 5 | * 6 | * Created on: 25/09/2017 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "lptmr.h" 12 | #include "smc.h" 13 | 14 | using namespace USBDM; 15 | 16 | /* 17 | * Low power timer (LPTMR) example 18 | * 19 | * Demonstrates use of timer call-back 20 | */ 21 | 22 | // Comment out the following line to use static interrupt handlers 23 | #define SET_HANDLERS_PROGRAMMATICALLY 24 | 25 | // Connection mapping - change as required 26 | using Led = GpioA<2, ActiveLow>; 27 | 28 | // Timer to use 29 | using Lptmr = Lptmr0; 30 | 31 | /** 32 | * This handler is set programmatically 33 | */ 34 | void flash(void) { 35 | Led::toggle(); 36 | } 37 | 38 | #ifndef SET_HANDLERS_PROGRAMMATICALLY 39 | /** 40 | * Example showing how to install a custom IRQ handler for the Lptmr. 41 | * This will avoid the time and space overhead of the USBDM call-back mechanism. 42 | */ 43 | namespace USBDM { 44 | 45 | template<> 46 | void Lptmr::irqHandler() { 47 | clearInterruptFlag(); 48 | Led::toggle(); 49 | } 50 | 51 | } 52 | #endif 53 | 54 | int main() { 55 | Led::setOutput(); 56 | 57 | // Enable LPTMR in time counting mode 58 | Lptmr::configureTimeCountingMode( 59 | LptmrResetOn_Compare, 60 | LptmrInterrupt_Enabled, 61 | LptmrClockSel_Lpoclk); 62 | 63 | // Set period of timer event 64 | Lptmr::setPeriod(2_s); 65 | 66 | #ifdef SET_HANDLERS_PROGRAMMATICALLY 67 | // This handler is set programmatically 68 | Lptmr::setCallback(flash); 69 | #endif 70 | 71 | Lptmr::enableNvicInterrupts(NvicPriority_Normal); 72 | 73 | // Check for errors so far 74 | checkError(); 75 | 76 | for(;;) { 77 | // Sleep between interrupts 78 | Smc::enterWaitMode(); 79 | console.writeln("Awake!"); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/lptmr-reaction-time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file lptmr-reaction-time.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Basic C++ LPTMR demo 5 | * Measures reaction time (no refinements!) 6 | * 7 | * Created on: 25/09/2017 8 | * Author: podonoghue 9 | ============================================================================ 10 | */ 11 | #include "hardware.h" 12 | #include "lptmr.h" 13 | #include "random" 14 | 15 | // Allow access to USBDM methods without USBDM:: prefix 16 | using namespace USBDM; 17 | 18 | // I/O connections - change as required 19 | using Led = GpioC<1,ActiveHigh>; 20 | using Button = GpioD<5,ActiveLow>; 21 | 22 | // Using LPTMR0 23 | using Timer = Lptmr0; 24 | 25 | int main() { 26 | 27 | Led::setOutput( 28 | PinDriveStrength_Low, 29 | PinDriveMode_PushPull, 30 | PinSlewRate_Slow); 31 | 32 | Button::setInput( 33 | PinPull_Up, 34 | PinAction_None, 35 | PinFilter_None); 36 | 37 | // 8MHz / 4096 => ~500 ns resolution 38 | Timer::configureTimeCountingMode( 39 | LptmrResetOn_Overflow, 40 | LptmrInterrupt_Disabled, 41 | LptmrClockSel_Oscerclk, 42 | LptmrPrescale_4096); 43 | 44 | for(;;) { 45 | Led::off(); 46 | waitMS(3000+rand()%4000); 47 | Led::on(); 48 | 49 | // This code assumes reasonable reaction times! 50 | uint32_t startTime = Timer::getCounterValue(); 51 | while (Button::isReleased()) { 52 | } 53 | uint32_t endTime = Timer::getCounterValue(); 54 | 55 | // Roll-over of the timer is not an issue as modulo arithmetic is used (uint32_t). 56 | uint32_t reactionTimeInTicks = endTime-startTime; 57 | float reactionTime = Timer::convertTicksToSeconds(reactionTimeInTicks); 58 | console.write("Your reaction time is ").write(reactionTime).writeln(" s"); 59 | } 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/mag3310-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file mag3310-example.cpp 4 | * @brief Demonstrates use of MAG3310 Magnetometer over I2C 5 | * @version V4.11.1.80 6 | * @author podonoghue 7 | * @note You may need to change the pin-mapping of the I2C interface 8 | ============================================================================ 9 | */ 10 | #include 11 | #include "system.h" 12 | #include "derivative.h" 13 | #include "hardware.h" 14 | #include "i2c.h" 15 | #include "mag3310.h" 16 | 17 | // Allows access to USBDM library name-space 18 | using namespace USBDM; 19 | 20 | /************************************************* 21 | * Global objects representing hardware 22 | **************************************************/ 23 | 24 | // I2C interface 25 | I2c0 i2c0; 26 | 27 | // Magnetometer via I2C 28 | MAG3310 magnetometer(i2c0); 29 | 30 | /**************************************************/ 31 | 32 | /** 33 | * Report magnetometer values 34 | * 35 | * @param magnetometer Magnetometer to use 36 | */ 37 | void report(MAG3310 &magnetometer) { 38 | int magStatus; 39 | int16_t magX,magY,magZ; 40 | magnetometer.readMagnetometerXYZ(magStatus, magX, magY, magZ); 41 | printf("s=0x%02X, mX=%10d, mY=%10d, mZ=%10d, ", magStatus, magX, magY, magZ); 42 | // Assumes the sensor is level 43 | printf("a=%d\n", (int)(180*atan2(magX, magY)/M_PI)); 44 | } 45 | 46 | int main() { 47 | printf("Starting\n"); 48 | 49 | uint8_t id = magnetometer.readID(); 50 | printf("Device ID = 0x%02X (should be 0xC4)\n", id); 51 | 52 | printf("Calibrating magnetometer\n" 53 | "Please rotate the board in all dimensions until complete (~20 s)\n"); 54 | magnetometer.calibrateMagnetometer(); 55 | 56 | for(;;) { 57 | report(magnetometer); 58 | waitMS(120); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/mcg-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file mcg-test.c 4 | * @brief Test Mcg configuration 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "mcg.h" 12 | 13 | /** 14 | * Test MCG 15 | */ 16 | 17 | using namespace USBDM; 18 | 19 | int main() { 20 | 21 | console.write(" SystemCoreClock = ").writeln(::SystemCoreClock); 22 | console.write(" SystemBusClock = ").writeln(::SystemBusClock); 23 | 24 | // These clocks are updated when the clock configuration changes 25 | console.write(" SystemCoreClock = ").writeln(USBDM::SystemCoreClock); 26 | console.write(" SystemBusClock = ").writeln(USBDM::SystemBusClock); 27 | console.write(" SystemMcgffClock = ").writeln(SystemMcgffClock); 28 | console.write(" SystemMcgFllClock = ").writeln(SystemMcgFllClock); 29 | console.write(" SystemMcgPllClock = ").writeln(SystemMcgPllClock); 30 | console.write(" SystemMcgOutClock = ").writeln(SystemMcgOutClock); 31 | // console.write(" SystemLpoClock = ").writeln(SystemLpoClock); 32 | 33 | // These clocks are determined dynamically 34 | console.write(" SystemMcgirClock = ").writeln(McgInfo::getMcgIrClock()); 35 | console.write(" SystemPeripheralClock = ").writeln(SimInfo::getPeripheralClock()); 36 | console.write(" SystemOscerClock = ").writeln(Osc0Info::getOscerClock()); 37 | console.write(" SystemErclk32kClock = ").writeln(SimInfo::getErc32kClock()); 38 | 39 | for(;;){ 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/mma8491q-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file mma8491q-example.cpp 4 | * @brief Demonstrates use of MMA8491q Accelerometer over I2C 5 | * @version V4.11.1.90 6 | * @author podonoghue 7 | * @note You may need to change the pin-mapping of the I2C interface 8 | ============================================================================ 9 | */ 10 | #include 11 | #include "system.h" 12 | #include "derivative.h" 13 | #include "hardware.h" 14 | #include "mma8491q.h" 15 | 16 | // Allows access to USBDM library name-space 17 | using namespace USBDM; 18 | 19 | /************************************************* 20 | * Global objects representing hardware 21 | **************************************************/ 22 | 23 | // I2C interface 24 | I2c0 i2c0; 25 | 26 | // Accelerometer via I2C 27 | // Enable pin will need adjustment e.g. 28 | // D8 => USBDM::GpioA<13> on FRDM-KL25 29 | // D8 => USBDM::GpioA<12> on FRDM-MK20D50 30 | MMA8491Q_T> accelerometer(i2c0); 31 | 32 | /**************************************************/ 33 | 34 | /** 35 | * Report accelerometer values 36 | * 37 | * @param accelerometer Accelerometer to use 38 | */ 39 | void report(MMA8491Q &accelerometer) { 40 | int accelStatus; 41 | int16_t accelX,accelY,accelZ; 42 | 43 | accelerometer.active(); 44 | waitMS(1000); 45 | accelerometer.readAccelerometerXYZ(accelStatus, accelX, accelY, accelZ); 46 | accelerometer.standby(); 47 | console. 48 | write("s=").write(accelStatus, Radix_16). 49 | write(", aX=").write(accelX). 50 | write(", aY=").write(accelY). 51 | write(", aZ=").writeln(accelZ); 52 | } 53 | 54 | int main() { 55 | printf("Starting\n"); 56 | 57 | report(accelerometer); 58 | printf("Doing simple calibration\n" 59 | "Make sure the device is level!\n"); 60 | 61 | waitMS(4000); 62 | 63 | accelerometer.calibrateAccelerometer(); 64 | 65 | // Make sure we have new values 66 | waitMS(100); 67 | 68 | printf("After calibration\n"); 69 | for(;;) { 70 | report(accelerometer); 71 | // waitMS(400); 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/pca9685-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file pca9685-example.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Demonstrates use of PCA9685 over I2C 5 | * @version V4.11.1.90 6 | * @author podonoghue 7 | * @note You may need to change the pin-mapping of the I2C interface 8 | ============================================================================ 9 | */ 10 | #include "system.h" 11 | #include "derivative.h" 12 | #include "hardware.h" 13 | #include "pca9685.h" 14 | 15 | // Allows access to USBDM library name-space 16 | using namespace USBDM; 17 | 18 | /************************************************* 19 | * Global objects representing hardware 20 | **************************************************/ 21 | 22 | // I2C interface 23 | I2c0 i2c0; 24 | 25 | // PCA9685 via I2C 26 | PCA9685 pca9685(i2c0); 27 | 28 | /**************************************************/ 29 | 30 | 31 | // LED connections 32 | #define RED_LED USBDM::gpio_LED_RED 33 | #define GREEN_LED USBDM::gpio_LED_GREEN 34 | 35 | int main() { 36 | 37 | pca9685.set_pin_high(3); 38 | pca9685.set_pin_pwm(3, 50); 39 | 40 | bool odd=true; 41 | for (;;) { 42 | odd = !odd; 43 | for (int i=0; i<15; i++) { 44 | if (odd) { 45 | pca9685.set_pin_high(i); 46 | } 47 | else { 48 | pca9685.set_pin_low(i); 49 | } 50 | } 51 | } 52 | // RED_LED::setOutput(); 53 | // GREEN_LED::setOutput(); 54 | // RED_LED::set(); 55 | // GREEN_LED::set(); 56 | // for(;;) { 57 | // RED_LED::toggle(); 58 | // delay(); 59 | // RED_LED::toggle(); 60 | // delay(); 61 | // GREEN_LED::toggle(); 62 | // delay(); 63 | // GREEN_LED::toggle(); 64 | // delay(); 65 | // } 66 | } 67 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/pit-example1.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file pit-example1.cpp (180.ARM_Peripherals/Snippets/) 4 | * @brief Programmable Interrupt Timer (PIT) Example 5 | * @author podonoghue 6 | * Toggles LED use PIT for delay. 7 | * This example uses busy-waiting so it not a practical solution 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "pit.h" 12 | 13 | using namespace USBDM; 14 | 15 | // Connection mapping - change as required 16 | // Led is assumed active-low 17 | using LED = GpioA<1, ActiveLow>; 18 | 19 | using Timer = Pit; 20 | using TimerChannel = Timer::Channel<0>; 21 | 22 | int main() { 23 | 24 | LED::setOutput(PinDriveStrength_High); 25 | 26 | // Enable PIT 27 | Timer::configure(); 28 | 29 | // Check for errors so far 30 | checkError(); 31 | 32 | for(;;) { 33 | // Delay in ticks using channel 0 34 | // This is a busy-waiting loop! 35 | TimerChannel::delay(100_ms); 36 | //console.writeln("Tick"); 37 | LED::toggle(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/pmc-example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * pmc-example.cpp 3 | * 4 | * Created on: 4 Jun 2019 5 | * Author: podonoghue 6 | */ 7 | #include "hardware.h" 8 | #include "pmc.h" 9 | #include "rcm.h" 10 | 11 | using namespace USBDM; 12 | 13 | __attribute__ ((section (".noinit"))) 14 | static bool pmcHandlerRan; 15 | 16 | /** 17 | * PMC call-back. 18 | * 19 | * Executes when PMC detect Warning or Reset Low-voltage events 20 | */ 21 | void callback(PmcInterruptReason reason) { 22 | pmcHandlerRan = true; 23 | 24 | switch(reason) { 25 | case PmcInterruptReason_LowVoltageDetect: 26 | for(;;) { 27 | // Wait here until reset occurs 28 | __asm__("nop"); 29 | } 30 | break; 31 | case PmcInterruptReason_LowVoltageWarning: 32 | console.writeln("PMC detected Low Voltage Warning level"); 33 | break; 34 | } 35 | } 36 | 37 | int main() { 38 | console.writeln("\n\nStarting"); 39 | 40 | if ((Rcm::getResetSource() & RcmSource_lvd) != 0) { 41 | console.writeln("========================================"); 42 | console.writeln("Reset due to low-voltage event"); 43 | if (pmcHandlerRan) { 44 | console.writeln("PMC handler ran before reset"); 45 | } 46 | else { 47 | console.writeln("PMC handler did not run before reset"); 48 | } 49 | console.writeln("========================================\n"); 50 | } 51 | // Need to manually set this variable as located in a non-initialised section 52 | pmcHandlerRan = false; 53 | 54 | console.write("Reset source = 0x"). 55 | write(Rcm::getResetSource(), Radix_16).write(" = "). 56 | writeln(Rcm::getResetSourceDescription()); 57 | 58 | Pmc::setCallback(callback); 59 | 60 | Pmc::enable(); 61 | Pmc::configureLowVoltageReset(PmcLowVoltageDetectAction_Interrupt, PmcLowVoltageDetectLevel_High); 62 | Pmc::configureLowVoltageWarning(PmcLowVoltageWarningAction_Interrupt, PmcLowVoltageWarningLevel_High); 63 | 64 | Pmc::enableNvicInterrupts(NvicPriority_Normal); 65 | 66 | for(;;) { 67 | console.writeln("Waiting for low-voltage event"); 68 | waitMS(100); 69 | } 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/rcm-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file rcm-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief RCM Example code 5 | * @date 12 Jul 2018 6 | ============================================================================ 7 | */ 8 | 9 | #include "hardware.h" 10 | #include "rcm.h" 11 | 12 | using namespace USBDM; 13 | 14 | int main() { 15 | console.writeln("Starting"); 16 | 17 | console.write("Reset source = 0x"). 18 | write(Rcm::getResetSource(), Radix_16).write(" = "). 19 | writeln(Rcm::getResetSourceDescription()); 20 | 21 | Rcm::configure( 22 | RcmResetPinRunWaitFilter_BusCLock, 23 | RcmResetPinStopFilter_LowPowerOscillator, 24 | RcmResetFilterBusClockCount_20); 25 | 26 | for(;;) { 27 | __asm__("nop"); 28 | } 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/tpm-pwm-example.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ============================================================================ 3 | * @file tpm-pwm-example.cpp 4 | * @brief Demo using Ftm class to implement a basic PWM output 5 | * 6 | * Created on: 10/6/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "tpm.h" 12 | 13 | using namespace USBDM; 14 | 15 | /** 16 | * Demonstrates use of the PWM outputs 17 | * 18 | * Uses PWM to change the brightness of an LED 19 | */ 20 | 21 | /* 22 | * This example is not supported on all targets as PWM feature may not be available 23 | * on the pins connected to the LEDs (e.g. K64F). 24 | * 25 | * The mapping of pins in may need to be changed to map PWM to LEDs as 26 | * preference was given to mapping to external pins on board (e.g. KL25Z). 27 | * 28 | */ 29 | // Connection mapping - change as required 30 | using Timer = Tpm2; 31 | using Led = Tpm2::Channel<1>; 32 | 33 | int main() { 34 | 35 | // Configure base TPM for left-aligned PWM 36 | Timer::configure( 37 | TpmMode_LeftAlign, 38 | TpmClockSource_Internal); 39 | 40 | /* 41 | * Change PWM period 42 | * Note - Setting the period affects all channels of the Timer 43 | */ 44 | Timer::setPeriod(5_us); 45 | 46 | // Configure channel as high-pulses 47 | Led::configure(TpmChMode_PwmHighTruePulses); 48 | 49 | // Configure pin associated with channel 50 | Led::setOutput(PinDriveStrength_High, PinDriveMode_PushPull, PinSlewRate_Slow); 51 | 52 | // Check if configuration failed 53 | checkError(); 54 | 55 | for(;;) { 56 | // Using percentage duty-cycle 57 | for (int i=1; i<=99; i++) { 58 | Led::setDutyCycle(i); 59 | waitMS(10); 60 | } 61 | // Using high-time 62 | for (int i=99; i>0; i--) { 63 | Led::setHighTime((i*5_us)/100.0); 64 | waitMS(10); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/uart-example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file uart-example.cpp (180.ARM_Peripherals/Snippets) 4 | * @brief Basic C++ demo of using UART interface 5 | * 6 | * Created on: 17 Jun 2018 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | /* 11 | * See also console-example.cpp since the console is usually mapped to one of the USBDM::Uart's 12 | * and all functions demonstrated are available on a USBDM::Uart as well. 13 | */ 14 | #include "hardware.h" 15 | #include "uart.h" 16 | 17 | 18 | using namespace USBDM; 19 | 20 | int main() { 21 | 22 | Uart0 uart; 23 | 24 | uart.configureAllPins(); 25 | 26 | uart.setBaudRate(115200); 27 | 28 | char aSingleCharacter; 29 | char aLineOfText[60]; 30 | uart.writeln("Hello from UART 0"); 31 | 32 | uart.setEcho(EchoMode_Off); 33 | uart.writeln("Please type any key (which will not be echoed)"); 34 | uart.read(aSingleCharacter); 35 | 36 | uart.setEcho(EchoMode_On); 37 | uart.writeln("Please press any key (which will be echoed)"); 38 | uart.read(aSingleCharacter); 39 | uart.writeln(); 40 | 41 | for(;;) { 42 | uart.setEcho(EchoMode_Off); 43 | uart.writeln("Please type a line of text terminated with enter (which will not be echoed)"); 44 | uart.gets(aLineOfText, sizeof(aLineOfText)); 45 | 46 | uart.setEcho(EchoMode_On); 47 | uart.writeln("Please type a line of text terminated with enter (which will be echoed)"); 48 | uart.gets(aLineOfText, sizeof(aLineOfText)); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /TestClock_MKL05/Snippets/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vector.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef SOURCES_VECTOR_H_ 9 | #define SOURCES_VECTOR_H_ 10 | 11 | namespace USBDM { 12 | 13 | class Vector { 14 | public: 15 | float x, y, z; 16 | 17 | constexpr Vector(float x, float y, float z) : x(x), y(y), z(z) { 18 | } 19 | virtual ~Vector() { 20 | } 21 | }; 22 | 23 | } /* namespace USBDM */ 24 | 25 | #endif /* SOURCES_VECTOR_H_ */ 26 | -------------------------------------------------------------------------------- /TestClock_MKL05/Sources/hardware.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hardware.cpp (generated from MK20D5.usbdmHardware) 3 | * @version 1.3.0 4 | * @brief Pin initialisation for MK20DX128VLF5 5 | * 6 | * ***************************** 7 | * *** DO NOT EDIT THIS FILE *** 8 | * ***************************** 9 | * 10 | * This file is generated automatically. 11 | * Any manual changes will be lost. 12 | */ 13 | 14 | #include "hardware.h" 15 | 16 | /** 17 | * Namespace enclosing USBDM classes 18 | */ 19 | namespace USBDM { 20 | 21 | /** 22 | * @addtogroup USBDM_Group USBDM Peripheral Interface 23 | * @brief Hardware Peripheral Interface and library 24 | * @{ 25 | */ 26 | 27 | /** 28 | * Startup code for C++ classes 29 | */ 30 | extern "C" void __attribute__((constructor)) cpp_initialise() { 31 | if constexpr (MapAllPinsOnStartup) { 32 | mapAllPins(); 33 | } 34 | } 35 | 36 | // No user object definitions found 37 | 38 | /** 39 | * Map all configured pins to peripheral signals. 40 | * 41 | * PCRs of allocated pins are set according to settings in Configure.usbdmProject 42 | * 43 | * @note Only the lower 16-bits of the PCR registers are initialised 44 | */ 45 | void mapAllPins() { 46 | #if false 47 | 48 | 49 | #endif 50 | 51 | 52 | #if defined(PCC_PCCn_CGC_MASK) 53 | PCC->PCC_PORTA = PCC_PCCn_CGC_MASK; 54 | PCC->PCC_PORTB = PCC_PCCn_CGC_MASK; 55 | #else 56 | enablePortClocks(PORTA_CLOCK_MASK|PORTB_CLOCK_MASK); 57 | #endif 58 | 59 | PORTA->GPCLR = ForceLockedPins|0x0000UL|PORT_GPCLR_GPWE(0x0018UL); 60 | PORTB->GPCLR = ForceLockedPins|0x0200UL|PORT_GPCLR_GPWE(0x0006UL); 61 | PORTB->GPCLR = ForceLockedPins|0x0220UL|PORT_GPCLR_GPWE(0x0018UL); 62 | 63 | if constexpr (ForceLockoutUnbondedPins) { 64 | PORTA->GPCLR = PinLock_Locked |0x0000UL|PORT_GPCLR_GPWE(0xC006UL); // Lockout unavailable pins 65 | PORTA->GPCHR = PinLock_Locked |0x0000UL|PORT_GPCHR_GPWE(0xFFFFUL); // Lockout unavailable pins 66 | PORTB->GPCLR = PinLock_Locked |0x0000UL|PORT_GPCLR_GPWE(0xC000UL); // Lockout unavailable pins 67 | PORTB->GPCHR = PinLock_Locked |0x0000UL|PORT_GPCHR_GPWE(0xFFFFUL); // Lockout unavailable pins 68 | } 69 | 70 | } 71 | /** 72 | * End group USBDM_Group 73 | * @} 74 | */ 75 | 76 | } // End namespace USBDM 77 | 78 | -------------------------------------------------------------------------------- /TestClock_MKL05/Sources/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hardware.h (180.ARM_Peripherals/Sources/hardware.h) 3 | * 4 | * Main header file for USBDM library. 5 | * Generated code is included via this file. 6 | * 7 | * @version V4.12.1.270 8 | * @date 1 December 2021 9 | */ 10 | 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | 20 | #ifndef INCLUDE_USBDM_HARDWARE_H_ 21 | #define INCLUDE_USBDM_HARDWARE_H_ 22 | 23 | #include "error.h" 24 | #include "pin_mapping.h" 25 | #include "delay.h" 26 | #include "console.h" 27 | 28 | // No header file inclusions found 29 | 30 | namespace USBDM { 31 | 32 | /** 33 | * Map all configured pins to peripheral signals. 34 | * 35 | * PCRs of allocated pins are set according to settings in Configure.usbdmProject 36 | * 37 | * @note Only the lower 16-bits of the PCR registers are initialised 38 | */ 39 | extern void mapAllPins(); 40 | // No user declarations found 41 | } // End namespace USBDM 42 | 43 | #endif /* INCLUDE_USBDM_HARDWARE_H_ */ 44 | -------------------------------------------------------------------------------- /TestClock_MKL05/Sources/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file main.cpp (180.ARM_Peripherals/Sources/main.cpp) 4 | * @brief Basic C++ demo 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "mcg.h" 12 | 13 | // Allow access to USBDM methods without USBDM:: prefix 14 | using namespace USBDM; 15 | 16 | /** 17 | * See more examples in Snippets directory 18 | */ 19 | 20 | // LED connection - change as required 21 | using Led = GpioB<8,ActiveLow>; 22 | 23 | void report() { 24 | console.setBaudRate(defaultBaudRate); 25 | console.setWidth(10).setPadding(Padding_LeadingSpaces); 26 | console.write(SystemCoreClock).write(',').write(SystemBusClock).write(": ").writeln(Mcg::getClockModeName()); 27 | } 28 | 29 | int main() { 30 | console.writeln("Starting\n"); 31 | 32 | Led::setOutput(); 33 | 34 | for(;;) { 35 | Led::toggle(); 36 | ClockConfig index = (ClockConfig)(rand()%6); 37 | report(); 38 | Mcg::clockTransition(Mcg::clockInfo[index]); 39 | } 40 | report(); 41 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_42MHz]); 42 | report(); 43 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEE_42MHz]); 44 | report(); 45 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPI_4MHz]); 46 | report(); 47 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPE_32kHz]); 48 | report(); 49 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_42MHz]); 50 | report(); 51 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FBE_33kHz]); 52 | report(); 53 | 54 | for(int count = 0;;count++) { 55 | Led::toggle(); 56 | waitMS(100); 57 | console.write(count).writeln(": Tick..."); 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /TestClock_MKL05/Startup_Code/console.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file console.cpp (180.ARM_Peripherals/Startup_Code/console.cpp) 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #include "derivative.h" 9 | #include "system.h" 10 | #include "pin_mapping.h" 11 | #include "console.h" 12 | 13 | /* 14 | * ***************************** 15 | * *** DO NOT EDIT THIS FILE *** 16 | * ***************************** 17 | * 18 | * This file is generated automatically. 19 | * Any manual changes will be lost. 20 | */ 21 | 22 | namespace USBDM { 23 | 24 | #if USE_CONSOLE 25 | 26 | /** 27 | * Print simple log message to console 28 | * 29 | * @param msg Message to print 30 | */ 31 | void log_error(const char *msg) { 32 | (void)msg; 33 | console.WRITELN(msg); 34 | } 35 | 36 | /** 37 | * @addtogroup CONSOLE_Group Console 38 | * @brief Console serial interface 39 | * @{ 40 | */ 41 | 42 | // Console instance 43 | Console console; 44 | 45 | /* 46 | * Initialises the Console 47 | */ 48 | extern "C" 49 | void console_initialise() { 50 | console.initialise(); 51 | console.setBaudRate(defaultBaudRate); 52 | console.setEcho(); 53 | console.configureAllPins(); 54 | } 55 | 56 | /* 57 | * Set Console baud rate 58 | * 59 | * @param baudRate - the baud rate to use 60 | */ 61 | extern "C" 62 | void console_setBaudRate(int baudRate = defaultBaudRate) { 63 | console.setBaudRate(baudRate); 64 | } 65 | 66 | /* 67 | * Transmits a single character to Console 68 | * 69 | * @param ch - character to send 70 | */ 71 | extern "C" 72 | void console_txChar(int ch) { 73 | console.write((char)ch); 74 | } 75 | 76 | /* 77 | * Receives a single character from Console (blocking) 78 | * 79 | * @return - character received 80 | */ 81 | extern "C" 82 | int console_rxChar(void) { 83 | return console.readChar(); 84 | } 85 | 86 | /** 87 | * @} 88 | */ 89 | #else 90 | 91 | Console console; 92 | 93 | #endif /* USE_CONSOLE */ 94 | 95 | } // End namespace USBDM 96 | -------------------------------------------------------------------------------- /TestClock_MKL05/Startup_Code/rtc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file rtc.cpp (180.ARM_Peripherals/Startup_Code/rtc.cpp) 3 | * 4 | * Created on: 21/09/2013 5 | * Author: podonoghue 6 | */ 7 | 8 | #include 9 | #include "derivative.h" 10 | #include "rtc.h" 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #ifdef USBDM_RTC_IS_DEFINED 20 | 21 | /* 22 | * To support time.h functions 23 | * 24 | * @param tp 25 | * @param tzp 26 | */ 27 | extern "C" __attribute__ ((__weak__)) 28 | int _gettimeofday(struct timeval *tp, void *) { 29 | // Start RTC if not already running 30 | USBDM::Rtc::initialise(); 31 | tp->tv_sec = USBDM::Rtc::getTime(); 32 | tp->tv_usec = 0; 33 | return 0; 34 | } 35 | 36 | /* 37 | * To support time.h functions 38 | * 39 | * @param tp 40 | * @param tzp 41 | */ 42 | extern "C" 43 | int settimeofday(const struct timeval *tp, const struct timezone *) { 44 | // Start RTC if not already running 45 | USBDM::Rtc::initialise(); 46 | USBDM::Rtc::setTime(tp->tv_sec); 47 | return 0; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /TestClock_MKL05/Startup_Code/system-gcc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file system-gcc.cpp (180.ARM_Peripherals/Startup_Code/system-gcc.cpp) 3 | * 4 | * GCC specific code 5 | * 6 | * Created on: 25/5/2017 7 | */ 8 | #include 9 | #include "pin_mapping.h" 10 | 11 | /* Prevents the exception handling name demangling code getting pulled in */ 12 | namespace __gnu_cxx { 13 | void __verbose_terminate_handler() { 14 | USBDM::setAndCheckErrorCode(USBDM::E_TERMINATED); 15 | } 16 | } 17 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void); 18 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void) { 19 | exit(1); 20 | } 21 | -------------------------------------------------------------------------------- /TestClock_MKL25/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestClock_MKL25 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | 31 | Documentation.html 32 | 1 33 | copy_PROJECT_LOC/Documentation/html/index.html 34 | 35 | 36 | 37 | 38 | copy_PROJECT_LOC 39 | $%7BPARENT-1-PROJECT_LOC%7D/mkl25 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /TestClock_MKL25/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Documentation Will Be Displayed Here 10 | 11 | 12 | 13 |
14 |

Placeholder documentation

15 |

This file will be replaced the first time you generate documentation using Doxygen

16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /TestClock_MKL25/Project_Headers/KinetisPowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/TestClock_MKL25/Project_Headers/KinetisPowerModes.png -------------------------------------------------------------------------------- /TestClock_MKL25/Project_Headers/control.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file control.h (180.ARM_Peripherals/Project_Headers/control.h) 3 | * @brief CONTROL routines 4 | * 5 | * @version V4.12.1.270 6 | * @date 20 November 2021 7 | */ 8 | #ifndef HEADER_CONTROL_H 9 | #define HEADER_CONTROL_H 10 | /* 11 | * ***************************** 12 | * *** DO NOT EDIT THIS FILE *** 13 | * ***************************** 14 | * 15 | * This file is generated automatically. 16 | * Any manual changes will be lost. 17 | */ 18 | 19 | namespace USBDM { 20 | 21 | /** 22 | * @addtogroup Control_Group CONTROL, Control 23 | * @brief Abstraction for Control 24 | * @{ 25 | */ 26 | 27 | 28 | /** 29 | * End CONTROL_Group 30 | * @} 31 | */ 32 | 33 | } // End namespace USBDM 34 | 35 | #endif /* HEADER_CONTROL_H */ 36 | 37 | -------------------------------------------------------------------------------- /TestClock_MKL25/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MKL25Z4.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MKL25Z4.h" 8 | -------------------------------------------------------------------------------- /TestClock_MKL25/Project_Headers/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file flash.h (180.ARM_Peripherals/Project_Headers/flash.h) 3 | * @brief Flash support 4 | * 5 | * Created on: 21 Sep 2016 6 | * Author: podonoghue 7 | */ 8 | #include "ftfa.h" 9 | -------------------------------------------------------------------------------- /TestClock_MKL25/Sources/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hardware.h (180.ARM_Peripherals/Sources/hardware.h) 3 | * 4 | * Main header file for USBDM library. 5 | * Generated code is included via this file. 6 | * 7 | * @version V4.12.1.270 8 | * @date 1 December 2021 9 | */ 10 | 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | 20 | #ifndef INCLUDE_USBDM_HARDWARE_H_ 21 | #define INCLUDE_USBDM_HARDWARE_H_ 22 | 23 | #include "error.h" 24 | #include "pin_mapping.h" 25 | #include "delay.h" 26 | #include "console.h" 27 | 28 | // No header file inclusions found 29 | 30 | namespace USBDM { 31 | 32 | /** 33 | * Map all configured pins to peripheral signals. 34 | * 35 | * PCRs of allocated pins are set according to settings in Configure.usbdmProject 36 | * 37 | * @note Only the lower 16-bits of the PCR registers are initialised 38 | */ 39 | extern void mapAllPins(); 40 | // No user declarations found 41 | } // End namespace USBDM 42 | 43 | #endif /* INCLUDE_USBDM_HARDWARE_H_ */ 44 | -------------------------------------------------------------------------------- /TestClock_MKL25/Sources/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | * @file main.cpp (180.ARM_Peripherals/Sources/main.cpp) 4 | * @brief Basic C++ demo 5 | * 6 | * Created on: 10/1/2016 7 | * Author: podonoghue 8 | ============================================================================ 9 | */ 10 | #include "hardware.h" 11 | #include "mcg.h" 12 | 13 | // Allow access to USBDM methods without USBDM:: prefix 14 | using namespace USBDM; 15 | 16 | /** 17 | * See more examples in Snippets directory 18 | */ 19 | 20 | // LED connection - change as required 21 | using Led = GpioB<18,ActiveLow>; 22 | 23 | void report() { 24 | console.setBaudRate(defaultBaudRate); 25 | console.setWidth(10).setPadding(Padding_LeadingSpaces); 26 | console.write(SystemCoreClock).write(',').write(SystemBusClock).write(": ").writeln(Mcg::getClockModeName()); 27 | console.flushOutput(); 28 | } 29 | 30 | int main() { 31 | console.writeln("Starting\n"); 32 | 33 | Led::setOutput(); 34 | 35 | for(;;) { 36 | Led::toggle(); 37 | report(); 38 | waitMS(100); 39 | Mcg::clockTransition(Mcg::clockInfo[(rand()%8)]); 40 | } 41 | report(); 42 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_42MHz]); 43 | report(); 44 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEE_40MHz]); 45 | report(); 46 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPI_4MHz]); 47 | report(); 48 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_BLPE_8MHz]); 49 | report(); 50 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FEI_42MHz]); 51 | report(); 52 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_FBE_8MHz]); 53 | report(); 54 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_PBE_8MHz]); 55 | report(); 56 | Mcg::clockTransition(Mcg::clockInfo[ClockConfig::ClockConfig_PEE_48M]); 57 | report(); 58 | 59 | for(int count = 0;;count++) { 60 | Led::toggle(); 61 | waitMS(100); 62 | console.write(count).writeln(": Tick..."); 63 | } 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /TestClock_MKL25/Startup_Code/console.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file console.cpp (180.ARM_Peripherals/Startup_Code/console.cpp) 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #include "derivative.h" 9 | #include "system.h" 10 | #include "pin_mapping.h" 11 | #include "console.h" 12 | 13 | /* 14 | * ***************************** 15 | * *** DO NOT EDIT THIS FILE *** 16 | * ***************************** 17 | * 18 | * This file is generated automatically. 19 | * Any manual changes will be lost. 20 | */ 21 | 22 | namespace USBDM { 23 | 24 | #if USE_CONSOLE 25 | 26 | /** 27 | * Print simple log message to console 28 | * 29 | * @param msg Message to print 30 | */ 31 | void log_error(const char *msg) { 32 | (void)msg; 33 | console.WRITELN(msg); 34 | } 35 | 36 | /** 37 | * @addtogroup CONSOLE_Group Console 38 | * @brief Console serial interface 39 | * @{ 40 | */ 41 | 42 | // Console instance 43 | Console console; 44 | 45 | /* 46 | * Initialises the Console 47 | */ 48 | extern "C" 49 | void console_initialise() { 50 | console.initialise(); 51 | console.setBaudRate(defaultBaudRate); 52 | console.setEcho(); 53 | console.configureAllPins(); 54 | } 55 | 56 | /* 57 | * Set Console baud rate 58 | * 59 | * @param baudRate - the baud rate to use 60 | */ 61 | extern "C" 62 | void console_setBaudRate(int baudRate = defaultBaudRate) { 63 | console.setBaudRate(baudRate); 64 | } 65 | 66 | /* 67 | * Transmits a single character to Console 68 | * 69 | * @param ch - character to send 70 | */ 71 | extern "C" 72 | void console_txChar(int ch) { 73 | console.write((char)ch); 74 | } 75 | 76 | /* 77 | * Receives a single character from Console (blocking) 78 | * 79 | * @return - character received 80 | */ 81 | extern "C" 82 | int console_rxChar(void) { 83 | return console.readChar(); 84 | } 85 | 86 | /** 87 | * @} 88 | */ 89 | #else 90 | 91 | Console console; 92 | 93 | #endif /* USE_CONSOLE */ 94 | 95 | } // End namespace USBDM 96 | -------------------------------------------------------------------------------- /TestClock_MKL25/Startup_Code/rtc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file rtc.cpp (180.ARM_Peripherals/Startup_Code/rtc.cpp) 3 | * 4 | * Created on: 21/09/2013 5 | * Author: podonoghue 6 | */ 7 | 8 | #include 9 | #include "derivative.h" 10 | #include "rtc.h" 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #ifdef USBDM_RTC_IS_DEFINED 20 | 21 | /* 22 | * To support time.h functions 23 | * 24 | * @param tp 25 | * @param tzp 26 | */ 27 | extern "C" __attribute__ ((__weak__)) 28 | int _gettimeofday(struct timeval *tp, void *) { 29 | // Start RTC if not already running 30 | USBDM::Rtc::initialise(); 31 | tp->tv_sec = USBDM::Rtc::getTime(); 32 | tp->tv_usec = 0; 33 | return 0; 34 | } 35 | 36 | /* 37 | * To support time.h functions 38 | * 39 | * @param tp 40 | * @param tzp 41 | */ 42 | extern "C" 43 | int settimeofday(const struct timeval *tp, const struct timezone *) { 44 | // Start RTC if not already running 45 | USBDM::Rtc::initialise(); 46 | USBDM::Rtc::setTime(tp->tv_sec); 47 | return 0; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /TestClock_MKL25/Startup_Code/system-gcc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file system-gcc.cpp (180.ARM_Peripherals/Startup_Code/system-gcc.cpp) 3 | * 4 | * GCC specific code 5 | * 6 | * Created on: 25/5/2017 7 | */ 8 | #include 9 | #include "pin_mapping.h" 10 | 11 | /* Prevents the exception handling name demangling code getting pulled in */ 12 | namespace __gnu_cxx { 13 | void __verbose_terminate_handler() { 14 | USBDM::setAndCheckErrorCode(USBDM::E_TERMINATED); 15 | } 16 | } 17 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void); 18 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void) { 19 | exit(1); 20 | } 21 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /USBDM_JB16_V4_10_Data/ 3 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/C_Layout.hwl: -------------------------------------------------------------------------------- 1 | OPEN source 0 0 60 85 2 | Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off 3 | OPEN assembly 60 0 40 31 4 | Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xC1AC 5 | OPEN procedure 0 39 60 17 6 | Procedure < attributes VALUES on,TYPES off 7 | OPEN register 60 31 40 25 8 | Register < attributes FORMAT AUTO,COMPLEMENT None 9 | OPEN memory 60 56 40 22 10 | Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x120 11 | OPEN data 0 56 60 22 12 | Data:1 < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 13 | OPEN data 0 78 60 22 14 | Data:2 < attributes SCOPE local,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 15 | OPEN command 60 78 40 22 16 | Command < attributes CACHESIZE 1000 17 | OPEN data 59 51 46 41 18 | Data:3 < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 19 | bckcolor 50331647 20 | font 'Courier New' 9 BLACK 21 | AUTOSIZE on 22 | ACTIVATE "Command" "Procedure" "Data:1" "Register" "Memory" "Source" "Assembly" "Data:2" "Data:3" 23 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Default.old0.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JB16_V4_10/Default.old0.mem -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/HC08_Full_Chip_Simulator.ini: -------------------------------------------------------------------------------- 1 | [Environment Variables] 2 | GENPATH={Project}Sources;{Compiler}lib\hc08c\device\src;{Compiler}lib\hc08c\device\include;{Compiler}lib\hc08c\device\asm_include;{Compiler}lib\hc08c\src;{Compiler}lib\hc08c\include;{Compiler}lib\hc08c\lib 3 | LIBPATH={Compiler}lib\hc08c\device\include;{Compiler}lib\hc08c\include 4 | OBJPATH={Project}bin 5 | TEXTPATH={Project}bin 6 | ABSPATH={Project}bin 7 | 8 | [HI-WAVE] 9 | Target=HC08FCS 10 | Layout=C_layout.hwl 11 | LoadDialogOptions=RUNANDSTOPAFTERLOAD="main" 12 | MainFrame=2,3,-1,-1,-1,-1,132,132,1092,693 13 | TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 14 | 15 | 16 | 17 | [HC08FCS] 18 | CMDFILE0=CMDFILE STARTUP ON ".\cmd\HC08_Full_Chip_Simulator_startup.cmd" 19 | CMDFILE1=CMDFILE RESET ON ".\cmd\HC08_Full_Chip_Simulator_reset.cmd" 20 | CMDFILE2=CMDFILE PRELOAD ON ".\cmd\HC08_Full_Chip_Simulator_preload.cmd" 21 | CMDFILE3=CMDFILE POSTLOAD ON ".\cmd\HC08_Full_Chip_Simulator_postload.cmd" 22 | SHOWPROT=0 23 | TRACE_ENABLEDISABLESTATE=0 24 | 25 | 26 | 27 | [PEDEBUG] 28 | CURRENTDEVICE=HC908JB16 29 | CURRENTMODE=1 30 | ASK_BEFORE_ERASING_FLASH=1 31 | AUTO_SYNC=1 32 | DO_INIT_PORTS=1 33 | 34 | 35 | 36 | 37 | 38 | [DEVICE] 39 | CHIPMODE=HC908JB16 40 | 41 | [HC908JB16] 42 | PROGRAMMING_ALGORITHM=0 43 | DOTRIM=1 44 | PRESERVE1_START=0 45 | PRESERVE1_END=0 46 | PRESERVE1_ACTIVE=0 47 | PRESERVE2_START=0 48 | PRESERVE2_END=0 49 | PRESERVE2_ACTIVE=0 50 | PRESERVE3_START=0 51 | PRESERVE3_END=0 52 | PRESERVE3_ACTIVE=0 53 | PRESERVE_EEPROM=0 54 | CUSTOM_TRIM=0 55 | NGS_TRIM_OVERRIDE_REFERENCE_FREQUENCY=0 56 | 57 | [SETTINGS] 58 | MEMORYSTART1=128 59 | MEMORYSTART2=0 60 | DEFAULT_SOURCE_PATH=C:\Program Files\Freescale\CodeWarrior for Microcontrollers V6.2\prog 61 | 62 | 63 | [CycleWin] 64 | XTAL=12000000 65 | 66 | 67 | [Recent Layout File List] 68 | File0=C:\Peter\Development\USBDM\USBDM_JB16_V2\C_Layout.hwl 69 | File1= 70 | File2= 71 | File3= 72 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/README.md: -------------------------------------------------------------------------------- 1 | Firmware for JB16 based BDMs 2 | Required Codewarrior for Microcontrollers (old version) 3 | 4 | Considered obsolete -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/BDM_RS08.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Header file for BDM routines. 3 | 4 | */ 5 | #ifndef _BDM_RS08_H_ 6 | #define _BDM_RS08_H_ 7 | 8 | U8 bdmSetVpp(U8 level ); 9 | 10 | #endif // _BDM_RS08_H_ 11 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/CmdProcessing.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Main command procedure for executing BDM commands received over the USB. 3 | */ 4 | #ifndef _CMDPROCESSING_H_ 5 | #define _CMDPROCESSING_H_ 6 | 7 | extern U8 commandExec(void); 8 | 9 | extern void commandLoop(void); 10 | extern U8 compatibleCommandExec(void); 11 | extern U8 debugCommandExec(void); 12 | extern U8 optionalReconnect(U8 when); 13 | 14 | extern U8 commandBuffer[]; // Buffer for USB command in, result out 15 | 16 | #ifdef __HC08__ 17 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 18 | #endif // __HC08__ 19 | extern U8 returnSize; // Size of command return result 20 | extern BDM_Option_t bdm_option; // Options for cable operation 21 | extern CableStatus_t cable_status; // Status of the BDM interface 22 | #pragma DATA_SEG DEFAULT 23 | 24 | #endif; -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/CmdProcessingCFV1.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGCFV1_H_ 2 | #define _CMDPROCESSINGCFV1_H_ 3 | 4 | U8 f_CMD_CF_WRITE_MEM(void); 5 | U8 f_CMD_CF_READ_MEM(void); 6 | U8 f_CMD_CF_WRITE_REG(void); 7 | U8 f_CMD_CF_READ_REG(void); 8 | U8 f_CMD_CF_WRITE_DREG(void); 9 | U8 f_CMD_CF_READ_DREG(void); 10 | U8 f_CMD_CF_WRITE_CREG(void); 11 | U8 f_CMD_CF_READ_CREG(void); 12 | U8 f_CMD_CF_WRITE_CSR2(void); 13 | U8 f_CMD_CF_READ_CSR2(void); 14 | U8 f_CMD_CF_WRITE_CSR3(void); 15 | U8 f_CMD_CF_READ_CSR3(void); 16 | 17 | #endif // _CMDPROCESSINGCFV1_H_ 18 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/CmdProcessingCFVx.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGCFVX_H_ 2 | #define _CMDPROCESSINGCFVX_H_ 3 | 4 | U8 f_CMD_CFVx_RESET(void); 5 | U8 f_CMD_CFVx_CONTROL_INTERFACE(void); 6 | U8 f_CMD_SPI_SET_SPEED(void); 7 | U8 f_CMD_SPI_GET_SPEED(void); 8 | 9 | #if (TARGET_CAPABILITY&CAP_CFVx) 10 | U8 f_CMD_CFVx_HALT(void); 11 | U8 f_CMD_CFVx_GO(void); 12 | U8 f_CMD_CFVx_STEP(void); 13 | U8 f_CMD_CFVx_READ_CREG(void); 14 | U8 f_CMD_CFVx_WRITE_CREG(void); 15 | U8 f_CMD_CFVx_READ_DREG(void); 16 | U8 f_CMD_CFVx_READ_STATUS_REG(void); 17 | U8 f_CMD_CFVx_WRITE_DREG(void); 18 | U8 f_CMD_CFVx_READ_REG(void); 19 | U8 f_CMD_CFVx_WRITE_REG(void); 20 | U8 f_CMD_CFVx_READ_MEM(void); 21 | U8 f_CMD_CFVx_WRITE_MEM(void); 22 | U8 f_CMD_CFVx_RESYNC(void); 23 | #endif 24 | #if (TARGET_CAPABILITY&(CAP_DSC|CAP_JTAG|CAP_ARM_JTAG)) 25 | U8 f_CMD_JTAG_GOTORESET(void); 26 | U8 f_CMD_JTAG_GOTOSHIFT(void); 27 | U8 f_CMD_JTAG_WRITE(void); 28 | U8 f_CMD_JTAG_READ(void); 29 | U8 f_CMD_JTAG_READ_WRITE(void); 30 | U8 f_CMD_JTAG_EXECUTE_SEQUENCE(void); 31 | U8 f_CMD_JTAG_RESET(void); 32 | #endif // (CAPABILITY&CAP_CFVx) 33 | 34 | #endif // _CMDPROCESSINGCFVX_H_ 35 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/CmdProcessingHCS.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGHCS_H_ 2 | #define _CMDPROCESSINGHCS_H_ 3 | 4 | U8 f_CMD_CONNECT(void); 5 | U8 f_CMD_SET_SPEED(void); 6 | U8 f_CMD_GET_SPEED(void); 7 | U8 f_CMD_CONTROL_INTERFACE(void); 8 | 9 | U8 f_CMD_READ_STATUS_REG(void); 10 | U8 f_CMD_WRITE_CONTROL_REG(void); 11 | 12 | U8 f_CMD_RESET(void); 13 | U8 f_CMD_STEP (void); 14 | U8 f_CMD_GO(void); 15 | U8 f_CMD_HALT(void); 16 | 17 | U8 f_CMD_HCS12_WRITE_REG(void); 18 | U8 f_CMD_HCS12_READ_REG(void); 19 | U8 f_CMD_HCS08_WRITE_REG(void); 20 | U8 f_CMD_HCS08_READ_REG(void); 21 | 22 | U8 f_CMD_HCS08_READ_MEM(void); 23 | U8 f_CMD_HCS08_WRITE_MEM(void); 24 | 25 | U8 f_CMD_HCS12_READ_MEM(void); 26 | U8 f_CMD_HCS12_WRITE_MEM(void); 27 | 28 | U8 f_CMD_WRITE_BD(void); 29 | U8 f_CMD_READ_BD(void); 30 | 31 | U8 f_CMD_WRITE_BKPT(void); 32 | U8 f_CMD_READ_BKPT(void); 33 | 34 | U8 f_CMD_SET_VPP(void); 35 | 36 | #endif // _CMDPROCESSINGHCS_H_ 37 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/Configure.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JB16_V4_10/Sources/Configure.h -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/Derivative.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: This file is recreated by the project wizard whenever the MCU is 3 | * changed and should not be edited by hand 4 | */ 5 | 6 | /* Include the derivative-specific header file */ 7 | #include 8 | 9 | 10 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/ICP.h: -------------------------------------------------------------------------------- 1 | #ifndef _ICP_H_ 2 | #define _ICP_H_ 3 | 4 | /*! Used to check for ICP during reset 5 | * 6 | * This function must be provided in user code. 7 | * It is called from the ICP boot code to 8 | * determine if the user code wants ICP on this 9 | * reset. 10 | * 11 | * See main.c. 12 | * 13 | * @return \n 14 | * 0 - normal boot \n 15 | * 1 - ICP boot 16 | */ 17 | extern U8 userDetectICP(void); 18 | 19 | #define ICP_FORCE_LOCATION (0xFFDE) 20 | /*! Force ICP execution on next reset 21 | ** 22 | ** This function is provided in the ICP flash area and 23 | ** accessed through a vector in a fixed location. 24 | ** This function may be called from user code to 25 | ** reboot into ICP mode 26 | */ 27 | #define forceICPReset (*(void(** far)(void)) ICP_FORCE_LOCATION) 28 | 29 | #define ICP_VERSION_SW_LOCATION (0xF800) 30 | #define ICP_VERSION_HW_LOCATION (ICP_VERSION_SW_LOCATION+1) 31 | /*! Version number of ICP boot code 32 | * 2 hex digits major.minor 33 | */ 34 | extern const U8 ICP_Version_SW; 35 | /*! Hardware Version number - see Configure.h 36 | * 2 hex digits 37 | * JM60 has +0x80 38 | */ 39 | extern const U8 ICP_Version_HW; 40 | 41 | //! Type for vector table entry 42 | typedef struct { 43 | char JMP; 44 | void (* const address)(void); 45 | } UserVector; 46 | 47 | 48 | #define USER_VECTORTABLE_LOCATION (0xF7CC) 49 | /* User vector table 50 | ** 51 | ** The vector table is relocated to the top of User Flash 52 | ** This is a jump table! 53 | ** 54 | ** See UserVectorTable.c 55 | ** 56 | */ 57 | extern const UserVector userVectorTable[17] @USER_VECTORTABLE_LOCATION; 58 | 59 | #endif -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/OSBDM_JB16.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration for the "Freescale OSBDM hardware". 3 | 4 | USBDM - Universal BDM, JB16 Version \n 5 | Configuration for Original Freescale OSBDM hardware, see 6 | @htmlonly Schematic @endhtmlonly \n 7 | Supports HC12, HCS08 and Coldfire V1 targets \n 8 | 9 | @note DO NOT CHANGE THIS FILE \n 10 | If you need to create another configuration make a copy of this file 11 | under a new name and change Configure.h appropropriately. 12 | */ 13 | // OSBDM & WTBDM hardware are the same 14 | #include "WTBDM_JB16.h" 15 | 16 | #undef ICP_PIN 17 | #undef ENABLE_ICP_PIN 18 | #undef DISABLE_ICP_PIN 19 | #undef TEST_ICP_PIN 20 | 21 | #define ICP_PIN (3<<0) // ICP Test input D.3 22 | #define ENABLE_ICP_PIN() (DDRD &= ~ICP_PIN) 23 | #define DISABLE_ICP_PIN() 24 | #define TEST_ICP_PIN() (~PTD & ICP_PIN) 25 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/TBDML(Swin)_JB16.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration for (minimal hardware TBDML - internal version). 3 | 4 | USBDM - Universal BDM, JB16 Version \n 5 | Based on Simplified TBDML (minimal hardware - internal version) - No details provided \n 6 | Supports HC12, HCS08 and Coldfire V1 targets \n 7 | 8 | @note DO NOT CHANGE THIS FILE \n 9 | If you need to create another configuration make a copy of this file 10 | under a new name and change Configure.h appropropriately. 11 | */ 12 | //==================================================================== 13 | #include "TBDML_JB16.h" // Identical hardware to TBDML 14 | 15 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/USB.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H_ 2 | #define _USB_H_ 3 | 4 | #include "Common.h" 5 | /* Public Functions */ 6 | void usb_init(void); 7 | 8 | extern void usb_isr(void); 9 | #endif -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/bdm_cf.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Header file for BDM routines. 3 | 4 | */ 5 | 6 | #ifndef _BDMCF_H_ 7 | #define _BDMCF_H_ 8 | 9 | 10 | #if (HW_CAPABILITY&CAP_CFVx_HW) 11 | 12 | //============================================================== 13 | // Shared interface 14 | void bdmcf_init(void); 15 | 16 | void bdm_suspend(void); 17 | void bdmCF_off(void); 18 | U16 bdm_targetVddMeasure(void); 19 | void bdmcf_interfaceIdle(void); 20 | U8 bdmCF_powerOnReset(void); 21 | void bdmCF_suspend(void); 22 | void bdmcf_interfaceIdle(void); 23 | 24 | //=============================================================== 25 | // Coldfire BDM mode interface 26 | U8 bdmcf_resync(void); 27 | U8 bdmcf_halt(void); 28 | U8 bdmcf_reset(U8 bkpt); 29 | U8 bdmcf_ta(U8 time_10us); 30 | U8 bdmcf_tx_msg(U16 data); 31 | U8 bdmcf_rx_msg(U16 *data); 32 | U8 bdmcf_txrx_msg(U16 *data); 33 | void bdmcf_tx(U8 count, U8 *data); 34 | U8 bdmcf_complete_chk(U16 next_cmd); 35 | U8 bdmcf_complete_chk_rx(void); 36 | U8 bdmcf_tx_msg_half_rx(U16 data); 37 | U8 bdmcf_rx(U8 count, U8 *data); 38 | U8 bdmcf_rxtx(U8 count, U8 *data, U16 next_cmd); 39 | U16 bdmcf_txRx16(U16 data); 40 | U8 spi_setSpeed(U16 freq); 41 | 42 | // Prototypes for the Rx and Tx functions 43 | void bdmcf_tx8_1(U8 data); 44 | U8 bdmcf_rx8_1(void); 45 | U8 bdmcf_txrx8_1(U8 data); 46 | U8 bdmcf_txrx_start(void); 47 | #endif 48 | 49 | #if (HW_CAPABILITY&CAP_CFVx_HW) || (HW_CAPABILITY&CAP_JTAG_HW) 50 | //================================================================= 51 | // JTAG mode interface 52 | U8 spi_setSpeed(U16 freq); 53 | void jtag_interfaceIdle(void); 54 | void jtag_init(void); 55 | void jtag_off(void); 56 | void jtag_transition_reset(void); 57 | void jtag_transition_shift(U8 mode); 58 | void jtag_write(U8 tap_transition, U8 bit_count, const U8 *writePtr); 59 | void jtag_read(U8 tap_transition, U8 bit_count, U8 *readPtr); 60 | void jtag_read_write(U8 transitionToIdle, U8 bitCount, const U8 *writePtr, U8 *readPtr); 61 | void jtag_set_hdr(U16 value); 62 | void jtag_set_hir(U16 value); 63 | void jtag_set_tdr(U16 value); 64 | void jtag_set_tir(U16 value); 65 | #endif 66 | 67 | #endif // _BDMCF_H_ 68 | 69 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/bdmcfMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef _BDMCFMACROS_H_ 2 | #define _BDMCFMACROS_H_ 3 | 4 | //================================================================================= 5 | /* BDM commands */ 6 | #define BDMCF_RETRY 40 /* how many times to retry before giving up */ 7 | #define BDMCF_CMD_NOP 0x0000 8 | #define BDMCF_CMD_GO 0x0C00 9 | #define BDMCF_CMD_RDMREG 0x2D80 10 | #define BDMCF_CMD_WDMREG 0x2C80 11 | #define BDMCF_CMD_RCREG 0x2980 12 | #define BDMCF_CMD_WCREG 0x2880 13 | #define BDMCF_CMD_RAREG 0x2180 14 | #define BDMCF_CMD_WAREG 0x2080 15 | #define BDMCF_CMD_READ8 0x1900 16 | #define BDMCF_CMD_READ16 0x1940 17 | #define BDMCF_CMD_READ32 0x1980 18 | #define BDMCF_CMD_WRITE8 0x1800 19 | #define BDMCF_CMD_WRITE16 0x1840 20 | #define BDMCF_CMD_WRITE32 0x1880 21 | #define BDMCF_CMD_DUMP8 0x1D00 22 | #define BDMCF_CMD_DUMP16 0x1D40 23 | #define BDMCF_CMD_DUMP32 0x1D80 24 | #define BDMCF_CMD_FILL8 0x1C00 25 | #define BDMCF_CMD_FILL16 0x1C40 26 | #define BDMCF_CMD_FILL32 0x1C80 27 | 28 | //=============================================================================== 29 | // Response from BDM communication 30 | // Status-bit value - 1st bit of Rx value 31 | #define BDMCF_STATUS_OK 0 32 | 33 | // LSB of data value when S==BDMCF_STATUS_OK 34 | #define BDMCF_RES_OK 0xFFFF 35 | // LSB of data value when S!=BDMCF_STATUS_OK 36 | #define BDMCF_RES_NOT_READY 0x0000 37 | #define BDMCF_RES_BUS_ERROR 0x0001 38 | #define BDMCF_RES_ILLEGAL 0xFFFF 39 | 40 | #endif // _BDMCFMACROS_H_ 41 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/led.h: -------------------------------------------------------------------------------- 1 | #ifndef _LED_H_ 2 | #define _LED_H_ 3 | 4 | #define LED_BLINK_PERIOD 150 /* duration of LED period */ 5 | #define LED_OFF_TIME 75 /* how long should the LED be off during the blink period */ 6 | 7 | typedef enum { 8 | LED_ON, 9 | LED_OFF, 10 | LED_BLINK 11 | } led_state_e; 12 | 13 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 14 | extern U8 led_state; 15 | #pragma DATA_SEG DEFAULT 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/Sources/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | /* the following times are in 100us multiples */ 5 | #define SUSPEND_TIME 30 /* time after which the device is put into low power mode in case of no USB activity */ 6 | #define RESUME_RECOVERY 370 /* time to wait after resume */ 7 | 8 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 9 | extern volatile U8 char suspend_timer; 10 | #pragma DATA_SEG DEFAULT 11 | 12 | #endif -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/USBDM_JB16_V4_10.mcp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JB16_V4_10/USBDM_JB16_V4_10.mcp -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/HC08_Full_Chip_Simulator_Postload.cmd: -------------------------------------------------------------------------------- 1 | // After load the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/HC08_Full_Chip_Simulator_Preload.cmd: -------------------------------------------------------------------------------- 1 | // Before load the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/HC08_Full_Chip_Simulator_Reset.cmd: -------------------------------------------------------------------------------- 1 | // After reset the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/HC08_Full_Chip_Simulator_Startup.cmd: -------------------------------------------------------------------------------- 1 | // At startup the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/MON08_Interface_Postload.cmd: -------------------------------------------------------------------------------- 1 | // After load the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/MON08_Interface_Preload.cmd: -------------------------------------------------------------------------------- 1 | // Before load the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/MON08_Interface_Reset.cmd: -------------------------------------------------------------------------------- 1 | // After reset the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/cmd/MON08_Interface_Startup.cmd: -------------------------------------------------------------------------------- 1 | // At startup the commands written below will be executed 2 | -------------------------------------------------------------------------------- /USBDM_JB16_V4_10/prm/burner.bbl: -------------------------------------------------------------------------------- 1 | OPENFILE "%ABS_FILE%.s19" 2 | format=motorola 3 | busWidth=1 4 | origin=0 5 | len=0x1000000 6 | destination=0 7 | SRECORD=Sx 8 | SENDBYTE 1 "%ABS_FILE%" 9 | CLOSE 10 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/.cwGeneratedFileSetLog: -------------------------------------------------------------------------------- 1 | Project_Settings/Startup_Code/start08.c 2 | Sources/main.c 3 | Project_Headers/derivative.h 4 | Project_Headers/mc9s08jm60.h 5 | Lib/mc9s08jm60.c 6 | Project_Settings/Linker_Files/Project.prm 7 | Project_Settings/Linker_Files/burner.bbl 8 | Project_Settings/Debugger/MC9S08JM60.mem 9 | Project_Settings/Debugger/MC9S08JM60.tcl -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/.gitignore: -------------------------------------------------------------------------------- 1 | /USBDM_*/ 2 | /JS16_Bootloader/ 3 | /GeneratedFiles.old/ 4 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/.settings/com.freescale.core.ide.newprojectwizard.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | versionGenerated/versionGenerated=1.10.1.FSL_mcu105_5085 3 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Collect.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cls 3 | rem *** Paths to various things 4 | set VERSION_NUMBER=4 5 | set VERSION_MINOR_NUMBER=10 6 | set VERSION_SUFFIX=_V%VERSION_NUMBER% 7 | set VERSION_MINOR_SUFFIX=_V%VERSION_NUMBER%_%VERSION_MINOR_NUMBER% 8 | 9 | set FLASH_DIR=%~dp0\GeneratedFiles 10 | 11 | set USBDM_ROOT=C:\Users\podonoghue\Development\USBDM 12 | 13 | rem where to find 'fixed' stuff 14 | set PACKAGE_FILES=%USBDM_ROOT%\usbdm-eclipse-makefiles-build\PackageFiles 15 | 16 | echo *** **************************************** 17 | echo *** Do Firmware files 18 | echo *** **************************************** 19 | 20 | cd %~dp0 21 | if not exist "%FLASH_DIR%" mkdir "%FLASH_DIR%" 22 | if not exist "%FLASH_DIR%\JS16" mkdir "%FLASH_DIR%\JS16" 23 | if not exist "%FLASH_DIR%\JMxx" mkdir "%FLASH_DIR%\JMxx" 24 | if not exist "%FLASH_DIR%\Tower" mkdir "%FLASH_DIR%\Tower" 25 | 26 | echo *** JS16... 27 | set FIRMWARE_VERSIONS=USBDM_CF_JS16CWJ USBDM_JS16CWJ USBDM_CF_SER_JS16CWJ USBDM_SER_JS16CWJ USBDM_SWD_SER_JS16CWJ USBDM_SWD_JS16CWJ 28 | for %%f in (%FIRMWARE_VERSIONS%) do copy .\%%f\USBDM*.sx "%FLASH_DIR%\JS16" 29 | echo *** JMxx... 30 | set FIRMWARE_VERSIONS=USBDM_CF_JMxxCLD USBDM_CF_SER_JMxxCLD USBDM_JMxxCLC USBDM_JMxxCLD USBDM_JMxx_MC56F8006Demo 31 | for %%f in (%FIRMWARE_VERSIONS%) do copy .\%%f\USBDM*.sx "%FLASH_DIR%\JMxx" 32 | echo *** TWR... 33 | set FIRMWARE_VERSIONS=USBDM_TWR_CFV1 USBDM_TWR_HCS08 USBDM_TWR_Kinetis USBDM_TWR_CFVx USBDM_TWR_HCS12 34 | for %%f in (%FIRMWARE_VERSIONS%) do copy .\%%f\USBDM*.sx "%FLASH_DIR%\Tower" 35 | 36 | goto allDone 37 | 38 | :allDone 39 | pause 40 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_JMxx_56F8006Demo.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_CF - MC56F8006 Demoboard version 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | */ 10 | #ifndef _CONFIGURE_H_ 11 | #define _CONFIGURE_H_ 12 | 13 | //========================================================================================== 14 | // USB Serial Number 15 | #define SERIAL_NO "USBDM-JMxx-MC56F006Demo-0001" //! Default USB serial number 16 | #define ProductDescription "USBDM DSC on MC56F8006 Demo board" //! USB description 17 | 18 | //========================================================================================== 19 | // Capabilities of the hardware - used to enable/disable appropriate code 20 | // 21 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_VDDSENSE|CAP_CDC|CAP_RST_IO|CAP_JTAG_HW) 22 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_VDDSENSE|CAP_CDC|CAP_RST|CAP_DSC ) //! 23 | 24 | // Include common pin assignments 25 | #include "USBDM_TWR.h" 26 | 27 | #endif // _CONFIGURE_H_ 28 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_TWR_CFV1.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_TWR_KINETIS - USDBM for Coldfire V1 TWR boards 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | 10 | \verbatim 11 | Change History 12 | +================================================================================================ 13 | | 18 Jul 2014 | Removed CAP_VDDSENSE - pgo, ver 4.10.6.170 14 | +================================================================================================ 15 | \endverbatim 16 | */ 17 | 18 | #ifndef _CONFIGURE_H_ 19 | #define _CONFIGURE_H_ 20 | 21 | //========================================================================================== 22 | // USB Serial Number 23 | #define SERIAL_NO "USBDM-TWR-CFV1-0001" //! Default USB serial number 24 | #define ProductDescription "USBDM Coldfire-V1 BDM for Tower" //! USB description 25 | 26 | //========================================================================================== 27 | // Capabilities of the hardware - used to enable/disable appropriate code 28 | // 29 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST_IO|CAP_BDM|CAP_CORE_REGS) 30 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST|CAP_CFV1) 31 | 32 | // Include common pin assignments 33 | #include "USBDM_TWR.h" 34 | 35 | #undef VDD_HAS_DIVIDER // Boards has no VDD input voltage divider 36 | 37 | #endif // _CONFIGURE_H_ 38 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_TWR_CFVx.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_TWR_KINETIS - USDBM for Coldfire boards using OSBDM e.g. M52259Demo 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | 10 | \verbatim 11 | Change History 12 | +================================================================================================ 13 | | 18 Jul 2014 | Removed CAP_VDDSENSE - pgo, ver 4.10.6.170 14 | +================================================================================================ 15 | \endverbatim 16 | */ 17 | 18 | #ifndef _CONFIGURE_H_ 19 | #define _CONFIGURE_H_ 20 | 21 | //========================================================================================== 22 | // USB Serial Number 23 | #define SERIAL_NO "USBDM-TWR-CFVx-0001" 24 | #define ProductDescription "USBDM CFVx BDM for Tower" 25 | 26 | //========================================================================================== 27 | // Capabilities of the hardware - used to enable/disable appropriate code 28 | // 29 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST_IO|CAP_JTAG_HW|CAP_CFVx_HW|CAP_PST|CAP_CORE_REGS) 30 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST|CAP_CFVx|CAP_JTAG|CAP_PST) 31 | 32 | // Include common pin assignments 33 | #include "USBDM_TWR.h" 34 | 35 | #define VDD_HAS_DIVIDER 2 // Board has VDD input 2:1 voltage divider 36 | 37 | #endif // _CONFIGURE_H_ 38 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_TWR_HCS08.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_TWR_HCS08 - USDBM for RS08/HCS08 TWR boards 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | 10 | \verbatim 11 | Change History 12 | +================================================================================================ 13 | | 18 Jul 2014 | Removed CAP_VDDSENSE - pgo, ver 4.10.6.170 14 | +================================================================================================ 15 | \endverbatim 16 | */ 17 | #ifndef _CONFIGURE_H_ 18 | #define _CONFIGURE_H_ 19 | 20 | //========================================================================================== 21 | // USB Serial Number 22 | #define SERIAL_NO "USBDM-TWR-HCS08-0001" 23 | #define ProductDescription "USBDM RS08,HCS08 BDM for Tower" 24 | 25 | //========================================================================================== 26 | // Capabilities of the hardware - used to enable/disable appropriate code 27 | // 28 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_BDM|CAP_FLASH|CAP_CORE_REGS) 29 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RS08|CAP_HCS08) 30 | 31 | // Include common pin assignments 32 | #include "USBDM_TWR.h" 33 | 34 | #define VDD_HAS_DIVIDER 2 // VDD input has 2:1 voltage divider 35 | 36 | #endif // _CONFIGURE_H_ 37 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_TWR_HCS12.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_TWR_HCS12 - USDBM for HCS12 TWR boards 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | 10 | \verbatim 11 | Change History 12 | +================================================================================================ 13 | | 18 Jul 2014 | Added CAP_HCSZVM - pgo, ver 4.10.6.170 14 | | 18 Jul 2014 | Removed CAP_VDDSENSE - pgo, ver 4.10.6.170 15 | +================================================================================================ 16 | \endverbatim 17 | */ 18 | #ifndef _CONFIGURE_H_ 19 | #define _CONFIGURE_H_ 20 | 21 | //========================================================================================== 22 | // USB Serial Number 23 | #define SERIAL_NO "USBDM-TWR-HCS12-0001" 24 | #define ProductDescription "USBDM HCS12 BDM for Tower" 25 | 26 | //========================================================================================== 27 | // Capabilities of the hardware - used to enable/disable appropriate code 28 | // 29 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST_IO|CAP_BDM|CAP_CORE_REGS) 30 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_HCS12|CAP_S12Z) 31 | 32 | // Include common pin assignments 33 | #include "USBDM_TWR.h" 34 | 35 | #define VDD_HAS_DIVIDER 2 // VDD input has 2:1 voltage divider 36 | 37 | #endif // _CONFIGURE_H_ 38 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/USBDM_TWR_Kinetis.h: -------------------------------------------------------------------------------- 1 | /*! @file 2 | @brief This file contains hardware specific information and configuration. 3 | 4 | USBDM_TWR_KINETIS - USDBM for Kinetis TWR boards 5 | 6 | @note DO NOT CHANGE THIS FILE \n 7 | If you need to create another configuration make a copy of this file 8 | under a new name and change Configure.h appropriately. 9 | 10 | \verbatim 11 | Change History 12 | +================================================================================================ 13 | | 18 Jul 2014 | Removed CAP_VDDSENSE - pgo, ver 4.10.6.170 14 | +================================================================================================ 15 | \endverbatim 16 | */ 17 | #ifndef _CONFIGURE_H_ 18 | #define _CONFIGURE_H_ 19 | 20 | //========================================================================================== 21 | // USB Serial Number 22 | #define SERIAL_NO "USBDM-TWR-KINETIS-0001" 23 | #define ProductDescription "USBDM Kinetis BDM for Tower" 24 | 25 | //========================================================================================== 26 | // Capabilities of the hardware - used to enable/disable appropriate code 27 | // 28 | #define HW_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST_IO|CAP_JTAG_HW|CAP_CORE_REGS) 29 | #define TARGET_CAPABILITY (CAP_VDDCONTROL|CAP_CDC|CAP_RST|CAP_ARM_JTAG) 30 | 31 | // Include common pin assignments 32 | #include "USBDM_TWR.h" 33 | 34 | #undef VDD_HAS_DIVIDER // Boards has no VDD input voltage divider 35 | 36 | #endif // _CONFIGURE_H_ 37 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Configure/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 5 | #pragma DATA_SEG DEFAULT 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_CF_JMxxCLD_V1.7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_CF_JMxxCLD_V1.7.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_CF_JMxxCLD_V3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_CF_JMxxCLD_V3.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_JMxxCLD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JMxx/USBDM_JMxxCLD.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_CF_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_CF_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_CF_SER_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_CF_SER_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SER_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SER_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SWD_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SWD_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SWD_SER_JS16CWJ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/GeneratedFiles/JS16/USBDM_SWD_SER_JS16CWJ.pdf -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Project_Settings/Debugger/MC9S08JM60.tcl: -------------------------------------------------------------------------------- 1 | #! 2 | 3 | #change SP 0x00 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Project_Settings/Debugger/MC9S08JS16.tcl: -------------------------------------------------------------------------------- 1 | #! 2 | 3 | #change SP 0x00 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Project_Settings/Linker_Files/burner.bbl: -------------------------------------------------------------------------------- 1 | OPENFILE "%ABS_FILE%.s19" 2 | format=motorola 3 | busWidth=1 4 | origin=0 5 | len=0x1000000 6 | destination=0 7 | SRECORD=Sx 8 | SENDBYTE 1 "%ABS_FILE%" 9 | CLOSE 10 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/README.md: -------------------------------------------------------------------------------- 1 | Firmware for JM60 and JS16 based BDMs 2 | Requires Codewarror V10.6.4 3 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/RemoteLaunch/results/remotelaunch.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/RemoteLaunch/results/remotelaunch.log -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/RemoteSystemsTempFiles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RemoteSystemsTempFiles 4 | 5 | 6 | 7 | 8 | 9 | 10 | org.eclipse.rse.ui.remoteSystemsTempNature 11 | 12 | 13 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/SaAnalysispointsManager.apconfig: -------------------------------------------------------------------------------- 1 | 2 | AnalysispointsManager 3 | Z:/Documents/Development/TestCodewarrior11/USBDM_JMxx_V4_12/SaAnalysispointsManager.apconfig 4 | 1 5 | Analysispoints Manager 6 | false 7 | 8 | Hcs08TracepointsManager 9 | Hcs08 Tracepoints Manager 10 | 11 | 12 | 0 13 | 14 | 15 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/ARM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ARM.h 3 | * 4 | * Created on: 20/08/2012 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef ARM_H_ 9 | #define ARM_H_ 10 | 11 | // Read registers 12 | #define ARM_RD_DP_STATUS (1) 13 | #define ARM_RD_DP_SELECT (2) 14 | #define ARM_RD_DP_RDBUFF (3) 15 | 16 | // Write registers 17 | #define ARM_WR_ABORT (0) 18 | #define ARM_WR_DP_CONTROL (1) 19 | #define ARM_WR_DP_SELECT (2) 20 | #define ARM_WR_DP_RDBUFF (3) 21 | 22 | // Read AP register 23 | #define ARM_RD_AP_REG0 (4) 24 | #define ARM_RD_AP_REG1 (5) 25 | #define ARM_RD_AP_REG2 (6) 26 | #define ARM_RD_AP_REG3 (7) 27 | // 28 | // Write AP register 29 | #define ARM_WR_AP_REG0 (4) 30 | #define ARM_WR_AP_REG1 (5) 31 | #define ARM_WR_AP_REG2 (6) 32 | #define ARM_WR_AP_REG3 (7) 33 | 34 | #define ARM_RD_AHB_CSW ARM_RD_AP_REG0 // SWD command for reading AHB-CSW 35 | #define ARM_RD_AHB_TAR ARM_RD_AP_REG1 // SWD command for reading AHB-TAR 36 | #define ARM_RD_AHB_DRW ARM_RD_AP_REG3 // SWD command for reading AHB-DRW 37 | 38 | #define ARM_WR_AHB_CSW ARM_WR_AP_REG0 // SWD command for writing AHB-CSW 39 | #define ARM_WR_AHB_TAR ARM_WR_AP_REG1 // SWD command for writing AHB-TAR 40 | #define ARM_WR_AHB_DRW ARM_WR_AP_REG3 // SWD command for writing AHB-DRW 41 | 42 | extern uint8_t lastJtagIR_Value; 43 | 44 | uint8_t arm_test(void); 45 | uint8_t arm_readReg(uint8_t regNo, uint8_t *data); 46 | uint8_t arm_writeReg(uint8_t regNo, const uint8_t *data); 47 | uint8_t arm_readAPReg(const uint8_t *address, uint8_t *buff); 48 | uint8_t arm_writeAPReg(const uint8_t *address, const uint8_t *buff); 49 | uint8_t arm_abortAP(void); 50 | 51 | uint8_t arm_CheckStickyPipelined(void); 52 | uint8_t arm_CheckStickyUnpipelined(void); 53 | 54 | #endif /* ARM_H_ */ 55 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/BDM_RS08.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Header file for BDM routines. 3 | 4 | */ 5 | #ifndef _BDM_RS08_H_ 6 | #define _BDM_RS08_H_ 7 | 8 | #if ((HW_CAPABILITY & CAP_FLASH) != 0) 9 | 10 | uint8_t bdmSetVpp(uint8_t level ); 11 | 12 | #endif 13 | 14 | #endif // _BDM_RS08_H_ 15 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessing.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Main command procedure for executing BDM commands received over the USB. 3 | */ 4 | #ifndef _CMDPROCESSING_H_ 5 | #define _CMDPROCESSING_H_ 6 | 7 | #include "BDM.h" 8 | 9 | extern void commandLoop(void); 10 | extern uint8_t compatibleCommandExec(void); 11 | extern uint8_t optionalReconnect(uint8_t when); 12 | 13 | extern uint8_t commandBuffer[]; // Buffer for USB command in, result out 14 | 15 | #ifdef __HC08__ 16 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 17 | #endif // __HC08__ 18 | extern uint8_t returnSize; // Size of command return result 19 | extern BDM_Option_t bdm_option; // Options for cable operation 20 | extern CableStatus_t cable_status; // Status of the BDM interface 21 | #ifdef __HC08__ 22 | #pragma DATA_SEG DEFAULT 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessingARM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CmdProcessingARM.h 3 | * 4 | * Created on: 20/08/2012 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef CMDPROCESSINGARM_H_ 9 | #define CMDPROCESSINGARM_H_ 10 | 11 | #include 12 | 13 | uint8_t f_CMD_ARM_CONNECT(void); 14 | uint8_t f_CMD_ARM_TARGET_STEP(void); 15 | uint8_t f_CMD_ARM_TARGET_GO(void); 16 | uint8_t f_CMD_ARM_TARGET_HALT(void); 17 | uint8_t f_CMD_ARM_WRITE_MEM(void); 18 | uint8_t f_CMD_ARM_READ_MEM(void); 19 | uint8_t f_CMD_ARM_WRITE_REG(void); 20 | uint8_t f_CMD_ARM_READ_ALL_CORE_REGS(void); 21 | uint8_t f_CMD_ARM_READ_REG(void); 22 | uint8_t f_CMD_ARM_WRITE_DREG(void); 23 | uint8_t f_CMD_ARM_READ_DREG(void); 24 | uint8_t f_CMD_ARM_WRITE_CREG(void); 25 | uint8_t f_CMD_ARM_READ_CREG(void); 26 | 27 | #endif /* CMDPROCESSINGARM_H_ */ 28 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessingCFV1.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGCFV1_H_ 2 | #define _CMDPROCESSINGCFV1_H_ 3 | 4 | #include 5 | uint8_t f_CMD_CF_READ_ALL_CORE_REGS(void); 6 | uint8_t f_CMD_CF_WRITE_MEM(void); 7 | uint8_t f_CMD_CF_READ_MEM(void); 8 | uint8_t f_CMD_CF_WRITE_REG(void); 9 | uint8_t f_CMD_CF_READ_REG(void); 10 | uint8_t f_CMD_CF_WRITE_DREG(void); 11 | uint8_t f_CMD_CF_READ_DREG(void); 12 | uint8_t f_CMD_CF_WRITE_CREG(void); 13 | uint8_t f_CMD_CF_READ_CREG(void); 14 | uint8_t f_CMD_CF_WRITE_CSR2(void); 15 | uint8_t f_CMD_CF_READ_CSR2(void); 16 | uint8_t f_CMD_CF_WRITE_CSR3(void); 17 | uint8_t f_CMD_CF_READ_CSR3(void); 18 | 19 | #endif // _CMDPROCESSINGCFV1_H_ 20 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessingCFVx.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGCFVX_H_ 2 | #define _CMDPROCESSINGCFVX_H_ 3 | 4 | #include 5 | 6 | uint8_t f_CMD_CFVx_RESET(void); 7 | //uint8_t f_CMD_CFVx_CONTROL_INTERFACE(void); 8 | uint8_t f_CMD_SPI_SET_SPEED(void); 9 | uint8_t f_CMD_SPI_GET_SPEED(void); 10 | 11 | #if (TARGET_CAPABILITY&CAP_CFVx) 12 | uint8_t f_CMD_CFVx_HALT(void); 13 | uint8_t f_CMD_CFVx_GO(void); 14 | uint8_t f_CMD_CFVx_STEP(void); 15 | uint8_t f_CMD_CFVx_READ_CREG(void); 16 | uint8_t f_CMD_CFVx_WRITE_CREG(void); 17 | uint8_t f_CMD_CFVx_READ_DREG(void); 18 | uint8_t f_CMD_CFVx_READ_STATUS_REG(void); 19 | uint8_t f_CMD_CFVx_WRITE_DREG(void); 20 | uint8_t f_CMD_CFVx_READ_ALL_CORE_REGS(void); 21 | uint8_t f_CMD_CFVx_READ_REG(void); 22 | uint8_t f_CMD_CFVx_WRITE_REG(void); 23 | uint8_t f_CMD_CFVx_READ_MEM(void); 24 | uint8_t f_CMD_CFVx_WRITE_MEM(void); 25 | uint8_t f_CMD_CFVx_RESYNC(void); 26 | #endif 27 | #if (TARGET_CAPABILITY&(CAP_DSC|CAP_JTAG|CAP_ARM_JTAG)) 28 | uint8_t f_CMD_JTAG_GOTORESET(void); 29 | uint8_t f_CMD_JTAG_GOTOSHIFT(void); 30 | uint8_t f_CMD_JTAG_WRITE(void); 31 | uint8_t f_CMD_JTAG_READ(void); 32 | uint8_t f_CMD_JTAG_READ_WRITE(void); 33 | uint8_t f_CMD_JTAG_EXECUTE_SEQUENCE(void); 34 | uint8_t f_CMD_JTAG_RESET(void); 35 | #endif // (CAPABILITY&CAP_CFVx) 36 | 37 | #endif // _CMDPROCESSINGCFVX_H_ 38 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessingHCS.h: -------------------------------------------------------------------------------- 1 | #ifndef _CMDPROCESSINGHCS_H_ 2 | #define _CMDPROCESSINGHCS_H_ 3 | 4 | uint8_t f_CMD_CUSTOM_COMMAND(void); 5 | uint8_t f_CMD_CONNECT(void); 6 | uint8_t f_CMD_SET_SPEED(void); 7 | uint8_t f_CMD_GET_SPEED(void); 8 | //uint8_t f_CMD_CONTROL_INTERFACE(void); 9 | 10 | uint8_t f_CMD_READ_STATUS_REG(void); 11 | uint8_t f_CMD_WRITE_CONTROL_REG(void); 12 | 13 | uint8_t f_CMD_RESET(void); 14 | uint8_t f_CMD_STEP (void); 15 | uint8_t f_CMD_GO(void); 16 | uint8_t f_CMD_HALT(void); 17 | 18 | uint8_t f_CMD_HCS12_WRITE_REG(void); 19 | uint8_t f_CMD_HCS12_READ_REG(void); 20 | uint8_t f_CMD_HCS08_WRITE_REG(void); 21 | uint8_t f_CMD_HCS08_READ_REG(void); 22 | 23 | uint8_t f_CMD_HCS08_READ_MEM(void); 24 | uint8_t f_CMD_HCS08_WRITE_MEM(void); 25 | 26 | uint8_t f_CMD_HCS12_READ_MEM(void); 27 | uint8_t f_CMD_HCS12_WRITE_MEM(void); 28 | 29 | uint8_t f_CMD_WRITE_BD(void); 30 | uint8_t f_CMD_READ_BD(void); 31 | 32 | uint8_t f_CMD_WRITE_BKPT(void); 33 | uint8_t f_CMD_READ_BKPT(void); 34 | 35 | uint8_t f_CMD_SET_VPP(void); 36 | 37 | #endif // _CMDPROCESSINGHCS_H_ 38 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/CmdProcessingSWD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CmdProcessingSWD.h 3 | * 4 | * Created on: 11/08/2012 5 | * Author: podonoghuE 6 | */ 7 | 8 | #ifndef CMDPROCESSINGSWD_H_ 9 | #define CMDPROCESSINGSWD_H_ 10 | 11 | uint8_t f_CMD_SWD_CONNECT(void); 12 | uint8_t f_CMD_SWD_TARGET_STEP(void); 13 | uint8_t f_CMD_SWD_TARGET_GO(void); 14 | uint8_t f_CMD_SWD_TARGET_HALT(void); 15 | uint8_t f_CMD_SWD_WRITE_MEM(void); 16 | uint8_t f_CMD_SWD_READ_MEM(void); 17 | uint8_t f_CMD_SWD_READ_ALL_CORE_REGS(void); 18 | uint8_t f_CMD_SWD_WRITE_REG(void); 19 | uint8_t f_CMD_SWD_READ_REG(void); 20 | uint8_t f_CMD_SWD_WRITE_DREG(void); 21 | uint8_t f_CMD_SWD_READ_DREG(void); 22 | uint8_t f_CMD_SWD_WRITE_CREG(void); 23 | uint8_t f_CMD_SWD_READ_CREG(void); 24 | 25 | #endif /* CMDPROCESSINGSWD_H_ */ 26 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/EDOUT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/USBDM_JMxx_V4_12/Sources/EDOUT -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/ICP_USB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ICP_USB.h 3 | * 4 | * Created on: 25/08/2011 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef ICP_USB_H_ 9 | #define ICP_USB_H_ 10 | 11 | #include "Common.h" 12 | 13 | #pragma CODE_SEG BOOT_ROM 14 | extern void initICP_USB(void); 15 | extern void startICP_USB(void); 16 | extern uint8_t icpReset(void); 17 | #pragma CODE_SEG DEFAULT 18 | 19 | #endif /* ICP_USB_H_ */ 20 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/SCI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SCI.h 3 | * 4 | * Created on: 29/09/2010 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef SCI_H_ 9 | #define SCI_H_ 10 | 11 | #include 12 | 13 | //! Structure for SetLineCoding/GetLineCoding 14 | //! This MUST agree with the USB format 15 | //! 16 | typedef struct { 17 | uint32_t dwDTERate; //!< data rate (littleEndian format) 18 | uint8_t bCharFormat; //!< character format 19 | uint8_t bParityType; //!< parity type 20 | uint8_t bDataBits; //!< number of bits 21 | } LineCodingStructure; 22 | 23 | // Interrupt handlers 24 | void sciTxHandler(void); 25 | void sciRxHandler(void); 26 | void sciErrorHandler(void); 27 | 28 | // SCI Tx Buffer 29 | uint8_t putTxBuffer(char *source, uint8_t size); 30 | uint8_t sciTxBufferFree(void); 31 | void checkUsbCdcTxData(void); 32 | 33 | // SCI Rx 34 | uint8_t setRxBuffer(char *buffer); 35 | uint8_t rxBufferItems(void); 36 | void checkUsbCdcRxData(void); 37 | 38 | void sciSetLineCoding(const LineCodingStructure *lineCodingStructure); 39 | const LineCodingStructure *sciGetLineCoding(void); 40 | void sciSetControlLineState(uint8_t value); 41 | void sciSendBreak(uint16_t length); 42 | 43 | #define SERIAL_STATE_CHANGE (1<<7) 44 | uint8_t getSerialState(void); 45 | 46 | #endif /* SCI_H_ */ 47 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/SCI_Debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SCI_Debug.h 3 | * 4 | * Created on: 06/08/2011 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef SCI_DEBUG_H_ 9 | #define SCI_DEBUG_H_ 10 | 11 | void debugTx(char ch); 12 | int debugRx(void); 13 | void debugPuts(const char * s); 14 | void debugSCIInit(void); 15 | 16 | #endif /* SCI_DEBUG_H_ */ 17 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/SWD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SWD.h 3 | * 4 | * Created on: 04/08/2012 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef SWD_H_ 9 | #define SWD_H_ 10 | 11 | #include "Common.h" 12 | 13 | // Ack values displaced by offset introduced during read (left justified 8-bit value) 14 | #define SWD_ACK_OK (0x1<<5) 15 | #define SWD_ACK_WAIT (0x2<<5) 16 | #define SWD_ACK_FAULT (0x4<<5) 17 | #define SWD_ACK_PROTOCOL (0x7<<5) 18 | 19 | void swd_interfaceIdle(void); 20 | void swd_init(void); 21 | void swd_txIdle8(void); 22 | 23 | uint8_t swd_test(void); 24 | 25 | uint8_t swd_sendCommandWithWait(uint8_t command); 26 | 27 | uint8_t swd_connect(void); 28 | uint8_t swd_readReg(uint8_t command, uint8_t *data); 29 | uint8_t swd_writeReg(uint8_t command, const uint8_t *data); 30 | uint8_t swd_readAPReg(const uint8_t *address, uint8_t *buff); 31 | uint8_t swd_writeAPReg(const uint8_t *address, const uint8_t *buff); 32 | uint8_t swd_clearStickyError(void); 33 | uint8_t swd_abortAP(void); 34 | #endif /* SWD_H_ */ 35 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/SaAnalysispointsManager.apconfig: -------------------------------------------------------------------------------- 1 | 2 | AnalysispointsManager 3 | 4 | 1 5 | Analysispoints Manager 6 | false 7 | 8 | Hcs08TracepointsManager 9 | Hcs08 Tracepoints Manager 10 | 11 | 12 | 0 13 | 14 | 15 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/USB.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H_ 2 | #define _USB_H_ 3 | 4 | #include "Common.h" 5 | 6 | extern void initUSB(void); 7 | 8 | extern void receiveUSBCommand( uint8_t size, uint8_t *buffer); 9 | extern void sendUSBResponse( uint8_t size, const uint8_t *buffer); 10 | 11 | void USBInterruptHandler( void ); 12 | 13 | void usbPutChar(char ch); 14 | void setBDMBusy(void); 15 | #endif // _USB_H_ 16 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/bdmcfMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef _BDMCFMACROS_H_ 2 | #define _BDMCFMACROS_H_ 3 | 4 | //================================================================================= 5 | /* BDM commands */ 6 | #define _BDMCF_CMD_NOP 0x0000 7 | #define _BDMCF_CMD_GO 0x0C00 8 | #define _BDMCF_CMD_RDMREG 0x2D80 9 | #define _BDMCF_CMD_WDMREG 0x2C80 10 | #define _BDMCF_CMD_RCREG 0x2980 11 | #define _BDMCF_CMD_WCREG 0x2880 12 | #define _BDMCF_CMD_RAREG 0x2180 13 | #define _BDMCF_CMD_WAREG 0x2080 14 | #define _BDMCF_CMD_READ8 0x1900 15 | #define _BDMCF_CMD_READ16 0x1940 16 | #define _BDMCF_CMD_READ32 0x1980 17 | #define _BDMCF_CMD_WRITE8 0x1800 18 | #define _BDMCF_CMD_WRITE16 0x1840 19 | #define _BDMCF_CMD_WRITE32 0x1880 20 | #define _BDMCF_CMD_DUMP8 0x1D00 21 | #define _BDMCF_CMD_DUMP16 0x1D40 22 | #define _BDMCF_CMD_DUMP32 0x1D80 23 | #define _BDMCF_CMD_FILL8 0x1C00 24 | #define _BDMCF_CMD_FILL16 0x1C40 25 | #define _BDMCF_CMD_FILL32 0x1C80 26 | 27 | //=============================================================================== 28 | // Response from BDM communication 29 | // Status-bit value - 1st bit of Rx value 30 | #define BDMCF_STATUS_OK 0 31 | 32 | // LSB of data value when S==BDMCF_STATUS_OK 33 | #define BDMCF_RES_OK 0xFFFF 34 | // LSB of data value when S!=BDMCF_STATUS_OK 35 | #define BDMCF_RES_NOT_READY 0x0000 36 | #define BDMCF_RES_BUS_ERROR 0x0001 37 | #define BDMCF_RES_ILLEGAL 0xFFFF 38 | 39 | #endif // _BDMCFMACROS_H_ 40 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/stdbool.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1998-2013 Free Software Foundation, Inc. 2 | 3 | This file is part of GCC. 4 | 5 | GCC is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 9 | 10 | GCC is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | Under Section 7 of GPL version 3, you are granted additional 16 | permissions described in the GCC Runtime Library Exception, version 17 | 3.1, as published by the Free Software Foundation. 18 | 19 | You should have received a copy of the GNU General Public License and 20 | a copy of the GCC Runtime Library Exception along with this program; 21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 | . */ 23 | 24 | /* 25 | * ISO C Standard: 7.16 Boolean type and values 26 | */ 27 | 28 | #ifndef _STDBOOL_H 29 | #define _STDBOOL_H 30 | 31 | #ifndef __cplusplus 32 | 33 | #define bool _Bool 34 | #define true 1 35 | #define false 0 36 | 37 | #else /* __cplusplus */ 38 | 39 | /* Supporting in C++ is a GCC extension. */ 40 | #define _Bool bool 41 | #define bool bool 42 | #define false false 43 | #define true true 44 | 45 | #endif /* __cplusplus */ 46 | 47 | /* Signal that all the definitions are present. */ 48 | #define __bool_true_false_are_defined 1 49 | 50 | #endif /* stdbool.h */ 51 | -------------------------------------------------------------------------------- /USBDM_JMxx_V4_12/Sources/stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stdint.h 3 | * 4 | * Created on: 11/09/2011 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef STDINT_H_ 9 | #define STDINT_H_ 10 | 11 | typedef unsigned char uint8_t; 12 | typedef unsigned int uint16_t; 13 | typedef unsigned long uint32_t; 14 | typedef signed char int8_t; 15 | typedef signed int int16_t; 16 | typedef signed long int32_t; 17 | 18 | #endif /* STDINT_H_ */ 19 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/.cwGeneratedFileSetLog: -------------------------------------------------------------------------------- 1 | ReferencedRSESystems.xml 2 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/.gitignore: -------------------------------------------------------------------------------- 1 | /OpenSDAv1/ 2 | /Debug/ 3 | /OpenSDAv1_Unique_ID/ 4 | /OpenSDAv2_0/ 5 | /OpenSDAv2_0_Unique_ID/ 6 | /OpenSDAv2_1/ 7 | /OpenSDAv2_1_Unique_ID/ 8 | /OpenSDAv1_Power/ 9 | /OpenSDAv1_Power_Unique_ID/ 10 | /.settings/ 11 | /OpenSDAv2_0_Power/ 12 | /OpenSDAv2_1_Unique_ID_Power/ 13 | /OpenSDAv2_0_Unique_ID_Power/ 14 | /OpenSDAv2_1_Power/ 15 | /OpenSDAv1_Unique_ID_Power/ 16 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | USBDM_Kinetis_OpenSDA 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/CDC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SCI.h 3 | * 4 | * Created on: 29/09/2010 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef SCI_H_ 9 | #define SCI_H_ 10 | 11 | #include 12 | 13 | /** 14 | * Structure for SetLineCoding/GetLineCoding 15 | * This MUST agree with the USB format 16 | */ 17 | typedef struct __attribute__((packed)) { 18 | uint32_t dwDTERate; //!< data rate (littleEndian format) 19 | uint8_t bCharFormat; //!< character format 20 | uint8_t bParityType; //!< parity type 21 | uint8_t bDataBits; //!< number of bits 22 | } LineCodingStructure; 23 | 24 | // Interrupt handlers 25 | void cdc_txHandler(void); 26 | void cdc_rxHandler(void); 27 | //void cdcErrorHandler(void); 28 | 29 | // SCI Tx Buffer 30 | bool cdc_putTxBuffer(char *source, uint8_t size); 31 | uint8_t cdc_txBufferIsFree(void); 32 | 33 | // SCI Rx 34 | uint8_t cdc_setRxBuffer(char *buffer); 35 | uint8_t cdc_rxBufferItemCount(void); 36 | void checkUsbCdcRxData(void); 37 | 38 | void cdc_setLineCoding(const LineCodingStructure *lineCodingStructure); 39 | const LineCodingStructure *cdc_getLineCoding(void); 40 | void cdc_setControlLineState(uint8_t value); 41 | void cdc_sendBreak(uint16_t length); 42 | 43 | #define SERIAL_STATE_CHANGE (1<<7) 44 | uint8_t cdc_getSerialState(void); 45 | 46 | #endif /* SCI_H_ */ 47 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/CmdProcessing.h: -------------------------------------------------------------------------------- 1 | /*! \file 2 | \brief Main command procedure for executing BDM commands received over the USB. 3 | */ 4 | #ifndef _CMDPROCESSING_H_ 5 | #define _CMDPROCESSING_H_ 6 | 7 | #include "BDM.h" 8 | 9 | extern void commandLoop(void); 10 | extern USBDM_ErrorCode compatibleCommandExec(void); 11 | extern USBDM_ErrorCode optionalReconnect(uint8_t when); 12 | 13 | extern uint8_t commandBuffer[]; // Buffer for USB command in, result out 14 | 15 | #ifdef __HC08__ 16 | #pragma DATA_SEG __SHORT_SEG Z_PAGE 17 | #endif // __HC08__ 18 | extern uint8_t returnSize; // Size of command return result 19 | extern BDM_Option_t bdm_option; // Options for cable operation 20 | extern CableStatus_t cable_status; // Status of the BDM interface 21 | #ifdef __HC08__ 22 | #pragma DATA_SEG DEFAULT 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/CmdProcessingSWD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CmdProcessingSWD.h 3 | * 4 | * Created on: 11/08/2012 5 | * Author: podonoghuE 6 | */ 7 | 8 | #ifndef CMDPROCESSINGSWD_H_ 9 | #define CMDPROCESSINGSWD_H_ 10 | 11 | USBDM_ErrorCode f_CMD_SWD_CONNECT(void); 12 | USBDM_ErrorCode f_CMD_SWD_TARGET_STEP(void); 13 | USBDM_ErrorCode f_CMD_SWD_TARGET_GO(void); 14 | USBDM_ErrorCode f_CMD_SWD_TARGET_HALT(void); 15 | USBDM_ErrorCode f_CMD_SWD_WRITE_MEM(void); 16 | USBDM_ErrorCode f_CMD_SWD_READ_MEM(void); 17 | USBDM_ErrorCode f_CMD_SWD_READ_ALL_CORE_REGS(void); 18 | USBDM_ErrorCode f_CMD_SWD_WRITE_REG(void); 19 | USBDM_ErrorCode f_CMD_SWD_READ_REG(void); 20 | USBDM_ErrorCode f_CMD_SWD_WRITE_DREG(void); 21 | USBDM_ErrorCode f_CMD_SWD_READ_DREG(void); 22 | USBDM_ErrorCode f_CMD_SWD_WRITE_CREG(void); 23 | USBDM_ErrorCode f_CMD_SWD_READ_CREG(void); 24 | 25 | #endif /* CMDPROCESSINGSWD_H_ */ 26 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPI.h 3 | * 4 | * Created on: 07/08/2012 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef SPI_H_ 9 | #define SPI_H_ 10 | 11 | #include 12 | #include 13 | 14 | #define DEFAULT_SPI_FREQUENCY (1000) //!< Initial SPI frequency 1000 kHz 15 | 16 | extern volatile uint8_t bitDelay; //!< Required software delay used with SPI base Tx/Rx 17 | extern volatile uint8_t rxTiming1; //!< bdm_Rx timing constant #1 18 | extern volatile uint8_t txTiming1; //!< bdm_Tx timing constant #1 19 | 20 | void spi_init(uint32_t ctar0, uint32_t ctar1); 21 | void spi_finalise(void); 22 | uint8_t spi_setSpeed(uint16_t freq); 23 | 24 | uint8_t f_CMD_SPI_SET_SPEED(void); 25 | uint8_t f_CMD_SPI_GET_SPEED(void); 26 | 27 | extern uint32_t spiBaudValue; 28 | 29 | //! Set SPI.CTAR0 value (non-persistent) 30 | //! 31 | //! @param ctar 32-bit CTAR value (excluding baud) 32 | //! 33 | 34 | static inline void spi_setCTAR0(uint32_t ctar) { 35 | SPI0->CTAR[0] = spiBaudValue|ctar; 36 | } 37 | 38 | //! Set SPI.CTAR1 value (non-persistent) 39 | //! 40 | //! @param ctar 32-bit CTAR value (excluding baud) 41 | //! 42 | 43 | static inline void spi_setCTAR1(uint32_t ctar) { 44 | SPI0->CTAR[1] = spiBaudValue|ctar; 45 | } 46 | 47 | #endif /* SPI_H_ */ 48 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/SWD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SWD.h 3 | * 4 | * Created on: 04/08/2012 5 | * Author: PODonoghue 6 | */ 7 | 8 | #ifndef SWD_H_ 9 | #define SWD_H_ 10 | 11 | #include "Common.h" 12 | #include 13 | 14 | // Ack values displaced by offset introduced during read (left justified 8-bit value) 15 | #define SWD_ACK_OK (0x1) 16 | #define SWD_ACK_WAIT (0x2) 17 | #define SWD_ACK_FAULT (0x4) 18 | #define SWD_ACK_PROTOCOL (0x7) 19 | 20 | void swd_interfaceIdle(void); 21 | void swd_init(void); 22 | void swd_txIdle8(void); 23 | 24 | uint8_t swd_test(uint8_t *returnSize, uint8_t *buff); 25 | uint8_t swd_reset_capture_mass_erase(uint8_t *returnSize, uint8_t *buff); 26 | 27 | uint8_t swd_sendCommandWithWait(uint8_t command); 28 | 29 | USBDM_ErrorCode swd_connect(void); 30 | USBDM_ErrorCode swd_readReg(uint8_t command, uint8_t *data); 31 | USBDM_ErrorCode swd_writeReg(uint8_t command, const uint8_t *data); 32 | USBDM_ErrorCode swd_readAPReg(const uint8_t *address, uint8_t *buff); 33 | USBDM_ErrorCode swd_writeAPReg(const uint8_t *address, const uint8_t *buff); 34 | USBDM_ErrorCode swd_clearStickyError(void); 35 | USBDM_ErrorCode swd_abortAP(void); 36 | #endif /* SWD_H_ */ 37 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/USB.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H_ 2 | #define _USB_H_ 3 | 4 | #include "Common.h" 5 | 6 | extern void checkUsbCdcTxData(void); 7 | 8 | extern void initUSB(void); 9 | 10 | extern void receiveUSBCommand( uint8_t size, uint8_t *buffer); 11 | extern void sendUSBResponse( uint8_t size, const uint8_t *buffer); 12 | 13 | void usbPutChar(char ch); 14 | void setBDMBusy(void); 15 | #endif // _USB_H_ 16 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/console.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file console.h 3 | * @brief Basic UART routines for console 4 | * @date 13 June 2015 5 | */ 6 | #include 7 | 8 | #ifndef UART_H_ 9 | #define UART_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /** 16 | * Initialises the UART 17 | * 18 | * @param baudRate - the baud rate to use e.g. @ref DEFAULT_BAUD_RATE 19 | */ 20 | void console_initialise(int baudRate); 21 | /** 22 | * Transmits a single character over the UART (blocking) 23 | * 24 | * @param ch - character to send 25 | */ 26 | void console_txChar(int ch); 27 | /** 28 | * Receives a single character over the UART (blocking) 29 | * 30 | * @return - character received 31 | */ 32 | int console_rxChar(void); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif /* UART_H_ */ 38 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file FRDM_K20D50M.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MK20D5.h" 8 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/dspiColdfire.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sciColdfire.h 3 | * 4 | * Created on: 02/03/2012 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef SPICOLDFIRE_H_ 9 | #define SPICOLDFIRE_H_ 10 | #include 11 | 12 | //! Initialise SPI for Coldfire BDM (17 bits as 1 + 16 transfer) 13 | //! 14 | //! @param freq - frequency to use 15 | //! 16 | uint8_t initDSPIColdfire(uint32_t freq /* kHz */); 17 | 18 | //! Exchange a 17-bit word with the target 19 | //! 20 | //! @param send - data to send 21 | //! @param receive - data received 22 | //! 23 | uint8_t rxtxDSPIColdfire(uint32_t send, uint32_t *receive); 24 | 25 | #endif /* SPICOLDFIRE_H_ */ 26 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/icp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * icp.h 3 | * 4 | * Created on: 01/03/2012 5 | * Author: podonoghue 6 | */ 7 | 8 | #ifndef ICP_H_ 9 | #define ICP_H_ 10 | 11 | void rebootToICP(void); 12 | void rebootToUser(void); 13 | #define MAGIC_REBOOT_KEY_VALUE (0xFF00EE55UL) 14 | 15 | typedef struct { 16 | uint32_t validKey; // Must be MAGIC_REBOOT_KEY_VALUE to indicate valid structure 17 | uint32_t *userFlashStart; // Start of user flash memory 18 | uint32_t *userFlashEnd; // End of user flash memory 19 | void (*startUp)(void); // User startup routine 20 | uint32_t *initialSP; // User initial SP 21 | } ICPData; 22 | 23 | extern ICPData icpData; 24 | 25 | #endif /* ICP_H_ */ 26 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/leds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * leds.h 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #ifndef LEDS_H_ 9 | #define LEDS_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void greenLedOn(void); 16 | void greenLedOff(void); 17 | void greenLedToggle(void); 18 | void redLedOn(void); 19 | void redLedOff(void); 20 | void redLedToggle(void); 21 | void blueLedOn(void); 22 | void blueLedOff(void); 23 | void blueLedToggle(void); 24 | void blueLedEnable(void); 25 | void blueLedDisable(void); 26 | void orangeLedOn(void); 27 | void orangeLedOff(void); 28 | void orangeLedToggle(void); 29 | 30 | void led_initialise(void); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* LEDS_H_ */ 37 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/Project_Headers/system.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file system.h 3 | * @brief System initialisation routines 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #ifndef SYSTEM_H_ 8 | #define SYSTEM_H_ 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern uint32_t SystemCoreClock; //!< System core clock frequency in Hz 17 | extern uint32_t SystemBusClock; //!< System bus clock frequency Hz 18 | 19 | /** 20 | * @brief Low-level initialize the system 21 | * 22 | * Low level setup of the microcontroller system. \n 23 | * Called very early in the initialisation. \n 24 | * May NOT use globals etc (as will be overwritten by BSS initialization) 25 | */ 26 | void SystemInitLowLevel(void); 27 | /** 28 | * @brief Initialize the system 29 | * 30 | * Setup the microcontroller system. 31 | */ 32 | void SystemInit(void); 33 | /** 34 | * @brief Update SystemCoreClock variable 35 | * 36 | * Updates the SystemCoreClock & SystemBusClock variables with current core Clock retrieved from CPU registers. 37 | */ 38 | void SystemCoreClockUpdate(void); 39 | 40 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- 41 | 42 | // UART default baud rate 43 | // Used by default UART setup for stdio 44 | // Note: Manually change Custom value 45 | // <110=> 110 46 | // <300=> 300 47 | // <600=> 600 48 | // <1200=> 1200 49 | // <2400=> 2400 50 | // <4800=> 4800 51 | // <9600=> 9600 52 | // <14400=> 14400 53 | // <19200=> 19200 54 | // <28800=> 28800 55 | // <38400=> 38400 56 | // <56000=> 56000 57 | // <57600=> 57600 58 | // <115200=> 115200 59 | // <115200=> Restore default 60 | // <115200=> Custom 61 | 62 | #ifndef DEFAULT_BAUD_RATE 63 | /** 64 | * Default baud rate for UART used for stdio 65 | */ 66 | #define DEFAULT_BAUD_RATE 115200 67 | #endif 68 | 69 | #if ((DEBUG&USB_PUTS_DEBUG) != 0) 70 | #include "uart.h" 71 | #define PUTS(x) puts(x) 72 | #define PRINTF(...) printf (__VA_ARGS__) 73 | #else 74 | #define PUTS(x) 75 | #define PRINTF(...) 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* SYSTEM_H_ */ 83 | -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/README.md: -------------------------------------------------------------------------------- 1 | Firmware for Kinetis based BDMs e.g. FRDM boards 2 | 3 | Requires either: 4 | * Eclipse CDT + ARM GNU GCC + USBDM 5 | * Kinetis Design Studion + USBM -------------------------------------------------------------------------------- /USBDM_Kinetis_OpenSDA_old/RemoteSystemsTempFiles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RemoteSystemsTempFiles 4 | 5 | 6 | 7 | 8 | 9 | 10 | org.eclipse.rse.ui.remoteSystemsTempNature 11 | 12 | 13 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/.gitignore: -------------------------------------------------------------------------------- 1 | /Snippets/ 2 | /OpenSDAv1/ 3 | /OpenSDAv1_Power/ 4 | /OpenSDAv1_Unique_ID/ 5 | /OpenSDAv1_Unique_ID_Power/ 6 | /OpenSDAv2_0/ 7 | /OpenSDAv2_0_Power/ 8 | /OpenSDAv2_0_Unique_ID/ 9 | /OpenSDAv2_0_Unique_ID_Power/ 10 | /OpenSDAv2_1_Power/ 11 | /OpenSDAv2_1_Unique_ID_Power/ 12 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Usbdm_Kinetis_OpenSDA_V5 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 | net.sourceforge.usbdm.cdt.tools.cnature 24 | org.eclipse.cdt.core.ccnature 25 | net.sourceforge.usbdm.cdt.tools.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | 31 | Documentation.html 32 | 1 33 | copy_PROJECT_LOC/Documentation/html/index.html 34 | 35 | 36 | 37 | 38 | copy_PROJECT_LOC 39 | $%7BPARENT-1-PROJECT_LOC%7D/Usbdm_Kinetis_OpenSDA_new 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/KinetisPowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/Usbdm_Kinetis_OpenSDA_V5/Project_Headers/KinetisPowerModes.png -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/PowerModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podonoghue/usbdm-firmware/c48dc04db794f0501b55e80c86e64428ae0319b6/Usbdm_Kinetis_OpenSDA_V5/Project_Headers/PowerModes.png -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/control.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file control.h (180.ARM_Peripherals/Project_Headers/control.h) 3 | * @brief CONTROL routines 4 | * 5 | * @version V4.12.1.270 6 | * @date 20 November 2021 7 | */ 8 | #ifndef HEADER_CONTROL_H 9 | #define HEADER_CONTROL_H 10 | /* 11 | * ***************************** 12 | * *** DO NOT EDIT THIS FILE *** 13 | * ***************************** 14 | * 15 | * This file is generated automatically. 16 | * Any manual changes will be lost. 17 | */ 18 | 19 | namespace USBDM { 20 | 21 | /** 22 | * @addtogroup Control_Group CONTROL, Control 23 | * @brief Abstraction for Control 24 | * @{ 25 | */ 26 | 27 | 28 | /** 29 | * End CONTROL_Group 30 | * @} 31 | */ 32 | 33 | } // End namespace USBDM 34 | 35 | #endif /* HEADER_CONTROL_H */ 36 | 37 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/derivative.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file derivative.h 3 | * @brief Include the derivative-specific header file MK20D5.h 4 | * @version V4.11.1.70 5 | * @date 13 Nov 2012 6 | */ 7 | #include "MK20D5.h" 8 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file flash.h (180.ARM_Peripherals/Project_Headers/flash.h) 3 | * @brief Flash support 4 | * 5 | * Created on: 21 Sep 2016 6 | * Author: podonoghue 7 | */ 8 | #include "ftfl.h" 9 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/sim.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sim.h (180.ARM_Peripherals/Project_Headers/sim.h) 3 | * @brief System Integration Module 4 | * 5 | * @version V4.12.1.210 6 | * @date 13 April 2016 7 | */ 8 | 9 | #ifndef HEADER_SIM_H 10 | #define HEADER_SIM_H 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #include "pin_mapping.h" 20 | 21 | namespace USBDM { 22 | 23 | /** 24 | * @addtogroup SIM_Group SIM, System Integration Module 25 | * @brief Abstraction for System Integration Module 26 | * @{ 27 | */ 28 | 29 | /** 30 | * @brief Template class representing the System Integration Module (SIM) 31 | * 32 | */ 33 | class Sim : public SimInfo { 34 | public: 35 | }; 36 | 37 | /** 38 | * End SIM_Group 39 | * @} 40 | */ 41 | 42 | } // End namespace USBDM 43 | 44 | #endif /* HEADER_SIM_H */ 45 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Project_Headers/vref.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vref.h (180.ARM_Peripherals/Project_Headers/vref.h) 3 | * @brief Voltage Reference 4 | * 5 | * @version V4.12.1.210 6 | * @date 13 April 2016 7 | * Author: podonoghue 8 | */ 9 | 10 | #ifndef HEADER_VREF_H 11 | #define HEADER_VREF_H 12 | /* 13 | * ***************************** 14 | * *** DO NOT EDIT THIS FILE *** 15 | * ***************************** 16 | * 17 | * This file is generated automatically. 18 | * Any manual changes will be lost. 19 | */ 20 | #include "derivative.h" 21 | #include "pin_mapping.h" 22 | 23 | namespace USBDM { 24 | 25 | /** 26 | * @addtogroup VREF_Group VREF, Voltage Reference 27 | * @brief C++ Class allowing access to Voltage Reference 28 | * @{ 29 | */ 30 | 31 | /** 32 | * Template class representing a Voltage Reference 33 | * 34 | * @tparam info Information class for VREF 35 | * 36 | * @code 37 | * using vref = VrefBase_T; 38 | * 39 | * vref::initialise(); 40 | * 41 | * @endcode 42 | */ 43 | template 44 | class VrefBase_T : public Info { 45 | 46 | CreatePeripheralPinChecker("VREF"); 47 | 48 | private: 49 | /** 50 | * This class is not intended to be instantiated 51 | */ 52 | VrefBase_T(const VrefBase_T&) = delete; 53 | VrefBase_T(VrefBase_T&&) = delete; 54 | 55 | public: 56 | /** Hardware instance pointer */ 57 | static constexpr HardwarePtr vref = Info::baseAddress; 58 | 59 | VrefBase_T() { 60 | }; 61 | 62 | public: 63 | // /VREF/InitMethod not found 64 | // No class Info found 65 | /** 66 | * Enable Vref output pin as Vref output. 67 | * Configures all Pin Control Register (PCR) values 68 | */ 69 | static void setOutput() { 70 | CheckPinExistsAndIsMapped::check(); 71 | 72 | using Pcr = PcrTable_T; 73 | 74 | // Enable and map pin to Vref_out is needed 75 | Pcr::setPCR(); 76 | } 77 | }; 78 | 79 | 80 | /** 81 | * End VREF_Group 82 | * @} 83 | */ 84 | 85 | } // End namespace USBDM 86 | 87 | #endif /* HEADER_VREF_H */ 88 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/.gitignore: -------------------------------------------------------------------------------- 1 | /hardware.cpp 2 | /i2c.cpp 3 | /usbdmError.cpp 4 | /spi.cpp 5 | /ftfa.cpp 6 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/Names.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \brief Header file for CmdTable.c 3 | */ 4 | #ifndef _NAMES_H_ 5 | #define _NAMES_H_ 6 | 7 | #if defined(DEBUG_BUILD) 8 | 9 | char const *getCommandName(unsigned char command); 10 | 11 | #else // defined(LOG) || defined(NEED_ALL_NAMES) 12 | 13 | // Dummy the routines if logging is not required 14 | static inline char const *getCommandName(unsigned char command) { (void) command; return ""; } 15 | 16 | #endif 17 | 18 | #endif // _NAMES_H_ 19 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/cmdProcessingSWD.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file CmdProcessingSWD.h 3 | * @brief SWD Command Processing 4 | * 5 | * @version V4.12.1.80 6 | * @date 13 April 2016 7 | */ 8 | #ifndef CMDPROCESSINGSWD_H_ 9 | #define CMDPROCESSINGSWD_H_ 10 | 11 | #include "commands.h" 12 | #include "cmdProcessing.h" 13 | 14 | namespace Swd { 15 | 16 | USBDM_ErrorCode f_CMD_CONNECT(void); 17 | USBDM_ErrorCode f_CMD_SET_SPEED(void); 18 | USBDM_ErrorCode f_CMD_GET_SPEED(void); 19 | 20 | USBDM_ErrorCode f_CMD_TARGET_STEP(void); 21 | USBDM_ErrorCode f_CMD_TARGET_GO(void); 22 | USBDM_ErrorCode f_CMD_TARGET_HALT(void); 23 | 24 | USBDM_ErrorCode f_CMD_WRITE_MEM(void); 25 | USBDM_ErrorCode f_CMD_READ_MEM(void); 26 | 27 | USBDM_ErrorCode f_CMD_READ_ALL_CORE_REGS(void); 28 | USBDM_ErrorCode f_CMD_WRITE_REG(void); 29 | USBDM_ErrorCode f_CMD_READ_REG(void); 30 | USBDM_ErrorCode f_CMD_WRITE_DREG(void); 31 | USBDM_ErrorCode f_CMD_READ_DREG(void); 32 | USBDM_ErrorCode f_CMD_WRITE_CREG(void); 33 | USBDM_ErrorCode f_CMD_READ_CREG(void); 34 | 35 | }; // End namespace Swd 36 | 37 | #endif /* CMDPROCESSINGSWD_H_ */ 38 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * interface.h 3 | * 4 | * Created on: 21 May 2021 5 | * Author: peter 6 | */ 7 | 8 | #ifndef SOURCES_INTERFACE_H_ 9 | #define SOURCES_INTERFACE_H_ 10 | #include "hardware.h" 11 | #include "smc.h" 12 | 13 | /** 14 | * GPIO for Activity LED 15 | */ 16 | class UsbLed : private USBDM::SDA_LED { 17 | 18 | public: 19 | using USBDM::SDA_LED::toggle; 20 | using USBDM::SDA_LED::on; 21 | using USBDM::SDA_LED::off; 22 | using USBDM::SDA_LED::write; 23 | 24 | /** Initialise activity LED */ 25 | inline static void initialise() { 26 | using namespace USBDM; 27 | 28 | setOutput(PinDriveStrength_High, PinDriveMode_PushPull, PinSlewRate_Slow); 29 | } 30 | }; 31 | 32 | /** 33 | * GPIO controlling some interface signals (SWD, UART-TX) 34 | */ 35 | class InterfaceEnable : public USBDM::GpioA<4, USBDM::ActiveLow> { 36 | public: 37 | /** Initialise pin as output driving inactive level */ 38 | static void initialise() { 39 | setOutput(); 40 | } 41 | }; 42 | 43 | 44 | #endif /* SOURCES_INTERFACE_H_ */ 45 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/interfaceCommon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interfaceCommon.h 3 | * @brief Low power timer interface 4 | * 5 | * @version V4.12.1.80 6 | * @date 13 April 2016 7 | */ 8 | #ifndef _BDMCOMMON_H_ 9 | #define _BDMCOMMON_H_ 10 | 11 | #include 12 | 13 | #include "commands.h" 14 | 15 | USBDM_ErrorCode setTarget(TargetType_t target); 16 | USBDM_ErrorCode checkTargetVdd(void); 17 | void suspend(void); 18 | USBDM_ErrorCode cycleTargetVddOn(TargetMode_t mode); 19 | USBDM_ErrorCode cycleTargetVdd(TargetMode_t mode); 20 | uint16_t targetVddMeasure(void); 21 | USBDM_ErrorCode clearStatus(void); 22 | USBDM_ErrorCode enableTargetVdd(); 23 | USBDM_ErrorCode setTargetVdd(TargetVddSelect_t targetVdd); 24 | 25 | #endif // _BDMCOMMON_H_ 26 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Sources/usb_implementation.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usb_implementation.h 3 | * @brief USB Kinetis implementation 4 | * 5 | * @version V4.12.1.150 6 | * @date 13 Nov 2016 7 | */ 8 | 9 | /* 10 | * Include appropriate example 11 | */ 12 | //#include "usb_implementation_cdc.h" 13 | //#include "usb_implementation_bulk.h" 14 | #include "usb_implementation_composite.h" 15 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Startup_Code/console.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file console.cpp (180.ARM_Peripherals/Startup_Code/console.cpp) 3 | * 4 | * Created on: 14/04/2013 5 | * Author: pgo 6 | */ 7 | 8 | #include "derivative.h" 9 | #include "system.h" 10 | #include "pin_mapping.h" 11 | #include "console.h" 12 | 13 | /* 14 | * ***************************** 15 | * *** DO NOT EDIT THIS FILE *** 16 | * ***************************** 17 | * 18 | * This file is generated automatically. 19 | * Any manual changes will be lost. 20 | */ 21 | 22 | namespace USBDM { 23 | 24 | #if USE_CONSOLE 25 | 26 | /** 27 | * Print simple log message to console 28 | * 29 | * @param msg Message to print 30 | */ 31 | void log_error(const char *msg) { 32 | (void)msg; 33 | console.WRITELN(msg); 34 | } 35 | 36 | /** 37 | * @addtogroup CONSOLE_Group Console 38 | * @brief Console serial interface 39 | * @{ 40 | */ 41 | 42 | // Console instance 43 | Console console; 44 | 45 | /* 46 | * Initialises the Console 47 | */ 48 | extern "C" 49 | void console_initialise() { 50 | console.initialise(); 51 | console.setBaudRate(defaultBaudRate); 52 | console.setEcho(); 53 | console.configureAllPins(); 54 | } 55 | 56 | 57 | 58 | /* 59 | * Set Console baud rate 60 | * 61 | * @param baudRate - the baud rate to use 62 | */ 63 | extern "C" 64 | void console_setBaudRate(int baudRate = defaultBaudRate) { 65 | console.setBaudRate(UartBaudRate(baudRate)); 66 | } 67 | 68 | /* 69 | * Transmits a single character to Console 70 | * 71 | * @param ch - character to send 72 | */ 73 | extern "C" 74 | void console_txChar(int ch) { 75 | console.write((char)ch); 76 | } 77 | 78 | /* 79 | * Receives a single character from Console (blocking) 80 | * 81 | * @return - character received 82 | */ 83 | extern "C" 84 | int console_rxChar(void) { 85 | return console.readChar(); 86 | } 87 | 88 | /** 89 | * @} 90 | */ 91 | #else 92 | 93 | Console console; 94 | 95 | #endif /* USE_CONSOLE */ 96 | 97 | } // End namespace USBDM 98 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Startup_Code/rtc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file rtc.cpp (180.ARM_Peripherals/Startup_Code/rtc.cpp) 3 | * 4 | * Created on: 21/09/2013 5 | * Author: podonoghue 6 | */ 7 | 8 | #include 9 | #include "derivative.h" 10 | #include "rtc.h" 11 | /* 12 | * ***************************** 13 | * *** DO NOT EDIT THIS FILE *** 14 | * ***************************** 15 | * 16 | * This file is generated automatically. 17 | * Any manual changes will be lost. 18 | */ 19 | #if false // /RTC/enablePeripheralSupport 20 | /* 21 | * To support time.h functions 22 | * 23 | * @param tp 24 | * @param tzp 25 | */ 26 | extern "C" __attribute__ ((__weak__)) 27 | int _gettimeofday(struct timeval *tp, void *) { 28 | // Enable RTC interface 29 | USBDM::Rtc::enableClock(); 30 | tp->tv_sec = USBDM::Rtc::getTime(); 31 | tp->tv_usec = 0; 32 | return 0; 33 | } 34 | 35 | /* 36 | * To support time.h functions 37 | * 38 | * @param tp 39 | * @param tzp 40 | */ 41 | extern "C" 42 | int settimeofday(const struct timeval *tp, const struct timezone *) { 43 | // Enable RTC interface 44 | USBDM::Rtc::enableClock(); 45 | USBDM::Rtc::setTime(tp->tv_sec); 46 | return 0; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /Usbdm_Kinetis_OpenSDA_V5/Startup_Code/system-gcc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @file system-gcc.cpp (180.ARM_Peripherals/Startup_Code/system-gcc.cpp) 3 | * 4 | * GCC specific code 5 | * 6 | * Created on: 25/5/2017 7 | */ 8 | #include 9 | #include "pin_mapping.h" 10 | 11 | /* Prevents the exception handling name demangling code getting pulled in */ 12 | namespace __gnu_cxx { 13 | void __verbose_terminate_handler() { 14 | USBDM::setAndCheckErrorCode(USBDM::E_TERMINATED); 15 | } 16 | } 17 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void); 18 | extern "C" __attribute__((__weak__)) void __cxa_pure_virtual(void) { 19 | exit(1); 20 | } 21 | --------------------------------------------------------------------------------