Anti-Sway Capstone 1.0
|
Thread Library. More...
#include <stdbool.h>
#include <pthread.h>
#include "MyRio.h"
#include "AIO.h"
#include "NiFpga.h"
#include "DIIRQ.h"
#include "TimerIRQ.h"
#include "io.h"
#include "setup.h"
Go to the source code of this file.
Data Structures | |
struct | ThreadResource |
Parameter for Threading Functions. More... | |
Macros | |
#define | BTI_US 5000u |
The timestep, in microseconds (us) | |
#define | BTI_MS 5u |
The timestep, in milliseconds (ms) | |
#define | BTI_S 0.005 |
The timestep, in seconds (s) | |
#define | g 9.81 |
Acceleration due to Gravity (m/s^2) | |
#define | PI 3.141592653549 |
Pi. | |
#define | l 0.47 |
Length of Rope (m) | |
#define | m_dt 2.092 |
Mass of the double Trolley (kg) | |
#define | m_st 0.664 |
Mass of the single Trolley (kg) | |
#define | m_p 0.765 |
Mass of User (kg) | |
#define | START_THREAD(thread, function, resource) |
Starts a thread. | |
#define | REGISTER_TIMER(resource) Irq_RegisterTimerIrq(&timer, &(resource.irq_context), BTI_US) |
Registers the global timer with a thread. | |
#define | STOP_THREAD(thread, resource) |
Stops a thread in this process. | |
#define | UNREGISTER_TIMER(resource) Irq_UnregisterTimerIrq(&timer, resource.irq_context) |
Unregisters the global timer with a thread. | |
#define | TIMER_TRIGGER(irq_assert, resource) |
#define | EXIT_THREAD() |
Variables | |
NiFpga_Session | myrio_session |
The MyRio Session. | |
Thread Library.
#define EXIT_THREAD | ( | ) |
Kills a Thread
Registers the global timer with a thread.
Registers the timer (global) with a particular thread (via its resource)
resource | The ThreadResource associated with a thread |
#define START_THREAD | ( | thread, | |
function, | |||
resource ) |
Starts a thread.
Starts a new thread within this process.
thread | The pthread_t ID variable to hold the thread's ID |
function | The Thread Function to execute for the thread |
resource | The ThreadResource to give the function |
#define STOP_THREAD | ( | thread, | |
resource ) |
Stops a thread in this process.
Signals a Thread using a ThreadResource object to stop
thread | The pthread_t holding the ID of the thread to stop |
resource | The ThreadResource associated with the thread |
#define TIMER_TRIGGER | ( | irq_assert, | |
resource ) |
Waits for a timer trigger (at the appropriate time step)
irq_assert | A uint32_t that shall hold the assertion code |
resource | A pointer to a ThreadResource for the thread associated with the global timer |
Unregisters the global timer with a thread.
Dissasociates a thread with a timer (via its resource)
resource | The ThreadResource to disassociate the global timer with |