mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-07 09:52:08 +08:00
bsp: nxp/mcx/mcxa/frdm-mcxa156: Enable SPI driver support.
Some checks failed
pkgs_test / change (push) Has been skipped
ToolsCI / Tools (push) Has been cancelled
AutoTestCI / components/cpp11 (push) Has been cancelled
AutoTestCI / kernel/atomic (push) Has been cancelled
AutoTestCI / kernel/atomic/riscv64 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11/riscv64 (push) Has been cancelled
AutoTestCI / kernel/device (push) Has been cancelled
AutoTestCI / kernel/ipc (push) Has been cancelled
AutoTestCI / kernel/irq (push) Has been cancelled
AutoTestCI / kernel/mem (push) Has been cancelled
AutoTestCI / kernel/mem/riscv64 (push) Has been cancelled
AutoTestCI / kernel/thread (push) Has been cancelled
AutoTestCI / kernel/timer (push) Has been cancelled
AutoTestCI / rtsmart/aarch64 (push) Has been cancelled
AutoTestCI / rtsmart/arm (push) Has been cancelled
AutoTestCI / rtsmart/riscv64 (push) Has been cancelled
AutoTestCI / components/utest (push) Has been cancelled
RT-Thread BSP Static Build Check / ESP32C3 (push) Has been cancelled
RT-Thread BSP Static Build Check / Infineon_TI_microchip (push) Has been cancelled
RT-Thread BSP Static Build Check / RT-Thread Online Packages (STM32F407 RT-Spark) (push) Has been cancelled
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (Raspberry Pico) (push) Has been cancelled
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (STM32F412 Nucleo) (push) Has been cancelled
RT-Thread BSP Static Build Check / aarch64 (push) Has been cancelled
RT-Thread BSP Static Build Check / gd32_n32_apm32 (push) Has been cancelled
RT-Thread BSP Static Build Check / hpmicro (push) Has been cancelled
RT-Thread BSP Static Build Check / i386-unknown (push) Has been cancelled
RT-Thread BSP Static Build Check / llvm-arm (push) Has been cancelled
RT-Thread BSP Static Build Check / mips (push) Has been cancelled
RT-Thread BSP Static Build Check / nordic(yml) (push) Has been cancelled
RT-Thread BSP Static Build Check / nuvoton (push) Has been cancelled
RT-Thread BSP Static Build Check / nxp_renesas (push) Has been cancelled
RT-Thread BSP Static Build Check / others_at32_hc32_ht32 (push) Has been cancelled
RT-Thread BSP Static Build Check / riscv-none (push) Has been cancelled
RT-Thread BSP Static Build Check / riscv64-unknown (push) Has been cancelled
RT-Thread BSP Static Build Check / simulator (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32_f2_f4 (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32_f7_g0_h7_mp15_u5_h5_wb5 (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32l4_f0_f1 (push) Has been cancelled
BSP compilation with more drivers / BSP Compilation with More Drivers (push) Has been cancelled
Some checks failed
pkgs_test / change (push) Has been skipped
ToolsCI / Tools (push) Has been cancelled
AutoTestCI / components/cpp11 (push) Has been cancelled
AutoTestCI / kernel/atomic (push) Has been cancelled
AutoTestCI / kernel/atomic/riscv64 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11/riscv64 (push) Has been cancelled
AutoTestCI / kernel/device (push) Has been cancelled
AutoTestCI / kernel/ipc (push) Has been cancelled
AutoTestCI / kernel/irq (push) Has been cancelled
AutoTestCI / kernel/mem (push) Has been cancelled
AutoTestCI / kernel/mem/riscv64 (push) Has been cancelled
AutoTestCI / kernel/thread (push) Has been cancelled
AutoTestCI / kernel/timer (push) Has been cancelled
AutoTestCI / rtsmart/aarch64 (push) Has been cancelled
AutoTestCI / rtsmart/arm (push) Has been cancelled
AutoTestCI / rtsmart/riscv64 (push) Has been cancelled
AutoTestCI / components/utest (push) Has been cancelled
RT-Thread BSP Static Build Check / ESP32C3 (push) Has been cancelled
RT-Thread BSP Static Build Check / Infineon_TI_microchip (push) Has been cancelled
RT-Thread BSP Static Build Check / RT-Thread Online Packages (STM32F407 RT-Spark) (push) Has been cancelled
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (Raspberry Pico) (push) Has been cancelled
RT-Thread BSP Static Build Check / RTduino/Arduino Libraries (STM32F412 Nucleo) (push) Has been cancelled
RT-Thread BSP Static Build Check / aarch64 (push) Has been cancelled
RT-Thread BSP Static Build Check / gd32_n32_apm32 (push) Has been cancelled
RT-Thread BSP Static Build Check / hpmicro (push) Has been cancelled
RT-Thread BSP Static Build Check / i386-unknown (push) Has been cancelled
RT-Thread BSP Static Build Check / llvm-arm (push) Has been cancelled
RT-Thread BSP Static Build Check / mips (push) Has been cancelled
RT-Thread BSP Static Build Check / nordic(yml) (push) Has been cancelled
RT-Thread BSP Static Build Check / nuvoton (push) Has been cancelled
RT-Thread BSP Static Build Check / nxp_renesas (push) Has been cancelled
RT-Thread BSP Static Build Check / others_at32_hc32_ht32 (push) Has been cancelled
RT-Thread BSP Static Build Check / riscv-none (push) Has been cancelled
RT-Thread BSP Static Build Check / riscv64-unknown (push) Has been cancelled
RT-Thread BSP Static Build Check / simulator (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32_f2_f4 (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32_f7_g0_h7_mp15_u5_h5_wb5 (push) Has been cancelled
RT-Thread BSP Static Build Check / stm32l4_f0_f1 (push) Has been cancelled
BSP compilation with more drivers / BSP Compilation with More Drivers (push) Has been cancelled
This patch: * Enables SPI support * Adds RW001 driver example * Increases heap size to 32kB. Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
@@ -39,6 +39,8 @@ src += ['MCXA156/drivers/fsl_lpi2c_edma.c']
|
||||
src += ['MCXA156/drivers/fsl_lptmr.c']
|
||||
src += ['MCXA156/drivers/fsl_lpuart.c']
|
||||
src += ['MCXA156/drivers/fsl_lpuart_edma.c']
|
||||
src += ['MCXA156/drivers/fsl_lpspi.c']
|
||||
src += ['MCXA156/drivers/fsl_lpspi_edma.c']
|
||||
src += ['MCXA156/drivers/fsl_ostimer.c']
|
||||
src += ['MCXA156/drivers/fsl_pwm.c']
|
||||
src += ['MCXA156/drivers/fsl_reset.c']
|
||||
|
||||
@@ -55,13 +55,9 @@ menu "On-chip Peripheral Drivers"
|
||||
default y
|
||||
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI3
|
||||
bool "Enable Flexcomm3 as SPI"
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable LPSPI1"
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI8
|
||||
bool "Enable Flexcomm8 as High Speed SPI"
|
||||
default y
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ADC
|
||||
@@ -167,7 +163,32 @@ endmenu
|
||||
|
||||
|
||||
menu "Board extended module Drivers"
|
||||
menuconfig BSP_USING_RW007
|
||||
bool "Enable RW007"
|
||||
default n
|
||||
select BSP_USING_SPI
|
||||
select BSP_USING_SPI1
|
||||
select PKG_USING_RW007
|
||||
select RT_USING_MEMPOOL
|
||||
select RW007_NOT_USE_EXAMPLE_DRIVERS
|
||||
|
||||
if BSP_USING_RW007
|
||||
config BOARD_RW007_SPI_BUS_NAME
|
||||
string "RW007 BUS NAME"
|
||||
default "spi1"
|
||||
|
||||
config BOARD_RW007_CS_PIN
|
||||
hex "CS pin index"
|
||||
default 0x46
|
||||
|
||||
config BOARD_RW007_INT_BUSY_PIN
|
||||
hex "INT/BUSY pin index"
|
||||
default 0x71
|
||||
|
||||
config BOARD_RW007_RST_PIN
|
||||
hex "RESET pin index"
|
||||
default 0x2F
|
||||
endif
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -52,6 +52,19 @@ extern uint32_t SystemCoreClock;
|
||||
void BOARD_InitBootClocks(void)
|
||||
{
|
||||
BOARD_BootClockFRO96M();
|
||||
|
||||
CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 2U);
|
||||
|
||||
CLOCK_EnableClock(kCLOCK_GateLPSPI0);
|
||||
CLOCK_EnableClock(kCLOCK_GateLPSPI1);
|
||||
CLOCK_EnableClock(kCLOCK_GateDMA);
|
||||
|
||||
CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0);
|
||||
CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1);
|
||||
|
||||
RESET_ReleasePeripheralReset(kLPSPI0_RST_SHIFT_RSTn);
|
||||
RESET_ReleasePeripheralReset(kLPSPI1_RST_SHIFT_RSTn);
|
||||
RESET_ReleasePeripheralReset(kDMA_RST_SHIFT_RSTn);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -22,6 +22,8 @@ processor_version: 0.15.0
|
||||
*/
|
||||
/* clang-format on */
|
||||
|
||||
#include "rtconfig.h"
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_port.h"
|
||||
#include "pin_mux.h"
|
||||
@@ -159,6 +161,109 @@ void BOARD_InitPins(void)
|
||||
kPORT_UnlockRegister};
|
||||
/* PORT3_12 (pin 63) is configured as LED_RED */
|
||||
PORT_SetPinConfig(PORT3, 12U, &port3_12_pin63_config);
|
||||
|
||||
#ifdef BSP_USING_SPI1
|
||||
const port_pin_config_t port2_12_pin34_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 34) is configured as LPSPI1_SCK */
|
||||
PORT_SetPinConfig(PORT2, 12U, &port2_12_pin34_config);
|
||||
|
||||
const port_pin_config_t port2_13_pin35_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 35) is configured as LPSPI1_SDO */
|
||||
PORT_SetPinConfig(PORT2, 13U, &port2_13_pin35_config);
|
||||
|
||||
const port_pin_config_t port2_16_pin37_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 37) is configured as LPSPI1_SDI */
|
||||
PORT_SetPinConfig(PORT2, 16U, &port2_16_pin37_config);
|
||||
|
||||
const port_pin_config_t port2_6_pin28_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_MuxAsGpio,
|
||||
/* 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_pin28_config);
|
||||
#endif
|
||||
|
||||
}
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
|
||||
@@ -9,6 +9,9 @@ MCUX_Config/board/clock_config.c
|
||||
MCUX_Config/board/pin_mux.c
|
||||
""")
|
||||
|
||||
if GetDepend(['BSP_USING_RW007']):
|
||||
src += Glob('ports/drv_spi_sample_rw007.c')
|
||||
|
||||
CPPPATH = [cwd, cwd + '/MCUX_Config/board']
|
||||
CPPDEFINES = ['DEBUG', 'CPU_MCXA156VLL']
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef BSP_USING_RW007
|
||||
#include <rtdbg.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include <spi_wifi_rw007.h>
|
||||
|
||||
#define BOARD_RW007_DEVICE_NAME "rw007"
|
||||
|
||||
extern void spi_wifi_isr(int vector);
|
||||
|
||||
static void rw007_gpio_init(void)
|
||||
{
|
||||
/* Configure IO */
|
||||
rt_pin_mode(BOARD_RW007_RST_PIN, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(BOARD_RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLDOWN);
|
||||
|
||||
/* Reset rw007 and config mode */
|
||||
rt_pin_write(BOARD_RW007_RST_PIN, PIN_LOW);
|
||||
|
||||
rt_thread_delay(rt_tick_from_millisecond(100));
|
||||
rt_pin_write(BOARD_RW007_RST_PIN, PIN_HIGH);
|
||||
|
||||
/* Wait rw007 ready(exit busy stat) */
|
||||
while (!rt_pin_read(BOARD_RW007_INT_BUSY_PIN))
|
||||
{
|
||||
rt_thread_delay(5);
|
||||
}
|
||||
|
||||
rt_thread_delay(rt_tick_from_millisecond(200));
|
||||
rt_pin_mode(BOARD_RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLUP);
|
||||
}
|
||||
|
||||
int wifi_spi_device_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char sn_version[32];
|
||||
|
||||
struct rt_spi_device *spi_device = rt_malloc(sizeof(struct rt_spi_device));
|
||||
if (!spi_device) return -1;
|
||||
|
||||
rw007_gpio_init();
|
||||
ret = rt_spi_bus_attach_device_cspin(spi_device, BOARD_RW007_DEVICE_NAME, BOARD_RW007_SPI_BUS_NAME, BOARD_RW007_CS_PIN, RT_NULL);
|
||||
if (ret != RT_EOK) return -2;
|
||||
|
||||
rt_hw_wifi_init("rw007");
|
||||
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
|
||||
rw007_sn_get(sn_version);
|
||||
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
|
||||
rw007_version_get(sn_version);
|
||||
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(wifi_spi_device_init);
|
||||
|
||||
static void int_wifi_irq(void *p)
|
||||
{
|
||||
((void)p);
|
||||
spi_wifi_isr(0);
|
||||
}
|
||||
|
||||
void spi_wifi_hw_init(void)
|
||||
{
|
||||
rt_pin_attach_irq(BOARD_RW007_INT_BUSY_PIN, PIN_IRQ_MODE_FALLING, int_wifi_irq, 0);
|
||||
rt_pin_irq_enable(BOARD_RW007_INT_BUSY_PIN, RT_TRUE);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -47,7 +47,7 @@ if PLATFORM == 'gcc':
|
||||
DEVICE = ' -mcpu=' + CPU + ' -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
|
||||
CFLAGS = DEVICE + ' -Wall -D__FPU_PRESENT'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__START=entry -D__STARTUP_CLEAR_BSS'
|
||||
LFLAGS = DEVICE + ' -specs=nano.specs -specs=nosys.specs -Wl,--defsym=__heap_size__=0x2000,--gc-sections,-Map=rtthread.map,--print-memory-usage -Tboard/linker_scripts/MCXA156_flash.ld'
|
||||
LFLAGS = DEVICE + ' -specs=nano.specs -specs=nosys.specs -Wl,--defsym=__heap_size__=0x8000,--gc-sections,-Map=rtthread.map,--print-memory-usage -Tboard/linker_scripts/MCXA156_flash.ld'
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
Reference in New Issue
Block a user