1 | /** |
---|
2 | * @file io-defs.h |
---|
3 | * |
---|
4 | * @ingroup lpc176x |
---|
5 | * |
---|
6 | * @brief Input/output module definitions. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2014 Taller Technologies. |
---|
11 | * |
---|
12 | * @author Boretto Martin (martin.boretto@tallertechnologies.com) |
---|
13 | * @author Diaz Marcos (marcos.diaz@tallertechnologies.com) |
---|
14 | * @author Lenarduzzi Federico (federico.lenarduzzi@tallertechnologies.com) |
---|
15 | * @author Daniel Chicco (daniel.chicco@tallertechnologies.com) |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.com/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef LIBBSP_ARM_LPC176X_IO_DEFS_H |
---|
23 | #define LIBBSP_ARM_LPC176X_IO_DEFS_H |
---|
24 | |
---|
25 | #include <bsp/lpc176x.h> |
---|
26 | #include <bsp/common-types.h> |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif /* __cplusplus */ |
---|
31 | |
---|
32 | #define LPC176X_PLL0CON 0XAAU |
---|
33 | #define LPC176X_PLL0CFG 0X55U |
---|
34 | |
---|
35 | #define LPC176X_CCLK_PRESCALER_DIVISOR 1000000U |
---|
36 | |
---|
37 | #define LPC176X_PINSEL ( &PINSEL0 ) |
---|
38 | #define LPC176X_PINMODE ( &PINMODE0 ) |
---|
39 | |
---|
40 | #define LPC176X_PIN_SELECT( index ) ( ( index ) >> 4U ) |
---|
41 | #define LPC176X_PIN_SELECT_SHIFT( index ) ( ( ( index ) & 0xFU ) << 1U ) |
---|
42 | #define LPC176X_PIN_SELECT_MASK 0x3U |
---|
43 | #define LPC176X_PIN_SELECT_MASK_SIZE 2U |
---|
44 | #define LPC176X_PIN_UART_0_TXD 2U |
---|
45 | #define LPC176X_PIN_UART_0_RXD 3U |
---|
46 | #define LPC176X_PIN_UART_1_TXD 15U |
---|
47 | #define LPC176X_PIN_UART_1_RXD 16U |
---|
48 | #define LPC176X_PIN_UART_2_TXD 10U |
---|
49 | #define LPC176X_PIN_UART_2_RXD 11U |
---|
50 | #define LPC176X_PIN_UART_3_TXD 0U |
---|
51 | #define LPC176X_PIN_UART_3_RXD 1U |
---|
52 | |
---|
53 | #define LPC176X_MODULE_BITS_COUNT 32U |
---|
54 | #define LPC176X_MODULE_COUNT ( LPC176X_MODULE_USB + 1U ) |
---|
55 | |
---|
56 | #define LPC176X_IO_PORT_COUNT 5U |
---|
57 | #define LPC176X_IO_INDEX_MAX ( LPC176X_IO_PORT_COUNT * \ |
---|
58 | LPC176X_MODULE_BITS_COUNT ) |
---|
59 | #define LPC176X_IO_INDEX_BY_PORT( port, bit ) ( ( ( port ) << 5U ) + ( bit ) ) |
---|
60 | #define LPC176X_IO_PORT( index ) ( ( index ) >> 5U ) |
---|
61 | #define LPC176X_IO_PORT_BIT( index ) ( ( index ) & 0x1FU ) |
---|
62 | |
---|
63 | /** |
---|
64 | * @brief Defines the functions according to the pin. |
---|
65 | * |
---|
66 | * Enumerated type to define the set of pin function for a io device. |
---|
67 | */ |
---|
68 | typedef enum { |
---|
69 | LPC176X_PIN_FUNCTION_00, |
---|
70 | LPC176X_PIN_FUNCTION_01, |
---|
71 | LPC176X_PIN_FUNCTION_10, |
---|
72 | LPC176X_PIN_FUNCTION_11, |
---|
73 | LPC176X_PIN_FUNCTION_COUNT |
---|
74 | } |
---|
75 | lpc176x_pin_function; |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief Defines the pin modes. |
---|
79 | * |
---|
80 | */ |
---|
81 | typedef enum { |
---|
82 | LPC176X_PIN_MODE_PULLUP, |
---|
83 | LPC176X_PIN_MODE_REPEATER, |
---|
84 | LPC176X_PIN_MODE_NONE, |
---|
85 | LPC176X_PIN_MODE_PULLDOWN, |
---|
86 | LPC176X_PIN_MODE_COUNT |
---|
87 | } |
---|
88 | lpc176x_pin_mode; |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief Defines all type of pins. |
---|
92 | * |
---|
93 | * Enumerated type to define the set of pin type for a io device. |
---|
94 | */ |
---|
95 | typedef enum { |
---|
96 | LPC176X_PIN_TYPE_DEFAULT, |
---|
97 | LPC176X_PIN_TYPE_ADC, |
---|
98 | LPC176X_PIN_TYPE_DAC, |
---|
99 | LPC176X_PIN_TYPE_OPEN_DRAIN |
---|
100 | } lpc176x_pin_type; |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief Represents each pclksel number. |
---|
104 | * |
---|
105 | * Enumerated type to define the set of values for a pcklsel. |
---|
106 | */ |
---|
107 | typedef enum { |
---|
108 | LPC176X_SCB_PCLKSEL0, |
---|
109 | LPC176X_SCB_PCLKSEL1, |
---|
110 | LPC176X_SCB_PCLKSEL_COUNT |
---|
111 | } lpc176x_scb_value_pclksel; |
---|
112 | |
---|
113 | /** |
---|
114 | * @brief Defines the module entry. |
---|
115 | */ |
---|
116 | typedef struct { |
---|
117 | /** |
---|
118 | * @brief Power entry bit. |
---|
119 | */ |
---|
120 | unsigned char power : 1; |
---|
121 | /** |
---|
122 | * @brief Clock entry bit. |
---|
123 | */ |
---|
124 | unsigned char clock : 1; |
---|
125 | /** |
---|
126 | * @brief Index entry bits. |
---|
127 | */ |
---|
128 | unsigned char index : 6; |
---|
129 | } lpc176x_module_entry; |
---|
130 | |
---|
131 | #define LPC176X_MODULE_ENTRY( mod, pwr, clk, idx ) \ |
---|
132 | [ mod ] = { \ |
---|
133 | .power = pwr, \ |
---|
134 | .clock = clk, \ |
---|
135 | .index = idx \ |
---|
136 | } |
---|
137 | |
---|
138 | #ifdef __cplusplus |
---|
139 | } |
---|
140 | #endif /* __cplusplus */ |
---|
141 | |
---|
142 | #endif /* LIBBSP_ARM_LPC176X_IO_DEFS_H */ |
---|