Subversion Repositories freemyipod

Rev

Rev 652 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
495 theseven 1
#include "emcoreapp.h"
2
 
3
 
4
#define ULCON  (*((uint32_t volatile*)0x3cc00000))
5
#define UCON   (*((uint32_t volatile*)0x3cc00004))
6
#define UFCON  (*((uint32_t volatile*)0x3cc00008))
7
#define UMCON  (*((uint32_t volatile*)0x3cc0000c))
8
#define UFSTAT (*((uint32_t volatile*)0x3cc00018))
9
#define UTXH   (*((uint8_t volatile*)0x3cc00020))
10
#define URXH   (*((uint8_t volatile*)0x3cc00024))
11
#define UBRDIV (*((uint32_t volatile*)0x3cc00028))
12
 
13
 
14
static void uart_tx(char byte)
15
{
16
    while (UFSTAT & BIT(9)) sleep(100);
17
    UTXH = byte;
18
}
19
 
20
static char uart_rx()
21
{
22
    while (!(UFSTAT & BITRANGE(0, 3))) sleep(100);
23
    return URXH;
24
}
25
 
26
static void main()
27
{
28
    int i;
29
    clockgate_enable(41, true);
30
    ULCON = 3;
31
    UCON = 0x405;
32
    UFCON = 7;
33
    UMCON = 0;
34
    switch (get_platform_id())
35
    {
36
    case 0x47324e49:  // IN2G
37
        UBRDIV = 38;
38
        break;
39
    case 0x4c435049:  // IPCL
40
        UBRDIV = 18;
41
        break;
42
    default:
43
        panic(PANIC_KILLTHREAD, "Unknown platform!");
44
    }
45
    uart_tx('~');
46
    while (true) uart_tx(uart_rx() ^ 0x20);
47
}
48
 
49
 
50
EMCORE_APP_HEADER("UART test", main, 127)