]> mj.ucw.cz Git - home-hw.git/commitdiff
SSR: Switched to libucw
authorMartin Mares <mj@ucw.cz>
Sat, 11 Aug 2018 12:25:28 +0000 (14:25 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 11 Aug 2018 12:25:28 +0000 (14:25 +0200)
ssr/turris/Makefile
ssr/turris/ssr-control.c

index 82a5498e8ce08fd21c2cffbb5f3e416e5097b45c..dd71f4a8ab8380023045b5a543c602c04b28f214 100644 (file)
@@ -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
 
index 0b680a0e99332439b6484c6845e44bb839e3127f..cd3e0826252b32dc5a3b6e1b22c3e68d0f808154 100644 (file)
@@ -4,6 +4,9 @@
  *     (c) 2018 Martin Mares <mj@ucw.cz>
  */
 
+#include <ucw/lib.h>
+#include <ucw/unaligned.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <time.h>
-#include <libusb-1.0/libusb.h>
 
-typedef uint8_t byte;
-typedef uint16_t u16;
-typedef uint32_t u32;
+#include <libusb-1.0/libusb.h>
 
 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;