[bsp][nxp]基于MCXN947的spi_driver添加spi7读写W25Q64_Flash:
This commit is contained in:
parent
c911ed4875
commit
42e01a80a0
|
@ -20,6 +20,9 @@ enum
|
|||
#ifdef BSP_USING_SPI3
|
||||
SPI3_INDEX,
|
||||
#endif
|
||||
#ifdef BSP_USING_SPI7
|
||||
SPI7_INDEX,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,41 +64,25 @@ static struct lpc_spi lpc_obj[] =
|
|||
.name = "spi3",
|
||||
},
|
||||
#endif
|
||||
#ifdef BSP_USING_SPI7
|
||||
{
|
||||
.LPSPIx = LPSPI7,
|
||||
.clock_attach_id = kFRO_HF_DIV_to_FLEXCOMM7,
|
||||
.clock_div_name = kCLOCK_DivFlexcom7Clk,
|
||||
.clock_name = kCLOCK_FroHf,
|
||||
.tx_dma_request = kDmaRequestMuxLpFlexcomm7Tx,
|
||||
.rx_dma_request = kDmaRequestMuxLpFlexcomm7Rx,
|
||||
.DMAx = DMA0,
|
||||
.tx_dma_chl = 2,
|
||||
.rx_dma_chl = 3,
|
||||
.name = "spi7",
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct lpc_sw_spi_cs
|
||||
{
|
||||
rt_uint32_t pin;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t pin)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
||||
struct rt_spi_device *spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device));
|
||||
struct lpc_sw_spi_cs *cs_pin = (struct lpc_sw_spi_cs *)rt_malloc(sizeof(struct lpc_sw_spi_cs));
|
||||
|
||||
cs_pin->pin = pin;
|
||||
rt_pin_mode(pin, PIN_MODE_OUTPUT);
|
||||
rt_pin_write(pin, PIN_HIGH);
|
||||
|
||||
ret = rt_spi_bus_attach_device(spi_device, device_name, bus_name, (void *)cs_pin);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
// struct lpc_spi *spi = RT_NULL;
|
||||
// spi = (struct lpc_spi *)(device->bus->parent.user_data);
|
||||
// ret = lpc_spi_init(spi->SPIx, cfg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -119,11 +106,11 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
|
|||
|
||||
|
||||
struct lpc_spi *spi = (struct lpc_spi *)(device->bus->parent.user_data);
|
||||
struct lpc_sw_spi_cs *cs = device->parent.user_data;
|
||||
// struct lpc_sw_spi_cs *cs = device->parent.user_data;
|
||||
|
||||
if(message->cs_take)
|
||||
{
|
||||
rt_pin_write(cs->pin, PIN_LOW);
|
||||
rt_pin_write(device->cs_pin, PIN_LOW);
|
||||
}
|
||||
|
||||
transfer.dataSize = message->length;
|
||||
|
@ -165,7 +152,7 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
|
|||
|
||||
if(message->cs_release)
|
||||
{
|
||||
rt_pin_write(cs->pin, PIN_HIGH);
|
||||
rt_pin_write(device->cs_pin, PIN_HIGH);
|
||||
}
|
||||
|
||||
return message->length;
|
||||
|
|
|
@ -140,7 +140,7 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
|
|||
# CONFIG_RT_USING_I2C is not set
|
||||
# CONFIG_RT_USING_PHY is not set
|
||||
# CONFIG_RT_USING_ADC is not set
|
||||
# CONFIG_RT_USING_DAC is not set
|
||||
CONFIG_RT_USING_DAC=y
|
||||
# CONFIG_RT_USING_NULL is not set
|
||||
# CONFIG_RT_USING_ZERO is not set
|
||||
# CONFIG_RT_USING_RANDOM is not set
|
||||
|
@ -150,7 +150,18 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
|
|||
# CONFIG_RT_USING_PM is not set
|
||||
# CONFIG_RT_USING_RTC is not set
|
||||
# CONFIG_RT_USING_SDIO is not set
|
||||
# CONFIG_RT_USING_SPI is not set
|
||||
CONFIG_RT_USING_SPI=y
|
||||
# CONFIG_RT_USING_SPI_BITOPS is not set
|
||||
CONFIG_RT_USING_QSPI=y
|
||||
# CONFIG_RT_USING_SPI_MSD is not set
|
||||
CONFIG_RT_USING_SFUD=y
|
||||
CONFIG_RT_SFUD_USING_SFDP=y
|
||||
CONFIG_RT_SFUD_USING_FLASH_INFO_TABLE=y
|
||||
CONFIG_RT_SFUD_USING_QSPI=y
|
||||
CONFIG_RT_SFUD_SPI_MAX_HZ=50000000
|
||||
CONFIG_RT_DEBUG_SFUD=y
|
||||
# CONFIG_RT_USING_ENC28J60 is not set
|
||||
# CONFIG_RT_USING_SPI_WIFI is not set
|
||||
# CONFIG_RT_USING_WDT is not set
|
||||
# CONFIG_RT_USING_AUDIO is not set
|
||||
# CONFIG_RT_USING_SENSOR is not set
|
||||
|
@ -1030,6 +1041,7 @@ CONFIG_PKG_RT_VSNPRINTF_FULL_VER="latest"
|
|||
# CONFIG_PKG_USING_ARDUINO_SEEED_LTC2941 is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_SEEED_LDC1612 is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_JARZEBSKI_MPU6050 is not set
|
||||
|
||||
#
|
||||
# Display
|
||||
|
@ -1056,6 +1068,7 @@ CONFIG_PKG_RT_VSNPRINTF_FULL_VER="latest"
|
|||
# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_ARDUINOJSON is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_TENSORFLOW_LITE_MICRO is not set
|
||||
# CONFIG_PKG_USING_ARDUINO_RUNNINGMEDIAN is not set
|
||||
|
||||
#
|
||||
# Data Storage
|
||||
|
@ -1108,16 +1121,21 @@ CONFIG_SOC_MCXN947=y
|
|||
#
|
||||
# On-chip Peripheral Drivers
|
||||
#
|
||||
# CONFIG_BSP_USING_DMA is not set
|
||||
CONFIG_BSP_USING_DMA=y
|
||||
CONFIG_BSP_USING_PIN=y
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART4=y
|
||||
CONFIG_BSP_USING_UART5=y
|
||||
CONFIG_BSP_USING_UART2=y
|
||||
# CONFIG_BSP_USING_I2C is not set
|
||||
# CONFIG_BSP_USING_SPI is not set
|
||||
CONFIG_BSP_USING_SPI=y
|
||||
CONFIG_BSP_USING_SPI3=y
|
||||
CONFIG_BSP_USING_SPI7=y
|
||||
CONFIG_BSP_USING_SPI8=y
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_DAC is not set
|
||||
# CONFIG_BSP_USING_SDIO is not set
|
||||
# CONFIG_BSP_USING_ETH is not set
|
||||
# CONFIG_BSP_USING_RTC is not set
|
||||
# CONFIG_BSP_USING_WDT is not set
|
||||
# CONFIG_BSP_USING_HWTIMER is not set
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
#include <rtdevice.h>
|
||||
#include <rtthread.h>
|
||||
#include "drv_pin.h"
|
||||
|
||||
#define LEDB_PIN ((0*32)+10)
|
||||
|
|
|
@ -64,6 +64,10 @@ menu "On-chip Peripheral Drivers"
|
|||
bool "Enable Flexcomm3 as SPI"
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI7
|
||||
bool "Enable Flexcomm7 as SPI"
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI8
|
||||
bool "Enable Flexcomm8 as High Speed SPI"
|
||||
default y
|
||||
|
|
|
@ -64,6 +64,12 @@ void BOARD_InitBootPins(void)
|
|||
// PORT1->PCR[4] = PORT_PCR_MUX(2) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC3_4 D[3] */
|
||||
// PORT1->PCR[5] = PORT_PCR_MUX(2) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC3_5 D[2] */
|
||||
|
||||
/* QSPI */
|
||||
PORT3->PCR[8] = PORT_PCR_MUX(3) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC7_P0, MOSI */
|
||||
PORT3->PCR[9] = PORT_PCR_MUX(3) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC7_P2, MISO */
|
||||
PORT3->PCR[7] = PORT_PCR_MUX(3) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC7_P1, CLK */
|
||||
PORT3->PCR[0] = PORT_PCR_MUX(3) | PORT_PCR_PS(0) | PORT_PCR_PE(0) | PORT_PCR_IBE(1); /* FC7_P1, CS */
|
||||
|
||||
PORT1->PCR[8] = PORT_PCR_MUX(2) | PORT_PCR_PS(0) | PORT_PCR_PE(1) | PORT_PCR_IBE(1); /* FC4_UART */
|
||||
PORT1->PCR[9] = PORT_PCR_MUX(2) | PORT_PCR_PS(0) | PORT_PCR_PE(1) | PORT_PCR_IBE(1); /* FC4_UART */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -91,6 +91,15 @@
|
|||
#define RT_USING_SERIAL_V1
|
||||
#define RT_SERIAL_USING_DMA
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_DAC
|
||||
#define RT_USING_SPI
|
||||
#define RT_USING_QSPI
|
||||
#define RT_USING_SFUD
|
||||
#define RT_SFUD_USING_SFDP
|
||||
#define RT_SFUD_USING_FLASH_INFO_TABLE
|
||||
#define RT_SFUD_USING_QSPI
|
||||
#define RT_SFUD_SPI_MAX_HZ 50000000
|
||||
#define RT_DEBUG_SFUD
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_HWTIMER
|
||||
|
||||
|
@ -281,11 +290,16 @@
|
|||
|
||||
/* On-chip Peripheral Drivers */
|
||||
|
||||
#define BSP_USING_DMA
|
||||
#define BSP_USING_PIN
|
||||
#define BSP_USING_UART
|
||||
#define BSP_USING_UART4
|
||||
#define BSP_USING_UART5
|
||||
#define BSP_USING_UART2
|
||||
#define BSP_USING_SPI
|
||||
#define BSP_USING_SPI3
|
||||
#define BSP_USING_SPI7
|
||||
#define BSP_USING_SPI8
|
||||
|
||||
/* Board extended module Drivers */
|
||||
|
||||
|
|
Loading…
Reference in New Issue