Changeset - 851511077b87
[Not reviewed]
default
0 4 0
Ethan Zonca (ethanzonca) - 9 years ago 2017-01-03 15:13:32
e@ethanzonca.com
Fix issue where miso was never initted
4 files changed with 7 insertions and 10 deletions:
0 comments (0 inline, 0 general)
Libraries/Si446x/si446x.c
Show inline comments
 
@@ -218,13 +218,13 @@ void si446x_sendcmd(uint8_t tx_len, uint
 
    	return;
 
    }
 
 
    // 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)
 
    {
 
    	SI446x_DESELECT;
 
    	return;
 
    }
 
@@ -240,13 +240,13 @@ void si446x_sendcmd(uint8_t tx_len, uint
 
 
		int reply = 0x00;
 
		uint8_t tx_requestack[2];
 
		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)
 
		{
 
			// Attempt to receive two bytes from the Si446x which should be an ACK
 
			uint8_t tmprx[2] = {0,0};
 
@@ -270,12 +270,13 @@ void si446x_sendcmd(uint8_t tx_len, uint
 
			}
 
 
			// Maximum number of attempts exceeded
 
			if(attempts > 1024)
 
			{
 
				//error_assert_silent(ERR_VHF_TIMEOUT);
 
				volatile uint32_t test = 344;
 
				break; // Break out, deinit and exit
 
			}
 
			attempts++;
 
		}
 
    }
 
 
@@ -375,13 +376,13 @@ static void __init_spi1(void)
 
	GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
 
	HAL_GPIO_Init(SI446x_CS_PORT, &GPIO_InitStruct);
 
	SI446x_DESELECT;
 
 
	// 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;
 
	GPIO_InitStruct.Alternate = GPIO_AF0_SPI1;
 
	HAL_GPIO_Init(SI446x_SCK_PORT, &GPIO_InitStruct);
 
 
@@ -392,13 +393,13 @@ static void __init_spi1(void)
 
	hspi1.Init.Direction = SPI_DIRECTION_2LINES;
 
 
	hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
 
	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;
 
	hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLED;
 
	HAL_SPI_Init(&hspi1);
 
}
Libraries/Si446x/si446x.h
Show inline comments
 
@@ -4,13 +4,13 @@
 
#include "stm32f0xx_hal.h"
 
 
 
// Hardware Options ///////////////////
 
 
// Timeout for blocking writes
 
#define SI446x_TIMEOUT 10
 
#define SI446x_TIMEOUT 50
 
 
// Crystal/oscillator frequency
 
#define SI446x_VCXO_FREQ  26000000UL
 
#define SI446x_SPI SPI1
 
 
// GPIO assignments
Libraries/aprs/afsk.c
Show inline comments
 
@@ -272,16 +272,12 @@ void afsk_start(void)
 
	phasedelta = PHASE_DELTA_1200;
 
	phase = 0;
 
	packet_pos = 0;
 
	current_sample_in_baud = 0;
 
	go = 1;
 

	
 
    // Wake up and configure radio
 
    //si446x_prepare();
 
    HAL_Delay(100);
 

	
 
	// Key the radio
 
	si446x_cw_on();
 

	
 
	// Start transmission
 
	afsk_timer_start();
 
}
Source/main.c
Show inline comments
 
@@ -30,13 +30,13 @@ int main(void)
 
  // Software timers
 
  uint32_t last_led = HAL_GetTick();
 
 
  while (1)
 
  {
 
	  // Blink LEDs
 
	  if(HAL_GetTick() - last_led > 1500)
 
	  if(HAL_GetTick() - last_led > 50)
 
	  {
 
		  gps_update_data();
 
		  aprs_send();
 
		  while(afsk_busy());
 
 
		  last_led = HAL_GetTick();
0 comments (0 inline, 0 general)