-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add setInterrupt method to HardwareSerial class #3376
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,10 @@ static void IRAM_ATTR _uart_isr(void *arg) | |
BaseType_t xHigherPriorityTaskWoken; | ||
uart_t* uart; | ||
|
||
if(arg != NULL) { | ||
(*((void(**)())arg))(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check should be made in the while loop below and byte There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @me-no-dev I don't think this could be used as an input filter. As written, it triggers once per interrupt, but, the interrupt can empty up to "fifo" of chars. see my comment above. |
||
for(i=0;i<3;i++){ | ||
uart = &_uart_bus_array[i]; | ||
if(uart->intr_handle == NULL){ | ||
|
@@ -96,6 +100,22 @@ static void IRAM_ATTR _uart_isr(void *arg) | |
} | ||
} | ||
|
||
void uartEnableInterrupt(uart_t* uart,void * func) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so why didn't you just change the original function? |
||
{ | ||
UART_MUTEX_LOCK(); | ||
uart->dev->conf1.rxfifo_full_thrhd = 112; | ||
uart->dev->conf1.rx_tout_thrhd = 2; | ||
uart->dev->conf1.rx_tout_en = 1; | ||
uart->dev->int_ena.rxfifo_full = 1; | ||
uart->dev->int_ena.frm_err = 1; | ||
uart->dev->int_ena.rxfifo_tout = 1; | ||
uart->dev->int_clr.val = 0xffffffff; | ||
|
||
esp_intr_alloc(UART_INTR_SOURCE(uart->num), (int)ESP_INTR_FLAG_IRAM, _uart_isr, func, &uart->intr_handle); | ||
UART_MUTEX_UNLOCK(); | ||
} | ||
|
||
/* | ||
void uartEnableInterrupt(uart_t* uart) | ||
{ | ||
UART_MUTEX_LOCK(); | ||
|
@@ -110,7 +130,7 @@ void uartEnableInterrupt(uart_t* uart) | |
esp_intr_alloc(UART_INTR_SOURCE(uart->num), (int)ESP_INTR_FLAG_IRAM, _uart_isr, NULL, &uart->intr_handle); | ||
UART_MUTEX_UNLOCK(); | ||
} | ||
|
||
*/ | ||
void uartDisableInterrupt(uart_t* uart) | ||
{ | ||
UART_MUTEX_LOCK(); | ||
|
@@ -148,9 +168,19 @@ void uartAttachRx(uart_t* uart, uint8_t rxPin, bool inverted) | |
} | ||
pinMode(rxPin, INPUT); | ||
pinMatrixInAttach(rxPin, UART_RXD_IDX(uart->num), inverted); | ||
uartEnableInterrupt(uart); | ||
uartEnableInterrupt(uart,NULL); | ||
} | ||
|
||
// void uartAttachRx(uart_t* uart, uint8_t rxPin, bool inverted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this method commented out? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, why? |
||
// { | ||
// if(uart == NULL || rxPin > 39) { | ||
// return; | ||
// } | ||
// pinMode(rxPin, INPUT); | ||
// pinMatrixInAttach(rxPin, UART_RXD_IDX(uart->num), inverted); | ||
// uartEnableInterrupt(uart); | ||
// } | ||
|
||
void uartAttachTx(uart_t* uart, uint8_t txPin, bool inverted) | ||
{ | ||
if(uart == NULL || txPin > 39) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be restored as this weakly declared method is called, this also breaks the tests which prevent this PR from being considered for merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was taken care of in #2991 prior to this :-)