EE445M RTOS
Taken at the University of Texas Spring 2015
test-combination.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/adc.h"
#include "libbutton/button.h"
#include "libtimer/timer.h"
#include "libschedule/schedule.h"
#include "libos/os.h"
#include "libheart/heartbeat.h"
#include "libadc/adc.h"
#include "libuart/uart.h"
#include "libdisplay/ST7735.h"
Include dependency graph for test-combination.c:

Go to the source code of this file.

Macros

#define HEARTBEAT_MODAL
 
#define SCHEDLUE_PRIORITY
 
#define SCHEDULER_MAX_THREADS   16
 
#define HEART_RED   GPIO_PIN_1
 
#define HEART_BLUE   GPIO_PIN_2
 
#define HEART_GREEN   GPIO_PIN_3
 

Functions

void button_debounce_end (notification button_notification)
 
void button_debounce_start (notification button_notification)
 
void postpone_suicide ()
 
void led_single_blink_red ()
 
void led_single_blink_green ()
 
void led_single_blink_blue ()
 
void led_blink_red ()
 
void led_blink_green ()
 
void led_blink_blue ()
 
int doctor ()
 
void display_adc_data_for_checkout ()
 
void main (void)
 

Variables

volatile uint32_t button_left_pressed
 
volatile uint32_t button_right_pressed
 
volatile uint32_t button_debounced_mailbox
 
volatile uint32_t button_debounced_wtf
 
volatile semaphore_t button_debounced_new_data
 
semaphore_t HW_ADC_SEQ2_SEM
 
uint32_t ADC0_SEQ2_SAMPLES [4]
 
volatile uint32_t red_work = 0
 
volatile uint32_t green_work = 0
 
volatile uint32_t blue_work = 0
 
volatile uint32_t red_single_work = 0
 
volatile uint32_t green_single_work = 0
 
volatile uint32_t blue_single_work = 0
 

Macro Definition Documentation

#define HEART_BLUE   GPIO_PIN_2

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

#define HEART_GREEN   GPIO_PIN_3

Definition at line 39 of file test-combination.c.

#define HEART_RED   GPIO_PIN_1

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

#define HEARTBEAT_MODAL

Definition at line 24 of file test-combination.c.

#define SCHEDLUE_PRIORITY

Definition at line 25 of file test-combination.c.

#define SCHEDULER_MAX_THREADS   16

Definition at line 26 of file test-combination.c.

Referenced by os_tcb_of(), os_threading_init(), and schedule_init().

Function Documentation

void button_debounce_end ( notification  button_notification)

Definition at line 59 of file test-combination.c.

References button_debounced_mailbox, button_debounced_new_data, BUTTONS_BOTH, GPIO_PORTF_BASE, GPIOPinRead(), and sem_post.

Referenced by button_debounce_start(), and main().

59  {
60 
63 }
volatile semaphore_t button_debounced_new_data
#define sem_post(sem)
#define BUTTONS_BOTH
Definition: button.h:28
volatile uint32_t button_debounced_mailbox
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 button_debounce_start ( notification  button_notification)

Definition at line 66 of file test-combination.c.

References button_debounce_end(), button_debounced_wtf, BUTTONS_BOTH, GPIO_PORTF_BASE, GPIOPinRead(), hw_channel_init(), hw_subscribe_single_shot, HW_TIMER, Hz, INT_TIMER0A, TIMER0_BASE, TIMER_CFG_ONE_SHOT, and timer_metadata_init.

66  {
67 
70  hw_channel_init(HW_TIMER, timer_metadata);
71  hw_subscribe_single_shot(HW_TIMER, timer_metadata,
73 }
volatile uint32_t button_debounced_wtf
#define TIMER_CFG_ONE_SHOT
Definition: timer.h:59
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define hw_subscribe_single_shot(type, metadata, isr)
Definition: hardware.h:190
#define BUTTONS_BOTH
Definition: button.h:28
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
#define Hz
Definition: nexus.h:45
void button_debounce_end(notification button_notification)
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
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

void display_adc_data_for_checkout ( )

Definition at line 147 of file test-combination.c.

References ADC0_SEQ2_SAMPLES, HW_ADC_SEQ2_SEM, sem_guard, and sem_take.

Referenced by main().

147  {
148 
149  while (1) {
152  uint8_t string_buf[5];
153  uint8_t tmp;
154  uint16_t i, j, k, l;
155  uint32_t num;
156 
157  for (i=0; i<4; ++i) {
158  num = ADC0_SEQ2_SAMPLES[i];
159  for (j=0; j<4; ++j) {
160  string_buf[3-j] = (num % 10) + 0x30;
161  num /= 10;
162  }
163 
164  string_buf[j] = 0;
165 
166  /* ST7735_DrawString(2, 2+i, string_buf, ST7735_YELLOW); */
167  }
168  }
169  /* os_surrender_context(); */
170  }
171 }
#define sem_take(sem)
uint32_t ADC0_SEQ2_SAMPLES[4]
Definition: hardware.c:46
semaphore_t HW_ADC_SEQ2_SEM
Definition: hardware.c:49
#define sem_guard(sem)

