#include #include #include #include #include // Internal hardware context struct __sh7305_ubc_context ubc_context; // Internal global int ubc_driver_is_installed = 0; //@note: we known that Casio doesn't use the UBC module static void sh7305_ubc_driver_install(void) { extern uint32_t vhex_dbr; extern uint32_t bubc_ram; extern uint32_t bubc_rom; extern uint32_t subc; // Check multiple installation if (ubc_driver_is_installed != 0) return; // Dump UBC handler memcpy(&bubc_ram, &bubc_rom, (size_t)&subc); // Set the DBR dbr_set(&vhex_dbr); // Start User Break Controller SH7305_POWER.MSTPCR0.UBC = 0; // Default initialization SH7305_UBC.CBR0.MFI = 0b000000; SH7305_UBC.CBR0.CE = 0; SH7305_UBC.CBR1.MFI = 0b000000; SH7305_UBC.CBR1.CE = 0; SH7305_UBC.CBCR.UBDE = 1; } static void sh7305_ubc_driver_uninstall(void) { // Nothing for now // TODO: Casio seems to stop UBC module when power off occur // SO, restore context if needed (?) } // Create driver object VHEX_DRIVER(3, driver_ubc_sh7305) = { .arch = MPU_SH7305, .install = &sh7305_ubc_driver_install, .uninstall = &sh7305_ubc_driver_uninstall, .name = "intc" };