Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonblocking w25n01g code tidy up #13562

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

SteveCEvans
Copy link
Member

Follow on from #13555

@SteveCEvans SteveCEvans self-assigned this Apr 21, 2024
Copy link

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13562 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

@ledvinap
Copy link
Contributor

can you merge upstream/master, please? it should remove conflicts

@nerdCopter
Copy link
Member

went fly this (5cdae1b) on non-affected target. figured it was the least i could do after effing up. logs were in-tact for APEXF7 W25Q128FV.

@nerdCopter
Copy link
Member

@SteveCEvans , this branch has merge conflicts. merging master (or rebase) will fix.
image

@nerdCopter
Copy link
Member

commit 6837ed2 needs closing #endif's

@SteveCEvans
Copy link
Member Author

commit 6837ed2 needs closing #endif's

Yup, rather daft copy-n-paste error!

Copy link
Member

@nerdCopter nerdCopter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding my approval for workflow, but hoping others will deep-inspect.

Copy link
Member

@haslinghuis haslinghuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haslinghuis
Copy link
Member

@ledvinap please test

{.u.buffers = {readStatus, readyStatus}, sizeof(readStatus), true, w25n01g_callbackReady},
{.u.buffers = {writeEnable, NULL}, sizeof(writeEnable), true, w25n01g_callbackWriteEnable},
{.u.buffers = {progExecCmd, NULL}, sizeof(progExecCmd), true, w25n01g_callbackWriteComplete},
{.u.buffers = {progExecDataLoad, NULL}, sizeof(progExecDataLoad), false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(maybe it would be more readable if command buffers were closer to segments (intermix them) )

@haslinghuis haslinghuis merged commit e0c0b64 into betaflight:master Apr 22, 2024
23 checks passed
@@ -353,7 +353,10 @@ bool w25n01g_identify(flashDevice_t *fdevice, uint32_t jedecID)
fdevice->couldBeBusy = true; // Just for luck we'll assume the chip could be busy even though it isn't specced to be
fdevice->vTable = &w25n01g_vTable;

#ifndef USE_QUADSPI
// Need to set clock speed for 8kHz logging support with SPI
spiSetClkDivisor(fdevice->io.handle.dev, spiCalculateDivider(100000000));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fdevice->io.handle.dev union member is used, but device can be in quad/octo mode.

if (fdevice->io.mode == FLASHIO_SPI) {

@ledvinap
Copy link
Contributor

@SteveCEvans :
Both gcc and clang support initialization of structure flexible member. With it, segments can be refactored, removing union and making code cleaner overall. dev will point to current segments, linking and skipping will be easier, it will save some memory.

I'd also pass segment index and busSegment_t* to callback (making it common for whole chain) and add flags to each buffers[] entry(skip, possibly last, etc), but that is personal preference ...

typedef struct busSegment_s {
        struct {
            // device associated with THIS transfer
            const extDevice_t *dev;
            // Segments to process in the next transfer.
            volatile struct busSegment_s *next;
            int segmentcount;  // number of segments in this block
        } head;
        struct {
            // Transmit buffer
            uint8_t *txData;
            // Receive buffer, or in the case of the final segment to
            uint8_t *rxData;
            int len;
            bool negateCS; // Should CS be negated at the end of this segment
            busStatus_e (*callback)(uint32_t arg);
        } buffers[];
} busSegment_t;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

None yet

4 participants