Skip to content

Commit

Permalink
Merge branch 'feat/sdio_slave_disable_hs' into 'master'
Browse files Browse the repository at this point in the history
sdio_slave: allow disabling highspeed mode

Closes IDF-5994

See merge request espressif/esp-idf!20312
  • Loading branch information
ginkgm committed Sep 30, 2022
2 parents bea7556 + 507864c commit 9bc18ba
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
3 changes: 3 additions & 0 deletions components/driver/include/driver/sdio_slave.h
Expand Up @@ -48,6 +48,9 @@ typedef struct {
the internal pull-ups are not sufficient for stable communication, please do connect external pull-ups on the
bus. This is only for example and debug use.
*/
#define SDIO_SLAVE_FLAG_DEFAULT_SPEED BIT(3) /**< Disable the highspeed support of the hardware. */
#define SDIO_SLAVE_FLAG_HIGH_SPEED 0 /**< Enable the highspeed support of the hardware. This is the
default option. The host will see highspeed capability, but the mode actually used is determined by the host. */
} sdio_slave_config_t;

/** Handle of a receive buffer, register a handle by calling ``sdio_slave_recv_register_buf``. Use the handle to load the buffer to the
Expand Down
2 changes: 1 addition & 1 deletion components/driver/sdio_slave.c
Expand Up @@ -230,6 +230,7 @@ static esp_err_t init_context(const sdio_slave_config_t *config)

context.hal->sending_mode = config->sending_mode;
context.hal->timing = config->timing;
context.hal->no_highspeed = (config->flags & SDIO_SLAVE_FLAG_DEFAULT_SPEED) == SDIO_SLAVE_FLAG_DEFAULT_SPEED;
context.hal->send_queue_size = config->send_queue_size;
context.hal->recv_buffer_size = config->recv_buffer_size;
//initialize ringbuffer resources
Expand Down Expand Up @@ -312,7 +313,6 @@ static inline esp_err_t sdio_slave_hw_init(sdio_slave_config_t *config)
periph_module_enable(PERIPH_SDIO_SLAVE_MODULE);

sdio_slave_hal_hw_init(context.hal);

return ESP_OK;
}

Expand Down
23 changes: 10 additions & 13 deletions components/hal/include/hal/sdio_slave_hal.h
@@ -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
Expand Down Expand Up @@ -210,6 +202,10 @@ typedef struct {
* configured before using the HAL. `SDIO_SLAVE_TIMING_PSEND_PSAMPLE` is
* recommended by default.
*/
//some boolean flags
struct {
uint32_t no_highspeed: 1; /**< Disable the highspeed support */
};
int send_queue_size; /**< Max buffers that can be queued before sending. Should be manually
* configured before using the HAL.
*/
Expand All @@ -220,6 +216,7 @@ typedef struct {
sdio_ringbuf_t send_desc_queue; /**< The ring buffer used to hold queued descriptors. Should be manually
* initialized before using the HAL.
*/

//Internal status, no need to touch.
send_state_t send_state; // Current state of sending part.
uint32_t tail_pkt_len; // The accumulated send length of the tail packet.
Expand Down
7 changes: 6 additions & 1 deletion components/hal/include/hal/sdio_slave_types.h
Expand Up @@ -25,9 +25,14 @@ typedef enum {
/// Timing of SDIO slave
typedef enum {
SDIO_SLAVE_TIMING_PSEND_PSAMPLE = 0,/**< Send at posedge, and sample at posedge. Default value for HS mode.
* If :c:macro:`SDIO_SLAVE_FLAG_HIGH_SPEED` is specified in
* :cpp:class:`sdio_slave_config_t`, this should be selected.
* Normally there's no problem using this to work in DS mode.
*/
SDIO_SLAVE_TIMING_NSEND_PSAMPLE ,///< Send at negedge, and sample at posedge. Default value for DS mode and below.
SDIO_SLAVE_TIMING_NSEND_PSAMPLE, /**< Send at negedge, and sample at posedge. Default value for DS mode and
* below. If :c:macro:`SDIO_SLAVE_FLAG_DEFAULT_SPEED` is specified in
* :cpp:class:`sdio_slave_config_t`, this should be selected.
*/
SDIO_SLAVE_TIMING_PSEND_NSAMPLE, ///< Send at posedge, and sample at negedge
SDIO_SLAVE_TIMING_NSEND_NSAMPLE, ///< Send at negedge, and sample at negedge
} sdio_slave_timing_t;
Expand Down
2 changes: 1 addition & 1 deletion components/hal/sdio_slave_hal.c
Expand Up @@ -168,7 +168,7 @@ void sdio_slave_hal_init(sdio_slave_context_t *hal)
void sdio_slave_hal_hw_init(sdio_slave_context_t *hal)
{
sdio_slave_ll_init(hal->slc);
sdio_slave_ll_enable_hs(hal->hinf, true);
sdio_slave_ll_enable_hs(hal->hinf, !hal->no_highspeed);
sdio_slave_ll_set_timing(hal->host, hal->timing);
sdio_slave_ll_slvint_t intr_ena = 0xff;
sdio_slave_ll_slvint_set_ena(hal->slc, &intr_ena);
Expand Down
1 change: 0 additions & 1 deletion tools/ci/check_copyright_ignore.txt
Expand Up @@ -744,7 +744,6 @@ components/hal/include/hal/esp_flash_err.h
components/hal/include/hal/mpu_hal.h
components/hal/include/hal/mpu_types.h
components/hal/include/hal/rtc_io_types.h
components/hal/include/hal/sdio_slave_hal.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
Expand Down

0 comments on commit 9bc18ba

Please sign in to comment.