Hanna
Sourcecode Batteriemanagementsystem
Doku Start
Informationen
Auflistung der Dateien
Datenstrukturen
Batman
Hanna
Documents
Eclipse
ws-bms
bms_main
utils
compiler.h
gehe zur Dokumentation dieser Datei
1
11
#ifndef UTILS_COMPILER_H
12
#define UTILS_COMPILER_H
13
24
#include <avr/io.h>
25
#include <avr/builtins.h>
26
#include <stdbool.h>
27
#include <stdint.h>
28
#include <stddef.h>
29
#include <stdlib.h>
30
#include <util/delay.h>
31
36
# define barrier() asm volatile("" ::: "memory")
37
46
#define Assert(expr) ((void) 0)
47
48
#include <
pmic.h
>
49
64
/* ! Check GCC and IAR part definition for 8-bit AVR */
65
#define AVR8_PART_IS_DEFINED(part) (defined(__ ## part ## __) || defined(__AVR_ ## part ## __))
66
67
73
#define XMEGA_A3U ( \
74
AVR8_PART_IS_DEFINED(ATxmega64A3U) || \
75
AVR8_PART_IS_DEFINED(ATxmega128A3U) || \
76
AVR8_PART_IS_DEFINED(ATxmega192A3U) || \
77
AVR8_PART_IS_DEFINED(ATxmega256A3U) \
78
)
79
80
#define XMEGA_A3BU ( \
81
AVR8_PART_IS_DEFINED(ATxmega256A3BU) \
82
)
83
91
#define XMEGA_AU (XMEGA_A1U || XMEGA_A3U || XMEGA_A3BU || XMEGA_A4U)
92
94
#define XMEGA (XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D || XMEGA_E)
95
99
//_____ M A C R O S ________________________________________________________
100
103
#define DISABLE 0
105
#define ENABLE 1
106
#ifndef __cplusplus
107
#if !defined(__bool_true_false_are_defined)
108
#define false 0
109
#define true 1
110
#endif
111
#endif
112
#define PASS 0
113
#define FAIL 1
114
#define LOW 0
115
#define HIGH 1
116
118
127
#define __always_inline inline __attribute__((__always_inline__))
128
130
131
140
#define __always_optimize __attribute__((optimize(3)))
141
142
143
148
158
#define Abs(a) (((a) < 0 ) ? -(a) : (a))
159
169
#define Min(a, b) (((a) < (b)) ? (a) : (b))
170
#define min(a, b) Min(a, b)
171
181
#define Max(a, b) (((a) > (b)) ? (a) : (b))
182
#define max(a, b) Max(a, b)
183
185
189
#define MSB(u16) (((uint8_t* )&u16)[1])
191
#define LSB(u16) (((uint8_t* )&u16)[0])
192
201
#define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) | ((uint16_t)(u16) << 8)))
202
204
205
206
//#include <pmic.h>
207
208
#define nop() do { __asm__ __volatile__ ("nop"); } while (0)
209
229
# include <avr/pgmspace.h>
230
# define PROGMEM_LOCATION(type, name, loc) \
231
type name __attribute__((section (#loc)))
232
# define PROGMEM_DECLARE(type, name) const type name __attribute__((__progmem__))
233
# define PROGMEM_STRING(x) PSTR(x)
234
# define PROGMEM_STRING_T PGM_P
235
# define PROGMEM_T const
236
# define PROGMEM_PTR_T const *
237
# define PROGMEM_BYTE_ARRAY_T uint8_t*
238
# define PROGMEM_WORD_ARRAY_T uint16_t*
239
# define PROGMEM_READ_BYTE(x) pgm_read_byte(x)
240
# define PROGMEM_READ_WORD(x) pgm_read_word(x)
241
243
248
//delay-makros definieren
249
#define delay_us(t) _delay_us(t)
250
#define delay_ms(t) _delay_ms(t)
251
#define delay_s(t) _delay_ms( t * 1000 )
252
253
#endif // UTILS_COMPILER_H
pmic.h
Programmable Multilevel Interrupt Controller driver.