diff --git a/Libraries/Si446x/si446x.c b/Libraries/Si446x/si446x.c --- a/Libraries/Si446x/si446x.c +++ b/Libraries/Si446x/si446x.c @@ -221,7 +221,7 @@ void si446x_sendcmd(uint8_t tx_len, uint // using transmit receive to transmit data because it actually blocks until the data is sent // an additional byte is added on to the transmission so we can receive the CTS byte - HAL_StatusTypeDef res = HAL_SPI_TransmitReceive(&hspi1, data, dummyrx, tx_len+1, SI446x_TIMEOUT); + volatile HAL_StatusTypeDef res = HAL_SPI_TransmitReceive(&hspi1, data, dummyrx, tx_len+1, SI446x_TIMEOUT); if(res != HAL_OK) { @@ -243,7 +243,7 @@ void si446x_sendcmd(uint8_t tx_len, uint tx_requestack[0] = SI446x_CMD_READ_CMD_BUFF; tx_requestack[1] = 0x00; - uint16_t attempts = 0; + volatile uint16_t attempts = 0; // Keep trying receive until it returns 0xFF (successful ACK) while (reply != 0xFF) @@ -273,6 +273,7 @@ void si446x_sendcmd(uint8_t tx_len, uint if(attempts > 1024) { //error_assert_silent(ERR_VHF_TIMEOUT); + volatile uint32_t test = 344; break; // Break out, deinit and exit } attempts++; @@ -378,7 +379,7 @@ static void __init_spi1(void) // SPI pins __SPI1_CLK_ENABLE(); - GPIO_InitStruct.Pin = SI446x_SCK_PIN|SI446x_MOSI_PIN|SI446x_MOSI_PIN; + GPIO_InitStruct.Pin = SI446x_SCK_PIN|SI446x_MOSI_PIN|SI446x_MISO_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; @@ -395,7 +396,7 @@ static void __init_spi1(void) hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; // Double-check, this is usually high, but might be low for this chip hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; // was 1edge before (rising edge of clock) hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLED; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;