]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/RegisterWriteProtect.c
Update demos that use FreeRTOS+FAT SL to have correct version numbers after the updat...
[freertos] / FreeRTOS / Demo / RX600_RX64M_RSK_Renesas_e2studio / Source / Renesas_Code / RegisterWriteProtect.c
1 /*\r
2  * RegisterWriteProtect.c\r
3  *\r
4  *  Created on: 4 Mar 2014\r
5  *      Author: WarnerR\r
6  */\r
7 \r
8 #include "r_cg_iodefine.h"\r
9 #include "stdint.h"\r
10 \r
11 #define PRC0_BIT        0x0001\r
12 #define PRC1_BIT        0x0002\r
13 #define PRC3_BIT        0x0008\r
14 \r
15 \r
16 void EnablePRCR( uint16_t protect )\r
17 {\r
18         /*\r
19          * PRCR         Bit Register to be Protected\r
20          * -----------------------------------------------------------------------------------------------------------------------------------------\r
21          * PRC0         Registers related to the clock generation circuit:\r
22          *                      SCKCR, SCKCR2, SCKCR3, PLLCR, PLLCR2, BCKCR, MOSCCR, SOSCCR, LOCOCR, ILOCOCR, HOCOCR, HOCOCR2, OSTDCR, OSTDSR\r
23          *\r
24          * PRC1         Registers related to the operating modes:\r
25          *                      SYSCR0, SYSCR1\r
26          *\r
27          *                      Registers related to the low power consumption functions:\r
28          *                      SBYCR, MSTPCRA, MSTPCRB, MSTPCRC, MSTPCRD, OPCCR, RSTCKCR, DPSBYCR, DPSIER0 to DPSIER3, DPSIFR0 to DPSIFR3, DPSIEGR0 to DPSIEGR3\r
29          *\r
30          *                      Registers related to clock generation circuit:\r
31          *                      MOSCWTCR, SOSCWTCR, MOFCR, HOCOPCR\r
32          *\r
33          *                      Software reset register:\r
34          *                      SWRR\r
35          *\r
36          * PRC3         Registers related to the LVD:\r
37          *                      LVCMPCR, LVDLVLR, LVD1CR0, LVD1CR1, LVD1SR, LVD2CR0, LVD2CR1, LVD2SR\r
38          */\r
39         SYSTEM.PRCR.WORD = (uint16_t)( 0xA500 | protect );\r
40 }\r
41 \r
42 void DisablePRCR( uint16_t protect )\r
43 {\r
44         /*\r
45          * PRCR         Bit Register to be Protected\r
46          * -----------------------------------------------------------------------------------------------------------------------------------------\r
47          * PRC0         Registers related to the clock generation circuit:\r
48          *                      SCKCR, SCKCR2, SCKCR3, PLLCR, PLLCR2, BCKCR, MOSCCR, SOSCCR, LOCOCR, ILOCOCR, HOCOCR, HOCOCR2, OSTDCR, OSTDSR\r
49          *\r
50          * PRC1         Registers related to the operating modes:\r
51          *                      SYSCR0, SYSCR1\r
52          *\r
53          *                      Registers related to the low power consumption functions:\r
54          *                      SBYCR, MSTPCRA, MSTPCRB, MSTPCRC, MSTPCRD, OPCCR, RSTCKCR, DPSBYCR, DPSIER0 to DPSIER3, DPSIFR0 to DPSIFR3, DPSIEGR0 to DPSIEGR3\r
55          *\r
56          *                      Registers related to clock generation circuit:\r
57          *                      MOSCWTCR, SOSCWTCR, MOFCR, HOCOPCR\r
58          *\r
59          *                      Software reset register:\r
60          *                      SWRR\r
61          *\r
62          * PRC3         Registers related to the LVD:\r
63          *                      LVCMPCR, LVDLVLR, LVD1CR0, LVD1CR1, LVD1SR, LVD2CR0, LVD2CR1, LVD2SR\r
64          */\r
65         uint16_t current_value;\r
66 \r
67         current_value = (uint16_t)( SYSTEM.PRCR.WORD & 0x00ff );\r
68         current_value = (uint16_t)( current_value & ~protect );\r
69 \r
70         SYSTEM.PRCR.WORD = (uint16_t)( 0xA500 | current_value );\r
71 }\r
72 \r