Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI Flash pins on TX16S currently left unconfigured #8365

Closed
rotorman opened this issue Mar 13, 2021 · 2 comments
Closed

SPI Flash pins on TX16S currently left unconfigured #8365

rotorman opened this issue Mar 13, 2021 · 2 comments
Labels

Comments

@rotorman
Copy link
Contributor

rotorman commented Mar 13, 2021

By going through the source code, I noticed the SPI Flash pins on TX16S (PI0 to PI3) are left unconfigured (= inputs and thus floating). The GD25Q127CSIG memory chip is physically populated on the TX16S PCB and connected to STM32F429BI SPI2 SCK, MISO and MOSI pins plus PI0 for the ChipSelect.

The pins are defined here:

#elif defined(PCBX10)
#define EEPROM_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
#define EEPROM_RCC_APB1Periph RCC_APB1Periph_SPI2
#define EEPROM_SPI_CS_GPIO GPIOI
#define EEPROM_SPI_CS_GPIO_PIN GPIO_Pin_0 // PI.00
#define EEPROM_SPI_SCK_GPIO GPIOI
#define EEPROM_SPI_SCK_GPIO_PIN GPIO_Pin_1 // PI.01
#define EEPROM_SPI_SCK_GPIO_PinSource GPIO_PinSource1
#define EEPROM_SPI_MISO_GPIO GPIOI
#define EEPROM_SPI_MISO_GPIO_PIN GPIO_Pin_2 // PI.02
#define EEPROM_SPI_MISO_GPIO_PinSource GPIO_PinSource2
#define EEPROM_SPI_MOSI_GPIO GPIOI
#define EEPROM_SPI_MOSI_GPIO_PIN GPIO_Pin_3 // PI.03
#define EEPROM_SPI_MOSI_GPIO_PinSource GPIO_PinSource3
#endif

but GPIO_Init() is never called for them when building for e.g. TX16S.

IMHO it would be better to minimally configure weak pull-ups, even if the SPI Flash chip is not actively used on TX16S:

  • high for the the chip select (PI0) and SPI2_SCK (PI1) pins and
  • low for SPI2_MOSI (PI3) and SPI2_MISO (PI2)

This is to avoid possible CMOS high current due to floating inputs.

@rotorman rotorman changed the title EEPROM pins on TX16S currently left undefined EEPROM pins on TX16S currently left unconfigured Mar 13, 2021
@rotorman
Copy link
Contributor Author

rotorman commented Mar 14, 2021

By looking at the mainboard PCB images of Jumper T18 and Jumper T16 (in addition to RadioMaster TX16S), I see that the SPI flash chip is present/populated on all.

I am suggesting following additions:

  1. in horus hal.h add following lines:
#define EEPROM_SPI       SPI2
#define EEPROM_SPI_AF    GPIO_AF_SPI2
  1. Add an additional file eeprom_driver.cpp in radio\src\targets\horus with following content:
void eepromInit()
{
  GPIO_InitTypeDef GPIO_InitStructure;
  
  // ChipSelect
  GPIO_InitStructure.GPIO_Pin = EEPROM_SPI_CS_GPIO_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(EEPROM_SPI_CS_GPIO, &GPIO_InitStructure);
  // Set initial state high == disabled
  GPIO_SetBits(EEPROM_SPI_CS_GPIO, EEPROM_SPI_CS_GPIO_PIN);
  
  GPIO_PinAFConfig(EEPROM_SPI_SCK_GPIO, EEPROM_SPI_SCK_GPIO_PinSource, GPIO_AF_SPI2);
  GPIO_PinAFConfig(EEPROM_SPI_MISO_GPIO, EEPROM_SPI_MISO_GPIO_PinSource, GPIO_AF_SPI2);
  GPIO_PinAFConfig(EEPROM_SPI_MOSI_GPIO, EEPROM_SPI_MOSI_GPIO_PinSource, GPIO_AF_SPI2);

  GPIO_InitStructure.GPIO_Pin = EEPROM_SPI_SCK_GPIO_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_Init(EEPROM_SPI_SCK_GPIO, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = EEPROM_SPI_MOSI_GPIO_PIN;
  GPIO_Init(EEPROM_SPI_MOSI_GPIO, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = EEPROM_SPI_MISO_GPIO_PIN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
  GPIO_Init(EEPROM_SPI_MISO_GPIO, &GPIO_InitStructure);

  // SPI configuration
  SPI_I2S_DeInit(EEPROM_SPI);
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; 
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_Init(EEPROM_SPI, &SPI_InitStructure);
  SPI_Cmd(EEPROM_SPI, ENABLE);
}
  1. Add an additional file eeprom_driver.h with following content:
void eepromInit()
  1. Add to horus boardInit():
#if defined(RADIO_FAMILY_T16)
  eepromInit();
#endif

@rotorman rotorman changed the title EEPROM pins on TX16S currently left unconfigured SPI Flash pins on TX16S currently left unconfigured Mar 29, 2021
@stale
Copy link

stale bot commented Oct 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 2, 2021
@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant