/*
 A program to compute descriptor sizes and generate an include
 
 Copyright (c) 2008-2011 Dimtel, Inc., All Rights Reserved

 $Id: descriptors.c,v 1.1 2012/11/11 01:24:32 dim Exp $
 $Date: 2012/11/11 01:24:32 $
 $Author: dim $
 $Revision: 1.1 $
 $Log: descriptors.c,v $
 Revision 1.1  2012/11/11 01:24:32  dim
 Moved from BxB, adapted to compile for both LLRF4 and IGP12

 Revision 1.1  2011/12/27 19:31:45  dim
 Updated to remove deprecated constructs (at, sfr, xdata, sbit)


*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#pragma pack(1)
#include "usb_descriptors.h"
#include "../include/board_ids.h"

int main(void)
{
  int size;
  
  size  = sizeof(usb_device);		/* descr_device    */
  size += sizeof(usb_qualifier);	/* descr_qualifier */
  size += sizeof(usb_config_full);	/* hs_descr_config */
  size += 1;				/* padding0        */
  size += sizeof(usb_config_full);	/* fs_descr_config */
  size += 1;				/* padding1        */
  
  size += 6;                            /* Language */
  size += 2 + strlen(iManufacturer)*2;	/* Manufacturer */
  size += 2 + strlen(iProduct)*2;	/* Product */
/*  size += 2 + strlen(iSerial)*2;	/* Serial */
  size += 2 + strlen(iInter0Alt0HS)*2;	/* Interface 0, alt0, HS */
  size += 2 + strlen(iInter0Alt1HS)*2;	/* Interface 0, alt1, HS */
  size += 2 + strlen(iInter0Alt0FS)*2;	/* Interface 0, alt0, FS */
  size += 2 + strlen(iInter0Alt1FS)*2;	/* Interface 0, alt1, FS */
  
  puts("#ifndef _DESC_SIZE_H_\n#define _DESC_SIZE_H_\n");
  printf("#define USBDESC_USAGE %d\n", size);
  printf("#define USBDESC_SERIAL_MAX %d\n\n", (512 - size - 2) / 2);
  puts("#endif /* _DESC_SIZE_H_ */\n");
  
  return 0;
}
