ibox bsp add spi1 and fal support
This commit is contained in:
parent
7d2471c423
commit
1d152b18eb
|
@ -41,8 +41,8 @@
|
|||
| **板载外设** | **支持情况** | **备注** |
|
||||
| :----------------- | :----------: | :------------------------------------- |
|
||||
| 以太网 | 支持 | W5500 使用 SPI2 |
|
||||
| RS485 | 支持 | 使用 UART4 |
|
||||
| LoRa | 暂不支持 | 使用 SPI1 LSD4RF |
|
||||
| RS485 | 支持 | MAX485 使用 UART4 |
|
||||
| LoRa | 支持 | 利尔达 LSD4RF-2F717N30 使用 SPI1 |
|
||||
| **片上外设** | **支持情况** | **备注** |
|
||||
| GPIO | 支持 | PA0, PA1... PG15 ---> PIN: 0, 1...144 |
|
||||
| UART | 支持 | UART1 |
|
||||
|
@ -52,6 +52,7 @@
|
|||
| ADC | 支持 | ADC1_CHANEL_10, ADC1_CHANNEL_11 |
|
||||
| PWM | 暂不支持 | |
|
||||
| IWG | 支持 | 命令:iwdg_sample wdt |
|
||||
| FLASH | 支持 | 已适配 FAL |
|
||||
| **扩展模块** | **支持情况** | **备注** |
|
||||
| WIFI ESP8266 | 支持 | 硬十 ESP-02 使用 UART3 |
|
||||
|
||||
|
@ -114,6 +115,8 @@ msh >
|
|||
- 此开发板外部高速晶振是 12MHz ;
|
||||
- 使用 WIFI ESP8266 , 需将 CH_PD (PG1) 引脚拉高 ;
|
||||
- 使用 W5500,需插上网线 ;
|
||||
- 测试 Lora 模块,可直接使用 sx12xx 软件包 ;
|
||||
- 使用 MAX485, 可使用 软件包中 串口例程,增加收发使能引脚的控制 ;
|
||||
|
||||
## 联系人信息
|
||||
|
||||
|
|
|
@ -10,41 +10,45 @@ KeepUserPlacement=false
|
|||
Mcu.Family=STM32F1
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=IWDG
|
||||
Mcu.IP10=USART3
|
||||
Mcu.IP10=USART2
|
||||
Mcu.IP11=USART3
|
||||
Mcu.IP2=NVIC
|
||||
Mcu.IP3=RCC
|
||||
Mcu.IP4=RTC
|
||||
Mcu.IP5=SPI2
|
||||
Mcu.IP6=SYS
|
||||
Mcu.IP7=UART4
|
||||
Mcu.IP8=USART1
|
||||
Mcu.IP9=USART2
|
||||
Mcu.IPNb=11
|
||||
Mcu.IP5=SPI1
|
||||
Mcu.IP6=SPI2
|
||||
Mcu.IP7=SYS
|
||||
Mcu.IP8=UART4
|
||||
Mcu.IP9=USART1
|
||||
Mcu.IPNb=12
|
||||
Mcu.Name=STM32F103Z(C-D-E)Tx
|
||||
Mcu.Package=LQFP144
|
||||
Mcu.Pin0=PC14-OSC32_IN
|
||||
Mcu.Pin1=PC15-OSC32_OUT
|
||||
Mcu.Pin10=PB13
|
||||
Mcu.Pin11=PB14
|
||||
Mcu.Pin12=PB15
|
||||
Mcu.Pin13=PA9
|
||||
Mcu.Pin14=PA10
|
||||
Mcu.Pin15=PA13
|
||||
Mcu.Pin16=PA14
|
||||
Mcu.Pin17=PC10
|
||||
Mcu.Pin18=PC11
|
||||
Mcu.Pin19=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin10=PA7
|
||||
Mcu.Pin11=PB10
|
||||
Mcu.Pin12=PB11
|
||||
Mcu.Pin13=PB13
|
||||
Mcu.Pin14=PB14
|
||||
Mcu.Pin15=PB15
|
||||
Mcu.Pin16=PA9
|
||||
Mcu.Pin17=PA10
|
||||
Mcu.Pin18=PA13
|
||||
Mcu.Pin19=PA14
|
||||
Mcu.Pin2=OSC_IN
|
||||
Mcu.Pin20=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin21=VP_SYS_VS_Systick
|
||||
Mcu.Pin20=PC10
|
||||
Mcu.Pin21=PC11
|
||||
Mcu.Pin22=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin23=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin24=VP_SYS_VS_Systick
|
||||
Mcu.Pin3=OSC_OUT
|
||||
Mcu.Pin4=PC0
|
||||
Mcu.Pin5=PC1
|
||||
Mcu.Pin6=PA2
|
||||
Mcu.Pin7=PA3
|
||||
Mcu.Pin8=PB10
|
||||
Mcu.Pin9=PB11
|
||||
Mcu.PinsNb=22
|
||||
Mcu.Pin8=PA5
|
||||
Mcu.Pin9=PA6
|
||||
Mcu.PinsNb=25
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103ZETx
|
||||
|
@ -74,6 +78,12 @@ PA2.Mode=Asynchronous
|
|||
PA2.Signal=USART2_TX
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=USART2_RX
|
||||
PA5.Mode=Full_Duplex_Master
|
||||
PA5.Signal=SPI1_SCK
|
||||
PA6.Mode=Full_Duplex_Master
|
||||
PA6.Signal=SPI1_MISO
|
||||
PA7.Mode=Full_Duplex_Master
|
||||
PA7.Signal=SPI1_MOSI
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB10.Mode=Asynchronous
|
||||
|
@ -132,7 +142,7 @@ ProjectManager.StackSize=0x400
|
|||
ProjectManager.TargetToolchain=MDK-ARM V5
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_ADC1_Init-ADC1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_ADC1_Init-ADC1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_SPI1_Init-SPI1-false-HAL-true
|
||||
RCC.ADCFreqValue=12000000
|
||||
RCC.ADCPresc=RCC_ADCPCLK2_DIV6
|
||||
RCC.AHBFreq_Value=72000000
|
||||
|
@ -167,6 +177,12 @@ SH.ADCx_IN10.0=ADC1_IN10,IN10
|
|||
SH.ADCx_IN10.ConfNb=1
|
||||
SH.ADCx_IN11.0=ADC1_IN11,IN11
|
||||
SH.ADCx_IN11.ConfNb=1
|
||||
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8
|
||||
SPI1.CalculateBaudRate=9.0 MBits/s
|
||||
SPI1.Direction=SPI_DIRECTION_2LINES
|
||||
SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate
|
||||
SPI1.Mode=SPI_MODE_MASTER
|
||||
SPI1.VirtualType=VM_MASTER
|
||||
SPI2.CalculateBaudRate=18.0 MBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
||||
|
|
|
@ -68,6 +68,7 @@ IWDG_HandleTypeDef hiwdg;
|
|||
|
||||
RTC_HandleTypeDef hrtc;
|
||||
|
||||
SPI_HandleTypeDef hspi1;
|
||||
SPI_HandleTypeDef hspi2;
|
||||
|
||||
UART_HandleTypeDef huart4;
|
||||
|
@ -90,6 +91,7 @@ static void MX_USART3_UART_Init(void);
|
|||
static void MX_SPI2_Init(void);
|
||||
static void MX_UART4_Init(void);
|
||||
static void MX_USART2_UART_Init(void);
|
||||
static void MX_SPI1_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
@ -135,6 +137,7 @@ int main(void)
|
|||
MX_SPI2_Init();
|
||||
MX_UART4_Init();
|
||||
MX_USART2_UART_Init();
|
||||
MX_SPI1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
@ -301,6 +304,44 @@ static void MX_RTC_Init(void)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI1 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI1_Init 0 */
|
||||
|
||||
/* USER CODE END SPI1_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SPI1_Init 1 */
|
||||
|
||||
/* USER CODE END SPI1_Init 1 */
|
||||
/* SPI1 parameter configuration*/
|
||||
hspi1.Instance = SPI1;
|
||||
hspi1.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi1.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
|
||||
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi1.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI1_Init 2 */
|
||||
|
||||
/* USER CODE END SPI1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI2 Initialization Function
|
||||
* @param None
|
||||
|
|
|
@ -226,7 +226,35 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hspi->Instance==SPI2)
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
/* USER CODE BEGIN SPI1_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI1_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**SPI1 GPIO Configuration
|
||||
PA5 ------> SPI1_SCK
|
||||
PA6 ------> SPI1_MISO
|
||||
PA7 ------> SPI1_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN SPI1_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspInit 1 */
|
||||
}
|
||||
else if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||
|
||||
|
@ -267,7 +295,26 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
|
||||
if(hspi->Instance==SPI2)
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI1_CLK_DISABLE();
|
||||
|
||||
/**SPI1 GPIO Configuration
|
||||
PA5 ------> SPI1_SCK
|
||||
PA6 ------> SPI1_MISO
|
||||
PA7 ------> SPI1_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
|
||||
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspDeInit 1 */
|
||||
}
|
||||
else if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||
|
||||
|
|
|
@ -36,6 +36,49 @@ menu "Onboard Peripheral Drivers"
|
|||
default 0x00
|
||||
|
||||
endif
|
||||
config BSP_USING_LORA
|
||||
bool "Enable LoRa Driver (spi1)"
|
||||
default n
|
||||
select PKG_USING_SX12XX
|
||||
select SX12XX_DEVICE_EXTERN_CONFIG
|
||||
select BSP_USING_SPI1
|
||||
if BSP_USING_LORA
|
||||
if SX12XX_DEVICE_EXTERN_CONFIG
|
||||
config SX12XX_SPI_DEVICE
|
||||
string "SPI device name"
|
||||
default "spi10"
|
||||
|
||||
config SX12XX_RST_PIN
|
||||
int "Reset PIN number"
|
||||
default 7
|
||||
|
||||
config SX12XX_DO0_PIN
|
||||
int "DO0 PIN number"
|
||||
default 103
|
||||
|
||||
config SX12XX_DO1_PIN
|
||||
int "DO1 PIN number"
|
||||
default 104
|
||||
|
||||
config SX12XX_DO2_PIN
|
||||
int "DO2 PIN number"
|
||||
default 105
|
||||
|
||||
config SX12XX_DO3_PIN
|
||||
int "DO3 PIN number"
|
||||
default 106
|
||||
|
||||
config SX12XX_DO4_PIN
|
||||
int "DO4 PIN number"
|
||||
default 107
|
||||
|
||||
config SX12XX_DO5_PIN
|
||||
int "DO5 PIN number"
|
||||
default 108
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
endmenu
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
|
@ -84,6 +127,9 @@ menu "On-chip Peripheral Drivers"
|
|||
bool "Enable UART4 RX DMA"
|
||||
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
|
||||
endif
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
default n
|
||||
menuconfig BSP_USING_I2C1
|
||||
bool "Enable I2C1 BUS (software simulation)"
|
||||
default n
|
||||
|
|
|
@ -16,6 +16,9 @@ if GetDepend(['BSP_USING_ETH']):
|
|||
|
||||
if GetDepend(['BSP_USING_WIFI_OR_GPRS']):
|
||||
src += Glob('ports/esp02_device.c')
|
||||
if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
|
||||
src += Glob('ports/on_chip_flash_init.c')
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
path += [cwd + '/ports']
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-12-5 SummerGift first version
|
||||
*/
|
||||
|
||||
#ifndef _FAL_CFG_H_
|
||||
#define _FAL_CFG_H_
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
extern const struct fal_flash_dev stm32_onchip_flash;
|
||||
|
||||
/* flash device table */
|
||||
#define FAL_FLASH_DEV_TABLE \
|
||||
{ \
|
||||
&stm32_onchip_flash, \
|
||||
}
|
||||
/* ====================== Partition Configuration ========================== */
|
||||
#ifdef FAL_PART_HAS_TABLE_CFG
|
||||
|
||||
/* partition table */
|
||||
#define FAL_PART_TABLE \
|
||||
{ \
|
||||
{FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 496 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "param", "onchip_flash", 496* 1024 , 16 * 1024, 0}, \
|
||||
}
|
||||
#endif /* FAL_PART_HAS_TABLE_CFG */
|
||||
#endif /* _FAL_CFG_H_ */
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-11-27 SummerGift add spi flash port file
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "fal.h"
|
||||
|
||||
#if defined(BSP_USING_ON_CHIP_FLASH)
|
||||
static int rt_hw_on_chip_flash_init(void)
|
||||
{
|
||||
fal_init();
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_on_chip_flash_init);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue