Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:02

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup lpc_i2s
0007  *
0008  * @brief I2S API.
0009  */
0010 
0011 /*
0012  * Copyright (c) 2010 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_ARM_SHARED_LPC_I2S_H
0037 #define LIBBSP_ARM_SHARED_LPC_I2S_H
0038 
0039 #include <bsp/utility.h>
0040 
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044 
0045 /**
0046  * @defgroup lpc_i2s I2S Support
0047  *
0048  * @ingroup RTEMSBSPsARMLPC24XX
0049  * @ingroup RTEMSBSPsARMLPC32XX
0050  *
0051  * @brief I2S support.
0052  *
0053  * @{
0054  */
0055 
0056 /**
0057  * @brief I2S control block.
0058  */
0059 typedef struct {
0060   uint32_t dao;
0061   uint32_t dai;
0062   uint32_t txfifo;
0063   uint32_t rxfifo;
0064   uint32_t state;
0065   uint32_t dma [2];
0066   uint32_t irq;
0067   uint32_t txrate;
0068   uint32_t rxrate;
0069 } lpc_i2s;
0070 
0071 /**
0072  * @name I2S Digital Audio Input and Output
0073  *
0074  * @{
0075  */
0076 
0077 #define I2S_DAIO_WORDWIDTH(val) BSP_FLD32(val, 0, 1)
0078 #define I2S_DAIO_MONO BSP_BIT32(2)
0079 #define I2S_DAIO_STOP BSP_BIT32(3)
0080 #define I2S_DAIO_RESET BSP_BIT32(4)
0081 #define I2S_DAIO_WS_SEL BSP_BIT32(5)
0082 #define I2S_DAIO_WS_HALFPERIOD(val) BSP_FLD32(val, 6, 14)
0083 #define I2S_DAIO_MUTE BSP_BIT32(15)
0084 
0085 /** @} */
0086 
0087 /**
0088  * @name I2S Status Feedback
0089  *
0090  * @{
0091  */
0092 
0093 #define I2S_STATE_IRQ BSP_BIT32(0)
0094 #define I2S_STATE_DMAREQ_0 BSP_BIT32(1)
0095 #define I2S_STATE_DMAREQ_1 BSP_BIT32(2)
0096 #define I2S_STATE_RX_LEVEL_GET(reg) BSP_FLD32GET(reg, 8, 11)
0097 #define I2S_STATE_TX_LEVEL_GET(reg) BSP_FLD32GET(reg, 16, 19)
0098 
0099 /** @} */
0100 
0101 /**
0102  * @name I2S DMA Configuration
0103  *
0104  * @{
0105  */
0106 
0107 #define I2S_DMA_RX_ENABLE BSP_BIT32(0)
0108 #define I2S_DMA_TX_ENABLE BSP_BIT32(1)
0109 #define I2S_DMA_RX_DEPTH(val) BSP_FLD32(val, 8, 11)
0110 #define I2S_DMA_TX_DEPTH(val) BSP_FLD32(val, 16, 19)
0111 
0112 /** @} */
0113 
0114 /**
0115  * @name I2S Interrupt Request Control
0116  *
0117  * @{
0118  */
0119 
0120 #define I2S_IRQ_RX BSP_BIT32(0)
0121 #define I2S_IRQ_TX BSP_BIT32(1)
0122 #define I2S_IRQ_RX_DEPTH(val) BSP_FLD32(val, 8, 11)
0123 #define I2S_IRQ_TX_DEPTH(val) BSP_FLD32(val, 16, 19)
0124 
0125 /** @} */
0126 
0127 /**
0128  * @name I2S Transmit and Receive Clock Rate
0129  *
0130  * @{
0131  */
0132 
0133 #define LPC24XX_I2S_RATE(val) BSP_FLD32(val, 0, 9)
0134 #define LPC32XX_I2S_RATE_X_DIVIDER(val) BSP_FLD32(val, 0, 7)
0135 #define LPC32XX_I2S_RATE_Y_DIVIDER(val) BSP_FLD32(val, 8, 15)
0136 
0137 /** @} */
0138 
0139 /** @} */
0140 
0141 #ifdef __cplusplus
0142 }
0143 #endif /* __cplusplus */
0144 
0145 #endif /* LIBBSP_ARM_SHARED_LPC_I2S_H */