Ignore:
Timestamp:
Sep 3, 2012, 8:21:47 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
c8ec8ce
Parents:
f0689d3
Message:

Progress on the host driver. Still untested.

git-svn-id: svn://pulkomandy.tk/avrstuff@66 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • V-USB_Dev/firmwares/herePic/driver/herepic.cpp

    rf0689d3 r8659a17  
    1515#include <USBKit.h>
    1616
     17#include "../shared.h"
     18#include "icsp.h"
    1719
    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.
    2222class MyUSBRoster: public BUSBRoster {
    2323        public:
     
    3535                }
    3636
     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                */
    3741                status_t DeviceAdded(BUSBDevice* device)
    3842                {
     
    4145                                && strcmp(device->ProductString(), "HerePic") == 0)
    4246                        {
    43                                 std::cout << "Programmer found !" << std::endl;
    44                                 // TODO send message to main app to tell it we're ready to go.
    4547                                fDevice = device;
     48                                // Notify main thread it's ok to continue
    4649                                sem_post(&fDeviceLock);
    4750                        }
     
    121124        } while(nextopt != -1);
    122125
    123         if (action <= 0)
     126        // If we found no valid action request, print usage and exit
     127        if (action <= 0 || action == 'h')
    124128        {
    125129                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);
    127133        }
    128134
    129         // TODO take action depending on command request in CLI
    130135        // TODO handle the boring usb stuff... (might be nice to abstract it so we
    131136        // can use both libusb and haiku usb kit)
     
    140145
    141146        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.
    142150        sem_getvalue(&deviceLock, &deviceAvailable);
    143151        if(deviceAvailable == 0)
    144152        {
    145                 std::cout << "Programmer not connected. Waiting for it..." << std::endl;
     153                std::cout << "Programmer hardware not detected. Please connect it now..." << std::endl;
    146154        }
    147155
     156        // Wait for the device
    148157        sem_wait(&deviceLock);
    149158
    150         // Here, perform the programming cycle !
     159        ICSP icsp(*theDevice);
     160
     161        // take action depending on command request in CLI
    151162        switch(action)
    152163        {
    153164                case 'r':
     165                        // read the chip
     166                        icsp.Read(filename);
     167                        break;
    154168                case 'w':
     169                        icsp.Write(filename);
     170                        // Here, perform the programming cycle !
     171                        break;
    155172                case 'e':
    156                         ;
     173                        icsp.Erase();
     174                        // erase the chip
     175                        break;
    157176        }
     177
     178        exit(0);
    158179}
Note: See TracChangeset for help on using the changeset viewer.