stm32wb_pac/tim2/
cnt.rs

1#[doc = "Reader of register CNT"]
2pub type R = crate::R<u32, super::CNT>;
3#[doc = "Writer for register CNT"]
4pub type W = crate::W<u32, super::CNT>;
5#[doc = "Register CNT `reset()`'s with value 0"]
6impl crate::ResetValue for super::CNT {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `CNT_H`"]
14pub type CNT_H_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `CNT_H`"]
16pub struct CNT_H_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> CNT_H_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !(0x7fff << 16)) | (((value as u32) & 0x7fff) << 16);
24        self.w
25    }
26}
27#[doc = "Reader of field `CNT_L`"]
28pub type CNT_L_R = crate::R<u16, u16>;
29#[doc = "Write proxy for field `CNT_L`"]
30pub struct CNT_L_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> CNT_L_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u16) -> &'a mut W {
37        self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
38        self.w
39    }
40}
41#[doc = "Reader of field `UIFCPY`"]
42pub type UIFCPY_R = crate::R<bool, bool>;
43impl R {
44    #[doc = "Bits 16:30 - High counter value (TIM2 only)"]
45    #[inline(always)]
46    pub fn cnt_h(&self) -> CNT_H_R {
47        CNT_H_R::new(((self.bits >> 16) & 0x7fff) as u16)
48    }
49    #[doc = "Bits 0:15 - Low counter value"]
50    #[inline(always)]
51    pub fn cnt_l(&self) -> CNT_L_R {
52        CNT_L_R::new((self.bits & 0xffff) as u16)
53    }
54    #[doc = "Bit 31 - Value depends on IUFREMAP in TIM2_CR1."]
55    #[inline(always)]
56    pub fn uifcpy(&self) -> UIFCPY_R {
57        UIFCPY_R::new(((self.bits >> 31) & 0x01) != 0)
58    }
59}
60impl W {
61    #[doc = "Bits 16:30 - High counter value (TIM2 only)"]
62    #[inline(always)]
63    pub fn cnt_h(&mut self) -> CNT_H_W {
64        CNT_H_W { w: self }
65    }
66    #[doc = "Bits 0:15 - Low counter value"]
67    #[inline(always)]
68    pub fn cnt_l(&mut self) -> CNT_L_W {
69        CNT_L_W { w: self }
70    }
71}