2 * cmd_proc_freertos_tms570.h
7 * Header file for cmdProc with FreeRTOS procedures included.
10 #ifndef CMDIO_BUFFER_H_
11 #define CMDIO_BUFFER_H_
13 #define MAX_BUFFER_LEN 128
18 #include "os_semphr.h"
23 xSemaphoreHandle mutex;
28 /** Initialize IO Buffers
32 /** Print string into an output buffer. Let it be blocking or nonblocking in case the buffer is full.
33 * @param[in] string String to be printed into buffer
34 * @param[in] length number of characters to be printed
35 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
36 * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
38 portBASE_TYPE printToOutputBuffer(const uint8_t * string, uint32_t length, portTickType ticks);
40 /** Print string into an input buffer. Let it be blocking or nonblocking in case the buffer is full.
41 * @param[in] string String to be printed into buffer
42 * @param[in] length number of characters to be printed
43 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
44 * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
46 portBASE_TYPE printToInputBuffer(const uint8_t * string, uint32_t length, portTickType ticks);
48 /** Read character from an output buffer. Let it be blocking or nonblocking in case the buffer is empty.
49 * @param[out] ch Character read from buffer
50 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is empty. portMAX_DELAY can be used.
51 * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
53 portBASE_TYPE readFromOutputBuffer(uint8_t * ch, portTickType ticks);
55 /** Read character from an input buffer. Let it be blocking or nonblocking in case the buffer is empty.
56 * @param[out] ch Character read from buffer
57 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
58 * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
60 portBASE_TYPE readFromInputBuffer(uint8_t * ch, portTickType ticks);
62 /** Read character from a buffer. Let it be blocking or nonblocking in case the buffer is empty.
63 * @param[in] buffer Pointer to buffer from which will be read.
64 * @param[out] ch Character read from buffer
65 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is empty. portMAX_DELAY can be used.
66 * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
68 portBASE_TYPE read(tBuffer* buffer, uint8_t * ch, portTickType ticks);
70 /** Print string to a buffer. Let it be blocking or nonblocking in case the buffer is full.
71 * @param[in] buffer Pointer to buffer from which will be read.
72 * @param[in] string String to be printed into buffer
73 * @param[in] length number of characters to be printed
74 * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
75 * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
77 portBASE_TYPE print(tBuffer* buffer, const uint8_t * string, uint32_t length, portTickType ticks);
79 /** Makes input buffer empty
81 void clearInputBuffer();
83 /** Makes output buffer empty
85 void clearOutputBuffer();
87 /** Makes buffer empty
88 * @param[in] buffer Buffer to be cleared
90 void clearBuffer(tBuffer * buffer);
92 /** Puts character into output buffer. Is blocking, when buffer is full.
93 * @param[in] cmd_io IO stack pointer
94 * @param[in] ch Character to be printed
95 * @return 1 when succes, 0 when fail
97 int buf_putc(cmd_io_t *cmd_io, int ch);
99 /** Gets character from input buffer, is blocking when buffer is empty.
100 * @param[in] cmd_io IO stack pointer
101 * @return read character
103 int buf_getc(cmd_io_t *cmd_io);
105 /** Writes string into output buffer, is blocking when buffer is full.
106 * @param[in] cmd_io IO stack pointer
107 * @param[in] buf String to be written
108 * @param[in] count Number of character to be written
109 * @return number of written characters
111 int buf_write(cmd_io_t *cmd_io, const void *buf, int count);
113 /** Reads string from input buffer, is blocking when buffer is empty.
114 * @param[in] cmd_io IO stack pointer
115 * @param[out] buf Buffer into which string be read
116 * @param[in] count Number of character to be read
117 * @return number of read characters
119 int buf_read(cmd_io_t *cmd_io, void *buf, int count);
121 #endif /* CMDIO_BUFFER_H_ */