スマートコンセント(富士通 FX-5204PS)をIEEE1888 StorageにWRITEするサンプルプログラムです。

Dependencies:   EthernetInterface FiapV2 HTTPClientForSOAP NTPClient TextLCD mbed-rtos mbed spxml

Fork of BlueUSB_f by Yasushi TAUCHI

スマートコンセント(富士通 FX-5204PS)をIEEE1888 StorageにWRITEするサンプルプログラムです。
USB HUBを使用して2台利用した例です。
表示のみは http://mbed.org/users/yueee_yt/code/BlueUSB_f/で公開しています。

BlueUSBより派生していますが、BluetoothとMass Storage Classは利用できません。

2台まで確認していますが、プログラム的には10台まで接続できるようにしています。
(RTOSとの整合により難しいかもしれません)

Revision:
1:3f2890d103fb
Parent:
0:606b230e5b4a
--- a/USBHost.h	Sat Apr 10 00:30:24 2010 +0000
+++ b/USBHost.h	Wed Sep 26 06:29:47 2012 +0000
@@ -39,11 +39,11 @@
 #define ENDPOINT_BULK 2
 #define ENDPOINT_INTERRUPT 3
 
-#define  DESCRIPTOR_TYPE_DEVICE			1
-#define  DESCRIPTOR_TYPE_CONFIGURATION	2
-#define  DESCRIPTOR_TYPE_STRING			3
-#define  DESCRIPTOR_TYPE_INTERFACE		4
-#define  DESCRIPTOR_TYPE_ENDPOINT		5
+#define  DESCRIPTOR_TYPE_DEVICE            1
+#define  DESCRIPTOR_TYPE_CONFIGURATION    2
+#define  DESCRIPTOR_TYPE_STRING            3
+#define  DESCRIPTOR_TYPE_INTERFACE        4
+#define  DESCRIPTOR_TYPE_ENDPOINT        5
 
 #define DESCRIPTOR_TYPE_HID         0x21
 #define DESCRIPTOR_TYPE_REPORT      0x22
@@ -52,24 +52,24 @@
 
 enum USB_CLASS_CODE
 {
-	CLASS_DEVICE,
-	CLASS_AUDIO,
-	CLASS_COMM_AND_CDC_CONTROL,
-	CLASS_HID,
-	CLASS_PHYSICAL = 0x05,
-	CLASS_STILL_IMAGING,
-	CLASS_PRINTER,
-	CLASS_MASS_STORAGE,
-	CLASS_HUB,
-	CLASS_CDC_DATA,
-	CLASS_SMART_CARD,
-	CLASS_CONTENT_SECURITY = 0x0D,
-	CLASS_VIDEO = 0x0E,
-	CLASS_DIAGNOSTIC_DEVICE = 0xDC,
-	CLASS_WIRELESS_CONTROLLER = 0xE0,
-	CLASS_MISCELLANEOUS = 0xEF,
-	CLASS_APP_SPECIFIC = 0xFE,
-	CLASS_VENDOR_SPECIFIC = 0xFF
+    CLASS_DEVICE,
+    CLASS_AUDIO,
+    CLASS_COMM_AND_CDC_CONTROL,
+    CLASS_HID,
+    CLASS_PHYSICAL = 0x05,
+    CLASS_STILL_IMAGING,
+    CLASS_PRINTER,
+    CLASS_MASS_STORAGE,
+    CLASS_HUB,
+    CLASS_CDC_DATA,
+    CLASS_SMART_CARD,
+    CLASS_CONTENT_SECURITY = 0x0D,
+    CLASS_VIDEO = 0x0E,
+    CLASS_DIAGNOSTIC_DEVICE = 0xDC,
+    CLASS_WIRELESS_CONTROLLER = 0xE0,
+    CLASS_MISCELLANEOUS = 0xEF,
+    CLASS_APP_SPECIFIC = 0xFE,
+    CLASS_VENDOR_SPECIFIC = 0xFF
 };
 
 #define  DEVICE_TO_HOST         0x80
@@ -77,22 +77,22 @@
 #define  REQUEST_TYPE_CLASS     0x20
 #define  RECIPIENT_DEVICE       0x00
 #define  RECIPIENT_INTERFACE    0x01
-#define  RECIPIENT_ENDPOINT		0x02
-#define  RECIPIENT_OTHER		0x03
+#define  RECIPIENT_ENDPOINT        0x02
+#define  RECIPIENT_OTHER        0x03
 
-#define  GET_STATUS				0
-#define  CLEAR_FEATURE			1
-#define  SET_FEATURE			3
-#define  SET_ADDRESS			5
-#define  GET_DESCRIPTOR			6
-#define  SET_DESCRIPTOR			7
-#define  GET_CONFIGURATION		8
-#define  SET_CONFIGURATION		9
-#define  GET_INTERFACE			10
-#define  SET_INTERFACE			11
-#define  SYNCH_FRAME			11
+#define  GET_STATUS                0
+#define  CLEAR_FEATURE            1
+#define  SET_FEATURE            3
+#define  SET_ADDRESS            5
+#define  GET_DESCRIPTOR            6
+#define  SET_DESCRIPTOR            7
+#define  GET_CONFIGURATION        8
+#define  SET_CONFIGURATION        9
+#define  GET_INTERFACE            10
+#define  SET_INTERFACE            11
+#define  SYNCH_FRAME            11
 
