blob: 2cca7b34a684993a7ec74f3729b3d7bf1a05029c [file] [log] [blame]
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07001/*
2 * Copyright (c) 2008 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <debug.h>
24#include <printf.h>
25#include <platform/at91sam7.h>
26#include <kernel/thread.h>
27#include <stdarg.h>
28
29void ser_init(void)
30{
31 AT91DBGU *dbgu = AT91DBGU_ADDR;
32
33// AT91PIO *pio = AT91PIO_ADDR;
34// pio->select_a = PIN_DRXD | PIN_DTXD;
35// pio->pio_disable = PIN_DRXD | PIN_DTXD;
36
37 dbgu->MR = DBGU_PAR_NONE | DBGU_MODE_NORMAL;
38 // dbgu->BRGR = 10; //MCK_IN_MHZ / 115200 / 16;
39 dbgu->BRGR = AT91_MCK_MHZ / 115200 / 16;
40 dbgu->CR = DBGU_RXEN | DBGU_TXEN;
41}
42
43void ser_putc(unsigned c)
44{
45 AT91DBGU *dbgu = AT91DBGU_ADDR;
46 if(c == 10) {
47 while(!(dbgu->SR & DBGU_TXRDY));
48 dbgu->THR = 13;
49 }
50 while(!(dbgu->SR & DBGU_TXRDY));
51 dbgu->THR = c;
52}
53
54void ser_puts(const char *s)
55{
56 AT91DBGU *dbgu = AT91DBGU_ADDR;
57 while(*s) {
58 if(*s == 10) {
59 while(!(dbgu->SR & DBGU_TXRDY));
60 dbgu->THR = 13;
61 }
62 while(!(dbgu->SR & DBGU_TXRDY));
63 dbgu->THR = *s++;
64 }
65}
66
67void dputc(char c)
68{
69 ser_putc(c);
70}
71
72void debug_halt()
73{
74 arch_disable_ints();
75 for(;;);
76}
77
78uint32_t debug_cycle_count()
79{
80 PANIC_UNIMPLEMENTED;
81}