projects
/
my-code
/
arm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b5dc3e
)
more testing, still uart0 not working!
author
hackbard
<hackbard@staubsauger.localdomain>
Wed, 8 Aug 2007 01:38:59 +0000
(
03:38
+0200)
committer
hackbard
<hackbard@staubsauger.localdomain>
Wed, 8 Aug 2007 01:38:59 +0000
(
03:38
+0200)
betty/fwbc.c
patch
|
blob
|
history
diff --git
a/betty/fwbc.c
b/betty/fwbc.c
index
fecb753
..
a625716
100644
(file)
--- a/
betty/fwbc.c
+++ b/
betty/fwbc.c
@@
-10,48
+10,69
@@
#define OSC_CLOCK 10000000
#define BAUDRATE 9600
#define OSC_CLOCK 10000000
#define BAUDRATE 9600
-#define P_DIV
1
+#define P_DIV
4
#define P_CLOCK (OSC_CLOCK/P_DIV)
typedef unsigned char u8;
typedef unsigned int u32;
#define P_CLOCK (OSC_CLOCK/P_DIV)
typedef unsigned char u8;
typedef unsigned int u32;
-void uart0_init(u32 br) {
+
+/* memory mapping */
+
+#define MMAP_BL 0x00
+#define MMAP_RAM 0x02
+#define MMAP_EXT 0x03
+
+void mmap_init(u8 memtype) {
+
+ MEMMAP=memtype;
+}
+
+void uart0_init(void) {
/* pin select -> tx rx */
/* pin select -> tx rx */
- PINSEL0&=~((1<<0)|(1<<1)|(1<<2)|(1<<3));
- PINSEL0|=((1<<0)|(1<<2));
+ PINSEL0=0x05;
- /* divisor */
- UART0_LCR|=(1<<7);
- //UART0_DLL=((OSC_CLOCK/(16*br)))&0xff;
- //UART0_DLM=(((OSC_CLOCK/(16*br)))&0xff00)>>8;
- UART0_DLL=65;
- UART0_DLM=0;
+ /* enable fifo */
+ UART0_FCR=0x07;
- /*
8 bit data
*/
- UART0_LCR=
((1<<0)|(1<<1))
;
+ /*
set dlab + word length
*/
+ UART0_LCR=
0x83
;
- /* activate rx tx fifo */
- UART0_FCR|=((1<<0)|(1<<1)|(1<<2));
+ /* set baud rate to 9600 @ 10/4 mhz */
+ UART0_DLL=0x10;
+ UART0_DLM=0x00;
+
+ /* unset dlab */
+ UART0_LCR=0x03;
}
}
-void uart_send(u8 byte) {
+void uart_send(char *txbuf) {
+
+ int i;
+
+ i=0;
- /* wait for empty transmit buffer */
- while(!(UART0_LSR&(1<<5)))
- continue;
+ while(txbuf[i])
+ UART0_THR=txbuf[i++];
+ UART0_THR='\n';
+ UART0_THR='\r';
- UART0_THR=byte;
+ while(!(UART0_LSR&(1<<6))) {}
}
int main(void) {
}
int main(void) {
+ char txbuf[]="uart0 working";
+
+ /* memory mapping of interrupt vectors to static ram */
+ mmap_init(MMAP_RAM);
+
/* initialization */
/* initialization */
- uart0_init(
9600
);
+ uart0_init();
while(1) {
while(1) {
- uart_send(
0x23
);
+ uart_send(
txbuf
);
}
return 0;
}
return 0;