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
51typedef int (*ps2_config_t)(const struct device *dev,
52 ps2_callback_t callback_isr);
53typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value);
54typedef int (*ps2_write_t)(const struct device *dev, uint8_t value);
55typedef int (*ps2_disable_callback_t)(const struct device *dev);
56typedef int (*ps2_enable_callback_t)(const struct device *dev);
57
58__subsystem struct ps2_driver_api {
59 ps2_config_t config;
60 ps2_read_t read;
61 ps2_write_t write;
62 ps2_disable_callback_t disable_callback;
63 ps2_enable_callback_t enable_callback;
64};
68
79__syscall int ps2_config(const struct device *dev,
80 ps2_callback_t callback_isr);
81
82static inline int z_impl_ps2_config(const struct device *dev,
83 ps2_callback_t callback_isr)
84{
85 return DEVICE_API_GET(ps2, dev)->config(dev, callback_isr);
86}
87
97__syscall int ps2_write(const struct device *dev, uint8_t value);
98
99static inline int z_impl_ps2_write(const struct device *dev, uint8_t value)
100{
101 return DEVICE_API_GET(ps2, dev)->write(dev, value);
102}
103
112__syscall int ps2_read(const struct device *dev, uint8_t *value);
113
114static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
115{
116 return DEVICE_API_GET(ps2, dev)->read(dev, value);
117}
118
126__syscall int ps2_enable_callback(const struct device *dev);
127
128static inline int z_impl_ps2_enable_callback(const struct device *dev)
129{
130 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
131
132 if (api->enable_callback == NULL) {
133 return -ENOSYS;
134 }
135
136 return api->enable_callback(dev);
137}
138
146__syscall int ps2_disable_callback(const struct device *dev);
147
148static inline int z_impl_ps2_disable_callback(const struct device *dev)
149{
150 const struct ps2_driver_api *api = DEVICE_API_GET(ps2, dev);
151
152 if (api->disable_callback == NULL) {
153 return -ENOSYS;
154 }
155
156 return api->disable_callback(dev);
157}
158
159#ifdef __cplusplus
160}
161#endif
162
166
167#include <zephyr/syscalls/ps2.h>
168
169#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:1375
System error numbers.
int ps2_config(const struct device *dev, ps2_callback_t callback_isr)
Configure a ps2 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 PS/2 device.
#define ENOSYS
Function not implemented.
Definition errno.h:82
#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