forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of SPI API for STM32H5 family (#324)
* fix PWM pin map in context of Timer change * Note about DAC on Nucleo-H503RB * Add ADC and DAC for STM32H5 * Copyright fix * Add I2C for STM32H5 * fix I2C related code * ADC/DAC fix * Enable I2C API * Copyright fix * Add SPI for STM32H5 * Modification of stm spi API for h5 family * fix I2C device * fix I2C ASYNCH macro * fix revert back the stop variable position * Fix clock for SPI * fix some details * Rename startup_stm32h563xx.s to startup_stm32h563xx.S * Rename startup_stm32h503xx.s to startup_stm32h503xx.S --------- Co-authored-by: Jan Kamidra <[email protected]>
- Loading branch information
Showing
10 changed files
with
206 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* mbed Microcontroller Library | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
****************************************************************************** | ||
* | ||
* Copyright (c) 2015-2024 STMicroelectronics. | ||
* All rights reserved. | ||
* | ||
* This software component is licensed by ST under BSD 3-Clause license, | ||
* the "License"; You may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* opensource.org/licenses/BSD-3-Clause | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
#include "mbed_assert.h" | ||
#include "mbed_error.h" | ||
#include "spi_api.h" | ||
|
||
#if DEVICE_SPI | ||
|
||
#include "cmsis.h" | ||
#include "pinmap.h" | ||
#include "PeripheralPins.h" | ||
#include "mbed_error.h" | ||
#include "spi_device.h" | ||
|
||
#if DEVICE_SPI_ASYNCH | ||
#define SPI_S(obj) (( struct spi_s *)(&(obj->spi))) | ||
#else | ||
#define SPI_S(obj) (( struct spi_s *)(obj)) | ||
#endif | ||
|
||
/* | ||
* Only the frequency is managed in the family specific part | ||
* the rest of SPI management is common to all STM32 families | ||
*/ | ||
int spi_get_clock_freq(spi_t *obj) | ||
{ | ||
struct spi_s *spiobj = SPI_S(obj); | ||
int spi_hz = 0; | ||
|
||
/* Get source clock depending on SPI instance */ | ||
switch ((int)spiobj->spi) { | ||
case SPI_1: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI1_CLKSOURCE); | ||
break; | ||
case SPI_2: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI2_CLKSOURCE); | ||
break; | ||
case SPI_3: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI3_CLKSOURCE); | ||
break; | ||
#if defined(SPI4) | ||
case SPI_4: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI4_CLKSOURCE); | ||
break; | ||
#endif | ||
#if defined(SPI5) | ||
case SPI_5: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI5_CLKSOURCE); | ||
break; | ||
#endif | ||
#if defined(SPI6) | ||
case SPI_6: | ||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI6_CLKSOURCE); | ||
break; | ||
#endif | ||
default: | ||
error("CLK: SPI instance not set"); | ||
break; | ||
} | ||
if (spi_hz == LL_RCC_PERIPH_FREQUENCY_NO) { | ||
error("spi_hz not found\n"); | ||
} | ||
return spi_hz; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* mbed Microcontroller Library | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
****************************************************************************** | ||
* | ||
* Copyright (c) 2015-2024 STMicroelectronics. | ||
* All rights reserved. | ||
* | ||
* This software component is licensed by ST under BSD 3-Clause license, | ||
* the "License"; You may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* opensource.org/licenses/BSD-3-Clause | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
#ifndef MBED_SPI_DEVICE_H | ||
#define MBED_SPI_DEVICE_H | ||
|
||
#include "stm32h5xx_ll_rcc.h" | ||
#include "stm32h5xx_ll_spi.h" | ||
|
||
#define SPI_IP_VERSION_V2 | ||
|
||
// Defines the word legnth capability of the device where Nth bit allows for N window size | ||
#define STM32_SPI_CAPABILITY_WORD_LENGTH (0xFFFFFFF8) | ||
|
||
// We have DMA support | ||
#define STM32_SPI_CAPABILITY_DMA 1 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2016-2024 STMicroelectronics | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef MBED_OS_STM_DMA_INFO_H | ||
#define MBED_OS_STM_DMA_INFO_H | ||
|
||
#include "cmsis.h" | ||
#include "stm_dma_utils.h" | ||
|
||
// STM32h5 devices. | ||
// On this device, the DMA channels may be chosen arbitrarily. | ||
|
||
/// Mapping from SPI index to DMA link info for Tx | ||
static const DMALinkInfo SPITxDMALinks[] = { | ||
{1, 0, GPDMA1_REQUEST_SPI1_TX}, | ||
{1, 2, GPDMA1_REQUEST_SPI2_TX}, | ||
{1, 4, GPDMA1_REQUEST_SPI3_TX} | ||
#if defined (SPI4) | ||
,{1, 6, GPDMA1_REQUEST_SPI4_TX} | ||
#endif | ||
#if defined (SPI5) | ||
,{2, 0, GPDMA1_REQUEST_SPI5_TX} | ||
#endif | ||
#if defined (SPI6) | ||
,{2, 2, GPDMA1_REQUEST_SPI6_TX} | ||
#endif | ||
}; | ||
|
||
/// Mapping from SPI index to DMA link info for Rx | ||
static const DMALinkInfo SPIRxDMALinks[] = { | ||
{1, 1, GPDMA1_REQUEST_SPI1_RX}, | ||
{1, 3, GPDMA1_REQUEST_SPI2_RX}, | ||
{1, 5, GPDMA1_REQUEST_SPI3_TX} | ||
#if defined (SPI4) | ||
,{1, 7, GPDMA1_REQUEST_SPI4_RX} | ||
#endif | ||
#if defined (SPI5) | ||
,{2, 1, GPDMA1_REQUEST_SPI5_RX} | ||
#endif | ||
#if defined (SPI6) | ||
,{2, 3, GPDMA1_REQUEST_SPI6_RX} | ||
#endif | ||
}; | ||
|
||
|
||
|
||
#endif //MBED_OS_STM_DMA_INFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters