Skip to content

Commit

Permalink
Merged mss-spi source code version 2.1.102.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lavakrishna authored and Lavakrishna committed Jun 28, 2023
2 parents 1f7e9f9 + 7b0771a commit 74855eb
Show file tree
Hide file tree
Showing 85 changed files with 5,993 additions and 4,296 deletions.
14 changes: 12 additions & 2 deletions driver-examples/mss/mss-spi/mpfs-spi-flash/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,15 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/boards/icicle-kit-es/platform_config}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.1062538732" name="Other assembler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="--specs=nano.specs" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs.421152303" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
</option>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1421831297" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool command="${cross_prefix}${cross_c}${cross_suffix}" commandLinePattern="${COMMAND} ${cross_toolchain_flags} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GCCErrorParser" id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1302065814" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.1809767938" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.1809767938" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1677881098" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/application}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platform}&quot;"/>
Expand Down Expand Up @@ -420,10 +425,15 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platform/platform_config_reference}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.1337214983" name="Other assembler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="--specs=nano.specs" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs.1232681309" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
</option>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1119827719" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool command="${cross_prefix}${cross_c}${cross_suffix}" commandLinePattern="${COMMAND} ${cross_toolchain_flags} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GCCErrorParser" id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.353851626" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.282256570" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.282256570" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.2102873659" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/application}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platform}&quot;"/>
Expand Down
29 changes: 17 additions & 12 deletions driver-examples/mss/mss-spi/mpfs-spi-flash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

This example project demonstrates the use of the PolarFire MSS SPI hardware
block. It reads and writes the content of an external SPI flash device. The
PolarFire SoC is configured as a master and SPI Flash acts as a slave for this
particular example project.
PolarFire SoC MSS SPI1 is configured as a master and SPI Flash acts as a slave.
The **(Micron MT25Q)** device available on the Mikrobus click board "MT25QL01GBBB"
connected on the MikroBus socket on Icicle kit was used to test this example project.

# How to use this example

**NOTE:** This project can not be directly used on the Icicle kit since the
flash memory device is not accessible via SPI.This example project is provided
as reference to demonstrate how to use the MSS SPI driver for accessing SPI Flash.
On connecting Icicle kit J11 to the host PC, you should see 4 COM port interfaces
connected. To use this project configure the COM port **interface1** as below:

The example project is targeted to PolarFire SoC hardware platform. The SPI0 is
configured in master mode whereas SPI flash is the slave. The data is then
transferred between SPI0 and SPI Flash.
Run the example project using a debugger. Place watches on buffers
g_flash_wr_buf and g_flash_rd_buf. You will then be able to observe the content
of g_flash_wr_buf being written into external flash and read back into the
g_flash_rd_buf buffer.
- 115200 baud
- 8 data bits
- 1 stop bit
- no parity
- no flow control

The example project is targeted to PolarFire SoC hardware platform. This is a self
contained example project. A greeting message is displayed over the UART terminal.

It configures the MSS SPI1 as master and the flash memory in the normal SPI mode
and does the write, read operations on it in that sequence. It then cross-checks
the content read from the memory with the contents that were written to it. A pass
or fail message is displayed as per the results.

