Fixed with HAL.

Fork of ST_L152_32MHZ by Peter Drescher

Not finish yet. External crystal doesn't work.

Committer:
dreschpe
Date:
Tue Mar 11 20:34:57 2014 +0000
Revision:
0:84e23a19e37d
Child:
1:bdeac50afe1a
Lib for the ST Nucleo L152RE board to switch the clock to 32MHz.; Out of the box the board is running on 16MHz.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:84e23a19e37d 1 /* mbed library for the ST NUCLEO board L152RE
dreschpe 0:84e23a19e37d 2 * to change the CPU clock to 32 MHz
dreschpe 0:84e23a19e37d 3 * A pll clock of 96 MHz is used to enable USB
dreschpe 0:84e23a19e37d 4 *
dreschpe 0:84e23a19e37d 5 * Copyright (c) 2014 Peter Drescher - DC2PD
dreschpe 0:84e23a19e37d 6 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 0:84e23a19e37d 7 *
dreschpe 0:84e23a19e37d 8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dreschpe 0:84e23a19e37d 9 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dreschpe 0:84e23a19e37d 10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dreschpe 0:84e23a19e37d 11 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dreschpe 0:84e23a19e37d 12 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dreschpe 0:84e23a19e37d 13 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
dreschpe 0:84e23a19e37d 14 * THE SOFTWARE.
dreschpe 0:84e23a19e37d 15 */
dreschpe 0:84e23a19e37d 16
dreschpe 0:84e23a19e37d 17
dreschpe 0:84e23a19e37d 18 #ifndef MBED_ST_L152_32MHZ_H
dreschpe 0:84e23a19e37d 19 #define MBED_ST_L152_32MHZ_H
dreschpe 0:84e23a19e37d 20
dreschpe 0:84e23a19e37d 21 /** Setup cpu speed to 32 MHz
dreschpe 0:84e23a19e37d 22 *
dreschpe 0:84e23a19e37d 23 * @code
dreschpe 0:84e23a19e37d 24 * #include "mbed.h"
dreschpe 0:84e23a19e37d 25 * #include "ST_L152_32MHZ.h"
dreschpe 0:84e23a19e37d 26 *
dreschpe 0:84e23a19e37d 27 * // place the init before other code to ensure right timing of other objects !
dreschpe 0:84e23a19e37d 28 * L152_init32 myinit(0); // use the internal oscillator
dreschpe 0:84e23a19e37d 29 *
dreschpe 0:84e23a19e37d 30 */
dreschpe 0:84e23a19e37d 31
dreschpe 0:84e23a19e37d 32 class L152_init32
dreschpe 0:84e23a19e37d 33 {
dreschpe 0:84e23a19e37d 34 public:
dreschpe 0:84e23a19e37d 35 /** Create a L152_init32 object to change the clock
dreschpe 0:84e23a19e37d 36 * @param external = 0 use internal oscillator
dreschpe 0:84e23a19e37d 37 * @param external = 1 use external 8 MHz crystal - you have to add some comonents to the pcb !
dreschpe 0:84e23a19e37d 38 */
dreschpe 0:84e23a19e37d 39 L152_init32(unsigned int external);
dreschpe 0:84e23a19e37d 40 int clk_err;
dreschpe 0:84e23a19e37d 41
dreschpe 0:84e23a19e37d 42 protected:
dreschpe 0:84e23a19e37d 43 // do the magic ;-)
dreschpe 0:84e23a19e37d 44 int setup_clock_32MHZ(int external);
dreschpe 0:84e23a19e37d 45 };
dreschpe 0:84e23a19e37d 46
dreschpe 0:84e23a19e37d 47 #endif
dreschpe 0:84e23a19e37d 48
dreschpe 0:84e23a19e37d 49