Here is the caller graph for this function:

int doctor ( )

Definition at line 139 of file test-combination.c.

References UART0_BASE, and UARTCharPut().

Referenced by main().

139  {
140 
141  /* uart_set_active_channel(UART0_BASE); */
142  UARTCharPut(UART0_BASE, 'd');
143  /* uart_send_string("Well what did you expect would happen? You're dreaming!\n"); */
144  return EXIT_SUCCESS;
145 }
#define UART0_BASE
Definition: hw_memmap.h:61
void UARTCharPut(uint32_t ui32Base, unsigned char ucData)
Definition: uart.c:1268

Here is the call graph for this function:

Here is the caller graph for this function:

void led_blink_blue ( )

Definition at line 130 of file test-combination.c.

References blue_work, GPIO_PIN_2, GPIO_PORTF_BASE, GPIOPinRead(), and GPIOPinWrite().

Referenced by main().

130  {
131  while (1) {
132  ++blue_work;
135  /* os_surrender_context(); */
136  }
137 }
volatile uint32_t blue_work
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_2
Definition: gpio.h:62
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 led_blink_green ( )

Definition at line 121 of file test-combination.c.

References GPIO_PIN_3, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and green_work.

121  {
122  while (1) {
123  ++green_work;
126  /* os_surrender_context(); */
127  }
128 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_3
Definition: gpio.h:63
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
volatile uint32_t green_work
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

void led_blink_red ( )

Definition at line 112 of file test-combination.c.

References GPIO_PIN_1, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and red_work.

Referenced by main().

112  {
113  while (1) {
114  ++red_work;
117  /* os_surrender_context(); */
118  }
119 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_1
Definition: gpio.h:61
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1006
volatile uint32_t red_work
#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 led_single_blink_blue ( )

Definition at line 105 of file test-combination.c.

References blue_single_work, GPIO_PIN_2, GPIO_PORTF_BASE, GPIOPinRead(), and GPIOPinWrite().

105  {
109 }
volatile uint32_t blue_single_work
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_2
Definition: gpio.h:62
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:

void led_single_blink_green ( )

Definition at line 99 of file test-combination.c.

References GPIO_PIN_3, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and green_single_work.

Referenced by postpone_suicide().

99  {
103 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_3
Definition: gpio.h:63
volatile uint32_t green_single_work
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 led_single_blink_red ( )

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

References GPIO_PIN_1, GPIO_PORTF_BASE, GPIOPinRead(), GPIOPinWrite(), and red_single_work.

93  {
97 }
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1038
#define GPIO_PIN_1
Definition: gpio.h:61
volatile uint32_t red_single_work
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:

void main ( void  )

Definition at line 173 of file test-combination.c.

References hw_metadata::adc, ADC0_BASE, adc_channel_init(), ADC_CTL_CH0, ADC_CTL_END, ADC_CTL_IE, adc_init(), adc_interrupt_init(), ADC_TRIGGER_TIMER, hw_timer_metadata::base, hw_adc_metadata::base, button_debounce_end(), button_metadata_init, BUTTONS_BOTH, hw_adc_metadata::channel, hw_adc_metadata::channel_configuration, display_adc_data_for_checkout(), DL_SOFT, doctor(), hw_timer_metadata::frequency, GPIO_BOTH_EDGES, GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PORTF_BASE, heart_init(), HW_BUTTON, hw_daemon(), hw_driver_init(), hw_init, hw_subscribe, HW_TIMER, HW_UART, Hz, INT_TIMER0A, INT_TIMER1A, INT_UART0, hw_timer_metadata::interrupt, IntMasterDisable(), IntMasterEnable(), led_blink_blue(), led_blink_red(), os_launch(), os_threading_init(), Output_On(), hw_timer_metadata::periodic, pidwork_init(), postpone_death, postpone_suicide(), hw_adc_metadata::sample_sequence, schedule(), shell_spawn(), SYSCTL_OSC_MAIN, SYSCTL_SYSDIV_1, SYSCTL_USE_OSC, SYSCTL_XTAL_16MHZ, SysCtlClockSet(), system_init(), system_register_command(), adc_trigger_metadata::timer, TIMER0_BASE, TIMER1_BASE, TIMER_CFG_ONE_SHOT, TIMER_CFG_PERIODIC, timer_metadata_init, hw_adc_metadata::trigger_metadata, hw_adc_metadata::trigger_source, UART0_BASE, UART_DEFAULT_BAUD_RATE, and uart_metadata_init.

173  {
174 
177 
179 
180  heart_init();
181  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_1);
182  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_2);
183  heart_init_(GPIO_PORTF_BASE, GPIO_PIN_3);
184 
185  /* begin display init */
186  Output_On();
187  /* end display init */
188 
189  /* begin timer init */
191  hw_driver_init(HW_TIMER, timer_metadata);
192  /* end timer init */
193 
194  /* button init */
196 
197  hw_init(HW_BUTTON, button_metadata);
198  hw_subscribe(HW_BUTTON, button_metadata, button_debounce_end);
199 
200  pidwork_init();
201 
202  /* start adc init */
203  hw_metadata metadata;
204  metadata.adc.base = ADC0_BASE;
206  metadata.adc.sample_sequence = 2;
207  metadata.adc.channel = 0;
208  metadata.adc.channel_configuration =
211  metadata.adc.trigger_metadata.timer.frequency = 2 Hz;
214 
215  adc_init(metadata);
216  adc_channel_init(metadata);
217  adc_interrupt_init(metadata);
218  /* adc_data_buffer = ADC0_SEQ2_SAMPLES; */
219  /* end adc init */
220 
221  /* begin shell init */
222  system_init();
223  system_register_command((const char*) "doctor", doctor);
225  hw_init(HW_UART, uart_metadata);
226 
227  /* Initialize the shell and the system it interacts with */
228  shell_spawn();
229  /* end shell init */
230 
234  schedule(hw_daemon, 100 Hz, DL_SOFT);
237  /* next test: different frequencies,pools */
238 
239  IntMasterEnable();
240  os_launch();
241 
242  postpone_death();
243 }
void led_blink_blue()
void pidwork_init()
Definition: jitter.c:6
uint32_t sample_sequence
Definition: hardware.h:88
#define TIMER_CFG_PERIODIC
Definition: timer.h:62
#define TIMER_CFG_ONE_SHOT
Definition: timer.h:59
memory_address_t base
Definition: hardware.h:86
#define TIMER0_BASE
Definition: hw_memmap.h:81
#define button_metadata_init(_base, _pin, _interrupt)
Definition: button.h:23
void display_adc_data_for_checkout()
void postpone_suicide()
void shell_spawn()
Definition: shell.c:26
adc_trigger_metadata trigger_metadata
Definition: hardware.h:91
#define GPIO_BOTH_EDGES
Definition: gpio.h:87
#define INT_TIMER1A
Definition: hw_ints.h:437
#define SYSCTL_OSC_MAIN
Definition: sysctl.h:378
#define hw_subscribe(type, metadata, isr)
Definition: hardware.h:178
#define SYSCTL_USE_OSC
Definition: sysctl.h:350
hw_timer_metadata timer
Definition: hardware.h:79
#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
frequency_t frequency
Definition: hardware.h:64
void adc_channel_init(hw_metadata metadata)
Definition: adc.c:36
#define UART_DEFAULT_BAUD_RATE
Definition: uart.h:14
#define ADC_CTL_CH0
Definition: adc.h:85
void os_threading_init()
Definition: os.c:34
uint32_t trigger_source
Definition: hardware.h:87
uint32_t interrupt
Definition: hardware.h:65
void schedule(task_t task, frequency_t frequency, DEADLINE_TYPE seriousness)
Definition: os.c:386
#define ADC0_BASE
Definition: hw_memmap.h:89
#define BUTTONS_BOTH
Definition: button.h:28
memory_address_t base
Definition: hardware.h:63
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
#define INT_UART0
Definition: hw_ints.h:451
#define TIMER1_BASE
Definition: hw_memmap.h:82
uint32_t periodic
Definition: hardware.h:66
uint32_t channel
Definition: hardware.h:89
bool IntMasterDisable(void)
Definition: interrupt.c:249
#define uart_metadata_init(_baud_rate, _channel, _interrupt)
Definition: uart.h:29
#define GPIO_PIN_3
Definition: gpio.h:63
bool IntMasterEnable(void)
hw_adc_metadata adc
Definition: hardware.h:100
#define ADC_CTL_END
Definition: adc.h:83
#define ADC_TRIGGER_TIMER
Definition: adc.h:65
#define timer_metadata_init(_base, _frequency, _interrupt, _periodic)
Definition: timer.h:21
void adc_init(hw_metadata metadata)
Definition: adc.c:16
void adc_interrupt_init(hw_metadata metadata)
Definition: adc.c:67
#define Hz
Definition: nexus.h:45
int doctor()
void system_init()
Definition: system.c:19
#define UART0_BASE
Definition: hw_memmap.h:61
#define SYSCTL_SYSDIV_1
Definition: sysctl.h:221
void button_debounce_end(notification button_notification)
void SysCtlClockSet(uint32_t ui32Config)
Definition: sysctl.c:2532
#define ADC_CTL_IE
Definition: adc.h:82
uint32_t channel_configuration
Definition: hardware.h:90
void Output_On(void)
Definition: ST7735.c:1594
#define INT_TIMER0A
Definition: hw_ints.h:435
bool system_register_command(const char *command_name, int(*command)())
Definition: system.c:29
void led_blink_red()
void hw_daemon(void)
Definition: hardware.c:172
#define GPIO_PORTF_BASE
Definition: hw_memmap.h:74

Here is the call graph for this function:

void postpone_suicide ( )

Definition at line 75 of file test-combination.c.

References button_debounced_mailbox, button_debounced_new_data, BUTTON_LEFT, button_left_pressed, BUTTON_RIGHT, button_right_pressed, led_single_blink_green(), os_surrender_context, sem_guard, and sem_take.

Referenced by main().

75  {
76 
77  while (1) {
83  }
87  }
88  }
90  }
91 }
volatile semaphore_t button_debounced_new_data
void led_single_blink_green()
#define sem_take(sem)
volatile uint32_t button_left_pressed
#define BUTTON_LEFT
Definition: button.h:26
#define BUTTON_RIGHT
Definition: button.h:27
#define sem_guard(sem)
#define os_surrender_context()
Definition: os.h:142
volatile uint32_t button_debounced_mailbox
volatile uint32_t button_right_pressed

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

