Back to home page

LXR

 
 

    


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

0001 /**
0002  * @file
0003  * 
0004  * @ingroup lm3s69xx_io
0005  *
0006  * @brief IO definitions.
0007  */
0008 
0009 /*
0010  * Copyright (c) 2013 Eugeniy Meshcheryakov <eugen@debian.org>
0011  *
0012  * The license and distribution terms for this file may be
0013  * found in the file LICENSE in this distribution or at
0014  * http://www.rtems.org/license/LICENSE.
0015  */
0016 
0017 #ifndef LIBBSP_ARM_LM3S69XX_IO_H
0018 #define LIBBSP_ARM_LM3S69XX_IO_H
0019 #include <bspopts.h>
0020 #include <stdbool.h>
0021 
0022 /**
0023  * @defgroup lm3s69xx_io IO Support
0024  *
0025  * @ingroup RTEMSBSPsARMLM3S69XX
0026  *
0027  * @brief IO support.
0028  */
0029 
0030 typedef enum {
0031   LM3S69XX_GPIO_DIRECTION_INPUT,
0032   LM3S69XX_GPIO_DIRECTION_OUTPUT
0033 } lm3s69xx_gpio_direction;
0034 
0035 typedef enum {
0036   LM3S69XX_GPIO_OTYPE_PUSH_PULL,
0037   LM3S69XX_GPIO_OTYPE_OPEN_DRAIN
0038 } lm3s69xx_gpio_otype;
0039 
0040 typedef enum {
0041   LM3S69XX_GPIO_DRIVE_2MA,
0042   LM3S69XX_GPIO_DRIVE_4MA,
0043   LM3S69XX_GPIO_DRIVE_8MA
0044 } lm3s69xx_gpio_drive;
0045 
0046 typedef enum {
0047   LM3S69XX_GPIO_NO_PULL,
0048   LM3S69XX_GPIO_PULL_UP,
0049   LM3S69XX_GPIO_PULL_DOWN
0050 } lm3s69xx_gpio_pull;
0051 
0052 typedef enum {
0053   LM3S69XX_GPIO_DIGITAL_DISABLE,
0054   LM3S69XX_GPIO_DIGITAL_ENABLE,
0055 } lm3s69xx_gpio_digital;
0056 
0057 typedef enum {
0058   LM3S69XX_GPIO_AF_DISABLE,
0059   LM3S69XX_GPIO_AF_ENABLE
0060 } lm3s69xx_gpio_af;
0061 
0062 typedef enum {
0063   LM3S69XX_GPIO_ANALOG_DISABLE,
0064   LM3S69XX_GPIO_ANALOG_ENABLE
0065 } lm3s69xx_gpio_analog;
0066 
0067 typedef enum {
0068   LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL,
0069   LM3S69XX_GPIO_SLEW_RATE_CONTROL
0070 } lm3s69xx_gpio_slew_rate_control;
0071 
0072 typedef struct {
0073   unsigned int pin_first : 8;
0074   unsigned int pin_last : 8;
0075   unsigned int digital : 1;
0076   unsigned int alternate : 1;
0077   unsigned int analog : 1;
0078   unsigned int dir : 1;
0079   unsigned int otype : 1;
0080   unsigned int drive : 2;
0081   unsigned int pull : 2;
0082   unsigned int slr : 1;
0083 } lm3s69xx_gpio_config;
0084 
0085 typedef enum {
0086   LM3S69XX_PORT_A,
0087   LM3S69XX_PORT_B,
0088   LM3S69XX_PORT_C,
0089   LM3S69XX_PORT_D,
0090   LM3S69XX_PORT_E,
0091   LM3S69XX_PORT_F,
0092   LM3S69XX_PORT_G,
0093 #if LM3S69XX_NUM_GPIO_BLOCKS > 7
0094   LM3S69XX_PORT_H
0095 #endif
0096 } lm3s69xx_gpio_port;
0097 
0098 #define LM3S69XX_GPIO_PIN(port, idx) (((port) << 3) | (idx))
0099 #define LM3S69XX_GPIO_PORT_OF_PIN(pin) (((pin) >> 3) & 0xf)
0100 #define LM3S69XX_GPIO_INDEX_OF_PIN(pin) ((pin) & 0x7)
0101 
0102 #define LM3S69XX_PIN_UART_TX(port, idx) \
0103   { \
0104     .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
0105     .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
0106     .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
0107     .alternate = LM3S69XX_GPIO_AF_ENABLE, \
0108     .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
0109     .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
0110     .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
0111     .drive = LM3S69XX_GPIO_DRIVE_2MA, \
0112     .pull = LM3S69XX_GPIO_NO_PULL, \
0113     .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
0114   }
0115 
0116 #define LM3S69XX_PIN_UART_RX(port, idx) \
0117   { \
0118     .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
0119     .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
0120     .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
0121     .alternate = LM3S69XX_GPIO_AF_ENABLE, \
0122     .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
0123     .dir = LM3S69XX_GPIO_DIRECTION_INPUT, \
0124     .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
0125     .drive = LM3S69XX_GPIO_DRIVE_2MA, \
0126     .pull = LM3S69XX_GPIO_PULL_UP, \
0127     .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
0128   }
0129 
0130 #define LM3S69XX_PIN_UART_RTS(port, idx) \
0131   { \
0132     .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
0133     .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
0134     .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
0135     .alternate = LM3S69XX_GPIO_AF_ENABLE, \
0136     .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
0137     .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
0138     .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
0139     .drive = LM3S69XX_GPIO_DRIVE_2MA, \
0140     .pull = LM3S69XX_GPIO_NO_PULL, \
0141     .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
0142   }
0143 
0144 #define LM3S69XX_PIN_UART_CTS(port, idx) \
0145   { \
0146     .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
0147     .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
0148     .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
0149     .alternate = LM3S69XX_GPIO_AF_ENABLE, \
0150     .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
0151     .dir = LM3S69XX_GPIO_DIRECTION_INPUT, \
0152     .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
0153     .drive = LM3S69XX_GPIO_DRIVE_2MA, \
0154     .pull = LM3S69XX_GPIO_PULL_UP, \
0155     .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
0156   }
0157 
0158 #define LM3S69XX_PIN_LED(port, idx) \
0159   { \
0160     .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
0161     .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
0162     .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
0163     .alternate = LM3S69XX_GPIO_AF_DISABLE, \
0164     .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
0165     .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
0166     .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
0167     .drive = LM3S69XX_GPIO_DRIVE_8MA, \
0168     .pull = LM3S69XX_GPIO_NO_PULL, \
0169     .slr = LM3S69XX_GPIO_SLEW_RATE_CONTROL \
0170   }
0171 
0172 #define LM3S69XX_PIN_SSI_TX(port, idx) LM3S69XX_PIN_UART_TX(port, idx)
0173 #define LM3S69XX_PIN_SSI_RX(port, idx) LM3S69XX_PIN_UART_RX(port, idx)
0174 
0175 #ifdef __cplusplus
0176 extern "C" {
0177 #endif
0178 
0179 void lm3s69xx_gpio_set_config(const lm3s69xx_gpio_config *config);
0180 void lm3s69xx_gpio_set_config_array(const lm3s69xx_gpio_config *configs, unsigned int count);
0181 void lm3s69xx_gpio_digital_enable(unsigned int pin, bool enable);
0182 void lm3s69xx_gpio_analog_mode_select(unsigned int pin, bool enable);
0183 
0184 void lm3s69xx_gpio_set_pin(unsigned int pin, bool set);
0185 bool lm3s69xx_gpio_get_pin(unsigned int pin);
0186 
0187 #ifdef __cplusplus
0188 }
0189 #endif
0190 
0191 #endif /* LIBBSP_ARM_LM3S69XX_IO_H */