EE445M RTOS
Taken at the University of Texas Spring 2015
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
test-button.c
Go to the documentation of this file.
1
/* -*- mode: c; c-basic-offset: 4; -*- */
2
/* Created by Hershal Bhave and Eric Crosson on 2015-01-24 */
3
/* Revision History: Look in Git FGT */
4
5
/* Standard Libs */
6
#include <stdint.h>
7
#include <stdbool.h>
8
#include <stdio.h>
9
#include <stdlib.h>
10
11
/* TI Includes */
12
#include "
inc/hw_ints.h
"
13
#include "
inc/hw_gpio.h
"
14
#include "
inc/hw_memmap.h
"
15
16
/* Driverlib Includes */
17
#include "
driverlib/debug.h
"
18
#include "
driverlib/gpio.h
"
19
#include "
driverlib/interrupt.h
"
20
#include "
driverlib/pin_map.h
"
21
#include "
driverlib/sysctl.h
"
22
#include "
driverlib/systick.h
"
23
#include "
driverlib/rom.h
"
24
25
#include "
libos/os.h
"
26
#include "
libbutton/button.h
"
27
#include "
libhw/hardware.h
"
28
29
uint32_t
button_left_pressed
= 0;
30
uint32_t
button_right_pressed
= 0;
31
32
void
update_pid
(
notification
button_bitmask) {
33
/* What was that technique we learned in 460n to avoid a bunch of
34
branches? cond && action*/
35
if
(button_bitmask.
_int
&
BUTTON_LEFT
) {
36
button_left_pressed
++;
37
}
38
if
(button_bitmask.
_int
&
BUTTON_RIGHT
) {
39
button_right_pressed
++;
40
}
41
}
42
43
int
main
() {
44
45
SysCtlClockSet
(
SYSCTL_SYSDIV_1
|
SYSCTL_USE_OSC
|
SYSCTL_OSC_MAIN
|
46
SYSCTL_XTAL_16MHZ
);
47
48
IntMasterDisable
();
49
50
button_metadata_init
(
GPIO_PORTF_BASE
,
BUTTONS_BOTH
,
GPIO_BOTH_EDGES
);
51
hw_init
(
HW_BUTTON
, button_metadata);
52
hw_subscribe
(
HW_BUTTON
, button_metadata,
update_pid
);
53
54
IntMasterEnable
();
55
56
postpone_death
();
57
}
main
int main()
Definition:
test-button.c:43
hw_memmap.h
systick.h
notification::_int
int _int
Definition:
notify.h:23
button_left_pressed
uint32_t button_left_pressed
Definition:
test-button.c:29
button_metadata_init
#define button_metadata_init(_base, _pin, _interrupt)
Definition:
button.h:23
debug.h
gpio.h
GPIO_BOTH_EDGES
#define GPIO_BOTH_EDGES
Definition:
gpio.h:87
button.h
button_right_pressed
uint32_t button_right_pressed
Definition:
test-button.c:30
SYSCTL_OSC_MAIN
#define SYSCTL_OSC_MAIN
Definition:
sysctl.h:378
hw_subscribe
#define hw_subscribe(type, metadata, isr)
Definition:
hardware.h:178
SYSCTL_USE_OSC
#define SYSCTL_USE_OSC
Definition:
sysctl.h:350
SYSCTL_XTAL_16MHZ
#define SYSCTL_XTAL_16MHZ
Definition:
sysctl.h:372
hw_init
#define hw_init(type, metadata)
Definition:
hardware.h:143
pin_map.h
BUTTONS_BOTH
#define BUTTONS_BOTH
Definition:
button.h:28
hw_ints.h
postpone_death
#define postpone_death()
Definition:
nexus.h:40
hardware.h
os.h
IntMasterDisable
bool IntMasterDisable(void)
Definition:
interrupt.c:249
BUTTON_LEFT
#define BUTTON_LEFT
Definition:
button.h:26
IntMasterEnable
bool IntMasterEnable(void)
update_pid
void update_pid(notification button_bitmask)
Definition:
test-button.c:32
BUTTON_RIGHT
#define BUTTON_RIGHT
Definition:
button.h:27
interrupt.h
hw_gpio.h
HW_BUTTON
Definition:
hardware.h:49
rom.h
sysctl.h
SYSCTL_SYSDIV_1
#define SYSCTL_SYSDIV_1
Definition:
sysctl.h:221
SysCtlClockSet
void SysCtlClockSet(uint32_t ui32Config)
Definition:
sysctl.c:2532
notification
Definition:
notify.h:22
GPIO_PORTF_BASE
#define GPIO_PORTF_BASE
Definition:
hw_memmap.h:74
board-progs
test-button
test-button.c
Generated on Fri Mar 13 2015 21:18:36 for EE445M RTOS by
1.8.9.1