diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_pal_lld.c')
-rw-r--r-- | lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_pal_lld.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_pal_lld.c b/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_pal_lld.c new file mode 100644 index 000000000..d4bd7d874 --- /dev/null +++ b/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_pal_lld.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2019 Rocco Marco Guglielmi | ||
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 ADUCM36x/hal_pal_lld.c | ||
19 | * @brief ADUCM36x PAL 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 local definitions. */ | ||
31 | /*===========================================================================*/ | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Driver exported variables. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | /*===========================================================================*/ | ||
38 | /* Driver local variables and types. */ | ||
39 | /*===========================================================================*/ | ||
40 | |||
41 | /*===========================================================================*/ | ||
42 | /* Driver local functions. */ | ||
43 | /*===========================================================================*/ | ||
44 | |||
45 | /*===========================================================================*/ | ||
46 | /* Driver interrupt handlers. */ | ||
47 | /*===========================================================================*/ | ||
48 | |||
49 | /*===========================================================================*/ | ||
50 | /* Driver exported functions. */ | ||
51 | /*===========================================================================*/ | ||
52 | |||
53 | /** | ||
54 | * @brief PAL driver initialization. | ||
55 | * | ||
56 | * @notapi | ||
57 | */ | ||
58 | void _pal_lld_init(void) { | ||
59 | |||
60 | } | ||
61 | |||
62 | /** | ||
63 | * @brief Pads mode setup. | ||
64 | * @details This function programs a pads group belonging to the same port | ||
65 | * with the specified mode. | ||
66 | * @note @p PAL_MODE_UNCONNECTED is implemented as push pull at minimum | ||
67 | * speed. | ||
68 | * | ||
69 | * @param[in] port the port identifier | ||
70 | * @param[in] mask the group mask | ||
71 | * @param[in] mode the mode | ||
72 | * | ||
73 | * @notapi | ||
74 | */ | ||
75 | void _pal_lld_setgroupmode(ioportid_t port, | ||
76 | ioportmask_t mask, | ||
77 | iomode_t mode) { | ||
78 | |||
79 | uint32_t con = (mode & PAL_ADUCM_CON_MASK) >> PAL_ADUCM_CON_OFF; | ||
80 | uint32_t oen = (mode & PAL_ADUCM_OEN_MASK) >> PAL_ADUCM_OEN_OFF; | ||
81 | uint32_t pul = (mode & PAL_ADUCM_PUL_MASK) >> PAL_ADUCM_PUL_OFF; | ||
82 | uint32_t oce = (mode & PAL_ADUCM_OCE_MASK) >> PAL_ADUCM_OCE_OFF; | ||
83 | uint32_t bit = 0; | ||
84 | while (true) { | ||
85 | if ((mask & 1) != 0) { | ||
86 | uint32_t m1, m2; | ||
87 | m1 = 3 << (bit * 2); | ||
88 | m2 = 1 << bit; | ||
89 | |||
90 | port->CON = (port->CON & ~m1) | con; | ||
91 | port->OEN = (port->OEN & ~m2) | oen; | ||
92 | port->PUL = (port->PUL & ~m2) | pul; | ||
93 | port->OCE = (port->OCE & ~m2) | oce; | ||
94 | |||
95 | } | ||
96 | mask >>= 1; | ||
97 | if (!mask) | ||
98 | return; | ||
99 | con <<= 2; | ||
100 | oen <<= 1; | ||
101 | pul <<= 1; | ||
102 | oce <<= 1; | ||
103 | bit++; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | #endif /* HAL_USE_PAL */ | ||
108 | |||
109 | /** @} */ | ||