aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_macros.h
blob: 52f82fd039b1f8d66ac945b850ca07ab74d79e1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef CH_SDMMC_MACROS_H_
#define CH_SDMMC_MACROS_H_



#define CACHE_ALIGNED  __attribute__((aligned(L1_CACHE_BYTES)))


#define IS_CACHE_ALIGNED(x) ((((uint32_t)(x)) & (L1_CACHE_BYTES - 1)) == 0)
#define ROUND_INT_DIV(n,d) (((n) + ((d)-1)) / (d))
#define ROUND_UP_MULT(x,m) (((x) + ((m)-1)) & ~((m)-1))
#define CEIL_INT_DIV(n,d) (((n) + (d) - 1) / (d))
#define ABS_DIFF(a,b) ((a) < (b) ? (b) - (a) : (a) - (b))
#define ARRAY_SIZE(x) (sizeof ((x)) / sizeof(*(x)))

#define _PrintTitle(s) TRACE(s)
#define _PrintField(f,v)	TRACE_1(f,v)

static inline uint32_t max_u32(uint32_t a, uint32_t b)
{
	return a > b ? a : b;
}

static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
	return a < b ? a : b;
}

#endif /* CH_SDMMC_MACROS_H_ */