/****************************************************************************** * Function Name: R_OSTM_Init * Description : Executes initial setting for the OSTM specified by the argument * : channel. Sets the count value using the timer cycle specified * : by the argument cycle. In this sample code, the initial setting * : is executed by the Userdef_OSTMn_Init of the user-defined * : function. * Arguments : uint32_t channel : OSTM channel (0 or 1) * : uint32_t mode : OSTM operating mode * : : OSTM_MODE_INTERVAL : Interval timer mode * : : OSTM_MODE_COMPARE : Free running compare mode * : uint32_t cycle : Timer cycle * Return Value : DEVDRV_SUCCESS : Success of OSTM initialization * : DEVDRV_ERROR : Failure of OSTM initialization ******************************************************************************/ int32_t R_OSTM_Init(uint32_t channel, uint32_t mode, uint32_t cycle) { int32_t ret; /* ==== Argument check ==== */ if ((channel >= OSTM_CH_TOTAL) || (mode > OSTM_MODE_COMPARE)) { return DEVDRV_ERROR; /* Argument error */ } /* ==== OSTM initialization ==== */ switch (channel) { case DEVDRV_CH_0: #ifdef USE_CH_OSTM0 ret = Userdef_OSTM0_Init(mode, cycle); #endif /* USE_CH_OSTM0 */ break; case DEVDRV_CH_1: #ifdef USE_CH_OSTM1 ret = Userdef_OSTM1_Init(mode, cycle); #endif /* USE_CH_OSTM1 */ break; default: /* Do not reach here based on the assumption */ ret = DEVDRV_ERROR; break; } return ret; }
/****************************************************************************** * Function Name: R_OSTM_Init * Description : * Arguments : uint32_t channel * : uint32_t mode * : uint32_t cycle * Return Value : DEVDRV_SUCCESS * : DEVDRV_ERROR ******************************************************************************/ int32_t R_OSTM_Init(uint32_t channel, uint32_t mode, uint32_t cycle) { int32_t ret; if ((channel >= OSTM_CH_TOTAL) || (mode > OSTM_MODE_COMPARE)) { return DEVDRV_ERROR; } switch (channel) { case DEVDRV_CH_0: ret = Userdef_OSTM0_Init(mode, cycle); break; case DEVDRV_CH_1: ret = Userdef_OSTM1_Init(mode, cycle); break; default: ret = DEVDRV_ERROR; break; } return ret; }