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

STM8S/A

STM8S_StdPeriph_Examples/I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.c
00004   * @author  MCD Application Team
00005   * @version  V2.2.0
00006   * @date     30-September-2014
00007   * @brief   Main program body
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 "main.h"
00032 
00033 /** @addtogroup I2C_TwoBoards
00034   * @{
00035   */
00036 
00037 /** @addtogroup I2C_DataExchange
00038   * @{
00039   */
00040 
00041 /* Private typedef -----------------------------------------------------------*/
00042 /* Private define ------------------------------------------------------------*/
00043 /* Private macro -------------------------------------------------------------*/
00044 /* Private variables ---------------------------------------------------------*/
00045 /* Private function prototypes -----------------------------------------------*/
00046 /* Private functions ---------------------------------------------------------*/
00047 /* Public functions ----------------------------------------------------------*/
00048 
00049 /**
00050   * @brief  Main program.
00051   * @param  None
00052   * @retval None
00053   */
00054 void main(void)
00055 {
00056 
00057   /* system_clock / 1 */
00058   CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
00059   
00060   /* Initialize LEDs mounted on STM8/128-EVAL board */
00061   STM_EVAL_LEDInit(LED2);
00062                 STM_EVAL_LEDOff(LED2);
00063         
00064   I2C_DeInit();
00065   /* Initialize I2C peripheral */
00066 
00067 #ifdef I2C_slave_7Bits_Address
00068   I2C_Init(100000, SLAVE_ADDRESS, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16);           
00069 #else
00070   I2C_Init(100000, SLAVE_ADDRESS, I2C_DUTYCYCLE_2, I2C_ACK_CURR,I2C_ADDMODE_10BIT, 16);
00071 #endif
00072 
00073   /* Enable Error Interrupt*/
00074   I2C_ITConfig((I2C_IT_TypeDef)(I2C_IT_ERR | I2C_IT_EVT | I2C_IT_BUF), ENABLE);
00075 
00076   /* Enable general interrupts */
00077   enableInterrupts();
00078 
00079   /*Main Loop */
00080   while (1)
00081   {
00082     /* infinite loop */
00083   }
00084 }
00085 
00086 #ifdef  USE_FULL_ASSERT
00087 /**
00088   * @brief  Reports the name of the source file and the source line number
00089   *   where the assert_param error has occurred.
00090   * @param  file: pointer to the source file name
00091   * @param  line: assert_param error line source number
00092   * @retval None
00093   */
00094 void assert_failed(uint8_t* file, uint32_t line)
00095 {
00096   /* User can add his own implementation to report the file name and line number,
00097      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00098 
00099   /* Infinite loop */
00100   while (1)
00101   {}
00102 }
00103 #endif
00104 
00105 /**
00106   * @}
00107   */
00108 
00109 /**
00110   * @}
00111   */
00112 
00113 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

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