1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/driver_atwinc15x0/patches/0006-rename-spi_flash_-functons.patch
2020-06-26 12:36:56 +02:00

375 lines
12 KiB
Diff

From f904e4d6ec1d6d5afa8f7b6da2822fb9e332796a Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Thu, 2 Apr 2020 01:54:57 +0200
Subject: [PATCH 6/6] rename spi_flash_* functons
---
src/driver/source/nmdrv.c | 2 +-
src/spi_flash/include/spi_flash.h | 10 ++--
src/spi_flash/source/spi_flash.c | 86 +++++++++++++++----------------
3 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/src/driver/source/nmdrv.c b/src/driver/source/nmdrv.c
index 3de10c3..d29560a 100644
--- a/src/driver/source/nmdrv.c
+++ b/src/driver/source/nmdrv.c
@@ -385,7 +385,7 @@ sint8 nm_drv_deinit(void * arg)
}
/* Disable SPI flash to save power when the chip is off */
- /* ret = spi_flash_enable(0); */
+ ret = atwinc15x0_flash_enable(0);
if (M2M_SUCCESS != ret) {
M2M_ERR("[nmi stop]: SPI flash disable fail\n");
goto ERR1;
diff --git a/src/spi_flash/include/spi_flash.h b/src/spi_flash/include/spi_flash.h
index a85aa72..41515d8 100644
--- a/src/spi_flash/include/spi_flash.h
+++ b/src/spi_flash/include/spi_flash.h
@@ -124,7 +124,7 @@ extern "C" {
* @brief Enable spi flash operations
* @version 1.0
*/
-sint8 spi_flash_enable(uint8 enable);
+sint8 atwinc15x0_flash_enable(uint8 enable);
/** \defgroup SPIFLASHAPI Function
* @ingroup SPIFLASH
*/
@@ -139,7 +139,7 @@ sint8 spi_flash_enable(uint8 enable);
* @note Returned value in Mb (Mega Bit).
* @return SPI flash size in case of success and a ZERO value in case of failure.
*/
-uint32 spi_flash_get_size(void);
+uint32 atwinc15x0_flash_get_size(void);
/**@}*/
/** @defgroup SPiFlashRead spi_flash_read
@@ -166,7 +166,7 @@ uint32 spi_flash_get_size(void);
* @sa m2m_wifi_download_mode, spi_flash_get_size
* @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
*/
-sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz);
+sint8 atwinc15x0_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz);
/**@}*/
/** @defgroup SPiFlashWrite spi_flash_write
@@ -197,7 +197,7 @@ sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz);
* @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
*/
-sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz);
+sint8 atwinc15x0_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz);
/**@}*/
/** @defgroup SPiFlashErase spi_flash_erase
@@ -223,7 +223,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz);
* @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
*/
-sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz);
+sint8 atwinc15x0_flash_erase(uint32 u32Offset, uint32 u32Sz);
/**@}*/
#ifdef ARDUINO
#ifdef __cplusplus
diff --git a/src/spi_flash/source/spi_flash.c b/src/spi_flash/source/spi_flash.c
index 12eff59..e70827c 100644
--- a/src/spi_flash/source/spi_flash.c
+++ b/src/spi_flash/source/spi_flash.c
@@ -96,7 +96,7 @@ SPI Flash DMA
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_read_status_reg(uint8 * val)
+static sint8 atwinc15x0_flash_read_status_reg(uint8 * val)
{
sint8 ret = M2M_SUCCESS;
uint8 cmd[1];
@@ -130,7 +130,7 @@ static sint8 spi_flash_read_status_reg(uint8 * val)
* @author M. Abdelmawla
* @version 1.0
*/
-static uint8 spi_flash_read_security_reg(void)
+static uint8 atwinc15x0_flash_read_security_reg(void)
{
uint8 cmd[1];
uint32 reg;
@@ -161,7 +161,7 @@ static uint8 spi_flash_read_security_reg(void)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_gang_unblock(void)
+static sint8 atwinc15x0_flash_gang_unblock(void)
{
uint8 cmd[1];
uint32 val = 0;
@@ -191,7 +191,7 @@ static sint8 spi_flash_gang_unblock(void)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_clear_security_flags(void)
+static sint8 atwinc15x0_flash_clear_security_flags(void)
{
uint8 cmd[1];
uint32 val = 0;
@@ -229,7 +229,7 @@ static sint8 spi_flash_clear_security_flags(void)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
+static sint8 atwinc15x0_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
{
uint8 cmd[5];
uint32 val = 0;
@@ -271,7 +271,7 @@ static sint8 spi_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr,
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_sector_erase(uint32 u32FlashAdr)
+static sint8 atwinc15x0_flash_sector_erase(uint32 u32FlashAdr)
{
uint8 cmd[4];
uint32 val = 0;
@@ -309,7 +309,7 @@ static sint8 spi_flash_sector_erase(uint32 u32FlashAdr)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_write_enable(void)
+static sint8 atwinc15x0_flash_write_enable(void)
{
uint8 cmd[1];
uint32 val = 0;
@@ -339,7 +339,7 @@ static sint8 spi_flash_write_enable(void)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_write_disable(void)
+static sint8 atwinc15x0_flash_write_disable(void)
{
uint8 cmd[1];
uint32 val = 0;
@@ -374,7 +374,7 @@ static sint8 spi_flash_write_disable(void)
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
+static sint8 atwinc15x0_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
{
uint8 cmd[4];
uint32 val = 0;
@@ -417,11 +417,11 @@ static sint8 spi_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_read_internal(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz)
+static sint8 atwinc15x0_flash_read_internal(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz)
{
sint8 ret = M2M_SUCCESS;
/* read size must be < 64KB */
- ret = spi_flash_load_to_cortus_mem(HOST_SHARE_MEM_BASE, u32Addr, u32Sz);
+ ret = atwinc15x0_flash_load_to_cortus_mem(HOST_SHARE_MEM_BASE, u32Addr, u32Sz);
if(M2M_SUCCESS != ret) goto ERR;
ret = nm_read_block(HOST_SHARE_MEM_BASE, pu8Buf, u32Sz);
ERR:
@@ -441,21 +441,21 @@ ERR:
* @author M. Abdelmawla
* @version 1.0
*/
-static sint8 spi_flash_pp(uint32 u32Offset, uint8 *pu8Buf, uint16 u16Sz)
+static sint8 atwinc15x0_flash_pp(uint32 u32Offset, uint8 *pu8Buf, uint16 u16Sz)
{
sint8 ret = M2M_SUCCESS;
uint8 tmp;
- spi_flash_write_enable();
+ atwinc15x0_flash_write_enable();
/* use shared packet memory as temp mem */
ret += nm_write_block(HOST_SHARE_MEM_BASE, pu8Buf, u16Sz);
- ret += spi_flash_page_program(HOST_SHARE_MEM_BASE, u32Offset, u16Sz);
- ret += spi_flash_read_status_reg(&tmp);
+ ret += atwinc15x0_flash_page_program(HOST_SHARE_MEM_BASE, u32Offset, u16Sz);
+ ret += atwinc15x0_flash_read_status_reg(&tmp);
do
{
if(ret != M2M_SUCCESS) goto ERR;
- ret += spi_flash_read_status_reg(&tmp);
+ ret += atwinc15x0_flash_read_status_reg(&tmp);
}while(tmp & 0x01);
- ret += spi_flash_write_disable();
+ ret += atwinc15x0_flash_write_disable();
ERR:
return ret;
}
@@ -467,7 +467,7 @@ ERR:
* @author M.S.M
* @version 1.0
*/
-static uint32 spi_flash_rdid(void)
+static uint32 atwinc15x0_flash_rdid(void)
{
unsigned char cmd[1];
uint32 reg = 0;
@@ -504,19 +504,19 @@ static uint32 spi_flash_rdid(void)
* @version 1.0
*/
#if 0
-static void spi_flash_unlock(void)
+static void atwinc15x0_flash_unlock(void)
{
uint8 tmp;
- tmp = spi_flash_read_security_reg();
- spi_flash_clear_security_flags();
+ tmp = atwinc15x0_flash_read_security_reg();
+ atwinc15x0_flash_clear_security_flags();
if(tmp & 0x80)
{
- spi_flash_write_enable();
- spi_flash_gang_unblock();
+ atwinc15x0_flash_write_enable();
+ atwinc15x0_flash_gang_unblock();
}
}
#endif
-static void spi_flash_enter_low_power_mode(void) {
+static void atwinc15x0_flash_enter_low_power_mode(void) {
volatile unsigned long tmp;
unsigned char* cmd = (unsigned char*) &tmp;
@@ -531,7 +531,7 @@ static void spi_flash_enter_low_power_mode(void) {
}
-static void spi_flash_leave_low_power_mode(void) {
+static void atwinc15x0_flash_leave_low_power_mode(void) {
volatile unsigned long tmp;
unsigned char* cmd = (unsigned char*) &tmp;
@@ -553,7 +553,7 @@ static void spi_flash_leave_low_power_mode(void) {
* @author M. Abdelmawla
* @version 1.0
*/
-sint8 spi_flash_enable(uint8 enable)
+sint8 atwinc15x0_flash_enable(uint8 enable)
{
sint8 s8Ret = M2M_SUCCESS;
if(REV(nmi_get_chipid()) >= REV_3A0) {
@@ -569,9 +569,9 @@ sint8 spi_flash_enable(uint8 enable)
u32Val |= ((0x1111ul) << 12);
nm_write_reg(0x1410, u32Val);
if(enable) {
- spi_flash_leave_low_power_mode();
+ atwinc15x0_flash_leave_low_power_mode();
} else {
- spi_flash_enter_low_power_mode();
+ atwinc15x0_flash_enter_low_power_mode();
}
/* Disable pinmux to SPI flash to minimize leakage. */
u32Val &= ~((0x7777ul) << 12);
@@ -595,14 +595,14 @@ ERR1:
* @author M. Abdelmawla
* @version 1.0
*/
-sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz)
+sint8 atwinc15x0_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz)
{
sint8 ret = M2M_SUCCESS;
if(u32Sz > FLASH_BLOCK_SIZE)
{
do
{
- ret = spi_flash_read_internal(pu8Buf, u32offset, FLASH_BLOCK_SIZE);
+ ret = atwinc15x0_flash_read_internal(pu8Buf, u32offset, FLASH_BLOCK_SIZE);
if(M2M_SUCCESS != ret) goto ERR;
u32Sz -= FLASH_BLOCK_SIZE;
u32offset += FLASH_BLOCK_SIZE;
@@ -610,7 +610,7 @@ sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz)
} while(u32Sz > FLASH_BLOCK_SIZE);
}
- ret = spi_flash_read_internal(pu8Buf, u32offset, u32Sz);
+ ret = atwinc15x0_flash_read_internal(pu8Buf, u32offset, u32Sz);
ERR:
return ret;
@@ -629,7 +629,7 @@ ERR:
* @author M. Abdelmawla
* @version 1.0
*/
-sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz)
+sint8 atwinc15x0_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz)
{
#ifdef PROFILING
uint32 t1 = 0;
@@ -657,7 +657,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz)
if (u32off)/*first part of data in the address page*/
{
u32wsz = u32Blksz - u32off;
- if(spi_flash_pp(u32Offset, pu8Buf, (uint16)BSP_MIN(u32Sz, u32wsz))!=M2M_SUCCESS)
+ if(atwinc15x0_flash_pp(u32Offset, pu8Buf, (uint16)BSP_MIN(u32Sz, u32wsz))!=M2M_SUCCESS)
{
ret = M2M_ERR_FAIL;
goto ERR;
@@ -672,7 +672,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz)
u32wsz = BSP_MIN(u32Sz, u32Blksz);
/*write complete page or the remaining data*/
- if(spi_flash_pp(u32Offset, pu8Buf, (uint16)u32wsz)!=M2M_SUCCESS)
+ if(atwinc15x0_flash_pp(u32Offset, pu8Buf, (uint16)u32wsz)!=M2M_SUCCESS)
{
ret = M2M_ERR_FAIL;
goto ERR;
@@ -706,7 +706,7 @@ ERR:
* @author M. Abdelmawla
* @version 1.0
*/
-sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz)
+sint8 atwinc15x0_flash_erase(uint32 u32Offset, uint32 u32Sz)
{
uint32 i = 0;
sint8 ret = M2M_SUCCESS;
@@ -718,14 +718,14 @@ sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz)
M2M_PRINT("\r\n>Start erasing...\r\n");
for(i = u32Offset; i < (u32Sz +u32Offset); i += (16*FLASH_PAGE_SZ))
{
- ret += spi_flash_write_enable();
- ret += spi_flash_read_status_reg(&tmp);
- ret += spi_flash_sector_erase(i + 10);
- ret += spi_flash_read_status_reg(&tmp);
+ ret += atwinc15x0_flash_write_enable();
+ ret += atwinc15x0_flash_read_status_reg(&tmp);
+ ret += atwinc15x0_flash_sector_erase(i + 10);
+ ret += atwinc15x0_flash_read_status_reg(&tmp);
do
{
if(ret != M2M_SUCCESS) goto ERR;
- ret += spi_flash_read_status_reg(&tmp);
+ ret += atwinc15x0_flash_read_status_reg(&tmp);
}while(tmp & 0x01);
}
@@ -744,14 +744,14 @@ ERR:
* @author M.S.M
* @version 1.0
*/
-uint32 spi_flash_get_size(void)
+uint32 atwinc15x0_flash_get_size(void)
{
uint32 u32FlashId = 0, u32FlashPwr = 0;
static uint32 gu32InernalFlashSize= 0;
if(!gu32InernalFlashSize)
{
- u32FlashId = spi_flash_rdid();//spi_flash_probe();
+ u32FlashId = atwinc15x0_flash_rdid();//spi_flash_probe();
if(u32FlashId != 0xffffffff)
{
/*flash size is the third byte from the FLASH RDID*/
@@ -767,4 +767,4 @@ uint32 spi_flash_get_size(void)
}
return gu32InernalFlashSize;
-}
\ No newline at end of file
+}
--
2.17.1