#ifndef __LTC1867_H__
#define __LTC1867_H__

#ifdef __cplusplus
 extern "C" {
#endif

#include "stm32f4xx.h"

#define LEDIR_FREQ          (8)
#define SAMPLES_PER_PERIOD  (1024)
#define TIMER_SRC_FREQ      (84 * 1000 * 1000)
#define TIMER_PERIOD_SAMPLE (TIMER_SRC_FREQ / LEDIR_FREQ / SAMPLES_PER_PERIOD - 1)
#define TIMER_PERIOD_DELAY  (TIMER_SRC_FREQ / 1000 / 1000 * 35 / 10 - 1)  /* 3.5us */

#define LTC1867_CH_CNT      (2)

#define PORT_LEDIR          (GPIOB)
#define PIN_LEDIR           (GPIO_Pin_0)
#define PORT_LTC1867        (GPIOA)
#define PIN_CONV            (GPIO_Pin_4)
#define PORT_SPI            (GPIOA)
#define PIN_SPI_CS          (GPIO_Pin_4)
#define PIN_SPI_SCK         (GPIO_Pin_5)
#define PIN_SPI_SDO         (GPIO_Pin_6)
#define PIN_SPI_SDI         (GPIO_Pin_7)

void ltc1867_init(void);
void ltc1867_ledir_on(void);
void ltc1867_ledir_off(void);
void ltc1867_ledir_toggle(void);
void ltc1867_delay(void);
void ltc1867_conv(void);
void ltc1867_spi_select(void);
uint16_t ltc1867_transfer(uint16_t data_send);

#ifdef __cplusplus
}
#endif

#endif /* __LTC1867_H__ */
