-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMedIOEx_DI_Ex2.c
51 lines (34 loc) · 1.45 KB
/
MedIOEx_DI_Ex2.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
/* MedIOEx-DI-Ex2.c
* Emergency stop sample with MedIOEx provides Raspberry Shield.
*
* Copyright (C) 2016 Polly Electronics & Automation
* If you have any troubles on MedIoEx, please do no not hesiate to contact [email protected]
* */
#include <stdio.h>
#include "pmedex.h"
#include <bcm2835.h>
int main(){
pe2a_DO_DI_init(); //DO and DI pins intialize
uint8_t arr_diGPIO[4]; //emergency stop buttons
for(;;){
arr_diGPIO[0] = pe2a_DI_getVal(pe2a_GPIO_J14_16); //DI : emergency stop NC
arr_diGPIO[1] = pe2a_DI_getVal(pe2a_GPIO_J14_15); //DI : emergency stop NC
arr_diGPIO[2] = pe2a_DI_getVal(pe2a_GPIO_J14_14); //DI : emergency stop NC
arr_diGPIO[3] = pe2a_DI_getVal(pe2a_GPIO_J14_13); //DI : emergency stop NC
if(arr_diGPIO[0] || arr_diGPIO[1] || arr_diGPIO[2] || arr_diGPIO[3] ){
printf("Emergency Status is NOT OK , buzzer should be ON \n")
pe2a_DO_setHigh(pe2a_GPIO_J4_1); //buzzer ON
pe2a_DO_setHigh(pe2a_GPIO_J4_2);
}
else
{
printf("Emergency Status is OK , buzzer should be OFF \n")
pe2a_DO_setLow(pe2a_GPIO_J4_1); //buzzer OFF
pe2a_DO_setLow(pe2a_GPIO_J4_2);
}
printf("\n\n");
delay(3); //3ms is needed for emergency stop in some cases
}
pe2a_bcm2835_close(); //All SPI port will be closed.
return 0;
}