/*
* Copyright (c) 2023-2028, SpaceTouch Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date          Author      Notes
* 2023-08-11    jinyaoh     the first version
*/

#include "platform.h"
#include "hal_headfile.h"
#include "hal_def.h"
#include "hal_reset.h"

/**
 * This function sets the specified pin to the reset pin, which is valid at a low level
 *
 * @param pinï¼š pin The value can be GPIO0-GPIO39
 *
 * @return None
 */
void hal_reset_gpio_set(gpio_pin_t pin)
{
    DEV_GPIO->CTL_f[pin].IE = 1;
    DEV_GPIO->CTL_f[pin].MFP = 0;
    DEV_GPIO->RSTN_f.EN = 0;
    DEV_GPIO->RSTN_f.PU = 1;
    DEV_GPIO->RSTN_f.SEL = pin;
    DEV_GPIO->RSTN_f.EN = 1;
}

/**
 * This function will restart the system
 *
 * @param None
 *
 * @return None
 */
void hal_reset_soft()
{
    DEV_RMU->BOOT_f.RE_BOOT = 1;
}

/**
 * this function will read chip id
 *
 * @param None
 *
 * @return None
 */
uint32_t hal_get_chip_id()
{
    return DEV_CHIP->ID;
}



