EE445M RTOS
Taken at the University of Texas Spring 2015
test-edf.c
Go to the documentation of this file.
1 /* -*- mode: c; c-basic-offset: 4; -*- */
2 /* Created by Eric Crosson on 2015-02-20 */
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_memmap.h"
14 
15 /* Driverlib Includes */
16 #include "driverlib/debug.h"
17 #include "driverlib/gpio.h"
18 #include "driverlib/interrupt.h"
19 #include "driverlib/pin_map.h"
20 #include "driverlib/sysctl.h"
21 #include "driverlib/systick.h"
22 
23 #define HEARTBEAT_MODAL
24 #define SCHEDLUE_PRIORITY
25 #define SCHEDULER_MAX_THREADS 16
26 
27 #include "libbutton/button.h"
28 #include "libtimer/timer.h"
29 #include "libschedule/schedule.h"
30 #include "libos/os.h"
31 #include "libheart/heartbeat.h"
32 
33 #define HEART_RED GPIO_PIN_1
34 #define HEART_BLUE GPIO_PIN_2
35 #define HEART_GREEN GPIO_PIN_3
36 
37 volatile uint32_t button_left_pressed;
38 volatile uint32_t button_right_pressed;
39 
40 volatile uint32_t button_debounced_mailbox;
41 volatile uint32_t button_debounced_wtf;
42 
44 
45 volatile uint32_t red_work = 0;
46 volatile uint32_t blue_work = 0;
47 
48 void button_debounce_end(notification button_notification) {
49 
52 }
53 
54 /* what the btn handler calls */
55 void button_debounce_start(notification button_notification) {
56 
59  hw_channel_init(HW_TIMER, timer_metadata);
60  hw_subscribe_single_shot(HW_TIMER, timer_metadata,
62 }
63 
65 
66  while (1) {
73  }
78  }
79  }
80  /* os_surrender_context(); */
81  }
82 }
83 
84 void led_blink_red() {
85  while (1) {
86  ++red_work;
89  /* os_surrender_context(); */
90  }
91 }
92 
94  while (1) {
95  ++blue_work;
98  /* os_surrender_context(); */
99  }
100 }
101 
102 void main(void) {
103 
106 
108 
109  heart_init();
110  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_1);
111  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_2);
112  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_3);
113 
114  /* begin timer init */
116  hw_driver_init(HW_TIMER, timer_metadata);
117  /* end timer init */
118 
119  /* button init */
121 
122  hw_init(HW_BUTTON, button_metadata);
123  hw_subscribe(HW_BUTTON, button_metadata, button_debounce_end);
124 
125  pidwork_init();
126 
129  /* schedule(led_blink_green, 10 Hz, DL_SOFT); */
132  /* next test: different frequencies,pools */
133 
134  IntMasterEnable();
135  os_launch();
136 
137  postpone_death();
138 }
void pidwork_init()
Definition: jitter.c:6
#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 hw_subscribe_single_shot(type, metadata, isr)
Definition: hardware.h:190
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_BOTH_EDGES
Definition: gpio.h:87
int8_t semaphore_t
volatile uint32_t button_debounced_mailbox
Definition: test-edf.c:40
#define sem_post(sem)
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
#define hw_subscribe(type, metadata, isr)
Definition: hardware.h:178
void button_debounce_start(notification button_notification)
Definition: test-edf.c:55
void main(void)
Definition: test-edf.c:102
volatile uint32_t button_left_pressed
Definition: test-edf.c:37
#define SYSCTL_USE_OSC
Definition: sysctl.h:350
void postpone_suicide()
Definition: test-edf.c:64
#define GPIO_PIN_2
Definition: gpio.h:62
#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 button_debounce_end(notification button_notification)
Definition: test-edf.c:48
void os_threading_init()
Definition: os.c:34
void schedule(task_t task, frequency_t frequency, DEADLINE_TYPE seriousness)
Definition: os.c:386
#define BUTTONS_BOTH
Definition: button.h:28
#define sem_take(sem)
void heart_init()
Initialize for visible transformation.
Definition: heartbeat.h:49
void os_launch()
Definition: os.c:161
#define postpone_death()
Definition: nexus.h:40
void hw_driver_init(HW_TYPE type, hw_metadata metadata)
Definition: hardware.c:62
volatile semaphore_t button_debounced_new_data
Definition: test-edf.c:43
volatile uint32_t button_right_pressed
Definition: test-edf.c:38
bool IntMasterDisable(void)
Definition: interrupt.c:249
#define BUTTON_LEFT
Definition: button.h:26
#define GPIO_PIN_3
Definition: gpio.h:63
bool IntMasterEnable(void)
#define BUTTON_RIGHT
Definition: button.h:27
void led_blink_blue()
Definition: test-edf.c:93
#define sem_guard(sem)
#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
volatile uint32_t blue_work
Definition: test-edf.c:46
void led_blink_red()
Definition: test-edf.c:84
void SysCtlClockSet(uint32_t ui32Config)
Definition: sysctl.c:2532
volatile uint32_t button_debounced_wtf
Definition: test-edf.c:41
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
volatile uint32_t red_work
Definition: test-edf.c:45
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74