-
Notifications
You must be signed in to change notification settings - Fork 0
/
boardSupport.c
53 lines (38 loc) · 1.22 KB
/
boardSupport.c
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
#include <stdint.h>
#include "boardSupport.h"
#include "TM4C123GH6PM.h"
#include <stdlib.h>
static uint32_t volatile tick;
void SysTick_Handler(void) {
++tick;
}
void initValues(void) {
SYSCTL->RCGCGPIO |= (1U << 5); // start up GPIO F pins
SYSCTL->GPIOHBCTL |= (1U << 5); // start up the advaced parfarile bus GPIO F
GPIOF_AHB->DIR |= (RED | BLUE | GREEN); //give all oif the directions to the dir
GPIOF_AHB->DEN |= (RED | BLUE | GREEN); // give all the values that will be drained
SystemCoreClockUpdate();
SysTick->LOAD = SystemCoreClock / 100U; // Set the reload value
SysTick->VAL = 0; // Clear the current value
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk;
__enable_irq();
}
// control the tick function to avoid race conditions
uint32_t TickCtr(void) {
uint32_t t;
__disable_irq();
t = tick;
__enable_irq();
return t;
}
void delay(uint32_t ticks) {
uint32_t ctrl = TickCtr();
while ((TickCtr() - ctrl) < ticks) {
}
}
void LedHandleOn(uint32_t color){
GPIOF_AHB -> DATA |= color;
}
void LedHandleOff(uint32_t color){
GPIOF_AHB -> DATA &= ~color;
}