1 |
2 |
fkluge |
/**
|
2 |
|
|
* $Id: scct.h 2 2015-06-15 13:52:02Z fkluge $
|
3 |
|
|
* @file scct.h
|
4 |
|
|
* @brief Register map and bit definitions for SCCT, assuming
|
5 |
|
|
* a 32 bit architecture.
|
6 |
|
|
* @author Florian Kluge <kluge@informatik.uni-augsburg.de>
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
#ifndef SCCT_H
|
10 |
|
|
#define SCCT_H 1
|
11 |
|
|
|
12 |
|
|
#ifdef __cplusplus
|
13 |
|
|
extern "C" {
|
14 |
|
|
#endif
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* @name Registers
|
18 |
|
|
* @{
|
19 |
|
|
*/
|
20 |
|
|
|
21 |
|
|
#define SCCT_CTR 0x00 //!< Counter registers (32 bit)
|
22 |
|
|
#define SCCT_PSC 0x04 //!< Prescaler (32 bit)
|
23 |
|
|
#define SCCT_CTR_IE 0x08 //!< Counter interrupt enable
|
24 |
|
|
#define SCCT_CTR_IS 0x0c //!< Counter interrupt status
|
25 |
|
|
|
26 |
|
|
#define SCCT_CH_MS 0x20 //!< Channel mode select (8 bit), 0=IC, 1=OC
|
27 |
|
|
#define SCCT_CH_AS 0x24 //!< Channel action select (16 bit)
|
28 |
|
|
#define SCCT_CH_IE 0x28 //!< Channel interrupt enable (8 bit)
|
29 |
|
|
#define SCCT_CH_IS 0x2c //!< Channel interrupt status (8 bit)
|
30 |
|
|
|
31 |
|
|
#define SCCT_CH_OCF 0x30 //!< Force output compare (8 bit)
|
32 |
|
|
#define SCCT_CH_INP 0x34 //!< Read input pins status (8 bit)
|
33 |
|
|
#define SCCT_CH_OUT 0x38 //!< Reat output pins status (8 bit)
|
34 |
|
|
|
35 |
|
|
#define SCCT_CH_CCR0 0x40 //!< Channel 0 capture/compare register
|
36 |
|
|
#define SCCT_CH_CCR1 0x44 //!< Channel 1 capture/compare register
|
37 |
|
|
#define SCCT_CH_CCR2 0x48 //!< Channel 2 capture/compare register
|
38 |
|
|
#define SCCT_CH_CCR3 0x4c //!< Channel 3 capture/compare register
|
39 |
|
|
#define SCCT_CH_CCR4 0x50 //!< Channel 4 capture/compare register
|
40 |
|
|
#define SCCT_CH_CCR5 0x54 //!< Channel 5 capture/compare register
|
41 |
|
|
#define SCCT_CH_CCR6 0x58 //!< Channel 6 capture/compare register
|
42 |
|
|
#define SCCT_CH_CCR7 0x5c //!< Channel 7 capture/compare register
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
*@}
|
46 |
|
|
*/
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* @name Bit definitions
|
51 |
|
|
* @{
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
#define SCCT_CTR_I_O 0x1 //!< Counter overflow interrupt bit
|
55 |
|
|
|
56 |
|
|
#define SCCT_CH_MS_IC 0x0 //!< Input-capture mode
|
57 |
|
|
#define SCCT_CH_MS_OC 0x1 //!< Output-compare mode
|
58 |
|
|
|
59 |
|
|
#define SCCT_IC_NONE 0x0 //!< No IC
|
60 |
|
|
#define SCCT_IC_POSEDGE 0x1 //!< Capture rising edges
|
61 |
|
|
#define SCCT_IC_NEGEDGE 0x2 //!< Capture falling edges
|
62 |
|
|
#define SCCT_IC_ANYEDGE 0x3 //!< Capture any edge
|
63 |
|
|
|
64 |
|
|
#define SCCT_OC_NONE 0x0 //!< No OC output action
|
65 |
|
|
#define SCCT_OC_HIGH 0x1 //!< Pull OC pin to high
|
66 |
|
|
#define SCCT_OC_LOW 0x2 //!< Pull OC pin to low
|
67 |
|
|
#define SCCT_OC_TOGGLE 0x3 //!< Toggle OC pin level
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* @}
|
71 |
|
|
*/
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* @name Macros for bit shifts
|
76 |
|
|
* The return values of these macros must be bitwise or'ed with the
|
77 |
|
|
* corresponding register's current content.
|
78 |
|
|
* @{
|
79 |
|
|
*/
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* @brief Calculate bit for 1-bit register.
|
83 |
|
|
*
|
84 |
|
|
* Use this macro to calculate bitmasks for the SCCT_CH_MS, SCCT_CH_IE,
|
85 |
|
|
* and SCCT_CH_OCF registers.
|
86 |
|
|
* Results can also be used to test the SCCT_CH_IS, SCCT_CH_INP, and
|
87 |
|
|
* SCCT_CH_OUT registers.
|
88 |
|
|
*
|
89 |
|
|
* @param channel For which channel?
|
90 |
|
|
* @param value the value for the bit
|
91 |
|
|
* @return a bit mask with the relevant bit set to the given value
|
92 |
|
|
*/
|
93 |
|
|
#define SCCT_CH_BITS_1(channel, value) (((value) << (channel)) & (1 << (channel)))
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* @brief Calculate bit for 2-bit register
|
97 |
|
|
* @param channel For which channel?
|
98 |
|
|
* @param value the value for the bits
|
99 |
|
|
* @return a bit mask with the relevant bits set to the given value
|
100 |
|
|
*/
|
101 |
|
|
#define SCCT_CH_BITS_2(channel, value) (((value) << ((channel)*2)) & (3 << ((channel)*2)))
|
102 |
|
|
|
103 |
|
|
/**
|
104 |
|
|
* @brief Get bitmask for setting channel do mode value
|
105 |
|
|
* @param channel Affected channel
|
106 |
|
|
* @param value Target mode, one of #SCCT_CH_MS_IC or #SCCT_CH_MS_OC
|
107 |
|
|
* @return corresponding bitmask
|
108 |
|
|
*/
|
109 |
|
|
#define SCCT_CH_MODE(channel, value) SCCT_CH_BITS_1((channel), (value))
|
110 |
|
|
|
111 |
|
|
/**
|
112 |
|
|
* @brief Get bitmask to set given channel to input-capture mode
|
113 |
|
|
* @param channel Affected channel
|
114 |
|
|
* @return Bitmask to set the given channel to input-capture mode
|
115 |
|
|
*/
|
116 |
|
|
#define SCCT_CH_MODE_IC(channel) SCCT_CH_MODE((channel), SCCT_CH_MS_IC)
|
117 |
|
|
|
118 |
|
|
/**
|
119 |
|
|
* @brief Get bitmask to set given channel to output-compare mode
|
120 |
|
|
* @param channel Affected channel
|
121 |
|
|
* @return Bitmask to set the given channel to output-compare mode
|
122 |
|
|
*/
|
123 |
|
|
#define SCCT_CH_MODE_OC(channel) SCCT_CH_MODE((channel), SCCT_CH_MS_OC)
|
124 |
|
|
|
125 |
|
|
/**
|
126 |
|
|
* @brief Get bitmask to set given channel's action
|
127 |
|
|
* @param channel Affected channel
|
128 |
|
|
* @param value depending on the channel's mode, either one of
|
129 |
|
|
* #SCCT_IC_NONE, #SCCT_IC_POSEDGE, #SCCT_IC_NEGEDGE, #SCCT_IC_ANYEDGE,
|
130 |
|
|
* or #SCCT_OC_NONE, #SCCT_OC_HIGH, #SCCT_OC_LOW, #SCCT_OC_TOGGLE.
|
131 |
|
|
* @return corresponding bitmask
|
132 |
|
|
*/
|
133 |
|
|
#define SCCT_CH_ACTION(channel, value) SCCT_CH_BITS_2((channel), (value))
|
134 |
|
|
|
135 |
|
|
/**
|
136 |
|
|
* @}
|
137 |
|
|
*/
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
#ifdef __cplusplus
|
141 |
|
|
}
|
142 |
|
|
#endif
|
143 |
|
|
|
144 |
|
|
#endif // !SCCT_H
|