source: rtems/c/src/lib/libbsp/arm/lpc176x/include/io-defs.h @ 6a941e3

4.115
Last change on this file since 6a941e3 was 19260fb, checked in by Martin Boretto <martin.boretto@…>, on 06/09/14 at 14:27:18

bsp/lpc176x: New BSP

  • Property mode set to 100644
File size: 3.1 KB
Line 
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
29extern "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
47#define LPC176X_MODULE_BITS_COUNT 32U
48#define LPC176X_MODULE_COUNT ( LPC176X_MODULE_USB + 1U )
49
50#define LPC176X_IO_PORT_COUNT 5U
51#define LPC176X_IO_INDEX_MAX ( LPC176X_IO_PORT_COUNT *       \
52                               LPC176X_MODULE_BITS_COUNT )
53#define LPC176X_IO_INDEX_BY_PORT( port, bit ) ( ( ( port ) << 5U ) + ( bit ) )
54#define LPC176X_IO_PORT( index ) ( ( index ) >> 5U )
55#define LPC176X_IO_PORT_BIT( index ) ( ( index ) & 0x1FU )
56
57/**
58 * @brief Defines the functions according to the pin.
59 *
60 * Enumerated type to define the set of pin function for a io device.
61 */
62typedef enum {
63  LPC176X_PIN_FUNCTION_00,
64  LPC176X_PIN_FUNCTION_01,
65  LPC176X_PIN_FUNCTION_10,
66  LPC176X_PIN_FUNCTION_11,
67  LPC176X_PIN_FUNCTION_COUNT
68}
69lpc176x_pin_function;
70
71/**
72 * @brief Defines all type of pins.
73 *
74 * Enumerated type to define the set of pin type for a io device.
75 */
76typedef enum {
77  LPC176X_PIN_TYPE_DEFAULT,
78  LPC176X_PIN_TYPE_ADC,
79  LPC176X_PIN_TYPE_DAC,
80  LPC176X_PIN_TYPE_OPEN_DRAIN
81} lpc176x_pin_type;
82
83/**
84 * @brief Represents each pclksel number.
85 *
86 * Enumerated type to define the set of values for a pcklsel.
87 */
88typedef enum {
89  LPC176X_SCB_PCLKSEL0,
90  LPC176X_SCB_PCLKSEL1,
91  LPC176X_SCB_PCLKSEL_COUNT
92} lpc176x_scb_value_pclksel;
93
94/**
95 * @brief Defines the module entry.
96 */
97typedef struct {
98  /**
99   * @brief Power entry bit.
100   */
101  unsigned char power : 1;
102  /**
103   * @brief Clock entry bit.
104   */
105  unsigned char clock : 1;
106  /**
107   * @brief Index entry bits.
108   */
109  unsigned char index : 6;
110} lpc176x_module_entry;
111
112#define LPC176X_MODULE_ENTRY( mod, pwr, clk, idx )  \
113  [ mod ] = {                                       \
114    .power = pwr,                                 \
115    .clock = clk,                                 \
116    .index = idx                                  \
117  }
118
119#ifdef __cplusplus
120}
121#endif /* __cplusplus */
122
123#endif /* LIBBSP_ARM_LPC176X_IO_DEFS_H */
Note: See TracBrowser for help on using the repository browser.