hal_api.c
来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 1,406 行 · 第 1/5 页
C
1,406 行
/**********************************************************************************/
/* */
/* Copyright (C) 2006 Oki Electric Industry Co., LTD. */
/* */
/* System Name : uPLAT7D series */
/* Module Name : uPLAT7D system HAL API program */
/* File Name : hal_api.c */
/* Revision : 01.00 */
/* Date : 2006/1/1 initial version */
/* */
/**********************************************************************************/
#include "common.h"
#include "hal_common.h"
#include "hal_state.h"
#include "hal_api.h"
/*****************************************************************************/
/* */
/* Function Name : uplat7dHAL_SIOInit */
/* Parameter : */
/* Input : Transmission parameter */
/* Output : Status of processing result */
/* Note : Initialize SIO. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_SioInit( struct uPLAT_SioParam *param )
{
int16_t ret = HAL_OK;
if(manageStateMachine(UPLAT7D_HAL_SIO_INIT) == HAL_OK){
ret = HalSio_SioInit( param );
manageStateMachine(UPLAT7D_HAL_SIO_INIT_END);
}else{
ret = HAL_DOUBLE_ERROR; /* Double error. */
}
return ret;
}
/*****************************************************************************/
/* */
/* Function Name : uplat7dHAL_SioRxData */
/* Parameter : */
/* Input : Pointer to transmission data */
/* Output : Status of processing result */
/* Note : It receives the data. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_SioRxData( int8_t *buff )
{
int16_t ret = HAL_OK;
if(manageStateMachine(UPLAT7D_HAL_SIO_RX_DATA) == HAL_OK){
ret = HalSio_SioRxData( buff );
manageStateMachine(UPLAT7D_HAL_SIO_RX_DATA_END);
}else{
ret = HAL_DOUBLE_ERROR; /* Double error. */
}
return ret;
}
/*****************************************************************************/
/* */
/* Function Name : uplat7dHAL_SioTxData */
/* Parameter : */
/* Input : Pointer to transmission data */
/* Output : State of processing result */
/* Note : Data is transmitted. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_SioTxData( int8_t *buff )
{
int16_t ret = HAL_OK;
if(manageStateMachine(UPLAT_7D_HAL_SIO_TX_DATA) == HAL_OK){
ret = HalSio_SioTxData( buff );
manageStateMachine(UPLAT_7D_HAL_SIO_TX_DATA_END);
}else{
ret = HAL_DOUBLE_ERROR; /* Double error. */
}
return ret;
}
/*****************************************************************************/
/* */
/* Function Name : uplat7dHAL_SioReadStatus */
/* Parameter : */
/* Input : Pointer to transmission status */
/* Output : State of processing result */
/* Note : Read transmission status. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_SioReadStatus( int16_t *status )
{
int16_t ret = HAL_OK;
if(manageStateMachine(UPLAT_7D_HAL_SIO_READ_STATUS) == HAL_OK){
ret = HalSio_SioReadStatus( status );
manageStateMachine(UPLAT_7D_HAL_SIO_READ_STATUS_END);
}else{
ret = HAL_DOUBLE_ERROR; /* Double error. */
}
return ret;
}
/*****************************************************************************/
/* */
/* Function Name : HalUart_UartInit */
/* Parameter : */
/* Input : Transmission parameter */
/* Output : Status of processing result */
/* Note : Initialize UART. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_UartInit( struct uPLAT_UartParam *param )
{
int16_t rtnVal = HAL_OK;
if(manageStateMachine(UPLAT7D_HAL_UART_INIT) == HAL_OK){
rtnVal = HalUart_UartInit( param );
manageStateMachine(UPLAT7D_HAL_UART_INIT_END);
}else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*****************************************************************************/
/* */
/* Function Name : HalUart_UartRxData */
/* Parameter : */
/* Input : Pointer to transmission data */
/* Output : Status of processing result */
/* Note : It receives the data. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_UartRxData(int8_t *buff)
{
int16_t rtnVal = HAL_OK;
if(manageStateMachine(UPLAT7D_HAL_UART_RX_DATA) == HAL_OK){
rtnVal = HalUart_UartRxData(buff);
manageStateMachine(UPLAT7D_HAL_UART_RX_DATA_END);
}else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*****************************************************************************/
/* */
/* Function Name : HalUart_UartTxData */
/* Parameter : */
/* Input : Pointer to transmission data */
/* Output : State of processing result */
/* Note : Data is transmitted. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_UartTxData( int8_t *buff )
{
int16_t rtnVal = HAL_OK;
if(manageStateMachine(UPLAT_7D_HAL_UART_TX_DATA) == HAL_OK){
rtnVal = HalUart_UartTxData( buff );
manageStateMachine(UPLAT_7D_HAL_UART_TX_DATA_END);
}else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*****************************************************************************/
/* */
/* Function Name : HalUart_UartReadStatus */
/* Parameter : */
/* Input : Pointer to transmission status */
/* Output : State of processing result */
/* Note : Read transmission status. */
/* */
/*****************************************************************************/
int16_t uplat7dHAL_UartReadStatus( int16_t *status )
{
int16_t rtnVal = HAL_OK;
if(manageStateMachine(UPLAT_7D_HAL_UART_READ_STATUS) == HAL_OK){
rtnVal = HalUart_UartReadStatus( status );
manageStateMachine(UPLAT_7D_HAL_UART_READ_STATUS_END);
}else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*********************************************************************/
/* */
/* Function Name : uplat7dHAL_PioSetFunction */
/* Input : struct uPLAT_PioFunctionParam */
/* Output : int16_t HAL_OK(1) */
/* HAL_DOUBLE_ERROR(-2) */
/* Note : Setfunctione pio. */
/* */
/*********************************************************************/
int16_t uplat7dHAL_PioSetFunction(uPLAT_PioFunctionParam *param)
{
int16_t rtnVal = HAL_OK;
if (manageStateMachine(UPLAT_7D_HAL_PIO_SET_FUNCTION) == HAL_OK) {
HalPio_PioSetFunction(param);
manageStateMachine(UPLAT_7D_HAL_PIO_SET_FUNCTION_END);
}
else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*********************************************************************/
/* */
/* Function Name : uplat7dHAL_PioGetFunction */
/* Input : struct uPLAT_PioFunctionParam */
/* Output : int16_t HAL_OK(1) */
/* HAL_DOUBLE_ERROR(-2) */
/* Note : Getfunctione pio. */
/* */
/*********************************************************************/
int16_t uplat7dHAL_PioGetFunction(uPLAT_PioFunctionParam *param)
{
int16_t rtnVal = HAL_OK;
if (manageStateMachine(UPLAT_7D_HAL_PIO_GET_FUNCTION) == HAL_OK) {
rtnVal = HalPio_PioGetFunction(param);
manageStateMachine(UPLAT_7D_HAL_PIO_GET_FUNCTION_END);
}
else{
rtnVal = HAL_DOUBLE_ERROR; /* Double error. */
}
return rtnVal;
}
/*********************************************************************/
/* */
/* Function Name : uplat7dHAL_PioSetIo */
/* Input : port_no , port_io */
/* Output : int16_t HAL_OK(1) */
/* HAL_DOUBLE_ERROR(-2) */
/* Note : Pio set io. */
/* */
/*********************************************************************/
int16_t uplat7dHAL_PioSetIo(uint16_t port_no, uint8_t port_io)
{
int16_t ret = HAL_OK;
if (manageStateMachine(UPLAT_7D_HAL_PIO_SET_IO) == HAL_OK) {
ret = HalPio_PioSetIo(port_no, port_io);
manageStateMachine(UPLAT_7D_HAL_PIO_SET_IO_END);
}
else{
ret = HAL_DOUBLE_ERROR; /* Double error. */
}
return ret;
}
/*********************************************************************/
/* */
/* Function Name : uplat7dHAL_PioReadIo */
/* Input : port_no , *port_io */
/* Output : int16_t HAL_OK(1) */
/* HAL_DOUBLE_ERROR(-2) */
/* Note : Pio set io read. */
/* */
/*********************************************************************/
int16_t uplat7dHAL_PioReadIo(uint16_t port_no, uint8_t *port_io)
{
int16_t ret = HAL_OK;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?