EE445M RTOS
Taken at the University of Texas Spring 2015
test-priority-scheduler.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "inc/hw_ints.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/rom.h"
#include "libos/os.h"
#include "libheart/heartbeat.h"
#include "libos/semaphore.h"
#include "libtimer/timer.h"
#include "libsystick/systick.h"
Include dependency graph for test-priority-scheduler.c:

Go to the source code of this file.

Macros

#define HEARTBEAT_MODAL
 

Functions

void timer_task ()
 
void Task1 ()
 
void Task2 ()
 
void TIMER0A_Handler (void)
 
void main (void)
 

Variables

uint32_t PIDWork = 0
 
semaphore_t semaphore
 
uint32_t interrupt_counter
 

Macro Definition Documentation

#define HEARTBEAT_MODAL

Definition at line 24 of file test-priority-scheduler.c.

Function Documentation

void main ( void  )

Definition at line 77 of file test-priority-scheduler.c.

References heart_init(), Hz, INT_TIMER0A, IntEnable(), IntMasterDisable(), IntMasterEnable(), os_add_thread(), os_launch(), OS_SYSTEM_POOL, os_threading_init(), postpone_death, sem_init, semaphore, SYSCTL_OSC_MAIN, SYSCTL_PERIPH_TIMER0, SYSCTL_SYSDIV_1, SYSCTL_USE_OSC, SYSCTL_XTAL_16MHZ, SysCtlClockGet(), SysCtlClockSet(), SysCtlPeripheralEnable(), Task1(), Task2(), TIMER0_BASE, TIMER_A, TIMER_CFG_PERIODIC, timer_metadata_init, TIMER_TIMA_TIMEOUT, TimerConfigure(), TimerEnable(), TimerIntEnable(), and TimerLoadSet().

77  {
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()
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
#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 heart_init()
Initialize for visible transformation.
Definition: heartbeat.h:49
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
#define OS_SYSTEM_POOL
Definition: os.h:28
#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)
void TimerEnable(uint32_t ui32Base, uint32_t ui32Timer)
Definition: timer.c:210
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
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)
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

void Task1 ( )

Definition at line 40 of file test-priority-scheduler.c.

References FAULT_PENDSV, heart_toggle(), IntPendSet(), semaphore, and semaphore_blocked.

Referenced by main().

40  {
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 }
void heart_toggle()
Toggle once.
Definition: heartbeat.h:106
void IntPendSet(uint32_t ui32Interrupt)
Definition: interrupt.c:844
semaphore_t semaphore
#define FAULT_PENDSV
Definition: hw_ints.h:56
#define semaphore_blocked(sem)

Here is the call graph for this function:

Here is the caller graph for this function:

void Task2 ( )

Definition at line 59 of file test-priority-scheduler.c.

References PIDWork.

Referenced by main().

59  {
60  while(1) {
61  ++PIDWork;
62  }
63 }
uint32_t PIDWork

Here is the caller graph for this function:

void TIMER0A_Handler ( void  )

Definition at line 66 of file test-priority-scheduler.c.

References interrupt_counter, sem_signal, semaphore, TIMER0_BASE, TIMER_TIMA_TIMEOUT, and TimerIntClear().

Referenced by __attribute__().

66  {
67 
69 
70  /* the task */
72  /* we should see Task1 blink the heartbeat */
73 
75 }
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define TIMER_TIMA_TIMEOUT
Definition: timer.h:135
void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: timer.c:1568
uint32_t interrupt_counter
#define sem_signal(sem)
semaphore_t semaphore

Here is the call graph for this function:

Here is the caller graph for this function:

void timer_task ( )

Definition at line 35 of file test-priority-scheduler.c.

References sem_post, semaphore, TIMER0_BASE, TIMER_TIMA_TIMEOUT, and TimerIntClear().

35  {
38 }
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define sem_post(sem)
#define TIMER_TIMA_TIMEOUT
Definition: timer.h:135
void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: timer.c:1568
semaphore_t semaphore

Here is the call graph for this function:

Variable Documentation

uint32_t interrupt_counter

Definition at line 33 of file test-priority-scheduler.c.

Referenced by TIMER0A_Handler().

uint32_t PIDWork = 0

Definition at line 31 of file test-priority-scheduler.c.

Referenced by Task2().

semaphore_t semaphore

Definition at line 32 of file test-priority-scheduler.c.

Referenced by main(), Task1(), TIMER0A_Handler(), and timer_task().