Skip to content

Commit

Permalink
Merge branch 'master' into 20231108_BETAFPVF411RX_BMI270
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter authored Mar 28, 2024
2 parents 66778f0 + d743e8e commit 9a593cd
Show file tree
Hide file tree
Showing 71 changed files with 1,541 additions and 746 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ jobs:
echo "outputs.shortsha: ${{ needs.build.outputs.shortsha }}"
echo "outputs.artfact: ${{ needs.build.outputs.artifact }}"
echo "outputs.artfact: ${{ needs.build.outputs.version }}"
echo "NOW=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
continue-on-error: true

- name: download artifacts
Expand All @@ -181,7 +182,7 @@ jobs:
repo: dev-unstable
owner: emuflight
token: ${{ secrets.NC_PAT_EMUF }}
tag: "hex-${{ github.run_number }}"
tag: "${{ env.NOW }}-hex"
draft: true
prerelease: true
allowUpdates: true
Expand Down Expand Up @@ -213,7 +214,7 @@ jobs:
repo: dev-master
owner: emuflight
token: ${{ secrets.NC_PAT_EMUF }}
tag: "hex-${{ github.run_number }}"
tag: "${{ env.NOW }}-hex"
draft: true
prerelease: true
allowUpdates: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct)
/* Get the PLLM value */
pllm = (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wduplicated-branches"
if((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSE)
{
/* Get the I2S source clock value */
Expand All @@ -433,6 +435,7 @@ void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct)
i2sclk = (uint32_t)(((HSI_VALUE / pllm) * plln) / pllr);
}
#endif /* I2S_EXTERNAL_CLOCK_VAL */
#pragma GCC diagnostic pop

/* Compute the Real divider depending on the MCLK output state, with a floating point */
if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
return HAL_ERROR;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wduplicated-branches"
if(huart->Init.HwFlowCtl != UART_HWCONTROL_NONE)
{
/* Check the parameters */
Expand All @@ -258,6 +260,7 @@ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
/* Check the parameters */
assert_param(IS_UART_INSTANCE(huart->Instance));
}
#pragma GCC diagnostic pop

if(huart->gState == HAL_UART_STATE_RESET)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uin
count32b = (len + 3) / 4;
for (i = 0; i < count32b; i++, src += 4)
{
USBx_DFIFO(ch_ep_num) = *((__packed uint32_t *)src);
USBx_DFIFO((uint32_t)ch_ep_num) = *((uint32_t *)src);
}
}
return HAL_OK;
Expand All @@ -843,7 +843,7 @@ void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len)

for ( i = 0; i < count32b; i++, dest += 4 )
{
*(__packed uint32_t *)dest = USBx_DFIFO(0);
*(uint32_t *)dest = USBx_DFIFO(0);

}
return ((void *)dest);
Expand Down
1 change: 1 addition & 0 deletions make/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ COMMON_SRC = \
io/dashboard.c \
io/displayport_max7456.c \
io/displayport_msp.c \
io/displayport_hdzero_osd.c \
io/displayport_oled.c \
io/displayport_srxl.c \
io/displayport_crsf.c \
Expand Down
19 changes: 15 additions & 4 deletions src/main/cms/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
// For VISIBLE*
#include "io/osd.h"
#include "io/rcdevice_cam.h"
#include "pg/vcd.h"

#include "rx/rx.h"

