Go to the documentation of this file.00001
00009 #ifndef _GLOBAL_H
00010 #define _GLOBAL_H
00011
00012 #define EXTERN extern
00013
00014
00015
00016
00017
00018
00019
00024 #define WHEEL_SIZE 1280U
00025
00033 #define SPEEDLIMIT_MAX 250U
00034
00039 #define SPEEDLIMIT_MIN 30U
00040
00043 #define DEFAULT_MAGNET_NUMBER_TACHO 1U
00044
00047 #define DEFAULT_MAGNET_NUMBER_PEDAL 1U
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #define RXD_PORT PORTD
00060 #define RXD_DDR DDRD
00061 #define RXD_BIT PD0
00062
00063
00064 #define TXD_PORT PORTD
00065 #define TXD_DDR DDRD
00066 #define TXD_BIT PD1
00067
00068
00069 #define LED1_PORT PORTB
00070 #define LED1_DDR DDRB
00071 #define LED1_BIT PB1
00072
00073 #define LED2_PORT PORTB
00074 #define LED2_DDR DDRB
00075 #define LED2_BIT PB0
00076
00077 #define LED3_PORT PORTD
00078 #define LED3_DDR DDRD
00079 #define LED3_BIT PD7
00080
00081 #define LED4_PORT PORTD
00082 #define LED4_DDR DDRD
00083 #define LED4_BIT PD6
00084
00085 #define LED5_PORT PORTD
00086 #define LED5_DDR DDRD
00087 #define LED5_BIT PD4
00088
00089
00090 #define MUX_VOLT_PORT PORTC
00091 #define MUX_VOLT_DDR DDRC
00092 #define MUX_VOLT_BIT PC4
00093
00094 #define MUX_CURR_PORT PORTC
00095 #define MUX_CURR_DDR DDRC
00096 #define MUX_CURR_BIT PC5
00097
00098
00099 #define SPEAKER_PORT PORTB
00100 #define SPEAKER_DDR DDRB
00101 #define SPEAKER_BIT PB2
00102
00103
00104 #define RELAY_PORT PORTD
00105 #define RELAY_DDR DDRD
00106 #define RELAY_BIT PD5
00107
00108
00109 #define FAN_PORT PORTC
00110 #define FAN_DDR DDRC
00111 #define FAN_BIT PC3
00112
00113
00114 #define INT0_PORT PORTD
00115 #define INT0_DDR DDRD
00116 #define INT0_BIT PD2
00117
00118
00119 #define INT1_PORT PORTD
00120 #define INT1_DDR DDRD
00121 #define INT1_BIT PD3
00122
00123
00124 #define VREF_PORT PORTC
00125 #define VREF_DDR DDRC
00126 #define VREF_BIT 7
00127
00128
00129 #define CSBASE_PORT PORTC
00130 #define CSBASE_DDR DDRC
00131 #define CSBASE_BIT PC1
00132
00133
00134 #define R3_PORT PORTC
00135 #define R3_DDR DDRC
00136 #define R3_BIT PC0
00137
00138
00139 #define VTH_PORT PORTC
00140 #define VTH_DDR DDRC
00141 #define VTH_BIT PC2
00142
00143
00144 #define SWITCH_PORT PORTC
00145 #define SWITCH_DDR DDRC
00146 #define SWITCH_BIT 6
00147
00148
00149 #define ADC_SWITCH ADC6
00150 #define ADC_TEMPERATURE ADC2
00151 #define ADC_VOLTAGE ADC0
00152 #define ADC_VREF ADC7
00153 #define ADC_CURRENT ADC1
00154
00155
00156
00157
00158
00169 #define MAX_CURRENT 523U
00170
00172 #define VALUE_TEMP_FAN 45U // 45°C
00173
00175 #define VALUE_TEMP_WARN 70U // 70°C
00176
00178 #define VALUE_TEMP_ERROR 80U // 80°C
00179
00181 #define ONE_MINUTE_MS ((UINT32)60000UL)
00182
00185 #define FW_VERSION 1172U
00186
00189 #define APPLICATION_CRC 0x5C751A3FUL
00190
00191 #define CRC32POLY 0xEDB88320UL
00192
00193
00194 #define STATIC static
00195 #define LOCAL_STATIC static
00196 #define CONST const
00197 #define VOLATILE volatile
00198
00199
00200 #ifndef SECTION_EEMEM
00201 #define SECTION_EEMEM __attribute__ ((section (".eeprom")))
00202 #endif
00203
00204 #ifndef SECTION_VERSION
00205 #define SECTION_VERSION __attribute__ ((section (".app_ver")))
00206 #endif
00207
00208 #ifndef SECTION_CRC
00209 #define SECTION_CRC __attribute__ ((section (".app_crc")))
00210 #endif
00211
00212
00213
00214
00215
00216
00217
00219 #define HIGH_BYTE(x) ((UINT8) (x >> 8U))
00220
00222 #define LOW_BYTE(x) ((UINT8) x)
00223
00225 #define LED1_ON() LED1_PORT &= ~(1U << LED1_BIT);
00226
00227 #define LED1_OFF() LED1_PORT |= (1U << LED1_BIT);
00228
00230 #define LED2_ON() LED2_PORT &= ~(1U << LED2_BIT);
00231
00232 #define LED2_OFF() LED2_PORT |= (1U << LED2_BIT);
00233
00235 #define LED3_ON() LED3_PORT &= ~(1U << LED3_BIT);
00236
00237 #define LED3_OFF() LED3_PORT |= (1U << LED3_BIT);
00238
00240 #define LED4_ON() LED4_PORT &= ~(1U << LED4_BIT);
00241
00242 #define LED4_OFF() LED4_PORT |= (1U << LED4_BIT);
00243
00245 #define LED5_ON() LED5_PORT &= ~(1U << LED5_BIT);
00246
00247 #define LED5_OFF() LED5_PORT |= (1U << LED5_BIT);
00248
00250 #define ALL_LEDS_ON() {LED1_ON(); LED2_ON(); LED3_ON(); \
00251 LED4_ON(); LED5_ON();}
00252
00254 #define ALL_LEDS_OFF() {LED1_OFF(); LED2_OFF(); LED3_OFF(); \
00255 LED4_OFF();LED5_OFF();}
00256
00258 #define MUX_CURR() { MUX_CURR_PORT |= (1U << MUX_CURR_BIT); \
00259 MUX_VOLT_PORT &= ~(1U << MUX_VOLT_BIT); }
00260
00262 #define MUX_VOLT() { MUX_VOLT_PORT |= (1U << MUX_VOLT_BIT); \
00263 MUX_CURR_PORT &= ~(1U << MUX_CURR_BIT); }
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 #ifndef BOOTLOADER
00276 EXTERN const UINT32 g_u32ApplicationCRC;
00277 EXTERN const UINT16 g_u16ApplicationVersion;
00278 #endif
00279 EXTERN const S_MEM_STRUCTRUE sMemoryEEPROM;
00280
00281
00282
00283 #undef EXTERN
00284 #endif //_GLOBAL_H
00285
00286