mirror of https://github.com/ARMmbed/mbed-os.git
Minor cleanup to target independent code
parent
2e96145b76
commit
38719908d1
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
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 );
|
||||
CY_UNUSED_PARAMETER( direction );
|
||||
CY_UNUSED_PARAMETER( timeout_ms );
|
||||
struct pbuf *p = NULL;
|
||||
if ( ( direction == WHD_NETWORK_TX) && ( size <= PBUF_POOL_BUFSIZE ) )
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction
|
|||
|
||||
void cy_buffer_release(whd_buffer_t buffer, whd_buffer_dir_t direction)
|
||||
{
|
||||
UNUSED_PARAMETER( direction );
|
||||
CY_UNUSED_PARAMETER( direction );
|
||||
(void) pbuf_free( (struct pbuf *)buffer );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,16 @@
|
|||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash Serial Flash
|
||||
* \addtogroup group_board_libs
|
||||
* \{
|
||||
* Variables for informing programming tools that there is an attached memory device and what
|
||||
* its characteristics are so it can be programmed just like the on-chip memory.
|
||||
*
|
||||
* \defgroup group_serial_flash_variables Variables
|
||||
* In addition to the APIs for reading and writting to memory at runtime, this library also
|
||||
* provides support for informing programming tools about the external memory so it can be
|
||||
* be written at the same time as internal flash. This support can be enabled by defining
|
||||
* CY_ENABLE_XIP_PROGRAM while building the application. With this define in place, code
|
||||
* will be generated in the .cy_sflash_user_data & .cy_toc_part2 sections. These locations
|
||||
* can be read by programming tools (eg: Cypress Programmer, OpenOCD, pyOCD) to know that
|
||||
* there is a memory device attached and how to program it.
|
||||
* \} group_board_libs
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
@ -51,12 +55,7 @@ typedef struct
|
|||
const uint32_t null_t; /* NULL termination */
|
||||
} stc_smif_ipblocks_arr_t;
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash_variables
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* This data can be placed anywhere in the internal memory, but it must be at a location that
|
||||
* can be determined and used for the calculation of the CRC16 checksum in the cyToc below. There
|
||||
* are multiple ways this can be accomplished including:
|
||||
|
|
@ -67,7 +66,7 @@ typedef struct
|
|||
CY_SECTION(".cy_sflash_user_data") __attribute__( (used) )
|
||||
const stc_smif_ipblocks_arr_t smifIpBlocksArr = {&smifBlockConfig, 0x00000000};
|
||||
|
||||
/**
|
||||
/*
|
||||
* This data is used to populate the table of contents part 2. When present, it is used by the boot
|
||||
* 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
|
||||
|
|
@ -92,12 +91,8 @@ const uint32_t cyToc[128] =
|
|||
[127] = 0x3BB30000 /* Offset=0x01FC: CRC16-CCITT (the upper 2 bytes contain the CRC and the lower 2 bytes are 0) */
|
||||
};
|
||||
|
||||
/** \} group_serial_flash_variables */
|
||||
|
||||
#endif /* defined(CY_ENABLE_XIP_PROGRAM) */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \} group_serial_flash */
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/** \cond internal */
|
||||
/** \cond INTERNAL */
|
||||
|
||||
/** Timeout to apply while polling the memory for its ready status after quad
|
||||
* enable command has been sent out. Quad enable is a non-volatile write.
|
||||
|
|
@ -75,21 +75,21 @@ static cy_stc_smif_block_config_t qspi_block_config =
|
|||
* configuration */
|
||||
cy_rslt_t cy_serial_flash_qspi_init(
|
||||
const cy_stc_smif_mem_config_t* mem_config,
|
||||
cyhal_gpio_t io0,
|
||||
cyhal_gpio_t io1,
|
||||
cyhal_gpio_t io2,
|
||||
cyhal_gpio_t io0,
|
||||
cyhal_gpio_t io1,
|
||||
cyhal_gpio_t io2,
|
||||
cyhal_gpio_t io3,
|
||||
cyhal_gpio_t io4,
|
||||
cyhal_gpio_t io5,
|
||||
cyhal_gpio_t io6,
|
||||
cyhal_gpio_t io7,
|
||||
cyhal_gpio_t io4,
|
||||
cyhal_gpio_t io5,
|
||||
cyhal_gpio_t io6,
|
||||
cyhal_gpio_t io7,
|
||||
cyhal_gpio_t sclk,
|
||||
cyhal_gpio_t ssel,
|
||||
cyhal_gpio_t ssel,
|
||||
uint32_t hz)
|
||||
{
|
||||
cy_en_smif_status_t smifStatus = CY_SMIF_SUCCESS;
|
||||
|
||||
|
||||
|
||||
cy_rslt_t result = cyhal_qspi_init(&qspi_obj, io0, io1, io2, io3, io4, io5, io6, io7,
|
||||
sclk, ssel, hz, 0);
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ cy_rslt_t cy_serial_flash_qspi_init(
|
|||
/* Enable Quad mode (1-1-4 or 1-4-4 modes) to use all the four I/Os during
|
||||
* communication.
|
||||
*/
|
||||
|
||||
|
||||
if(qspi_block_config.memConfig[MEM_SLOT]->deviceCfg->readCmd->dataWidth == CY_SMIF_WIDTH_QUAD
|
||||
|| qspi_block_config.memConfig[MEM_SLOT]->deviceCfg->programCmd->dataWidth == CY_SMIF_WIDTH_QUAD)
|
||||
{
|
||||
|
|
@ -126,13 +126,13 @@ cy_rslt_t cy_serial_flash_qspi_init(
|
|||
if((CY_RSLT_SUCCESS != result) || (CY_SMIF_SUCCESS != smifStatus))
|
||||
{
|
||||
cy_serial_flash_qspi_deinit();
|
||||
|
||||
|
||||
if(CY_SMIF_SUCCESS != smifStatus)
|
||||
{
|
||||
result = (cy_rslt_t)smifStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ void cy_serial_flash_qspi_deinit(void)
|
|||
{
|
||||
Cy_SMIF_MemDeInit(qspi_obj.base);
|
||||
}
|
||||
|
||||
|
||||
cyhal_qspi_free(&qspi_obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,8 @@
|
|||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash Serial Flash
|
||||
* \addtogroup group_board_libs Serial Flash
|
||||
* \{
|
||||
* Driver for interfacing with the serial flash (QSPI NOR flash).
|
||||
*
|
||||
* \defgroup group_serial_flash_macros Macros
|
||||
* \defgroup group_serial_flash_functions Functions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
@ -46,35 +42,31 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash_macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** The function or operation is not supported on the target or the memory */
|
||||
#define CY_RSLT_SERIAL_FLASH_ERR_UNSUPPORTED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH, 1))
|
||||
|
||||
/** \} group_serial_flash_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash_functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initializes the serial flash memory.
|
||||
* \brief Initializes the serial flash memory. This function accepts up to 8
|
||||
* I/Os. Number of I/Os depend on the type of memory interface. Pass NC when an
|
||||
* I/O is unused.
|
||||
* Single SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7)
|
||||
* Dual SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7)
|
||||
* Quad SPI - (io0, io1, io2, io3) or (io4, io5, io6, io7)
|
||||
* Octal SPI - All 8 I/Os are used.
|
||||
* \param mem_config Memory configuration to be used for initializing
|
||||
* \param io0 Data/IO pin 0 connected to the memory
|
||||
* \param io1 Data/IO pin 1 connected to the memory
|
||||
* \param io2 Data/IO pin 2 connected to the memory
|
||||
* \param io3 Data/IO pin 3 connected to the memory
|
||||
* \param io4 Data/IO pin 4 connected to the memory
|
||||
* \param io5 Data/IO pin 5 connected to the memory
|
||||
* \param io6 Data/IO pin 6 connected to the memory
|
||||
* \param io7 Data/IO pin 7 connected to the memory
|
||||
* \param io0 Data/IO pin 0 connected to the memory, Pass NC when unused.
|
||||
* \param io1 Data/IO pin 1 connected to the memory, Pass NC when unused.
|
||||
* \param io2 Data/IO pin 2 connected to the memory, Pass NC when unused.
|
||||
* \param io3 Data/IO pin 3 connected to the memory, Pass NC when unused.
|
||||
* \param io4 Data/IO pin 4 connected to the memory, Pass NC when unused.
|
||||
* \param io5 Data/IO pin 5 connected to the memory, Pass NC when unused.
|
||||
* \param io6 Data/IO pin 6 connected to the memory, Pass NC when unused.
|
||||
* \param io7 Data/IO pin 7 connected to the memory, Pass NC when unused.
|
||||
* \param sclk Clock pin connected to the memory
|
||||
* \param ssel Slave select pin connected to the memory
|
||||
* \param hz Clock frequency to be used with the memory
|
||||
* \param hz Clock frequency to be used with the memory. This parameter is
|
||||
* ignored currently. Change the CLK_HF frequency using either the
|
||||
Device Configurator tool or the clock driver.
|
||||
* \returns CY_RSLT_SUCCESS if the initialization was successful, an error code
|
||||
* otherwise.
|
||||
*/
|
||||
|
|
@ -111,6 +103,17 @@ size_t cy_serial_flash_qspi_get_size(void);
|
|||
*/
|
||||
size_t cy_serial_flash_qspi_get_erase_size(uint32_t addr);
|
||||
|
||||
/**
|
||||
* \brief Utility function to calculate the starting address of an erase sector
|
||||
* to which the given address belongs.
|
||||
* \param addr Address in the sector for which the starting address is returned.
|
||||
* \returns Starting address of the sector
|
||||
*/
|
||||
__STATIC_INLINE uint32_t cy_serial_flash_get_sector_start_address(uint32_t addr)
|
||||
{
|
||||
return (addr & ~(cy_serial_flash_qspi_get_erase_size(addr) - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads data from the serial flash memory. This is a blocking
|
||||
* function. Returns error if (addr + length) exceeds the flash size.
|
||||
|
|
@ -162,12 +165,10 @@ cy_rslt_t cy_serial_flash_qspi_erase(uint32_t addr, size_t length);
|
|||
*/
|
||||
cy_rslt_t cy_serial_flash_qspi_enable_xip(bool enable);
|
||||
|
||||
/** \} group_serial_flash_functions */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CY_IP_MXSMIF */
|
||||
|
||||
/** \} group_serial_flash */
|
||||
/** \} group_board_libs */
|
||||
|
|
|
|||
Loading…
Reference in New Issue