Laurent Huot
/
SPI
drtgddf
UART.cpp@1:2b2be189b4db, 2016-01-11 (annotated)
- Committer:
- larryspaghetti
- Date:
- Mon Jan 11 21:09:20 2016 +0000
- Revision:
- 1:2b2be189b4db
- Parent:
- 0:aab1f335cf6b
f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
larryspaghetti | 0:aab1f335cf6b | 1 | #include "UART.h" |
larryspaghetti | 1:2b2be189b4db | 2 | #include "LPC17xx.h" |
larryspaghetti | 0:aab1f335cf6b | 3 | |
larryspaghetti | 0:aab1f335cf6b | 4 | UART::UART() |
larryspaghetti | 0:aab1f335cf6b | 5 | { |
larryspaghetti | 1:2b2be189b4db | 6 | PCOMP = (int *)0x400FC0C4; |
larryspaghetti | 1:2b2be189b4db | 7 | PCLKSEL0 = (int *)0x400FC1A8; |
larryspaghetti | 1:2b2be189b4db | 8 | U0LCR = (int *)0x4000C00C; |
larryspaghetti | 1:2b2be189b4db | 9 | U0DLL = (int *)0x4000C000; |
larryspaghetti | 1:2b2be189b4db | 10 | U0DLM = (int *)0x4000C004; |
larryspaghetti | 1:2b2be189b4db | 11 | U0FCR = (int *)0x4000C008; |
larryspaghetti | 1:2b2be189b4db | 12 | PINSEL0 = (int *)0x4002C000; |
larryspaghetti | 0:aab1f335cf6b | 13 | |
larryspaghetti | 1:2b2be189b4db | 14 | |
larryspaghetti | 0:aab1f335cf6b | 15 | //Donne acces aux registres DLL et DLM pour set le baud rate |
larryspaghetti | 0:aab1f335cf6b | 16 | *U0LCR |= 0x00000080; |
larryspaghetti | 0:aab1f335cf6b | 17 | |
larryspaghetti | 1:2b2be189b4db | 18 | //On met le registre de PCLK_UART0 à 01 |
larryspaghetti | 1:2b2be189b4db | 19 | *PCLKSEL0 |= 0x00000080; |
larryspaghetti | 1:2b2be189b4db | 20 | |
larryspaghetti | 0:aab1f335cf6b | 21 | //On active les pins pour TXD0 |
larryspaghetti | 0:aab1f335cf6b | 22 | *PINSEL0 &= ~0x00000020; |
larryspaghetti | 0:aab1f335cf6b | 23 | *PINSEL0 |= 0x00000010; |
larryspaghetti | 0:aab1f335cf6b | 24 | |
larryspaghetti | 0:aab1f335cf6b | 25 | //On active le FIFO |
larryspaghetti | 0:aab1f335cf6b | 26 | *U0FCR |= 0x00000001; |
larryspaghetti | 0:aab1f335cf6b | 27 | |
larryspaghetti | 0:aab1f335cf6b | 28 | //8 bits de data |
larryspaghetti | 0:aab1f335cf6b | 29 | *U0LCR |= 0x00000003; |
larryspaghetti | 0:aab1f335cf6b | 30 | //1 Seul stop bit, pas de parite |
larryspaghetti | 0:aab1f335cf6b | 31 | *U0LCR &= ~0x0000000C; |
larryspaghetti | 0:aab1f335cf6b | 32 | } |