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
* (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;