risc-v/espressif: Add support for System Reset
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
parent
c1efa8c85a
commit
cf90fa62b2
@ -36,7 +36,7 @@ CHIP_ASRCS = esp_vectors.S
|
||||
CHIP_CSRCS = esp_allocateheap.c esp_start.c esp_idle.c
|
||||
CHIP_CSRCS += esp_irq.c esp_gpio.c esp_libc_stubs.c
|
||||
CHIP_CSRCS += esp_lowputc.c esp_serial.c
|
||||
CHIP_CSRCS += esp_timerisr.c
|
||||
CHIP_CSRCS += esp_timerisr.c esp_systemreset.c
|
||||
|
||||
ifeq ($(CONFIG_WATCHDOG),y)
|
||||
CHIP_CSRCS += esp_wdt.c
|
||||
@ -49,7 +49,7 @@ endif
|
||||
# Fetch source files and add them to build
|
||||
|
||||
ESP_HAL_3RDPARTY_UNPACK = esp-hal-3rdparty
|
||||
ESP_HAL_3RDPARTY_ID = nuttx-20230324
|
||||
ESP_HAL_3RDPARTY_ID = nuttx-20230330
|
||||
ESP_HAL_3RDPARTY_ZIP = $(ESP_HAL_3RDPARTY_ID).zip
|
||||
ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty/archive
|
||||
|
||||
|
158
arch/risc-v/src/espressif/esp_systemreset.c
Normal file
158
arch/risc-v/src/espressif/esp_systemreset.c
Normal file
@ -0,0 +1,158 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/espressif/esp_systemreset.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "esp_systemreset.h"
|
||||
|
||||
#include "esp_private/system_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define SHUTDOWN_HANDLERS_NO 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_register_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* This function allows you to register a handler that gets invoked before
|
||||
* the application is restarted.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - Function to execute on restart.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success (positive non-zero values are cmd-specific).
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp_register_shutdown_handler(shutdown_handler_t handler)
|
||||
{
|
||||
for (int i = 0; i < SHUTDOWN_HANDLERS_NO; i++)
|
||||
{
|
||||
if (shutdown_handlers[i] == handler)
|
||||
{
|
||||
return -EEXIST;
|
||||
}
|
||||
else if (shutdown_handlers[i] == NULL)
|
||||
{
|
||||
shutdown_handlers[i] = handler;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_unregister_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* This function allows you to unregister a handler which was previously
|
||||
* registered using esp_register_shutdown_handler function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - Function to execute on restart.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success (positive non-zero values are cmd-specific).
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp_unregister_shutdown_handler(shutdown_handler_t handler)
|
||||
{
|
||||
for (int i = 0; i < SHUTDOWN_HANDLERS_NO; i++)
|
||||
{
|
||||
if (shutdown_handlers[i] == handler)
|
||||
{
|
||||
shutdown_handlers[i] = NULL;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* Process all registered shutdown callback functions.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_shutdown_handler(void)
|
||||
{
|
||||
for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--)
|
||||
{
|
||||
if (shutdown_handlers[i])
|
||||
{
|
||||
shutdown_handlers[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_systemreset
|
||||
*
|
||||
* Description:
|
||||
* Internal reset logic.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_systemreset(void)
|
||||
{
|
||||
esp_restart_noos();
|
||||
}
|
111
arch/risc-v/src/espressif/esp_systemreset.h
Normal file
111
arch/risc-v/src/espressif/esp_systemreset.h
Normal file
@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/espressif/esp_systemreset.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_ESPRESSIF_ESP_SYSTEMRESET_H
|
||||
#define __ARCH_RISCV_SRC_ESPRESSIF_ESP_SYSTEMRESET_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Shutdown handler type */
|
||||
|
||||
typedef void (*shutdown_handler_t)(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_register_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* This function allows you to register a handler that gets invoked before
|
||||
* the application is restarted.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - Function to execute on restart.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success (positive non-zero values are cmd-specific).
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp_register_shutdown_handler(shutdown_handler_t handler);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_unregister_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* This function allows you to unregister a handler which was previously
|
||||
* registered using esp_register_shutdown_handler function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - Function to execute on restart.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success (positive non-zero values are cmd-specific).
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp_unregister_shutdown_handler(shutdown_handler_t handler);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_shutdown_handler
|
||||
*
|
||||
* Description:
|
||||
* Process all registered shutdown callback functions.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_shutdown_handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISCV_SRC_ESPRESSIF_ESP_SYSTEMRESET_H */
|
@ -80,6 +80,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_hw_support/port/$(C
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_hw_support/port/$(CHIP_SERIES)/systimer.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/brownout.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/clk.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/system_internal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/brownout_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/efuse_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/systimer_hal.c
|
||||
|
@ -85,6 +85,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_rom/patches/esp_rom
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_rom/patches/esp_rom_wdt.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/brownout.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/clk.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/system_internal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/brownout_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/efuse_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/uart_hal.c
|
||||
|
@ -84,7 +84,9 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_rom/patches/esp_rom
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_rom/patches/esp_rom_wdt.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/brownout.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/clk.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/esp_system/port/soc/$(CHIP_SERIES)/system_internal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/brownout_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/cache_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/efuse_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/uart_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_UNPACK)/components/hal/uart_hal_iram.c
|
||||
|
@ -16,6 +16,7 @@ CONFIG_ARCH_CHIP_ESPRESSIF=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
|
@ -24,6 +24,10 @@ CSRCS = esp32c3_boot.c esp32c3_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL),y)
|
||||
CSRCS += esp32c3_appinit.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||
CSRCS += esp32c3_reset.c
|
||||
endif
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
|
81
boards/risc-v/espressif/esp32c3-generic/src/esp32c3_reset.c
Normal file
81
boards/risc-v/espressif/esp32c3-generic/src/esp32c3_reset.c
Normal file
@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/espressif/esp32c3-generic/src/esp32c3_reset.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "esp_systemreset.h"
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_RESET
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset board. Support for this function is required by board-level
|
||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* status - Status information provided with the reset event. This
|
||||
* meaning of this status information is board-specific. If not
|
||||
* used by a board, the value zero may be provided in calls to
|
||||
* board_reset().
|
||||
*
|
||||
* Returned Value:
|
||||
* If this function returns, then it was not possible to power-off the
|
||||
* board due to some constraints. The return value in this case is a
|
||||
* board-specific reason for the failure to shutdown.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_reset(int status)
|
||||
{
|
||||
syslog(LOG_INFO, "reboot status=%d\n", status);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case EXIT_SUCCESS:
|
||||
up_shutdown_handler();
|
||||
break;
|
||||
case CONFIG_BOARD_ASSERT_RESET_VALUE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
up_systemreset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_RESET */
|
@ -16,6 +16,7 @@ CONFIG_ARCH_CHIP_ESPRESSIF=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
|
@ -24,6 +24,10 @@ CSRCS = esp32c6_boot.c esp32c6_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL),y)
|
||||
CSRCS += esp32c6_appinit.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||
CSRCS += esp32c6_reset.c
|
||||
endif
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
|
81
boards/risc-v/espressif/esp32c6-generic/src/esp32c6_reset.c
Normal file
81
boards/risc-v/espressif/esp32c6-generic/src/esp32c6_reset.c
Normal file
@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/espressif/esp32c6-generic/src/esp32c6_reset.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "esp_systemreset.h"
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_RESET
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset board. Support for this function is required by board-level
|
||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* status - Status information provided with the reset event. This
|
||||
* meaning of this status information is board-specific. If not
|
||||
* used by a board, the value zero may be provided in calls to
|
||||
* board_reset().
|
||||
*
|
||||
* Returned Value:
|
||||
* If this function returns, then it was not possible to power-off the
|
||||
* board due to some constraints. The return value in this case is a
|
||||
* board-specific reason for the failure to shutdown.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_reset(int status)
|
||||
{
|
||||
syslog(LOG_INFO, "reboot status=%d\n", status);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case EXIT_SUCCESS:
|
||||
up_shutdown_handler();
|
||||
break;
|
||||
case CONFIG_BOARD_ASSERT_RESET_VALUE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
up_systemreset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_RESET */
|
@ -16,6 +16,7 @@ CONFIG_ARCH_CHIP_ESPRESSIF=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
|
@ -24,6 +24,10 @@ CSRCS = esp32h2_boot.c esp32h2_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL),y)
|
||||
CSRCS += esp32h2_appinit.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||
CSRCS += esp32h2_reset.c
|
||||
endif
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
|
81
boards/risc-v/espressif/esp32h2-generic/src/esp32h2_reset.c
Normal file
81
boards/risc-v/espressif/esp32h2-generic/src/esp32h2_reset.c
Normal file
@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/espressif/esp32h2-generic/src/esp32h2_reset.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "esp_systemreset.h"
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_RESET
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset board. Support for this function is required by board-level
|
||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* status - Status information provided with the reset event. This
|
||||
* meaning of this status information is board-specific. If not
|
||||
* used by a board, the value zero may be provided in calls to
|
||||
* board_reset().
|
||||
*
|
||||
* Returned Value:
|
||||
* If this function returns, then it was not possible to power-off the
|
||||
* board due to some constraints. The return value in this case is a
|
||||
* board-specific reason for the failure to shutdown.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_reset(int status)
|
||||
{
|
||||
syslog(LOG_INFO, "reboot status=%d\n", status);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case EXIT_SUCCESS:
|
||||
up_shutdown_handler();
|
||||
break;
|
||||
case CONFIG_BOARD_ASSERT_RESET_VALUE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
up_systemreset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_RESET */
|
Loading…
Reference in New Issue
Block a user