mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
machine: remove bytes package dependency in flash code
This also moves flash padding code to a single place, since it was copied 5 times. This change is necessary in Go 1.24 to avoid an import cycle.
This commit is contained in:
committed by
Ron Evans
parent
ea53ace270
commit
52b9fcd57f
@@ -64,3 +64,14 @@ type BlockDevice interface {
|
||||
// EraseBlockSize to map addresses to blocks.
|
||||
EraseBlocks(start, len int64) error
|
||||
}
|
||||
|
||||
// pad data if needed so it is long enough for correct byte alignment on writes.
|
||||
func flashPad(p []byte, writeBlockSize int) []byte {
|
||||
overflow := len(p) % writeBlockSize
|
||||
if overflow != 0 {
|
||||
for i := 0; i < writeBlockSize-overflow; i++ {
|
||||
p = append(p, 0xff)
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user