EE445M RTOS
Taken at the University of Texas Spring 2015
test-debounce.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "inc/hw_ints.h"
#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/timer.h"
#include "driverlib/adc.h"
#include "libos/os.h"
#include "libos/jitter.h"
#include "libheart/heartbeat.h"
#include "libbutton/button.h"
#include "libtimer/timer.h"
#include "libhw/hardware.h"
#include "libos/semaphore.h"
#include "libadc/adc.h"
#include "libuart/uart.h"
#include "libshell/shell.h"
Include dependency graph for test-debounce.c:

Go to the source code of this file.

Macros

#define HEARTBEAT_MODAL
 

Functions

void button_debounce_end (notification button_notification)
 
void button_debounce_start (notification button_notification)
 
void led_blink_red ()
 
void led_blink_green ()
 
void led_blink_blue ()
 
void postpone_suicide ()
 
int main ()
 

Variables

volatile uint32_t button_left_pressed
 
volatile uint32_t button_right_pressed
 
volatile uint32_t button_debounced_mailbox
 
volatile uint32_t button_debounced_wtf
 
volatile semaphore_t button_debounced_new_data
 
uint32_t red_work = 0
 
uint32_t blue_work = 0
 
uint32_t green_work = 0
 

Macro Definition Documentation

#define HEARTBEAT_MODAL

Definition at line 26 of file test-debounce.c.

Function Documentation

void button_debounce_end ( notification  button_notification)

Definition at line 52 of file test-debounce.c.

References button_debounced_mailbox, button_debounced_new_data, BUTTONS_BOTH, GPIO_PORTF_BASE, GPIOPinRead(), and sem_post.

Referenced by button_debounce_start().

52  {
53 
56 }
#define sem_post(sem)
#define BUTTONS_BOTH
Definition: button.h:28
volatile semaphore_t button_debounced_new_data
Definition: test-debounce.c:46
volatile uint32_t button_debounced_mailbox
Definition: test-debounce.c:43
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

void button_debounce_start ( notification  button_notification)

Definition at line 59 of file test-debounce.c.

References button_debounce_end(), button_debounced_wtf, BUTTONS_BOTH, GPIO_PORTF_BASE, GPIOPinRead(), hw_channel_init(), hw_subscribe_single_shot, HW_TIMER, Hz, INT_TIMER0A, TIMER0_BASE, TIMER_CFG_ONE_SHOT, and timer_metadata_init.

Referenced by main().

