Skip to content

Commit 4daf926

Browse files
Refactor Winbond w25n02k support
This is being done as part of support for NEXUSX target. The previously introduced target ORBITH743 has already introduced support for the Winbond w25n02k 2Gbit/256MByte array. This commit refactors it to increase code quality. flash_w25n01g.c is renamed to flash_w25n.c. The driver no longer supports just w25n01g, but two chips of the w25n family now. More chips might be added in future targets. The name change reflects this new larger family support. Cleanup of some magic numbers in flash_w25n.c Removal of w25n01g_readExtensionBytes. It had a magic number in it and was unused. Rather than fixing the magic number it just gets removed. Addition of USE_FLASH_W25N02K and use of it in targets. Keeps target definitions more accurate and independent of flash driver implementation details.
1 parent cb8dea6 commit 4daf926

12 files changed

Lines changed: 596 additions & 610 deletions

File tree

cmake/at32-bootloader.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ main_sources(BOOTLOADER_SOURCES
2121
drivers/time.c
2222
drivers/timer.c
2323
drivers/flash_m25p16.c
24-
drivers/flash_w25n01g.c
24+
drivers/flash_w25n.c
2525
drivers/flash.c
2626

2727
fc/firmware_update_common.c

docs/Blackbox.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ These chips are also supported:
120120
* Winbond W25Q64 - 64 Mbit / 8 MByte
121121
* Micron N25Q0128 - 128 Mbit / 16 MByte
122122
* Winbond W25Q128 - 128 Mbit / 16 MByte
123+
* Winbond W25N01 - 1 Gbit / 128 MByte
124+
* Winbond W25N02 - 2 Gbit / 256 MByte
123125

124126
#### Enable recording to dataflash
125127
On the Configurator's CLI tab, you must enter `set blackbox_device=SPIFLASH` to switch to logging to an onboard dataflash chip, then save.

src/main/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ main_sources(COMMON_SRC
179179
drivers/flash.h
180180
drivers/flash_m25p16.c
181181
drivers/flash_m25p16.h
182-
drivers/flash_w25n01g.c
183-
drivers/flash_w25n01g.h
182+
drivers/flash_w25n.c
183+
drivers/flash_w25n.h
184184
drivers/gimbal_common.h
185185
drivers/gimbal_common.c
186186
drivers/headtracker_common.h

src/main/drivers/bus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ typedef enum {
142142
DEVHW_MS4525, // Pitot meter
143143
DEVHW_DLVR, // Pitot meter
144144
DEVHW_M25P16, // SPI NOR flash
145-
DEVHW_W25N01G, // SPI 128MB flash
145+
DEVHW_W25N, // SPI 128MB or 256MB flash from Winbond W25N family
146146
DEVHW_UG2864, // I2C OLED display
147147
DEVHW_SDCARD, // Generic SD-Card
148148
DEVHW_IRLOCK, // IR-Lock visual positioning hardware

src/main/drivers/flash.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "flash.h"
3232
#include "flash_m25p16.h"
33-
#include "flash_w25n01g.h"
33+
#include "flash_w25n.h"
3434

3535
#include "common/time.h"
3636

@@ -56,17 +56,17 @@ static flashDriver_t flashDrivers[] = {
5656
},
5757
#endif
5858

59-
#ifdef USE_FLASH_W25N01G
59+
#if defined(USE_FLASH_W25N01G) || defined(USE_FLASH_W25N02K)
6060
{
61-
.init = w25n01g_init,
62-
.isReady = w25n01g_isReady,
63-
.waitForReady = w25n01g_waitForReady,
64-
.eraseSector = w25n01g_eraseSector,
65-
.eraseCompletely = w25n01g_eraseCompletely,
66-
.pageProgram = w25n01g_pageProgram,
67-
.readBytes = w25n01g_readBytes,
68-
.getGeometry = w25n01g_getGeometry,
69-
.flush = w25n01g_flush
61+
.init = w25n_init,
62+
.isReady = w25n_isReady,
63+
.waitForReady = w25n_waitForReady,
64+
.eraseSector = w25n_eraseSector,
65+
.eraseCompletely = w25n_eraseCompletely,
66+
.pageProgram = w25n_pageProgram,
67+
.readBytes = w25n_readBytes,
68+
.getGeometry = w25n_getGeometry,
69+
.flush = w25n_flush
7070
},
7171
#endif
7272

0 commit comments

Comments
 (0)