Skip to content

Commit 3871990

Browse files
committed
Minor cleanup to target independent code
1 parent 2e96145 commit 3871990

File tree

4 files changed

+59
-63
lines changed

4 files changed

+59
-63
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/common/cy_network_buffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction, unsigned short size, unsigned long timeout_ms)
3535
{
36-
UNUSED_PARAMETER( direction );
37-
UNUSED_PARAMETER( timeout_ms );
36+
CY_UNUSED_PARAMETER( direction );
37+
CY_UNUSED_PARAMETER( timeout_ms );
3838
struct pbuf *p = NULL;
3939
if ( ( direction == WHD_NETWORK_TX) && ( size <= PBUF_POOL_BUFSIZE ) )
4040
{
@@ -62,7 +62,7 @@ whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction
6262

6363
void cy_buffer_release(whd_buffer_t buffer, whd_buffer_dir_t direction)
6464
{
65-
UNUSED_PARAMETER( direction );
65+
CY_UNUSED_PARAMETER( direction );
6666
(void) pbuf_free( (struct pbuf *)buffer );
6767
}
6868

targets/TARGET_Cypress/TARGET_PSOC6/common/cy_serial_flash_prog.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@
2727
*******************************************************************************/
2828

2929
/**
30-
* \addtogroup group_serial_flash Serial Flash
30+
* \addtogroup group_board_libs
3131
* \{
32-
* Variables for informing programming tools that there is an attached memory device and what
33-
* its characteristics are so it can be programmed just like the on-chip memory.
34-
*
35-
* \defgroup group_serial_flash_variables Variables
32+
* In addition to the APIs for reading and writting to memory at runtime, this library also
33+
* provides support for informing programming tools about the external memory so it can be
34+
* be written at the same time as internal flash. This support can be enabled by defining
35+
* CY_ENABLE_XIP_PROGRAM while building the application. With this define in place, code
36+
* will be generated in the .cy_sflash_user_data & .cy_toc_part2 sections. These locations
37+
* can be read by programming tools (eg: Cypress Programmer, OpenOCD, pyOCD) to know that
38+
* there is a memory device attached and how to program it.
39+
* \} group_board_libs
3640
*/
3741

3842
#include <stdint.h>
@@ -51,12 +55,7 @@ typedef struct
5155
const uint32_t null_t; /* NULL termination */
5256
} stc_smif_ipblocks_arr_t;
5357

54-
/**
55-
* \addtogroup group_serial_flash_variables
56-
* \{
57-
*/
58-
59-
/**
58+
/*
6059
* This data can be placed anywhere in the internal memory, but it must be at a location that
6160
* can be determined and used for the calculation of the CRC16 checksum in the cyToc below. There
6261
* are multiple ways this can be accomplished including:
@@ -67,7 +66,7 @@ typedef struct
6766
CY_SECTION(".cy_sflash_user_data") __attribute__( (used) )
6867
const stc_smif_ipblocks_arr_t smifIpBlocksArr = {&smifBlockConfig, 0x00000000};
6968

70-
/**
69+
/*
7170
* This data is used to populate the table of contents part 2. When present, it is used by the boot
7271
* process and programming tools to determine key characteristics about the memory usage including
7372
* where the boot process should start the application from and what external memories are connected
@@ -92,12 +91,8 @@ const uint32_t cyToc[128] =
9291
[127] = 0x3BB30000 /* Offset=0x01FC: CRC16-CCITT (the upper 2 bytes contain the CRC and the lower 2 bytes are 0) */
9392
};
9493

95-
/** \} group_serial_flash_variables */
96-
9794
#endif /* defined(CY_ENABLE_XIP_PROGRAM) */
9895

9996
#if defined(__cplusplus)
10097
}
10198
#endif
102-
103-
/** \} group_serial_flash */

targets/TARGET_Cypress/TARGET_PSOC6/common/cy_serial_flash_qspi.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
#endif
3737

3838

39-
/** \cond internal */
39+
/** \cond INTERNAL */
4040