uint32_t ADC0_SEQ2_SAMPLES[4]

Definition at line 46 of file hardware.c.

Referenced by ADC0Seq2_Handler(), and display_adc_data_for_checkout().

volatile uint32_t blue_single_work = 0

Definition at line 57 of file test-combination.c.

Referenced by led_single_blink_blue().

volatile uint32_t blue_work = 0

Definition at line 54 of file test-combination.c.

Referenced by led_blink_blue().

volatile uint32_t button_debounced_mailbox

Definition at line 44 of file test-combination.c.

Referenced by button_debounce_end(), and postpone_suicide().

volatile semaphore_t button_debounced_new_data

Definition at line 47 of file test-combination.c.

Referenced by button_debounce_end(), and postpone_suicide().

volatile uint32_t button_debounced_wtf

Definition at line 45 of file test-combination.c.

Referenced by button_debounce_start().

volatile uint32_t button_left_pressed

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

Referenced by postpone_suicide().

volatile uint32_t button_right_pressed

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

Referenced by postpone_suicide().

volatile uint32_t green_single_work = 0

Definition at line 56 of file test-combination.c.

Referenced by led_single_blink_green().

volatile uint32_t green_work = 0

Definition at line 53 of file test-combination.c.

Referenced by led_blink_green().

semaphore_t HW_ADC_SEQ2_SEM

Definition at line 49 of file hardware.c.

Referenced by ADC0Seq2_Handler(), and display_adc_data_for_checkout().

volatile uint32_t red_single_work = 0

Definition at line 55 of file test-combination.c.

Referenced by led_single_blink_red().

volatile uint32_t red_work = 0

Definition at line 52 of file test-combination.c.

Referenced by led_blink_red().