-//		-5 is nak
+//        -5 is nak
 /*
 0010 ACK Handshake
 1010 NAK Handshake
@@ -110,55 +110,55 @@
 
 typedef struct
 {
-	u8	bLength;
-	u8	bDescriptorType;
-	u16 bcdUSB;
-	u8 bDeviceClass;
-	u8 bDeviceSubClass;
-	u8 bDeviceProtocol;
-	u8 bMaxPacketSize;
-	u16 idVendor;
-	u16 idProduct;
-	u16 bcdDevice;	// version
-	u8 iManufacturer;
-	u8 iProduct;
-	u8 iSerialNumber;
-	u8 bNumConfigurations;
-} DeviceDescriptor;	// 16 bytes
+    u8    bLength;
+    u8    bDescriptorType;
+    u16 bcdUSB;
+    u8 bDeviceClass;
+    u8 bDeviceSubClass;
+    u8 bDeviceProtocol;
+    u8 bMaxPacketSize;
+    u16 idVendor;
+    u16 idProduct;
+    u16 bcdDevice;    // version
+    u8 iManufacturer;
+    u8 iProduct;
+    u8 iSerialNumber;
+    u8 bNumConfigurations;
+} DeviceDescriptor;    // 16 bytes
 
 typedef struct
 {
-	u8	bLength;
-	u8	bDescriptorType;
-	u16	wTotalLength;
-	u8	bNumInterfaces;
-	u8	bConfigurationValue;	// Value to use as an argument to select this configuration
-	u8	iConfiguration;			// Index of String Descriptor describing this configuration
-	u8	bmAttributes;			// Bitmap D7 Reserved, set to 1. (USB 1.0 Bus Powered),D6 Self Powered,D5 Remote Wakeup,D4..0 = 0
-	u8	bMaxPower;				// Maximum Power Consumption in 2mA units
+    u8    bLength;
+    u8    bDescriptorType;
+    u16    wTotalLength;
+    u8    bNumInterfaces;
+    u8    bConfigurationValue;    // Value to use as an argument to select this configuration
+    u8    iConfiguration;            // Index of String Descriptor describing this configuration
+    u8    bmAttributes;            // Bitmap D7 Reserved, set to 1. (USB 1.0 Bus Powered),D6 Self Powered,D5 Remote Wakeup,D4..0 = 0
+    u8    bMaxPower;                // Maximum Power Consumption in 2mA units
 } ConfigurationDescriptor;
 
 typedef struct
 {
-	u8	bLength;
-	u8	bDescriptorType;
-	u8  bInterfaceNumber;
-	u8	bAlternateSetting;
-	u8	bNumEndpoints;
-	u8	bInterfaceClass;
-	u8	bInterfaceSubClass;
-	u8	bInterfaceProtocol;
-	u8	iInterface;				// Index of String Descriptor Describing this interface
+    u8    bLength;
+    u8    bDescriptorType;
+    u8  bInterfaceNumber;
+    u8    bAlternateSetting;
+    u8    bNumEndpoints;
+    u8    bInterfaceClass;
+    u8    bInterfaceSubClass;
+    u8    bInterfaceProtocol;
+    u8    iInterface;                // Index of String Descriptor Describing this interface
 } InterfaceDescriptor;
 
 typedef struct
 {
-	u8	bLength;
-	u8	bDescriptorType;
-	u8	bEndpointAddress;	// Bits 0:3 endpoint, Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints)
-	u8	bmAttributes;		// Bits 0:1 00 = Control, 01 = Isochronous, 10 = Bulk, 11 = Interrupt
-	u16 wMaxPacketSize;
-	u8	bInterval;			// Interval for polling endpoint data transfers.
+    u8    bLength;
+    u8    bDescriptorType;
+    u8    bEndpointAddress;    // Bits 0:3 endpoint, Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints)
+    u8    bmAttributes;        // Bits 0:1 00 = Control, 01 = Isochronous, 10 = Bulk, 11 = Interrupt
+    u16 wMaxPacketSize;
+    u8    bInterval;            // Interval for polling endpoint data transfers.
 } EndpointDescriptor;
 
 typedef struct {
@@ -179,22 +179,22 @@
 void USBLoop();
 u8* USBGetBuffer(u32* len);
 
-//	Optional callback for transfers, called at interrupt time
+//    Optional callback for transfers, called at interrupt time
 typedef void (*USBCallback)(int device, int endpoint, int status, u8* data, int len, void* userData);
 
-//	Transfers
+//    Transfers
 int USBControlTransfer(int device, int request_type, int request, int value, int index, u8* data, int length, USBCallback callback = 0, void* userData = 0);
 int USBInterruptTransfer(int device, int ep, u8* data, int length, USBCallback callback = 0, void* userData = 0);
-int USBBulkTransfer(int device, int ep, u8* data, int length, USBCallback callback = 0, void* userData = 0);
+int USBBulkTransfer     (int device, int ep, u8* data, int length, USBCallback callback = 0, void* userData = 0);
 
-//	Standard Device methods
+//    Standard Device methods
 int GetDescriptor(int device, int descType, int descIndex, u8* data, int length);
 int GetString(int device, int index, char* dst, int length);
 int SetAddress(int device, int new_addr);
 int SetConfiguration(int device, int configNum);
 int SetInterface(int device, int ifNum, int altNum);
 
-//	Implemented to notify app of the arrival of a device
+//    Implemented to notify app of the arrival of a device
 void OnLoadDevice(int device, DeviceDescriptor* deviceDesc, InterfaceDescriptor* interfaceDesc);
 
 #endif
\ No newline at end of file