]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/cmdproc/src/cmdproc_io_tisci.c
e8eb5f96b5fca0777d4342143d4e3591f974a41f
[pes-rpp/rpp-test-sw.git] / rpp / lib / cmdproc / src / cmdproc_io_tisci.c
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware
4
5   cmd_proc_io_tisci.c - IO layer functions for SCI on TMS570 and FreeRTOS
6
7   Copyright (C) 2001-2009 by Pavel Pisa pisa@cmp.felk.cvut.cz
8             (C) 2002-2009 by PiKRON Ltd. http://www.pikron.com
9             (C) 2007 by Michal Sojka <sojkam1@fel.cvut.cz>
10             (C) 2012 by Michal Horn <hornmich@fel.cvut.cz>
11
12   This file can be used and copied according to next
13   license alternatives
14    - MPL - Mozilla Public License
15    - GPL - GNU Public License
16    - other license provided by project originators
17  *******************************************************************/
18
19
20 /* Include files */
21 #include "cmdproc_io_tisci.h"
22 #include "types.h"
23 #include "rpp/rpp.h"
24
25 /**
26  * @brief Print character on SCI
27  * @param cmd_io cmd_io structure
28  * @param ch character to be printed
29  * @return always 1
30  *
31  */
32 int tisci_putc(cmd_io_t *cmd_io, int ch) {
33         rpp_sci_putc((uint8_t)ch);
34     return 1;
35 }
36
37 /**
38  * @brief Read character from SCI
39  * @param cmd_io cmd_io structure
40  * @return character ASCII code
41  *
42  */
43 int tisci_getc(cmd_io_t *cmd_io) {
44         int ret = '\0';
45         ret = rpp_sci_getc();
46         if (ret == FAILURE) {
47         ret = '\0';
48         }
49     return ret;
50 }
51
52 /**
53  * @brief Print string on SCI
54  * @param cmd_io cmd_io structure
55  * @param buf String buffer to be printed
56  * @param count maximum character number to be printed
57  * @return number of printed characters
58  *
59  */
60 int tisci_write(cmd_io_t *cmd_io, const void *buf, int count) {
61     const char *tmpBuf = buf;
62
63         return rpp_sci_printf("%s", tmpBuf);
64 }
65
66 /**
67  * @brief Read string from SCI
68  * @param cmd_io cmd_io structure
69  * @param buf String buffer
70  * @param count maximum character number to be read
71  * @return SUCCESS
72  */
73 int tisci_read(cmd_io_t *cmd_io, void *buf, int count) {
74     uint8_t* tmpBuf = buf;
75         return rpp_sci_read(count, tmpBuf);
76 }
77
78 /**
79  *  IO stack for cmdProc
80  */
81 cmd_io_t cmd_io_buf={
82         tisci_putc,
83         tisci_getc,
84         tisci_write,
85         tisci_read
86 };
87