From d8d87351acd4a8fef65db6a59993cbac99dc3bab Mon Sep 17 00:00:00 2001 From: Gergő J. Miklós Date: Tue, 6 Aug 2019 08:51:57 +0200 Subject: qmc5883 initial --- src/lm75.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/lm75.c') diff --git a/src/lm75.c b/src/lm75.c index 2e14738..3754a56 100644 --- a/src/lm75.c +++ b/src/lm75.c @@ -12,7 +12,7 @@ -extern uint16 devicef; +//extern uint16 devicef; extern void bus_err(int ern); extern void print_help(void); extern uchar *xchg_data (uchar *buf, uint8 wrlen, uint8 waitlen, uint8 rdlen); @@ -20,7 +20,7 @@ uchar buf[32]; -void lm75_print_all(void) +void lm75_print_all(const uchar *opts) { printf( "============ LM75xx interface ===========\n" @@ -121,11 +121,11 @@ void lm75_read_all(const uchar *opts){ // Print out whole device's data // { // printf("00:%f\n", calc_temp(strtof(opts, NULL))); // } else { - printf("00:%f\n", calc_temp(0.0)); + fprintf(stdout, "00:%f\n", calc_temp(0.0)); // } - printf("01:0x%x\n", read_conf()); - printf("02:%f\n", read_thys()); - printf("03:%f\n", read_tos()); + fprintf(stdout, "01:0x%x\n", read_conf()); + fprintf(stdout, "02:%f\n", read_thys()); + fprintf(stdout, "03:%f\n", read_tos()); } @@ -142,9 +142,9 @@ void lm75_read_one(const uchar *opts){ // Prints the selected r } else { if( !isdigit(*(opts+i)) ){ //# Check the register string - printf("The Register address must be an integer!\n"); + fprintf(stderr, "The Register address must be an integer!\n"); print_help(); - lm75_print_all(); + lm75_print_all(NULL); exit (EXIT_FAILURE); } temp[i] = *(opts+i); //# copy register string @@ -158,16 +158,16 @@ void lm75_read_one(const uchar *opts){ // Prints the selected r switch (id) //# Which register is selected? { case 0x00: - printf("%f\n", calc_temp(atof((char*)temp))); //# with the offset + fprintf(stdout, "%f\n", calc_temp(atof((char*)temp))); //# with the offset break; case 0x01: - printf("0x%x\n", read_conf()); + fprintf(stdout, "0x%x\n", read_conf()); break; case 0x02: - printf("%f\n", read_thys()); + fprintf(stdout, "%f\n", read_thys()); break; case 0x03: - printf("%f\n", read_tos()); + fprintf(stdout, "%f\n", read_tos()); break; default: print_help(); @@ -253,7 +253,7 @@ void lm75_conf_set(const uchar *opts){ // Prints the selected r } else { - lm75_print_all(); + lm75_print_all(NULL); exit(EXIT_FAILURE); } buf[0] = 0x01; @@ -274,7 +274,7 @@ void lm75_conf_set(const uchar *opts){ // Prints the selected r } else { - lm75_print_all(); + lm75_print_all(NULL); exit(EXIT_FAILURE); } buf[0] = 0x01; @@ -295,7 +295,7 @@ void lm75_conf_set(const uchar *opts){ // Prints the selected r } else { - lm75_print_all(); + lm75_print_all(NULL); exit(EXIT_FAILURE); } buf[0] = 0x01; @@ -325,7 +325,7 @@ void lm75_conf_set(const uchar *opts){ // Prints the selected r } else { - lm75_print_all(); + lm75_print_all(NULL); exit(EXIT_FAILURE); } buf[0] = 0x01; @@ -337,7 +337,7 @@ void lm75_conf_set(const uchar *opts){ // Prints the selected r // if( !isxdigit(*(opts+i)) || *(opts+i) !='x' || opts[i] != ','){ //# Check the register string // printf("The Register address, and value must be a hex, or an integer!\n"); print_help(); - lm75_print_all(); + lm75_print_all(NULL); exit (EXIT_FAILURE); // } // } -- cgit v1.2.3