@@ -1176,6 +1176,60 @@ u1_t radio_rssi () {
1176
1176
return r ;
1177
1177
}
1178
1178
1179
+ // Reads the raw temperature
1180
+ // \retval New raw temperature reading in 2's complement format
1181
+ s1_t radio_GetRawTemp (void ) {
1182
+
1183
+ #define RF_IMAGECAL_TEMPMONITOR_MASK 0xFE
1184
+ #define RF_IMAGECAL_TEMPMONITOR_ON 0x00
1185
+ #define RF_IMAGECAL_TEMPMONITOR_OFF 0x01
1186
+
1187
+ int8_t temp = 0 ;
1188
+ uint8_t previousOpMode , RegTemp ;
1189
+
1190
+ // Save current Operation Mode
1191
+ previousOpMode = readReg (RegOpMode );
1192
+
1193
+ // Put device in FSK Sleep Mode
1194
+ opmode (OPMODE_SLEEP );
1195
+
1196
+ // select FSK modem (from sleep mode)
1197
+ opmodeFSK ();
1198
+ ASSERT ((readReg (RegOpMode ) & OPMODE_LORA ) == 0 );
1199
+
1200
+ // Put device in FSK RxSynth
1201
+ opmode (OPMODE_FSRX );
1202
+
1203
+ // Enable Temperature reading
1204
+ writeReg (FSKRegImageCal , (readReg (RegOpMode ) & RF_IMAGECAL_TEMPMONITOR_MASK ) |
1205
+ RF_IMAGECAL_TEMPMONITOR_ON );
1206
+
1207
+ // Wait 150us
1208
+ hal_waitUntil (os_getTime () + us2osticks (150 ));
1209
+
1210
+ // Disable Temperature reading
1211
+ writeReg (FSKRegImageCal , (readReg (RegOpMode ) & RF_IMAGECAL_TEMPMONITOR_MASK ) |
1212
+ RF_IMAGECAL_TEMPMONITOR_OFF );
1213
+
1214
+ // Put device in FSK Sleep Mode
1215
+ opmode (OPMODE_SLEEP );
1216
+
1217
+ // Read temperature
1218
+ RegTemp = readReg (FSKRegTemp );
1219
+
1220
+ if ((RegTemp & 0x80 ) == 0x80 ) {
1221
+ temp = 255 - RegTemp ;
1222
+ } else {
1223
+ temp = RegTemp ;
1224
+ temp *= -1 ;
1225
+ }
1226
+
1227
+ // Reload previous Op Mode
1228
+ writeReg (RegOpMode , previousOpMode );
1229
+
1230
+ return temp ;
1231
+ }
1232
+
1179
1233
/// \brief get the current RSSI on the current channel.
1180
1234
///
1181
1235
/// monitor rssi for specified number of ostime_t ticks, and return statistics
0 commit comments