/*
 * activity6.c
 *
 *  Created on: Sep 25, 2025
 *      Author: sowgro
 */

#include <stdio.h>
#include "systick.h"

// moved struct to systick.h

void activity6_run() {
	systick_t *s = (systick_t *) 0xE000E010;
	printf("%lu\r\n", s->CVR);

	s->RVR = 8000000;
	s->CSR |= 1;      // Turn on systick timer
	s->CSR |= 1<<2;   // Use internal clock

	int time = 0;
	int count = 0;
	for(;;) {
        if (s->CSR & (1<<16)) {
            count++;
            if (count == 10) { // Count to 10 tenths then print next second
                printf ("%d\r\n", time);
                time++;
                count = 0;
            }

        }
	}
}
