From: Martin Mares Date: Wed, 26 Feb 2020 17:31:04 +0000 (+0100) Subject: BSB: More interface definitions X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e0be750110e27eda533b385d43aa49177de21900;p=home-hw.git BSB: More interface definitions --- diff --git a/bsb/firmware/interface.h b/bsb/firmware/interface.h index 0168d20..84595c2 100644 --- a/bsb/firmware/interface.h +++ b/bsb/firmware/interface.h @@ -4,6 +4,11 @@ * (c) 2020 Martin Mareš */ +#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 + * + * 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, +}; diff --git a/bsb/firmware/main.c b/bsb/firmware/main.c index c2b5397..ca30ffe 100644 --- a/bsb/firmware/main.c +++ b/bsb/firmware/main.c @@ -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];