Zephyr API Documentation 4.0.0-rc3
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
14#ifndef ZEPHYR_INCLUDE_DRIVERS_PS2_H_
15#define ZEPHYR_INCLUDE_DRIVERS_PS2_H_
16
17#include <errno.h>
18#include <zephyr/types.h>
19#include <stddef.h>
20#include <zephyr/device.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
39typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data);
40
48typedef int (*ps2_config_t)(const struct device *dev,
49 ps2_callback_t callback_isr);
50typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value);
51typedef int (*ps2_write_t)(const struct device *dev, uint8_t value);
52typedef int (*ps2_disable_callback_t)(const struct device *dev);
53typedef int (*ps2_enable_callback_t)(const struct device *dev);
54
55__subsystem struct ps2_driver_api {
56 ps2_config_t config;
57 ps2_read_t read;
58 ps2_write_t write;
59 ps2_disable_callback_t disable_callback;
60 ps2_enable_callback_t enable_callback;
61};
76__syscall int ps2_config(const struct device *dev,
77 ps2_callback_t callback_isr);
78
79static inline int z_impl_ps2_config(const struct device *dev,
80 ps2_callback_t callback_isr)
81{
82 const struct ps2_driver_api *api =
83 (struct ps2_driver_api *)dev->api;
84
85 return api->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 const struct ps2_driver_api *api =
102 (const struct ps2_driver_api *)dev->api;
103
104 return api->write(dev, value);
105}
106
115__syscall int ps2_read(const struct device *dev, uint8_t *value);
116
117static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
118{
119 const struct ps2_driver_api *api =
120 (const struct ps2_driver_api *)dev->api;
121
122 return api->read(dev, value);
123}
124
132__syscall int ps2_enable_callback(const struct device *dev);
133
134static inline int z_impl_ps2_enable_callback(const struct device *dev)
135{
136 const struct ps2_driver_api *api =
137 (const struct ps2_driver_api *)dev->api;
138
139 if (api->enable_callback == NULL) {
140 return -ENOSYS;
141 }
142
143 return api->enable_callback(dev);
144}
145
153__syscall int ps2_disable_callback(const struct device *dev);
154
155static inline int z_impl_ps2_disable_callback(const struct device *dev)
156{
157 const struct ps2_driver_api *api =
158 (const struct ps2_driver_api *)dev->api;
159
160 if (api->disable_callback == NULL) {
161 return -ENOSYS;
162 }
163
164 return api->disable_callback(dev);
165}
166
167#ifdef __cplusplus
168}
169#endif
170
175#include <zephyr/syscalls/ps2.h>
176
177#endif /* ZEPHYR_INCLUDE_DRIVERS_PS2_H_ */
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:39
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
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
void * data
Address of the device instance private data.
Definition device.h:422
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418