#ifndef AD5941_PORT_H
#define AD5941_PORT_H

#include <stdint.h>
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"

/* SPI host */
#define AD594x_HOST     SPI2_HOST

/* SPI pins — match PCB net EIS_IC */
#define PIN_NUM_MISO    13
#define PIN_NUM_MOSI    11
#define PIN_NUM_CLK     12
#define PIN_NUM_CS      10

/* AD5941 control pins */
#define AD5940_CS_PIN       PIN_NUM_CS
#define AD5940_RST_PIN      5       /* ESP32-S3 GPIO5  → AD5941 ~RESET */
#define AD5940_GP0INT_PIN   4       /* ESP32-S3 GPIO4  → AD5941 GPIO0  */

void ad5941_port_init_spi(void);
void ad5941_port_init_gpio(void);
void ad5941_port_spi_rw(uint8_t *tx, uint8_t *rx, unsigned long len);

#endif
