1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Serial Communication Interface RPP API implementation file.
25 * RPP API documentation.
31 #if rppCONFIG_INCLUDE_SCI == 1
34 #if rppCONFIG_DRV == 1
38 static boolean_t initialized = FALSE;
47 #if rppCONFIG_DRV == 1
55 boolean_t rpp_sci_setup(uint32_t baud)
57 boolean_t known = FALSE;
59 // FIXME This is a standard list of baud rates. This should include only
106 #if rppCONFIG_DRV == 1
107 drv_sci_set_baudrate(baud);
114 uint16_t rpp_sci_available()
116 uint16_t available = 0;
118 #if rppCONFIG_DRV == 1
119 available = drv_sci_available();
126 int8_t rpp_sci_read(uint32_t amount, uint8_t* buffer)
128 #if rppCONFIG_DRV == 1
129 drv_sci_receive(amount, buffer, portMAX_DELAY);
136 int8_t rpp_sci_read_nb(uint32_t amount, uint8_t* buffer)
138 #if rppCONFIG_DRV == 1
139 if(drv_sci_receive(amount, buffer, 0) != SUCCESS) {
148 int8_t rpp_sci_write(uint32_t amount, uint8_t* data)
150 #if rppCONFIG_DRV == 1
151 drv_sci_send(amount, data, portMAX_DELAY);
157 int8_t rpp_sci_write_nb(uint32_t amount, uint8_t* data)
159 #if rppCONFIG_DRV == 1
160 if(drv_sci_send(amount, data, 0) != SUCCESS) {
168 int32_t rpp_sci_printf(const char *format, ...)
170 char str[MAX_BUFFER_LEN];
174 va_start(argList, format);
176 length = vsnprintf(str, sizeof(str), format, argList);
181 #if rppCONFIG_DRV == 1
182 if(drv_sci_send((uint32_t)length,
184 portMAX_DELAY) != SUCCESS) {
194 #endif /* rppCONFIG_INCLUDE_SCI */