Skip to content

Commit

Permalink
refined the interrupt implementation for the drf1262 library, there a…
Browse files Browse the repository at this point in the history
…re rough edges but it's fine
  • Loading branch information
Michael Shipman committed Feb 14, 2024
1 parent 67dba58 commit 2c75bc1
Show file tree
Hide file tree
Showing 37 changed files with 77,718 additions and 77,432 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
path = Code/libraries/std-cmd
url = https://github.com/UMDBPP/std-cmd.git
branch = main
[submodule "Code/libraries/libnmea"]
path = Code/libraries/libnmea
url = https://github.com/jacketizer/libnmea.git
branch = master
2 changes: 1 addition & 1 deletion Code/Not_XbeeJoint/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pico_enable_stdio_usb(test 1)

pico_add_extra_outputs(test)

target_link_libraries(test pico_stdlib hardware_flash hardware_sync hardware_spi pico_rand pico_unique_id hardware_irq)
target_link_libraries(test pico_stdlib hardware_flash hardware_sync hardware_spi pico_rand pico_unique_id)

add_executable(test_rx_tx
test.cpp
Expand Down
2 changes: 1 addition & 1 deletion Code/Not_XbeeJoint/test/build/CMakeCache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ PICO_BOOT_STAGE2_DIR:INTERNAL=/Users/michaelshipman/Developer/command_module/Cod
PICO_CMAKE_PRELOAD_PLATFORM_DIR:INTERNAL=/Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/cmake/preload/platforms
PICO_CMAKE_PRELOAD_PLATFORM_FILE:INTERNAL=/Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/cmake/preload/platforms/rp2040.cmake
PICO_COMPILER_ASM:INTERNAL=/opt/homebrew/bin/arm-none-eabi-gcc
PICO_DOXYGEN_EXCLUDE_PATHS:INTERNAL= /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common/cmsis /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040/hardware_regs /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common/cmsis /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040/hardware_regs
PICO_DOXYGEN_EXCLUDE_PATHS:INTERNAL= /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common/cmsis /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040/hardware_regs /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common/cmsis /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040/hardware_regs /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common/cmsis /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040/hardware_regs
PICO_DOXYGEN_PATHS:INTERNAL= /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/common /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/lib/cyw43-driver/src /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2_common /Users/michaelshipman/Developer/command_module/Code/Not_XbeeJoint/pico-sdk/src/rp2040
PICO_NO_HARDWARE:INTERNAL=0
PICO_ON_DEVICE:INTERNAL=1
Expand Down
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/CMakeFiles/test.dir/test.cpp.obj
Binary file not shown.
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/CMakeFiles/test_rx.dir/test.cpp.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/CMakeFiles/test_tx.dir/test.cpp.obj
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/test.bin
Binary file not shown.
32,301 changes: 16,179 additions & 16,122 deletions Code/Not_XbeeJoint/test/build/test.dis

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test.elf
Binary file not shown.
1,322 changes: 663 additions & 659 deletions Code/Not_XbeeJoint/test/build/test.elf.map

Large diffs are not rendered by default.

5,153 changes: 2,579 additions & 2,574 deletions Code/Not_XbeeJoint/test/build/test.hex

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test.uf2
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/test_rx.bin
Binary file not shown.
32,301 changes: 16,179 additions & 16,122 deletions Code/Not_XbeeJoint/test/build/test_rx.dis

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_rx.elf
Binary file not shown.
1,322 changes: 663 additions & 659 deletions Code/Not_XbeeJoint/test/build/test_rx.elf.map

Large diffs are not rendered by default.

5,153 changes: 2,579 additions & 2,574 deletions Code/Not_XbeeJoint/test/build/test_rx.hex

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_rx.uf2
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/test_rx_tx.bin
Binary file not shown.
32,301 changes: 16,179 additions & 16,122 deletions Code/Not_XbeeJoint/test/build/test_rx_tx.dis

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_rx_tx.elf
Binary file not shown.
1,324 changes: 664 additions & 660 deletions Code/Not_XbeeJoint/test/build/test_rx_tx.elf.map

Large diffs are not rendered by default.

5,155 changes: 2,580 additions & 2,575 deletions Code/Not_XbeeJoint/test/build/test_rx_tx.hex

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_rx_tx.uf2
Binary file not shown.
Binary file modified Code/Not_XbeeJoint/test/build/test_tx.bin
Binary file not shown.
32,301 changes: 16,179 additions & 16,122 deletions Code/Not_XbeeJoint/test/build/test_tx.dis

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_tx.elf
Binary file not shown.
1,322 changes: 663 additions & 659 deletions Code/Not_XbeeJoint/test/build/test_tx.elf.map

Large diffs are not rendered by default.

5,153 changes: 2,579 additions & 2,574 deletions Code/Not_XbeeJoint/test/build/test_tx.hex

Large diffs are not rendered by default.

Binary file modified Code/Not_XbeeJoint/test/build/test_tx.uf2
Binary file not shown.
33 changes: 25 additions & 8 deletions Code/Not_XbeeJoint/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
#include "../../libraries/rp2040-drf1262-lib/SX1262.h"
#include "hardware/flash.h"
#include "hardware/gpio.h"
#include "hardware/irq.h"
// #include "hardware/irq.h"
#include "hardware/spi.h"
#include "pico/binary_info.h"
#include "pico/rand.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ DRF1262 radio(spi0, CS_PIN, SCK_PIN, MOSI_PIN, MISO_PIN, TXEN_PIN, DIO1_PIN,

char id[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1] = {0};

short debug_msgs = 1; // controls if debug messages are printed
short debug_msgs = 0; // controls if debug messages are printed

enum Commands_Ext { HELP = STAT + 1 }; // how to add extra op codes for fun

Expand All @@ -55,6 +55,8 @@ Config not_xbee_test_config;

char radio_buf[100] = {0};

bool tx_done = true;

void help_handler(uint8_t *args);
void gpio_callback(uint gpio, uint32_t events);

Expand All @@ -63,7 +65,10 @@ void gpio_callback(uint gpio, uint32_t events);
int main() {
stdio_init_all();

gpio_set_irq_callback(&gpio_callback);
// gpio_set_irq_callback(&gpio_callback);

gpio_set_irq_enabled_with_callback(DIO1_PIN, GPIO_IRQ_EDGE_RISE, true,
&gpio_callback);

sleep_ms(5000);

Expand All @@ -87,16 +92,21 @@ int main() {
print_command(&cmd);
cmd.handler(cmd.params);

sleep_ms(500);
// sleep_ms(500);
}
}

void transmit_test(uint8_t *buf, short len) {
printf("Transmit Test\n");

tx_done = false;

radio.radio_send(buf, len);

// sleep_ms(100);
while (!tx_done)
;

// sleep_ms(100);

#if INCLUDE_DEBUG
radio.get_radio_errors();
Expand Down Expand Up @@ -149,7 +159,9 @@ void get_handler(uint8_t *args) { printf("handler not implemented\n"); }
void set_handler(uint8_t *args) { printf("handler not implemented\n"); }

void help_handler(uint8_t *args) {
printf("Enter commands at the promp below\nCommand format: Op-Code args\n");
printf(
"Enter commands at the promp below\nCommand format: Op-Code "
"args\n");
}

void send_handler(uint8_t *args) {
Expand All @@ -176,10 +188,15 @@ void gpio_callback(uint gpio, uint32_t events) {
if (gpio == DIO1_PIN) {
radio.get_irq_status();

if (radio.irqs.RX_DONE)
if (radio.irqs.RX_DONE) {
radio.read_radio_buffer((uint8_t *)radio_buf, sizeof(radio_buf));
printf("%s\n", radio_buf);
}

if (radio.irqs.TX_DONE) radio.disable_tx();
if (radio.irqs.TX_DONE) {
tx_done = true;
radio.disable_tx();
}

radio.clear_irq_status();
}
Expand Down
1 change: 1 addition & 0 deletions Code/libraries/libnmea
Submodule libnmea added at 91fd43

0 comments on commit 2c75bc1

Please sign in to comment.