mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi_slave: add a private API to reset transaction queue
This commit is contained in:
parent
e7879abbcc
commit
3dc36f622c
39
components/driver/include/esp_private/spi_slave_internal.h
Normal file
39
components/driver/include/esp_private/spi_slave_internal.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* This file contains SPI Slave private/internal APIs. Private/Internal APIs are:
|
||||
* - Visible to other IDF components
|
||||
* - Suggest NOT to use these APIs in your applications
|
||||
* - We don't provide backward compatibility on these APIs either
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "hal/spi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @note
|
||||
* This API is used to reset SPI Slave transaction queue. After calling this function:
|
||||
* - The SPI Slave transaction queue will be reset.
|
||||
*
|
||||
* @note This API shouldn't be called when the corresponding SPI Master is doing an SPI transaction.
|
||||
* If this gets called when its corresponding SPI Master is doing an SPI transaction, the SPI Slave behaviour is undefined
|
||||
*
|
||||
* @param host SPI peripheral that is acting as a slave
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_queue_reset(spi_host_device_t host);
|
@ -283,6 +283,33 @@ esp_err_t spi_slave_free(spi_host_device_t host)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note
|
||||
* This API is used to reset SPI Slave transaction queue. After calling this function:
|
||||
* - The SPI Slave transaction queue will be reset.
|
||||
*
|
||||
* Therefore, this API shouldn't be called when the corresponding SPI Master is doing an SPI transaction.
|
||||
*
|
||||
* @note
|
||||
* We don't actually need to enter a critical section here.
|
||||
* SPI Slave ISR will only get triggered when its corresponding SPI Master's transaction is done.
|
||||
* As we don't expect this function to be called when its corresponding SPI Master is doing an SPI transaction,
|
||||
* so concurrent call to these registers won't happen
|
||||
*
|
||||
*/
|
||||
esp_err_t SPI_SLAVE_ATTR spi_slave_queue_reset(spi_host_device_t host)
|
||||
{
|
||||
SPI_CHECK(is_valid_host(host), "invalid host", ESP_ERR_INVALID_ARG);
|
||||
SPI_CHECK(spihost[host], "host not slave", ESP_ERR_INVALID_ARG);
|
||||
|
||||
esp_intr_disable(spihost[host]->intr);
|
||||
spi_ll_set_int_stat(spihost[host]->hal.hw);
|
||||
|
||||
spihost[host]->cur_trans = NULL;
|
||||
xQueueReset(spihost[host]->trans_queue);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t SPI_SLAVE_ATTR spi_slave_queue_trans(spi_host_device_t host, const spi_slave_transaction_t *trans_desc, TickType_t ticks_to_wait)
|
||||
{
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed 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.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
|
@ -699,7 +699,6 @@ components/hal/include/hal/rtc_io_types.h
|
||||
components/hal/include/hal/sdio_slave_ll.h
|
||||
components/hal/include/hal/sha_hal.h
|
||||
components/hal/include/hal/spi_flash_encrypt_hal.h
|
||||
components/hal/include/hal/spi_slave_hal.h
|
||||
components/hal/include/hal/spi_slave_hd_hal.h
|
||||
components/hal/include/hal/uhci_types.h
|
||||
components/hal/include/hal/usb_hal.h
|
||||
|
Loading…
Reference in New Issue
Block a user