source: PlatformSupport/CustomPeripherals/pcores/warp_timer_plbw_v1_00_a/src/warp_timer_plbw.c

Last change on this file was 1042, checked in by kwilhelm, 16 years ago

adding warp_timer

File size: 3.7 KB
Line 
1///////////////////////////////////////////////////////////////-*-C-*-
2//
3// Copyright (c) 2007 Xilinx, Inc.  All rights reserved.
4//
5// Xilinx, Inc.  XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION
6// "AS IS" AS  A COURTESY TO YOU.  BY PROVIDING  THIS DESIGN, CODE, OR
7// INFORMATION  AS  ONE   POSSIBLE  IMPLEMENTATION  OF  THIS  FEATURE,
8// APPLICATION OR  STANDARD, XILINX  IS MAKING NO  REPRESENTATION THAT
9// THIS IMPLEMENTATION  IS FREE FROM  ANY CLAIMS OF  INFRINGEMENT, AND
10// YOU ARE  RESPONSIBLE FOR OBTAINING  ANY RIGHTS YOU MAY  REQUIRE FOR
11// YOUR  IMPLEMENTATION.   XILINX  EXPRESSLY  DISCLAIMS  ANY  WARRANTY
12// WHATSOEVER  WITH RESPECT  TO  THE ADEQUACY  OF THE  IMPLEMENTATION,
13// INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR REPRESENTATIONS THAT
14// THIS IMPLEMENTATION  IS FREE  FROM CLAIMS OF  INFRINGEMENT, IMPLIED
15// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16//
17//////////////////////////////////////////////////////////////////////
18
19#include "warp_timer_plbw.h"
20#include "xparameters.h"
21#include "xcope.h"
22
23inline xc_status_t xc_warp_timer_plbw_create(xc_iface_t **iface, void *config_table)
24{
25    // set up iface
26    *iface = (xc_iface_t *) config_table;
27
28#ifdef XC_DEBUG
29    WARP_TIMER_PLBW_Config *_config_table = config_table;
30
31    if (_config_table->xc_create == NULL) {
32        print("config_table.xc_create == NULL\r\n");
33        exit(1);
34    }
35#endif
36
37    // does nothing
38    return XC_SUCCESS;
39}
40
41inline xc_status_t xc_warp_timer_plbw_release(xc_iface_t **iface) 
42{
43    // does nothing
44    return XC_SUCCESS;
45}
46
47inline xc_status_t xc_warp_timer_plbw_open(xc_iface_t *iface)
48{
49    // does nothing
50    return XC_SUCCESS;
51}
52
53inline xc_status_t xc_warp_timer_plbw_close(xc_iface_t *iface)
54{
55    // does nothing
56    return XC_SUCCESS;
57}
58
59inline xc_status_t xc_warp_timer_plbw_read(xc_iface_t *iface, xc_r_addr_t addr, uint32_t *value)
60{
61    *value = *((uint32_t *) addr);
62    return XC_SUCCESS;
63}
64
65inline xc_status_t xc_warp_timer_plbw_write(xc_iface_t *iface, xc_w_addr_t addr, const uint32_t value)
66{
67    *((uint32_t *) addr) = value;
68    return XC_SUCCESS;
69}
70
71xc_status_t xc_warp_timer_plbw_getshmem(xc_iface_t *iface, const char *name, void **shmem)
72{
73    WARP_TIMER_PLBW_Config *_config_table = (WARP_TIMER_PLBW_Config *) iface;
74
75    if (strcmp("timer0_timeLeft", name) == 0) {
76        *shmem = (void *) & _config_table->timer0_timeLeft;
77    }
78    else if (strcmp("timer1_timeLeft", name) == 0) {
79        *shmem = (void *) & _config_table->timer1_timeLeft;
80    }
81    else if (strcmp("timer2_timeLeft", name) == 0) {
82        *shmem = (void *) & _config_table->timer2_timeLeft;
83    }
84    else if (strcmp("timer3_timeLeft", name) == 0) {
85        *shmem = (void *) & _config_table->timer3_timeLeft;
86    }
87    else if (strcmp("timer_control_r", name) == 0) {
88        *shmem = (void *) & _config_table->timer_control_r;
89    }
90    else if (strcmp("timer_status", name) == 0) {
91        *shmem = (void *) & _config_table->timer_status;
92    }
93    else if (strcmp("timer0_countTo", name) == 0) {
94        *shmem = (void *) & _config_table->timer0_countTo;
95    }
96    else if (strcmp("timer1_countTo", name) == 0) {
97        *shmem = (void *) & _config_table->timer1_countTo;
98    }
99    else if (strcmp("timer2_countTo", name) == 0) {
100        *shmem = (void *) & _config_table->timer2_countTo;
101    }
102    else if (strcmp("timer3_countTo", name) == 0) {
103        *shmem = (void *) & _config_table->timer3_countTo;
104    }
105    else if (strcmp("timer_control_w", name) == 0) {
106        *shmem = (void *) & _config_table->timer_control_w;
107    } else { shmem = NULL; return XC_FAILURE; } 
108
109    return XC_SUCCESS;
110}
Note: See TracBrowser for help on using the repository browser.