|
|
@ -28,6 +28,8 @@ typedef struct _Sm2310_DEV_HANDLE { |
|
|
|
|
|
|
|
SEL_WAKEUP_LIST selList; |
|
|
|
|
|
|
|
volatile BOOL irqFlag; |
|
|
|
|
|
|
|
void (*usrIsr)(); |
|
|
|
|
|
|
|
SM2130_SPI_DEV *pDevCtrl; |
|
|
@ -346,14 +348,21 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
SM2130_XFER *xfer; |
|
|
|
SM2130_SPI_DEV *pDrvCtrl = dev->pDevCtrl; |
|
|
|
STATUS ret = OK; |
|
|
|
BOOL iflag; |
|
|
|
|
|
|
|
semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
switch (cmd) { |
|
|
|
case FIOSELECT: |
|
|
|
ret = selNodeAdd(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
|
if (dev->irqFlag) { |
|
|
|
selWakeup((SEL_WAKEUP_NODE *)arg); |
|
|
|
} else { |
|
|
|
if (selNodeAdd(&dev->selList, (SEL_WAKEUP_NODE *)arg) == ERROR) { |
|
|
|
selWakeup((SEL_WAKEUP_NODE *)arg); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case FIOUNSELECT: |
|
|
|
ret = selNodeDelete(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
|
selNodeDelete(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
|
break; |
|
|
|
case FIOC_SM2130_WR: |
|
|
|
xfer = (SM2130_XFER *)(arg); |
|
|
@ -384,21 +393,22 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
break; |
|
|
|
|
|
|
|
case FIOC_SM2130_ACKIRQ: |
|
|
|
if (pDrvCtrl->funcAckIrq) { |
|
|
|
if (pDrvCtrl->irqCount > 0) { |
|
|
|
UINT32 us = (UINT32)arg; |
|
|
|
if (us == 0) { |
|
|
|
us = 100; |
|
|
|
} |
|
|
|
pDrvCtrl->funcAckIrq(TRUE); |
|
|
|
sysUsDelay(us); |
|
|
|
pDrvCtrl->funcAckIrq(FALSE); |
|
|
|
iflag = dev->irqFlag; |
|
|
|
dev->irqFlag = FALSE; |
|
|
|
if (pDrvCtrl->funcAckIrq && iflag) { |
|
|
|
UINT32 us = (UINT32)arg; |
|
|
|
if (us == 0) { |
|
|
|
us = 100; |
|
|
|
} |
|
|
|
pDrvCtrl->funcAckIrq(TRUE); |
|
|
|
sysUsDelay(us); |
|
|
|
pDrvCtrl->funcAckIrq(FALSE); |
|
|
|
} else { |
|
|
|
errnoSet(ENOTSUP); |
|
|
|
ret = ERROR; |
|
|
|
if (!pDrvCtrl->funcAckIrq) { |
|
|
|
errnoSet(ENOTSUP); |
|
|
|
ret = ERROR; |
|
|
|
} |
|
|
|
} |
|
|
|
pDrvCtrl->irqCount = 0; |
|
|
|
break; |
|
|
|
case FIOC_SM2130_READY: |
|
|
|
if (pDrvCtrl->funcIsReady) { |
|
|
@ -470,6 +480,8 @@ LOCAL void sm1553isr(void *data) |
|
|
|
|
|
|
|
++pDrvCtrl->irqCount; |
|
|
|
|
|
|
|
dev->irqFlag = TRUE; |
|
|
|
|
|
|
|
//logMsg("sm1553isr interrupt", 1, 2, 3, 4, 5, 6);
|
|
|
|
if (dev->usrIsr) { |
|
|
|
dev->usrIsr(); |
|
|
@ -526,6 +538,7 @@ LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev) |
|
|
|
if (dev) { |
|
|
|
pDrvCtrl->refcount = 0; |
|
|
|
dev->usrIsr = NULL; |
|
|
|
dev->irqFlag = FALSE; |
|
|
|
selWakeupListInit(&dev->selList); |
|
|
|
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, sm2130_driver_node) == OK) { |
|
|
|
pDrvCtrl->devHandle = dev; |
|
|
|