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; diff --git a/Libraries/Si446x/si446x.h b/Libraries/Si446x/si446x.h --- a/Libraries/Si446x/si446x.h +++ b/Libraries/Si446x/si446x.h @@ -7,7 +7,7 @@ // Hardware Options /////////////////// // Timeout for blocking writes -#define SI446x_TIMEOUT 10 +#define SI446x_TIMEOUT 50 // Crystal/oscillator frequency #define SI446x_VCXO_FREQ 26000000UL diff --git a/Libraries/aprs/afsk.c b/Libraries/aprs/afsk.c --- a/Libraries/aprs/afsk.c +++ b/Libraries/aprs/afsk.c @@ -275,10 +275,6 @@ void afsk_start(void) current_sample_in_baud = 0; go = 1; - // Wake up and configure radio - //si446x_prepare(); - HAL_Delay(100); - // Key the radio si446x_cw_on(); diff --git a/Source/main.c b/Source/main.c --- a/Source/main.c +++ b/Source/main.c @@ -33,7 +33,7 @@ int main(void) while (1) { // Blink LEDs - if(HAL_GetTick() - last_led > 1500) + if(HAL_GetTick() - last_led > 50) { gps_update_data(); aprs_send();