From: Martin Mares Date: Sat, 11 Aug 2018 12:25:28 +0000 (+0200) Subject: SSR: Switched to libucw X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=9bfa87e890a50801b682ae9e7b45093663fc1082;p=home-hw.git SSR: Switched to libucw --- diff --git a/ssr/turris/Makefile b/ssr/turris/Makefile index 82a5498..dd71f4a 100644 --- a/ssr/turris/Makefile +++ b/ssr/turris/Makefile @@ -6,12 +6,14 @@ include $(TOPDIR)/include/package.mk PC := PATH=$(STAGING_DIR_HOST)/bin:$(PATH) PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) PKG_CONFIG_LIBDIR=$(PKG_CONFIG_PATH) STAGING_PREFIX=$(STAGING_DIR)/usr $(PKG_CONFIG) USB_CFLAGS := $(shell $(PC) --cflags libusb-1.0) USB_LDFLAGS := $(shell $(PC) --libs libusb-1.0) +UCW_CFLAGS := $(shell $(PC) --cflags libucw) +UCW_LDFLAGS := $(shell $(PC) --libs libucw) export PATH=$(TARGET_PATH_PKG) CC=$(TARGET_CC_NOCACHE) LD=$(TARGET_LD_NOCACHE) -CFLAGS=$(TARGET_CFLAGS) $(USB_CFLAGS) -std=gnu99 -LDFLAGS=$(TARGET_LDFLAGS) $(USB_LDFLAGS) +CFLAGS=$(TARGET_CFLAGS) $(USB_CFLAGS) $(UCW_CFLAGS) -std=gnu99 +LDFLAGS=$(TARGET_LDFLAGS) $(USB_LDFLAGS) $(UCW_LDFLAGS) all: ssr-control upload diff --git a/ssr/turris/ssr-control.c b/ssr/turris/ssr-control.c index 0b680a0..cd3e082 100644 --- a/ssr/turris/ssr-control.c +++ b/ssr/turris/ssr-control.c @@ -4,6 +4,9 @@ * (c) 2018 Martin Mares */ +#include +#include + #include #include #include @@ -11,39 +14,12 @@ #include #include #include -#include -typedef uint8_t byte; -typedef uint16_t u16; -typedef uint32_t u32; +#include struct libusb_context *usb_ctxt; struct libusb_device_handle *devh; -static void __attribute__((noreturn)) die(char *msg, ...) -{ - va_list args; - va_start(args, msg); - vfprintf(stderr, msg, args); - fputc('\n', stderr); - exit(1); -} - -static inline u32 get_u32_be(const void *p) -{ - const byte *c = (const byte *)p; - return (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]; -} - -static inline void put_u32_be(void *p, u32 x) -{ - byte *c = (byte *)p; - c[0] = x >> 24; - c[1] = x >> 16; - c[2] = x >> 8; - c[3] = x; -} - void open_device(void) { int err;