@ -1,6 +1,4 @@
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# include  "DSP2833x_Device.h" 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# include  "DSP2833x_ECan.h" 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# include  <cstddef> 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# include  "CAN.h" 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				namespace  canSpace  { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
			
			 
			 
			
				@ -185,7 +183,7 @@ void CAN::config(Uint16 baudrate, Uint16 flags){
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				void  CAN : : configTxMBox ( Uint16  boxNumber ,  const  MsgID &  configID ,  const  MsgCtrlReg &  configCtrlReg ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if  ( boxNumber  >  31 )  return ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    volatile  MBOX *  p_MailBox ( NULL ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    volatile  MBOX *  p_MailBox ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    p_MailBox  =  & ( p_CanMBoxes_ - > MBOX0 )  +  boxNumber ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    Uint32  mboxControl ( 0 ) ; 
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -201,7 +199,6 @@ void CAN::configTxMBox(Uint16 boxNumber, const MsgID& configID, const MsgCtrlReg
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        while ( ( CanShadow_ . CANTRS . all  &  mboxControl )  ! =  0 ) ;       // Wait for TRS bit to be cleared
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Mailbox disable
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    CanShadow_ . CANME . all  =  p_CanRegs_ - > CANME . all ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    CanShadow_ . CANME . all  & =  ~ ( mboxControl ) ; 
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -217,7 +214,7 @@ void CAN::configTxMBox(Uint16 boxNumber, const MsgID& configID, const MsgCtrlReg
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Write to RTR and TPL field in control reg
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    p_MailBox - > MSGCTRL . bit . RTR  =  configCtrlReg . bit . RTR ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // p_MailBox->MSGCTRL.bit.TPL = configData.msgCtrlReg.bit.TPL;  // enable if you need to set msg priority lvl
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    p_MailBox - > MSGCTRL . bit . TPL  =  configCtrlReg . bit . TPL ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Mailbox enable
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    CanShadow_ . CANME . all  =  p_CanRegs_ - > CANME . all ; 
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -229,7 +226,7 @@ void CAN::configTxMBox(Uint16 boxNumber, const MsgID& configID, const MsgCtrlReg
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				void  CAN : : configRxMBox ( Uint16  boxNumber ,  const  MsgID &  configID ,  const  MsgCtrlReg &  configCtrlReg ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if  ( boxNumber  >  31 )  return ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    volatile  MBOX *  p_MailBox ( NULL ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    volatile  MBOX *  p_MailBox ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    p_MailBox  =  & ( p_CanMBoxes_ - > MBOX0 )  +  boxNumber ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    Uint32  mboxControl ( 0 ) ; 
 
			
		 
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
			
			 
			 
			
				@ -256,17 +253,13 @@ void CAN::configRxMBox(Uint16 boxNumber, const MsgID& configID, const MsgCtrlReg
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Overwrite protection
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // If "ON" make sure that an additional mailbox is configured to store ’  overflow’   messages.
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // CanShadow_.CANOPC.all = p_CanRegs_->CANOPC.all;
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // CanShadow_.CANOPC.all |= mboxControl;                      // Should be one more mailbox to store 'overflow' messages
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // CanShadow_.CANOPC.all |= mboxControl;                 // Should be one more mailbox to store 'overflow' messages
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // p_CanRegs_->CANOPC.all = CanShadow_.CANOPC.all;
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Enable Mailbox
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    CanShadow_ . CANME . all  =  p_CanRegs_ - > CANME . all ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    CanShadow_ . CANME . all  | =  mboxControl ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    p_CanRegs_ - > CANME . all  =  CanShadow_ . CANME . all ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // Write to the mailbox RAM field   // TODO doesn't work when rx. Check for RTR
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // p_MailBox->MDL.all = 0x55555555;
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    // p_MailBox->MDH.all = 0x55555555;
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}