EE445M RTOS
Taken at the University of Texas Spring 2015
test-os.c File Reference
#include <stdint.h>
#include <stdbool.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/uart.h"
#include "libos/os.h"
#include "libheart/heartbeat.h"
#include "libhw/hardware.h"
#include "libstd/nexus.h"
#include <sys/stat.h>
Include dependency graph for test-os.c:

Go to the source code of this file.

Macros

#define HEARTBEAT_MODAL
 
#define UART_FIFO_SIZE   0x7f
 
#define PIDWORK_BUFFER_SIZE   0x7f
 

Functions

void Thread1 (void)
 
void Thread2 (void)
 
void uart_consumer (void)
 
int main ()
 

Variables

volatile uint32_t pidwork
 
volatile uint32_t highest_pidwork
 
volatile uint32_t lowest_pidwork
 
volatile uint32_t pidwork_idx
 
volatile uint32_t * pidwork_buffer
 
volatile uint32_t uart_producer_idx
 
volatile uint32_t uart_consumer_idx
 
volatile char * uart_fifo
 
volatile uint32_t uart_dropped_chars
 

Macro Definition Documentation

#define HEARTBEAT_MODAL

Definition at line 22 of file test-os.c.

#define PIDWORK_BUFFER_SIZE   0x7f

Definition at line 32 of file test-os.c.

Referenced by main(), pidwork_record(), and Thread2().

#define UART_FIFO_SIZE   0x7f

Definition at line 31 of file test-os.c.

Referenced by main(), and uart_consumer().

Function Documentation

int main ( void  )

A thread that continuously toggles GPIO pin 3 on GPIO_PORT_F.

Definition at line 93 of file test-os.c.

References GPIO_PIN_0, GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PORTA_BASE, GPIO_PORTF_BASE, GPIOPinConfigure(), GPIOPinTypeUART(), heart_init(), highest_pidwork, Hz, IntMasterDisable(), IntMasterEnable(), lowest_pidwork, os_add_thread(), OS_INTERACTIVE_POOL, os_launch(), os_threading_init(), pidwork, pidwork_buffer, PIDWORK_BUFFER_SIZE, pidwork_idx, postpone_death, SYSCTL_OSC_MAIN, SYSCTL_PERIPH_GPIOA, SYSCTL_PERIPH_UART0, SYSCTL_SYSDIV_1, SYSCTL_USE_OSC, SYSCTL_XTAL_16MHZ, SysCtlClockGet(), SysCtlClockSet(), SysCtlPeripheralEnable(), Thread1(), Thread2(), UART0_BASE, UART_CONFIG_PAR_NONE, UART_CONFIG_STOP_ONE, UART_CONFIG_WLEN_8, UART_FIFO_SIZE, and UARTConfigSetExpClk().

93  {
94 
95  char uart_fifo_raw[UART_FIFO_SIZE];
96  uint32_t pidwork_buffer_raw[PIDWORK_BUFFER_SIZE];
97 
100 
102 
103  /* Initialize global variables */
104  pidwork = 0;
105  highest_pidwork = 0;
106  lowest_pidwork = (uint32_t)(-1);
107  pidwork_buffer = pidwork_buffer_raw;
108  pidwork_idx = 0;
109 
110  /* Enable the UART */
113  GPIOPinConfigure(GPIO_PA0_U0RX);
114  GPIOPinConfigure(GPIO_PA1_U0TX);
119 
120  /* Enable the UART interrupt. */
121 
122  /* IntEnable(INT_UART0); */
123  /* UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); */
124  /* uart_fifo = uart_fifo_raw; */
125  /* uart_producer_idx = 0; */
126  /* uart_consumer_idx = UART_FIFO_SIZE - 1; */
127 
128  os_threading_init(100 Hz);
131  /* os_add_thread(hw_daemon, OS_SYSTEM_POOL); */
132 
133  heart_init();
134  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_1);
135  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_2);
136  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_3);
137 
138  /* os_trap_ */
139  os_launch();
140 
141  /* PONDER: why do interrupts fire without this? */
142  IntMasterEnable();
143  postpone_death();
144 }
tcb_t * os_add_thread(task_t task)
Definition: os.c:72
void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2031
#define GPIO_PIN_0
Definition: gpio.h:60
void UARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk, uint32_t ui32Baud, uint32_t ui32Config)
Definition: uart.c:368
#define PIDWORK_BUFFER_SIZE
Definition: test-os.c:32
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
volatile uint32_t pidwork_idx
Definition: test-os.c:37
#define SYSCTL_USE_OSC
Definition: sysctl.h:350
#define GPIO_PIN_2
Definition: gpio.h:62
uint32_t SysCtlClockGet(void)
Definition: sysctl.c:2727
#define SYSCTL_XTAL_16MHZ
Definition: sysctl.h:372
#define GPIO_PIN_1
Definition: gpio.h:61
#define SYSCTL_PERIPH_UART0
Definition: sysctl.h:122
void os_threading_init()
Definition: os.c:34
#define UART_CONFIG_STOP_ONE
Definition: uart.h:90
volatile uint32_t lowest_pidwork
Definition: test-os.c:36
#define UART_CONFIG_WLEN_8
Definition: uart.h:85
#define SYSCTL_PERIPH_GPIOA
Definition: sysctl.h:71
void heart_init()
Initialize for visible transformation.
Definition: heartbeat.h:49
#define GPIO_PORTA_BASE
Definition: hw_memmap.h:53
void Thread1(void)
Definition: test-os.c:46
void os_launch()
Definition: os.c:161
#define postpone_death()
Definition: nexus.h:40
volatile uint32_t pidwork
Definition: test-os.c:34
#define OS_INTERACTIVE_POOL
Definition: os.h:32
bool IntMasterDisable(void)
Definition: interrupt.c:249
void SysCtlPeripheralEnable(uint32_t ui32Peripheral)
Definition: sysctl.c:841
#define GPIO_PIN_3
Definition: gpio.h:63
bool IntMasterEnable(void)
volatile uint32_t * pidwork_buffer
Definition: test-os.c:38
void GPIOPinConfigure(uint32_t ui32PinConfig)
Definition: gpio.c:2509
#define UART_FIFO_SIZE
Definition: test-os.c:31
void Thread2(void)
Definition: test-os.c:60
#define Hz
Definition: nexus.h:45
#define UART0_BASE
Definition: hw_memmap.h:61
volatile uint32_t highest_pidwork
Definition: test-os.c:35
#define SYSCTL_SYSDIV_1
Definition: sysctl.h:221
void SysCtlClockSet(uint32_t ui32Config)
Definition: sysctl.c:2532
#define UART_CONFIG_PAR_NONE
Definition: uart.h:93
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

