Add global usbMSCenabled flag.

Make ISPandReset honor this flag by disabling MSC first
This commit is contained in:
Stefan `Sec` Zehl 2011-06-27 01:35:32 +02:00
parent 050df7db06
commit bb4b0f1b9c
4 changed files with 15 additions and 2 deletions

View File

@ -143,4 +143,7 @@ uint8_t getInput(void);
uint32_t GetUUID32(void);
uint16_t GetUUID16(void);
// for core/iap/iap.c (no official definition)
void iap_entry(uint32_t param_tab[], uint32_t result_tab[]);
#endif

View File

@ -1,5 +1,7 @@
#include "lpc134x.h"
#include "sysdefs.h"
#include "basic/basic.h"
#include "usb/usbmsc.h"
/* Missing from core */
@ -73,7 +75,11 @@ void EnableWatchdog(uint32_t ms){
};
void ISPandReset(int delay){
EnableWatchdog(1000*delay);
ReinvokeISP();
if(usbMSCenabled){
usbMSCOff();
delayms(500);
};
EnableWatchdog(1000*delay);
ReinvokeISP();
};

View File

@ -12,6 +12,7 @@
USB_DEV_INFO DeviceInfo;
MSC_DEVICE_INFO MscDevInfo;
ROM ** rom = (ROM **)0x1fff1ff8;
char usbMSCenabled=0;
void usbMSCWrite(uint32_t offset, uint8_t src[], uint32_t length) {
dataflash_random_write(src, offset, length);
@ -84,6 +85,7 @@ void usbMSCInit(void) {
(*rom)->pUSBD->init(&DeviceInfo); /* USB Initialization */
(*rom)->pUSBD->connect(true); /* USB Connect */
usbMSCenabled=1;
}
#ifdef CFG_USBMSC
@ -94,5 +96,6 @@ void USB_IRQHandler() {
void usbMSCOff(void) {
(*rom)->pUSBD->connect(false); /* USB Disconnect */
usbMSCenabled=0;
}

View File

@ -39,6 +39,7 @@
#include "projectconfig.h"
extern char usbMSCenabled;
void usbMSCWrite(uint32_t offset, uint8_t src[], uint32_t length);
void usbMSCRead(uint32_t offset, uint8_t dst[], uint32_t length);
void usbMSCInit(void);