@.CHARSET =CP1251 ( Cyrillic )
@GNU AS

.INCLUDE   "/src/inc/base.inc"

@.ITEM     APB1PERIPH_BASE
.EQU  TIM13_BASE     , APB1PERIPH_BASE + 0x1C00
.EQU  TIM13          , PERIPH_BASE + TIM13_BASE
.EQU  TIM14_BASE     , APB1PERIPH_BASE + 0x2000
.EQU  TIM14          , PERIPH_BASE + TIM14_BASE

@.ITEM     TIM13 TIM13_BASE TIM14 TIM14_BASE
.EQU  TIM13T14_CR1      , 0x00                        @ TIM13T14 control register 1 (TIMx_CR1)
.EQU  TIM13T14_DIER     , 0X0C                        @ TIM13T14 DMA/interrupt enable register (TIMx_DIER)
.EQU  TIM13T14_SR       , 0X10                        @ TIM13T14 status register (TIMx_SR)
.EQU  TIM13T14_EGR      , 0X14                        @ TIM13T14 event generation register (TIMx_EGR)
.EQU  TIM13T14_CCMR1    , 0X18                        @ TIM13T14 capture/compare mode register 1 (TIMx_CCMR1)
.EQU  TIM13T14_CCER     , 0X20                        @ TIM13T14 capture/compare enable register (TIMx_CCER)
.EQU  TIM13T14_CNT      , 0X24                        @ TIM13T14 counter ( TIMx_CNT)
.EQU  TIM13T14_PSC      , 0X28                        @ TIM13T14 prescaler ( TIMx_PSC)
.EQU  TIM13T14_ARR      , 0X2C                        @ TIM13T14 auto-reload register (TIMx_ARR)
.EQU  TIM13T14_CCR1     , 0X34                        @ TIM13T14 capture/compare register 1 (TIMx_CCR1)

@.ITEM     TIM13T14_CR1
.EQU  TIM13T14_CR1_CKD_N, 8                           @ Bits 9:8 CKD[1:0]: Clock division
.EQU  TIM13T14_CR1_CKD_1TCK, 0                        @ 00: tDTS=tCK_INT
.EQU  TIM13T14_CR1_CKD_2TCK, 1 << 8                   @ 01: tDTS=2*tCK_INT
.EQU  TIM13T14_CR1_CKD_4TCK, 2 << 8                   @ 10: tDTS=4*tCK_INT
.EQU  TIM13T14_CR1_APRE , 1 << 7                      @ Bit 7 ARPE: Auto-reload preload enable
.EQU  TIM13T14_CR1_OPM  , 1 << 3                      @ Bit 3 OPM: One pulse mode
.EQU  TIM13T14_CR1_URS  , 1 << 2                      @ Bit 2 URS: Update request source
.EQU  TIM13T14_CR1_UDIS , 1 << 1                      @ Bit 1 UDIS: Update disable
.EQU  TIM13T14_CR1_CEN  , 1                           @ Bit 0 CEN: Counter enable

@.ITEM     TIM13T14_DIER
.EQU  TIM13T14_DIER_CC1IE, 1 << 1                     @ Bit 1 CC1IE: Capture/Compare 1 interrupt enable
.EQU  TIM13T14_DIER_UIE , 1 << 0                      @ Bit 0 UIE: Update interrupt enable

@.ITEM     TIM13T14_SR
.EQU  TIM13T14_SR_CC1OF , 1 << 9                      @ Bit 9 CC1OF: Capture/Compare 1 overcapture flag
.EQU  TIM13T14_SR_CC1IF , 1 << 1                      @ Bit 1 CC1IF: Capture/Compare 1 interrupt flag
.EQU  TIM13T14_SR_UIF   , 1 << 0                      @ Bit 0 UIF: Update interrupt flag

@.ITEM     TIM13T14_EGR
.EQU  TIM13T14_EGR_CC1G , 1 << 1                      @ Bit 1 CC1G: Capture/Compare 1 generation
.EQU  TIM13T14_EGR_UG   , 1 << 0                      @ Bit 0 UG: Update generation

