LTlib LaurTec Library
4.0.0 Beta
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
main.c
Go to the documentation of this file.
1
#include <xc.h>
2
3
#include "
LTlib.h
"
4
5
#include "
module_IO.h
"
6
#include "
module_IO.c
"
7
8
//******************************************************************************
9
//The software reads PORTB where you have 4 buttons on RB4-RB7 (BT1-BT4).
10
//If the button on RB4 is pressed all the LEDs on PORTD are turned ON.
11
//******************************************************************************
12
13
#define BUTTON_PRESSED 0x00
14
15
int
main
(
void
) {
16
17
IO_set_all_ports_as_inputs
();
18
19
IO_enable_pull_up_resistors
(
IO_PORTB
,
IO_BIT4
+
IO_BIT5
+
IO_BIT6
+
IO_BIT7
);
20
21
IO_set_port_direction
(
IO_PORTD
,
IO_ALL_PORT_OUTPUT
);
22
23
while
(1){
24
25
if
(
IO_read_port_bit
(
IO_PORTB
,
IO_BIT4
) ==
BUTTON_PRESSED
) {
26
IO_write_port
(
IO_PORTD
, 0xFF);
27
}
else
{
28
IO_write_port
(
IO_PORTD
, 0x00);
29
}
30
}
31
}
LTlib_v_4.0.0
ex
PIC18
_module_IO
02 - module_IO_bit_masking.X
main.c
Generated on Sun Feb 21 2016 13:52:58 for LTlib LaurTec Library by
1.8.3.1