Skip to content

Commit

Permalink
Update common libraries
Browse files Browse the repository at this point in the history
Updated Serial Flash interface & Network buffer classes to avoid warnings and improve robustness. Fixed issue with mbed_overrides trying to use an old implementation of cy_serial_flash_init() function.
  • Loading branch information
cy-opm authored and adbridge committed Nov 18, 2019
1 parent d842762 commit ba19dfb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
#include <stdlib.h>
#include "cy_network_buffer.h"
#include "cy_utils.h"
#include "memp.h"
#include "lwip/memp.h"
#define SDIO_BLOCK_SIZE (64U)

whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction, unsigned short size, unsigned long timeout_ms)
{
UNUSED_PARAMETER( direction );
UNUSED_PARAMETER( timeout_ms );
struct pbuf *p = NULL;
if ( ( direction == WHD_NETWORK_TX) && ( size <= PBUF_POOL_BUFSIZE ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "cy_result.h"
#include "whd.h"
#include "whd_network_types.h"
#include "pbuf.h"
#include "lwip/pbuf.h"

#if defined(__cplusplus)
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const stc_smif_ipblocks_arr_t smifIpBlocksArr = {&smifBlockConfig, 0x00000000};
* process and programming tools to determine key characteristics about the memory usage including
* where the boot process should start the application from and what external memories are connected
* (if any). This must consume a full row of flash memory row. The last entry is a checksum of the
* other values in the ToC which must be updated if any other value changes.
* other values in the ToC which must be updated if any other value changes. This can be done manually
* or by running 'cymcuelftool -S' to recompute the checksum.
*/
CY_SECTION(".cy_toc_part2") __attribute__( (used) )
const uint32_t cyToc[128] =
Expand Down
23 changes: 14 additions & 9 deletions targets/TARGET_Cypress/TARGET_PSOC6/common/cy_serial_flash_qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {

/* SMIF slot from which the memory configuration is picked up - fixed to 0 as the driver
* supports only one device */
#define MEM_SLOT (0u)
#define MEM_SLOT (0u)

/** \endcond */

Expand Down Expand Up @@ -123,21 +123,26 @@ cy_rslt_t cy_serial_flash_qspi_init(
}
}

if((CY_RSLT_SUCCESS == result) && (CY_SMIF_SUCCESS == smifStatus))
if((CY_RSLT_SUCCESS != result) || (CY_SMIF_SUCCESS != smifStatus))
{
return CY_RSLT_SUCCESS;
}
else
{
Cy_SMIF_MemDeInit(qspi_obj.base);
cy_serial_flash_qspi_deinit();
return (cy_rslt_t)smifStatus;

if(CY_SMIF_SUCCESS != smifStatus)
{
result = (cy_rslt_t)smifStatus;
}
}

return result;
}

void cy_serial_flash_qspi_deinit(void)
{
Cy_SMIF_MemDeInit(qspi_obj.base);
if (qspi_obj.base != NULL)
{
Cy_SMIF_MemDeInit(qspi_obj.base);
}

cyhal_qspi_free(&qspi_obj);
}

Expand Down
19 changes: 9 additions & 10 deletions targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "mbed_power_mgmt.h"
#include "rtos_idle.h"
#include "us_ticker_api.h"

#if defined(CY_ENABLE_XIP_PROGRAM)
#include "cycfg_qspi_memslot.h"
#endif /*defined(CY_ENABLE_XIP_PROGRAM)*/
#if defined(MBED_CONF_TARGET_XIP_ENABLE)
#include "cy_serial_flash_qspi.h"
#endif /* defined(MBED_CONF_TARGET_XIP_ENABLE) */
Expand Down Expand Up @@ -70,31 +74,26 @@ void mbed_sdk_init(void)
mailbox_init();
#endif

#if (CY_CPU_CORTEX_M0P)
#if defined(COMPONENT_SPE)
/* Set up the device based on configurator selections */
init_cycfg_all();
#endif
cybsp_init();

#if (CY_CPU_CORTEX_M0P)
#if !defined(COMPONENT_SPM_MAILBOX)
/* Enable global interrupts */
__enable_irq();
#endif
#else
#if !defined(TARGET_PSA)
/* Set up the device based on configurator selections */
cybsp_init();
/*
* Init the us Ticker here to avoid imposing on the limited stack space of the idle thread.
* This also allows the first call to sleep to occur faster.
*/
us_ticker_init();
#endif

#if defined(CYBSP_ENABLE_FLASH_STORAGE)
/* The linker script allows storing data in external memory, if needed, enable access to that memory. */
cy_serial_flash_init();
cy_serial_flash_enable_xip(true);
const uint32_t bus_frequency = 50000000lu;
cy_serial_flash_qspi_init(smifMemConfigs[0], CYBSP_QSPI_D0, CYBSP_QSPI_D1, CYBSP_QSPI_D2, CYBSP_QSPI_D3, NC, NC, NC, NC, CYBSP_QSPI_SCK, CYBSP_QSPI_SS, bus_frequency);
cy_serial_flash_qspi_enable_xip(true);
#endif

/* Enable global interrupts (disabled in CM4 startup assembly) */
Expand Down

0 comments on commit ba19dfb

Please sign in to comment.