]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/app/usbcan/usb_vend.c
lpc17xx embedded: new function for obtaining chip bittiming constant parameters.
[lincan.git] / embedded / app / usbcan / usb_vend.c
index fbe5be97bd402760ecd644cecb5c9ec4247c1a72..460c85d7573fac82bc5dfa5fcff80e3067cc063e 100644 (file)
@@ -14,7 +14,7 @@
   #include <byteswap.h>
 #endif
 
-#include "./can/lpc17xx_can.h"
+#include "./can/can_bittiming.h"
 
 extern struct canuser_t *canuser;
 extern uint8_t vendor_ret;
@@ -140,12 +140,12 @@ error:
        return -1;
 }
 
-int get_bittiming_const_complete_fnc(usb_device_t *udev){
-
+int usbcan_get_bittiming_const_reply(usb_device_t *udev){
        int dest_chip;
+       struct canchip_t *chip;
 
-       struct can_lmc1_chip_data *chip_data=NULL;
-       struct can_bittiming_const *btc;
+       struct can_bittiming_const btc_buff;
+       struct can_bittiming_const *btc = &btc_buff;
 
        uint8_t buffer[USBCAN_BITTIMING_CONST_SIZE];
        uint32_t *ptr;
@@ -155,14 +155,13 @@ int get_bittiming_const_complete_fnc(usb_device_t *udev){
                dest_chip=(udev->request.wIndex);
                if ((dest_chip>=MAX_TOT_CHIPS)||(dest_chip<0))
                        goto error;
-               if (!chips_p[dest_chip])
+               if ((chip = chips_p[dest_chip]) == NULL)
                        goto error;
-               if ((chip_data=((struct can_lmc1_chip_data*)(chips_p[dest_chip]->chip_data)))==NULL){
+               if (chip->chipspecops->get_bittiming_const == NULL){
                        goto error;
                }
 
-               btc = &chip_data->btc;
-               
+               chip->chipspecops->get_bittiming_const(chip, btc);              
                ptr = (uint32_t*) buffer;
 
                #if __BYTE_ORDER == __BIG_ENDIAN
@@ -217,7 +216,7 @@ int usbcan_vendor(usb_device_t *udev)
                        return 1;
 
                case USBCAN_VENDOR_GET_BITTIMING_CONST:
-                       get_bittiming_const_complete_fnc(udev);
+                       usbcan_get_bittiming_const_reply(udev);
                        return 1;
                //lpc17xx - end