Add support for Corsair Lighting Pro
[temp2RGB.git] / src / cpu_temperature.rs
1 use crate::wrapper_winring0;
2
3 const OLS_TYPE: u32 = 40000;
4
5 const F17H_M01H_THM_TCON_CUR_TMP: u32 = 0x00059800;
6 const F17H_TEMP_OFFSET_FLAG: u32 = 0x80000;
7 const FAMILY_17H_PCI_CONTROL_REGISTER: u32 = 0x60;
8
9 pub fn read() -> f32 {
10 unsafe {
11 wrapper_winring0::WritePciConfigDwordEx(
12 0x00,
13 FAMILY_17H_PCI_CONTROL_REGISTER,
14 F17H_M01H_THM_TCON_CUR_TMP,
15 );
16
17 let output: &mut u32 = &mut 0;
18 let ok = wrapper_winring0::ReadPciConfigDwordEx(
19 0x00,
20 FAMILY_17H_PCI_CONTROL_REGISTER + 4,
21 output,
22 );
23 let offset_flag = *output & F17H_TEMP_OFFSET_FLAG != 0;
24 let mut temperature = ((*output >> 21) * 125) as f32 * 0.001;
25 if offset_flag {
26 temperature -= 49.;
27 }
28
29 // dbg!(ok);
30 // dbg!(temperature);
31
32 temperature
33 }
34 }