Lines Matching refs:CANmodule

117 void CO_CANsetNormalMode(CO_CANmodule_t *CANmodule){  in CO_CANsetNormalMode()  argument
118 uint16_t C_CTRL1copy = CAN_REG(CANmodule->CANdriverState, C_CTRL1); in CO_CANsetNormalMode()
122 CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1copy; in CO_CANsetNormalMode()
125 while((CAN_REG(CANmodule->CANdriverState, C_CTRL1) & 0x00E0) != 0x0000); in CO_CANsetNormalMode()
127 CANmodule->CANnormal = true; in CO_CANsetNormalMode()
133 CO_CANmodule_t *CANmodule, in CO_CANmodule_init() argument
154 if(CANmodule==NULL || rxArray==NULL || txArray==NULL){ in CO_CANmodule_init()
186 CANmodule->CANdriverState = CANdriverState; in CO_CANmodule_init()
187 CANmodule->CANmsgBuff = CANmsgBuff; in CO_CANmodule_init()
188 CANmodule->rxArray = rxArray; in CO_CANmodule_init()
189 CANmodule->rxSize = rxSize; in CO_CANmodule_init()
190 CANmodule->txArray = txArray; in CO_CANmodule_init()
191 CANmodule->txSize = txSize; in CO_CANmodule_init()
192 CANmodule->CANnormal = false; in CO_CANmodule_init()
193 CANmodule->useCANrxFilters = (rxSize <= 16U) ? true : false; in CO_CANmodule_init()
194 CANmodule->bufferInhibitFlag = false; in CO_CANmodule_init()
195 CANmodule->firstCANtxMessage = true; in CO_CANmodule_init()
196 CANmodule->CANtxCount = 0U; in CO_CANmodule_init()
197 CANmodule->errOld = 0U; in CO_CANmodule_init()
198 CANmodule->em = NULL; in CO_CANmodule_init()
266 if(CANmodule->useCANrxFilters){ in CO_CANmodule_init()
293 CANmodule->CANmsgBuffSize = 16; in CO_CANmodule_init()
297 CANmodule->CANmsgBuffSize = 12; in CO_CANmodule_init()
301 CANmodule->CANmsgBuffSize = 8; in CO_CANmodule_init()
305 CANmodule->CANmsgBuffSize = 6; in CO_CANmodule_init()
309 CANmodule->CANmsgBuffSize = 4; in CO_CANmodule_init()
358 void CO_CANmodule_disable(CO_CANmodule_t *CANmodule){ in CO_CANmodule_disable() argument
359 CO_CANsetConfigurationMode(CANmodule->CANdriverState); in CO_CANmodule_disable()
371 CO_CANmodule_t *CANmodule, in CO_CANrxBufferInit() argument
381 if((CANmodule!=NULL) && (object!=NULL) && (pFunct!=NULL) && (index < CANmodule->rxSize)){ in CO_CANrxBufferInit()
383 CO_CANrx_t *buffer = &CANmodule->rxArray[index]; in CO_CANrxBufferInit()
385 uint16_t addr = CANmodule->CANdriverState; in CO_CANrxBufferInit()
408 if(CANmodule->useCANrxFilters){ in CO_CANrxBufferInit()
474 CO_CANmodule_t *CANmodule, in CO_CANtxBufferInit() argument
483 if((CANmodule != NULL) && (index < CANmodule->txSize)){ in CO_CANtxBufferInit()
485 buffer = &CANmodule->txArray[index]; in CO_CANtxBufferInit()
539 CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer){ in CO_CANsend() argument
541 uint16_t addr = CANmodule->CANdriverState; in CO_CANsend()
546 if(!CANmodule->firstCANtxMessage){ in CO_CANsend()
548 …CO_errorReport((CO_EM_t*)CANmodule->em, CO_EM_CAN_TX_OVERFLOW, CO_EMC_CAN_OVERRUN, (buffer->ident … in CO_CANsend()
561 if((C_TR01CONcopy & 0x8) == 0 && CANmodule->CANtxCount == 0){ in CO_CANsend()
562 CANmodule->bufferInhibitFlag = buffer->syncFlag; in CO_CANsend()
563 CO_CANsendToModule(addr, CANmodule->CANmsgBuff, buffer); in CO_CANsend()
568 CANmodule->CANtxCount++; in CO_CANsend()
577 void CO_CANclearPendingSyncPDOs(CO_CANmodule_t *CANmodule){ in CO_CANclearPendingSyncPDOs() argument
583 if(CANmodule->bufferInhibitFlag){ in CO_CANclearPendingSyncPDOs()
584 volatile uint16_t C_CTRL1old = CAN_REG(CANmodule->CANdriverState, C_CTRL1); in CO_CANclearPendingSyncPDOs()
585 …CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old & 0xFFFE; /* WIN = 0 - use buffer reg… in CO_CANclearPendingSyncPDOs()
586 CAN_REG(CANmodule->CANdriverState, C_TR01CON) &= 0xFFF7; /* clear TXREQ */ in CO_CANclearPendingSyncPDOs()
587 CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old; in CO_CANclearPendingSyncPDOs()
588 CANmodule->bufferInhibitFlag = false; in CO_CANclearPendingSyncPDOs()
592 if(CANmodule->CANtxCount != 0U){ in CO_CANclearPendingSyncPDOs()
594 CO_CANtx_t *buffer = &CANmodule->txArray[0]; in CO_CANclearPendingSyncPDOs()
595 for(i = CANmodule->txSize; i > 0U; i--){ in CO_CANclearPendingSyncPDOs()
599 CANmodule->CANtxCount--; in CO_CANclearPendingSyncPDOs()
610 …CO_errorReport((CO_EM_t*)CANmodule->em, CO_EM_TPDO_OUTSIDE_WINDOW, CO_EMC_COMMUNICATION, tpdoDelet… in CO_CANclearPendingSyncPDOs()
616 void CO_CANverifyErrors(CO_CANmodule_t *CANmodule){ in CO_CANverifyErrors() argument
618 CO_EM_t* em = (CO_EM_t*)CANmodule->em; in CO_CANverifyErrors()
620 err = CAN_REG(CANmodule->CANdriverState, C_INTF) >> 8; in CO_CANverifyErrors()
621 if(CAN_REG(CANmodule->CANdriverState, C_INTF) & 4){ in CO_CANverifyErrors()
625 if(CANmodule->errOld != err){ in CO_CANverifyErrors()
626 CANmodule->errOld = err; in CO_CANverifyErrors()
631 CAN_REG(CANmodule->CANdriverState, C_INTF) &= 0xFFFB;/* clear bits */ in CO_CANverifyErrors()
644 …if(!CANmodule->firstCANtxMessage) CO_errorReport(em, CO_EM_CAN_TX_BUS_PASSIVE, CO_EMC_CAN_PASSIVE,… in CO_CANverifyErrors()
674 void CO_CANinterrupt(CO_CANmodule_t *CANmodule) { in CO_CANinterrupt() argument
677 if(CAN_REG(CANmodule->CANdriverState, C_INTF) & 0x02) { in CO_CANinterrupt()
684 C_CTRL1old = CAN_REG(CANmodule->CANdriverState, C_CTRL1); in CO_CANinterrupt()
685 …CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old & 0xFFFE; /* WIN = 0 - use buffer reg… in CO_CANinterrupt()
686 C_RXFUL1copy = CAN_REG(CANmodule->CANdriverState, C_RXFUL1); in CO_CANinterrupt()
687 CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old; in CO_CANinterrupt()
691 CAN_REG(CANmodule->CANdriverState, C_INTF) &= 0xFFFD; in CO_CANinterrupt()
692 C_FIFOcopy = CAN_REG(CANmodule->CANdriverState, C_FIFO); in CO_CANinterrupt()
713 for(FNRB=1; FNRB<CANmodule->CANmsgBuffSize; FNRB++) { in CO_CANinterrupt()
722 rcvMsg = &CANmodule->CANmsgBuff[FNRB]; in CO_CANinterrupt()
724 if(CANmodule->useCANrxFilters) { in CO_CANinterrupt()
728 if(index < CANmodule->rxSize) { in CO_CANinterrupt()
729 buffer = &CANmodule->rxArray[index]; in CO_CANinterrupt()
739 buffer = &CANmodule->rxArray[0]; in CO_CANinterrupt()
740 for(index = CANmodule->rxSize; index > 0U; index--) { in CO_CANinterrupt()
761 C_CTRL1old = CAN_REG(CANmodule->CANdriverState, C_CTRL1); in CO_CANinterrupt()
762 …CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old & 0xFFFE; /* WIN = 0 - use buffer reg… in CO_CANinterrupt()
763 CAN_REG(CANmodule->CANdriverState, C_RXFUL1) &= ~(mask); in CO_CANinterrupt()
764 CAN_REG(CANmodule->CANdriverState, C_CTRL1) = C_CTRL1old; in CO_CANinterrupt()
769 FNRB = (CAN_REG(CANmodule->CANdriverState, C_FIFO) & 0x3F); in CO_CANinterrupt()
774 if(CAN_REG(CANmodule->CANdriverState, C_INTF) & 0x01) { in CO_CANinterrupt()
777 CAN_REG(CANmodule->CANdriverState, C_INTF) &= 0xFFFE; in CO_CANinterrupt()
779 CANmodule->firstCANtxMessage = false; in CO_CANinterrupt()
781 CANmodule->bufferInhibitFlag = false; in CO_CANinterrupt()
783 if(CANmodule->CANtxCount > 0U){ in CO_CANinterrupt()
787 CO_CANtx_t *buffer = &CANmodule->txArray[0]; in CO_CANinterrupt()
789 for(i = CANmodule->txSize; i > 0U; i--){ in CO_CANinterrupt()
793 CANmodule->CANtxCount--; in CO_CANinterrupt()
796 CANmodule->bufferInhibitFlag = buffer->syncFlag; in CO_CANinterrupt()
797 CO_CANsendToModule(CANmodule->CANdriverState, CANmodule->CANmsgBuff, buffer); in CO_CANinterrupt()
805 CANmodule->CANtxCount = 0U; in CO_CANinterrupt()