[bsp][stm32g474-nucleo][RTduino] support SPI
This commit is contained in:
parent
cd1c08b3cd
commit
6071e8aa14
|
@ -12,6 +12,10 @@
|
|||
#include "pins_arduino.h"
|
||||
#include <drv_gpio.h>
|
||||
|
||||
#define DBG_TAG "RTduino.pins_arduino"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
|
||||
* [] means optional
|
||||
|
@ -47,3 +51,32 @@ const pin_map_t pin_map_table[]=
|
|||
{A6, RT_NULL, "adc1", RT_ADC_INTERN_CH_VREF}, /* ADC, On-Chip: internal reference voltage */
|
||||
{A7, RT_NULL, "adc1", RT_ADC_INTERN_CH_TEMPER}, /* ADC, On-Chip: internal temperature sensor */
|
||||
};
|
||||
|
||||
#ifdef RTDUINO_USING_SPI
|
||||
void switchToSPI(const char *bus_name)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
if(!rt_strcmp(bus_name, "spi1"))
|
||||
{
|
||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
|
||||
|
||||
/**SPI1 GPIO Configuration
|
||||
PA5 ------> SPI1_SCK
|
||||
PA6 ------> SPI1_MISO
|
||||
PA7 ------> SPI1_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
LOG_I("D11, D12 and D13 will switch from PWM to SPI");
|
||||
}
|
||||
}
|
||||
#endif /* RTDUINO_USING_SPI */
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
/* i2c1 : PB9-SDA PB8-SCL */
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||
|
||||
#define SS D10
|
||||
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi1"
|
||||
|
||||
/* Serial2 : PA9-TX PA10-RX */
|
||||
#define RTDUINO_SERIAL2_DEVICE_NAME "uart1"
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
/*#define HAL_SAI_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
|
|
|
@ -30,8 +30,13 @@ menu "Onboard Peripheral Drivers"
|
|||
select BSP_USING_PWM8_CH2
|
||||
select BSP_USING_I2C
|
||||
select BSP_USING_I2C1
|
||||
select BSP_USING_SPI
|
||||
select BSP_USING_SPI1
|
||||
# select BSP_SPI1_TX_USING_DMA
|
||||
# select BSP_SPI1_RX_USING_DMA
|
||||
select RTDUINO_USING_WIRE
|
||||
select RTDUINO_USING_SPI
|
||||
imply RTDUINO_USING_SERVO
|
||||
imply RTDUINO_USING_WIRE
|
||||
default n
|
||||
endmenu
|
||||
|
||||
|
@ -146,6 +151,27 @@ menu "On-chip Peripheral Drivers"
|
|||
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI Bus"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 Bus"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_I2C1
|
||||
bool "Enable I2C1 BUS (software simulation)"
|
||||
default n
|
||||
|
|
Loading…
Reference in New Issue