Hello all,
I have a question i just cannot get my head around right now.
I am working with MSP430F5529, which has an USB module onboard. I am working with CCS 6.1 just for the notice.
Now I did simply integrate the USB composite CDC MSC example, which is already using elm-chans FatFs implementation via SPI to SD card.
This all works pretty nice ( after a lot of debugging and coding and sweat and tears :) ).
Now what is not working , but I would really like to have that, is if I build a file on SDcard with my MSP430:
f_mount(0, &fatfs); /* Give a work area to the default drive */ if (f_open(&File, "textertester.txt", FA_WRITE | FA_CREATE_ALWAYS) == FR_OK) { /* Create a file */ unsigned int bw, btw; f_write(&File, "test\r\n", 11, &bw); /* Write data to the file */ f_close(&File); /* Close the file */ }
so now there is: textertester.txt on the SDcard , I know that for sure, BUT
my windows explorer is not showing that new data, unless I pull out the SDcard and put it in again, or the same with the USB connector.
Now how can I get the windows explorer to "live" refresh the data contect of the connected MSC SDcard? Anyone ever done that? For a running product that would be a huge plus, not having to pull and push the connectors all the time to see the new logged data :)
Now I will share my workaround with you; I did simulate in the code, that the card has been pulled out and after a while been pushed in again, that works, BUT then windows does create a popup with connected removable device each time i create a new file, I can live with that but I would rather prefer another solution.
Dont bother if you never seen the elm chan TI-code, but if you have maybe you can point out somethings I could do more easily.
As always I will keep updates about my successes in here, I try to figure out today how to implement it.
Thanks for helping and reading.
seb
// an removal has been detected mediaInfo.mediaPresent = kUSBMSC_MEDIA_NOT_PRESENT; mediaInfo.mediaChanged = 0x01; uint8_t state; Scsi_Read_Capacity_10[0].lLba[0] = (uint8_t)(mediaInfo.lastBlockLba >> 24); Scsi_Read_Capacity_10[0].lLba[1] = (uint8_t)(mediaInfo.lastBlockLba >> 16); Scsi_Read_Capacity_10[0].lLba[2] = (uint8_t)(mediaInfo.lastBlockLba >> 8); Scsi_Read_Capacity_10[0].lLba[3] = (uint8_t)(mediaInfo.lastBlockLba); Scsi_Read_Capacity_10[0].bLength[0] = (uint8_t)(mediaInfo.bytesPerBlock >> 24); Scsi_Read_Capacity_10[0].bLength[1] = (uint8_t)(mediaInfo.bytesPerBlock >> 16); Scsi_Read_Capacity_10[0].bLength[2] = (uint8_t)(mediaInfo.bytesPerBlock >> 8); Scsi_Read_Capacity_10[0].bLength[3] = (uint8_t)(mediaInfo.bytesPerBlock); MscControl[0].lbaSize = (uint16_t)Scsi_Read_Capacity_10[0].bLength[2] << 8 | Scsi_Read_Capacity_10[0].bLength[3]; //If the 0 was reported as not removable, then leave mediaPresent/mediaChanged as //their initialized defaults. if (USBMSC_config.LUN[0].removable){ //Set Unit Attention flag. This flag is used in Scsi_Request_Sense(). MscState.bUnitAttention = TRUE; MscState.Scsi_Status = SCSI_FAILED; state = USBMSC_getState(); if (state == kUSBMSC_readInProgress || state == kUSBMSC_writeInProgress){ if (McsCbw.bmCBWFlags == 0x80){ // DIRECTION_IN usbStallInEndpoint(MSC0_INTFNUM); } else { usbStallOutEndpoint(MSC0_INTFNUM); } Msc_ResetStateMachine(); Msc_ResetFlags(); Msc_ResetStruct(); MscState.isMSCConfigured = TRUE; Scsi_Send_CSW(MSC0_INTFNUM); } // } MscControl[0].bMediaPresent = mediaInfo.mediaPresent; } MscControl[0].bWriteProtected = mediaInfo.writeProtected; // mscProcessBuffer(); // Handle READ/WRITE cmds from the host while(!(P1IN & BIT2)){ __no_operation(); mscProcessBuffer(); // Handle READ/WRITE cmds from the host } __no_operation(); while((P1IN & BIT2)); // an insertion has been detected mediaInfo.mediaPresent = kUSBMSC_MEDIA_PRESENT; mediaInfo.mediaChanged = 0x01; Scsi_Read_Capacity_10[0].lLba[0] = (uint8_t)(mediaInfo.lastBlockLba >> 24); Scsi_Read_Capacity_10[0].lLba[1] = (uint8_t)(mediaInfo.lastBlockLba >> 16); Scsi_Read_Capacity_10[0].lLba[2] = (uint8_t)(mediaInfo.lastBlockLba >> 8); Scsi_Read_Capacity_10[0].lLba[3] = (uint8_t)(mediaInfo.lastBlockLba); Scsi_Read_Capacity_10[0].bLength[0] = (uint8_t)(mediaInfo.bytesPerBlock >> 24); Scsi_Read_Capacity_10[0].bLength[1] = (uint8_t)(mediaInfo.bytesPerBlock >> 16); Scsi_Read_Capacity_10[0].bLength[2] = (uint8_t)(mediaInfo.bytesPerBlock >> 8); Scsi_Read_Capacity_10[0].bLength[3] = (uint8_t)(mediaInfo.bytesPerBlock); MscControl[0].lbaSize = (uint16_t)Scsi_Read_Capacity_10[0].bLength[2] << 8 | Scsi_Read_Capacity_10[0].bLength[3]; /// wenn Karte eingesteckt wird einmal hier rein und naschliessend auch ins nächste MscState.bUnitAttention = TRUE; MscState.Scsi_Status = SCSI_FAILED; if (USBMSC_config.LUN[0].removable){ //Or if media still present, but has changed... //Set Unit Attention flag. This flag is used in Scsi_Request_Sense(). MscState.bUnitAttention = TRUE; MscState.Scsi_Status = SCSI_FAILED; state = USBMSC_getState(); if (state == kUSBMSC_readInProgress || state == kUSBMSC_writeInProgress){ if (McsCbw.bmCBWFlags == 0x80){ // DIRECTION_IN usbStallInEndpoint(MSC0_INTFNUM); } else { usbStallOutEndpoint(MSC0_INTFNUM); } Msc_ResetStateMachine(); Msc_ResetFlags(); Msc_ResetStruct(); MscState.isMSCConfigured = TRUE; Scsi_Send_CSW(MSC0_INTFNUM); } // } MscControl[0].bMediaPresent = mediaInfo.mediaPresent; } MscControl[0].bWriteProtected = mediaInfo.writeProtected; while(!(P1IN & BIT2)){ __no_operation(); mscProcessBuffer(); // Handle READ/WRITE cmds from the host }