-
Notifications
You must be signed in to change notification settings - Fork 0
/
portas.c
57 lines (44 loc) · 1.54 KB
/
portas.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
#include <pic16f877a.h> /* Pic definitions */
#include <stdbool.h> /* Bools, true of false */
#include <stdint.h> /* For uint8_t definition */
#include <stdlib.h>
#include <xc.h> /* XC8 General Include File */
#include "pulls.h"
static void init_aux_ports(void);
static void init_i2c_port(void);
static void init_uart_port(void);
/******************************************************************************/
/* Ports */
/******************************************************************************/
inline void init_ports(void)
{
init_aux_ports();
init_i2c_port();
init_uart_port();
return;
}
static void init_aux_ports(void)
{
/* Port B and D are set to output */
TRISB = 0;
TRISD = 0;
PORTB = 0x00;
PORTD = 0x00;
return;
}
static void init_i2c_port(void)
{
/* SDA and SCL as inputs */
TRISCbits.TRISC3 = 1;
TRISCbits.TRISC4 = 1;
return;
}
static void init_uart_port(void)
{
/* TX as output and RX as input */
TRISCbits.TRISC6 = 0;
pull_up_terrain_kline(50);
TRISCbits.TRISC7 = 1;
return;
}
/* ************************************************************************** */