Listing 114 continued Commbgndc

*********************************************************************************************************

* OUTPUT CHARACTER

* Description : This function is called by your application to send a character on the comnunications

* channel. The character to send is first inserted into the Tx buffer and will be sent by

* the Tx ISR. If this is the first character placed into the buffer, the Tx ISR will be

* enabled. If the Tx buffer is full, the character will not be sent (i.e. it will be lost)

* Arguments : 'ch' is the CCMM port channel number and can either be:

* CCMML

* CCMM2

* Returns : CCMM_NO_ERR if the function was successful (the buffer was not full)

* CCMM_TX_FULL if the buffer was full

* CCMM_BAD_CH if you have specified an incorrect channel *********************************************************************************************************

INT8U CammPutChar (INT8U ch, INT8U c) {

COM_RING_BUF *pbuf ;

switch (ch) { /* Obtain pointer to ccirmunications channel */

case CCMML:

pbuf = SCarmlBuf; break;

case CCMM2:

pbuf = &Corm2Buf; break;

default:

if (pbuf->RingBufTxCtr < CCMM_TX_BUF_SIZE) ( /* See if buffer is full */

pbuf->RingBufTxCtr++; /* No, increment character count */

*pbuf->RingBufTxIriPtr++ = c; /* Put character into buffer */

if (pbuf->RingBufTxInPtr == Spbuf->RingBufTX[OCMM_TX_BUF_SI2E]) { /* Wrap IN pointer V

pbuf->RingBufTxInPtr = &pbuf->RingBufTx[0] ;

if (pbuf->RingBufTxCtr == 1) { /* See if this is the first character */

CorrrrfExIntEn(ch); /* Yes, Enable Tx interrupts */

* INSERT CHARACTER INTO RIN3 BUFFER

* Description : This function is called by the Rx ISR to insert a character into the receive ring buffer.

* Arguments : "ch1 is the CCMM port channel number and can either be:

* CCMML

* 0CMM2

* 'c' is the character to insert into the ring buffer. If the buffer is full, the

* character will not be inserted, it will be lost.

★A*******************************************************************************************************

void CcnmPutRxChar (INT8U ch, INT8U c) {

switch (ch) { /* Obtain pointer to communications channel */

case CCMML:

pbuf = SCammlBuf; break;

case CCMM2:

pbuf = &Caim2Buf; break;

default:

return;

if (pbuf->RingBufRxCtr < CCMM_RX_BUF_SIZE) { /* See if buffer is full */

pbuf->RingBufR>iCtr++; /* No, incranent character count */

*pbuf->RingBufRxInPtr++ = c; /* Put character into buffer */

if (pbuf->RingBufRxInPtr - &pbuf->Rii^BufRx[CCMlKX_BUF_SIZE]) { /* Wrap IN pointer */

pbuf->RingBufRxInPtr = &pbuf->RingBufRx[0] ;

Was this article helpful?

0 0

Post a comment