/*!
 * @file        user_I2C_config.h
 *
 * @brief       I2C configurations
 *
 * @version     V1.0.0
 *
 * @date        2026-03-25
 *
 * @attention
 *
 *  Copyright (C) 2026 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the Geehy Semiconductor Software License Agreement for the governing permissions
 *  and limitations under the License.
 */

#ifndef USER_I2C_CONFIG_H
#define USER_I2C_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes */
#include "g32a10xx_gpio.h"


/** @addtogroup Examples
  @{
  */

/** @addtogroup I2C_Examples
  @{
  */

/** @addtogroup GPIO_I2C_SLAVE
  @{
  */

/** @defgroup GPIO_I2C_SALVE_Macros Macros
  @{
  */
  
/* I2C slave device pin define */
#define I2C_SLAVE_SDA_PIN       GPIO_PIN_13
#define I2C_SLAVE_SDA_PORT      GPIOB
#define I2C_SLAVE_SDA_CLK       RCM_AHB_PERIPH_GPIOB

#define I2C_SLAVE_SCL_PIN       GPIO_PIN_14
#define I2C_SLAVE_SCL_PORT      GPIOB
#define I2C_SLAVE_SCL_CLK       RCM_AHB_PERIPH_GPIOB

/* I2C slave device  config */
#define I2C_SLAVE_ADDR          (uint8_t)0xA8  /* Ignore LSB */
#define I2C_SLAVE_PAGE_SIZE     (uint8_t)32U
#define I2C_SLAVE_REGADDR_SIZE  (uint8_t)2U


/* I2C bus level */
#define I2C_SDA_HIGH()      Gpio_SetBit(I2C_SLAVE_SDA_PORT, (uint16_t)I2C_SLAVE_SDA_PIN)
#define I2C_SDA_LOW()       Gpio_ClearBit(I2C_SLAVE_SDA_PORT, (uint16_t)I2C_SLAVE_SDA_PIN)

#define I2C_SDA_READ()      Gpio_ReadInputBit(I2C_SLAVE_SDA_PORT, (uint16_t)I2C_SLAVE_SDA_PIN)
#define I2C_SCL_READ()      Gpio_ReadInputBit(I2C_SLAVE_SCL_PORT, (uint16_t)I2C_SLAVE_SCL_PIN)

/**@} end of group GPIO_I2C_SALVE_Macros */

/** @defgroup GPIO_I2C_SALVE_Variables Variables
  @{
  */

/* I2C user configuration */

extern Gpio_ConfigType g_sdaGpioConfig;
extern Gpio_ConfigType g_sclGpioConfig;

/**@} end of group GPIO_I2C_SALVE_Variables */

#ifdef __cplusplus
}
#endif

#endif /* USER_I2C_CONFIG_H */

/**@} end of group GPIO_I2C_SLAVE */
/**@} end of group I2C_Examples */
/**@} end of group Examples */
