-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch.cpp
More file actions
30 lines (26 loc) · 922 Bytes
/
Switch.cpp
File metadata and controls
30 lines (26 loc) · 922 Bytes
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
/*
* Switch.cpp
*
* 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
void Switch_Init(void){
// write this
IOMUX->SECCFG.PINCM[PA28INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA27INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA16INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA15INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA0INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA18INDEX] = 0x00040081; // input, no pull
IOMUX->SECCFG.PINCM[PA17INDEX] = 0x00040081; // input, no pull
}
// return current state of switches
uint32_t Switch_In(void){
// write this
uint32_t data = GPIOA->DIN31_0;
data = ((data>>15)&0x03) | ((data&((1<<28)|(1<<27)))>>25);
return data; // return 0; //replace this your code
}