ECE4760 - Laser Projector (ipb7, jcc384, pfc38)
1
Raster Laser Projection
|
#include <plib.h>
Go to the source code of this file.
Data Structures | |
struct | pt |
struct | pt_sem |
Macros | |
#define | __LC_ADDRLABELS_H__ |
#define | LC_INIT(s) s = NULL |
#define | LC_RESUME(s) |
#define | LC_CONCAT2(s1, s2) s1##s2 |
#define | LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2) |
#define | LC_SET(s) |
#define | LC_END(s) |
#define | PT_WAITING 0 |
#define | PT_YIELDED 1 |
#define | PT_EXITED 2 |
#define | PT_ENDED 3 |
#define | __PT_SEM_H__ |
#define | PT_SEM_INIT(s, c) (s)->count = c |
#define | PT_SEM_WAIT(pt, s) |
#define | PT_SEM_SIGNAL(pt, s) |
#define | PT_YIELD_TIME_msec(delay_time) |
#define | PT_GET_TIME() (time_tick_millsec) |
#define | PT_RATE_INIT() int pt_pri_count = 0; |
#define | PT_RATE_LOOP() pt_pri_count = (pt_pri_count+1) & 0xf ; |
#define | PT_RATE_SCHEDULE(f, rate) |
#define | PT_DEBUG_VALUE(level, duration) |
#define | PT_SEM_SET(s) (s)->count=1 |
#define | PT_SEM_CLEAR(s) (s)->count=0 |
#define | PT_SEM_READ(s) (s)->count |
#define | PT_SEM_ACCEPT(s) |
#define | PB_DIVISOR (1 << OSCCONbits.PBDIV) |
#define | PB_FREQ sys_clock/PB_DIVISOR |
#define | clrscr() printf( "\x1b[2J") |
#define | home() printf( "\x1b[H") |
#define | pcr() printf( '\r') |
#define | crlf putchar(0x0a); putchar(0x0d); |
#define | backspace 0x7f |
#define | max_chars 64 |
Initialization | |
#define | PT_INIT(pt) |
Declaration and definition | |
#define | PT_THREAD(name_args) |
#define | PT_BEGIN(pt) |
#define | PT_END(pt) |
Blocked wait | |
#define | PT_WAIT_UNTIL(pt, condition) |
#define | PT_WAIT_WHILE(pt, cond) |
Hierarchical protothreads | |
#define | PT_WAIT_THREAD(pt, thread) |
#define | PT_SPAWN(pt, child, thread) |
Exiting and restarting | |
#define | PT_RESTART(pt) |
#define | PT_EXIT(pt) |
Calling a protothread | |
#define | PT_SCHEDULE(f) |
Yielding from a protothread | |
#define | PT_YIELD(pt) |
#define | PT_YIELD_UNTIL(pt, cond) |
Yield from the protothread until a condition occurs. More... | |
Typedefs | |
typedef void * | lc_t |
Functions | |
int | PT_GetSerialBuffer (struct pt *pt) |
int | PutSerialBuffer (struct pt *pt) |
int | PT_DMA_PutSerialBuffer (struct pt *pt) |
void | __ISR (_TIMER_5_VECTOR, IPL2AUTO) Timer5Handler(void) |
void | PT_setup (void) |
Variables | |
char | PT_term_buffer [max_chars] |
int | num_char |
char | PT_send_buffer [max_chars] |
int | num_send_chars |
int | CVRCON_setup |
volatile unsigned int | time_tick_millsec |
Protothreads implementation.
Definition in file pt_cornell_1_2_1.h.
#define __LC_ADDRLABELS_H__ |
Definition at line 173 of file pt_cornell_1_2_1.h.
#define __PT_SEM_H__ |
Definition at line 475 of file pt_cornell_1_2_1.h.
#define backspace 0x7f |
Definition at line 615 of file pt_cornell_1_2_1.h.
#define clrscr | ( | ) | printf( "\x1b[2J") |
Definition at line 611 of file pt_cornell_1_2_1.h.
#define crlf putchar(0x0a); putchar(0x0d); |
Definition at line 614 of file pt_cornell_1_2_1.h.
#define home | ( | ) | printf( "\x1b[H") |
Definition at line 612 of file pt_cornell_1_2_1.h.
#define LC_CONCAT | ( | s1, | |
s2 | |||
) | LC_CONCAT2(s1, s2) |
Definition at line 188 of file pt_cornell_1_2_1.h.
#define LC_CONCAT2 | ( | s1, | |
s2 | |||
) | s1##s2 |
Definition at line 187 of file pt_cornell_1_2_1.h.
#define LC_END | ( | s | ) |
Definition at line 196 of file pt_cornell_1_2_1.h.
#define LC_INIT | ( | s | ) | s = NULL |
Definition at line 178 of file pt_cornell_1_2_1.h.
#define LC_RESUME | ( | s | ) |
Definition at line 180 of file pt_cornell_1_2_1.h.
#define LC_SET | ( | s | ) |
Definition at line 190 of file pt_cornell_1_2_1.h.
#define max_chars 64 |
Definition at line 616 of file pt_cornell_1_2_1.h.
#define PB_DIVISOR (1 << OSCCONbits.PBDIV) |
Definition at line 609 of file pt_cornell_1_2_1.h.
#define PB_FREQ sys_clock/PB_DIVISOR |
Definition at line 610 of file pt_cornell_1_2_1.h.
#define pcr | ( | ) | printf( '\r') |
Definition at line 613 of file pt_cornell_1_2_1.h.
#define PT_BEGIN | ( | pt | ) |
Declare the start of a protothread inside the C function implementing the protothread.
This macro is used to declare the starting point of a protothread. It should be placed at the start of the function in which the protothread runs. All C statements above the PT_BEGIN() invokation will be executed each time the protothread is scheduled.
pt | A pointer to the protothread control structure. |
Definition at line 265 of file pt_cornell_1_2_1.h.
#define PT_DEBUG_VALUE | ( | level, | |
duration | |||
) |
Definition at line 586 of file pt_cornell_1_2_1.h.
#define PT_END | ( | pt | ) |
Declare the end of a protothread.
This macro is used for declaring that a protothread ends. It must always be used together with a matching PT_BEGIN() macro.
pt | A pointer to the protothread control structure. |
Definition at line 277 of file pt_cornell_1_2_1.h.
#define PT_ENDED 3 |
Definition at line 211 of file pt_cornell_1_2_1.h.
#define PT_EXIT | ( | pt | ) |
Exit the protothread.
This macro causes the protothread to exit. If the protothread was spawned by another protothread, the parent protothread will become unblocked and can continue to run.
pt | A pointer to the protothread control structure. |
Definition at line 396 of file pt_cornell_1_2_1.h.
#define PT_EXITED 2 |
Definition at line 210 of file pt_cornell_1_2_1.h.
#define PT_GET_TIME | ( | ) | (time_tick_millsec) |
Definition at line 557 of file pt_cornell_1_2_1.h.
#define PT_INIT | ( | pt | ) |
Initialize a protothread.
Initializes a protothread. Initialization must be done prior to starting to execute the protothread.
pt | A pointer to the protothread control structure. |
Definition at line 230 of file pt_cornell_1_2_1.h.
#define PT_RATE_INIT | ( | ) | int pt_pri_count = 0; |
Definition at line 562 of file pt_cornell_1_2_1.h.
#define PT_RATE_LOOP | ( | ) | pt_pri_count = (pt_pri_count+1) & 0xf ; |
Definition at line 565 of file pt_cornell_1_2_1.h.
#define PT_RATE_SCHEDULE | ( | f, | |
rate | |||
) |
Definition at line 573 of file pt_cornell_1_2_1.h.
#define PT_RESTART | ( | pt | ) |
Restart the protothread.
This macro will block and cause the running protothread to restart its execution at the place of the PT_BEGIN() call.
pt | A pointer to the protothread control structure. |
Definition at line 379 of file pt_cornell_1_2_1.h.
#define PT_SCHEDULE | ( | f | ) |
Schedule a protothread.
This function shedules a protothread. The return value of the function is non-zero if the protothread is running or zero if the protothread has exited.
f | The call to the C function implementing the protothread to be scheduled |
Definition at line 421 of file pt_cornell_1_2_1.h.
#define PT_SEM_ACCEPT | ( | s | ) |
Definition at line 599 of file pt_cornell_1_2_1.h.
#define PT_SEM_CLEAR | ( | s | ) | (s)->count=0 |
Definition at line 597 of file pt_cornell_1_2_1.h.
#define PT_SEM_INIT | ( | s, | |
c | |||
) | (s)->count = c |
Initialize a semaphore
This macro initializes a semaphore with a value for the counter. Internally, the semaphores use an "unsigned int" to represent the counter, and therefore the "count" argument should be within range of an unsigned int.
s | (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore |
c | (unsigned int) The initial count of the semaphore. initializer |
Definition at line 497 of file pt_cornell_1_2_1.h.
#define PT_SEM_READ | ( | s | ) | (s)->count |
Definition at line 598 of file pt_cornell_1_2_1.h.
#define PT_SEM_SET | ( | s | ) | (s)->count=1 |
Definition at line 596 of file pt_cornell_1_2_1.h.
#define PT_SEM_SIGNAL | ( | pt, | |
s | |||
) |
Signal a semaphore
This macro carries out the "signal" operation on the semaphore. The signal operation increments the counter inside the semaphore, which eventually will cause waiting protothreads to continue executing.
pt | (struct pt *) A pointer to the protothread (struct pt) in which the operation is executed. |
s | (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore |
Definition at line 536 of file pt_cornell_1_2_1.h.
#define PT_SEM_WAIT | ( | pt, | |
s | |||
) |
Wait for a semaphore
This macro carries out the "wait" operation on the semaphore. The wait operation causes the protothread to block while the counter is zero. When the counter reaches a value larger than zero, the protothread will continue.
pt | (struct pt *) A pointer to the protothread (struct pt) in which the operation is executed. |
s | (struct pt_sem *) A pointer to the pt_sem struct representing the semaphore |
Definition at line 515 of file pt_cornell_1_2_1.h.
#define PT_SPAWN | ( | pt, | |
child, | |||
thread | |||
) |
Spawn a child protothread and wait until it exits.
This macro spawns a child protothread and waits until it exits. The macro can only be used within a protothread.
pt | A pointer to the protothread control structure. |
child | A pointer to the child protothread's control structure. |
thread | The child protothread with arguments |
Definition at line 356 of file pt_cornell_1_2_1.h.
#define PT_THREAD | ( | name_args | ) |
Declaration of a protothread.
This macro is used to declare a protothread. All protothreads must be declared with this macro.
name_args | The name and arguments of the C function implementing the protothread. |
Definition at line 250 of file pt_cornell_1_2_1.h.
#define PT_WAIT_THREAD | ( | pt, | |
thread | |||
) |
Block and wait until a child protothread completes.
This macro schedules a child protothread. The current protothread will block until the child protothread completes.
pt | A pointer to the protothread control structure. |
thread | The child protothread with arguments |
Definition at line 342 of file pt_cornell_1_2_1.h.
#define PT_WAIT_UNTIL | ( | pt, | |
condition | |||
) |
Block and wait until condition is true.
This macro blocks the protothread until the specified condition is true.
pt | A pointer to the protothread control structure. |
condition | The condition. |
Definition at line 298 of file pt_cornell_1_2_1.h.
#define PT_WAIT_WHILE | ( | pt, | |
cond | |||
) |
Block and wait while condition is true.
This function blocks and waits while condition is true. See PT_WAIT_UNTIL().
pt | A pointer to the protothread control structure. |
cond | The condition. |
Definition at line 317 of file pt_cornell_1_2_1.h.
#define PT_WAITING 0 |
Definition at line 208 of file pt_cornell_1_2_1.h.
#define PT_YIELD | ( | pt | ) |
Yield from the current protothread.
This function will yield the protothread, thereby allowing other processing to take place in the system.
pt | A pointer to the protothread control structure. |
Definition at line 441 of file pt_cornell_1_2_1.h.
#define PT_YIELD_TIME_msec | ( | delay_time | ) |
Definition at line 550 of file pt_cornell_1_2_1.h.
#define PT_YIELD_UNTIL | ( | pt, | |
cond | |||
) |
Yield from the protothread until a condition occurs.
pt | A pointer to the protothread control structure. |
cond | The condition. This function will yield the protothread, until the specified condition evaluates to true. |
Definition at line 461 of file pt_cornell_1_2_1.h.
#define PT_YIELDED 1 |
Definition at line 209 of file pt_cornell_1_2_1.h.
typedef void* lc_t |
Definition at line 176 of file pt_cornell_1_2_1.h.
void __ISR | ( | _TIMER_5_VECTOR | , |
IPL2AUTO | |||
) |
Definition at line 729 of file pt_cornell_1_2_1.h.
int PT_DMA_PutSerialBuffer | ( | struct pt * | pt | ) |
Definition at line 695 of file pt_cornell_1_2_1.h.
int PT_GetSerialBuffer | ( | struct pt * | pt | ) |
Definition at line 622 of file pt_cornell_1_2_1.h.
void PT_setup | ( | void | ) |
Definition at line 737 of file pt_cornell_1_2_1.h.
int PutSerialBuffer | ( | struct pt * | pt | ) |
Definition at line 678 of file pt_cornell_1_2_1.h.
int CVRCON_setup |
Definition at line 722 of file pt_cornell_1_2_1.h.
int num_char |
Definition at line 621 of file pt_cornell_1_2_1.h.
int num_send_chars |
Definition at line 677 of file pt_cornell_1_2_1.h.
char PT_send_buffer[max_chars] |
Definition at line 676 of file pt_cornell_1_2_1.h.
char PT_term_buffer[max_chars] |
Definition at line 620 of file pt_cornell_1_2_1.h.
volatile unsigned int time_tick_millsec |
Definition at line 725 of file pt_cornell_1_2_1.h.