Updated to use readw and writew
authorppisa <ppisa>
Mon, 14 Feb 2005 12:46:43 +0000 (12:46 +0000)
committerppisa <ppisa>
Mon, 14 Feb 2005 12:46:43 +0000 (12:46 +0000)
lincan/src/unican_cl2.c

index e0d30e1..b576c5e 100644 (file)
@@ -32,6 +32,7 @@ UCEL A FUNKCE:
 \r
 /* includes */\r
 #include "../include/canmsg.h"\r
+#include "../include/can_sysdep.h"\r
 #include "../include/unican_types.h"\r
 #include "../include/unican_cl2.h"\r
 #include "linux/delay.h"\r
@@ -104,7 +105,7 @@ eCL2_RESULT cl2_test_card
    for ( i = 0; i < 10000; i++ )\r
    {\r
      if ( isAA && is55 ) return CL2_OK;\r
-     tmpWord = *((volatile U16*)(card->baseAddressPtr));\r
+     tmpWord = unican_readw(card->baseAddressPtr);\r
      /*printk("cl2_test_card: %08lx %04x\n", (long)card->baseAddressPtr, tmpWord);*/\r
      udelay(100);\r
      if ( (tmpWord & 0x00FF) == 0x00AA ) isAA = TRUE;\r
@@ -132,7 +133,7 @@ eCL2_RESULT cl2_reset_card
    sCAN_CARD *card           /* Pointer to card structure */\r
    )\r
    {\r
-   *((U16*)(card->baseAddressPtr + CL2_RESET_REGISTER)) = 0x0000;\r
+   unican_writew(0x0000, card->baseAddressPtr + CL2_RESET_REGISTER);\r
    return CL2_OK;\r
    } /* cl2_reset_card */\r
 \r
@@ -153,7 +154,7 @@ eCL2_RESULT cl2_get_version
    U16 *version                /* returns card version */\r
    )\r
    {\r
-   *version = *((U16*)(card->baseAddressPtr + CL2_VERSION_REGISTER));\r
+   *version = unican_readw(card->baseAddressPtr + CL2_VERSION_REGISTER);\r
    return CL2_OK;\r
    } /* cl2_get_version */\r
 \r
@@ -175,7 +176,7 @@ eCL2_RESULT cl2_gen_interrupt
    sCAN_CARD *card           /* Pointer to card structure */\r
    )\r
    {\r
-   *((U16*)(card->baseAddressPtr + CL2_GEN_INT_REGISTER)) = 0x0000;\r
+   unican_writew(0x0000, card->baseAddressPtr + CL2_GEN_INT_REGISTER);\r
    return CL2_OK;\r
    } /* cl2_gen_interrupt */\r
 \r
@@ -197,7 +198,7 @@ eCL2_RESULT cl2_start_it
    sCAN_CARD *card           /* Pointer to card structure */\r
    )\r
    {\r
-   *((U16*)(card->baseAddressPtr + CL2_START_IT_REGISTER)) = 0x0000;\r
+   unican_writew(0x0000, card->baseAddressPtr + CL2_START_IT_REGISTER);\r
    return CL2_OK;\r
    } /* cl2_start_it */\r
 \r
@@ -217,7 +218,7 @@ eCL2_RESULT cl2_clear_interrupt
    sCAN_CARD *card           /* Pointer to card structure */\r
    )\r
    {\r
-   *((U16*)(card->baseAddressPtr + CL2_CLEAR_INT_REGISTER)) = 0x0000;\r
+   unican_writew(0x0000, card->baseAddressPtr + CL2_CLEAR_INT_REGISTER);\r
    return CL2_OK;\r
    } /* cl2_clear_interrupt */\r
 \r
@@ -242,10 +243,10 @@ eCL2_RESULT cl2_int_mode
    )\r
    {\r
    if ( mode > INT_MODE_ALL ) return CL2_BAD_PARAM;\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = mode;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_INT_MODE + CL2_COMMAND_VALID);\r
+   unican_writew(mode, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_INT_MODE + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_int_mode */\r
 \r
@@ -267,10 +268,10 @@ eCL2_RESULT cl2_iit_mode
    BOOLEAN1 onoff              /* IIT mode - TRUE=on, FALSE=off */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID ) return\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID ) return\r
       CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)onoff;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_IIT_MODE + CL2_COMMAND_VALID);\r
+   unican_writew((U16)onoff, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_IIT_MODE + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_iit_mode */\r
 \r
@@ -292,10 +293,10 @@ eCL2_RESULT cl2_sync_mode
    BOOLEAN1 onoff              /* Sync mode - TRUE=on, FALSE=off */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)onoff;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SYNC_MODE + CL2_COMMAND_VALID);\r
+   unican_writew((U16)onoff, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_SYNC_MODE + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_sync_mode */\r
 \r
@@ -317,10 +318,10 @@ eCL2_RESULT cl2_rtr_mode
    BOOLEAN1 onoff              /* RTR mode - TRUE=on, FALSE=off */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)onoff;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_RTR_MODE + CL2_COMMAND_VALID);\r
