Skip to content

Commit

Permalink
projects: ad400x-fmcz: Add stm32 platform
Browse files Browse the repository at this point in the history
This adds the stm32 platfrom to the ad400x project.
It usies the standard spi of the stm32 and was
tested using the sdp K1 development board.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
  • Loading branch information
ahaslam2 committed May 15, 2024
1 parent 619b967 commit 3b83e8f
Show file tree
Hide file tree
Showing 10 changed files with 426 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/ad400x-fmcz/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Uncomment to use the desired platform
# PLATFORM = xilinx
# PLATFORM = stm32

# Select the example you want to enable by choosing y for enabling and n for disabling
BASIC_EXAMPLE = n
Expand Down
8 changes: 8 additions & 0 deletions projects/ad400x-fmcz/builds.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@
"pulsar_adc_zed"
]
}
},
"stm32": {
"basic": {
"flags": "BASIC_EXAMPLE=y IIO_EXAMPLE=n"
},
"iio": {
"flags": "BASIC_EXAMPLE=n IIO_EXAMPLE=y"
}
}
}
158 changes: 158 additions & 0 deletions projects/ad400x-fmcz/sdp-ck1z.ioc
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#MicroXplorer Configuration settings - do not modify
CAD.formats=
CAD.pinconfig=
CAD.provider=
File.Version=6
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
Mcu.CPN=STM32F469NIH6
Mcu.Family=STM32F4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SPI1
Mcu.IP3=SYS
Mcu.IP4=UART5
Mcu.IPNb=5
Mcu.Name=STM32F469NIHx
Mcu.Package=TFBGA216
Mcu.Pin0=PB4
Mcu.Pin1=PB3
Mcu.Pin2=PC12
Mcu.Pin3=PA15
Mcu.Pin4=PD2
Mcu.Pin5=PH0/OSC_IN
Mcu.Pin6=PH1/OSC_OUT
Mcu.Pin7=PA7
Mcu.Pin8=VP_SYS_VS_Systick
Mcu.PinsNb=9
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F469NIHx
MxCube.Version=6.5.0
MxDb.Version=DB.6.0.50
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
NVIC.UART5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA15.GPIOParameters=GPIO_Speed,GPIO_Label
PA15.GPIO_Label=SPI1_CS
PA15.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PA15.Locked=true
PA15.Signal=GPIO_Output
PA7.Locked=true
PA7.Mode=Full_Duplex_Master
PA7.Signal=SPI1_MOSI
PB3.GPIOParameters=GPIO_PuPd
PB3.GPIO_PuPd=GPIO_PULLUP
PB3.Locked=true
PB3.Mode=Full_Duplex_Master
PB3.Signal=SPI1_SCK
PB4.Locked=true
PB4.Mode=Full_Duplex_Master
PB4.Signal=SPI1_MISO
PC12.Mode=Asynchronous
PC12.Signal=UART5_TX
PD2.Mode=Asynchronous
PD2.Signal=UART5_RX
PH0/OSC_IN.Mode=HSE-External-Oscillator
PH0/OSC_IN.Signal=RCC_OSC_IN
PH1/OSC_OUT.Mode=HSE-External-Oscillator
PH1/OSC_OUT.Signal=RCC_OSC_OUT
PinOutPanel.CurrentBGAView=Top
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F469NIHx
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.27.1
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=sdp-ck1z.ioc
ProjectManager.ProjectName=sdp-ck1z
ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_UART5_Init-UART5-false-HAL-true,4-MX_SPI1_Init-SPI1-false-HAL-true
RCC.AHBFreq_Value=180000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
RCC.APB1Freq_Value=45000000
RCC.APB1TimFreq_Value=90000000
RCC.APB2CLKDivider=RCC_HCLK_DIV2
RCC.APB2Freq_Value=90000000
RCC.APB2TimFreq_Value=180000000
RCC.CortexFreq_Value=180000000
RCC.DSIFreq_Value=20000000
RCC.DSITXEscFreq_Value=5000000
RCC.EthernetFreq_Value=180000000
RCC.FCLKCortexFreq_Value=180000000
RCC.FamilyName=M
RCC.HCLKFreq_Value=180000000
RCC.HSE_VALUE=8000000
RCC.HSICalibrationValue=16
RCC.I2SFreq_Value=192000000
RCC.IPParameters=AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,DSIFreq_Value,DSITXEscFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSICalibrationValue,I2SFreq_Value,LCDTFTFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLDSIFreq_Value,PLLDSIVCOFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLM,PLLN,PLLQCLKFreq_Value,PLLRCLKFreq_Value,PLLRFreq_Value,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSourceVirtual,RTCFreq_Value,RTCHSEDivFreq_Value,SAIAFreq_Value,SAIBFreq_Value,SDIOFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value
RCC.LCDTFTFreq_Value=96000000
RCC.MCO2PinFreq_Value=180000000
RCC.PLLCLKFreq_Value=180000000
RCC.PLLDSIFreq_Value=160000000
RCC.PLLDSIVCOFreq_Value=320000000
RCC.PLLI2SQCLKFreq_Value=96000000
RCC.PLLI2SRCLKFreq_Value=192000000
RCC.PLLM=4
RCC.PLLN=180
RCC.PLLQCLKFreq_Value=90000000
RCC.PLLRCLKFreq_Value=180000000
RCC.PLLRFreq_Value=180000000
RCC.PLLSAIPCLKFreq_Value=192000000
RCC.PLLSAIQCLKFreq_Value=96000000
RCC.PLLSAIRCLKFreq_Value=192000000
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
RCC.RTCFreq_Value=32000
RCC.RTCHSEDivFreq_Value=4000000
RCC.SAIAFreq_Value=96000000
RCC.SAIBFreq_Value=96000000
RCC.SDIOFreq_Value=90000000
RCC.SYSCLKFreq_VALUE=180000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.USBFreq_Value=90000000
RCC.VCOI2SOutputFreq_Value=384000000
RCC.VCOInputFreq_Value=2000000
RCC.VCOOutputFreq_Value=360000000
RCC.VCOSAIOutputFreq_Value=384000000
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
SPI1.CalculateBaudRate=45.0 MBits/s
SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER
UART5.IPParameters=VirtualMode
UART5.VirtualMode=Asynchronous
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=custom
2 changes: 2 additions & 0 deletions projects/ad400x-fmcz/src.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ INCS += $(PROJECT)/src/common/common_data.h \
$(PROJECT)/src/platform/$(PLATFORM)/parameters.h

