|
1 |
| - .section .text |
2 |
| - .align 4 |
| 1 | +.section .text |
| 2 | +.align 4 |
3 | 3 |
|
4 |
| - .global irq_handler |
5 |
| - #define BUFF_ADDR 0x60800000 |
| 4 | +.global irq_handler |
| 5 | +#define BUFF_ADDR 0x60800000 |
6 | 6 |
|
7 | 7 | irq_handler:
|
8 |
| - stmfd sp!, {r0-r7, ip, lr} |
| 8 | + stmfd sp!,{r0-r7,ip,lr} |
9 | 9 |
|
10 |
| - // get interrupt number |
11 |
| - mov r4, #0x18000000 |
12 |
| - add r4, r4, #0x80000 |
13 |
| - ldr r5, [r4, #0x104] |
14 |
| - and r5, r5, #0x1f |
15 |
| - cmp r5, #0x10 // UDC interrupt |
| 10 | + /* get interrupt number */ |
| 11 | + mov r4,#0x18000000 |
| 12 | + add r4,r4,#0x80000 |
| 13 | + ldr r5,[r4,#0x104] |
| 14 | + and r5,r5,#0x1f |
| 15 | + cmp r5,#0x10 /* UDC interrupt */ |
16 | 16 |
|
17 |
| - bleq udc_irq |
| 17 | + bleq udc_irq |
18 | 18 |
|
19 |
| - // clear pending interrupt |
20 |
| - mov r3, #1 |
21 |
| - mov r2, r3, LSL r5 |
22 |
| - str r2, [r4, #0x118] |
| 19 | + /* clear pending interrupt */ |
| 20 | + mov r3,#1 |
| 21 | + mov r2,r3,LSL r5 |
| 22 | + str r2,[r4,#0x118] |
23 | 23 |
|
24 |
| - ldmfd sp!, {r0-r7, ip, lr} |
25 |
| - subs pc, lr, #4 |
| 24 | + ldmfd sp!,{r0-r7,ip,lr} |
| 25 | + subs pc,lr,#4 |
26 | 26 |
|
27 | 27 | udc_irq:
|
28 |
| - stmfd sp!, {r4-r8, lr} |
| 28 | + stmfd sp!,{r4-r8,lr} |
29 | 29 |
|
30 |
| - // handle usb interrupt |
31 |
| - ldr r4,=0x180A0000 |
32 |
| - ldr r5, [r4, #0x18] // UDC_INTFLAG |
| 30 | + /* handle usb interrupt */ |
| 31 | + ldr r4,=0x180A0000 |
| 32 | + ldr r5,[r4,#0x18] /* UDC_INTFLAG */ |
33 | 33 |
|
34 |
| - // ep0 in intr |
35 |
| - tst r5, #0x04 |
36 |
| - beq bulk_recv_intr |
| 34 | + /* ep0 in intr */ |
| 35 | + tst r5,#0x04 |
| 36 | + beq bulk_recv_intr |
| 37 | +ep0: |
| 38 | + ldr r5,[r4,#0x40] |
| 39 | + mov r5,r5,lsr #10 |
| 40 | + mov r5,r5,lsl #10 /* clear lower 10 bits in TX0STAT */ |
| 41 | + str r5,[r4,#0x40] |
37 | 42 |
|
38 |
| - // write_reg32(UDC_TX0STAT, read_reg32(UDC_TX0STAT) & ~0x7FF); |
39 |
| - ldr r5, [r4, #0x40] |
40 |
| - mov r5, r5, lsr #10 |
41 |
| - mov r5, r5, lsl #10 // clear clower 10 bits |
42 |
| - str r5, [r4, #0x40] |
| 43 | + /* set buffer addres in UDC_DMA0LM_OADDR */ |
| 44 | + mov r5,#0x60000000 |
| 45 | + str r5,[r4, #0x3c] |
43 | 46 |
|
44 |
| - // write_reg32(UDC_DMA0LM_OADDR, (uint32_t)(state.ctrlep_data)); |
45 |
| - mov r5, #0x60000000 |
46 |
| - str r5, [r4, #0x3c] |
| 47 | + /* write DMA_START in UDC_DMA0CTLO */ |
| 48 | + mov r5,#1 |
| 49 | + str r5,[r4,#0x38] |
47 | 50 |
|
48 |
| - // write_reg32(UDC_DMA0CTLO, read_reg32(UDC_DMA0CTLO) | ENP_DMA_START); |
49 |
| - mov r5, #1 |
50 |
| - str r5, [r4, #0x38] |
| 51 | + ldmfd sp!,{r4-r8,pc} |
51 | 52 |
|
52 |
| - ldmfd sp!, {r4-r8, pc} |
53 |
| - |
54 |
| -// bulk out interrupt |
| 53 | +/* bulk out interrupt */ |
55 | 54 | bulk_recv_intr:
|
56 |
| - tst r5, #0x100 |
57 |
| - ldmeqfd sp!, {r4-r8, pc} |
| 55 | + tst r5,#0x100 |
| 56 | + ldmeqfd sp!,{r4-r8,pc} |
58 | 57 |
|
59 |
| - // read UDC_RX1STAT |
60 |
| - ldr r5, [r4, #0x54] |
61 |
| - mov r5, r5, lsl #21 |
62 |
| - mov r5, r5, lsr #21 // r5 = length |
| 58 | + /* read UDC_RX1STAT */ |
| 59 | + ldr r5,[r4,#0x54] |
| 60 | + mov r5,r5,lsl #21 |
| 61 | + mov r5,r5,lsr #21 /* r5 = length */ |
63 | 62 |
|
64 |
| - ldr r6,=usb_sz |
65 |
| - ldr r6, [r6] |
66 |
| - ldr r7, [r6] // r7 = total_code_length expected |
| 63 | + ldr r6,=usb_sz |
| 64 | + ldr r6,[r6] |
| 65 | + ldr r7,[r6] /* r7 = total_code_length expected */ |
67 | 66 |
|
68 |
| - subs r7, r7, r5 |
69 |
| - bne usb_bulk_out1_recv |
| 67 | + subs r7,r7,r5 |
| 68 | + bne usb_bulk_out1_recv |
70 | 69 |
|
71 |
| - // copy from buff to the begining of the ram |
72 |
| - ldr r0,=BUFF_ADDR |
73 |
| - ldr r1,[r0,#-4] // size |
| 70 | + /* copy from buff to the begining of the ram */ |
| 71 | + ldr r0,=BUFF_ADDR |
| 72 | + ldr r1,[r0,#-4] /* size */ |
74 | 73 |
|
75 |
| - ldr r1,=0x800000 // buffer size |
| 74 | + ldr r1,=0x800000 /* buffer size */ |
76 | 75 |
|
77 |
| - add r1,r1,r0 // end address |
78 |
| - ldr r2,=0x60000000 // destination |
| 76 | + add r1,r1,r0 /* end address */ |
| 77 | + ldr r2,=0x60000000 /* destination */ |
79 | 78 | 1:
|
80 |
| - cmp r1,r0 |
81 |
| - ldrhi r3,[r0],#4 |
82 |
| - strhi r3,[r2],#4 |
83 |
| - bhi 1b |
| 79 | + cmp r1,r0 |
| 80 | + ldrhi r3,[r0],#4 |
| 81 | + strhi r3,[r2],#4 |
| 82 | + bhi 1b |
84 | 83 |
|
85 |
| - // execute user code |
86 |
| - ldr r0,=0x60000000 |
87 |
| - bx r0 // jump to 0x60000000 |
| 84 | + /* execute user code */ |
| 85 | + ldr r0,=0x60000000 |
| 86 | + bx r0 /* jump to 0x60000000 */ |
88 | 87 |
|
89 | 88 | usb_bulk_out1_recv:
|
90 |
| - str r7, [r6] // size = size - received |
| 89 | + str r7,[r6] /* size = size - received */ |
91 | 90 |
|
92 |
| - ldr r6,=usb_write_addr |
93 |
| - ldr r7, [r6] |
| 91 | + ldr r6,=usb_write_addr |
| 92 | + ldr r7,[r6] |
94 | 93 |
|
95 |
| - add r7, r7, r5 |
96 |
| - str r7, [r6] // usb_write_addr += length |
| 94 | + add r7,r7,r5 |
| 95 | + str r7,[r6] /* usb_write_addr += length */ |
97 | 96 |
|
98 |
| - str r7, [r4, #0x60] // DMA1LM_OADDR = usb_write_addr |
| 97 | + str r7,[r4,#0x60] /* DMA1LM_OADDR = usb_write_addr */ |
99 | 98 |
|
100 |
| - mov r5, #1 |
101 |
| - str r5, [r4, #0x5c] // DMA1_CTL0 = ENP_DMA_START |
| 99 | + mov r5,#1 |
| 100 | + str r5,[r4,#0x5c] /* DMA1_CTL0 = ENP_DMA_START */ |
102 | 101 |
|
103 |
| - ldmfd sp!, {r4-r8, pc} |
| 102 | + ldmfd sp!,{r4-r8,pc} |
0 commit comments