auto-sync
This commit is contained in:
parent
cb0b9b2a4e
commit
53c78eec96
|
@ -44,13 +44,10 @@ static Logging logger;
|
|||
#if EFI_POTENTIOMETER || defined(__DOXYGEN__)
|
||||
Mcp42010Driver config[DIGIPOT_COUNT];
|
||||
|
||||
void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, ioportid_t port, ioportmask_t pin) {
|
||||
driver->spiConfig.end_cb = NULL;
|
||||
driver->spiConfig.ssport = port;
|
||||
driver->spiConfig.sspad = pin;
|
||||
void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, brain_pin_e csPin) {
|
||||
driver->spiConfig.cr1 = SPI_POT_CONFIG;
|
||||
driver->spi = spi;
|
||||
mySetPadMode("pot chip select", port, pin, PAL_STM32_MODE_OUTPUT);
|
||||
initSpiCs(&driver->spiConfig, csPin);
|
||||
}
|
||||
|
||||
static int getPotStep(int resistanceWA) {
|
||||
|
@ -111,7 +108,7 @@ void initPotentiometers(board_configuration_s *boardConfiguration) {
|
|||
}
|
||||
|
||||
initPotentiometer(&config[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice),
|
||||
getHwPort(csPin), getHwPin(csPin));
|
||||
csPin);
|
||||
}
|
||||
|
||||
addConsoleActionII("pot", setPotResistanceCommand);
|
||||
|
|
|
@ -17,7 +17,7 @@ typedef struct {
|
|||
SPIConfig spiConfig;
|
||||
} Mcp42010Driver;
|
||||
|
||||
void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, ioportid_t port, ioportmask_t pin);
|
||||
//void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, ioportid_t port, ioportmask_t pin);
|
||||
void initPotentiometers(board_configuration_s *boardConfiguration);
|
||||
void setPotResistance(Mcp42010Driver *driver, int channel, int resistance);
|
||||
|
||||
|
|
|
@ -289,3 +289,12 @@ SPIDriver * getSpiDevice(spi_device_e spiDevice) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||
spiConfig->end_cb = NULL;
|
||||
ioportid_t port = getHwPort(csPin);
|
||||
ioportmask_t pin = getHwPin(csPin);
|
||||
spiConfig->ssport = port;
|
||||
spiConfig->sspad = pin;
|
||||
mySetPadMode("chip select", port, pin, PAL_STM32_MODE_OUTPUT);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,32 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
// 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)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
SPIDriver * getSpiDevice(spi_device_e spiDevice);
|
||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
|
||||
void turnOnSpi(spi_device_e device);
|
||||
void lockSpi(spi_device_e device);
|
||||
void unlockSpi(void);
|
||||
|
|
|
@ -37,16 +37,4 @@ void adc_in_out(McpAdcState *state);
|
|||
|
||||
int getMcp3208adc(int channel);
|
||||
|
||||
|
||||
// Peripherial Clock 84MHz SPI1 SPI1 SPI2/3
|
||||
// Peripherial Clock 42MHz SPI2 SPI3
|
||||
#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) // 42 MHz 21 MHZ
|
||||
#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz
|
||||
#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) // 10.5 MHz 5.25 MHz
|
||||
#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) // 5.25 MHz 2.626 MHz
|
||||
#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) // 2.626 MHz 1.3125 MHz
|
||||
#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) // 1.3125 MHz 656.25 KHz
|
||||
#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) // 656.25 KHz 328.125 KHz
|
||||
#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) // 328.125 KHz 164.06 KHz
|
||||
|
||||
#endif /* MCP3208_H_ */
|
||||
|
|
|
@ -33,24 +33,6 @@ static THD_WORKING_AREA(tp_MMC_Monitor,UTILITY_THREAD_STACK_SIZE); // MMC monit
|
|||
*/
|
||||
MMCDriver MMCD1;
|
||||
|
||||
// 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)
|
||||
static SPIConfig hs_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
||||
SPI_BaudRatePrescaler_8 };
|
||||
static SPIConfig ls_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
||||
|
|
Loading…
Reference in New Issue