void Thread1 ( void  )

A thread that continuously toggles GPIO pin 1 on GPIO_PORT_F.

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

References atomic, GPIO_PIN_1, GPIO_PIN_2, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and pidwork.

Referenced by main().

46  {
47  while(1) {
48  /* BEGIN CRITICAL SECTION */
49  atomic (
50  ++pidwork;
51  );
52  /* END CRITICAL SECTION */
55  /* os_surrender_context(); */
56  }
57 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_2
Definition: gpio.h:62
#define GPIO_PIN_1
Definition: gpio.h:61
#define atomic(x)
Definition: nexus.h:32
volatile uint32_t pidwork
Definition: test-os.c:34
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 Thread2 ( void  )

A thread that continuously toggles GPIO pin 2 on GPIO_PORT_F.

Definition at line 60 of file test-os.c.

References GPIO_PIN_1, GPIO_PIN_2, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), highest_pidwork, lowest_pidwork, pidwork, pidwork_buffer, PIDWORK_BUFFER_SIZE, and pidwork_idx.

Referenced by main().

60  {
61  while(1) {
64  if (pidwork != 0) {
65  if (highest_pidwork < pidwork) {
67  }
68  if (lowest_pidwork > pidwork) {
70  }
73  }
74  pidwork = 0;
75  /* os_surrender_context(); */
76  }
77 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define PIDWORK_BUFFER_SIZE
Definition: test-os.c:32
volatile uint32_t pidwork_idx
Definition: test-os.c:37
#define GPIO_PIN_2
Definition: gpio.h:62
#define GPIO_PIN_1
Definition: gpio.h:61
volatile uint32_t lowest_pidwork
Definition: test-os.c:36
volatile uint32_t pidwork
Definition: test-os.c:34
volatile uint32_t * pidwork_buffer
Definition: test-os.c:38
volatile uint32_t highest_pidwork
Definition: test-os.c:35
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 uart_consumer ( void  )

Definition at line 79 of file test-os.c.

References GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), UART0_BASE, uart_consumer_idx, uart_fifo, UART_FIFO_SIZE, uart_producer_idx, and UARTCharPut().

79  {
80 
81  while (1) {
83 
88  }
89  }
90 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
volatile uint32_t uart_producer_idx
Definition: test-os.c:40
#define GPIO_PIN_2
Definition: gpio.h:62
#define GPIO_PIN_1
Definition: gpio.h:61
#define GPIO_PIN_3
Definition: gpio.h:63
volatile char * uart_fifo
Definition: test-os.c:42
#define UART_FIFO_SIZE
Definition: test-os.c:31
volatile uint32_t uart_consumer_idx
Definition: test-os.c:41
#define UART0_BASE
Definition: hw_memmap.h:61
void UARTCharPut(uint32_t ui32Base, unsigned char ucData)
Definition: uart.c:1268
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:

Variable Documentation

volatile uint32_t highest_pidwork

Definition at line 35 of file test-os.c.

Referenced by main(), and Thread2().

volatile uint32_t lowest_pidwork

Definition at line 36 of file test-os.c.

Referenced by main(), and Thread2().

volatile uint32_t pidwork

Definition at line 34 of file test-os.c.

Referenced by main(), Thread1(), and Thread2().

volatile uint32_t* pidwork_buffer

Definition at line 38 of file test-os.c.

Referenced by main(), and Thread2().

volatile uint32_t pidwork_idx

Definition at line 37 of file test-os.c.

Referenced by main(), and Thread2().

volatile uint32_t uart_consumer_idx

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

Referenced by uart_consumer().

volatile uint32_t uart_dropped_chars

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

volatile char* uart_fifo

Definition at line 42 of file test-os.c.

Referenced by uart_consumer().

volatile uint32_t uart_producer_idx

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

Referenced by uart_consumer().