EE445M RTOS
Taken at the University of Texas Spring 2015
test-countdown.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset: 4; */
2 /* Created by Hershal Bhave and Eric Crosson on <2015-03-15 Sun> */
3 /* Revision History: Look in Git FGT */
4 
5 #include "../common/adcpp.hpp"
6 #include "../common/blinker.hpp"
7 #include "../common/uartpp.hpp"
8 #include "../common/shellpp.hpp"
9 #include "../common/semaphorepp.hpp"
10 #include "../common/motorpp.hpp"
11 #include "../common/drivepp.hpp"
12 #include "../common/canpp.hpp"
13 #include "../common/ctlsysctl.hpp"
14 #include "../common/switchpp.hpp"
15 
16 #include "libos/os.h"
17 #include "libschedule/schedule.h"
18 
19 #include <stdint.h>
20 #include <stdlib.h>
21 #include <stdbool.h>
22 
23 #include "inc/hw_memmap.h"
24 
25 #include "driverlib/adc.h"
26 #include "driverlib/sysctl.h"
27 #include "driverlib/gpio.h"
28 #include "driverlib/interrupt.h"
29 #include "driverlib/uart.h"
30 
35 
36 #define UART0_RX_BUFFER_SIZE 8
39 
40 void timer_updater() {
41  uint32_t timer_data;
42 
43  while(1) {
44  /* todo: populate these uint32_t's with sensor data */
45  timer_data = TimerValueGet(TIMER2_BASE, TIMER_A);
46  uart0.printf("timer: %u\n", timer_data);
47  os_surrender_context();
48  }
49 }
50 
51 int main(void) {
52 
54  IntMasterDisable();
55 
56  blink = blinker(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
57 
59  uart0 = uart(UART0_BASE, INT_UART0);
60 
61  countdown_timer = timer(2, TIMER_BOTH, TIMER_CFG_ONE_SHOT,
62  SysCtlClockGet()*180, TIMER_TIMA_TIMEOUT, true);
63 
64  blink_timer = timer(1, TIMER_A, TIMER_CFG_PERIODIC,
65  SysCtlClockGet()/2, TIMER_TIMA_TIMEOUT, true);
66 
67  os_threading_init();
68  schedule(timer_updater, 200);
69  os_launch();
70 }
71 
72 extern "C" void Timer2A_Handler() {
73  countdown_timer.ack();
74  blink.toggle(PIN_RED);
75 }
76 
77 extern "C" void Timer1A_Handler() {
78  blink_timer.ack();
79  blink.toggle(PIN_GREEN);
80 }
81 
82 extern "C" void __cxa_pure_virtual() { while (1) {} }
timer blink_timer
static buffer< char, 8 > UART0_RX_BUFFER
Definition: uartpp.hpp:28
void Timer1A_Handler()
void printf(const char *pcString,...)
Definition: uartpp.cpp:360
timer countdown_timer
uart uart0
int main(void)
const pin_t PIN_RED
Definition: blinker.hpp:18
void Timer2A_Handler()
virtual uint32_t ack()
Definition: timerpp.cpp:74
static semaphore UART0_RX_SEM
static void set_clock(void)
Definition: ctlsysctl.hpp:109
virtual void toggle(pin_t pin)
Definition: blinker.cpp:34
const pin_t PIN_GREEN
Definition: blinker.hpp:19
void __cxa_pure_virtual()
blinker blink
void timer_updater()