Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
kscan.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
16#ifndef ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_
17#define ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_
18
19#include <errno.h>
20#include <zephyr/types.h>
21#include <stddef.h>
22#include <zephyr/device.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
46typedef void (*kscan_callback_t)(const struct device *dev, uint32_t row,
47 uint32_t column,
48 bool pressed);
49
57typedef int (*kscan_config_t)(const struct device *dev,
58 kscan_callback_t callback);
59typedef int (*kscan_disable_callback_t)(const struct device *dev);
60typedef int (*kscan_enable_callback_t)(const struct device *dev);
61
62__subsystem struct kscan_driver_api {
63 kscan_config_t config;
64 kscan_disable_callback_t disable_callback;
65 kscan_enable_callback_t enable_callback;
66};
81__syscall int kscan_config(const struct device *dev,
82 kscan_callback_t callback);
83
84static inline int z_impl_kscan_config(const struct device *dev,
85 kscan_callback_t callback)
86{
87 const struct kscan_driver_api *api =
88 (struct kscan_driver_api *)dev->api;
89
90 return api->config(dev, callback);
91}
99__syscall int kscan_enable_callback(const struct device *dev);
100
101static inline int z_impl_kscan_enable_callback(const struct device *dev)
102{
103 const struct kscan_driver_api *api =
104 (const struct kscan_driver_api *)dev->api;
105
106 if (api->enable_callback == NULL) {
107 return -ENOSYS;
108 }
109
110 return api->enable_callback(dev);
111}
112
120__syscall int kscan_disable_callback(const struct device *dev);
121
122static inline int z_impl_kscan_disable_callback(const struct device *dev)
123{
124 const struct kscan_driver_api *api =
125 (const struct kscan_driver_api *)dev->api;
126
127 if (api->disable_callback == NULL) {
128 return -ENOSYS;
129 }
130
131 return api->disable_callback(dev);
132}
133
134#ifdef __cplusplus
135}
136#endif
137
142#include <zephyr/syscalls/kscan.h>
143
144#endif /* ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_ */
System error numbers.
int kscan_disable_callback(const struct device *dev)
Disables callback.
int kscan_config(const struct device *dev, kscan_callback_t callback)
Configure a Keyboard scan instance.
int kscan_enable_callback(const struct device *dev)
Enables callback.
void(* kscan_callback_t)(const struct device *dev, uint32_t row, uint32_t column, bool pressed)
Keyboard scan callback called when user press/release a key on a matrix keyboard.
Definition kscan.h:46
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409