-
Notifications
You must be signed in to change notification settings - Fork 0
/
PR_UART.c
90 lines (73 loc) · 4.63 KB
/
PR_UART.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*******************************************************************************************************************************//**
*
* @file DR_gpio.c
* @brief Descripcion del modulo
* @date 1 de abr. de 2016
* @author Ing. Marcelo Trujillo
*
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** INCLUDES
**********************************************************************************************************************************/
#include "PR_UART.h"
#include "DR_UART.h"
/***********************************************************************************************************************************
*** DEFINES PRIVADOS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** MACROS PRIVADAS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** TIPOS DE DATOS PRIVADOS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** TABLAS PRIVADAS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** VARIABLES GLOBALES PUBLICAS
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** VARIABLES GLOBALES PRIVADAS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** PROTOTIPO DE FUNCIONES PRIVADAS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** FUNCIONES PRIVADAS AL MODULO
**********************************************************************************************************************************/
/***********************************************************************************************************************************
*** FUNCIONES GLOBALES AL MODULO
**********************************************************************************************************************************/
/*********************************************************************************************
* @fn void PushTx( uint8_t dato )
* @brief La aplicación pone los datos que se desean transmitir, en el buffer de transmisión
* @param dato: valor que se desea transmitir
* @return void
********************************************************************************************/
void UART1_PushTx( uint8_t dato )
{
if (CantidadTx==TOPE_BUFFER_TX) {
//buffer lleno
} else {
BufferTx[ (IndiceTxStart + CantidadTx) % TOPE_BUFFER_TX ] = dato;
CantidadTx ++;
UART1_Iniciar_Envio();
}
}
/*********************************************************************************************
* @fn int16_t UART_PopRx( void )
* @brief Saca datos del buffer de recepción para ser leídos desde la aplicación
* @param void
* @return Devuelve el dato que saca del buffer de recepcion
********************************************************************************************/
int16_t UART1_PopRx( void )
{
int16_t dato;
if( CantidadRx == 0 )
return -1;
dato = (uint16_t) BufferRx[ IndiceRxStart ];
IndiceRxStart ++;
IndiceRxStart %= TOPE_BUFFER_RX;
CantidadRx--;
return dato;
}