X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fstm-demo%2Fao_demo.c;h=ea4dadfa89d438513c1414308569367d525bb947;hp=63647aac912238d461bccea33e7e33f647df082d;hb=f7cfbbce2b94b5ac0094a0e34e1766fe1ceb12c8;hpb=9b9357f48597a034211affb3f18fc6089816456d diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index 63647aac..ea4dadfa 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -111,10 +111,29 @@ ao_spi_read(void) { } } + + +static void +ao_temp (void) +{ + struct ao_adc adc; + int temp; + + ao_adc_get(&adc); + + /* + * r = (110 - 25) / (ts_cal_hot - ts_cal_cold) + * 25 + (110 - 25) * (temp - ts_cal_cold) / (ts_cal_hot - ts_cal_cold) + */ + temp = 25 + (110 - 25) * (adc.temp - stm_temp_cal.ts_cal_cold) / (stm_temp_cal.ts_cal_hot - stm_temp_cal.ts_cal_cold); + printf ("temp: %d\n", temp); +} + __code struct ao_cmds ao_demo_cmds[] = { { ao_dma_test, "D\0DMA test" }, { ao_spi_write, "W\0SPI write" }, { ao_spi_read, "R\0SPI read" }, + { ao_temp, "t\0Show temp" }, { 0, NULL } };