Skip to content
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

HardwareSerial disable USART interrupt #22

Open
sintrb opened this issue Jul 4, 2024 · 0 comments
Open

HardwareSerial disable USART interrupt #22

sintrb opened this issue Jul 4, 2024 · 0 comments

Comments

@sintrb
Copy link

sintrb commented Jul 4, 2024

cores/arduino/api/HardwareSerial.cpp

when "rxBufferTail == rxBufferHead" USART interrupt will be disable. What time to enable USART interrupt. If not no way to read data. make a ring buff is more useful.

extern "C" void USART1_IRQHandler(void) {
    if(USART1->STATR & USART_FLAG_RXNE) {
        // Write into buffer
        rxBuffer[rxBufferTail] = USART1->DATAR & (uint16_t)0x01FF;

        rxBufferTail = (rxBufferTail + 1) % RX_BUFFER_SIZE;

        if(rxBufferTail == rxBufferHead) {
            // Buffer empty, disable USART interrupt
            USART1->CTLR1 &= ~USART_FLAG_RXNE;  // here
            return;
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant