Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ps2.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
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_PS2_H_
14#define ZEPHYR_INCLUDE_DRIVERS_PS2_H_
15
16#include <errno.h>
17#include <zephyr/types.h>
18#include <stddef.h>
19#include <zephyr/device.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
35
42typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data);
43
49
54typedef int (*ps2_config_t)(const struct device *dev,
55 ps2_callback_t callback_isr);
56
61typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value);
62
67typedef int (*ps2_write_t)(const struct device *dev, uint8_t value);
68
72typedef int (*ps2_disable_callback_t)(const struct device *dev);
73
78typedef int (*ps2_enable_callback_t)(const struct device *dev);
79
95
97
108__syscall int ps2_config(const struct device *dev,
109 ps2_callback_t callback_isr);
110
111static inline int z_impl_ps2_config(const struct device *dev,
112 ps2_callback_t callback_isr)
113{
114 return DEVICE_API_GET(ps2, dev)->config(dev, callback_isr);
115}
116
126__syscall int ps2_write(const struct device *dev, uint8_t value);
127
128static inline int z_impl_ps2_write(const struct device *dev, uint8_t value)
129{
130 return DEVICE_API_GET(ps2, dev)->write(dev, value);
131}
132
141__syscall int ps2_read(const struct device *dev, uint8_t *value);
142
143static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
144{
145 return DEVICE_API_GET(ps2, dev)->read(dev, value);
146}
147
155__syscall int ps2_enable_callback(const struct device *dev);
156
157static inline int z_impl_ps2_enable_callback(const struct device *dev)
158{
159 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
160
161 if (api->enable_callback == NULL) {
162 return -ENOSYS;
163 }
164
165 return api->enable_callback(dev);
166}
167
175__syscall int ps2_disable_callback(const struct device *dev);
176
177static inline int z_impl_ps2_disable_callback(const struct device *dev)
178{
179 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
180
181 if (api->disable_callback == NULL) {
182 return -ENOSYS;
183 }
184
185 return api->disable_callback(dev);
186}
187
188#ifdef __cplusplus
189}
190#endif
191
195
196#include <zephyr/syscalls/ps2.h>
197
198#endif /* ZEPHYR_INCLUDE_DRIVERS_PS2_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
System error numbers.
int(* ps2_read_t)(const struct device *dev, uint8_t *value)
Callback API for reading from a PS/2 device.
Definition ps2.h:61
int(* ps2_config_t)(const struct device *dev, ps2_callback_t callback_isr)
Callback API for configuring a PS/2 device.
Definition ps2.h:54
int(* ps2_disable_callback_t)(const struct device *dev)
Callback API for disabling a PS/2 device callback.
Definition ps2.h:72
int(* ps2_enable_callback_t)(const struct device *dev)
Callback API for enabling a PS/2 device callback.
Definition ps2.h:78
int(* ps2_write_t)(const struct device *dev, uint8_t value)
Callback API for writing to a PS/2 device.
Definition ps2.h:67
int ps2_config(const struct device *dev, ps2_callback_t callback_isr)
Configure a PS/2 device instance.
int ps2_enable_callback(const struct device *dev)
Enables callback.
int ps2_read(const struct device *dev, uint8_t *value)
Read slave-to-host values from PS/2 device.
void(* ps2_callback_t)(const struct device *dev, uint8_t data)
PS/2 callback called when user types or click a mouse.
Definition ps2.h:42
int ps2_disable_callback(const struct device *dev)
Disables callback.
int ps2_write(const struct device *dev, uint8_t value)
Write to a PS/2 device.
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
<span class="mlabel">Driver Operations</span> PS/2 driver operations
Definition ps2.h:83
ps2_disable_callback_t disable_callback
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition ps2.h:91
ps2_enable_callback_t enable_callback
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition ps2.h:93
ps2_config_t config
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition ps2.h:85
ps2_read_t read
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition ps2.h:87
ps2_write_t write
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition ps2.h:89