Skip to content

Commit

Permalink
Merge branch 'master' into more-baros
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Feb 13, 2024
2 parents 06ba9d3 + 190ba7e commit b369a27
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
35 changes: 18 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
uses: rlespinasse/github-slug-action@v4

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.target }}
Expand All @@ -29,7 +29,7 @@ jobs:
pip install wheel
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio
Expand All @@ -47,7 +47,7 @@ jobs:
targets: ${{ steps.set-targets.outputs.targets }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-targets
run: echo "targets=[$( (grep '\[env:.*UART\]' src/targets/unified.ini ; grep -r '\[env:.*STLINK\]' src/targets/) | sed 's/.*://' | sed s/.$// | egrep "(STLINK|UART)" | grep -v DEPRECATED | tr '\n' ',' | sed 's/,$/"\n/' | sed 's/,/","/'g | sed 's/^/"/')]" >> $GITHUB_OUTPUT

Expand All @@ -64,15 +64,15 @@ jobs:
uses: rlespinasse/github-slug-action@v4

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.target }}
Expand All @@ -84,7 +84,7 @@ jobs:
pip install wheel
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio
Expand Down Expand Up @@ -118,32 +118,33 @@ jobs:
esac
- name: Store Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: firmware
name: temp-${{ matrix.target }}
path: ~/artifacts/**/*
retention-days: 1
continue-on-error: true

firmware:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout targets repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ExpressLRS/targets
path: src/hardware

- name: Get firmware artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: firmware
path: dist
merge-multiple: true

- name: Copy hardware files to firmware folder
run: cp -r src/hardware dist/firmware
Expand All @@ -157,7 +158,7 @@ jobs:
run: cd src ; find bootloader -name \*.bin -o -name \*.frk | grep -v src/ | cpio -pdm ../dist/firmware

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand All @@ -168,7 +169,7 @@ jobs:
shiv -c flash -o ../../dist/firmware/flasher.pyz pyserial .
- name: Update firmware artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: firmware
path: dist/**/*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
- uses: actions/stale@v9
with:
days-before-issue-stale: -1
days-before-issue-close: 12
Expand Down
25 changes: 15 additions & 10 deletions src/lib/LUA/rx_devLUA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,33 +222,38 @@ static void luaparamMappingChannelIn(struct luaPropertiesCommon *item, uint8_t a
config.SetPwmChannelRaw(ch, newPwmCh.raw);
}

static uint8_t configureSerialPin(uint8_t sibling, uint8_t oldMode, uint8_t newMode)
static void configureSerialPin(uint8_t sibling, uint8_t oldMode, uint8_t newMode)
{
for (int ch=0 ; ch<GPIO_PIN_PWM_OUTPUTS_COUNT ; ch++)
{
if (GPIO_PIN_PWM_OUTPUTS[ch] == sibling)
{
// set sibling pin channel settings based on this pins settings
rx_config_pwm_t newPin3Config;
// Retain as much of the sibling's current config as possible
rx_config_pwm_t siblingPinConfig;
siblingPinConfig.raw = config.GetPwmChannel(ch)->raw;

// If the new mode is serial, the sibling is also forced to serial
if (newMode == somSerial)
{
newPin3Config.val.mode = somSerial;
siblingPinConfig.val.mode = somSerial;
}
else
// If the new mode is not serial, and the sibling is serial, set the sibling to PWM (50Hz)
else if (siblingPinConfig.val.mode == somSerial)
{
newPin3Config.val.mode = som50Hz;
siblingPinConfig.val.mode = som50Hz;
}
config.SetPwmChannelRaw(ch, newPin3Config.raw);

config.SetPwmChannelRaw(ch, siblingPinConfig.raw);
break;
}
}

if (oldMode != newMode)
{
deferExecution(100, [](){
reconfigureSerial();
});
}
return newMode;
}

static void luaparamMappingOutputMode(struct luaPropertiesCommon *item, uint8_t arg)
Expand All @@ -263,11 +268,11 @@ static void luaparamMappingOutputMode(struct luaPropertiesCommon *item, uint8_t
// Check if pin == 1/3 and do other pin adjustment accordingly
if (GPIO_PIN_PWM_OUTPUTS[ch] == 1)
{
newPwmCh.val.mode = configureSerialPin(3, oldMode, newPwmCh.val.mode);
configureSerialPin(3, oldMode, newPwmCh.val.mode);
}
else if (GPIO_PIN_PWM_OUTPUTS[ch] == 3)
{
newPwmCh.val.mode = configureSerialPin(1, oldMode, newPwmCh.val.mode);
configureSerialPin(1, oldMode, newPwmCh.val.mode);
}
config.SetPwmChannelRaw(ch, newPwmCh.raw);
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/OTA/OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ bool ICACHE_RAM_ATTR ValidatePacketCrcFull(OTA_Packet_s * const otaPktPtr)

bool ICACHE_RAM_ATTR ValidatePacketCrcStd(OTA_Packet_s * const otaPktPtr)
{
uint8_t backupCrcHigh = otaPktPtr->std.crcHigh;

uint16_t const inCRC = ((uint16_t)otaPktPtr->std.crcHigh << 8) + otaPktPtr->std.crcLow;
// For smHybrid the CRC only has the packet type in byte 0
// For smWide the FHSS slot is added to the CRC in byte 0 on PACKET_TYPE_RCDATAs
Expand All @@ -507,6 +509,9 @@ bool ICACHE_RAM_ATTR ValidatePacketCrcStd(OTA_Packet_s * const otaPktPtr)
}
uint16_t const calculatedCRC =
ota_crc.calc((uint8_t*)otaPktPtr, OTA4_CRC_CALC_LEN, OtaCrcInitializer);

otaPktPtr->std.crcHigh = backupCrcHigh;

return inCRC == calculatedCRC;
}