+   unican_writew((U16)onoff, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_RTR_MODE + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_rtr_mode */\r
 \r
@@ -350,10 +351,10 @@ eCL2_RESULT cl2_buf_size
    )\r
    {\r
    if ( bufSize > 64 ) return CL2_BAD_PARAM;\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = bufSize;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_BUF_SIZE + CL2_COMMAND_VALID);\r
+   unican_writew(bufSize, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_BUF_SIZE + CL2_COMMAND_VALID), card->commandRegister);\r
    card->syncTxBufSize = bufSize;\r
    card->asyncTxBufSize = 64 - bufSize;\r
    card->syncTxBufPtr = card->syncTxBufBase;\r
@@ -382,10 +383,10 @@ eCL2_RESULT cl2_set_iit
    U16 iit                     /* time period in x100 us */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = iit;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_IIT + CL2_COMMAND_VALID);\r
+   unican_writew(iit, card->dataPtr);\r
+   unican_writew(((U16)cmCL2_SET_IIT + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_iit */\r
 \r
@@ -406,10 +407,9 @@ eCL2_RESULT cl2_start_firmware
    sCAN_CARD *card            /* Pointer to card structure */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_START_FIRMWARE +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_START_FIRMWARE + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_start_firmware */\r
 \r
@@ -434,11 +434,10 @@ eCL2_RESULT cl2_set_rec_mode
    BOOLEAN1 mode              /* Mode - TRUE=ext, FALSE=std */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)mode;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_REC_MODE +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)mode, card->dataPtr);\r
+   unican_writew((U16)cmCL2_SET_REC_MODE + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_rec_mode */\r
 \r
@@ -460,11 +459,10 @@ eCL2_RESULT cl2_clr_rx_buffer
    sCAN_CARD *card           /* Pointer to card structure */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
    card->rxBufPtr = card->rxBufBase;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_CLR_RX_BUFFER +\r
-                                     CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_CLR_RX_BUFFER + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_clr_rx_buffer */\r
 \r
@@ -486,11 +484,10 @@ eCL2_RESULT cl2_clr_sync_buffer
    sCAN_CARD *card            /* Pointer to card structure */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
    card->syncTxBufPtr = card->syncTxBufBase;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_CLR_SYNC_BUFFER +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_CLR_SYNC_BUFFER + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_clr_sync_buffer */\r
 \r
@@ -512,11 +509,10 @@ eCL2_RESULT cl2_clr_async_buffer
    sCAN_CARD *card            /* Pointer to card structure */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
    card->asyncTxBufPtr = card->syncTxBufBase + card->syncTxBufSize*16;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_CLR_ASYNC_BUFFER +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_CLR_ASYNC_BUFFER + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_clr_async_buffer */\r
 \r
@@ -540,10 +536,9 @@ eCL2_RESULT cl2_send_time_sync
    sCAN_CARD *card             /* Pointer to card structure */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID ) return\r
-      CL2_COMMAND_BUSY;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SEND_TIME_SYNC +\r
-                                    CL2_COMMAND_VALID);\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
+      return CL2_COMMAND_BUSY;\r
+   unican_writew((U16)cmCL2_SEND_TIME_SYNC + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_send_time_sync */\r
 \r
@@ -570,7 +565,7 @@ eCL2_RESULT cl2_set_time_cobid
    U16 cobidL, cobidH;\r
    U16 *ptr = (U16 *)card->dataPtr;\r
 \r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
 \r
    if ( COBID & CL2_TMP_EXHIGH ) /* standard or extended format? */\r
@@ -594,8 +589,7 @@ eCL2_RESULT cl2_set_time_cobid
      *ptr = 0;\r
    }\r
 \r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_TIME_COBID +\r
-                                     CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_SET_TIME_COBID + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_time_cobid */\r
 \r
@@ -622,11 +616,10 @@ eCL2_RESULT cl2_set_receive_limit
    )\r
    {\r
    if ( limit > 127 ) return CL2_BAD_PARAM;\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = limit;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_RECEIVE_LIMIT +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew(limit, card->dataPtr);\r
+   unican_writew((U16)cmCL2_SET_RECEIVE_LIMIT + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_receive_limit */\r
 \r
@@ -658,7 +651,7 @@ eCL2_RESULT cl2_download_rtr_list
    U32 COBID;\r
    U16 cobidH, cobidL, i;\r
 \r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID ) return\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID ) return\r
       CL2_COMMAND_BUSY;\r
    if ( rtrList->nb > 64 ) return CL2_BAD_PARAM;\r
 \r
@@ -694,8 +687,7 @@ eCL2_RESULT cl2_download_rtr_list
    ptrRTR++;\r
    }\r
 \r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_DOWNLOAD_RTR_LIST +\r
-                                     CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_DOWNLOAD_RTR_LIST + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_download_rtrlist */\r
 \r
@@ -725,7 +717,7 @@ eCL2_RESULT cl2_subscribe_rtr
    U32 COBID;\r
    U16 cobidH, cobidL;\r
 \r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
    if ( RTRnumber > 9 ) return CL2_BAD_PARAM;\r
 \r
