]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_M4F_M0_LPC43xx_Keil/system/fpu_init.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_M4F_M0_LPC43xx_Keil / system / fpu_init.c
1 /*********************************************************************** \r
2  * $Id: fpu_init.c \r
3  * \r
4  * Project: LPC43xx \r
5  * \r
6  * Description: fpu initialization routine\r
7  * \r
8  * Copyright(C) 2011, NXP Semiconductor\r
9  * All rights reserved.\r
10  * \r
11  ***********************************************************************\r
12  * Software that is described herein is for illustrative purposes only  \r
13  * which provides customers with programming information regarding the  \r
14  * products. This software is supplied "AS IS" without any warranties.  \r
15  * NXP Semiconductors assumes no responsibility or liability for the \r
16  * use of the software, conveys no license or title under any patent, \r
17  * copyright, or mask work right to the product. NXP Semiconductors \r
18  * reserves the right to make changes in the software without \r
19  * notification. NXP Semiconductors also make no representation or \r
20  * warranty that such application will be suitable for the specified \r
21  * use without further testing or modification. \r
22  **********************************************************************/\r
23 \r
24 #define LPC_CPACR               0xE000ED88               \r
25 \r
26 #define SCB_MVFR0           0xE000EF40\r
27 #define SCB_MVFR0_RESET     0x10110021\r
28 \r
29 #define SCB_MVFR1           0xE000EF44\r
30 #define SCB_MVFR1_RESET     0x11000011\r
31 \r
32 #include "stdint.h"\r
33 \r
34 void fpuInit(void)\r
35 {\r
36 // from arm trm manual:\r
37 //                ; CPACR is located at address 0xE000ED88\r
38 //                LDR.W R0, =0xE000ED88\r
39 //                ; Read CPACR\r
40 //                LDR R1, [R0]\r
41 //                ; Set bits 20-23 to enable CP10 and CP11 coprocessors\r
42 //                ORR R1, R1, #(0xF << 20)\r
43 //                ; Write back the modified value to the CPACR\r
44 //                STR R1, [R0]\r
45 \r
46                 \r
47     volatile uint32_t* regCpacr = (uint32_t*) LPC_CPACR;\r
48     volatile uint32_t* regMvfr0 = (uint32_t*) SCB_MVFR0;\r
49     volatile uint32_t* regMvfr1 = (uint32_t*) SCB_MVFR1;\r
50     volatile uint32_t Cpacr;\r
51     volatile uint32_t Mvfr0;\r
52     volatile uint32_t Mvfr1;    \r
53     char vfpPresent = 0;\r
54 \r
55     Mvfr0 = *regMvfr0;\r
56     Mvfr1 = *regMvfr1;\r
57 \r
58     vfpPresent = ((SCB_MVFR0_RESET == Mvfr0) && (SCB_MVFR1_RESET == Mvfr1));\r
59     \r
60     if(vfpPresent)\r
61     {\r
62         Cpacr = *regCpacr;\r
63         Cpacr |= (0xF << 20);\r
64         *regCpacr = Cpacr;   // enable CP10 and CP11 for full access\r
65     }\r
66 \r
67 }\r
68 \r
69 \r