~ruther/uni-mam-arm

dcbb63902e125a0ec7a6236c3e394b46058f12d7 — Rutherther 4 months ago f65841c
feat(arm03): null timer while button is held
1 files changed, 19 insertions(+), 8 deletions(-)

M arm03/src/main.c
M arm03/src/main.c => arm03/src/main.c +19 -8
@@ 73,7 73,10 @@ timer_t startstop_debounce_timer;

exti_t startstop_exti;
pin_t startstop_button;
exti_t null_button;
pin_t null_button;

void null_timer(void);
void toggle_timer(void);

void main()
{


@@ 94,14 97,17 @@ void main()
  //  digit update frequency * digits * 34
  //  aim for 100 Hz * 4 * 17 = 6 800 Hz

  exti_init(&null_button, 4, EXTI, SYSCFG);
  exti_external_interrupt(&null_button, EXTI_GPIOA);
  exti_rising_interrupt(&null_button);
  exti_enable_interrupt(&null_button);
  /* exti_init(&null_button, 4, EXTI, SYSCFG); */
  /* exti_external_interrupt(&null_button, EXTI_GPIOA); */
  /* exti_rising_interrupt(&null_button); */
  /* exti_enable_interrupt(&null_button); */
  pin_init(&null_button, GPIOA, 4);
  pin_into_input(&null_button);
  pin_speed(&null_button, LOW_SPEED);

  exti_init(&startstop_exti, 0, EXTI, SYSCFG);
  exti_external_interrupt(&startstop_exti, EXTI_GPIOB);
  exti_rising_interrupt(&startstop_exti);
  exti_falling_interrupt(&startstop_exti);
  exti_enable_interrupt(&startstop_exti);

  pin_init(&startstop_button, GPIOB, 0);


@@ 144,7 150,12 @@ void main()

  // Application
  while (1) {
    uint32_t count = timer_count(&stopwatch_timer) >> 2;
    uint32_t count = 0;
    if (!pin_read(&null_button)) {
      null_timer();
    } else {
      count = timer_count(&stopwatch_timer) >> 2;
    }

    display_enable_digit(&display, 0,
                         (count % display.max_value) >= 1000);


@@ 188,7 199,7 @@ void TIM3_handler(void) {

void TIM4_handler(void) {
  timer_clear_interrupt(&startstop_debounce_timer);
  if (pin_read(&startstop_button)) {
  if (!pin_read(&startstop_button)) {
    toggle_timer();
  }
}

Do not follow this link