This section provides explanations of the TWENET library and AHI functions related to UART.
UART
UART usage relies on serial.c
, .h
and uart.c
, .h
found in TWENETutils.
This section explains AHI-compatible functions with behaviors specific to TWELITE GOLD.
- When using UART1, you must call
vAHI_UartSetLocation()
orvAHI_UartSetLocationByPio_MW()
to specify the assigned ports beforehand. - UART0 does not require any special procedure like UART1 for usage.
vAHI_UartSetLocation()
void vAHI_UartSetLocation(uint8_t u8port, bool_t bSel);
Specifies the port assignment for UART.
- Does not affect UART0 assignment; it cannot be changed from the default ports (DIO6,7).
- Two assignment options are available for UART1.
- This function must be called when using UART1.
- To assign other options for UART1, use
vAHI_UartSetLocationEx_MW()
.
bSel | TX | RX |
---|---|---|
FALSE | DIO14(PIO10) | DIO15(PIO11) |
TRUE | DIO11(PIO0)*1 | DIO13(PIO1) |
*1 This overlaps with the default SPICLK pin.
vAHI_UartSetLocationByPio_MW()
void vAHI_UartSetLocationByPio_MW(uint8_t u8port, uint8 u8TxPort, uint8 u8RxPort)
Assigns ports for UART.
Specify E_AHI_UART_1
for u8port
.
Set the PIO numbers for the TX and RX ports using u8TxPort
and u8RxPort
.
Available PIO numbers (DIO numbers):
- TX: 0 (DO0, DIO11), 6 (DIO5), 10 (DIO14), 20 (DIO16)
- RX: 7 (DIO4), 1 (DIO13), 11 (DIO15), 19 (DIO13)
vAHI_UartDisable()
void vAHI_UartDisable(uint8_t u8port)
Disables the UART port specified by u8port
.
The pin state will return to its initial configuration as defined in TWENETmcu/board/pin_mux.c
at startup.