Zephyr Project API 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
37
44typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data);
45
51
56typedef int (*ps2_config_t)(const struct device *dev,
57 ps2_callback_t callback_isr);
58
63typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value);
64
69typedef int (*ps2_write_t)(const struct device *dev, uint8_t value);
70
74typedef int (*ps2_disable_callback_t)(const struct device *dev);
75
80typedef int (*ps2_enable_callback_t)(const struct device *dev);
81
97
99
109__syscall int ps2_config(const struct device *dev,
110 ps2_callback_t callback_isr);
111
112static inline int z_impl_ps2_config(const struct device *dev,
113 ps2_callback_t callback_isr)
114{
115 return DEVICE_API_GET(ps2, dev)->config(dev, callback_isr);
116}
117
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
140__syscall int ps2_read(const struct device *dev, uint8_t *value);
141
142static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
143{
144 return DEVICE_API_GET(ps2, dev)->read(dev, value);
145}
146
153__syscall int ps2_enable_callback(const struct device *dev);
154
155static inline int z_impl_ps2_enable_callback(const struct device *dev)
156{
157 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
158
159 if (api->enable_callback == NULL) {
160 return -ENOSYS;
161 }
162
163 return api->enable_callback(dev);
164}
165
172__syscall int ps2_disable_callback(const struct device *dev);
173
174static inline int z_impl_ps2_disable_callback(const struct device *dev)
175{
176 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
177
178 if (api->disable_callback == NULL) {
179 return -ENOSYS;
180 }
181
182 return api->disable_callback(dev);
183}
184
185#ifdef __cplusplus
186}
187#endif
188
192
193#include <zephyr/syscalls/ps2.h>
194
195#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:1449
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:63
int(* ps2_config_t)(const struct device *dev, ps2_callback_t callback_isr)
@def_driverbackendgroup{PS/2,ps2_interface}
Definition ps2.h:56
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_disable_callback_t)(const struct device *dev)
Callback API for disabling a PS/2 device callback.
Definition ps2.h:74
int(* ps2_enable_callback_t)(const struct device *dev)
Callback API for enabling a PS/2 device callback.
Definition ps2.h:80
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:44
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.
int(* ps2_write_t)(const struct device *dev, uint8_t value)
Callback API for writing to a PS/2 device.
Definition ps2.h:69
#define ENOSYS
Function not implemented.
Definition errno.h:83
#define NULL
Definition iar_missing_defs.h:20
__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
@driver_ops{PS/2}
Definition ps2.h:85
ps2_disable_callback_t disable_callback
@driver_ops_optional Disables callback.
Definition ps2.h:93
ps2_enable_callback_t enable_callback
@driver_ops_optional Enables callback.
Definition ps2.h:95
ps2_config_t config
@driver_ops_mandatory Configure a PS/2 device instance.
Definition ps2.h:87
ps2_read_t read
@driver_ops_mandatory Read slave-to-host values from PS/2 device.
Definition ps2.h:89
ps2_write_t write
@driver_ops_mandatory Write to a PS/2 device.
Definition ps2.h:91