123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /*
- * sensor number: 1
- * sensor name: +12V
- * brief: ltc4280
- */
- int sensor_1_init(void)
- {
- return 0;
- }
- int sensor_1_write(void)
- {
- return 0;
- }
- int sensor_1_read(uint8_t *reading)
- {
- uint8_t buf = 5;
- int ret;
- int fd = open("/dev/i2c3", O_RDWR);
- ret = stm32_i2c_master_write(fd, 0xAA, &buf, 1);
- if(ret == 0)
- {
- ret = stm32_i2c_master_read(fd, 0xAA, &buf, 1);
- if(ret != 0)
- {
- printf("Sensor 1 read error!\n");
- }
- }
- else
- {
- printf("Sensor 1 write error!\n");
- }
- close(fd);
- //printf("read sensor 1: %#x!\n", buf);
- *reading = buf;
- return 0;
- }
- /*
- * sensor number: 2
- * sensor name: +12V_Current
- * brief: ltc4280
- */
- int sensor_2_init(void)
- {
- // log("init sensor 2!\r\n");
- return 0;
- }
- int sensor_2_write(void)
- {
- // log("write sensor 2!\r\n");
- return 0;
- }
- int sensor_2_read(uint8_t *reading)
- {
- uint8_t buf = 4;
- int ret;
- int fd = open("/dev/i2c3", O_RDWR);
- ret = stm32_i2c_master_write(fd, 0xAA, &buf, 1);
- if(ret == 0)
- {
- ret = stm32_i2c_master_read(fd, 0xAA, &buf, 1);
- if(ret != 0)
- printf("Sensor 2 read error!\n");
- }
- else
- printf("Sensor 2 write error!\n");
- close(fd);
- *reading = buf;
- return 0;
- }
- /*
- * sensor number: 3
- * sensor name: Temp_Board
- * brief: G780 local
- */
- int sensor_3_init(void)
- {
- // log("init sensor 2!\r\n");
- return 0;
- }
- int sensor_3_write(void)
- {
- // log("write sensor 2!\r\n");
- return 0;
- }
- int sensor_3_read(uint8_t *reading)
- {
- uint8_t buf = 0;
- int ret;
- int fd = open("/dev/i2c3", O_RDWR);
- ret = stm32_i2c_master_write(fd, 0x98, &buf, 1);
- if(ret == 0)
- {
- ret = stm32_i2c_master_read(fd, 0x98, &buf, 1);
- if(ret != 0)
- printf("Sensor 3 read error!\n");
- }
- else
- printf("Sensor 3 write error!\n");
- close(fd);
- *reading = buf;
- return 0;
- }
- /*
- * sensor number: 4
- * sensor name: Temp_FPGA
- * brief: G780 remote
- */
- int sensor_4_init(void)
- {
- // log("init sensor 2!\r\n");
- return 0;
- }
- int sensor_4_write(void)
- {
- // log("write sensor 2!\r\n");
- return 0;
- }
- int sensor_4_read(uint8_t *reading)
- {
- uint8_t buf = 1;
- int ret;
- int fd = open("/dev/i2c3", O_RDWR);
- ret = stm32_i2c_master_write(fd, 0x98, &buf, 1);
- if(ret == 0)
- {
- ret = stm32_i2c_master_read(fd, 0x98, &buf, 1);
- if(ret != 0)
- printf("Sensor 4 read error!\n");
- }
- else
- printf("Sensor 4 write error\n");
- close(fd);
- *reading = buf;
- return 0;
- }
- /*
- * sensor number: 5
- * sensor name: +1.5V
- * brief: adc_ch1
- */
- int sensor_5_init(void)
- {
- return 0;
- }
- int sensor_5_write(void)
- {
- return 0;
- }
- int sensor_5_read(uint8_t *reading)
- {
- uint16_t buf;
- stm32_adc_get_value(1, &buf);
- *reading = buf>>4;
- return 0;
- }
- /*
- * sensor number: 6
- * sensor name: +0.75V
- * brief: adc_ch2
- */
- int sensor_6_init(void)
- {
- return 0;
- }
- int sensor_6_write(void)
- {
- return 0;
- }
- int sensor_6_read(uint8_t *reading)
- {
- uint16_t buf;
- stm32_adc_get_value(2, &buf);
- *reading = buf>>4;
- return 0;
- }
|