stm32100e_eval_ioe.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32100e_eval_ioe.h
00004   * @author  MCD Application Team
00005   * @version V4.3.0
00006   * @date    10/15/2010
00007   * @brief   This file contains all the functions prototypes for the IO Expander
00008   *   firmware driver.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00020   */ 
00021 
00022   /* File Info : ---------------------------------------------------------------
00023     SUPPORTED FEATURES:
00024       - Touch Screen Features: Single point mode (Polling/Interrupt).     
00025       - TempSensor Feature: accuracy not determined (Polling).
00026       - IO Read/write : Set/Reset and Read (Polling/Interrupt).
00027       
00028     UNSUPPORTED FEATURES:
00029       - Row ADC Feature is not supported (not implemented on STM32100E-EVAL board)
00030       - Joystick: config and Read (Polling/Interrupt) 
00031 ----------------------------------------------------------------------------*/
00032 
00033 
00034 /* Define to prevent recursive inclusion -------------------------------------*/
00035 #ifndef __STM32100E_EVAL_IOE_H
00036 #define __STM32100E_EVAL_IOE_H
00037 
00038 #ifdef __cplusplus
00039  extern "C" {
00040 #endif   
00041    
00042 /* Includes ------------------------------------------------------------------*/
00043 #include "stm32f10x.h"
00044 
00045 /** @addtogroup Utilities
00046   * @{
00047   */
00048 
00049 /** @addtogroup STM32_EVAL
00050   * @{
00051   */ 
00052 
00053 /** @addtogroup STM32100E_EVAL
00054   * @{
00055   */
00056     
00057 /** @defgroup STM32100E_EVAL_IOE 
00058   * @{
00059   */ 
00060 
00061 /** @defgroup STM32100E_EVAL_IOE_Exported_Types
00062   * @{
00063   */ 
00064 
00065 /** 
00066   * @brief  Touch Screen Information structure  
00067   */ 
00068 typedef struct
00069 {
00070   uint16_t TouchDetected;
00071   uint16_t X;
00072   uint16_t Y;
00073   uint16_t Z;
00074 }TS_STATE; 
00075   
00076 
00077 /** 
00078   * @brief  IO_Expander Error codes  
00079   */ 
00080 typedef enum
00081 {
00082   IOE_OK = 0,
00083   IOE_FAILURE, 
00084   IOE_TIMEOUT,
00085   PARAM_ERROR,
00086   IOE1_NOT_OPERATIONAL,
00087 }IOE_Status_TypDef;
00088 
00089 /** 
00090   * @brief  IO bit values  
00091   */ 
00092 typedef enum
00093 {
00094   BitReset = 0,
00095   BitSet = 1
00096 }IOE_BitValue_TypeDef;
00097 
00098 /** 
00099   * @brief  IOE DMA Direction  
00100   */ 
00101 typedef enum
00102 {
00103   IOE_DMA_TX = 0,
00104   IOE_DMA_RX = 1
00105 }IOE_DMADirection_TypeDef;
00106 
00107 /** @defgroup STM32100E_EVAL_IOE_Exported_Constants
00108   * @{
00109   */ 
00110 
00111 /**
00112  * @brief Uncomment the line below to enable verfying each written byte in write
00113  *        operation. The I2C_WriteDeviceRegister() function will then compare the
00114  *        written and read data and return error status if a mismatch occurs.
00115  */
00116 /* #define VERIFY_WRITTENDATA */
00117 
00118 /**
00119  * @brief Uncomment the line below if you want to use user defined Delay function
00120  *        (for precise timing), otherwise default _delay_ function defined within
00121  *         this driver is used (less precise timing).  
00122  */
00123 /* #define USE_Delay */
00124 
00125 /**
00126  * @brief Uncomment the line below if you want to use user timeout callback.
00127  *        Function prototypes is declared in this file but function body may be
00128  *        implemented into user application.  
00129  */
00130 /* #define USE_TIMEOUT_USER_CALLBACK */
00131 
00132 #ifdef USE_Delay
00133 #include "main.h"
00134  
00135   #define _delay_     Delay  /* !< User can provide more timing precise _delay_ function
00136                                    (with 10ms time base), using SysTick for example */
00137 #else
00138   #define _delay_     delay      /* !< Default _delay_ function with less precise timing */
00139 #endif    
00140 
00141 /*------------------------------------------------------------------------------
00142     Hardware Configuration 
00143 ------------------------------------------------------------------------------*/
00144 /** 
00145   * @brief  I2C port definitions  
00146   */
00147 #define IOE_I2C                          I2C2
00148 #define IOE_I2C_CLK                      RCC_APB1Periph_I2C2
00149 #define IOE_I2C_SCL_PIN                  GPIO_Pin_10
00150 #define IOE_I2C_SCL_GPIO_PORT            GPIOB
00151 #define IOE_I2C_SCL_GPIO_CLK             RCC_APB2Periph_GPIOB
00152 #define IOE_I2C_SDA_PIN                  GPIO_Pin_11
00153 #define IOE_I2C_SDA_GPIO_PORT            GPIOB
00154 #define IOE_I2C_SDA_GPIO_CLK             RCC_APB2Periph_GPIOB
00155 #define IOE_I2C_DR                       ((uint32_t)0x40005810)
00156 #define IOE_I2C_SPEED                    300000  
00157 
00158 /** 
00159   * @brief  IOE DMA definitions  
00160   */
00161 #define IOE_DMA                          DMA1
00162 #define IOE_DMA_CLK                      RCC_AHBPeriph_DMA1
00163 #define IOE_DMA_TX_CHANNEL               DMA1_Channel4
00164 #define IOE_DMA_RX_CHANNEL               DMA1_Channel5
00165 #define IOE_DMA_TX_TCFLAG                DMA1_FLAG_TC4
00166 #define IOE_DMA_RX_TCFLAG                DMA1_FLAG_TC5
00167   
00168 
00169 /** 
00170   * @brief  IO Expander Interrupt line on EXTI  
00171   */ 
00172 #define IOE_IT_PIN                       GPIO_Pin_12
00173 #define IOE_IT_GPIO_PORT                 GPIOA
00174 #define IOE_IT_GPIO_CLK                  RCC_APB2Periph_GPIOA
00175 #define IOE_IT_EXTI_PORT_SOURCE          GPIO_PortSourceGPIOA
00176 #define IOE_IT_EXTI_PIN_SOURCE           GPIO_PinSource12
00177 #define IOE_IT_EXTI_LINE                 EXTI_Line12
00178 #define IOE_IT_EXTI_IRQn                 EXTI15_10_IRQn       
00179 
00180 
00181 /** 
00182   * @brief  The 7 bits IO Expanders adresses and chip IDs  
00183   */ 
00184 #define IOE_1_ADDR                 0x82    
00185 #define STMPE811_ID                0x0811
00186 
00187 
00188 /*------------------------------------------------------------------------------
00189     Functional and Interrupt Management
00190 ------------------------------------------------------------------------------*/
00191 /** 
00192   * @brief  IO Expander Functionalities definitions  
00193   */ 
00194 #define IOE_ADC_FCT              0x01
00195 #define IOE_TS_FCT               0x02
00196 #define IOE_IO_FCT               0x04
00197 #define IOE_TEMPSENS_FCT         0x08
00198 
00199 /** 
00200   * @brief  Interrupt source configuration definitons  
00201   */ 
00202 #define IOE_ITSRC_TSC           0x01  /* IO_Exapnder 1 */
00203 #define IOE_ITSRC_TEMPSENS      0x08  /* IO_Exapnder 1 */
00204 
00205 /** 
00206   * @brief  Glaobal Interrupts definitions  
00207   */ 
00208 #define IOE_GIT_GPIO             0x80
00209 #define IOE_GIT_ADC              0x40
00210 #define IOE_GIT_TEMP             0x20
00211 #define IOE_GIT_FE               0x10
00212 #define IOE_GIT_FF               0x08
00213 #define IOE_GIT_FOV              0x04
00214 #define IOE_GIT_FTH              0x02
00215 #define IOE_GIT_TOUCH            0x01
00216 
00217 /**
00218   * @brief IO Exapanders Pins definition 
00219   */ 
00220 #define IO1_IN_ALL_PINS          (uint32_t)(IO_Pin_ALL)
00221 #define IO1_OUT_ALL_PINS         (uint32_t)(IO_Pin_ALL)
00222 
00223 
00224 /*------------------------------------------------------------------------------
00225     STMPE811 device register definition
00226 ------------------------------------------------------------------------------*/
00227 /** 
00228   * @brief  Identification registers  
00229   */ 
00230 #define IOE_REG_CHP_ID             0x00
00231 #define IOE_REG_ID_VER             0x02
00232 
00233 /** 
00234   * @brief  General Control Registers  
00235   */ 
00236 #define IOE_REG_SYS_CTRL1          0x03
00237 #define IOE_REG_SYS_CTRL2          0x04
00238 #define IOE_REG_SPI_CFG            0x08 
00239 
00240 /** 
00241   * @brief  Interrupt Control register  
00242   */ 
00243 #define IOE_REG_INT_CTRL           0x09
00244 #define IOE_REG_INT_EN             0x0A
00245 #define IOE_REG_INT_STA            0x0B
00246 #define IOE_REG_GPIO_INT_EN        0x0C
00247 #define IOE_REG_GPIO_INT_STA       0x0D
00248 
00249 /** 
00250   * @brief  GPIO Registers  
00251   */ 
00252 #define IOE_REG_GPIO_SET_PIN       0x10
00253 #define IOE_REG_GPIO_CLR_PIN       0x11
00254 #define IOE_REG_GPIO_MP_STA        0x12
00255 #define IOE_REG_GPIO_DIR           0x13
00256 #define IOE_REG_GPIO_ED            0x14
00257 #define IOE_REG_GPIO_RE            0x15
00258 #define IOE_REG_GPIO_FE            0x16
00259 #define IOE_REG_GPIO_AF            0x17
00260 
00261 /** 
00262   * @brief  ADC Registers  
00263   */ 
00264 #define IOE_REG_ADC_INT_EN         0x0E
00265 #define IOE_REG_ADC_INT_STA        0x0F
00266 #define IOE_REG_ADC_CTRL1          0x20
00267 #define IOE_REG_ADC_CTRL2          0x21
00268 #define IOE_REG_ADC_CAPT           0x22
00269 #define IOE_REG_ADC_DATA_CH0       0x30 /* 16-Bit register */
00270 #define IOE_REG_ADC_DATA_CH1       0x32 /* 16-Bit register */
00271 #define IOE_REG_ADC_DATA_CH2       0x34 /* 16-Bit register */
00272 #define IOE_REG_ADC_DATA_CH3       0x36 /* 16-Bit register */
00273 #define IOE_REG_ADC_DATA_CH4       0x38 /* 16-Bit register */
00274 #define IOE_REG_ADC_DATA_CH5       0x3A /* 16-Bit register */
00275 #define IOE_REG_ADC_DATA_CH6       0x3B /* 16-Bit register */
00276 #define IOE_REG_ADC_DATA_CH7       0x3C /* 16-Bit register */ 
00277 
00278 /** 
00279   * @brief  TouchScreen Registers  
00280   */ 
00281 #define IOE_REG_TSC_CTRL           0x40
00282 #define IOE_REG_TSC_CFG            0x41
00283 #define IOE_REG_WDM_TR_X           0x42 
00284 #define IOE_REG_WDM_TR_Y           0x44
00285 #define IOE_REG_WDM_BL_X           0x46
00286 #define IOE_REG_WDM_BL_Y           0x48
00287 #define IOE_REG_FIFO_TH            0x4A
00288 #define IOE_REG_FIFO_STA           0x4B
00289 #define IOE_REG_FIFO_SIZE          0x4C
00290 #define IOE_REG_TSC_DATA_X         0x4D 
00291 #define IOE_REG_TSC_DATA_Y         0x4F
00292 #define IOE_REG_TSC_DATA_Z         0x51
00293 #define IOE_REG_TSC_DATA_XYZ       0x52 
00294 #define IOE_REG_TSC_FRACT_XYZ      0x56
00295 #define IOE_REG_TSC_DATA           0x57
00296 #define IOE_REG_TSC_I_DRIVE        0x58
00297 #define IOE_REG_TSC_SHIELD         0x59
00298 
00299 /** 
00300   * @brief  Temperature Sensor registers  
00301   */ 
00302 #define IOE_REG_TEMP_CTRL          0x60
00303 #define IOE_REG_TEMP_DATA          0x61
00304 #define IOE_REG_TEMP_TH            0x62
00305 
00306 /*------------------------------------------------------------------------------
00307     Functions parameters defines
00308 ------------------------------------------------------------------------------*/
00309 /**
00310   * @brief Touch Screen Pins definition 
00311   */ 
00312 #define TOUCH_YD                    IO_Pin_1 /* IO_Exapnader_1 */ /* Input */
00313 #define TOUCH_XD                    IO_Pin_2 /* IO_Exapnader_1 */ /* Input */
00314 #define TOUCH_YU                    IO_Pin_3 /* IO_Exapnader_1 */ /* Input */
00315 #define TOUCH_XU                    IO_Pin_4 /* IO_Exapnader_1 */ /* Input */
00316 #define TOUCH_IO_ALL                (uint32_t)(IO_Pin_1 | IO_Pin_2 | IO_Pin_3 | IO_Pin_4)
00317 
00318 /** 
00319   * @brief  IO Pins  
00320   */ 
00321 #define IO_Pin_0                 0x01
00322 #define IO_Pin_1                 0x02
00323 #define IO_Pin_2                 0x04
00324 #define IO_Pin_3                 0x08
00325 #define IO_Pin_4                 0x10
00326 #define IO_Pin_5                 0x20
00327 #define IO_Pin_6                 0x40
00328 #define IO_Pin_7                 0x80
00329 #define IO_Pin_ALL               0xFF
00330 
00331 /** 
00332   * @brief  IO Pin directions  
00333   */ 
00334 #define Direction_IN             0x00
00335 #define Direction_OUT            0x01
00336 
00337 /** 
00338   * @brief  Interrupt Line output parameters  
00339   */ 
00340 #define Polarity_Low             0x00
00341 #define Polarity_High            0x04
00342 #define Type_Level               0x00
00343 #define Type_Edge                0x02
00344 
00345 /** 
00346   * @brief IO Interrupts  
00347   */ 
00348 #define IO_IT_0                  0x01
00349 #define IO_IT_1                  0x02
00350 #define IO_IT_2                  0x04
00351 #define IO_IT_3                  0x08
00352 #define IO_IT_4                  0x10
00353 #define IO_IT_5                  0x20
00354 #define IO_IT_6                  0x40
00355 #define IO_IT_7                  0x80
00356 #define ALL_IT                   0xFF
00357 #define IOE_TS_IT                (uint8_t)(IO_IT_0 | IO_IT_1 | IO_IT_2)
00358 
00359 /** 
00360   * @brief  Edge detection value  
00361   */ 
00362 #define EDGE_FALLING              0x01
00363 #define EDGE_RISING               0x02
00364 
00365 /** 
00366   * @brief  Global interrupt Enable bit  
00367   */ 
00368 #define IOE_GIT_EN                0x01
00369 
00370 /**
00371   * @}
00372   */ 
00373 
00374 
00375 
00376 /** @defgroup STM32100E_EVAL_IOE_Exported_Macros
00377   * @{
00378   */ 
00379 /**
00380   * @}
00381   */ 
00382 
00383 
00384 
00385 /** @defgroup STM32100E_EVAL_IOE_Exported_Functions
00386   * @{
00387   */ 
00388 
00389 /** 
00390   * @brief  Configuration and initialization functions  
00391   */
00392 uint8_t IOE_Config(void);
00393 uint8_t IOE_ITConfig(uint32_t IOE_ITSRC_Source);
00394 
00395 /** 
00396   * @brief  Timeout user callback function. This function is called when a timeout
00397   *         condition occurs during communication with IO Expander. Only protoype
00398   *         of this function is decalred in IO Expander driver. Its implementation
00399   *         may be done into user application. This function may typically stop
00400   *         current operations and reset the I2C peripheral and IO Expander.
00401   *         To enable this function use uncomment the define USE_TIMEOUT_USER_CALLBACK
00402   *         at the top of this file.          
00403   */
00404 #ifdef USE_TIMEOUT_USER_CALLBACK 
00405  uint8_t IOE_TimeoutUserCallback(void);
00406 #else
00407  #define IOE_TimeoutUserCallback()  IOE_TIMEOUT
00408 #endif /* USE_TIMEOUT_USER_CALLBACK */
00409 
00410 /** 
00411   * @brief IO pins control functions
00412   */
00413 uint8_t IOE_WriteIOPin(uint8_t IO_Pin, IOE_BitValue_TypeDef BitVal);
00414 uint8_t IOE_ReadIOPin(uint32_t IO_Pin);
00415 
00416 /** 
00417   * @brief Touch Screen controller functions
00418   */
00419 TS_STATE* IOE_TS_GetState(void);
00420 
00421 /** 
00422   * @brief Interrupts Mangement functions
00423   */
00424 FlagStatus IOE_GetGITStatus(uint8_t DeviceAddr, uint8_t Global_IT);
00425 uint8_t IOE_ClearGITPending(uint8_t DeviceAddr, uint8_t IO_IT);
00426 FlagStatus IOE_GetIOITStatus(uint8_t DeviceAddr, uint8_t IO_IT);
00427 uint8_t IOE_ClearIOITPending(uint8_t DeviceAddr, uint8_t IO_IT);
00428 
00429 
00430 /** 
00431   * @brief Temperature Sensor functions
00432   */
00433 uint32_t IOE_TempSens_GetData(void);
00434 
00435 
00436 /** 
00437   * @brief IO-Expander Control functions
00438   */
00439 uint8_t IOE_IsOperational(uint8_t DeviceAddr);
00440 uint8_t IOE_Reset(uint8_t DeviceAddr);
00441 uint16_t IOE_ReadID(uint8_t DeviceAddr);
00442 
00443 uint8_t IOE_FnctCmd(uint8_t DeviceAddr, uint8_t Fct, FunctionalState NewState);
00444 uint8_t IOE_IOPinConfig(uint8_t DeviceAddr, uint8_t IO_Pin, uint8_t Direction);
00445 uint8_t IOE_GITCmd(uint8_t DeviceAddr, FunctionalState NewState);
00446 uint8_t IOE_GITConfig(uint8_t DeviceAddr, uint8_t Global_IT, FunctionalState NewState);
00447 uint8_t IOE_IOITConfig(uint8_t DeviceAddr, uint8_t IO_IT, FunctionalState NewState);
00448 
00449 /** 
00450   * @brief Low Layer functions
00451   */
00452 uint8_t IOE_TS_Config(void);
00453 uint8_t IOE_TempSens_Config(void);
00454 uint8_t IOE_IOAFConfig(uint8_t DeviceAddr, uint8_t IO_Pin, FunctionalState NewState);
00455 uint8_t IOE_IOEdgeConfig(uint8_t DeviceAddr, uint8_t IO_Pin, uint8_t Edge);
00456 uint8_t IOE_ITOutConfig(uint8_t Polarity, uint8_t Type);
00457 
00458 uint8_t I2C_WriteDeviceRegister(uint8_t DeviceAddr, uint8_t RegisterAddr, uint8_t RegisterValue);
00459 uint8_t I2C_ReadDeviceRegister(uint8_t DeviceAddr, uint8_t RegisterAddr);
00460 uint16_t I2C_ReadDataBuffer(uint8_t DeviceAddr, uint32_t RegisterAddr);
00461 #ifdef __cplusplus
00462 }
00463 
00464 #endif
00465 #endif /* __STM32100E_EVAL_IOE_H */
00466 
00467 /**
00468   * @}
00469   */ 
00470 
00471 /**
00472   * @}
00473   */ 
00474 
00475 /**
00476   * @}
00477   */ 
00478 
00479 /**
00480   * @}
00481   */ 
00482 
00483 /**
00484   * @}
00485   */     
00486 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32