4141
/** Timeout to apply while polling the memory for its ready status after quad
4242
* 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 =
7575
* configuration */
7676
cy_rslt_t cy_serial_flash_qspi_init(
7777
const cy_stc_smif_mem_config_t* mem_config,
78-
cyhal_gpio_t io0,
79-
cyhal_gpio_t io1,
80-
cyhal_gpio_t io2,
78+
cyhal_gpio_t io0,
79+
cyhal_gpio_t io1,
80+
cyhal_gpio_t io2,
8181
cyhal_gpio_t io3,
82-
cyhal_gpio_t io4,
83-
cyhal_gpio_t io5,
84-
cyhal_gpio_t io6,
85-
cyhal_gpio_t io7,
82+
cyhal_gpio_t io4,
83+
cyhal_gpio_t io5,
84+
cyhal_gpio_t io6,
85+
cyhal_gpio_t io7,
8686
cyhal_gpio_t sclk,
87-
cyhal_gpio_t ssel,
87+
cyhal_gpio_t ssel,
8888
uint32_t hz)
8989
{
9090
cy_en_smif_status_t smifStatus = CY_SMIF_SUCCESS;
9191

92-
92+
9393
cy_rslt_t result = cyhal_qspi_init(&qspi_obj, io0, io1, io2, io3, io4, io5, io6, io7,
9494
sclk, ssel, hz, 0);
9595

@@ -106,7 +106,7 @@ cy_rslt_t cy_serial_flash_qspi_init(
106106
/* Enable Quad mode (1-1-4 or 1-4-4 modes) to use all the four I/Os during
107107
* communication.
108108
*/
109-
109+
110110
if(qspi_block_config.memConfig[MEM_SLOT]->deviceCfg->readCmd->dataWidth == CY_SMIF_WIDTH_QUAD
111111
|| qspi_block_config.memConfig[MEM_SLOT]->deviceCfg->programCmd->dataWidth == CY_SMIF_WIDTH_QUAD)
112112
{
@@ -126,13 +126,13 @@ cy_rslt_t cy_serial_flash_qspi_init(
126126
if((CY_RSLT_SUCCESS != result) || (CY_SMIF_SUCCESS != smifStatus))
127127
{
128128
cy_serial_flash_qspi_deinit();
129-
129+
130130
if(CY_SMIF_SUCCESS != smifStatus)
131131
{
132132
result = (cy_rslt_t)smifStatus;
133133
}
134134
}
135-
135+
136136
return result;
137137
}
138138

@@ -142,7 +142,7 @@ void cy_serial_flash_qspi_deinit(void)
142142
{
143143
Cy_SMIF_MemDeInit(qspi_obj.base);
144144
}
145-
145+
146146
cyhal_qspi_free(&qspi_obj);
147147
}
148148

targets/TARGET_Cypress/TARGET_PSOC6/common/cy_serial_flash_qspi.h

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
*******************************************************************************/
2626

2727
/**
28-
* \addtogroup group_serial_flash Serial Flash
28+
* \addtogroup group_board_libs Serial Flash
2929
* \{
30-
* Driver for interfacing with the serial flash (QSPI NOR flash).
31-
*
32-
* \defgroup group_serial_flash_macros Macros
33-
* \defgroup group_serial_flash_functions Functions
3430
*/
3531

3632
#pragma once
@@ -46,35 +42,31 @@
4642
extern "C" {
4743
#endif
4844

49-
/**
50-
* \addtogroup group_serial_flash_macros
51-
* \{
52-
*/
53-
5445
/** The function or operation is not supported on the target or the memory */
5546
#define CY_RSLT_SERIAL_FLASH_ERR_UNSUPPORTED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH, 1))
5647

57-
/** \} group_serial_flash_macros */
58-
5948
/**
60-
* \addtogroup group_serial_flash_functions
61-
* \{
62-
*/
63-
64-
/**
65-
* \brief Initializes the serial flash memory.
49+
* \brief Initializes the serial flash memory. This function accepts up to 8
50+
* I/Os. Number of I/Os depend on the type of memory interface. Pass NC when an
51+
* I/O is unused.
52+
* Single SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7)
53+
* Dual SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7)
54+
* Quad SPI - (io0, io1, io2, io3) or (io4, io5, io6, io7)
55+
* Octal SPI - All 8 I/Os are used.
6656
* \param mem_config Memory configuration to be used for initializing
67-
* \param io0 Data/IO pin 0 connected to the memory
68-
* \param io1 Data/IO pin 1 connected to the memory
69-
* \param io2 Data/IO pin 2 connected to the memory
70-
* \param io3 Data/IO pin 3 connected to the memory
71-
* \param io4 Data/IO pin 4 connected to the memory
72-
* \param io5 Data/IO pin 5 connected to the memory
73-
* \param io6 Data/IO pin 6 connected to the memory
74-
* \param io7 Data/IO pin 7 connected to the memory
57+
* \param io0 Data/IO pin 0 connected to the memory, Pass NC when unused.
58+
* \param io1 Data/IO pin 1 connected to the memory, Pass NC when unused.
59+
* \param io2 Data/IO pin 2 connected to the memory, Pass NC when unused.
60+
* \param io3 Data/IO pin 3 connected to the memory, Pass NC when unused.
61+
* \param io4 Data/IO pin 4 connected to the memory, Pass NC when unused.
62+
* \param io5 Data/IO pin 5 connected to the memory, Pass NC when unused.
63+
* \param io6 Data/IO pin 6 connected to the memory, Pass NC when unused.
64+
* \param io7 Data/IO pin 7 connected to the memory, Pass NC when unused.
7565
* \param sclk Clock pin connected to the memory
7666
* \param ssel Slave select pin connected to the memory
77-
* \param hz Clock frequency to be used with the memory
67+
* \param hz Clock frequency to be used with the memory. This parameter is
68+
* ignored currently. Change the CLK_HF frequency using either the
69+
Device Configurator tool or the clock driver.
7870
* \returns CY_RSLT_SUCCESS if the initialization was successful, an error code
7971
* otherwise.
8072
*/
@@ -111,6 +103,17 @@ size_t cy_serial_flash_qspi_get_size(void);
111103
*/
112104
size_t cy_serial_flash_qspi_get_erase_size(uint32_t addr);
113105

106+
/**
107+
* \brief Utility function to calculate the starting address of an erase sector
108+
* to which the given address belongs.
109+
* \param addr Address in the sector for which the starting address is returned.
110+
* \returns Starting address of the sector
111+
*/
112+
__STATIC_INLINE uint32_t cy_serial_flash_get_sector_start_address(uint32_t addr)
113+
{
114+
return (addr & ~(cy_serial_flash_qspi_get_erase_size(addr) - 1));
115+
}
116+
114117
/**
115118
* \brief Reads data from the serial flash memory. This is a blocking
116119
* 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);
162165
*/
163166
cy_rslt_t cy_serial_flash_qspi_enable_xip(bool enable);
164167

165-
/** \} group_serial_flash_functions */
166-
167168
#if defined(__cplusplus)
168169
}
169170
#endif
170171

171172
#endif /* CY_IP_MXSMIF */
172173

173-
/** \} group_serial_flash */
174+
/** \} group_board_libs */

0 commit comments

Comments
 (0)