Nirvana Jay / Mbed 2 deprecated F7DISCO_Demo

Dependencies:   BSP_DISCO_F746NG_patch mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers k_bsp.c Source File

k_bsp.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    k_bsp.c
00004   * @author  MCD Application Team
00005   * @version V1.1.0
00006   * @date    21-September-2015
00007   * @brief   This file provides the kernel bsp functions
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "k_bsp.h"
00030 
00031 /** @addtogroup CORE
00032   * @{
00033   */
00034 
00035 /** @defgroup KERNEL_BSP
00036   * @brief Kernel BSP routines
00037   * @{
00038   */
00039 
00040 /* External variables --------------------------------------------------------*/
00041   extern uint8_t SelLayer;
00042 
00043 /* Private typedef -----------------------------------------------------------*/
00044 /* Private defines -----------------------------------------------------------*/
00045 /* Private macros ------------------------------------------------------------*/
00046 /* Private variables ---------------------------------------------------------*/
00047 /* Private function prototypes -----------------------------------------------*/
00048 /* Private functions ---------------------------------------------------------*/
00049 /**
00050   * @brief  Initializes LEDs, SDRAM, touch screen, CRC and SRAM.
00051   * @param  None 
00052   * @retval None
00053   */
00054 void k_BspInit(void)
00055 {
00056   /* Initialize the NOR */
00057   BSP_QSPI_Init();
00058   BSP_QSPI_MemoryMappedMode();
00059   
00060   /* Initialize the SDRAM */
00061   BSP_SDRAM_Init();
00062   
00063   /* Initialize the Touch screen */
00064   BSP_TS_Init(420, 272);
00065 
00066   /* Enable CRC to Unlock GUI */
00067  __HAL_RCC_CRC_CLK_ENABLE();
00068   
00069  /* Enable Back up SRAM */
00070 __HAL_RCC_BKPSRAM_CLK_ENABLE();
00071   
00072 }
00073 
00074 /**
00075   * @brief  Read the coordinate of the point touched and assign their
00076   *         value to the variables u32_TSXCoordinate and u32_TSYCoordinate
00077   * @param  None
00078   * @retval None
00079   */
00080 void k_TouchUpdate(void)
00081 {
00082   static GUI_PID_STATE TS_State = {0, 0, 0, 0};
00083   __IO TS_StateTypeDef  ts;
00084   uint16_t xDiff, yDiff;  
00085 
00086   BSP_TS_GetState((TS_StateTypeDef *)&ts);
00087 
00088   if((ts.touchX[0] >= LCD_GetXSize()) ||(ts.touchY[0] >= LCD_GetYSize()) ) 
00089   {
00090     ts.touchX[0] = 0;
00091     ts.touchY[0] = 0;
00092     ts.touchDetected =0;
00093   }
00094 
00095   xDiff = (TS_State.x > ts.touchX[0]) ? (TS_State.x - ts.touchX[0]) : (ts.touchX[0] - TS_State.x);
00096   yDiff = (TS_State.y > ts.touchY[0]) ? (TS_State.y - ts.touchY[0]) : (ts.touchY[0] - TS_State.y);
00097   
00098   
00099   if((TS_State.Pressed != ts.touchDetected ) ||
00100      (xDiff > 30 )||
00101       (yDiff > 30))
00102   {
00103     TS_State.Pressed = ts.touchDetected;
00104     TS_State.Layer = SelLayer;
00105     if(ts.touchDetected) 
00106     {
00107       TS_State.x = ts.touchX[0];
00108       TS_State.y = ts.touchY[0];
00109       GUI_TOUCH_StoreStateEx(&TS_State);
00110     }
00111     else
00112     {
00113       GUI_TOUCH_StoreStateEx(&TS_State);
00114       TS_State.x = 0;
00115       TS_State.y = 0;
00116     }
00117   }
00118 }
00119 
00120 /**
00121   * @}
00122   */
00123 
00124 /**
00125   * @}
00126   */
00127 
00128 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/