no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
stm32_tdm.c File Reference

Implementation of TDM driver using STM32's SAI peripheral. More...

#include <stdlib.h>
#include <errno.h>
#include "no_os_gpio.h"
#include "stm32_gpio.h"
#include "no_os_tdm.h"
#include "stm32_tdm.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
#include "no_os_irq.h"
#include "stm32_irq.h"
#include "no_os_lf256fifo.h"
Include dependency graph for stm32_tdm.c:

Functions

int32_t stm32_tdm_init (struct no_os_tdm_desc **desc, const struct no_os_tdm_init_param *param)
 Initialize the TDM communication peripheral.
 
int32_t stm32_tdm_remove (struct no_os_tdm_desc *desc)
 Free the resources allocated by stm32_tdm_init().
 
int32_t stm32_tdm_read (struct no_os_tdm_desc *desc, void *data, uint16_t nb_samples)
 Read data using SAI TDM mode.
 
int32_t stm32_stop_tdm_transfer (struct no_os_tdm_desc *desc)
 Stop SAI DMA transfer.
 
int32_t stm32_pause_tdm_transfer (struct no_os_tdm_desc *desc)
 Pause SAI DMA transfer.
 
int32_t stm32_resume_tdm_transfer (struct no_os_tdm_desc *desc)
 Resume SAI DMA transfer.
 

Variables

const struct no_os_tdm_platform_ops stm32_tdm_platform_ops
 stm32 platform specific TDM platform ops structure
 

Detailed Description

Implementation of TDM driver using STM32's SAI peripheral.

Author
Darius Berghe (dariu.nosp@m.s.be.nosp@m.rghe@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2020(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ stm32_pause_tdm_transfer()

int32_t stm32_pause_tdm_transfer ( struct no_os_tdm_desc * desc)

Pause SAI DMA transfer.

Parameters
desc- The TDM descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ stm32_resume_tdm_transfer()

int32_t stm32_resume_tdm_transfer ( struct no_os_tdm_desc * desc)

Resume SAI DMA transfer.

Parameters
desc- The TDM descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ stm32_stop_tdm_transfer()

int32_t stm32_stop_tdm_transfer ( struct no_os_tdm_desc * desc)

Stop SAI DMA transfer.

Parameters
desc- The TDM descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ 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.

Parameters
desc- The TDM descriptor.
param- The structure that contains the TDM parameters.
Returns
0 in case of success, negative error code otherwise.

◆ 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.

Parameters
desc- The TDM descriptor.
data- The buffer to fill with the received data.
nb_samples- Number of samples to read.
Returns
0 in case of success, negative error code otherwise.

◆ stm32_tdm_remove()

int32_t stm32_tdm_remove ( struct no_os_tdm_desc * desc)

Free the resources allocated by stm32_tdm_init().

Parameters
desc- The TDM descriptor.
Returns
0 in case of success, negative error code otherwise.

Variable Documentation

◆ stm32_tdm_platform_ops

const struct no_os_tdm_platform_ops stm32_tdm_platform_ops
Initial value:
= {
.tdm_ops_init = &stm32_tdm_init,
.tdm_ops_read = &stm32_tdm_read,
.tdm_ops_stop = &stm32_stop_tdm_transfer,
.tdm_ops_pause = &stm32_pause_tdm_transfer,
.tdm_ops_resume = &stm32_resume_tdm_transfer,
.tdm_ops_remove = &stm32_tdm_remove
}
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
int32_t stm32_resume_tdm_transfer(struct no_os_tdm_desc *desc)
Resume SAI DMA transfer.
Definition stm32_tdm.c:339
int32_t stm32_tdm_remove(struct no_os_tdm_desc *desc)
Free the resources allocated by stm32_tdm_init().
Definition stm32_tdm.c:231
int32_t stm32_stop_tdm_transfer(struct no_os_tdm_desc *desc)
Stop SAI DMA transfer.
Definition stm32_tdm.c:288
int32_t stm32_pause_tdm_transfer(struct no_os_tdm_desc *desc)
Pause SAI DMA transfer.
Definition stm32_tdm.c:314
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

stm32 platform specific TDM platform ops structure

stm32 specific TDM platform ops structure