Select Git revision
-
hyunjun_cho authoredhyunjun_cho authored
app3.c 2.93 KiB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
#define TEMP_DEV_PATH "/dev/temp_dev"
#define SOUND_DEV_PATH "/dev/sound_dev"
#define LED_DEV_PATH "/dev/led_dev"
#define LED2_DEV_PATH "/dev/led2_dev"
#define INTERVAL 50000
#define IOCTL_MAGIC_NUMBER 'K'
#define IOCTL_MAGIC_NUMBER2 'J'
#define IOCTL_CMD_SET_TEMP_BLINK _IOWR(IOCTL_MAGIC_NUMBER,1,int)
#define IOCTL_CMD_SET_TEMP_OFF _IOWR(IOCTL_MAGIC_NUMBER,2,int)
#define IOCTL_CMD_SET_SOUND_BLINK _IOWR(IOCTL_MAGIC_NUMBER2, 1, int)
#define IOCTL_CMD_SET_SOUND_OFF _IOWR(IOCTL_MAGIC_NUMBER2, 2, int)
int main() {
int temp_fd = open(TEMP_DEV_PATH, O_RDWR);
int sound_fd = open(SOUND_DEV_PATH, O_RDWR);
int sound_data = 0;
int led_fd, led2_fd;
int led_data = 1, led2_data = 1;
__pid_t pid;
led_fd = open(LED_DEV_PATH, O_RDONLY);
led2_fd = open(LED2_DEV_PATH, O_RDONLY);
char config[3] = {0, };
int data[2] = {0, };
float result[2] = {0, };
char reg = 0x03;
if(temp_fd < 0) {
printf("fail to open TEMP sensor device\n");
return 1;
}
config[0] = 0x02;
config[1] = 0x15;
config[2] = 0x40;
for(int i = 0; i < 3; i++) {
write(temp_fd, &config[i], 1);
sleep(1);
}
sleep(1);
int temp = 0, j = 0;
float cTemp = 0, fTemp = 0;