/*!
 * @file        user_adc_config.c
 *
 * @brief       ADC 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.
 */

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

/** @addtogroup Examples
  @{
  */

/** @addtogroup ADC_Examples
  @{
  */

/** @addtogroup ADC_TMRTrigger
  @{
*/

/** @defgroup ADC_TMRTrigger_Variables Variables
  @{
*/

/* Configure gpio pin */
Gpio_ConfigType gpioConfig = {
    .pin        = (uint16_t)GPIO_PIN_1,
    .mode       = GPIO_MODE_AN,
    .outtype    = GPIO_OUT_TYPE_PP,
    .speed      = GPIO_SPEED_10MHz,
    .pupd       = GPIO_PUPD_NO,
};

/* Configure adc */
Adc_ConfigType adcConfig = {
    /* Set resolution */
    .resolution = ADC_RESOLUTION_12B,
    /* Set dataAlign */
    .dataAlign = ADC_DATA_ALIGN_RIGHT,
    /* Set scanDir */
    .scanDir = ADC_SCAN_DIR_UPWARD,
    /* Set convMode continous */
    .convMode   = ADC_CONVERSION_SINGLE,
    /* Set extTrigConv */
    .extTrigConv  = ADC_EXT_TRIG_CONV_TRG1,
    /* Set TrigEdge */
    .extTrigEdge = ADC_EXT_TRIG_EDGE_RISING,
};

/* Configure timer */
Tmr_TimeBaseType  timeBaseConfig = {
    /* Set clockDivision = 1 */
    .clockDivision =  TMR_CKD_DIV1,
    /* Up-counter */
    .counterMode =  TMR_COUNTER_MODE_UP,
    /* Set divider = 63999. So TMR1 clock freq = 64MHz/(63999 + 1) = 1000HZ */
    .div = 64000-1,
    /* Set counter = 1000 */
    .period = 1000u,
    /* Repetition counter = 0x0 */
    .repetitionCounter =  0,
};


Tmr_OcConfigType  occonfig = {
    /* PWM2 mode */
    .OC_Mode =  TMR_OC_MODE_PWM2,
    /* Enable CH4 ouput */
    .OC_OutputState  =  TMR_OUTPUT_STATE_ENABLE,
    /* Set compare value = 500u, when TMR1_CNT equal TMR1_CC4, ADC will trigger */
    .Pulse = 500,
    .OC_OutputNState = TMR_OUTPUT_NSTATE_DISABLE,
    .OC_Polarity = TMR_OC_POLARITY_HIGH,
    .OC_NPolarity = TMR_OC_NPOLARITY_HIGH,
    .OC_Idlestate = TMR_OCIDLESTATE_RESET,
    .OC_NIdlestate = TMR_OCNIDLESTATE_RESET,
};

/**@} end of group ADC_TMRTrigger_Variables */
/**@} end of group ADC_TMRTrigger */
/**@} end of group ADC_Examples */
/**@} end of group Examples */
