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 21:03:03 2014 +0000
Revision:
1:bdeac50afe1a
Parent:
0:84e23a19e37d
change result type to enum

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 1:bdeac50afe1a 32 typedef enum { OK = 0 , PLL_ERR, EXT_ERR }ClockStatus;
dreschpe 1:bdeac50afe1a 33
dreschpe 0:84e23a19e37d 34 class L152_init32
dreschpe 0:84e23a19e37d 35 {
dreschpe 0:84e23a19e37d 36 public:
dreschpe 0:84e23a19e37d 37 /** Create a L152_init32 object to change the clock
dreschpe 0:84e23a19e37d 38 * @param external = 0 use internal oscillator
dreschpe 0:84e23a19e37d 39 * @param external = 1 use external 8 MHz crystal - you have to add some comonents to the pcb !
dreschpe 0:84e23a19e37d 40 */
dreschpe 0:84e23a19e37d 41 L152_init32(unsigned int external);
dreschpe 1:bdeac50afe1a 42 ClockStatus Status;
dreschpe 0:84e23a19e37d 43
dreschpe 0:84e23a19e37d 44 protected:
dreschpe 0:84e23a19e37d 45 // do the magic ;-)
dreschpe 1:bdeac50afe1a 46 ClockStatus setup_clock_32MHZ(int external);
dreschpe 0:84e23a19e37d 47 };
dreschpe 0:84e23a19e37d 48
dreschpe 0:84e23a19e37d 49 #endif
dreschpe 0:84e23a19e37d 50
dreschpe 0:84e23a19e37d 51