Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include TDM docs #87

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/programming_guide/reference/i2c/i2c_master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an |I2C| master devic
.. code-block:: c

#include <xs1.h>
#include <i2c.h>
#include "i2c.h"

i2c_master_t i2c_ctx;

Expand Down
2 changes: 1 addition & 1 deletion doc/programming_guide/reference/i2c/i2c_slave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an |I2C| slave device
.. code-block:: c

#include <xs1.h>
#include <i2c.h>
#include "i2c.h"

port_t p_scl = XS1_PORT_1A;
port_t p_sda = XS1_PORT_1B;
Expand Down
37 changes: 31 additions & 6 deletions doc/programming_guide/reference/i2s/i2s.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
|I2S| Library
#############

A software defined library that allows you to control an |I2S| (Inter-IC Sound) bus via xcore ports. |I2S| is a digital data streaming interfaces particularly appropriate for transmission of audio data. The components in the library are controlled via C and can either act as |I2S| master or |I2S| slave.
A software defined library that allows you to control an |I2S| (Inter-IC Sound) bus via xcore ports. |I2S| is a digital data streaming interfaces particularly appropriate for transmission of audio data. TDM is a special case of |I2S| which supports transport of more than two audio channels and is partially included in the library at this time. The components in the library are controlled via C and can either act as |I2S| master, |I2S| slave or TDM slave.

.. note::

The TDM protocol is not yet supported by this library.
TDM is only currently supported as a TDM16 slave Tx component. Expansion of this library to support master or slave Rx is possible and can be done on request.

|I2S| is a protocol between two devices where one is the *master* and one is the *slave* . The protocol is made up of four signals shown
in :ref:`i2s_wire_table`.
|I2S| is a protocol between two devices where one is the *master* and one is the *slave* which determines who drives the clock lines. The protocol is made up of four signals shown in :ref:`i2s_wire_table`.

.. _i2s_wire_table:

.. list-table:: |I2S| data wires
:class: vertical-borders horizontal-borders

* - *MCLK*
- Clock line, driven by external oscillator
- Clock line, driven by external oscillator. This signal is optional.
* - *BCLK*
- Bit clock. This is a fixed divide of the *MCLK* and is driven
by the master.
Expand All @@ -34,7 +33,32 @@ All |I2S| functions can be accessed via the ``i2s.h`` header:

.. code-block:: c

#include <i2s.h>
#include "i2s.h"

TDM is a protocol between two devices similar to |I2S| where one is the *master* and one is the *slave* which determines who drives the clock lines. The protocol is made up of four signals shown in :ref:`tdm_wire_table`.

.. _tdm_wire_table:

.. list-table:: TDM data wires
:class: vertical-borders horizontal-borders

* - *MCLK*
- Clock line, driven by external oscillator. This signal is optional.
* - *BCLK*
- Bit clock. This is a fixed divide of the *MCLK* and is driven
by the master.
* - *FSYCNH*
- Frame synchronization. Toggles at the start of the TDM data frame. This is driven by the master.
* - *DATA*
- Data line, driven by one of the slave or master depending on
the data direction. There may be several data lines in
differing directions.

Currently supported TDM functions can be accessed via the ``i2s_tdm_slave.h`` header:

.. code-block:: c

#include "i2s_tdm_slave.h"

.. toctree::
:maxdepth: 2
Expand All @@ -43,3 +67,4 @@ All |I2S| functions can be accessed via the ``i2s.h`` header:
i2s_common.rst
i2s_master.rst
i2s_slave.rst
i2s_tdm_slave.rst
11 changes: 11 additions & 0 deletions doc/programming_guide/reference/i2s/i2s_common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
|I2S| Common API
****************

|I2S| Instances
===============

The following structures and functions are used by an |I2S| master or slave instance.

.. doxygengroup:: hil_i2s_core
:content-only:

TDM Instances
=============

