#ifndef __HAL_INTERFACE_API_H__
#define __HAL_INTERFACE_API_H__

#include <linux/types.h>
#include "stm32f429xx.h"
#include "com_gpio.h"


/* GPIO Interface */
void  stm32_gpio_init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init);
void stm32_gpio_write(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
GPIO_PinState stm32_gpio_read(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);

/* I2C Interface */
int stm32_i2c_master_write(int fd, uint8_t address, uint8_t *pBuf, uint16_t size);
int stm32_i2c_master_read(int fd, uint8_t address, uint8_t *pBuf, uint16_t size);
int stm32_i2c_set_addr(int fd, uint8_t OwnAddress);
int stm32_i2c_slave_recv(int fd, uint8_t *pBuf);
int stm32_i2c_master_write_read(int fd, uint8_t address, uint8_t *pWrBuf, uint8_t writeLen, uint8_t *pRdBuf, uint8_t readLen);

/* FMC Interface */
int fmc_write_8bit(uint32_t address, uint8_t *buf, uint32_t len);
int fmc_read_8bit(uint32_t address, uint8_t *buf, uint32_t len);
int fmc_write_16bit(uint32_t address, uint16_t *buf, uint32_t len);
int fmc_read_16bit(uint32_t address, uint16_t *buf, uint32_t len);
int fmc_write_32bit(uint32_t address, uint32_t *buf, uint32_t len);
int fmc_read_32bit(uint32_t address, uint32_t *buf, uint32_t len);
int fmc_set_bus_width(uint8_t bus_is16bit);

/* SPI Interface */
int stm32_spi_master_read(uint8_t spi, uint8_t *pBuf, uint32_t size);
int stm32_spi_master_write(uint8_t spi, uint8_t *pBuf, uint32_t size);
int stm32_spi_master_write_read(uint8_t spi, uint8_t *txBuf, uint32_t txSize, uint8_t *rxBuf, uint32_t rxSize);
int sf_get_id(uint8_t spi, uint8_t *id);
int sf_sector_erase(uint8_t spi, uint32_t Address);
int sf_read(uint8_t spi, uint32_t Address, uint8_t *buf, uint32_t size);
int sf_write(uint8_t spi, uint32_t Address, uint8_t *buf, uint32_t size);
int sf_chip_erase(uint8_t spi);

/* ADC Interface */
int stm32_adc_get_value(uint8_t channel, uint16_t *value);

/* UART Interface */
/* Platform Interface */
int stm32_reset_mcu(void);
uint32_t stm32_generate_random32bit(void);

/* gpio i2c */
int stm32_gpio_i2c_master_write(int fd, uint8_t address, uint8_t *pBuf, uint16_t size);
int stm32_gpio_i2c_master_read(int fd, uint8_t address, uint8_t *pBuf, uint16_t size);


#endif /* __HAL_INTERFACE_API_H__ */