Skip to content

Commit 3e79641

Browse files
committed
test(spi_flash): Add framework to test driver can work under flash auto-suspend
1 parent 2458734 commit 3e79641

File tree

16 files changed

+956
-14
lines changed

16 files changed

+956
-14
lines changed

components/hal/esp32c2/include/hal/spimem_flash_ll.h

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -717,6 +717,80 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
717717
dev->user2.val = user2_reg;
718718
}
719719

720+
// For flash test utils
721+
722+
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
723+
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_SPI1_INTR_SOURCE
724+
725+
/**
726+
* @brief Get the address of the interrupt status register.
727+
*
728+
* This function returns a pointer to the interrupt status register of the SPI memory device.
729+
*
730+
* @param[in] dev Pointer to the SPI memory device structure.
731+
* @return volatile void* Pointer to the interrupt status register.
732+
*/
733+
static inline volatile void *spimem_flash_ll_get_interrupt_status_reg(spi_mem_dev_t *dev)
734+
{
735+
return &dev->int_st;
736+
}
737+
738+
/**
739+
* @brief Clear specific interrupt status bits.
740+
*
741+
* This function clears the specified interrupt bits in the interrupt clear register of the SPI memory device.
742+
*
743+
* @param[in] dev Pointer to the SPI memory device structure.
744+
* @param[in] mask Bitmask specifying which interrupt bits to clear.
745+
*/
746+
__attribute__((always_inline))
747+
static inline void spimem_flash_ll_clear_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
748+
{
749+
dev->int_clr.val = mask;
750+
}
751+
752+
/**
753+
* @brief Enable specific interrupt bits.
754+
*
755+
* This function enables the specified interrupts in the interrupt enable register of the SPI memory device.
756+
*
757+
* @param[in] dev Pointer to the SPI memory device structure.
758+
* @param[in] mask Bitmask specifying which interrupt bits to enable.
759+
*/
760+
__attribute__((always_inline))
761+
static inline void spimem_flash_ll_enable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
762+
{
763+
dev->int_ena.val |= mask;
764+
}
765+
766+
/**
767+
* @brief Disable specific interrupt bits.
768+
*
769+
* This function disables the specified interrupts in the interrupt enable register of the SPI memory device.
770+
*
771+
* @param[in] dev Pointer to the SPI memory device structure.
772+
* @param[in] mask Bitmask specifying which interrupt bits to disable.
773+
*/
774+
__attribute__((always_inline))
775+
static inline void spimem_flash_ll_disable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
776+
{
777+
dev->int_ena.val &= (~mask);
778+
}
779+
780+
/**
781+
* @brief Get the current interrupt status.
782+
*
783+
* This function retrieves the current interrupt status from the interrupt status register of the SPI memory device.
784+
*
785+
* @param[in] dev Pointer to the SPI memory device structure.
786+
* @param[out] intr_status Pointer to a variable where the interrupt status will be stored.
787+
*/
788+
__attribute__((always_inline))
789+
static inline void spimem_flash_ll_get_intr_mask(spi_mem_dev_t *dev, uint32_t *intr_status)
790+
{
791+
*intr_status = dev->int_st.val;
792+
}
793+
720794
#ifdef __cplusplus
721795
}
722796
#endif

components/hal/esp32c3/include/hal/spimem_flash_ll.h

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -732,6 +732,80 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
732732
dev->user2.val = user2_reg;
733733
}
734734

