[stm32f412] support RTduino SPI
This commit is contained in:
parent
71560bafb5
commit
0400fffafc
@ -69,7 +69,7 @@ I2C bus is `SCL/D15` and `SDA/D14` pins. Users can directly include the `#includ
|
|||||||
|
|
||||||
### 3.2 SPI Bus
|
### 3.2 SPI Bus
|
||||||
|
|
||||||
This board doesn't support Arduino SPI header file and functions.
|
The SPI bus of the Nucleo board is the `CS/D10`, `MOSI/D11`, `MISO/D12` and `SCK/D13` pins printed on the board. These `D11`, `D12` and `D13` pins It is taken over by the RT-Thread SPI device framework and there is no need to directly control these pins. User needs to operate `D10` chip select pin. Directly quote `#include <SPI.h>` (Arduino official SPI header file) to use. After using the SPI function, the PWM function of `D10` and `D11` will be irreversibly disabled and converted to the SPI function.
|
||||||
|
|
||||||
### 3.3 Serial
|
### 3.3 Serial
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚默
|
|||||||
|
|
||||||
### 3.2 SPI总线
|
### 3.2 SPI总线
|
||||||
|
|
||||||
目前本BSP不支持使用Arduino的SPI功能。
|
Nucleo板的SPI总线是板上丝印的 `CS/D10`、`MOSI/D11`、`MISO/D12` 以及 `SCK/D13` 引脚,这`D11`、`D12` 以及 `D13` 引脚是被RT-Thread SPI设备框架接管的,不需要直接操控这些引脚。用户需要操作 `D10` 片选引脚。直接引用`#include <SPI.h>`(Arduino官方SPI头文件)即可使用。在使用SPI功能后,`D10` 和 `D11` 的PWM功能将会不可逆失效,转为SPI功能。
|
||||||
|
|
||||||
### 3.3 串口
|
### 3.3 串口
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#include "pins_arduino.h"
|
#include "pins_arduino.h"
|
||||||
#include <drv_gpio.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]}
|
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
|
||||||
* [] means optional
|
* [] means optional
|
||||||
@ -50,3 +54,34 @@ const pin_map_t pin_map_table[]=
|
|||||||
{A6, RT_NULL, "adc1", RT_ADC_INTERN_CH_VREF}, /* ADC, On-Chip: internal reference voltage */
|
{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 */
|
{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);
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6);
|
||||||
|
HAL_GPIO_DeInit(GPIOA, 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_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
LOG_W("D11, D12 and D13 will switch from PWM to SPI");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* RTDUINO_USING_SPI */
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
#define A6 (26)
|
#define A6 (26)
|
||||||
#define A7 (27)
|
#define A7 (27)
|
||||||
|
|
||||||
|
#define RTDUINO_PIN_MAX_LIMIT A7 /* pin number max limit check */
|
||||||
|
|
||||||
#define F_CPU 96000000L /* CPU:96MHz */
|
#define F_CPU 96000000L /* CPU:96MHz */
|
||||||
|
|
||||||
#define LED_BUILTIN D17 /* Default Built-in LED */
|
#define LED_BUILTIN D17 /* Default Built-in LED */
|
||||||
@ -48,4 +50,7 @@
|
|||||||
/* i2c1 : PB9-SDA PB8-SCL */
|
/* i2c1 : PB9-SDA PB8-SCL */
|
||||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||||
|
|
||||||
|
#define SS D10
|
||||||
|
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi1"
|
||||||
|
|
||||||
#endif /* Pins_Arduino_h */
|
#endif /* Pins_Arduino_h */
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
/* #define HAL_SAI_MODULE_ENABLED */
|
/* #define HAL_SAI_MODULE_ENABLED */
|
||||||
/* #define HAL_SD_MODULE_ENABLED */
|
/* #define HAL_SD_MODULE_ENABLED */
|
||||||
/* #define HAL_MMC_MODULE_ENABLED */
|
/* #define HAL_MMC_MODULE_ENABLED */
|
||||||
/* #define HAL_SPI_MODULE_ENABLED */
|
#define HAL_SPI_MODULE_ENABLED
|
||||||
#define HAL_TIM_MODULE_ENABLED
|
#define HAL_TIM_MODULE_ENABLED
|
||||||
#define HAL_UART_MODULE_ENABLED
|
#define HAL_UART_MODULE_ENABLED
|
||||||
/* #define HAL_USART_MODULE_ENABLED */
|
/* #define HAL_USART_MODULE_ENABLED */
|
||||||
|
@ -27,8 +27,13 @@ menu "Onboard Peripheral Drivers"
|
|||||||
select BSP_USING_PWM14_CH1
|
select BSP_USING_PWM14_CH1
|
||||||
select BSP_USING_I2C
|
select BSP_USING_I2C
|
||||||
select BSP_USING_I2C1
|
select BSP_USING_I2C1
|
||||||
|
select BSP_USING_SPI
|
||||||
|
select BSP_USING_SPI1
|
||||||
|
select BSP_SPI1_TX_USING_DMA
|
||||||
|
select BSP_SPI1_RX_USING_DMA
|
||||||
imply RTDUINO_USING_SERVO
|
imply RTDUINO_USING_SERVO
|
||||||
imply RTDUINO_USING_WIRE
|
imply RTDUINO_USING_WIRE
|
||||||
|
imply RTDUINO_USING_SPI
|
||||||
default n
|
default n
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
@ -142,6 +147,27 @@ menu "On-chip Peripheral Drivers"
|
|||||||
endif
|
endif
|
||||||
endif
|
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
|
||||||
|
|
||||||
config BSP_USING_ON_CHIP_FLASH
|
config BSP_USING_ON_CHIP_FLASH
|
||||||
bool "Enable on-chip FLASH"
|
bool "Enable on-chip FLASH"
|
||||||
default n
|
default n
|
||||||
|
@ -62,11 +62,11 @@ Hardware Drivers Config --->
|
|||||||
|
|
||||||
### 3.1 I2C总线
|
### 3.1 I2C总线
|
||||||
|
|
||||||
STM32F410 Nucleo板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
Nucleo板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||||
|
|
||||||
### 3.2 SPI总线
|
### 3.2 SPI总线
|
||||||
|
|
||||||
目前本BSP不支持使用Arduino的SPI功能。
|
Nucleo板的SPI总线是板上丝印的 `CS/D10`、`MOSI/D11`、`MISO/D12` 以及 `SCK/D13` 引脚,这`D11`、`D12` 以及 `D13` 引脚是被RT-Thread SPI设备框架接管的,不需要直接操控这些引脚。用户需要操作 `D10` 片选引脚。直接引用`#include <SPI.h>`(Arduino官方SPI头文件)即可使用。在使用SPI功能后,`D10` 和 `D11` 的PWM功能将会不可逆失效,转为SPI功能。
|
||||||
|
|
||||||
### 3.3 串口
|
### 3.3 串口
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user