yarf 0.1
Yet Another RepRap Firmware
Functions | Variables
src/movement/planner_queue.h File Reference

The planning queue stores blocks prepared by the planner, until they are executed by the block handler. More...

#include "yarf.h"
#include "block.h"
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Functions

uint8_t plan_q_next_index (uint8_t block_index)
 Returns the index of the block added after the block specified by the given index.
uint8_t plan_q_prev_index (uint8_t block_index)
 Returns the index of the block added before the block specified by the given block_index.
bool plan_q_full (void)
 Returns whether the planning queue is full.
bool plan_q_empty (void)
 Returns whether the planning queue is empty.
uint8_t plan_q_size (void)
 Returns the number of items in the planning queue.
block_tplan_q_get (uint8_t index)
 Returns the block at the specified index in the planning queue.
block_tplan_q_head (void)
 Returns a pointer to the block at the head of the planning queue.
uint8_t plan_q_head_index (void)
 Returns the index of the head of the queue, i.e.
void plan_q_shift_head (void)
 Shifts the head pointer of the planning queue, registering a new block that was added to the queue.
block_tplan_q_tail (void)
 Returns a pointer to the block at the tail of the planning queue.
uint8_t plan_q_tail_index (void)
 Returns the index of the tail of the queue, i.e.
void plan_q_discard_tail (void)
 Discards the oldest block in the queue, making room for a new block to be added.
void plan_q_clear (void)
 Clears the planning queue.
void plan_q_init (void)
 Initializes the planning queue.

Variables

block_t q [PLANNER_QUEUE_SIZE]
 Array for storing the blocks in the planning queue.
volatile uint8_t q_head
 Index of the head of the queue, which is the location where the next block to enter the queue will be added.
volatile uint8_t q_tail
 Index of the tail of the queue, which is the location of the next block to executed by the block handler.

Detailed Description

The planning queue stores blocks prepared by the planner, until they are executed by the block handler.

Author:
Pieter Agten (pieter.agten@gmail.com)
Date:
23 sep 2011 The planning queue is implemented as a circular buffer. Its size is determined by the PLANNER_QUEUE_SIZE configuration parameter. The queue is implemented almost completely in the planner_queue.h header file, so the compiler will be able to optimize it aggressively.

Definition in file planner_queue.h.


Function Documentation

bool plan_q_empty ( void  ) [inline]

Returns whether the planning queue is empty.

Returns:
true if the planning queue if empty and false otherwise.

Definition at line 115 of file planner_queue.h.

bool plan_q_full ( void  ) [inline]

Returns whether the planning queue is full.

Returns:
true if the planning queue if full and false otherwise.

Definition at line 104 of file planner_queue.h.

block_t* plan_q_get ( uint8_t  index) [inline]

Returns the block at the specified index in the planning queue.

Parameters:
indexthe index in the planning queue of the block to return
Returns:
The block at the specified index in the planning queue.

Definition at line 139 of file planner_queue.h.

block_t* plan_q_head ( void  ) [inline]

Returns a pointer to the block at the head of the planning queue.

This block is considered to empty, so the pointer can be used to add a new block to the queue. If the queue is full, this function returns NULL.

Returns:
A pointer to the block at the head of the planning queue or NULL if the queue is full.

Definition at line 154 of file planner_queue.h.

uint8_t plan_q_head_index ( void  ) [inline]

Returns the index of the head of the queue, i.e.

the index of an empty position where a new block can be written. The caller is responsible for checking that the queue is not full before writing to the returned location.

Returns:
The index of the head of the queue (i.e. where a new block can be added).

Definition at line 171 of file planner_queue.h.

uint8_t plan_q_next_index ( uint8_t  block_index) [inline]

Returns the index of the block added after the block specified by the given index.

Parameters:
block_indexthe index for which to return the next index
Returns:
The next index after the given index.

Definition at line 72 of file planner_queue.h.

uint8_t plan_q_prev_index ( uint8_t  block_index) [inline]

Returns the index of the block added before the block specified by the given block_index.

Parameters:
block_indexthe index for which to return the previous index
Returns:
The previous index before the given index.

Definition at line 90 of file planner_queue.h.

uint8_t plan_q_size ( void  ) [inline]

Returns the number of items in the planning queue.

Returns:
The number of items in the planning queue.

Definition at line 126 of file planner_queue.h.

block_t* plan_q_tail ( void  ) [inline]

Returns a pointer to the block at the tail of the planning queue.

The tail block is the oldest block in the queue. If the queue is empty, this function returns NULL.

Returns:
A pointer to the block at the tail of the planning queue or NULL if the queue is empty.

Definition at line 197 of file planner_queue.h.

uint8_t plan_q_tail_index ( void  ) [inline]

Returns the index of the tail of the queue, i.e.

the index of the oldest block in the queue. The caller is responsible for checking that the queue is not empty when using the returned index.

Returns:
The index of the tail of the queue (i.e. the index of the oldest block in the queue).

Definition at line 215 of file planner_queue.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines