[bsp][stm32f411][RTduino] pins_switch_to_spi -> switchToSPI

This commit is contained in:
Meco Man 2023-07-09 13:23:57 -04:00 committed by Man, Jianting (Meco)
parent 7cdf0ac5cf
commit 5a51cd29c7
2 changed files with 15 additions and 8 deletions

View File

@ -51,16 +51,20 @@ const pin_map_t pin_map_table[]=
{A7, RT_NULL, "adc1", RT_ADC_INTERN_CH_TEMPER}, /* ADC, On-Chip: internal temperature sensor */
};
void pins_switch_to_spi(const char *bus_name)
#ifdef RTDUINO_USING_SPI
void switchToSPI(const char *bus_name)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(!rt_strcmp(bus_name, "spi1"))
{
__HAL_RCC_TIM1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_7);
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_7);
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
@ -76,3 +80,4 @@ void pins_switch_to_spi(const char *bus_name)
LOG_W("D11, D12 and D13 will switch from PWM to SPI");
}
}
#endif /* RTDUINO_USING_SPI */

View File

@ -45,9 +45,11 @@
#define LED_BUILTIN D13 /* Default Built-in LED */
/* i2c1 : PB9-SDA PB8-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
#define SS D7
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi1"
#define SS D10
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi1"
#define RTDUINO_TONE_HWTIMER_DEVICE_NAME "timer9"
#endif /* Pins_Arduino_h */