#include "config.h"#include "uart/uart_lib.h"
Go to the source code of this file.
Defines | |
| #define | BITSAMPLING 8 |
| #define | Byte_transfer_enable() { LINCR = (0<<LIN13)|(1<<LENA)|(1<<LCMD2)|(1<<LCMD1)|(1<<LCMD0); } |
| #define | LBT_MASK ((1<<LBT5)|(1<<LBT4)|(1<<LBT3)|(1<<LBT2)|(1<<LBT1)|(1<<LBT0)) |
| #define | Lin_get_data() ( LINDAT ) |
| #define | Lin_rx_response_ready() ( LINSIR & (1<<LRXOK) ) |
| #define | Lin_set_btr_brr(bt, br) |
| #define | Lin_set_data(data) ( LINDAT = data ) |
| #define | Lin_tx_response_ready() ( LINSIR & (1<<LTXOK) ) |
Functions | |
| r_uart_gtchar | uart_getchar (void) |
| This function allows to get a character from the UART. | |
| bit | uart_init (void) |
| This function configures the UART configuration and timming following the constant definition of BAUDRATE and enables the UART controller. | |
| r_uart_ptchar | uart_putchar (p_uart_ptchar ch) |
| This function allows to send a character on the UART. | |
| bit | uart_test_hit (void) |
| This function allows to inform if a character was received. | |
| #define BITSAMPLING 8 |
| #define Byte_transfer_enable | ( | ) | { LINCR = (0<<LIN13)|(1<<LENA)|(1<<LCMD2)|(1<<LCMD1)|(1<<LCMD0); } |
| #define LBT_MASK ((1<<LBT5)|(1<<LBT4)|(1<<LBT3)|(1<<LBT2)|(1<<LBT1)|(1<<LBT0)) |
Definition at line 26 of file uart_lib.c.
| #define Lin_get_data | ( | ) | ( LINDAT ) |
| #define Lin_rx_response_ready | ( | ) | ( LINSIR & (1<<LRXOK) ) |
| #define Lin_set_btr_brr | ( | bt, | |||
| br | ) |
Value:
{ U8 __jacq__; \
__jacq__ = LINCR; \
LINCR &= ~(1<<LENA); \
LINBTR = ((1<<LDISR) | (LBT_MASK & bt)); \
LINBRRH = (U8)((((((((U32)FOSC*1000)<<1)/(((U32)br)*bt))+1)>>1)-1)>>8); \
LINBRRL = (U8)(( (((((U32)FOSC*1000)<<1)/(((U32)br)*bt))+1)>>1)-1) ; \
LINCR = __jacq__; }
Definition at line 30 of file uart_lib.c.
Referenced by uart_init().
| #define Lin_set_data | ( | data | ) | ( LINDAT = data ) |
| #define Lin_tx_response_ready | ( | ) | ( LINSIR & (1<<LTXOK) ) |
| r_uart_gtchar uart_getchar | ( | void | ) |
This function allows to get a character from the UART.
Definition at line 73 of file uart_lib.c.
References Lin_get_data, and Lin_rx_response_ready.
Referenced by build_cmd().
00074 { 00075 while(!Lin_rx_response_ready()); 00076 return Lin_get_data(); 00077 }
| bit uart_init | ( | void | ) |
This function configures the UART configuration and timming following the constant definition of BAUDRATE and enables the UART controller.
Definition at line 54 of file uart_lib.c.
References BAUDRATE, BITSAMPLING, Byte_transfer_enable, Lin_set_btr_brr, Lin_set_data, and TRUE.
Referenced by ushell_task_init().
00055 { 00056 Lin_set_btr_brr(BITSAMPLING,BAUDRATE); 00057 Byte_transfer_enable(); 00058 Lin_set_data(0xFF); 00059 return TRUE; 00060 }
| r_uart_ptchar uart_putchar | ( | p_uart_ptchar | uc_wr_byte | ) |
This function allows to send a character on the UART.
| uc_wr_byte | character to print on UART. |
Definition at line 63 of file uart_lib.c.
References Lin_set_data, and Lin_tx_response_ready.
Referenced by build_cmd(), print_hex16(), print_msg(), and ushell_task().
00064 { 00065 while (!Lin_tx_response_ready()); 00066 Lin_set_data(ch); 00067 return (ch); 00068 }
| bit uart_test_hit | ( | void | ) |
This function allows to inform if a character was received.
Definition at line 48 of file uart_lib.c.
References Lin_rx_response_ready.
Referenced by build_cmd().
00049 { 00050 return (Lin_rx_response_ready()); 00051 }
1.5.7.1