-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLED.c
More file actions
64 lines (58 loc) · 1.27 KB
/
LED.c
File metadata and controls
64 lines (58 loc) · 1.27 KB
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
54
55
56
57
58
59
60
61
62
63
64
/*
* LED.c
*
* Created on: Nov 5, 2023
* Author:
*/
/*
* LED.c
*
* Created on: Nov 5, 2023
* Author:
*/
#include <ti/devices/msp/msp.h>
#include "../inc/LaunchPad.h"
// LaunchPad.h defines all the indices into the PINCM table
// initialize your LEDs
void LED_Init(void){
IOMUX->SECCFG.PINCM[PB12INDEX] = (uint32_t) 0x00000081;
IOMUX->SECCFG.PINCM[PB17INDEX] = (uint32_t) 0x00000081;
IOMUX->SECCFG.PINCM[PB13INDEX] = (uint32_t) 0x00000081;
GPIOB->DOE31_0 |= 0x00023000; // enable outputs
}
// data specifies which LED to turn on
void LED_On(uint32_t data){
if(data == 12){
GPIOB->DOUTSET31_0 = (1<<12);
}
if(data == 17){
GPIOB->DOUTSET31_0 = (1<<17);
}
if(data == 13){
GPIOB->DOUTSET31_0 = (1<<13);
}
}
// data specifies which LED to turn off
void LED_Off(uint32_t data){
if(data == 12){
GPIOB->DOUTCLR31_0 = (1<<12);
}
if(data == 17){
GPIOB->DOUTCLR31_0 = (1<<17);
}
if(data == 13){
GPIOB->DOUTCLR31_0 = (1<<13);
}
}
// data specifies which LED to toggle
void LED_Toggle(uint32_t data){
if(data == 12){
GPIOB->DOUTTGL31_0 = (1<<12);
}
if(data == 17){
GPIOB->DOUTTGL31_0= (1<<17);
}
if(data == 13){
GPIOB->DOUTTGL31_0= (1<<13);
}
}