Skip to content

Commit 30e84c4

Browse files
AlessandroAUcruwallerRogero-JyeSmithspinorkit
authored
Adds ghost atto as target (ExpressLRS#194)
* BF passthrough upload tweaks and updated xmodem file to latest version * r9mm bootloaders updated (ExpressLRS#206) Co-authored-by: AlessandroAU <[email protected]> * Add R9SLIM+ target (ExpressLRS#209) * Start working on R9SLIM+ variant * R9SLIM dual uart support * R9SLIM+ antenna switch init added Co-authored-by: Roger <[email protected]> * Fix R9 RX monitor_speed (ExpressLRS#213) * crc lib plus 0x83 poly for ota crc (ExpressLRS#210) * crc lib plus 0x83 poly for ota crc * new lua based on PeHo's version (ExpressLRS#161) * new lua based on PeHo's version * Update CRSF.cpp * fix merge error * new lua based on PeHo's version * Update CRSF.cpp * fix merge error * lua updates * fix couple of things * Delete ExLRS2.lua * remove uneeded extra call * Update tx_main.cpp * reduce build targets (ExpressLRS#207) Co-authored-by: Jye <[email protected]> * R9MX receiver MCU type fixes (ExpressLRS#211) Fixed: - MCU type - MCU frequency - RAM size - Flash offset handling for BetaflighPassthrough target - ClockConfig fix * Add R9SLIM+ target (ExpressLRS#209) * Start working on R9SLIM+ variant * R9SLIM dual uart support * R9SLIM+ antenna switch init added Co-authored-by: Roger <[email protected]> * Fix R9 RX monitor_speed (ExpressLRS#213) * crc lib plus 0x83 poly for ota crc * fixes * fix build * fix build * Update crc.cpp * fix infinite loop Co-authored-by: Jye <[email protected]> Co-authored-by: Jye <[email protected]> Co-authored-by: Cru Waller <[email protected]> Co-authored-by: Roger <[email protected]> * Fix timing check on Link rate changes to try and prevent hangs. (ExpressLRS#220) * Update user_defines.txt * fix mistake... * rebase 1 * init * GHOST_ATTO variant updated / fixed (ExpressLRS#169) * GHOST_ATTO variant updated / fixed * pio.ini: FLASH_APP_OFFSET to ATTO config * Variant: Ghost ATTO RX variant fixes (ExpressLRS#170) * latency tester * working led * led updates * targets: Ghost ATTO to use dual uart (Serial In/Out pads) (ExpressLRS#200) * fix * remove latency tester to cleanup PR * put back latency tester as per master * fix * fix 2 * Fix led timing * adds bl Co-authored-by: Cru Waller <[email protected]> Co-authored-by: Roger <[email protected]> Co-authored-by: Jye <[email protected]> Co-authored-by: Jye <[email protected]> Co-authored-by: Kit Adams <[email protected]>
1 parent dcb0f62 commit 30e84c4

19 files changed

Lines changed: 978 additions & 40 deletions

img/GHST_ATTO_V1.1_PINOUT.png

2.66 MB
Loading

src/boards/GHOST_ATTO.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"build": {
3+
"cpu": "cortex-m4",
4+
"extra_flags": "-DSTM32F301x8=1 -DSTM32F3xx=1 -DSTM32F301=1",
5+
"f_cpu": "72000000L",
6+
"ldscript": "ldscript.ld",
7+
"mcu": "stm32f301k8",
8+
"product_line": "STM32F301x8",
9+
"variants_dir": "variants",
10+
"variant": "GHOST_ATTO"
11+
},
12+
"connectivity": [
13+
"can"
14+
],
15+
"debug": {
16+
"default_tools": [
17+
"stlink"
18+
],
19+
"jlink_device": "STM32F301K8",
20+
"onboard_tools": [
21+
"stlink"
22+
],
23+
"openocd_board": "st_nucleo_f3",
24+
"svd_path": "STM32F30x.svd"
25+
},
26+
"frameworks": [
27+
"arduino",
28+
"cmsis",
29+
"mbed",
30+
"stm32cube",
31+
"libopencm3"
32+
],
33+
"name": "STM32F301K8",
34+
"upload": {
35+
"maximum_ram_size": 16384,
36+
"maximum_size": 65536,
37+
"protocol": "stlink",
38+
"protocols": [
39+
"jlink",
40+
"stlink",
41+
"blackmagic",
42+
"mbed"
43+
]
44+
},
45+
"url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f3-series/stm32f301/stm32f301k8.html",
46+
"vendor": "ST"
47+
}
7.14 KB
Binary file not shown.

src/lib/CRSF/CRSF.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ TaskHandle_t xESP32uartWDT = NULL;
1515
SemaphoreHandle_t mutexOutFIFO = NULL;
1616
#endif
1717

18-
#if defined(TARGET_R9M_TX) || defined(TARGET_R9M_LITE_TX) || defined(TARGET_R9M_LITE_PRO_TX)
18+
#if defined(TARGET_R9M_TX) || defined(TARGET_R9M_LITE_TX) || defined(TARGET_R9M_LITE_PRO_TX) || defined(TARGET_RX_GHOST_ATTO_V1)
1919
HardwareSerial CRSF::Port(USART3);
20-
#ifndef TARGET_R9M_LITE_PRO_TX
21-
#include "stm32f1xx_hal.h"
22-
#include "stm32f1xx_hal_gpio.h"
23-
#else
20+
#if defined(TARGET_R9M_LITE_PRO_TX) || defined(TARGET_RX_GHOST_ATTO_V1)
2421
#include "stm32f3xx_hal.h"
2522
#include "stm32f3xx_hal_gpio.h"
23+
#else
24+
#include "stm32f1xx_hal.h"
25+
#include "stm32f1xx_hal_gpio.h"
2626
#endif
2727
#endif
2828

@@ -376,7 +376,7 @@ void ICACHE_RAM_ATTR CRSF::sendSyncPacketToTX(void *pvParameters) // in values i
376376

377377
#endif
378378

379-
#if defined(PLATFORM_ESP8266) || defined(TARGET_R9M_RX) || defined(UNIT_TEST)
379+
#if defined(PLATFORM_ESP8266) || defined(TARGET_R9M_RX) || defined(TARGET_RX_GHOST_ATTO_V1) ||defined(UNIT_TEST)
380380
bool CRSF::RXhandleUARTout()
381381
{
382382
uint8_t peekVal = SerialOutFIFO.peek(); // check if we have data in the output FIFO that needs to be written

src/lib/CRSF/CRSF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class CRSF
305305
{
306306

307307
public:
308-
#if defined(PLATFORM_ESP8266) || defined(TARGET_R9M_RX) || defined(UNIT_TEST)
308+
#if defined(PLATFORM_ESP8266) || defined(TARGET_R9M_RX) || defined(TARGET_RX_GHOST_ATTO_V1) ||defined(UNIT_TEST)
309309

310310
CRSF(Stream *dev) : _dev(dev)
311311
{

src/lib/EEPROM/elrs_eeprom.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "elrs_eeprom.h"
22
#include <Arduino.h>
33

4+
#ifndef TARGET_RX_GHOST_ATTO_V1
5+
46
#if defined(TARGET_R9M_TX) || defined(TARGET_R9M_LITE_TX) || defined(TARGET_R9M_LITE_PRO_TX)
57
extEEPROM EEPROM(kbits_2, 1, 1, 0x51);
68
#elif defined(TARGET_R9M_RX)
@@ -64,3 +66,5 @@ ELRS_EEPROM::Commit()
6466
}
6567
#endif
6668
}
69+
70+
#endif
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#include <Arduino.h>
2+
#include <stdint.h>
3+
#include "targets.h"
4+
5+
#if (GPIO_PIN_LED_WS2812 != UNDEF_PIN) && (GPIO_PIN_LED_WS2812_FAST != UNDEF_PIN)
6+
#define WS2812_LED_IS_USED 1
7+
8+
static inline void LEDsend_1(void) {
9+
digitalWriteFast(GPIO_PIN_LED_WS2812_FAST, HIGH);
10+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
11+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
12+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
13+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
14+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
15+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
16+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
17+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
18+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
19+
digitalWriteFast(GPIO_PIN_LED_WS2812_FAST, LOW);
20+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
21+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
22+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
23+
__NOP(); __NOP(); __NOP();
24+
}
25+
26+
static inline void LEDsend_0(void) {
27+
digitalWriteFast(GPIO_PIN_LED_WS2812_FAST, HIGH);
28+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
29+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
30+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
31+
__NOP(); __NOP(); __NOP();
32+
digitalWriteFast(GPIO_PIN_LED_WS2812_FAST, LOW);
33+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
34+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
35+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
36+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
37+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
38+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
39+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
40+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
41+
__NOP(); __NOP(); __NOP(); __NOP(); __NOP();
42+
}
43+
44+
static inline uint32_t bitReverse(uint8_t input)
45+
{
46+
uint8_t r = input; // r will be reversed bits of v; first get LSB of v
47+
uint8_t s = 8 - 1; // extra shift needed at end
48+
49+
for (input >>= 1; input; input >>= 1)
50+
{
51+
r <<= 1;
52+
r |= input & 1;
53+
s--;
54+
}
55+
r <<= s; // shift when input's highest bits are zero
56+
return r;
57+
}
58+
59+
void WS281BsetLED(uint8_t const * const RGB) // takes RGB data
60+
{
61+
pinMode(GPIO_PIN_LED_WS2812, OUTPUT);
62+
63+
uint32_t LedColourData =
64+
bitReverse(RGB[1]) + // Green
65+
(bitReverse(RGB[0]) << 8) + // Red
66+
(bitReverse(RGB[2]) << 16); // Blue
67+
uint8_t bits = 24;
68+
while (bits--)
69+
{
70+
(LedColourData & 0x1) ? LEDsend_1() : LEDsend_0();
71+
LedColourData >>= 1;
72+
}
73+
delayMicroseconds(50); // needed to latch in the values
74+
}
75+
76+
void WS281BsetLED(uint8_t const r, uint8_t const g, uint8_t const b) // takes RGB data
77+
{
78+
uint8_t data[3] = {r, g, b};
79+
WS281BsetLED(data);
80+
}
81+
82+
void WS281BsetLED(uint32_t color) // takes RGB data
83+
{
84+
uint8_t data[3];
85+
data[0] = (color & 0x00FF0000) >> 16;
86+
data[1] = (color & 0x0000FF00) >> 8;
87+
data[2] = (color & 0x000000FF) >> 0;
88+
WS281BsetLED(data);
89+
}
90+
91+
#endif /* (GPIO_PIN_LED_WS2812 != UNDEF_PIN) && (GPIO_PIN_LED_WS2812_FAST != UNDEF_PIN) */

src/lib/SX1280Driver/SX1280.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,21 @@ void SX1280Driver::End()
4545

4646
bool SX1280Driver::Begin()
4747
{
48+
bool success = false;
4849
hal.init();
4950
hal.TXdoneCallback = &SX1280Driver::TXnbISR;
5051
hal.RXdoneCallback = &SX1280Driver::RXnbISR;
5152

5253
hal.reset();
5354
Serial.println("SX1280 Begin");
5455
delay(100);
55-
56+
Serial.print("Read Vers: ");
5657
uint16_t firmwareRev = (((hal.ReadRegister(REG_LR_FIRMWARE_VERSION_MSB)) << 8) | (hal.ReadRegister(REG_LR_FIRMWARE_VERSION_MSB + 1)));
57-
Serial.print("Firmware Revision: ");
58+
if ((firmwareRev != 0) || (firmwareRev != 65536))
59+
{
60+
success = true;
61+
}
5862
Serial.println(firmwareRev);
59-
6063
this->SetMode(SX1280_MODE_STDBY_RC); //step 1 put in STDBY_RC mode
6164
hal.WriteCommand(SX1280_RADIO_SET_PACKETTYPE, SX1280_PACKET_TYPE_LORA); //Step 2: set packet type to LoRa
6265
this->ConfigModParams(currBW, currSF, currCR); //Step 5: Configure Modulation Params
@@ -66,8 +69,8 @@ bool SX1280Driver::Begin()
6669
this->SetFrequency(this->currFreq); //Step 3: Set Freq
6770
this->SetFIFOaddr(0x00, 0x00); //Step 4: Config FIFO addr
6871
this->SetDioIrqParams(SX1280_IRQ_RADIO_ALL, SX1280_IRQ_TX_DONE | SX1280_IRQ_RX_DONE, SX1280_IRQ_RADIO_NONE, SX1280_IRQ_RADIO_NONE); //set IRQ to both RXdone/TXdone on DIO1
69-
70-
return true;
72+
73+
return success;
7174
}
7275

7376
void ICACHE_RAM_ATTR SX1280Driver::Config(SX1280_RadioLoRaBandwidths_t bw, SX1280_RadioLoRaSpreadingFactors_t sf, SX1280_RadioLoRaCodingRates_t cr, uint32_t freq, uint8_t PreambleLength)

src/lib/SX1280Driver/SX1280_hal.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void SX1280Hal::init()
8686
#endif
8787

8888
#ifdef PLATFORM_STM32
89+
Serial.println("Config SPI");
8990
SPI.setMOSI(GPIO_PIN_MOSI);
9091
SPI.setMISO(GPIO_PIN_MISO);
9192
SPI.setSCLK(GPIO_PIN_SCK);

src/platformio.ini

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,47 @@ src_filter = ${common_env_data.src_filter} -<ESP8266*.*> -<STM32*.*> -<rx_main.c
403403
extra_scripts = ${common_env_data.extra_scripts}
404404
lib_deps = NeoPixelBus
405405

406+
[env:GHOST_ATTO_2400_RX_via_STLINK]
407+
408+
framework = arduino
409+
board = GHOST_ATTO
410+
build_unflags = -Os
411+
build_flags =
412+
-D TARGET_RX_GHOST_ATTO_V1
413+
-D TARGET_100mW_MODULE
414+
-D PLATFORM_STM32
415+
-D HSE_VALUE=32000000U
416+
-O2
417+
-DVECT_TAB_OFFSET=0x08004000U
418+
-Wl,--defsym=FLASH_APP_OFFSET=0x4000
419+
src_filter = ${common_env_data.src_filter} -<ESP32*.*> -<ESP8266*.*> -<WS281B*.*> -<tx_*.cpp>
420+
upload_protocol = custom
421+
extra_scripts =
422+
${common_env_data.extra_scripts}
423+
python/upload_stlink.py
424+
upload_flags =
425+
BOOTLOADER=bootloader/ghost/bl_ghost_atto.bin
426+
VECT_OFFSET=0x4000
427+
lib_deps =
428+
https://github.com/PaoloP74/extEEPROM.git
429+
Wire
430+
monitor_speed = 420000
431+
432+
[env:GHOST_ATTO_2400_RX_via_BetaflightPassthrough]
433+
platform = ${env:GHOST_ATTO_2400_RX_via_STLINK.platform}
434+
framework = ${env:GHOST_ATTO_2400_RX_via_STLINK.framework}
435+
board = ${env:GHOST_ATTO_2400_RX_via_STLINK.board}
436+
build_unflags = ${env:GHOST_ATTO_2400_RX_via_STLINK.build_unflags}
437+
build_flags = ${env:GHOST_ATTO_2400_RX_via_STLINK.build_flags}
438+
src_filter = ${env:GHOST_ATTO_2400_RX_via_STLINK.src_filter}
439+
extra_scripts = ${common_env_data.extra_scripts}
440+
lib_deps = ${env:GHOST_ATTO_2400_RX_via_STLINK.lib_deps}
441+
upload_protocol = custom
442+
upload_command =
443+
python python/runpython.py $PYTHONEXE python/BFinitPassthrough.py 420000
444+
python python/runpython.py $PYTHONEXE python/UARTupload.py $SOURCE
445+
monitor_speed = 420000
446+
406447
[env:DIY_2400_RX_ESP8285_SX1280_via_UART]
407448
408449
platform_packages = [email protected]

0 commit comments

Comments
 (0)