Compare commits

...

1 Commits

Author SHA1 Message Date
Ayke van Laethem 2b7fa93fcb machine: add flash start/end address that can be used for data 2023-02-20 20:58:36 +01:00
5 changed files with 39 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
package main
import "machine"
func main() {
println("flash data start:", machine.FlashDataStart())
println("flash data end: ", machine.FlashDataEnd())
}
+23
View File
@@ -0,0 +1,23 @@
//go:build nrf
package machine
import "unsafe"
//go:extern __flash_data_start
var flashDataStart [0]byte
//go:extern __flash_data_end
var flashDataEnd [0]byte
// Return the start of the writable flash area, aligned on a page boundary. This
// is usually just after the program and static data.
func FlashDataStart() uintptr {
return (uintptr(unsafe.Pointer(&flashDataStart)) + flashPageSize - 1) &^ (flashPageSize - 1)
}
// Return the end of the writable flash area. Usually this is the address one
// past the end of the on-chip flash.
func FlashDataEnd() uintptr {
return uintptr(unsafe.Pointer(&flashDataEnd))
}
+2
View File
@@ -6,6 +6,8 @@ import (
"device/nrf"
)
const flashPageSize = 1024
// Get peripheral and pin number for this GPIO pin.
func (p Pin) getPortPin() (*nrf.GPIO_Type, uint32) {
return nrf.GPIO, uint32(p)
+2
View File
@@ -12,6 +12,8 @@ func CPUFrequency() uint32 {
return 64000000
}
const flashPageSize = 4096
// InitADC initializes the registers needed for ADC.
func InitADC() {
return // no specific setup on nrf52 machine.
+4
View File
@@ -69,3 +69,7 @@ _heap_start = _ebss;
_heap_end = ORIGIN(RAM) + LENGTH(RAM);
_globals_start = _sdata;
_globals_end = _ebss;
/* For the flash API */
__flash_data_start = LOADADDR(.data) + SIZEOF(.data);
__flash_data_end = ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT);