Subversion Repositories NaviCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
196 killagreg 1
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
1 ingob 2
* File Name          : 91x_ahbapb.c
3
* Author             : MCD Application Team
196 killagreg 4
* Version            : V2.1
5
* Date               : 12/22/2008
6
* Description        : This file provides all the AHBAPB firmware functions.
1 ingob 7
********************************************************************************
8
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14
*******************************************************************************/
15
 
16
/* Includes ------------------------------------------------------------------*/
17
#include "91x_ahbapb.h"
18
 
19
/* Private typedef -----------------------------------------------------------*/
20
/* Private define ------------------------------------------------------------*/
21
 
22
/* Private macro -------------------------------------------------------------*/
23
/* Private variables ---------------------------------------------------------*/
24
/* Private function prototypes -----------------------------------------------*/
25
/* Private functions ---------------------------------------------------------*/
26
#define AHBAPB_SplitCounter_Mask 0xFFE0FFFF
27
#define AHBAPB_SetTimeOut_Mask   0xFFFFFFE0
28
#define AHBAPB_Address_Mask      0xFEFFFFFF
29
#define AHBAPB_FLAG_RW_Mask      0x01000000
30
/*******************************************************************************
31
* Function Name  : AHBAPB_DeInit
32
* Description    : Deinitializes the AHBAPBx peripheral registers to their default
33
*                  reset values.
34
* Input          : AHBAPBx: where x can be 0 or 1 to select the AHBAPB peripheral.
35
* Output         : None
36
* Return         : None
37
*******************************************************************************/
38
void AHBAPB_DeInit(AHBAPB_TypeDef* AHBAPBx)
39
{
40
  AHBAPBx->BCR = 0x00000000;
41
  AHBAPBx->BSR = 0x00000000;
42
}
43
/*******************************************************************************
44
* Function Name  : AHBAPB_Init
45
* Description    : Initializes the AHBAPBx peripheral according to the specified
46
*                  parameters in the AHBAPB_InitStruct .
47
* Input          :- AHBAPBx: where x can be 0 or 1 to select the AHBAPB peripheral.
48
*                 - AHBAPB_InitStruct: pointer to a AHBAPB_InitTypeDef structure that
49
*                   contains the configuration information for the specified AHBAPB
50
*                   peripheral.
51
* Output         : None
52
* Return         : None
53
*******************************************************************************/
54
void AHBAPB_Init(AHBAPB_TypeDef* AHBAPBx, AHBAPB_InitTypeDef* AHBAPB_InitStruct)
55
{
56
 
57
  if(AHBAPB_InitStruct->AHBAPB_Split == AHBAPB_Split_Enable)
58
  {
59
    /* Set SPLITEN bit;*/
60
    AHBAPBx->BCR |= AHBAPB_Split_Enable;
61
    /*Split_CNT bits[20:16]*/
62
    AHBAPBx->BCR &= AHBAPB_SplitCounter_Mask;
63
    AHBAPBx->BCR |=  (AHBAPB_InitStruct->AHBAPB_SplitCounter)<<16;
64
  }
65
  else
66
  {
67
    /*/ Clear SPLITEN bit;*/
68
    AHBAPBx->BCR &= AHBAPB_Split_Disable;
69
  }
70
  /*APB Time out*/
71
  if(AHBAPB_InitStruct->AHBAPB_Error == AHBAPB_Error_Enable)
72
  {
73
    /* Set ERREN bit*/
74
    AHBAPBx->BCR |= AHBAPB_Error_Enable;
75
    /*Time ouit counter*/
76
    AHBAPBx->BCR &= AHBAPB_SetTimeOut_Mask;
77
    AHBAPBx->BCR |= AHBAPB_InitStruct->AHBAPB_SetTimeOut;
78
  }
79
  else
80
  {
81
    /* Clear ERREN bit*/
82
    AHBAPBx->BCR &= AHBAPB_Error_Disable;
83
  }
84
}
85
 
