Fraise  2.1
FRAmework for Interfacing Software and Electronics

Common Fraise API. More...

Common Fraise API.

Sending raw bytes messages


bool fraise_putbytes (const char *data, uint8_t len)
 Send a raw bytes message. More...
 
void fraise_put_init ()
 Initialize the 'put' buffer.
 
void fraise_put_int8 (int8_t b)
 
void fraise_put_uint8 (uint8_t b)
 
void fraise_put_int16 (int16_t b)
 
void fraise_put_uint16 (uint16_t b)
 
void fraise_put_int32 (int32_t b)
 
void fraise_put_uint32 (uint32_t b)
 
bool fraise_put_send ()
 Send the 'put' buffer with fraise_putbytes()
 

Sending text messages


bool fraise_puts (const char *msg)
 Send a text message. More...
 
void fraise_putchar (char c)
 push a single character to the text buffer More...
 
void fraise_printf (const char *fmt,...) __attribute__((format(printf
 Push a printf-formatted buffered text to the text buffer. More...
 

Optional user defined callbacks


void setup ()
 Setup the application (optional user defined) More...
 
void loop ()
 Application loop (optional user defined) More...
 
void fraise_receivebytes (const char *data, uint8_t len)
 Receive raw bytes (optional user defined) More...
 
void fraise_receivechars (const char *data, uint8_t len)
 Receive text message (optional user defined) More...
 
void fraise_receivebytes_broadcast (const char *data, uint8_t len)
 Receive broadcast raw bytes (optional user defined) More...
 
void fraise_receivechars_broadcast (const char *data, uint8_t len)
 Receive broadcast text message (optional user defined) More...
 

Bytes receive decoding utils:


Note
These functions are only valid when called from fraise_receivebytes() or fraise_receivebytes_broadcast(). If there's not enough data left, they return 0.
int8_t fraise_get_int8 ()
 
uint8_t fraise_get_uint8 ()
 
int16_t fraise_get_int16 ()
 
uint16_t fraise_get_uint16 ()
 
int32_t fraise_get_int32 ()
 
uint32_t fraise_get_uint32 ()
 
void fraise_init_get_buffer (const char *data, uint8_t len)
 Init the 'get' buffer. More...
 

Global fraise driver management


void fraise_setup ()
 Initialize the Fraise driver. More...
 
void fraise_unsetup ()
 Stop and cleanup the Fraise driver.
 
void fraise_get_pins (int *rxpin, int *txpin, int *drvpin)
 Get the pin numbers that Fraise is using. More...
 

Misc


bool claim_pio_sm_irq (const pio_program_t *program, PIO *pio_hw, uint *sm, uint *program_offset, uint *irq)
 Request attribution of a pio/sm (and optionnaly irq) for a given pio program. More...
 

Function Documentation

◆ fraise_putbytes()

bool fraise_putbytes ( const char *  data,
uint8_t  len 
)

Send a raw bytes message.

Parameters
datathe address of the first byte to send
lenthe number of bytes to send
Returns
false if the TX buffer is full, true otherwise

◆ fraise_puts()

bool fraise_puts ( const char *  msg)

Send a text message.

Parameters
msgthe text message to send, must be a null-terminated string
Returns
false if the TX buffer is full, true otherwise

◆ fraise_putchar()

void fraise_putchar ( char  c)

push a single character to the text buffer

Parameters
cthe char to send
Note
the message will be sent with fraise_puts() and flushed after each \n (newline) character

◆ fraise_printf()

void fraise_printf ( const char *  fmt,
  ... 
)

Push a printf-formatted buffered text to the text buffer.

Parameters
fmt,...the formatted text
Note
the message will be sent and flushed after each \n character (fraise_printf() internally calls fraise_putchar())

◆ setup()

void setup ( )

Setup the application (optional user defined)

Note
the user can define this function, which will be automatically called once at startup

◆ loop()

void loop ( )

Application loop (optional user defined)

Note
the user can define this function, which will be called repeatedly after setup()

◆ fraise_receivebytes()

void fraise_receivebytes ( const char *  data,
uint8_t  len 
)

Receive raw bytes (optional user defined)

Parameters
datathe buffer containing the received bytes
lenthe number of received bytes
Note
the user can define this function, which will be called when a raw bytes message has been received

◆ fraise_receivechars()

void fraise_receivechars ( const char *  data,
uint8_t  len 
)

Receive text message (optional user defined)

Parameters
datathe buffer containing the received characters
lenthe number of received characters
Note
the user can define this function, which will be called when a text message has been received

◆ fraise_receivebytes_broadcast()

void fraise_receivebytes_broadcast ( const char *  data,
uint8_t  len 
)

Receive broadcast raw bytes (optional user defined)

Parameters
datathe buffer containing the received bytes
lenthe number of received bytes
Note
the user can define this function, which will be called when a broadcast raw bytes message has been received

◆ fraise_receivechars_broadcast()

void fraise_receivechars_broadcast ( const char *  data,
uint8_t  len 
)

Receive broadcast text message (optional user defined)

Parameters
datathe buffer containing the received characters
lenthe number of received characters
Note
the user can define this function, which will be called when a broadcast text message has been received

◆ fraise_init_get_buffer()

void fraise_init_get_buffer ( const char *  data,
uint8_t  len 
)

Init the 'get' buffer.

Parameters
datathe buffer containing the data to decode
lenthe number of data bytes
Note
this function is automatically called before fraise_receivebytes() or fraise_receivebytes_broadcast() are called.

◆ fraise_setup()

void fraise_setup ( )

Initialize the Fraise driver.

Note
This is automatically called at startup, so in most cases you won't need it.

◆ fraise_get_pins()

void fraise_get_pins ( int *  rxpin,
int *  txpin,
int *  drvpin 
)

Get the pin numbers that Fraise is using.

Parameters
rxpinthe address where to store the number of the RX pin
txpinthe address where to store the number of the TX pin
drvpinthe address where to store the number of the DRV pin

◆ claim_pio_sm_irq()

bool claim_pio_sm_irq ( const pio_program_t *  program,
PIO *  pio_hw,
uint *  sm,
uint *  program_offset,
uint *  irq 
)

Request attribution of a pio/sm (and optionnaly irq) for a given pio program.

Parameters
programthe pio program we want a sm to run
pio_hwthe address where to store the available pio
smthe address where to store the index of the available state machine
program_offsetthe address where to store the offset from which the program can be written
irqif not null, the address where to store the index of the chosen irq
Returns
false if this fails.