forked from grblHAL/RP2040
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added USB serial and flash storage of settings
NOTE: needs latest Pico SDK!
- Loading branch information
Showing
10 changed files
with
663 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,61 @@ | ||
/* | ||
flash.c - driver code for RP2040 ARM processor | ||
Part of grblHAL | ||
Copyright (c) 2021 Terje Io | ||
This code reads/writes the whole RAM-based emulated EPROM contents from/to flash | ||
Grbl is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Grbl is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Grbl. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* | ||
IMPORTANT! If both cores are in use synchronization has to be added since flash cannot be read during programming | ||
See 4.1.8. hardware_flash in the SDK documentation. | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include "hardware/flash.h" | ||
#include "hardware/regs/addressmap.h" | ||
|
||
#include "driver.h" | ||
|
||
#define FLASH_TARGET_OFFSET (1024 * 512) | ||
|
||
static const uint8_t *flash_target = (const uint8_t *)(XIP_BASE + FLASH_TARGET_OFFSET); // Last page start adress | ||
|
||
bool memcpy_from_flash (uint8_t *dest) | ||
{ | ||
memcpy(dest, flash_target, hal.nvs.size); | ||
|
||
return true; | ||
} | ||
|
||
bool memcpy_to_flash (uint8_t *source) | ||
{ | ||
if (!memcmp(source, flash_target, hal.nvs.size)) | ||
return true; | ||
|
||
__disable_irq(); | ||
flash_range_erase(FLASH_TARGET_OFFSET, FLASH_SECTOR_SIZE); | ||
flash_range_program(FLASH_TARGET_OFFSET, source, FLASH_PAGE_SIZE * (hal.nvs.size / FLASH_PAGE_SIZE + (hal.nvs.size % FLASH_PAGE_SIZE ? 1 :0))); | ||
__enable_irq(); | ||
|
||
return !memcmp(source, flash_target, hal.nvs.size); | ||
} |
This file contains 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,30 @@ | ||
/* | ||
flash.h - driver code for RP2040 ARM processor | ||
Part of grblHAL | ||
Copyright (c) 2021 Terje Io | ||
Grbl is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Grbl is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Grbl. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef _flash_h_ | ||
#define _flash_h_ | ||
|
||
bool memcpy_from_flash (uint8_t *dest); | ||
bool memcpy_to_flash (uint8_t *source); | ||
|
||
#endif |
This file contains 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 |
---|---|---|
|
@@ -25,5 +25,5 @@ | |
|
||
int main (void) | ||
{ | ||
grbl_enter(); | ||
} | ||
grbl_enter(); | ||
} |
This file contains 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
Oops, something went wrong.