system.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /** @file system.c
  2. * @brief System Driver Source File
  3. * @date 29.May.2013
  4. * @version 03.05.02
  5. *
  6. * This file contains:
  7. * - API Functions
  8. * .
  9. * which are relevant for the System driver.
  10. */
  11. /* (c) Texas Instruments 2009-2013, All rights reserved. */
  12. /* USER CODE BEGIN (0) */
  13. /* USER CODE END */
  14. /* Include Files */
  15. #include "system.h"
  16. #include "sys_selftest.h"
  17. #include "sys_pcr.h"
  18. #include "pinmux.h"
  19. /* USER CODE BEGIN (1) */
  20. /* USER CODE END */
  21. /** @fn void systemInit(void)
  22. * @brief Initializes System Driver
  23. *
  24. * This function initializes the System driver.
  25. *
  26. */
  27. /* USER CODE BEGIN (2) */
  28. /* USER CODE END */
  29. void setupPLL(void)
  30. {
  31. /* USER CODE BEGIN (3) */
  32. /* USER CODE END */
  33. /** - Configure PLL control registers */
  34. /** @b Initialize @b Pll1: */
  35. /** - Setup pll control register 1:
  36. * - Setup reset on oscillator slip
  37. * - Setup bypass on pll slip
  38. * - setup Pll output clock divider to max before Lock
  39. * - Setup reset on oscillator fail
  40. * - Setup reference clock divider
  41. * - Setup Pll multiplier
  42. */
  43. systemREG1->PLLCTL1 = 0x00000000U
  44. | 0x20000000U
  45. | ((0x1FU)<< 24U)
  46. | 0x00000000U
  47. | ((6U - 1U)<< 16U)
  48. | ((150U - 1U)<< 8U);
  49. /** - Setup pll control register 2
  50. * - Enable/Disable frequency modulation
  51. * - Setup spreading rate
  52. * - Setup bandwidth adjustment
  53. * - Setup internal Pll output divider
  54. * - Setup spreading amount
  55. */
  56. systemREG1->PLLCTL2 = 0x00000000U
  57. | (255U << 22U)
  58. | (7U << 12U)
  59. | ((2U - 1U)<< 9U)
  60. | 61U;
  61. /** @b Initialize @b Pll2: */
  62. /** - Setup pll2 control register :
  63. * - setup Pll output clock divider to max before Lock
  64. * - Setup reference clock divider
  65. * - Setup internal Pll output divider
  66. * - Setup Pll multiplier
  67. */
  68. systemREG2->PLLCTL3 = ((2U - 1U) << 29U)
  69. | ((0x1FU)<< 24U)
  70. | ((6U - 1U)<< 16U)
  71. | ((150U - 1U) << 8U);
  72. /** - Enable PLL(s) to start up or Lock */
  73. systemREG1->CSDIS = 0x00000000U
  74. | 0x00000000U
  75. | 0x00000008U
  76. | 0x00000080U
  77. | 0x00000000U
  78. | 0x00000000U
  79. | 0x00000000U;
  80. }
  81. void trimLPO(void)
  82. {
  83. /* USER CODE BEGIN (4) */
  84. /* USER CODE END */
  85. /** @b Initialize Lpo: */
  86. /** Load TRIM values from OTP if present else load user defined values */
  87. if(LPO_TRIM_VALUE != 0xFFFFU)
  88. {
  89. systemREG1->LPOMONCTL = (1U << 24U)
  90. | LPO_TRIM_VALUE;
  91. }
  92. else
  93. {
  94. systemREG1->LPOMONCTL = (1U << 24U)
  95. | (16U << 8U)
  96. | 8U;
  97. }
  98. /* USER CODE BEGIN (5) */
  99. /* USER CODE END */
  100. }
  101. void setupFlash(void)
  102. {
  103. /* USER CODE BEGIN (6) */
  104. /* USER CODE END */
  105. /** - Setup flash read mode, address wait states and data wait states */
  106. flashWREG->FRDCNTL = 0x00000000U
  107. | (3U << 8U)
  108. | (1U << 4U)
  109. | 1U;
  110. /** - Setup flash access wait states for bank 7 */
  111. FSM_WR_ENA_HL = 0x5U;
  112. EEPROM_CONFIG_HL = 0x00000002U
  113. | (3U << 16U) ;
  114. /* USER CODE BEGIN (7) */
  115. /* USER CODE END */
  116. /** - Disable write access to flash state machine registers */
  117. FSM_WR_ENA_HL = 0xAU;
  118. /** - Setup flash bank power modes */
  119. flashWREG->FBFALLBACK = 0x00000000U
  120. | (SYS_ACTIVE << 14U)
  121. | (SYS_SLEEP << 12U)
  122. | (SYS_SLEEP << 10U)
  123. | (SYS_SLEEP << 8U)
  124. | (SYS_SLEEP << 6U)
  125. | (SYS_SLEEP << 4U)
  126. | (SYS_ACTIVE << 2U)
  127. | SYS_ACTIVE;
  128. /* USER CODE BEGIN (8) */
  129. /* USER CODE END */
  130. }
  131. void periphInit(void)
  132. {
  133. /* USER CODE BEGIN (9) */
  134. /* USER CODE END */
  135. /** - Disable Peripherals before peripheral powerup*/
  136. systemREG1->CLKCNTL &= 0xFFFFFEFFU;
  137. /** - Release peripherals from reset and enable clocks to all peripherals */
  138. /** - Power-up all peripherals */
  139. pcrREG->PSPWRDWNCLR0 = 0xFFFFFFFFU;
  140. pcrREG->PSPWRDWNCLR1 = 0xFFFFFFFFU;
  141. pcrREG->PSPWRDWNCLR2 = 0xFFFFFFFFU;
  142. pcrREG->PSPWRDWNCLR3 = 0xFFFFFFFFU;
  143. /** - Enable Peripherals */
  144. systemREG1->CLKCNTL |= 1U << 8U;
  145. /* USER CODE BEGIN (10) */
  146. /* USER CODE END */
  147. }
  148. void mapClocks(void)
  149. {
  150. /* USER CODE BEGIN (11) */
  151. /* USER CODE END */
  152. /** @b Initialize @b Clock @b Tree: */
  153. /** - Disable / Enable clock domain */
  154. systemREG1->CDDIS= (FALSE << 4U ) /* AVCLK 1 OFF */
  155. |(TRUE << 5U ) /* AVCLK 2 OFF */
  156. |(FALSE << 8U ) /* VCLK3 OFF */
  157. |(FALSE << 9U ) /* VCLK4 OFF */
  158. |(FALSE << 10U) /* AVCLK 3 OFF */
  159. |(FALSE << 11U); /* AVCLK 4 OFF */
  160. /* Work Around for Errata SYS#46:
  161. *
  162. * Errata Description:
  163. * Clock Source Switching Not Qualified with Clock Source Enable And Clock Source Valid
  164. * Workaround:
  165. * Always check the CSDIS register to make sure the clock source is turned on and check
  166. * the CSVSTAT register to make sure the clock source is valid. Then write to GHVSRC to switch the clock.
  167. */
  168. /** - Wait for until clocks are locked */
  169. while ((systemREG1->CSVSTAT & ((systemREG1->CSDIS ^ 0xFFU) & 0xFFU)) != ((systemREG1->CSDIS ^ 0xFFU) & 0xFFU))
  170. {
  171. } /* Wait */
  172. /* USER CODE BEGIN (12) */
  173. /* USER CODE END */
  174. /* Now the PLLs are locked and the PLL outputs can be sped up */
  175. /* The R-divider was programmed to be 0xF. Now this divider is changed to programmed value */
  176. systemREG1->PLLCTL1 = (systemREG1->PLLCTL1 & 0xE0FFFFFFU)|((1U - 1U)<< 24U);
  177. systemREG2->PLLCTL3 = (systemREG2->PLLCTL3 & 0xE0FFFFFFU)|((1U - 1U)<< 24U);
  178. /** - Map device clock domains to desired sources and configure top-level dividers */
  179. /** - All clock domains are working off the default clock sources until now */
  180. /** - The below assignments can be easily modified using the HALCoGen GUI */
  181. /** - Setup GCLK, HCLK and VCLK clock source for normal operation, power down mode and after wakeup */
  182. systemREG1->GHVSRC = (SYS_PLL1 << 24U)
  183. | (SYS_PLL1 << 16U)
  184. | SYS_PLL1;
  185. /** - Setup synchronous peripheral clock dividers for VCLK1, VCLK2, VCLK3 */
  186. systemREG1->CLKCNTL = (systemREG1->CLKCNTL & 0xF0F0FFFFU)
  187. | (1U << 24U)
  188. | (1U << 16U);
  189. systemREG2->CLK2CNTL = (systemREG2->CLK2CNTL & 0xFFFFF0F0U)
  190. | (1U) << 8U
  191. | (1U);
  192. /* USER CODE BEGIN (13) */
  193. /* USER CODE END */
  194. /** - Setup RTICLK1 and RTICLK2 clocks */
  195. systemREG1->RCLKSRC = (1U << 24U)
  196. | (SYS_VCLK << 16U)
  197. | (1U << 8U)
  198. | SYS_VCLK;
  199. /** - Setup asynchronous peripheral clock sources for AVCLK1 and AVCLK2 */
  200. systemREG1->VCLKASRC = (SYS_VCLK << 8U)
  201. | SYS_VCLK;
  202. systemREG2->VCLKACON1 = ((1U - 1U ) << 24U)
  203. | (0U << 20U)
  204. | (SYS_VCLK << 16U)
  205. | ((1U - 1U ) << 8U)
  206. | (0U << 4U)
  207. | SYS_VCLK;
  208. /* USER CODE BEGIN (14) */
  209. /* USER CODE END */
  210. }
  211. void systemInit(void)
  212. {
  213. /* USER CODE BEGIN (15) */
  214. /* USER CODE END */
  215. /* Configure PLL control registers and enable PLLs.
  216. * The PLL takes (127 + 1024 * NR) oscillator cycles to acquire lock.
  217. * This initialization sequence performs all the tasks that are not
  218. * required to be done at full application speed while the PLL locks.
  219. */
  220. setupPLL();
  221. /* USER CODE BEGIN (16) */
  222. /* USER CODE END */
  223. /* Run eFuse controller start-up checks and start eFuse controller ECC self-test.
  224. * This includes a check for the eFuse controller error outputs to be stuck-at-zero.
  225. */
  226. //efcCheck();
  227. /* USER CODE BEGIN (17) */
  228. /* USER CODE END */
  229. /* Enable clocks to peripherals and release peripheral reset */
  230. periphInit();
  231. /* USER CODE BEGIN (18) */
  232. /* USER CODE END */
  233. /* Configure device-level multiplexing and I/O multiplexing */
  234. //muxInit();
  235. /* USER CODE BEGIN (19) */
  236. /* USER CODE END */
  237. #if 0
  238. /* Wait for eFuse controller self-test to complete and check results */
  239. if ((!checkefcSelfTest()) !=0U) /* eFuse controller ECC logic self-test failed */
  240. {
  241. efcClass2Error(); /* device operation is not reliable */
  242. }
  243. #endif
  244. /* USER CODE BEGIN (20) */
  245. /* USER CODE END */
  246. /** - Set up flash address and data wait states based on the target CPU clock frequency
  247. * The number of address and data wait states for the target CPU clock frequency are specified
  248. * in the specific part's datasheet.
  249. */
  250. setupFlash();
  251. /* USER CODE BEGIN (21) */
  252. /* USER CODE END */
  253. /** - Configure the LPO such that HF LPO is as close to 10MHz as possible */
  254. trimLPO();
  255. /* USER CODE BEGIN (23) */
  256. /* USER CODE END */
  257. /** - Wait for PLLs to start up and map clock domains to desired clock sources */
  258. mapClocks();
  259. /* USER CODE BEGIN (24) */
  260. /* USER CODE END */
  261. /** - set ECLK pins functional mode */
  262. systemREG1->SYSPC1 = 0U;
  263. /** - set ECLK pins default output value */
  264. systemREG1->SYSPC4 = 0U;
  265. /** - set ECLK pins output direction */
  266. systemREG1->SYSPC2 = 1U;
  267. /** - set ECLK pins open drain enable */
  268. systemREG1->SYSPC7 = 0U;
  269. /** - set ECLK pins pullup/pulldown enable */
  270. systemREG1->SYSPC8 = 0U;
  271. /** - set ECLK pins pullup/pulldown select */
  272. systemREG1->SYSPC9 = 1U;
  273. /** - Setup ECLK */
  274. systemREG1->ECPCNTL = (0U << 24U)
  275. | (0U << 23U)
  276. | ((8U - 1U) & 0xFFFFU);
  277. /* USER CODE BEGIN (25) */
  278. /* USER CODE END */
  279. }
  280. void systemPowerDown(uint32 mode)
  281. {
  282. /* USER CODE BEGIN (26) */
  283. /* USER CODE END */
  284. /* Disable clock sources */
  285. systemREG1->CSDISSET = mode & 0x000000FFU;
  286. /* Disable clock domains */
  287. systemREG1->CDDIS = (mode >> 8U) & 0x00000FFFU;
  288. /* Idle CPU */
  289. /*SAFETYMCUSW 88 S MR:2.1 <REVIEWED> "Assembly in C needed" */
  290. asm(" wfi");
  291. /* USER CODE BEGIN (27) */
  292. /* USER CODE END */
  293. }
  294. /* USER CODE BEGIN (28) */
  295. /* USER CODE END */
  296. /** @fn void systemGetConfigValue(system_config_reg_t *config_reg, config_value_type_t type)
  297. * @brief Get the initial or current values of the configuration registers
  298. *
  299. * @param[in] *config_reg: pointer to the struct to which the initial or current value of the configuration registers need to be stored
  300. * @param[in] type: whether initial or current value of the configuration registers need to be stored
  301. * - InitialValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  302. * - CurrentValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  303. *
  304. * This function will copy the initial or current value (depending on the parameter 'type') of the configuration registers to the struct pointed by config_reg
  305. *
  306. */
  307. void systemGetConfigValue(system_config_reg_t *config_reg, config_value_type_t type)
  308. {
  309. if (type == InitialValue)
  310. {
  311. config_reg->CONFIG_SYSPC1 = SYS_SYSPC1_CONFIGVALUE;
  312. config_reg->CONFIG_SYSPC2 = SYS_SYSPC2_CONFIGVALUE;
  313. config_reg->CONFIG_SYSPC7 = SYS_SYSPC7_CONFIGVALUE;
  314. config_reg->CONFIG_SYSPC8 = SYS_SYSPC8_CONFIGVALUE;
  315. config_reg->CONFIG_SYSPC9 = SYS_SYSPC9_CONFIGVALUE;
  316. config_reg->CONFIG_CSDIS = SYS_CSDIS_CONFIGVALUE;
  317. config_reg->CONFIG_CDDIS = SYS_CDDIS_CONFIGVALUE;
  318. config_reg->CONFIG_GHVSRC = SYS_GHVSRC_CONFIGVALUE;
  319. config_reg->CONFIG_VCLKASRC = SYS_VCLKASRC_CONFIGVALUE;
  320. config_reg->CONFIG_RCLKSRC = SYS_RCLKSRC_CONFIGVALUE;
  321. config_reg->CONFIG_MSTGCR = SYS_MSTGCR_CONFIGVALUE;
  322. config_reg->CONFIG_MINITGCR = SYS_MINITGCR_CONFIGVALUE;
  323. config_reg->CONFIG_MSINENA = SYS_MSINENA_CONFIGVALUE;
  324. config_reg->CONFIG_PLLCTL1 = SYS_PLLCTL1_CONFIGVALUE_2;
  325. config_reg->CONFIG_PLLCTL2 = SYS_PLLCTL2_CONFIGVALUE;
  326. config_reg->CONFIG_UERFLAG = SYS_UERFLAG_CONFIGVALUE;
  327. if(LPO_TRIM_VALUE != 0xFFFFU)
  328. {
  329. config_reg->CONFIG_LPOMONCTL = SYS_LPOMONCTL_CONFIGVALUE_1;
  330. }
  331. else
  332. {
  333. config_reg->CONFIG_LPOMONCTL = SYS_LPOMONCTL_CONFIGVALUE_2;
  334. }
  335. config_reg->CONFIG_CLKTEST = SYS_CLKTEST_CONFIGVALUE;
  336. config_reg->CONFIG_DFTCTRLREG1 = SYS_DFTCTRLREG1_CONFIGVALUE;
  337. config_reg->CONFIG_DFTCTRLREG2 = SYS_DFTCTRLREG2_CONFIGVALUE;
  338. config_reg->CONFIG_GPREG1 = SYS_GPREG1_CONFIGVALUE;
  339. config_reg->CONFIG_RAMGCR = SYS_RAMGCR_CONFIGVALUE;
  340. config_reg->CONFIG_BMMCR1 = SYS_BMMCR1_CONFIGVALUE;
  341. config_reg->CONFIG_MMUGCR = SYS_MMUGCR_CONFIGVALUE;
  342. config_reg->CONFIG_CLKCNTL = SYS_CLKCNTL_CONFIGVALUE;
  343. config_reg->CONFIG_ECPCNTL = SYS_ECPCNTL_CONFIGVALUE;
  344. config_reg->CONFIG_DEVCR1 = SYS_DEVCR1_CONFIGVALUE;
  345. config_reg->CONFIG_SYSECR = SYS_SYSECR_CONFIGVALUE;
  346. config_reg->CONFIG_PLLCTL3 = SYS2_PLLCTL3_CONFIGVALUE_2;
  347. config_reg->CONFIG_STCCLKDIV = SYS2_STCCLKDIV_CONFIGVALUE;
  348. config_reg->CONFIG_CLK2CNTL = SYS2_CLK2CNTL_CONFIGVALUE;
  349. config_reg->CONFIG_VCLKACON1 = SYS2_VCLKACON1_CONFIGVALUE;
  350. config_reg->CONFIG_CLKSLIP = SYS2_CLKSLIP_CONFIGVALUE;
  351. config_reg->CONFIG_EFC_CTLEN = SYS2_EFC_CTLEN_CONFIGVALUE;
  352. }
  353. else
  354. {
  355. config_reg->CONFIG_SYSPC1 = systemREG1->SYSPC1;
  356. config_reg->CONFIG_SYSPC2 = systemREG1->SYSPC2;
  357. config_reg->CONFIG_SYSPC7 = systemREG1->SYSPC7;
  358. config_reg->CONFIG_SYSPC8 = systemREG1->SYSPC8;
  359. config_reg->CONFIG_SYSPC9 = systemREG1->SYSPC9;
  360. config_reg->CONFIG_CSDIS = systemREG1->CSDIS;
  361. config_reg->CONFIG_CDDIS = systemREG1->CDDIS;
  362. config_reg->CONFIG_GHVSRC = systemREG1->GHVSRC;
  363. config_reg->CONFIG_VCLKASRC = systemREG1->VCLKASRC;
  364. config_reg->CONFIG_RCLKSRC = systemREG1->RCLKSRC;
  365. config_reg->CONFIG_MSTGCR = systemREG1->MSTGCR;
  366. config_reg->CONFIG_MINITGCR = systemREG1->MINITGCR;
  367. config_reg->CONFIG_MSINENA = systemREG1->MSINENA;
  368. config_reg->CONFIG_PLLCTL1 = systemREG1->PLLCTL1;
  369. config_reg->CONFIG_PLLCTL2 = systemREG1->PLLCTL2;
  370. config_reg->CONFIG_UERFLAG = systemREG1->UERFLAG;
  371. config_reg->CONFIG_LPOMONCTL = systemREG1->LPOMONCTL;
  372. config_reg->CONFIG_CLKTEST = systemREG1->CLKTEST;
  373. config_reg->CONFIG_DFTCTRLREG1 = systemREG1->DFTCTRLREG1;
  374. config_reg->CONFIG_DFTCTRLREG2 = systemREG1->DFTCTRLREG2;
  375. config_reg->CONFIG_GPREG1 = systemREG1->GPREG1;
  376. config_reg->CONFIG_RAMGCR = systemREG1->RAMGCR;
  377. config_reg->CONFIG_BMMCR1 = systemREG1->BMMCR1;
  378. config_reg->CONFIG_MMUGCR = systemREG1->MMUGCR;
  379. config_reg->CONFIG_CLKCNTL = systemREG1->CLKCNTL;
  380. config_reg->CONFIG_ECPCNTL = systemREG1->ECPCNTL;
  381. config_reg->CONFIG_DEVCR1 = systemREG1->DEVCR1;
  382. config_reg->CONFIG_SYSECR = systemREG1->SYSECR;
  383. config_reg->CONFIG_PLLCTL3 = systemREG2->PLLCTL3;
  384. config_reg->CONFIG_STCCLKDIV = systemREG2->STCCLKDIV;
  385. config_reg->CONFIG_CLK2CNTL = systemREG2->CLK2CNTL;
  386. config_reg->CONFIG_VCLKACON1 = systemREG2->VCLKACON1;
  387. config_reg->CONFIG_CLKSLIP = systemREG2->CLKSLIP;
  388. config_reg->CONFIG_EFC_CTLEN = systemREG2->EFC_CTLEN;
  389. }
  390. }
  391. /** @fn void tcmflashGetConfigValue(tcmflash_config_reg_t *config_reg, config_value_type_t type)
  392. * @brief Get the initial or current values of the configuration registers
  393. *
  394. * @param[in] *config_reg: pointer to the struct to which the initial or current value of the configuration registers need to be stored
  395. * @param[in] type: whether initial or current value of the configuration registers need to be stored
  396. * - InitialValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  397. * - CurrentValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  398. *
  399. * This function will copy the initial or current value (depending on the parameter 'type') of the configuration registers to the struct pointed by config_reg
  400. *
  401. */
  402. void tcmflashGetConfigValue(tcmflash_config_reg_t *config_reg, config_value_type_t type)
  403. {
  404. if (type == InitialValue)
  405. {
  406. config_reg-> CONFIG_FRDCNTL = TCMFLASH_FRDCNTL_CONFIGVALUE;
  407. config_reg-> CONFIG_FEDACCTRL1 = TCMFLASH_FEDACCTRL1_CONFIGVALUE;
  408. config_reg-> CONFIG_FEDACCTRL2 = TCMFLASH_FEDACCTRL2_CONFIGVALUE;
  409. config_reg-> CONFIG_FEDACSDIS = TCMFLASH_FEDACSDIS_CONFIGVALUE;
  410. config_reg-> CONFIG_FBPROT = TCMFLASH_FBPROT_CONFIGVALUE;
  411. config_reg-> CONFIG_FBSE = TCMFLASH_FBSE_CONFIGVALUE;
  412. config_reg-> CONFIG_FBAC = TCMFLASH_FBAC_CONFIGVALUE;
  413. config_reg-> CONFIG_FBFALLBACK = TCMFLASH_FBFALLBACK_CONFIGVALUE;
  414. config_reg-> CONFIG_FPAC1 = TCMFLASH_FPAC1_CONFIGVALUE;
  415. config_reg-> CONFIG_FPAC2 = TCMFLASH_FPAC2_CONFIGVALUE;
  416. config_reg-> CONFIG_FMAC = TCMFLASH_FMAC_CONFIGVALUE;
  417. config_reg-> CONFIG_FLOCK = TCMFLASH_FLOCK_CONFIGVALUE;
  418. config_reg-> CONFIG_FDIAGCTRL = TCMFLASH_FDIAGCTRL_CONFIGVALUE;
  419. config_reg-> CONFIG_FEDACSDIS2 = TCMFLASH_FEDACSDIS2_CONFIGVALUE;
  420. }
  421. else
  422. {
  423. config_reg-> CONFIG_FRDCNTL = flashWREG->FRDCNTL;
  424. config_reg-> CONFIG_FEDACCTRL1 = flashWREG->FEDACCTRL1;
  425. config_reg-> CONFIG_FEDACCTRL2 = flashWREG->FEDACCTRL2;
  426. config_reg-> CONFIG_FEDACSDIS = flashWREG->FEDACSDIS;
  427. config_reg-> CONFIG_FBPROT = flashWREG->FBPROT;
  428. config_reg-> CONFIG_FBSE = flashWREG->FBSE;
  429. config_reg-> CONFIG_FBAC = flashWREG->FBAC;
  430. config_reg-> CONFIG_FBFALLBACK = flashWREG->FBFALLBACK;
  431. config_reg-> CONFIG_FPAC1 = flashWREG->FPAC1;
  432. config_reg-> CONFIG_FPAC2 = flashWREG->FPAC2;
  433. config_reg-> CONFIG_FMAC = flashWREG->FMAC;
  434. config_reg-> CONFIG_FLOCK = flashWREG->FLOCK;
  435. config_reg-> CONFIG_FDIAGCTRL = flashWREG->FDIAGCTRL;
  436. config_reg-> CONFIG_FEDACSDIS2 = flashWREG->FEDACSDIS2;
  437. }
  438. }
  439. /** @fn void sramGetConfigValue(sram_config_reg_t *config_reg, config_value_type_t type)
  440. * @brief Get the initial or current values of the configuration registers
  441. *
  442. * @param[in] *config_reg: pointer to the struct to which the initial or current value of the configuration registers need to be stored
  443. * @param[in] type: whether initial or current value of the configuration registers need to be stored
  444. * - InitialValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  445. * - CurrentValue: initial value of the configuration registers will be stored in the struct pointed by config_reg
  446. *
  447. * This function will copy the initial or current value (depending on the parameter 'type') of the configuration registers to the struct pointed by config_reg
  448. *
  449. */
  450. void sramGetConfigValue(sram_config_reg_t *config_reg, config_value_type_t type)
  451. {
  452. if (type == InitialValue)
  453. {
  454. config_reg->CONFIG_RAMCTRL[0U] = SRAM_RAMCTRL_CONFIGVALUE;
  455. config_reg->CONFIG_RAMTHRESHOLD[0U] = SRAM_RAMTHRESHOLD_CONFIGVALUE;
  456. config_reg->CONFIG_RAMINTCTRL[0U] = SRAM_RAMINTCTRL_CONFIGVALUE;
  457. config_reg->CONFIG_RAMTEST[0U] = SRAM_RAMTEST_CONFIGVALUE;
  458. config_reg->CONFIG_RAMADDRDECVECT[0U] = SRAM_RAMADDRDECVECT_CONFIGVALUE;
  459. config_reg->CONFIG_RAMCTRL[1U] = SRAM_RAMCTRL_CONFIGVALUE;
  460. config_reg->CONFIG_RAMTHRESHOLD[1U] = SRAM_RAMTHRESHOLD_CONFIGVALUE;
  461. config_reg->CONFIG_RAMINTCTRL[1U] = SRAM_RAMINTCTRL_CONFIGVALUE;
  462. config_reg->CONFIG_RAMTEST[1U] = SRAM_RAMTEST_CONFIGVALUE;
  463. config_reg->CONFIG_RAMADDRDECVECT[1U] = SRAM_RAMADDRDECVECT_CONFIGVALUE;
  464. }
  465. else
  466. {
  467. config_reg->CONFIG_RAMCTRL[0U] = tcram1REG->RAMCTRL;
  468. config_reg->CONFIG_RAMTHRESHOLD[0U] = tcram1REG->RAMTHRESHOLD;
  469. config_reg->CONFIG_RAMINTCTRL[0U] = tcram1REG->RAMINTCTRL;
  470. config_reg->CONFIG_RAMTEST[0U] = tcram1REG->RAMTEST;
  471. config_reg->CONFIG_RAMADDRDECVECT[0U] = tcram1REG->RAMADDRDECVECT;
  472. config_reg->CONFIG_RAMCTRL[1U] = tcram2REG->RAMCTRL;
  473. config_reg->CONFIG_RAMTHRESHOLD[1U] = tcram2REG->RAMTHRESHOLD;
  474. config_reg->CONFIG_RAMINTCTRL[1U] = tcram2REG->RAMINTCTRL;
  475. config_reg->CONFIG_RAMTEST[1U] = tcram2REG->RAMTEST;
  476. config_reg->CONFIG_RAMADDRDECVECT[1U] = tcram2REG->RAMADDRDECVECT;
  477. }
  478. }