blob: cd6a56bb6e7753a3c9ed4147d3ede00f460b0ba2 [file] [log] [blame]
Nico Huber00694402026-02-14 21:26:49 +01001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2026 Nico Huber <nico.h@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17/*
18 * This file is merely mimicking the expected API, so we
19 * can build test the ni845x_spi driver. Everything in
20 * here is derived from the usage in `ni845x_spi.c`.
21 */
22
23#ifndef __NI845X_H__
24#define __NI845X_H__ 1
25
26#include <stdint.h>
27
28typedef uint8_t uInt8;
29typedef uint16_t uInt16;
30typedef uint32_t uInt32;
31typedef int32_t int32;
32typedef uInt32 NiHandle;
33
34enum {
35 kNi845x12Volts,
36 kNi845x15Volts,
37 kNi845x18Volts,
38 kNi845x25Volts,
39 kNi845x33Volts,
40};
41
42void ni845xStatusToString(int32 err, uInt32 buf_size, char *buf);
43
44int32 ni845xFindDevice(char *resource_name, NiHandle *, uInt32 *found_devices_count);
45int32 ni845xFindDeviceNext(NiHandle, char *resource_name);
46int32 ni845xCloseFindDeviceHandle(NiHandle);
47
48int32 ni845xOpen(char *resource_name, uInt32 *opened_handle);
49int32 ni845xSetIoVoltageLevel(uInt32 device_handle, uInt8 selected_voltage_100mV);
50int32 ni845xClose(uInt32 device_handle);
51
52int32 ni845xSpiConfigurationOpen(NiHandle *);
53int32 ni845xSpiConfigurationSetClockRate(NiHandle, uInt16 SCK_freq_in_KHz);
54int32 ni845xSpiConfigurationGetClockRate(NiHandle, uInt16 *clock_freq_read_KHz);
55int32 ni845xSpiWriteRead(uInt32 device_handle, NiHandle, uInt32 write_size, const uInt8 *write_buf, uInt32 *read_size, uInt8 *read_buf);
56int32 ni845xSpiConfigurationClose(NiHandle);
57
58#endif /* !__NI845X_H__ */