Skip to content

Commit c990ae9

Browse files
committed
heltec: First working state
Target: Heltec wireless, may work on the heltec lora too. No success for hetler wireless lite yet. Add definitions for the DIO1 and DIO2 lines Changed files as little as possible to include the changes for the heltec hardware The board mimics as LOPY. In order to create the firware, run make BOARD=LOPY Tested: Raw LORA send and receive. ToDo: 1. Test LoraWAN 2. Tidy up the code. Make a HELTEC board type. 3. Make the extra pins on heltec boards available
1 parent 7a645eb commit c990ae9

File tree

18 files changed

+138
-30
lines changed

18 files changed

+138
-30
lines changed

drivers/sx127x/sx1276/sx1276.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ SX1276_t SX1276;
188188
/*!
189189
* Hardware DIO IRQ callback initialization
190190
*/
191-
DioIrqHandler *DioIrq[] = { SX1276OnDioIrq };
191+
// DioIrqHandler *DioIrq[] = { SX1276OnDioIrq };
192+
DioIrqHandler *DioIrq[] = { SX1276OnDio0Irq, SX1276OnDio1Irq,
193+
SX1276OnDio2Irq, SX1276OnDio3Irq,
194+
SX1276OnDio4Irq, NULL };
192195

193196
/*!
194197
* Tx and Rx timers
@@ -979,8 +982,8 @@ void SX1276Reset( void )
979982
// Wait 2 ms
980983
DelayMs( 2 );
981984

982-
// Configure RESET as input
983-
GpioInit( &SX1276.Reset, RADIO_RESET, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );
985+
// Set Reset Pin to 1 (previous: Configure RESET as input)
986+
GpioInit( &SX1276.Reset, RADIO_RESET, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );
984987

985988
// Wait 6 ms
986989
DelayMs( 6 );

drivers/sx127x/sx1276/sx1276.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ typedef struct SX1276_s
123123
{
124124
Gpio_t Reset;
125125
Gpio_t DIO;
126+
Gpio_t DIO1;
127+
Gpio_t DIO2;
126128
Spi_t Spi;
127129
RadioSettings_t Settings;
128130
uint32_t irqFlags;

esp32/application.mk

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ APP_ETHERNET_SRC_C = $(addprefix mods/,\
312312
)
313313

314314
APP_SX1272_SRC_C = $(addprefix drivers/sx127x/,\
315-
sx1272/sx1272.c \
315+
sx1276/sx1276.c \
316316
)
317317

318318
APP_SX1276_SRC_C = $(addprefix drivers/sx127x/,\
@@ -528,8 +528,16 @@ ifeq ($(BOARD), ESP32)
528528
endif
529529
ifeq ($(BOARD), LOPY)
530530
APP_BIN = $(BUILD)/lopy.bin
531+
CFLAGS += -DESP32_GENERIC -DHELTEC
532+
# set FLASH size set by make parameter.
533+
ifeq ($(FLASH_SIZE), 8MB)
534+
CFLAGS += -DMICROPY_HW_FLASH_SIZE=0x800000
535+
endif
536+
ifeq ($(FLASH_SIZE), 4MB)
537+
CFLAGS += -DMICROPY_HW_FLASH_SIZE=0x400000
538+
endif
531539
endif
532-
ifeq ($(BOARD), LOPY4)
540+
ifeq ($(BOARD), LOPY4) # modification for Heltec boards
533541
APP_BIN = $(BUILD)/lopy4.bin
534542
ifeq ($(MOD_SIGFOX_ENABLED), 1)
535543
$(BUILD)/sigfox/radio_sx127x.o: CFLAGS = $(CFLAGS_SIGFOX)

esp32/boards/LOPY/mpconfigboard.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
#define LOPY
1111

12-
#define MICROPY_HW_BOARD_NAME "LoPy"
12+
#define MICROPY_HW_BOARD_NAME "Heltec Wireless Stick"
1313
#define MICROPY_PY_SYS_PLATFORM "LoPy"
1414
#define MICROPY_HW_HB_PIN_NUM (0)
1515
#define MICROPY_HW_SAFE_PIN_NUM (21)
1616

17-
#define DEFAULT_AP_SSID "lopy-wlan"
17+
#define DEFAULT_AP_SSID "heltec-wlan"
1818

1919
#define MICROPY_LPWAN_DIO_PIN
2020

@@ -31,6 +31,14 @@ extern uint32_t micropy_lpwan_dio_pin_num;
3131
extern uint32_t micropy_lpwan_dio_pin_index;
3232
extern void * micropy_lpwan_dio_pin;
3333

34+
extern uint32_t micropy_lpwan_dio1_pin_num;
35+
extern uint32_t micropy_lpwan_dio1_pin_index;
36+
extern void * micropy_lpwan_dio1_pin;
37+
38+
extern uint32_t micropy_lpwan_dio2_pin_num;
39+
extern uint32_t micropy_lpwan_dio2_pin_index;
40+
extern void * micropy_lpwan_dio2_pin;
41+
3442
extern uint32_t micropy_lpwan_ncs_pin_num;
3543
extern uint32_t micropy_lpwan_ncs_pin_index;
3644
extern void * micropy_lpwan_ncs_pin;

esp32/boards/LOPY/pins.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ G31,GPI35,P17
1919
G30,GPI34,P18
2020
G6,GPIO32,P19
2121
G7,GPIO33,P20
22-
G8,GPIO26,P21
2322
G9,GPIO25,P22
2423
G10,GPIO14,P23

esp32/boards/make-pins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def parse_af_file(self, filename, pin_col, pinname_col, af_start_col):
139139
raise ValueError("Invalid pin number {:s} in row {:s}".format(row[pin_col]), row)
140140
pin = Pin(row[pinname_col], pin_num)
141141
# FIXME: hack to force the SX1272 pins to be available
142-
if row[pinname_col] == 'GPIO17' or row[pinname_col] == 'GPIO18' or row[pinname_col] == 'GPIO23':
142+
# if row[pinname_col] == 'GPIO17' or row[pinname_col] == 'GPIO18' or row[pinname_col] == 'GPIO23':
143+
if row[pinname_col] in ('GPIO14', 'GPIO18', 'GPIO26'):
143144
pin.board_pin = True
144145
self.cpu_pins.append(NamedPin(row[pinname_col], pin))
145146
# af_idx = 0

esp32/bootloader/bootloader.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static bool find_active_image(bootloader_state_t *bs, esp_partition_pos_t *parti
415415
// bootmgr_verify! (so that the changes are not saved to flash)
416416
ESP_LOGI(TAG, "Checking safe boot pin");
417417
uint32_t ActiveImg = boot_info->ActiveImg;
418-
uint32_t safeboot = wait_for_safe_boot (boot_info, &ActiveImg);
418+
uint32_t safeboot = 0; // wait_for_safe_boot (boot_info, &ActiveImg);
419419
if (safeboot > 0) {
420420
ESP_LOGI(TAG, "Safe boot requested!");
421421
}
@@ -432,7 +432,6 @@ static bool find_active_image(bootloader_state_t *bs, esp_partition_pos_t *parti
432432
return false;
433433
}
434434
}
435-
436435
// load the selected active image
437436
memcpy(partition, &bs->image[ActiveImg], sizeof(esp_partition_pos_t));
438437
return true;

esp32/lora/board.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ void BoardInitMcu( void )
4545
{
4646
if( McuInitialized == false )
4747
{
48-
#if defined(LOPY) || defined (FIPY)
49-
SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC );
50-
SX1272IoInit( );
51-
#elif defined(LOPY4)
48+
#if defined(LOPY4) || defined(HELTEC)
5249
SpiInit( &SX1276.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC );
5350
SX1276IoInit( );
51+
#elif defined(LOPY) || defined (FIPY)
52+
SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC );
53+
SX1272IoInit( );
5454
#endif
5555

5656
TimerHwInit( );
@@ -61,12 +61,12 @@ void BoardInitMcu( void )
6161

6262
void BoardDeInitMcu( void )
6363
{
64-
#if defined(LOPY) || defined (FIPY)
65-
SpiDeInit( &SX1272.Spi );
66-
SX1272IoDeInit( );
67-
#elif defined(LOPY4)
64+
#if defined(LOPY4) || defined(HELTEC)
6865
SpiDeInit( &SX1276.Spi );
6966
SX1276IoDeInit( );
67+
#elif defined(LOPY) || defined (FIPY)
68+
SpiDeInit( &SX1272.Spi );
69+
SX1272IoDeInit( );
7070
#endif
7171

7272
McuInitialized = false;

esp32/lora/board.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ Maintainer: Miguel Luis and Gregory Cristian
4343
#include "lora/system/spi.h"
4444
#include "lora/system/delay.h"
4545
#include "radio.h"
46-
#if defined(LOPY) || defined (FIPY)
46+
#if defined(HELTEC)
47+
#include "sx1276/sx1276.h"
48+
#include "sx1276-board.h"
49+
#elif defined(LOPY) || defined (FIPY)
4750
#include "sx1272/sx1272.h"
4851
#include "sx1272-board.h"
4952
#elif defined(LOPY4)
@@ -72,6 +75,8 @@ Maintainer: Miguel Luis and Gregory Cristian
7275
#define RADIO_NSS micropy_lpwan_ncs_pin_index
7376

7477
#define RADIO_DIO micropy_lpwan_dio_pin_index
78+
#define RADIO_DIO1 micropy_lpwan_dio1_pin_index
79+
#define RADIO_DIO2 micropy_lpwan_dio2_pin_index
7580
#endif
7681

7782
void BoardInitPeriph( void );

esp32/lora/gpio-board.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ Maintainer: Miguel Luis and Gregory Cristian
3131
#include "pins.h"
3232

3333
pin_obj_t *gpio_board_map[NBR_GP_PINS] = {
34-
&pin_GPIO17,
34+
&pin_GPIO14,
3535
&pin_GPIO18,
36-
&pin_GPIO23,
36+
&pin_GPIO26,
3737
&pin_GPIO5,
3838
&pin_GPIO27,
3939
&pin_GPIO19,
40+
&pin_GPI35,
41+
&pin_GPI34,
4042
};
4143

4244
/*!

0 commit comments

Comments
 (0)