/**
  ******************************************************************************
  * @file    Common/utilities.h
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    23-March-2012
  * @brief   This code has been developped for STM32F051 Discovery Kit.
*                       General purpose function prototypes and definitions.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UTILITIES_H
#define __UTILITIES_H

/* Includes ------------------------------------------------------------------*/
#include "stm32F0xx.h"
#include "core_cm0.h"

/* Exported constants --------------------------------------------------------*/
extern uint32_t G_tickValue;
extern uint32_t G_tick;


/* Exported macros -----------------------------------------------------------*/
#define GPIO_HIGH(a,b)      a->BSRR = b
#define GPIO_LOW(a,b)       a->BRR = b
#define GPIO_TOGGLE(a,b)    a->ODR ^= b


/* Exported constants --------------------------------------------------------*/

#define  PLL_MUL_X  6
#define GPIO_LED_ERROR   GPIO_Pin_11          //PC.11
#define GPIO_NRSTPD      GPIO_Pin_2           //PD.2


#define  LED_ERROR_HIGH  GPIO_LOW(GPIOC, GPIO_LED_ERROR);
#define  LED_ERROR_LOW   GPIO_HIGH(GPIOC, GPIO_LED_ERROR);


#define  NRSTPD_HIGH  GPIO_HIGH(GPIOA, GPIO_NRSTPD);
#define  NRSTPD_LOW   GPIO_LOW(GPIOA, GPIO_NRSTPD);



/* exported typedef -------------------------------------------------------------------*/
typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus;

/* function prototypes -------------------------------------------------------*/
void Init_LED(void);
void delay_ms(uint32_t n_ms);
void delay_10us(uint32_t n_10us);

extern void(*delay)(uint32_t); //Func pointer to delay_ms

#endif /* __UTILITIES_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/


