OpenCores

Subversion Repositories quad_decoder

[/] [quad_decoder/] [trunk/] [c_src/] [quad_decoder.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 scottnortman
/*------------------------------------------------------------------------------
2
*   File:   quad_decoder.h
3
*   Desc:   Header file for the baseline quadrature decoder driver API.
4
*   Date:   Initiated October, 2009
5
*   Auth:   Scott Nortman, Bridge Electronic Design LLC
6
*   Current Version: v1.0.0
7
*
8
*   Revision History
9
*
10
*
11
*   When        Who                 What
12
*   ---------------------------------------------------------------------------
13
*   10/2009     S. Nortman          Initial development started.
14
*   7/2010      S. Nortman          Added comments, clean code, release v1.0.0
15
*
16
*----------------------------------------------------------------------------*/
17
 
18
#ifndef _QUAD_DECODER_H_
19
#define _QUAD_DECODER_H_
20
 
21
#include <stdint.h>
22
 
23
#ifndef TRUE
24
#define TRUE 1
25
#endif
26
 
27
#ifndef FALSE
28
#define FALSE 0
29
#endif
30
 
31
/* Registers and bit definitions */
32
 
33
/* Quadrature Control Register, offset from base address */
34
#define QUAD_DCDR_QCR_REG( handle ) ( *(volatile uint32_t *)(handle+0x00) )
35
#define QCR_ECNT                    ( 0 )       /* Enable Count bit */
36
#define QCR_CTDR                    ( 1 )       /* Count direction bit */
37
#define QCR_INEN                    ( 2 )       /* Index enable enable bit */
38
#define QCR_INZC                    ( 3 )       /* Index zero count bit */
39
#define QCR_INIE                    ( 4 )       /* Index interrupt enable */
40
#define QCR_PLCT                    ( 5 )       /* Pre-load count bit */
41
#define QCR_UNIE                    ( 6 )       /* Underflow interrupt enable bit */
42
#define QCR_OVIE                    ( 7 )       /* Overflow interrupt enable bit */
43
#define QCR_QLAT                    ( 8 )       /* Quadrature count latch bit */
44
#define QCR_ICHA                    ( 9 )       /* Index CHA set */
45
#define QCR_ICHB                    ( 10 )      /* Index CHB set */
46
#define QCR_IDXL                    ( 11 )      /* Index level set */
47
#define QCR_QEIE                    ( 12 )      /* Quadrature error interrupt enable bit */
48
#define QCR_INRC                    ( 13 )      /* index event causes a read of quad count into QRW */
49
#define QCR_CCME                    ( 14 )      /* Quadrature Compare Match Enable */
50
#define QCR_CMIE                    ( 15 )      /* Quad. Compare Match Interrupt Enable */
51
 
52
/* Quadrature status register */
53
#define QUAD_DCDR_QSR_REG( handle ) ( *(volatile uint32_t *)(handle+0x04))
54
#define QSR_QERR                    ( 0 )       /* Quadrature error status bit */
55
#define QSR_CTOV                    ( 1 )       /* Quadrature counter overflow status bit */
56
#define QSR_CTUN                    ( 2 )       /* Quadrature counter underflow status bit */
57
#define QSR_INEV                    ( 3 )       /* Index event status bit */
58
#define QSR_CCME                    ( 4 )       /* Count Compare Match Event */
59
 
60
/* Quadrature count read / write register */
61
#define QUAD_DCDR_QRW_REG( handle ) ( *(volatile uint32_t *)(handle+0x08))
62
 
63
/*  Function:   quad_dcdr_test
64
*   Desc:       Performs a test of the quadrature decoder module.  See the
65
*               comments in the source file for more information.
66
*   Args:       uint32_t base_add, the base address offset
67
*   Ret:        None
68
*   Note:       Must be called after a successful call to quad_dcdr_ioinit.
69
*               This function calls quad_dcdr_sim.
70
*/
71
void quad_dcdr_test( uint32_t base_add );
72
 
73
/*  Function:
74
*   Desc:
75
*   Args:
76
*   Ret:
77
*   Note:
78
*/
79
int8_t quad_dcdr_ioinit( void );
80
 
81
/*  Function:
82
*   Desc:
83
*   Args:
84
*   Ret:
85
*   Note:
86
*/
87
uint8_t quad_dcdr_sim( int32_t steps, int8_t error );
88
 
89
#endif /* _QUAD_DECODER_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2014 OpenCores.org, equivalent to ORSoC AB, all rights reserved. OpenCores®, registered trademark.