Statistics: Posted by costaud — Mon Jan 12, 2015 11:07 am
Code:
typedef enum {
FIVE_BITS = 0x0,
SIX_BITS = 0x1,
SEVEN_BITS = 0x2,
EIGHT_BITS = 0x3
} UartBitsNum4Char;
typedef enum {
ONE_STOP_BIT = 0,
ONE_HALF_STOP_BIT = BIT2, //0x00000004
TWO_STOP_BIT = BIT2
} UartStopBitsNum;
typedef enum {
NONE_BITS = 0,
ODD_BITS = 0,
EVEN_BITS = BIT4 //0x00000010
} UartParityMode;
typedef enum {
STICK_PARITY_DIS = 0,
STICK_PARITY_EN = BIT3 | BIT5 // 0x00000008| 0x00000020
} UartExistParity;
Code:
WRITE_PERI_REG(UART_CONF0(uart_no), (UartExistParity) UartDev.exist_parity
| (UartParityMode) UartDev.parity
| ((UartStopBitsNum)UartDev.stop_bits << UART_STOP_BIT_NUM_S)
| ((UartBitsNum4Char)UartDev.data_bits << UART_BIT_NUM_S));
Code:
#define UART_CONF0( i ) (REG_UART_BASE( i ) + 0x20)
#define REG_UART_BASE( i ) (0x60000000+(i)*0xf00)
#define UART_STOP_BIT_NUM_S 4
#define UART_BIT_NUM_S 2
Code:
typedef enum {
STICK_PARITY_DIS = 0, // No parity
STICK_PARITY_EN = BIT1
} UartExistParity;
typedef enum {
ODD_BITS = BIT0,
EVEN_BITS = 0
} UartParityMode;
typedef enum {
ONE_STOP_BIT = 1,
ONE_HALF_STOP_BIT = 2,
TWO_STOP_BIT = 3
} UartStopBitsNum;
Code:
WRITE_PERI_REG(UART_CONF0(uart_no), UartDev.exist_parity
| UartDev.parity
| (UartDev.stop_bits << UART_STOP_BIT_NUM_S)
| (UartDev.data_bits << UART_BIT_NUM_S));
Statistics: Posted by Peter — Sun Jan 11, 2015 6:11 pm