EE445M RTOS
Taken at the University of Texas Spring 2015
test-priority-scheduler.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 #include "driverlib/rom.h"
23 
24 #define HEARTBEAT_MODAL
25 #include "libos/os.h"
26 #include "libheart/heartbeat.h"
27 #include "libos/semaphore.h"
28 #include "libtimer/timer.h"
29 #include "libsystick/systick.h"
30 
31 uint32_t PIDWork = 0;
34 
35 void timer_task() {
38 }
39 
40 void Task1() {
41 
42  /* Consider: if I can trigger pendsv from an atomic block, will
43  * the atomic block be restarted when the context resumes? */
44  while(1) {
45  /* defun: sem_wait */
46  --semaphore;
47  while (semaphore_blocked(semaphore)) {
48  /* defun: os_surrender_context */
49  /* TODO: examine in the context of this not switching to
50  * Task2 but instead running the loop endlessly */
52  /* end_defun */
53  }
54  /* end_defun */
55  heart_toggle();
56  }
57 }
58 
59 void Task2() {
60  while(1) {
61  ++PIDWork;
62  }
63 }
64 
65 /* Why does this not trigger more than once? */
66 void TIMER0A_Handler(void) {
67 
69 
70  /* the task */
72  /* we should see Task1 blink the heartbeat */
73 
75 }
76 
77 void main(void) {
78 
81 
83 
84  heart_init();
86 
89  TimerConfigure(timer_metadata.timer.base, timer_metadata.timer.periodic);
90  TimerLoadSet(timer_metadata.timer.base, TIMER_A, SysCtlClockGet() / timer_metadata.timer.frequency);
91  TimerIntEnable(timer_metadata.timer.base, TIMER_TIMA_TIMEOUT);
92  IntEnable(timer_metadata.timer.interrupt);
93  TimerEnable(timer_metadata.timer.base, TIMER_A);
94 
95  os_threading_init(100 Hz);
98 
100  os_launch();
101 
102  postpone_death();
103 }
tcb_t * os_add_thread(task_t task)
Definition: os.c:72
#define TIMER_CFG_PERIODIC
Definition: timer.h:62
void TimerIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: timer.c:1464
#define TIMER0_BASE
Definition: hw_memmap.h:81
void Task1()
int8_t semaphore_t
#define sem_post(sem)
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
void heart_toggle()
Toggle once.
Definition: heartbeat.h:106
#define SYSCTL_USE_OSC
Definition: sysctl.h:350
#define TIMER_TIMA_TIMEOUT
Definition: timer.h:135
uint32_t SysCtlClockGet(void)
Definition: sysctl.c:2727
#define SYSCTL_XTAL_16MHZ
Definition: sysctl.h:372
void os_threading_init()
Definition: os.c:34
#define TIMER_A
Definition: timer.h:152
void IntPendSet(uint32_t ui32Interrupt)
Definition: interrupt.c:844
void heart_init()
Initialize for visible transformation.
Definition: heartbeat.h:49
uint32_t PIDWork
void TimerConfigure(uint32_t ui32Base, uint32_t ui32Config)
Definition: timer.c:347
void os_launch()
Definition: os.c:161
#define postpone_death()
Definition: nexus.h:40
void TIMER0A_Handler(void)
#define OS_SYSTEM_POOL
Definition: os.h:28
void timer_task()
void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: timer.c:1568
#define SYSCTL_PERIPH_TIMER0
Definition: sysctl.h:114
bool IntMasterDisable(void)
Definition: interrupt.c:249
void SysCtlPeripheralEnable(uint32_t ui32Peripheral)
Definition: sysctl.c:841
bool IntMasterEnable(void)
uint32_t interrupt_counter
void TimerEnable(uint32_t ui32Base, uint32_t ui32Timer)
Definition: timer.c:210
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
#define sem_signal(sem)
semaphore_t semaphore
#define Hz
Definition: nexus.h:45
#define SYSCTL_SYSDIV_1
Definition: sysctl.h:221
void SysCtlClockSet(uint32_t ui32Config)
Definition: sysctl.c:2532
void TimerLoadSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
Definition: timer.c:969
void Task2()
#define INT_TIMER0A
Definition: hw_ints.h:435
#define sem_init(sem)
#define FAULT_PENDSV
Definition: hw_ints.h:56
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610
#define semaphore_blocked(sem)
void main(void)