OpenCores
URL https://opencores.org/ocsvn/usb_device_core/usb_device_core/trunk

Subversion Repositories usb_device_core

[/] [usb_device_core/] [trunk/] [sw/] [example.c] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ultra_embe
#include <stdint.h>
2
#include <unistd.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include "timer.h"
6
#include "usb_uart.h"
7
#include "usb_cdc.h"
8
#include "usb_device.h"
9
#include "usbf_hw.h"
10
 
11
//-----------------------------------------------------------------
12
// Defines:
13
//-----------------------------------------------------------------
14
#define USB_DEV_BASE   0x80000000
15
 
16
//-----------------------------------------------------------------
17
// main
18
//-----------------------------------------------------------------
19
int main(int argc, char *argv[])
20
{
21
    printf("USB Device Test\n");
22
 
23
    // USB init
24
    usbf_init(USB_DEV_BASE, 0, usb_cdc_process_request);
25
    usb_uart_init();
26
 
27
    // Force detach
28
    usbhw_attach(0);
29
    timer_sleep(100);
30
    usbhw_attach(1);
31
 
32
    while (1)
33
    {
34
        usbhw_service();
35
 
36
        // Loopback
37
        if (usb_uart_haschar())
38
        {
39
            int ch = usb_uart_getchar();
40
            printf("Received %c\n", ch);
41
            usb_uart_putchar(ch);
42
        }
43
    }
44
 
45
    return 0;
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.