735+
// For flash test utils
736+
737+
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
738+
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_SPI1_INTR_SOURCE
739+
740+
/**
741+
* @brief Get the address of the interrupt status register.
742+
*
743+
* This function returns a pointer to the interrupt status register of the SPI memory device.
744+
*
745+
* @param[in] dev Pointer to the SPI memory device structure.
746+
* @return volatile void* Pointer to the interrupt status register.
747+
*/
748+
static inline volatile void *spimem_flash_ll_get_interrupt_status_reg(spi_mem_dev_t *dev)
749+
{
750+
return &dev->int_st;
751+
}
752+
753+
/**
754+
* @brief Clear specific interrupt status bits.
755+
*
756+
* This function clears the specified interrupt bits in the interrupt clear register of the SPI memory device.
757+
*
758+
* @param[in] dev Pointer to the SPI memory device structure.
759+
* @param[in] mask Bitmask specifying which interrupt bits to clear.
760+
*/
761+
__attribute__((always_inline))
762+
static inline void spimem_flash_ll_clear_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
763+
{
764+
dev->int_clr.val = mask;
765+
}
766+
767+
/**
768+
* @brief Enable specific interrupt bits.
769+
*
770+
* This function enables the specified interrupts in the interrupt enable register of the SPI memory device.
771+
*
772+
* @param[in] dev Pointer to the SPI memory device structure.
773+
* @param[in] mask Bitmask specifying which interrupt bits to enable.
774+
*/
775+
__attribute__((always_inline))
776+
static inline void spimem_flash_ll_enable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
777+
{
778+
dev->int_ena.val |= mask;
779+
}
780+
781+
/**
782+
* @brief Disable specific interrupt bits.
783+
*
784+
* This function disables the specified interrupts in the interrupt enable register of the SPI memory device.
785+
*
786+
* @param[in] dev Pointer to the SPI memory device structure.
787+
* @param[in] mask Bitmask specifying which interrupt bits to disable.
788+
*/
789+
__attribute__((always_inline))
790+
static inline void spimem_flash_ll_disable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
791+
{
792+
dev->int_ena.val &= (~mask);
793+
}
794+
795+
/**
796+
* @brief Get the current interrupt status.
797+
*
798+
* This function retrieves the current interrupt status from the interrupt status register of the SPI memory device.
799+
*
800+
* @param[in] dev Pointer to the SPI memory device structure.
801+
* @param[out] intr_status Pointer to a variable where the interrupt status will be stored.
802+
*/
803+
__attribute__((always_inline))
804+
static inline void spimem_flash_ll_get_intr_mask(spi_mem_dev_t *dev, uint32_t *intr_status)
805+
{
806+
*intr_status = dev->int_st.val;
807+
}
808+
735809
#ifdef __cplusplus
736810
}
737811
#endif

components/hal/esp32c5/include/hal/spimem_flash_ll.h

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -763,6 +763,80 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
763763
dev->user2.val = user2_reg;
764764
}
765765

766+
// For flash test utils
767+
768+
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
769+
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_MSPI_INTR_SOURCE
770+
771+
/**
772+
* @brief Get the address of the interrupt status register.
773+
*
774+
* This function returns a pointer to the interrupt status register of the SPI memory device.
775+
*
776+
* @param[in] dev Pointer to the SPI memory device structure.
777+
* @return volatile void* Pointer to the interrupt status register.
778+
*/
779+
static inline volatile void *spimem_flash_ll_get_interrupt_status_reg(spi_mem_dev_t *dev)
780+
{
781+
return &dev->int_st;
782+
}
783+
784+
/**
785+
* @brief Clear specific interrupt status bits.
786+
*
787+
* This function clears the specified interrupt bits in the interrupt clear register of the SPI memory device.
788+
*
789+
* @param[in] dev Pointer to the SPI memory device structure.
790+
* @param[in] mask Bitmask specifying which interrupt bits to clear.
791+
*/
792+
__attribute__((always_inline))
793+
static inline void spimem_flash_ll_clear_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
794+
{
795+
dev->int_clr.val = mask;
796+
}
797+
798+
/**
799+
* @brief Enable specific interrupt bits.
800+
*
801+
* This function enables the specified interrupts in the interrupt enable register of the SPI memory device.
802+
*
803+
* @param[in] dev Pointer to the SPI memory device structure.
804+
* @param[in] mask Bitmask specifying which interrupt bits to enable.
805+
*/
806+
__attribute__((always_inline))
807+
static inline void spimem_flash_ll_enable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
808+
{
809+
dev->int_ena.val |= mask;
810+
}
811+
812+
/**
813+
* @brief Disable specific interrupt bits.
814+
*
815+
* This function disables the specified interrupts in the interrupt enable register of the SPI memory device.
816+
*
817+
* @param[in] dev Pointer to the SPI memory device structure.
818+
* @param[in] mask Bitmask specifying which interrupt bits to disable.
819+
*/
820+
__attribute__((always_inline))
821+
static inline void spimem_flash_ll_disable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
822+
{
823+
dev->int_ena.val &= (~mask);
824+
}
825+
826+
/**
827+
* @brief Get the current interrupt status.
828+
*
829+
* This function retrieves the current interrupt status from the interrupt status register of the SPI memory device.
830+
*
831+
* @param[in] dev Pointer to the SPI memory device structure.
832+
* @param[out] intr_status Pointer to a variable where the interrupt status will be stored.
833+
*/
834+
__attribute__((always_inline))
835+
static inline void spimem_flash_ll_get_intr_mask(spi_mem_dev_t *dev, uint32_t *intr_status)
836+
{
837+
*intr_status = dev->int_st.val;
838+
}
839+
766840
#ifdef __cplusplus
767841
}
768842
#endif

