STM8S/A Standard Peripherals Firmware Library: main.c Source File

STM8S/A

STM8S_StdPeriph_Examples/SPI/SPI_SimplexLCD/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    SPI_SimplexLCD\main.c
00004   * @author  MCD Application Team
00005   * @version  V2.2.0
00006   * @date     30-September-2014
00007   * @brief   This file contains the main function for SPI simplex communication with LCD example.
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 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 "stm8s.h"
00030 #include "stm8s_eval.h"
00031 #include "stm8s_eval_lcd.h"
00032 
00033 /**
00034   * @addtogroup SPI_SimplexLCD
00035   * @{
00036   */
00037 
00038 /* Private typedef -----------------------------------------------------------*/
00039 
00040 /* Private define ------------------------------------------------------------*/
00041 /* Private macro -------------------------------------------------------------*/
00042 /* Private variables ---------------------------------------------------------*/
00043 /* Private function prototypes -----------------------------------------------*/
00044 void PrintLogo(void);
00045 void Delay(uint32_t nCount);
00046 /* Private functions ---------------------------------------------------------*/
00047 /* Global variables ----------------------------------------------------------*/
00048 /* Public functions ----------------------------------------------------------*/
00049 
00050 /**
00051   * @brief  Main program.
00052   * @param  None
00053   * @retval None
00054   */
00055 void main(void)
00056 {
00057   uint8_t i = 0;
00058   
00059   /* Select fCPU = 16MHz */
00060   CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
00061   
00062   /* Init the Eval board LCD */
00063   STM8S_EVAL_LCD_Init();
00064 
00065   /* Clear LCD */
00066   LCD_Clear();
00067 
00068   LCD_SetCursorPos(LCD_LINE1, 0);
00069   LCD_Print("SPI-LCD example");         
00070   
00071   /* Display "moving" ST logo */
00072   for (i = 1; i < 8; i++)
00073   {
00074     PrintLogo();
00075     Delay(0xFFFF);
00076   }
00077   
00078   LCD_SetCursorPos(LCD_LINE2, 0);
00079   LCD_Print("               ");
00080 
00081   LCD_DisplayLogo(0x93);
00082   Delay(600);
00083   while(1)
00084   {}
00085 
00086 }
00087 
00088 /**
00089   * @brief  Delay.
00090   * @param  nCount
00091   * @retval None
00092   */
00093 void Delay(uint32_t nCount)
00094 {
00095     /* Decrement nCount value */
00096     while (nCount != 0)
00097     {
00098         nCount--;
00099     }
00100 }
00101 
00102 /**
00103   * @brief  Print ST logo on the LCD
00104   * @param  None
00105   * @retval None
00106   */
00107 void PrintLogo(void)
00108 {
00109   static uint8_t logo_pos = 0x90;
00110   static int8_t logo_pos_index = 1;
00111 
00112   LCD_SetCursorPos(LCD_LINE2, 0);
00113   LCD_Print("               ");
00114 
00115   LCD_DisplayLogo(logo_pos);
00116   logo_pos += logo_pos_index;
00117   if (logo_pos > 0x95)
00118   {
00119     logo_pos -= 2;
00120     logo_pos_index = -1;
00121   }
00122   if (logo_pos < 0x90)
00123   {
00124     logo_pos += 2;
00125     logo_pos_index = 1;
00126   }
00127 }
00128 
00129 #ifdef USE_FULL_ASSERT
00130 
00131 /**
00132   * @brief  Reports the name of the source file and the source line number
00133   *   where the assert_param error has occurred.
00134   * @param file: pointer to the source file name
00135   * @param line: assert_param error line source number
00136   * @retval None
00137   */
00138 void assert_failed(uint8_t* file, uint32_t line)
00139 { 
00140   /* User can add his own implementation to report the file name and line number,
00141      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00142 
00143   /* Infinite loop */
00144   while (1)
00145   {
00146   }
00147 }
00148 #endif
00149 
00150 /**
00151   * @}
00152   */
00153 
00154 
00155 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com