rt-thread/bsp/hc32/libraries/hc32_drivers/drv_spi.h

70 lines
1.4 KiB
C
Raw Normal View History

/*
2024-01-09 21:56:37 +08:00
* Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-04-28 CDT first version
*/
#ifndef __DRV_SPI_H__
#define __DRV_SPI_H__
/*******************************************************************************
* Include files
******************************************************************************/
#include <rtthread.h>
#include "rtdevice.h"
#include "drv_dma.h"
#include "drv_irq.h"
#ifdef __cplusplus
extern "C" {
#endif
struct hc32_hw_spi_cs
{
rt_uint8_t port;
rt_uint16_t pin;
};
2024-01-09 21:56:37 +08:00
struct hc32_spi_irq_config
{
struct hc32_irq_config irq_config;
func_ptr_t irq_callback;
};
struct hc32_spi_config
{
2024-01-09 21:56:37 +08:00
CM_SPI_TypeDef *Instance;
char *bus_name;
rt_uint32_t clock;
rt_uint32_t timeout;
struct hc32_spi_irq_config err_irq;
#ifdef BSP_SPI_USING_DMA
struct dma_config *dma_rx;
struct dma_config *dma_tx;
#endif
};
struct hc32_spi
{
struct hc32_spi_config *config;
struct rt_spi_configuration *cfg;
struct rt_spi_bus spi_bus;
2024-01-09 21:56:37 +08:00
rt_uint16_t spi_dma_flag;
};
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, uint8_t cs_gpio_port, uint16_t cs_gpio_pin);
#ifdef __cplusplus
}
#endif
#endif /* __DRV_SPI_H__ */