1 /******************************************************************************
2 *
3 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
4 * Analog Devices, Inc.),
5 * Copyright (C) 2023-2024 Analog Devices, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************************/
20
21 //#include "smoh.h"
22 #include "skbd.h"
23 #include "skbd_reva.h"
24 #include "gpio.h"
25 #include "mxc_assert.h"
26 #include "mxc_pins.h"
27 #include "mxc_sys.h"
28 #include "mxc_lock.h"
29
MXC_SKBD_PreInit(void)30 int MXC_SKBD_PreInit(void)
31 {
32 return MXC_SKBD_RevA_PreInit();
33 }
34
MXC_SKBD_Init(mxc_skbd_config_t config)35 int MXC_SKBD_Init(mxc_skbd_config_t config)
36 {
37 /* Enable the SKBD clock i.e. just in case clock is disabled */
38 MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CTB);
39 MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_KBD);
40
41 // MXC_GPIO_Config(&gpio_cfg_kbd_P0);
42 // MXC_GPIO_Config(&gpio_cfg_kbd_P1);
43 MXC_GPIO_Config(&gpio_cfg_kbd_P2);
44
45 return MXC_SKBD_RevA_Init((mxc_skbd_reva_regs_t *)MXC_SKBD, config);
46 }
47
MXC_SKBD_EnableInterruptEvents(unsigned int events)48 int MXC_SKBD_EnableInterruptEvents(unsigned int events)
49 {
50 return MXC_SKBD_RevA_EnableInterruptEvents((mxc_skbd_reva_regs_t *)MXC_SKBD, events);
51 }
52
MXC_SKBD_DisableInterruptEvents(unsigned int events)53 int MXC_SKBD_DisableInterruptEvents(unsigned int events)
54 {
55 return MXC_SKBD_RevA_DisableInterruptEvents((mxc_skbd_reva_regs_t *)MXC_SKBD, events);
56 }
57
MXC_SKBD_ClearInterruptStatus(unsigned int status)58 int MXC_SKBD_ClearInterruptStatus(unsigned int status)
59 {
60 return MXC_SKBD_RevA_ClearInterruptStatus((mxc_skbd_reva_regs_t *)MXC_SKBD, status);
61 }
62
MXC_SKBD_InterruptStatus(unsigned int * status)63 int MXC_SKBD_InterruptStatus(unsigned int *status)
64 {
65 return MXC_SKBD_RevA_InterruptStatus((mxc_skbd_reva_regs_t *)MXC_SKBD, status);
66 }
67
MXC_SKBD_ReadKeys(mxc_skbd_keys_t * keys)68 int MXC_SKBD_ReadKeys(mxc_skbd_keys_t *keys)
69 {
70 return MXC_SKBD_RevA_ReadKeys((mxc_skbd_reva_regs_t *)MXC_SKBD, (mxc_skbd_reva_keys_t *)keys);
71 }
72
MXC_SKBD_Close(void)73 int MXC_SKBD_Close(void)
74 {
75 /* Reset the SKBD controller */
76 MXC_SYS_Reset_Periph(MXC_SYS_RESET1_KBD);
77
78 /* Wait until SKBD reset completes */
79 while (MXC_F_GCR_RST1_KBD & MXC_GCR->rst1) {}
80
81 return MXC_SKBD_RevA_Close();
82 }
83
MXC_SKBD_GetVersion(void)84 const char *MXC_SKBD_GetVersion(void)
85 {
86 return MXC_SKBD_REVA_VERSION_STRING;
87 }
88