GlobLib
HAL and API libraries for MCUs and hardware.
coms128.c
Go to the documentation of this file.
1 
17 #include "coms128.h"
18 
19 void com128_dataSent(void);
20 void com128_dataOut(uint8_t byte);
21 
22 //FIFO8 object and memory buffer
23 static FIFO8 tx;
24 static uint8_t tx_buf[TX_SIZE];
25 
26 //Connects all objects together, see module examples
27 ret_point COMOUT_con128(void (*put)(uint8_t)){
28 
29  FIFO8_init(&tx,FIFO8_AUTO,tx_buf,TX_SIZE,put);
30  STRING11_setOutput(&com128_dataOut);
31  return &com128_dataSent;
32 }
33 
34 //This is called now by USART.txISR
35 void com128_dataSent(void){
36 
37  FIFO8_get(&tx);
38 
39 }
40 
41 //This is called by STRING11 output calls
42 void com128_dataOut(uint8_t byte){
43 
44  FIFO8_put(&tx,byte);
45 
46 }
Fifo contents flushed to output function ASAP.
Definition: fifo8.h:47
fifo8_error_t FIFO8_get(FIFO8 *target)
Takes a character from the buffer.
Definition: fifo8.c:45
void STRING11_setOutput(void(*out_fun)(uint8_t))
Set the target output stream for print functions.
Definition: string11.c:122
void(* ret_point)(void)
Return function pointer type for COMOUT_con128.
Definition: coms128.h:62
Header file for COMS128.
fifo8_error_t FIFO8_put(FIFO8 *target, uint8_t byte)
Adds a character to the buffer.
Definition: fifo8.c:20
ret_point COMOUT_con128(void(*put)(uint8_t))
Initializes FIFO8 and STRING11.
Definition: coms128.c:27
fifo8_error_t FIFO8_init(FIFO8 *target, fifo8_mode_t mode, uint8_t *buffer, uint16_t size, void(*output)(uint8_t byte))
Initializes the FIFO8 buffer.
Definition: fifo8.c:64
#define TX_SIZE
Size of the memory buffer used by FIFO8.
Definition: coms128.h:52
Data structure for FIFO8 perihperal interface.
Definition: fifo8.h:75