Subversion Repositories NaviCtrl

Rev

Rev 378 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 378 Rev 379
Line 117... Line 117...
117
//                              
117
//                              
118
//
118
//
119
// Returnvalue: none
119
// Returnvalue: none
120
//________________________________________________________________________________________________________________________________________
120
//________________________________________________________________________________________________________________________________________
Line -... Line 121...
-
 
121
 
-
 
122
void SSC_Speed(u32 speed)
-
 
123
{
-
 
124
        SSP_InitTypeDef         SSP_InitStructure;
-
 
125
 
-
 
126
    SSP_Cmd(SSP1, DISABLE);
-
 
127
        SSP_DeInit(SSP1);
-
 
128
        SSP_StructInit(&SSP_InitStructure);
-
 
129
        SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola;
-
 
130
        SSP_InitStructure.SSP_Mode = SSP_Mode_Master;
-
 
131
        SSP_InitStructure.SSP_CPHA = SSP_CPHA_1Edge;
-
 
132
        SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low;
-
 
133
        // Set Baud Rate (Prescaler)
-
 
134
        // bit rate is BRCLK/SSP_ClockPrescaler/(1+SSP_ClockRate))
-
 
135
        // With MSCLK = 48MHz = BRCLK we get for the SPICLK = 48Mhz / 20 / (1+5) = 400 kHz 
-
 
136
        SSP_InitStructure.SSP_ClockRate = 5; //5
-
 
137
        SSP_InitStructure.SSP_ClockPrescaler = (48000 / (5+1)) / speed;
-
 
138
        SSP_Init(SSP1, &SSP_InitStructure);
-
 
139
        SSP_Cmd(SSP1, ENABLE);
-
 
140
}
-
 
141
 
121
 
142
 
122
void SSC_Init(void)
143
void SSC_Init(void)
123
{
144
{
124
        GPIO_InitTypeDef        GPIO_InitStructure;
-
 
125
        SSP_InitTypeDef         SSP_InitStructure;
145
        GPIO_InitTypeDef        GPIO_InitStructure;
126
//      WIU_InitTypeDef         WIU_InitStructure;
146
//      WIU_InitTypeDef         WIU_InitStructure;
127
        // enable APB clock for SPI1
147
        // enable APB clock for SPI1
128
        SCU_APBPeriphClockConfig(__SSP1 ,ENABLE);
148
        SCU_APBPeriphClockConfig(__SSP1 ,ENABLE);
129
        // configure P5.4 -> SD-CS as an output pin
149
        // configure P5.4 -> SD-CS as an output pin
Line 149... Line 169...
149
        GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
169
        GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
150
        GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;
170
        GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;
151
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
171
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
152
        GPIO_Init (GPIO3, &GPIO_InitStructure);
172
        GPIO_Init (GPIO3, &GPIO_InitStructure);
153
        // configure SPI1
173
        // configure SPI1
154
        SSP_DeInit(SSP1);
174
    SSC_Speed(400);
155
        SSP_StructInit(&SSP_InitStructure);
-
 
156
        SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola;
-
 
157
        SSP_InitStructure.SSP_Mode = SSP_Mode_Master;
-
 
158
        SSP_InitStructure.SSP_CPHA = SSP_CPHA_1Edge;
-
 
159
        SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low;
-
 
160
        // Set Baud Rate (Prescaler)
-
 
161
        // bit rate is BRCLK/SSP_ClockPrescaler/(1+SSP_ClockRate))
-
 
162
        // With MSCLK = 48MHz/2 = BRCLK we get for the SPICLK = 24Mhz / 8 / (1+5) = 500 kHz
-
 
163
        SSP_InitStructure.SSP_ClockRate = 5; //5
-
 
164
        SSP_InitStructure.SSP_ClockPrescaler = 4; //8
-
 
165
        SSP_Init(SSP1, &SSP_InitStructure);
-
 
166
        SSC_Disable();
175
        SSC_Disable();
167
        SSP_Cmd(SSP1, ENABLE);
176
        SSP_Cmd(SSP1, ENABLE);
Line 168... Line 177...
168
 
177