2022-03-23 14:16:14 +08:00
|
|
|
/*
|
2023-04-18 10:26:23 +08:00
|
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
2022-03-23 14:16:14 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2022-03-25 23:06:43 +08:00
|
|
|
* 2021-10-11 kyle first version
|
2022-06-16 10:54:30 +08:00
|
|
|
* 2022-6-14 solar Remove the const attribute of private data in ops
|
2022-03-23 14:16:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SPI_BIT_OPS_H__
|
|
|
|
#define __SPI_BIT_OPS_H__
|
|
|
|
|
|
|
|
#include <rtdevice.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rt_spi_bit_ops
|
|
|
|
{
|
2022-06-16 10:54:30 +08:00
|
|
|
void *data; /* private data for lowlevel routines */
|
2024-04-10 06:33:29 +08:00
|
|
|
void (*const pin_init)(void);
|
2022-03-23 14:16:14 +08:00
|
|
|
void (*const tog_sclk)(void *data);
|
|
|
|
void (*const set_sclk)(void *data, rt_int32_t state);
|
|
|
|
void (*const set_mosi)(void *data, rt_int32_t state);
|
|
|
|
void (*const set_miso)(void *data, rt_int32_t state);
|
|
|
|
rt_int32_t (*const get_sclk)(void *data);
|
|
|
|
rt_int32_t (*const get_mosi)(void *data);
|
|
|
|
rt_int32_t (*const get_miso)(void *data);
|
|
|
|
|
|
|
|
void (*const dir_mosi)(void *data, rt_int32_t state);
|
|
|
|
void (*const dir_miso)(void *data, rt_int32_t state);
|
|
|
|
|
|
|
|
void (*const udelay)(rt_uint32_t us);
|
2022-03-24 08:30:41 +08:00
|
|
|
rt_uint32_t delay_us; /* sclk, mosi and miso line delay */
|
2022-03-23 14:16:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rt_spi_bit_obj
|
|
|
|
{
|
|
|
|
struct rt_spi_bus bus;
|
|
|
|
struct rt_spi_bit_ops *ops;
|
|
|
|
struct rt_spi_configuration config;
|
|
|
|
};
|
|
|
|
|
2022-03-24 08:30:41 +08:00
|
|
|
rt_err_t rt_spi_bit_add_bus(struct rt_spi_bit_obj *obj,
|
2022-03-23 14:16:14 +08:00
|
|
|
const char *bus_name,
|
|
|
|
struct rt_spi_bit_ops *ops);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|