mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-21 17:20:01 +00:00
Fixes and debug printfs
This commit is contained in:
parent
4f08580358
commit
db3d3bd441
@ -14,10 +14,9 @@
|
||||
#define PI_OUTPUT (1)
|
||||
#define PI_LOW (0)
|
||||
#define PI_HIGH (1)
|
||||
#define PI_MAX_USER_GPIO (31)
|
||||
|
||||
#define CH341_PIN_CS (101)
|
||||
#define CH341_PIN_IRQ (102)
|
||||
#define CH341_PIN_IRQ (0)
|
||||
|
||||
// forward declaration of alert handler that will be used to emulate interrupts
|
||||
// static void lgpioAlertHandler(int num_alerts, lgGpioAlert_p alerts, void *userdata);
|
||||
@ -85,10 +84,10 @@ class Ch341Hal : public RadioLibHal
|
||||
|
||||
void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) override
|
||||
{
|
||||
if ((interruptNum == RADIOLIB_NC) || (interruptNum > PI_MAX_USER_GPIO)) {
|
||||
if ((interruptNum == RADIOLIB_NC)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Attach interrupt to pin %d \n", interruptNum);
|
||||
pinedio_attach_interrupt(&this->pinedio, (pinedio_int_pin)interruptNum, (pinedio_int_mode)mode, interruptCb);
|
||||
|
||||
// set lgpio alert callback
|
||||
@ -108,9 +107,10 @@ class Ch341Hal : public RadioLibHal
|
||||
|
||||
void detachInterrupt(uint32_t interruptNum) override
|
||||
{
|
||||
if ((interruptNum == RADIOLIB_NC) || (interruptNum > PI_MAX_USER_GPIO)) {
|
||||
if ((interruptNum == RADIOLIB_NC)) {
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "Detach interrupt from pin %d \n", interruptNum);
|
||||
|
||||
pinedio_deattach_interrupt(&this->pinedio, (pinedio_int_pin)interruptNum);
|
||||
|
||||
|
@ -89,6 +89,8 @@ static void LIBUSB_CALL cb_in(struct libusb_transfer *transfer)
|
||||
static int32_t usb_transfer(struct pinedio_inst *inst, const char *func, unsigned int writecnt, unsigned int readcnt,
|
||||
const uint8_t *writearr, uint8_t *readarr, bool lock)
|
||||
{
|
||||
if (writecnt > 10)
|
||||
fprintf(stderr, "Writing %d bytes to SPI!\n", writecnt);
|
||||
int state_out = TRANS_IDLE;
|
||||
inst->transfer_out->buffer = (uint8_t *)writearr;
|
||||
inst->transfer_out->length = writecnt;
|
||||
@ -480,7 +482,10 @@ static void *pinedio_pin_poll_thread(void *arg)
|
||||
enum pinedio_int_mode mode =
|
||||
inst_int->previous_state == false && state == true ? PINEDIO_INT_MODE_RISING : PINEDIO_INT_MODE_FALLING;
|
||||
if (inst_int->mode & mode) {
|
||||
fprintf(stderr, "Calling Callback!\n");
|
||||
pinedio_mutex_unlock(&inst->usb_access_mutex);
|
||||
inst_int->callback();
|
||||
pinedio_mutex_lock(&inst->usb_access_mutex);
|
||||
}
|
||||
}
|
||||
inst_int->previous_state = state;
|
||||
@ -488,7 +493,7 @@ static void *pinedio_pin_poll_thread(void *arg)
|
||||
|
||||
should_exit = inst->pin_poll_thread_exit;
|
||||
pinedio_mutex_unlock(&inst->usb_access_mutex);
|
||||
platform_sleep(1000 / 30);
|
||||
platform_sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,12 +524,14 @@ int32_t pinedio_deattach_interrupt(struct pinedio_inst *inst, enum pinedio_int_p
|
||||
{
|
||||
pinedio_mutex_lock(&inst->usb_access_mutex);
|
||||
inst->interrupts[int_pin].callback = NULL;
|
||||
inst->int_running_cnt--;
|
||||
if (inst->int_running_cnt == 0) {
|
||||
inst->pin_poll_thread_exit = true;
|
||||
pinedio_mutex_unlock(&inst->usb_access_mutex);
|
||||
pthread_join(inst->pin_poll_thread, NULL);
|
||||
return 0;
|
||||
if (inst->int_running_cnt != 0) {
|
||||
inst->int_running_cnt--;
|
||||
if (inst->int_running_cnt == 0) {
|
||||
inst->pin_poll_thread_exit = true;
|
||||
pinedio_mutex_unlock(&inst->usb_access_mutex);
|
||||
pthread_join(inst->pin_poll_thread, NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
pinedio_mutex_unlock(&inst->usb_access_mutex);
|
||||
return 0;
|
||||
|
@ -19,7 +19,9 @@ enum pinedio_int_pin {
|
||||
PINEDIO_INT_PIN_IRQ,
|
||||
// PINEDIO_INT_PIN_BUSY, // not implemented yet
|
||||
PINEDIO_INT_PIN_MAX
|
||||
|
||||
};
|
||||
// #define PINEDIO_INT_PIN_MAX 110
|
||||
|
||||
enum pinedio_int_mode {
|
||||
PINEDIO_INT_MODE_RISING = 0x01,
|
||||
|
Loading…
Reference in New Issue
Block a user