Shield Code 6.0
Loading...
Searching...
No Matches
PDC Class Reference

Manages UART transmits through peripheral DMA controller (PDC). More...

#include <PDC.hpp>

Public Member Functions

 PDC ()
 Default constructor for the PDC class. Initializes all relevant register pointers.
 
void init ()
 Turns on PDC, waits until ready. Must be called AFTER Serial.begin() in setup().
 
template<typename T >
void send (T *buffer, int size)
 Adds data to the PDC buffer to be sent out through UART.
 
template<typename T >
void send_next (T *buffer, int size)
 Adds data to the backup PDC buffer. Identical to send().
 
bool is_on ()
 Checks if the PDC and UART are on.
 
void enableUARTInterrupt ()
 
void UART_Handler ()
 

Private Attributes

volatile uint32_t *const p_UART_TPR
 
volatile uint32_t *const p_UART_TCR
 
volatile uint32_t *const p_UART_TNPR
 
volatile uint32_t *const p_UART_TNCR
 
volatile uint32_t *const p_UART_PTCR
 
volatile uint32_t *const p_UART_PTSR
 
volatile uint32_t *const p_UART_SR
 
uint8_t backup_buffer [294]
 

Detailed Description

Manages UART transmits through peripheral DMA controller (PDC).

Definition at line 33 of file PDC.hpp.

Constructor & Destructor Documentation

◆ PDC()

PDC::PDC ( )
inline

Default constructor for the PDC class. Initializes all relevant register pointers.

Definition at line 53 of file PDC.hpp.

Member Function Documentation

◆ enableUARTInterrupt()

void PDC::enableUARTInterrupt ( )
inline

Definition at line 149 of file PDC.hpp.

◆ init()

void PDC::init ( )
inline

Turns on PDC, waits until ready. Must be called AFTER Serial.begin() in setup().

Definition at line 67 of file PDC.hpp.

◆ is_on()

bool PDC::is_on ( )
inline

Checks if the PDC and UART are on.

Definition at line 145 of file PDC.hpp.

◆ send()

template<typename T >
void PDC::send ( T *  buffer,
int  size 
)
inline

Adds data to the PDC buffer to be sent out through UART.

Template Parameters
T- data type of buffer - either char pointer or integer array
Parameters
buffer- pointer to data buffer. Note that it doesn't like pointer casts, so global pointers to sentinels must be used. That's not an issue with Arduino's Serial library because it's blocking - avoiding that is the whole point of this.
size- size of buffer

This can also handle text in an ASCII readable format by using a char pointer:

String message = "Hello World!";
uint8_t* p_message = (uint8_t*)message.c_str();
pdc.send(p_message, sizeof(message));
void send(T *buffer, int size)
Adds data to the PDC buffer to be sent out through UART.
Definition: PDC.hpp:96
PDC pdc
Definition: main.cpp:79

But, Serial.print() is recommended for any debugging application to avoid global declarations.

Note for later - negative numbers are sent as two's complement. make sure Jules' parser is reading that correctly.

Definition at line 96 of file PDC.hpp.

◆ send_next()

template<typename T >
void PDC::send_next ( T *  buffer,
int  size 
)
inline

Adds data to the backup PDC buffer. Identical to send().

Definition at line 122 of file PDC.hpp.

◆ UART_Handler()

void PDC::UART_Handler ( )
inline

Definition at line 157 of file PDC.hpp.

Member Data Documentation

◆ backup_buffer

uint8_t PDC::backup_buffer[294]
private

Definition at line 44 of file PDC.hpp.

◆ p_UART_PTCR

volatile uint32_t* const PDC::p_UART_PTCR
private

Definition at line 40 of file PDC.hpp.

◆ p_UART_PTSR

volatile uint32_t* const PDC::p_UART_PTSR
private

Definition at line 41 of file PDC.hpp.

◆ p_UART_SR

volatile uint32_t* const PDC::p_UART_SR
private

Definition at line 42 of file PDC.hpp.

◆ p_UART_TCR

volatile uint32_t* const PDC::p_UART_TCR
private

Definition at line 37 of file PDC.hpp.

◆ p_UART_TNCR

volatile uint32_t* const PDC::p_UART_TNCR
private

Definition at line 39 of file PDC.hpp.

◆ p_UART_TNPR

volatile uint32_t* const PDC::p_UART_TNPR
private

Definition at line 38 of file PDC.hpp.

◆ p_UART_TPR

volatile uint32_t* const PDC::p_UART_TPR
private

Definition at line 36 of file PDC.hpp.


The documentation for this class was generated from the following file: