Zephyr API Documentation 4.0.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
48typedef void (*kscan_callback_t)(const struct device *dev, uint32_t row,
49 uint32_t column,
50 bool pressed);
51
60typedef int (*kscan_config_t)(const struct device *dev,
61 kscan_callback_t callback);
62typedef int (*kscan_disable_callback_t)(const struct device *dev);
63typedef int (*kscan_enable_callback_t)(const struct device *dev);
64
65__subsystem struct kscan_driver_api {
66 kscan_config_t config;
67 kscan_disable_callback_t disable_callback;
68 kscan_enable_callback_t enable_callback;
69};
85__syscall int kscan_config(const struct device *dev,
86 kscan_callback_t callback);
87
88static inline int z_impl_kscan_config(const struct device *dev,
89 kscan_callback_t callback)
90{
91 const struct kscan_driver_api *api =
92 (struct kscan_driver_api *)dev->api;
93
94 return api->config(dev, callback);
95}
104__syscall int kscan_enable_callback(const struct device *dev);
105
106static inline int z_impl_kscan_enable_callback(const struct device *dev)
107{
108 const struct kscan_driver_api *api =
109 (const struct kscan_driver_api *)dev->api;
110
111 if (api->enable_callback == NULL) {
112 return -ENOSYS;
113 }
114
115 return api->enable_callback(dev);
116}
117
126__syscall int kscan_disable_callback(const struct device *dev);
127
128static inline int z_impl_kscan_disable_callback(const struct device *dev)
129{
130 const struct kscan_driver_api *api =
131 (const struct kscan_driver_api *)dev->api;
132
133 if (api->disable_callback == NULL) {
134 return -ENOSYS;
135 }
136
137 return api->disable_callback(dev);
138}
139
140#ifdef __cplusplus
141}
142#endif
143
148#include <zephyr/syscalls/kscan.h>
149
150#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:48
#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:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418