Expand Down
25 changes: 14 additions & 11 deletions src/lib/PWM/waveform_8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void disableIdleTimer() {
// waveform smoothly on next low->high transition. For immediate change, stopWaveform()
// first, then it will immediately begin.
void startWaveform8266(uint8_t pin, uint32_t timeHighUS, uint32_t timeLowUS) {
if ((pin > 16) || isFlashInterfacePin(pin) || (timeHighUS == 0)) {
if ((pin > 16) || isFlashInterfacePin(pin)) {
return;
}
Waveform *wave = &wvfState.waveform[pin];
Expand Down Expand Up @@ -257,30 +257,33 @@ static IRAM_ATTR void timer1Interrupt() {
uint32_t desired = 0;
uint32_t *timeToUpdate;
wvfState.waveformState ^= mask;
if (wvfState.waveformState & mask) {
if (i == 16) {
GP16O = 1;
}
GPOS = mask;

if (wave->nextHighLowUs != 0) {
if (wvfState.waveformState & mask && wave->nextHighLowUs != 0) {
// Copy over next full-cycle timings
uint32_t next = wave->nextHighLowUs;
wave->nextHighLowUs = 0; // indicate the change has taken place
wave->timeHighCycles = wave->desiredHighCycles = microsecondsToClockCycles(next >> 16);
wave->timeLowCycles = wave->desiredLowCycles = microsecondsToClockCycles(next & 0xffff);
wave->lastEdge = 0;
}
if (wvfState.waveformState & mask) {
if (wave->timeHighCycles != 0) {
if (i == 16) {
GP16O = 1;
}
GPOS = mask;
}
if (wave->lastEdge) {
desired = wave->desiredLowCycles;
timeToUpdate = &wave->timeLowCycles;
}
nextEdgeCycles = wave->timeHighCycles;
} else {
if (i == 16) {
GP16O = 0;
if (wave->timeLowCycles != 0) {
if (i == 16) {
GP16O = 0;
}
GPOC = mask;
}
GPOC = mask;
desired = wave->desiredHighCycles;
timeToUpdate = &wave->timeHighCycles;
nextEdgeCycles = wave->timeLowCycles;
Expand Down
17 changes: 13 additions & 4 deletions src/lib/SX127xDriver/SX127x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,19 @@ bool SX127xDriver::Begin()
ConfigLoraDefaults();
// Force the next power update, and use the defaults for RFO_HF or PA_BOOST
pwrCurrent = PWRPENDING_NONE;
SetOutputPower(0);
#if defined(TARGET_UNIFIED_RX) || defined(TARGET_UNIFIED_TX)
if (POWER_OUTPUT_VALUES2 == nullptr)
#endif
{
if (OPT_USE_SX1276_RFO_HF)
{
SetOutputPower(SX127X_MAX_OUTPUT_POWER_RFO_HF);
}
else
{
SetOutputPower(SX127X_MAX_OUTPUT_POWER);
}
}
CommitOutputPower();

return true;
Expand Down Expand Up @@ -475,9 +487,6 @@ void ICACHE_RAM_ATTR SX127xDriver::GetLastPacketStats()
hal.writeRegister(SX127X_REG_FIFO_ADDR_PTR, FIFOaddr, radio[secondRadioIdx]);
hal.readRegister(SX127X_REG_FIFO, RXdataBuffer_second, PayloadLength, radio[secondRadioIdx]);

// leaving only the type in the first byte (crcHigh was cleared)
RXdataBuffer[0] &= 0b11;
RXdataBuffer_second[0] &= 0b11;
// if the second packet is same to the first, it's valid
if (memcmp(RXdataBuffer, RXdataBuffer_second, PayloadLength) == 0)
{
Expand Down
2 changes: 2 additions & 0 deletions src/lib/SX127xDriver/SX127xRegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ typedef enum
#define SX127X_PA_SELECT_RFO 0b00000000 // 7 7 RFO pin output, power limited to +14 dBm
#define SX127X_PA_SELECT_BOOST 0b10000000 // 7 7 PA_BOOST pin output, power limited to +20 dBm
#define SX127X_PA_POWER_MASK 0b01111111 // 6 0 PA MAX_POWER and OUTPUT_POWER combined bit mask
#define SX127X_MAX_OUTPUT_POWER_RFO_HF 0b00000000 // Max output power when using RFO_HF
#define SX127X_MAX_OUTPUT_POWER 0b01110000 // Enable max output power
// SX127X_REG_OCP
#define SX127X_OCP_OFF 0b00000000 // 5 5 PA overload current protection disabled
#define SX127X_OCP_ON 0b00100000 // 5 5 PA overload current protection enabled
Expand Down
3 changes: 0 additions & 3 deletions src/lib/SX1280Driver/SX1280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,6 @@ void ICACHE_RAM_ATTR SX1280Driver::GetLastPacketStats()
WORD_ALIGNED_ATTR uint8_t RXdataBuffer_second[RXBuffSize];
hal.ReadBuffer (FIFOaddr, RXdataBuffer_second, PayloadLength, radio[secondRadioIdx]);

// leaving only the type in the first byte (crcHigh was cleared)
RXdataBuffer[0] &= 0b11;
RXdataBuffer_second[0] &= 0b11;
// if the second packet is same to the first, it's valid
if(memcmp(RXdataBuffer, RXdataBuffer_second, PayloadLength) == 0)
{
Expand Down

0 comments on commit b369a27

Please sign in to comment.