main
John Lauer Publish assumption-based R11 assembly study, locked firmware and new review footage d61d6cb
/* Lab bring-up identity only. Replace with Adom's allocated VID/PID before release.
 * Descriptor structures/macros are provided by TinyUSB (MIT; see licenses). */
#include "tusb.h"
#include <string.h>
#ifndef ADOM_USB_VID
#error An explicit USB VID is required
#endif
#ifndef ADOM_USB_PID
#error An explicit USB PID is required
#endif
extern char load_device_serial[33];
static const tusb_desc_device_t device={
 .bLength=sizeof(tusb_desc_device_t),.bDescriptorType=TUSB_DESC_DEVICE,.bcdUSB=0x0200,
 .bDeviceClass=TUSB_CLASS_MISC,.bDeviceSubClass=MISC_SUBCLASS_COMMON,.bDeviceProtocol=MISC_PROTOCOL_IAD,
 .bMaxPacketSize0=64,.idVendor=ADOM_USB_VID,.idProduct=ADOM_USB_PID,.bcdDevice=0x0001,
 .iManufacturer=1,.iProduct=2,.iSerialNumber=3,.bNumConfigurations=1};
static const uint8_t config[]={
 TUD_CONFIG_DESCRIPTOR(1,2,0,TUD_CONFIG_DESC_LEN+TUD_CDC_DESC_LEN,TUSB_DESC_CONFIG_ATT_SELF_POWERED,0),
 TUD_CDC_DESCRIPTOR(0,4,0x81,8,0x02,0x82,64)};
const uint8_t *tud_descriptor_device_cb(void){return (const uint8_t *)&device;}
const uint8_t *tud_descriptor_configuration_cb(uint8_t index){(void)index;return config;}
const uint16_t *tud_descriptor_string_cb(uint8_t index,uint16_t langid){
 (void)langid;static uint16_t out[64];const char *s;
 if(index==0){out[0]=(TUSB_DESC_STRING<<8)|4;out[1]=0x0409;return out;}
 switch(index){case 1:s="Adom prototype";break;case 2:s="Electronic load USB bring-up - output locked OFF";break;case 3:s=load_device_serial;break;case 4:s="Load protocol";break;default:return NULL;}
 size_t n=strlen(s);if(n>63)n=63;for(size_t i=0;i<n;i++)out[i+1]=(uint8_t)s[i];out[0]=(uint16_t)((TUSB_DESC_STRING<<8)|(2*n+2));return out;
}