This project provides build configurations and debug launchers as explained
[here](https://mi-v-ecosystem.github.io/redirects/repo-polarfire-soc-bare-metal-examples)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.openocd.launchConfigurationType">
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="false"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="true"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
/*******************************************************************************
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Application code running on E51
* @file e51.c
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief Application code running on E51
*
*/

#include <stdio.h>
#include <string.h>
#include "mpfs_hal/mss_hal.h"
#include "drivers/mss/mss_mmuart/mss_uart.h"

volatile uint32_t count_sw_ints_h0 = 0U;

Expand All @@ -32,12 +38,21 @@ void e51(void)
clear_soft_interrupt();
set_csr(mie, MIP_MSIP);

(void)mss_config_clk_rst(MSS_PERIPH_MMUART0, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_ON);

MSS_UART_init( &g_mss_uart0_lo,
MSS_UART_115200_BAUD,
MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

MSS_UART_polled_tx_string(&g_mss_uart0_lo ,
(const uint8_t*)"\r\nThis message is from E51.\
\r\nApplication will execute from U54_1.\r\n");

#if (IMAGE_LOADED_BY_BOOTLOADER == 0)

/* Raise software interrupt to wake hart 1 */

raise_soft_interrupt(1U);

#endif

__enable_irq();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
/**************************************************************************//**
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
/******************************************************************************
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Application code running on U54.
* @file u54_1.c
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief Application code running on U54_1.
*
* This example project demonstrates the use of the PolarFire MSS SPI hardware
* block. It reads and writes the content of an external SPI flash device.
*
*/

#include <stdint.h>
#include <string.h>
#include "mpfs_hal/mss_hal.h"
#include "drivers/mss/mss_spi/mss_spi.h"
#include "drivers/off-chip/mt25ql01gbbb/mt25ql01gbbb.h"
#include "drivers/mss/mss_mmuart/mss_uart.h"

#define BUFFER_SIZE 3000U

Expand All @@ -29,6 +35,23 @@ static uint8_t g_flash_rd_buf[BUFFER_SIZE];
static uint8_t verify_write(uint8_t* write_buff, uint8_t* read_buff, uint16_t size);
static void mss_spi_overflow_handler(uint8_t mss_spi_core);

uint8_t g_message[] =
"\r\n\r\n\
******************* PolarFire SoC MSS SPI Example Project ********************\r\n\
\r\n\r\n";

uint8_t g_message1[] =
"\r\n\r\n\
Write-Read test on the SPI flash successful\r\n\
\r\n\r\n\
Data stored in g_flash_rd_buf is identical from the data stored in g_flash_wr_buf";

uint8_t g_message2[] =
"\r\n\r\n\
Write-Read test on the SPI flash failed\r\n\
\r\n\r\n\
Data stored in g_flash_rd_buf is different from the data stored in g_flash_wr_buf";

/**************************************************************************//**
* Main Function
*/
Expand All @@ -43,6 +66,9 @@ void u54_1(void)

#if (IMAGE_LOADED_BY_BOOTLOADER == 0)

clear_soft_interrupt();
set_csr(mie, MIP_MSIP);

/*Put this hart into WFI.*/

do
Expand All @@ -55,7 +81,14 @@ void u54_1(void)
clear_soft_interrupt();
#endif

SYSREG->SOFT_RESET_CR &= ~(0x01UL << 10U);
(void)mss_config_clk_rst(MSS_PERIPH_SPI1, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_ON);
(void)mss_config_clk_rst(MSS_PERIPH_MMUART1, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_ON);

MSS_UART_init(&g_mss_uart1_lo,
MSS_UART_115200_BAUD,
MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

MSS_UART_polled_tx(&g_mss_uart1_lo,g_message,sizeof(g_message));

/**************************************************************************//**
* Initialize write and read buffers
Expand All @@ -76,16 +109,16 @@ void u54_1(void)
* Flash Driver Initialization
*/

FLASH_init(&g_mss_spi0_lo, mss_spi_overflow_handler);
FLASH_init(&g_mss_spi1_lo, mss_spi_overflow_handler);

FLASH_global_unprotect(&g_mss_spi0_lo);
FLASH_global_unprotect(&g_mss_spi1_lo);

FLASH_erase_64k_block(&g_mss_spi0_lo, 0U);
FLASH_erase_64k_block(&g_mss_spi1_lo, 0U);

/**************************************************************************//**
* Check SPI Flash part manufacturer and device ID.
*/
FLASH_read_device_id(&g_mss_spi0_lo, &manufacturer_id, &device_id);
FLASH_read_device_id(&g_mss_spi1_lo, &manufacturer_id, &device_id);
if((FLASH_MANUFACTURER_ID != manufacturer_id) || (FLASH_DEVICE_ID != device_id))
{
++errors;
Expand All @@ -95,14 +128,23 @@ void u54_1(void)
* Write Data to Flash.
*/
address = 200U;
FLASH_program(&g_mss_spi0_lo, address, g_flash_wr_buf, sizeof(g_flash_wr_buf));
FLASH_program(&g_mss_spi1_lo, address, g_flash_wr_buf, sizeof(g_flash_wr_buf));

/* Read Data From Flash */
address = 200U;
FLASH_read(&g_mss_spi0_lo, address, g_flash_rd_buf, sizeof(g_flash_wr_buf));
FLASH_read(&g_mss_spi1_lo, address, g_flash_rd_buf, sizeof(g_flash_wr_buf));

errors = verify_write(g_flash_rd_buf, g_flash_wr_buf, sizeof(g_flash_wr_buf));

if (0 == errors)
{
MSS_UART_polled_tx(&g_mss_uart1_lo,g_message1,sizeof(g_message1));
}
else
{
MSS_UART_polled_tx(&g_mss_uart1_lo,g_message2,sizeof(g_message2));
}

while(1U)
{
;
Expand Down Expand Up @@ -139,14 +181,15 @@ static void mss_spi_overflow_handler(uint8_t mss_spi_core)
if (mss_spi_core)
{
/* reset SPI1 */
(void)mss_config_clk_rst(MSS_PERIPH_SPI1, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_OFF);
/* Take SPI1 out of reset. */
(void)mss_config_clk_rst(MSS_PERIPH_SPI1, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_ON);

}
else
{
/* reset SPI0 */

(void)mss_config_clk_rst(MSS_PERIPH_SPI0, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_OFF);
/* Take SPI0 out of reset. */
(void)mss_config_clk_rst(MSS_PERIPH_SPI0, (uint8_t) MPFS_HAL_FIRST_HART, PERIPHERAL_ON);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/*******************************************************************************
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Application code running on U54_2
* @file u54_2.c
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief Application code running on U54_2
*
*/

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/*******************************************************************************
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Application code running on U54_3
* @file u54_3.c
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief Application code running on U54_3
*
*/

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/*******************************************************************************
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Application code running on U54_4
* @file u54_4.c
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief Application code running on U54_4
*
*/

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/*************************************************************************//**
* Copyright 2019-2020 Microchip FPGA Embedded Systems Solutions.
* common.h
/*****************************************************************************
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* @file common.h
*
* @author Microchip FPGA Embedded Systems Solutions
*
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/*******************************************************************************
* Copyright 2019-2022 Microchip FPGA Embedded Systems Solutions.
* Copyright 2019 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* MPFS HAL Embedded Software
* @file mss_sw_config.h
*
* @author Microchip FPGA Embedded Systems Solutions
*
* @brief MPFS HAL Embedded Software
*
*/

Expand Down
Loading

0 comments on commit 74855eb

Please sign in to comment.