SRCS += $(DRIVERS)/api/no_os_spi.c \
$(DRIVERS)/api/no_os_dma.c \
$(DRIVERS)/api/no_os_gpio.c \
$(DRIVERS)/api/no_os_uart.c \
$(DRIVERS)/api/no_os_pwm.c \
Expand All @@ -30,6 +31,7 @@ SRCS += $(NO-OS)/util/no_os_util.c \

INCS += $(INCLUDE)/no_os_axi_io.h \
$(INCLUDE)/no_os_spi.h \
$(INCLUDE)/no_os_dma.h \
$(INCLUDE)/no_os_gpio.h \
$(INCLUDE)/no_os_error.h \
$(INCLUDE)/no_os_delay.h \
Expand Down
3 changes: 3 additions & 0 deletions projects/ad400x-fmcz/src/examples/examples_src.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ endif
ifeq (xilinx,$(PLATFORM))
CFLAGS += -DSPI_ENGINE_OFFLOAD_EXAMPLE
endif
ifeq (stm32,$(PLATFORM))
CFLAGS += -DUSE_STANDARD_SPI
endif

ifeq (y,$(strip $(IIO_EXAMPLE)))
CFLAGS += -DIIO_EXAMPLE=1
Expand Down
2 changes: 2 additions & 0 deletions projects/ad400x-fmcz/src/platform/platform_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
/******************************************************************************/
#ifdef XILINX_PLATFORM
#include "xilinx/parameters.h"
#elif defined STM32_PLATFORM
#include "stm32/parameters.h"
#endif

#ifdef IIO_SUPPORT
Expand Down
79 changes: 79 additions & 0 deletions projects/ad400x-fmcz/src/platform/stm32/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/***************************************************************************//**
* @file main.c
* @brief Main file for STM32 platform of ad400x-fmcz project.
* @author Axel Haslam (ahaslam@baylibre.com)
********************************************************************************
* Copyright 2024(c) Analog Devices, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - 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.
* - The use of this software may or may not infringe the patent rights
* of one or more patent holders. This license does not release you
* from the requirement that you obtain separate licenses from these
* patent holders to use this software.
* - Use of the software either in source or binary form, must be run
* on or directly connected to an Analog Devices Inc. component.
*
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.
*******************************************************************************/

/******************************************************************************/
/***************************** Include Files **********************************/
/******************************************************************************/
#include "platform_includes.h"
#include "common_data.h"
#include "no_os_error.h"

#ifdef BASIC_EXAMPLE
#include "basic_example.h"
#elif defined(IIO_EXAMPLE)
#include "iio_example.h"
#endif

/***************************************************************************//**
* @brief Main function execution for STM32 platform.
*
* @return ret - Result of the enabled examples execution.
*******************************************************************************/
int main()
{
int ret = -EINVAL;

stm32_init();
#ifdef BASIC_EXAMPLE
struct no_os_uart_desc *uart;

ret = no_os_uart_init(&uart, &ad400x_uart_ip);
if (ret)
return ret;

no_os_uart_stdio(uart);

ret = basic_example_main();
#elif defined(IIO_EXAMPLE)
ret = iio_example_main();
#else
#error At least one example has to be selected using y value in Makefile.
#endif
return ret;
}
57 changes: 57 additions & 0 deletions projects/ad400x-fmcz/src/platform/stm32/parameters.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/***************************************************************************//**
* @file parameters.c
* @brief Definition of STM32 platform data used by eval-ad400x project.
* @author Axel Haslam (ahaslam@baylibre.com)
********************************************************************************
* Copyright 2024(c) Analog Devices, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - 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.
* - The use of this software may or may not infringe the patent rights
* of one or more patent holders. This license does not release you
* from the requirement that you obtain separate licenses from these
* patent holders to use this software.
* - Use of the software either in source or binary form, must be run
* on or directly connected to an Analog Devices Inc. component.
*
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.
*******************************************************************************/

/******************************************************************************/
/***************************** Include Files **********************************/
/******************************************************************************/
#include "parameters.h"

/******************************************************************************/
/********************** Macros and Constants Definitions **********************/
/******************************************************************************/
uint8_t in_buff[MAX_SIZE_BASE_ADDR] = {0};

struct stm32_uart_init_param ad400x_uart_extra_ip = {
.huart = &huart5,
};

struct stm32_spi_init_param ad400x_spi_extra_ip = {
.chip_select_port = SPI_CS_PORT,
.get_input_clock = HAL_RCC_GetPCLK2Freq,
};
Loading

0 comments on commit 3b83e8f

Please sign in to comment.