Expand Down Expand Up @@ -329,7 +330,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
buff[0] = 0x0;
if ((p->type == OME_Submenu) && p->func && (p->flags & OPTSTRING)) {
// Special case of sub menu entry with optional value display.
char *str = ((CMSMenuOptFuncPtr)p->func)();
char *str = ((CMSMenuOptFuncPtr)(long)p->func)();
strncpy( buff, str, CMS_DRAW_BUFFER_LEN);
}
strncat(buff, ">", CMS_DRAW_BUFFER_LEN);
Expand Down Expand Up @@ -597,9 +598,19 @@ void cmsMenuOpen(void) {
} else {
smallScreen = false;
linesPerMenuItem = 1;
leftMenuColumn = 2;
#if defined(USE_HDZERO_OSD)
if ((vcdProfile()->video_system == VIDEO_SYSTEM_HD) && (pCurrentDisplay->cols > 30))
{ leftMenuColumn = HDINDENT + 2; }
else
#endif
{ leftMenuColumn = SDINDENT + 2; }
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
rightMenuColumn = pCurrentDisplay->cols - 2;
#if defined(USE_HDZERO_OSD)
if ((vcdProfile()->video_system == VIDEO_SYSTEM_HD) && (pCurrentDisplay->cols > 30))
{ rightMenuColumn = pCurrentDisplay->cols - 2 - HDINDENT; }
else
#endif
{ rightMenuColumn = pCurrentDisplay->cols - 2; }
#else
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
#endif
Expand Down Expand Up @@ -634,7 +645,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr) {
currentCtx.menu = NULL;
if (exitType == CMS_EXIT_SAVEREBOOT) {
displayClearScreen(pDisplay);
displayWrite(pDisplay, 5, 3, "REBOOTING...");
displayWrite(pDisplay, (pCurrentDisplay->cols % 2) - 6, 3, "REBOOTING...");
displayResync(pDisplay); // Was max7456RefreshAll(); why at this timing?
stopMotors();
stopPwmAllMotors();
Expand Down
2 changes: 1 addition & 1 deletion src/main/cms/cms_menu_blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) {
return 0;
}
displayClearScreen(pDisplay);
displayWrite(pDisplay, 5, 3, "ERASING FLASH...");
displayWrite(pDisplay, (pCurrentDisplay->cols % 2) - 7, 3, "ERASING FLASH...");
displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing?
flashfsEraseCompletely();
while (!flashfsIsReady()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/cms/cms_menu_vtx_smartaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ static OSD_Entry saCmsMenuConfigEntries[] = {
{ "OP MODEL", OME_TAB, saCmsConfigOpmodelByGvar, &(OSD_TAB_t){ &saCmsOpmodel, 2, saCmsOpmodelNames }, DYNAMIC },
{ "FSEL MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFselMode, DYNAMIC },
{ "PIT FMODE", OME_TAB, saCmsConfigPitFModeByGvar, &saCmsEntPitFMode, 0 },
{ "POR FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsORFreqGetString, &saCmsMenuPORFreq, OPTSTRING },
{ "POR FREQ", OME_Submenu, (CMSEntryFuncPtr)(long)saCmsORFreqGetString, &saCmsMenuPORFreq, OPTSTRING },
#ifdef USE_EXTENDED_CMS_MENUS
{ "STATX", OME_Submenu, cmsMenuChange, &saCmsMenuStats, 0 },
#endif /* USE_EXTENDED_CMS_MENUS */
Expand Down Expand Up @@ -534,7 +534,7 @@ static OSD_Entry saCmsMenuFreqModeEntries[] = {
{ "- SMARTAUDIO -", OME_Label, NULL, NULL, 0 },

{ "", OME_Label, NULL, saCmsStatusString, DYNAMIC },
{ "FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsUserFreqGetString, &saCmsMenuUserFreq, OPTSTRING },
{ "FREQ", OME_Submenu, (CMSEntryFuncPtr)(long)saCmsUserFreqGetString, &saCmsMenuUserFreq, OPTSTRING },
{ "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 },
{ "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 },
{ "CONFIG", OME_Submenu, cmsMenuChange, &saCmsMenuConfig, 0 },
Expand Down
50 changes: 50 additions & 0 deletions src/main/common/bitarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,53 @@ void bitArrayCopy(void *array, unsigned from, unsigned to) {
bitArrayClr(array, to);
}
}

void bitArrayClrAll(bitarrayElement_t *array, size_t size)
{
memset(array, 0, size);
}

__attribute__((always_inline)) static inline uint8_t __CTZ(uint32_t val)
{
// __builtin_ctz is not defined for zero, since it's arch
// dependant. However, in ARM it gets translated to a
// rbit and then a clz, making it return 32 for zero on ARM.
// For other architectures, explicitely implement the same
// semantics.
#ifdef __arm__
uint8_t zc;
__asm__ volatile ("rbit %1, %1\n\t"
"clz %0, %1"
: "=r" (zc)
: "r" (val) );
return zc;
#else
// __builtin_clz is not defined for zero, since it's arch
// dependant. Make it return 32 like ARM's CLZ.
return val ? __builtin_ctz(val) : 32;
#endif
}

int bitArrayFindFirstSet(const bitarrayElement_t *array, unsigned start, size_t size)
{
const uint32_t *ptr = (uint32_t*)array;
const uint32_t *end = ptr + (size / 4);
const uint32_t *p = ptr + start / (8 * 4);

if (p < end) {
int ret;
// First iteration might need to mask some bits
uint32_t mask = 0xFFFFFFFF << (start % (8 * 4));
if ((ret = __CTZ(*p & mask)) != 32) {
return (((char *)p) - ((char *)ptr)) * 8 + ret;
}
p++;
while (p < end) {
if ((ret = __CTZ(*p)) != 32) {
return (((char *)p) - ((char *)ptr)) * 8 + ret;
}
p++;
}
}
return -1;
}
13 changes: 13 additions & 0 deletions src/main/common/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@

#pragma once

typedef uint32_t bitarrayElement_t;

bool bitArrayGet(const void *array, unsigned bit);
void bitArraySet(void *array, unsigned bit);
void bitArrayClr(void *array, unsigned bit);
void bitArrayXor(void *dest, size_t size, void *op1, void *op2);
void bitArrayCopy(void *array, unsigned from, unsigned to);
void bitArrayClrAll(bitarrayElement_t *array, size_t size);
// Returns the first set bit with pos >= start_bit, or -1 if all bits
// are zero. Note that size must indicate the size of array in bytes.
// In most cases, you should use the BITARRAY_FIND_FIRST_SET() macro
// to call this function.
int bitArrayFindFirstSet(const bitarrayElement_t *array, unsigned start_bit, size_t size);

#define BITARRAY_DECLARE(name, bits) bitarrayElement_t name[(bits + 31) / 32]
#define BITARRAY_SET_ALL(array) bitArraySetAll(array, sizeof(array))
#define BITARRAY_CLR_ALL(array) bitArrayClrAll(array, sizeof(array))
#define BITARRAY_FIND_FIRST_SET(array, start_bit) bitArrayFindFirstSet(array, start_bit, sizeof(array))
5 changes: 4 additions & 1 deletion src/main/drivers/beesign.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ static uint8_t beesignCRC(const beesign_frame_t *pPackage) {
return crc;
}

// compiler reports unused
/*
static uint8_t beesignChkID(uint8_t id) {
UNUSED(id);
return BEESIGN_OK;
}
*/

uint8_t beesignReceive(uint8_t **pRcvFrame) {
if (!receiveFrameValid) {
Expand Down Expand Up @@ -608,7 +611,7 @@ bool checkBeesignSerialPort(void) {

void beesignUpdate(timeUs_t currentTimeUs) {
UNUSED(currentTimeUs);
if (checkBeesignSerialPort) {
if (checkBeesignSerialPort()) {
#ifdef USE_OSD_BEESIGN
static uint32_t beesignTaskCounter = 0;
static uint32_t beesignSendNextCounterPoint = 0;
Expand Down
11 changes: 11 additions & 0 deletions src/main/drivers/display_font_metadata.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "drivers/display_font_metadata.h"
#include "drivers/osd.h"

bool displayFontMetadataUpdateFromCharacter(displayFontMetadata_t *metadata, const osdCharacter_t *chr)
{
if (chr && FONT_CHR_IS_METADATA(chr)) {
metadata->version = chr->data[5];
return true;
}
return false;
}
24 changes: 24 additions & 0 deletions src/main/drivers/display_font_metadata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <stdbool.h>
#include <stdint.h>

typedef struct osdCharacter_s osdCharacter_t;

typedef struct displayFontMetadata_s {
uint8_t version;
uint16_t charCount;
} displayFontMetadata_t;

// 'E', 'M', 'U', 'F'
#define FONT_CHR_IS_METADATA(chr) ((chr)->data[0] == 'E' && \
(chr)->data[1] == 'M' && \
(chr)->data[2] == 'U' && \
(chr)->data[3] == 'F')

#define FONT_METADATA_CHR_INDEX 255
// Used for runtime detection of display drivers that might
// support 256 or 512 characters.
#define FONT_METADATA_CHR_INDEX_2ND_PAGE 256

bool displayFontMetadataUpdateFromCharacter(displayFontMetadata_t *metadata, const osdCharacter_t *chr);
2 changes: 1 addition & 1 deletion src/main/drivers/serial_softserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ uint32_t softSerialTxBytesFree(const serialPort_t *instance) {
return 0;
}
softSerial_t *s = (softSerial_t *)instance;
uint8_t bytesUsed = (s->port.txBufferHead - s->port.txBufferTail) & (s->port.txBufferSize - 1);
uint32_t bytesUsed = (s->port.txBufferHead - s->port.txBufferTail) & (s->port.txBufferSize - 1);
return (s->port.txBufferSize - 1) - bytesUsed;
}

Expand Down
24 changes: 19 additions & 5 deletions src/main/fc/fc_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#include "rx/spektrum.h"

#include "io/beeper.h"
#include "io/displayport_hdzero_osd.h"
#include "io/displayport_max7456.h"
#include "io/displayport_srxl.h"
#include "io/serial.h"
Expand Down Expand Up @@ -508,12 +509,25 @@ void init(void) {
if (feature(FEATURE_OSD)) {
#if defined(USE_OSD_BEESIGN)
// If there is a beesign for the OSD then use it
osdDisplayPort = beesignDisplayPortInit(vcdProfile());
#elif defined(USE_MAX7456)
if (!osdDisplayPort) {
osdDisplayPort = beesignDisplayPortInit(vcdProfile());
}
#endif
#if defined(USE_HDZERO_OSD)
if (!osdDisplayPort) {
osdDisplayPort = hdzeroOsdDisplayPortInit();
}
#endif
#if defined(USE_MAX7456)
// If there is a max7456 chip for the OSD then use it
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
#elif defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT) // OSD over MSP; not supported (yet)
osdDisplayPort = displayPortMspInit();
if (!osdDisplayPort) {
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
}
#endif
#if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT) // OSD over MSP; not supported (yet)
if (!osdDisplayPort) {
osdDisplayPort = displayPortMspInit();
}
#endif
// osdInit will register with CMS by itself.
osdInit(osdDisplayPort);
Expand Down
6 changes: 6 additions & 0 deletions src/main/fc/fc_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/osd.h"
#include "io/displayport_hdzero_osd.h"
#include "io/piniobox.h"
#include "io/serial.h"
#include "io/transponder_ir.h"
Expand Down Expand Up @@ -159,6 +160,11 @@ static void taskHandleSerial(timeUs_t currentTimeUs) {
bool evaluateMspData = osdSlaveIsLocked ? MSP_SKIP_NON_MSP_DATA : MSP_EVALUATE_NON_MSP_DATA;;
#endif
mspSerialProcess(evaluateMspData, mspFcProcessCommand, mspFcProcessReply);

#ifdef USE_HDZERO_OSD
// Capture HDZero messages to determine if VTX is connected
hdzeroOsdSerialProcess(mspFcProcessCommand);
#endif
}

static void taskBatteryAlerts(timeUs_t currentTimeUs) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/interface/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ static void cliSerial(char *cmdline) {
ptr = nextArg(ptr);
if (ptr) {
val = atoi(ptr);
portConfig.functionMask = val & 0xFFFF;
portConfig.functionMask = val & 0xFFFFFFFF;
validArgumentCount++;
}
for (int i = 0; i < 4; i ++) {
Expand Down
Loading

0 comments on commit 9a593cd

Please sign in to comment.