Skip to content

Commit

Permalink
HAL_QURT: cleanup and add error handler setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Jun 28, 2024
1 parent bb9f602 commit 61f5a0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
30 changes: 20 additions & 10 deletions libraries/AP_HAL_QURT/HAL_QURT_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
#include "interface.h"
#include "protocol.h"


extern "C" {
typedef void (*external_error_handler_t)(void);
void fc_set_external_error_handler(external_error_handler_t err_func);
};

static void crash_error_handler(void)
{
HAP_PRINTF("CRASH_ERROR_HANDLER");
}

using namespace QURT;

static UARTDriver serial0Driver("/dev/console");
Expand Down Expand Up @@ -101,9 +112,11 @@ void HAL_QURT::send_test_message(void)

void HAL_QURT::main_thread(void)
{
HAP_PRINTF("In main_thread!");
HAP_PRINTF("In main_thread! PTR=%p", &HAL_QURT::main_thread);

//fc_set_external_error_handler(crash_error_handler);

// Let SLPI image send out it's initialization response before we
// Let SLPI image send out it's initialization response before we
// try to send anything out.
qurt_timer_sleep(1000000);

Expand All @@ -124,22 +137,19 @@ void HAL_QURT::main_thread(void)
HAP_PRINTF("starting loop");

for (;;) {
qurt_timer_sleep(1000000);
// send_test_message();
// ensure other threads get some time
qurt_timer_sleep(200);

// call main loop
_callbacks->loop();
// if (debug_loop_count == 100) {
// send_test_message();
// debug_loop_count = 0;
// }
// debug_loop_count++;
}
}

void HAL_QURT::start_main_thread(Callbacks* callbacks)
{
_callbacks = callbacks;
scheduler->thread_create(FUNCTOR_BIND_MEMBER(&HAL_QURT::main_thread, void), "main_thread",
(10 * 1024),
(20 * 1024),
AP_HAL::Scheduler::PRIORITY_MAIN,
0);
}
Expand Down
10 changes: 6 additions & 4 deletions libraries/AP_HAL_QURT/UARTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ void QURT::UARTDriver::_begin(uint32_t b, uint16_t rxS, uint16_t txS)
* all ports. This means we don't get delays while waiting to
* write GPS config packets
*/
if (rxS < 8192) {
rxS = 8192;
if (rxS < 4096) {
rxS = 4096;
}
if (txS < 32000) {
txS = 32000;
if (txS < 4096) {
txS = 4096;
}

while (_in_timer) hal.scheduler->delay(1);
Expand Down Expand Up @@ -159,6 +159,8 @@ ssize_t QURT::UARTDriver::_read(uint8_t *buffer, uint16_t size)
*/
bool QURT::UARTDriver::_write_pending_bytes(void)
{
WITH_SEMAPHORE(_write_mutex);

// write any pending bytes
uint32_t available_bytes = _writebuf.available();
uint16_t n = available_bytes;
Expand Down

0 comments on commit 61f5a0a

Please sign in to comment.