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
107__syscall int ps2_config(const struct device *dev,
108 ps2_callback_t callback_isr);
109
110static inline int z_impl_ps2_config(const struct device *dev,
111 ps2_callback_t callback_isr)
112{
113 return DEVICE_API_GET(ps2, dev)->config(dev, callback_isr);
114}
115
124__syscall int ps2_write(const struct device *dev, uint8_t value);
125
126static inline int z_impl_ps2_write(const struct device *dev, uint8_t value)
127{
128 return DEVICE_API_GET(ps2, dev)->write(dev, value);
129}
130
138__syscall int ps2_read(const struct device *dev, uint8_t *value);
139
140static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
141{
142 return DEVICE_API_GET(ps2, dev)->read(dev, value);
143}
144
151__syscall int ps2_enable_callback(const struct device *dev);
152
153static inline int z_impl_ps2_enable_callback(const struct device *dev)
154{
155 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
156
157 if (api->enable_callback == NULL) {
158 return -ENOSYS;
159 }
160
161 return api->enable_callback(dev);
162}
163
170__syscall int ps2_disable_callback(const struct device *dev);
171
172static inline int z_impl_ps2_disable_callback(const struct device *dev)
173{
174 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
175
176 if (api->disable_callback == NULL) {
177 return -ENOSYS;
178 }
179
180 return api->disable_callback(dev);
181}
182
183#ifdef __cplusplus
184}
185#endif
186
190
191#include <zephyr/syscalls/ps2.h>
192
193#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