rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
rusefi_halconf.h
Go to the documentation of this file.
1// file rusefi_halconf.h
2
3#pragma once
4
5#define _CHIBIOS_HAL_CONF_
6#define _CHIBIOS_HAL_CONF_VER_8_4_
7
8#include "mcuconf.h"
9
10#include "efifeatures.h"
11#include "thread_priority.h"
12
13/*===========================================================================*/
14/* Conditional EFI feature settings */
15/*===========================================================================*/
16
17// If EFI_CAN_SUPPORT, enable CAN driver
18#define HAL_USE_CAN EFI_CAN_SUPPORT
19
20// If EFI_USB_SERIAL, enable USB features
21#define HAL_USE_USB EFI_USB_SERIAL
22#define HAL_USE_SERIAL_USB EFI_USB_SERIAL
23
24// If EFI_FILE_LOGGING and SDC, enable SDIO/SDMMC driver
25#if defined(EFI_SDC_DEVICE) && EFI_FILE_LOGGING
26 #define HAL_USE_SDC TRUE
27 #define FATFS_HAL_DEVICE EFI_SDC_DEVICE
28#else
29 #define HAL_USE_SDC FALSE
30#endif
31
32/**
33 * @brief Number of initialization attempts before rejecting the card.
34 * @note Attempts are performed at 10mS intervals.
35 */
36#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
37#define SDC_INIT_RETRY 100
38#endif
39
40/**
41 * @brief Delays insertions.
42 * @details If enabled this options inserts delays into the MMC waiting
43 * routines releasing some extra CPU time for the threads with
44 * lower priority, this may slow down the driver a bit however.
45 */
46#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
47#define SDC_NICE_WAITING TRUE
48#endif
49
50// If EFI_FILE_LOGGING but not SDC, use SPI instead
51#if !defined(EFI_SDC_DEVICE) && EFI_FILE_LOGGING
52 #define HAL_USE_MMC_SPI TRUE
53#else
54 #define HAL_USE_MMC_SPI FALSE
55#endif
56
57// If USB and File logging, enable USB Mass Storage & community
58#ifndef HAL_USE_USB_MSD
59#define HAL_USE_USB_MSD (EFI_FILE_LOGGING && EFI_USB_SERIAL)
60#endif // HAL_USE_USB_MSD
61#define HAL_USE_COMMUNITY (EFI_FILE_LOGGING && EFI_USB_SERIAL) || HAL_USE_EEPROM
62#define USB_MSD_LUN_COUNT 2
63
64// only the MSD driver requires USB_USE_WAIT
65#define USB_USE_WAIT (EFI_FILE_LOGGING && EFI_USB_SERIAL)
66
67// Ethernet
68#define HAL_USE_MAC EFI_ETHERNET
69
70/*===========================================================================*/
71/* Required rusEFI settings */
72/*===========================================================================*/
73
74// Enable flags
75#ifdef EFI_BOOTLOADER
76 // Disable stuff we don't need in the bootloader
77 #define HAL_USE_ADC FALSE
78 #define HAL_USE_GPT FALSE
79#else
80 // We are not the bootloader, enable stuff!
81 #ifndef HAL_USE_ADC
82 #define HAL_USE_ADC TRUE
83 #endif // HAL_USE_ADC
84 #ifndef HAL_USE_GPT
85 #define HAL_USE_GPT TRUE
86 #endif // HAL_USE_GPT
87#endif
88
89#define HAL_USE_PAL TRUE
90
91/*===========================================================================*/
92/* PAL driver related settings. */
93/*===========================================================================*/
94
95/**
96 * @brief No DAC subsystem.
97 */
98#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
99#define HAL_USE_DAC FALSE
100#endif
101
102/**
103 * @brief Enables the SPI subsystem.
104 */
105#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
106#define HAL_USE_SPI TRUE
107#endif
108
109/**
110 * @brief Enables the SDC subsystem.
111 */
112#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
113#define HAL_USE_SDC FALSE
114#endif
115
116/*===========================================================================*/
117/* SERIAL driver related settings. */
118/*===========================================================================*/
119
120/**
121 * @brief Default bit rate.
122 * @details Configuration parameter, this is the baud rate selected for the
123 * default configuration.
124 */
125#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
126#define SERIAL_DEFAULT_BITRATE 38400
127#endif
128
129/**
130 * @brief Serial buffers size.
131 * @details Configuration parameter, you can change the depth of the queue
132 * buffers depending on the requirements of your application.
133 * @note The default is 16 bytes for both the transmission and receive
134 * buffers.
135 */
136#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
137#define SERIAL_BUFFERS_SIZE 16
138#endif
139
140/**
141 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
142 * @note Disabling this option saves both code and data space.
143 */
144#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
145#define UART_USE_MUTUAL_EXCLUSION FALSE
146#endif
147
148// Options for individual drivers
149
150// ADC
151#define ADC_USE_WAIT TRUE
152#define ADC_USE_MUTUAL_EXCLUSION FALSE
153#define CAN_USE_SLEEP_MODE FALSE
154
155// CAN
156#define CAN_USE_SLEEP_MODE FALSE
157
158// MMC SPI
159#define MMC_NICE_WAITING TRUE
160
161// PAL
162#define PAL_USE_CALLBACKS TRUE
163
164// USB Serial
165#ifndef SERIAL_USB_BUFFERS_RX_SIZE
166#define SERIAL_USB_BUFFERS_RX_SIZE 64
167#endif
168
169#if (SERIAL_USB_BUFFERS_RX_SIZE != 64)
170#error Please keep SERIAL_USB_BUFFERS_SIZE until https://forum.chibios.org/viewtopic.php?f=35&t=6395 is properly fixed!
171#endif
172
173#ifndef SERIAL_USB_BUFFERS_RX_NUMBER
174#define SERIAL_USB_BUFFERS_RX_NUMBER 2
175#endif
176
177#ifndef SERIAL_USB_BUFFERS_TX_SIZE
178#define SERIAL_USB_BUFFERS_TX_SIZE 512
179#endif
180
181#ifndef SERIAL_USB_BUFFERS_TX_NUMBER
182#define SERIAL_USB_BUFFERS_TX_NUMBER 2
183#endif
184
185// USB Mass Storage
186#if EFI_USE_COMPRESSED_INI_MSD
187// if enabled, we do gzip decompression on the MSD thread - it requires more stack space
188#define USB_MSD_THREAD_WA_SIZE 2048
189#endif
190
191// SPI
192#define SPI_USE_WAIT TRUE
193#define SPI_USE_MUTUAL_EXCLUSION TRUE
194
195// Extra field in the UART driver's struct to store a reference to the DMA receive buffer object
196#define UART_DRIVER_EXT_FIELDS void* dmaAdapterInstance;
197
198// Ethernet MAC
199#define MAC_USE_ZERO_COPY FALSE
200#define MAC_USE_EVENTS TRUE
201
202#include "error_handling_c.h"
203
204// WARNING:
205// this while loop has non-determinited timeout! Current value is almost random.
206// Please consider CPU speed, IRQ load, expected and worst case event wait time!
207// Currently this is used instead of simple while (condition) loop in polling SPI driver.
208// We exect problems when SPI clock is low and CPU speed is high
209#define LIMITED_WHILE_LOOP(condition, ...) \
210 { int limit = 1000000 ; \
211 while (condition) { \
212 if (limit-- == 0) { \
213 criticalErrorC(__VA_ARGS__); \
214 break; \
215 } \
216 } \
217 }
This file sets the thread priority for the threads running on rusEFI.