/*
 * SPDX-FileCopyrightText: Copyright (c) 2025 Ha Thach (tinyusb.org)
 * SPDX-License-Identifier: MIT
 *
 * This file is part of the TinyUSB stack.
 */
#ifndef TUSB_HCD_MAX3421_H
#define TUSB_HCD_MAX3421_H

#ifdef __cplusplus
 extern "C" {
#endif

//--------------------------------------------------------------------+
// SPI transfer API with MAX3421E are implemented by application
// - spi_cs_api(), spi_xfer_api(), int_api()
//--------------------------------------------------------------------+

// API to control MAX3421 SPI CS
extern void tuh_max3421_spi_cs_api(uint8_t rhport, bool active);

// API to transfer data with MAX3421 SPI
// Either tx_buf or rx_buf can be NULL, which means transfer is write or read only
extern bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx_buf, size_t xfer_bytes);

// API to enable/disable MAX3421 INTR pin interrupt
extern void tuh_max3421_int_api(uint8_t rhport, bool enabled);

//--------------------------------------------------------------------+
// API for read/write MAX3421 registers
// are implemented by this driver, can be used by application
//--------------------------------------------------------------------+

// API to read MAX3421's register. Implemented by TinyUSB
uint8_t tuh_max3421_reg_read(uint8_t rhport, uint8_t reg, bool in_isr);

// API to write MAX3421's register. Implemented by TinyUSB
bool tuh_max3421_reg_write(uint8_t rhport, uint8_t reg, uint8_t data, bool in_isr);

#ifdef __cplusplus
 }
#endif

#endif
