📄 swtxuart.c
字号:
/************************************************************
Copyright (C) 1995-2002 Pumpkin, Inc. and its
Licensor(s). Freely distributable.
$Source: C:\\RCS\\D\\salvo\\demo\\d5\\swtxuart.c,v $
$Author: aek $
$Revision: 1.9 $
$Date: 2001-10-25 19:56:53-07 $
Support file.
************************************************************/
#ifndef SWTXUART_C_INCLUDES
#define SWTXUART_C_INCLUDES
#include "d5.h"
#include "main.h"
#include "salvo.h"
#if TRANSMITTERS >= 1
_OSLabel(TaskTxa);
_OSLabel(TaskTxb);
_OSLabel(TaskTxc);
_OSLabel(TaskTxd);
#endif
/************************************************************
**** ****
** **
TaskTx()
This is bit-banging transmit task that handles up to four
transmitters at once.
It explicitly takes its data from txNBuff[] and places it in
txNData. It context-switches whenever it has nothing to do.
There's little point in having independent transmitter tasks,
since having the transmitters run synchronously results in a
maximum of one character delay. By placing all four
transmitters in the same task, a considerable RAM and ROM
savings is realized.
** **
**** ****
************************************************************/
#if TRANSMITTERS >= 1
void TaskTx( void )
{
/* Start with all Tx outputs inactive (i.e. idling).*/
TX1 = 1;
#if TRANSMITTERS >= 2
TX2 = 1;
#endif
#if TRANSMITTERS >= 3
TX3 = 1;
#endif
#if TRANSMITTERS >= 4
TX4 = 1;
#endif
/* initialize transmitters. */
InitBcb(TX1BCBP, TX1_BUFF_SIZE);
#if TRANSMITTERS >= 2
InitBcb(TX2BCBP, TX2_BUFF_SIZE);
#endif
#if TRANSMITTERS >= 3
InitBcb(TX3BCBP, TX3_BUFF_SIZE);
#endif
#if TRANSMITTERS >= 4
InitBcb(TX4BCBP, TX4_BUFF_SIZE);
#endif
txState = 0;
for (;;) {
/* nothing happens until the semaphore is */
/* signaled. */
OS_WaitBinSem(BINSEM_TXBUFF_P, OSNO_TIMEOUT, TaskTxa);
/* get local copy of data to be sent. Activate */
/* transmitter if there's data to send. O/wise */
/* deactivate transmitter. */
if ( GetTx1Buff(&tx1Data) )
txStatus.tx1Active = 1;
else
txStatus.tx1Active = 0;
#if TRANSMITTERS >= 2
if ( GetTx2Buff(&tx2Data) )
txStatus.tx2Active = 1;
else
txStatus.tx2Active = 0;
#endif
#if TRANSMITTERS >= 3
if ( GetTx3Buff(&tx3Data) )
txStatus.tx3Active = 1;
else
txStatus.tx3Active = 0;
#endif
#if TRANSMITTERS >= 4
if ( GetTx4Buff(&tx4Data) )
txStatus.tx4Active = 1;
else
txStatus.tx4Active = 0;
#endif
/* tell ISR data is ready to be shifted out. */
OSProtect();
OSSignalBinSem(BINSEM_TXSTART_P);
OSUnprotect();
ToggleTPTx();
/* wait till ISR is done. */
OS_WaitBinSem(BINSEM_TXDONE_P, OSNO_TIMEOUT, TaskTxb);
/* since we're using only a binsem to indicate */
/* data being available in _any_ buffer, and */
/* since more than a single byte may have been */
/* put into any buffer, and since we just got */
/* (i.e. stripped) a maximum of one byte from */
/* each buffer, then buffers may still be non- */
/* empty, and we must stay alive until they're */
/* completely empty -- all four of 'em. */
#if TRANSMITTERS == 1
if ( TX1BCB.count != 0 )
#elif TRANSMITTERS == 2
if ( ( TX1BCB.count != 0 ) || ( TX2BCB.count != 0 ) )
#elif TRANSMITTERS == 3
if ( ( TX1BCB.count != 0 ) || ( TX2BCB.count != 0 ) \
|| ( TX3BCB.count != 0 ) )
#elif TRANSMITTERS == 4
if ( ( TX1BCB.count != 0 ) || ( TX2BCB.count != 0 ) \
|| ( TX3BCB.count != 0 ) || ( TX4BCB.count != 0 ) )
#endif
OSSignalBinSem(BINSEM_TXBUFF_P);
}
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -