no-OS
tdm.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef TDM_H_
40 #define TDM_H_
41 
42 #include <stdint.h>
43 #include <stdbool.h>
44 
50 struct tdm_platform_ops;
51 
52 enum tdm_mode {
57 };
58 
65  enum tdm_mode mode;
67  uint8_t data_size;
69  uint8_t data_offset;
73  uint8_t slots_per_frame;
79  bool fs_lastbit;
85  void *extra;
86 };
87 
92 struct tdm_desc {
96  void *extra;
97 };
98 
106  int32_t (*tdm_ops_init)(struct tdm_desc **, const struct tdm_init_param *);
108  int32_t (*tdm_ops_read)(struct tdm_desc *, void *, uint16_t);
110  int32_t (*tdm_ops_write)(struct tdm_desc *, void *, uint16_t);
112  int32_t (*tdm_ops_remove)(struct tdm_desc *);
113 };
114 
115 /* Initialize the TDM communication peripheral. */
116 int32_t tdm_init(struct tdm_desc **desc,
117  const struct tdm_init_param *param);
118 
119 /* Free the resources allocated by tdm_init(). */
120 int32_t tdm_remove(struct tdm_desc *desc);
121 
122 /* Read data. */
123 int32_t tdm_read(struct tdm_desc *desc,
124  void *data,
125  uint16_t bytes_number);
126 
127 /* Write data. */
128 int32_t tdm_write(struct tdm_desc *desc,
129  void *data,
130  uint16_t bytes_number);
131 
132 #endif // TDM_H_
tdm_init_param::fs_lastbit
bool fs_lastbit
Definition: tdm.h:79
tdm_desc
Structure holding TDM descriptor.
Definition: tdm.h:92
tdm_init
int32_t tdm_init(struct tdm_desc **desc, const struct tdm_init_param *param)
Initialize the TDM communication peripheral.
Definition: tdm.c:51
tdm_init_param::data_size
uint8_t data_size
Definition: tdm.h:67
tdm_write
int32_t tdm_write(struct tdm_desc *desc, void *data, uint16_t bytes_number)
Write data using the TDM interface.
Definition: tdm.c:96
tdm_init_param::slots_per_frame
uint8_t slots_per_frame
Definition: tdm.h:73
tdm_init_param
Structure holding the parameters for TDM initialization.
Definition: tdm.h:63
TDM_SLAVE_RX
@ TDM_SLAVE_RX
Definition: tdm.h:56
tdm_platform_ops::tdm_ops_read
int32_t(* tdm_ops_read)(struct tdm_desc *, void *, uint16_t)
Definition: tdm.h:108
tdm_init_param::platform_ops
const struct tdm_platform_ops * platform_ops
Definition: tdm.h:83
tdm_desc::extra
void * extra
Definition: tdm.h:96
tdm_read
int32_t tdm_read(struct tdm_desc *desc, void *data, uint16_t bytes_number)
Read data using the TDM interface.
Definition: tdm.c:82
TDM_MASTER_RX
@ TDM_MASTER_RX
Definition: tdm.h:54
tdm_init_param::fs_active_low
bool fs_active_low
Definition: tdm.h:75
tdm_init_param::fs_active_length
uint8_t fs_active_length
Definition: tdm.h:77
tdm_desc::platform_ops
const struct tdm_platform_ops * platform_ops
Definition: tdm.h:94
tdm_remove
int32_t tdm_remove(struct tdm_desc *desc)
Free the resources allocated by tdm_init().
Definition: tdm.c:70
tdm_init_param::mode
enum tdm_mode mode
Definition: tdm.h:65
TDM_MASTER_TX
@ TDM_MASTER_TX
Definition: tdm.h:53
TDM_SLAVE_TX
@ TDM_SLAVE_TX
Definition: tdm.h:55
tdm_init_param::data_lsb_first
bool data_lsb_first
Definition: tdm.h:71
tdm_init_param::extra
void * extra
Definition: tdm.h:85
tdm_platform_ops
Structure holding TDM function pointers that point to the platform specific function.
Definition: tdm.h:104
tdm_platform_ops::tdm_ops_write
int32_t(* tdm_ops_write)(struct tdm_desc *, void *, uint16_t)
Definition: tdm.h:110
tdm_platform_ops::tdm_ops_init
int32_t(* tdm_ops_init)(struct tdm_desc **, const struct tdm_init_param *)
Definition: tdm.h:106
tdm_init_param::data_offset
uint8_t data_offset
Definition: tdm.h:69
tdm_init_param::rising_edge_sampling
bool rising_edge_sampling
Definition: tdm.h:81
tdm_platform_ops::tdm_ops_remove
int32_t(* tdm_ops_remove)(struct tdm_desc *)
Definition: tdm.h:112
tdm_mode
tdm_mode
Definition: tdm.h:52