Selaa lähdekoodia

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

下里巴人 11 kuukautta sitten
vanhempi
commit
9e690694c7

+ 18 - 1
bsp/nxp/mcx/mcxa/Libraries/drivers/drv_spi.c

@@ -17,7 +17,10 @@
 enum
 {
 #ifdef BSP_USING_SPI0
-    SPI0_INDEX
+    SPI0_INDEX,
+#endif
+#ifdef BSP_USING_SPI1
+    SPI1_INDEX,
 #endif
 };
 
@@ -58,6 +61,20 @@ static struct lpc_spi lpc_obj[] =
         .name = "spi0",
     },
 #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)

+ 4 - 0
bsp/nxp/mcx/mcxa/frdm-mcxa153/board/Kconfig

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

+ 103 - 0
bsp/nxp/mcx/mcxa/frdm-mcxa153/board/MCUX_Config/board/pin_mux.c

@@ -53,6 +53,7 @@ void BOARD_InitPins(void)
 
     RESET_ReleasePeripheralReset(kCTIMER1_RST_SHIFT_RSTn);
     RESET_ReleasePeripheralReset(kLPSPI0_RST_SHIFT_RSTn);
+    RESET_ReleasePeripheralReset(kLPSPI1_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);
 #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
     const port_pin_config_t port3_27_pin34_config = {/* Internal pull-up resistor is enabled */
                                                      kPORT_PullUp,