betaflight / betaflight

Open Source Flight Controller Firmware
GNU General Public License v3.0
8.06k stars 2.87k forks source link

Nonblocking w25n01g code tidy up #13562

Closed SteveCEvans closed 1 month ago

SteveCEvans commented 1 month ago

Follow on from https://github.com/betaflight/betaflight/pull/13555

github-actions[bot] commented 1 month ago

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

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

ledvinap commented 1 month ago

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

nerdCopter commented 1 month ago

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 commented 1 month ago

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

nerdCopter commented 1 month ago

commit 6837ed2 needs closing #endif's

SteveCEvans commented 1 month ago

commit 6837ed2 needs closing #endif's

Yup, rather daft copy-n-paste error!

haslinghuis commented 1 month ago

@ledvinap please test

ledvinap commented 1 month ago

@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;