rusefi/firmware/hw_layer/hardware.h

67 lines
1.9 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/*
2016-07-17 00:01:48 -07:00
* @file hardware.h
2015-07-10 06:01:56 -07:00
*
* @date May 27, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2020-02-18 05:16:19 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
// 'startHardware' is invoked both on boot and configuration change
void startHardware();
void stopHardware();
2019-04-12 17:52:51 -07:00
#if HAL_USE_SPI
2015-07-10 06:01:56 -07:00
// Peripherial Clock 42MHz SPI2 SPI3
// Peripherial Clock 84MHz SPI1 SPI1 SPI2/3
// 42 MHz 21 MHZ
#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
// 21 MHz 10.5 MHz
#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
// 10.5 MHz 5.25 MHz
#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
// 5.25 MHz 2.626 MHz
#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
// 2.626 MHz 1.3125 MHz
#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
// 1.3125 MHz 656.25 KHz
#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
// 656.25 KHz 328.125 KHz
#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
// 328.125 KHz 164.06 KHz
#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
2019-03-25 19:41:31 -07:00
int getSpiPrescaler(spi_speed_e speed, spi_device_e device);
2023-08-30 20:59:40 -07:00
SPIDriver * getSpiDevice(spi_device_e spiDevice);
2015-07-10 06:01:56 -07:00
void turnOnSpi(spi_device_e device);
void lockSpi(spi_device_e device);
2020-08-02 14:58:57 -07:00
void unlockSpi(spi_device_e device);
2015-07-10 19:01:50 -07:00
brain_pin_e getMisoPin(spi_device_e device);
brain_pin_e getMosiPin(spi_device_e device);
brain_pin_e getSckPin(spi_device_e device);
2015-07-10 06:01:56 -07:00
void printSpiConfig(const char *msg, spi_device_e device);
2015-07-10 06:01:56 -07:00
#endif /* HAL_USE_SPI */
void applyNewHardwareSettings();
// Initialize hardware that doesn't require configuration to be loaded
void initHardwareNoConfig();
// Initialize hardware with configuration loaded
void initHardware();
2021-07-14 19:37:05 -07:00
2023-12-12 14:02:56 -08:00
void checkLastResetCause();
2023-09-25 09:43:48 -07:00
// todo: can we do simpler here? move conditional compilation into debounce.h?
2021-07-14 19:37:05 -07:00
#if EFI_PROD_CODE
#include "debounce.h"
2023-09-25 09:43:48 -07:00
#else
class ButtonDebounce;
2015-07-10 06:01:56 -07:00
#endif /* EFI_PROD_CODE */
2017-02-14 18:01:56 -08:00
void setBor(int borValue);