00001 #include "pic_utils.h"
00002
00003
00004
00005
00006
00007
00008 #if NUMBER_PORTS == 2
00009 uns8 port_shadow[NUMBER_PORTS] = {0, 0};
00010 #endif
00011
00012 #if NUMBER_PORTS == 3
00013 uns8 port_shadow[NUMBER_PORTS] = {0, 0, 0};
00014 #endif
00015
00016 #if NUMBER_PORTS == 4
00017 uns8 port_shadow[NUMBER_PORTS] = {0, 0, 0, 0};
00018 #endif
00019
00020 #if NUMBER_PORTS == 5
00021 uns8 port_shadow[NUMBER_PORTS] = {0, 0, 0, 0, 0};
00022 #endif
00023
00024
00025 void set_pin_var(uns8 port, uns8 pin) {
00026 uns8 array_location = port - PORTA;
00027 set_bit(port_shadow[array_location], pin);
00028 port_array[array_location] = port_shadow[array_location];
00029 }
00030
00031 void clear_pin_var(uns8 port, uns8 pin) {
00032 uns8 array_location = port - PORTA;
00033 clear_bit(port_shadow[array_location], pin);
00034 port_array[array_location] = port_shadow[array_location];
00035 }
00036
00037 void toggle_pin_var(uns8 port, uns8 pin) {
00038 uns8 array_location = port - PORTA;
00039 port_shadow[array_location] ^= (1 << (pin));
00040 port_array[array_location] = port_shadow[array_location];
00041 }
00042
00043
00044 void change_pin_var(uns8 port, uns8 pin, bit value) {
00045 uns8 array_location = port - PORTA;
00046 if (value) {
00047 set_bit(port_shadow[array_location], pin);
00048 } else {
00049 clear_bit(port_shadow[array_location], pin);
00050 }
00051 port_array[array_location] = port_shadow[array_location];
00052 }
00053
00054