1 | #include <stdio.h>
|
2 | #include <math.h>
|
3 | #include <xgpio.h>
|
4 | #include <xparameters.h>
|
5 | #include <xintc.h>
|
6 | #include <xuartlite.h>
|
7 | #include <xuartlite_l.h>
|
8 | #include "platform.h"
|
9 | #include "mb_interface.h"
|
10 |
|
11 |
|
12 | XUartLite_Handler CallBackRef;
|
13 |
|
14 |
|
15 | void print(char *str);
|
16 | void RecvHandler(void *CallBackRef);
|
17 | //void RecvTestHandler(void *CallBackRef);
|
18 |
|
19 | void Random_ISR (void * CallbackRef);
|
20 |
|
21 | int status;
|
22 |
|
23 | XUartLite interrupt;
|
24 | //XGpio interrupt;
|
25 | XGpio pwm;
|
26 | XGpio enable;
|
27 | XIntc intc;
|
28 |
|
29 | int main()
|
30 | {
|
31 |
|
32 | status = XUartLite_Initialize(&interrupt, XPAR_UARTLITE_0_DEVICE_ID);
|
33 | if (status != XST_SUCCESS) {
|
34 | print("XUartLite crash\n\r");
|
35 | }
|
36 |
|
37 | status = XUartLite_SelfTest(&interrupt);
|
38 | if (status != XST_SUCCESS) {
|
39 | print("XUartLite_SelfTest crash\n\r");
|
40 | }
|
41 | //XGpio_Initialize(&interrupt, XPAR_RS232_UART_1_DEVICE_ID);
|
42 | status = XIntc_Initialize(&intc, XPAR_INTC_0_DEVICE_ID);
|
43 | if (status != XST_SUCCESS) {
|
44 | print("XIntc_Initialize crash\n\r");
|
45 | }
|
46 |
|
47 | XGpio_Initialize(&pwm, XPAR_PWM_GPIO_0_DEVICE_ID);
|
48 | XGpio_Initialize(&enable, XPAR_EN_GPIO_0_DEVICE_ID);
|
49 |
|
50 |
|
51 | //XUartLite_SetRecvHandler(&interrupt, RecvHandler, &interrupt);
|
52 | status = XIntc_Connect(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR, (XInterruptHandler)RecvHandler, (void *)&interrupt);
|
53 | if (status != XST_SUCCESS) {
|
54 | print("XIntc_Initialize crash\n\r");
|
55 | }
|
56 | status = XIntc_Start(&intc, XIN_REAL_MODE);
|
57 | if (status != XST_SUCCESS) {
|
58 | print("XIntc_Start crash\n\r");
|
59 | }
|
60 | XIntc_Enable(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR);
|
61 |
|
62 | XGpio_SetDataDirection(&pwm,1,0);
|
63 | XGpio_SetDataDirection(&enable,1,0);
|
64 |
|
65 | microblaze_enable_interrupts();
|
66 |
|
67 | print("Ready\n\r");
|
68 |
|
69 | XUartLite_EnableInterrupt(&interrupt);
|
70 |
|
71 |
|
72 | //XUartLite_SetRecvHandler(&interrupt, RecvTestHandler, &interrupt);
|
73 |
|
74 | //XGpio_InterruptGlobalEnable (&interrupt);
|
75 | //XGpio_InterruptEnable(&interrupt, XGPIO_IR_CH1_MASK);
|
76 | //microblaze_enable_interrupts();
|
77 |
|
78 | while (1)
|
79 | {
|
80 | //printf("while(1)");
|
81 | //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR, 0xaa);
|
82 | //status = XUartLite_RecvByte(XPAR_RS232_UART_1_BASEADDR);
|
83 | //printf("RCV=%d\n\r",status);
|
84 |
|
85 | }
|
86 |
|
87 | }
|
88 |
|
89 | //void Random_ISR(void *CallbackRef)
|
90 | void RecvHandler(void *CallBackRef)
|
91 | {
|
92 | XIntc_Acknowledge(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR);
|
93 | print("RCV\n\r");
|
94 | XUartLite_ResetFifos(&interrupt);
|
95 |
|
96 | }
|