Small fixes
This commit is contained in:
parent
4c6adc9c89
commit
dca3a03ab9
@ -195,7 +195,7 @@ bool mpu6000_who_am_i();
|
||||
while(1)
|
||||
{
|
||||
// Read the fifo queue, this returns the number of bytes read
|
||||
int num = mpu6000_read_fifo(&g, dataz);
|
||||
int num = mpu6000_read_fifo(&g, data);
|
||||
|
||||
// if num returned is negative an error has occurred
|
||||
if(num > 0)
|
||||
@ -219,5 +219,6 @@ bool mpu6000_who_am_i();
|
||||
// HAL_Delay(100);
|
||||
// --------------- END ACCELEROMETER TEST ------------
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "drivers/spi.h"
|
||||
|
||||
spi_profile mpu6000_spi_profile;
|
||||
uint8_t num_failed_receive = 0;
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: SPI1_Init initializes the SPI1 instance with predefined values*
|
||||
@ -322,7 +323,7 @@ int mpu6000_read_fifo(gyro_t* gyro, int16_t* data_out)
|
||||
|
||||
|
||||
fifoCount = (uint16_t)((countH << 8) | countL);
|
||||
if (fifoCount == 1024)
|
||||
if (fifoCount == 1024 || num_failed_receive > 20)
|
||||
{
|
||||
reg[0] = MPU_RA_USER_CTRL;
|
||||
reg[1] = BIT_FIFO_RESET;
|
||||
@ -337,7 +338,12 @@ int mpu6000_read_fifo(gyro_t* gyro, int16_t* data_out)
|
||||
}
|
||||
|
||||
if (fifoCount < 6)
|
||||
{
|
||||
num_failed_receive++;
|
||||
return -3;
|
||||
}
|
||||
else
|
||||
num_failed_receive = 0;
|
||||
|
||||
/* Make sure that only complete sets of gyro data are read */
|
||||
bytesRead = (fifoCount/6)*6;
|
||||
|
@ -69,7 +69,7 @@ bool spi_init(SPI_TypeDef *spi_instance, // The spi instance to be used i.e. SPI
|
||||
gpioInit.Pin = out_profile->spi_nss;
|
||||
gpioInit.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpioInit.Pull = GPIO_PULLUP;
|
||||
gpioInit.Speed = GPIO_SPEED_LOW;
|
||||
gpioInit.Speed = GPIO_SPEED_HIGH;
|
||||
gpioInit.Alternate = 0;
|
||||
HAL_GPIO_Init(out_profile->spi_nss_port, &gpioInit);
|
||||
|
||||
@ -81,7 +81,7 @@ bool spi_init(SPI_TypeDef *spi_instance, // The spi instance to be used i.e. SPI
|
||||
gpioInit.Pin = spi_miso | spi_mosi | spi_sck;
|
||||
gpioInit.Mode = GPIO_MODE_AF_PP;
|
||||
gpioInit.Pull = GPIO_NOPULL;
|
||||
gpioInit.Speed = GPIO_SPEED_LOW;
|
||||
gpioInit.Speed = GPIO_SPEED_HIGH;
|
||||
gpioInit.Alternate = spi_af;
|
||||
HAL_GPIO_Init(spi_miso_port, &gpioInit);
|
||||
|
||||
@ -123,10 +123,6 @@ bool spi_transmit(spi_profile *profile,
|
||||
{
|
||||
HAL_StatusTypeDef err; /* SPI transmission status variable */
|
||||
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
|
||||
// err = HAL_SPI_Transmit(profile->profile, data, 2, 10);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
|
||||
|
||||
// Tell the selected slave that the data is intended for him/her (hen)
|
||||
HAL_GPIO_WritePin(profile->spi_nss_port, profile->spi_nss, GPIO_PIN_RESET);
|
||||
// Send the data
|
||||
|
@ -14,7 +14,7 @@
|
||||
static uint32_t usTicks = 0;
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: Starts the system clock at 100MHz *
|
||||
* BRIEF: Starts the system clock at 144MHz *
|
||||
* INFORMATION: In the current version it works with ADC and DMA *
|
||||
***********************************************************************/
|
||||
void system_clock_config(void)
|
||||
|
Reference in New Issue
Block a user