diff options
Diffstat (limited to 'lib/chibios/os/hal/boards/OLIMEX_LPC_P2148/board.c')
-rw-r--r-- | lib/chibios/os/hal/boards/OLIMEX_LPC_P2148/board.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/boards/OLIMEX_LPC_P2148/board.c b/lib/chibios/os/hal/boards/OLIMEX_LPC_P2148/board.c new file mode 100644 index 000000000..5060e41ab --- /dev/null +++ b/lib/chibios/os/hal/boards/OLIMEX_LPC_P2148/board.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "hal.h" | ||
18 | |||
19 | #define VAL_TC0_PRESCALER 0 | ||
20 | |||
21 | /** | ||
22 | * @brief PAL setup. | ||
23 | * @details Digital I/O ports static configuration as defined in @p board.h. | ||
24 | * This variable is used by the HAL when initializing the PAL driver. | ||
25 | */ | ||
26 | #if HAL_USE_PAL || defined(__DOXYGEN__) | ||
27 | const PALConfig pal_default_config = | ||
28 | { | ||
29 | VAL_PINSEL0, | ||
30 | VAL_PINSEL1, | ||
31 | VAL_PINSEL2, | ||
32 | {VAL_FIO0PIN, VAL_FIO0DIR}, | ||
33 | {VAL_FIO1PIN, VAL_FIO1DIR} | ||
34 | }; | ||
35 | #endif | ||
36 | |||
37 | /* | ||
38 | * Timer 0 IRQ handling here. | ||
39 | */ | ||
40 | static CH_IRQ_HANDLER(T0IrqHandler) { | ||
41 | |||
42 | CH_IRQ_PROLOGUE(); | ||
43 | T0IR = 1; /* Clear interrupt on match MR0. */ | ||
44 | |||
45 | chSysLockFromISR(); | ||
46 | chSysTimerHandlerI(); | ||
47 | chSysUnlockFromISR(); | ||
48 | |||
49 | VICVectAddr = 0; | ||
50 | CH_IRQ_EPILOGUE(); | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * Early initialization code. | ||
55 | * This initialization must be performed just after stack setup and before | ||
56 | * any other initialization. | ||
57 | */ | ||
58 | void __early_init(void) { | ||
59 | |||
60 | lpc214x_clock_init(); | ||
61 | } | ||
62 | |||
63 | #if HAL_USE_MMC_SPI | ||
64 | /* Board-related functions related to the MMC_SPI driver.*/ | ||
65 | bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { | ||
66 | |||
67 | (void)mmcp; | ||
68 | return !palReadPad(IOPORT2, PB_CP1); | ||
69 | } | ||
70 | |||
71 | bool mmc_lld_is_write_protected(MMCDriver *mmcp) { | ||
72 | |||
73 | (void)mmcp; | ||
74 | return palReadPad(IOPORT2, PB_WP1); | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | /* | ||
79 | * Board-specific initialization code. | ||
80 | */ | ||
81 | void boardInit(void) { | ||
82 | |||
83 | /* | ||
84 | * System Timer initialization, 1ms intervals. | ||
85 | */ | ||
86 | SetVICVector(T0IrqHandler, 0, SOURCE_Timer0); | ||
87 | VICIntEnable = INTMASK(SOURCE_Timer0); | ||
88 | TC *timer = T0Base; | ||
89 | timer->TC_PR = VAL_TC0_PRESCALER; | ||
90 | timer->TC_MR0 = (PCLK / CH_CFG_ST_FREQUENCY) / (VAL_TC0_PRESCALER + 1); | ||
91 | timer->TC_MCR = 3; /* Interrupt and clear TC on match MR0. */ | ||
92 | timer->TC_TCR = 2; /* Reset counter and prescaler. */ | ||
93 | timer->TC_TCR = 1; /* Timer enabled. */ | ||
94 | } | ||