Go to the source code of this file.
Enumerations | |
| enum | { UART_BW_MUL1 = 0, UART_BW_MUL2 = 1, UART_BW_MUL3 = 2, UART_BW_MUL4 = 3 } |
| Define mul bits. More... | |
| enum | UART_ParityTypeDef { PARITY_NONE = 0, PARITY_EVEN, PARITY_ODD } |
| Define parity type. More... | |
| enum | UART_StopBitTypeDef { STOP_BIT_ONE = 0, STOP_BIT_ONE_DOT_FIVE = BIT(4), STOP_BIT_TWO = BIT(5) } |
| Define the length of stop bit. More... | |
| enum | UART_RTSModeTypeDef { UART_RTS_MODE_AUTO = 0, UART_RTS_MODE_MANUAL } |
| Define UART RTS mode. More... | |
| enum | UART_TxPinDef { UART_TX_PA2 = GPIO_PA2, UART_TX_PB1 = GPIO_PB1, UART_TX_PD0 = GPIO_PD0, UART_TX_PD3 = GPIO_PD3, UART_TX_PD7 = GPIO_PD7 } |
| Define UART TX pin:A2 B1 D0 D3 D7. More... | |
| enum | UART_RxPinDef { UART_RX_PA0 = GPIO_PA0, UART_RX_PB0 = GPIO_PB0, UART_RX_PB7 = GPIO_PB7, UART_RX_PC3 = GPIO_PC3, UART_RX_PC5 = GPIO_PC5, UART_RX_PD6 = GPIO_PD6 } |
| Define UART RX pin: A0 B0 B7 C3 C5 D6. More... | |
| enum | UART_CtsPinDef { UART_CTS_PA3 = GPIO_PA3, UART_CTS_PB2 = GPIO_PB2, UART_CTS_PC4 = GPIO_PC4, UART_CTS_PD1 = GPIO_PD1 } |
| Define UART CTS pin : A3 B2 C4 D1. More... | |
| enum | UART_RtsPinDef { UART_RTS_PA4 = GPIO_PA4, UART_RTS_PB3 = GPIO_PB3, UART_RTS_PB6 = GPIO_PB6, UART_RTS_PC0 = GPIO_PC0 } |
| Define UART RTS pin : A4 B3 B6 C0. More... | |
Functions | |
| static unsigned char | uart_tx_is_busy (void) |
| This function servers to indicate Tx state. More... | |
| static void | uart_reset (void) |
| This function resets the UART module. More... | |
| void | uart_init (unsigned short g_uart_div, unsigned char g_bwpc, UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit) |
| This function initializes the UART module. More... | |
| void | uart_init_baudrate (unsigned int Baudrate, unsigned int System_clock, UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit) |
| This function initializes the UART module. More... | |
| void | uart_dma_enable (unsigned char rx_dma_en, unsigned char tx_dma_en) |
| enable uart DMA mode More... | |
| void | uart_irq_enable (unsigned char rx_irq_en, unsigned char tx_irq_en) |
| config the irq of uart tx and rx More... | |
| void | uart_ndma_send_byte (unsigned char uartData) |
| uart send data function with not DMA method. variable uart_TxIndex,it must cycle the four registers 0x90 0x91 0x92 0x93 for the design of SOC. so we need variable to remember the index. More... | |
| void | uart_ndma_irq_triglevel (unsigned char rx_level, unsigned char tx_level) |
| config the number level setting the irq bit of status register 0x9d ie 0x9d[3]. uart_ndma_get_irq If the cnt register value(0x9c[0,3]) larger or equal than the value of 0x99[0,3] or the cnt register value(0x9c[4,7]) less or equal than the value of 0x99[4,7], it will set the irq bit of status register 0x9d, ie 0x9d[3] More... | |
| unsigned char | uart_ndmairq_get (void) |
| get the status of uart irq. More... | |
| volatile unsigned char | uart_dma_send (unsigned char *Addr) |
| uart send data function, this function tell the DMA to get data from the RAM and start the DMA transmission More... | |
| volatile unsigned char | uart_send_byte (unsigned char byte) |
| uart send data function, this function tell the DMA to get data from the RAM and start the DMA transmission More... | |
| void | uart_recbuff_init (unsigned char *RecvAddr, unsigned short RecvBufLen) |
| data receive buffer initiate function. DMA would move received uart data to the address space, uart packet length needs to be no larger than (recBuffLen - 4). More... | |
| unsigned char | uart_is_parity_error (void) |
| This function determines whether parity error occurs once a packet arrives. More... | |
| void | uart_clear_parity_error (void) |
| This function clears parity error status once when it occurs. More... | |
| void | uart_set_rts (unsigned char Enable, UART_RTSModeTypeDef Mode, unsigned char Thresh, unsigned char Invert, UART_RtsPinDef pin) |
| UART hardware flow control configuration. Configure RTS pin. More... | |
| void | uart_set_rts_level (unsigned char Polarity) |
| This function sets the RTS pin's level manually. More... | |
| void | uart_set_cts (unsigned char Enable, unsigned char Select, UART_CtsPinDef pin) |
| UART hardware flow control configuration. Configure CTS pin. More... | |
| void | uart_gpio_set (UART_TxPinDef tx_pin, UART_RxPinDef rx_pin) |
| This function serves to select pin for UART module. More... | |
| enum UART_ParityTypeDef |
| enum UART_StopBitTypeDef |
| enum UART_RTSModeTypeDef |
| enum UART_TxPinDef |
| enum UART_RxPinDef |
| enum UART_CtsPinDef |
| enum UART_RtsPinDef |
|
inlinestatic |
This function servers to indicate Tx state.
| [in] | none. |
|
inlinestatic |
This function resets the UART module.
| [in] | none |
| void uart_init | ( | unsigned short | g_uart_div, |
| unsigned char | g_bwpc, | ||
| UART_ParityTypeDef | Parity, | ||
| UART_StopBitTypeDef | StopBit | ||
| ) |
This function initializes the UART module.
| [in] | g_uart_div | - uart clock divider |
| [in] | g_bwpc | - bitwidth, should be set to larger than sys_clk baud rate g_uart_div g_bwpc
16Mhz 9600 118 13
19200 118 6
115200 9 13
24Mhz 9600 249 9
19200 124 9
115200 12 15
32Mhz 9600 235 13
19200 235 6
115200 17 13
48Mhz 9600 499 9
19200 249 9
115200 25 15
|
| [in] | Parity | - selected parity type for UART interface |
| [in] | StopBit | - selected length of stop bit for UART interface |
| void uart_init_baudrate | ( | unsigned int | Baudrate, |
| unsigned int | System_clock, | ||
| UART_ParityTypeDef | Parity, | ||
| UART_StopBitTypeDef | StopBit | ||
| ) |
This function initializes the UART module.
| [in] | Baudrate | - uart baud rate |
| [in] | System_clock | - clock of system |
| [in] | Parity | - selected parity type for UART interface |
| [in] | StopBit | - selected length of stop bit for UART interface |
| void uart_dma_enable | ( | unsigned char | rx_dma_en, |
| unsigned char | tx_dma_en | ||
| ) |
enable uart DMA mode
| [in] | none |
| void uart_irq_enable | ( | unsigned char | rx_irq_en, |
| unsigned char | tx_irq_en | ||
| ) |
config the irq of uart tx and rx
| [in] | rx_irq_en | - 1:enable rx irq. 0:disable rx irq |
| [in] | tx_irq_en | - 1:enable tx irq. 0:disable tx irq |
| void uart_ndma_send_byte | ( | unsigned char | uartData | ) |
uart send data function with not DMA method. variable uart_TxIndex,it must cycle the four registers 0x90 0x91 0x92 0x93 for the design of SOC. so we need variable to remember the index.
| [in] | uartData | - the data to be send. |
| void uart_ndma_irq_triglevel | ( | unsigned char | rx_level, |
| unsigned char | tx_level | ||
| ) |
config the number level setting the irq bit of status register 0x9d ie 0x9d[3]. uart_ndma_get_irq If the cnt register value(0x9c[0,3]) larger or equal than the value of 0x99[0,3] or the cnt register value(0x9c[4,7]) less or equal than the value of 0x99[4,7], it will set the irq bit of status register 0x9d, ie 0x9d[3]
| [in] | rx_level | - receive level value. ie 0x99[0,3] |
| [in] | tx_level | - transmit level value.ie 0x99[4,7] |
| unsigned char uart_ndmairq_get | ( | void | ) |
get the status of uart irq.
| [in] | none |
| volatile unsigned char uart_dma_send | ( | unsigned char * | Addr | ) |
uart send data function, this function tell the DMA to get data from the RAM and start the DMA transmission
| [in] | Addr | - pointer to the buffer containing data need to send |
| volatile unsigned char uart_send_byte | ( | unsigned char | byte | ) |
uart send data function, this function tell the DMA to get data from the RAM and start the DMA transmission
| [in] | byte | - single byte data need to send |
| void uart_recbuff_init | ( | unsigned char * | RecvAddr, |
| unsigned short | RecvBufLen | ||
| ) |
data receive buffer initiate function. DMA would move received uart data to the address space, uart packet length needs to be no larger than (recBuffLen - 4).
| [in] | RecvAddr | - pointer to the receiving buffer |
| [in] | RecvBufLen | - length in byte of the receiving buffer |
| unsigned char uart_is_parity_error | ( | void | ) |
This function determines whether parity error occurs once a packet arrives.
| [in] | none |
| void uart_clear_parity_error | ( | void | ) |
This function clears parity error status once when it occurs.
| [in] | none |
| void uart_set_rts | ( | unsigned char | Enable, |
| UART_RTSModeTypeDef | Mode, | ||
| unsigned char | Thresh, | ||
| unsigned char | Invert, | ||
| UART_RtsPinDef | pin | ||
| ) |
UART hardware flow control configuration. Configure RTS pin.
| [in] | Enable | - enable or disable RTS function. |
| [in] | Mode | - set the mode of RTS(auto or manual). |
| [in] | Thresh | - threshold of trig RTS pin's level toggle(only for auto mode), it means the number of bytes that has arrived in Rx buf. |
| [in] | Invert | - whether invert the output of RTS pin(only for auto mode) |
| [in] | pin | - RTS pin select,it can be GPIO_PA4/GPIO_PB3/GPIO_PB6/GPIO_PC0. |
| void uart_set_rts_level | ( | unsigned char | Polarity | ) |
This function sets the RTS pin's level manually.
| [in] | Polarity | - set the output of RTS pin(only for manual mode) |
| void uart_set_cts | ( | unsigned char | Enable, |
| unsigned char | Select, | ||
| UART_CtsPinDef | pin | ||
| ) |
UART hardware flow control configuration. Configure CTS pin.
| [in] | Enable | - enable or disable CTS function. |
| [in] | Select | - when CTS's input equals to select, tx will be stopped |
| [in] | pin | - CTS pin select,it can be GPIO_PA3/GPIO_PB2/GPIO_PC4/GPIO_PD1. |
| void uart_gpio_set | ( | UART_TxPinDef | tx_pin, |
| UART_RxPinDef | rx_pin | ||
| ) |
This function serves to select pin for UART module.
| [in] | tx_pin | - the pin to send data. |
| [in] | rx_pin | - the pin to receive data. |