+#define CAN_DEBUG
+
#include <stdio.h>
#include <system_def.h>
#include <hal_intr.h>
-#include "./can/ul_usb1.h"
#include "./can/can.h"
-#include "./can/can_sysdep.h"
+#include "./can/can_sysless.h"
#include "./can/main.h"
#include "./can/devcommon.h"
#include "./usb/usb_vend.h"
-//#include "./can/ul_usb1.h"
+#include "./can/ul_usb1.h"
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#include <byteswap.h>
#endif
extern struct canuser_t *canuser;
+extern uint8_t vendor_ret;
int set_ext_mask_complete_fnc(struct usb_ep_t *ep, int status){
int dest_chip;
// wIndex, wValue, bRequest, wLength
int dest_chip;
struct ul_usb1_chip_data *chip_data;
- uint8_t ret;
dest_chip=(udev->request.wIndex);
if ((dest_chip>=MAX_TOT_CHIPS)||(dest_chip<0))
- return 0; // Should look like ok (0) or stall (-1)?
+ return -1; // Should look like ok (0) or stall (-1)?
if (!chips_p[dest_chip])
- return 0; // Should look like ok (0) or stall (-1)?
+ return -1; // Should look like ok (0) or stall (-1)?
switch ( udev->request.bRequest) {
case USBCAN_VENDOR_EXT_MASK_SET:
udev->ep0.complete_fnc=set_ext_mask_complete_fnc;
return 1;
case USBCAN_VENDOR_EXT_MASK_STATUS:
- ret=-1;
+ vendor_ret=-1;
if ((chip_data=((struct ul_usb1_chip_data*)(chips_p[dest_chip]->chip_data)))==NULL)
- usb_send_control_data(udev,&ret,1);
+ usb_send_control_data(udev,&vendor_ret,1);
else{
- ret=(chip_data->flags & UL_USB1_CHIP_MASK_SET)?1:0;
- usb_send_control_data(udev,&ret,1);
+ vendor_ret=(chip_data->flags & UL_USB1_CHIP_MASK_SET)?1:0;
+ usb_send_control_data(udev,&vendor_ret,1);
}
chip_data->flags &= ~UL_USB1_CHIP_MASK_SET;
return 1;
udev->ep0.complete_fnc=set_baud_rate_complete_fnc;
return 1;
case USBCAN_VENDOR_BAUD_RATE_STATUS:
- ret=-1;
+ vendor_ret=-1;
if ((chip_data=((struct ul_usb1_chip_data*)(chips_p[dest_chip]->chip_data)))==NULL)
- usb_send_control_data(udev,&ret,1);
+ usb_send_control_data(udev,&vendor_ret,1);
else{
- ret=(chip_data->flags & UL_USB1_CHIP_BAUD_SET)?1:0;
- usb_send_control_data(udev,&ret,1);
+ vendor_ret=(chip_data->flags & UL_USB1_CHIP_BAUD_SET)?1:0;
+ usb_send_control_data(udev,&vendor_ret,1);
}
chip_data->flags &= ~UL_USB1_CHIP_BAUD_SET;
return 1;
case USBCAN_VENDOR_SET_BTREGS:
{
uint16_t value=udev->request.wValue;
- ret=1;
+ vendor_ret=1;
if (chips_p[dest_chip]->chipspecops->set_btregs(chips_p[dest_chip],value&0xFF,(value>>8)&0xFF)<0)
- ret=0;
- usb_send_control_data(udev,&ret,1);
- return 1;
+ vendor_ret=0;
+ usb_send_control_data(udev,&vendor_ret,1);
}
return 1;
{
struct canque_edge_t *qedge;
struct canque_slot_t *slot;
- ret=0;
+ vendor_ret=0;
if (canque_get_inslot(canuser->qends, &qedge, &slot, 0)>=0){
canque_abort_inslot(canuser->qends, qedge, slot);
- ret=1;
+ DEBUGMSG("USBCAN_VENDOR_CHECK_TX_STAT - Free slot found\r\n");
+ vendor_ret=1;
}
- usb_send_control_data(udev,&ret,1);
+ DEBUGMSG("USBCAN_VENDOR_CHECK_TX_STAT - Sending %d\r\n",vendor_ret);
+ usb_send_control_data(udev,&vendor_ret,1);
return 1;
}
case USBCAN_VENDOR_START_CHIP:
- ret=1;
+ vendor_ret=1;
if (chips_p[dest_chip]->chipspecops->start_chip(chips_p[dest_chip])<0)
- ret=0;
- usb_send_control_data(udev,&ret,1);
+ vendor_ret=0;
+ usb_send_control_data(udev,&vendor_ret,1);
return 1;
case USBCAN_VENDOR_STOP_CHIP:
- ret=1;
+ vendor_ret=1;
if (chips_p[dest_chip]->chipspecops->stop_chip(chips_p[dest_chip])<0)
- ret=0;
- usb_send_control_data(udev,&ret,1);
+ vendor_ret=0;
+ usb_send_control_data(udev,&vendor_ret,1);
return 1;
}