USB composite device example program, drag-and-drop flash writer.

Dependencies:   SWD USBDevice mbed BaseDAP

Embed: (wiki syntax)

« Back to documentation index

USBMSD_Drop Class Reference

USBMSD_Drop Class Reference

drag-and-drop using the USBMSD class More...

#include <USBMSD_Drop.h>

Inherited by myUSBMSD_Drop, myUSBMSD_Drop, and USBMSD_LPC.

Public Member Functions

 USBMSD_Drop ()
 create drag-and-drop file transfer
virtual void Drop (const uint8_t *data, int len, int offset, int total)
 drag-and-drop file received
void attach (void(*fptr)(const uint8_t *data, int len, int offset, int total))
 Attach a callback for when a file is received.

Detailed Description

drag-and-drop using the USBMSD class

 #include "mbed.h"
 #include "USBMSD_Drop.h"
 Serial pc(USBTX, USBRX);
 USBMSD_Drop* host;
 
 void callback(const uint8_t* data, int len, int offset, int total)
 {
     for(int i = 0; i < len && (offset+i) < total; i++) {
         pc.putc(data[i]);
     }
 }
 
 int main() {
     host = new USBMSD_Drop();
     host->attach(callback);
     while(1); // forever
 }

Definition at line 33 of file USBMSD_Drop.h.


Constructor & Destructor Documentation

USBMSD_Drop (  )

create drag-and-drop file transfer

Definition at line 7 of file USBMSD_Drop.cpp.


Member Function Documentation

void attach ( void(*)(const uint8_t *data, int len, int offset, int total)  fptr )

Attach a callback for when a file is received.

Parameters:
fptrfunction pointer

Definition at line 17 of file USBMSD_Drop.cpp.

virtual void Drop ( const uint8_t *  data,
int  len,
int  offset,
int  total 
) [virtual]

drag-and-drop file received

Parameters:
datareceived data pointer
lendata length
offsetoffset from file top
totaltotal file size

Reimplemented in USBMSD_LPC.

Definition at line 47 of file USBMSD_Drop.h.