#include "common/phal_F4_F7/dma/dma.h"
#include "common/phal_F4_F7/phal_F4_F7.h"
Go to the source code of this file.
|
| enum | parity_t { PT_EVEN = 0b010
, PT_ODD = 0b100
, PT_NONE = 0b000
} |
| |
| enum | word_length_t { WORD_8
, WORD_9
} |
| |
| enum | stop_bits_t { SB_ONE = 0b00
, SB_TWO = 0b01
, SB_HALF = 0b10
, SB_ONE_HALF = 0b11
} |
| |
| enum | hw_flow_ctl_t { HW_DISABLE
, CTS
, RTS
, CTS_RTS
} |
| |
| enum | ovsample_t { OV_16 = 0
, OV_8 = 1
} |
| |
| enum | obsample_t { OB_DISABLE
, OB_ENABLE
} |
| |
|
| bool | PHAL_initUSART (usart_init_t *handle, const uint32_t fck) |
| | Initialize a USART Peripheral with desired settings.
|
| |
| void | PHAL_usartTxBl (usart_init_t *handle, uint8_t *data, uint32_t len) |
| | TX using no DMA (blocks until complete)
|
| |
| void | PHAL_usartRxBl (usart_init_t *handle, uint8_t *data, uint32_t len) |
| | RX using no DMA (blocks until complete)
|
| |
| bool | PHAL_usartTxDma (usart_init_t *handle, uint16_t *data, uint32_t len) |
| | Starts a tx using dma, use PHAL_usartTxDmaComplete to ensure the previous transmission is complete.
|
| |
| bool | PHAL_usartRxDma (usart_init_t *handle, uint16_t *data, uint32_t len, bool cont) |
| | Starts an rx using dma of a specific length.
|
| |
| bool | PHAL_disableContinousRxDMA (usart_init_t *handle) |
| | Disables the Continous RX that was previously used.
|
| |
| bool | PHAL_usartTxBusy (usart_init_t *handle) |
| | Returns whether USART peripheral is currently transmitting data.
|
| |
| bool | PHAL_usartRxBusy (usart_init_t *handle) |
| | Returns whether USART peripheral is currently receiving data.
|
| |
| void | usart_recieve_complete_callback (usart_init_t *handle) |
| | Callback function called immediately after reception of a USART RX message Uses USART IDLE line interrupt.
|
| |
- Author
- Aditya Anand (anand.nosp@m.89@p.nosp@m.urdue.nosp@m..edu) - Redesign of L4 USART HAL by Dawson Moore (moore.nosp@m.800@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
- Version
- 0.1
- Date
- 2024-1-4
- Copyright
- Copyright (c) 2024
◆ UART5_RXDMA_CONT_CONFIG
| #define UART5_RXDMA_CONT_CONFIG |
( |
| rx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(UART5->RDR), \
.mem_addr = (uint32_t)(rx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b0, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 0, \
.periph = DMA1, \
.stream = DMA1_Stream0}
◆ UART5_TXDMA_CONT_CONFIG
| #define UART5_TXDMA_CONT_CONFIG |
( |
| tx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(UART5->TDR), \
.mem_addr = (uint32_t)(tx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b1, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 7, \
.periph = DMA1, \
.stream = DMA1_Stream7}
◆ USART1_RXDMA_CONT_CONFIG
| #define USART1_RXDMA_CONT_CONFIG |
( |
| rx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(USART1->RDR), \
.mem_addr = (uint32_t)(rx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b0, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 5, \
.periph = DMA2, \
.stream = DMA2_Stream5}
◆ USART1_TXDMA_CONT_CONFIG
| #define USART1_TXDMA_CONT_CONFIG |
( |
| tx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(USART1->TDR), \
.mem_addr = (uint32_t)(tx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b1, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 7, \
.periph = DMA2, \
.stream = DMA2_Stream7}
◆ USART4_RXDMA_CONT_CONFIG
| #define USART4_RXDMA_CONT_CONFIG |
( |
| rx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(UART4->RDR), \
.mem_addr = (uint32_t)(rx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b0, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 2, \
.periph = DMA1, \
.stream = DMA1_Stream2}
◆ USART4_TXDMA_CONT_CONFIG
| #define USART4_TXDMA_CONT_CONFIG |
( |
| tx_addr_, |
|
|
| priority_ ) |
Value: { \
.periph_addr = (uint32_t)&(UART4->TDR), \
.mem_addr = (uint32_t)(tx_addr_), \
.tx_size = 1, \
.increment = false, \
.circular = false, \
.dir = 0b1, \
.mem_inc = true, \
.periph_inc = false, \
.mem_to_mem = false, \
.priority = (priority_), \
.mem_size = 0b00, \
.periph_size = 0b00, \
.tx_isr_en = true, \
.dma_chan_request = 0b0100, \
.stream_idx = 4, \
.periph = DMA1, \
.stream = DMA1_Stream4}
◆ hw_flow_ctl_t
| Enumerator |
|---|
| HW_DISABLE | Hardware flow control disable.
|
| CTS | Enable Clear to send control.
|
| RTS | Enable Request to send control.
|
| CTS_RTS | Enable both CTS and RTS.
|
◆ obsample_t
| Enumerator |
|---|
| OB_DISABLE | Disable one bit sampling.
|
| OB_ENABLE | Enable one bit sampling.
|
◆ ovsample_t
| Enumerator |
|---|
| OV_16 | Oversample by 16.
|
| OV_8 | Oversample by 8.
|
◆ parity_t
| Enumerator |
|---|
| PT_EVEN | Even Parity.
|
| PT_ODD | Odd Parity.
|
| PT_NONE | Disable Parity bits.
|
◆ stop_bits_t
| Enumerator |
|---|
| SB_ONE | One Stop bit.
|
| SB_TWO | Two Stop bits.
|
| SB_HALF | One half stop bit.
|
| SB_ONE_HALF | 1.5 Stop bits
|
◆ word_length_t
| Enumerator |
|---|
| WORD_8 | 8-Bit word length
|
| WORD_9 | 9-Bit word length
|
◆ PHAL_disableContinousRxDMA()
Disables the Continous RX that was previously used.
- Parameters
-
| handle | The handle for the usart configuration |
Disables the Continous RX that was previously used.
- Parameters
-
| handle | Pointer to the USART handle. |
- Returns
- true if the operation was successful, false otherwise.
◆ PHAL_initUSART()
| bool PHAL_initUSART |
( |
usart_init_t * | handle, |
|
|
const uint32_t | fck ) |
Initialize a USART Peripheral with desired settings.
- Parameters
-
| handle | Handle containing settings for USART peripheral |
| fck | Clock rate going to USART peripheral (APBx bus) |
- Returns
- true Successfully initialized USART peripheral
-
false Failed to initialize USART peripheral
Initialize a USART Peripheral with desired settings.
This function configures the USART peripheral, calculates and sets the baud rate, and enables the necessary clocks and DMA streams.
- Parameters
-
| handle | Pointer to a usart_init_t struct containing the configuration. |
| fck | The clock frequency of the peripheral in Hz. |
- Returns
- true if initialization is successful, false otherwise.
◆ PHAL_usartRxBl()
| void PHAL_usartRxBl |
( |
usart_init_t * | handle, |
|
|
uint8_t * | data, |
|
|
uint32_t | len ) |
RX using no DMA (blocks until complete)
- Parameters
-
| handle | The handle for the usart configuration |
| data | The address of the data to receive |
| len | Number of u8s expected to receive. Will block if not received. |
RX using no DMA (blocks until complete)
- Parameters
-
| handle | Pointer to the USART handle. |
| data | Pointer to the buffer to store received data. |
| len | The length of the data to receive in bytes. |
◆ PHAL_usartRxBusy()
Returns whether USART peripheral is currently receiving data.
- Parameters
-
| handle | Handle of USART peripheral check |
- Returns
- true USART peripheral is currently receiving a message
-
false USART peripheal is not currently receiving a message
Returns whether USART peripheral is currently receiving data.
- Parameters
-
| handle | Pointer to the USART handle. |
- Returns
- true if the peripheral is busy, false otherwise.
◆ PHAL_usartRxDma()
| bool PHAL_usartRxDma |
( |
usart_init_t * | handle, |
|
|
uint16_t * | data, |
|
|
uint32_t | len, |
|
|
bool | cont ) |
Starts an rx using dma of a specific length.
- Parameters
-
| handle | The handle for the usart configuration |
| data | The address to put the received data, ensure a cast to (uint16_t *), even if 8 bits |
| len | Number of units of data, depending on the configured word length |
| cont | Enable Continous RX using the idle line interrupt (only need to call this function once, and HAL will keep recieving messages of the same length) |
◆ PHAL_usartTxBl()
| void PHAL_usartTxBl |
( |
usart_init_t * | handle, |
|
|
uint8_t * | data, |
|
|
uint32_t | len ) |
TX using no DMA (blocks until complete)
- Parameters
-
| handle | The handle for the usart configuration |
| data | The address of the data to send |
| len | Number of u8s |
TX using no DMA (blocks until complete)
- Parameters
-
| handle | Pointer to the USART handle. |
| data | Pointer to the data to transmit. |
| len | The length of the data in bytes. |
◆ PHAL_usartTxBusy()
Returns whether USART peripheral is currently transmitting data.
- Parameters
-
| handle | Handle of USART peripheral to check |
- Returns
- true USART peripheral is currently sending a message
-
false USART peripheal is not currently sending a message
Returns whether USART peripheral is currently transmitting data.
- Parameters
-
| handle | Pointer to the USART handle. |
- Returns
- true if the peripheral is busy, false otherwise.
◆ PHAL_usartTxDma()
| bool PHAL_usartTxDma |
( |
usart_init_t * | handle, |
|
|
uint16_t * | data, |
|
|
uint32_t | len ) |
Starts a tx using dma, use PHAL_usartTxDmaComplete to ensure the previous transmission is complete.
- Parameters
-
| handle | The handle for the usart configuration |
| data | The address of the data to send, ensure a cast to (uint16_t *), even if 8 bits |
| len | Number of units of data, depending on the configured word length |
◆ usart_recieve_complete_callback()
| void usart_recieve_complete_callback |
( |
usart_init_t * | handle | ) |
|
|
extern |
Callback function called immediately after reception of a USART RX message Uses USART IDLE line interrupt.
NOTE: this is executed during an interrupt handler call, so keep code in this function light
- Parameters
-
| handle | Handle of USART peripheral that just recieved a message |