Fraise  2.1
FRAmework for Interfacing Software and Electronics
fraisedevice.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Fraise device firmware v2.1
4  *
5  *********************************************************************
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software Foundation,
18  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20 *********************************************************************
21  * Copyright (c) Antoine Rousseau 2009 - 2015
22  ********************************************************************/
23 
24 #ifndef FRAISEDEV_H
25 #define FRAISEDEV_H
26 
29 #include <core.h>
30 
38 //-------------- SYSTEM -------------
39 
44 void fraiseInit(void);
53 void fraiseService(void); // to be called by the main loop.
56 void fraiseSetID(unsigned char id); // normally you don't have to use this.
57 void fraiseISR(); //to be called by low priority interrupt.
58 void fraiseSetInterruptEnable(char enable); //fraiseInit automatically enables interrupt.
59 char fraiseGetInterruptEnable(void);
60 
61 //-------------- OUT ----------------
62 
72 char fraiseSend(const unsigned char *buf, unsigned char len);
73 
80 void fraiseSendBroadcast(const unsigned char *buf, unsigned char len);
81 
85 //-------------- IN ----------------
92 void fraiseReceiveChar();
93 void fraiseReceive();
95 
100 unsigned char fraiseGetChar();
101 unsigned char fraisePeekChar();
102 unsigned char fraiseGetIndex();
103 unsigned char fraiseGetAt(unsigned char i);
104 unsigned char fraiseGetLen();
105 void fraiseSendCopy();
106 
107 #define fraiseGetInt() ((unsigned int)(fraiseGetChar()<<8) + (unsigned int)fraiseGetChar())
108 #define fraiseGetLong() (((unsigned long)( \
109  (((unsigned int)fraiseGetChar()) << 8) + fraiseGetChar()) ) << 16 | \
110  (((unsigned int)fraiseGetChar()) << 8) + fraiseGetChar())
111 
112 
113 
118 #define PARAM_CHAR(n,p) case n: p = fraiseGetChar();
120 #define PARAM_INT(n,p) case n: p = fraiseGetInt();
122 #define PARAM_LONG(n,p) case n: p = fraiseGetLong();
124 
126 #define GETPARAM(n, p, i) case n: i = p; break
127 
128 
132 #endif //FRAISEDEV_H
133 
fraisePeekChar
unsigned char fraisePeekChar()
See next char (but keep it in the buffer).
fraiseGetLen
unsigned char fraiseGetLen()
Get total length of current receive packet.
fraiseService
void fraiseService(void)
Fraise device service routine.
fraiseReceive
void fraiseReceive()
Raw message to this device.
fraiseReceiveCharBroadcast
void fraiseReceiveCharBroadcast()
String message to every device.
fraiseGetAt
unsigned char fraiseGetAt(unsigned char i)
Get RXbuffer content at a given place.
fraiseSendCopy
void fraiseSendCopy()
Copy the RX buffer to TX buffer, in char mode, from first RX byte to the one before current index (do...
fraiseReceiveBroadcast
void fraiseReceiveBroadcast()
Raw message to every device.
fraiseGetChar
unsigned char fraiseGetChar()
Get next char from receive buffer.
fraiseGetIndex
unsigned char fraiseGetIndex()
Get read index in RXbuffer.
fraiseInit
void fraiseInit(void)
Init fraise device stack. Normally automatically called by fruitInit().
fraiseSend
char fraiseSend(const unsigned char *buf, unsigned char len)
Put a message into the Fraise TX queue.
fraiseSendBroadcast
void fraiseSendBroadcast(const unsigned char *buf, unsigned char len)
Broadcast a message to every connected fruit; this fonction is blocking (it returns when the message ...
fraiseReceiveChar
void fraiseReceiveChar()
String message to this device.