EE445M RTOS
Taken at the University of Texas Spring 2015
|
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "libut/utlist.h"
#include "libhw/hardware.h"
#include "libbuffer/buffer.h"
#include "driverlib/uart.h"
#include "driverlib/timer.h"
#include "libuart/uart.h"
#include "libtimer/timer.h"
#include "libbutton/button.h"
Go to the source code of this file.
Functions | |
void | hw_init_daemon () |
void | hw_driver_init (HW_TYPE type, hw_metadata metadata) |
void | hw_channel_init (HW_TYPE type, hw_metadata metadata) |
void | _hw_subscribe (HW_TYPE type, hw_metadata metadata, void(*isr)(notification note), bool single_shot) |
void | hw_unsubscribe (HW_TYPE type, hw_metadata metadata, void(*isr)(notification note)) |
void | hw_notify (HW_TYPE type, hw_metadata metadata, notification note) |
void | hw_daemon (void) |
void | hw_notify_uart (hw_metadata uart_metadata) |
hw_channel * | _hw_get_channel (HW_TYPE type, hw_metadata metadata) |
hw_driver * | hw_driver_singleton (HW_TYPE type) |
void | GPIOPortF_Handler (void) |
void | UART0_Handler (void) |
void | TIMER0A_Handler (void) |
void | TIMER1A_Handler (void) |
void | TIMER2A_Handler (void) |
void | ADC0Seq0_Handler (void) |
void | ADC0Seq1_Handler (void) |
void | ADC0Seq2_Handler (void) |
void | ADC0Seq3_Handler (void) |
Variables | |
static hw_driver | HW_UART_DRIVER |
static hw_driver | HW_TIMER_DRIVER |
static hw_driver | HW_BUTTON_DRIVER |
static uint8_t | UART0_RX_BUFFER [BUFFER_MAX_LENGTH] |
static uint8_t | UART0_RX_BUFFER_SIZE = 0 |
static uint8_t | UART0_TX_BUFFER [BUFFER_MAX_LENGTH] |
static uint8_t | UART0_TX_BUFFER_SIZE = 0 |
uint32_t | ADC0_SEQ0_SAMPLES [4] |
uint32_t | ADC0_SEQ1_SAMPLES [4] |
uint32_t | ADC0_SEQ2_SAMPLES [4] |
uint32_t | ADC0_SEQ3_SAMPLES [4] |
semaphore_t | HW_ADC_SEQ2_SEM |
uint32_t | jitter_begin |
uint32_t | jitter_end |
|
inline |
For internal use only. Take care of the conversion between a memory-mapped (raw) hw address and the index of said peripheral channel in the memory banks of libhw's device-specific data structures.
hw_group | The hardware group in question |
raw_hw_channel | The specific channel of |
Definition at line 203 of file hardware.c.
References hw_timer_metadata::base, hw_button_metadata::base, hw_metadata::button, hw_uart_metadata::channel, hw_driver::channels, GPIO_PORTE_BASE, HW_BUTTON, hw_driver_singleton(), HW_TIMER, HW_UART, postpone_death, hw_metadata::timer, TIMER0_BASE, hw_metadata::uart, and UART0_BASE.
Referenced by _hw_subscribe(), hw_channel_init(), hw_notify(), and hw_unsubscribe().
void _hw_subscribe | ( | HW_TYPE | , |
hw_metadata | , | ||
void(*)(notification note) | isr, | ||
bool | |||
) |
Subscribe to a hardware interrupt. This is also called connecting a signal (the isr to be notified) to a slot (the hw-triggered driver isr).
The | hardware type in question |
Metadata | about the device |
The | pseudo-isr to be notified by the hardware driver |
Definition at line 121 of file hardware.c.
References _hw_get_channel(), CDL_DELETE, CDL_PREPEND, hw_channel::free_slots, hw_channel::full_slots, _isr_subscription::single_shot_subscription, and _isr_subscription::slot.
Referenced by schedule_aperiodic().
void ADC0Seq0_Handler | ( | void | ) |
Definition at line 378 of file hardware.c.
References ADC0_BASE, ADC0_SEQ3_SAMPLES, ADCIntClear(), and ADCSequenceDataGet().
Referenced by __attribute__().
void ADC0Seq1_Handler | ( | void | ) |
Definition at line 385 of file hardware.c.
References ADC0_BASE, ADC0_SEQ3_SAMPLES, ADCIntClear(), and ADCSequenceDataGet().
Referenced by __attribute__().
void ADC0Seq2_Handler | ( | void | ) |
Definition at line 392 of file hardware.c.
References ADC0_BASE, ADC0_SEQ2_SAMPLES, ADCIntClear(), ADCSequenceDataGet(), HW_ADC_SEQ2_SEM, HWREG, jitter_end, NVIC_ST_CURRENT, and sem_post.
Referenced by __attribute__().
void ADC0Seq3_Handler | ( | void | ) |
Definition at line 402 of file hardware.c.
References ADC0_BASE, ADC0_SEQ3_SAMPLES, ADCIntClear(), and ADCSequenceDataGet().
Referenced by __attribute__().
void GPIOPortF_Handler | ( | void | ) |
GPIO PortF (includes on-board buttons) isr responsible for notifying all subscriptions with information describing the interrupt.
Definition at line 238 of file hardware.c.
References button_metadata_init, BUTTONS_BOTH, GPIO_PORTF_BASE, GPIOIntClear(), GPIOPinRead(), HW_BUTTON, hw_notify(), notification_init, and NULL.
Referenced by __attribute__().
void hw_channel_init | ( | HW_TYPE | , |
hw_metadata | |||
) |
This function is responsible for enabling a specific channel on the specified hardware device. Internal libhw datastructures will also be reset.
hw_group | The hardware group in question |
raw_channel | The memory-mapped address of the device channel to initialize |
metadata | Information about how to initialize the device |
Definition at line 94 of file hardware.c.
References _hw_get_channel(), button_set_interrupt(), CDL_PREPEND, hw_channel::free_slots, hw_channel::full_slots, HW_BUTTON, HW_DRIVER_MAX_SUBSCRIPTIONS, HW_TIMER, HW_UART, hw_channel::isr_subscriptions, NULL, postpone_death, timer_add_interrupt(), and uart_init().
Referenced by adc_interrupt_init(), button_debounce_start(), and main().
void hw_daemon | ( | void | ) |
Definition at line 172 of file hardware.c.
References hw_notify_uart(), HW_SEM_UART0, INT_UART0, os_surrender_context, sem_guard, sem_take, UART0_BASE, UART_DEFAULT_BAUD_RATE, and uart_metadata_init.
Referenced by hw_init_daemon(), and main().
void hw_driver_init | ( | HW_TYPE | , |
hw_metadata | |||
) |
This function is responsible for enabling the peripherals and internal data strutures used by the specified .
hw_group | The hardware group driver to initialize |
Definition at line 62 of file hardware.c.
References hw_timer_metadata::base, button_init(), hw_uart_metadata::channel, HW_BUTTON, HW_TIMER, HW_UART, postpone_death, SYSCTL_PERIPH_GPIOA, SYSCTL_PERIPH_GPIOF, SYSCTL_PERIPH_TIMER0, SYSCTL_PERIPH_UART0, SysCtlPeripheralEnable(), hw_metadata::timer, TIMER0_BASE, hw_metadata::uart, and UART0_BASE.
Referenced by main().
Return the one hw_driver per hardware device group in use by the TM4C.
The | hardware type to grab a pointer of |
Definition at line 220 of file hardware.c.
References HW_BUTTON, HW_BUTTON_DRIVER, HW_TIMER, HW_TIMER_DRIVER, HW_UART, HW_UART_DRIVER, NULL, and postpone_death.
Referenced by _hw_get_channel().
void hw_init_daemon | ( | ) |
Initialize libhw's internal data structures
Definition at line 54 of file hardware.c.
References hw_daemon(), and os_add_thread().
void hw_notify | ( | HW_TYPE | , |
hw_metadata | , | ||
notification | |||
) |
Notify threads subscribed to about an incoming hardware event.
hw_group | The hardwawre group that received the incoming hardware event |
channel | The channel of that received the incoming hardware event |
notifications | The notification (prepared by NVIC-invoked ISR) containing information regarding the recently-occurring hardware interrupt event |
Definition at line 149 of file hardware.c.
References _hw_get_channel(), CDL_DELETE, CDL_PREPEND, hw_channel::free_slots, hw_channel::full_slots, _isr_subscription::next, NULL, _isr_subscription::single_shot_subscription, and _isr_subscription::slot.
Referenced by GPIOPortF_Handler(), hw_notify_uart(), s_Handler(), sA_Handler(), TIMER0A_Handler(), TIMER1A_Handler(), and TIMER2A_Handler().
void hw_notify_uart | ( | hw_metadata | uart_metadata | ) |
Iterate over all chars in the respective uart's RX_FIFO and notify all subscribed tasks.
UART | metadata |
Definition at line 189 of file hardware.c.
References notification::_char, buffer_dec, buffer_empty, buffer_last, hw_notify(), HW_UART, and UART0_RX_BUFFER.
Referenced by hw_daemon().
void hw_unsubscribe | ( | HW_TYPE | , |
hw_metadata | , | ||
void(*)(notification note) | isr | ||
) |
Unsubscribe from a hardware interrupt. This is also called disconnecting a signal (the isr in question) from a slot (the hw-triggered driver isr).
The | hardware type in question |
Metadata | about the device |
The | pseudo-isr to be notified by the hardware driver |
Definition at line 137 of file hardware.c.
References _hw_get_channel(), CDL_DELETE, CDL_PREPEND, hw_channel::free_slots, and hw_channel::full_slots.
Referenced by shell_kill().
void TIMER0A_Handler | ( | void | ) |
TIMER0A isr responsible for notifying all subscriptions with information describing the interrupt.
This isr was generated automatically by bin/lisp/rtos-interrupt-generator.el
Definition at line 341 of file hardware.c.
References hw_notify(), HW_TIMER, notification_init, NULL, TIMER0_BASE, timer_metadata_init, TIMER_TIMA_TIMEOUT, and TimerIntClear().
void TIMER1A_Handler | ( | void | ) |
TIMER1A isr responsible for notifying all subscriptions with information describing the interrupt.
This isr was generated automatically by bin/lisp/rtos-interrupt-generator.el
Definition at line 355 of file hardware.c.
References hw_notify(), HW_TIMER, HWREG, jitter_begin, notification_init, NULL, NVIC_ST_CURRENT, TIMER1_BASE, timer_metadata_init, TIMER_TIMA_TIMEOUT, and TimerIntClear().
Referenced by __attribute__().
void TIMER2A_Handler | ( | void | ) |
TIMER2A isr responsible for notifying all subscriptions with information describing the interrupt.
This isr was generated automatically by bin/lisp/rtos-interrupt-generator.el
Definition at line 370 of file hardware.c.
References hw_notify(), HW_TIMER, notification_init, NULL, TIMER2_BASE, timer_metadata_init, TIMER_TIMA_TIMEOUT, and TimerIntClear().
Referenced by __attribute__().
void UART0_Handler | ( | void | ) |
UART0 isr responsible for notifying all subscriptions with information describing the interrupt.
Definition at line 254 of file hardware.c.
References buffer_add, buffer_dec, buffer_empty, buffer_full, HW_SEM_UART0, sem_post, UART0_BASE, UART0_RX_BUFFER, UART_INT_RT, UART_INT_RX, UART_INT_TX, UART_LAST_WAS_CR, UARTCharGetNonBlocking(), UARTCharPut(), UARTCharsAvail(), UARTIntClear(), and UARTIntStatus().
Referenced by __attribute__().
uint32_t ADC0_SEQ0_SAMPLES[4] |
Definition at line 44 of file hardware.c.
uint32_t ADC0_SEQ1_SAMPLES[4] |
Definition at line 45 of file hardware.c.
uint32_t ADC0_SEQ2_SAMPLES[4] |
Definition at line 46 of file hardware.c.
Referenced by ADC0Seq2_Handler(), display_adc_data_for_checkout(), and main().
uint32_t ADC0_SEQ3_SAMPLES[4] |
Definition at line 47 of file hardware.c.
Referenced by ADC0Seq0_Handler(), ADC0Seq1_Handler(), and ADC0Seq3_Handler().
semaphore_t HW_ADC_SEQ2_SEM |
Definition at line 49 of file hardware.c.
Referenced by ADC0Seq2_Handler(), display_adc_data_for_checkout(), and led_blink_green().
|
static |
Definition at line 36 of file hardware.c.
Referenced by hw_driver_singleton().
|
static |
Definition at line 35 of file hardware.c.
Referenced by hw_driver_singleton().
|
static |
Definition at line 34 of file hardware.c.
Referenced by hw_driver_singleton().
uint32_t jitter_begin |
Definition at line 51 of file hardware.c.
Referenced by TIMER1A_Handler().
uint32_t jitter_end |
Definition at line 52 of file hardware.c.
Referenced by ADC0Seq2_Handler().
|
static |
Definition at line 38 of file hardware.c.
Referenced by hw_notify_uart(), and UART0_Handler().
|
static |
Definition at line 39 of file hardware.c.
|
static |
Definition at line 41 of file hardware.c.
|
static |
Definition at line 42 of file hardware.c.