-
Notifications
You must be signed in to change notification settings - Fork 0
/
leddiod.c
56 lines (48 loc) · 1.06 KB
/
leddiod.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
/*
* leddiod.c
*
* Created on: Nov 16, 2016
* Author: marisov
*/
#include "leddiod.h"
struct GPIO_containar_Struc D1;
/*
* ledinit
* Initialize port wich connected to diode
* @ * dir - port name
* @ * out - pin number
* */
void ledInit(uint8_t selectedPort,
uint16_t selectedPins){
D1.port = selectedPort;
D1.pin = selectedPins;
GPIO_setAsOutputPin(D1.port, D1.pin);
GPIO_setOutputLowOnPin(D1.port, D1.pin);
}
void ledStateSet(char state){
switch (state){
case(ON):
GPIO_setOutputHighOnPin(D1.port, D1.pin);
break;
case(OFF):
GPIO_setOutputLowOnPin(D1.port, D1.pin);
break;
case(CHANGE):
GPIO_toggleOutputOnPin(D1.port, D1.pin);
break;
}
}
void blink(int bNum)
{
int j;
unsigned char previesState;
previesState = GPIO_getInputPinValue(D1.port, D1.pin);
for(j = (bNum + 1); j; j--){
__delay_cycles(62500);
ledStateSet(CHANGE);
}
if(previesState != GPIO_getInputPinValue(D1.port, D1.pin))
ledStateSet(CHANGE);
}
void loBattSygnalling(){
}