2010-07-07 15:32:02 +00:00
|
|
|
//
|
|
|
|
// ctrl.h : AVR uC code for ctrl buffer initialisation and put/get ops
|
|
|
|
//
|
|
|
|
// Copyright (c) 2010 flukso.net
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#ifndef CTRL_H
|
|
|
|
#define CTRL_H
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include "buffer.h"
|
|
|
|
|
|
|
|
#ifndef CTRL_RX_BUFFER_SIZE
|
2010-10-16 19:25:57 +00:00
|
|
|
#define CTRL_RX_BUFFER_SIZE 32
|
2010-07-07 15:32:02 +00:00
|
|
|
#endif
|
|
|
|
#ifndef CTRL_TX_BUFFER_SIZE
|
2010-10-16 19:25:57 +00:00
|
|
|
#define CTRL_TX_BUFFER_SIZE 32
|
2010-07-07 15:32:02 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-16 19:25:57 +00:00
|
|
|
/**
|
|
|
|
* Initialize the ctrl receive and transmit buffers.
|
|
|
|
*
|
|
|
|
* Overrule the default Rx and Tx ctrl buffer size (32 bytes) in the makefile.
|
|
|
|
*/
|
2010-07-07 15:32:02 +00:00
|
|
|
void ctrlInit(void);
|
|
|
|
|
2010-10-16 19:25:57 +00:00
|
|
|
/**
|
|
|
|
* Check whether the ctrl Tx buffer is empty.
|
|
|
|
*
|
|
|
|
* @return TRUE/FALSE if empty/not empty
|
|
|
|
*/
|
|
|
|
uint8_t ctrlTxBufferIsEmpty(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a byte to the ctrl Tx buffer's tail.
|
|
|
|
*
|
|
|
|
* @param data the byte to be added to the buffer's tail
|
|
|
|
* @return TRUE/FALSE if byte could/could not be written
|
|
|
|
*/
|
|
|
|
uint8_t ctrlAddToTxBuffer(uint8_t data);
|
2010-07-07 15:32:02 +00:00
|
|
|
|
2010-10-16 19:25:57 +00:00
|
|
|
/**
|
|
|
|
* Fetch a byte from the ctrl Tx buffer's head.
|
|
|
|
*
|
|
|
|
* @param data pointer where the byte has to be written
|
|
|
|
* @return TRUE/FALSE if a byte could be fetched/not fetched
|
|
|
|
*/
|
2010-07-07 15:32:02 +00:00
|
|
|
uint8_t ctrlGetFromTxBuffer(uint8_t* data);
|
|
|
|
|
2010-10-16 19:25:57 +00:00
|
|
|
/**
|
|
|
|
* Check whether the ctrl Rx buffer is empty.
|
|
|
|
*
|
|
|
|
* @return TRUE/FALSE if empty/not empty
|
|
|
|
*/
|
|
|
|
uint8_t ctrlRxBufferIsEmpty(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a byte to the ctrl Rx buffer.
|
|
|
|
*
|
|
|
|
* @param data the byte to be added to the buffer's tail
|
|
|
|
* @return TRUE/FALSE if empty/not empty
|
|
|
|
*/
|
|
|
|
uint8_t ctrlAddToRxBuffer(uint8_t data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch a byte from the ctrl Rx buffer's head.
|
|
|
|
*
|
|
|
|
* @param data pointer where the byte has to be written
|
|
|
|
* @return TRUE/FALSE if a byte could be fetched/not fetched
|
|
|
|
*/
|
|
|
|
uint8_t ctrlGetFromRxBuffer(uint8_t* data);
|
2010-07-07 15:32:02 +00:00
|
|
|
|
2010-12-26 18:03:22 +00:00
|
|
|
/**
|
|
|
|
* Flush the ctrl Rx buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ctrlFlushReceiveBuffer(void);
|
|
|
|
|
2010-10-16 19:25:57 +00:00
|
|
|
/**
|
|
|
|
* Loop all bytes from the ctrl Rx to Tx buffer.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-26 18:03:22 +00:00
|
|
|
void ctrlRxToTxLoop(void);
|
|
|
|
|
|
|
|
void ctrlDecode(void);
|
|
|
|
void ctrlCmdGet(uint8_t cmd);
|
|
|
|
void ctrlCmdSet(uint8_t cmd);
|
|
|
|
void ctrlCmdCommit(void);
|