スマートコンセント PS-5204PSをmbedで
Dependencies: FatFileSystemCpp mbed TextLCD
Fork of BlueUSB by
Fusjitsu スマートコンセント FX-5204PSを利用できます。
BlueUSBを利用していますが、Bluetoothは兼用できません。
複数台利用するには、USBハブを使用してください。ただし相性があります。
・良ければ10台まで利用できるかも。
・稼働中に追加はできますが、外すことはできません。
LED1-3, スマートコンセント接続状態(3台まで表示)
LED4、点滅で正常動作
Diff: main.cpp
- Revision:
- 1:3f2890d103fb
- Parent:
- 0:606b230e5b4a
- Child:
- 2:32a2d06f4fe2
--- a/main.cpp Sat Apr 10 00:30:24 2010 +0000 +++ b/main.cpp Wed Sep 26 06:29:47 2012 +0000 @@ -34,34 +34,28 @@ int _device; u32 _blockSize; u32 _blockCount; - + public: - USBFileSystem() : FATFileSystem("usb"),_device(0),_blockSize(0),_blockCount(0) - { + USBFileSystem() : FATFileSystem("usb"),_device(0),_blockSize(0),_blockCount(0) { } - - void SetDevice(int device) - { + + void SetDevice(int device) { _device = device; } - - virtual int disk_initialize() - { + + virtual int disk_initialize() { return MassStorage_ReadCapacity(_device,&_blockCount,&_blockSize); } - - virtual int disk_write(const char *buffer, int block_number) - { + + virtual int disk_write(const char *buffer, int block_number) { return MassStorage_Write(_device,block_number,1,(u8*)buffer,_blockSize); } - - virtual int disk_read(char *buffer, int block_number) - { + + virtual int disk_read(char *buffer, int block_number) { return MassStorage_Read(_device,block_number,1,(u8*)buffer,_blockSize); } - - virtual int disk_sectors() - { + + virtual int disk_sectors() { return _blockCount; } }; @@ -69,16 +63,14 @@ void DumpFS(int depth, int count) { DIR *d = opendir("/usb"); - if (!d) - { + if (!d) { printf("USB file system borked\n"); return; } printf("\nDumping root dir\n"); struct dirent *p; - for(;;) - { + for(;;) { p = readdir(d); if (!p) break; @@ -112,10 +104,24 @@ } void TestShell(); - +void InitUSPS(); +void USPS_Refresh(); +DigitalOut led1(LED1); +Timer t; int main() { pc.baud(460800); printf("BlueUSB\nNow get a bunch of usb or bluetooth things and plug them in\n"); - TestShell(); + InitUSPS(); + //TestShell(); + USBInit(); + t.start(); + while(1){ + USBLoop(); + if(t>1 ){ + t.start(); + led1=!led1; +USPS_Refresh(); + } + } }