Go to the source code of this file.
|
#define | EL_UART_1 0 |
|
#define | EL_UART_2 1 |
|
#define | EL_UART_BLUETOOTH EL_UART_1 |
|
void el_uart_use_reset_code |
( |
el_bool |
k, |
|
|
el_int8 |
x |
|
) |
| |
Setup a value that: upon receiving that value, reset the chip.
- Parameters
-
k | whether to use such a feature or not |
x | the value that triggers a hardware reset |
The Tiny Bootloader will first send a specific value to the UART bus shortly before a microcontroller programming. After that, the microcontroller needs to be reseted in a short time window. This reset code feature let the microcontroller reset itself automatically once the value occurs. The image below shows the setting in the TinyBootloader when the code is 128 (used in the examples of this lib).
void el_uart_send_char |
( |
el_index |
ch, |
|
|
char |
c |
|
) |
| |
Send one byte of data to the serial channel.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
x | the value to be sent |
Note: the return of this function does not necessarily mean the transmission is finished. To determine whether the transmission is still undergoing, use el_uart_is_sending.
void el_uart_send_string |
( |
el_index |
ch, |
|
|
const char * |
str |
|
) |
| |
Send a string (an array of char terminated by a null) to the serial channel.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
str | pointer to the string to be sent |
Note: the return of this function does not necessarily mean the transmission is finished. To determine whether the transmission is still undergoing, use el_uart_is_sending.
bool el_uart_is_sending |
( |
el_index |
ch | ) |
|
Check whether the transmission issued in the last sending function is finished.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
- Returns
- Boolean value of "is still sending or not"
el_uint16 el_uart_get_char_counter |
( |
el_index |
ch | ) |
|
Check how many bytes are received and buffered in the channel.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
- Returns
- the number of bytes received and buffered
char el_uart_get_char |
( |
el_index |
ch | ) |
|
Take out one byte from the receiving buffer in order of first-in-first-out.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
- Returns
- the byte
void el_uart_flush_char |
( |
el_index |
ch | ) |
|
Totally clear up the receiving buffer of a serial channel.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
el_uint16 el_uart_get_string |
( |
el_index |
ch, |
|
|
char * |
buf, |
|
|
el_uint16 |
buf_size, |
|
|
el_bool |
return_line |
|
) |
| |
Get a string ended with a null (0 or '\0') or a carriage-return ('\r', (the "Enter" key).
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
buf | pointer of a buffer to store the received string |
buf_size | size of the given buffer, which gives a limit to the length of the string received |
return_line | finish the string once (1) a carriage-return, (0) a null is received. |
- Returns
- length of the string
The null char received at last is not notable as a string in C is always terminated by a null. In case of ending with a carriage-return, the carriage-return itself will be placed in the string and followed by a null that terminates the string as usual.
char el_uart_peek_first_char |
( |
el_index |
ch | ) |
|
Check the first byte in the receiving buffer, but does not remove it from the buffer.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
- Returns
- value of the first byte
char el_uart_peek_last_char |
( |
el_index |
ch | ) |
|
Check the last byte in the receiving buffer but do not remove it from the buffer.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |
- Returns
- value of the last byte
void el_uart_erase_last_char |
( |
el_index |
ch | ) |
|
Remove the last byte received in the receiving buffer.
- Parameters
-
ch | serial channel index (at present, only 0 is effective) |