Changeset 41d46ae in avrstuff


Ignore:
Timestamp:
Sep 3, 2012, 11:09:37 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
0262b6e
Parents:
c8ec8ce
Message:

Fix USB communication code. Now to debug the ICSP part...

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • V-USB_Dev/firmwares/herePic/driver/icsp.h

    rc8ec8ce r41d46ae  
    55 */
    66
     7#include <assert.h>
     8#include <errno.h>
    79#include <string.h>
    810
     
    1719                uint16_t Execute(ICSPCommands command, uint16_t param = 0)
    1820                {
    19                         // TODO send the command to the device
     21                        //std::cout << "Sending command " << command << " " << param << " to the device" << std::endl;
     22
     23                        // send the command to the device
    2024                        uint16 length;
    2125                        uint8 reqType = USB_REQTYPE_VENDOR;
     
    2327                        {
    2428                                length = 2;
    25                                 reqType |= USB_REQTYPE_DEVICE_OUT;
     29                                reqType |= USB_REQTYPE_DEVICE_IN; // Device to host
    2630                        } else {
    2731                                length = 0;
    28                                 reqType |= USB_REQTYPE_DEVICE_IN;
     32                                reqType |= USB_REQTYPE_DEVICE_OUT; // Host to device
    2933                        }
    3034
    3135                        ssize_t result = fDevice.ControlTransfer(reqType, command, param, 0,
    32                                 length, &param);
     36                                length, length == 0 ? NULL:&param);
    3337                        if (result == length) {
    3438                                // We transferred as much bytes as we wanted.
     
    3741                        } else {
    3842                                // Not enough bytes transferred, or the result is an error code
    39                                 std::cerr << "USB communication error " << result
    40                                         << "(" << strerror(result) << ")" << std::endl;;
     43                                std::cerr << "USB communication error " << errno
     44                                        << "(" << strerror(errno) << ")" << std::endl;;
    4145                                return result;
    4246                        }
Note: See TracChangeset for help on using the changeset viewer.