22
22
#define TIMEOUT_MAX UINT32_MAX
23
23
// Short timeout for sending/receiving ESSL packets
24
24
#define PACKET_TIMEOUT_MS 50
25
- // Used for padding unaligned packets, to simplify the logic and keep PPP protocol intact when padded
26
- #define PPP_SOF 0x7E
25
+
27
26
static const char * TAG = "eppp_sdio_host" ;
28
27
static SemaphoreHandle_t s_essl_mutex = NULL ;
29
28
static essl_handle_t s_essl = NULL ;
30
29
static sdmmc_card_t * s_card = NULL ;
31
30
32
- static CACHE_ALIGNED_ATTR uint8_t send_buffer [SDIO_PAYLOAD ];
31
+ static DRAM_DMA_ALIGNED_ATTR uint8_t send_buffer [SDIO_PAYLOAD ];
33
32
static DMA_ATTR uint8_t rcv_buffer [SDIO_PAYLOAD ];
34
33
35
34
esp_err_t eppp_sdio_host_tx (void * h , void * buffer , size_t len )
@@ -92,6 +91,7 @@ esp_err_t eppp_sdio_host_init(struct eppp_config_sdio_s *eppp_config)
92
91
93
92
sdmmc_host_t config = SDMMC_HOST_DEFAULT ();
94
93
config .flags = SDMMC_HOST_FLAG_4BIT ;
94
+ config .flags |= SDMMC_HOST_FLAG_ALLOC_ALIGNED_BUF ;
95
95
config .max_freq_khz = SDMMC_FREQ_HIGHSPEED ;
96
96
97
97
s_card = (sdmmc_card_t * )malloc (sizeof (sdmmc_card_t ));
@@ -117,9 +117,8 @@ esp_err_t eppp_sdio_host_init(struct eppp_config_sdio_s *eppp_config)
117
117
static esp_err_t get_intr (uint32_t * out_raw )
118
118
{
119
119
esp_err_t ret = ESP_OK ;
120
- ESP_GOTO_ON_ERROR (essl_wait_int (s_essl , TIMEOUT_MAX ), err , TAG , "essl-wait-int failed" );
121
- ESP_GOTO_ON_ERROR (essl_get_intr (s_essl , out_raw , NULL , TIMEOUT_MAX ), err , TAG , "essl-get-int failed" );
122
- ESP_GOTO_ON_ERROR (essl_clear_intr (s_essl , * out_raw , TIMEOUT_MAX ), err , TAG , "essl-clear-int failed" );
120
+ ESP_GOTO_ON_ERROR (essl_get_intr (s_essl , out_raw , NULL , 0 ), err , TAG , "essl-get-int failed" );
121
+ ESP_GOTO_ON_ERROR (essl_clear_intr (s_essl , * out_raw , 0 ), err , TAG , "essl-clear-int failed" );
123
122
ESP_LOGD (TAG , "intr: %08" PRIX32 , * out_raw );
124
123
err :
125
124
return ret ;
@@ -128,16 +127,22 @@ static esp_err_t get_intr(uint32_t *out_raw)
128
127
esp_err_t eppp_sdio_host_rx (esp_netif_t * netif )
129
128
{
130
129
uint32_t intr ;
131
- esp_err_t err = get_intr ( & intr );
130
+ esp_err_t err = essl_wait_int ( s_essl , TIMEOUT_MAX );
132
131
if (err == ESP_ERR_TIMEOUT ) {
133
132
return ESP_OK ;
134
133
}
134
+ xSemaphoreTake (s_essl_mutex , portMAX_DELAY );
135
+ err = get_intr (& intr );
136
+ if (err == ESP_ERR_TIMEOUT ) {
137
+ xSemaphoreGive (s_essl_mutex );
138
+ return ESP_OK ;
139
+ }
135
140
if (err != ESP_OK ) {
136
141
ESP_LOGE (TAG , "failed to check for interrupts %d" , err );
142
+ xSemaphoreGive (s_essl_mutex );
137
143
return ESP_FAIL ;
138
144
}
139
145
if (intr & ESSL_SDIO_DEF_ESP32 .new_packet_intr_mask ) {
140
- xSemaphoreTake (s_essl_mutex , portMAX_DELAY );
141
146
esp_err_t ret ;
142
147
do {
143
148
size_t size_read = SDIO_PAYLOAD ;
@@ -158,8 +163,8 @@ esp_err_t eppp_sdio_host_rx(esp_netif_t *netif)
158
163
}
159
164
}
160
165
} while (ret == ESP_ERR_NOT_FINISHED );
161
- xSemaphoreGive (s_essl_mutex );
162
166
}
167
+ xSemaphoreGive (s_essl_mutex );
163
168
return ESP_OK ;
164
169
}
165
170
0 commit comments