diff --git a/cmdline/read-temp.c b/cmdline/read-temp.c index 82d689d..47efe30 100644 --- a/cmdline/read-temp.c +++ b/cmdline/read-temp.c @@ -125,49 +125,26 @@ int cnt, vid, pid; return 0; } - int rqRefreshHasNew[] = {6, 0, 0}; - int rqHasNew[] = {2, 0, 0}; - int rqGetNew[] = {2, 1, 0}; - int rqAdvance[] = {6, 1, 0}; + int dbg_getchar[] = {6, 0, 0}; int *rq; + fprintf(stdout, "answer: value=0x%04x (%i)\n", 1,1); while(1) { - // refresh "hasNew" variable - rq = rqRefreshHasNew; - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000); - if(cnt < 0){ - fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror()); - } - // check whether we have new - rq = rqHasNew; + rq = dbg_getchar; + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000); if(cnt < 0){ fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror()); } rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8); - - if(rxIndex) { // if we have new data? - // advance the new char pointer... - rq = rqAdvance; - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000); - if(cnt < 0){ - fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror()); - } - rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8); - - // get the new char and print it - rq = rqGetNew; - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000); - if(cnt < 0){ - fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror()); - } - rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8); - if(rxIndex != 0 && (rxIndex & 0xff) != 0xff){ - fprintf(stdout, "%c", rxIndex); - } - } - usleep(100); + + if(rxIndex > 256) { + usleep(10000); + } else { + fprintf(stdout, "%c", rxIndex); + fflush(stdout); + } } } else { usage(); diff --git a/firmware/masterchip/spi_config.h b/firmware/masterchip/spi_config.h index adc910d..8a19d8c 100644 --- a/firmware/masterchip/spi_config.h +++ b/firmware/masterchip/spi_config.h @@ -1,5 +1,5 @@ -#define SPI_BAUDRATE 30000 +#define SPI_BAUDRATE 1260000 #define SPI_MASTER #define SPI_SS_PORT D #define SPI_SS_PIN 7 diff --git a/firmware/slavechip/filter.c b/firmware/slavechip/filter.c index 9d02551..3288fb0 100644 --- a/firmware/slavechip/filter.c +++ b/firmware/slavechip/filter.c @@ -14,7 +14,7 @@ float avg_noise[CHANNELCOUNT]; void process_thermocouple_value(int16_t raw_data, uint8_t channel){ - printf("procthermval, val %i, chan %i",raw_data,channel); + printf("procthermval, val %i, chan %i\n",raw_data,channel); // This function does everything that needs to be done to raw adc values float a = raw_data; a -= sensordata[channel].offset; diff --git a/firmware/slavechip/main.c b/firmware/slavechip/main.c index 61d14c6..8fbc68e 100644 --- a/firmware/slavechip/main.c +++ b/firmware/slavechip/main.c @@ -65,7 +65,7 @@ int __attribute__((noreturn)) main(void) { // measure temps 5*2 times for(uint8_t i=0; i<5; i++) { - printf("starting temp measuring"); + printf("starting temp measuring\n"); for(uint8_t active_sensor=0; active_sensor<2; active_sensor++) { // only measuring two probes atm muxer_set(active_sensor); while(!mcpadc_has_new_data()) _delay_ms(10); @@ -76,10 +76,9 @@ int __attribute__((noreturn)) main(void) { process_thermocouple_value(data,active_sensor); _delay_ms(1000); } - printf("a"); } - printf("now measuring offsets"); + printf("now measuring offsets\n"); // measure 2 offsets for(uint8_t active_sensor=0; active_sensor<2; active_sensor++) { // only measuring two offsets atm printf("active sensor: %i",active_sensor); @@ -90,7 +89,7 @@ int __attribute__((noreturn)) main(void) { while(!mcpadc_has_new_data()) _delay_ms(10); data = mcpadc_get_data(); - printf("retrieved offset data %i", data); + printf("retrieved offset data %i\n", data); // TODO: what to do with the offset? offset_measure_stop();