OpenCores
URL https://opencores.org/ocsvn/neo430/neo430/trunk

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [sw/] [lib/] [neo430/] [include/] [neo430_uart.h] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
// #################################################################################################
2
// #  < neo430_uart.h - Internal UART driver functions >                                           #
3
// # ********************************************************************************************* #
4
// # BSD 3-Clause License                                                                          #
5
// #                                                                                               #
6
// # Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
7
// #                                                                                               #
8
// # Redistribution and use in source and binary forms, with or without modification, are          #
9
// # permitted provided that the following conditions are met:                                     #
10
// #                                                                                               #
11
// # 1. Redistributions of source code must retain the above copyright notice, this list of        #
12
// #    conditions and the following disclaimer.                                                   #
13
// #                                                                                               #
14
// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
15
// #    conditions and the following disclaimer in the documentation and/or other materials        #
16
// #    provided with the distribution.                                                            #
17
// #                                                                                               #
18
// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
19
// #    endorse or promote products derived from this software without specific prior written      #
20
// #    permission.                                                                                #
21
// #                                                                                               #
22
// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
23
// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
24
// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
25
// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
26
// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
27
// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
28
// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
29
// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
30
// # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
31
// # ********************************************************************************************* #
32
// # The NEO430 Processor - https://github.com/stnolting/neo430                                    #
33
// #################################################################################################
34
 
35
#ifndef neo430_uart_h
36
#define neo430_uart_h
37
 
38
// Libs required by functions
39
#include <stdarg.h>
40
 
41
// prototypes
42
void neo430_uart_setup(uint32_t baudrate);                                              // activate and configure UART
43
void neo430_uart_disable(void);                                                         // deactivate uart
44
uint32_t neo430_uart_get_baudrate(void);                                                // compute actual baudrate using UART's current configuration
45
void neo430_uart_putc(char c);                                                          // send single char
46
char neo430_uart_getc(void);                                                            // wait and read single char
47
uint16_t neo430_uart_char_received(void);                                               // test if a char has been received
48
char neo430_uart_char_read(void);                                                       // get a received char
49
void neo430_uart_print(char *s);                                                        // print a text string
50
void neo430_uart_br_print(char *s);                                                     // print a text string and allow easy line breaks
51
uint16_t neo430_uart_scan(char *buffer, uint16_t max_size, uint16_t echo);              // read several chars into buffer
52
void neo430_uart_print_hex_char(char c);                                                // print byte as a hex char
53
void neo430_uart_print_hex_byte(uint8_t b);                                             // print byte as 2 hex numbers
54
void neo430_uart_print_hex_word(uint16_t w);                                            // print word as 4 hex numbers
55
void neo430_uart_print_hex_dword(uint32_t dw);                                          // print double word as 8 hex numbers
56
void neo430_uart_print_hex_qword(uint64_t qw);                                          // print quad word as 16 hex numbers
57
void neo430_uart_print_bin_byte(uint8_t b);                                             // print byte in binary form
58
void neo430_uart_print_bin_word(uint16_t w);                                            // print word in binary form
59
void neo430_uart_print_bin_dword(uint32_t dw);                                          // print double word in binary form
60
void neo430_itoa(uint32_t x, uint16_t leading_zeros, char *res);                        // convert double word to decimal number
61
void neo430_printf(char *format, ...);                                                  // print format string
62
uint32_t neo430_hexstr_to_uint(char *buffer, uint8_t length);                           // convert hex string to number
63
void neo430_uart_bs(uint16_t n);                                                        // return terminal cursor n positions
64
void neo430_uart_print_fpf_32(int32_t num, uint16_t fpf_c, uint16_t num_frac_digits_c); // print fixed-point number
65
 
66
#endif // neo430_uart_h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.