Project

General

Profile

Revision 323

more stuff

View differences:

utils.c
7 7

  
8 8
int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
9 9
    if (lsb == NULL) return NULL_PTR;
10
    *lsb = val;
10
    *lsb = (uint8_t)val;
11 11
    return SUCCESS;
12 12
}
13 13

  
......
21 21
    if(value == NULL) return NULL_PTR;
22 22
    uint32_t n = 0;
23 23
    if(sys_inb(port, &n)) return READ_ERROR;
24
    *value = n;
24
    *value = (uint8_t)n;
25 25
    return SUCCESS;
26 26
}
27 27

  
......
31 31
    return SUCCESS;
32 32
}
33 33

  
34
int32_t min(int32_t a, int32_t b){ return (b < a ? b : a); }
35
int32_t max(int32_t a, int32_t b){ return (a < b ? b : a); }
34
int16_t min16(int16_t a, int16_t b){ return (b < a ? b : a); }
35
uint16_t umin16(uint16_t a, uint16_t b){ return (b < a ? b : a); }
36
int32_t min32(int32_t a, int32_t b){ return (b < a ? b : a); }
37
double  dmin (double  a, double  b){ return (b < a ? b : a); }
36 38

  
37
double min_d(double a, double b){ return (b < a ? b : a); }
38
double max_d(double a, double b){ return (a < b ? b : a); }
39
double abs_d(double a)          { return (a < 0 ? -a: a); }
39
int16_t max16(int16_t a, int16_t b){ return (a < b ? b : a); }
40
uint16_t umax16(uint16_t a, uint16_t b){ return (a < b ? b : a); }
41
int32_t max32(int32_t a, int32_t b){ return (a < b ? b : a); }
42
double  dmax (double  a, double  b){ return (a < b ? b : a); }
43

  
44
double dabs(double a)          { return (a < 0 ? -a: a); }
45

  
46
int deq(double a, double b){ return (dabs(a-b) < 1e-10 ? true : false); }

Also available in: Unified diff