serial.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __RT_SERIAL_H__
  2. #define __RT_SERIAL_H__
  3. #ifndef AT91C_BASE_US0
  4. #define AT91C_BASE_US0 (0xFFFC0000) // (US0) Base Address
  5. #endif
  6. #ifndef AT91C_BASE_US1
  7. #define AT91C_BASE_US1 (0xFFFC4000) // (US1) Base Address
  8. #endif
  9. #define AT91C_US_RXRDY ((unsigned int) 0x1 << 0) /* US RXRDY Interrupt */
  10. #define AT91C_US_TXRDY ((unsigned int) 0x1 << 1) /* US TXRDY Interrupt */
  11. #define AT91C_US_RSTRX ((unsigned int) 0x1 << 2) /* US Reset Receiver */
  12. #define AT91C_US_RSTTX ((unsigned int) 0x1 << 3) /* US Reset Transmitter */
  13. #define AT91C_US_RXEN ((unsigned int) 0x1 << 4) /* US Receiver Enable */
  14. #define AT91C_US_RXDIS ((unsigned int) 0x1 << 5) /* US Receiver Disable */
  15. #define AT91C_US_TXEN ((unsigned int) 0x1 << 6) /* US Transmitter Enable */
  16. #define AT91C_US_TXDIS ((unsigned int) 0x1 << 7) /* US Transmitter Disable */
  17. #define AT91C_US_RSTSTA ((unsigned int) 0x1 << 8) /* US Reset Status Bits */
  18. #define AT91C_US_USMODE_NORMAL ((unsigned int) 0x0) /* USAR) Normal */
  19. #define AT91C_US_USMODE_RS485 ((unsigned int) 0x1) /* USAR) RS485 */
  20. #define AT91C_US_USMODE_HWHSH ((unsigned int) 0x2) /* USAR) Hardware Handshaking */
  21. #define AT91C_US_USMODE_MODEM ((unsigned int) 0x3) /* USAR) Modem */
  22. #define AT91C_US_USMODE_ISO7816_0 ((unsigned int) 0x4) /* USAR) ISO7816 protocol: T = 0 */
  23. #define AT91C_US_USMODE_ISO7816_1 ((unsigned int) 0x6) /* USAR) ISO7816 protocol: T = 1 */
  24. #define AT91C_US_USMODE_IRDA ((unsigned int) 0x8) /* USAR) IrDA */
  25. #define AT91C_US_USMODE_SWHSH ((unsigned int) 0xC) /* USAR) Software Handshaking */
  26. #define AT91C_US_CLKS_CLOCK ((unsigned int) 0x0 << 4) /* USAR) Clock */
  27. #define AT91C_US_CLKS_FDIV1 ((unsigned int) 0x1 << 4) /* USAR) fdiv1 */
  28. #define AT91C_US_CLKS_SLOW ((unsigned int) 0x2 << 4) /* USAR) slow_clock (ARM) */
  29. #define AT91C_US_CLKS_EXT ((unsigned int) 0x3 << 4) /* USAR) External (SCK) */
  30. #define AT91C_US_CHRL_5_BITS ((unsigned int) 0x0 << 6) /* USAR) Character Length: 5 bits */
  31. #define AT91C_US_CHRL_6_BITS ((unsigned int) 0x1 << 6) /* USAR) Character Length: 6 bits */
  32. #define AT91C_US_CHRL_7_BITS ((unsigned int) 0x2 << 6) /* USAR) Character Length: 7 bits */
  33. #define AT91C_US_CHRL_8_BITS ((unsigned int) 0x3 << 6) /* USAR) Character Length: 8 bits */
  34. #define AT91C_US_PAR_EVEN ((unsigned int) 0x0 << 9) /* DBGU Even Parity */
  35. #define AT91C_US_PAR_ODD ((unsigned int) 0x1 << 9) /* DBGU Odd Parity */
  36. #define AT91C_US_PAR_SPACE ((unsigned int) 0x2 << 9) /* DBGU Parity forced to 0 (Space) */
  37. #define AT91C_US_PAR_MARK ((unsigned int) 0x3 << 9) /* DBGU Parity forced to 1 (Mark) */
  38. #define AT91C_US_PAR_NONE ((unsigned int) 0x4 << 9) /* DBGU No Parity */
  39. #define AT91C_US_PAR_MULTI_DROP ((unsigned int) 0x6 << 9) /* DBGU Multi-drop mode */
  40. #define AT91C_US_NBSTOP_1_BIT ((unsigned int) 0x0 << 12) /* USART 1 stop bit */
  41. #define AT91C_US_NBSTOP_15_BIT ((unsigned int) 0x1 << 12) /* USART Asynchronous (SYNC=0) 2 stop bits Synchronous (SYNC=1) 2 stop bits */
  42. #define AT91C_US_NBSTOP_2_BIT ((unsigned int) 0x2 << 12) /* USART 2 stop bits */
  43. #define MCK 48054857
  44. #define BR 115200 /* Baud Rate */
  45. #define BRD (MCK/16/BR) /* Baud Rate Divisor */
  46. #endif