tr4mpass/include/util/usb_helpers.h
tr4m0ryp f369657971 Task 002: Utility modules (log, plist_helpers, usb_helpers)
Implemented three foundational utility modules:
- log: leveled logging with ANSI colors to stderr
- plist_helpers: libplist convenience wrappers for dict access and XML serialization
  (renamed plist_dict_get_bool_val/plist_dict_get_uint_val to avoid collision with
  libplist 2.x native symbols plist_dict_get_bool/plist_dict_get_uint)
- usb_helpers: libusb control transfer wrappers for DFU operations

Files created:
- include/util/log.h, src/util/log.c
- include/util/plist_helpers.h, src/util/plist_helpers.c
- include/util/usb_helpers.h, src/util/usb_helpers.c

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 01:55:57 +02:00

37 lines
1.2 KiB
C

#ifndef USB_HELPERS_H
#define USB_HELPERS_H
#include <stdint.h>
#include <libusb-1.0/libusb.h>
/*
* Perform a USB control transfer with a data stage.
* Returns number of bytes transferred on success, negative libusb error code
* on failure.
*/
int usb_ctrl_transfer(libusb_device_handle *dev,
uint8_t bmRequestType,
uint8_t bRequest,
uint16_t wValue,
uint16_t wIndex,
unsigned char *data,
uint16_t wLength,
unsigned int timeout);
/*
* Perform a USB control transfer with no data stage (wLength=0).
* Returns 0 on success, negative libusb error code on failure.
*/
int usb_ctrl_transfer_no_data(libusb_device_handle *dev,
uint8_t bmRequestType,
uint8_t bRequest,
uint16_t wValue,
uint16_t wIndex,
unsigned int timeout);
/*
* Print a human-readable description of a libusb error code to stderr.
*/
void usb_print_error(int libusb_error);
#endif /* USB_HELPERS_H */