components/hal/esp32c6/include/hal/spimem_flash_ll.h

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -751,6 +751,80 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
751751
dev->user2.val = user2_reg;
752752
}
753753

754+
// For flash test utils
755+
756+
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
757+
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_MSPI_INTR_SOURCE
758+
759+
/**
760+
* @brief Get the address of the interrupt status register.
761+
*
762+
* This function returns a pointer to the interrupt status register of the SPI memory device.
763+
*
764+
* @param[in] dev Pointer to the SPI memory device structure.
765+
* @return volatile void* Pointer to the interrupt status register.
766+
*/
767+
static inline volatile void *spimem_flash_ll_get_interrupt_status_reg(spi_mem_dev_t *dev)
768+
{
769+
return &dev->int_st;
770+
}
771+
772+
/**
773+
* @brief Clear specific interrupt status bits.
774+
*
775+
* This function clears the specified interrupt bits in the interrupt clear register of the SPI memory device.
776+
*
777+
* @param[in] dev Pointer to the SPI memory device structure.
778+
* @param[in] mask Bitmask specifying which interrupt bits to clear.
779+
*/
780+
__attribute__((always_inline))
781+
static inline void spimem_flash_ll_clear_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
782+
{
783+
dev->int_clr.val = mask;
784+
}
785+
786+
/**
787+
* @brief Enable specific interrupt bits.
788+
*
789+
* This function enables the specified interrupts in the interrupt enable register of the SPI memory device.
790+
*
791+
* @param[in] dev Pointer to the SPI memory device structure.
792+
* @param[in] mask Bitmask specifying which interrupt bits to enable.
793+
*/
794+
__attribute__((always_inline))
795+
static inline void spimem_flash_ll_enable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
796+
{
797+
dev->int_ena.val |= mask;
798+
}
799+
800+
/**
801+
* @brief Disable specific interrupt bits.
802+
*
803+
* This function disables the specified interrupts in the interrupt enable register of the SPI memory device.
804+
*
805+
* @param[in] dev Pointer to the SPI memory device structure.
806+
* @param[in] mask Bitmask specifying which interrupt bits to disable.
807+
*/
808+
__attribute__((always_inline))
809+
static inline void spimem_flash_ll_disable_intr_mask(spi_mem_dev_t *dev, uint32_t mask)
810+
{
811+
dev->int_ena.val &= (~mask);
812+
}
813+
814+
/**
815+
* @brief Get the current interrupt status.
816+
*
817+
* This function retrieves the current interrupt status from the interrupt status register of the SPI memory device.
818+
*
819+
* @param[in] dev Pointer to the SPI memory device structure.
820+
* @param[out] intr_status Pointer to a variable where the interrupt status will be stored.
821+
*/
822+
__attribute__((always_inline))
823+
static inline void spimem_flash_ll_get_intr_mask(spi_mem_dev_t *dev, uint32_t *intr_status)
824+
{
825+
*intr_status = dev->int_st.val;
826+
}
827+
754828
#ifdef __cplusplus
755829
}
756830
#endif

0 commit comments

Comments
 (0)