]> mj.ucw.cz Git - home-hw.git/commitdiff
BSB: More interface definitions
authorMartin Mares <mj@ucw.cz>
Wed, 26 Feb 2020 17:31:04 +0000 (18:31 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 26 Feb 2020 17:31:04 +0000 (18:31 +0100)
bsb/firmware/interface.h
bsb/firmware/main.c

index 0168d2038907f0dc38af6f42fed47dac9bd05639..84595c29d0e8d9502fb4b5678d5f67be4936b187 100644 (file)
@@ -4,6 +4,11 @@
  *     (c) 2020 Martin Mareš <mj@ucw.cz>
  */
 
+#define BSB_USB_VENDOR 0x4242
+#define BSB_USB_PRODUCT 0x0003
+#define BSB_USB_VERSION 0x0100
+
+// Status sent on the interrupt endpoint
 enum bsb_tx_result {
        TX_RESULT_NONE,
        TX_RESULT_OK,
@@ -30,3 +35,36 @@ struct bsb_stats {
        u32 tx_ok;
 };
 
+/*
+ *     Structure of BSB frames
+ *
+ *             start of frame (0xdc)
+ *             source address XOR 0x80
+ *             destination address
+ *             length
+ *             operation
+ *             <parameters depending on operation>
+ *             16-bit CRC
+ */
+
+enum bsb_address {
+       BSB_ADDR_BOILER = 0,
+       BSB_ADDR_EXT_BOARD = 3,
+       BSB_ADDR_ROOM1 = 6,
+       BSB_ADDR_ROOM2 = 7,
+       BSB_ADDR_GATEWAY = 0x42,
+       BSB_ADDR_BROADCAST = 0x7f,
+};
+
+enum bsb_op {
+       BSB_OP_REQUEST_INFO = 1,
+       BSB_OP_INFO = 2,
+       BSB_OP_SET = 3,
+       BSB_OP_ACK = 4,
+       BSB_OP_NACK = 5,
+       BSB_OP_QUERY = 6,
+       BSB_OP_ANSWER = 7,
+       BSB_OP_ERROR = 8,
+       BSB_OP_QUERY_DEFAULT = 0x0f,
+       BSB_OP_ANSWER_DEFAULT = 0x10,
+};
index c2b5397bd901e106aecfc18d6d024e20bb03f400..ca30ffe1e6c02244e211ed285ed85c5aa87a1f44 100644 (file)
@@ -422,6 +422,20 @@ static void bsb_init(void)
 
 static usbd_device *usbd_dev;
 
+enum usb_string {
+       STR_MANUFACTURER = 1,
+       STR_PRODUCT,
+       STR_SERIAL,
+};
+
+static char usb_serial_number[13];
+
+static const char *usb_strings[] = {
+       "United Computer Wizards",
+       "BSB Gateway",
+       usb_serial_number,
+};
+
 static const struct usb_device_descriptor device = {
        .bLength = USB_DT_DEVICE_SIZE,
        .bDescriptorType = USB_DT_DEVICE,
@@ -430,12 +444,12 @@ static const struct usb_device_descriptor device = {
        .bDeviceSubClass = 0,
        .bDeviceProtocol = 0,
        .bMaxPacketSize0 = 64,
-       .idVendor = 0x4242,
-       .idProduct = 0x0003,
-       .bcdDevice = 0x0200,
-       .iManufacturer = 1,
-       .iProduct = 2,
-       .iSerialNumber = 3,
+       .idVendor = BSB_USB_VENDOR,
+       .idProduct = BSB_USB_PRODUCT,
+       .bcdDevice = BSB_USB_VERSION,
+       .iManufacturer = STR_MANUFACTURER,
+       .iProduct = STR_PRODUCT,
+       .iSerialNumber = STR_SERIAL,
        .bNumConfigurations = 1,
 };
 
@@ -514,14 +528,6 @@ static const struct usb_config_descriptor config = {
        .interface = ifaces,
 };
 
-static char usb_serial_number[13];
-
-static const char *usb_strings[] = {
-       "United Computer Wizards",
-       "BSB Gateway",
-       usb_serial_number,
-};
-
 static byte usb_configured;
 static byte usb_ep82_pending;
 static uint8_t usbd_control_buffer[64];