@@ -755,8 +747,7 @@ eCL2_RESULT cl2_subscribe_rtr
      *ptrU16 = 0;\r
    }\r
 \r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SUBSCRIBE_RTR +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_SUBSCRIBE_RTR + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_subscribe_rtr */\r
 \r
@@ -782,7 +773,7 @@ eCL2_RESULT cl2_desubscribe_rtr
    {\r
    U16 i;\r
 \r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
 \r
    for ( i = 0; i < 10; i++ )\r
@@ -796,9 +787,8 @@ eCL2_RESULT cl2_desubscribe_rtr
 \r
    if ( i >= 10 ) return CL2_BAD_PARAM;\r
 \r
-   *((U16*)card->dataPtr) = i;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_DESUBSCRIBE_RTR +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew(i, card->dataPtr);\r
+   unican_writew((U16)cmCL2_DESUBSCRIBE_RTR + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_desubscribe_rtr */\r
 \r
@@ -826,7 +816,7 @@ eCL2_RESULT cl2_set_sync_cobid
    U16 cobidL, cobidH;\r
    U16 *ptr = (U16 *)card->dataPtr;\r
 \r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
 \r
    if ( COBID & CL2_TMP_EXHIGH ) /* standard or extended format? */\r
@@ -850,7 +840,7 @@ eCL2_RESULT cl2_set_sync_cobid
      *ptr = 0;\r
    }\r
 \r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_COBID + CL2_COMMAND_VALID);\r
+   unican_writew(((U16)cmCL2_SET_COBID + CL2_COMMAND_VALID), card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_sync_cobid */\r
 \r
@@ -874,11 +864,10 @@ eCL2_RESULT cl2_set_sync_period
    U16 period                  /* period in x100 us */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)period;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_SYNC_PERIOD +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)period, card->dataPtr);\r
+   unican_writew((U16)cmCL2_SET_SYNC_PERIOD + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_sync_period */\r
 \r
@@ -902,11 +891,10 @@ eCL2_RESULT cl2_set_sync_window
    U16 window                  /* period in x100 us */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = (U16)window;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_SYNC_WINDOW +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)window, card->dataPtr);\r
+   unican_writew((U16)cmCL2_SET_SYNC_WINDOW + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_sync_window */\r
 \r
@@ -929,11 +917,10 @@ eCL2_RESULT cl2_set_bitrate
    U16 bitrate                 /* CAN bitrate */\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->dataPtr) = bitrate;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_SET_BITRATE +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew(bitrate, card->dataPtr);\r
+   unican_writew((U16)cmCL2_SET_BITRATE + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_set_bitrate */\r
 \r
@@ -954,10 +941,9 @@ eCL2_RESULT cl2_bus_reset
    sCAN_CARD *card\r
    )\r
    {\r
-   if ( *(U16*)card->commandRegister & CL2_COMMAND_VALID )\r
+   if ( unican_readw(card->commandRegister) & CL2_COMMAND_VALID )\r
       return CL2_COMMAND_BUSY;\r
-   *((U16*)card->commandRegister) = ((U16)cmCL2_BUS_RESET +\r
-                                    CL2_COMMAND_VALID);\r
+   unican_writew((U16)cmCL2_BUS_RESET + CL2_COMMAND_VALID, card->commandRegister);\r
    return CL2_OK;\r
    } /* cl2_bus_reset */\r
 \r
@@ -1042,7 +1028,7 @@ eCL2_RESULT cl2_send_sync
       }\r
 \r
    tmpU16 = (((U16)cobidH) & 0xFF00) | CL2_MESSAGE_VALID;\r
-   *(U16*)card->syncTxBufPtr = tmpU16;\r
+   unican_writew(tmpU16, card->syncTxBufPtr);\r
 \r
    if ( (card->syncTxBufBase + card->syncTxBufSize*16) <=\r
         (card->syncTxBufPtr += 16) )\r
@@ -1133,7 +1119,7 @@ eCL2_RESULT cl2_send_async
       }\r
 \r
    tmpU16 = (((U16)cobidH) & 0xFF00) | CL2_MESSAGE_VALID;\r
-   *(U16*)card->asyncTxBufPtr = tmpU16;\r
+   unican_writew(tmpU16, card->asyncTxBufPtr);\r
 \r
    if ( (card->asyncTxBufBase + card->asyncTxBufSize*16) <=\r
         (card->asyncTxBufPtr += 16) )\r
@@ -1261,7 +1247,7 @@ eCL2_RESULT cl2_receive_data
       {\r
       canMessage->timeStamp = *ptrU16 << 8 | *ptrU16 >> 8;\r
       }\r
-   *(U16*)card->rxBufPtr = 0x0000;\r
+   unican_writew(0x0000, card->rxBufPtr);\r
 \r
    /* increment rx-buffer pointer */\r
    if ( (card->rxBufBase + card->rxBufSize*16 ) <= (card->rxBufPtr += 16) )\r