Skip to content

Commit f4bf655

Browse files
committed
chore: remove BSP_SD_DetectITConfig
Interrupt have to be managed using Arduino interrupt API Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent ac3768f commit f4bf655

File tree

3 files changed

+6
-76
lines changed

3 files changed

+6
-76
lines changed

src/Sd2Card.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ bool Sd2Card::init(uint32_t detect, uint32_t level)
5757
if (detect != SD_DETECT_NONE) {
5858
PinName p = digitalPinToPinName(detect);
5959
if ((p == NC) || \
60-
BSP_SD_DetectPin(set_GPIO_Port_Clock(STM_PORT(p)),
61-
STM_LL_GPIO_PIN(p), level) != MSD_OK) {
60+
BSP_SD_DetectPin(p, level) != MSD_OK) {
6261
return false;
6362
}
6463
}

src/bsp_sd.c

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,14 @@ uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef
381381

382382
/**
383383
* @brief Set the SD card device detect pin, port and level.
384-
* @param port one of the gpio port
385-
* @param pin one of the gpio pin
384+
* @param p PinName of the detect pin
386385
* @param level the level of the detect pin (HIGH or LOW)
387386
* @retval SD status
388387
*/
389-
uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin, uint32_t level)
388+
uint8_t BSP_SD_DetectPin(PinName p, uint32_t level)
390389
{
390+
GPIO_TypeDef *port = set_GPIO_Port_Clock(STM_PORT(p));
391+
uint32_t pin = STM_LL_GPIO_PIN(p);
391392
if (port != 0) {
392393
SD_detect_ll_gpio_pin = pin;
393394
SD_detect_gpio_port = port;
@@ -397,75 +398,6 @@ uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin, uint32_t level)
397398
return MSD_ERROR;
398399
}
399400

400-
/**
401-
* @brief Configures Interrupt mode for SD detection pin.
402-
* @retval Status
403-
*/
404-
uint8_t BSP_SD_DetectITConfig(void (*callback)(void))
405-
{
406-
uint8_t sd_state = MSD_ERROR;
407-
if (SD_detect_ll_gpio_pin != LL_GPIO_PIN_ALL) {
408-
LL_GPIO_SetPinPull(SD_detect_gpio_port, SD_detect_ll_gpio_pin, LL_GPIO_PULL_UP);
409-
uint16_t SD_detect_gpio_pin = GPIO_PIN_All;
410-
switch (SD_detect_ll_gpio_pin) {
411-
case LL_GPIO_PIN_0:
412-
SD_detect_gpio_pin = GPIO_PIN_0;
413-
break;
414-
case LL_GPIO_PIN_1:
415-
SD_detect_gpio_pin = GPIO_PIN_1;
416-
break;
417-
case LL_GPIO_PIN_2:
418-
SD_detect_gpio_pin = GPIO_PIN_2;
419-
break;
420-
case LL_GPIO_PIN_3:
421-
SD_detect_gpio_pin = GPIO_PIN_3;
422-
break;
423-
case LL_GPIO_PIN_4:
424-
SD_detect_gpio_pin = GPIO_PIN_4;
425-
break;
426-
case LL_GPIO_PIN_5:
427-
SD_detect_gpio_pin = GPIO_PIN_5;
428-
break;
429-
case LL_GPIO_PIN_6:
430-
SD_detect_gpio_pin = GPIO_PIN_6;
431-
break;
432-
case LL_GPIO_PIN_7:
433-
SD_detect_gpio_pin = GPIO_PIN_7;
434-
break;
435-
case LL_GPIO_PIN_8:
436-
SD_detect_gpio_pin = GPIO_PIN_8;
437-
break;
438-
case LL_GPIO_PIN_9:
439-
SD_detect_gpio_pin = GPIO_PIN_9;
440-
break;
441-
case LL_GPIO_PIN_10:
442-
SD_detect_gpio_pin = GPIO_PIN_10;
443-
break;
444-
case LL_GPIO_PIN_11:
445-
SD_detect_gpio_pin = GPIO_PIN_11;
446-
break;
447-
case LL_GPIO_PIN_12:
448-
SD_detect_gpio_pin = GPIO_PIN_12;
449-
break;
450-
case LL_GPIO_PIN_13:
451-
SD_detect_gpio_pin = GPIO_PIN_13;
452-
break;
453-
case LL_GPIO_PIN_14:
454-
SD_detect_gpio_pin = GPIO_PIN_14;
455-
break;
456-
case LL_GPIO_PIN_15:
457-
SD_detect_gpio_pin = GPIO_PIN_15;
458-
break;
459-
default:
460-
Error_Handler();
461-
break;
462-
}
463-
stm32_interrupt_enable(SD_detect_gpio_port, SD_detect_gpio_pin, callback, GPIO_MODE_IT_RISING_FALLING);
464-
sd_state = MSD_OK;
465-
}
466-
return sd_state;
467-
}
468-
469401
/**
470402
* @brief Detects if SD card is correctly plugged in the memory slot or not.
471403
* @retval Returns if SD is detected or not

src/bsp_sd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ uint8_t BSP_SD_DeInit(void);
174174
#if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U)
175175
uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef *selport, uint32_t selpin);
176176
#endif
177-
uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin, uint32_t level);
178-
uint8_t BSP_SD_DetectITConfig(void (*callback)(void));
177+
uint8_t BSP_SD_DetectPin(PinName p, uint32_t level);
179178
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
180179
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
181180
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);

0 commit comments

Comments
 (0)