-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
31 lines (21 loc) · 844 Bytes
/
utils.h
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
30
#ifndef _UTILS_H_
#define _UTILS_H_
#include <inttypes.h>
#include "config.h"
#define sysTimer() T1TC
extern const int power10[9];
char* ultoa(uint32_t val, char* dest);
char* ltoa(int32_t val, char* dest);
#define TUNE_FAC 0.96154
//#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/(delayval)) /2 ) )
#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/(delayval)) /4 * TUNE_FAC) )
#define delay_ms(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000/(delayval)) /4 * TUNE_FAC) )
void delay_us_(uint32_t delayval);
inline static void _PINSEL(const int bit, const int val)
{
if(bit < 16)
PINSEL0 = (PINSEL0 & ~(3<<(2*bit))) | ((val & 3) << (2*bit));
else
PINSEL1 = (PINSEL1 & ~(3<<(2*(bit-16)))) | ((val & 3) << (2*(bit-16)));
}
#endif /* _UTILS_H_ */