Sound Generator Library
Fork of Sound_Generator by
Embed:
(wiki syntax)
Show/hide line numbers
sdg_userdef.c
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer 00021 * Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 00024 /****************************************************************************** 00025 Includes <System Includes> , "Project Includes" 00026 ******************************************************************************/ 00027 #include "r_typedefs.h" 00028 #include "dev_drv.h" /* Device Driver common header */ 00029 #include "devdrv_sdg.h" /* SDG Driver header */ 00030 #include "iodefine.h" 00031 #include "sdg_iobitmask.h" 00032 #include "rza_io_regrw.h" 00033 00034 /****************************************************************************** 00035 Typedef definitions 00036 ******************************************************************************/ 00037 00038 00039 /****************************************************************************** 00040 Macro definitions 00041 ******************************************************************************/ 00042 #define REGW16(CH, REG, BIT, VAL) RZA_IO_RegWrite_16(&CH.REG, VAL, CH##_##REG##_##BIT##_SHIFT, CH##_##REG##_##BIT) 00043 00044 /****************************************************************************** 00045 Imported global variables and functions (from other files) 00046 ******************************************************************************/ 00047 00048 00049 /****************************************************************************** 00050 Exported global variables and functions (to be accessed by other files) 00051 ******************************************************************************/ 00052 00053 00054 /****************************************************************************** 00055 Private global variables and functions 00056 ******************************************************************************/ 00057 00058 00059 /****************************************************************************** 00060 * Function Name: Userdef_SDG0_Open 00061 * Description : This function is a user-defined function. 00062 * Arguments : none 00063 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG0 00064 * : DEVDRV_ERROR : Failure to initialize SDG0 00065 ******************************************************************************/ 00066 int32_t Userdef_SDG0_Open(void) 00067 { 00068 return DEVDRV_ERROR; 00069 } 00070 00071 /****************************************************************************** 00072 * Function Name: Userdef_SDG1_Open 00073 * Description : This function is a user-defined function. 00074 * Arguments : none 00075 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG1 00076 * : DEVDRV_ERROR : Failure to initialize SDG1 00077 ******************************************************************************/ 00078 int32_t Userdef_SDG1_Open(void) 00079 { 00080 /* input the clock to SDG1 */ 00081 RZA_IO_RegWrite_8(&CPG.STBCR5, 0, CPG_STBCR5_MSTP54_SHIFT, CPG_STBCR5_MSTP54); 00082 00083 /* check the mode of SDG1 */ 00084 if (0 != RZA_IO_RegRead_8(&SDG1.SGCR1, SDGn_SGCR1_SGST_SHIFT, SDGn_SGCR1_SGST)) { 00085 return DEVDRV_ERROR; 00086 } 00087 00088 /* ---- P8_11 : SDOUT_1 ---- */ 00089 /* Port initialize */ 00090 REGW16(GPIO, PIBC8, PIBC811, 0); 00091 REGW16(GPIO, PBDC8, PBDC811, 0); 00092 REGW16(GPIO, PM8, PM811, 1); 00093 REGW16(GPIO, PMC8, PMC811, 0); 00094 REGW16(GPIO, PIPC8, PIPC811, 0); 00095 /* Port mode : Multiplex mode */ 00096 /* Port function setting : 7th multiplex function */ 00097 /* I/O control mode : Peripheral function */ 00098 /* Bidirectional mode : Disable */ 00099 REGW16(GPIO, PBDC8, PBDC811, 0); 00100 REGW16(GPIO, PFC8, PFC811, 0); 00101 REGW16(GPIO, PFCE8, PFCE811, 1); 00102 REGW16(GPIO, PFCAE8,PFCAE811,1); 00103 REGW16(GPIO, PIPC8, PIPC811, 1); 00104 REGW16(GPIO, PMC8, PMC811, 1); 00105 00106 return DEVDRV_SUCCESS; 00107 } 00108 00109 /****************************************************************************** 00110 * Function Name: Userdef_SDG2_Open 00111 * Description : This function is a user-defined function. 00112 * Arguments : none 00113 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG2 00114 * : DEVDRV_ERROR : Failure to initialize SDG2 00115 ******************************************************************************/ 00116 int32_t Userdef_SDG2_Open(void) 00117 { 00118 return DEVDRV_ERROR; 00119 } 00120 00121 /****************************************************************************** 00122 * Function Name: Userdef_SDG3_Open 00123 * Description : This function is a user-defined function. 00124 * Arguments : none 00125 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG3 00126 * : DEVDRV_ERROR : Failure to initialize SDG3 00127 ******************************************************************************/ 00128 int32_t Userdef_SDG3_Open(void) 00129 { 00130 /* input the clock to SDG3 */ 00131 RZA_IO_RegWrite_8(&CPG.STBCR5, 0, CPG_STBCR5_MSTP52_SHIFT, CPG_STBCR5_MSTP52); 00132 00133 /* check the mode of SDG3 */ 00134 if (0 != RZA_IO_RegRead_8(&SDG3.SGCR1, SDGn_SGCR1_SGST_SHIFT, SDGn_SGCR1_SGST)) { 00135 return DEVDRV_ERROR; 00136 } 00137 00138 /* ---- P8_13 : SDOUT_3 ---- */ 00139 /* Port initialize */ 00140 REGW16(GPIO, PIBC8, PIBC813, 0); 00141 REGW16(GPIO, PBDC8, PBDC813, 0); 00142 REGW16(GPIO, PM8, PM813, 1); 00143 REGW16(GPIO, PMC8, PMC813, 0); 00144 REGW16(GPIO, PIPC8, PIPC813, 0); 00145 /* Port mode : Multiplex mode */ 00146 /* Port function setting : 7th multiplex function */ 00147 /* I/O control mode : Peripheral function */ 00148 /* Bidirectional mode : Disable */ 00149 REGW16(GPIO, PBDC8, PBDC813, 0); 00150 REGW16(GPIO, PFC8, PFC813, 0); 00151 REGW16(GPIO, PFCE8, PFCE813, 1); 00152 REGW16(GPIO, PFCAE8,PFCAE813, 1); 00153 REGW16(GPIO, PIPC8, PIPC813, 1); 00154 REGW16(GPIO, PMC8, PMC813, 1); 00155 00156 return DEVDRV_SUCCESS; 00157 } 00158 00159 /****************************************************************************** 00160 * Function Name: Userdef_SDG0_Close 00161 * Description : This function is a user-defined function. 00162 * Arguments : none 00163 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG0 00164 * : DEVDRV_ERROR : Failure to initialize SDG0 00165 ******************************************************************************/ 00166 int32_t Userdef_SDG0_Close(void) 00167 { 00168 return DEVDRV_ERROR; 00169 } 00170 00171 00172 /****************************************************************************** 00173 * Function Name: Userdef_SDG1_Close 00174 * Description : This function is a user-defined function. 00175 * Arguments : none 00176 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG1 00177 * : DEVDRV_ERROR : Failure to initialize SDG1 00178 ******************************************************************************/ 00179 int32_t Userdef_SDG1_Close(void) 00180 { 00181 /* Stop the SDG1 */ 00182 RZA_IO_RegWrite_8(&SDG1.SGCR1, 0, SDGn_SGCR1_STPM_SHIFT, SDGn_SGCR1_STPM); 00183 RZA_IO_RegWrite_8(&SDG1.SGCR1, 0, SDGn_SGCR1_SGST_SHIFT, SDGn_SGCR1_SGST); 00184 /* Stop input the clock to SDG1 */ 00185 RZA_IO_RegWrite_8(&CPG.STBCR5, 1, CPG_STBCR5_MSTP54_SHIFT, CPG_STBCR5_MSTP54); 00186 00187 return DEVDRV_SUCCESS; 00188 } 00189 00190 /****************************************************************************** 00191 * Function Name: Userdef_SDG2_Close 00192 * Description : This function is a user-defined function. 00193 * Arguments : none 00194 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG2 00195 * : DEVDRV_ERROR : Failure to initialize SDG2 00196 ******************************************************************************/ 00197 int32_t Userdef_SDG2_Close(void) 00198 { 00199 return DEVDRV_ERROR; 00200 } 00201 00202 /****************************************************************************** 00203 * Function Name: Userdef_SDG3_Close 00204 * Description : This function is a user-defined function. 00205 * Arguments : none 00206 * Return Value : DEVDRV_SUCCESS : Success to initialize SDG3 00207 * : DEVDRV_ERROR : Failure to initialize SDG3 00208 ******************************************************************************/ 00209 int32_t Userdef_SDG3_Close(void) 00210 { 00211 /* Stop the SDG3 */ 00212 RZA_IO_RegWrite_8(&SDG3.SGCR1, 0, SDGn_SGCR1_STPM_SHIFT, SDGn_SGCR1_STPM); 00213 RZA_IO_RegWrite_8(&SDG3.SGCR1, 0, SDGn_SGCR1_SGST_SHIFT, SDGn_SGCR1_SGST); 00214 /* Stop input the clock to SDG3 */ 00215 RZA_IO_RegWrite_8(&CPG.STBCR5, 1, CPG_STBCR5_MSTP52_SHIFT, CPG_STBCR5_MSTP52); 00216 00217 return DEVDRV_SUCCESS; 00218 } 00219 00220 /* End of File */
Generated on Fri Jul 15 2022 04:21:34 by
1.7.2
