common.h revision 1.1
1/*	$NetBSD: common.h,v 1.1 2021/12/07 17:39:55 brad Exp $	*/
2
3/*
4 * Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef _COMMON_H_
20#define _COMMON_H_
21
22#include "responses.h"
23
24struct function_block {
25	int	(*func_clear)(int, bool);
26	int	(*func_phy_read)(int, bool, int, uint8_t, uint8_t, uint8_t *);
27	int	(*func_phy_write)(int, bool, int, uint8_t, uint8_t);
28};
29
30EXTERN int decode_motor_level(int);
31EXTERN int common_clear(struct function_block *, int, bool);
32EXTERN int common_identify(struct function_block *, int, bool, int, struct scmd_identify_response *);
33EXTERN int common_diag(struct function_block *, int, bool, int, struct scmd_diag_response *);
34EXTERN int common_get_motor(struct function_block *, int, bool, int, struct scmd_motor_response *);
35EXTERN int common_set_motor(struct function_block *, int, bool, int, char, int8_t);
36EXTERN int common_invert_motor(struct function_block *, int, bool, int, char);
37EXTERN int common_bridge_motor(struct function_block *, int, bool, int);
38EXTERN int common_enable_disable(struct function_block *, int, bool, int);
39EXTERN int common_control_1(struct function_block *, int, bool, int);
40EXTERN int common_get_update_rate(struct function_block *, int, bool, uint8_t *);
41EXTERN int common_set_update_rate(struct function_block *, int, bool, uint8_t);
42EXTERN int common_force_update(struct function_block *, int, bool);
43EXTERN int common_get_ebus_speed(struct function_block *, int, bool, uint8_t *);
44EXTERN int common_set_ebus_speed(struct function_block *, int, bool, uint8_t);
45EXTERN int common_get_lock_state(struct function_block *, int, bool, int, uint8_t *);
46EXTERN int common_set_lock_state(struct function_block *, int, bool, int, uint8_t);
47
48#endif
49