HW_Lib/main.c

52 lines
1.2 KiB
C
Raw Normal View History

2024-05-09 05:56:55 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "t_spi.h"
2024-05-09 06:38:55 +00:00
#include "t_iic.h"
2024-05-10 05:47:39 +00:00
#include "t_task.h"
#include "t_arg.h"
2024-06-02 04:57:33 +00:00
#include "tool.h"
2024-05-20 13:53:19 +00:00
#include <time.h>
2024-05-10 05:47:39 +00:00
void Test(char *name, void (*pFunction)()) {
2024-05-20 13:53:19 +00:00
clock_t start, end;
double cpu_time_used;
2024-05-10 05:47:39 +00:00
printf("\n------< %s TEST >------\n", name);
2024-05-20 13:53:19 +00:00
start = clock();
2024-05-10 05:47:39 +00:00
pFunction();
2024-05-20 13:53:19 +00:00
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("\nTime taken by %s: %f seconds\n", name, cpu_time_used);
2024-05-10 05:47:39 +00:00
printf("\n------< %s END >------\n", name);
}
2024-05-09 06:38:55 +00:00
2024-06-02 04:57:33 +00:00
#define END "\n"
#define TYPE_F(v) _Generic((v), \
char :"[char]-> "#v"=%c" END, \
short :"[short]-> "#v"=%d" END, \
int :"[int]-> "#v"=%d" END, \
float :"[float]-> "#v"=%.2f" END , \
double :"[double]-> "#v"=%.2f" END, \
default: "[err]-> "#v"=%p" END)
#define POUT(s) printf(TYPE_F(s) ,s)
2024-05-09 05:56:55 +00:00
int main() {
2024-06-02 04:57:33 +00:00
srand((unsigned) time(NULL));
int i = 1;
POUT((++i) + (++i));
char str[] = "123.456";
float result = Str2Float(str);
printf("Result: %.3f\n", result);
// Test("SPI", Test_spi);
// Test("IIC", Test_iic);
// Test("ArgPase", Test_argpase);
// Test("Task", Test_task);
2024-05-09 05:56:55 +00:00
return 0;
}