sdc.c
来自「基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7」· C语言 代码 · 共 1,112 行 · 第 1/4 页
C
1,112 行
/**************** Begin Port Specific Section **************/
return (SD_INBYTE (uart->base_address + SD_URXH_OFFSET));
/**************** End Port Specific Section ****************/
#endif
return (NU_FALSE);
}
/****************************************************************************/
/* FUNCTION */
/* */
/* SDC_Carrier */
/* */
/* DESCRIPTION */
/* */
/* This function checks for a carrier. */
/* */
/* CALLED BY */
/* */
/* MDM_Hangup */
/* */
/* CALLS */
/* */
/* none */
/* */
/* INPUTS */
/* */
/* none */
/* */
/* OUTPUTS */
/* */
/* STATUS : The status of the detection. */
/* */
/****************************************************************************/
STATUS SDC_Carrier(SD_PORT *uart)
{
return (NU_TRUE);
}
/****************************************************************************
Note: All functions below this point are generic and should not require
any changes to support other UARTS.
****************************************************************************/
/****************************************************************************/
/* FUNCTION */
/* */
/* SDC_Put_String */
/* */
/* DESCRIPTION */
/* */
/* This writes a null-terminated string out to the serial port. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* SDC_Put_Char */
/* */
/* INPUTS */
/* */
/* CHAR * : String to be written to the serial port. */
/* SD_PORT * : Serial port to send the string to. */
/* */
/* OUTPUTS */
/* */
/* none */
/* */
/****************************************************************************/
VOID SDC_Put_String(CHAR *str, SD_PORT *uart)
{
/* Grab the semaphore so that strings between threads
do not get mixed. */
if (NU_Obtain_Semaphore(uart->sd_semaphore, NU_SUSPEND) == NU_SUCCESS)
{
/* Send out the string. */
for (; *str != 0; str++)
SDC_Put_Char(*str, uart);
/* Allow other threads to use this service. */
NU_Release_Semaphore (uart->sd_semaphore);
}
}
/****************************************************************************/
/* FUNCTION */
/* */
/* SDC_Data_Ready */
/* */
/* DESCRIPTION */
/* */
/* This function checks to see if there are any characters in the */
/* receive buffer. A status value is returned indicating whether */
/* characters are present in the receive buffer. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* none */
/* */
/* INPUTS */
/* */
/* SD_PORT * : Serial port to check for data. */
/* */
/* OUTPUTS */
/* */
/* STATUS The status indicates the */
/* presence of characters. */
/* */
/****************************************************************************/
STATUS SDC_Data_Ready(SD_PORT *port)
{
/* Check the status. */
if((port->rx_buffer_status == NU_BUFFER_FULL) ||
(port->rx_buffer_status == NU_BUFFER_DATA))
return (NU_TRUE);
else
return (NU_FALSE);
}
/****************************************************************************/
/* FUNCTION */
/* */
/* SDC_Change_Communication_Mode */
/* */
/* DESCRIPTION */
/* */
/* This function switches the serial port between terminal mode and */
/* network mode. The mode affects how incoming characters are directed. */
/* */
/* CALLED BY */
/* */
/* MDM_Change_Communication_Mode */
/* */
/* CALLS */
/* */
/* none */
/* */
/* INPUTS */
/* */
/* INT : The mode of operation desired. */
/* */
/* OUTPUTS */
/* */
/* none */
/* */
/****************************************************************************/
VOID SDC_Change_Communication_Mode(INT mode, SD_PORT *uart)
{
uart->communication_mode = mode;
} /* SDC_Change_Communication_Mode */
/****************************************************************************/
/* FUNCTION */
/* */
/* SDC_Reset */
/* */
/* DESCRIPTION */
/* */
/* This function intializes the data variables associated with a UART */
/* */
/* CALLED BY */
/* */
/* PPP_Dial */
/* PPP_Wait_For_Client */
/* */
/* CALLS */
/* */
/* none */
/* */
/* INPUTS */
/* */
/* SD_PORT * : Serial port to reset */
/* */
/* OUTPUTS */
/* */
/* STATUS : Returns URT_SUCCESS if successful initialization, */
/* else a negative value is returned. */
/* */
/****************************************************************************/
VOID SDC_Reset (SD_PORT *uart)
{
/* Ini the error counters */
uart->frame_errors = 0;
uart->overrun_errors = 0;
uart->parity_errors = 0;
uart->busy_errors = 0;
uart->general_errors = 0;
}
/***************************************************************************
* FUNCTION
*
* URT_Init_Port
*
* DESCRIPTION
*
* This function intializes the data variables associated with a UART
*
* CALLED BY
*
* PPP_Dial
* PPP_Wait_For_Client
*
* CALLS
*
* none
*
* INPUTS
*
* SD_PORT * : Serial port to reset
*
* OUTPUTS
*
* STATUS : Returns URT_SUCCESS if successful initialization,
* else a negative value is returned.
*
****************************************************************************/
#ifdef PPP
STATUS URT_Init_Port(DV_DEVICE_ENTRY *device)
{
SD_PORT *uart;
STATUS ret_status;
/* Get a pointer to the UART layer of this device. */
uart = &((PPP_LAYER *) device->ppp_layer)->uart;
/* Init the serial port, copy init parameters from the device
structure. */
uart->com_port = device->dev_com_port;
uart->baud_rate = device->dev_baud_rate;
uart->data_bits = device->dev_data_bits;
uart->stop_bits = device->dev_stop_bits;
uart->parity = device->dev_parity;
uart->data_mode = device->dev_data_mode;
uart->vector = device->dev_vect;
uart->driver_options = device->dev_driver_options;
uart->communication_mode = MDM_TERMINAL_COMMUNICATION;
uart->sd_buffer_size = (2 * (PPP_MTU + PPP_FCS_SIZE +
PPP_MAX_PROTOCOL_SIZE + PPP_MAX_ADDR_CONTROL_SIZE));
/* Init the port */
ret_status = NU_SD_Init_Port (uart);
if (ret_status == NU_SUCCESS)
{
/* Copy the vector back into the device entry just in case
the UART driver changed it. */
device->dev_vect = uart->vector;
}
return (ret_status);
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?