aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c')
-rw-r--r--lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c b/lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c
new file mode 100644
index 000000000..ba5e96b2b
--- /dev/null
+++ b/lib/chibios/os/hal/ports/LPC/LPC214x/hal_pal_lld.c
@@ -0,0 +1,112 @@
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/**
18 * @file LPC214x/hal_pal_lld.c
19 * @brief LPC214x FIO low level driver code.
20 *
21 * @addtogroup PAL
22 * @{
23 */
24
25#include "hal.h"
26
27#if HAL_USE_PAL || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver exported variables. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver local variables and types. */
35/*===========================================================================*/
36
37/*===========================================================================*/
38/* Driver local functions. */
39/*===========================================================================*/
40
41/*===========================================================================*/
42/* Driver interrupt handlers. */
43/*===========================================================================*/
44
45/*===========================================================================*/
46/* Driver exported functions. */
47/*===========================================================================*/
48
49/**
50 * @brief LPC214x I/O ports configuration.
51 * @details FIO units and PINSEL registers initialization.
52 *
53 * @param[in] config the LPC214x ports configuration
54 *
55 * @notapi
56 */
57void _pal_lld_init(const PALConfig *config) {
58
59 /* Enables the access through the fast registers.*/
60 SCS = 3;
61
62 /* I/O pads initial assignment, device drivers may change this setup at a
63 * later time.*/
64 PINSEL0 = config->pinsel0;
65 PINSEL1 = config->pinsel1;
66 PINSEL2 = config->pinsel2;
67
68 /* I/O pads direction initial setting.*/
69 FIO0Base->FIO_MASK = 0;
70 FIO0Base->FIO_PIN = config->P0Data.pin;
71 FIO0Base->FIO_DIR = config->P0Data.dir;
72 FIO1Base->FIO_MASK = 0;
73 FIO1Base->FIO_PIN = config->P1Data.pin;
74 FIO1Base->FIO_DIR = config->P1Data.dir;
75}
76
77/**
78 * @brief Pads mode setup.
79 * @details This function programs a pads group belonging to the same port
80 * with the specified mode.
81 * @note @p PAL_MODE_UNCONNECTED is implemented as push pull output with
82 * high state.
83 * @note This function does not alter the @p PINSELx registers. Alternate
84 * functions setup must be handled by device-specific code.
85 *
86 * @param[in] port the port identifier
87 * @param[in] mask the group mask
88 * @param[in] mode the mode
89 *
90 * @notapi
91 */
92void _pal_lld_setgroupmode(ioportid_t port,
93 ioportmask_t mask,
94 iomode_t mode) {
95
96 switch (mode) {
97 case PAL_MODE_RESET:
98 case PAL_MODE_INPUT:
99 port->FIO_DIR &= ~mask;
100 break;
101 case PAL_MODE_UNCONNECTED:
102 port->FIO_PIN |= mask;
103 /* Falls through.*/
104 case PAL_MODE_OUTPUT_PUSHPULL:
105 port->FIO_DIR |= mask;
106 break;
107 }
108}
109
110#endif /* HAL_USE_PAL */
111
112/** @} */