void MIPS32 IntConfigureSystem(u8 mode) { unsigned int temp; asm("di"); // Disable all interrupts temp = _CP0_GET_STATUS(); // Get Status temp |= 0x00400000; // Set BEV bit _CP0_SET_STATUS(temp); // Update Status #if defined(PIC32_PINGUINO_220) || defined(GENERIC32MX250F128) || defined(GENERIC32MX220F032) _CP0_SET_EBASE(0xBD003000); // Set an EBase value of 0xBD003000 #else _CP0_SET_EBASE(0xBD005000); // Set an EBase value of 0xBD005000 #endif _CP0_SET_INTCTL(0x00000020); // Set the Vector Spacing to non-zero value temp = _CP0_GET_CAUSE(); // Get Cause temp |= 0x00800000; // Set IV _CP0_SET_CAUSE(temp); // Update Cause temp = _CP0_GET_STATUS(); // Get Status temp &= 0xFFBFFFFD; // Clear BEV and EXL _CP0_SET_STATUS(temp); // Update Status switch (mode) { case INT_SYSTEM_CONFIG_MULT_VECTOR: // Set the CP0 registers for multi-vector interrupt INTCONSET = 0x1000; // Set MVEC bit break; case INT_SYSTEM_CONFIG_SINGLE_VECTOR: // Set the CP0 registers for single-vector interrupt INTCONCLR = 0x1000; // Clear MVEC bit break; } asm("ei"); // Enable all interrupts }
/******************************************************************** * Function: static void InitializeSystem(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: InitializeSystem is a centralize initialization * routine. All required USB initialization routines * are called from here. * * User application initialization routine should * also be called from here. * * Note: None *******************************************************************/ static void _MIPS32 InitializeSystem(void) { // #elif defined(__C32__) // AD1PCFG = 0xFFFF; FIXME! // #endif #if defined(__32MX460F512L__)|| defined(__32MX795F512L__) // Configure the PIC32 core for the best performance // at the operating frequency. The operating frequency is already set to // 60MHz through Device Config Registers // SYSTEMConfigPerformance(60000000); #endif // SYSTEMConfigPerformance(40000000); _CP0_SET_EBASE(_RESET_ADDR); // 割り込みベクターを9D00_1000 に変更する. // The USB specifications require that USB peripheral devices must never source // current onto the Vbus pin. Additionally, USB peripherals should not source // current on D+ or D- when the host/hub is not actively powering the Vbus line. // When designing a self powered (as opposed to bus powered) USB peripheral // device, the firmware should make sure not to turn on the USB module and D+ // or D- pull up resistor unless Vbus is actively powered. Therefore, the // firmware needs some means to detect when Vbus is being powered by the host. // A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and // can be used to detect when Vbus is high (host actively powering), or low // (host is shut down or otherwise not supplying power). The USB firmware // can then periodically poll this I/O pin to know when it is okay to turn on // the USB module/D+/D- pull up resistor. When designing a purely bus powered // peripheral device, it is not possible to source current on D+ or D- when the // host is not actively providing power on Vbus. Therefore, implementing this // bus sense feature is optional. This firmware can be made to use this bus // sense feature by making sure "USE_USB_BUS_SENSE_IO" has been defined in the // HardwareProfile.h file. #if defined(USE_USB_BUS_SENSE_IO) tris_usb_bus_sense = INPUT_PIN; // See HardwareProfile.h #endif // If the host PC sends a GetStatus (device) request, the firmware must respond // and let the host know if the USB peripheral device is currently bus powered // or self powered. See chapter 9 in the official USB specifications for details // regarding this request. If the peripheral device is capable of being both // self and bus powered, it should not return a hard coded value for this request. // Instead, firmware should check if it is currently self or bus powered, and // respond accordingly. If the hardware has been configured like demonstrated // on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the // currently selected power source. On the PICDEM FS USB Demo Board, "RA2" // is used for this purpose. If using this feature, make sure "USE_SELF_POWER_SENSE_IO" // has been defined in HardwareProfile - (platform).h, and that an appropriate I/O pin // has been mapped to it. #if defined(USE_SELF_POWER_SENSE_IO) tris_self_power = INPUT_PIN; // See HardwareProfile.h #endif UserInit(); USBDeviceInit(); //usb_device.c. Initializes USB module SFRs and firmware //variables to known states. }//end InitializeSystem
void MIPS32 IntSetEBASE(unsigned int ebase_address) { _CP0_SET_EBASE(ebase_address); }