1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use core::ptr;
const ADDR: u32 = 0x00800080;
fn cal(addr_offset: u32, bit_shift: u32, bit_mask: u32) -> u32 {
unsafe {
let addr: *const u32 = (ADDR + addr_offset) as *const _;
let value = ptr::read(addr);
(value >> bit_shift) & bit_mask
}
}
pub fn usb_transn_cal() -> u8 {
cal(4, 0, 0b11111) as u8
}
pub fn usb_transp_cal() -> u8 {
cal(4, 5, 0b11111) as u8
}
pub fn usb_trim_cal() -> u8 {
cal(4, 10, 0b111) as u8
}
pub fn adc0_biascomp_scale_cal() -> u8 {
cal(0, 2, 0b111) as u8
}
pub fn adc0_biasref_scale_cal() -> u8 {
cal(0, 5, 0b111) as u8
}
pub fn adc0_biasr2r_scale_cal() -> u8 {
cal(1, 0, 0b111) as u8
}
pub fn adc1_biascomp_scale_cal() -> u8 {
cal(2, 2, 0b111) as u8
}
pub fn adc1_biasref_scale_cal() -> u8 {
cal(2, 5, 0b111) as u8
}
pub fn adc1_biasr2r_scale_cal() -> u8 {
cal(3, 0, 0b111) as u8
}