59  {
60 
63  hw_channel_init(HW_TIMER, timer_metadata);
64  hw_subscribe_single_shot(HW_TIMER, timer_metadata,
66 }
#define TIMER_CFG_ONE_SHOT
Definition: timer.h:59
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define hw_subscribe_single_shot(type, metadata, isr)
Definition: hardware.h:190
volatile uint32_t button_debounced_wtf
Definition: test-debounce.c:44
#define BUTTONS_BOTH
Definition: button.h:28
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
#define Hz
Definition: nexus.h:45
void button_debounce_end(notification button_notification)
Definition: test-debounce.c:52
void hw_channel_init(HW_TYPE type, hw_metadata metadata)
Definition: hardware.c:94
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
#define INT_TIMER0A
Definition: hw_ints.h:435
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

void led_blink_blue ( )

Definition at line 86 of file test-debounce.c.

References blue_work, GPIO_PIN_2, GPIO_PORTF_BASE, GPIOPinRead(), and GPIOPinWrite().

Referenced by postpone_suicide().

86  {
87  /* while (1) { */
88  ++blue_work;
91  /* os_surrender_context(); */
92  /* } */
93 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_2
Definition: gpio.h:62
uint32_t blue_work
Definition: test-debounce.c:49
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

void led_blink_green ( )

Definition at line 77 of file test-debounce.c.

References GPIO_PIN_3, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and green_work.

Referenced by postpone_suicide().

77  {
78  /* while (1) { */
79  ++green_work;
82  /* os_surrender_context(); */
83  /* } */
84 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
uint32_t green_work
Definition: test-debounce.c:50
#define GPIO_PIN_3
Definition: gpio.h:63
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

void led_blink_red ( )

Definition at line 68 of file test-debounce.c.

References GPIO_PIN_1, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), os_surrender_context, and red_work.

68  {
69  while (1) {
70  ++red_work;
74  }
75 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_1
Definition: gpio.h:61
#define os_surrender_context()
Definition: os.h:142
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
uint32_t red_work
Definition: test-debounce.c:48
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

int main ( void  )

Definition at line 112 of file test-debounce.c.

References button_debounce_start(), button_debounced_mailbox, button_debounced_new_data, button_left_pressed, button_metadata_init, button_right_pressed, BUTTONS_BOTH, DL_SOFT, GPIO_BOTH_EDGES, GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PORTF_BASE, heart_init(), HW_BUTTON, hw_driver_init(), hw_init, hw_subscribe, HW_TIMER, Hz, INT_TIMER0A, IntMasterDisable(), IntMasterEnable(), os_launch(), os_threading_init(), postpone_suicide(), schedule(), sem_init, SYSCTL_OSC_MAIN, SYSCTL_SYSDIV_1, SYSCTL_USE_OSC, SYSCTL_XTAL_16MHZ, SysCtlClockSet(), TIMER0_BASE, TIMER_CFG_ONE_SHOT, and timer_metadata_init.

112  {
113 
116 
118 
119  /* begin heartbeat init */
120  heart_init();
121  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_1);
122  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_2);
123  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_3);
124  /* end heartbeat init */
125 
126  /* begin timer init */
128  hw_driver_init(HW_TIMER, timer_metadata);
129  /* end timer init */
130 
131  /* button init */
136 
138 
139  hw_init(HW_BUTTON, button_metadata);
140  hw_subscribe(HW_BUTTON, button_metadata, button_debounce_start);
141  /* end button init */
142 
145 
146  IntMasterEnable();
147  os_launch();
148 
149  while (1) {}
150 }
#define TIMER_CFG_ONE_SHOT
Definition: timer.h:59
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define button_metadata_init(_base, _pin, _interrupt)
Definition: button.h:23
#define GPIO_BOTH_EDGES
Definition: gpio.h:87
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
#define hw_subscribe(type, metadata, isr)
Definition: hardware.h:178
#define SYSCTL_USE_OSC
Definition: sysctl.h:350
volatile uint32_t button_right_pressed
Definition: test-debounce.c:41
#define GPIO_PIN_2
Definition: gpio.h:62
volatile uint32_t button_left_pressed
Definition: test-debounce.c:40
#define SYSCTL_XTAL_16MHZ
Definition: sysctl.h:372
#define hw_init(type, metadata)
Definition: hardware.h:143
#define GPIO_PIN_1
Definition: gpio.h:61
void os_threading_init()
Definition: os.c:34
void schedule(task_t task, frequency_t frequency, DEADLINE_TYPE seriousness)
Definition: os.c:386
void postpone_suicide()
Definition: test-debounce.c:95
#define BUTTONS_BOTH
Definition: button.h:28
void heart_init()
Initialize for visible transformation.
Definition: heartbeat.h:49
void os_launch()
Definition: os.c:161
void hw_driver_init(HW_TYPE type, hw_metadata metadata)
Definition: hardware.c:62
volatile semaphore_t button_debounced_new_data
Definition: test-debounce.c:46
bool IntMasterDisable(void)
Definition: interrupt.c:249
#define GPIO_PIN_3
Definition: gpio.h:63
bool IntMasterEnable(void)
void button_debounce_start(notification button_notification)
Definition: test-debounce.c:59
volatile uint32_t button_debounced_mailbox
Definition: test-debounce.c:43
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
#define Hz
Definition: nexus.h:45
#define SYSCTL_SYSDIV_1
Definition: sysctl.h:221
void SysCtlClockSet(uint32_t ui32Config)
Definition: sysctl.c:2532
#define INT_TIMER0A
Definition: hw_ints.h:435
#define sem_init(sem)
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

void postpone_suicide ( )

Definition at line 95 of file test-debounce.c.

References button_debounced_mailbox, button_debounced_new_data, BUTTON_LEFT, button_left_pressed, BUTTON_RIGHT, button_right_pressed, led_blink_blue(), led_blink_green(), sem_guard, and sem_take.

Referenced by main().

95  {
96 
97  while (1) {
101  led_blink_blue();
103  }
105  led_blink_green();
107  }
108  }
109  }
110 }
volatile uint32_t button_right_pressed
Definition: test-debounce.c:41
volatile uint32_t button_left_pressed
Definition: test-debounce.c:40
#define sem_take(sem)
volatile semaphore_t button_debounced_new_data
Definition: test-debounce.c:46
#define BUTTON_LEFT
Definition: button.h:26
#define BUTTON_RIGHT
Definition: button.h:27
#define sem_guard(sem)
volatile uint32_t button_debounced_mailbox
Definition: test-debounce.c:43
void led_blink_blue()
Definition: test-debounce.c:86
void led_blink_green()
Definition: test-debounce.c:77

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

uint32_t blue_work = 0

Definition at line 49 of file test-debounce.c.

Referenced by led_blink_blue().

volatile uint32_t button_debounced_mailbox

Definition at line 43 of file test-debounce.c.

Referenced by button_debounce_end(), main(), and postpone_suicide().

volatile semaphore_t button_debounced_new_data

Definition at line 46 of file test-debounce.c.

Referenced by button_debounce_end(), main(), and postpone_suicide().

volatile uint32_t button_debounced_wtf

Definition at line 44 of file test-debounce.c.

Referenced by button_debounce_start().

volatile uint32_t button_left_pressed

Definition at line 40 of file test-debounce.c.

Referenced by main(), and postpone_suicide().

volatile uint32_t button_right_pressed

Definition at line 41 of file test-debounce.c.

Referenced by main(), and postpone_suicide().

uint32_t green_work = 0

Definition at line 50 of file test-debounce.c.

Referenced by led_blink_green().

uint32_t red_work = 0

Definition at line 48 of file test-debounce.c.

Referenced by led_blink_red().