Skip to content

Lr1110 quickfixes #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
15 changes: 8 additions & 7 deletions lr1110/Makefile.setup
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TOCK_USERLAND_BASE_DIR ?= ..
LR1110_DIR = $(TOCK_USERLAND_BASE_DIR)/lr1110/lr1110

VERSION_HASH := 7c33c9ef136c841a7b44f530d2415789c86f48af
VERSION_HASH := e34742993932c97731f513ffa3028d284b163d31

SEEED_DIR := $(LR1110_DIR)/seeed
ZIP_FILE := $(SEEED_DIR).zip
Expand All @@ -27,12 +27,13 @@ $(LR1110_DIR)/radio_planner.c: $(SEEED_DIR)/smtc_hal/smtc_modem_hal.c
cp $(LR1110_DIR)/seeed/lora_basics_modem/smtc_modem_core/radio_planner/src/radio_planner.c $(LR1110_DIR)/radio_planner.c
cd $(LR1110_DIR); patch -p0 < ../radio_planner.patch

$(SEEED_DIR)/smtc_hal/smtc_modem_hal.c:
curl -L --output $(ZIP_FILE) "https://codeload.github.com/Seeed-Studio/Seeed_Wio_WM1110_Dev_Board/zip/$(VERSION_HASH)"
unzip -q $(ZIP_FILE) -d $(SEEED_DIR)
rm -f $(ZIP_FILE) # Remove zip file after unzip
mv $(EXTRACTED_DIR)/* $(SEEED_DIR)/
rmdir $(EXTRACTED_DIR) # move unzipped code to SEEED_DIR, remove original directory

$(SEEED_DIR):
mkdir -p $(SEEED_DIR)

$(SEEED_DIR)/smtc_hal/smtc_modem_hal.c: | $(SEEED_DIR)
curl -L "https://github.com/Seeed-Studio/Seeed_Wio_WM1110_Dev_Board/archive/$(VERSION_HASH).tar.gz" | \
tar --strip-components=1 -xz -C $(SEEED_DIR)
touch $(SEEED_DIR)
# Need to remove certain system headers because we provide our own.
rm $(SEEED_DIR)/smtc_hal/inc/smtc_hal_flash.h
1 change: 1 addition & 0 deletions lr1110/lr1110/src_changed/lr11xx_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <stdint.h> // C99 types
#include <stdbool.h> // bool type
#include <string.h> // memset

#include <libtock-sync/services/alarm.h>
#include <libtock-sync/net/lora_phy.h>
Expand Down
16 changes: 11 additions & 5 deletions lr1110/lr1110/src_changed/smtc_hal_flash.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <stdlib.h>

#include <libtock-sync/storage/nonvolatile_storage.h>

#include "smtc_hal.h"
Expand Down Expand Up @@ -26,12 +28,16 @@ smtc_hal_status_t hal_flash_write_buffer( uint32_t addr, const uint8_t* buffer,
void hal_flash_read_buffer( uint32_t addr, uint8_t* buffer, uint32_t size )
{
returncode_t ret;

int length_read = 0;
ret = libtocksync_nonvolatile_storage_read(addr, size, buffer, size, &length_read);
if (ret != RETURNCODE_SUCCESS) return SMTC_HAL_FAILURE;

return SMTC_HAL_SUCCESS;
int max_tries = 3;

do {
ret = libtocksync_nonvolatile_storage_read(addr, size, buffer, size, &length_read);
max_tries--;
if (max_tries == 0) {
exit(ret);
}
} while (ret != RETURNCODE_SUCCESS);
}

smtc_hal_status_t hal_flash_deinit( void )
Expand Down
3 changes: 2 additions & 1 deletion lr1110/lr1110/src_changed/smtc_hal_gpio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "smtc_hal_gpio.h"
#include "smtc_hal_config.h"
#include "smtc_hal_gpio.h"
#include "smtc_hal_mcu.h"

#include <libtock/net/lora_phy.h>
#include <libtock/peripherals/gpio.h>
Expand Down
6 changes: 4 additions & 2 deletions lr1110/lr1110/src_changed/smtc_hal_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include "smtc_hal_rtc.h"

#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <libtock-sync/services/alarm.h>

void hal_clock_init(void)
{
Expand Down Expand Up @@ -57,7 +59,7 @@ void hal_hex_to_bin( char *input, uint8_t *dst, int len )
{
char tmp[3];
uint16_t length = strlen( input );
tmp[2] = NULL;
tmp[2] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big fan of this change. I frequently tell my students 0, False, '\0', and NULL are separate things and should be used in semantically meaningful ways. /rant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, turn on -std=c23 and on newer compilers it seems to be a hard error by default :)

for( int i = 0; i < length; i+=2 )
{
tmp[0] = input[i];
Expand Down
1 change: 1 addition & 0 deletions lr1110/lr1110/src_changed/smtc_hal_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "smtc_hal_rtc.h"

#include <libtock/peripherals/syscalls/alarm_syscalls.h>
#include <libtock-sync/services/alarm.h>


uint32_t hal_rtc_get_time_s( void )
Expand Down
Loading