Changeset 8659a17 in avrstuff for V-USB_Dev/firmwares/herePic/driver/herepic.cpp
- Timestamp:
- Sep 3, 2012, 8:21:47 PM (12 years ago)
- Branches:
- main
- Children:
- c8ec8ce
- Parents:
- f0689d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
V-USB_Dev/firmwares/herePic/driver/herepic.cpp
rf0689d3 r8659a17 15 15 #include <USBKit.h> 16 16 17 #include "../shared.h" 18 #include "icsp.h" 17 19 18 // We need a subclass of USBRoster to enumerate devices. The Deviceadded hook 19 // will be called for all plugged devices. If we don't find the correct one, 20 // it will also be called later, as devices are plugged. So we can wait for the 21 // right device to come in ! 20 21 // We need a subclass of USBRoster to enumerate devices. 22 22 class MyUSBRoster: public BUSBRoster { 23 23 public: … … 35 35 } 36 36 37 /* The DeviceAdded hook will be called for all plugged devices. 38 If we don't find the correct one, the method will also be called later, 39 as devices are plugged. So we can wait for the right device to come in! 40 */ 37 41 status_t DeviceAdded(BUSBDevice* device) 38 42 { … … 41 45 && strcmp(device->ProductString(), "HerePic") == 0) 42 46 { 43 std::cout << "Programmer found !" << std::endl;44 // TODO send message to main app to tell it we're ready to go.45 47 fDevice = device; 48 // Notify main thread it's ok to continue 46 49 sem_post(&fDeviceLock); 47 50 } … … 121 124 } while(nextopt != -1); 122 125 123 if (action <= 0) 126 // If we found no valid action request, print usage and exit 127 if (action <= 0 || action == 'h') 124 128 { 125 129 usage(argv[0]); 126 exit(action); 130 // Exit code is EXIT_SUCCESS if we reach this by -h option. Otherwise 131 // the arguments are incorrect 132 exit(action < 0 ? action : 0); 127 133 } 128 134 129 // TODO take action depending on command request in CLI130 135 // TODO handle the boring usb stuff... (might be nice to abstract it so we 131 136 // can use both libusb and haiku usb kit) … … 140 145 141 146 int deviceAvailable; 147 // TODO we rely on the initial device scan being done when we get here. Is 148 // that always true ? If not, we may print this message in cases where it 149 // is not needed. 142 150 sem_getvalue(&deviceLock, &deviceAvailable); 143 151 if(deviceAvailable == 0) 144 152 { 145 std::cout << "Programmer not connected. Waiting for it..." << std::endl;153 std::cout << "Programmer hardware not detected. Please connect it now..." << std::endl; 146 154 } 147 155 156 // Wait for the device 148 157 sem_wait(&deviceLock); 149 158 150 // Here, perform the programming cycle ! 159 ICSP icsp(*theDevice); 160 161 // take action depending on command request in CLI 151 162 switch(action) 152 163 { 153 164 case 'r': 165 // read the chip 166 icsp.Read(filename); 167 break; 154 168 case 'w': 169 icsp.Write(filename); 170 // Here, perform the programming cycle ! 171 break; 155 172 case 'e': 156 ; 173 icsp.Erase(); 174 // erase the chip 175 break; 157 176 } 177 178 exit(0); 158 179 }
Note:
See TracChangeset
for help on using the changeset viewer.