Changeset 8659a17 in avrstuff
- Timestamp:
- Sep 3, 2012, 8:21:47 PM (12 years ago)
- Branches:
- main
- Children:
- c8ec8ce
- Parents:
- f0689d3
- Location:
- V-USB_Dev/firmwares/herePic
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
V-USB_Dev/firmwares/herePic/driver/Makefile
rf0689d3 r8659a17 1 herepic: herepic.cpp 2 g++ -o $@ $ ^-Os -Wall -ldevice1 herepic: herepic.cpp icsp.h ../shared.h 2 g++ -o $@ $< -Os -Wall -ldevice -
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 } -
V-USB_Dev/firmwares/herePic/main.c
rf0689d3 r8659a17 1 /* HEREPIC - AVR-based ICSP programmer for microchip PIC16F6xx and 16F8xx devices2 * Copyright 2012, Adrien Destugues <pulkomandy@pulkomandy.tk>3 *4 * This file is distributed under the terms of the MIT licence.5 */6 1 7 2 /* This project is targetted at the VUSBDev hacking board. */ … … 17 12 18 13 #include "usbdrv/usbdrv.h" 14 #include "shared.h" 19 15 20 16 // IO pins: … … 39 35 // Timers may make it easier to do that in parallel with the USB handling, since 40 36 // timings are in the nanosecond range. 41 42 43 // ICSP commands are 6-bit wide, for most of them (but not all) the 2 MSb are44 // ignored.45 // We also use these as USB commands for now, but we may do otherwise, since46 // transferring only 14 data bytes in an USB frame is quite a bit of waste.47 // We need some custom commands on USB side as well, to reset the PIC and such48 // things.49 typedef enum50 {51 // HOST to DEVICE52 LoadConfigWord = 0b0000,53 LoadCodeWord = 0b0010,54 LoadDataWord = 0b0011,55 56 // Configuration57 NextAddress = 0b0110,58 BeginEraseProgram = 0b001000,59 BeginProgramOnly = 0b011000,60 BulkEraseCode = 0b1001,61 BulkEraseData = 0b1011,62 BulkEraseConfig1 = 0b000001,63 BulkEraseConfig2 = 0b000111,64 65 // DEVICE to HOST66 ReadCodeWord = 0b0100,67 ReadDataWord = 0b0101,68 } ICSPCommands;69 37 70 38
Note:
See TracChangeset
for help on using the changeset viewer.