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