Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:03

0001 /**
0002  * @file
0003  *
0004  * @ingroup RTEMSBSPsARMLPC176X
0005  *
0006  * @brief Input/output module definitions.
0007  */
0008 
0009 /*
0010  * Copyright (c) 2014 Taller Technologies.
0011  *
0012  * @author  Boretto Martin    (martin.boretto@tallertechnologies.com)
0013  * @author  Diaz Marcos (marcos.diaz@tallertechnologies.com)
0014  * @author  Lenarduzzi Federico  (federico.lenarduzzi@tallertechnologies.com)
0015  * @author  Daniel Chicco  (daniel.chicco@tallertechnologies.com)
0016  *
0017  * The license and distribution terms for this file may be
0018  * found in the file LICENSE in this distribution or at
0019  * http://www.rtems.org/license/LICENSE.
0020  */
0021 
0022 #ifndef LIBBSP_ARM_LPC176X_IO_DEFS_H
0023 #define LIBBSP_ARM_LPC176X_IO_DEFS_H
0024 
0025 #include <bsp/lpc176x.h>
0026 #include <bsp/common-types.h>
0027 
0028 #ifdef __cplusplus
0029 extern "C" {
0030 #endif /* __cplusplus */
0031 
0032 #define LPC176X_PLL0CON 0XAAU
0033 #define LPC176X_PLL0CFG 0X55U
0034 
0035 #define LPC176X_CCLK_PRESCALER_DIVISOR 1000000U
0036 
0037 #define LPC176X_PINSEL ( &PINSEL0 )
0038 #define LPC176X_PINMODE ( &PINMODE0 )
0039 
0040 #define LPC176X_PIN_SELECT( index ) ( ( index ) >> 4U )
0041 #define LPC176X_PIN_SELECT_SHIFT( index ) ( ( ( index ) & 0xFU ) << 1U )
0042 #define LPC176X_PIN_SELECT_MASK 0x3U
0043 #define LPC176X_PIN_SELECT_MASK_SIZE 2U
0044 #define LPC176X_PIN_UART_0_TXD 2U
0045 #define LPC176X_PIN_UART_0_RXD 3U
0046 #define LPC176X_PIN_UART_1_TXD 15U
0047 #define LPC176X_PIN_UART_1_RXD 16U
0048 #define LPC176X_PIN_UART_2_TXD 10U
0049 #define LPC176X_PIN_UART_2_RXD 11U
0050 #define LPC176X_PIN_UART_3_TXD 0U
0051 #define LPC176X_PIN_UART_3_RXD 1U
0052 
0053 #define LPC176X_MODULE_BITS_COUNT 32U
0054 #define LPC176X_MODULE_COUNT ( LPC176X_MODULE_USB + 1U )
0055 
0056 #define LPC176X_IO_PORT_COUNT 5U
0057 #define LPC176X_IO_INDEX_MAX ( LPC176X_IO_PORT_COUNT *       \
0058                                LPC176X_MODULE_BITS_COUNT )
0059 #define LPC176X_IO_INDEX_BY_PORT( port, bit ) ( ( ( port ) << 5U ) + ( bit ) )
0060 #define LPC176X_IO_PORT( index ) ( ( index ) >> 5U )
0061 #define LPC176X_IO_PORT_BIT( index ) ( ( index ) & 0x1FU )
0062 
0063 /**
0064  * @brief Defines the functions according to the pin.
0065  *
0066  * Enumerated type to define the set of pin function for a io device.
0067  */
0068 typedef enum {
0069   LPC176X_PIN_FUNCTION_00,
0070   LPC176X_PIN_FUNCTION_01,
0071   LPC176X_PIN_FUNCTION_10,
0072   LPC176X_PIN_FUNCTION_11,
0073   LPC176X_PIN_FUNCTION_COUNT
0074 }
0075 lpc176x_pin_function;
0076 
0077 /**
0078  * @brief Defines the pin modes.
0079  *
0080  */
0081 typedef enum {
0082   LPC176X_PIN_MODE_PULLUP,
0083   LPC176X_PIN_MODE_REPEATER,
0084   LPC176X_PIN_MODE_NONE,
0085   LPC176X_PIN_MODE_PULLDOWN,
0086   LPC176X_PIN_MODE_COUNT
0087 }
0088 lpc176x_pin_mode;
0089 
0090 /**
0091  * @brief Defines all type of pins.
0092  *
0093  * Enumerated type to define the set of pin type for a io device.
0094  */
0095 typedef enum {
0096   LPC176X_PIN_TYPE_DEFAULT,
0097   LPC176X_PIN_TYPE_ADC,
0098   LPC176X_PIN_TYPE_DAC,
0099   LPC176X_PIN_TYPE_OPEN_DRAIN
0100 } lpc176x_pin_type;
0101 
0102 /**
0103  * @brief Represents each pclksel number.
0104  *
0105  * Enumerated type to define the set of values for a pcklsel.
0106  */
0107 typedef enum {
0108   LPC176X_SCB_PCLKSEL0,
0109   LPC176X_SCB_PCLKSEL1,
0110   LPC176X_SCB_PCLKSEL_COUNT
0111 } lpc176x_scb_value_pclksel;
0112 
0113 /**
0114  * @brief Defines the module entry.
0115  */
0116 typedef struct {
0117   /**
0118    * @brief Power entry bit.
0119    */
0120   unsigned char power : 1;
0121   /**
0122    * @brief Clock entry bit.
0123    */
0124   unsigned char clock : 1;
0125   /**
0126    * @brief Index entry bits.
0127    */
0128   unsigned char index : 6;
0129 } lpc176x_module_entry;
0130 
0131 #define LPC176X_MODULE_ENTRY( mod, pwr, clk, idx )  \
0132   [ mod ] = {                                       \
0133     .power = pwr,                                 \
0134     .clock = clk,                                 \
0135     .index = idx                                  \
0136   }
0137 
0138 #ifdef __cplusplus
0139 }
0140 #endif /* __cplusplus */
0141 
0142 #endif /* LIBBSP_ARM_LPC176X_IO_DEFS_H */