spi_flash: move buffer check from hal layer to driver layer

Prior to this change, `spi_flash_hal_supports_direct_write` and
`spi_flash_hal_supports_direct_read` will check the buffer pointer
place, which should be done in driver layer, instead of HAL layer.
This commit is contained in:
Armando
2022-04-01 16:53:40 +08:00
parent c4bcf1117c
commit a8a47a61f5
6 changed files with 46 additions and 55 deletions

View File

@@ -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
*/
#include "soc/soc_caps.h"
#include "spi_flash_defs.h"
@@ -19,6 +11,7 @@
#include "esp_log.h"
#include "cache_utils.h"
#include "esp_flash_partitions.h"
#include "esp_memory_utils.h"
#define SPI_FLASH_HAL_MAX_WRITE_BYTES 64
@@ -69,6 +62,10 @@ static const spi_flash_host_driver_t esp_flash_gpspi_host = {
esp_err_t memspi_host_init_pointers(memspi_host_inst_t *host, const memspi_host_config_t *cfg)
{
if (!esp_ptr_internal(host) && cfg->host_id == SPI1_HOST) {
return ESP_ERR_INVALID_ARG;
}
#if SOC_MEMSPI_IS_INDEPENDENT
if (cfg->host_id == SPI1_HOST)
host->inst.driver = &esp_flash_default_host;