The following structures and functions are used by an TDM master or slave instance.

.. doxygengroup:: hil_i2s_tdm_core
:content-only:
2 changes: 1 addition & 1 deletion doc/programming_guide/reference/i2s/i2s_master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an |I2S| master devic
.. code-block:: c

#include <xs1.h>
#include <i2s.h>
#include "i2s.h"

port_t p_i2s_dout[1];
port_t p_bclk;
Expand Down
2 changes: 1 addition & 1 deletion doc/programming_guide/reference/i2s/i2s_slave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an |I2S| slave device
.. code-block:: c

#include <xs1.h>
#include <i2s.h>
#include "i2s.h"

// Setup ports and clocks
port_t p_bclk = XS1_PORT_1B;
Expand Down
59 changes: 59 additions & 0 deletions doc/programming_guide/reference/i2s/i2s_tdm_slave.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. include:: ../../../substitutions.rst

*********
TDM Slave
*********

TDM Slave Tx Usage
==================

The following code snippet demonstrates the basic usage of a TDM slave Tx device.

.. code-block:: c

#include <xs1.h>
#include "i2s_tdm_slave.h"

// Setup ports and clocks
port_t p_bclk = XS1_PORT_1A;
port_t p_fsync = XS1_PORT_1B;
port_t p_dout = XS1_PORT_1C;

xclock_t clk_bclk = XS1_CLKBLK_1;

// Setup callbacks
// NOTE: See API or sln_voice examples for more on using the callbacks
i2s_tdm_ctx_t ctx;
i2s_callback_group_t i_i2s = {
.init = (i2s_init_t) i2s_init,
.restart_check = (i2s_restart_check_t) i2s_restart_check,
.receive = NULL,
.send = (i2s_send_t) i2s_send,
.app_data = NULL,
};

// Initialize the TDM slave
i2s_tdm_slave_tx_16_init(
&ctx,
&i_i2s,
p_dout,
p_fsync,
p_bclk,
clk_bclk,
0,
I2S_SLAVE_SAMPLE_ON_BCLK_FALLING,
NULL);

// Start the slave device in this thread
// NOTE: You may wish to launch the slave device in a different thread.
// See the XTC Tools documentation reference for lib_xcore.
i2s_tdm_slave_tx_16_thread(&ctx);

TDM Slave Tx API
================

The following structures and functions are used to initialize and start a TDM slave Tx instance.

.. doxygengroup:: hil_i2s_tdm_slave_tx16
:content-only:

2 changes: 1 addition & 1 deletion doc/programming_guide/reference/spi/spi_master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an SPI master device.
.. code-block:: c

#include <xs1.h>
#include <spi.h>
#include "spi.h"

spi_master_t spi_ctx;
spi_master_device_t spi_dev;
Expand Down
2 changes: 1 addition & 1 deletion doc/programming_guide/reference/spi/spi_slave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code snippet demonstrates the basic usage of an SPI slave device.
.. code-block:: c

#include <xs1.h>
#include <spi.h>
#include "spi.h"

// Setup callbacks
// NOTE: See API or SDK examples for more on using the callbacks
Expand Down
3 changes: 2 additions & 1 deletion doc/programming_guide/reference/uart/uart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ All UART functions can be accessed via the ``uart.h`` header:

.. code-block:: c

#include <uart.h>
#include "uart.h"


.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion doc/shared/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ The peripheral IO framework is a collection of IO libraries written in C for XCO

- UART - transmit and receive
- |I2C| - master and slave
- |I2S| - master and slave
- |I2S| - master and slave and TDM slave Tx
- SPI - master and slave
2 changes: 1 addition & 1 deletion modules/uart/api/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Enum type representing the different options
* parity types.
*/
typedef enum uart_parity_t {
typedef enum uart_parity {
UART_PARITY_NONE = 0,
UART_PARITY_EVEN,
UART_PARITY_ODD
Expand Down
Loading