Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 9 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of SPI LL module. |
5 | * @brief Header file of SPI LL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
- | 10 | * All rights reserved.</center></h2> |
|
10 | * |
11 | * |
11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
14 | * this list of conditions and the following disclaimer. |
- | |
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
16 | * this list of conditions and the following disclaimer in the documentation |
- | |
17 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
19 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
20 | * without specific prior written permission. |
- | |
21 | * |
- | |
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
32 | * |
16 | * |
33 | ****************************************************************************** |
17 | ****************************************************************************** |
34 | */ |
18 | */ |
35 | 19 | ||
36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
37 | #ifndef __STM32F1xx_LL_SPI_H |
21 | #ifndef STM32F1xx_LL_SPI_H |
38 | #define __STM32F1xx_LL_SPI_H |
22 | #define STM32F1xx_LL_SPI_H |
39 | 23 | ||
40 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
41 | extern "C" { |
25 | extern "C" { |
42 | #endif |
26 | #endif |
43 | 27 | ||
Line 160... | Line 144... | ||
160 | 144 | ||
161 | /** @defgroup SPI_LL_EC_MODE Operation Mode |
145 | /** @defgroup SPI_LL_EC_MODE Operation Mode |
162 | * @{ |
146 | * @{ |
163 | */ |
147 | */ |
164 | #define LL_SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) /*!< Master configuration */ |
148 | #define LL_SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) /*!< Master configuration */ |
165 | #define LL_SPI_MODE_SLAVE 0x00000000U /*!< Slave configuration */ |
149 | #define LL_SPI_MODE_SLAVE 0x00000000U /*!< Slave configuration */ |
166 | /** |
150 | /** |
167 | * @} |
151 | * @} |
168 | */ |
152 | */ |
169 | 153 | ||
170 | 154 | ||
Line 242... | Line 226... | ||
242 | #if defined(USE_FULL_LL_DRIVER) |
226 | #if defined(USE_FULL_LL_DRIVER) |
243 | 227 | ||
244 | /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation |
228 | /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation |
245 | * @{ |
229 | * @{ |
246 | */ |
230 | */ |
247 | #define LL_SPI_CRCCALCULATION_DISABLE 0x00000000U /*!< CRC calculation disabled */ |
231 | #define LL_SPI_CRCCALCULATION_DISABLE 0x00000000U /*!< CRC calculation disabled */ |
248 | #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CR1_CRCEN) /*!< CRC calculation enabled */ |
232 | #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CR1_CRCEN) /*!< CRC calculation enabled */ |
249 | /** |
233 | /** |
250 | * @} |
234 | * @} |
251 | */ |
235 | */ |
252 | #endif /* USE_FULL_LL_DRIVER */ |
236 | #endif /* USE_FULL_LL_DRIVER */ |
253 | 237 | ||
Line 326... | Line 310... | ||
326 | * @param SPIx SPI Instance |
310 | * @param SPIx SPI Instance |
327 | * @retval State of bit (1 or 0). |
311 | * @retval State of bit (1 or 0). |
328 | */ |
312 | */ |
329 | __STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx) |
313 | __STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx) |
330 | { |
314 | { |
331 | return (READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)); |
315 | return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL); |
332 | } |
316 | } |
333 | 317 | ||
334 | /** |
318 | /** |
335 | * @brief Set SPI operation mode to Master or Slave |
319 | * @brief Set SPI operation mode to Master or Slave |
336 | * @note This bit should not be changed when communication is ongoing. |
320 | * @note This bit should not be changed when communication is ongoing. |
Line 591... | Line 575... | ||
591 | * @param SPIx SPI Instance |
575 | * @param SPIx SPI Instance |
592 | * @retval State of bit (1 or 0). |
576 | * @retval State of bit (1 or 0). |
593 | */ |
577 | */ |
594 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx) |
578 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx) |
595 | { |
579 | { |
596 | return (READ_BIT(SPIx->CR1, SPI_CR1_CRCEN) == (SPI_CR1_CRCEN)); |
580 | return ((READ_BIT(SPIx->CR1, SPI_CR1_CRCEN) == (SPI_CR1_CRCEN)) ? 1UL : 0UL); |
597 | } |
581 | } |
598 | 582 | ||
599 | /** |
583 | /** |
600 | * @brief Set CRCNext to transfer CRC on the line |
584 | * @brief Set CRCNext to transfer CRC on the line |
601 | * @note This bit has to be written as soon as the last data is written in the SPIx_DR register. |
585 | * @note This bit has to be written as soon as the last data is written in the SPIx_DR register. |
Line 689... | Line 673... | ||
689 | * @arg @ref LL_SPI_NSS_HARD_INPUT |
673 | * @arg @ref LL_SPI_NSS_HARD_INPUT |
690 | * @arg @ref LL_SPI_NSS_HARD_OUTPUT |
674 | * @arg @ref LL_SPI_NSS_HARD_OUTPUT |
691 | */ |
675 | */ |
692 | __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx) |
676 | __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx) |
693 | { |
677 | { |
694 | register uint32_t Ssm = (READ_BIT(SPIx->CR1, SPI_CR1_SSM)); |
678 | uint32_t Ssm = (READ_BIT(SPIx->CR1, SPI_CR1_SSM)); |
695 | register uint32_t Ssoe = (READ_BIT(SPIx->CR2, SPI_CR2_SSOE) << 16U); |
679 | uint32_t Ssoe = (READ_BIT(SPIx->CR2, SPI_CR2_SSOE) << 16U); |
696 | return (Ssm | Ssoe); |
680 | return (Ssm | Ssoe); |
697 | } |
681 | } |
698 | 682 | ||
699 | /** |
683 | /** |
700 | * @} |
684 | * @} |
Line 710... | Line 694... | ||
710 | * @param SPIx SPI Instance |
694 | * @param SPIx SPI Instance |
711 | * @retval State of bit (1 or 0). |
695 | * @retval State of bit (1 or 0). |
712 | */ |
696 | */ |
713 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) |
697 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) |
714 | { |
698 | { |
715 | return (READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)); |
699 | return ((READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)) ? 1UL : 0UL); |
716 | } |
700 | } |
717 | 701 | ||
718 | /** |
702 | /** |
719 | * @brief Check if Tx buffer is empty |
703 | * @brief Check if Tx buffer is empty |
720 | * @rmtoll SR TXE LL_SPI_IsActiveFlag_TXE |
704 | * @rmtoll SR TXE LL_SPI_IsActiveFlag_TXE |
721 | * @param SPIx SPI Instance |
705 | * @param SPIx SPI Instance |
722 | * @retval State of bit (1 or 0). |
706 | * @retval State of bit (1 or 0). |
723 | */ |
707 | */ |
724 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef *SPIx) |
708 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef *SPIx) |
725 | { |
709 | { |
726 | return (READ_BIT(SPIx->SR, SPI_SR_TXE) == (SPI_SR_TXE)); |
710 | return ((READ_BIT(SPIx->SR, SPI_SR_TXE) == (SPI_SR_TXE)) ? 1UL : 0UL); |
727 | } |
711 | } |
728 | 712 | ||
729 | /** |
713 | /** |
730 | * @brief Get CRC error flag |
714 | * @brief Get CRC error flag |
731 | * @rmtoll SR CRCERR LL_SPI_IsActiveFlag_CRCERR |
715 | * @rmtoll SR CRCERR LL_SPI_IsActiveFlag_CRCERR |
732 | * @param SPIx SPI Instance |
716 | * @param SPIx SPI Instance |
733 | * @retval State of bit (1 or 0). |
717 | * @retval State of bit (1 or 0). |
734 | */ |
718 | */ |
735 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx) |
719 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx) |
736 | { |
720 | { |
737 | return (READ_BIT(SPIx->SR, SPI_SR_CRCERR) == (SPI_SR_CRCERR)); |
721 | return ((READ_BIT(SPIx->SR, SPI_SR_CRCERR) == (SPI_SR_CRCERR)) ? 1UL : 0UL); |
738 | } |
722 | } |
739 | 723 | ||
740 | /** |
724 | /** |
741 | * @brief Get mode fault error flag |
725 | * @brief Get mode fault error flag |
742 | * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF |
726 | * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF |
743 | * @param SPIx SPI Instance |
727 | * @param SPIx SPI Instance |
744 | * @retval State of bit (1 or 0). |
728 | * @retval State of bit (1 or 0). |
745 | */ |
729 | */ |
746 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx) |
730 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx) |
747 | { |
731 | { |
748 | return (READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)); |
732 | return ((READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)) ? 1UL : 0UL); |
749 | } |
733 | } |
750 | 734 | ||
751 | /** |
735 | /** |
752 | * @brief Get overrun error flag |
736 | * @brief Get overrun error flag |
753 | * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR |
737 | * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR |
754 | * @param SPIx SPI Instance |
738 | * @param SPIx SPI Instance |
755 | * @retval State of bit (1 or 0). |
739 | * @retval State of bit (1 or 0). |
756 | */ |
740 | */ |
757 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx) |
741 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx) |
758 | { |
742 | { |
759 | return (READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)); |
743 | return ((READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)) ? 1UL : 0UL); |
760 | } |
744 | } |
761 | 745 | ||
762 | /** |
746 | /** |
763 | * @brief Get busy flag |
747 | * @brief Get busy flag |
764 | * @note The BSY flag is cleared under any one of the following conditions: |
748 | * @note The BSY flag is cleared under any one of the following conditions: |
Line 772... | Line 756... | ||
772 | * @param SPIx SPI Instance |
756 | * @param SPIx SPI Instance |
773 | * @retval State of bit (1 or 0). |
757 | * @retval State of bit (1 or 0). |
774 | */ |
758 | */ |
775 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef *SPIx) |
759 | __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef *SPIx) |
776 | { |
760 | { |
777 | return (READ_BIT(SPIx->SR, SPI_SR_BSY) == (SPI_SR_BSY)); |
761 | return ((READ_BIT(SPIx->SR, SPI_SR_BSY) == (SPI_SR_BSY)) ? 1UL : 0UL); |
778 | } |
762 | } |
779 | 763 | ||
780 | 764 | ||
781 | /** |
765 | /** |
782 | * @brief Clear CRC error flag |
766 | * @brief Clear CRC error flag |
Line 797... | Line 781... | ||
797 | * @param SPIx SPI Instance |
781 | * @param SPIx SPI Instance |
798 | * @retval None |
782 | * @retval None |
799 | */ |
783 | */ |
800 | __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx) |
784 | __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx) |
801 | { |
785 | { |
802 | __IO uint32_t tmpreg; |
786 | __IO uint32_t tmpreg_sr; |
803 | tmpreg = SPIx->SR; |
787 | tmpreg_sr = SPIx->SR; |
804 | (void) tmpreg; |
788 | (void) tmpreg_sr; |
805 | tmpreg = CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE); |
789 | CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE); |
806 | (void) tmpreg; |
- | |
807 | } |
790 | } |
808 | 791 | ||
809 | /** |
792 | /** |
810 | * @brief Clear overrun error flag |
793 | * @brief Clear overrun error flag |
811 | * @note Clearing this flag is done by a read access to the SPIx_DR |
794 | * @note Clearing this flag is done by a read access to the SPIx_DR |
Line 821... | Line 804... | ||
821 | (void) tmpreg; |
804 | (void) tmpreg; |
822 | tmpreg = SPIx->SR; |
805 | tmpreg = SPIx->SR; |
823 | (void) tmpreg; |
806 | (void) tmpreg; |
824 | } |
807 | } |
825 | 808 | ||
- | 809 | /** |
|
- | 810 | * @brief Clear frame format error flag |
|
- | 811 | * @note Clearing this flag is done by reading SPIx_SR register |
|
- | 812 | * @rmtoll SR FRE LL_SPI_ClearFlag_FRE |
|
- | 813 | * @param SPIx SPI Instance |
|
- | 814 | * @retval None |
|
- | 815 | */ |
|
- | 816 | __STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx) |
|
- | 817 | { |
|
- | 818 | __IO uint32_t tmpreg; |
|
- | 819 | tmpreg = SPIx->SR; |
|
- | 820 | (void) tmpreg; |
|
- | 821 | } |
|
826 | 822 | ||
827 | /** |
823 | /** |
828 | * @} |
824 | * @} |
829 | */ |
825 | */ |
830 | 826 | ||
Line 906... | Line 902... | ||
906 | * @param SPIx SPI Instance |
902 | * @param SPIx SPI Instance |
907 | * @retval State of bit (1 or 0). |
903 | * @retval State of bit (1 or 0). |
908 | */ |
904 | */ |
909 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef *SPIx) |
905 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef *SPIx) |
910 | { |
906 | { |
911 | return (READ_BIT(SPIx->CR2, SPI_CR2_ERRIE) == (SPI_CR2_ERRIE)); |
907 | return ((READ_BIT(SPIx->CR2, SPI_CR2_ERRIE) == (SPI_CR2_ERRIE)) ? 1UL : 0UL); |
912 | } |
908 | } |
913 | 909 | ||
914 | /** |
910 | /** |
915 | * @brief Check if Rx buffer not empty interrupt is enabled |
911 | * @brief Check if Rx buffer not empty interrupt is enabled |
916 | * @rmtoll CR2 RXNEIE LL_SPI_IsEnabledIT_RXNE |
912 | * @rmtoll CR2 RXNEIE LL_SPI_IsEnabledIT_RXNE |
917 | * @param SPIx SPI Instance |
913 | * @param SPIx SPI Instance |
918 | * @retval State of bit (1 or 0). |
914 | * @retval State of bit (1 or 0). |
919 | */ |
915 | */ |
920 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) |
916 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) |
921 | { |
917 | { |
922 | return (READ_BIT(SPIx->CR2, SPI_CR2_RXNEIE) == (SPI_CR2_RXNEIE)); |
918 | return ((READ_BIT(SPIx->CR2, SPI_CR2_RXNEIE) == (SPI_CR2_RXNEIE)) ? 1UL : 0UL); |
923 | } |
919 | } |
924 | 920 | ||
925 | /** |
921 | /** |
926 | * @brief Check if Tx buffer empty interrupt |
922 | * @brief Check if Tx buffer empty interrupt |
927 | * @rmtoll CR2 TXEIE LL_SPI_IsEnabledIT_TXE |
923 | * @rmtoll CR2 TXEIE LL_SPI_IsEnabledIT_TXE |
928 | * @param SPIx SPI Instance |
924 | * @param SPIx SPI Instance |
929 | * @retval State of bit (1 or 0). |
925 | * @retval State of bit (1 or 0). |
930 | */ |
926 | */ |
931 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(SPI_TypeDef *SPIx) |
927 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(SPI_TypeDef *SPIx) |
932 | { |
928 | { |
933 | return (READ_BIT(SPIx->CR2, SPI_CR2_TXEIE) == (SPI_CR2_TXEIE)); |
929 | return ((READ_BIT(SPIx->CR2, SPI_CR2_TXEIE) == (SPI_CR2_TXEIE)) ? 1UL : 0UL); |
934 | } |
930 | } |
935 | 931 | ||
936 | /** |
932 | /** |
937 | * @} |
933 | * @} |
938 | */ |
934 | */ |
Line 969... | Line 965... | ||
969 | * @param SPIx SPI Instance |
965 | * @param SPIx SPI Instance |
970 | * @retval State of bit (1 or 0). |
966 | * @retval State of bit (1 or 0). |
971 | */ |
967 | */ |
972 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) |
968 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) |
973 | { |
969 | { |
974 | return (READ_BIT(SPIx->CR2, SPI_CR2_RXDMAEN) == (SPI_CR2_RXDMAEN)); |
970 | return ((READ_BIT(SPIx->CR2, SPI_CR2_RXDMAEN) == (SPI_CR2_RXDMAEN)) ? 1UL : 0UL); |
975 | } |
971 | } |
976 | 972 | ||
977 | /** |
973 | /** |
978 | * @brief Enable DMA Tx |
974 | * @brief Enable DMA Tx |
979 | * @rmtoll CR2 TXDMAEN LL_SPI_EnableDMAReq_TX |
975 | * @rmtoll CR2 TXDMAEN LL_SPI_EnableDMAReq_TX |
Line 1002... | Line 998... | ||
1002 | * @param SPIx SPI Instance |
998 | * @param SPIx SPI Instance |
1003 | * @retval State of bit (1 or 0). |
999 | * @retval State of bit (1 or 0). |
1004 | */ |
1000 | */ |
1005 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) |
1001 | __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) |
1006 | { |
1002 | { |
1007 | return (READ_BIT(SPIx->CR2, SPI_CR2_TXDMAEN) == (SPI_CR2_TXDMAEN)); |
1003 | return ((READ_BIT(SPIx->CR2, SPI_CR2_TXDMAEN) == (SPI_CR2_TXDMAEN)) ? 1UL : 0UL); |
1008 | } |
1004 | } |
1009 | 1005 | ||
1010 | /** |
1006 | /** |
1011 | * @brief Get the data register address used for DMA transfer |
1007 | * @brief Get the data register address used for DMA transfer |
1012 | * @rmtoll DR DR LL_SPI_DMA_GetRegAddr |
1008 | * @rmtoll DR DR LL_SPI_DMA_GetRegAddr |
1013 | * @param SPIx SPI Instance |
1009 | * @param SPIx SPI Instance |
1014 | * @retval Address of data register |
1010 | * @retval Address of data register |
1015 | */ |
1011 | */ |
1016 | __STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(SPI_TypeDef *SPIx) |
1012 | __STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(SPI_TypeDef *SPIx) |
1017 | { |
1013 | { |
1018 | return (uint32_t) & (SPIx->DR); |
1014 | return (uint32_t) &(SPIx->DR); |
1019 | } |
1015 | } |
1020 | 1016 | ||
1021 | /** |
1017 | /** |
1022 | * @} |
1018 | * @} |
1023 | */ |
1019 | */ |
Line 1055... | Line 1051... | ||
1055 | * @param TxData Value between Min_Data=0x00 and Max_Data=0xFF |
1051 | * @param TxData Value between Min_Data=0x00 and Max_Data=0xFF |
1056 | * @retval None |
1052 | * @retval None |
1057 | */ |
1053 | */ |
1058 | __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData) |
1054 | __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData) |
1059 | { |
1055 | { |
- | 1056 | #if defined (__GNUC__) |
|
- | 1057 | __IO uint8_t *spidr = ((__IO uint8_t *)&SPIx->DR); |
|
1060 | SPIx->DR = TxData; |
1058 | *spidr = TxData; |
- | 1059 | #else |
|
- | 1060 | *((__IO uint8_t *)&SPIx->DR) = TxData; |
|
- | 1061 | #endif /* __GNUC__ */ |
|
1061 | } |
1062 | } |
1062 | 1063 | ||
1063 | /** |
1064 | /** |
1064 | * @brief Write 16-Bits in the data register |
1065 | * @brief Write 16-Bits in the data register |
1065 | * @rmtoll DR DR LL_SPI_TransmitData16 |
1066 | * @rmtoll DR DR LL_SPI_TransmitData16 |
Line 1067... | Line 1068... | ||
1067 | * @param TxData Value between Min_Data=0x00 and Max_Data=0xFFFF |
1068 | * @param TxData Value between Min_Data=0x00 and Max_Data=0xFFFF |
1068 | * @retval None |
1069 | * @retval None |
1069 | */ |
1070 | */ |
1070 | __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) |
1071 | __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) |
1071 | { |
1072 | { |
- | 1073 | #if defined (__GNUC__) |
|
- | 1074 | __IO uint16_t *spidr = ((__IO uint16_t *)&SPIx->DR); |
|
- | 1075 | *spidr = TxData; |
|
- | 1076 | #else |
|
1072 | SPIx->DR = TxData; |
1077 | SPIx->DR = TxData; |
- | 1078 | #endif /* __GNUC__ */ |
|
1073 | } |
1079 | } |
1074 | 1080 | ||
1075 | /** |
1081 | /** |
1076 | * @} |
1082 | * @} |
1077 | */ |
1083 | */ |
Line 1190... | Line 1196... | ||
1190 | */ |
1196 | */ |
1191 | 1197 | ||
1192 | /** @defgroup I2S_LL_EC_DATA_FORMAT Data format |
1198 | /** @defgroup I2S_LL_EC_DATA_FORMAT Data format |
1193 | * @{ |
1199 | * @{ |
1194 | */ |
1200 | */ |
1195 | #define LL_I2S_DATAFORMAT_16B 0x00000000U /*!< Data length 16 bits, Channel lenght 16bit */ |
1201 | #define LL_I2S_DATAFORMAT_16B 0x00000000U /*!< Data length 16 bits, Channel length 16bit */ |
1196 | #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) /*!< Data length 16 bits, Channel lenght 32bit */ |
1202 | #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) /*!< Data length 16 bits, Channel length 32bit */ |
1197 | #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0) /*!< Data length 24 bits, Channel lenght 32bit */ |
1203 | #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0) /*!< Data length 24 bits, Channel length 32bit */ |
1198 | #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1) /*!< Data length 16 bits, Channel lenght 32bit */ |
1204 | #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1) /*!< Data length 16 bits, Channel length 32bit */ |
1199 | /** |
1205 | /** |
1200 | * @} |
1206 | * @} |
1201 | */ |
1207 | */ |
1202 | 1208 | ||
1203 | /** @defgroup I2S_LL_EC_POLARITY Clock Polarity |
1209 | /** @defgroup I2S_LL_EC_POLARITY Clock Polarity |
Line 1254... | Line 1260... | ||
1254 | 1260 | ||
1255 | /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency |
1261 | /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency |
1256 | * @{ |
1262 | * @{ |
1257 | */ |
1263 | */ |
1258 | 1264 | ||
1259 | #define LL_I2S_AUDIOFREQ_192K 192000U /*!< Audio Frequency configuration 192000 Hz */ |
1265 | #define LL_I2S_AUDIOFREQ_192K 192000U /*!< Audio Frequency configuration 192000 Hz */ |
1260 | #define LL_I2S_AUDIOFREQ_96K 96000U /*!< Audio Frequency configuration 96000 Hz */ |
1266 | #define LL_I2S_AUDIOFREQ_96K 96000U /*!< Audio Frequency configuration 96000 Hz */ |
1261 | #define LL_I2S_AUDIOFREQ_48K 48000U /*!< Audio Frequency configuration 48000 Hz */ |
1267 | #define LL_I2S_AUDIOFREQ_48K 48000U /*!< Audio Frequency configuration 48000 Hz */ |
1262 | #define LL_I2S_AUDIOFREQ_44K 44100U /*!< Audio Frequency configuration 44100 Hz */ |
1268 | #define LL_I2S_AUDIOFREQ_44K 44100U /*!< Audio Frequency configuration 44100 Hz */ |
1263 | #define LL_I2S_AUDIOFREQ_32K 32000U /*!< Audio Frequency configuration 32000 Hz */ |
1269 | #define LL_I2S_AUDIOFREQ_32K 32000U /*!< Audio Frequency configuration 32000 Hz */ |
1264 | #define LL_I2S_AUDIOFREQ_22K 22050U /*!< Audio Frequency configuration 22050 Hz */ |
1270 | #define LL_I2S_AUDIOFREQ_22K 22050U /*!< Audio Frequency configuration 22050 Hz */ |
1265 | #define LL_I2S_AUDIOFREQ_16K 16000U /*!< Audio Frequency configuration 16000 Hz */ |
1271 | #define LL_I2S_AUDIOFREQ_16K 16000U /*!< Audio Frequency configuration 16000 Hz */ |
1266 | #define LL_I2S_AUDIOFREQ_11K 11025U /*!< Audio Frequency configuration 11025 Hz */ |
1272 | #define LL_I2S_AUDIOFREQ_11K 11025U /*!< Audio Frequency configuration 11025 Hz */ |
1267 | #define LL_I2S_AUDIOFREQ_8K 8000U /*!< Audio Frequency configuration 8000 Hz */ |
1273 | #define LL_I2S_AUDIOFREQ_8K 8000U /*!< Audio Frequency configuration 8000 Hz */ |
1268 | #define LL_I2S_AUDIOFREQ_DEFAULT 2U /*!< Audio Freq not specified. Register I2SDIV = 2 */ |
1274 | #define LL_I2S_AUDIOFREQ_DEFAULT 2U /*!< Audio Freq not specified. Register I2SDIV = 2 */ |
1269 | /** |
1275 | /** |
1270 | * @} |
1276 | * @} |
1271 | */ |
1277 | */ |
1272 | #endif /* USE_FULL_LL_DRIVER */ |
1278 | #endif /* USE_FULL_LL_DRIVER */ |
1273 | 1279 | ||
Line 1348... | Line 1354... | ||
1348 | * @param SPIx SPI Instance |
1354 | * @param SPIx SPI Instance |
1349 | * @retval State of bit (1 or 0). |
1355 | * @retval State of bit (1 or 0). |
1350 | */ |
1356 | */ |
1351 | __STATIC_INLINE uint32_t LL_I2S_IsEnabled(SPI_TypeDef *SPIx) |
1357 | __STATIC_INLINE uint32_t LL_I2S_IsEnabled(SPI_TypeDef *SPIx) |
1352 | { |
1358 | { |
1353 | return (READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SE) == (SPI_I2SCFGR_I2SE)); |
1359 | return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SE) == (SPI_I2SCFGR_I2SE)) ? 1UL : 0UL); |
1354 | } |
1360 | } |
1355 | 1361 | ||
1356 | /** |
1362 | /** |
1357 | * @brief Set I2S data frame length |
1363 | * @brief Set I2S data frame length |
1358 | * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n |
1364 | * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n |
Line 1528... | Line 1534... | ||
1528 | { |
1534 | { |
1529 | return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_ODD) >> 8U); |
1535 | return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_ODD) >> 8U); |
1530 | } |
1536 | } |
1531 | 1537 | ||
1532 | /** |
1538 | /** |
1533 | * @brief Enable the master clock ouput (Pin MCK) |
1539 | * @brief Enable the master clock output (Pin MCK) |
1534 | * @rmtoll I2SPR MCKOE LL_I2S_EnableMasterClock |
1540 | * @rmtoll I2SPR MCKOE LL_I2S_EnableMasterClock |
1535 | * @param SPIx SPI Instance |
1541 | * @param SPIx SPI Instance |
1536 | * @retval None |
1542 | * @retval None |
1537 | */ |
1543 | */ |
1538 | __STATIC_INLINE void LL_I2S_EnableMasterClock(SPI_TypeDef *SPIx) |
1544 | __STATIC_INLINE void LL_I2S_EnableMasterClock(SPI_TypeDef *SPIx) |
1539 | { |
1545 | { |
1540 | SET_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE); |
1546 | SET_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE); |
1541 | } |
1547 | } |
1542 | 1548 | ||
1543 | /** |
1549 | /** |
1544 | * @brief Disable the master clock ouput (Pin MCK) |
1550 | * @brief Disable the master clock output (Pin MCK) |
1545 | * @rmtoll I2SPR MCKOE LL_I2S_DisableMasterClock |
1551 | * @rmtoll I2SPR MCKOE LL_I2S_DisableMasterClock |
1546 | * @param SPIx SPI Instance |
1552 | * @param SPIx SPI Instance |
1547 | * @retval None |
1553 | * @retval None |
1548 | */ |
1554 | */ |
1549 | __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx) |
1555 | __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx) |
1550 | { |
1556 | { |
1551 | CLEAR_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE); |
1557 | CLEAR_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE); |
1552 | } |
1558 | } |
1553 | 1559 | ||
1554 | /** |
1560 | /** |
1555 | * @brief Check if the master clock ouput (Pin MCK) is enabled |
1561 | * @brief Check if the master clock output (Pin MCK) is enabled |
1556 | * @rmtoll I2SPR MCKOE LL_I2S_IsEnabledMasterClock |
1562 | * @rmtoll I2SPR MCKOE LL_I2S_IsEnabledMasterClock |
1557 | * @param SPIx SPI Instance |
1563 | * @param SPIx SPI Instance |
1558 | * @retval State of bit (1 or 0). |
1564 | * @retval State of bit (1 or 0). |
1559 | */ |
1565 | */ |
1560 | __STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef *SPIx) |
1566 | __STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef *SPIx) |
1561 | { |
1567 | { |
1562 | return (READ_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE) == (SPI_I2SPR_MCKOE)); |
1568 | return ((READ_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE) == (SPI_I2SPR_MCKOE)) ? 1UL : 0UL); |
1563 | } |
1569 | } |
1564 | 1570 | ||
1565 | /** |
1571 | /** |
1566 | * @} |
1572 | * @} |
1567 | */ |
1573 | */ |
Line 1620... | Line 1626... | ||
1620 | * @param SPIx SPI Instance |
1626 | * @param SPIx SPI Instance |
1621 | * @retval State of bit (1 or 0). |
1627 | * @retval State of bit (1 or 0). |
1622 | */ |
1628 | */ |
1623 | __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx) |
1629 | __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx) |
1624 | { |
1630 | { |
1625 | return (READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)); |
1631 | return ((READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)) ? 1UL : 0UL); |
1626 | } |
1632 | } |
1627 | 1633 | ||
- | 1634 | ||
1628 | /** |
1635 | /** |
1629 | * @brief Get channel side flag. |
1636 | * @brief Get channel side flag. |
1630 | * @note 0: Channel Left has to be transmitted or has been received\n |
1637 | * @note 0: Channel Left has to be transmitted or has been received\n |
1631 | * 1: Channel Right has to be transmitted or has been received\n |
1638 | * 1: Channel Right has to be transmitted or has been received\n |
1632 | * It has no significance in PCM mode. |
1639 | * It has no significance in PCM mode. |
Line 1634... | Line 1641... | ||
1634 | * @param SPIx SPI Instance |
1641 | * @param SPIx SPI Instance |
1635 | * @retval State of bit (1 or 0). |
1642 | * @retval State of bit (1 or 0). |
1636 | */ |
1643 | */ |
1637 | __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_CHSIDE(SPI_TypeDef *SPIx) |
1644 | __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_CHSIDE(SPI_TypeDef *SPIx) |
1638 | { |
1645 | { |
1639 | return (READ_BIT(SPIx->SR, SPI_SR_CHSIDE) == (SPI_SR_CHSIDE)); |
1646 | return ((READ_BIT(SPIx->SR, SPI_SR_CHSIDE) == (SPI_SR_CHSIDE)) ? 1UL : 0UL); |
1640 | } |
1647 | } |
1641 | 1648 | ||
1642 | /** |
1649 | /** |
1643 | * @brief Clear overrun error flag |
1650 | * @brief Clear overrun error flag |
1644 | * @rmtoll SR OVR LL_I2S_ClearFlag_OVR |
1651 | * @rmtoll SR OVR LL_I2S_ClearFlag_OVR |
Line 1662... | Line 1669... | ||
1662 | tmpreg = SPIx->SR; |
1669 | tmpreg = SPIx->SR; |
1663 | (void)tmpreg; |
1670 | (void)tmpreg; |
1664 | } |
1671 | } |
1665 | 1672 | ||
1666 | /** |
1673 | /** |
- | 1674 | * @brief Clear frame format error flag |
|
- | 1675 | * @rmtoll SR FRE LL_I2S_ClearFlag_FRE |
|
- | 1676 | * @param SPIx SPI Instance |
|
- | 1677 | * @retval None |
|
- | 1678 | */ |
|
- | 1679 | __STATIC_INLINE void LL_I2S_ClearFlag_FRE(SPI_TypeDef *SPIx) |
|
- | 1680 | { |
|
- | 1681 | LL_SPI_ClearFlag_FRE(SPIx); |
|
- | 1682 | } |
|
- | 1683 | ||
- | 1684 | /** |
|
1667 | * @} |
1685 | * @} |
1668 | */ |
1686 | */ |
1669 | 1687 | ||
1670 | /** @defgroup I2S_LL_EF_IT Interrupt Management |
1688 | /** @defgroup I2S_LL_EF_IT Interrupt Management |
1671 | * @{ |
1689 | * @{ |
Line 1913... | Line 1931... | ||
1913 | 1931 | ||
1914 | #ifdef __cplusplus |
1932 | #ifdef __cplusplus |
1915 | } |
1933 | } |
1916 | #endif |
1934 | #endif |
1917 | 1935 | ||
1918 | #endif /* __STM32F1xx_LL_SPI_H */ |
1936 | #endif /* STM32F1xx_LL_SPI_H */ |
1919 | 1937 | ||
1920 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
1938 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |