no-OS
stm32_tdm.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef STM32_TDM_H_
40 #define STM32_TDM_H_
41 
42 #include <stdint.h>
43 #include "no_os_tdm.h"
44 #include "stm32_hal.h"
45 #include "no_os_irq.h"
46 
54  SAI_Block_TypeDef *base;
56  //struct no_os_irq_ctrl_desc *nvic;
57 };
58 
65  SAI_HandleTypeDef hsai;
74 };
75 
80 
81 
82 /* Initialize the TDM communication peripheral. */
83 int32_t stm32_tdm_init(struct no_os_tdm_desc **desc,
84  const struct no_os_tdm_init_param *param);
85 
86 /* Free the resources allocated by stm32_tdm_init(). */
87 int32_t stm32_tdm_remove(struct no_os_tdm_desc *desc);
88 
89 /* Write and read data to/from TDM. */
90 int32_t stm32_tdm_read(struct no_os_tdm_desc *desc, void *data,
91  uint16_t bytes_number);
92 
93 /* Stop TDM DMA Data transfer */
94 int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc);
95 
96 /* Pause TDM DMA Data transfer */
97 int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc);
98 
99 /* Resume TDM DMA Data transfer */
100 int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc);
101 
102 
103 #endif // STM32_TDM_H_
no_os_alloc.h
NO_OS_TDM_MASTER_RX
@ NO_OS_TDM_MASTER_RX
Definition: no_os_tdm.h:54
no_os_tdm_desc::extra
void * extra
Definition: no_os_tdm.h:106
stm32_tdm_init_param::base
SAI_Block_TypeDef * base
Definition: stm32_tdm.h:54
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:148
stm32_tdm_read
int32_t stm32_tdm_read(struct no_os_tdm_desc *desc, void *data, uint16_t nb_samples)
Read data using SAI TDM mode.
Definition: stm32_tdm.c:259
no_os_irq.h
Header file of IRQ interface.
no_os_irq_register_callback
int32_t no_os_irq_register_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: no_os_irq.c:98
no_os_tdm_init_param::fs_active_length
uint8_t fs_active_length
Definition: no_os_tdm.h:77
lf256fifo_init
int lf256fifo_init(struct lf256fifo **)
no_os_tdm_init_param::data_offset
uint8_t data_offset
Definition: no_os_tdm.h:69
stm32_tdm_desc::rx_half_callback
struct no_os_callback_desc rx_half_callback
Definition: stm32_tdm.h:71
stm32_tdm_init_param
Structure holding the initialization parameters for stm32 platform specific TDM parameters.
Definition: stm32_tdm.h:52
stm32_tdm_desc
stm32 platform specific TDM descriptor
Definition: stm32_tdm.h:63
stm32_stop_tdm_transfer
int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc)
Stop SAI DMA transfer.
Definition: stm32_tdm.c:294
no_os_tdm_init_param::fs_lastbit
bool fs_lastbit
Definition: no_os_tdm.h:79
stm32_resume_tdm_transfer
int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc)
Resume SAI DMA transfer.
Definition: stm32_tdm.c:345
no_os_tdm_init_param::rx_half_complete_callback
void(* rx_half_complete_callback)(void *rx_arg)
Definition: no_os_tdm.h:87
stm32_tdm_platform_ops
const struct no_os_tdm_platform_ops stm32_tdm_platform_ops
stm32 specific TDM platform ops structure
Definition: stm32_tdm.c:54
NO_OS_TDM_SLAVE_RX
@ NO_OS_TDM_SLAVE_RX
Definition: no_os_tdm.h:56
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:60
stm32_resume_tdm_transfer
int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc)
Resume SAI DMA transfer.
Definition: stm32_tdm.c:345
no_os_tdm_desc::irq_id
uint32_t irq_id
Definition: no_os_tdm.h:100
NO_OS_TDM_DMA_IRQ
@ NO_OS_TDM_DMA_IRQ
Definition: no_os_irq.h:95
stm32_tdm_platform_ops
const struct no_os_tdm_platform_ops stm32_tdm_platform_ops
stm32 platform specific TDM platform ops structure
Definition: stm32_tdm.c:54
no_os_callback_desc::peripheral
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:156
stm32_tdm_init
int32_t stm32_tdm_init(struct no_os_tdm_desc **desc, const struct no_os_tdm_init_param *param)
Initialize the TDM communication peripheral.
Definition: stm32_tdm.c:69
no_os_tdm_init_param::mode
enum no_os_tdm_mode mode
Definition: no_os_tdm.h:65
no_os_tdm_desc
Structure holding TDM descriptor.
Definition: no_os_tdm.h:98
no_os_tdm_init_param::irq_id
uint32_t irq_id
Definition: no_os_tdm.h:83
no_os_error.h
Error codes definition.
stm32_irq.h
Header file for stm32 irq specifics.
no_os_tdm_init_param::fs_active_low
bool fs_active_low
Definition: no_os_tdm.h:75
no_os_tdm_platform_ops
Structure holding TDM function pointers that point to the platform specific function.
Definition: no_os_tdm.h:114
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:152
stm32_tdm.h
Header file for the stm32 tdm driver.
stm32_tdm_init
int32_t stm32_tdm_init(struct no_os_tdm_desc **desc, const struct no_os_tdm_init_param *param)
Initialize the TDM communication peripheral.
Definition: stm32_tdm.c:69
stm32_tdm_desc::hsai
SAI_HandleTypeDef hsai
Definition: stm32_tdm.h:65
stm32_pause_tdm_transfer
int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc)
Pause SAI DMA transfer.
Definition: stm32_tdm.c:320
no_os_tdm_init_param::data_lsb_first
bool data_lsb_first
Definition: no_os_tdm.h:71
no_os_irq_init_param::platform_ops
const struct no_os_irq_platform_ops * platform_ops
Definition: no_os_irq.h:117
stm32_irq_ops
const struct no_os_irq_platform_ops stm32_irq_ops
stm32 specific IRQ platform ops structure
Definition: stm32_irq.c:588
no_os_irq_ctrl_init
int32_t no_os_irq_ctrl_init(struct no_os_irq_ctrl_desc **desc, const struct no_os_irq_init_param *param)
Initialize the IRQ interrupts.
Definition: no_os_irq.c:51
stm32_tdm_desc::nvic_rx_halfcplt
struct no_os_irq_ctrl_desc * nvic_rx_halfcplt
Definition: stm32_tdm.h:67
NO_OS_TDM_SLAVE_TX
@ NO_OS_TDM_SLAVE_TX
Definition: no_os_tdm.h:55
no_os_tdm_init_param::rx_complete_callback
void(* rx_complete_callback)(void *rx_arg)
Definition: no_os_tdm.h:85
no_os_tdm_init_param::extra
void * extra
Definition: no_os_tdm.h:91
no_os_callback_desc::handle
void * handle
Definition: no_os_irq.h:158
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:150
stm32_tdm_remove
int32_t stm32_tdm_remove(struct no_os_tdm_desc *desc)
Free the resources allocated by stm32_tdm_init().
Definition: stm32_tdm.c:237
NO_OS_TDM_MASTER_TX
@ NO_OS_TDM_MASTER_TX
Definition: no_os_tdm.h:53
stm32_stop_tdm_transfer
int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc)
Stop SAI DMA transfer.
Definition: stm32_tdm.c:294
no_os_callback_desc::event
enum no_os_irq_event event
Definition: no_os_irq.h:154
no_os_tdm_platform_ops::tdm_ops_init
int32_t(* tdm_ops_init)(struct no_os_tdm_desc **, const struct no_os_tdm_init_param *)
Definition: no_os_tdm.h:116
no_os_lf256fifo.h
SPSC lock-free fifo of fixed size (256), specialized for UART.
NO_OS_EVT_DMA_RX_COMPLETE
@ NO_OS_EVT_DMA_RX_COMPLETE
Definition: no_os_irq.h:76
stm32_gpio.h
Header file for stm32 gpio specifics.
stm32_tdm_read
int32_t stm32_tdm_read(struct no_os_tdm_desc *desc, void *data, uint16_t bytes_number)
Read data using SAI TDM mode.
Definition: stm32_tdm.c:259
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
stm32_pause_tdm_transfer
int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc)
Pause SAI DMA transfer.
Definition: stm32_tdm.c:320
stm32_tdm_remove
int32_t stm32_tdm_remove(struct no_os_tdm_desc *desc)
Free the resources allocated by stm32_tdm_init().
Definition: stm32_tdm.c:237
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:113
no_os_tdm_init_param::data_size
uint8_t data_size
Definition: no_os_tdm.h:67
no_os_tdm_init_param
Structure holding the parameters for TDM initialization.
Definition: no_os_tdm.h:63
no_os_tdm_init_param::slots_per_frame
uint8_t slots_per_frame
Definition: no_os_tdm.h:73
no_os_irq_enable
int32_t no_os_irq_enable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: no_os_irq.c:187
no_os_gpio.h
Header file of GPIO Interface.
NO_OS_EVT_DMA_RX_HALF_COMPLETE
@ NO_OS_EVT_DMA_RX_HALF_COMPLETE
Definition: no_os_irq.h:77
stm32_tdm_desc::nvic_rxcplt
struct no_os_irq_ctrl_desc * nvic_rxcplt
Definition: stm32_tdm.h:69
no_os_tdm.h
Header file of TDM Interface.
no_os_irq_ctrl_desc
Definition: no_os_irq.h:129
stm32_tdm_desc::rx_callback
struct no_os_callback_desc rx_callback
Definition: stm32_tdm.h:73
stm32_hal.h
no_os_tdm_init_param::rising_edge_sampling
bool rising_edge_sampling
Definition: no_os_tdm.h:81
no_os_tdm_desc::rx_fifo
struct lf256fifo * rx_fifo
Definition: no_os_tdm.h:104
errno.h
Error macro definition for ARM Compiler.