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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [soc/] [hibi_pe_dma_example_1/] [1.0/] [src/] [cpu1/] [main.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * file   main.c
3
 * date   2012-02-21
4
 * author Lasse Lehtonen
5
 *
6
 */
7
 
8
#include <stdio.h>
9
#include <stdlib.h>
10
#include <string.h>
11
#include <sys/alt_irq.h>
12
 
13
 
14
#include "hpd_functions.h"
15
 
16
 
17
void my_hpd_isr();
18
void my_hpd_isr_init();
19
 
20
int main()
21
{
22
  printf("CPU1: starts\n");
23
 
24
  hpd_initialize();
25
  hpd_rx_packet_reinit(3);
26
  my_hpd_isr_init();
27
 
28
  //printf("CPU1: retires!\n");
29
  while(1); return 0;
30
}
31
 
32
 
33
 
34
void my_hpd_isr()
35
{
36
  // This pe gets data only on packet channel 3.
37
  // Omitting others.
38
  char data[17]; data[16] = 0;
39
  if(hpd_rx_packet_poll(3)) {
40
    hpd_rx_packet_read(3, data);
41
    printf("CPU1: \"%s\"\n", data);
42
    hpd_tx_send_copy((int)data, 4, 0x406);
43
    hpd_irq_packet_ack(3);
44
    hpd_rx_packet_reinit(3);
45
  } else {
46
    printf("CPU1: got unexpected interrupt!\n");
47
  }
48
}
49
 
50
 
51
void my_hpd_isr_init()
52
{
53
  int status;
54
 
55
  status = alt_ic_isr_register(HIBI_PE_DMA_1_IRQ_INTERRUPT_CONTROLLER_ID,
56
                               HIBI_PE_DMA_1_IRQ, my_hpd_isr,
57
                               0, 0);
58
 
59
  if(status) {
60
    printf("CPU1: registering my_hpd_isr failed!\n");
61
  }
62
 
63
  status = alt_ic_irq_enable(HIBI_PE_DMA_1_IRQ_INTERRUPT_CONTROLLER_ID,
64
                             HIBI_PE_DMA_1_IRQ);
65
 
66
  if(status) {
67
    printf("CPU1: enabling hpd interrupt failed!\n");
68
  }
69
 
70
  hpd_irq_enable();
71
}

powered by: WebSVN 2.1.0

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