86
/*******************************************************************************
87
* Function Name  : AHBAPB_StructInit
88
* Description    : Initialize the AHBAPB Init Structure parameters
89
* Input          : AHBAPB_InitStruct : pointer to a AHBAPB_InitTypeDef structure
90
*                  which will be initialized.
91
* Output         : None
92
* Return         : None
93
*******************************************************************************/
94
void AHBAPB_StructInit(AHBAPB_InitTypeDef* AHBAPB_InitStruct)
95
{
96
  /* Reset AHBAPB init structure parameters values */
97
  AHBAPB_InitStruct->AHBAPB_Split        = AHBAPB_Split_Enable;
98
  AHBAPB_InitStruct->AHBAPB_SplitCounter = 0xFF;
99
  AHBAPB_InitStruct->AHBAPB_Error        = AHBAPB_Error_Enable;
100
  AHBAPB_InitStruct->AHBAPB_SetTimeOut   = 0xFF;
101
 
102
}
103
 
104
/*******************************************************************************
105
* Function Name  : AHBAPB_GetFlagStatus
106
* Description    : Checks whether the specified AHBAPB flag is set or not.
107
* Input          : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral
108
*                  - AHBAPB_FLAG: specifies the flag to check.
109
*                    This parameter can be one of the following values:
110
*                      - AHBAPB_FLAG_ERROR: error flag
111
*                      - AHBAPB_FLAG_OUTM : Out of Memory flag
112
*                      - AHBAPB_FLAG_APBT : APB Time-out flag
113
*                      - AHBAPB_FLAG_RW   : Access type flag
114
* Output         : None
115
* Return         : The new state of AHBAPB_FLAG (SET or RESET).
116
*******************************************************************************/
117
FlagStatus AHBAPB_GetFlagStatus(AHBAPB_TypeDef* AHBAPBx, u8 AHBAPB_FLAG)
118
{
119
  if(AHBAPB_FLAG == AHBAPB_FLAG_RW)
120
  {
121
    if ((AHBAPBx->PAER & AHBAPB_FLAG_RW_Mask) == RESET)
122
    {
123
       return RESET;
124
    }
125
    else
126
    {
127
      return SET;
128
    }
129
  }
130
  else
131
  {
132
    if ((AHBAPBx->BSR & AHBAPB_FLAG) == RESET)
133
    {
134
      return RESET;
135
    }
136
    else
137
    {
138
     return SET;
139
    }
140
  }
141
}
142
/*******************************************************************************
143
* Function Name  : AHBAPB_ClearFlag
144
* Description    : Clears the AHBAPBx flags.
145
* Input          : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral
146
*                  - AHBAPB_FLAG: flags to clear. This parameter one of the
147
*                    following values:
148
*                      - AHBAPB_FLAG_ERROR: error flag
149
*                      - AHBAPB_FLAG_OUTM : Out of Memory flag
150
*                      - AHBAPB_FLAG_APBT : APB Time-out flag
151
* Output         : None
152
* Return         : None
153
*******************************************************************************/
154
void AHBAPB_ClearFlag(AHBAPB_TypeDef* AHBAPBx, u8 AHBAPB_FLAG)
155
{
156
  /* Clear the flag */
157
  AHBAPBx->BSR &= ~AHBAPB_FLAG;
158
}
159
/*******************************************************************************
160
* Function Name  : AHBAPB_GetPeriphAddrError
161
* Description    : Gets the AHBAPB error address peripherals.
162
* Input          : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral
163
* Output         : None
164
* Return         : The Peropheral address error
165
*******************************************************************************/
166
u32 AHBAPB_GetPeriphAddrError(AHBAPB_TypeDef* AHBAPBx)
167
{
168
  u32 AHBAPB_Address = 0x00000000;
169
 
170
  /*Return Oeripheral address without RW bit*/
171
  AHBAPB_Address = (AHBAPBx->PAER)& AHBAPB_Address_Mask;
172
  return (AHBAPB_Address);
173
}
196 killagreg 174
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/