@.ITEM     TIM13T14_CCMR1
.EQU  TIM13T14_CCMR1_OCxM_FROZ, 0                     @ 000: Frozen - The comparison between the output compare register TIMx_CCR1 and the counter TIMx_CNT has no effect on the outputs.(this mode is used to generate a timing base).
.EQU  TIM13T14_CCMR1_OCxM_SETCH1, 1                   @ 001: Set channel to active level on match. OC1REF signal is forced high when the counter TIMx_CNT matches the capture/compare register 1 (TIMx_CCR1).
.EQU  TIM13T14_CCMR1_OCxM_RSTCH1, 2                   @ 010: Set channel to inactive level on match. OC1REF signal is forced low when the counter TIMx_CNT matches the capture/compare register 1 (TIMx_CCR1).
.EQU  TIM13T14_CCMR1_OCxM_TGLCH1, 3                   @ 011: Toggle - OC1REF toggles when TIMx_CNT=TIMx_CCR1
.EQU  TIM13T14_CCMR1_OCxM_FORCELOW, 4                 @ 100: Force inactive level - OC1REF is forced low
.EQU  TIM13T14_CCMR1_OCxM_FORCEHIGH, 5                @ 101: Force active level - OC1REF is forced high
.EQU  TIM13T14_CCMR1_OCxM_PWM1, 6                     @ 110: PWM mode 1 - In upcounting, channel 1 is active as long as TIMx_CNT<TIMx_CCR1 else inactive. In downcounting, channel 1 is inactive (OC1REF=‘0’) as long as TIMx_CNT>TIMx_CCR1 else active (OC1REF=’1’).
.EQU  TIM13T14_CCMR1_OCxM_PWM2, 7                     @ 111: PWM mode 2 - In upcounting, channel 1 is inactive as long as TIMx_CNT<TIMx_CCR1  else active. In downcounting, channel 1 is active as long as TIMx_CNT>TIMx_CCR1 else inactive.
.EQU  TIM13T14_CCMR1_OC1M_N, 4                        @ Bits 6:4 OC1M: Output Compare 1 mode
.EQU  TIM13T14_CCMR1_OC1PE, 1 << 3                    @ Bit 3 OC1PE: Output Compare 1 preload enable
.EQU  TIM13T14_CCMR1_OC1FE, 1 << 2                    @ Bit 2 OC1FE: Output Compare 1 fast enable
.EQU  TIM13T14_CCMR1_CC1S_N, 0                        @ Bits 1:0 CC1S: Capture/Compare 1 selection
.EQU  TIM13T14_CCMR1_CC1S_CC1OUT, 0                   @ 00: CC1 channel is configured as output
.EQU  TIM13T14_CCMR1_CC1S_IC1_TO_TI1, 1               @ 01: CC1 channel is configured as input, IC1 is mapped on TI1
.EQU  TIM13T14_CCMR1_CC1S_IC1_TO_TI2, 2               @ 10: CC1 channel is configured as input, IC1 is mapped on TI2
.EQU  TIM13T14_CCMR1_CC1S_IC1_TO_TRC, 3               @ 11: CC1 channel is configured as input, IC1 is mapped on TRC. This mode is working only if an internal trigger input is selected through TS bit (TIMx_SMCR register) Note: CC1S bits are writable only when the channel is OFF (CC1E = ‘0’ in TIMx_CCER).
.EQU  TIM13T14_CCMR1_ICxF_OFCKLT, 0                   @ 0000: No filter, sampling is done at fDTS
.EQU  TIM13T14_CCMR1_ICxF_CKN2, 1                     @ 0001: fSAMPLING=fCK_INT, N=2
.EQU  TIM13T14_CCMR1_ICxF_CKN4, 2                     @ 0010: fSAMPLING=fCK_INT, N=4
.EQU  TIM13T14_CCMR1_ICxF_CKN8, 3                     @ 0011: fSAMPLING=fCK_INT, N=8
.EQU  TIM13T14_CCMR1_ICxF_TS2N6, 4                    @ 0100: fSAMPLING=fDTS/2, N=6
.EQU  TIM13T14_CCMR1_ICxF_TS2N8, 5                    @ 0101: fSAMPLING=fDTS/2, N=8
.EQU  TIM13T14_CCMR1_ICxF_TS4N6, 6                    @ 0110: fSAMPLING=fDTS/4, N=6
.EQU  TIM13T14_CCMR1_ICxF_TS4N8, 7                    @ 0111: fSAMPLING=fDTS/4, N=8
.EQU  TIM13T14_CCMR1_ICxF_TS8N6, 8                    @ 1000: fSAMPLING=fDTS/8, N=6
.EQU  TIM13T14_CCMR1_ICxF_TS8N8, 9                    @ 1001: fSAMPLING=fDTS/8, N=8
.EQU  TIM13T14_CCMR1_ICxF_TS16N5, 10                  @ 1010: fSAMPLING=fDTS/16, N=5
.EQU  TIM13T14_CCMR1_ICxF_TS16N6, 11                  @ 1011: fSAMPLING=fDTS/16, N=6
.EQU  TIM13T14_CCMR1_ICxF_TS16N8, 12                  @ 1100: fSAMPLING=fDTS/16, N=8
.EQU  TIM13T14_CCMR1_ICxF_TS32N5, 13                  @ 1101: fSAMPLING=fDTS/32, N=5
.EQU  TIM13T14_CCMR1_ICxF_TS32N6, 14                  @ 1110: fSAMPLING=fDTS/32, N=6
.EQU  TIM13T14_CCMR1_ICxF_TS32N8, 15                  @ 1111: fSAMPLING=fDTS/32, N=8
.EQU  TIM13T14_CCMR1_ICxPSC_1, 0                      @ 00: no prescaler, capture is done each time an edge is detected on the capture input
.EQU  TIM13T14_CCMR1_ICxPSC_2, 1                      @ 01: capture is done once every 2 events
.EQU  TIM13T14_CCMR1_ICxPSC_4, 2                      @ 10: capture is done once every 4 events
.EQU  TIM13T14_CCMR1_ICxPSC_8, 3                      @ 11: capture is done once every 8 events
.EQU  TIM13T14_CCMR1_IÑ1F_N, 4                        @ Bits 7:4 IC1F[3:0]: Input capture 1 filter
.EQU  TIM13T14_CCMR1_IC1PSC_N, 2                      @ Bits 3:2 IC1PSC: Input capture 1 prescaler

@.ITEM     TIM13T14_CCER
.EQU  TIM13T14_CCER_CC1NP, 1 << 3                     @ Bit 3 CC1NP: Capture/Compare 1 complementary output polarity
.EQU  TIM13T14_CCER_CC1P, 1 << 1                      @ Bit 1 CC1P: Capture/Compare 1 output polarity
.EQU  TIM13T14_CCER_CC1E, 1 << 0                      @ Bit 0 CC1E: Capture/Compare 1 output enable


