forked from maxnet/pico-webserver
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schematics and additional pictures, reconfigure for using SPI0 wh…
…ich is faster and more reliable.
- Loading branch information
Showing
9 changed files
with
67 additions
and
11 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
#ifndef _FLASHER_H_INCLUDE_ | ||
#define _FLASHER_H_INCLUDE_ | ||
|
||
uint8_t * flash_address(uint32_t sector); | ||
uint8_t * flash_read(uint8_t * dest, uint32_t sector, uint32_t len); | ||
void flash_write(uint32_t sector, uint8_t * sour, uint32_t len); | ||
|
||
#endif |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,31 @@ | ||
#include "pico/stdlib.h" | ||
#include "hardware/flash.h" | ||
#include <string.h> | ||
|
||
extern uint8_t __flash_binary_end; | ||
|
||
static inline size_t get_sector_offset(uint32_t sector) { | ||
return (((size_t)(&__flash_binary_end - (uint8_t *)XIP_BASE) / FLASH_SECTOR_SIZE) + sector + 1) * FLASH_SECTOR_SIZE; | ||
} | ||
|
||
uint8_t * flash_address(uint32_t sector) { | ||
return (uint8_t *)XIP_BASE + get_sector_offset(sector); | ||
} | ||
|
||
uint8_t * flash_read(uint8_t * dest, uint32_t sector, uint32_t len) { | ||
return memcpy(dest, (uint8_t *)XIP_BASE + get_sector_offset(sector), len); | ||
} | ||
|
||
void flash_write(uint32_t sector, uint8_t * sour, uint32_t len) { | ||
uint8_t buffer[FLASH_PAGE_SIZE]; | ||
size_t offset = get_sector_offset(sector); | ||
flash_range_erase(offset, (len / FLASH_SECTOR_SIZE + 1) * FLASH_SECTOR_SIZE); | ||
while (len) { | ||
uint32_t sz = (len < FLASH_PAGE_SIZE) ? len : FLASH_PAGE_SIZE; | ||
memcpy(buffer, sour, sz); | ||
sour += sz; | ||
flash_range_program(offset, buffer, sz); | ||
offset += FLASH_PAGE_SIZE; | ||
len -= sz; | ||
} | ||
} |
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