Fraise  2.1
FRAmework for Interfacing Software and Electronics
Fruit module

Fruit module implements Core module, Fraise device module and EEPROM parameters module. More...

Fruit module implements Core module, Fraise device module and EEPROM parameters module.

Any normal firmware should include Fruit module.

Example :

/*********************************************************************
* Fraise fruit example
*********************************************************************/
#define BOARD Versa2
#include <fruit.h>
t_delay printDelay;
t_time printPeriod = 500000; // default print period to 0.5 second (500000 microsecond)
unsigned char count;
//-------- the setup() function is called once at startup
void setup() {
fruitInit(); // initialize the board and the Fraise library
pinModeDigitalOut(LED); // set the LED pin to digital out mode
digitalClear(LED); // clear the LED
pinModeDigitalIn(K1); // set pin K1 to digital input mode
}
// ------- the loop() function is called indefinitely
void loop() {
fraiseService(); // listen to Fraise events
if(delayFinished(printDelay)) // when printDelay triggers:
{
delayStart(printDelay, printPeriod);// re-start printDelay
count = count + 1; // increment count
printf("Ccount %d\n", count); // print count value
printf("CK1 %d\n", digitalRead(K1));// print the state of input pin K1
}
}
// ------- the fraiseReceiveChar() function is called when a "text" message arrived
void fraiseReceiveChar() // receive text message.
{
unsigned char c = fraiseGetChar(); // get the first character of the message.
if(c == 'L') { // if the first char is 'L',
c = fraiseGetChar(); // get the next one;
digitalWrite(LED, c != '0'); // if it's the char '0', switch off the LED (otherwide switch it on)
}
else if(c == 'E') { // if the first char is 'E', echo the message (send it back to host):
printf("C"); // start a text message
c = fraiseGetLen(); // get the length of the incoming packet
while(c--) printf("%c", fraiseGetChar());// print each byte of the incoming packet
putchar('\n'); // append end of line to send the message
}
}
// ------- the fraiseReceive() function is called when a "raw bytes" message arrived
void fraiseReceive() // receive raw bytes
{
unsigned char c = fraiseGetChar(); // get the first byte of the message
if(c == 1) { // if it's equal to 1,
printPeriod = fraiseGetLong(); // set printPeriod to the next long int in the incoming message.
}
}

Initialization

void fruitInit (void)
 Init fruit module at setup(). More...
 

Service

#define fruitService()
 Fruit module service routine, to be called by main loop(). More...
 

Function Documentation

◆ fruitInit()

void fruitInit ( void  )

Init fruit module at setup().

Init core, configure serial port as a fraise device.

Macro Definition Documentation

◆ fruitService

#define fruitService ( )

Fruit module service routine, to be called by main loop().

Check for input data from Fraise.

fraiseGetLong
#define fraiseGetLong()
Get next 32 bit long integer from receive buffer.
Definition: fraisedevice.h:108
digitalWrite
#define digitalWrite(conn, val)
Digital write to pin. Set the pin output voltage to LOW or HIGH.
Definition: core.h:162
loop
void loop()
User defined forever loop.
fruitInit
void fruitInit(void)
Init fruit module at setup().
t_delay
unsigned long t_delay
Delay type.
Definition: core.h:215
digitalClear
#define digitalClear(conn)
Digital clear pin. Clear the pin output voltage.
Definition: core.h:168
pinModeDigitalIn
#define pinModeDigitalIn(conn)
Set pin mode to Digital Input.
Definition: core.h:132
fraiseGetLen
unsigned char fraiseGetLen()
Get total length of current receive packet.
digitalRead
#define digitalRead(conn)
Digital read from pin. Get the voltage (0/1) seen from the pin.
Definition: core.h:155
fruit.h
fraiseService
void fraiseService(void)
Fraise device service routine.
fraiseReceive
void fraiseReceive()
Raw message to this device.
setup
void setup()
User defined initialization.
fraiseGetChar
unsigned char fraiseGetChar()
Get next char from receive buffer.
pinModeDigitalOut
#define pinModeDigitalOut(conn)
Set pin mode to Digital Output.
Definition: core.h:142
t_time
unsigned long t_time
Time type.
Definition: core.h:212
delayFinished
#define delayFinished(delay)
Test delay timeout.
Definition: core.h:225
delayStart
#define delayStart(delay, micros)
Start delay.
Definition: core.h:220
fraiseReceiveChar
void fraiseReceiveChar()
String message to this device.