no-OS
stm32_tdm.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef STM32_TDM_H_
34 #define STM32_TDM_H_
35 
36 #include <stdint.h>
37 #include "no_os_tdm.h"
38 #include "stm32_hal.h"
39 #include "no_os_irq.h"
40 
48  SAI_Block_TypeDef *base;
50  //struct no_os_irq_ctrl_desc *nvic;
51 };
52 
59  SAI_HandleTypeDef hsai;
68 };
69 
74 
75 
76 /* Initialize the TDM communication peripheral. */
77 int32_t stm32_tdm_init(struct no_os_tdm_desc **desc,
78  const struct no_os_tdm_init_param *param);
79 
80 /* Free the resources allocated by stm32_tdm_init(). */
81 int32_t stm32_tdm_remove(struct no_os_tdm_desc *desc);
82 
83 /* Write and read data to/from TDM. */
84 int32_t stm32_tdm_read(struct no_os_tdm_desc *desc, void *data,
85  uint16_t bytes_number);
86 
87 /* Stop TDM DMA Data transfer */
88 int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc);
89 
90 /* Pause TDM DMA Data transfer */
91 int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc);
92 
93 /* Resume TDM DMA Data transfer */
94 int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc);
95 
96 
97 #endif // STM32_TDM_H_
no_os_alloc.h
NO_OS_TDM_MASTER_RX
@ NO_OS_TDM_MASTER_RX
Definition: no_os_tdm.h:48
no_os_tdm_desc::extra
void * extra
Definition: no_os_tdm.h:100
stm32_tdm_init_param::base
SAI_Block_TypeDef * base
Definition: stm32_tdm.h:48
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
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:253
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:92
no_os_tdm_init_param::fs_active_length
uint8_t fs_active_length
Definition: no_os_tdm.h:71
lf256fifo_init
int lf256fifo_init(struct lf256fifo **)
no_os_tdm_init_param::data_offset
uint8_t data_offset
Definition: no_os_tdm.h:63
stm32_tdm_desc::rx_half_callback
struct no_os_callback_desc rx_half_callback
Definition: stm32_tdm.h:65
stm32_tdm_init_param
Structure holding the initialization parameters for stm32 platform specific TDM parameters.
Definition: stm32_tdm.h:46
stm32_tdm_desc
stm32 platform specific TDM descriptor
Definition: stm32_tdm.h:57
stm32_stop_tdm_transfer
int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc)
Stop SAI DMA transfer.
Definition: stm32_tdm.c:288
no_os_tdm_init_param::fs_lastbit
bool fs_lastbit
Definition: no_os_tdm.h:73
stm32_resume_tdm_transfer
int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc)
Resume SAI DMA transfer.
Definition: stm32_tdm.c:339
no_os_tdm_init_param::rx_half_complete_callback
void(* rx_half_complete_callback)(void *rx_arg)
Definition: no_os_tdm.h:81
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:48
NO_OS_TDM_SLAVE_RX
@ NO_OS_TDM_SLAVE_RX
Definition: no_os_tdm.h:50
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:54
stm32_resume_tdm_transfer
int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc)
Resume SAI DMA transfer.
Definition: stm32_tdm.c:339
no_os_tdm_desc::irq_id
uint32_t irq_id
Definition: no_os_tdm.h:94
NO_OS_TDM_DMA_IRQ
@ NO_OS_TDM_DMA_IRQ
Definition: no_os_irq.h:89
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:48
no_os_callback_desc::peripheral
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:150
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:63
no_os_tdm_init_param::mode
enum no_os_tdm_mode mode
Definition: no_os_tdm.h:59
no_os_tdm_desc
Structure holding TDM descriptor.
Definition: no_os_tdm.h:92
no_os_tdm_init_param::irq_id
uint32_t irq_id
Definition: no_os_tdm.h:77
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:69
no_os_tdm_platform_ops
Structure holding TDM function pointers that point to the platform specific function.
Definition: no_os_tdm.h:108
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:146
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:63
stm32_tdm_desc::hsai
SAI_HandleTypeDef hsai
Definition: stm32_tdm.h:59
stm32_pause_tdm_transfer
int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc)
Pause SAI DMA transfer.
Definition: stm32_tdm.c:314
no_os_tdm_init_param::data_lsb_first
bool data_lsb_first
Definition: no_os_tdm.h:65
no_os_irq_init_param::platform_ops
const struct no_os_irq_platform_ops * platform_ops
Definition: no_os_irq.h:111
stm32_irq_ops
const struct no_os_irq_platform_ops stm32_irq_ops
stm32 specific IRQ platform ops structure
Definition: stm32_irq.c:582
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:45
stm32_tdm_desc::nvic_rx_halfcplt
struct no_os_irq_ctrl_desc * nvic_rx_halfcplt
Definition: stm32_tdm.h:61
NO_OS_TDM_SLAVE_TX
@ NO_OS_TDM_SLAVE_TX
Definition: no_os_tdm.h:49
no_os_tdm_init_param::rx_complete_callback
void(* rx_complete_callback)(void *rx_arg)
Definition: no_os_tdm.h:79
no_os_tdm_init_param::extra
void * extra
Definition: no_os_tdm.h:85
no_os_callback_desc::handle
void * handle
Definition: no_os_irq.h:152
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:144
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:231
NO_OS_TDM_MASTER_TX
@ NO_OS_TDM_MASTER_TX
Definition: no_os_tdm.h:47
stm32_stop_tdm_transfer
int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc)
Stop SAI DMA transfer.
Definition: stm32_tdm.c:288
no_os_callback_desc::event
enum no_os_irq_event event
Definition: no_os_irq.h:148
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:110
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:70
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:253
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:69
stm32_pause_tdm_transfer
int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc)
Pause SAI DMA transfer.
Definition: stm32_tdm.c:314
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:231
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:107
no_os_tdm_init_param::data_size
uint8_t data_size
Definition: no_os_tdm.h:61
no_os_tdm_init_param
Structure holding the parameters for TDM initialization.
Definition: no_os_tdm.h:57
no_os_tdm_init_param::slots_per_frame
uint8_t slots_per_frame
Definition: no_os_tdm.h:67
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:181
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:71
stm32_tdm_desc::nvic_rxcplt
struct no_os_irq_ctrl_desc * nvic_rxcplt
Definition: stm32_tdm.h:63
no_os_tdm.h
Header file of TDM Interface.
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
stm32_tdm_desc::rx_callback
struct no_os_callback_desc rx_callback
Definition: stm32_tdm.h:67
stm32_hal.h
no_os_tdm_init_param::rising_edge_sampling
bool rising_edge_sampling
Definition: no_os_tdm.h:75
no_os_tdm_desc::rx_fifo
struct lf256fifo * rx_fifo
Definition: no_os_tdm.h:98
errno.h
Error macro definition for ARM Compiler.