drv_api.c
来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 568 行 · 第 1/2 页
C
568 行
case DRVNO_CAP:
rtnVal = smpDrv_CloseFtm_Cap();
break;
default :
rtnVal = DRV_PARAM_ERROR;
break;
}
if (rtnVal == DRV_OK) {
smpDrv_manageStateMachine(drv_no, DRVEVENT_CLOSE, handle);
}
return rtnVal;
}
/************************************************************************/
/* */
/* Function Name : smpDrv_read */
/* Input : drv_no Device drivers number. */
/* size . */
/* buff. */
/* Output : int16_t DRV_OK(1) */
/* DRV_PARAM_ERROR(-2) */
/* */
/* Note : Read data from register to buffer. */
/* */
/************************************************************************/
int16_t smpDrv_read(uint16_t drv_no, int8_t *buff, uint16_t size, int16_t handle)
{
int16_t rtnVal = DRV_OK;
rtnVal = smpDrv_manageStateMachine(drv_no, DRVEVENT_READ, handle);
if(rtnVal == DRV_OK) {
switch (drv_no) {
case DRVNO_INTFIQ:
case DRVNO_INTEXINT:
rtnVal = DRV_OK;
break;
case DRVNO_TIMER:
rtnVal = DRV_OK;
break;
case DRVNO_SIO:
rtnVal = smpDrv_ReadSIO(buff, size);
break;
case DRVNO_DMAC:
break;
case DRVNO_PIO:
break;
case DRVNO_UART:
rtnVal = smpDrv_ReadUART(buff, size);
break;
case DRVNO_PM:
break;
case DRVNO_XBUS:
rtnVal = DRV_OK;
break;
case DRVNO_REMAP:
break;
case DRVNO_ICCC:
rtnVal = DRV_OK;
break;
case DRVNO_LCDC:
rtnVal = DRV_OK;
break;
case DRVNO_WDT:
break;
case DRVNO_ADC:
rtnVal = DRV_OK;
break;
case DRVNO_I2C:
rtnVal = smpDrv_ReadI2C((uint8_t *)buff, size);
break;
case DRVNO_RTC:
rtnVal = DRV_OK;
break;
case DRVNO_SPI:
break;
case DRVNO_ART:
break;
case DRVNO_PWM:
break;
case DRVNO_CAP:
break;
default :
rtnVal = DRV_PARAM_ERROR;
break;
}
}
return rtnVal;
}
/************************************************************************/
/* */
/* Function Name : smpDrv_write */
/* Input : drv_no Device drivers number. */
/* size . */
/* buff. */
/* Output : int16_t DRV_OK(1) */
/* DRV_PARAM_ERROR(-2) */
/* */
/* Note : Copy data from buffer to register. */
/* */
/************************************************************************/
int16_t smpDrv_write(uint16_t drv_no, int8_t *buff, uint16_t size, int16_t handle)
{
int16_t rtnVal = DRV_OK;
rtnVal = smpDrv_manageStateMachine(drv_no, DRVEVENT_WRITE, handle);
if(rtnVal == DRV_OK) {
switch (drv_no) {
case DRVNO_INTFIQ:
case DRVNO_INTEXINT:
rtnVal = DRV_OK;
break;
case DRVNO_TIMER:
rtnVal = DRV_OK;
break;
case DRVNO_SIO:
rtnVal = smpDrv_WriteSIO(buff, size);
break;
case DRVNO_DMAC:
break;
case DRVNO_PIO:
break;
case DRVNO_UART:
rtnVal = smpDrv_WriteUART(buff, size);
break;
case DRVNO_PM:
break;
case DRVNO_XBUS:
rtnVal = DRV_OK;
break;
case DRVNO_REMAP:
break;
case DRVNO_ICCC:
rtnVal = DRV_OK;
break;
case DRVNO_LCDC:
rtnVal = DRV_OK;
break;
case DRVNO_WDT:
break;
case DRVNO_ADC:
rtnVal = DRV_OK;
break;
case DRVNO_I2C:
rtnVal = smpDrv_WriteI2C((uint8_t *)buff, size);
break;
case DRVNO_RTC:
rtnVal = DRV_OK;
break;
case DRVNO_SPI:
break;
case DRVNO_ART:
break;
case DRVNO_PWM:
break;
case DRVNO_CAP:
break;
default :
rtnVal = DRV_PARAM_ERROR;
break;
}
}
return rtnVal;
}
/************************************************************************/
/* */
/* Function Name : smpDrv_ioctl */
/* Input : drv_no Device drivers number. */
/* cmd . */
/* arg . */
/* Output : int16_t DRV_OK(1) */
/* DRV_PARAM_ERROR(-2) */
/* */
/* Note : Control HAL directly. */
/* */
/************************************************************************/
int16_t smpDrv_ioctl(uint16_t drv_no, uint16_t cmd, uint32_t arg, int16_t handle)
{
int16_t rtnVal = DRV_OK;
rtnVal = smpDrv_manageStateMachine(drv_no, DRVEVENT_IOCTL, handle);
if(rtnVal == DRV_OK) {
switch (drv_no) {
case DRVNO_TIMER:
rtnVal = smpDrv_IoctlTimer(cmd, arg);
break;
case DRVNO_SIO:
break;
case DRVNO_DMAC:
rtnVal = smpDrv_IoctlDmac(cmd, arg);
break;
case DRVNO_PIO:
break;
case DRVNO_UART:
break;
case DRVNO_PM:
rtnVal = smpDrv_IoctlPM(cmd, arg);
break;
case DRVNO_XBUS:
rtnVal = DRV_OK;
break;
case DRVNO_REMAP:
rtnVal = smpDrv_IoctlRemap(cmd, arg);
break;
case DRVNO_ICCC:
rtnVal = DRV_OK;
break;
case DRVNO_LCDC:
rtnVal = smpDrv_IoctlLcdc(cmd, arg);
break;
case DRVNO_WDT:
break;
case DRVNO_ADC:
rtnVal = smpDrv_IoctlAdc(cmd, arg);
break;
case DRVNO_I2C:
break;
case DRVNO_RTC:
rtnVal = smpDrv_IoctlRtc(cmd, arg);
break;
case DRVNO_SPI:
rtnVal = smpDrv_IoctlSpi(cmd, arg);
break;
case DRVNO_ART:
rtnVal = smpDrv_IoctlFtm_Art(cmd, arg);
break;
case DRVNO_PWM:
rtnVal = smpDrv_IoctlFtm_Pwm(cmd, arg);
break;
case DRVNO_CAP:
rtnVal = smpDrv_IoctlFtm_Cap(cmd, arg);
break;
default :
rtnVal = DRV_PARAM_ERROR;
break;
}
}
return rtnVal;
}
/************************************************************************/
/* */
/* Function Name : smpDrv_poll */
/* Input : drv_no Device drivers number. */
/* cmd . */
/* count . */
/* Output : int16_t DRV_OK(1) */
/* DRV_PARAM_ERROR(-2) */
/* */
/* Note : None. */
/* */
/************************************************************************/
int16_t smpDrv_poll(uint16_t drv_no, uint16_t cmd, uint16_t count, int16_t handle)
{
int16_t rtnVal = DRV_OK;
rtnVal = smpDrv_manageStateMachine(drv_no, DRVEVENT_POLL, handle);
if(rtnVal == DRV_OK) {
switch (drv_no) {
case DRVNO_TIMER:
smpDrv_PollTimer(cmd, count);
break;
case DRVNO_PWM:
smpDrv_PollFtm_Pwm(cmd, count);
break;
default :
rtnVal = DRV_PARAM_ERROR;
break;
}
}
return rtnVal;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?