[bsp][Infineon]Fix drv_gpio and spi problem
This commit is contained in:
parent
7a4f9d0ada
commit
a0a3b3cf87
@ -19,6 +19,8 @@
|
||||
|
||||
#define PIN_IFXPORT_MAX __IFX_PORT_MAX
|
||||
|
||||
static cyhal_gpio_callback_data_t irq_cb_data[PIN_IFXPORT_MAX];
|
||||
|
||||
static const struct pin_irq_map pin_irq_map[] =
|
||||
{
|
||||
{CYHAL_PORT_0, ioss_interrupts_gpio_0_IRQn},
|
||||
@ -66,6 +68,8 @@ static struct rt_pin_irq_hdr pin_irq_handler_tab[] =
|
||||
|
||||
rt_inline void pin_irq_handler(int irqno)
|
||||
{
|
||||
Cy_GPIO_ClearInterrupt(CYHAL_GET_PORTADDR(irqno), CYHAL_GET_PIN(irqno));
|
||||
|
||||
if (pin_irq_handler_tab[irqno].hdr)
|
||||
{
|
||||
pin_irq_handler_tab[irqno].hdr(pin_irq_handler_tab[irqno].args);
|
||||
@ -93,8 +97,6 @@ static void irq_callback(void *callback_arg, cyhal_gpio_event_t event)
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
cyhal_gpio_callback_data_t irq_cb_data;
|
||||
|
||||
static void ifx_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode)
|
||||
{
|
||||
rt_uint16_t gpio_pin;
|
||||
@ -247,7 +249,6 @@ static rt_err_t ifx_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
rt_uint16_t gpio_pin;
|
||||
rt_base_t level;
|
||||
rt_uint8_t pin_irq_mode;
|
||||
|
||||
const struct pin_irq_map *irqmap;
|
||||
|
||||
if (PORT_GET(pin) < PIN_IFXPORT_MAX)
|
||||
@ -272,10 +273,13 @@ static rt_err_t ifx_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
|
||||
irqmap = &pin_irq_map[gpio_port];
|
||||
|
||||
irq_cb_data.callback = irq_callback;
|
||||
irq_cb_data.callback_arg = (rt_uint16_t *)&pin_irq_map[gpio_port].port;
|
||||
#if !defined(COMPONENT_CAT1C)
|
||||
IRQn_Type irqn = (IRQn_Type)(irqmap->irqno + PORT_GET(irqmap->port));
|
||||
#endif
|
||||
irq_cb_data[irqn].callback = irq_callback;
|
||||
irq_cb_data[irqn].callback_arg = (rt_uint16_t *)&pin_irq_map[gpio_port].port;
|
||||
|
||||
cyhal_gpio_register_callback(gpio_pin, &irq_cb_data);
|
||||
cyhal_gpio_register_callback(gpio_pin, &irq_cb_data[irqn]);
|
||||
|
||||
Cy_GPIO_ClearInterrupt(CYHAL_GET_PORTADDR(gpio_pin), CYHAL_GET_PIN(gpio_pin));
|
||||
|
||||
|
@ -93,30 +93,35 @@ static void ifx_spi_init(struct ifx_spi *spi_device)
|
||||
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
result = cyhal_spi_init(spi_device->spi_handle_t->spi_obj, spi_device->spi_handle_t->mosi_pin, spi_device->spi_handle_t->miso_pin,
|
||||
spi_device->spi_handle_t->sck_pin, NC, NULL, spi_device->spi_handle_t->spi_obj->data_bits,
|
||||
spi_device->spi_handle_t->spi_obj->mode, false);
|
||||
static uint8_t init_flag = 1;
|
||||
|
||||
if (result != RT_EOK)
|
||||
if (init_flag)
|
||||
{
|
||||
LOG_E("spi%s init fail", spi_device->spi_handle_t->bus_name);
|
||||
return;
|
||||
result = cyhal_spi_init(spi_device->spi_handle_t->spi_obj, spi_device->spi_handle_t->mosi_pin, spi_device->spi_handle_t->miso_pin,
|
||||
spi_device->spi_handle_t->sck_pin, NC, NULL, spi_device->spi_handle_t->spi_obj->data_bits,
|
||||
spi_device->spi_handle_t->spi_obj->mode, false);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("spi%s init fail", spi_device->spi_handle_t->bus_name);
|
||||
return;
|
||||
}
|
||||
|
||||
result = cyhal_spi_set_frequency(spi_device->spi_handle_t->spi_obj, spi_device->spi_handle_t->freq);
|
||||
if (result == CYHAL_SPI_RSLT_CLOCK_ERROR)
|
||||
{
|
||||
LOG_E("%s set frequency fail", spi_device->spi_handle_t->bus_name);
|
||||
return;
|
||||
}
|
||||
LOG_I("[%s] freq:[%d]HZ\n", spi_device->spi_handle_t->bus_name, spi_device->spi_handle_t->freq);
|
||||
|
||||
/* Register a callback function to be called when the interrupt fires */
|
||||
cyhal_spi_register_callback(spi_device->spi_handle_t->spi_obj, spi_interrupt_callback, spi_device);
|
||||
|
||||
/* Enable the events that will trigger the call back function */
|
||||
cyhal_spi_enable_event(spi_device->spi_handle_t->spi_obj, CYHAL_SPI_IRQ_DONE, 4, true);
|
||||
}
|
||||
|
||||
LOG_I("[%s] freq:[%d]HZ\n", spi_device->spi_handle_t->bus_name, spi_device->spi_handle_t->freq);
|
||||
|
||||
result = cyhal_spi_set_frequency(spi_device->spi_handle_t->spi_obj, spi_device->spi_handle_t->freq);
|
||||
if (result == CYHAL_SPI_RSLT_CLOCK_ERROR)
|
||||
{
|
||||
LOG_E("%s set frequency fail", spi_device->spi_handle_t->bus_name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Register a callback function to be called when the interrupt fires */
|
||||
cyhal_spi_register_callback(spi_device->spi_handle_t->spi_obj, spi_interrupt_callback, spi_device);
|
||||
|
||||
/* Enable the events that will trigger the call back function */
|
||||
cyhal_spi_enable_event(spi_device->spi_handle_t->spi_obj, CYHAL_SPI_IRQ_DONE, 4, true);
|
||||
init_flag = 0;
|
||||
}
|
||||
|
||||
static rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
|
@ -14,84 +14,6 @@ menu "Onboard Peripheral Drivers"
|
||||
select BSP_USING_UART
|
||||
select BSP_USING_UART6
|
||||
default y
|
||||
|
||||
menuconfig BSP_USING_SDMMC
|
||||
bool "Enable SDMMC (sd card)"
|
||||
default n
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
if BSP_USING_SDMMC
|
||||
menuconfig BSP_USING_SDCARD
|
||||
bool "Enable SDCARD (sd card)"
|
||||
select BSP_USING_SDCARD_PIN_CONFIG
|
||||
default n
|
||||
if BSP_USING_SDCARD
|
||||
config BSP_USING_SDCARD_EMMC_ENANBLE
|
||||
bool "Enable SDCARD emmc"
|
||||
default false
|
||||
config BSP_USING_SDCARD_BUS_WIDTH
|
||||
int "Enable SDCARD bus width"
|
||||
default 4
|
||||
config BSP_USING_SDCARD_LED_CTRL_ENANBLE
|
||||
bool "Enable SDCARD led control"
|
||||
default false
|
||||
menuconfig BSP_USING_SDCARD_PIN_CONFIG
|
||||
bool "Enable SDCARD pin config"
|
||||
default y
|
||||
if BSP_USING_SDCARD_PIN_CONFIG
|
||||
config BSP_USING_SDCARD_CMD_PIN
|
||||
int "Enable SDCARD cmd pin,default:P2_4 --> 20"
|
||||
default 20
|
||||
config BSP_USING_SDCARD_CLK_PIN
|
||||
int "Enable SDCARD clk pin,default:P2_5 --> 21"
|
||||
default 21
|
||||
config BSP_USING_SDCARD_DAT0_PIN
|
||||
int "Enable SDCARD dat0 pin,default:P2_0 --> 16"
|
||||
default 16
|
||||
config BSP_USING_SDCARD_DAT1_PIN
|
||||
int "Enable SDCARD dat1 pin,default:P2_1 --> 17"
|
||||
default 17
|
||||
config BSP_USING_SDCARD_DAT2_PIN
|
||||
int "Enable SDCARD dat2 pin,default:P2_2 --> 18"
|
||||
default 18
|
||||
config BSP_USING_SDCARD_DAT3_PIN
|
||||
int "Enable SDCARD dat3 pin,default:P2_3 --> 19"
|
||||
default 19
|
||||
config BSP_USING_SDCARD_DAT4_PIN
|
||||
int "Enable SDCARD dat4 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT5_PIN
|
||||
int "Enable SDCARD dat5 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT6_PIN
|
||||
int "Enable SDCARD dat6 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT7_PIN
|
||||
int "Enable SDCARD dat7 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DETECT_PIN
|
||||
int "Enable SDCARD detect pin,default:P2_6 --> 22"
|
||||
default 22
|
||||
config BSP_USING_SDCARD_IO_VOLT_SEL_PIN
|
||||
int "Enable SDCARD io volt sel pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_CARD_IF_PWR_EN_PIN
|
||||
int "Enable SDCARD card if pwr en pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_CARD_MECH_WRITE_PROT_PIN
|
||||
int "Enable SDCARD card mech write prot pin,default:NC"
|
||||
default -1
|
||||
if BSP_USING_SDCARD_LED_CTRL_ENANBLE
|
||||
config BSP_USING_SDCARD_LED_CTRL_PIN
|
||||
int "Enable SDCARD led ctrl pin,default:NC"
|
||||
default -1
|
||||
endif
|
||||
config BSP_USING_SDCARD_CARD_EMMC_RESET_PIN
|
||||
int "Enable SDCARD card emmc reset pin,default:NC"
|
||||
default -1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endmenu
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
@ -213,18 +135,6 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
config BSP_USING_SDMMC
|
||||
bool "Enable SDMMC (sd card)"
|
||||
default n
|
||||
select RT_USING_SDIO
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
if BSP_USING_SDMMC
|
||||
config BSP_USING_SDIO1
|
||||
bool "Enable SDIO1 (sd card)"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_HW_I2C
|
||||
bool "Enable Hardware I2C Bus"
|
||||
default n
|
||||
@ -336,6 +246,95 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SDMMC
|
||||
bool "Enable SDMMC (sd card)"
|
||||
default n
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
if BSP_USING_SDMMC
|
||||
menuconfig BSP_USING_SDCARD
|
||||
bool "Enable SDCARD (sd card)"
|
||||
select BSP_USING_SDCARD_PIN_CONFIG
|
||||
default n
|
||||
if BSP_USING_SDCARD
|
||||
config BSP_USING_SDCARD_EMMC_ENANBLE
|
||||
bool "Enable SDCARD emmc"
|
||||
default false
|
||||
config BSP_USING_SDCARD_BUS_WIDTH
|
||||
int "Enable SDCARD bus width"
|
||||
default 4
|
||||
config BSP_USING_SDCARD_LED_CTRL_ENANBLE
|
||||
bool "Enable SDCARD led control"
|
||||
default false
|
||||
menuconfig BSP_USING_SDCARD_PIN_CONFIG
|
||||
bool "Enable SDCARD pin config"
|
||||
default y
|
||||
if BSP_USING_SDCARD_PIN_CONFIG
|
||||
config BSP_USING_SDCARD_CMD_PIN
|
||||
int "Enable SDCARD cmd pin,default:P2_4 --> 20"
|
||||
default 20
|
||||
config BSP_USING_SDCARD_CLK_PIN
|
||||
int "Enable SDCARD clk pin,default:P2_5 --> 21"
|
||||
default 21
|
||||
config BSP_USING_SDCARD_DAT0_PIN
|
||||
int "Enable SDCARD dat0 pin,default:P2_0 --> 16"
|
||||
default 16
|
||||
config BSP_USING_SDCARD_DAT1_PIN
|
||||
int "Enable SDCARD dat1 pin,default:P2_1 --> 17"
|
||||
default 17
|
||||
config BSP_USING_SDCARD_DAT2_PIN
|
||||
int "Enable SDCARD dat2 pin,default:P2_2 --> 18"
|
||||
default 18
|
||||
config BSP_USING_SDCARD_DAT3_PIN
|
||||
int "Enable SDCARD dat3 pin,default:P2_3 --> 19"
|
||||
default 19
|
||||
config BSP_USING_SDCARD_DAT4_PIN
|
||||
int "Enable SDCARD dat4 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT5_PIN
|
||||
int "Enable SDCARD dat5 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT6_PIN
|
||||
int "Enable SDCARD dat6 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DAT7_PIN
|
||||
int "Enable SDCARD dat7 pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_DETECT_PIN
|
||||
int "Enable SDCARD detect pin,default:P2_6 --> 22"
|
||||
default 22
|
||||
config BSP_USING_SDCARD_IO_VOLT_SEL_PIN
|
||||
int "Enable SDCARD io volt sel pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_CARD_IF_PWR_EN_PIN
|
||||
int "Enable SDCARD card if pwr en pin,default:NC"
|
||||
default -1
|
||||
config BSP_USING_SDCARD_CARD_MECH_WRITE_PROT_PIN
|
||||
int "Enable SDCARD card mech write prot pin,default:NC"
|
||||
default -1
|
||||
if BSP_USING_SDCARD_LED_CTRL_ENANBLE
|
||||
config BSP_USING_SDCARD_LED_CTRL_PIN
|
||||
int "Enable SDCARD led ctrl pin,default:NC"
|
||||
default -1
|
||||
endif
|
||||
config BSP_USING_SDCARD_CARD_EMMC_RESET_PIN
|
||||
int "Enable SDCARD card emmc reset pin,default:NC"
|
||||
default -1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_FS
|
||||
bool "Enable filesystem"
|
||||
default n
|
||||
if BSP_USING_FS
|
||||
config BSP_USING_SDCARD_FS
|
||||
bool "Enable SDCARD filesystem"
|
||||
select BSP_USING_SDHI
|
||||
select RT_USING_DFS_ELMFAT
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_LVGL
|
||||
bool "Enable LVGL for LCD"
|
||||
select PKG_USING_LVGL
|
||||
|
Loading…
x
Reference in New Issue
Block a user