blob: 6cca0755c70b3eeb1f099fcf66f0df2b1a59c6b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-12-20 BruceOu first implementation
*/
#ifndef __DRV_SPI_H__
#define __DRV_SPI_H__
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#ifdef __cplusplus
extern "C" {
#endif
struct gd32_spi_cs
{
uint32_t GPIOx;
uint32_t GPIO_Pin;
};
/* gd32 spi dirver class */
struct gd32_spi
{
uint32_t spi_periph;
char *bus_name;
rcu_periph_enum spi_clk;
rcu_periph_enum sck_gpio_clk;
rcu_periph_enum miso_gpio_clk;
rcu_periph_enum mosi_gpio_clk;
struct rt_spi_bus *spi_bus;
uint32_t sck_spi_port;
uint32_t miso_spi_port;
uint32_t mosi_spi_port;
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x || defined SOC_SERIES_GD32H7xx || defined SOC_SERIES_GD32F5xx
uint32_t alt_func_num;
#endif
uint16_t sck_pin;
uint16_t miso_pin;
uint16_t mosi_pin;
};
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin);
#ifdef __cplusplus
}
#endif
#endif /* __DRV_SPI_H__ */
|