Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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 <zephyr/types.h>
18#include <stddef.h>
19#include <device.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
38typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data);
39
47typedef int (*ps2_config_t)(const struct device *dev,
48 ps2_callback_t callback_isr);
49typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value);
50typedef int (*ps2_write_t)(const struct device *dev, uint8_t value);
51typedef int (*ps2_disable_callback_t)(const struct device *dev);
52typedef int (*ps2_enable_callback_t)(const struct device *dev);
53
54__subsystem struct ps2_driver_api {
55 ps2_config_t config;
56 ps2_read_t read;
57 ps2_write_t write;
58 ps2_disable_callback_t disable_callback;
59 ps2_enable_callback_t enable_callback;
60};
75__syscall int ps2_config(const struct device *dev,
76 ps2_callback_t callback_isr);
77
78static inline int z_impl_ps2_config(const struct device *dev,
79 ps2_callback_t callback_isr)
80{
81 const struct ps2_driver_api *api =
82 (struct ps2_driver_api *)dev->api;
83
84 return api->config(dev, callback_isr);
85}
86
96__syscall int ps2_write(const struct device *dev, uint8_t value);
97
98static inline int z_impl_ps2_write(const struct device *dev, uint8_t value)
99{
100 const struct ps2_driver_api *api =
101 (const struct ps2_driver_api *)dev->api;
102
103 return api->write(dev, value);
104}
105
114__syscall int ps2_read(const struct device *dev, uint8_t *value);
115
116static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value)
117{
118 const struct ps2_driver_api *api =
119 (const struct ps2_driver_api *)dev->api;
120
121 return api->read(dev, value);
122}
123
131__syscall int ps2_enable_callback(const struct device *dev);
132
133static inline int z_impl_ps2_enable_callback(const struct device *dev)
134{
135 const struct ps2_driver_api *api =
136 (const struct ps2_driver_api *)dev->api;
137
138 if (api->enable_callback == NULL) {
139 return -ENOSYS;
140 }
141
142 return api->enable_callback(dev);
143}
144
152__syscall int ps2_disable_callback(const struct device *dev);
153
154static inline int z_impl_ps2_disable_callback(const struct device *dev)
155{
156 const struct ps2_driver_api *api =
157 (const struct ps2_driver_api *)dev->api;
158
159 if (api->disable_callback == NULL) {
160 return -ENOSYS;
161 }
162
163 return api->disable_callback(dev);
164}
165
166#ifdef __cplusplus
167}
168#endif
169
174#include <syscalls/ps2.h>
175
176#endif /* ZEPHYR_INCLUDE_DRIVERS_PS2_H_ */
void
Definition: eswifi_shell.c:15
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:38
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
Definition: errno.h:83
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
static fdata_t data[2]
Definition: test_fifo_contexts.c:15