[bsp][nxp][mcxa153] add spi1 driver entry

This commit is contained in:
下里巴人 2024-08-29 09:07:05 +08:00 committed by GitHub
parent 8b4fb52905
commit 9e690694c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 125 additions and 1 deletions

View File

@ -17,7 +17,10 @@
enum enum
{ {
#ifdef BSP_USING_SPI0 #ifdef BSP_USING_SPI0
SPI0_INDEX SPI0_INDEX,
#endif
#ifdef BSP_USING_SPI1
SPI1_INDEX,
#endif #endif
}; };
@ -58,6 +61,20 @@ static struct lpc_spi lpc_obj[] =
.name = "spi0", .name = "spi0",
}, },
#endif #endif
#ifdef BSP_USING_SPI1
{
.LPSPIx = LPSPI1,
.clock_attach_id = kFRO12M_to_LPSPI1,
.clock_div_name = kCLOCK_DivLPSPI1,
.clock_name = kCLOCK_Fro12M,
.tx_dma_request = kDma0RequestLPSPI1Tx,
.rx_dma_request = kDma0RequestLPSPI1Rx,
.DMAx = DMA0,
.tx_dma_chl = 0,
.rx_dma_chl = 1,
.name = "spi1",
},
#endif
}; };
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t pin) rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t pin)

View File

@ -54,6 +54,10 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_SPI0 config BSP_USING_SPI0
bool "Enable SPI0" bool "Enable SPI0"
default n default n
config BSP_USING_SPI1
bool "Enable SPI1"
default n
endif endif
menuconfig BSP_USING_ADC menuconfig BSP_USING_ADC

View File

@ -53,6 +53,7 @@ void BOARD_InitPins(void)
RESET_ReleasePeripheralReset(kCTIMER1_RST_SHIFT_RSTn); RESET_ReleasePeripheralReset(kCTIMER1_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kLPSPI0_RST_SHIFT_RSTn); RESET_ReleasePeripheralReset(kLPSPI0_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kLPSPI1_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kLPI2C0_RST_SHIFT_RSTn); RESET_ReleasePeripheralReset(kLPI2C0_RST_SHIFT_RSTn);
@ -247,6 +248,108 @@ void BOARD_InitPins(void)
PORT_SetPinConfig(PORT1, 3U, &port1_3_pin59_config); PORT_SetPinConfig(PORT1, 3U, &port1_3_pin59_config);
#endif #endif
#ifdef BSP_USING_SPI1
const port_pin_config_t port2_12_pin22_config = {/* Internal pull-up/down resistor is disabled */
kPORT_PullDisable,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPSPI1_SCK */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT2_12 (pin 22) is configured as LPSPI1_SCK */
PORT_SetPinConfig(PORT2, 12U, &port2_12_pin22_config);
const port_pin_config_t port2_13_pin23_config = {/* Internal pull-up/down resistor is disabled */
kPORT_PullDisable,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPSPI1_SDO */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT2_13 (pin 23) is configured as LPSPI1_SDO */
PORT_SetPinConfig(PORT2, 13U, &port2_13_pin23_config);
const port_pin_config_t port2_16_pin24_config = {/* Internal pull-up/down resistor is disabled */
kPORT_PullDisable,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPSPI1_SDI */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT2_16 (pin 24) is configured as LPSPI1_SDI */
PORT_SetPinConfig(PORT2, 16U, &port2_16_pin24_config);
const port_pin_config_t port2_6_pin20_config = {/* Internal pull-up/down resistor is disabled */
kPORT_PullDisable,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPSPI1_PCS1 */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT2_6 (pin 20) is configured as LPSPI1_PCS1 */
PORT_SetPinConfig(PORT2, 6U, &port2_6_pin20_config);
#endif
#ifdef BSP_USING_I2C0 #ifdef BSP_USING_I2C0
const port_pin_config_t port3_27_pin34_config = {/* Internal pull-up resistor is enabled */ const port_pin_config_t port3_27_pin34_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp, kPORT_PullUp,