-
Notifications
You must be signed in to change notification settings - Fork 0
Javier/dma to flash #18
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
Open
Byte-Entropy
wants to merge
16
commits into
master
Choose a base branch
from
Javier/DmaToFlash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+337
−19
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0754247
feat: Add NAU7802 24-bit ADC driver
Byte-Entropy e49a889
Refactor NAU7802 driver, normalize filenames, and clean up repository
Byte-Entropy abdf0f2
Updated Readme to match previous Refactor
Byte-Entropy 1211490
WIP Task.cpp
Byte-Entropy d59885a
b26641e
WIP: Implement Custom Delay
Byte-Entropy 839aa90
Fix: Driverr compilation (obj) Success
Byte-Entropy dabe891
Initial Commit ADD DMA Transfer SPI & I2C
Byte-Entropy 147c7d7
Modif rm txt
Byte-Entropy 44e5660
MX66L1G45GMI: Add DMA-backed SPI interface and refactor driver
Byte-Entropy 6d49ad3
ADD Comprehensive README
Byte-Entropy db2a532
Merge branch 'master' into Javier/DmaToFlash
Byte-Entropy 7c9a2b6
FIX problems under Git Comments
Byte-Entropy 41dcf52
Merge branch 'Javier/DmaToFlash' of https://github.com/UCSOAR/Periphe…
Byte-Entropy fe7be3e
FIX Interface cpp
Byte-Entropy d09119e
FIX MX cpp ADN INTERFACE
Byte-Entropy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| # Ignore .pre-commit-config.yaml | ||
| .pre-commit-config.yaml | ||
|
|
||
| #Ignore Makefile | ||
| Makefile | ||
| # Ignore other Branch specific dirs | ||
| PeripheralDriversSubmodule/NAU7802/* | ||
| PeripheralDriversSubmodule/MX66L1G45GMI/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Ignore txt files containing notes about DMA | ||
| DMA-NOTES.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /** | ||
| ******************************************************************************** | ||
| * @file MX66L1G45GMI_Interface.cpp | ||
| * @author Javier | ||
| * @date Jan 28, 2026 | ||
| * @brief Interface Implementation for MX66L1G45GMI Flash Memory Driver. | ||
| ******************************************************************************** | ||
| */ | ||
|
|
||
| /************************************ | ||
| * INCLUDES | ||
| ************************************/ | ||
| #include "MX66L1G45GMI.hpp" | ||
| #include "DMATransfer.hpp" | ||
| #include "stm32g4xx_hal.h" | ||
|
|
||
| #include "main.h" | ||
|
|
||
| /************************************ | ||
| * PRIVATE MACROS AND DEFINES | ||
| ************************************/ | ||
| extern SPI_HandleTypeDef hspi1; | ||
|
|
||
|
|
||
| /************************************ | ||
| * VARIABLES | ||
| ************************************/ | ||
|
|
||
| /************************************ | ||
| * FUNCTION DECLARATIONS | ||
| ************************************/ | ||
|
|
||
| /************************************ | ||
| * FUNCTION DEFINITIONS | ||
| ************************************/ | ||
|
|
||
| // Chip Select Implementation | ||
| void IMPL_SetCS(bool high) { | ||
| HAL_GPIO_WritePin(SPI_FLASH_CS_GPIO_Port, SPI_FLASH_CS_Pin, high ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||
| } | ||
|
|
||
| // Delay Implementation | ||
| void IMPL_Delay(uint32_t ms) { | ||
| HAL_Delay(ms); | ||
| } | ||
|
|
||
| void IMPL_Write(const uint8_t* data, uint16_t len) { | ||
| // Use Polling for tiny commands (<=32 bytes) to avoid DMA overhead | ||
| if (len <= 32) { | ||
| HAL_SPI_Transmit(&hspi1, (uint8_t*)data, len, 100); | ||
| } else { | ||
| // Use DMA for larger data transfers (TX-only) | ||
| if (DMAControl::Transfer(&hspi1, 0, (uint8_t*)data, nullptr, len) != HAL_OK) | ||
| { | ||
| SOAR_PRINT("IMPL_Write: DMA Transfer Error\n"); | ||
| return; | ||
| } | ||
|
|
||
| // BLOCKING WAIT: Protects the stack buffer 'tData' inside the driver | ||
| while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY) | ||
| ; | ||
| } | ||
| } | ||
|
|
||
| // Read Implementation | ||
| void IMPL_Read(uint8_t* data, uint16_t len) { | ||
| // Use DMA Tool | ||
| DMAControl::Transfer(&hspi1, 0, nullptr, data, len); | ||
| // BLOCKING WAIT | ||
| int tick1 = HAL_GetTick(); | ||
|
|
||
| while (HAL_GetTick() - tick1 < 500) { // 500ms timeout | ||
| if(HAL_SPI_GetState(&hspi1) == HAL_SPI_STATE_READY) break; | ||
| MX66_Delay(1); | ||
| } | ||
| if (HAL_GetTick() - tick1 >= 500) { | ||
| SOAR_PRINT("IMPL_Read: DMA Transfer Timeout\n"); | ||
| return; | ||
| } | ||
| } | ||
| // Setup Function | ||
| void Setup_Flash_Interface() { | ||
| static MX66_Config cfg; | ||
|
|
||
| cfg.Write = IMPL_Write; | ||
| cfg.Read = IMPL_Read; | ||
| cfg.SetCS = IMPL_SetCS; | ||
| cfg.Delay = IMPL_Delay; | ||
|
|
||
| // Inject dependencies into the abstract driver | ||
| MX66_Init(&cfg); | ||
| } | ||
| // End of MX66L1G45GMI_Interface.cpp | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have a note that this uses HAL delay, what is the point of this if we are renaming it only? And why is there two delays and explain why you used each one at that point and why