mirror of
https://github.com/eddyem/STM8_samples.git
synced 2026-03-21 09:11:02 +03:00
started voltmeter hacking
This commit is contained in:
6
voltmeters/calc/U.m
Normal file
6
voltmeters/calc/U.m
Normal file
@@ -0,0 +1,6 @@
|
||||
function u = U(ADU)
|
||||
adu = uint32(ADU)
|
||||
adu *= 3584
|
||||
adu = bitshift(adu, -17);
|
||||
u = uint32(10*adu);
|
||||
endfunction
|
||||
BIN
voltmeters/calc/u5
Executable file
BIN
voltmeters/calc/u5
Executable file
Binary file not shown.
20
voltmeters/calc/u5.c
Normal file
20
voltmeters/calc/u5.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t U(uint32_t x){
|
||||
x *= 3584;
|
||||
x >>= 17;
|
||||
return x*10;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
uint32_t x = 131072;
|
||||
int i;
|
||||
if(argc > 1){
|
||||
for(i = 1; i < argc; i++){
|
||||
x = atoi(argv[i]);
|
||||
printf("U(%u) = %u\n", x, U(x));
|
||||
}
|
||||
}else printf("U(%u) = %u\n", x, U(x));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user