+int set_canbtr_complete_fnc(struct usb_ep_t *ep, int status){
+ int dest_chip;
+
+// int32_t rate,sjw,sampl_pt,flags;
+ uint32_t brp, sjw, tseg1, tseg2;
+
+ struct can_lmc1_chip_data *chip_data=NULL;
+
+ usb_device_t *udev=ep->udev;
+ unsigned char *data=ep->ptr - ep->actual;
+
+ if (udev->request.bRequest==USBCAN_VENDOR_SET_CANBTR){
+ dest_chip=(udev->request.wIndex);
+ if ((dest_chip>=MAX_TOT_CHIPS)||(dest_chip<0))
+ goto error;
+ if (!chips_p[dest_chip])
+ goto error;
+ if ((chip_data=((struct can_lmc1_chip_data*)(chips_p[dest_chip]->chip_data)))==NULL)
+ goto nodata;
+
+ brp=*(uint32_t *)(data);
+ sjw=*(uint32_t *)(data+4);
+ tseg1=*(uint32_t *)(data+8);
+ tseg2=*(uint32_t *)(data+12);
+ #if __BYTE_ORDER == __BIG_ENDIAN
+ brp = bswap_32(brp);
+ sjw = bswap_32(sjw);
+ tseg1 = bswap_32(tseg1);
+ tseg2 = bswap_32(tseg2);
+ #endif
+
+
+ printf("BRP: %d, SJW: %d, TSEG1: %d, TSEG2: %d \n", brp, sjw, tseg1, tseg2);
+ CAN_set_bittiming(chips_p[dest_chip], brp, sjw, tseg1, tseg2);
+
+// if (chips_p[dest_chip]->chipspecops->baud_rate(chips_p[dest_chip], rate, chips_p[dest_chip]->clock, sjw, sampl_pt, flags)<0)
+// goto error;
+ chip_data->flags |= CAN_LMC1_CHIP_CANBTR_SET;
+ }
+ return 0;
+error:
+ chip_data->flags &= ~CAN_LMC1_CHIP_CANBTR_SET;
+nodata:
+ return -1;
+}
+