Carga Dinâmica  0.1
Sistemas de Instrumentação Electrónica
uart.h
Go to the documentation of this file.
1 
5 /* ************************************************************************** */
6 #ifndef UART_H /* Guard against multiple inclusion */
7 #define UART_H
8 
9 
10 // //**************************************************************************
15 #include <stdlib.h>
16 #include <stdint.h>
17 #include <xc.h>
18 #include <sys/attribs.h>
19 
20 #include "interrup.h"
21 
22 
23 //**************************************************************************
24 //defines interrupt
25 
26 #define DisableUart1RxInterrupt() IEC0bits.U1RXIE = 0;
27 #define EnableUart1RxInterrupt() IEC0bits.U1RXIE = 1;
28 #define DisableUart1TxInterrupt() IEC0bits.U1TXIE = 0;
29 #define EnableUart1TxInterrupt() IEC0bits.U1TXIE = 1;
30 #define UART_BUF_SIZE 256
31 #define INDEX_MASK (UART_BUF_SIZE-1)
32 
33 //**************************************************************************
34 
35 typedef struct
36 {
37  uint8_t data[UART_BUF_SIZE];
38  uint16_t head;
39  uint16_t tail;
40  uint16_t count;
41 } SerialBuf;
42 
43 //**************************************************************************
44 // global
45 
46 volatile static SerialBuf rxb;
47 volatile static SerialBuf txb;
48 
49 //**************************************************************************
57 void initUart(uint32_t PBCLK);
58 
59 //**************************************************************************
68 void _mon_putc (char c);
69 
70 //**************************************************************************
85 uint8_t readChar(char *pchar);
86 
87 
88 #endif
static volatile SerialBuf rxb
Transmission buffer.
Definition: uart.h:46
uint8_t readChar(char *pchar)
function uart reader for interruption
static volatile SerialBuf txb
Reception buffer.
Definition: uart.h:47
uint16_t tail
Last pos in array.
Definition: uart.h:39
uint16_t head
Inittial pos in array.
Definition: uart.h:38
Definition: uart.h:35
void initUart(uint32_t PBCLK)
Initial uart1.
configuratoin for i2c
#define UART_BUF_SIZE
must be 2&#39;s power
Definition: uart.h:30
void _mon_putc(char c)
function uart transmitter for polling
uint16_t count
Number of characters.
Definition: uart.h:40