Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

int flexcan_mbm_xmit ( struct flexcan_device *  flexcan,
struct can_frame *  frame 
)

function to xmit message buffer

Parameters:
flexcan the pointer of can hardware device.
frame the pointer of can message frame.
Returns:
Returns 0 if xmit is success. otherwise returns non-zero.

Definition at line 249 of file mbm.c.

{
      int i = flexcan->xmit_mb;
      struct can_hw_mb *hwmb = flexcan->hwmb;

      do {
            if (hwmb[i].mb_cs.cs.code == CAN_MB_TX_INACTIVE)
                  break;
            if ((++i) > flexcan->maxmb) {
                  if (flexcan->fifo)
                        i = FLEXCAN_MAX_FIFO_MB;
                  else
                        i = flexcan->xmit_maxmb + 1;
            }
            if (i == flexcan->xmit_mb)
                  return -1;
      } while (1);

      flexcan->xmit_mb = i + 1;
      if (flexcan->xmit_mb > flexcan->maxmb) {
            if (flexcan->fifo)
                  flexcan->xmit_mb = FLEXCAN_MAX_FIFO_MB;
            else
                  flexcan->xmit_mb = flexcan->xmit_maxmb + 1;
      }

      if (frame->can_id & CAN_RTR_FLAG)
            hwmb[i].mb_cs.cs.rtr = 1;
      else
            hwmb[i].mb_cs.cs.rtr = 0;

      if (frame->can_id & CAN_EFF_FLAG) {
            hwmb[i].mb_cs.cs.ide = 1;
            hwmb[i].mb_cs.cs.srr = 1;
            hwmb[i].mb_id = frame->can_id & CAN_EFF_MASK;
      } else {
            hwmb[i].mb_cs.cs.ide = 0;
            hwmb[i].mb_id = (frame->can_id & CAN_SFF_MASK) << 18;
      }

      hwmb[i].mb_cs.cs.length = frame->can_dlc;
      flexcan_memcpy(hwmb[i].mb_data, frame->data, frame->can_dlc);
      hwmb[i].mb_cs.cs.code = CAN_MB_TX_ONCE;
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index