Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
vielex
/
bes_labs_2019
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ffba0b05
authored
Mar 05, 2019
by
Víctor Elexpe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Possible solution
parent
1b6e15b4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
4 deletions
Labware/Lab8_SwitchLEDinterface/SwitchLEDInterface.c
Labware/Lab8_SwitchLEDinterface/SwitchLEDInterface.c
View file @
ffba0b05
...
...
@@ -12,11 +12,26 @@
#include "TExaS.h"
#include "tm4c123gh6pm.h"
#define GPIO_PORTE_DATA_R (*((volatile unsigned long *)0x400243FC))
#define GPIO_PORTE_DIR_R (*((volatile unsigned long *)0x40024400))
#define GPIO_PORTE_AFSEL_R (*((volatile unsigned long *)0x40024420))
#define GPIO_PORTE_PUR_R (*((volatile unsigned long *)0x40024510))
#define GPIO_PORTE_DEN_R (*((volatile unsigned long *)0x4002451C))
#define GPIO_PORTE_LOCK_R (*((volatile unsigned long *)0x40024520))
#define GPIO_PORTE_CR_R (*((volatile unsigned long *)0x40024524))
#define GPIO_PORTE_AMSEL_R (*((volatile unsigned long *)0x40024528))
#define GPIO_PORTE_PCTL_R (*((volatile unsigned long *)0x4002452C))
#define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
// ***** 2. Global Declarations Section *****
unsigned
long
SW4
;
unsigned
long
Out
;
// FUNCTION PROTOTYPES: Each subroutine defined
void
DisableInterrupts
(
void
);
// Disable interrupts
void
EnableInterrupts
(
void
);
// Enable interrupts
void
PortE_init
(
void
);
// Init port PE0 PE1
void
Delay1ms
(
unsigned
long
msec
);
// ***** 3. Subroutines Section *****
...
...
@@ -25,16 +40,41 @@ void EnableInterrupts(void); // Enable interrupts
// To avoid damaging your hardware, ensure that your circuits match the schematic
// shown in Lab8_artist.sch (PCB Artist schematic file) or
// Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat).
int
main
(
void
){
int
main
(
void
)
{
//**********************************************************************
// The following version tests input on PE0 and output on PE1
//**********************************************************************
TExaS_Init
(
SW_PIN_PE0
,
LED_PIN_PE1
,
ScopeOn
);
// activate grader and set system clock to 80 MHz
PortE_init
();
EnableInterrupts
();
// enable interrupts for the grader
while
(
1
){
SW4
=
GPIO_PORTE_DATA_R
&
0x00
;
if
(
SW4
)
{
GPIO_PORTE_DATA_R
=
0x02
;
}
Delay1ms
(
100
);
}
}
void
PortE_init
()
{
volatile
unsigned
long
delay
;
SYSCTL_RCGC2_R
|=
0x00000010
;
// 1) F clock
delay
=
SYSCTL_RCGC2_R
;
// delay to allow clock to stabilize
GPIO_PORTE_AMSEL_R
&=
0x00
;
// 2) disable analog function
GPIO_PORTE_PCTL_R
&=
0x00000000
;
// 3) GPIO clear bit PCTL
GPIO_PORTE_DIR_R
&=
~
0x00
;
// 4.1) PF0 input,
GPIO_PORTE_DIR_R
|=
0x01
;
// 4.2) PF1 output
GPIO_PORTE_AFSEL_R
&=
0x00
;
// 5) no alternate function
GPIO_PORTE_PUR_R
|=
0x10
;
// 6) enable pullup resistor on PF4
GPIO_PORTE_DEN_R
|=
0x11
;
// 7) enable digital pins PF1-PF0
}
void
Delay1ms
(
unsigned
long
msec
)
{
unsigned
long
count
;
while
(
msec
>
0
)
{
count
=
1600
;
while
(
count
>
0
)
{
count
--
;
}
ms
--
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment