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
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void startHardware();
|
|
|
|
void stopHardware();
|
2021-07-14 22:28:44 -07:00
|
|
|
|
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);
|
|
|
|
|
2019-04-04 16:29:33 -07:00
|
|
|
EXTERNC 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
|
|
|
|
|
|
|
#endif /* HAL_USE_SPI */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void applyNewHardwareSettings();
|
2021-03-25 13:22:03 -07:00
|
|
|
|
|
|
|
// Initialize hardware that doesn't require configuration to be loaded
|
2021-11-16 01:15:29 -08:00
|
|
|
void initHardwareNoConfig();
|
2021-03-25 13:22:03 -07:00
|
|
|
|
|
|
|
// Initialize hardware with configuration loaded
|
2021-11-16 01:15:29 -08:00
|
|
|
void initHardware();
|
2021-07-14 19:37:05 -07:00
|
|
|
|
|
|
|
#if EFI_PROD_CODE
|
|
|
|
#include "debounce.h"
|
2021-03-25 13:22:03 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_PROD_CODE */
|
|
|
|
|
2017-02-14 18:01:56 -08:00
|
|
|
void showBor(void);
|
|
|
|
void setBor(int borValue);
|
|
|
|
|
2020-09-08 08:29:38 -07:00
|
|
|
class ButtonDebounce;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-09-08 08:29:38 -07:00
|
|
|
#endif /* __cplusplus */
|