Listing 114 continued Commbgndc

* GET TX CHARACTER FRCM RING BUFFER

* Description : This function is called by the Tx ISR to extract the next character frcm the Tx buffer.

* The function returns FALSE if the buffer is enpty after the character is extracted frcm

* the buffer. This is done to signal the Tx ISR to disable interrupts because this is the

* last character to send.

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

* CCMM1

* CCMM2

* 'err' is a pointer to where an error code will be deposited:

* *err is set to CCMM_NO_ERR if at least one character was left in the

* *err is set to CCWM_TX_EMPIY if the Tx buffer is enpty.

* *err is set to CCMM_BAD_CH if you have specified an incorrect channel

* Returns : The next character in the Tx buffer or NUL if the buffer is empty. *********************************************************************************************************

INT8U CcmmGetTxChar CENT8U ch, INT8U *err) (

INT8U c;

pbuf = ScCcjnnlBuf ; break;

/* Obtain pointer to ccmmunications channel */

case CCMM2:

pbuf = &Ccmm2Buf; break;

default:

if (pbuf->RingBufTxCtr > 0) { /* See if buffer is enpty pbuf->RingBufTxCtr—; /* No, decrement character count c = *pbuf->RingBufTxOutPtr++; /* Get character frcm buffer if (pbuf->RingBufTxOutPtr - &pbuf->RingBufTx[CCMM_TX_BUF_SIZE]) { /* Wrap OUT pointer pbuf->RingBufTxOutPtr = &pbuf->RingBufTx[OJ ;

*err = CCWMJCLERR;

return (c); /* Characters are still available

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

INITIALIZE COMMUNICATIONS MODULE

* Description : This function is called by your application to initialize the coirriunications nodule. You

* must call this function before calling any other functions.

* Arguments : none

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

void Ccrmlnit (void) {

CCWM_RING_BUF *pbuf;

pbuf = StCorenlBuf ;

pbuf->RingBufRxCtr = 0; pbuf->RingBufRxIriPtr = &pbuf->RingBufRx[0] ; pbuf->RingBufRxOutPtr = &pbuf->RingBufRx[0] ; pbuf->RingBufTxCtr - 0; pbuf->RingBufTxInPtr - &pbuf->RingBufTx[0] ; pbuf->RingBufTxOutPtr = Spbuf->RingBufTx[0] ;

pbuf = &Comn2Buf;

pbuf->RingBufRxCtr = 0 ; pbuf->RingBufRxInPtr = &pbuf->RingBufRx[0] ; pihjf->RingBufI!xOutPtr - &pbuf->RingBufRx[0] ; pbuf->RingBufTxCtr = 0; pbuf->RingBufTxInPtr = &pbuf->RingBufTx[0] ; pbuf->RingBufTxOutPtr - &pbuf->RingBufTx[0] ;

/* Initialize the ring buffer for CCMffl. */

/* Initialize the ring buffer for CCMM2 */

Was this article helpful?

0 0

Post a comment