Zephyr Project API  3.3.0
A Scalable Open Source RTOS
ec_host_cmd_periph.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Google LLC.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_HOST_CMD_PERIPH_H_
13#define ZEPHYR_INCLUDE_DRIVERS_HOST_CMD_PERIPH_H_
14
15#include <zephyr/sys/__assert.h>
16#include <zephyr/device.h>
17#include <zephyr/kernel.h>
18#include <zephyr/types.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
42 size_t *len;
44 struct k_sem *dev_owns;
46 struct k_sem *handler_owns;
47};
48
54 void *buf;
56 size_t len;
57};
58
60 const struct device *dev, struct ec_host_cmd_periph_rx_ctx *rx_ctx);
61
63 const struct device *dev,
64 const struct ec_host_cmd_periph_tx_buf *tx_buf);
65
66__subsystem struct ec_host_cmd_periph_api {
69};
70
86static inline int
88 struct ec_host_cmd_periph_rx_ctx *rx_ctx)
89{
90 const struct ec_host_cmd_periph_api *api =
91 (const struct ec_host_cmd_periph_api *)dev->api;
92
93 return api->init(dev, rx_ctx);
94}
95
107static inline int ec_host_cmd_periph_send(
108 const struct device *dev,
109 const struct ec_host_cmd_periph_tx_buf *tx_buf)
110{
111 const struct ec_host_cmd_periph_api *api =
112 (const struct ec_host_cmd_periph_api *)dev->api;
113
114 return api->send(dev, tx_buf);
115}
116
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* ZEPHYR_INCLUDE_DRIVERS_HOST_CMD_PERIPH_H_ */
static int ec_host_cmd_periph_init(const struct device *dev, struct ec_host_cmd_periph_rx_ctx *rx_ctx)
Initialize a host command device.
Definition: ec_host_cmd_periph.h:87
int(* ec_host_cmd_periph_api_send)(const struct device *dev, const struct ec_host_cmd_periph_tx_buf *tx_buf)
Definition: ec_host_cmd_periph.h:62
int(* ec_host_cmd_periph_api_init)(const struct device *dev, struct ec_host_cmd_periph_rx_ctx *rx_ctx)
Definition: ec_host_cmd_periph.h:59
static int ec_host_cmd_periph_send(const struct device *dev, const struct ec_host_cmd_periph_tx_buf *tx_buf)
Sends the specified data to the host.
Definition: ec_host_cmd_periph.h:107
Public kernel APIs.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition: device.h:378
const void * api
Definition: device.h:384
Definition: ec_host_cmd_periph.h:66
ec_host_cmd_periph_api_send send
Definition: ec_host_cmd_periph.h:68
ec_host_cmd_periph_api_init init
Definition: ec_host_cmd_periph.h:67
Context for host command peripheral and framework to pass rx data.
Definition: ec_host_cmd_periph.h:34
uint8_t * buf
Definition: ec_host_cmd_periph.h:40
size_t * len
Definition: ec_host_cmd_periph.h:42
struct k_sem * handler_owns
Definition: ec_host_cmd_periph.h:46
struct k_sem * dev_owns
Definition: ec_host_cmd_periph.h:44
Context for host command peripheral and framework to pass tx data.
Definition: ec_host_cmd_periph.h:52
void * buf
Definition: ec_host_cmd_periph.h:54
size_t len
Definition: ec_host_cmd_periph.h:56