📄 sioapi.c
字号:
/*******************************************************************************
sioapi.c
********************************************************************************
Written by: Shaheen Mahomed
nSoft Developement.
********************************************************************************
Version
0.00aA 17 Jun 04 SSM Began using pic18 uart code from MPLab Maestro
0.00aB 14 Aug 04 BDW Patching in data handeling
0.00aD 15 Sep 04 BDW Making build compatible with new Protocessors
0.00aI 11 Oct 04 BDW Increasing SIO buffer sizes
*******************************************************************************/
#include <fst.h>
#include <sioapi.h>
#include "UARTIntC.h"
#if defined ( P18F6720 )
#include <p18f6720.h>
#elif defined (P18F6520)
#include <p18f6520.h>
#else
#error must defined P18F6X20 compiler option
#endif
/*=========================================================================*/
/*Done for UART1 checked and works*/
BYTE sioapi_init ( UINT port_handle )
{
UARTIntInit(port_handle);
return 0;
}
//=============================================================================
BYTE sioapi_enable ( UINT port_handle )
{
/*Tx is disabled to allow the first byte to be sent immediately when
transmitting data. If Tx is enabled the Interrupt Flag TXIF will not
be cleared and the data will not be transmitted*/
mDisableUARTTxInt(port_handle);
mEnableUARTRxInt(port_handle);
return 0;
}
/*=========================================================================*/
/*Done for UART1 need to check*/
BYTE sioapi_disable ( UINT port_handle )
{
mDisableUARTTxInt(port_handle);
mDisableUARTRxInt(port_handle);
return 0;
}
/*=========================================================================*/
/*Returns a value of 1 if successful or 0 if an error occurs*/
BYTE sioapi_setport ( UINT port_handle, UINT baud, UINT parity, UINT data, UINT stop)
{
return mSetUARTPort(port_handle, baud, parity);
}
/*=========================================================================*/
BYTE sioapi_puts ( UINT port_handle, BYTE *str, UINT length )
{
UARTIntPutString(port_handle,str,length);
return 0;
}
/*=========================================================================*/
/*Done for UART1 checked and works*/
BYTE sioapi_putch ( UINT port_handle, BYTE ch )
{
UARTIntPutString(port_handle,&ch,1);
return 0;
}
/*=========================================================================*/
/* return 0 if no more charaters in receive buffer */
/*Done for UART1 need to check*/
BYTE sioapi_ixrx ( UINT port_handle )
{
return UARTIntGetRxBufferDataSize(port_handle);
}
/*=========================================================================*/
/* return 0 if space in the tx_queue */
/*Done for UART1 need to test*/
BYTE sioapi_ixtx ( UINT port_handle )
{
return UARTIntGetTxBufferDataSize(port_handle);
}
/*=========================================================================*/
/*Done for UART1 need to test*/
BYTE sioapi_getch ( UINT port_handle )
{
return UARTIntGetChar(port_handle);
}
/*=========================================================================*/
/* return 0 if not completed */
BYTE sioapi_tx_complete ( UINT port_handle )
{
BYTE val = sioapi_ixtx ( port_handle ) ;
if ( val == (BYTE)0 )
{
if ( port_handle == (BYTE)0 )
{
return(BYTE) TXSTA1bits.TRMT;
}
else
{
return(BYTE) TXSTA2bits.TRMT;
}
}
else
{
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -