Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/flight_controller/inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extern volatile uint32_t rfCustomReplyBufferPointerSent;

extern volatile int headerToWrite;
extern volatile int headerWritten;
extern volatile int julian;
extern volatile int julian, bob;
extern volatile float bear[];

extern char *CleanupNumberString(char *inString);
Expand Down
8 changes: 7 additions & 1 deletion src/flight_controller/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ volatile uint32_t configSize = 0;
volatile int headerWritten;
volatile int headerToWrite;
volatile int julian = -99;
volatile int bob = -99;
volatile float bear[3] = {0.0f,};

extern biquad_state kdBqFilterState[];
Expand Down Expand Up @@ -1161,7 +1162,7 @@ void ProcessCommand(char *inString)
else if (!strcmp("error", inString))
{

snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "%li %lu %lu\n", deviceWhoAmI, errorMask, failsafeHappend);RfCustomReplyBuffer(rf_custom_out_buffer);
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "%lu %lu %lu\n", deviceWhoAmI, errorMask, failsafeHappend);RfCustomReplyBuffer(rf_custom_out_buffer);
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "ba:%lu\n", armingStructure.boardArmed);RfCustomReplyBuffer(rf_custom_out_buffer);
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "lfa:%lu\n", armingStructure.latchFirstArm);RfCustomReplyBuffer(rf_custom_out_buffer);
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "ams:%lu\n", armingStructure.armModeSet);RfCustomReplyBuffer(rf_custom_out_buffer);
Expand Down Expand Up @@ -2050,6 +2051,11 @@ void ProcessCommand(char *inString)
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "#me Goes Pro!! %i\n", julian);
RfCustomReplyBuffer(rf_custom_out_buffer);
}
else if (!strcmp("bob", inString))
{
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "#me Goes Pro!! %i\n", bob);
RfCustomReplyBuffer(rf_custom_out_buffer);
}
else if (!strcmp("bear", inString))
{
snprintf(rf_custom_out_buffer, RF_BUFFER_SIZE, "#me BARELY!! %i, %i, %i\n", (int)(bear[0]*10000), (int)(bear[1]*10000), (int)(bear[2]*10000));
Expand Down
12 changes: 12 additions & 0 deletions src/flight_controller/src/drivers/flash_chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ int FindFirstEmptyPage(void)
uint32_t allFFsTotal = 0;
uint32_t firstEmptySector;

//TEST: force always off
flashInfo.currentWriteAddress = 0;
flashInfo.enabled = FLASH_FULL;
return (0);

//TEST: force always on
flashInfo.enabled = STAT_FLASH_ENABLED;
flashInfo.currentWriteAddress = 0;
return (1);

//find first empty sector
for (x = 0; x < flashInfo.totalSize; x = x + (flashInfo.pageSize * flashInfo.pagesPerSector) )
{
Expand Down Expand Up @@ -427,6 +437,8 @@ int InitFlashChip(void)
int flashReturn;
//TODO: Allow working with multiple flash chips

//TESTING
return 0;
//TODO: Check for DMA conflicts
if (board.dmasSpi[board.spis[board.flash[0].spiNumber].RXDma].enabled)
{
Expand Down
32 changes: 20 additions & 12 deletions src/flight_controller/src/drivers/maxOsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,10 @@ int CheckForVideoSignal(void)

//maxOsdRecord.commandStatus = OSD_COMMAND_STATUS_SPI_SENDING_DMA_VIDEO_TYPE;

julian++;
spiReturnData = MaxSendReceiveCommand(MAX7456ADD_STAT, 0xFF, 1, 1);
bob = spiReturnData;

if (3 & spiReturnData)
{
//video found!
Expand Down Expand Up @@ -2272,8 +2275,8 @@ int HandleMaxOsd(void)
{

//disabled for now
return(0);
if (InlineMillis() - lastTimeRun > 100)
//return(0);
if (InlineMillis() - lastTimeRun < 10)
return(0);

if ( (maxOsdRecord.type == OSD_TYPE_SPI) && (maxOsdRecord.videoMode == VIDEO_MODE_UNKNOWN) )
Expand Down Expand Up @@ -2301,7 +2304,7 @@ int HandleMaxOsd(void)
int InitMaxOsd(void)
{

return(0);
//return(0);
int x; //set
uint8_t spiReturnData; //set

Expand Down Expand Up @@ -2414,18 +2417,23 @@ static void DrawScreen(void)

if (bufferLength)
{
if (HAL_DMA_GetState(&dmaHandles[board.dmasActive[board.spis[board.maxOsd[0].spiNumber].TXDma].dmaHandle]) == HAL_DMA_STATE_READY && HAL_SPI_GetState(&spiHandles[board.spis[board.maxOsd[0].spiNumber].spiHandle]) == HAL_SPI_STATE_READY)
{
//if (HAL_DMA_GetState(&dmaHandles[board.dmasActive[board.spis[board.maxOsd[0].spiNumber].TXDma].dmaHandle]) == HAL_DMA_STATE_READY && HAL_SPI_GetState(&spiHandles[board.spis[board.maxOsd[0].spiNumber].spiHandle]) == HAL_SPI_STATE_READY)
//{
//callback function is free to use, set callback.
if(callbackFunctionArray[MAX_OSD_TX_DMA_FP] == NULL)
{
callbackFunctionArray[MAX_OSD_TX_DMA_FP] = FlashDmaRxCallback;
maxOsdRecord.commandStatus = OSD_COMMAND_STATUS_SPI_SENDING_DMA;
// if(callbackFunctionArray[MAX_OSD_TX_DMA_FP] == NULL)
// {
// callbackFunctionArray[MAX_OSD_TX_DMA_FP] = FlashDmaRxCallback;
maxOsdRecord.commandStatus = OSD_COMMAND_STATUS_SPI_SENDING_BLK;
//maxOsdRecord.commandStatus = OSD_COMMAND_STATUS_SPI_SENDING_DMA;
inlineDigitalLo(ports[board.maxOsd[0].csPort], board.maxOsd[0].csPin);
HAL_SPI_TransmitReceive_DMA(&spiHandles[board.spis[board.maxOsd[0].spiNumber].spiHandle], txBuffer, rxBuffer, bufferLength);
HAL_SPI_TransmitReceive(&spiHandles[board.spis[board.maxOsd[0].spiNumber].spiHandle], txBuffer, rxBuffer, bufferLength, 500);
inlineDigitalHi(ports[board.maxOsd[0].csPort], board.maxOsd[0].csPin);
maxOsdRecord.commandStatus = OSD_COMMAND_STATUS_IDLE;

//HAL_SPI_TransmitReceive_DMA(&spiHandles[board.spis[board.maxOsd[0].spiNumber].spiHandle], txBuffer, rxBuffer, bufferLength);
lastTimeRun = InlineMillis();
}
}
// }
//}
}

}
Expand Down
8 changes: 6 additions & 2 deletions src/flight_controller/src/drivers/spring_bus_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void DeInitGyroExti(void)

void InitGyroExti(void)
{
EXTI_Init(ports[board.gyros[0].extiPort], board.gyros[0].extiPin, board.gyros[0].extiIRQn, 2, 0, GPIO_MODE_IT_RISING, GPIO_PULLUP);
EXTI_Init(ports[board.gyros[0].extiPort], board.gyros[0].extiPin, board.gyros[0].extiIRQn, 2, 0, GPIO_MODE_IT_RISING, GPIO_PULLDOWN);
}

void AccGyroDeinit(void)
Expand Down Expand Up @@ -104,17 +104,21 @@ uint32_t AccGyroInit(loopCtrl_e loopCtrl)
if (!AccGyroDeviceDetect())
{
//make sure IMU is a known version
deviceWhoAmI = 6660;
return 0; //testing
}

if (!AccGyroDeviceInit(loopCtrl)) {
deviceWhoAmI = 6661;
return 0; //testing
}

//goto TESTI; //testing
SPI_Init(board.gyros[0].spiFastBaud);
if (board.gyros[0].spiSlowBaud != board.gyros[0].spiFastBaud)
SPI_Init(board.gyros[0].spiFastBaud);

// after the gyro is started, start up the interrupt
DeInitializeGpio(ports[board.gyros[0].extiPort], board.gyros[0].extiPin);
InitGyroExti();

skipGyro = 0;
Expand Down
13 changes: 9 additions & 4 deletions src/flight_controller/src/drivers/spring_imuf9001.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define IMUF_COMMAND_HEADER 'h'
#define IMUF_COMMAND_RST '13'

static const uint16_t imufCurrentVersion = 105;
static const uint16_t imufCurrentVersion = 106;

volatile gyroToBoardCommMode_t currentCommMode;

Expand Down Expand Up @@ -236,7 +236,7 @@ int AccGyroDeviceInit(loopCtrl_e gyroLoop)
data.param5 = ( ( (uint16_t)mainConfig.tuneProfile[activeProfile].filterConfig[YAW].gyro.q) << 16 ) | (uint16_t)mainConfig.tuneProfile[activeProfile].filterConfig[YAW].gyro.w;
data.param6 = ( ( (uint16_t)mainConfig.tuneProfile[activeProfile].filterConfig[PITCH].gyro.lpf) << 16 ) | (uint16_t)mainConfig.tuneProfile[activeProfile].filterConfig[ROLL].gyro.lpf;
data.param7 = ( ( (uint16_t)mainConfig.tuneProfile[activeProfile].filterConfig[YAW].gyro.lpf) << 16 ) | 0;
data.param8 = ( (int16_t)mainConfig.gyroConfig.minorBoardRotation[X] << 16 ) | mainConfig.gyroConfig.gyroRotation;
data.param8 = ( (int16_t)mainConfig.gyroConfig.minorBoardRotation[X] << 16 ) | (uint16_t)mainConfig.gyroConfig.gyroRotation;
data.param9 = ( (int16_t)mainConfig.gyroConfig.minorBoardRotation[Z] << 16 ) | (int16_t)mainConfig.gyroConfig.minorBoardRotation[Y];

for (attempt = 0; attempt < 4; attempt++)
Expand Down Expand Up @@ -298,8 +298,10 @@ int AccGyroDeviceDetect(void)
RtcWriteBackupRegister(RFBL_BKR_BOOT_ADDRESSS_REG, UPT_ADDRESS);
DelayMs(500);
SystemReset();
deviceWhoAmI = 6662;
} else {
return (*(imufVersion_t *)&(reply.param1)).firmware;
deviceWhoAmI = (*(imufVersion_t *)&(reply.param1)).firmware;
return deviceWhoAmI;
}
}
}
Expand Down Expand Up @@ -333,8 +335,11 @@ void ImuDeviceReadComplete(void)
inlineDigitalHi(ports[board.gyros[0].csPort], board.gyros[0].csPin);
if ( (currentCommMode == GTBCM_GYRO_ACC_FILTER_F) || (currentCommMode == GTBCM_GYRO_ACC_QUAT_FILTER_F))
{
volatile uint32_t crc1 = ((*(uint32_t *)(&imuRxCommFrame.gyroFrame+mainConfig.gyroConfig.imufMode-4)) & 0xFF);
volatile uint32_t crc1 = ((*(uint32_t *)(&imuRxCommFrame.gyroFrame + mainConfig.gyroConfig.imufMode-4)) & 0xFF);
volatile uint32_t crc2 = (HAL_CRC_Calculate(&CrcHandle, (uint32_t *)(&imuRxCommFrame.gyroFrame), (mainConfig.gyroConfig.imufMode >> 2)-1) & 0xFF);
//volatile uint32_t crc1 = ( (*(uint32_t *)(dmaRxBuffer+gyroConfig()->imuf_mode-4)) & 0xFF );
//volatile uint32_t crc2 = ( getCrcImuf9001((uint32_t *)(dmaRxBuffer), (gyroConfig()->imuf_mode >> 2)-1) & 0xFF );
crc1 = crc2 = 1;
if(
crc1 != crc2
)
Expand Down
2 changes: 2 additions & 0 deletions src/flight_controller/src/flight_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ void UpdateBlackbox(pid_output flightPids[], float flightSetPoints[], float dpsG
(void)(filteredAccData);
#endif

//TEST: force always on, start logging after 4 seconds
if ( (mainConfig.rcControlsConfig.rcCalibrated) && (boardArmed) && (ModeActive(M_LOGGING)) && (flashInfo.enabled == STAT_FLASH_ENABLED) )
//if ( 1 )
//if ( InlineMillis() > 4 )
{
ledStatus.status = LEDS_FASTER_BLINK;
LoggingEnabled = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/low_level_driver/HELIO_SPRING.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@
#define MAX_OSD_SPI_MOSI_AF SPI3_MOSI_AF
#define MAX_OSD_TX_DMA_FP FP_DMA1_S7

#define MAX_OSD_SPI_FAST_BAUD SPI_BAUDRATEPRESCALER_4
#define MAX_OSD_SPI_SLOW_BAUD SPI_BAUDRATEPRESCALER_4
#define MAX_OSD_SPI_FAST_BAUD SPI_BAUDRATEPRESCALER_8
#define MAX_OSD_SPI_SLOW_BAUD SPI_BAUDRATEPRESCALER_8

//Flash Config
#define FLASH_ENABLED 1
Expand All @@ -474,5 +474,5 @@
#define FLASH_SPI_MOSI_AF SPI3_MOSI_AF
#define FLASH_RX_DMA_FP FP_DMA1_S7

#define FLASH_SPI_FAST_BAUD SPI_BAUDRATEPRESCALER_4
#define FLASH_SPI_SLOW_BAUD SPI_BAUDRATEPRESCALER_4
#define FLASH_SPI_FAST_BAUD SPI_BAUDRATEPRESCALER_8
#define FLASH_SPI_SLOW_BAUD SPI_BAUDRATEPRESCALER_8