Skip to content
Snippets Groups Projects

copied and adapted example from mdk, added init and config uart

Merged jakok07 requested to merge initilize-and-use-uart-transmitter into main
2 files
+ 13
4
Compare changes
  • Side-by-side
  • Inline
Files
2
#include "esp32-c3-uart-interface.h"
static void clearBits(volatile uint32_t *registerAddress, uint32_t bitPositions, uint32_t numBits) {
uint32_t mask = (uint32_t)(1 << numBits) - 1; // Create a mask with the specified number of bits set to 1
mask <<= bitPositions; // Shift the mask to the correct bit positions
*registerAddress &= ~mask; // Clear the bits in the register using bitwise AND with the inverse of the mask
uint32_t mask = (uint32_t)(1 << numBits) - 1;
mask <<= bitPositions;
*registerAddress &= ~mask;
}
static void setBit(volatile uint32_t *registerAddress, uint32_t bitPositions) {
uint32_t mask = (uint32_t)(1 << bitPositions);
*registerAddress |= ~mask;
}
static void init_uart_enable_clk(){
@@ -151,7 +156,11 @@ void enable_uart_transmitter(){
set_65_to_rd_byte();
// clear UART_TXFIFO_EMPTY_INT interrupt by setting UART_TXFIFO_EMPTY_INT_CLR;
setBit(C3_UART_INT_CLR_REG_UART0, 1)
// enable UART_TXFIFO_EMPTY_INT interrupt by setting UART_TXFIFO_EMPTY_INT_ENA;
setBit(C3_UART_INT_ENA_REG_UART0, 1)
// detect UART_TXFIFO_EMPTY_INT and wait for the completion of data transmission.
}
Loading