| Nico Huber | 0069440 | 2026-02-14 21:26:49 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 28 | typedef uint8_t uInt8; |
| 29 | typedef uint16_t uInt16; |
| 30 | typedef uint32_t uInt32; |
| 31 | typedef int32_t int32; |
| 32 | typedef uInt32 NiHandle; |
| 33 | |
| 34 | enum { |
| 35 | kNi845x12Volts, |
| 36 | kNi845x15Volts, |
| 37 | kNi845x18Volts, |
| 38 | kNi845x25Volts, |
| 39 | kNi845x33Volts, |
| 40 | }; |
| 41 | |
| 42 | void ni845xStatusToString(int32 err, uInt32 buf_size, char *buf); |
| 43 | |
| 44 | int32 ni845xFindDevice(char *resource_name, NiHandle *, uInt32 *found_devices_count); |
| 45 | int32 ni845xFindDeviceNext(NiHandle, char *resource_name); |
| 46 | int32 ni845xCloseFindDeviceHandle(NiHandle); |
| 47 | |
| 48 | int32 ni845xOpen(char *resource_name, uInt32 *opened_handle); |
| 49 | int32 ni845xSetIoVoltageLevel(uInt32 device_handle, uInt8 selected_voltage_100mV); |
| 50 | int32 ni845xClose(uInt32 device_handle); |
| 51 | |
| 52 | int32 ni845xSpiConfigurationOpen(NiHandle *); |
| 53 | int32 ni845xSpiConfigurationSetClockRate(NiHandle, uInt16 SCK_freq_in_KHz); |
| 54 | int32 ni845xSpiConfigurationGetClockRate(NiHandle, uInt16 *clock_freq_read_KHz); |
| 55 | int32 ni845xSpiWriteRead(uInt32 device_handle, NiHandle, uInt32 write_size, const uInt8 *write_buf, uInt32 *read_size, uInt8 *read_buf); |
| 56 | int32 ni845xSpiConfigurationClose(NiHandle); |
| 57 | |
| 58 | #endif /* !__NI845X_H__ */ |