nrf: add ReadTemperature method
Similar to the rp2040, the nrf has an on-board temperature sensor. The main reason why I added this function was to show how this new API is more general and can be used on multiple chips.
Этот коммит содержится в:
родитель
70b3ece6ec
коммит
a68f7e4ce3
1 изменённых файлов: 11 добавлений и 0 удалений
|
@ -372,3 +372,14 @@ func GetRNG() (ret uint32, err error) {
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadTemperature reads the silicon die temperature of the chip. The return
|
||||||
|
// value is in milli-celsius.
|
||||||
|
func ReadTemperature() int32 {
|
||||||
|
nrf.TEMP.TASKS_START.Set(1)
|
||||||
|
for nrf.TEMP.EVENTS_DATARDY.Get() == 0 {
|
||||||
|
}
|
||||||
|
temp := int32(nrf.TEMP.TEMP.Get()) * 250 // the returned value is in units of 0.25°C
|
||||||
|
nrf.TEMP.EVENTS_DATARDY.Set(0)
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче